query
stringlengths 7
9.55k
| document
stringlengths 10
363k
| metadata
dict | negatives
listlengths 0
101
| negative_scores
listlengths 0
101
| document_score
stringlengths 3
10
| document_rank
stringclasses 102
values |
|---|---|---|---|---|---|---|
DELETE /prioridades/1 DELETE /prioridades/1.json
|
def destroy
@prioridade = Prioridade.find(params[:id])
@prioridade.destroy
respond_to do |format|
format.html { redirect_to prioridades_url }
format.json { head :no_content }
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def destroy\n @prioridad.destroy\n respond_to do |format|\n format.html { redirect_to prioridads_url, notice: 'Se ha eliminado la Prioridad.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @prioridade_adocao = PrioridadeAdocao.find(params[:id])\n @prioridade_adocao.destroy\n\n respond_to do |format|\n format.html { redirect_to prioridade_adocoes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @prepagada = Prepagada.find(params[:id])\n @prepagada.destroy\n\n respond_to do |format|\n format.html { redirect_to prepagadas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @pre_contrato.destroy\n respond_to do |format|\n format.html { redirect_to pre_contratos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @prueba_json.destroy\n respond_to do |format|\n format.html { redirect_to prueba_jsons_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @asignatura.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n @unidad.destroy\n respond_to do |format|\n format.html { redirect_to unidades_url }\n format.json { head :no_content }\n end\n end",
"def delete\n client.delete(\"/#{id}\")\n end",
"def destroy\n @prior = Prior.find(params[:id])\n @prior.pfts.destroy\n @prior.destroy\n\n respond_to do |format|\n format.html { redirect_to(priors_url) }\n format.xml { head :ok }\n format.csv { head :ok }\n format.json { head :ok }\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(path)\n RestClient.delete request_base+path\n end",
"def destroy\n #@clinica.destroy\n @clinica.update(:status => 0)\n respond_to do |format|\n format.html { redirect_to clinicas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @humanidades1 = Humanidades1.find(params[:id])\n @humanidades1.destroy\n\n respond_to do |format|\n format.html { redirect_to humanidades1s_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @premio = Premio.find(params[:id])\n @premio.destroy\n\n respond_to do |format|\n format.html { redirect_to premios_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @premio = Premio.find(params[:id])\n @premio.destroy\n\n respond_to do |format|\n format.html { redirect_to premios_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @prestacion = Prestacion.find(params[:id])\n @prestacion.destroy\n\n respond_to do |format|\n format.html { redirect_to prestacions_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @gran_unidad.destroy\n respond_to do |format|\n format.html { redirect_to gran_unidad_index_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @predio.destroy\n respond_to do |format|\n format.html { redirect_to predios_url, notice: 'Predio foi deletado com sucesso.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tipo_contrato = TipoContrato.find(params[:id])\n @tipo_contrato.destroy\n\n respond_to do |format|\n format.html { redirect_to tipo_contratos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @sugerencia = Sugerencia.find(params[:id])\n @sugerencia.destroy\n\n respond_to do |format|\n format.html { redirect_to sugerencias_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @requerimiento = Requerimiento.find(params[:id])\n @requerimiento.destroy\n\n respond_to do |format|\n format.html { redirect_to requerimientos_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @tipo_unidad.destroy\n respond_to do |format|\n format.html { redirect_to tipo_unidades_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @preceed = Preceed.find(params[:id])\n @preceed.destroy\n\n respond_to do |format|\n format.html { redirect_to preceeds_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @prestador = Prestador.find(params[:id])\n @prestador.destroy\n\n respond_to do |format|\n format.html { redirect_to prestadores_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @antecedente = Antecedente.find(params[:id])\n @antecedente.destroy\n\n respond_to do |format|\n format.html { redirect_to antecedentes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @trpriority.destroy\n respond_to do |format|\n format.html { redirect_to trpriorities_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n bef_delete = Before::Delete.new\n respond_to do |format|\n if bef_delete.child_of_relation(@cliente, :lotes)\n format.json { render json: \"Algunos lotes dependen de este cliente. No se puede eliminar.\", status: :conflict }\n else\n @cliente.destroy\n format.json { render json: {message: \"Cliente eliminado con éxito\"} }\n end\n end\n end",
"def destroy\n @pre_step = PreStep.find(params[:id])\n @pre_step.destroy\n\n respond_to do |format|\n format.html { redirect_to pre_steps_url }\n format.json { head :ok }\n end\n end",
"def delete\n render json: Post.delete(params[\"id\"])\n end",
"def destroy\n @reqpriority.destroy\n respond_to do |format|\n format.html { redirect_to reqpriorities_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @relatestagiario = Relatestagiario.find(params[:id])\n @relatestagiario.destroy\n\n respond_to do |format|\n format.html { redirect_to(relatestagiarios_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @recurso = Recurso.find(params[:id])\n @recurso.destroy\n\n respond_to do |format|\n format.html { redirect_to recursos_url }\n format.json { head :no_content }\n end\n end",
"def delete\n render :json => @fiestas.delete_at(params[:id].to_i)\n end",
"def destroy\n redirect_to_path = topico_perguntas_path(@pergunta.topico)\n @pergunta.destroy\n respond_to do |format|\n format.html { redirect_to set_path, notice: \"Pergunta deletada com sucesso.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @respuesta = Respuesta.find(params[:id])\n @respuesta.destroy\n\n respond_to do |format|\n format.html { redirect_to respuestas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @respuesta = Respuesta.find(params[:id])\n @respuesta.destroy\n\n head :no_content\n end",
"def delete\n render json: Company.delete(params[\"id\"])\n end",
"def destroy\n relationship = Relationships.find(params[:id])\n relationship.destroy\n head 204\n end",
"def destroy\n @cliente = Cliente.find(params[:cliente_id])\n @pago = @cliente.pagos.find(params[:id])\n @pago.destroy\n\n respond_to do |format|\n format.html { redirect_to [@cliente, @pago] }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tipo_pregunta = TipoPregunta.find(params[:id])\n @tipo_pregunta.destroy\n\n head :no_content\n end",
"def destroy\n @datos_insumos_reactivo.destroy\n respond_to do |format|\n format.html { redirect_to datos_insumos_reactivos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @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 #--ADICIONADO\n @cliente.perfilclientes.destroy\n #--ADICIONADO\n @cliente.destroy\n respond_to do |format|\n format.html { redirect_to clientes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @servico_pacote.destroy\n respond_to do |format|\n format.html { redirect_to servico_pacotes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @diciplina = Diciplina.find(params[:id])\n @diciplina.destroy\n\n respond_to do |format|\n format.html { redirect_to diciplinas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @trabalho = Trabalho.find(params[:id])\n @trabalho.destroy\n\n respond_to do |format|\n format.html { redirect_to trabalhos_url }\n format.json { head :no_content }\n end\n end",
"def borrar \n\n fiesta.destroy\n render json: fiesta \n end",
"def destroy\n @asignatura = Asignatura.find(params[:id])\n @asignatura.destroy\n\n respond_to do |format|\n format.html { redirect_to asignaturas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @asignatura = Asignatura.find(params[:id])\n @asignatura.destroy\n\n respond_to do |format|\n format.html { redirect_to asignaturas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @pagamento = Pagamento.find(params[:id])\n os = @pagamento.os\n @pagamento.destroy\n\n respond_to do |format|\n #format.html { redirect_to pagamentos_url }\n format.html { redirect_to os }\n format.json { head :no_content }\n end\n end",
"def destroy\n @persona = Persona.find(params[:id])\n @persona.destroy\n\n respond_to do |format|\n format.json { head :ok }\n end\n \n end",
"def destroy\n @agronomiaquimica = Agronomiaquimica.find(params[:id])\n @agronomiaquimica.destroy\n\n respond_to do |format|\n format.html { redirect_to agronomiaquimicas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @pregoestitulo.destroy\n respond_to do |format|\n format.html { redirect_to pregoestitulos_url, notice: 'Título excluído com sucesso.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tipo_distribucion.destroy\n respond_to do |format|\n format.html { redirect_to tipos_distribuciones_url }\n format.json { head :no_content }\n end\n end",
"def delete path\n make_request(path, \"delete\", {})\n end",
"def delete_aos_version(args = {}) \n delete(\"/aosversions.json/#{args[:aosVersionId]}\", args)\nend",
"def delete\n unless possui_acesso?()\n return\n end\n @aviso = Aviso.find(params[:id])\n @aviso.destroy\n\n respond_to do |format|\n format.html { redirect_to avisos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @dependencia = Dependencia.find(params[:id])\n begin\n @dependencia.destroy\n rescue ActiveRecord::DeleteRestrictionError => e\n flash[:error]=\"No se pudo eliminar porque otros dependen de el\\n(#{e})\"\n end\n respond_to do |format|\n format.html { redirect_to dependencias_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @reconocimiento = Reconocimiento.find(params[:id])\n @reconocimiento.destroy\n\n respond_to do |format|\n format.html { redirect_to reconocimientos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @pre = Pre.find(params[:id])\n @pre.destroy\n\n respond_to do |format|\n format.html { redirect_to pres_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @competency_pertenece_asignatura = CompetencyPerteneceAsignatura.find(params[:id])\n @competency_pertenece_asignatura.destroy\n\n respond_to do |format|\n format.html { redirect_to competency_pertenece_asignaturas_url }\n format.json { head :no_content }\n end\n end",
"def delete_from_entzumena\n headline = Headline.where({:source_item_type => params[:source_item_type], :source_item_id => params[:source_item_id]}).first\n if headline.destroy\n render :json => true, :status => 200\n else\n render :json => false, :status => :error\n end\n end",
"def destroy\n @visitante.destroy\n respond_to do |format|\n format.html { redirect_to visitantes_url, notice: 'Visitante was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete\n supprimer = QuestionOuverteService.instance.supprimerQuestion(params[:id])\n (supprimer) ? (render json: true, status: :ok) : (render json: false, status: :not_found)\n end",
"def destroy\n @atividades_extra.destroy\n respond_to do |format|\n format.html { redirect_to atividades_extras_url, notice: 'Atividades extra was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @pagamento = Pagamento.find(params[:id])\n @pagamento.destroy\n\n respond_to do |format|\n format.html { redirect_to pagamentos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @solicitudrecurso = Solicitudrecurso.find(params[:id])\n @tramos=Peticion.where(\"solicitudrecurso_id = ?\",@solicitudrecurso.id).to_a # busco todos los tramos que tenian el id\n @tramos.each {|tramo| tramo.destroy} # los elimino en cascada\n @solicitudrecurso.destroy\n \n respond_to do |format|\n format.html { redirect_to(solicitudrecursos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @premio = Premio.find(params[:id])\n @premio.destroy\n\n respond_to do |format|\n format.html { redirect_to(premios_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @presenza = Presenza.find(params[:id])\n @presenza.destroy\n\n respond_to do |format|\n format.html { redirect_to presenze_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @puntaje = Puntaje.find(params[:id])\n @puntaje.destroy\n\n respond_to do |format|\n format.html { redirect_to puntajes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @asiento = Asiento.find(params[:id])\n @asiento.destroy\n\n respond_to do |format|\n format.html { redirect_to asientos_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @fulcliente = Fulcliente.find(params[:id])\n @fulcliente.destroy\n\n respond_to do |format|\n format.html { redirect_to fulclientes_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @personal_rubro.destroy\n respond_to do |format|\n format.html { redirect_to personal_rubros_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @unidad = Unidad.find(params[:id])\n @unidad.destroy\n\n respond_to do |format|\n format.html { redirect_to(unidades_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @core_tipo_unidade = Core::TipoUnidade.find(params[:id])\n @core_tipo_unidade.destroy\n\n respond_to do |format|\n format.html { redirect_to core_tipo_unidades_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tipo_trabajador.destroy\n respond_to do |format|\n format.html { redirect_to tipo_trabajadors_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @objeto.destroy\n respond_to do |format|\n format.html { redirect_to referencia_bases_url, notice: \"Referencia base was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @trabajo.destroy\n respond_to do |format|\n format.html { redirect_to cliente_url(@cliente), notice: 'Trabajo was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tipo_compra.destroy\n respond_to do |format|\n format.html { redirect_to tipo_compras_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @requisition.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 @indicativo = Indicativo.find(params[:id])\n @indicativo.destroy\n\n respond_to do |format|\n format.html { redirect_to indicativos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @repuestum = Repuestum.find(params[:id])\n @repuestum.destroy\n\n respond_to do |format|\n format.html { redirect_to repuesta_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @resa.destroy\n respond_to do |format|\n format.html { redirect_to resas_url }\n format.json { head :no_content }\n end\n end",
"def delete\n request(:delete)\n end",
"def delete\n Iterable.request(conf, base_path).delete\n end",
"def destroy\n @atracao = Atracao.find(params[:id])\n @atracao.destroy\n\n respond_to do |format|\n format.html { redirect_to atracaos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @dato = Dato.find(params[:id])\n @dato.destroy\n\n respond_to do |format|\n format.html { redirect_to datos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @seguro = Seguro.find(params[:id])\n @seguro.destroy\n\n respond_to do |format|\n format.html { redirect_to seguros_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @pagenate = Pagenate.find(params[:id])\n @pagenate.destroy\n\n respond_to do |format|\n format.html { redirect_to pagenates_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @cliente.destroy\n respond_to do |format|\n format.html { redirect_to clientes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @retroalimentacion = Retroalimentacion.find(params[:id])\n @retroalimentacion.destroy\n\n respond_to do |format|\n format.html { redirect_to retroalimentacions_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @datosgenerale.destroy\n respond_to do |format|\n format.html { redirect_to datosgenerales_url }\n format.json { head :no_content }\n end\n end",
"def delete_tenant_circle(args = {}) \n delete(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def destroy\n @solicitudrecurso = Solicitudrecurso.find(params[:id])\n @solicitudrecurso.destroy\n @tramos=Peticion.find_all_by_solicitudrecurso_id(@solicitudrecurso.id) # busco todos los tramos que tenian el id\n @tramos.each {|tramo| tramo.destroy} # los elimino en cascada\n\n respond_to do |format|\n format.html { redirect_to(solicitudrecursos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @pagamento = Pagamento.find(params[:id])\n @pagamento.destroy\n\n respond_to do |format|\n format.html { redirect_to @pagamento.serata }\n format.json { head :no_content }\n end\n end",
"def destroy\n @objeto.destroy\n respond_to do |format|\n format.html { redirect_to tipo_referencia_bases_url, notice: \"Tipo referencia base was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @preguntum = Preguntum.find(params[:id])\n @preguntum.destroy\n\n respond_to do |format|\n format.html { redirect_to pregunta_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @status_ativ = StatusAtiv.find(params[:id])\n @status_ativ.destroy\n\n respond_to do |format|\n format.html { redirect_to status_ativs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tipoveiculo.destroy\n respond_to do |format|\n format.html { redirect_to tipoveiculos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @relatory.destroy\n respond_to do |format|\n format.html { redirect_to relatories_url, notice: 'Relatório deletado.' }\n format.json { head :no_content }\n end\n end"
] |
[
"0.7238399",
"0.7114864",
"0.6559257",
"0.6489752",
"0.64694107",
"0.63929635",
"0.6392403",
"0.63845396",
"0.6342004",
"0.63398266",
"0.63263386",
"0.63185185",
"0.63168615",
"0.6315532",
"0.6315532",
"0.6311681",
"0.63079846",
"0.63011056",
"0.63003945",
"0.62871087",
"0.62789166",
"0.6278616",
"0.62714845",
"0.6269772",
"0.6263197",
"0.6261965",
"0.6261309",
"0.62513137",
"0.6240152",
"0.62343556",
"0.6231468",
"0.6217589",
"0.6215074",
"0.62139827",
"0.6211975",
"0.62117094",
"0.6210721",
"0.62024254",
"0.6191782",
"0.6187237",
"0.61835194",
"0.61782014",
"0.6178122",
"0.6177737",
"0.61770636",
"0.61639845",
"0.6159653",
"0.6159445",
"0.6159445",
"0.6159423",
"0.6155501",
"0.6154113",
"0.6153454",
"0.61515445",
"0.6148125",
"0.61360365",
"0.61354935",
"0.6134681",
"0.613288",
"0.6130711",
"0.61284834",
"0.6123198",
"0.611872",
"0.61142695",
"0.61112356",
"0.61106205",
"0.6109756",
"0.61080533",
"0.6106568",
"0.61040264",
"0.6103723",
"0.6102602",
"0.6099165",
"0.6095542",
"0.60939866",
"0.6093569",
"0.60923296",
"0.60918677",
"0.60865736",
"0.6084497",
"0.608194",
"0.60796326",
"0.60784835",
"0.6076024",
"0.6074858",
"0.6072936",
"0.60712796",
"0.60700303",
"0.606499",
"0.6064424",
"0.6064332",
"0.6064099",
"0.6059102",
"0.6058911",
"0.6058168",
"0.60575956",
"0.605601",
"0.6054355",
"0.6053819",
"0.60524213"
] |
0.7494435
|
0
|
Returns a hash with selected header fields.
|
def options
{
version: @version,
delim: @delim,
randomized: @flags[0],
ordered: @flags[1],
rotated: @flags[2],
comments: @flags[3]
}
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def header_fields\n header.fields\n end",
"def headers\n fields.map(&:name).map(&:to_sym)\n end",
"def headers\n h = {}\n raw.headers_hash.each {|k,v| h[k] = v }\n h\n end",
"def getHeaderFieldNames\n\t\tend",
"def to_hash\n @headers\n end",
"def headers\n @headers ||= begin\n mail = Mail.new(self.raw_headers)\n mail.header.fields.each_with_object({}) do |field, hash|\n hash[field.name.downcase] ||= []\n hash[field.name.downcase] << field.decoded\n end\n end\n end",
"def header_fields\n @csv.headers\n end",
"def search_header\n header = {}\n header[:start_record] = start_record\n header[:requested_records] = requested_records\n header[:retrieved_records] = retrieved_records\n header[:total_records] = total_record_count\n header\n end",
"def headers(hash = {})\n hash.each_pair do |k,v|\n header[k] = v\n end\n end",
"def get_headers\n headers = []\n @data.each do |druid, column_hash|\n headers << column_hash.keys\n end\n headers_out = headers.flatten.uniq\n end",
"def header_fields\n IO.binread(@path, HEADER_SIZE, 0).unpack(\"N5C1\")\n end",
"def header_to_hash data\n header = {}\n data = data.split(@opts[:delimiter])\n self.req[\"Verb\"], self.req[\"Url\"], self.req[\"Version\"] = data.shift.split(\" \", 3)\n data.each do |line|\n k,v = line.split(\":\", 2)\n if !@opts[:header_bl] || !(HEADER_BLACKLIST.include? k)\n header[k] = v.lstrip\n end\n end\n header\n end",
"def headers_hash\n @headers_hash ||= Hash[@http_headers.split(\"\\x00\").map{|x| x.split(': ',2)}]\n end",
"def save_header\n return if gml_header.blank?\n attrs = gml_header.select { |k,v| self.send(\"#{k}=\", v) if self.respond_to?(k) && !v.blank?; [k,v] }.to_hash\n # puts \"Tag.save_header: #{attrs.inspect}\"\n return attrs\n end",
"def fields_hash\n each_pair.to_h\n end",
"def headers(hash = {})\n hash.each_pair do |k,v|\n @header[k] = v\n end\n end",
"def get_headers_\n hin = ATS::Headers_in.new\n hin.all.reduce({}) do |memo, pair| \n memo[pair.first.downcase] = pair[1]; memo\n end\n end",
"def headers\n @attributes + @includes.values.flatten\n end",
"def headers\n @headers ||= begin\n @mail.header.fields.inject({}) do |memo, field|\n name = field.name.downcase.to_s\n next memo if self.class.skipped_headers.include?(name)\n\n header = unquoted_header(name)\n memo.update(name => self.class.unescape(header))\n end\n end\n end",
"def gml_header\n # Rails.logger.debug \"Tag #{id}: gml_header\"\n # doc = self.class.read_gml_header(self.gml)\n doc = gml_document\n\n if doc.nil? || (doc/'header').nil?\n Rails.logger.error \"Tag#gml_header: NIL OR NO HEADER DOC\"\n return {}\n end\n\n attrs = {}\n attrs[:filename] = (doc/'header'/'filename')[0].text rescue nil\n\n # whitelist approach -- explicitly name things\n client = (doc/'header'/'client')[0] rescue nil\n attrs[:gml_application] = (client/'name').text rescue nil\n attrs[:gml_username] = (client/'username').text rescue nil\n attrs[:gml_keywords] = (client/'keywords').text rescue nil\n attrs[:gml_uniquekey] = (client/'uniqueKey').text rescue nil\n\n # Non-gml_ prefixed fields...\n attrs[:location] = (client/'location').text rescue nil # this could also be in <drawing>\n\n # encode the uniquekey with SHA-1 immediately\n # FIXME this slows this method down significantly -- denormalize whole hash to the model on save...?\n attrs[:gml_uniquekey_hash] = self.class.hash_uniquekey(attrs[:gml_uniquekey]) unless attrs[:gml_uniquekey].blank?\n\n return attrs\n end",
"def headers\n {}\n end",
"def headers\n {}\n end",
"def headers\n {}\n end",
"def header_array\n hash = get_headers \n arr = []\n hash.each do |k, v|\n\tv.each do |i|\n\tarr << k + \"=\" + i\n\tend\nend\n arr\nend",
"def extract_parts_hash\n parts_hash = {}\n\n @header_string.sub!(/\\ARange:\\s*/, '')\n\n range_spec_string, params_strings = split_header_string(@header_string)\n\n parts_hash.merge! extract_range_spec_hash(range_spec_string)\n parts_hash.merge! extract_params_hash(params_strings)\n\n return parts_hash\n end",
"def headers\n # units and source have to go last, so if we push in a new header, these go\n # at end\n @headers+['units','source']\n end",
"def header(buf)\n peek = buf.readbyte(0)\n\n header = {}\n header[:type], type = HEADREP.select do |t, desc|\n mask = (peek >> desc[:prefix]) << desc[:prefix]\n mask == desc[:pattern]\n end.first\n\n header[:name] = integer(buf, type[:prefix])\n if header[:type] != :indexed\n header[:name] -= 1\n\n if header[:name] == -1\n header[:name] = string(buf)\n end\n\n if header[:type] == :substitution\n header[:index] = integer(buf, 0)\n end\n\n header[:value] = string(buf)\n end\n\n header\n end",
"def get_headers\nheader_values = {}\n i = 1\n # while !params[:header][:type_.to_s + \"#{i}\"].nil?\n while !params[:header_values_.to_s + \"#{i}\"].nil?\n\t value = params[:header_values_.to_s + \"#{i}\"].map!{|i| CGI::unescape(i).gsub(\"\\\"\", \"'\")}\n \theader_values[params[:header][:type_.to_s + \"#{i}\"]] = value\n i += 1\n end\n header_values\nend",
"def headers; return {}; end",
"def headers; return {}; end",
"def arrange_representative_header header\n head={\"FIRST NAME\" => \"first_name\",\n \"LAST NAME\" => \"last_name\",\n \"EMAIL\" => \"email\",\n \"UIN\" => \"uin\",\n \"FULL ACADEMIC UNIT NAME\" => \"academic_unit_name\",\n \"COLLEGE\" => \"college\"\n }\n arranged_header=[]\n header.each do |k|\n arranged_header.push head[k]\n end\n return arranged_header\n end",
"def to_headers\n headers = {}\n h = data.merge(@deleted_hash)\n h.each_pair do |k,v|\n key = to_header_key(k,v)\n headers[key] = v || DUMMY_VALUE\n end\n\n headers\n end",
"def headers\n columns.map(&:header)\n end",
"def headers_with_selection selected_sort, except: [], headers: nil\n headers ||= self.headers\n all_headers = []\n if selected_sort.keys.length > 0\n all_headers = headers.each do |header|\n if header[:field] == selected_sort['field']\n header[:sorted_by] = selected_sort['direction']\n else\n header[:sorted_by] = nil\n end.deep_dup\n end\n else\n all_headers = headers.deep_dup\n end\n return all_headers.select{ |header| !except.include?(header[:field]) }\n end",
"def headers\n @headers ||= message.header_fields\n end",
"def headers(binary: false)\n @headers ||= {}\n @headers[\"x-optidash-binary\"] = 1 if binary\n @headers\n end",
"def fields\r\n @hash.keys\r\n end",
"def headers=(hash); end",
"def headers=(hash); end",
"def hash\n [id, name, margin_left, margin_right, margin_top, margin_bottom, logo_visible_flag, header_logo_position, remit_to_visibile_flag, header_address_position, header_title_visibile_flag, header_title_caption, header_title_position, header_title_font, header_terms_visible_flag, header_terms_caption, header_due_date_visible_flag, header_due_date_caption, header_po_number_visible_flag, header_po_number_caption, header_reference_visible_flag, header_reference_caption, header_account_visible_flag, header_account_caption, header_tax_id_visible_flag, header_tax_id_caption, header_ship_to_visible_flag, header_ship_to_caption, service_header_ticket_number_visible_flag, serivce_header_ticket_number_caption, service_header_company_name_visible_flag, service_header_company_name_caption, service_header_summary_visible_flag, service_header_summary_caption, service_header_contact_name_visible_flag, service_header_contact_name_caption, service_header_detail_description_visible_flag, service_header_detail_description_caption, service_header_resolution_visible_flag, service_header_resolution_caption, service_header_amount_visible_flag, service_header_amount_caption, service_header_billing_method_visible_flag, service_header_billing_method_caption, service_header_closed_tasks_visible_flag, service_header_open_tasks_visible_flag, service_header_bundled_tickets_visible_flag, project_header_project_name_visible_flag, project_header_project_name_caption, project_header_company_name_visible_flag, project_header_company_name_caption, project_header_original_downpayment_visible_flag, project_header_original_downpayment_caption, project_header_contact_name_visible_flag, project_header_contact_name_caption, project_header_amount_visible_flag, project_header_amount_caption, project_header_billing_method_visible_flag, project_header_billing_method_caption, project_header_billing_type_visible_flag, project_header_billing_type_caption, _info].hash\n end",
"def headers(_context)\n {}\n end",
"def header(buf)\n peek = buf.getbyte\n buf.seek(-1, IO::SEEK_CUR)\n\n header = {}\n header[:type], type = HEADREP.select do |t, desc|\n mask = (peek >> desc[:prefix]) << desc[:prefix]\n mask == desc[:pattern]\n end.first\n\n header[:name] = integer(buf, type[:prefix])\n if header[:type] != :indexed\n header[:name] -= 1\n\n if header[:name] == -1\n header[:name] = string(buf)\n end\n\n if header[:type] == :substitution\n header[:index] = integer(buf, 0)\n end\n\n header[:value] = string(buf)\n end\n\n header\n end",
"def headerlist; return ['X-MXL-NoteHash', 'X-MXL-Hash', 'X-MX-Bounce']; end",
"def to_hash\n @fields\n end",
"def postmark_headers\n array = []\n header_fields.each do |field|\n key = field.name.downcase\n # @see https://github.com/wildbit/postmark-gem/blob/master/lib/postmark/message_extensions/mail.rb#L74\n # @see https://github.com/wildbit/postmark-gem/pull/36#issuecomment-22298955\n unless %w(from to cc bcc reply-to subject tag content-type date).include?(key) || (Array === field.value && field.value.size > 1)\n array << {'Name' => field.name, 'Value' => field.value}\n end\n end\n array\n end",
"def header\n new_header = GElf::SectionHeader.new\n\n GElf.gelf_getshdr(self,new_header)\n return new_header\n end",
"def get\n @keys.each do |key|\n short_name = key.split('.').last\n @header << (@header.include?(short_name) ? key : short_name)\n end\n @header.join(',') + \"\\n\"\n end",
"def print_item_header\n return keys\n end",
"def get_request_header(hid = false)\n header = Hash.new\n\n case get_carrier()\n when CARRIER_KDDI\n header['X-UP-SUBNO'] = self[:uid]\n when CARRIER_SOFTBANK\n header['X-JPHONE-UID'] = self[:uid]\n end if has_key?(:uid)\n\n header['User-Agent'] = get_useragent(hid)\n\n @props[:exheader].split(\"\\r\\n\").each do |field|\n key,value = field.split(':')\n unless key.nil? || value.nil?\n header[key.strip] = value.strip\n end\n end\n\n header\n end",
"def headers\n @headers ||= {}\n end",
"def parse_header(raw)\n header = {}\n field = nil\n\n raw.each_line do |line|\n case line\n when /^([A-Za-z0-9!\\#$%&'*+\\-.^_`|~]+):\\s*(.*?)\\s*\\z/om\n field, value = $1, $2\n header[field] = value\n when /^\\s+(.*?)\\s*\\z/om\n value = $1\n fail \"bad header '#{line}'.\" unless field\n\n header[field][-1] << ' ' << value\n else\n fail \"bad header '#{line}'.\"\n end\n end\n\n header.each do |key, value|\n value.strip!\n value.gsub!(/\\s+/, ' ')\n end\n\n header\n end",
"def header(hash = {})\n @headers.merge!(hash)\n end",
"def headers\n @headers ||= {}\n end",
"def collection_hash\n collection_field_pairs = collection_fields.map do |field|\n [ normalize_header(field.header), field.value ]\n end\n Hash[ collection_field_pairs ]\n end",
"def to_hsh\n {name => {:columns => columns, :unqiue => unique}}\n end",
"def get_ordered_headers\n headers = get_headers\n template_headers = get_template_headers\n ordered_headers = ['druid', 'sourceId']\n # Select only headers with values somewhere in the data\n template_headers.each {|th| ordered_headers << th if headers.include?(th)}\n ordered_headers\n end",
"def getHeader() @header1 end",
"def extract_header_data(response)\n header_type = get_full_type_signature(:SoapResponseHeader)\n headers = response.header[:response_header].dup\n process_attributes(headers, false)\n result = headers.inject({}) do |result, (key, v)|\n normalize_output_field(headers, header_type[:fields], key)\n result[key] = headers[key]\n result\n end\n return result\n end",
"def request_headers\n {}\n end",
"def headers_with_indexes\n @headers_with_indexes ||= headers.each_with_index.to_h\n end",
"def to_h\n array = []\n array << @header.to_h if @header\n @entries.each do |entry|\n array << entry.to_h\n end\n array\n end",
"def row_hash(row)\n Hash[raw_headers.zip(row)].with_indifferent_access\n end",
"def precomputed_header_keys_for_rack\n @precomputed_header_keys_for_rack ||= begin\n @headers.attributes.keys.each_with_object(Hash.new) do |key,hash|\n name = key.to_s\n name = \"HTTP_#{name.gsub('-','_').upcase}\" unless ( name == \"CONTENT_TYPE\" || name == \"CONTENT_LENGTH\" )\n hash[name] = key\n end\n end\n end",
"def headers\r\n # give access to helpers to opts with a different name\r\n @opts\r\n end",
"def info_hash\n @fields\n end",
"def hashed_fields_for_export\n hash = {}\n\n self.ordered_questions.map { |q| hash[q.answer_field] = q.text }\n\n hash.merge!({\n location_code: \"Location Code\",\n user_agent: \"User Agent\",\n page: \"Page\",\n referer: \"Referrer\",\n created_at: \"Created At\"\n })\n\n if self.organization.enable_ip_address?\n hash.merge!({\n ip_address: \"IP Address\"\n })\n end\n\n hash\n end",
"def get_header_section(dns_query)\n header_section = {}\n HEADER_FIELD_INDEX.each do |header, index|\n header_section[header] = dns_query[index[0], index[1]].unpack(\"n\")[0]\n end\n return header_section\n end",
"def header(prev_header)\n Bitcoin.double_sha256(filter_hash.htb + prev_header.htb).bth\n end",
"def index_headers\n index_fields.map { |field| field.label }\n end",
"def fields\n @fields = headers.map.with_index do |header, index|\n Field.new(header, row_data[index])\n end\n end",
"def headers\n @headers.reject {|k, v| k == :body }.map do |k, v|\n translate_header_name(k) + ': ' + v + \"\\n\"\n end.join\n end",
"def header article\r\n\t\tarticle.attributes.keys.join(', ')\r\n\tend",
"def hash\n [format, display_header, display_from_email_address, display_email_address, display_to_email_address, display_cc_email_address, display_bcc_email_address, time_zone_offset, convert_attachments, field_labels, preserve_original_date].hash\n end",
"def columns\n @header.to_a\n end",
"def headers\n schema.headers\n end",
"def headers\n schema.headers\n end",
"def headers\n schema.headers\n end",
"def headers\n schema.headers\n end",
"def headers\n @headers ||={}\n end",
"def fields; h.fields; end",
"def headers\n @attributes[:headers]\n end",
"def headers\n matching_masks = self.hr_config.matching_masks_for_url(self.url)\n matching_masks.inject({}) do |hash, mask|\n hash.merge(self.hr_config.get(mask, 'headers') || {})\n end\n end",
"def headers\n %w[YAML_KEY VALUE MISSING UNCHANGED]\n end",
"def hash\n [sort_key, type, tooltip, label, field, sort_ascending, drilldown_id, hidden, navigation, column_identifier, render_configuration].hash\n end",
"def find_header(header)\n {}.tap do |returning|\n contents.scan(header_with_content_regexp(header)).flatten.first.split(\"\\n\").each do |setting|\n name, value = *setting.split('=').map(&:strip)\n returning[name] = value\n end\n end\n end",
"def build_header_output\n output = []\n\n @header.each do |line|\n _data = []\n line.each do |h|\n _data << {:value => h, :color => @style[:header]}\n end\n output << _data\n end\n output\n end",
"def formulate_headers(auth_header)\n {\n 'Content-Type' => 'application/json',\n 'Authorization' => auth_header,\n 'Content-Encoding' => 'gzip',\n 'Accept' => 'application/json'\n }\n end",
"def getHeader()\n header = \"\"\n\n appendStr(header, \"time\")\n appendStr(header, \"seqno\")\n $cmd_list.each do | name, cmd, type |\n appendStr(header, name)\n end\n return header\nend",
"def tuple_keys\n header.tuple_keys\n end",
"def meta\n @meta ||= begin\n arr = @header_str.split(/\\r?\\n/)\n arr.shift\n arr.inject({}) do |hash, hdr|\n key, val = hdr.split(/:\\s+/, 2)\n hash[key.downcase] = val\n hash\n end\n end\n end",
"def headers\n if !block_given?\n return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:headers, []).call(),::Vertx::MultiMap)\n end\n raise ArgumentError, \"Invalid arguments when calling headers()\"\n end",
"def fields\n to_h.keys\n .reject{|key| key.start_with?('_sm_')}\n .map{|key| key.to_sym}\n .to_set\n end",
"def get_header(body_bytesize_length)\r\n # We would like each request to be sent with the current time\r\n date = rfc1123date()\r\n\r\n return {\r\n 'Content-Type' => 'application/json',\r\n 'Authorization' => signature(date, body_bytesize_length),\r\n 'Log-Type' => @logstashLoganalyticsConfiguration.custom_log_table_name,\r\n 'x-ms-date' => date,\r\n 'time-generated-field' => @logstashLoganalyticsConfiguration.time_generated_field,\r\n 'x-ms-AzureResourceId' => @logstashLoganalyticsConfiguration.azure_resource_id\r\n }\r\n end",
"def header_build\n header = \"customer name\" + @delimiter + \"gender\" + @delimiter\n header += \"age\" + @delimiter + \"birthday\" + @delimiter + \"cpf\" + @delimiter + \"id\" + @delimiter\n header += \"state\" + @delimiter + \"city\" + @delimiter + \"street\" + @delimiter + \"zip_code\" + @delimiter\n header += \"company name\" + @delimiter + \"industry\" + @delimiter + \"cnpj\"\n header\nend",
"def build_headers(headers)\n headers.select do |key, value|\n !(key.to_s =~ /cookie/i)\n end.inject([]) do |memo, header|\n memo << {\n :name => header[0].to_s.split('_').map(&:capitalize).join('-'),\n :value => header[1].to_s\n }\n end\nend",
"def machine_hash(headers,rows)\n # This is just to give a nice data structure (a hash of )\n rows.each_with_index.map do |row, index|\n # todo - rearrange the hash so it is sorted - do we need the row index?\n Hash[headers.each_with_index.map { |header, pos| \n [header, row[pos] ]}\n ].merge('row' => index+2)\n end\n end",
"def record_header(cursor)\n origin = cursor.position\n header = RecordHeader.new\n cursor.backward.name(\"header\") do |c|\n case page_header.format\n when :compact\n # The \"next\" pointer is a relative offset from the current record.\n header.next = c.name(\"next\") { origin + c.read_sint16 }\n\n # Fields packed in a 16-bit integer (LSB first):\n # 3 bits for type\n # 13 bits for heap_number\n bits1 = c.name(\"bits1\") { c.read_uint16 }\n header.type = RECORD_TYPES[bits1 & 0x07]\n header.heap_number = (bits1 & 0xfff8) >> 3\n when :redundant\n # The \"next\" pointer is an absolute offset within the page.\n header.next = c.name(\"next\") { c.read_uint16 }\n\n # Fields packed in a 24-bit integer (LSB first):\n # 1 bit for offset_size (0 = 2 bytes, 1 = 1 byte)\n # 10 bits for n_fields\n # 13 bits for heap_number\n bits1 = c.name(\"bits1\") { c.read_uint24 }\n header.offset_size = (bits1 & 1).zero? ? 2 : 1\n header.n_fields = (bits1 & (((1 << 10) - 1) << 1)) >> 1\n header.heap_number = (bits1 & (((1 << 13) - 1) << 11)) >> 11\n end\n\n # Fields packed in an 8-bit integer (LSB first):\n # 4 bits for n_owned\n # 4 bits for flags\n bits2 = c.name(\"bits2\") { c.read_uint8 }\n header.n_owned = bits2 & 0x0f\n header.info_flags = (bits2 & 0xf0) >> 4\n\n case page_header.format\n when :compact\n record_header_compact_additional(header, cursor)\n when :redundant\n record_header_redundant_additional(header, cursor)\n end\n\n header.length = origin - cursor.position\n end\n\n header\n end",
"def header\n @result['_header']\n end",
"def header_names headers\n header_names = []\n headers.each do |header|\n header_names.append header[:name]\n end\n header_names.join \",\"\nend",
"def headers_by_index(headers)\n result = Hash.new\n headers.each_with_index do |column, index|\n result[index] = column\n end\n result\nend",
"def headers\n msg['headers']||{}\n end"
] |
[
"0.76029897",
"0.7440678",
"0.7068711",
"0.68863803",
"0.68485767",
"0.6643628",
"0.6640296",
"0.6601318",
"0.65462494",
"0.6480545",
"0.64641213",
"0.64422363",
"0.6388955",
"0.6364178",
"0.636414",
"0.6349031",
"0.6341213",
"0.6330138",
"0.63254786",
"0.63105243",
"0.6284926",
"0.6284926",
"0.6284926",
"0.626739",
"0.62643534",
"0.62270355",
"0.622333",
"0.6216118",
"0.62149507",
"0.62149507",
"0.62146175",
"0.620977",
"0.620803",
"0.6187604",
"0.6183757",
"0.61554927",
"0.6155428",
"0.6142944",
"0.6142944",
"0.61319375",
"0.6115835",
"0.6109836",
"0.61075974",
"0.60999316",
"0.60841197",
"0.6080734",
"0.6062379",
"0.60596615",
"0.6059258",
"0.6059216",
"0.6046372",
"0.60459435",
"0.60457015",
"0.60361093",
"0.6034018",
"0.60339004",
"0.6030624",
"0.6025566",
"0.6024848",
"0.6022909",
"0.6010865",
"0.60061574",
"0.60060763",
"0.5994419",
"0.59864986",
"0.59839314",
"0.5982457",
"0.5979499",
"0.5970627",
"0.59681326",
"0.59636664",
"0.5959215",
"0.5954846",
"0.59500253",
"0.5947898",
"0.59478885",
"0.59478885",
"0.59478885",
"0.5946872",
"0.5927301",
"0.5912325",
"0.5910918",
"0.5910476",
"0.59070545",
"0.5904384",
"0.59039694",
"0.589719",
"0.58923167",
"0.5887834",
"0.5886882",
"0.58862764",
"0.5884117",
"0.58718127",
"0.58658934",
"0.58615774",
"0.58604366",
"0.5859838",
"0.5859232",
"0.58576363",
"0.5853858",
"0.58532363"
] |
0.0
|
-1
|
Returns a header. The header consists of six 32bit unsigned integers. Integers are stored in bigendian byte order. The order and meaning of the fields are as follows: [+version+] version number [+numstr+] number of pointers [+longlen+] size of longest fortune [+shortlen+] size of shortest fortune [+flags+] stores multiple booleans (bitfield) [1] randomize order [2] sorting in alphabetical order [4] Caesar encryption [8] allow comments [+delim+] 8bit unsigned integer packed to 32bit which represents a delimeter character
|
def header_fields
IO.binread(@path, HEADER_SIZE, 0).unpack("N5C1")
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def header\n @sfntVersion, @numTables, *rest = @bytes[0, 4 + 2 + 2 + 2 + 2].unpack('Nnnnn')\n end",
"def header_for_string string\n header = string.length << 1 # make room for a low bit of 1\n header = header | 1 # set the low bit to 1\n pack_int header\n end",
"def packed()\n header = self.version.chr + \n @type.chr + \n @seq_no.chr + \n @flags.chr + \n TacacsPlus.pack_int_net(@session_id,4) + \n TacacsPlus.pack_int_net(@length,4)\n return(header)\n end",
"def header\n MAGIC + [VERSION].pack('n')\n end",
"def make_header\n\t\t\theader = nil\n\t\t\tlength = self.payload.size\n\n\t\t\tself.log.debug \"Making wire protocol header for payload of %d bytes\" % [ length ]\n\n\t\t\t# Pack the frame according to its size\n\t\t\tif length >= 2**16\n\t\t\t\tself.log.debug \" giant size, using 8-byte (64-bit int) length field\"\n\t\t\t\theader = [ self.flags, 127, length ].pack( 'c2q>' )\n\t\t\telsif length > 125\n\t\t\t\tself.log.debug \" big size, using 2-byte (16-bit int) length field\"\n\t\t\t\theader = [ self.flags, 126, length ].pack( 'c2n' )\n\t\t\telse\n\t\t\t\tself.log.debug \" small size, using payload length field\"\n\t\t\t\theader = [ self.flags, length ].pack( 'c2' )\n\t\t\tend\n\n\t\t\tself.log.debug \" header is: 0: %02x %02x\" % header.unpack('C*')\n\t\t\treturn header\n\t\tend",
"def header(h, buffer = Buffer.new)\n rep = HEADREP[h[:type]]\n\n case h[:type]\n when :indexed\n buffer << integer(h[:name] + 1, rep[:prefix])\n when :changetablesize\n buffer << integer(h[:value], rep[:prefix])\n else\n if h[:name].is_a? Integer\n buffer << integer(h[:name] + 1, rep[:prefix])\n else\n buffer << integer(0, rep[:prefix])\n buffer << string(h[:name])\n end\n\n buffer << string(h[:value])\n end\n\n # set header representation pattern on first byte\n fb = buffer.ord | rep[:pattern]\n buffer.setbyte(0, fb)\n\n buffer\n end",
"def read_header(fp)\n tags = Support::HexString.from_bin(fp.read(1)).ord\n type = (tags & 0x70) >> 4\n size = tags & 0xF\n shift = 4\n while tags & 0x80 > 0\n tags = Support::HexString.from_bin(fp.read(1)).ord\n size += (tags & 0x7F) << shift\n shift += 7\n end\n [type, size]\n end",
"def rhdr\n b = rbyte\n code, value = b & 7, b >> 3\n case value\n when 0..22\n return code, value\n when 23...31\n return code, rlongint(value-22)\n else\n n = renc\n return code, rlongint(n)\n end\n end",
"def header(h, buffer = Buffer.new)\n rep = HEADREP[h[:type]]\n\n if h[:type] == :indexed\n buffer << integer(h[:name], rep[:prefix])\n\n else\n if h[:name].is_a? Integer\n buffer << integer(h[:name]+1, rep[:prefix])\n else\n buffer << integer(0, rep[:prefix])\n buffer << string(h[:name])\n end\n\n if h[:type] == :substitution\n buffer << integer(h[:index], 0)\n end\n\n if h[:value].is_a? Integer\n buffer << integer(h[:value], 0)\n else\n buffer << string(h[:value])\n end\n end\n\n # set header representation pattern on first byte\n fb = buffer[0].unpack(\"C\").first | rep[:pattern]\n buffer.setbyte(0, fb)\n\n buffer\n end",
"def header(h, buffer = \"\")\n rep = HEADREP[h[:type]]\n\n if h[:type] == :indexed\n buffer << integer(h[:name], rep[:prefix])\n\n else\n if h[:name].is_a? Integer\n buffer << integer(h[:name]+1, rep[:prefix])\n else\n buffer << integer(0, rep[:prefix])\n buffer << string(h[:name])\n end\n\n if h[:type] == :substitution\n buffer << integer(h[:index], 0)\n end\n\n if h[:value].is_a? Integer\n buffer << integer(h[:value], 0)\n else\n buffer << string(h[:value])\n end\n end\n\n # set header representation pattern on first byte\n fb = buffer[0].unpack(\"C\").first | rep[:pattern]\n buffer.setbyte(0, fb)\n\n buffer\n end",
"def header\n @version, @flags, @numStrikes = @bytes[0, 8].unpack('nnN')\n\n @strikeOffset = (0...@numStrikes).map do |n|\n start = 8 + n * 4\n @bytes[start, 4].unpack('N')[0]\n end\n end",
"def store_header #:nodoc:\n record = 0x0014 # Record identifier\n # length # Bytes to follow\n\n str = @header # header string\n cch = str.length # Length of header string\n encoding = @header_encoding # Character encoding\n\n\n # Character length is num of chars not num of bytes\n cch /= 2 if encoding != 0\n\n # Change the UTF-16 name from BE to LE\n str = str.unpack('v*').pack('n*') if encoding != 0\n\n length = 3 + str.length\n\n header = [record, length].pack('vv')\n data = [cch, encoding].pack('vC')\n\n prepend(header, data, str)\n end",
"def header(buf)\n peek = buf.readbyte(0)\n\n header = {}\n header[:type], type = HEADREP.find do |_t, desc|\n mask = (peek >> desc[:prefix]) << desc[:prefix]\n mask == desc[:pattern]\n end\n\n fail CompressionError unless header[:type]\n\n header[:name] = integer(buf, type[:prefix])\n\n case header[:type]\n when :indexed\n fail CompressionError if (header[:name]).zero?\n header[:name] -= 1\n when :changetablesize\n header[:value] = header[:name]\n else\n if (header[:name]).zero?\n header[:name] = string(buf)\n else\n header[:name] -= 1\n end\n header[:value] = string(buf)\n end\n\n header\n end",
"def header_for_id(id)\n raise 'Id must be 4 bytes' unless id.gsub(' ', '').length == 4*2\n # header is really \"B1 96 B1 D3 ED AE 5F 92 #{id}\"\n # however we're chopping off one byte to fit within 12 bytes in the search code.\n\n # the byte after item id changes. maybe 06 or 02 depending on the item.\n \"B1 96 B1 D3 ED AE 5F 92 #{id}\".gsub(' ', '')\n end",
"def read_header\n\t@bytes_to_be_read = 0\n\tread_mt_header_string(MThd_BYTE_ARRAY, @skip_init) # \"MThd\"\n\n\t@bytes_to_be_read = read32()\n\tformat = read16()\n\tntrks = read16()\n\tdivision = read16()\n\n\theader(format, ntrks, division)\n\n\t# Flush any extra stuff, in case the length of the header is not 6\n\tif @bytes_to_be_read > 0\n get_bytes(@bytes_to_be_read)\n @bytes_to_be_read = 0\n\tend\n\n\treturn ntrks\n end",
"def get_header\n begin\n size = @out.read(33)\n size = size[0..-2]\n\n # Sanity check the size\n if not size_check(size)\n @log.error \"[#{Time.now.iso8601}] Size returned from mentos.py invalid.\"\n stop \"Size returned from mentos.py invalid.\"\n raise MentosError, \"Size returned from mentos.py invalid.\"\n end\n\n # Read the amount of bytes we should be expecting. We first\n # convert the string of bits into an integer.\n header_bytes = size.to_s.to_i(2) + 1\n @log.info \"[#{Time.now.iso8601}] Size in: #{size.to_s} (#{header_bytes.to_s})\"\n @out.read(header_bytes)\n rescue\n @log.error \"[#{Time.now.iso8601}] Failed to get header.\"\n stop \"Failed to get header.\"\n raise MentosError, \"Failed to get header.\"\n end\n end",
"def get_header_info\n @data.rewind\n \n #column_count_offset = 33, record_count_offset = 24, record_length_offset = 36\n @record_count, @data_offset, @record_length = data.read(HEADER_LENGTH).unpack(\"@24 I x4 I I\")\n @column_count = (@data_offset-400)/200\n end",
"def header_for_reference index\n header = index << 1 # shift value left to leave a low bit of 0\n pack_int header\n end",
"def header(buf)\n peek = buf.readbyte(0)\n\n header = {}\n header[:type], type = HEADREP.select do |t, desc|\n mask = (peek >> desc[:prefix]) << desc[:prefix]\n mask == desc[:pattern]\n end.first\n\n header[:name] = integer(buf, type[:prefix])\n if header[:type] != :indexed\n header[:name] -= 1\n\n if header[:name] == -1\n header[:name] = string(buf)\n end\n\n if header[:type] == :substitution\n header[:index] = integer(buf, 0)\n end\n\n header[:value] = string(buf)\n end\n\n header\n end",
"def id_to_header(id)\n id.to_s(16)\n end",
"def header\n header = \"%FDF-1.2\\n\\n1 0 obj\\n<<\\n/FDF << /Fields 2 0 R\"\n # /F\n header << \"/F (#{options[:file]})\" if options[:file]\n # /UF\n header << \"/UF (#{options[:ufile]})\" if options[:ufile]\n # /ID\n header << \"/ID[\" << options[:id].join << \"]\" if options[:id]\n header << \">>\\n>>\\nendobj\\n2 0 obj\\n[\"\n return header\n end",
"def header_udp package_number, file_size, signaze\n number_package = \"%0#{@header_number_package_size}b\" % package_number\n eof = \"0\" if signal == \"send\"\n eof = \"1\" if signal == \"eof\"\n file_size + number_package + eof\n end",
"def header_udp package_number, file_size, signal=\"send\"\n file_size = \"%0#{@header_file_size}b\" % file_size\n number_package = \"%0#{@header_number_package_size}b\" % package_number\n eof = \"0\" if signal == \"send\"\n eof = \"1\" if signal == \"eof\"\n file_size + number_package + eof\n end",
"def header_udp package_number, file_size, signal=\"send\"\n file_size = \"%0#{@header_file_size}b\" % file_size\n number_package = \"%0#{@header_number_package_size}b\" % package_number\n eof = \"0\" if signal == \"send\"\n eof = \"1\" if signal == \"eof\"\n file_size + number_package + eof\n end",
"def header(buf)\n peek = buf.getbyte\n buf.seek(-1, IO::SEEK_CUR)\n\n header = {}\n header[:type], type = HEADREP.select do |t, desc|\n mask = (peek >> desc[:prefix]) << desc[:prefix]\n mask == desc[:pattern]\n end.first\n\n header[:name] = integer(buf, type[:prefix])\n if header[:type] != :indexed\n header[:name] -= 1\n\n if header[:name] == -1\n header[:name] = string(buf)\n end\n\n if header[:type] == :substitution\n header[:index] = integer(buf, 0)\n end\n\n header[:value] = string(buf)\n end\n\n header\n end",
"def header_length() 3 end",
"def get_header_string(io)\n chunk_size = 2**12\n loc = 0\n string = ''\n while chunk = @io.read(chunk_size)\n string << chunk\n start_looking = ((loc-20) < 0) ? 0 : (loc-20)\n break if string[start_looking..-1] =~ /<(spectrum|chromatogram)/\n loc += chunk_size\n end\n string\n end",
"def header_len\n (@binhdr[12, 1].unpack(\"C\").pop >> 4) << 2\n end",
"def getHeader()\n header = \"\"\n\n appendStr(header, \"time\")\n appendStr(header, \"seqno\")\n $cmd_list.each do | name, cmd, type |\n appendStr(header, name)\n end\n return header\nend",
"def unpack_header(header)\n # fixed fields\n self.version = header.slice!(0)\n self.type = header.slice!(0)\n self.seq_no = header.slice!(0)\n self.flags = header.slice!(0)\n self.session_id = header.slice!(0..3)\n self.length = header.slice!(0..3)\n return(nil)\n end",
"def header_size\n FFI::Type::ULONG.size + FFI::Type::USHORT.size + FFI::Type::USHORT.size\n end",
"def header_to_id(header_id)\n if !header_id.is_a?(String)\n Instana.logger.debug \"header_to_id received a #{header_id.class}: returning 0\"\n return 0\n end\n if header_id.length < 16\n # The header is less than 16 chars. Prepend\n # zeros so we can convert correctly\n missing = 16 - header_id.length\n header_id = (\"0\" * missing) + header_id\n end\n [header_id].pack(\"H*\").unpack(\"q>\")[0]\n rescue => e\n Instana.logger.info \"#{__method__}:#{File.basename(__FILE__)}:#{__LINE__}: #{e.message}\"\n Instana.logger.debug e.backtrace.join(\"\\r\\n\")\n end",
"def read_mt_header_string(bytes, skip)\n\tb = []\n\tbytes_to_read = 4\n\twhile true\n data = get_bytes(bytes_to_read)\n b += data\n if b.length < 4\n error(\"unexpected EOF while trying to read header string #{s}\")\n end\n\n # See if we found the bytes we're looking for\n return if b == bytes\n\n if skip\t\t# Try again with the next char\n i = b[1..-1].index(bytes[0])\n if i.nil?\n b = []\n bytes_to_read = 4\n else\n b = b[i..-1]\n bytes_to_read = 4 - i\n end\n else\n error(\"header string #{bytes.collect{|b| b.chr}.join} not found\")\n end\n\tend\n end",
"def record_header(cursor)\n origin = cursor.position\n header = RecordHeader.new\n cursor.backward.name(\"header\") do |c|\n case page_header.format\n when :compact\n # The \"next\" pointer is a relative offset from the current record.\n header.next = c.name(\"next\") { origin + c.read_sint16 }\n\n # Fields packed in a 16-bit integer (LSB first):\n # 3 bits for type\n # 13 bits for heap_number\n bits1 = c.name(\"bits1\") { c.read_uint16 }\n header.type = RECORD_TYPES[bits1 & 0x07]\n header.heap_number = (bits1 & 0xfff8) >> 3\n when :redundant\n # The \"next\" pointer is an absolute offset within the page.\n header.next = c.name(\"next\") { c.read_uint16 }\n\n # Fields packed in a 24-bit integer (LSB first):\n # 1 bit for offset_size (0 = 2 bytes, 1 = 1 byte)\n # 10 bits for n_fields\n # 13 bits for heap_number\n bits1 = c.name(\"bits1\") { c.read_uint24 }\n header.offset_size = (bits1 & 1).zero? ? 2 : 1\n header.n_fields = (bits1 & (((1 << 10) - 1) << 1)) >> 1\n header.heap_number = (bits1 & (((1 << 13) - 1) << 11)) >> 11\n end\n\n # Fields packed in an 8-bit integer (LSB first):\n # 4 bits for n_owned\n # 4 bits for flags\n bits2 = c.name(\"bits2\") { c.read_uint8 }\n header.n_owned = bits2 & 0x0f\n header.info_flags = (bits2 & 0xf0) >> 4\n\n case page_header.format\n when :compact\n record_header_compact_additional(header, cursor)\n when :redundant\n record_header_redundant_additional(header, cursor)\n end\n\n header.length = origin - cursor.position\n end\n\n header\n end",
"def header_for_array array\n header = array.length << 1 # make room for a low bit of 1\n header = header | 1 # set the low bit to 1\n pack_int header\n end",
"def build_block_header(type, size, last)\n begin\n bit_string = sprintf(\"%b%7b\", last, type).gsub(\" \",\"0\")\n block_header_s = [bit_string].pack(\"B*\")\n block_header_s += [size].pack(\"VX\").reverse # size is 3 bytes\n rescue\n raise FlacInfoWriteError, \"error building block header\"\n end\n end",
"def get_rec_header!\n if @abca\n return [nil, nil] unless get_byte.between?(0x80, 0xbf)\n if @ofs == 0x11 or @data[@ofs-1].ord & 0x20 != 0\n get_node_type_and_version\n else\n get_node_type_and_version_abca\n end\n else\n return [nil, nil] unless get_byte == 0x80\n get_node_type_and_version\n end\n end",
"def write_header\n # Include Header and encryption version indicator\n flags = @cipher.version || 0 # Same as 0b0000_0000_0000_0000\n\n # If the data is to be compressed before being encrypted, set the\n # compressed bit in the version byte\n flags |= 0b1000_0000_0000_0000 if @compress\n\n @ios.write \"#{MAGIC_HEADER}#{[flags].pack('v')}\"\n end",
"def id_to_header(id)\n return '' unless id.is_a?(String)\n # Only send 64bit IDs downstream for now\n id.length == 32 ? id[16..-1] : id\n end",
"def len_header\n return @len_header unless @len_header.nil?\n _pos = @_io.pos\n @_io.seek(88)\n @len_header = @_io.read_u8le\n @_io.seek(_pos)\n @len_header\n end",
"def header\n chunk_header = nil\n File.open(@file_name) do |file|\n file.seek(@offset + 4 + @size_length, IO::SEEK_CUR)\n chunk_header = file.read(@header_size)\n end\n chunk_header\n end",
"def getHeader() @header1 end",
"def parse_header(io)\n\t variable_name = nil\n\t parse_pairs io do |code, value|\n\t\tcase code\n\t\t when '0' then next\n\t\t when '9'\n\t\t\tvariable_name = value\n\t\t else\n\t\t\theader[variable_name] = value\n\t\tend\n\t end\n\tend",
"def parse_frame_header\n header_size = @version == 2 ? 6 : 10\n header_formate = @version == 2 ? \"A3B24\" : \"A4B32B16\"\n id, size_bits, flags_bits = @file_io.read(header_size).unpack(header_formate)\n\n @name = ID_MAPPING[id.to_sym]\n @size = Helper.id3_size_caculate(size_bits, has_zero_bit: @version == 4)\n @flags = parse_flags(flags_bits)\n end",
"def read_tls_header_type (socket)\n header = socket.read(5)\n h_type, h_maj_version, h_min_version, h_length = header.unpack('CCCn')\n return h_type\nend",
"def write_header(primary_key, fields)\n # 5 == field_header + field_footer size\n total_size = fields.inject(0){|sum,field| sum += (field || '').size + 5}\n # 13 == record header + record footer\n total_size += 13\n @io.write [total_size, primary_key].pack(\"VV\") \n end",
"def header_size(header)\n header.unpack(\"N\").first\n end",
"def inspect #:nodoc:\n s = \"#<#{self.class}:0x#{(self.object_id*2).to_s(16)} \"\n @header_object.each_pair do |k,v|\n s += \"(#{k.upcase} size=#{v[1]} offset=#{v[2]}) \" unless k == \"ASF_Header_Object\"\n end\n s += \"\\b>\"\n end",
"def id_to_header(id)\n unless id.is_a?(Integer) || id.is_a?(String)\n Instana.logger.debug \"id_to_header received a #{id.class}: returning empty string\"\n return String.new\n end\n [id.to_i].pack('q>').unpack('H*')[0].gsub(/^0+/, '')\n rescue => e\n Instana.logger.info \"#{__method__}:#{File.basename(__FILE__)}:#{__LINE__}: #{e.message}\"\n Instana.logger.debug e.backtrace.join(\"\\r\\n\")\n end",
"def header_size\n 12\n end",
"def header_length\n self[:ip_vhl] & 0x0f\n end",
"def big_header(string)\n outstring = \"$ *********************************************************\\n$ ** **\\n$ ** #{string} \\n$ ** **\\n$ *********************************************************\\n\"\n return outstring\n end",
"def h000000000000000000000000000000000000000000010111000110111101eader_udp package_number, file_size, signal=\"send\"\n file_size = \"%0#{@header_file_size}b\" % file_size\n number_package = \"%0#{@header_number_package_size}b\" % package_number\n eof = \"0\" if signal == \"send\"\n eof = \"1\" if signal == \"eof\"\n file_size initialize(socket, address=nil)\n @package_size = 1024\n @address = address\n # @header_package_data = 60\n @header_file_size = 60\n @header_number_package_size = 20\n @header_eof_size = 1\n @header_size = @header_file_size + @header_number_package_size + @header_eof_size\n @oob_char = '!'\n @socket = socket\n end",
"def header_str\n \"\"\n end",
"def monta_header\n # CAMPO TAMANHO VALOR\n # tipo do registro [1] 0\n # operacao [1] 1\n # literal remessa [7] REMESSA\n # brancos [16]\n # info. conta [20]\n # empresa mae [30]\n # cod. banco [3]\n # nome banco [15]\n # data geracao [6] formato DDMMAA\n # complemento registro [294]\n # num. sequencial [6] 000001\n \"01REMESSA #{info_conta}#{empresa_mae.format_size(30)}#{cod_banco}#{nome_banco}#{data_geracao}#{complemento}000001\"\n end",
"def monta_header\n # CAMPO TAMANHO VALOR\n # tipo do registro [1] 0\n # operacao [1] 1\n # literal remessa [7] REMESSA\n # Código do serviço [2] 01\n # cod. servico [15] COBRANCA\n # info. conta [20]\n # empresa mae [30]\n # cod. banco [3]\n # nome banco [15]\n # data geracao [6] formato DDMMAA\n # complemento registro [294]\n # num. sequencial [6] 000001\n \"01REMESSA01COBRANCA #{info_conta}#{empresa_mae.format_size(30).remove_accents}#{cod_banco}#{nome_banco}#{data_geracao}#{versao_layout}#{complemento}000001\"\n end",
"def fil_header\n @fil_header ||= cursor(pos_fil_header).name(\"fil_header\") do |c|\n {\n :checksum => c.name(\"checksum\") { c.get_uint32 },\n :offset => c.name(\"offset\") { c.get_uint32 },\n :prev => c.name(\"prev\") {\n Innodb::Page.maybe_undefined(c.get_uint32)\n },\n :next => c.name(\"next\") {\n Innodb::Page.maybe_undefined(c.get_uint32)\n },\n :lsn => c.name(\"lsn\") { c.get_uint64 },\n :type => c.name(\"type\") { PAGE_TYPE_BY_VALUE[c.get_uint16] },\n :flush_lsn => c.name(\"flush_lsn\") { c.get_uint64 },\n :space_id => c.name(\"space_id\") { c.get_uint32 },\n }\n end\n end",
"def header\n @raw.split(\"--\" + boundary)[0]\n end",
"def parse_type_and_size\n hdr = byte\n hdr_size = 1\n continue = (hdr & 0b10000000)\n type = (hdr & 0b01110000) >> 4\n size = (hdr & 0b00001111)\n size_len = 4\n while continue != 0\n hdr = byte\n hdr_size += 1\n continue = (hdr & 0b10000000)\n size += (hdr & 0b01111111) << size_len\n size_len += 7\n end\n return [type, size, hdr_size]\n end",
"def header_to_id(header_id)\n header_id.to_i(16)\n end",
"def gen_header(fp)\n fp.puts(\"/*\")\n fp.puts(\" * Copyright (c) 2015, Masayuki Kimura\")\n fp.puts(\" * All rights reserved.\")\n fp.puts(\" *\")\n fp.puts(\" * Redistribution and use in source and binary forms, with or without\")\n fp.puts(\" * modification, are permitted provided that the following conditions are met:\")\n fp.puts(\" * * Redistributions of source code must retain the above copyright\")\n fp.puts(\" * notice, this list of conditions and the following disclaimer.\")\n fp.puts(\" * * Redistributions in binary form must reproduce the above copyright\")\n fp.puts(\" * notice, this list of conditions and the following disclaimer in the\")\n fp.puts(\" * documentation and/or other materials provided with the distribution.\")\n fp.puts(\" * * Neither the name of the Masayuki Kimura nor the\")\n fp.puts(\" * names of its contributors may be used to endorse or promote products\")\n fp.puts(\" * derived from this software without specific prior written permission.\")\n fp.puts(\" *\")\n fp.puts(\" * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \\\"AS IS\\\" AND\")\n fp.puts(\" * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\")\n fp.puts(\" * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\")\n fp.puts(\" * DISCLAIMED. IN NO EVENT SHALL MASAYUKI KIMURA BE LIABLE FOR ANY\")\n fp.puts(\" * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\")\n fp.puts(\" * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\")\n fp.puts(\" * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\")\n fp.puts(\" * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\")\n fp.puts(\" * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\")\n fp.puts(\" * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\")\n fp.puts(\" */\")\n fp.puts(\"\")\n fp.puts(\"/* CAUTION! THIS SOURCE CODE IS GENERATED AUTOMATICALLY. DON'T MODIFY BY HAND. */\")\n fp.puts(\"\")\n fp.puts(\"\")\nend",
"def gen_header(fp)\n fp.puts(\"/*\")\n fp.puts(\" * Copyright (c) 2015, Masayuki Kimura\")\n fp.puts(\" * All rights reserved.\")\n fp.puts(\" *\")\n fp.puts(\" * Redistribution and use in source and binary forms, with or without\")\n fp.puts(\" * modification, are permitted provided that the following conditions are met:\")\n fp.puts(\" * * Redistributions of source code must retain the above copyright\")\n fp.puts(\" * notice, this list of conditions and the following disclaimer.\")\n fp.puts(\" * * Redistributions in binary form must reproduce the above copyright\")\n fp.puts(\" * notice, this list of conditions and the following disclaimer in the\")\n fp.puts(\" * documentation and/or other materials provided with the distribution.\")\n fp.puts(\" * * Neither the name of the Masayuki Kimura nor the\")\n fp.puts(\" * names of its contributors may be used to endorse or promote products\")\n fp.puts(\" * derived from this software without specific prior written permission.\")\n fp.puts(\" *\")\n fp.puts(\" * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \\\"AS IS\\\" AND\")\n fp.puts(\" * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\")\n fp.puts(\" * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\")\n fp.puts(\" * DISCLAIMED. IN NO EVENT SHALL MASAYUKI KIMURA BE LIABLE FOR ANY\")\n fp.puts(\" * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\")\n fp.puts(\" * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\")\n fp.puts(\" * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\")\n fp.puts(\" * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\")\n fp.puts(\" * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\")\n fp.puts(\" * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\")\n fp.puts(\" */\")\n fp.puts(\"\")\n fp.puts(\"/* CAUTION! THIS SOURCE CODE IS GENERATED AUTOMATICALLY. DON'T MODIFY BY HAND. */\")\n fp.puts(\"\")\n fp.puts(\"\")\nend",
"def header_to_s # :nodoc:\n if (header)\n pad = \" \" * headeri\n\n return pad + header + \"\\n\" + pad + \"=\" * header.length + \"\\n\\n\"\n end\n\n return ''\n end",
"def gen_header(fp)\n fp.puts(\"/*\")\n fp.puts(\" * Copyright (c) 2015, msyksphinz\")\n fp.puts(\" * All rights reserved.\")\n fp.puts(\" *\")\n fp.puts(\" * Redistribution and use in source and binary forms, with or without\")\n fp.puts(\" * modification, are permitted provided that the following conditions are met:\")\n fp.puts(\" * * Redistributions of source code must retain the above copyright\")\n fp.puts(\" * notice, this list of conditions and the following disclaimer.\")\n fp.puts(\" * * Redistributions in binary form must reproduce the above copyright\")\n fp.puts(\" * notice, this list of conditions and the following disclaimer in the\")\n fp.puts(\" * documentation and/or other materials provided with the distribution.\")\n fp.puts(\" * * Neither the name of the msyksphinz nor the\")\n fp.puts(\" * names of its contributors may be used to endorse or promote products\")\n fp.puts(\" * derived from this software without specific prior written permission.\")\n fp.puts(\" *\")\n fp.puts(\" * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \\\"AS IS\\\" AND\")\n fp.puts(\" * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\")\n fp.puts(\" * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\")\n fp.puts(\" * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\")\n fp.puts(\" * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\")\n fp.puts(\" * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\")\n fp.puts(\" * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\")\n fp.puts(\" * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\")\n fp.puts(\" * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\")\n fp.puts(\" * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\")\n fp.puts(\" */\")\n fp.puts(\"\")\n fp.puts(\"/* CAUTION! THIS SOURCE CODE IS GENERATED AUTOMATICALLY. DON'T MODIFY BY HAND. */\")\n fp.puts(\"\")\n fp.puts(\"\")\nend",
"def read_header\n @height = next_uint16 + 1\n puts \"Height: #{@height}\" if @verbose\n\n @width = next_uint16 + 1\n puts \"Width: #{@width}\" if @verbose\n\n @yoffset = next_uint16\n @xoffset = next_uint16\n puts \"Offsets: #{@xoffset}, #{@yoffset}\" if @verbose\n\n @xstart = next_int32\n @ystart = next_int32\n puts \"Start: #{@xstart}, #{@ystart}\" if @verbose\n\n @xend = next_int32\n @yend = next_int32\n\n puts \"End: #{@xend}, #{@yend}\" if @verbose\n end",
"def toString()\n @header[LENGTH - 1] = checksum()\n return @header + @message\n end",
"def actual_header\n data.lines.first.chomp\n end",
"def generate_header_info\n magic = FileMagic.new\n @header_info = magic.file(@file_name)\n magic.close\n\n @header_info\n end",
"def header_build\n header = \"customer name\" + @delimiter + \"gender\" + @delimiter\n header += \"age\" + @delimiter + \"birthday\" + @delimiter + \"cpf\" + @delimiter + \"id\" + @delimiter\n header += \"state\" + @delimiter + \"city\" + @delimiter + \"street\" + @delimiter + \"zip_code\" + @delimiter\n header += \"company name\" + @delimiter + \"industry\" + @delimiter + \"cnpj\"\n header\nend",
"def search_for_header(header_id)\n raise \"Header is nil\" unless header_id\n expected_len = 12 * 2\n raise \"Invalid header length #{header_id.length} != #{expected_len}\\n#{header_id}\" unless header_id.length == expected_len\n header_id = header_id.upcase\n result = []\n result << \"8001000C #{header_id[0...8]}\"\n result << \"#{header_id[8...16]} #{header_id[16...24]}\"\n end",
"def PcbElementHeader(flags, desc, name, value, mx, my, tx, ty, tdir, tscale, tflags)\n _SFlags = %Q(\"#{flags}\")\n _Desc = %Q(\"#{desc}\")\n _Name = %Q(\"#{name}\")\n _Value = %Q(\"#{value}\")\n _MX = mx.round\n _MY = my.round\n _TX = tx.round\n _TY = ty.round\n _TDir = tdir.round\n _TScale = tscale.round\n _TSFlags = %Q(\"#{tflags}\")\n %Q(Element[#{_SFlags} #{_Desc} #{_Name} #{_Value} #{_MX} #{_MY} #{_TX} #{_TY} #{_TDir} #{_TScale} #{_TSFlags}]\\n)\nend",
"def parse_header(line)\n case line\n when /^#%checkm/\n match = /^#%checkm_(\\d+)\\.(\\d+)/.match line\n @version = \"#{match[1]}.#{match[2]}\" if match\n when /^#%eof/\n @eof = true\n when /^#%fields/\n list = line.split('|')\n list.shift\n @fields = list.map { |v| v.strip.downcase }\n when /^#%prefix/, /^#%profile/\n # do nothing\n end\n end",
"def serialize_header(buffer)\n Header.serialize(buffer, [0, request_id, 0, op_code])\n end",
"def parse_header(string)\n {\n # identificação do registro header (conteúdo 0)\n :tipo_registro => string[0..0].to_i,\n # identificação do arquivo retorno\n :codigo_retorno => string[1..1],\n # identificação por extenso do tipo de movimento\n :literal_retorno => string[2..8],\n # identificação do tipo de serviço\n :codigo_servico => string[9..10],\n # identificação por extenso do tipo de serviço\n :literal_servico => string[11..25],\n # código da empresa no bradesco\n :codigo_empresa => string[26..45].strip,\n # razão social da empresa\n :razao_social => string[46..75],\n # número do banco na câmara de compensação\n :codigo_banco => string[76..78],\n # nome por extenso do banco cobrador\n :nome_banco => string[79..93].strip,\n # data de geração do arquivo\n :data_geracao => convert_date(string[94..99]),\n # brancos\n #:brancos1 => string[100..107],\n # número aviso bancário\n :numero_aviso_bancario => string[108..112],\n # brancos\n #:brancos2 => string[113..378],\n # data de crédito dos lançamentos\n :data_credito => convert_date(string[379..384]),\n # brancos\n #:brancos3 => string[385..393],\n # número sequencial do registro no arquivo\n :numero_sequencial => string[394..399]\n }\n end",
"def readHeader(iFile)\n rError = nil\n rHeader = nil\n\n iFile.seek(0)\n lBinaryHeader = iFile.read(12)\n # Check if the format is ok\n if (lBinaryHeader[0..3] != 'RIFF')\n rError = RuntimeError.new('Invalid header: not RIFF')\n elsif (lBinaryHeader[8..11] != 'WAVE')\n rError = RuntimeError.new('Invalid header: not WAVE')\n else\n lReader = RIFFReader.new(iFile)\n rError, lFMTSize = lReader.setFilePos('fmt ')\n if (rError == nil)\n # lFMTSize should be 18\n if (lFMTSize >= 16)\n lBinFormat = iFile.read(lFMTSize)\n # Read values\n lAudioFormat, lNbrChannels, lSampleRate, lByteRate, lBlockAlign, lNbrBitsPerSample = lBinFormat[0..17].unpack('vvVVvv')\n # Check values\n if (lBlockAlign != (lNbrChannels*lNbrBitsPerSample)/8)\n rError = RuntimeError.new(\"Invalid header: Block alignment (#{lBlockAlign}) should be #{(lNbrChannels*lNbrBitsPerSample)/8}.\")\n elsif (lByteRate != lBlockAlign*lSampleRate)\n rError = RuntimeError.new(\"Invalid header: Byte rate (#{lByteRate}) should be #{lBlockAlign*lSampleRate}.\")\n else\n # OK, header is valid\n rHeader = WSK::Model::Header.new(lAudioFormat, lNbrChannels, lSampleRate, lNbrBitsPerSample)\n end\n else\n rError = RuntimeError.new(\"Invalid fmt header size: #{lFMTSize} should be >= 16.\")\n end\n end\n end\n\n return rError, rHeader\n end",
"def header_size\n TYPE_SIZE\n end",
"def header_length\n @header_length ||= DBF_HEADER_SIZE + columns.size * 32 + 1\n end",
"def header\n new_header = GElf::SectionHeader.new\n\n GElf.gelf_getshdr(self,new_header)\n return new_header\n end",
"def normalize_header!\n @gsi.dsc = HeaderOption::DSC::TELETEXT_LEVEL_2\n @gsi.lc = @gsi.lc.to_i.to_s.rjust(2,'0')\n @gsi.tnb = @gsi.tnb.to_i.to_s.rjust(5,'0')\n @gsi.tns = @gsi.tns.to_i.to_s.rjust(5,'0')\n @gsi.tng = @gsi.tng.to_i.to_s.rjust(3,'0')\n @gsi.tcp = @gsi.tcp[0..1].to_i.to_s.ljust(2,'0') + \n @gsi.tcp[2..3].to_i.to_s.ljust(2,'0') +\n @gsi.tcp[4..5].to_i.to_s.ljust(2,'0') +\n @gsi.tcp[6..7].to_i.to_s.ljust(2,'0')\n @gsi.tcf = @gsi.tcf[0..1].to_i.to_s.ljust(2,'0') +\n @gsi.tcf[2..3].to_i.to_s.ljust(2,'0') +\n @gsi.tcf[4..5].to_i.to_s.ljust(2,'0') +\n @gsi.tcf[6..7].to_i.to_s.ljust(2,'0')\n @gsi.co = @gsi.co.upcase\n end",
"def parse_header(string)\n {\n # identificação do registro header\n :tipo_registro => string[0..0].to_i,\n # identificação do arquivo retorno\n :codigo_retorno => string[1..1],\n # identificação por extenso do tipo de movimento\n :literal_retorno => string[2..8],\n # identificação do tipo de serviço\n :codigo_servico => string[9..10],\n # identificação por extenso do tipo de serviço\n :literal_servico => string[11..25],\n # agência mantenedora da conta\n :agencia => string[26..29],\n # complemento de registro\n :zeros => string[30..31],\n # número da conta corrente da empresa\n :conta => string[32..36],\n # dígito de auto-conferência ag/conta empresa\n :dac => string[37..37],\n # complemento do registro\n #:brancos1 => string[38..45],\n # nome por extenso da \"empresa mãe\"\n :nome_empresa => string[46..75],\n # número do banco na câmara de compensação\n :codigo_banco => string[76..78],\n # nome por extenso do banco cobrador\n :nome_banco => string[79..93].strip,\n # data de geração do arquivo\n :data_geracao => string[94..99],\n # unidade de densidade\n :densidade => string[100..104],\n # densidade de gravação do arquivo\n :unidade_densidade => string[105..107],\n # número sequencial do arquivo retorno\n :numero_sequencial_arquivo_retorno => string[108..112],\n # data de crédito dos lançamentos\n :data_credito => string[113..118],\n # complemento do registro\n #:brancos2 => string[119..393],\n # número sequencial do registro no arquivo\n :numero_sequencial => string[394..399]\n }\n end",
"def grab_header\n return @header if (@header and !@header.empty?)\n @file.rewind\n fields.each_with_index do |field_name, i|\n @header[i]= field_name.strip\n end\n @header\n end",
"def to_s\n [0xFF, 0xFF, 0xFF, 0xFF, @header_data, @content_data.string].pack('c5a*')\n end",
"def header(nheaders,hname)\n\t\t\tnheaders.each_line do |lh|\n\t\t\t\tn,v = lh.split(\": \")\n\t\t\t\tif n == hname\n\t\t\t\t\treturn v\n\t\t\t\tend\n\t\t\tend\n\t\t\treturn hstr\n\t\tend",
"def header_fields\n header.fields\n end",
"def frtrefheader(io)\n result = frtheader(io.read(4)) # rt, grbitFrt\n result[:ref8] = ref8u(io.read(8)) # ref8 (8 bytes): A Ref8U that references the range of cells associated with the containing record.\n result\n end",
"def print_header\n header = \"\"\n Imgrb::BmpMethods::add_bmp_bytes(header, file_size, 4)\n\n #Reserved, depends on application. Safe to set to 0s\n header << 0.chr*4\n\n #Offset. 40 (from DIB) + 14 (from header)\n Imgrb::BmpMethods::add_bmp_bytes(header, 54, 4)\n\n #Size of DIB-header\n Imgrb::BmpMethods::add_bmp_bytes(header, 40, 4)\n\n Imgrb::BmpMethods::add_bmp_bytes(header, @width, 4)\n Imgrb::BmpMethods::add_bmp_bytes(header, @height, 4)\n\n #Color planes, must be set to 1\n Imgrb::BmpMethods::add_bmp_bytes(header, 1, 2)\n\n #Bits per pixel. Always write 24-bit bmps.\n Imgrb::BmpMethods::add_bmp_bytes(header, 24, 2)\n\n #No compression\n Imgrb::BmpMethods::add_bmp_bytes(header, 0, 4)\n\n #Image size. Can be 0 for compression method 0.\n Imgrb::BmpMethods::add_bmp_bytes(header, image_size, 4)\n\n Imgrb::BmpMethods::add_bmp_bytes(header, @horizontal_res, 4)\n Imgrb::BmpMethods::add_bmp_bytes(header, @vertical_res, 4)\n\n #Default color palette\n Imgrb::BmpMethods::add_bmp_bytes(header, 0, 4)\n\n #All colors important\n Imgrb::BmpMethods::add_bmp_bytes(header, 0, 4)\n end",
"def create_file_header_and_data(path, is_payload, is_custom_payload)\r\n #print_status(\"Length of #{path}: #{path.length}\")\r\n if is_payload and is_custom_payload\r\n file_data = File.binread(path.from(72))\r\n elsif is_payload and !is_custom_payload\r\n file_data = generate_payload_exe\r\n else\r\n file_data = File.binread(File.basename(path))\r\n end\r\n\r\n file_data_crc32 = crc32(file_data).to_i\r\n\r\n # HEAD_CRC: Lower 2 bytes of CRC32 of the next bytes of header after HEAD_TYPE.\r\n # The bogus value for HEAD_CRC will be replaced later.\r\n file_header = \"\"\r\n file_header << \"AA\"\r\n # HEAD_SIZE: file header size.\r\n if is_payload\r\n file_header << [31 + path.length].pack(\"v\")\r\n else\r\n file_header << [31 + ::File.basename(path).length].pack(\"v\")\r\n end\r\n # HEAD_TYPE: header type is 1.\r\n file_header << \"\\x01\"\r\n # HEAD_FLAGS: header flags. \\x01\\x80 is ADDSIZE|SOLID.\r\n file_header << \"\\x01\\x80\"\r\n # PACK_SIZE: size when packed.\r\n file_header << [file_data.length].pack(\"V\")\r\n #print_status(\"#{file_data.length}\")\r\n # ORIG_SIZE: original size. Same as PACK_SIZE since no compression is *truly* taking place.\r\n file_header << [file_data.length].pack(\"V\")\r\n # FTIME: file date and time in MS-DOS format\r\n file_header << \"\\x63\\xB0\\x55\\x4E\"\r\n # ATTR: DOS/Windows file attribute bit field, as int, as produced by the Windows GetFileAttributes() API.\r\n file_header << \"\\x20\\x00\\x00\\x00\"\r\n # CRC32: CRC32 of the compressed file\r\n file_header << [file_data_crc32].pack(\"V\")\r\n # Compression type\r\n file_header << \"\\x00\"\r\n # Compression quality\r\n file_header << \"\\x03\"\r\n # Parameter for decompression\r\n file_header << \"\\x0A\\x00\"\r\n # RESERVED1\r\n file_header << \"\\x54\\x45\"\r\n # FNAME_SIZE: size of filename string\r\n if is_payload\r\n file_header << [path.length].pack(\"v\")\r\n else\r\n # print_status(\"#{::File.basename(path).length}\")\r\n file_header << [::File.basename(path).length].pack(\"v\")\r\n end\r\n #file_header << [path.length].pack(\"v\")\r\n # FNAME: filename string. Empty for now. Fill in later.\r\n if is_payload\r\n file_header << path\r\n else\r\n file_header << ::File.basename(path)\r\n end\r\n\r\n #print_status(\"Calculating other_file_header...\")\r\n file_header_crc32 = crc32(file_header[4, file_header.length]).to_s(16)\r\n file_header_crc16 = file_header_crc32.last(4).to_i(base=16)\r\n file_header[0,2] = [file_header_crc16].pack(\"v\")\r\n file_header << file_data\r\n end",
"def getHdr()\n\t\treturn @hdr\n\tend",
"def header_id(n)\n \"#{n.dom_id}_header\"\n end",
"def lsn_low32_header\n fil_header[:lsn] & 0xffffffff\n end",
"def size_fil_header\n 4 + 4 + 4 + 4 + 8 + 2 + 8 + 4\n end",
"def parse_header( data )\n k,v = data.split(\"\\0\", 2)\n return [k, v.delete(\"\\0\")]\n end",
"def make_tcpmsghdr(data)\r\n\t\tlen = data.length\r\n\t\t# The server doesn't like packets that are bigger...\r\n\t\traise RuntimeError, 'Length too big' if (len > 0x1000)\r\n\t\tlen /= 8\r\n\r\n\t\t# Pack the pieces in ...\r\n\t\tpkt = [\r\n\t\t\t1,0,0,0, # rep, ver, verMinor, pad\r\n\t\t\t0xb00bface, # session id (nice)\r\n\t\t\tdata.length + 16, # msg len\r\n\t\t\t0x20534d4d, # seal (\"MMS \")\r\n\t\t\tlen + 2, # chunkCount\r\n\t\t\t@pkts, 0, # seq, MBZ\r\n\t\t\trand(0xffffffff),rand(0xffffffff) # timeSent -- w/e\r\n\t\t].pack('CCCCVVVVvvVV')\r\n\r\n\t\t# Add the data\r\n\t\tpkt << data\r\n\r\n\t\t# Pad it to 8 bytes...\r\n\t\tleft = data.length % 8\r\n\t\tpkt << (\"\\x00\" * (8 - left)) if (left > 0)\r\n\r\n\t\tpkt\r\n\tend",
"def fsp_header\n @fsp_header ||= cursor(pos_fsp_header).name(\"fsp\") do |c|\n {\n :space_id => c.name(\"space_id\") { c.get_uint32 },\n :unused => c.name(\"unused\") { c.get_uint32 },\n :size => c.name(\"size\") { c.get_uint32 },\n :free_limit => c.name(\"free_limit\") { c.get_uint32 },\n :flags => c.name(\"flags\") { \n self.class.decode_flags(c.get_uint32)\n },\n :frag_n_used => c.name(\"frag_n_used\") { c.get_uint32 },\n :free => c.name(\"list[free]\") {\n Innodb::List::Xdes.new(@space, Innodb::List.get_base_node(c))\n },\n :free_frag => c.name(\"list[free_frag]\") {\n Innodb::List::Xdes.new(@space, Innodb::List.get_base_node(c))\n },\n :full_frag => c.name(\"list[full_frag]\") {\n Innodb::List::Xdes.new(@space, Innodb::List.get_base_node(c))\n },\n :first_unused_seg => c.name(\"first_unused_seg\") { c.get_uint64 },\n :full_inodes => c.name(\"list[full_inodes]\") {\n Innodb::List::Inode.new(@space, Innodb::List.get_base_node(c))\n },\n :free_inodes => c.name(\"list[free_inodes]\") {\n Innodb::List::Inode.new(@space, Innodb::List.get_base_node(c))\n },\n }\n end\n end",
"def size_index_header\n 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 8 + 2 + 8\n end",
"def header_length size\n size.to_s(16).length +\n CHUNK_SIGNATURE_HEADER.length +\n SIGNATURE_LENGTH +\n CLRF.length +\n size +\n CLRF.length\n end",
"def headerlist; return ['X-MXL-NoteHash', 'X-MXL-Hash', 'X-MX-Bounce']; end",
"def header_data\n\t\treturn self.normalized_headers.to_s\n\tend",
"def getSampleHeader()\n r = File.open(@communityFile, \"r\")\n @sampleHeader = r.gets.split(\"\\t\")[0]\n r.close()\n end",
"def read_header_file_name\n std = nil\n if !buffer_empty?\n return nil, std\n end\n\n skip_space!\n p = get_pos(0)\n if next?('\"')\n std = false\n close = '\"'\n elsif next?('<')\n std = true\n close = '>'\n else\n return nil, std\n end\n b = \"\"\n while !next?(close)\n c = readc\n if c.nil? || c == '\\n'\n raise \"#{p}: premature end of header name\"\n # errorp(p, \"premature end of header name\");\n end\n b << c\n end\n if b.size == 0\n raise \"#{p}: header name should not be empty\"\n # errorp(p, \"header name should not be empty\");\n end\n\n return b, std\n end"
] |
[
"0.7577788",
"0.7355922",
"0.6988792",
"0.6936034",
"0.6903621",
"0.6896628",
"0.68669695",
"0.6850049",
"0.68225014",
"0.67953503",
"0.6762603",
"0.66968715",
"0.65758455",
"0.6489688",
"0.6478887",
"0.6450188",
"0.64365697",
"0.6431695",
"0.63790965",
"0.63444895",
"0.6291893",
"0.62103844",
"0.62041056",
"0.62041056",
"0.6202059",
"0.61646223",
"0.61470693",
"0.60941195",
"0.6039977",
"0.60385454",
"0.60316944",
"0.60235274",
"0.5978817",
"0.5974328",
"0.5952671",
"0.5928298",
"0.5922463",
"0.5896232",
"0.5891112",
"0.58738655",
"0.5859369",
"0.5858604",
"0.58509445",
"0.58199537",
"0.5796804",
"0.57912165",
"0.5784429",
"0.5776682",
"0.5775344",
"0.57724917",
"0.5760129",
"0.5758441",
"0.5738215",
"0.57309127",
"0.57239324",
"0.5703829",
"0.56983465",
"0.5696861",
"0.56879544",
"0.5669735",
"0.56344527",
"0.5632629",
"0.5620041",
"0.56177527",
"0.56051123",
"0.5590476",
"0.5588958",
"0.55801374",
"0.55589783",
"0.55441904",
"0.5537651",
"0.55279446",
"0.5526929",
"0.55188686",
"0.5507939",
"0.5502896",
"0.54904073",
"0.54731077",
"0.54724675",
"0.546656",
"0.5449002",
"0.544106",
"0.5437807",
"0.54363203",
"0.5435244",
"0.5417497",
"0.54133755",
"0.54071",
"0.5403513",
"0.5403013",
"0.540276",
"0.5378948",
"0.53763485",
"0.53621966",
"0.5340982",
"0.53369015",
"0.53364646",
"0.53190506",
"0.53124607",
"0.53121936"
] |
0.7280266
|
2
|
Returns a pointer from a certain position.
|
def get_pointer_at(index)
IO.binread(@path, POINTER_SIZE, HEADER_SIZE + POINTER_SIZE * index).unpack("N").first
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def at(pos)\n pos = pos.to_int\n\n if 0 <= pos && !has_size?\n return read_access(pos)\n elsif 0 <= pos && pos < size\n return read_access(pos)\n elsif -size <= pos && pos < 0\n return read_access(size + pos)\n else\n return nil\n end\n end",
"def at(position)\n self[position]\n end",
"def from(position)\n self[position..-1]\n end",
"def from(position)\n self[position..-1]\n end",
"def from(position)\n self[position..-1]\n end",
"def read_pointer\n to_ptr.ptr\n end",
"def read_pointer(buffer, offset = 0)\n unpack_pointer(buffer[offset, (offset + pointer_size)])\n end",
"def to(position)\n first position + 1\n end",
"def to(position)\n first position + 1\n end",
"def to position\n self[0..position]\n end",
"def offset(off)\n return self if off == 0\n next_item.offset(off - 1)\n end",
"def at(position)\n self.class.base_class.where(\"#{scoped_position} = ?\", position).limit(1).first\n end",
"def pointer\n\n @pointer\n end",
"def get_at(point)\n board[coords_to_pos(point)]\n end",
"def pos_to_index(position)\n position[1] * 8 + position[0]\n end",
"def position_to_index(position)\n position - 1\n end",
"def at(p0) end",
"def offset(*) end",
"def offset\n 1\n end",
"def [](loc, idx)\n return loc if immediate?(idx)\n\n sequence[loc]\n end",
"def read_at (pos)\r\n @data[pos]\r\n end",
"def at(pos)\n @map[pos]\n end",
"def get_item_at(position)\n # TODO Stubbed - Required definition and implementation\n end",
"def at(offset)\n if loaded? || (offset >= 0 ? lazy_possible?(head, offset + 1) : lazy_possible?(tail, offset.abs))\n super\n elsif offset >= 0\n first(:offset => offset)\n else\n last(:offset => offset.abs - 1)\n end\n end",
"def at(index)\n\t\tx = @head\n\t\ty = 0\n\t\tuntil x == nil\n\t\t\tif y == index\n\t\t\t\treturn x\n\t\t\tend\n\t\t\ty += 1\n\t\t\tx = x.next\n\t\tend\n\tend",
"def row(position)\n position[0]\n end",
"def at(idx)\n Ruby.primitive :array_aref\n idx = Type.coerce_to idx, Fixnum, :to_int\n idx += @total if idx < 0\n\n return nil if idx < 0 or idx >= @total\n\n @tuple.at @start + idx\n end",
"def to(position)\n self[0..position]\n end",
"def to(position)\n self[0..position]\n end",
"def get_item_at(position)\n # TODO Stubbed - Required definition and implementation\n end",
"def first_offset; end",
"def first_offset; end",
"def position=(_arg0); end",
"def offset\n\t\t\t@position + @offset\n\t\tend",
"def get_at(position)\n\t\t\t\tif @head != nil && position >= 0 && position < @head.length\n\t\t\t\t\t# TODO: could be improved by looking backworkds from tail if position is nearear length than 0\n\t\t\t\t\treturn _get_at_list(@head, position)\n\t\t\t\telse\n\t\t\t\t\traise RuntimeError.new(\"The specified position is outside [0; list lenght] or the list has no elements.\")\n\t\t\t\tend\n\t\t\tend",
"def get_addr(mem, m, index, rb)\n # position mode\n if m == 0\n return mem[index]\n end\n\n # relative base mode\n if m == 2\n return mem[index] + rb\n end\n\n puts \"💥 Error, unsupported mode, abort mission 💥\"\n\n return 0\nend",
"def get_index(position:)\n row = (position - 1) / 3\n col = (position - 1) % 3\n return row, col\n end",
"def position\n if offset <= 0\n d\n\n elsif offset > dn_index\n dn_position\n\n else\n d_range[offset]\n\n end\n end",
"def node_at(pointer_like)\n current_pointer = node_context.document_location.pointer\n node_context.document.node_at(pointer_like, current_pointer)\n end",
"def node_at(pointer_like)\n current_pointer = node_context.document_location.pointer\n node_context.document.node_at(pointer_like, current_pointer)\n end",
"def node_at(pointer_like)\n current_pointer = node_context.document_location.pointer\n node_context.document.node_at(pointer_like, current_pointer)\n end",
"def pos\n @position[:current]\n end",
"def offset_to(source_position, pattern, offset = 0)\n actual_line = source_position.line - 1\n actual_offset = source_position.offset + offset - 1\n\n return nil if actual_line >= engine.lines.size\n\n actual_index = engine.lines[actual_line].index(pattern, actual_offset)\n\n actual_index && actual_index + 1 - source_position.offset\n end",
"def at(index)\n each.with_index { |v, i| return v if i == index }\n return nil\n end",
"def at(index); end",
"def offset(arg0)\n end",
"def position(index)\n return [-1, -1] unless index < string.length\n\n row_start = @line_starts.select { |line_start| line_start <= index }.last\n row = @line_starts.index(row_start)\n column = index - row_start\n [row, column]\n end",
"def get_at_index(index)\n return nil if @head.nil?\n \n pointer = @head\n count = 0\n until pointer.next.nil? || count == index\n pointer = pointer.next\n count += 1\n end\n\n return pointer.data\n end",
"def to_ptr\n @pointer\n end",
"def to_ptr\n @pointer\n end",
"def to_ptr\n @pointer\n end",
"def to_ptr\n @pointer\n end",
"def to_ptr\n @pointer\n end",
"def position(location)\n @cells[location.to_i - 1]\n end",
"def position(location)\n @cells[location.to_i - 1]\n end",
"def starting_position=(_arg0); end",
"def position; end",
"def position; end",
"def position; end",
"def position; end",
"def position; end",
"def position; end",
"def position; end",
"def position; end",
"def get_at_index(index)\r\n return nil unless @head\r\n return nil if index < 0\r\n cursor = @head\r\n index.times do\r\n return nil unless cursor.next\r\n cursor = cursor.next\r\n end\r\n return cursor.data\r\n end",
"def ptr(x)\r\n ret = Ragweed::Ptr.new(x)\r\n ret.p = self\r\n return ret\r\n end",
"def get_point(pos)\n @grid[pos[0]][pos[1]]\n end",
"def pos()\n #This is a stub, used for indexing\n end",
"def [](idx) \n if idx >= @total\n return nil\n end\n\n @tuple.at(@start + idx)\n end",
"def get_at_index(index)\n counter = 0\n pointer = @head\n return nil if @head.nil?\n until counter == index || pointer.next.nil?\n pointer = pointer.next\n counter += 1\n end\n return pointer.data\n end",
"def [](loc, idx)\n case flag(idx)\n when :immediate then loc\n when :position then read(loc)\n when :relative then read(loc + relative_base)\n end\n end",
"def ptr\n TestLab::Utility.ptr(self.address)\n end",
"def first\n @first ||= FFI::MemoryPointer.new(:pointer)\n end",
"def first\n @first ||= FFI::MemoryPointer.new(:pointer)\n end",
"def offset; end",
"def offset; end",
"def offset; end",
"def pos() @current end",
"def next_starting_position\n\t\tpos = @starting_positions[@pos_idx]\n\t\t@pos_idx = (@pos_idx + 1) % @starting_positions.length\n\t\tpos\n\tend",
"def position(pos)\n @cells[to_index(pos)]\n end",
"def at(index)\n return nil if @head.nil? \n return @head if index == 1\n return nil if index > self.size\n self.each_with_index do |current, ind|\n return current if ind == index\n end\n\n end",
"def to(position)\n self[0..position]\n end",
"def at( index )\r\n @ary.at(index + @offset)\r\n end",
"def to(position)\n self[0..position]\n end",
"def to(position)\n self[0..position]\n end",
"def pos=(p0) end",
"def pos=(p0) end",
"def pos=(p0) end",
"def pos=(p0) end",
"def first\n @cursor_instance.jump( nil )\n return current\n end",
"def find_princess_position\n position_coordinates('p')\n end",
"def to_offset(text, position); end",
"def [](position)\n raise IndexError, \"Bad position: #{position}\" unless position.between?(1,9)\n @state[position - 1]\n end",
"def at(index)\n if index >= @size\n return nil\n elsif index == 0\n return @head\n end\n search_index = @head\n index.times {\n search_index = search_index.next_node\n }\n return search_index\n end",
"def next(pointer); end",
"def next(pointer); end",
"def get_at_index(index)\n return nil if index > length\n return get_at_index_helper(index, 0, @head)\n end",
"def position\n first.position\n end",
"def at(expr, &blk)\n search(expr, &blk).first\n end",
"def find(value)\n \n index = findIndex(value)\n return nil if ! index\n result = at(index)\n\n if index == 0\n offset = value\n else\n offset = value - result[1]\n end\n \n [index, result[0], result[1], result[2], offset]\n end"
] |
[
"0.6970928",
"0.6819975",
"0.66309315",
"0.6619104",
"0.6619104",
"0.64606345",
"0.63734245",
"0.6283717",
"0.6283717",
"0.6274268",
"0.62027806",
"0.6160391",
"0.6130122",
"0.604367",
"0.6026829",
"0.60121626",
"0.599911",
"0.59691626",
"0.5967498",
"0.596382",
"0.5949572",
"0.59455764",
"0.59360516",
"0.59232605",
"0.5916188",
"0.5900885",
"0.58925974",
"0.58914465",
"0.58914465",
"0.58799255",
"0.586869",
"0.586869",
"0.58653545",
"0.5853915",
"0.5820876",
"0.5784991",
"0.57814044",
"0.5771146",
"0.57608414",
"0.57608414",
"0.57608414",
"0.57376176",
"0.5733003",
"0.57249117",
"0.57114786",
"0.57107735",
"0.5704123",
"0.570169",
"0.5699064",
"0.5699064",
"0.5699064",
"0.5699064",
"0.5699064",
"0.5697983",
"0.5697983",
"0.5694443",
"0.56904835",
"0.56904835",
"0.56904835",
"0.56904835",
"0.56904835",
"0.56904835",
"0.56904835",
"0.56904835",
"0.56855655",
"0.5674946",
"0.5674035",
"0.5671923",
"0.5666438",
"0.5665132",
"0.5660022",
"0.5657835",
"0.56553924",
"0.56553924",
"0.565155",
"0.565155",
"0.565155",
"0.5648668",
"0.56396586",
"0.5636328",
"0.5608474",
"0.5600928",
"0.5588558",
"0.55835253",
"0.55835253",
"0.55767316",
"0.55767316",
"0.55767316",
"0.55767316",
"0.5572895",
"0.5567506",
"0.55665934",
"0.5554563",
"0.55380946",
"0.55362695",
"0.55362695",
"0.5531492",
"0.55217576",
"0.55147856",
"0.55122596"
] |
0.717713
|
0
|
before_filter :redirect_unless_admin, :except => [:destroy]
|
def index
@users = User.paginate(:per_page => 9, :page => params[:page], :order => 'created_at DESC')
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def admin_required\n redirect_to(\"/\") unless admin?\n end",
"def redirect_unless_admin\n redirect_to root_path unless current_user && current_user.admin?\n end",
"def restrictToAdmin! ; redirect to('/login'),303 unless admin? ; end",
"def require_admin\n unless view_context.admin?\n redirect_to root_url\n end\n end",
"def require_admin\n redirect_to root_path unless admin_logged_in?\n end",
"def require_admin\n redirect_to(root_path) unless current_user.admin?\n end",
"def admin_user\n redirect_to(root_url) unless current_user.admin?\nend",
"def authorizeAdmin\n redirect_to '/adminlogin' unless admin_user\n end",
"def admin_user\n redirect_to(root_url) unless current_user.admin?\n end",
"def admin_user\n redirect_to recipes_path unless current_user.admin?\n end",
"def authorize_admin!\n redirect_to login_path unless current_user\n end",
"def authorize_admin!\n redirect_to home_path unless current_user&.admin\n end",
"def admin_user\n redirect_to('/') unless current_user.isadmin?\n end",
"def admin_user\n redirect_to(root_url) unless current_user.admin?\n end",
"def ensure_admin_user\n redirect_to dashboard_index_path unless is_admin?\n end",
"def admin_user\n redirect_to(root_url) unless correct_user.admin? \n end",
"def require_admin_login\n unless admin_signed_in?\n redirect_to login_url\n end\n end",
"def admin_user\n redirect_to root_url unless current_user.admin?\n end",
"def admin_user\n redirect_to root_url unless current_user.admin?\n end",
"def admin_user\n redirect_to(root_path) unless current_user.admin?\n end",
"def authorize_admin\n redirect_to(:controller => 'main', :action => 'index') and return false unless @logged_in_user.is_admin?\n end",
"def check_admin\n redirect_to new_admin_session_path unless is_admin?\n end",
"def admin_only\n unless current_user.admin?\n redirect_to :back, :alert => \"Access denied.\"\n end\n end",
"def admin_user\n redirect_to(root_url) unless current_user.admin?\n end",
"def restrict_to_admin\n unless is_admin\n flash[:danger] = \"You are not an administrator.\"\n redirect_to root_url\n end\n end",
"def require_admin\n redirect_to root_path unless @current_user.admin?\n end",
"def require_admin\n #byebug\n redirect_to user_path(current_user) unless current_user.role === \"Admin\"\n end",
"def admin_user\n redirect_to(root_url) unless current_user.admin?\n\n end",
"def admin_user\n redirect_to(root_url) unless current_user.admin?\n \n end",
"def admin_user\n redirect_to(login_path) unless current_user.is_admin?\n end",
"def admin_user\n redirect_to categories_index_url unless current_user.admin?\n end",
"def admin_only!\n\tif !current_user || !current_user.administrator\n\t\tredirect \"/\"\n\tend\nend",
"def admin_user\n redirect_to(root_url) unless current_user.admin?\n end",
"def admin_user\n redirect_to(root_url) unless current_user.admin?\n end",
"def admin_user\n redirect_to(root_url) unless current_user.admin?\n end",
"def admin_user\n redirect_to(root_url) unless current_user.admin?\n end",
"def admin_user\n redirect_to(root_url) unless current_user.admin?\n end",
"def admin_user\n redirect_to(root_url) unless current_user.admin?\n end",
"def admin_user\n redirect_to(root_url) unless current_user.admin?\n end",
"def admin_user\n redirect_to(root_url) unless current_user.admin?\n end",
"def admin_user\n redirect_to(root_url) unless current_user.admin?\n end",
"def admin_user\n redirect_to(root_url) unless current_user.admin?\n end",
"def admin_user\n redirect_to(root_url) unless current_user.admin?\n end",
"def admin_user\n redirect_to(root_url) unless current_user.admin?\n end",
"def admin_user\n redirect_to(root_url) unless current_user.admin?\n end",
"def admin_user\n redirect_to(root_url) unless current_user.admin?\n end",
"def admin_user\n redirect_to(root_url) unless current_user.admin?\n end",
"def admin_user\n redirect_to(root_url) unless current_user.admin?\n end",
"def require_admin\n if current_user.nil?\n redirect_to root_url and return\n elsif !current_user.admin?\n redirect_to root_url and return\n end\n end",
"def admin_user\n redirect_to(root_url) unless current_user.is_admin?\n end",
"def admin_user\n redirect_to(root_url) unless current_user.is_admin?\n end",
"def redirect_unless_user_is_admin\n unless current_user_is_admin?\n flash[:alert] = \"You do not have permission to view that page.\"\n redirect_to root_url\n end\n end",
"def admin_user\n redirect_to(root_path) unless current_user.admin?\n end",
"def admin_user\n redirect_to(root_path) unless current_user.admin?\n end",
"def admin_user\n redirect_to(root_path) unless current_user.admin?\n end",
"def destroy_filter\n not actuale?\n end",
"def block_admin_action\n redirect_back(fallback_location: root_path, alert: I18n.t('admin.should_not_do_action')) if current_user.admin?\n end",
"def block_admin_action\n redirect_back(fallback_location: root_path, alert: I18n.t('admin.should_not_do_action')) if current_user.admin?\n end",
"def require_admin!\n return if user_signed_in? && current_user.admin?\n\n flash[:error] = t('flash.no_permission')\n redirect_to_root\n end",
"def authorize_admin\n redirect_to root_path, notice: \"You don't have access to admin pages.\" if !current_user.admin?\n end",
"def check_admin\n redirect_to root_path unless current_user.has_role? :admin\n end",
"def must_be_authenticated!\n unless current_admin\n redirect_to :controller => 'home', :action => 'index'\n end\n end",
"def admin!\n redirect_to root_path, alert: \"Not authorized\" and return unless is_admin?\n end",
"def admin_only\n return if admin_user?\n\n add_message 'Insufficient permission to view page'\n redirect_to '/'\n end",
"def user_is_admin\n redirect_to root_path unless current_user && current_user.is_admin?\n end",
"def admin_user\n # redirect_to(root_url) unless\n current_user.admin?\n end",
"def admin_user\n redirect_to(root_url) unless current_user.admin? \n end",
"def Usuario_noAdmin\n redirect_to(root_url) if current_usuario.admin?\n end",
"def admin_user\n redirect_to(admin_page_url) if current_user.admin?\n end",
"def redirect_if_not_an_admin\n return if current_user.admin?\n flash[:danger] = 'Access denied.'\n redirect_to root_path\n end",
"def ensure_author_is_admin\n unless current_author_is_admin?\n redirect_to :root\n end \n end",
"def admin_user\n render_forbidden unless current_user.admin?\n end",
"def require_admin\n if user_signed_in?\n unless current_user.is_admin?\n redirect_to root_path\n end\n end\n end",
"def authorize_admin\n return unless !current_admin\n redirect_to root_path, alert: 'Admins only!'\n end",
"def admin_only\n @user = current_user\n if @user.role != \"admin\"\n redirect_to root_path\n end\n end",
"def admin_user\n redirect_to(root_url) unless current_user && current_user.admin?\n end",
"def protected!\n redirect '/login' if current_user.nil?\n redirect '/admin' if current_user.name == \"admin\"\n end",
"def admin_required\n if current_user && current_user.admin\n return\n end\n redirect_to \"/login\", notice: 'Logga in som administratör.'\n end",
"def admin_only\n if !Volt.current_user.admin\n redirect_to '/login'\n end\n end",
"def check_admin\n redirect_to :root unless current_user.admin?\n end",
"def authorize_admin\n return unless current_user.admin?\n redirect_to root_path, alert: 'Admins only!'\n end",
"def redirect_to_home_if_user_requests_admin\n if params[:controller].scan(/^rails_admin/).length > 0\n unless user_signed_in? && current_user.role == 'admin' \n redirect_to \"/#{I18n.locale}\"\n end\n end\n end",
"def authorize_admin\n redirect_to root_path, flash: {:error => \"User don't have admin privileges\"} unless isAdmin?\n end",
"def require_admin!\n authenticate_user!\n\n if current_user && !current_user.admin?\n redirect_to root_path\n end\n end",
"def require_admin!\n authenticate_user!\n\n if current_user && !current_user.admin?\n redirect_to root_path\n end\n end",
"def require_admin!\n authenticate_user!\n\n if current_user && !current_user.admin?\n redirect_to root_path\n end\n end",
"def require_admin!\n authenticate_user!\n\n if current_user && !current_user.admin?\n redirect_to root_path\n end\n end",
"def admin_user\n redirect_to(news_index_path) unless is_admin?\n end",
"def admin_user\n redirect_to(root_url) unless current_user.admin?\n end",
"def admin_only\n unless current_user.admin\n redirect_to home_path, notice: \n \"You must be an admin to perform that function!\"\n end\n end",
"def authorize_admin\n return unless !current_user.admin?\n redirect_to root_path, alert: 'Admins only!'\n end",
"def authorize_admin\n return unless !current_user.admin?\n redirect_to root_path, alert: 'Admins only!'\n end",
"def admin_user\n redirect_to(root_url) unless current_user.admin?\n end",
"def admin_user\n redirect_to(root_url) unless current_user.admin?\n end",
"def admin_user\n redirect_to(root_url) unless current_user.admin?\n end",
"def admin_user\n redirect_to(root_url) unless current_user.admin?\n end",
"def admin_user\n redirect_to(root_url) unless current_user.admin?\n end",
"def admin_user\n \t\tredirect_to(root_url) unless current_user.admin?\n \tend",
"def filter_user_is_admin\n # We aren't going to redirect on this one. Since it's an admin interface it's pretty sensitive so \n # we're going to give a \"not found\" response (security through obscurity anyone?)\n unless( user_is_admin)\n respond_to do |wants|\n wants.atom { head 404}\n wants.atomsvc { head 404}\n wants.html do\n render :file => \"#{RAILS_ROOT}/public/404.html\", :status => 404\n end\n end\n end\n end",
"def redirect_non_admins_to\n \"/\"\n end",
"def check_admin\n return redirect_to user_dashboard_path unless current_user.is_admin?\n end"
] |
[
"0.78114533",
"0.7809175",
"0.7726401",
"0.7714722",
"0.7624823",
"0.7536182",
"0.7533477",
"0.75055194",
"0.7386417",
"0.7371928",
"0.7367805",
"0.73637325",
"0.7358599",
"0.7354418",
"0.73437166",
"0.731265",
"0.7302716",
"0.7285374",
"0.7285374",
"0.72819865",
"0.7280039",
"0.72784793",
"0.7265832",
"0.72494143",
"0.7244715",
"0.7218195",
"0.7216913",
"0.72062844",
"0.7201677",
"0.7196945",
"0.7196507",
"0.7189853",
"0.7182313",
"0.7182313",
"0.7182313",
"0.7182313",
"0.7182313",
"0.7182313",
"0.7182313",
"0.7182313",
"0.7182313",
"0.7182313",
"0.7182313",
"0.7182313",
"0.7182313",
"0.7182313",
"0.7182313",
"0.71814185",
"0.7176188",
"0.71560204",
"0.71560204",
"0.7155217",
"0.7117818",
"0.7117818",
"0.7117818",
"0.7107817",
"0.7106835",
"0.7106835",
"0.71011305",
"0.7092105",
"0.7087318",
"0.7086721",
"0.70855474",
"0.70847285",
"0.70827496",
"0.7077777",
"0.70741934",
"0.70735663",
"0.70716727",
"0.7070506",
"0.705828",
"0.7056615",
"0.7043729",
"0.7039467",
"0.7036902",
"0.70365465",
"0.70319873",
"0.7029588",
"0.7025176",
"0.70242774",
"0.7022102",
"0.7009359",
"0.70057905",
"0.6999805",
"0.6999038",
"0.69990104",
"0.69990104",
"0.69951946",
"0.6991808",
"0.6988555",
"0.6986787",
"0.6986787",
"0.6983832",
"0.6983832",
"0.6983832",
"0.6983832",
"0.6983832",
"0.6979286",
"0.6978896",
"0.69780344",
"0.69741845"
] |
0.0
|
-1
|
Deoxyribonucleic acid (DNA) is a chemical found in the nucleus of cells and carries the "instructions" for the development and functioning of living organisms. In DNA strings, symbols "A" and "T" are complements of each other, as "C" and "G". You have function with one side of the DNA (string, except for Haskell); you need to get the other complementary side. DNA strand is never empty or there is no DNA at all (again, except for Haskell). DNA_strand ("ATTGC") return "TAACG" DNA_strand ("GTAT") return "CATA"
|
def DNA_strand(dna)
new_dna = ""
dna.each_char do |letter|
if letter == "A"
new_dna += "T"
elsif letter == "T"
new_dna += "A"
elsif letter == "C"
new_dna += "G"
elsif letter == "G"
new_dna += "C"
else
new_dna += letter
end
end
return new_dna
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def DNA_strand(dna)\n arr = dna.split(//)\n another_arr = Array.new\n arr.each do |chr|\n case chr\n when \"A\"\n another_arr << \"T\"\n when \"T\"\n another_arr << \"A\"\n when \"C\"\n another_arr << \"G\"\n else\n another_arr << \"C\"\n end\n end\n \"String #{dna} is #{another_arr.join}\"\nend",
"def DNA_strand(dna)\n dna.tr('ATCG', 'TAGC')\n new_strand = []\n dna.split('').each do |letter|\n if letter === 'A'\n new_strand.push('T')\n elsif letter === 'T'\n new_strand.push('A')\n elsif letter === 'C'\n new_strand.push('G')\n elsif letter === 'G'\n new_strand.push('C')\n end\n end\n return new_strand.join('')\nend",
"def DNA_strand(dna)\n n = dna.split(\"\")\n mapping = {'T' => 'A', 'A' => 'T', 'C' => 'G', 'G' => 'C'}\n # n = n.map {|e| mapping[e] || e}\n n.map! {|e| mapping[e] || e}\n n = n.join(\"\")\n return n\nend",
"def DNA_strand(dna)\n dna.tr('ATGC', 'TACG')\nend",
"def DNA_strand(dna)\n dna.tr(\"ACTG\", \"TGAC\")\nend",
"def dna_to_rna(string)\n index = 0\n rna_strand = \"\"\n while index < string.length\n if string[index] == \"G\"\n rna_strand << \"C\"\n elsif string[index] == \"C\"\n rna_strand << \"G\"\n elsif string[index] == \"T\"\n rna_strand << \"A\"\n elsif string[index] == \"A\"\n rna_strand << \"U\"\n end\n index += 1\n end\n return rna_strand\nend",
"def DNA_strand(dna)\n new_dna = ''\n dna.each_char do |x|\n case x\n when 'a'\n new_dna << 't'\n when 't'\n new_dna << 'a'\n when 'g'\n new_dna << 'c'\n when 'c'\n new_dna << 'g'\n end\nend\nputs new_dna\nend",
"def getDna (cds, seq)\n loc = cds.locations\n sbeg = loc[0].from.to_i\n send = loc[0].to.to_i\n fasta = Bio::Sequence::NA.new(seq.subseq(sbeg,send))\n position = \"#{sbeg}..#{send}\"\n if loc[0].strand == -1\n fasta.reverse_complement!\n end\n dna = Bio::Sequence.auto(fasta)\n return dna\nend",
"def getDna (cds, seq)\n loc = cds.locations\n sbeg = loc[0].from.to_i\n send = loc[0].to.to_i\n fasta = Bio::Sequence::NA.new(seq.subseq(sbeg,send))\n position = \"#{sbeg}..#{send}\"\n if loc[0].strand == -1\n fasta.reverse_complement!\n end\n dna = Bio::Sequence.auto(fasta)\n return dna\n end",
"def amino_acid (bases)\n case bases\n when /^TT[TCY]$/\n return \"F\"\n when /^TT[AGR]$/\n return \"L\"\n when /^CT.$/\n return \"L\"\n when /^AT[TCAHYWM]$/\n return \"I\"\n when \"ATG\"\n return \"M\"\n when /^GT.$/\n return \"V\"\n when /^TC.$/\n return \"S\"\n when /^CC.$/\n return \"P\"\n when /^AC.$/\n return \"T\"\n when /^GC.$/\n return \"A\"\n when /^TA[TCY]$/\n return \"Y\"\n when /^TA[AGR]$/\n return \"*\"\n when /^T[GR]A$/\n return \"*\"\n when /^CA[TCY]$/\n return \"H\"\n when /^CA[AGR]$/\n return \"Q\"\n when /^AA[TCY]$/\n return \"N\"\n when /^AA[AGR]$/\n return \"K\"\n when /^GA[TCY]$/\n return \"D\"\n when /^GA[AGR]$/\n return \"E\"\n when /^TG[TCY]$/\n return \"C\"\n when \"TGG\"\n return \"W\"\n when /^CG.$/\n return \"R\"\n when /^AG[TCY]$/\n return \"S\"\n when /^[AM]G[AGR]$/\n return \"R\"\n when /^GG.$/\n return \"G\"\n when /^[ATW][CGS][CTY]$/\n return \"S\"\n when /^[TCY]T[AGR]$/\n return \"L\"\n else\n return \"#\"\n end\n end",
"def parse_strand\n x = field_fetch('Strand', @d0)\n if x =~ /^(.+)Reverse +complement\\s*$/ then\n @strand = $1.strip\n @complement = true\n else\n @strand = x\n @complement = nil\n end\n end",
"def reverse_complement(dna_string)\n complementary = {'A' => 'T', 'T' => 'A', 'C' => 'G', 'G' => 'C'}\n complement = \"\"\n dna_string.reverse.each_char do |nucleotide|\n complement += complementary[nucleotide]\n end\n complement\nend",
"def amino_acid_2 (bases)\n bases_to_aa = []\n aa_list = []\n base1 = bases[0].to_list\n base2 = bases[1].to_list\n base3 = bases[2].to_list\n l1 = base1.size - 1\n l2 = base2.size - 1\n l3 = base3.size - 1\n (0..l1).each do |n1|\n b1 = base1[n1]\n (0..l2).each do |n2|\n b2 = base2[n2]\n (0..l3).each do |n3|\n b3 = base3[n3]\n bases_all = b1 + b2 + b3\n bases_to_aa << bases_all\n end\n end\n end\n\n bases_to_aa.each do |base|\n case base\n when /^TT[TCY]$/\n aa = \"F\"\n when /^TT[AGR]$/\n aa = \"L\"\n when /^CT.$/\n aa = \"L\"\n when /^AT[TCAHYWM]$/\n aa = \"I\"\n when \"ATG\"\n aa = \"M\"\n when /^GT.$/\n aa = \"V\"\n when /^TC.$/\n aa = \"S\"\n when /^CC.$/\n aa = \"P\"\n when /^AC.$/\n aa = \"T\"\n when /^GC.$/\n aa = \"A\"\n when /^TA[TCY]$/\n aa = \"Y\"\n when /^TA[AGR]$/\n aa = \"*\"\n when /^T[GR]A$/\n aa = \"*\"\n when /^CA[TCY]$/\n aa = \"H\"\n when /^CA[AGR]$/\n aa = \"Q\"\n when /^AA[TCY]$/\n aa = \"N\"\n when /^AA[AGR]$/\n aa = \"K\"\n when /^GA[TCY]$/\n aa = \"D\"\n when /^GA[AGR]$/\n aa = \"E\"\n when /^TG[TCY]$/\n aa = \"C\"\n when \"TGG\"\n aa = \"W\"\n when /^CG.$/\n aa = \"R\"\n when /^AG[TCY]$/\n aa = \"S\"\n when /^[AM]G[AGR]$/\n aa = \"R\"\n when /^GG.$/\n aa = \"G\"\n when /^[ATW][CGS][CTY]$/\n aa = \"S\"\n when /^[TCY]T[AGR]$/\n aa = \"L\"\n else\n aa = \"-\"\n end\n aa_list << aa\n end\n aa_out = aa_list.uniq.join\n return aa_out\n end",
"def rna_to_amino_acid(rna)\n # Protein Translation Problem: Translate an RNA string into an amino acid string.\n # Input: An RNA string Pattern and the array GeneticCode.\n # Output: The translation of Pattern into an amino acid string Peptide. \n\n r_to_c_h = rna_to_codon_hash\n # puts r_to_c_h\n i = 0\n codon_length = 3\n amino_acid = \"\"\n while (codon = rna.slice(i, codon_length)) do\n # puts codon\n # puts r_to_c_h[codon.to_sym]\n break if codon.empty?\n amino_acid += r_to_c_h[codon.to_sym].to_s\n i += codon_length\n end\n return amino_acid\n end",
"def strand\n (mrna = self.mrnas.first) ? mrna.strand : '+'\n end",
"def strand\n unless defined?(@strand); parse_strand; end\n @strand\n end",
"def validity_check\n\n if strand == '+'\n\n codon = ref_seq[0..2].map(&:last).join\n return true if codon.include?('N')\n codon == 'ATG'\n\n elsif strand == '-'\n\n codon = ref_seq[-3..-1].map(&:last).join\n return true if codon.include?('N')\n codon == 'CAT'\n\n end\n\n end",
"def all_else_dna(dna)\n # Input: A\n # Output: C G T\n # Input: C\n # Output: A G T\n dna_a = [\"A\", \"C\", \"G\", \"T\"]\n # puts dna_a.join(\" \")\n dna_a.delete(dna)\n # puts dna_a.join(\" \")\n return dna_a\n end",
"def hit_strand; @genomic.strand; end",
"def dnaSequence s\n hash, diff = Hash.new(0), Hash.new(0)\n diff[[0, 0, 0]] = 1\n\n sum = 0\n s.chars.each { |c|\n hash[c] += 1\n res = [hash['A'] - hash['C'], hash['C'] - hash['G'], hash['G'] - hash['T']]\n sum += diff[res]\n diff[res] += 1\n }\n sum\nend",
"def DNAtoRNA(dna)\n dna.gsub(\"T\", \"U\")\nend",
"def query_strand; @mrna.strand; end",
"def complement(nucleotide)\n case nucleotide\n when \"A\"\n \"T\"\n when \"T\"\n \"A\"\n when \"G\"\n \"C\"\n when \"C\"\n \"G\"\n end\nend",
"def test_genomic2cdna_fw # forward strand (variation rs67960011)\n t = Ensembl::Core::Transcript.find_by_stable_id(\"ENST00000039007\")\n assert_equal(573,t.genomic2cdna(38260562)) \n end",
"def genomic_sequence\n genome_id = params[:genome][:id]\n reference_id = params[:reference]\n strand = params[:strand].presence || '+'\n\n ref = Reference.find(:first, :conditions => {:name => reference_id, :genome_id => genome_id})\n\n if ref.present?\n seq = Bio::Sequence::NA.new(\"#{ref.sequence.sequence.to_s}\")\n start = params[:start].presence || 1\n stop = params[:end].presence || seq.length\n @subseq = seq.subseq(start.to_i, stop.to_i)\n @subseq = @subseq.reverse_complement if strand == '-'\n end\n\n id = \"#{ref.name} #{start}..#{stop} #{strand}\"\n render :text => @subseq.to_fasta(id, 60), :content_type => 'text/plain'\n end",
"def encode_peptide(genome, amino_acid)\n # We say that a DNA string Pattern encodes an amino acid string Peptide if the \n # RNA string transcribed from either Pattern or its reverse complement Pattern translates into Peptide. \n # For example, the DNA string GAAACT is transcribed into GAAACU and translated into ET. \n # The reverse complement of this DNA string, AGTTTC, is transcribed into AGUUUC and translated into SF. \n # Thus, GAAACT encodes both ET and SF.”\n\n # Peptide Encoding Problem: Find substrings of a genome encoding a given amino acid sequence.\n # Input: A DNA string Text, an amino acid string Peptide, and the array GeneticCode.\n # Output: All substrings of Text encoding Peptide (if any such substrings exist). \n\n match_dna = []\n codon_length = 3\n rna_seq_length = (amino_acid.length * codon_length)\n \n rna = dna_to_rna(genome)\n i = 0\n while (rna_seq = rna.slice(i, rna_seq_length )) do\n # puts rna_seq\n match_dna << rna_to_dna(rna_seq) if rna_peptide_match?(rna_seq, amino_acid)\n i += 1\n end\n\n rna = dna_to_rna(reverse_complement(genome))\n # puts rna\n i = 0\n while (rna_seq = rna.slice(i, rna_seq_length )) do\n # puts rna_seq\n match_dna << reverse_complement(rna_to_dna(rna_seq)) if rna_peptide_match?(rna_seq, amino_acid)\n i += 1\n end\n\n match_dna\n end",
"def getsandwich(str)\n bread = false\n inbetween= \"\"\n breadcount = 0\n (str.size-4).times do |n|\n if str[n..n+4] == 'bread'\n breadcount += 1\n end\n end\n if breadcount != 2\n return \"\"\n end\n str.size.times do |b|\n slice = str[b..b+4]\n if slice == \"bread\"\n bread = !bread\n end\n if bread == true\n inbetween += str[b]\n end\n end\n return inbetween[5...inbetween.size]\nend",
"def rna_to_dna(rna)\n rna.gsub(\"U\", \"T\")\n end",
"def dna_to_rna(dna)\n dna.gsub(\"T\", \"U\")\n end",
"def getSeqLoc seqName, seqLoc, strand, header=nil\n seq = Bio::FastaFormat.new(getGene(seqName))\n bioSeq = seq.to_biosequence()\n loc = seqLoc.split(\"..\")\n if strand.to_i == -1\n tmp_seq = Bio::Sequence::NA.new(bioSeq.subseq(loc[0].to_i,loc[1].to_i)).reverse_complement\n sequence = Bio::Sequence.new(tmp_seq)\n elsif strand.to_i == 1\n sequence = Bio::Sequence.new(bioSeq.subseq(loc[0].to_i,loc[1].to_i).to_s.downcase)\n else\n abort \"Bad Strand : 1 or -1 needed\"\n end\n if header != nil\n puts sequence.output_fasta(\"#{header}\",60)\n return sequence.output_fasta(\"#{header}\",60)\n else\n puts sequence.output_fasta(\"#{bioSeq.accessions[0]}|#{loc[0]}..#{loc[1]}|#{strand}\",60)\n return sequence.output_fasta(\"#{bioSeq.accessions[0]}|#{loc[0]}..#{loc[1]}|#{strand}\",60)\n end\n end",
"def getSeqLoc\n if ARGV.length == 4\n strand = ARGV[2]\n location = ARGV[1]\n else\n abort \"You need to specify location and strand !\"\n end\n loc = location.split(\"..\")\n bioSeq = @gbkObj.to_biosequence\n if strand.to_i == -1\n sequence = Bio::Sequence.new(bioSeq.subseq(loc[0].to_i,loc[1].to_i).reverse_complement)\n elsif strand.to_i == 1\n sequence = Bio::Sequence.new(bioSeq.subseq(loc[0].to_i,loc[1].to_i))\n else\n abort \"Bad Strand : 1 or -1 needed\"\n end\n puts sequence.output_fasta(\"#{bioSeq.accessions[0]}|#{loc[0]}..#{loc[1]}|#{strand}\",60)\n end",
"def isDNA?(fasta)\n seq = File.read(fasta, 10000).split(\"\\n\").grep(/^[^>]/).join\n seq.upcase.count(\"ACTGNU\").to_f / seq.upcase.count(\"ACDEFGHIKLMNPQRSTVWYZ\") > 0.90\nend",
"def getFtProtID\n protein_id = ARGV[1]\n protId = \"\"\n @gbkObj.each_cds do |ft|\n ftH = ft.to_hash\n ftloc = ft.locations\n if ftH[\"protein_id\"][0].include? protein_id\n gene = []\n product = []\n gene = ftH[\"gene\"] if !ftH[\"gene\"].nil?\n product = ftH[\"product\"] if !ftH[\"product\"].nil?\n protId = ftH[\"protein_id\"][0] if !ftH[\"protein_id\"].nil?\n locustag = ftH[\"locus_tag\"][0] if !ftH[\"locus_tag\"].nil?\n if ftloc[0].strand == -1\n location = \"c#{ftloc[0].from}..#{ftloc[0].to}\"\n else\n location = \"#{ftloc[0].from}..#{ftloc[0].to}\"\n end\n dna = getDna(ft,@gbkObj.to_biosequence)\n seqout = dna.output_fasta(\"#{@accession}|#{location}|#{protId}|#{locustag}|#{gene[0]}|#{product[0]}\",60)\n puts seqout\n end\n end\n end",
"def dna_to_rna(dna)\n dna.tr('T', 'U')\nend",
"def getFtsSequences\n @gb.each_cds do |ft|\n ftH = ft.to_hash\n loc = ft.locations\n loc = \"c#{ft.locations[0].to_s}\" if ft.locations[0].strand == -1\n gene = []\n product = []\n gene = ftH[\"gene\"] if !ftH[\"gene\"].nil?\n product = ftH[\"product\"] if !ftH[\"product\"].nil?\n dna = getDna(ft,@gb.to_biosequence)\n seqout = dna.output_fasta(\"#{@accession}|#{loc}|#{ftH[\"protein_id\"][0]}|#{gene[0]}|#{product[0]}|#{@org}\",60)\n puts seqout\n end\nend",
"def getSequence(seq, complement, locations)\n subseq = \"\"\n locations.each do |loc|\n if (loc.strand == 1)\n s1 = loc.from - 1\n s2 = loc.to - 1\n s = seq\n elsif (loc.strand == -1)\n s1 = seq.length - loc.from\n s2 = seq.length - loc.to\n s = complement\n else\n STDERR.printf(\"Error: I don't know how to handle #{locations}\\n\")\n exit(1)\n end\n s1, s2 = s2, s1 if s1 > s2\n subseq += s[s1..s2]\n if subseq.length == 0\n STDERR << \"Problem with \" << loc << \"\\n\"\n end\n end\n return subseq\nend",
"def to_rna\n @dna = @dna_type.tr('T', 'U')\n end",
"def rev_comp(seq) # AAAGG-G => CCCTT-T\n # remove N start and last bases\n seq = seq.sub(/^N+/, '')\n seq.sub!(/N+$/, '')\n return nil if seq.include?(\"N\".freeze)\n seq.upcase!\n seq.reverse!\n seq.tr!('ATGC'.freeze, 'TACG'.freeze)\n return seq\n end",
"def strand\n return self.seq_region_strand\n end",
"def isDNA?(fasta)\n seq = File.read(fasta, 10000).split(\"\\n\").grep(/^[^>]/).join\n seq.upcase.count(\"ACTGNU\").to_f / seq.upcase.count(\"ACDEFGHIKLMNPQRSTVWYZ\") > 0.90\nend",
"def consonants(consonants_letter)\r\n consonants = \"bcdefghjklmnpqrstvwxyz\"\r\n current_location = consonants.index(consonants_letter)\r\n new_consonants = current_location + 1\r\n if consonants.index(consonants_letter) == 21\r\n results = \"b\"\r\n else\r\n results = consonants[new_consonants]\r\n end\r\n results\r\nend",
"def dna_string(string)\n letters = string.upcase.split('')\n return_arr = []\n letters.each do |i|\n if i == 'G'\n arr = []\n arr.push('G','C')\n return_arr.push(arr)\n elsif i == 'C'\n arr = []\n arr.push('C','G')\n return_arr.push(arr)\n elsif i == 'A'\n arr = []\n arr.push('A','T')\n return_arr.push(arr)\n elsif i == 'T'\n arr = []\n arr.push('T','A')\n return_arr.push(arr)\n end\n end\n p return_arr\nend",
"def cannabinoid_abbreviation; end",
"def sequence\n return self.dna.sequence\n end",
"def const_adv(str)\n consonants = [\"b\",\"c\",\"d\",\"f\",\"g\",\"h\",\"j\",\"k\",\"l\",\"m\",\"n\",\"p\",\"q\",\"r\",\"s\",\"t\",\"v\",\"w\",\"x\",\"y\",\"z\"]\n str = str.split('')\n str_new = str.map do |char|\n if consonants.include?(char)\n consonants.rotate(1)[consonants.index(char)]\n else\n char\n end\n end\n str_new.join\nend",
"def complement?\n unless defined?(@complement); parse_strand; end\n @complement\n end",
"def location_string_from_feature(feature)\n location = feature.locations.first\n location_string = location.range.to_s\n if location.strand == -1 #negative strand\n location_string = \"complement(#{location_string})\"\n end\n location_string\nend",
"def consonant(letter)\n alphabet = \"bcdfghjklmnpqrstvwxyz\"\n alphabet2 = alphabet.chars.rotate.join('')\n each_id = alphabet.index(letter.downcase)\n next_consonant = alphabet2[each_id]\n end",
"def reverse_strand?\n @strand == '-'\n end",
"def chef_dna\n @chef_dna ||= ChefDna.new\n end",
"def get_next_consonant (consonant)\n\treturn 'b' if consonant == 'z'\n\tconsonants = 'bcdfghjklmnpqrstvwxyz'.chars\n\tconsonants[ consonants.index(consonant) + 1 ]\nend",
"def get_next_consonant (consonant)\n\treturn 'b' if consonant == 'z'\n\tconsonants = 'bcdfghjklmnpqrstvwxyz'.chars\n\tconsonants[consonants.index(consonant) + 1]\nend",
"def measure_DNA\n show do\n title \"Measure DNA Concentration\"\n check \"Elute DNA into 1.5 mL tubes by spinning at 17.0 xg for one minute, keep the columns.\"\n check \"Pipette the flow through (30 uL) onto the center of the column, spin again at 17.0 xg for one minute. Discard the columns this time.\"\n # check \"Go to B9 and nanodrop all of 1.5 mL tubes, enter DNA concentrations for all tubes in the following:\"\n table operations.start_table\n .output_item(OUTPUT)\n .get(:conc, type: 'number', heading: \"Concentration (ng/uL)\", default: 7)\n .get(:note, type: 'text', heading: \"Notes\")\n .end_table\n end\n end",
"def compute(left_strand,right_strand)\n return 0 if left_strand == right_strand\n\n left_chars = left_strand.chars\n right_chars = right_strand.chars\n\n distance = 0\n\n left_chars.each_with_index do |left_char,idx|\n right_char = right_chars[idx]\n break if right_char.nil? # ignore extra length on first strand when longer\n\n distance += 1 unless left_char == right_char\n end\n\n distance\n end",
"def get_sandwich(str)\n firstbread = false\n secondbread = false\n fillingsstart = 0\n fillingsend = 0\n str.size.times do |i|\n if firstbread == false\n split = str[i..(i + 4)]\n if split == \"bread\"\n firstbread = true\n fillingsstart = (i + 5)\n end\n end\n if firstbread == true && secondbread == false\n split2 = str[i..(i + 4)]\n if split2 == \"bread\"\n secondbread = false\n fillingsend = (i - 1)\n end\n end\n end\n return str[fillingsstart..fillingsend]\nend",
"def count_nucleotides( input )\n\n bases = {\n \"A\" => 0,\n \"C\" => 0,\n \"G\" => 0,\n \"T\" => 0,\n }\n\n dna = [ ]\n\n input.upcase.chars.each do | letter |\n if bases.key? letter\n bases[ letter ] +=1 # if letter matches than start the counter\n else\n dna.push \"#{ letter } is not a nucleotide.\" # if letter is not a match then saves letter and states that in output\n end\n\n\n end #input.chars\n\n bases.each do | key, value |\n dna.push \"#{ key }, #{ value }\"\n end\n\n puts dna\n # puts bases\n end",
"def submit_dna(sequence)\n\n\n params = Hash.new\n params['email'] = 'dunarel@gmail.com'\n params['title'] = 'test_web_service'\n params['sequence'] = sequence\n #clustalw2 specific params\n params['format'] = 'fasta' #\n params['alignment'] = 'fast' #slow\n #params['quicktree'] = 0\n params['type'] = 'dna'\n params['output'] = 'phylip'\n\n\n #call inherited\n return run_params(params)\n\n\n end",
"def read_strand(id, name)\n @strands.compact!\n Strand.new(id, name) unless @strands.map(&:id).include?(id)\n end",
"def consonant(letter)\n\talphabet = \"bcdfghjklmnpqrstvwxyz\"\n\talphabet2 = alphabet.chars.rotate.join('')\n\teach_id = alphabet.index(letter.downcase)\n\tnext_consonant = alphabet2[each_id]\nend",
"def consonant(letter)\n\talphabet = \"bcdfghjklmnpqrstvwxyz\"\n\talphabet2 = alphabet.chars.rotate.join('')\n\teach_id = alphabet.index(letter.downcase)\n\tnext_consonant = alphabet2[each_id]\nend",
"def abba(str)\n str.chars.each_cons(4)\n .select{|word| word == word.reverse and word[0] != word[1]}\n .map(&:join)\n end",
"def validate_nucleuotides!(dna)\n invalid = dna.chars.uniq - VALID_NUCLEOTIDE\n raise ArgumentError unless invalid.empty?\n end",
"def getFtsLoc\n location = ARGV[1]\n loc = location.split(\"..\")\n @gb.each_cds do |ft|\n ftH = ft.to_hash\n ftloc = ft.locations\n if ftloc[0].from == loc[0].to_i && ftloc[0].to == loc[1].to_i\n gene = []\n product = []\n gene = ftH[\"gene\"] if !ftH[\"gene\"].nil?\n product = ftH[\"product\"] if !ftH[\"product\"].nil?\n loc = \"c#{location}\" if ftloc[0].strand == -1\n dna = getDna(ft,@gb.to_biosequence)\n seqout = dna.output_fasta(\"#{@accession}|#{loc}|#{ftH[\"protein_id\"][0]}|#{gene[0]}|#{product[0]}|#{@org}\",60)\n puts seqout\n end\n end\nend",
"def getFtLocus\n locustag = ARGV[1]\n protId = \"\"\n @gbkObj.each_cds do |ft|\n ftH = ft.to_hash\n ftloc = ft.locations\n if ftH[\"locus_tag\"][0].eql? locustag\n gene = []\n product = []\n gene = ftH[\"gene\"] if !ftH[\"gene\"].nil?\n product = ftH[\"product\"] if !ftH[\"product\"].nil?\n protId = ftH[\"protein_id\"][0] if !ftH[\"protein_id\"].nil?\n locustag = ftH[\"locus_tag\"][0] if !ftH[\"locus_tag\"].nil?\n if ftloc[0].strand == -1\n location = \"c#{ftloc[0].from}..#{ftloc[0].to}\"\n else\n location = \"#{ftloc[0].from}..#{ftloc[0].to}\"\n end\n dna = getDna(ft,@gbkObj.to_biosequence)\n seqout = dna.output_fasta(\"#{@accession}|#{location}|#{protId}|#{locustag}|#{gene[0]}|#{product[0]}\",60)\n puts seqout\n end\n end\n end",
"def next_consonant(name)\n name = name.downcase\n consonants = \"bcdfghjklmnpqrstvwxyz\"\n i = 0\n consonants_changed = \"\"\n\n until i == name.length\n consonants_index = consonants.index(name[i])\n if consonants_index == nil\n consonants_changed += name[i]\n elsif consonants_index == 20\n consonants_changed += \"b\"\n else\n consonants_changed += consonants[consonants_index+1]\n end\n i = i + 1\n end\n return consonants_changed\n end",
"def query_align(seqs)\n seqtype = nil\n unless seqs.is_a?(Bio::Alignment)\n seqs = Bio::Alignment.new(seqs)\n end\n seqs.each do |s|\n if s.is_a?(Bio::Sequence::AA) then\n seqtype = 'PROTEIN'\n elsif s.is_a?(Bio::Sequence::NA) then\n seqtype = 'DNA'\n end\n break if seqtype\n end\n query_string(seqs.to_fasta(70, :avoid_same_name => true), seqtype)\n end",
"def cds_seq\n cds_length = self.coding_region_cdna_end - self.coding_region_cdna_start + 1\n \n return self.seq[(self.coding_region_cdna_start - 1), cds_length]\n end",
"def hamming_dna(dna_1, dna_2)\n hamming = 0;\n dna_1.split(\"\").each_with_index do |v, i|\n dna_2.split(\"\")[i] != v ? hamming += 1 : hamming = hamming\n end\n hamming\nend",
"def next_consonant(letter)\n\tconsonants = \"bcdfghjklmnpqrstvwxyz\"\n\tif letter == \"z\"\n\t\tnext_consonant = \"b\"\n\telse\n\tnext_consonant = consonants[consonants.index(letter) + 1]\nend\nend",
"def cdna2genomic(pos)\n #FIXME: Still have to check for when pos is outside of scope of cDNA.\n # Identify the exon we're looking at.\n exon_with_target = self.exon_for_cdna_position(pos)\n \n accumulated_position = 0\n ex = self.exons.sort_by {|e| e.seq_region_start}\n ex.reverse! if self.strand == -1\n ex.each do |exon| \n if exon == exon_with_target\n length_to_be_taken_from_exon = pos - (accumulated_position + 1)\n if self.strand == -1\n return exon.seq_region_end - length_to_be_taken_from_exon\n else\n return exon.seq_region_start + length_to_be_taken_from_exon\n end\n else\n accumulated_position += exon.length \n end\n end\n end",
"def get_sandwich(str)\n new_str = \"\"\n (str.size - 4).times do |ingred|\n slice = str[ingred..(ingred + 4)]\n if slice == \"bread\"\n new_str = str[str.index(slice) + 5..str.rindex(slice) - 1]\n end\n end\n return new_str\nend",
"def genomic2cdna(pos)\n #FIXME: Still have to check for when pos is outside of scope of cDNA.\n # Identify the exon we're looking at.\n exon_with_target = self.exon_for_genomic_position(pos)\n \n accumulated_position = 0\n ex = self.exons.sort_by {|e| e.seq_region_start}\n ex.reverse! if self.strand == -1\n ex.each do |exon|\n if exon.stable_id == exon_with_target.stable_id\n if self.strand == 1\n accumulated_position += ( pos - exon.start) +1\n else\n accumulated_position += ( exon.stop - pos ) +1\n end \n return accumulated_position\n else\n accumulated_position += exon.length \n end\n end\n return RuntimeError, \"Position outside of cDNA scope\"\n end",
"def count_nucleotides(input)\n\n bases = {\n \"A\" => 0,\n \"C\" => 0,\n \"G\" => 0,\n \"T\" => 0\n }\n\n dna = []\n\n input.upcase.chars.each do |letter|\n # puts \"#{letter}\"\n\n #version 1\n # is_nucleotides = false\n #\n # bases.each do |key, value|\n # # puts \"#{key}, #{value}\"\n #\n # if letter == key\n # bases[key] += 1\n # is_nucleotides = true\n # end\n # end #bases.each\n #\n # if is_nucleotides == false\n # dna.push \"#{letter} is not a nucleotide.\"\n # end #if\n\n #version 2\n if bases.key? letter\n bases[letter] +=1\n else\n dna.push \"#{letter} is not a nucleotide.\"\n end\n\n end #input.chars\n\n bases.each do |key, value|\n dna.push \"#{key}, #{value}\"\n end\n\n # puts bases\n puts dna\n\nend",
"def count_nucleotides dna\n bases_count = {\n 'A' => 0,\n 'C' => 0, \n 'T' => 0,\n 'G' => 0,\n }\n \n \n #\n dna.each_char do |x|\n if bases_count.key? base\n bases_count[ base ] += 1\n else \n puts \"#{base} not a valid nucleotide\"\n end # if\n end # DNA.each_char end\n\n bases_count.each do |key, val|\n puts \"#{key} : #{val}\"\n end #bases_count.each end\n \n\nend",
"def test_project_from_assembly_to_contigs_with_strand\n # This chromosomal region is covered by 4 contigs and 3 gaps\n # One of the contigs are on the reverse strand.\n assert_equal(7, @target_slices_contigs_with_strand.length)\n assert_equal('contig:Btau_4.0:AAFC03028964:90:9214:1', @target_slices_contigs_with_strand[0].display_name)\n assert_equal(Gap, @target_slices_contigs_with_strand[1].class)\n assert_equal('contig:Btau_4.0:AAFC03028959:1:1746:-1', @target_slices_contigs_with_strand[2].display_name)\n assert_equal(Gap, @target_slices_contigs_with_strand[3].class)\n assert_equal('contig:Btau_4.0:AAFC03028970:1:17365:1', @target_slices_contigs_with_strand[4].display_name)\n assert_equal(Gap, @target_slices_contigs_with_strand[5].class)\n assert_equal('contig:Btau_4.0:AAFC03028962:1:35:1', @target_slices_contigs_with_strand[6].display_name)\n end",
"def count ( nucleotide, strand )\n\tstrand.upcase.count( nucleotide )\nend",
"def forward_strand?\n @strand == '+'\n end",
"def count_nucleotides(input)\n dna = []\n\n bases = {\n \"A\" => 0,\n \"C\" => 0,\n \"T\" => 0,\n \"G\" => 0,\n }\n\n input.upcase.chars.each do |letter|\n # puts \"Checking for letter: #{letter}\"\n\n is_nucleotides = false\n\n bases.each do |key, value|\n # puts \"The key: #{key} add the value: #{value}.\"\n\n if letter == key\n bases[key] += 1\n is_nucleotides = true\n end\n end #bases.each\n\n if is_nucleotides == false\n dna.push \"#{letter} is not a nucleotide.\"\n end\n\n end #input.chars\n\n bases.each do |key, value|\n dna.push \"#{key}, #{value}\"\n end\n\n puts dna.uniq\n # puts bases\nend",
"def display_id\n organism_name = self.dnafrag.genome_db.taxon_id\n genomedb = self.dnafrag.genome_db.genome_db_id\n coord = self.dnafrag.slice.seq_region.coord_system.name\n dna_name = self.dnafrag.name\n start = self.dnafrag_start\n stop = self.dnafrag_end\n \n return \"#{organism_name}:#{genomedb}:#{coord}:#{dna_name}:#{start}:#{stop}:#{self.dnafrag_strand}\"\n \n end",
"def coding_region_cdna_start\n answer = 0\n \n self.exons.each do |exon|\n if exon == self.translation.start_exon\n answer += self.translation.seq_start\n return answer\n else\n answer += exon.length\n end\n end\n \n end",
"def get_sandwich(str)\n b = \"bread\"\n count = 0\n countb = 0\n str.size.times do |i|\n if str[i..(i+4)] == b\n countb = i - 1\n end \n end\n str.size.times do |i| \n if str[i..(i+4)] == b\n count = i + 5\n return str[count..(countb)]\n end \n end\nend",
"def get_sandwich(string) # return whatever is between the bread\n return \"\" if string.scan(/bread/).length != 2\n new_str = \"\"\n (string.size-4).times do |i|\n if string[i..i+4] == 'bread'\n val = i+5\n until string[val..val+4] == 'bread'\n new_str += string[val]\n val += 1\n end\n break\n end\n end\n return new_str\nend",
"def genome(liszt)\n=begin\n[samopen] SAM header is present: 2 sequences\n7621912 reads; of these:\n 4009241 (52.60%) were paired; of these:\n 1983557 (49.47%) aligned concordantly 0 times\n 1818685 (45.36%) aligned concordantly exactly 1 time\n 206999 (5.16%) aligned concordantly >1 times\n ----\n 1983557 pairs aligned concordantly 0 times; of these:\n 409503 (20.64%) aligned discordantly 1 time\n ----\n 1574054 pairs aligned 0 times concordantly or discordantly; of these:\n 3148108 mates make up the pairs; of these:\n 1009275 (32.06%) aligned 0 times\n 35392 (1.12%) aligned exactly 1 time\n 2103441 (66.82%) aligned >1 times\n 3612671 (47.40%) were unpaired; of these:\n 498719 (13.80%) aligned 0 times\n 2246121 (62.17%) aligned exactly 1 time\n 867831 (24.02%) aligned >1 times\n=end\n #puts(liszt);exit\n dict={}; liszt.shift\n dict[\"total\"]=liszt.shift.split[0]; #liszt.shift\n dict[\"paired\"]=liszt.shift.split[0]; liszt.shift #conc 0\n dict[\"conc_once\"]=liszt.shift.split[0]\n dict[\"conc_mult\"]=liszt.shift.split[0]\n liszt.shift(2); dict[\"disc_once\"]=\"\"; dict[\"disc_mult\"]=\"\"\n line=liszt.shift\n line.include?(\">1 times\") ? dict[\"disc_mult\"]=line.split[0] : dict[\"disc_once\"]=line.split[0]\n liszt.shift\n dict[\"unaligned_pairs\"]=liszt.shift.split[0]\n liszt.shift\n dict[\"unmates\"]=liszt.shift.split[0] #unaligned mates\n dict[\"mate_once\"]=liszt.shift.split[0]\n dict[\"mate_mult\"]=liszt.shift.split[0]\n dict[\"unpaired\"]=liszt.shift.split[0]\n dict[\"unpair_unaligned\"]=liszt.shift.split[0]\n dict[\"unpair_once\"]=liszt.shift.split[0]\n dict[\"unpair_mult\"]=liszt.shift.split[0]\n dict\nend",
"def sequence_locator(seq=\"\",temp_dir=File.dirname($0))\n hxb2_ref = \"TGGAAGGGCTAATTCACTCCCAACGAAGACAAGATATCCTTGATCTGTGGATCTACCACACACAAGGCTACTTCCCTGATTAGCAGAACTACACACCAGGGCCAGGGATCAGATATCCACTGACCTTTGGATGGTGCTACAAGCTAGTACCAGTTGAGCCAGAGAAGTTAGAAGAAGCCAACAAAGGAGAGAACACCAGCTTGTTACACCCTGTGAGCCTGCATGGAATGGATGACCCGGAGAGAGAAGTGTTAGAGTGGAGGTTTGACAGCCGCCTAGCATTTCATCACATGGCCCGAGAGCTGCATCCGGAGTACTTCAAGAACTGCTGACATCGAGCTTGCTACAAGGGACTTTCCGCTGGGGACTTTCCAGGGAGGCGTGGCCTGGGCGGGACTGGGGAGTGGCGAGCCCTCAGATCCTGCATATAAGCAGCTGCTTTTTGCCTGTACTGGGTCTCTCTGGTTAGACCAGATCTGAGCCTGGGAGCTCTCTGGCTAACTAGGGAACCCACTGCTTAAGCCTCAATAAAGCTTGCCTTGAGTGCTTCAAGTAGTGTGTGCCCGTCTGTTGTGTGACTCTGGTAACTAGAGATCCCTCAGACCCTTTTAGTCAGTGTGGAAAATCTCTAGCAGTGGCGCCCGAACAGGGACCTGAAAGCGAAAGGGAAACCAGAGGAGCTCTCTCGACGCAGGACTCGGCTTGCTGAAGCGCGCACGGCAAGAGGCGAGGGGCGGCGACTGGTGAGTACGCCAAAAATTTTGACTAGCGGAGGCTAGAAGGAGAGAGATGGGTGCGAGAGCGTCAGTATTAAGCGGGGGAGAATTAGATCGATGGGAAAAAATTCGGTTAAGGCCAGGGGGAAAGAAAAAATATAAATTAAAACATATAGTATGGGCAAGCAGGGAGCTAGAACGATTCGCAGTTAATCCTGGCCTGTTAGAAACATCAGAAGGCTGTAGACAAATACTGGGACAGCTACAACCATCCCTTCAGACAGGATCAGAAGAACTTAGATCATTATATAATACAGTAGCAACCCTCTATTGTGTGCATCAAAGGATAGAGATAAAAGACACCAAGGAAGCTTTAGACAAGATAGAGGAAGAGCAAAACAAAAGTAAGAAAAAAGCACAGCAAGCAGCAGCTGACACAGGACACAGCAATCAGGTCAGCCAAAATTACCCTATAGTGCAGAACATCCAGGGGCAAATGGTACATCAGGCCATATCACCTAGAACTTTAAATGCATGGGTAAAAGTAGTAGAAGAGAAGGCTTTCAGCCCAGAAGTGATACCCATGTTTTCAGCATTATCAGAAGGAGCCACCCCACAAGATTTAAACACCATGCTAAACACAGTGGGGGGACATCAAGCAGCCATGCAAATGTTAAAAGAGACCATCAATGAGGAAGCTGCAGAATGGGATAGAGTGCATCCAGTGCATGCAGGGCCTATTGCACCAGGCCAGATGAGAGAACCAAGGGGAAGTGACATAGCAGGAACTACTAGTACCCTTCAGGAACAAATAGGATGGATGACAAATAATCCACCTATCCCAGTAGGAGAAATTTATAAAAGATGGATAATCCTGGGATTAAATAAAATAGTAAGAATGTATAGCCCTACCAGCATTCTGGACATAAGACAAGGACCAAAGGAACCCTTTAGAGACTATGTAGACCGGTTCTATAAAACTCTAAGAGCCGAGCAAGCTTCACAGGAGGTAAAAAATTGGATGACAGAAACCTTGTTGGTCCAAAATGCGAACCCAGATTGTAAGACTATTTTAAAAGCATTGGGACCAGCGGCTACACTAGAAGAAATGATGACAGCATGTCAGGGAGTAGGAGGACCCGGCCATAAGGCAAGAGTTTTGGCTGAAGCAATGAGCCAAGTAACAAATTCAGCTACCATAATGATGCAGAGAGGCAATTTTAGGAACCAAAGAAAGATTGTTAAGTGTTTCAATTGTGGCAAAGAAGGGCACACAGCCAGAAATTGCAGGGCCCCTAGGAAAAAGGGCTGTTGGAAATGTGGAAAGGAAGGACACCAAATGAAAGATTGTACTGAGAGACAGGCTAATTTTTTAGGGAAGATCTGGCCTTCCTACAAGGGAAGGCCAGGGAATTTTCTTCAGAGCAGACCAGAGCCAACAGCCCCACCAGAAGAGAGCTTCAGGTCTGGGGTAGAGACAACAACTCCCCCTCAGAAGCAGGAGCCGATAGACAAGGAACTGTATCCTTTAACTTCCCTCAGGTCACTCTTTGGCAACGACCCCTCGTCACAATAAAGATAGGGGGGCAACTAAAGGAAGCTCTATTAGATACAGGAGCAGATGATACAGTATTAGAAGAAATGAGTTTGCCAGGAAGATGGAAACCAAAAATGATAGGGGGAATTGGAGGTTTTATCAAAGTAAGACAGTATGATCAGATACTCATAGAAATCTGTGGACATAAAGCTATAGGTACAGTATTAGTAGGACCTACACCTGTCAACATAATTGGAAGAAATCTGTTGACTCAGATTGGTTGCACTTTAAATTTTCCCATTAGCCCTATTGAGACTGTACCAGTAAAATTAAAGCCAGGAATGGATGGCCCAAAAGTTAAACAATGGCCATTGACAGAAGAAAAAATAAAAGCATTAGTAGAAATTTGTACAGAGATGGAAAAGGAAGGGAAAATTTCAAAAATTGGGCCTGAAAATCCATACAATACTCCAGTATTTGCCATAAAGAAAAAAGACAGTACTAAATGGAGAAAATTAGTAGATTTCAGAGAACTTAATAAGAGAACTCAAGACTTCTGGGAAGTTCAATTAGGAATACCACATCCCGCAGGGTTAAAAAAGAAAAAATCAGTAACAGTACTGGATGTGGGTGATGCATATTTTTCAGTTCCCTTAGATGAAGACTTCAGGAAGTATACTGCATTTACCATACCTAGTATAAACAATGAGACACCAGGGATTAGATATCAGTACAATGTGCTTCCACAGGGATGGAAAGGATCACCAGCAATATTCCAAAGTAGCATGACAAAAATCTTAGAGCCTTTTAGAAAACAAAATCCAGACATAGTTATCTATCAATACATGGATGATTTGTATGTAGGATCTGACTTAGAAATAGGGCAGCATAGAACAAAAATAGAGGAGCTGAGACAACATCTGTTGAGGTGGGGACTTACCACACCAGACAAAAAACATCAGAAAGAACCTCCATTCCTTTGGATGGGTTATGAACTCCATCCTGATAAATGGACAGTACAGCCTATAGTGCTGCCAGAAAAAGACAGCTGGACTGTCAATGACATACAGAAGTTAGTGGGGAAATTGAATTGGGCAAGTCAGATTTACCCAGGGATTAAAGTAAGGCAATTATGTAAACTCCTTAGAGGAACCAAAGCACTAACAGAAGTAATACCACTAACAGAAGAAGCAGAGCTAGAACTGGCAGAAAACAGAGAGATTCTAAAAGAACCAGTACATGGAGTGTATTATGACCCATCAAAAGACTTAATAGCAGAAATACAGAAGCAGGGGCAAGGCCAATGGACATATCAAATTTATCAAGAGCCATTTAAAAATCTGAAAACAGGAAAATATGCAAGAATGAGGGGTGCCCACACTAATGATGTAAAACAATTAACAGAGGCAGTGCAAAAAATAACCACAGAAAGCATAGTAATATGGGGAAAGACTCCTAAATTTAAACTGCCCATACAAAAGGAAACATGGGAAACATGGTGGACAGAGTATTGGCAAGCCACCTGGATTCCTGAGTGGGAGTTTGTTAATACCCCTCCCTTAGTGAAATTATGGTACCAGTTAGAGAAAGAACCCATAGTAGGAGCAGAAACCTTCTATGTAGATGGGGCAGCTAACAGGGAGACTAAATTAGGAAAAGCAGGATATGTTACTAATAGAGGAAGACAAAAAGTTGTCACCCTAACTGACACAACAAATCAGAAGACTGAGTTACAAGCAATTTATCTAGCTTTGCAGGATTCGGGATTAGAAGTAAACATAGTAACAGACTCACAATATGCATTAGGAATCATTCAAGCACAACCAGATCAAAGTGAATCAGAGTTAGTCAATCAAATAATAGAGCAGTTAATAAAAAAGGAAAAGGTCTATCTGGCATGGGTACCAGCACACAAAGGAATTGGAGGAAATGAACAAGTAGATAAATTAGTCAGTGCTGGAATCAGGAAAGTACTATTTTTAGATGGAATAGATAAGGCCCAAGATGAACATGAGAAATATCACAGTAATTGGAGAGCAATGGCTAGTGATTTTAACCTGCCACCTGTAGTAGCAAAAGAAATAGTAGCCAGCTGTGATAAATGTCAGCTAAAAGGAGAAGCCATGCATGGACAAGTAGACTGTAGTCCAGGAATATGGCAACTAGATTGTACACATTTAGAAGGAAAAGTTATCCTGGTAGCAGTTCATGTAGCCAGTGGATATATAGAAGCAGAAGTTATTCCAGCAGAAACAGGGCAGGAAACAGCATATTTTCTTTTAAAATTAGCAGGAAGATGGCCAGTAAAAACAATACATACTGACAATGGCAGCAATTTCACCGGTGCTACGGTTAGGGCCGCCTGTTGGTGGGCGGGAATCAAGCAGGAATTTGGAATTCCCTACAATCCCCAAAGTCAAGGAGTAGTAGAATCTATGAATAAAGAATTAAAGAAAATTATAGGACAGGTAAGAGATCAGGCTGAACATCTTAAGACAGCAGTACAAATGGCAGTATTCATCCACAATTTTAAAAGAAAAGGGGGGATTGGGGGGTACAGTGCAGGGGAAAGAATAGTAGACATAATAGCAACAGACATACAAACTAAAGAATTACAAAAACAAATTACAAAAATTCAAAATTTTCGGGTTTATTACAGGGACAGCAGAAATCCACTTTGGAAAGGACCAGCAAAGCTCCTCTGGAAAGGTGAAGGGGCAGTAGTAATACAAGATAATAGTGACATAAAAGTAGTGCCAAGAAGAAAAGCAAAGATCATTAGGGATTATGGAAAACAGATGGCAGGTGATGATTGTGTGGCAAGTAGACAGGATGAGGATTAGAACATGGAAAAGTTTAGTAAAACACCATATGTATGTTTCAGGGAAAGCTAGGGGATGGTTTTATAGACATCACTATGAAAGCCCTCATCCAAGAATAAGTTCAGAAGTACACATCCCACTAGGGGATGCTAGATTGGTAATAACAACATATTGGGGTCTGCATACAGGAGAAAGAGACTGGCATTTGGGTCAGGGAGTCTCCATAGAATGGAGGAAAAAGAGATATAGCACACAAGTAGACCCTGAACTAGCAGACCAACTAATTCATCTGTATTACTTTGACTGTTTTTCAGACTCTGCTATAAGAAAGGCCTTATTAGGACACATAGTTAGCCCTAGGTGTGAATATCAAGCAGGACATAACAAGGTAGGATCTCTACAATACTTGGCACTAGCAGCATTAATAACACCAAAAAAGATAAAGCCACCTTTGCCTAGTGTTACGAAACTGACAGAGGATAGATGGAACAAGCCCCAGAAGACCAAGGGCCACAGAGGGAGCCACACAATGAATGGACACTAGAGCTTTTAGAGGAGCTTAAGAATGAAGCTGTTAGACATTTTCCTAGGATTTGGCTCCATGGCTTAGGGCAACATATCTATGAAACTTATGGGGATACTTGGGCAGGAGTGGAAGCCATAATAAGAATTCTGCAACAACTGCTGTTTATCCATTTTCAGAATTGGGTGTCGACATAGCAGAATAGGCGTTACTCGACAGAGGAGAGCAAGAAATGGAGCCAGTAGATCCTAGACTAGAGCCCTGGAAGCATCCAGGAAGTCAGCCTAAAACTGCTTGTACCAATTGCTATTGTAAAAAGTGTTGCTTTCATTGCCAAGTTTGTTTCATAACAAAAGCCTTAGGCATCTCCTATGGCAGGAAGAAGCGGAGACAGCGACGAAGAGCTCATCAGAACAGTCAGACTCATCAAGCTTCTCTATCAAAGCAGTAAGTAGTACATGTAACGCAACCTATACCAATAGTAGCAATAGTAGCATTAGTAGTAGCAATAATAATAGCAATAGTTGTGTGGTCCATAGTAATCATAGAATATAGGAAAATATTAAGACAAAGAAAAATAGACAGGTTAATTGATAGACTAATAGAAAGAGCAGAAGACAGTGGCAATGAGAGTGAAGGAGAAATATCAGCACTTGTGGAGATGGGGGTGGAGATGGGGCACCATGCTCCTTGGGATGTTGATGATCTGTAGTGCTACAGAAAAATTGTGGGTCACAGTCTATTATGGGGTACCTGTGTGGAAGGAAGCAACCACCACTCTATTTTGTGCATCAGATGCTAAAGCATATGATACAGAGGTACATAATGTTTGGGCCACACATGCCTGTGTACCCACAGACCCCAACCCACAAGAAGTAGTATTGGTAAATGTGACAGAAAATTTTAACATGTGGAAAAATGACATGGTAGAACAGATGCATGAGGATATAATCAGTTTATGGGATCAAAGCCTAAAGCCATGTGTAAAATTAACCCCACTCTGTGTTAGTTTAAAGTGCACTGATTTGAAGAATGATACTAATACCAATAGTAGTAGCGGGAGAATGATAATGGAGAAAGGAGAGATAAAAAACTGCTCTTTCAATATCAGCACAAGCATAAGAGGTAAGGTGCAGAAAGAATATGCATTTTTTTATAAACTTGATATAATACCAATAGATAATGATACTACCAGCTATAAGTTGACAAGTTGTAACACCTCAGTCATTACACAGGCCTGTCCAAAGGTATCCTTTGAGCCAATTCCCATACATTATTGTGCCCCGGCTGGTTTTGCGATTCTAAAATGTAATAATAAGACGTTCAATGGAACAGGACCATGTACAAATGTCAGCACAGTACAATGTACACATGGAATTAGGCCAGTAGTATCAACTCAACTGCTGTTAAATGGCAGTCTAGCAGAAGAAGAGGTAGTAATTAGATCTGTCAATTTCACGGACAATGCTAAAACCATAATAGTACAGCTGAACACATCTGTAGAAATTAATTGTACAAGACCCAACAACAATACAAGAAAAAGAATCCGTATCCAGAGAGGACCAGGGAGAGCATTTGTTACAATAGGAAAAATAGGAAATATGAGACAAGCACATTGTAACATTAGTAGAGCAAAATGGAATAACACTTTAAAACAGATAGCTAGCAAATTAAGAGAACAATTTGGAAATAATAAAACAATAATCTTTAAGCAATCCTCAGGAGGGGACCCAGAAATTGTAACGCACAGTTTTAATTGTGGAGGGGAATTTTTCTACTGTAATTCAACACAACTGTTTAATAGTACTTGGTTTAATAGTACTTGGAGTACTGAAGGGTCAAATAACACTGAAGGAAGTGACACAATCACCCTCCCATGCAGAATAAAACAAATTATAAACATGTGGCAGAAAGTAGGAAAAGCAATGTATGCCCCTCCCATCAGTGGACAAATTAGATGTTCATCAAATATTACAGGGCTGCTATTAACAAGAGATGGTGGTAATAGCAACAATGAGTCCGAGATCTTCAGACCTGGAGGAGGAGATATGAGGGACAATTGGAGAAGTGAATTATATAAATATAAAGTAGTAAAAATTGAACCATTAGGAGTAGCACCCACCAAGGCAAAGAGAAGAGTGGTGCAGAGAGAAAAAAGAGCAGTGGGAATAGGAGCTTTGTTCCTTGGGTTCTTGGGAGCAGCAGGAAGCACTATGGGCGCAGCCTCAATGACGCTGACGGTACAGGCCAGACAATTATTGTCTGGTATAGTGCAGCAGCAGAACAATTTGCTGAGGGCTATTGAGGCGCAACAGCATCTGTTGCAACTCACAGTCTGGGGCATCAAGCAGCTCCAGGCAAGAATCCTGGCTGTGGAAAGATACCTAAAGGATCAACAGCTCCTGGGGATTTGGGGTTGCTCTGGAAAACTCATTTGCACCACTGCTGTGCCTTGGAATGCTAGTTGGAGTAATAAATCTCTGGAACAGATTTGGAATCACACGACCTGGATGGAGTGGGACAGAGAAATTAACAATTACACAAGCTTAATACACTCCTTAATTGAAGAATCGCAAAACCAGCAAGAAAAGAATGAACAAGAATTATTGGAATTAGATAAATGGGCAAGTTTGTGGAATTGGTTTAACATAACAAATTGGCTGTGGTATATAAAATTATTCATAATGATAGTAGGAGGCTTGGTAGGTTTAAGAATAGTTTTTGCTGTACTTTCTATAGTGAATAGAGTTAGGCAGGGATATTCACCATTATCGTTTCAGACCCACCTCCCAACCCCGAGGGGACCCGACAGGCCCGAAGGAATAGAAGAAGAAGGTGGAGAGAGAGACAGAGACAGATCCATTCGATTAGTGAACGGATCCTTGGCACTTATCTGGGACGATCTGCGGAGCCTGTGCCTCTTCAGCTACCACCGCTTGAGAGACTTACTCTTGATTGTAACGAGGATTGTGGAACTTCTGGGACGCAGGGGGTGGGAAGCCCTCAAATATTGGTGGAATCTCCTACAGTATTGGAGTCAGGAACTAAAGAATAGTGCTGTTAGCTTGCTCAATGCCACAGCCATAGCAGTAGCTGAGGGGACAGATAGGGTTATAGAAGTAGTACAAGGAGCTTGTAGAGCTATTCGCCACATACCTAGAAGAATAAGACAGGGCTTGGAAAGGATTTTGCTATAAGATGGGTGGCAAGTGGTCAAAAAGTAGTGTGATTGGATGGCCTACTGTAAGGGAAAGAATGAGACGAGCTGAGCCAGCAGCAGATAGGGTGGGAGCAGCATCTCGAGACCTGGAAAAACATGGAGCAATCACAAGTAGCAATACAGCAGCTACCAATGCTGCTTGTGCCTGGCTAGAAGCACAAGAGGAGGAGGAGGTGGGTTTTCCAGTCACACCTCAGGTACCTTTAAGACCAATGACTTACAAGGCAGCTGTAGATCTTAGCCACTTTTTAAAAGAAAAGGGGGGACTGGAAGGGCTAATTCACTCCCAAAGAAGACAAGATATCCTTGATCTGTGGATCTACCACACACAAGGCTACTTCCCTGATTAGCAGAACTACACACCAGGGCCAGGGGTCAGATATCCACTGACCTTTGGATGGTGCTACAAGCTAGTACCAGTTGAGCCAGATAAGATAGAAGAGGCCAATAAAGGAGAGAACACCAGCTTGTTACACCCTGTGAGCCTGCATGGGATGGATGACCCGGAGAGAGAAGTGTTAGAGTGGAGGTTTGACAGCCGCCTAGCATTTCATCACGTGGCCCGAGAGCTGCATCCGGAGTACTTCAAGAACTGCTGACATCGAGCTTGCTACAAGGGACTTTCCGCTGGGGACTTTCCAGGGAGGCGTGGCCTGGGCGGGACTGGGGAGTGGCGAGCCCTCAGATCCTGCATATAAGCAGCTGCTTTTTGCCTGTACTGGGTCTCTCTGGTTAGACCAGATCTGAGCCTGGGAGCTCTCTGGCTAACTAGGGAACCCACTGCTTAAGCCTCAATAAAGCTTGCCTTGAGTGCTTCAAGTAGTGTGTGCCCGTCTGTTGTGTGACTCTGGTAACTAGAGATCCCTCAGACCCTTTTAGTCAGTGTGGAAAATCTCTAGCA\"\n hxb2_l = hxb2_ref.size\n head = \"\"\n 8.times {head << (65 + rand(25)).chr}\n temp_file = temp_dir + \"/\" + head + \"_temp\"\n temp_aln = temp_dir + \"/\" + head + \"_temp_aln\"\n\n l1 = 0\n l2 = 0\n name = \">test\"\n temp_in = File.open(temp_file,\"w\")\n temp_in.puts \">ref\"\n temp_in.puts hxb2_ref\n temp_in.puts name\n temp_in.puts seq\n temp_in.close\n\n begin\n print `muscle -in #{temp_file} -out #{temp_aln} -quiet`\n aln_seq = fasta_to_hash(temp_aln)\n aln_test = aln_seq[name]\n aln_test =~ /^(\\-*)(\\w.*\\w)(\\-*)$/\n gap_begin = $1.size\n gap_end = $3.size\n aln_test2 = $2\n ref = aln_seq[\">ref\"]\n ref = ref[gap_begin..(-gap_end-1)]\n ref_size = ref.size\n if ref_size > 1.3*(seq.size)\n l1 = l1 + gap_begin\n l2 = l2 + gap_end\n max_seq = aln_test2.scan(/[ACGT]+/).max_by(&:length)\n aln_test2 =~ /#{max_seq}/\n before_aln_seq = $`\n before_aln = $`.size\n post_aln_seq = $'\n post_aln = $'.size\n before_aln_seq_size = before_aln_seq.scan(/[ACGT]+/).join(\"\").size\n b1 = (1.3 * before_aln_seq_size).to_i\n post_aln_seq_size = post_aln_seq.scan(/[ACGT]+/).join(\"\").size\n b2 = (1.3 * post_aln_seq_size).to_i\n if (before_aln > seq.size) and (post_aln <= seq.size)\n ref = ref[(before_aln - b1)..(ref_size - post_aln - 1)]\n l1 = l1 + (before_aln - b1)\n elsif (post_aln > seq.size) and (before_aln <= seq.size)\n ref = ref[before_aln..(ref_size - post_aln - 1 + b2)]\n l2 = l2 + post_aln - b2\n elsif (post_aln > seq.size) and (before_aln > seq.size)\n ref = ref[(before_aln - b1)..(ref_size - post_aln - 1 + b2)]\n l1 = l1 + (before_aln - b1)\n l2 = l2 + (post_aln - b2)\n end\n temp_in = File.open(temp_file,\"w\")\n temp_in.puts \">ref\"\n temp_in.puts ref\n temp_in.puts name\n temp_in.puts seq\n temp_in.close\n print `muscle -in #{temp_file} -out #{temp_aln} -quiet`\n aln_seq = fasta_to_hash(temp_aln)\n aln_test = aln_seq[name]\n aln_test =~ /^(\\-*)(\\w.*\\w)(\\-*)$/\n gap_begin = $1.size\n gap_end = $3.size\n aln_test2 = $2\n ref = aln_seq[\">ref\"]\n ref = ref[gap_begin..(-gap_end-1)]\n ref_size = ref.size\n end\n aln_seq = fasta_to_hash(temp_aln)\n aln_test = aln_seq[name]\n aln_test =~ /^(\\-*)(\\w.*\\w)(\\-*)$/\n gap_begin = $1.size\n gap_end = $3.size\n aln_test = $2\n aln_test =~ /^(\\w+)(\\-*)\\w/\n s1 = $1.size\n g1 = $2.size\n aln_test =~ /\\w(\\-*)(\\w+)$/\n s2 = $2.size\n g2 = $1.size\n ref = aln_seq[\">ref\"]\n ref = ref[gap_begin..(-gap_end-1)]\n\n l1 = l1 + gap_begin\n l2 = l2 + gap_end\n repeat = 0\n\n if g1 == g2 and (s1 + g1 + s2) == ref.size\n if s1 > s2 and g2 > 2*s2\n ref = ref[0..(-g2-1)]\n repeat = 1\n l2 = l2 + g2\n elsif s1 < s2 and g1 > 2*s1\n ref = ref[g1..-1]\n repeat = 1\n l1 = l1 + g1\n end\n else\n if g1 > 2*s1\n ref = ref[g1..-1]\n repeat = 1\n l1 = l1 + g1\n end\n if g2 > 2*s2\n ref = ref[0..(-g2 - 1)]\n repeat = 1\n l2 = l2 + g2\n end\n end\n\n while repeat == 1\n temp_in = File.open(temp_file,\"w\")\n temp_in.puts \">ref\"\n temp_in.puts ref\n temp_in.puts name\n temp_in.puts seq\n temp_in.close\n print `muscle -in #{temp_file} -out #{temp_aln} -quiet`\n aln_seq = fasta_to_hash(temp_aln)\n aln_test = aln_seq[name]\n aln_test =~ /^(\\-*)(\\w.*\\w)(\\-*)$/\n gap_begin = $1.size\n gap_end = $3.size\n aln_test = $2\n aln_test =~ /^(\\w+)(\\-*)\\w/\n s1 = $1.size\n g1 = $2.size\n aln_test =~ /\\w(\\-*)(\\w+)$/\n s2 = $2.size\n g2 = $1.size\n ref = aln_seq[\">ref\"]\n ref = ref[gap_begin..(-gap_end-1)]\n l1 = l1 + gap_begin\n l2 = l2 + gap_end\n repeat = 0\n if g1 > 2*s1\n ref = ref[g1..-1]\n repeat = 1\n l1 = l1 + g1\n end\n if g2 > 2*s2\n ref = ref[0..(-g2 - 1)]\n repeat = 1\n l2 = l2 + g2\n end\n end\n ref = hxb2_ref[l1..(hxb2_l - l2 - 1)]\n\n temp_in = File.open(temp_file,\"w\")\n temp_in.puts \">ref\"\n temp_in.puts ref\n temp_in.puts name\n temp_in.puts seq\n temp_in.close\n print `muscle -in #{temp_file} -out #{temp_aln} -quiet`\n aln_seq = fasta_to_hash(temp_aln)\n aln_test = aln_seq[name]\n ref = aln_seq[\">ref\"]\n\n #refine alignment\n\n if ref =~ /^(\\-+)/\n l1 = l1 - $1.size\n elsif ref =~ /(\\-+)$/\n l2 = l2 + $1.size\n end\n\n if (hxb2_l - l2 - 1) >= l1\n ref = hxb2_ref[l1..(hxb2_l - l2 - 1)]\n temp_in = File.open(temp_file,\"w\")\n temp_in.puts \">ref\"\n temp_in.puts ref\n temp_in.puts name\n temp_in.puts seq\n temp_in.close\n print `muscle -in #{temp_file} -out #{temp_aln} -quiet`\n aln_seq = fasta_to_hash(temp_aln)\n aln_test = aln_seq[name]\n ref = aln_seq[\">ref\"]\n\n ref_size = ref.size\n sim_count = 0\n (0..(ref_size-1)).each do |n|\n ref_base = ref[n]\n test_base = aln_test[n]\n sim_count += 1 if ref_base == test_base\n end\n similarity = (sim_count/ref_size.to_f*100).round(1)\n print `rm -f #{temp_file}`\n print `rm -f #{temp_aln}`\n loc_p1 = l1 + 1\n loc_p2 = hxb2_l - l2\n if seq.size != (loc_p2 - loc_p1 + 1)\n indel = true\n elsif aln_test.include?(\"-\")\n indel = true\n else\n indel = false\n end\n return [loc_p1,loc_p2,similarity,indel,aln_test,ref]\n else\n return [0,0,0,0,0,0,0]\n end\n rescue\n print `rm -f #{temp_file}`\n print `rm -f #{temp_aln}`\n return [0,0,0,0,0,0,0]\n end\nend",
"def getFtsNtSequences\n @gbkObj.each_cds do |ft|\n ftH = ft.to_hash\n loc = ft.locations\n gene = []\n product = []\n protId = \"\"\n gene = ftH[\"gene\"] if !ftH[\"gene\"].nil?\n product = ftH[\"product\"] if !ftH[\"product\"].nil?\n protId = ftH[\"protein_id\"][0] if !ftH[\"protein_id\"].nil?\n locustag = ftH[\"locus_tag\"][0] if !ftH[\"locus_tag\"].nil?\n dna = getDna(ft,@gbkObj.to_biosequence)\n seqout = dna.output_fasta(\"#{@accession}|#{loc}|#{protId}|#{locustag}|#{gene[0]}|#{product[0]}\",60)\n puts seqout\n end\n end",
"def min_distance_pattern_dna(pattern, dna)\n pattern.upcase!\n # d(Pattern,Dna) = ∑ d(Pattern,Dna[i]).\n min_dist = 0\n dna.each do |text|\n text.upcase!\n min_dist += min_distance_pattern_text(pattern, text)\n end\n return min_dist\n end",
"def poss( syn )\n cod = SITE_SYNONYMITY[nuc_codon.join]\n return [] unless cod\n\n pos_codon\n .zip(cod.split(\"\"))\n .select{|p| p.last == (syn=='syn' ? 's' : 'n')}\n .map(&:first)\n end",
"def special2csa(str)\n {\n '中断' => 'CHUDAN',\n '投了' => 'TORYO',\n '持将棋' => 'JISHOGI',\n '千日手' => 'SENNICHITE',\n '詰み' => 'TSUMI',\n '不詰' => 'FUZUMI',\n '切れ負け' => 'TIME_UP',\n '反則勝ち' => 'ILLEGAL_ACTION', # 直前の手が反則(先頭に+か-で反則した側の情報を含める必要が有る)\n '反則負け' => 'ILLEGAL_MOVE' # ここで手番側が反則,反則の内容はコメントで表現\n }[str] || (raise ParseError)\n end",
"def next_consonant(char)\n char = char.downcase\n compare = \"bcdfghjklmnpqrstvwxyz\"\n\n # not a consonant, i.e., no instance of the variable\n if compare.count(char) == 0\n # puts \"Not a consonant\"\n return nil\n end\n\n consonant_index = compare.index(char)\n\n if consonant_index == compare.length - 1 # end edge case\n return 'b'\n else\n return compare[consonant_index + 1]\n end\nend",
"def start_of_word(str,index)\n if str.length > 1\n str.slice(0,index)\n else\n alphabet= (\"a\"..\"z\").to_a\n alphabet_seq = (\"a\"..alphabet[index]).to_a\n alphabet_seq.join\n end\nend",
"def bcd2dpd(arg)\n # assign each bit to a variable, named as in the description\n a,b,c,d,e,f,g,h,i,j,k,m = (\"%012B\"%arg).split('').collect{|bit| bit.to_i}\n\n # derive the result bits, using boolean expressions only\n #-- [the operators are: '&'=AND, '|'=OR, '\\'=NOT.]\n p=b | (a & j) | (a & f & i)\n q=c | (a & k) | (a & g & i)\n r=d\n s=(f & (bitnot(a) | bitnot(i))) | (bitnot(a) & e & j) | (e & i)\n t=g | (bitnot(a) & e &k) | (a & i)\n u=h\n v=a | e | i\n w=a | (e & i) | (bitnot(e) & j)\n x=e | (a & i) | (bitnot(a) & k)\n y=m\n\n # concatenate the bits and return\n # result = [p,q,r,s,t,u,v,w,x,y].collect{|bit| bit.to_s}.inject{|aa,bb|aa+bb}.to_i(2)\n result = 0\n [p,q,r,s,t,u,v,w,x,y].each do |bit|\n result <<= 1\n result |= bit\n end\n result\nend",
"def agc_to_string(agc)\n if agc==AGC_FAST\n return(\"Fast\")\n elsif agc==AGC_SLOW\n return(\"Slow\")\n else\n return(\"Unknown\")\n end\nend",
"def get_sandwich(str)\n\n (str.size - 2).times do |i|\n slice = str[i..(i + 4)]\n if slice == \"bread\"\n slice = str[5..(str.size-6)]\n return slice\n end\n end\nend",
"def next_consonant(letter)\nconsonant = \"bcdfghjklmnpqrstvwxyz\"\ncurrent_index = consonant.index(letter)\nconsonant[current_index + 1]\n\tif letter == \"z\"\n\t\tprint \"b\"\n\telse letter == \" \"\n\t\tprint \" \"\n\tend\nend",
"def next_consonant(string)\n\tconsonants = \"bcdfghjklmnpqrstvwxyz\"\n\t#set index of string \n\tindex = 0\n\t#set index of vowels\n\ti = 0\n\t#create an empty string\n\tconverted_string = \"\"\n\t#for each index of the string, checks if equal to corresponding consonant and if so goes to the next consonant by adding one to the index\n\twhile index < string.length\n\t\t#start with if string has \"z\", converts to \"b\"\n\t\tif string[index] == consonants[20]\n\t\t\tconverted_string += \"b\"\n\t\t#if the string has any consonant besides \"z\"\n\t\telsif string[index] == consonants[i]\n\t\t\tconverted_string += consonants[i+1]\n\t\t#if string has vowels doesnt change character\n\t\telse \n\t\t\tconverted_string += string[index]\n\t\tend\n\t\t#go to next index in string\n\t\tindex += 1\n\t\t#reset vowel index to zero\n\t\ti += 1\n\tend\n\tconverted_string\nend",
"def consonant_changer(letter)\r\n\tif letter == \"z\"\r\n\t\tnew_letter = \"b\"\r\n\telsif letter == \" \"\r\n\t \tnew_letter = \" \"\r\n\telse\r\n\t\tconsonant_index = \"bcdfghjklmnpqrstvwxyz\".index(letter)\r\n \tnew_letter =\"bcdfghjklmnpqrstvwxyz\"[consonant_index.next]\r\n\tend\r\nend",
"def getSeq\n bioSeq = @gbkObj.to_biosequence\n sequence = Bio::Sequence.new(bioSeq)\n puts sequence.output_fasta(\"#{bioSeq.accessions[0]}\",60)\n end",
"def guess_sequence_type(sequence_string)\n cleaned_sequence = sequence_string.gsub(/[^A-Z]/i, '') # removing non-letter characters\n cleaned_sequence.gsub!(/[NX]/i, '') # removing ambiguous characters\n\n return nil if cleaned_sequence.length < 10 # conservative\n\n composition = composition(cleaned_sequence) \n composition_NAs = composition.select { |character, count|character.match(/[ACGTU]/i) } # only putative NAs\n putative_NA_counts = composition_NAs.collect { |key_value_array| key_value_array[1] } # only count, not char\n putative_NA_sum = putative_NA_counts.inject { |sum, n| sum + n } # count of all putative NA\n putative_NA_sum = 0 if putative_NA_sum.nil?\n\n if putative_NA_sum > (0.9 * cleaned_sequence.length)\n return :nucleotide\n else\n return :protein\n end\n end",
"def median_string(dna, k)\n # MedianString(Dna, k)\n # distance ← ∞\n # for i ←0 to 4k −1\n # Pattern ← NumberToPattern(i, k)\n # if distance > DistanceBetweenPatternAndStrings(Pattern, Dna)\n # distance ← DistanceBetweenPatternAndStrings(Pattern, Dna)\n # Median ← Pattern\n # return Median \n\n pattern = number_to_pattern(0, k)\n median = pattern\n distance = min_distance_pattern_dna(pattern, dna)\n # puts distance\n (1..(4**k-1)).each do |i|\n pattern = number_to_pattern(i, k)\n # puts \"GAC: \" + min_distance_pattern_dna(pattern, dna).to_s if pattern == \"GAC\"\n if distance > min_distance_pattern_dna(pattern, dna)\n distance = min_distance_pattern_dna(pattern, dna)\n # puts distance\n median = pattern\n end\n end\n\n return median\n end",
"def guess_type(sequence_string)\n cleaned_sequence = sequence_string.gsub(/[^A-Z]/i, '') # removing non-letter characters\n cleaned_sequence.gsub!(/[NX]/i, '') # removing ambiguous characters\n\n return nil if cleaned_sequence.length < 10 # conservative\n\n composition = composition(cleaned_sequence)\n composition_NAs = composition.select {|character, count| character.match(/[ACGTU]/i)} # only putative NAs\n putative_NA_counts = composition_NAs.collect {|key_value_array| key_value_array[1]} # only count, not char\n putative_NA_sum = putative_NA_counts.inject {|sum, n| sum + n} # count of all putative NA\n putative_NA_sum = 0 if putative_NA_sum.nil?\n\n if putative_NA_sum > (0.9 * cleaned_sequence.length)\n return :nucleotide\n else\n return :protein\n end\n end"
] |
[
"0.8217318",
"0.8165577",
"0.8039898",
"0.8033274",
"0.77156717",
"0.7475059",
"0.7097327",
"0.68559027",
"0.6777053",
"0.63311213",
"0.6179472",
"0.6169128",
"0.60611296",
"0.60525054",
"0.6024831",
"0.5999893",
"0.5912713",
"0.59122306",
"0.58293104",
"0.57746375",
"0.5745267",
"0.5698617",
"0.5663751",
"0.5606256",
"0.5573051",
"0.5569316",
"0.55121124",
"0.5444017",
"0.5429658",
"0.5427012",
"0.5370366",
"0.5341639",
"0.52827543",
"0.52686614",
"0.5261778",
"0.5255766",
"0.5252605",
"0.5234499",
"0.5230616",
"0.519349",
"0.51839066",
"0.5172631",
"0.51662",
"0.51609194",
"0.51460594",
"0.5125637",
"0.5106286",
"0.50636524",
"0.50569993",
"0.5052725",
"0.50447327",
"0.5041613",
"0.50387",
"0.502606",
"0.5008519",
"0.4987506",
"0.49828616",
"0.49796516",
"0.49780747",
"0.49780747",
"0.49754247",
"0.4965271",
"0.49447966",
"0.4936431",
"0.49325997",
"0.49277392",
"0.49229413",
"0.49117362",
"0.48941115",
"0.48905516",
"0.48776266",
"0.48749775",
"0.48503467",
"0.48482856",
"0.48325887",
"0.48225427",
"0.4774398",
"0.47689828",
"0.47614208",
"0.47610736",
"0.47301757",
"0.472962",
"0.47200578",
"0.47195822",
"0.4718739",
"0.47146547",
"0.47113615",
"0.47098684",
"0.47069505",
"0.47024646",
"0.4700978",
"0.47007206",
"0.46962768",
"0.46962094",
"0.46953523",
"0.46951684",
"0.46865508",
"0.46859896",
"0.46717367",
"0.46693942"
] |
0.8098095
|
2
|
DELETE /asignacions/1 DELETE /asignacions/1.xml
|
def destroy
@asignacionexa = Asignacionlabexa.find(params[:id])
@asignacionexa.destroy
respond_to do |format|
format.html { redirect_to(asignacionlabexas_url) }
format.xml { head :ok }
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def destroy\r\n @asignacion = Asignacion.find(params[:id])\r\n @asignacion.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_to(asignacions_url) }\r\n format.xml { head :ok }\r\n end\r\n end",
"def destroy\n @correspondenciasasignada = Correspondenciasasignada.find(params[:id])\n @correspondenciasasignada.destroy\n\n respond_to do |format|\n format.html { redirect_to(correspondenciasasignadas_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n RestClient.delete \"#{REST_API_URI}/contents/#{id}.xml\" \n self\n end",
"def destroy\n @alphasignup = Alphasignup.find(params[:id])\n @alphasignup.destroy\n\n respond_to do |format|\n format.html { redirect_to(alphasignups_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @config_xml = ConfigXml.find(params[:id])\n @config_xml.destroy\n\n respond_to do |format|\n format.html { redirect_to(config_xmls_url) }\n format.xml { head :ok }\n end\n rescue ActiveRecord::RecordNotFound => e\n prevent_access(e)\n end",
"def destroy\n @desasignado = Desasignado.find(params[:id])\n @desasignado.destroy\n\n respond_to do |format|\n format.html { redirect_to(desasignados_url) }\n format.xml { head :ok }\n end\n end",
"def netdev_resxml_delete( xml )\n top = netdev_resxml_top( xml )\n par = top.instance_variable_get(:@parent)\n par['delete'] = 'delete'\n end",
"def destroy\n @absence_request = AbsenceRequest.find(params[:id])\n @absence_request.destroy\n\n respond_to do |format|\n format.html { redirect_to(absence_requests_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @signature = Signature.find(params[:id])\n @signature.destroy rescue flash[:notice] = 'No se puede borrar la asignatura'\n\n respond_to do |format|\n format.html { redirect_to(signatures_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @aplicacion = Aplicacion.find(params[:id])\n @aplicacion.destroy\n\n respond_to do |format|\n format.html { redirect_to(aplicacions_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @envelope = Envelope.find(params[:id])\n @envelope.destroy\n\n respond_to do |format|\n format.html { redirect_to(envelopes_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @advertise = Advertise.find(params[:id])\n @advertise.destroy\n\n respond_to do |format|\n format.html { redirect_to(advertises_url) }\n format.xml { head :ok }\n end\n end",
"def delete()\n response = send_post_request(@xml_api_delete_path)\n response.is_a?(Net::HTTPSuccess) or response.is_a?(Net::HTTPRedirection)\n end",
"def destroy\n @aviso = Aviso.find(params[:id])\n @aviso.destroy\n\n respond_to do |format|\n format.html { redirect_to(avisos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @markup = Markup.find(params[:id])\n @markup.destroy\n\n respond_to do |format|\n format.html { redirect_to [@parent, :markups] }\n format.xml { head :ok }\n end\n end",
"def destroy\n @association = Association.find(params[:id])\n @association.destroy\n\n respond_to do |format|\n format.html { redirect_to(associations_url) }\n format.xml { head :ok }\n end\n end",
"def delete()\n response = send_post_request(@xml_api_delete_path)\n response.is_a?(Net::HTTPSuccess) or response.is_a?(Net::HTTPRedirection)\n end",
"def destroy\n @visarequest = Visarequest.find(params[:id])\n @visarequest.destroy\n\n respond_to do |format|\n format.html { redirect_to(visarequests_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @asistencia = Asistencia.find(params[:id])\n @asistencia.destroy\n\n respond_to do |format|\n format.html { redirect_to(asistencias_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @acre = Acre.find(params[:id])\n @acre.destroy\n\n respond_to do |format|\n format.html { redirect_to(acres_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @associate = Associate.find(params[:id])\n @associate.destroy\n\n respond_to do |format|\n format.html { redirect_to(associates_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @pdig = Pdig.find(params[:id])\n @pdig.destroy\n\n respond_to do |format|\n format.html { redirect_to(pdigs_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @conseq = Conseq.find(params[:id])\n @conseq.destroy\n\n respond_to do |format|\n format.html { redirect_to(conseqs_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @signature = Signature.find(params[:id])\n @signature.destroy\n\n respond_to do |format|\n format.html { redirect_to(signatures_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @bdig = Bdig.find(params[:id])\n @bdig.destroy\n\n respond_to do |format|\n format.html { redirect_to(bdigs_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @az_invoice = AzInvoice.find(params[:id])\n @az_invoice.destroy\n\n respond_to do |format|\n format.html { redirect_to(az_invoices_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @atividade_avaliacao = AtividadeAvaliacao.find(params[:id])\n @atividade_avaliacao.destroy\n\n respond_to do |format|\n format.html { redirect_to(atividade_avaliacaos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @ingredience = Ingredience.find(params[:id])\n @ingredience.destroy\n\n respond_to do |format|\n format.html { redirect_to(ingrediences_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @correspondenciasclase = Correspondenciasclase.find(params[:id])\n @correspondenciasclase.destroy\n\n respond_to do |format|\n format.html { redirect_to(correspondenciasclases_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @asignatura = Asignatura.find(params[:id])\n @asignatura.destroy\n\n respond_to do |format|\n format.html { redirect_to asignaturas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @asignatura = Asignatura.find(params[:id])\n @asignatura.destroy\n\n respond_to do |format|\n format.html { redirect_to asignaturas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n client = Connection::MarkLogic.new.client\n client.send_corona_request(\"/v1/documents?uri=/amandments/amandment_#{@amandment.id}.xml\", :delete)\n @amandment.destroy\n respond_to do |format|\n format.html { redirect_to home_meeting_path, notice: 'Amandman was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @arc = Arc.find(params[:id])\n @arc.destroy\n\n respond_to do |format|\n format.html { redirect_to(arcs_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @aauto = Aauto.find(params[:id])\n @aauto.destroy\n\n respond_to do |format|\n format.html { redirect_to(aautos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @adjunto = Adjunto.find(params[:id])\n @adjunto.destroy\n\n respond_to do |format|\n format.html { redirect_to(adjuntos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @atividade = Atividade.find(params[:id])\n @atividade.destroy\n\n respond_to do |format|\n format.html { redirect_to(atividades_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @association = Association.find(params[:id])\n @association.destroy\n\n respond_to do |format|\n format.html { redirect_to associations_url }\n format.xml { head :ok }\n end\n end",
"def destroy\n @genbank_file.destroy\n\n respond_to do |format|\n format.xml { head :ok }\n format.json { head :ok }\n end\n end",
"def destroy\n @vigencia = Vigencia.find(params[:id])\n @vigencia.destroy\n\n respond_to do |format|\n format.html { redirect_to(vigencias_url) }\n format.xml { head :ok }\n end\n end",
"def delete_analysis(analysis_id); rest_delete(\"#{link('analyses')}/#{analysis_id}\"); nil; end",
"def destroy\n @envelope.destroy\n\n respond_to do |format|\n format.html { redirect_to :root }\n format.json { head :ok }\n end\n end",
"def destroy\n @convenio = Convenio.find(params[:id])\n @convenio.destroy\n\n respond_to do |format|\n format.html { redirect_to(convenios_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @affiliate = Affiliate.find(params[:id])\n @affiliate.destroy\n\n respond_to do |format|\n format.html { redirect_to(affiliates_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @annex = Annex.find(params[:id])\n @annex.destroy\n\n respond_to do |format|\n format.html { redirect_to annexes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @correspondence = Correspondence.find(params[:id])\n @correspondence.destroy\n\n respond_to do |format|\n format.html { redirect_to(correspondences_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @siaikekka = Siaikekka.find(params[:id])\n @siaikekka.destroy\n\n respond_to do |format|\n format.html { redirect_to(siaikekkas_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @iguanasactualizacion = Iguanasactualizacion.find(params[:id])\n @iguanasactualizacion.destroy\n\n respond_to do |format|\n format.html { redirect_to(iguanasactualizaciones_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @aniversario = Aniversario.find(params[:id])\n @aniversario.destroy\n\n respond_to do |format|\n format.html { redirect_to(aniversarios_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @sa = Sa.find(params[:id])\n @sa.destroy\n\n respond_to do |format|\n format.html { redirect_to(sas_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @concert = Concert.find(params[:id])\n @concert.destroy\n\n respond_to do |format|\n format.html { redirect_to(concerts_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @visita = Visita.find(params[:id])\n @visita.destroy\n\n respond_to do |format|\n format.html { redirect_to(paciente_visitas_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @diagram = Diagram.find(params[:id])\n @diagram.destroy\n\n respond_to do |format|\n format.html { redirect_to(diagrams_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @certificado = Certificado.find(params[:id])\n @certificado.destroy\n\n respond_to do |format|\n format.html { redirect_to(certificados_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @aisle = Aisle.find(params[:id])\n @aisle.destroy\n\n respond_to do |format|\n format.html { redirect_to(aisles_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @child_dupa2 = ChildDupa2.find(params[:id])\n @child_dupa2.destroy\n\n respond_to do |format|\n format.html { redirect_to(child_dupa2s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @seta = Seta.find(params[:id])\n @seta.destroy\n\n respond_to do |format|\n format.html { redirect_to(setas_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @invier_acceso = InvierAcceso.find(params[:id])\n @invier_acceso.destroy\n\n respond_to do |format|\n format.html { redirect_to(invier_accesos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @expedicao = Expedicao.find(params[:id])\n @expedicao.destroy\n\n respond_to do |format|\n format.html { redirect_to(expedicoes_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @seccion = Seccion.find(params[:id])\n @seccion.destroy\n\n respond_to do |format|\n format.html { redirect_to(seccions_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @solicitation = Solicitation.find(params[:id])\n @solicitation.destroy\n\n respond_to do |format|\n format.html { redirect_to(solicitations_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @invoice = Invoice.find(params[:id])\n @invoice.destroy\n\n respond_to do |format|\n format.html { redirect_to(invoices_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @invoice = Invoice.find(params[:id])\n @invoice.destroy\n\n respond_to do |format|\n format.html { redirect_to(invoices_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @invoice = Invoice.find(params[:id])\n @invoice.destroy\n\n respond_to do |format|\n format.html { redirect_to(invoices_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @invoice = Invoice.find(params[:id])\n @invoice.destroy\n\n respond_to do |format|\n format.html { redirect_to(invoices_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @invoice = Invoice.find(params[:id])\n @invoice.destroy\n\n respond_to do |format|\n format.html { redirect_to(invoices_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @estacion = Estacion.find(params[:id])\n @estacion.destroy\n\n respond_to do |format|\n format.html { redirect_to(estaciones_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @ocupation = Ocupation.find(params[:id])\n @ocupation.destroy\n\n respond_to do |format|\n format.html { redirect_to(ocupations_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @estatu = Estatu.find(params[:id])\n @estatu.destroy\n\n respond_to do |format|\n format.html { redirect_to(estatus_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @upload_file = UploadFile.find(params[:id])\n doc_no=@upload_file.doc_no\n @upload_file.destroy\n\n respond_to do |format|\n format.html { redirect_to upload_files_url(:doc_no=>doc_no) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @especificacao = Especificacao.find(params[:id])\n @especificacao.destroy\n\n respond_to do |format|\n format.html { redirect_to(especificacaos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @invoice = Invoice.find(params[:id])\n @invoice.destroy\n\n respond_to do |format|\n format.html { redirect_to invoices_url }\n format.xml { head :ok }\n end\n end",
"def delete\n response = WebPay.client.delete(path)\n response['deleted']\n end",
"def destroy\n @aspect = Aspect.find(params[:id])\n @aspect.destroy\n\n respond_to do |format|\n format.html { redirect_to(aspects_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @representative = Representative.find(params[:id])\n @representative.destroy\n\n respond_to do |format|\n format.html { redirect_to(representatives_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @relatestagiario = Relatestagiario.find(params[:id])\n @relatestagiario.destroy\n\n respond_to do |format|\n format.html { redirect_to(relatestagiarios_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @actividad = Actividad.find(params[:id])\n @actividad.destroy\n\n respond_to do |format|\n format.html { redirect_to(actividads_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @feefile = Feefile.find(params[:id])\n directory= \"uploads\"\n path =File.join(directory,@feefile.feefilename)\n File.delete(path)\n @feefile.destroy\n \n\n respond_to do |format|\n format.html { redirect_to(feefiles_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @asignatura.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n @estudiante = Estudiante.find(params[:id])\n @estudiante.destroy\n\n respond_to do |format|\n format.html { redirect_to(estudiantes_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @estudiante = Estudiante.find(params[:id])\n @estudiante.destroy\n\n respond_to do |format|\n format.html { redirect_to(estudiantes_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @alumini = Alumini.find(params[:id])\n @alumini.destroy\n\n respond_to do |format|\n format.html { redirect_to(aluminis_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @direccion = Direccion.find(params[:id])\n @direccion.destroy\n\n respond_to do |format|\n format.html { redirect_to(direccions_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @asignacione.destroy\n respond_to do |format|\n format.html { redirect_to asignaciones_url, notice: 'Asignacione Fue destruido con éxito.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @almacen = Almacen.find(params[:id])\n @almacen.destroy\n \n respond_to do |format|\n format.html { redirect_to(almacenes_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @instituicao = Instituicao.find(params[:id])\n @instituicao.destroy\n\n respond_to do |format|\n format.html { redirect_to(instituicoes_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @documento = @externo.documentos.find(params[:id])\n @documento.destroy\n\n respond_to do |format|\n format.html { redirect_to(documentos_url(@externo)) }\n format.xml { head :ok }\n end\n end",
"def delete_trust(xml) \n if current_user \n trust_root = xml.root.get_elements('TrustRoot').first.text \n unless trust_root.empty? \n @trust = current_user.trusts.find(:first, :conditions => ['trust_root = ?', trust_root]) \n if @trust \n @trust.destroy \n return render(:text => \"<Response>success</Response>\") \n end \n end \n end \n render :text => '<Response>trust root does not exist</Response>' \n end",
"def destroy\n @omatsuri = Omatsuri.find(params[:id])\n @omatsuri.destroy\n\n respond_to do |format|\n format.html { redirect_to(omatsuris_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @activite = Activite.find(params[:id])\n @activite.destroy\n\n respond_to do |format|\n format.html { redirect_to association_activites_url(@association) }\n format.xml { head :ok }\n end\n end",
"def delete(container_name, file_name)\n validate_path_elements(container_name, file_name)\n\n client.request(\n method: :delete,\n path: \"#{container_name}/#{file_name}\",\n expected: 204\n )\n end",
"def destroy\n @inscripcione = Inscripcione.find(params[:id])\n @inscripcione.destroy\n\n respond_to do |format|\n format.html { redirect_to(inscripciones_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @abonne = Abonne.find(params[:id])\n @abonne.destroy\n\n respond_to do |format|\n format.html { redirect_to(abonnes_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @atest = Atest.find(params[:id])\n @atest.destroy\n\n respond_to do |format|\n format.html { redirect_to(atests_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @segmento = Segmento.find(params[:id])\n @segmento.destroy\n\n respond_to do |format|\n format.html { redirect_to(segmentos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @adqui = Adqui.find(params[:id])\n @adqui.destroy\n\n respond_to do |format|\n format.html { redirect_to(adquis_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @certidao = Certidao.find(params[:id])\n @certidao.destroy\n\n respond_to do |format|\n format.html { redirect_to(certidaos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @transaction_goods_taxis = Transaction::Goods::Taxe.find(params[:id])\n @transaction_goods_taxis.destroy\n\n respond_to do |format|\n format.html { redirect_to(transaction_goods_taxes_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @configuracion = Configuracion.find(params[:id])\n @configuracion.destroy\n\n respond_to do |format|\n format.html { redirect_to(configuracions_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @exammaker = Exammaker.find(params[:id])\n @exammaker.destroy\n\n respond_to do |format|\n format.html { redirect_to(exammakers_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @exammaker = Exammaker.find(params[:id])\n @exammaker.destroy\n\n respond_to do |format|\n format.html { redirect_to(exammakers_url) }\n format.xml { head :ok }\n end\n end"
] |
[
"0.7131648",
"0.67933595",
"0.6673514",
"0.6633145",
"0.6617581",
"0.6615463",
"0.6613866",
"0.655674",
"0.65266186",
"0.6502938",
"0.646792",
"0.64372283",
"0.64339435",
"0.6392215",
"0.6372797",
"0.6368019",
"0.63528043",
"0.634449",
"0.63436955",
"0.63310266",
"0.63171494",
"0.63127136",
"0.6308618",
"0.6301916",
"0.62941194",
"0.62934685",
"0.6290343",
"0.62796044",
"0.6275377",
"0.62743276",
"0.62743276",
"0.6262282",
"0.62616664",
"0.62603694",
"0.6253926",
"0.625176",
"0.624897",
"0.62437224",
"0.6240656",
"0.6233568",
"0.62297624",
"0.62295556",
"0.6220364",
"0.62179905",
"0.62118316",
"0.6207669",
"0.61979246",
"0.6193177",
"0.61887944",
"0.6186302",
"0.6180885",
"0.61769086",
"0.61767954",
"0.6172398",
"0.617238",
"0.6172257",
"0.6167233",
"0.61605877",
"0.6158326",
"0.61578095",
"0.61507815",
"0.61507815",
"0.61507815",
"0.61507815",
"0.61507815",
"0.6150569",
"0.61503226",
"0.6143838",
"0.61428833",
"0.6136753",
"0.6136512",
"0.613321",
"0.61325765",
"0.6131926",
"0.6131346",
"0.61262137",
"0.61254746",
"0.61195815",
"0.61188024",
"0.61183447",
"0.61164796",
"0.6115195",
"0.6112922",
"0.61128473",
"0.6111326",
"0.6110799",
"0.6107499",
"0.610685",
"0.6104013",
"0.610155",
"0.60996",
"0.6098709",
"0.6093659",
"0.6093347",
"0.60896707",
"0.60875386",
"0.6084018",
"0.60835624",
"0.60800534",
"0.60800534"
] |
0.67171013
|
2
|
def tool_params params.permit(:tool_name) end
|
def tool_obits
params.require(:id)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def tool_params\n params.require(:tool).permit(\n :name,\n :slug,\n :type,\n :description,\n :source_url,\n :instructions,\n :up_for_adoption\n )\n end",
"def tool_params\n params.require(:tool).permit(:name, :language, :json_spec)\n end",
"def tool_params\n params.require(:tool).permit(:name, :serial, :model, :location, :location_id, :category_id, :purchased, :cost, :value, :put_in_service, :loaner, :in_service, :retired, :condition, :annual_service, :note, :tab)\n end",
"def tool_params\n params.require(:tool).permit(:name, :description, :image, :serial, :barcode, :date_purchased, :capability, :reservable, :max_reservation_time, :category_ids=>[])\n end",
"def tool_params\n params.require(:tool).permit(:title, :link, :description, tags: [])\n end",
"def tool_part_params\n params.require(:tool_part).permit()\n end",
"def tool_params\n params.require(:tool).permit(:tool_type, :tool_model, :condition, :point_cost, :availability)\n end",
"def tool_type_params\n params.require(:tool_type).permit(:name, :description)\n end",
"def tool_params\n params.require(:tool).permit(:id, :price, :name, :brand, :model, :description, :availability, :delivery_options, :delivery_fee, :min_delivery_fee, :user_id, :photo)\n end",
"def update_tool_params\n params.require(:tool).permit(:name, :description, :def_tool_id)\n end",
"def s_tool_params\n params.require(:s_tool).permit(\n :name_id,\n :description,\n :serial_number,\n :inventory_number,\n :rfid_tag,\n :barcode_tag,\n :consist,\n :min_amount,\n :storage_place,\n :state,\n :comments,\n {s_tool_files: []}\n )\n end",
"def tooling_params\n params.require(:tooling).permit(:deliver_to, :part_type, :part_level, :commodity, :tool_source, :go1_go2_lt, :go2_t1_lt, :t1_t2_lt, :t2_t3_lt, :t3_t4_lt, :t4_linetry_lt, :raw_material_lt, :go1_1_target, :go1_1_actual, :go1_1_design_target, :go1_1_correlated, :go1_2_target, :go1_2_actual, :go2_1_actual, :go2_2_target, :go2_2_actual, :go2_2_design_target, :go2_2_correlated, :go2_3_actual, :go1_1_design_number, :go1_2_design_number, :go2_1_design_number, :go2_2_design_number, :go2_3_design_change)\n end",
"def tool_reservation_params\n params.require(:tool_reservation).permit(:person_id, :tool_id, :reservation_beginning, :reservation_ending)\n end",
"def compliance_tool_params\n params.require(:compliance_tool).permit(:customer_name, :date_of_flag, :transaction_amount_if_applicable, :notes, :customer_number, :open_or_closed)\n end",
"def which_params\n params.require(:which).permit(:name, :description)\n end",
"def technology_params\r\n params.require(:technology).permit(:name, :long_name, :link)\r\n end",
"def utility_params\n params.require(:utility).permit(:name, :icon_name, :stock_on_hand, :stock_at_full, :delete_time)\n end",
"def technology_params\n\t\t\tparams.require(:technology).permit(:name, :description)\n\t\tend",
"def navtoolhw_params\n params.fetch(:navtoolhw, {})\n params.permit(:id, :hw_class_description)\n end",
"def equipment_things_to_check_params\n params.require(:equipment_things_to_check).permit(:name)\n end",
"def software_params\n params.require(:software).permit(:name, :description)\n end",
"def software_params\n params.require(:software).permit(:name, :description)\n end",
"def kit_params\n params.require(:kit).permit(:name)\n end",
"def project_utility_params\n params.require(:project_utility).permit(:utility_id, :project_site_information_id)\n end",
"def tools_card_params\n params.require(:tools_card).permit(:employee_id, :content)\n end",
"def type_of_help_params\n params.require(:type_of_help).permit(:name)\n end",
"def equipment_profile_params\n params.require(:equipment_profile).permit(:name)\n end",
"def create\n @tool = Tool.new(tool_params)\n\n respond_to do |format|\n if @tool.save\n format.html { redirect_to @tool, notice: 'Tool was successfully created.' }\n format.json { render :show, status: :created, location: @tool }\n else\n format.html { render :new }\n format.json { render json: @tool.errors, status: :unprocessable_entity }\n end\n end\n end",
"def technology_params\n params.require(:technology).permit(:name, :url, :editor, :license, :pricing, :description, :characteristics, :tags, :files)\n end",
"def featurename_params\n params.require(:featurename).permit(:attribute)\n end",
"def prog_params\n params.require(:prog).permit(:Название, :Лицензия, :Тип_лицензии, :Лиценз_№)\n end",
"def material_params\n key = type.name.underscore.gsub('/', '_').to_sym # form will typically submit 'material/gemstone'\n params.require(key).permit(:type,\n :parent_id,\n :name_en,\n :name_zh,\n :name_pinyin,\n :description,\n :notes,\n :selectable,\n :inherit_display_name)\n end",
"def get_params\r\n #params.require(:widget).permit(:name)\r\n params.require(:widget).permit!\r\n end",
"def study_guide_params\n params.require(:study_guide).permit(:name)\n end",
"def shower_params\n params.require(:shower).permit(:welcomer)\n end",
"def maker_master_params\n params.require(:maker_master).permit(:maker_name)\n end",
"def create_program_params\n params.require(:program).permit(:name)\n end",
"def expert_params\n params.require(:expert).permit(:name, :personal_website_url)\n end",
"def real_estate_utility_params\n params.require(:real_estate_utility).permit(:name, :code, :options)\n end",
"def material_params\n params.permit(:material_type, :vendor, :process, :file,:file_url)\n end",
"def set_tool\n @tool = Tool.find(params[:id])\n end",
"def standard_params\n params.require(:standard).permit(:name, :desc)\n end",
"def wine_maker_params\n params.require(:wine_maker).permit(:name)\n end",
"def algorithm_name_params\n params.require(:algorithm_name).permit(:algorithm_name)\n end",
"def technology_params\n params.require(:technology).permit(:name, :image, :user_id)\n end",
"def shelter_params\n params.require(:shelter).permit(:name)\n end",
"def program_params\n params.require(:program).permit(:new_program)\n end",
"def create\n @tool = Tool.new(tool_params)\n\n respond_to do |format|\n if @tool.save\n format.html { redirect_to @tool; gflash :success => 'Tool was successfully created.' }\n format.json { render action: 'show', status: :created, location: @tool }\n else\n set_form_drop_down\n format.html { render action: 'new' }\n format.json { render json: @tool.errors, status: :unprocessable_entity }\n end\n end\n end",
"def command_params\n params.require(:command).permit(:name, :json)\n end",
"def machine_info_params\n params.require(:machine_info).permit(:name)\n end",
"def utility_provider_params\n params.require(:utility_provider).permit(:name, :co2_coefficient, :active)\n end",
"def water_supply_params\n params.require(:water_supply).permit(:provider, :house_id)\n end",
"def test_dep_collector_params\n params.require(:test_dep_collector).permit(:os_name)\n end",
"def method_of_use_params\n params.require(:method_of_use).permit(:name, :description, :plant_id, :path_of_plant_id)\n end",
"def dock_params\n params.require(:dock).permit(:name)\n end",
"def create\n @tool = Tool.new(params[:tool])\n\n respond_to do |format|\n if @tool.save\n format.html { redirect_to @tool, notice: 'Tool was successfully created.' }\n format.json { render json: @tool, status: :created, location: @tool }\n else\n format.html { render action: \"new\" }\n format.json { render json: @tool.errors, status: :unprocessable_entity }\n end\n end\n end",
"def mineral_params\n params.require(:mineral).permit(:name)\n end",
"def plant_params\n params.require(:plant).permit(:name, :profile)\n end",
"def equipment_params\n params.require(:equipment).permit(:name, :location, :inventory_nr, :adhoc)\n end",
"def assignature_params\n params.require(:assignature).permit(:name)\n end",
"def admin_panel_tag_params\n params.require(:admin_panel_tag).permit(:name, :description)\n end",
"def pack_params\n params.require(:pack).permit(:name)\n end",
"def reqdifficulty_params\n params.require(:reqdifficulty).permit(:reqdifficultyname)\n end",
"def operating_system_params\n params.require(:operating_system).permit(:name)\n end",
"def grade_params\n params.require(:grade).permit(:name,:platform_type)\n end",
"def thing_params\n params.require(:thing).permit(:user_id,:place_id, :name, :clean_day, :clean_frequency, :remarks, :tool1, :tool2, :tool3, :tool4, :tool5, :image)\n end",
"def tool=(name)\n @tool = name.to_sym\n end",
"def pref_params\n params.require(:pref).permit(:name)\n end",
"def energy_technologye_params\n params.require(:energy_technologye).permit(:name)\n end",
"def manpower_params\n params.require(:manpower).permit(:project_engineer, :materials_engineer, :project_foreman)\n end",
"def safety_manual_params\n params.require(:safety_manual).permit(:title)\n end",
"def tr_program_params\n params.require(:tr_program).permit(:name, :active_status, :sort)\n end",
"def gym_params\n params.require(:gym).permit(:gym_name)\n end",
"def power_supply_params\n params.require(:power_supply).permit(:name, :price, :code, :brand, :model, :series, :powertype, :maxpower, :fans, :pfc, :mainconnector, :twelvevrails, :pci, :sata, :efficiency, :voltageprotection, :inputvoltage, :inputfrequency, :inputcurrent, :output, :dimensions, :features)\n end",
"def platform_assistive_technology_params\n params.require(:platform_assistive_technology).permit(:platform_id, :assistive_technology_id)\n end",
"def set_tool\n @tool = Tool.find(params[:id])\n end",
"def set_tool\n @tool = Tool.find(params[:id])\n end",
"def buy_option_params\n params.require(:buy_option).permit(:material_id, :company_name, :price, :date)\n end",
"def equipmentmodel_params\n params.require(:equipmentmodel).permit(:name, :brand_id)\n end",
"def make_params\n params.require(:make).permit(:name)\n end",
"def suppliertype_params\n params.require(:suppliertype).permit!\n end",
"def passanger_params\n params.require(:passanger).permit(:name, :train_id)\n end",
"def attr_params\n params.require(:attr).permit(:name)\n end",
"def special_params\n params.require(:special).permit(:info)\n end",
"def create\n @tool_type = ToolType.new(tool_type_params)\n\n respond_to do |format|\n if @tool_type.save\n format.html { redirect_to @tool_type, notice: 'Tool type was successfully created.' }\n format.json { render action: 'show', status: :created, location: @tool_type }\n else\n format.html { render action: 'new' }\n format.json { render json: @tool_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def training_method_params\n params.require(:training_method).permit(:name, :description)\n end",
"def light_supply_params\n params.require(:light_supply).permit(:provider, :house_id)\n end",
"def weapon_quality_params\n params.require(:weapon_quality).permit(:name, :trigger, :description)\n end",
"def education_service_provided_typology_params\n params.require(:education_service_provided_typology).permit(:name, :description)\n end",
"def plant_params\n params.fetch(:plant, {}).permit(:name)\n end",
"def training_material_params\n params.require(:training_material).permit(:training_title_id, :name, :attachment)\n end",
"def create\n @tool = Tool.new(tool_params)\n user = User.find(params[:user_id])\n @tool.user_id = current_user.id\n respond_to do |format|\n if @tool.save\n format.html { redirect_to user_tools_path, notice: 'Tool was successfully added.' }\n format.json { render :show, status: :created, location: @tool }\n else\n format.html { render :new }\n format.json { render json: @tool.errors, status: :unprocessable_entity }\n end\n end\n end",
"def wine_app_params\n params.require(:wine_app).permit([:name])\n end",
"def handover_way_params\n params.require(:handover_way).permit(:name)\n end",
"def switt_params\n params.require(:switt).permit(:name, :super_power)\n end",
"def medical_equipment_params\n params.require(:medical_equipment).permit(:name)\n end",
"def help_option_params\n params.require(:help_option).permit(:descriptionvol, :descriptioncall)\n end",
"def exec_params\n params.require(:exec).permit(:name)\n end",
"def mod_pack_params\n params.require(:mod_pack).permit(:name)\n end",
"def operating_system_params\n params.require(:operating_system).permit(:name)\n end"
] |
[
"0.8913012",
"0.8863078",
"0.8719983",
"0.8698839",
"0.8627929",
"0.86091584",
"0.860656",
"0.85701895",
"0.83607966",
"0.8262755",
"0.8232917",
"0.74913794",
"0.74469185",
"0.72768396",
"0.7129551",
"0.71281147",
"0.70993614",
"0.7036273",
"0.7013189",
"0.6950364",
"0.6948385",
"0.6948385",
"0.6919631",
"0.6865137",
"0.68594474",
"0.67986",
"0.67761964",
"0.67676824",
"0.6751371",
"0.67416465",
"0.6714455",
"0.6708211",
"0.67024815",
"0.6698923",
"0.66982543",
"0.66980416",
"0.6692486",
"0.6687745",
"0.66648096",
"0.6654208",
"0.6652805",
"0.664548",
"0.664032",
"0.6634868",
"0.6628784",
"0.66242564",
"0.6621599",
"0.66052645",
"0.6594402",
"0.65899676",
"0.6587567",
"0.65827554",
"0.6578965",
"0.65770084",
"0.6565052",
"0.6562255",
"0.65620434",
"0.65615404",
"0.6559411",
"0.65573835",
"0.6555598",
"0.6551696",
"0.65509784",
"0.6548207",
"0.6547297",
"0.6545063",
"0.6542404",
"0.65417826",
"0.65309155",
"0.6528758",
"0.6518431",
"0.65097773",
"0.65042704",
"0.65037173",
"0.6500388",
"0.64946604",
"0.64946604",
"0.6490718",
"0.64864886",
"0.6480653",
"0.6478699",
"0.64778787",
"0.64776015",
"0.64699835",
"0.646302",
"0.6462367",
"0.6456089",
"0.6455544",
"0.64528245",
"0.6452072",
"0.6445846",
"0.6444592",
"0.6444259",
"0.64397556",
"0.6436017",
"0.6433287",
"0.6431423",
"0.64313376",
"0.64264184",
"0.6423267"
] |
0.67549044
|
28
|
puts instance_variables send :attr_reader, instance_variables
|
def initialize args
index = 0
puts args
#iterates through all the instance variables declared at the time
#of class creation and sets
self.class.instance_variables.each do |instance_variable|
#To set instance_variable as per new object values
self.class.instance_variable_set( "#{ instance_variable}", args[ index ] )
#To get value of class_variable i.e. returns array
class_variable_array = self.class.class_variable_get( "@#{ instance_variable }" )
#To push new args value into class variable
self.class.class_variable_set( "@#{ instance_variable }", class_variable_array.push( "#{ args[ index ] }" ) )
index += 1
end
puts self.is_a? Sourcedetails
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def instance_variables() end",
"def instance_variables; end",
"def inspect\n instance_variables.each_with_object([\n \"\\n#<#{self.class}:0x#{object_id.to_s(16)}>\",\n \"\\tInstance variables:\"\n ]) do |item, result|\n result << \"\\t\\t#{item} = #{instance_variable_get(item)}\"\n result\n end.join(\"\\n\")\n end",
"def inspect() \n print @obj_name\n print \" which is \"\n print @obj_attr\n print \" & \"\n puts @obj_secondattr\n end",
"def toString\n\t\tself.instance_variables.each do |i|\n\t\t\tputs \"#{i[1..-1]}: #{self.instance_variable_get(i)}\\n\"\n\t\tend\n\tend",
"def toString\n\t\tself.instance_variables.each do |i|\n\t\t\tputs \"#{i[1..-1]}: #{self.instance_variable_get(i)}\\n\"\n\t\tend\n\tend",
"def print\n puts \"#{@name}\" #same as :name accessor above.\nend",
"def printA\n \"Show instance variable: #{@a}\"\n end",
"def instance_variable_names; end",
"def class_variables() end",
"def inspect\n \"#<#{self.class} #{instance_variables.map{|iv| \"#{iv}=>#{instance_variable_get(iv).inspect}\"}.join(', ')}>\"\n end",
"def class_variables; end",
"def inspect\n ivar_string = (instance_variables.map(&:to_sym) - HIDDEN_IVARS).map do |ivar|\n \"#{ivar}=#{instance_variable_get(ivar).inspect}\"\n end.join(\", \")\n \"#<#{self.class}:#{object_id} #{ivar_string}>\"\n end",
"def inspect\n ivar_string = (instance_variables.map(&:to_sym) - HIDDEN_IVARS).map do |ivar|\n \"#{ivar}=#{instance_variable_get(ivar).inspect}\"\n end.join(\", \")\n \"#<#{self.class}:#{object_id} #{ivar_string}>\"\n end",
"def class_variables\n end",
"def pretty_print_instance_variables\n instance_variables.sort\n end",
"def pretty_print_instance_variables\n instance_variables.sort\n end",
"def resolveV\r\n puts 'printing a list of instance variables:'\r\n\r\n puts @@currClass.instance_variables.to_s\r\n @@bLastUsed = false\r\n @@forwardClasses = []\r\n end",
"def pretty_print_instance_variables\n %w(@nodes)\n end",
"def inspect\n \"#<#{self.class} @attributes=#{@attributes.inspect}>\"\n end",
"def inspect\n \"#<#{self.class.inspect} @name=#{name.inspect}>\"\n end",
"def instance_variables\n get_instance_variables.to_a.collect{ |n| \"#{n}\".to_sym }\n end",
"def inspect\n %{<#{self.class.name} #{self.class.props.reduce([]) do |s, d| \n s << [d.first, send(d.first).inspect].join(\"=\")\n end.join(\" \")}>}\n end",
"def print_attribute(*) end",
"def inspect\n \"#{self.name}, #{self.email}, #{self.age}\"\n end",
"def instance_variables\n get_instance_variables.to_a.collect{ |n| \"@#{n}\".to_sym }\n end",
"def sum\r\n puts \"Hello\"\r\n puts @instance_var #wont be shown\r\n end",
"def inspect\n \"#<#{self.class.name} @name=#{@name}>\"\n end",
"def print\n Kernel.print(self)\n end",
"def inspect\n self._inspect({})\n end",
"def inspect\n\t\treturn %{#<%s:0x%0x %s>} % [\n\t\t\tself.class.name,\n\t\t\tself.object_id / 2,\n\t\t\tself.ivar_descriptions.join( ', ' ),\n\t\t]\n\tend",
"def pretty_print_instance_variables\n (instance_variables - pretty_print_ignore).sort\n end",
"def instance_variable_name; end",
"def inspect; end",
"def inspect; end",
"def inspect; end",
"def inspect; end",
"def inspect; end",
"def inspect; end",
"def inspect; end",
"def inspect; end",
"def inspect; end",
"def inspect; end",
"def inspect; end",
"def inspect; end",
"def inspect; end",
"def inspect; end",
"def inspect; end",
"def inspect; end",
"def inspect; end",
"def inspect; end",
"def inspect; end",
"def inspect; end",
"def inspect; end",
"def inspect; end",
"def inspect; end",
"def inspect; end",
"def inspect; end",
"def inspect; end",
"def inspect; end",
"def inspect; end",
"def inspect; end",
"def attributes\n instance_values\n end",
"def inspect\n output = \"#<#{self.class}:#{(object_id << 1).to_s(16)}\"\n\n %i[username token idle_timeout duration].each do |attribute|\n value = instance_variable_get \"@#{attribute}\".to_sym\n output += \" @#{attribute}=#{value}\" unless value.nil?\n end\n\n output += '>'\n output\n end",
"def inspect\n \"#<#{self.class.inspect} @args=#{args.inspect}\"\n end",
"def state\n self.instance_variables.map { |variable| self.instance_variable_get variable }\n end",
"def state\n self.instance_variables.map { |variable| self.instance_variable_get variable }\n end",
"def state\n self.instance_variables.map { |variable| self.instance_variable_get variable }\n end",
"def attributes\n instance_variables.map{ |iv| iv.sub('@','') }\n end",
"def print_properties\n orientdb.print_class_properties self\n end",
"def inspect\n end",
"def inspect\n end",
"def insp\r\n self.inspect\r\n end",
"def inspect\n end",
"def inspect\n end",
"def inspect\n end",
"def inspect\n end",
"def inspect\n end",
"def inspect\n end",
"def inspect\n end",
"def inspect\n end",
"def inspect\n end",
"def inspect\n end",
"def inspect\n end",
"def inspect\n end",
"def inspect\n end",
"def instance_attributes; end",
"def attr_reader(*)\n end",
"def inspect\n \"(#{self})\"\n end",
"def inspect\n vals = ATTRS.map { |field| \"#{field}: #{public_send(field).inspect}\" }\n \"#<#{self.class.name} #{vals.join(', ')}>\"\n end",
"def inspect\n result = +\"#<#{self.class.name}:#{object_id}\"\n symbol_names = members.map(&:name)\n result << \" @members=#{symbol_names}>\"\n result\n end",
"def inspect() end",
"def inspect() end",
"def inspect() end",
"def inspect() end",
"def inspect() end",
"def inspect() end",
"def inspect() end",
"def inspect() end",
"def inspect() end",
"def inspect() end"
] |
[
"0.748733",
"0.7472346",
"0.7401862",
"0.7135171",
"0.7009385",
"0.7009385",
"0.6978225",
"0.6968471",
"0.6893099",
"0.6837483",
"0.6822872",
"0.6815532",
"0.6725305",
"0.6725305",
"0.6651798",
"0.659805",
"0.659805",
"0.6589626",
"0.6528915",
"0.64905286",
"0.64892375",
"0.6440549",
"0.64403605",
"0.64016414",
"0.6376544",
"0.6373027",
"0.63687503",
"0.6348447",
"0.6297443",
"0.62691456",
"0.6266326",
"0.6263874",
"0.62598956",
"0.6251292",
"0.6251292",
"0.6251292",
"0.6251292",
"0.6251292",
"0.6251292",
"0.6251292",
"0.6251292",
"0.6251292",
"0.6251292",
"0.6251292",
"0.6251292",
"0.6251292",
"0.6251292",
"0.6251292",
"0.6251292",
"0.6251292",
"0.6251292",
"0.6251292",
"0.6251292",
"0.6251292",
"0.6251292",
"0.6251292",
"0.6251292",
"0.6251292",
"0.6251292",
"0.6251292",
"0.6251292",
"0.6251292",
"0.623173",
"0.6231054",
"0.6229384",
"0.620183",
"0.620183",
"0.620183",
"0.6186515",
"0.6185562",
"0.6179402",
"0.6179402",
"0.6174994",
"0.61745507",
"0.61745507",
"0.61745507",
"0.61745507",
"0.61745507",
"0.61745507",
"0.61745507",
"0.61745507",
"0.61745507",
"0.61745507",
"0.61745507",
"0.61745507",
"0.61745507",
"0.61721486",
"0.615858",
"0.6154118",
"0.6128468",
"0.61131227",
"0.609592",
"0.609592",
"0.609592",
"0.609592",
"0.609592",
"0.609592",
"0.609592",
"0.609592",
"0.609592",
"0.609592"
] |
0.0
|
-1
|
generate upper quartile value
|
def upper_quartile
return nil if self.empty?
sorted_array = self.sort
u = (0.25*(3*sorted_array.length))
if (u-u.truncate).is_a?(Integer)
return sorted_array[(u-u.truncate)-1]
else
sample = sorted_array[u.truncate.abs-1]
sample1 = sorted_array[(u.truncate.abs)]
return sample+((sample1-sample)*(u-u.truncate))
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def upperQuartile(node)\n\t\t# Max humidity value from the node in the past day\n\t\tmax_hum = Reading.select(:humidty, :recorded_at).where(node_id: node, recorded_at: Time.zone.now.beginning_of_day..Time.zone.now.end_of_day).maximum(:humidity)\n\t\t# Max temperature value from the node in the past day\n\t\tmax_temp = Reading.select(:temperature, :recorded_at).where(node_id: node, recorded_at: Time.zone.now.beginning_of_day..Time.zone.now.end_of_day).maximum(:temperature)\n\t\t# Determine the parameter with the highest value\n\t\tmax_val = [max_hum, max_temp].max\t\n\n\t\t# Check if node has returned any values for the current day\n\t\t# Set the max bound into quartiles\n\t\tunless max_val.nil? \n\t\t\toffset = 25 - (max_val % 25)\n\t\t\t# Visibility adjustment\n\t\t\tif offset == 1 \n\t\t\t\toffset = 5\n\t\t\tend\n\t\t\treturn max_val + offset\n\t\tend\n\t\t# Otherwise, set default max for empty graph\n\t\treturn 100\n\tend",
"def quartile(sorted_elements)\n if sorted_elements.length % 2 == 0\n (sorted_elements[(sorted_elements.length / 2)] + sorted_elements[(sorted_elements.length / 2) - 1]).to_f / 2\n else\n sorted_elements[sorted_elements.length / 2].to_f\n end\nend",
"def lower_quartile\n return nil if self.empty?\n sorted_array = self.sort\n u = 0.25*sorted_array.length + 1\n if (u-u.truncate).is_a?(Integer)\n return sorted_array[(u-u.truncate)-1]\n else\n sample = sorted_array[u.truncate.abs-1]\n sample1 = sorted_array[(u.truncate.abs)]\n return sample+((sample1-sample)*(u-u.truncate))\n end\n end",
"def quartile_boundaries # rubocop:disable Metrics/AbcSize\n top = scores.reject { |x| gh_outliers.include? x }.max\n range = (1..top).to_a\n range = [0] * 3 if range.empty?\n mids = (1..3).map do |q|\n index = (q * range.size / 4) - 1\n range[index]\n end\n bounds = (mids + [max.score]).uniq.sort\n ([0] * (5 - bounds.size)) + bounds\n end",
"def excel_quartile(array, quartile)\n # Returns nil if array is empty and covers the case of array.length == 1\n return array.first if array.length <= 1\n sorted = array.sort\n # The 4th quartile is always the last element in the sorted list.\n return sorted.last if quartile == 4\n # Source: http://mathworld.wolfram.com/Quartile.html\n quartile_position = 0.25 * (quartile*sorted.length + 4 - quartile)\n quartile_int = quartile_position.to_i\n lower = sorted[quartile_int - 1]\n upper = sorted[quartile_int]\n lower + (upper - lower) * (quartile_position - quartile_int)\n end",
"def quartiles(arr)\n sort_arr = arr.sort()\n len = sort_arr.size()\n q1_q2_q3 = [0.25, 0.5, 0.75].collect { |v|\n indx_f = (len * v) - 0.5\n indx_i = indx_f.to_i()\n if (indx_i == indx_f)\n sort_arr[indx_i]\n else\n res = indx_f - indx_i\n (sort_arr[indx_i] * (1 - res)) + (sort_arr[indx_i+1] * res)\n end\n }\n return [sort_arr[0]] + q1_q2_q3 + [sort_arr[-1]] \n end",
"def last_quartile(already_sorted=false)\n return nil if size < 4\n a = already_sorted ? self : sort\n a[((size / 2) + 1)..-1].median(true)\n end",
"def quartiles(already_sorted=false)\n a = already_sorted ? self : sort\n [a.first_quartile(true), a.median(true), a.last_quartile(true)]\n end",
"def get_quartiles(scores)\r\n \r\n end",
"def interquartile_range(already_sorted=false)\n return nil if size < 4\n a = already_sorted ? self : sort\n a.last_quartile - a.first_quartile\n end",
"def quartiles\n quartiles = Array.new(5) { [] }\n @raw.each_with_object(quartiles) do |elem, acc|\n acc[quartile(elem.score)] << elem\n end\n end",
"def vector_percentile\n c = size - indexes(*Daru::MISSING_VALUES).size\n ranked.recode! { |i| i.nil? ? nil : (i.quo(c)*100).to_f }\n end",
"def quartile(score)\n return nil if score.negative? || score > max.score\n quartile_boundaries.count { |bound| score > bound }\n end",
"def upper_bound(data)\n return (q3(data) + (1.5 * iqr(data))).to_f\n end",
"def display_quartiles(scores)\r\n\r\n end",
"def display_quartiles(scores)\r\n get_quartiles(scores) { |total| puts \"Quartile total: #{total}\" }\r\n end",
"def quantile q\n cut = (q.to_f * count).ceil\n obs = 0\n for i in 0...size\n obs += self.frequency[i]\n return i if obs > 0 && obs >= cut\n end\n return nil\n end",
"def first_quartile(already_sorted=false)\n return nil if size < 4\n a = already_sorted ? self : sort\n a[0..((size / 2) - 1)].median(true)\n end",
"def lowerQuartile(node)\n\t\t# Min humidity value from the node in the past day\n\t\tmin_hum = Reading.select(:humidity, :recorded_at).where(node_id: node, recorded_at: Time.zone.now.beginning_of_day..Time.zone.now.end_of_day).minimum(:humidity)\n\t\t# Min temperature value from the node in the past day\n\t\tmin_temp = Reading.select(:temperature, :recorded_at).where(node_id: node, recorded_at: Time.zone.now.beginning_of_day..Time.zone.now.end_of_day).minimum(:temperature)\n\t\t# Determine the parameter with the lowest value\n\t\tmin_val = [min_hum, min_temp].min\n\n\t\t# Check if node has returned any values for the current day\n\t\t# Set the min bound into quartiles\n\t\tunless min_val.nil?\n\t\t\toffset = (min_val % 25)\n\t\t\t# Visibility adjustment\n\t\t\tif offset == 1 \n\t\t\t\toffset = 5\n\t\t\tend\t\t\t\n\t\t\treturn min_val - (offset)\n\t\tend\n\t\t# Graph will be empty, set default min\n\t\treturn 0\n\tend",
"def get_quartiles(scores)\r\n (0..scores.length-1).each do |i|\r\n sum = 0\r\n if i%(scores.length/4) == 0\r\n (i..(i+scores.length/4-1)).each {|index| sum += scores[index]}\r\n yield sum\r\n end\r\n end\r\n end",
"def last_five_quarters\n period.to_quarter_period.value.downto(4)\n end",
"def last_five_quarters\n period.to_quarter_period.value.downto(4)\n end",
"def percentile(percentile, values)\n values_sorted = values.sort\n\n floor = (percentile * (values_sorted.length - 1) + 1).floor - 1\n mod = (percentile * (values_sorted.length - 1) + 1).modulo(1)\n\n values_sorted[floor] + (mod * (values_sorted[floor + 1] - values_sorted[floor]))\n end",
"def get_quartiles(scores)\n\ti = 0\n\tquarts = []\n\tindex = 0\n\tnumOfValuesPerIndex = scores.length/4\n\ttotals = 0\n\twhile i < scores.length\n\t if(i % numOfValuesPerIndex == 0)\n\t if(i != 0)\n\t quarts << totals\n\t end\n\t totals = scores[i]\n\t else\n\t totals += scores[i]\n\t end\n\t i += 1\n\tend\n\tquarts << totals\t\n\tyield(quarts)\n end",
"def median\n percentile(50)\n end",
"def test_histogram_min_and_max_with_fewer_buckets\n hist = ScoutApm::NumericHistogram.new(5)\n\n 10.times {\n (1..10).to_a.each do |i|\n hist.add(i)\n end\n }\n\n assert_equal 1.5, round(hist.quantile(0), 1)\n assert_equal 9.5, round(hist.quantile(100), 1)\n end",
"def display_quartiles(scores)\n\tget_quartiles(scores) do |quarts|\n\t i = 1\n\t quarts.each do |value|\n\t puts \"The total for the #{i}st Quartile is #{value}\"\n\t\ti += 1\n\t end\n\tend\n end",
"def ceil\n Quantity.new(@value.ceil, @unit)\n end",
"def ceil()\n #This is a stub, used for indexing\n end",
"def percentile p\n sorted_array = self.sort\n rank = (p.to_f / 100) * (self.length + 1)\n\n return nil if self.length == 0\n\n if rank.truncate > 0 && rank.truncate < self.length\n sample_0 = sorted_array[rank.truncate - 1]\n sample_1 = sorted_array[rank.truncate]\n\n (rank.fractional_part * (sample_1 - sample_0)) + sample_0\n elsif rank.truncate == 0\n sorted_array.first.to_f\n elsif rank.truncate == self.length\n sorted_array.last.to_f\n end\n end",
"def wquantiles(data, probs=QUARTILES)\n grouped = data.group_by(&:first).map { |a, b| [a, b.reduce(0) { |sum, e| sum + e.last }] }\n values, weights = grouped.sort_by(&:first).transpose\n\n sum = 0\n cum_weights = weights.map { |e| sum += e }\n\n probs.map do |prob|\n h = 1 + (sum - 1) * prob\n mod = h % 1\n\n k1 = cum_weights.find_index { |e| e >= h.floor }\n k2 = cum_weights.find_index { |e| e >= h.ceil }\n\n (1 - mod) * values[k1] + (mod) * values[k2]\n end\nend",
"def quartile_inc()\n return MicrosoftGraph::Drives::Item::Items::Item::Workbook::Functions::Quartile_Inc::QuartileIncRequestBuilder.new(@path_parameters, @request_adapter)\n end",
"def get_upper_limit_of(range)\n range.end\nend",
"def ceil() end",
"def quarter\n (month / 3.0).ceil\n end",
"def gut_max\n Bubs::Guts::GUTS_MAX.to_f\n end",
"def qcks_max_slow_down\n Quicksands[terrain_tag][:max_slow_down] \n end",
"def ceil\n end",
"def irfibrap\n vag=(valorfibrap * 100) / 50\n vag.round(2)\n end",
"def percentile_by_count(array,percentile)\n count = (array.length * (percentile)).floor\n verbose \"Array entry at 95th percentile: #{count-1}\"\n array.sort[count-1]\nend",
"def range_bucket(value, size=10)\n if value.present?\n x = (value / size * size) + 1\n y = x + (size - 1)\n return \"#{x} - #{y}\"\n end\n end",
"def get_upper_limit_of(range)\n range.last\nend",
"def percentile(p)\n sorted_array = self.sort\n rank = (p.to_f / 100) * (self.length + 1)\n\n return nil if self.length == 0\n\n if rank.truncate > 0 && rank.truncate < self.length\n sample_0 = sorted_array[rank.truncate - 1]\n sample_1 = sorted_array[rank.truncate]\n\n # Returns the fractional part of a float. For example, <tt>(6.67).fractional_part == 0.67</tt>\n fractional_part = (rank - rank.truncate).abs\n (fractional_part * (sample_1 - sample_0)) + sample_0\n elsif rank.truncate == 0\n sorted_array.first.to_f\n elsif rank.truncate == self.length\n sorted_array.last.to_f\n end\n end",
"def irfibra\n vag=(fibra * 100) / 50\n vag.round(2)\n end",
"def to_q\n 1+(self/100.0)\n end",
"def get_upper_limit_of(range)\n range.max\nend",
"def get_upper_limit_of(range)\n range.max\nend",
"def upper_limit_for(desired_prime_number)\n i = 2\n while (i / Math.log(i)) < desired_prime_number do\n i = i + 1\n end\n return i\n end",
"def ceiling\n push pop.ceil\n end",
"def rand_step_func max_footprint, min_steps, max_steps, floor = 0.0\n steps = []\n step_ranges = interval_sample(0, max_footprint, rand_int(min_steps - 1, max_steps - 1)).sort + [max_footprint]\n probs = interval_sample(floor, 1, step_ranges.length, 6).sort.reverse\n step_ranges.each_with_index do |footprint, i|\n steps << {'cum_footprint' => footprint, 'p' => probs[i]}\n end\n DecreasingStepFunction.new steps\n end",
"def ceil\n self\n end",
"def ceil\n self\n end",
"def pth_quantile(x, p)\n m = (x.length + 1) * p\n return 0 if m < 1 || m > x.length\n j = m.floor\n j == m ? x[m - 1] : impl_mean(x[j - 1, 2])\n end",
"def quarter\n (month / 3.0).ceil\n end",
"def tau(num)\r\n\ttmp = num.prime_division.map(&:last)\r\n#\tnum.prime_division.each{ |i| puts i.join(', ') }\r\n\ttmp.inject(1){|prod,i| prod *= i+1}\r\nend",
"def ceiling\n case type\n when :string then 50\n when :integer then 42\n when :float then 42.0\n end\n end",
"def ordinal_rank(percentile, size)\n # n = P / 100 * N + 1/2\n ((percentile / 100.0 * size) + 0.5)\n end",
"def get_upper_limit_of(range)\n\tn = 1..20\n\tn.last\nend",
"def percentile(q, strategy=:midpoint)\n case strategy\n when :midpoint\n midpoint_percentile(q)\n when :linear\n linear_percentile(q)\n else\n raise ArgumentError, \"Unknown strategy #{strategy}\"\n end\n end",
"def quartile_method=(quartile_method)\n validator = EnumAttributeValidator.new('String', ['Exclusive', 'Inclusive'])\n unless validator.valid?(quartile_method)\n fail ArgumentError, 'invalid value for \"quartile_method\", must be one of #{validator.allowable_values}.'\n end\n @quartile_method = quartile_method\n end",
"def percentile_rank(p)\n\t\t\tif p < 0.0 || p > 100.0\n\t\t\t\tnil\n\t\t\telse\n\t\t\t\tsize = self.size \n\t\t\t\tif size == 0\n\t\t\t\t\tnil\n\t\t\t\telsif size == 1\n\t\t\t\t\tself[0]\n\t\t\t\telse\n\t\t\t\t\tsorted = self.sort\n\t\t\t\t\ti = (p * size / 100.0).floor\n\t\t\t\t\ti = size - 1 if i == size\n\t\t\t\t\tsorted[i]\n\t\t\tend # size ==\n\t\tend # p < 0.0 || p > 100.0\n\tend",
"def cut_factor\r\n return 0.0\r\n end",
"def [](percentile)\n i = (list.size * percentile / 100.0).ceil - 1\n list[i]\n end",
"def liquid_cube(volume_cuft, equiptype)\n return number_to_percentage(volume_cuft.to_f / Equipment.where(:equip_name => equiptype).first.cb_limit_cuft * 100, precision: 2)\n end",
"def nist_alternate_rank(percentile, size)\n # n = ((P / 100) * (N - 1)) + 1\n (((percentile / 100.0) * (size - 1)) + 1)\n end",
"def get_quartiles(topic_id)\n assignment_id = SignUpTopic.where(id: topic_id).pluck(:assignment_id).first\n num_reviews_allowed = Assignment.where(id: assignment_id).pluck(:num_reviews_allowed).first\n num_participants_in_assignment = AssignmentParticipant.where(parent_id: assignment_id).length\n num_topics_in_assignment = SignUpTopic.where(assignment_id: assignment_id).length\n num_choosers_this_topic = ReviewBid.where(sign_up_topic_id: topic_id).length\n avg_reviews_per_topic = (num_participants_in_assignment*num_reviews_allowed)/num_topics_in_assignment\n\n if num_choosers_this_topic < avg_reviews_per_topic/2\n return 'rgb(124,252,0)'\n elsif num_choosers_this_topic > avg_reviews_per_topic/2 and num_choosers_this_topic < avg_reviews_per_topic\n return 'rgb(255,255,0)'\n else\n return 'rgb(255,99,71)'\n end\n end",
"def ceil(ndigits = 0)\n appr(Q.new(10)**-ndigits, 1)\n end",
"def upper_bound\n self.class.upper_bound(@obs, z_value)\n end",
"def range\n @fuel * MILES_PER_GALLON\n end",
"def get_cdf(x)\n if x >= @lower && x < @upper\n (x - @lower).fdiv(@upper - @lower)\n elsif x >= @upper\n 1.0\n else \n 0.0\n end\t \n end",
"def cgamma(z)\n if z.real < 0.5\n PI / (CMath.sin(PI * z) * cgamma(1.0 - z))\n else\n z -= 1.0\n x = (1...QLEN).inject(Q[0]) { |s, i| s + Q[i] / (z + i) }\n t = z + QLEN_G + 0.5\n SQRT_2PI * (t**(z + 0.5)) * CMath.exp(-t) * x\n end\nend",
"def percentile(pct)\n n = raw_statistics.length\n i = ((pct.to_f / 100) * n).ceil\n\n x = raw_statistics[n - (i - 0)]&.won || 0\n y = raw_statistics[n - (i - 1)]&.won || 0\n\n ((x + y).to_f / 2).ceil\n end",
"def high\n @range_high\n end",
"def max_x( n )\n (Math.sqrt( 6*n ) / 6).to_i\n end",
"def sum_of_divisor_up_to(n, upper_limit = 999)\n p = upper_limit / n\n n * p * (p + 1) / 2\nend",
"def quartile_exc()\n return MicrosoftGraph::Drives::Item::Items::Item::Workbook::Functions::Quartile_Exc::QuartileExcRequestBuilder.new(@path_parameters, @request_adapter)\n end",
"def to(upper_limit)\n SumOfMultiples.to(upper_limit, @args)\n end",
"def bounds(values)\n q1 = values.percentile(25)\n q3 = values.percentile(75)\n iqr = q3 - q1\n lower = q1 - (iqr * 1.5)\n upper = q3 + (iqr * 1.5)\n inrange = values.select { |v| v >= lower && v <= upper }\n lower = [lower, inrange.min].max\n upper = [upper, inrange.max].min\n belowrange = values.select { |v| v < lower }\n aboverange = values.select { |v| v > upper }\n [belowrange, lower, upper, aboverange]\nend",
"def upper_bound_for_nth_prime (n)\n return n * (Math.log(n) + Math.log(Math.log(n-1) ) )\n end",
"def upto(max, &block)\n step(max, +1, &block)\n end",
"def getQuo ( x , y )\n\tq = x / y\n\treturn q\nend",
"def upper_bound; end",
"def lower_bound(data)\n return (q1(data) - (1.5 * iqr(data))).to_f\n end",
"def valorfibrap\n\t\tvag=(fibra * 70) / 100\n vag.round(2)\n\tend",
"def get_median\n if @lowerhalf.size >= @higherhalf.size\n return @lowerhalf.max\n else\n return @higherhalf.min\n end\nend",
"def getMultpiles(range)\n\tmultiples = []\n\tfor i in 3...range\n\t\tif i % 3 == 0 || i % 5 == 0\n\t\t\tmultiples << i\n\t\tend\n\tend\n\treturn multiples\nend",
"def percentile_index(percentile)\n index = (self.samples_count * percentile.to_f / 100).to_i\n index.zero? ? index : index - 1\n end",
"def max\r\n @range.max\r\n end",
"def fast_bucket_function\n Proc.new do |item|\n if item.is_a?(Float) && item.nan?\n nil\n else\n bucket_number = (item - min)/increment\n if bucket_number > counter_size || bucket_number < 0\n nil\n else\n [bucket_number.to_i, counter_size-1].min\n end\n end\n end\n end",
"def ceil\n round :ceil\n end",
"def p005(upper_bound = 20)\n # This builds on the idea that any value which is a multiple of another value can be used instead of it\n # Also that the lowest common multiple is a product of the minimal set of prime-multiples that cover the factors\n # So e.g. the lowest common multiple of 1..6 would be 5 x 2 x 2 x 3 = 60, where 2 appears twice because 2 x 2 = 4\n required_factors = (2..upper_bound).to_a\n required_primes = {}\n required_factors.each do |factor|\n required_primes.merge!(Prime.prime_division(factor).to_h) do |_prime_factor, old_multiple, new_multiple|\n [old_multiple, new_multiple].max\n end\n end\n required_primes.reduce(1) { |common_multiple, prime_multiple| common_multiple * prime_multiple[0]**prime_multiple[1] }\nend",
"def multi_trial(cutoff)\n total = 0\n cutoff_scaled = cutoff / 100.0\n for _ in 0..NUM_TRIALS\n lower_value = rand()\n higher_value = 2 * lower_value\n if rand() < 0.5 then\n total += (if lower_value >= cutoff then lower_value else higher_value end)\n else\n total += (if higher_value >= cutoff then higher_value else lower_value end)\n end\n end\n return 100 * total / NUM_TRIALS\nend",
"def current_quarter\n \n case self.month\n \n when 1..3 then 1\n when 4..6 then 2\n when 7..9 then 3\n else 4\n end\n \n end",
"def qcks_max_sink\n Quicksands[terrain_tag][:max_sink]\n end",
"def full_coverage_phi\n PI - max_coverage_phi\n end",
"def percentile_exc()\n return MicrosoftGraph::Drives::Item::Items::Item::Workbook::Functions::Percentile_Exc::PercentileExcRequestBuilder.new(@path_parameters, @request_adapter)\n end",
"def irvitaminas\n vag=(vitymin * 100) / 50\n vag.round(2)\n end",
"def step(ctx, value, percentile)\n return if value.nil?\n raise ActiveRecord::StatementInvalid, \"1st argument to percentile() is not numeric\" unless value.is_a?(Numeric)\n @percentile ||= percentile\n @values << value\n end",
"def currentQuarter\n value = nil\n sql = ActiveRecord::Base.connection();\n #value, dummy = sql.execute(\"SELECT MAX(enclaveQuarter), 0 FROM enclavequarters WHERE enclaveYear = #{self.currentYear}\").fetch_row\n value = sql.select_value(\"SELECT MAX(enclaveQuarter) FROM enclavequarters WHERE enclaveYear = #{self.currentYear}\")\n value\n end",
"def quarter_gpa(quarter = nil)\n t = transcripts.find(system_key, quarter.year, quarter.quarter_code_id) rescue nil\n raw_gpa = t.nil? ? nil : (t.qtr_grade_points/t.qtr_graded_attmp) rescue nil\n '%.2f' % raw_gpa rescue \"unknown\" \n end"
] |
[
"0.76547885",
"0.75556237",
"0.74556005",
"0.73508096",
"0.72094834",
"0.71289724",
"0.69251245",
"0.68558437",
"0.68357986",
"0.6714768",
"0.6644293",
"0.6552409",
"0.6528319",
"0.65141267",
"0.64158475",
"0.6297665",
"0.6293136",
"0.6206528",
"0.6144667",
"0.6133184",
"0.5883594",
"0.5883594",
"0.58087957",
"0.56748223",
"0.56521446",
"0.56390035",
"0.56353647",
"0.56221294",
"0.5532639",
"0.5510541",
"0.54942936",
"0.54704255",
"0.54504377",
"0.54265845",
"0.5408353",
"0.54068",
"0.5401954",
"0.5399573",
"0.53984416",
"0.5392227",
"0.53820217",
"0.53819925",
"0.5378522",
"0.5354428",
"0.5349423",
"0.5346547",
"0.53455085",
"0.5345",
"0.5340076",
"0.53321236",
"0.5304806",
"0.5304806",
"0.5296535",
"0.5286346",
"0.5269567",
"0.52450544",
"0.52283514",
"0.521928",
"0.52147937",
"0.52052027",
"0.51968783",
"0.51950127",
"0.51598185",
"0.5142289",
"0.5140511",
"0.51317614",
"0.5114398",
"0.5097962",
"0.5094158",
"0.50935125",
"0.508634",
"0.5068842",
"0.50674504",
"0.506633",
"0.50578207",
"0.5056304",
"0.50528675",
"0.5048117",
"0.50474226",
"0.5041922",
"0.50242275",
"0.50188375",
"0.5011134",
"0.5004193",
"0.50014913",
"0.49961498",
"0.49885985",
"0.49835247",
"0.49805853",
"0.49762207",
"0.49758393",
"0.497289",
"0.49654472",
"0.49506935",
"0.49465936",
"0.49463665",
"0.49453238",
"0.49407122",
"0.49391174",
"0.49362543"
] |
0.8381107
|
0
|
generate lower quartile value
|
def lower_quartile
return nil if self.empty?
sorted_array = self.sort
u = 0.25*sorted_array.length + 1
if (u-u.truncate).is_a?(Integer)
return sorted_array[(u-u.truncate)-1]
else
sample = sorted_array[u.truncate.abs-1]
sample1 = sorted_array[(u.truncate.abs)]
return sample+((sample1-sample)*(u-u.truncate))
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def upper_quartile\n return nil if self.empty?\n sorted_array = self.sort\n u = (0.25*(3*sorted_array.length))\n if (u-u.truncate).is_a?(Integer)\n return sorted_array[(u-u.truncate)-1]\n else\n sample = sorted_array[u.truncate.abs-1]\n sample1 = sorted_array[(u.truncate.abs)]\n return sample+((sample1-sample)*(u-u.truncate))\n end\n end",
"def quartile(sorted_elements)\n if sorted_elements.length % 2 == 0\n (sorted_elements[(sorted_elements.length / 2)] + sorted_elements[(sorted_elements.length / 2) - 1]).to_f / 2\n else\n sorted_elements[sorted_elements.length / 2].to_f\n end\nend",
"def excel_quartile(array, quartile)\n # Returns nil if array is empty and covers the case of array.length == 1\n return array.first if array.length <= 1\n sorted = array.sort\n # The 4th quartile is always the last element in the sorted list.\n return sorted.last if quartile == 4\n # Source: http://mathworld.wolfram.com/Quartile.html\n quartile_position = 0.25 * (quartile*sorted.length + 4 - quartile)\n quartile_int = quartile_position.to_i\n lower = sorted[quartile_int - 1]\n upper = sorted[quartile_int]\n lower + (upper - lower) * (quartile_position - quartile_int)\n end",
"def quartiles(arr)\n sort_arr = arr.sort()\n len = sort_arr.size()\n q1_q2_q3 = [0.25, 0.5, 0.75].collect { |v|\n indx_f = (len * v) - 0.5\n indx_i = indx_f.to_i()\n if (indx_i == indx_f)\n sort_arr[indx_i]\n else\n res = indx_f - indx_i\n (sort_arr[indx_i] * (1 - res)) + (sort_arr[indx_i+1] * res)\n end\n }\n return [sort_arr[0]] + q1_q2_q3 + [sort_arr[-1]] \n end",
"def quartile_boundaries # rubocop:disable Metrics/AbcSize\n top = scores.reject { |x| gh_outliers.include? x }.max\n range = (1..top).to_a\n range = [0] * 3 if range.empty?\n mids = (1..3).map do |q|\n index = (q * range.size / 4) - 1\n range[index]\n end\n bounds = (mids + [max.score]).uniq.sort\n ([0] * (5 - bounds.size)) + bounds\n end",
"def upperQuartile(node)\n\t\t# Max humidity value from the node in the past day\n\t\tmax_hum = Reading.select(:humidty, :recorded_at).where(node_id: node, recorded_at: Time.zone.now.beginning_of_day..Time.zone.now.end_of_day).maximum(:humidity)\n\t\t# Max temperature value from the node in the past day\n\t\tmax_temp = Reading.select(:temperature, :recorded_at).where(node_id: node, recorded_at: Time.zone.now.beginning_of_day..Time.zone.now.end_of_day).maximum(:temperature)\n\t\t# Determine the parameter with the highest value\n\t\tmax_val = [max_hum, max_temp].max\t\n\n\t\t# Check if node has returned any values for the current day\n\t\t# Set the max bound into quartiles\n\t\tunless max_val.nil? \n\t\t\toffset = 25 - (max_val % 25)\n\t\t\t# Visibility adjustment\n\t\t\tif offset == 1 \n\t\t\t\toffset = 5\n\t\t\tend\n\t\t\treturn max_val + offset\n\t\tend\n\t\t# Otherwise, set default max for empty graph\n\t\treturn 100\n\tend",
"def lowerQuartile(node)\n\t\t# Min humidity value from the node in the past day\n\t\tmin_hum = Reading.select(:humidity, :recorded_at).where(node_id: node, recorded_at: Time.zone.now.beginning_of_day..Time.zone.now.end_of_day).minimum(:humidity)\n\t\t# Min temperature value from the node in the past day\n\t\tmin_temp = Reading.select(:temperature, :recorded_at).where(node_id: node, recorded_at: Time.zone.now.beginning_of_day..Time.zone.now.end_of_day).minimum(:temperature)\n\t\t# Determine the parameter with the lowest value\n\t\tmin_val = [min_hum, min_temp].min\n\n\t\t# Check if node has returned any values for the current day\n\t\t# Set the min bound into quartiles\n\t\tunless min_val.nil?\n\t\t\toffset = (min_val % 25)\n\t\t\t# Visibility adjustment\n\t\t\tif offset == 1 \n\t\t\t\toffset = 5\n\t\t\tend\t\t\t\n\t\t\treturn min_val - (offset)\n\t\tend\n\t\t# Graph will be empty, set default min\n\t\treturn 0\n\tend",
"def interquartile_range(already_sorted=false)\n return nil if size < 4\n a = already_sorted ? self : sort\n a.last_quartile - a.first_quartile\n end",
"def quartiles(already_sorted=false)\n a = already_sorted ? self : sort\n [a.first_quartile(true), a.median(true), a.last_quartile(true)]\n end",
"def get_quartiles(scores)\r\n \r\n end",
"def last_quartile(already_sorted=false)\n return nil if size < 4\n a = already_sorted ? self : sort\n a[((size / 2) + 1)..-1].median(true)\n end",
"def quartiles\n quartiles = Array.new(5) { [] }\n @raw.each_with_object(quartiles) do |elem, acc|\n acc[quartile(elem.score)] << elem\n end\n end",
"def first_quartile(already_sorted=false)\n return nil if size < 4\n a = already_sorted ? self : sort\n a[0..((size / 2) - 1)].median(true)\n end",
"def vector_percentile\n c = size - indexes(*Daru::MISSING_VALUES).size\n ranked.recode! { |i| i.nil? ? nil : (i.quo(c)*100).to_f }\n end",
"def quantile q\n cut = (q.to_f * count).ceil\n obs = 0\n for i in 0...size\n obs += self.frequency[i]\n return i if obs > 0 && obs >= cut\n end\n return nil\n end",
"def quartile(score)\n return nil if score.negative? || score > max.score\n quartile_boundaries.count { |bound| score > bound }\n end",
"def display_quartiles(scores)\r\n\r\n end",
"def get_quartiles(scores)\r\n (0..scores.length-1).each do |i|\r\n sum = 0\r\n if i%(scores.length/4) == 0\r\n (i..(i+scores.length/4-1)).each {|index| sum += scores[index]}\r\n yield sum\r\n end\r\n end\r\n end",
"def display_quartiles(scores)\r\n get_quartiles(scores) { |total| puts \"Quartile total: #{total}\" }\r\n end",
"def upper_bound(data)\n return (q3(data) + (1.5 * iqr(data))).to_f\n end",
"def wquantiles(data, probs=QUARTILES)\n grouped = data.group_by(&:first).map { |a, b| [a, b.reduce(0) { |sum, e| sum + e.last }] }\n values, weights = grouped.sort_by(&:first).transpose\n\n sum = 0\n cum_weights = weights.map { |e| sum += e }\n\n probs.map do |prob|\n h = 1 + (sum - 1) * prob\n mod = h % 1\n\n k1 = cum_weights.find_index { |e| e >= h.floor }\n k2 = cum_weights.find_index { |e| e >= h.ceil }\n\n (1 - mod) * values[k1] + (mod) * values[k2]\n end\nend",
"def percentile(percentile, values)\n values_sorted = values.sort\n\n floor = (percentile * (values_sorted.length - 1) + 1).floor - 1\n mod = (percentile * (values_sorted.length - 1) + 1).modulo(1)\n\n values_sorted[floor] + (mod * (values_sorted[floor + 1] - values_sorted[floor]))\n end",
"def lower_bound(data)\n return (q1(data) - (1.5 * iqr(data))).to_f\n end",
"def quartile_inc()\n return MicrosoftGraph::Drives::Item::Items::Item::Workbook::Functions::Quartile_Inc::QuartileIncRequestBuilder.new(@path_parameters, @request_adapter)\n end",
"def get_quartiles(scores)\n\ti = 0\n\tquarts = []\n\tindex = 0\n\tnumOfValuesPerIndex = scores.length/4\n\ttotals = 0\n\twhile i < scores.length\n\t if(i % numOfValuesPerIndex == 0)\n\t if(i != 0)\n\t quarts << totals\n\t end\n\t totals = scores[i]\n\t else\n\t totals += scores[i]\n\t end\n\t i += 1\n\tend\n\tquarts << totals\t\n\tyield(quarts)\n end",
"def test_histogram_min_and_max_with_fewer_buckets\n hist = ScoutApm::NumericHistogram.new(5)\n\n 10.times {\n (1..10).to_a.each do |i|\n hist.add(i)\n end\n }\n\n assert_equal 1.5, round(hist.quantile(0), 1)\n assert_equal 9.5, round(hist.quantile(100), 1)\n end",
"def percentile p\n sorted_array = self.sort\n rank = (p.to_f / 100) * (self.length + 1)\n\n return nil if self.length == 0\n\n if rank.truncate > 0 && rank.truncate < self.length\n sample_0 = sorted_array[rank.truncate - 1]\n sample_1 = sorted_array[rank.truncate]\n\n (rank.fractional_part * (sample_1 - sample_0)) + sample_0\n elsif rank.truncate == 0\n sorted_array.first.to_f\n elsif rank.truncate == self.length\n sorted_array.last.to_f\n end\n end",
"def median\n percentile(50)\n end",
"def to_q\n 1+(self/100.0)\n end",
"def percentile(p)\n sorted_array = self.sort\n rank = (p.to_f / 100) * (self.length + 1)\n\n return nil if self.length == 0\n\n if rank.truncate > 0 && rank.truncate < self.length\n sample_0 = sorted_array[rank.truncate - 1]\n sample_1 = sorted_array[rank.truncate]\n\n # Returns the fractional part of a float. For example, <tt>(6.67).fractional_part == 0.67</tt>\n fractional_part = (rank - rank.truncate).abs\n (fractional_part * (sample_1 - sample_0)) + sample_0\n elsif rank.truncate == 0\n sorted_array.first.to_f\n elsif rank.truncate == self.length\n sorted_array.last.to_f\n end\n end",
"def pth_quantile(x, p)\n m = (x.length + 1) * p\n return 0 if m < 1 || m > x.length\n j = m.floor\n j == m ? x[m - 1] : impl_mean(x[j - 1, 2])\n end",
"def min_value_quarter_sheet(value)\n only_values = self.class.only_values\n min = only_values.first\n only_values.each do |only_value|\n if only_value <= value\n min = only_value\n else\n break\n end\n end\n {:base_value => base_value,:value_quarter_sheet =>min ,:t => eval(\"v_#{min}_t\"),:tr => eval(\"v_#{min}_tr\")}\n end",
"def display_quartiles(scores)\n\tget_quartiles(scores) do |quarts|\n\t i = 1\n\t quarts.each do |value|\n\t puts \"The total for the #{i}st Quartile is #{value}\"\n\t\ti += 1\n\t end\n\tend\n end",
"def fast_bucket_function\n Proc.new do |item|\n if item.is_a?(Float) && item.nan?\n nil\n else\n bucket_number = (item - min)/increment\n if bucket_number > counter_size || bucket_number < 0\n nil\n else\n [bucket_number.to_i, counter_size-1].min\n end\n end\n end\n end",
"def qcks_max_slow_down\n Quicksands[terrain_tag][:max_slow_down] \n end",
"def ceil\n Quantity.new(@value.ceil, @unit)\n end",
"def last_five_quarters\n period.to_quarter_period.value.downto(4)\n end",
"def last_five_quarters\n period.to_quarter_period.value.downto(4)\n end",
"def ceil()\n #This is a stub, used for indexing\n end",
"def rand_step_func max_footprint, min_steps, max_steps, floor = 0.0\n steps = []\n step_ranges = interval_sample(0, max_footprint, rand_int(min_steps - 1, max_steps - 1)).sort + [max_footprint]\n probs = interval_sample(floor, 1, step_ranges.length, 6).sort.reverse\n step_ranges.each_with_index do |footprint, i|\n steps << {'cum_footprint' => footprint, 'p' => probs[i]}\n end\n DecreasingStepFunction.new steps\n end",
"def cut_factor\r\n return 0.0\r\n end",
"def get_cdf(x)\n if x >= @lower && x < @upper\n (x - @lower).fdiv(@upper - @lower)\n elsif x >= @upper\n 1.0\n else \n 0.0\n end\t \n end",
"def range\n @fuel * MILES_PER_GALLON\n end",
"def percentile(q, strategy=:midpoint)\n case strategy\n when :midpoint\n midpoint_percentile(q)\n when :linear\n linear_percentile(q)\n else\n raise ArgumentError, \"Unknown strategy #{strategy}\"\n end\n end",
"def percentile_by_count(array,percentile)\n count = (array.length * (percentile)).floor\n verbose \"Array entry at 95th percentile: #{count-1}\"\n array.sort[count-1]\nend",
"def percentile_rank(p)\n\t\t\tif p < 0.0 || p > 100.0\n\t\t\t\tnil\n\t\t\telse\n\t\t\t\tsize = self.size \n\t\t\t\tif size == 0\n\t\t\t\t\tnil\n\t\t\t\telsif size == 1\n\t\t\t\t\tself[0]\n\t\t\t\telse\n\t\t\t\t\tsorted = self.sort\n\t\t\t\t\ti = (p * size / 100.0).floor\n\t\t\t\t\ti = size - 1 if i == size\n\t\t\t\t\tsorted[i]\n\t\t\tend # size ==\n\t\tend # p < 0.0 || p > 100.0\n\tend",
"def getQuo ( x , y )\n\tq = x / y\n\treturn q\nend",
"def getMultpiles(range)\n\tmultiples = []\n\tfor i in 3...range\n\t\tif i % 3 == 0 || i % 5 == 0\n\t\t\tmultiples << i\n\t\tend\n\tend\n\treturn multiples\nend",
"def quartile_method=(quartile_method)\n validator = EnumAttributeValidator.new('String', ['Exclusive', 'Inclusive'])\n unless validator.valid?(quartile_method)\n fail ArgumentError, 'invalid value for \"quartile_method\", must be one of #{validator.allowable_values}.'\n end\n @quartile_method = quartile_method\n end",
"def em(x, min=nil)\n min ||= x * @n / 5\n rand(x**@n) + min*@n\n end",
"def percentile_inc()\n return MicrosoftGraph::Drives::Item::Items::Item::Workbook::Functions::Percentile_Inc::PercentileIncRequestBuilder.new(@path_parameters, @request_adapter)\n end",
"def liquid_cube(volume_cuft, equiptype)\n return number_to_percentage(volume_cuft.to_f / Equipment.where(:equip_name => equiptype).first.cb_limit_cuft * 100, precision: 2)\n end",
"def range_bucket(value, size=10)\n if value.present?\n x = (value / size * size) + 1\n y = x + (size - 1)\n return \"#{x} - #{y}\"\n end\n end",
"def quarter\n (month / 3.0).ceil\n end",
"def getBasePart(max,rerolls=[])\n z=Density.new\n z.delete(0)\n z.exact=false\n z.fail=true\n z.uniform=false\n n=max - rerolls.reject{ |n| n==max }.size\n for k in (1..(max-1)).reject{ |n| rerolls.include?n } do\n z[k]=Rational(1,n)\n end\n return z\n end",
"def ceil\n end",
"def getBasePart(max,rerolls=[])\n z=Density.new\n z.delete(0)\n z.fail=true\n z.exact=false\n z.uniform=false\n n=max - rerolls.reject{ |n| n==max }.size\n for k in (1..(max-1)).reject{ |n| rerolls.include?n } do\n z[k]=Rational(1,n)\n end\n return z\n end",
"def [](percentile)\n i = (list.size * percentile / 100.0).ceil - 1\n list[i]\n end",
"def ceiling\n push pop.ceil\n end",
"def test_raw_range_1\r\n r = GerbilCharts::Models::RawRange.new\r\n\r\n \t[10,20,10,0,0,1001,19920,882991.22].each do |v|\r\n\t\tr.update v\r\n\tend\r\n\r\n\tr.min_max do |mn,mx|\r\n \tassert mn==0\r\n\t\tassert mx==882991.22\r\n\tend\r\n end",
"def ceil() end",
"def quartile_exc()\n return MicrosoftGraph::Drives::Item::Items::Item::Workbook::Functions::Quartile_Exc::QuartileExcRequestBuilder.new(@path_parameters, @request_adapter)\n end",
"def ceil\n self\n end",
"def ceil\n self\n end",
"def get_quartiles(topic_id)\n assignment_id = SignUpTopic.where(id: topic_id).pluck(:assignment_id).first\n num_reviews_allowed = Assignment.where(id: assignment_id).pluck(:num_reviews_allowed).first\n num_participants_in_assignment = AssignmentParticipant.where(parent_id: assignment_id).length\n num_topics_in_assignment = SignUpTopic.where(assignment_id: assignment_id).length\n num_choosers_this_topic = ReviewBid.where(sign_up_topic_id: topic_id).length\n avg_reviews_per_topic = (num_participants_in_assignment*num_reviews_allowed)/num_topics_in_assignment\n\n if num_choosers_this_topic < avg_reviews_per_topic/2\n return 'rgb(124,252,0)'\n elsif num_choosers_this_topic > avg_reviews_per_topic/2 and num_choosers_this_topic < avg_reviews_per_topic\n return 'rgb(255,255,0)'\n else\n return 'rgb(255,99,71)'\n end\n end",
"def floor\n Quantity.new(@value.floor, @unit)\n end",
"def mileage(min: T.unsafe(nil), max: T.unsafe(nil)); end",
"def multi_trial(cutoff)\n total = 0\n cutoff_scaled = cutoff / 100.0\n for _ in 0..NUM_TRIALS\n lower_value = rand()\n higher_value = 2 * lower_value\n if rand() < 0.5 then\n total += (if lower_value >= cutoff then lower_value else higher_value end)\n else\n total += (if higher_value >= cutoff then higher_value else lower_value end)\n end\n end\n return 100 * total / NUM_TRIALS\nend",
"def f(x)\n (2**(30.403243784-x**2)).floor * 10**(-9)\nend",
"def cgamma(z)\n if z.real < 0.5\n PI / (CMath.sin(PI * z) * cgamma(1.0 - z))\n else\n z -= 1.0\n x = (1...QLEN).inject(Q[0]) { |s, i| s + Q[i] / (z + i) }\n t = z + QLEN_G + 0.5\n SQRT_2PI * (t**(z + 0.5)) * CMath.exp(-t) * x\n end\nend",
"def project(value)\n return value * 4 / line[:quarter]\n end",
"def quarter_gpa(quarter = nil)\n t = transcripts.find(system_key, quarter.year, quarter.quarter_code_id) rescue nil\n raw_gpa = t.nil? ? nil : (t.qtr_grade_points/t.qtr_graded_attmp) rescue nil\n '%.2f' % raw_gpa rescue \"unknown\" \n end",
"def quarter\n (month / 3.0).ceil\n end",
"def irfibrap\n vag=(valorfibrap * 100) / 50\n vag.round(2)\n end",
"def price_setter(min, max)\n price_range = []\n (min..max).step(5) { |x| price_range.push(x) }\n return price_range.sample\nend",
"def percentile_exc()\n return MicrosoftGraph::Drives::Item::Items::Item::Workbook::Functions::Percentile_Exc::PercentileExcRequestBuilder.new(@path_parameters, @request_adapter)\n end",
"def q(x, n, m)\n 1.0 - cdf(x, n, m)\n end",
"def step(ctx, value, percentile)\n return if value.nil?\n raise ActiveRecord::StatementInvalid, \"1st argument to percentile() is not numeric\" unless value.is_a?(Numeric)\n @percentile ||= percentile\n @values << value\n end",
"def interquartile_mean(array, cutoff = 0.25, needs_sort = true)\n return NAN unless (array.count > 0) && (cutoff <= 0.5)\n # $stderr.puts(\"interquartile_mean(): a = #{array}\")\n array = array.sort if needs_sort\n n = array.size\n lo = n * cutoff\n hi = n * (1.0 - cutoff)\n\n # Handle edge case where cutoff has eliminated everything except\n # the middle element. \n return array[lo.floor] if (lo.floor == hi.floor)\n\n tvalue = 0.0 # accumulated value\n tweight = 0.0 # accumulated weight\n \n # Note that since trimming is symmetrical from both ends of the \n # array, we count from 0 to n/2 and handle both ends at once.\n for i in 0...n/2\n if (i+1 < lo)\n # trimmed...\n elsif (i < lo)\n # partial coverage\n weight = (i + 1) - lo\n tvalue += (array[i] + array[n-1-i]) * weight\n tweight += 2 * weight\n else\n # full coverage\n tvalue += (array[i] + array[n-1-i])\n tweight += 2.0\n end\n end\n # Include middle element of odd-length arrays. (Note: because we\n # handled the edge case above, we know here that the weight of the\n # middle element is 1.0)\n if n.odd?\n tvalue += array[n/2]\n tweight += 1\n end\n\n tvalue / tweight\n end",
"def generate_harder_value(rnd_obj, _)\n # generate from the top 70% upwards\n min, max = fetch_min_max_values\n diff = max-min\n top_seventy_percent = 0.7 * diff\n @value = rnd_obj.rand(Integer(top_seventy_percent)..max)\n end",
"def ceiling\n case type\n when :string then 50\n when :integer then 42\n when :float then 42.0\n end\n end",
"def evaluate_param(x); (x.is_a?(Range) ? rand(x) : x).to_f; end",
"def ceiling_precise()\n return MicrosoftGraph::Drives::Item::Items::Item::Workbook::Functions::Ceiling_Precise::CeilingPreciseRequestBuilder.new(@path_parameters, @request_adapter)\n end",
"def iqrange(obj, opts={})\n opt = {:method => DEFAULT_QUARTILE_METHOD, :sorted => false}.merge( opts )\n srted = opt[:sorted] ? obj : obj.sort\n sz = srted.size\n return 0 if sz == 1\n answer =\n case opt[:method]\n when :tukey\n hi_idx = sz / 2\n lo_idx = (sz % 2 == 0) ? hi_idx-1 : hi_idx\n median(srted[hi_idx..-1]) - median(srted[0..lo_idx])\n when :moore_mccabe\n hi_idx = sz / 2\n lo_idx = hi_idx - 1\n hi_idx += 1 unless sz.even?\n median(srted[hi_idx..-1]) - median(srted[0..lo_idx])\n else\n raise ArgumentError, \"method must be :tukey or :moore_mccabe\"\n end\n answer.to_f\n end",
"def get_median\n if @lowerhalf.size >= @higherhalf.size\n return @lowerhalf.max\n else\n return @higherhalf.min\n end\nend",
"def min\r\n @range.min\r\n end",
"def nist_alternate_rank(percentile, size)\n # n = ((P / 100) * (N - 1)) + 1\n (((percentile / 100.0) * (size - 1)) + 1)\n end",
"def gen\n (x=rand)>0.5 ? x : (x < rand/2.0) ? 1.0 - x : x\nend",
"def qcks_max_sink\n Quicksands[terrain_tag][:max_sink]\n end",
"def geckometer(value, min, max)\n self.push(:item => value, :min => {:value => min}, :max => {:value => max})\n end",
"def range\n @range ||= 0.upto(@limit)\n end",
"def irfibra\n vag=(fibra * 100) / 50\n vag.round(2)\n end",
"def ceiling_math()\n return MicrosoftGraph::Drives::Item::Items::Item::Workbook::Functions::Ceiling_Math::CeilingMathRequestBuilder.new(@path_parameters, @request_adapter)\n end",
"def bounds(values)\n q1 = values.percentile(25)\n q3 = values.percentile(75)\n iqr = q3 - q1\n lower = q1 - (iqr * 1.5)\n upper = q3 + (iqr * 1.5)\n inrange = values.select { |v| v >= lower && v <= upper }\n lower = [lower, inrange.min].max\n upper = [upper, inrange.max].min\n belowrange = values.select { |v| v < lower }\n aboverange = values.select { |v| v > upper }\n [belowrange, lower, upper, aboverange]\nend",
"def ordinal_rank(percentile, size)\n # n = P / 100 * N + 1/2\n ((percentile / 100.0 * size) + 0.5)\n end",
"def percentile(pct)\n n = raw_statistics.length\n i = ((pct.to_f / 100) * n).ceil\n\n x = raw_statistics[n - (i - 0)]&.won || 0\n y = raw_statistics[n - (i - 1)]&.won || 0\n\n ((x + y).to_f / 2).ceil\n end",
"def upper_limit_for(desired_prime_number)\n i = 2\n while (i / Math.log(i)) < desired_prime_number do\n i = i + 1\n end\n return i\n end",
"def percentile_index(percentile)\n index = (self.samples_count * percentile.to_f / 100).to_i\n index.zero? ? index : index - 1\n end",
"def irvitaminas\n vag=(vitymin * 100) / 50\n vag.round(2)\n end",
"def tau(num)\r\n\ttmp = num.prime_division.map(&:last)\r\n#\tnum.prime_division.each{ |i| puts i.join(', ') }\r\n\ttmp.inject(1){|prod,i| prod *= i+1}\r\nend"
] |
[
"0.7934418",
"0.73654604",
"0.72243565",
"0.7124244",
"0.71010566",
"0.70272595",
"0.6925963",
"0.6925916",
"0.68456227",
"0.68196166",
"0.68000853",
"0.65981805",
"0.6504334",
"0.64692694",
"0.6363976",
"0.63264924",
"0.6234617",
"0.6131828",
"0.6009446",
"0.6008697",
"0.5848882",
"0.5761135",
"0.57507527",
"0.5681245",
"0.56686294",
"0.56545204",
"0.5622921",
"0.5598282",
"0.55564",
"0.5469665",
"0.5426372",
"0.5422399",
"0.54156446",
"0.5382719",
"0.5371423",
"0.53589785",
"0.53546315",
"0.53546315",
"0.53345436",
"0.5334405",
"0.5269466",
"0.52411824",
"0.52375454",
"0.5232012",
"0.52288145",
"0.5224967",
"0.52230513",
"0.52218103",
"0.52075523",
"0.5207541",
"0.5195408",
"0.51922727",
"0.5185705",
"0.5185329",
"0.5164663",
"0.5162729",
"0.5160736",
"0.5145642",
"0.5145044",
"0.5143293",
"0.5141537",
"0.5122547",
"0.51158726",
"0.51158726",
"0.5107465",
"0.5100799",
"0.5099282",
"0.5098069",
"0.5088633",
"0.5072273",
"0.5056741",
"0.5056328",
"0.50522804",
"0.50487244",
"0.5037634",
"0.5031463",
"0.5025408",
"0.5017349",
"0.5016568",
"0.50134724",
"0.49991786",
"0.4996687",
"0.49907362",
"0.49903828",
"0.49784",
"0.49768305",
"0.4975478",
"0.49631032",
"0.494677",
"0.49466425",
"0.49412078",
"0.49405167",
"0.49396652",
"0.49302563",
"0.49293151",
"0.49286968",
"0.49243864",
"0.49203274",
"0.49173585",
"0.4913553"
] |
0.8052058
|
0
|
tabulate elements and frequencies of an Enumerable return [Hash] return a hash of :element => :freq_count
|
def count_freq
hash = Hash.new(0)
self.each do |element|
hash[element] +=1
end
return hash
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def element_frequency_count\n collection.each_with_object(Hash.new(0)) {|element, occurrence| occurrence[element] += 1}\n end",
"def frequencies\n inject(Hash.new(0)) { |h,v| h[v] += 1; h }\n end",
"def frequency(a)\r\n a.group_by do |e|\r\n e\r\n end.map do |key, values|\r\n [values.size]\r\n end\r\nend",
"def compute_frequencies(list)\n dict = {}\n list.each do |token|\n unless dict.has_key?(token)\n dict[token] = list.count(token)\n end\n end\n dict\nend",
"def count_freq(array)\n array.each_with_object(Hash.new(0)) { |obj, counts| counts[obj] += 1 }\n end",
"def freq(array)\n hash = Hash.new(0)\n array.each{|key| hash[key] += 1}\n hash\nend",
"def freq_list\n freq_hash = each_with_object(Hash.new(0)) { |v, h| h[v] += 1 }\n freq_hash.sort_by { |k, v| -v }\n end",
"def element_count(arr)\n hash = {} \n\n # debugger \n arr.each {|ele| hash[ele] = arr.count(ele) }\n\n hash \nend",
"def count_elements(array)\n array.group_by(&:itself).map { |key, value| key.merge(count: value.length)} # counts number of times occur\nend",
"def counts\n count = Hash.new(0)\n self.each{|ele| count[ele] += 1}\n count\n end",
"def element_count(arr)\n fre = {}\n fre.default = 0\n arr.each { |el| fre[el] += 1 }\n return fre\nend",
"def count_elements(array)\n counts = Hash.new 0\n unique_elements = array.uniq\n\n unique_elements.each do |item|\n item[:count] = array.count(item)\n end\n\n unique_elements\nend",
"def compute_frequencies\n @transitions.map { |value, transition_hash|\n sum = 0.0\n transition_hash.each { |succ_value, occurencies| \n sum += occurencies\n }\n \n transition_hash.each { |succ_value, occurencies|\n @frequencies[value] ||= Hash.new{0}\n @frequencies[value][succ_value] = occurencies/sum \n }\n }\n end",
"def freq_calc(mult_arr)\n\tresult_arr = []\n\tsubarrs_by_index = reorder_on_index(mult_arr)\n\tsubarrs_by_index.uniq.each do |arr|\n\t\tarr.uniq.each do |letter|\n\t\t\tresult_arr << {letter => (count(arr, letter))}\n\t\tend\n\t\tp arr.uniq\n\tend\n\treturn result_arr\nend",
"def count_elements(collections)\n counts = Hash.new(0)\n collections.collect {|element| counts[element]+=1 }\n counts.collect do |hash, number|\n hash[:count] = number\n end\n counts.keys\nend",
"def compute_element_occurrence(values)\n uniq_elements = Hash.new(0)\n values.map { |x| uniq_elements[x] += 1 }\n uniq_elements\nend",
"def frequency_of_items(sorted=true)\n \n items = self.all_items(uniq=false)\n table = {}\n \n items.each do |item|\n table.has_key?(item) ? table[item] += 1 : table[item] = 1\n end\n \n # sort descending : minus sign of value\n sorted ? table.sort_by{ |key, value| -value} : table\n end",
"def count_elements(array)\n #Build hash where key = name and val = count\n counts = Hash.new(0)\n array.each do |element|\n counts[element[:name]] += 1\n end\n\n #Turn this into array of hashes\n ret = []\n counts.map do |key, val|\n h = {}\n h[:name] = key\n h[:count] = val\n ret << h\n end\n ret\nend",
"def frequency\n counts = Hash.new(0)\n self.words.each { |word| counts[word] += 1 }\n counts\n end",
"def element_count(arr)\n newHash = Hash.new(0)\n arr.each{|x|newHash[x]+=1}\n return newHash\n\nend",
"def count_elements(animals)\n animal_hash = {}\n animals.each do |animal| \n animals.count(animal)\n animal_hash[animal] = animals.count(animal)\n end\n animal_hash\nend",
"def analyze_data(ary)\n frequency = count_frequency(ary)\n sort_hash(frequency)\nend",
"def count_occurrences(array)\n occurrences = {}\n\n array.uniq.each do |element|\n occurrences[element] = array.count(element)\n end\n\n occurrences.each do |element, count|\n puts \"#{element} => #{count}\"\n end\nend",
"def count_occurrences(array)\n frequncies = Hash.new(0)\n\n array.each do |word|\n frequncies[word] += 1\n end\n\n frequncies.each do |word, frequency|\n puts \"#{word} => #{frequency}\"\n end\nend",
"def count_elements(array)\n array.each_with_object(Hash.new(0)){|arr, hash| hash[arr[:name]] += 1}.map{|key, value|{:name=>key, :count=>value}}\nend",
"def count_occurrences(array)\n\toccurences = {}\n\n\tarray.each do |element|\n\t\toccurences[element] = array.count(element)\n\tend\n\n\toccurences.each do |element, count|\n\t\tputs \"#{element} => #{count}\"\n\tend\t\nend",
"def count_elements(array)\n array.uniq.collect do |word|\n word[:count] = array.count(word)\n word\n end\nend",
"def frequencies_of(option)\n frequencies = Hash.new(0)\n if option == :artists\n artists.each do |artist|\n frequencies[artist] += 1\n end\n frequencies\n elsif option == :genres\n genres.each do |genre|\n frequencies[genre] += 1\n end\n frequencies\n elsif option == :tracks\n tracks.each do |track|\n frequencies[track] += 1\n end\n frequencies\n end\n end",
"def count_elements(array)\n new_array = array.uniq\n new_array.each do |hash|\n hash[:count] = array.count(hash)\n end\n new_array\nend",
"def count_occurences_w_hash(arry)\n occurrences = {}\n \n arry.each {|ele|\n occurrences[ele] = arry.count(ele)\n }\n \n occurrences.each {|k,v|\n puts \"#{k.to_s} => #{v}\"\n }\nend",
"def count(array)\n hash = {}\n array.each do |item|\n hash[item] = array.count(item)\n end\n hash\nend",
"def frequencies\n $heap[:word_freqs] = {}\n $heap[:count] = 0 # we need because of operator order, see below\n # A little flavour of the real Forth style here...\n while $stack.length > 0\n # ...but the following line is not in style, because the \n # naive implementation would be too slow\n if $heap[:word_freqs].include? $stack.last\n # Increment the frequency, postfix style: f 1 +\n $stack.push $heap[:word_freqs][$stack.last] # push f\n $stack.push 1\n $stack.push $stack.pop + $stack.pop\n else\n $stack.push 1\n end\n # Load the updated freq back onto heap\n $heap[:count] = $stack.pop\n $heap[:word_freqs][$stack.pop] = $heap[:count] # can't write head[_][stack.pop] = stack.pop\n end\n # Push result onto the stack\n $stack.push $heap[:word_freqs]\n $heap[:word_freqs] = nil; $heap[:count] = nil # Don't need this variable\nend",
"def count_hash(arr)\n count = {}\n arr.each {|e|\n count[e] ||= 0\n count[e] += 1\n }\n count\n end",
"def freq\n @freq ||= begin\n # calculate ngram counts for the haystack\n counts = Hash.new(0)\n veach(\"Haystack\", @haystack) do |element|\n element.ngrams.each do |ngram|\n counts[ngram] += 1\n end\n end\n\n # turn counts into inverse frequencies\n map = Hash.new(1)\n total = counts.values.inject(&:+).to_f\n counts.each do |ngram, count|\n map[ngram] = ((total / count) * 10).round\n end\n map\n end\n end",
"def count_occurences(array = [])\n elements = {}\n array.each { |e| elements[e] = array.count(e) }\n elements.each { |key, value| puts \"#{key} => #{value}\" }\nend",
"def count_elements(array)\n\t# My attempt:\n\t# hash = {}\n\t# array.each do |e|\n\t# \thash[e] = 1\n\t# end\n\t# new_array = []\n\t# hash.each do |animal, count|\n\t# \tnew_array = hash.select{|animal2, count2| animal2 == animal}\n\t# end\n\t# new_array\n\n\t# Stack Overflow:\n\tcounts = Hash.new(0) # sets default value (the value that is returned when trying to access key that does not exist) to 0 instead of nil\n\tarray.each { |e| counts[e] += 1 }\n\tcounts\nend",
"def occurences_count\n\t\t\t\t\t\tHash.new(0).tap do |result|\n\t\t\t\t\t\t each { |item| result[item] += 1 }\n\t\t\t\t\t\tend\n\t\t\t\tend",
"def element_count(arr)\n # Write your code here\n array = arr.uniq\n result = {}\n i = 0\n x = array.length\n loop do\n result.store(array[i],arr.count(array[i]))\n i += 1\n break if i == x\n end \nreturn result\nend",
"def Occurrence_count(arr)\n\th1={}\n\tarr.each do |element|\n\t\th1[\"#{element}\"].nil? ? h1[\"#{element}\"]=1 : h1[\"#{element}\"]+=1\n\tend\n\th1.each do |key,value|\n\t\tputs \"\tOccurrence of #{ key } in the array is #{value} times \"\n\tend\t\nend",
"def element_count(arr)\n\n # initialize 0 as needed to count\n count = Hash.new(0)\n arr.each do |c|\n count[c] += 1 \n end\n return count\n\nend",
"def count_frecuency(word_list)\n\tcounts = Hash.new(0) #es un hash que estará inicializado en 0, si indexamos en un key que no existe este retornará 0\n\tword_list.each do |word|\n\t\tcounts[word] +=1 #counts[word] es un hash con la clave del item actual, sabiendo que en principio no hay ningun item cuando asigne counts[word] +=1, sumará 1+0 ya que en principio el hash esta inicializado en 0\n \tend\n\tcounts\t\nend",
"def favorite_food_frequency\n all_favorite_foods.each_with_object(Hash.new(0)) do |food, object|\n object[food] += 1\n end\n end",
"def count_frequency(word_list)\n counts = Hash.new(0)\n for word in word_list\n counts[word] += 1\n end\n counts\nend",
"def count_occurrences(arr)\n answer = Hash.new(0)\n arr.each { |item| answer[item] += 1}\n answer.each {|key, value| puts \"#{key} => #{value}\" }\nend",
"def count_frequency(word_list)\n\tcounts = Hash.new(0)\n\tfor word in word_list\n\t\tcounts[word] += 1\n\tend\n\tcounts\nend",
"def solution0(a)\n\n total_count = 0\n elem_counts = Hash.new(0)\n\n a.each do |elem|\n elem_counts[elem] += 1\n total_count += 1 if elem_counts[elem] == 2\n end\n\n return total_count\n\nend",
"def calculate_term_frequencies\n results = []\n \n @data.each do |document|\n document_result = {}\n \n document.each do |term|\n if document_result.key?(term)\n document_result[term] += 1.0\n else\n document_result[term] = 1.0\n end\n end\n \n # Normalize the count\n document_result.each_key do |term|\n document_result[term] /= document.size\n end\n \n results << document_result\n end\n \n results\n end",
"def count_occurrences(array)\n number_of_occurrences = {}\n array.each do |element|\n if number_of_occurrences.include?(element)\n number_of_occurrences[element] += 1\n else\n number_of_occurrences[element] = 1\n end\n end\n number_of_occurrences\nend",
"def count_value_frequency\n frequency = []\n @item.reviews.each do |review|\n review.properties.each do |k, v|\n frequency << k\n frequency << v\n end\n end\n frequency.each_slice(2).to_a\n end",
"def gem_element arr\n freq = Hash.new(0)\n count = 0\n\n combo = arr.map(&:chars).map(&:uniq).flatten\n combo.each{ |key| freq[key]+=1 }\n freq.each{ |k,v| count +=1 if v == arr.size }\n count\n \nend",
"def get_freq\n #instantiate with values to ensure consistent ordering\n freq = { 1 => 0, 2 => 0, 3 => 0, 4 => 0, 5 => 0 }\n #sum up freqencies of each number\n last_100 = get_last_100\n last_100.each do |item|\n freq[item.to_i] += 1\n end\n # convert to percentage\n freq.each do |key, val|\n #divide by real length to handle case of less than 100 outputs\n freq[key] = val / last_100.length.to_f\n end\n freq\n end",
"def count_occurrences(array)\n hash = {}\n array.each do |element|\n if hash.has_key?(element)\n hash[element] += 1\n else\n hash[element] = 1\n end\n end\n hash.each { |key, value| puts \"#{key} => #{value}\" }\nend",
"def highestfrequency\r\n #@counts.group_by { |x| x }.map { |element, matches| [ element, matches ] }.to_h\r\n #@counts.each_with_object({}) { |item, memo| memo[item] ||= 0; memo[item] += 1 }\r\n ##@counts.uniq.map { |x| [x, @counts.count(x)] }.to_h\r\n #freq = @counts.inject(Hash.new(0)) { |h,v| h[v] += 1; h }\r\n @counts.max_by { |k,v| v }\r\n end",
"def hash_letter_freq( array )\n\n i = 0 # keeps track of outter loop\n hash = Hash.new()\n\n while( array.length > i )\n\n count = 1\n\n i2 = 1 + i # keeps track of inner while loop\n\n while( array.length > i2 ) # this will never check the last element of the array - otherwise have i2 check itself by doing i2 = i\n\n # puts(\"i #{i} | i2 #{i2}\") -- check if iteration is made right\n\n if( array[i] == array[i2] )\n count += 1\n end\n\n i2 += 1\n end # inner - while\n\n # alternative cond: hash.has_key?(\"#{array[i]}\") http://ruby-doc.org/core-1.9.3/Hash.html#method-i-has_key-3F\n if( hash[\"#{array[i]}\"] == nil ) # checks if key exists\n hash[\"#{array[i]}\"] = count\n end\n\n # for the last element in the array -- skipped by i2\n if( i2 == array.length )\n if( hash[\"#{array[i]}\"] == nil )\n hash[\"#{array[i]}\"] = 1\n end\n end\n\n\n i += 1\n end # while -outter\n\n # puts( hash )\n return hash\n\nend",
"def calculate_frequencies\n order_attributes(true)\n build_tree\n end",
"def count_occurence(array)\n counts = Hash.new(0)\n array.each { |name| counts[name] += 1 }\n puts counts\n\n price_calculator=PriceCalculator.new\n price_calculator.sepitem_quantity(counts)\n\n end",
"def count_occurrences(array)\n occurences = {}\n array.each do |element|\n if occurences.key?(element)\n occurences[element] += 1\n else\n occurences[element] = 1\n end\n end\n\n occurences.each { |key, value| puts \"#{key}: #{value}\" }\nend",
"def freqs(cts)\n total = cts.values.inject(0) {|memo, obj| memo + obj}\n freqs = Hash.new()\n cts.each {|k, v|\n freqs[k] = v.to_f / total\n }\n freqs\n end",
"def count_occurrences(array)\n occurances = {}\n\n array.each do |item|\n if occurances[item]\n occurances[item] += 1\n else \n occurances[item] = 1\n end\n end\n \n occurances.each do |key, value| \n puts \"#{key} => #{value}\"\n end\nend",
"def word_frequency(words)\n frequencies = Hash.new(0)\n words.each do |word|\n frequencies[word] += 1\n end\n frequencies\nend",
"def tags\n articles.map { |article| article[:tags] }.flatten.compact.inject(Hash.new(0)) { |frequency_map, tag|\n frequency_map[tag] += 1\n frequency_map\n }\nend",
"def count_occurrences(array)\n count = ''\n output = { }\n\n array.each do |item|\n count = array.count(item)\n output[item] = count\n end\n output.each do |key, value|\n puts \"#{key} => #{value}\"\n end\nend",
"def find_elements(arr)\n elements = Hash.new(0)\n\n arr.each { |ele| elements[ele] += 1 }\n\n elements\nend",
"def count_occurrences_improved(arr)\n counts = Hash.new { |h, k| h[k] = 0 }\n arr.each { |element| counts[element] += 1 }\n counts.each { |element, count| puts \"#{element} => #{count}\" }\nend",
"def frequency\n \n end",
"def get_item_frequency_counts orders\n\n counts = {}\n\n orders.each do |order|\n items = order['line_items']\n items.each do |item|\n id = item['product_id']\n if counts[id]\n counts[id] += 1\n else\n counts[id] = 1\n end\n end\n end\n\n counts\n\nend",
"def counts\n @counts ||=\n begin\n h = {}\n by_label.each do |label, notes|\n h[label] = notes.size\n end\n h\n end\n end",
"def count_elements(arr)\n hash = {}\n count = 0\n\n arr.each do |x|\n if !hash.key?(x)\n hash[x] = true\n end\n end\n\n arr.each do |x|\n if hash.key?(x+1)\n count += 1\n end\n end\n\n count\nend",
"def count_occurrences(array)\n count = Hash.new\n counter = 0\n array.each { |i| \n if count[i] == nil\n count[i] = 1\n else\n count[i] = count[i] += 1\n end\n counter += 1\n }\n count.each_pair { |k, v| puts \"#{k} => #{v}\"}\nend",
"def frequencies\n analyzer = Frequency.call(\n dataset: dataset,\n stemming: stemming,\n block_size: window,\n last_block: :small_last,\n split_across: false,\n progress: ->(p) { progress&.call((p.to_f / 100.0 * 33.0).to_i) }\n )\n\n # Combine all the block hashes, summing the values\n total = analyzer.blocks.size.to_f\n\n base_frequencies = {}\n analyzer.blocks.each_with_index do |b, i|\n progress&.call((i.to_f / total * 16.0).to_i + 33)\n\n b.each_key do |k|\n base_frequencies[k] ||= 0\n base_frequencies[k] += 1\n end\n end\n\n # Get the frequencies of cooccurrence with the word in question\n joint_frequencies = {}\n pairs.each_with_index do |(word, word2_array), i|\n joint_frequencies[word] = {}\n\n analyzer.blocks.each_with_index do |b, j|\n if progress\n p = (i.to_f / pairs.size.to_f) +\n (1 / pairs.size.to_f) * (j.to_f / total.to_f)\n progress.call((p * 17.0).to_i + 49)\n end\n\n next unless b[word]&.>(0)\n\n if word2_array.empty?\n b.each_key do |k|\n joint_frequencies[word][k] ||= 0\n joint_frequencies[word][k] += 1\n end\n else\n word2_array.each do |w|\n if b.key?(w)\n joint_frequencies[word][w] ||= 0\n joint_frequencies[word][w] += 1\n end\n end\n end\n end\n end\n\n [base_frequencies, joint_frequencies, analyzer.blocks.size]\n end",
"def results_frequency_for_each_combination\n category_id = self.id\n results = Result.where({\"category_id\" => category_id})\n result_hash = Hash.new(0)\n count = 0\n\n results.each do |combo| \n winner = combo.loved_id\n loser = combo.lost_id\n if winner != nil && loser != nil\n result_hash[winner.to_s + \"-\" + loser.to_s] += 1\n end\n end\n return result_hash\n end",
"def grams\n @frequencies.keys\n end",
"def word_frequency\n @word_use = Hash.new(0)\n words.each { |w| @word_use[w] += 1 }\n @word_use\n end",
"def calculate_term_frequencies\n results = []\n\n @tokenized_documents.each do |tokens|\n document_result = {}\n tokens[:words].each do |term, count|\n document_result[term] = (count/tokens[:total_count].to_f).round(6)\n end\n\n results << document_result\n end\n\n results\n end",
"def word_frequency(text)\n norm_array = normalize(text).to_a\n freq = { }\n norm_array.each_with_object(Hash.new(0)){|key,hash| hash[key] += 1}\nend",
"def count_elements(arr)\n counter = Array.new\n counter_helper = Array.new\n arr.each do |element|\n if counter_helper.include?(element)\n counter[counter_helper.find_index(element)][:count] += 1\n else\n counter_helper.push(element.clone)\n element[:count] = 1\n counter.push(element)\n end\n end\n counter\nend",
"def array_to_count_hash(arr)\n h = {}\n arr.each do |el|\n if h.has_key?(el)\n h[el] += 1\n else\n h[el] = 1\n end\n end\n return h\n end",
"def count_occurrences1(array)\n occurrences = {}\n\n array.map(&:downcase).each do |element|\n occurrences[element] = array.count(element)\n end\n\n occurrences.each do |element, count|\n puts \"#{element} => #{count}\"\n end\nend",
"def frequencies(column, normalizer)\n frequency_table = {}\n column_name_sym = column[:column_name].to_sym\n if normalizer\n sample.each do |row|\n elem = normalizer.call(row[column_name_sym])\n update_frequency_element(frequency_table, elem)\n end\n else\n sample.each do |row|\n elem = row[column_name_sym]\n update_frequency_element(frequency_table, elem)\n end\n end\n length = sample.count.to_f\n frequency_table.map { |key, value| value / length }\n end",
"def get_element_and_attribute_counts(document)\n elements = {}\n attributes = {}\n document.elements.each do |element|\n element.traverse do |n|\n next unless n.element?\n path = n.ancestors.map {|x| x.name}.reverse.push(n.name).drop(1).join(\"/\")\n if elements.keys.include?(path)\n elements[path] += 1\n else\n elements[path] = 1\n end\n n.keys.each do |k|\n if attributes.keys.include?(\"#{path}[@#{k}]\")\n attributes[\"#{path}[@#{k}]\"] += 1\n else\n attributes[\"#{path}[@#{k}]\"] = 1\n end\n end\n end\n end\n return elements, attributes\n end",
"def serializable_hash \n results.each.inject(empty_bins) do |histogram, result|\n histogram[result] = histogram[result] ? histogram[result] + 1 : 1; histogram\n end\n end",
"def getfreqs\n @freqs = Hash.new\n @fieldvalues.each do |v|\n @freqs[v] = @db.execute(\"select count(*) from #{@tablename} where #{@fieldname} = '#{v}'\").to_s \n end\nend",
"def count_occurrences(array)\n result = {}\n array.each do |x|\n result[x] = if !result.key?(x)\n 1\n else\n result.fetch(x) + 1\n end\n end\n result.each do |k, count|\n p \"#{k} => #{count}\"\n end\nend",
"def count_by(&block)\n self.group_by(&block)\n .map{ |key, items| [key, items&.count] }\n .to_h\n end",
"def count_by(&block)\n self.group_by(&block)\n .map{ |key, items| [key, items&.count] }\n .to_h\n end",
"def count_elements(array)\n new_hash = {}\n count = 0\n array.each do |x|\n if new_hash.key? x\n new_hash[x] = new_hash[x] + 1\n #binding.pry\n else\n new_hash[x] = 1\n end\n end\n new_hash\n # code goes here\nend",
"def count_occurrences(list)\n keys = list.uniq\n count = keys.map{ |key| list.count(key) }\n keys.each_index{ |indx| puts \"#{keys[indx]} => #{count[indx]}\"}\nend",
"def count(r)\n c = Hash.new(0)\n r.each { |z| c[z] += 1}\n c\nend",
"def checkSearchTerms(wordHash, searchTermsArray, documentCounter, resultsHash, wordArray)\n documentCounter;\n documentNumber = \"Document \" + documentCounter.to_s\n searchTermsArray.each do |word|\n resultsHash.merge!(word => { documentNumber => wordHash[word]})\n # need to figure out the frequency based on the wordHash[word] and the wordArray.length\n end\n # puts wordArray.length\n # puts resultsHash\nend",
"def count_elements(collection)\n count_array = []\n hash_array = []\n\n collection.each do |hash|\n\n if count_array.include?(hash[:name])\n hash_array.each do |value|\n if value[:name] == hash[:name]\n value[:count] = value[:count] + 1\n end\n end\n else\n new_hash = {}\n new_hash[:name] = hash[:name]\n new_hash[:count] = 1\n\n count_array << hash[:name]\n hash_array << new_hash\n end\n\n\n end\n\n return hash_array\nend",
"def collect_values_with_count\n\t\tvalues = Hash.new {|h,k| h[k]=0}\n\t\tself.class.ecore.eAllAttributes.each do |a|\n\t\t\tv = self.send(:\"#{a.name}\")\n\t\t\tif v!=nil\n\t\t\t\tif a.many\n\t\t\t\t\tv.each {|el| values[el]+=1}\n\t\t\t\telse\n\t\t\t\t\tvalues[v]+=1\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\tvalues\t\t\t\n\tend",
"def my_uniq(arr)\n #make hash with each item in teh array as a key, and the value will be its frequency\n new_arr = []\n freqhash = Hash.new(0)\n arr.each do |ele| \n freqhash[ele] += 1\n end\n \n freqhash.each do |k, v| \n new_arr << k\n end\n \n new_arr\nend",
"def sort_by_occurrence_h(input)\n output = input.each_with_object(Hash.new(0)){ |tag, counts| counts[tag] += 1 }\n output = Hash[output.sort_by{ |tags, counts| counts}.reverse]\n return output\n end",
"def mode(arr)\n\tarr.sort!\n\tfreq_val = Hash.new(0)\n\tarr.each{ |i|\n\t freq_val[i] += 1 }\n\t freq_val.sort_by { |k,v| v}\n\t return freq_val.values[0]\nend",
"def calcuate_frequencies(sequences)\n freq_array = Array.new(4) {|i|Array.new(10){|i| 0}} #2-dimensional array, second dimension initialised to 0's\n sequences.each do |seq|\n for position in 0..3\n freq_array[position][seq[position].to_i] += 1 #increment frequency value by 1\n end\n end\n freq_array\nend",
"def genre_count(hash)\n\thash.group_by { |k, v| v[:genre] }.map { |k, v| { k => v.count } }\nend",
"def count_elements(array)\n counted = []\n array.each do |item|\n item[:count] = array.count(item)\n counted << item\n end\n return counted.uniq{ |item|\n item[:name]\n }\nend",
"def document_frequency\n @corpus.each_with_object({}) do |doc, df|\n doc.bag_of_words.keys.each do |word|\n df[word] = (df.fetch(word) { 0.0 }) + 1.0\n end\n end\n end",
"def overall_frequency\n categories.inject(0) { |carry, item| carry + item[1] }\n end",
"def analysis\n hash = {}\n @array.each do |item|\n chars = item.chars.to_a - @used_chars\n\n chars.each do |char|\n if hash[char] == nil\n hash[char] = 1\n else\n hash[char] += 1\n end\n end\n end\n\n hash.sort_by { |_, v| -v }\n end"
] |
[
"0.78163415",
"0.73577553",
"0.71876377",
"0.7151512",
"0.70271146",
"0.69654363",
"0.67742014",
"0.6757071",
"0.6754002",
"0.6748162",
"0.67333263",
"0.6732251",
"0.67198086",
"0.65939933",
"0.6572978",
"0.65581775",
"0.6548955",
"0.6539481",
"0.6493705",
"0.64782935",
"0.64599437",
"0.6451593",
"0.64279526",
"0.64246124",
"0.64244425",
"0.6397569",
"0.6392661",
"0.63913155",
"0.6373951",
"0.63685745",
"0.6316524",
"0.6291591",
"0.6289593",
"0.627801",
"0.6273403",
"0.6262769",
"0.6262595",
"0.6261034",
"0.6228991",
"0.6214699",
"0.6214352",
"0.61911315",
"0.61769515",
"0.6136217",
"0.61314917",
"0.6124242",
"0.61180323",
"0.61156994",
"0.6111056",
"0.6097738",
"0.6094196",
"0.60848504",
"0.606975",
"0.6063801",
"0.6053124",
"0.6030112",
"0.6016817",
"0.6014193",
"0.6013628",
"0.6012823",
"0.6008399",
"0.6001695",
"0.5989766",
"0.5986634",
"0.5976348",
"0.59689176",
"0.5957758",
"0.5948437",
"0.5937746",
"0.5935534",
"0.59300286",
"0.5913245",
"0.5911712",
"0.59007806",
"0.59004503",
"0.58951527",
"0.58608496",
"0.5860102",
"0.5859058",
"0.58531606",
"0.5841739",
"0.5823598",
"0.5819404",
"0.5800121",
"0.5800121",
"0.57944816",
"0.5793332",
"0.5791041",
"0.57857454",
"0.5773825",
"0.57674557",
"0.5762924",
"0.5762762",
"0.5756618",
"0.57469726",
"0.5743667",
"0.5741717",
"0.57410455",
"0.5733274",
"0.5731254"
] |
0.80565524
|
0
|
Process for moving any binders
|
def moveitem
errors = []
@binder = Binder.find(params[:id])
if params[:target] != params[:id]
src = Mongo.log(current_teacher.id.to_s,
__method__.to_s,
params[:controller].to_s,
@binder.id.to_s,
params)
@binder.sift_siblings()
@inherited = inherit_from(params[:target])
@parenthash = @inherited[:parenthash]
@parentsarr = @inherited[:parentsarr]
@parentperarr = @inherited[:parentperarr]
@parent_child_count = @inherited[:parent_child_count]
#nps = new parents, ops = old parents
@nps = @parentsarr.collect {|x| x["id"] || x[:id]}
if !@nps.include?(params[:id])
@ops = @binder.parents.collect {|x| x["id"] || x[:id]}
@ops.each do |opid|
if opid != "0"
op = Binder.find(opid)
op.update_attributes( :owned_fork_total => op.owned_fork_total - (@binder.fork_total+@binder.owned_fork_total),
:files => op.files - @binder.files,
:folders => op.folders - @binder.folders - (@binder.type == 1 ? 1 : 0),
:total_size => op.total_size - @binder.total_size,
:pub_size => op.pub_size - @binder.pub_size,
:priv_size => op.priv_size - @binder.priv_size)
end
end
#Binder.find(op.last).inc(:children,-1)
# DELAYTAG
Binder.delay(:queue => 'thumbgen').generate_folder_thumbnail(@binder.parent["id"] || @binder.parent[:id])
#Save old permissions to remove childrens' inherited permissions
@ppers = @binder.parent_permissions
@binder.update_attributes( :parent => @parenthash,
:parents => @parentsarr,
:parent_permissions => @parentperarr,
:order_index => @parent_child_count)
# DELAYTAG
Binder.delay(:queue => 'thumbgen').generate_folder_thumbnail(@binder.parent["id"] || @binder.parent[:id])
# must update the common ancestor of the children before
@binder.update_parent_tags()
#@binder is the object being moved
#If directory, deal with the children
if @binder.type == 1 #Eventually will apply to type == 3 too
@children = @binder.subtree
@children.each do |h|
@current_parents = h.parents
@size = @current_parents.size
@npperarr = h.parent_permissions
@ppers.each {|p| @npperarr.delete(p)}
h.update_attributes(:parents => @parentsarr + @current_parents[(@current_parents.index({"id" => @binder.id.to_s, "title" => @binder.title}))..(@size - 1)],
:parent_permissions => @parentperarr + @npperarr)
h.update_parent_tags()
Mongo.log( current_teacher.id.to_s,
__method__.to_s,
params[:controller].to_s,
h.id.to_s,
params,
{ :src => src })
end
end
#Update new parents' folder/file/size counts
@parents = @binder.parents.collect {|x| x["id"] || x[:id]}
@parents.each do |pid|
if pid != "0"
parent = Binder.find(pid)
parent.update_attributes( :owned_fork_total => parent.owned_fork_total + (@binder.fork_total+@binder.owned_fork_total),
:files => parent.files + @binder.files,
:folders => parent.folders + @binder.folders + (@binder.type == 1 ? 1 : 0),
:total_size => parent.total_size + @binder.total_size,
:pub_size => parent.pub_size + @binder.pub_size,
:priv_size => parent.priv_size + @binder.priv_size)
end
end
else
errors << "Invalid target location"
end
else
errors << "You cannot put something inside itself"
end
rescue BSON::InvalidObjectId
errors << "Invalid Request"
rescue Mongoid::Errors::DocumentNotFound
errors << "Invalid Request"
ensure
respond_to do |format|
format.html {render :text => errors.empty? ? 1 : errors.map{|err| "<li>#{err}</li>"}.join.html_safe}
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def process_moves\n @delta[:moves].each do |move| process_move(move) end\n end",
"def move\n super\n gravitize\n end",
"def apply\n\t\tunless @already_added\n\t\t\t@space.entities.add @clone\n\t\t\t@already_added = true\n\t\tend\n\t\t\n\t\t@move_action.apply\n\tend",
"def move; end",
"def move; end",
"def process\n process_moves\n reassign_team_sets\n reset_quantitative_data\n #notify\n end",
"def forward(mappings)\n mappings.each do |from, to|\n from = event_model(from).symbol\n targets = Array[*to].map { |ev| event_model(ev).symbol }\n\n if event_model(from).terminal?\n non_terminal = targets.find_all do |name|\n !event_model(name).terminal?\n end\n unless non_terminal.empty?\n raise ArgumentError,\n \"trying to establish a forwarding relation from \"\\\n \"the terminal event #{from} to the non-terminal \"\\\n \"event(s) #{targets}\"\n end\n end\n\n forwarding_sets[from].merge targets\n end\n update_terminal_flag\n end",
"def move\n\n end",
"def doMove _obj, _args\n \"_obj doMove _args;\" \n end",
"def process_movement\n # Delete the graphics associated to moving\n @ranges.each{|tile| tile.visible = false}\n @ranges = []\n @arrow_path.each{|a| a.dispose}\n @arrow_path = []\n # Move the cursor back to the selected unit\n proc = Proc.new{@selected_unit.selected = false\n @show_move = false\n @selected_unit.sprite.move(@passed_positions)\n @selected_unit.stop_capture if @passed_positions.size != 0}\n cursor.add_move_action(@selected_unit.x, @selected_unit.y, proc)\n # go to phase 3\n @phase = 3\n end",
"def process_movement\n # Move the cursor back to the selected unit\n proc = Proc.new{@unit.selected = false\n @unit.sprite.move(@passed_positions.clone)\n @unit.stop_capture if @passed_positions.size != 0\n @passed_positions = []}\n cursor.add_move_action(@unit.x, @unit.y, proc, 0, nil, true)\n # Delete the arrow path graphics and move-range tiles\n @arrow_path.each{|a| a.dispose}\n @arrow_path = []\n remove_ranges\n # Disable input, proceed to moving unit\n cursor.disable_input = true\n @phase = 4\n end",
"def call_move_handler\n return if @move_handler.nil?\n @move_handler.call\n @move_handler = nil\n end",
"def move(rover)\n rover.command.each do |m|\n remove_rover(rover)\n rover.move(m)\n place_rover(rover)\n end\n end",
"def move\n \n end",
"def move\n \n end",
"def move _obj, _args\n \"_obj move _args;\" \n end",
"def pre_sync\n #move\n end",
"def switchmove _obj, _args\n \"_obj switchmove _args;\" \n end",
"def update_routine_move\n if @wait_count > 0\n @wait_count -= 1\n else\n @move_succeed = true\n command = @move_route.list[@move_route_index]\n if command\n process_move_command(command)\n advance_move_route_index\n end\n end\n end",
"def pbMapChangeMoveDependentEvents\n return\n end",
"def move(*args)\n \t# Sending destination path\n \tputs \"MOVING\"\n \tmove_entity(*args[0].public_path)\n \tsuper\n end",
"def commandMove _obj, _args\n \"_obj commandMove _args;\" \n end",
"def process_route_end\n if @move_route.repeat\n @move_route_index = -1\n elsif @move_route_forcing\n @move_route_forcing = false\n restore_move_route\n end\n end",
"def move(to)\n @moved = true\n super(to)\n end",
"def binder; end",
"def binder; end",
"def process_mover(move)\n from_team_set = get_team_set_by_team_id(move[:from])\n return unless from_team_set.present?\n to_team_set = get_team_set_by_team_id(move[:to])\n to_team = get_delta_team_by_id(move[:to])\n review_set = get_review_set_for_ownerable(from_team_set.id, move[:id])\n review_set = review_set_class.create(ownerable_id: move[:id], ownerable_type: user_class.name, team_set_id: to_team_set.id) if (!review_set.present? && to_team_set.present?)\n return unless review_set.present?\n if move[:to].present? && to_team_set.present?\n review_set.team_set_id = to_team_set.id\n review_set.save\n review_set.thinkspace_peer_assessment_reviews.destroy_all\n to_team[:total].each do |reviewable_id|\n review_class.create(reviewable_id: reviewable_id, reviewable_type: user_class.name, review_set_id: review_set.id)\n end\n else\n review_set.destroy\n end\n end",
"def moves\n # overridden in slideable/stepable modules\n end",
"def moves\n # warn \"Explorer: #{explorer.last}\"\n # warn @robots.map(&:last)\n # warn @items.map(&:last)\n\n clear_tasks\n assign_tasks\n\n @my_bots.map(&:next_command)\n end",
"def class_update\n if can_drop_bomb? and closest_target\n drop_bomb if on_top_of?(closest_target)\n if facing_right_of?(closest_target)\n turn_left\n end\n if facing_left_of?(closest_target)\n turn_right\n end\n end\n go_forward\n loop_position\n end",
"def post_sync\n reset_movement\n reset_flags\n end",
"def moving!\n end",
"def interpret_move(command)\n ensure_placed\n @robot.move_forward\n end",
"def process_handling\n super\n return prev_actor if handle?(:prev_actor) && Input.trigger?(:R)\n return next_actor if handle?(:next_actor) && Input.trigger?(:L)\n end",
"def move_entity entity; end",
"def move_type_path\n return if @path == :pending\n return unless movable?\n while (command = @path[@move_route_index])\n # @move_route_index += 1\n break if move_type_custon_exec_command(command)\n end\n end",
"def post_process\n end",
"def move_by *args\n incremental_position = parse_position(*args)\n incremental_position[:x] ||= 0\n incremental_position[:y] ||= 0\n objects = get_objects.select do |object|\n next object.is_a?(Mask)\n end\n # Move all children Masks back via #set_position.\n objects.each do |mask|\n mask.set_position(\n (mask.x - incremental_position[:x]),\n (mask.y - incremental_position[:y])\n )\n end\n super # Move Layer forward\n # Move all children Masks forward via #move_by.\n objects.each do |mask|\n mask.move_by incremental_position\n end\n end",
"def move_gear_post(gear, destination_container, state_map)\n app = gear.application\n reply = ResultIO.new\n gear_components = gear.component_instances\n start_order, stop_order = app.calculate_component_orders\n source_container = gear.get_proxy\n\n if gear.group_instance.platform.downcase == \"windows\"\n log_debug \"DEBUG: Restoring ownership and user ACLs for Windows gear '#{gear.uuid}'\"\n rsync_keyfile = Rails.configuration.auth[:rsync_keyfile]\n log_debug `eval \\`ssh-agent\\`; ssh-add #{rsync_keyfile}; ssh -o StrictHostKeyChecking=no -A root@#{destination_container.get_ip_address} \"/cygdrive/c/openshift/bin/oo-cmd.exe oo-admin-restore-acls --uuid:#{gear.uuid}\"; exit_code=$?; ssh-agent -k;exit $exit_code`\n end\n\n start_order.each do |cinst|\n next unless gear_components.include? cinst\n cart = cinst.cartridge_name\n idle, leave_stopped = state_map[cart]\n unless leave_stopped\n log_debug \"DEBUG: Starting cartridge '#{cart}' in '#{app.name}' after move on #{destination_container.id}\"\n args = build_base_gear_args(gear)\n args = build_base_component_args(cinst, args)\n reply.append destination_container.send(:run_cartridge_command, cart, gear, \"start\", args, false)\n end\n end\n\n log_debug \"DEBUG: Fixing DNS and mongo for gear '#{gear.uuid}' after move\"\n log_debug \"DEBUG: Changing server identity of '#{gear.uuid}' from '#{source_container.id}' to '#{destination_container.id}'\"\n gear.server_identity = destination_container.id\n # Persist server identity for gear in mongo\n res = Application.where({\"_id\" => app.id, \"gears.uuid\" => gear.uuid}).update({\"$set\" => {\"gears.$.server_identity\" => gear.server_identity}})\n raise OpenShift::OOException.new(\"Could not set gear server_identity to #{gear.server_identity}\") if res.nil? or !res[\"updatedExisting\"]\n\n gear.group_instance.gear_size = destination_container.get_node_profile\n # Persist gear size for current group instance in mongo\n res = Application.where({\"_id\" => app.id, \"group_instances._id\" => gear.group_instance.id}).update({\"$set\" => {\"group_instances.$.gear_size\" => gear.group_instance.gear_size}})\n raise OpenShift::OOException.new(\"Could not set group instance gear_size to #{gear.group_instance.gear_size}\") if res.nil? or !res[\"updatedExisting\"]\n begin\n dns = OpenShift::DnsService.instance\n public_hostname = destination_container.get_public_hostname\n dns.modify_application(gear.name, app.domain_namespace, public_hostname)\n dns.publish\n ensure\n dns.close\n end\n reply\n end",
"def moveInGunner _obj, _args\n \"_obj moveInGunner _args;\" \n end",
"def binder=(_arg0); end",
"def post_process\n bind_files\n make_tasks\n end",
"def FollowingMoveRoute(commands,waitComplete=false)\n $PokemonTemp.dependentEvents.SetMoveRoute(commands,waitComplete)\nend",
"def move(*args)\n begin\n move_no_cleanup(*args)\n rescue Orp::MovementAlreadyComplete\n warn \"Attempted to complete already completed movement\"\n nil\n rescue\n delete\n raise\n end\n end",
"def move\n begin\n conversation = params['conversation']\n message = @frontapp_service.get_message(conversation)\n if(@frontapp_service.has_spam_tag?(conversation) && !@frontapp_service.in_spam_inbox?(conversation))\n # has spam tag and is moved to non-spam folder\n Rails.logger.info \"------ MARKING MESSAGE AS HAM\\n#{message[0..255]}\\n------\"\n @spam_service.mark_ham(message)\n @frontapp_service.mark_ham(conversation)\n @message_service.mark_ham(conversation['id'], message)\n elsif !@frontapp_service.has_spam_tag?(conversation)\n # does not have spam tag and is moved to spam folder\n Rails.logger.info \"------ MARKING MESSAGE AS SPAM\\n#{message[0..255]}\\n------\"\n @spam_service.mark_spam(message)\n @frontapp_service.mark_spam(conversation)\n @message_service.mark_spam(conversation['id'], message)\n end\n render json: { ok: true }\n rescue => e\n Rails.logger.error \"[move] #{e.message}\\n#{e.backtrace.join(\"\\n\")}\"\n render json: { error: 'Oops, something did not go as planned' }, status: 500\n end\n end",
"def process_route_end\n if @move_route.repeat\n @move_route_index = -1\n elsif @move_route_forcing\n @on_path_finding = false\n @move_route_forcing = false\n restore_move_route\n end\n @move_type = @previous_move_type\n end",
"def move\n\t\t'moved passed'\n\tend",
"def retutn_map_postions\n $game_temp.battle_move = true\n pos = $game_temp.battle_result == 1 ? $game_temp.escape_pos : $game_temp.end_pos\n @moving_actors = []\n for i in 0...$game_party.actors.size\n @moving_actors[i] = i == 0 ? $game_player : $game_player.caterpillar[i-1]\n @moving_actors[i].move_update.clear if i > 0\n end\n started_moving = false\n loop do\n if started_moving == true\n for i in 0...$game_party.actors.size\n set_battle_position(@moving_actors[i], @actors_pos[i])\n end\n else\n for i in 0...$game_party.actors.size\n set_battle_position(@moving_actors[i], pos)\n end\n @actors_pos = set_end_postion(pos)\n end\n started_moving = true\n update_basic(false, true, true)\n break if all_in_postion(@actors_pos)\n end\n set_plus_postion\n $game_temp.battle_move = false\n wait(10)\n end",
"def move\n if !destination.alive\n Game.scene.remove_object self\n else\n d_x, d_y = *destination.position\n b_x, b_y = *position\n \n if d_x.round == b_x.round and d_y.round == b_y.round\n finished\n else\n vlen = Math.sqrt((d_x - b_x)*(d_x - b_x) + (d_y - b_y)*(d_y - b_y))\n\t \n\t m_x = (d_x - b_x)*speed/vlen\n\t m_y = (d_y - b_y)*speed/vlen\n\t \n\t position[0] += m_x\n\t position[1] += m_y\n end\n end\n end",
"def explore\n rover_bay.each do |r|\n if pass_path_check?(r)\n move(r)\n else\n raise \"There is a collision\\nin placement #{r.coordinate.inspect}, please revise instruction set #{r.command.inspect}\"\n end\n end\n end",
"def run_once(predictors)\n\t\t\t\tloop do\n\t\t\t\t\tmove = get_next_move(predictors)\n\t\t\t\t\tprocess_move(move)\n\t\t\t\t\tbreak if stage_num == nil\n\t\t\t\tend\n\t\t\tend",
"def setup_move\n return TSBS.error(@acts[0], 4, @used_sequence) if @acts.size < 5\n stop_all_movements\n goto(@acts[1], @acts[2], @acts[3], @acts[4], @acts[5] || 0)\n end",
"def moveInCommander _obj, _args\n \"_obj moveInCommander _args;\" \n end",
"def moveInDriver _obj, _args\n \"_obj moveInDriver _args;\" \n end",
"def capture(direction)\r\n @warrior.bind!(direction)\r\n end",
"def move_dirs\n \n end",
"def move(direction)\n \n end",
"def set_move_route(commands,waitComplete=true)\n $PokemonGlobal.dependentEvents.each_with_index do |event,i|\n next if !event[8][/FollowerPkmn/]\n pbMoveRoute(@realEvents[i],commands,waitComplete)\n end\n end",
"def move_folder_ind\n create_process(process: \"MOVE_FOLDER\")\n end",
"def post_process; end",
"def smove(source, destination, member); end",
"def smove(source, destination, member); end",
"def forward(steps)\n move(steps)\n end",
"def move\n move_by a, m\n end",
"def after_processing\n end",
"def move_finished\n @glade['toolbar_generate_map'].sensitive = true\n @glade['toolbar_record_points'].sensitive = true\n @locate_thread = nil\n @glade['toolbar_move'].active = false\n end",
"def process_hooks(user, actual_targets)\n exec_hooks(Move, :process_hooks, binding)\n return true\n end",
"def retract_reverse_mappings\n @binary_mappings.each do |object_type, mapping|\n mapping.all_member.to_a. # Avoid problems with deletion from all_member\n each do |member|\n next unless member.is_a?(MM::Mapping)\n member.retract if member.forward_mapping # This is the reverse of some mapping\n end\n mapping.re_rank\n end\n end",
"def execute_move\n\t\traise RuntimeError, 'This must be implemented in child class'\n\tend",
"def after_processing_hook; end",
"def move(key, db); end",
"def move(key, db); end",
"def postprocess\n @@morphs.each do |morph|\n # this does a simple replacement for character groups, so that:\n # \"(|A)\" becomes the equivalent of \"(#{Rule['A'].chars.join('|')})\"\n morph.from.gsub!(/(\\||\\&)([A-Z])/) { Rule[$2].chars.join($1 == '|' ? $1 : '') }\n morph.from = Regexp.new(morph.from)\n end\n end",
"def set_actor_postions(actors_pos)\n $game_temp.battle_move = true\n $game_temp.actors_start_position = []\n @moving_actors = []\n for i in 0...$game_party.actors.size\n $game_temp.actors_position[i] = set_actors_screen_postion(actors_pos[i])\n @moving_actors[i] = i == 0 ? $game_player : $game_player.caterpillar[i-1]\n @moving_actors[i].move_update.clear if i > 0\n end\n loop do\n for i in 0...$game_party.actors.size\n set_battle_position(@moving_actors[i], actors_pos[i])\n $game_temp.actors_position[i] = set_actors_screen_postion(actors_pos[i])\n end\n update_basic(false, true, true)\n break if all_in_postion(actors_pos)\n end\n $game_temp.battle_move = false\n wait(10)\n end",
"def lmove(source, destination, where_source, where_destination); end",
"def lmove(source, destination, where_source, where_destination); end",
"def move_later\n nekst = self.next\n self.append_to(nekst) if nekst\n end",
"def forward; end",
"def forward; end",
"def move(pid, num_punters, map, claimed, rem, setup=false, tbl=nil)\n sites = map['sites']\n rivers = map['rivers']\n mines = map['mines']\n _format = \"\"\"\nInvoke C++ program with the following format:\nn m k pid np\ns_1 t_1 c_1\n...\ns_m t_m c_m (edges)\na_1 ... a_k (mines)\nmode\nextra\n\n0 <= s_i, t_i < m\n-1 <= c_i < np (-1: not claimed)\n0 <= a_i < n\n\n\nif mode == 'state'\n extra == ''\n The C++ program should return\n 'tbl (state)'\n where state is a string representing a state (without spaces)\nif mode == 'run'\n extra looks like:\ntbl\nai_kind\n The C++ program should return\n 'pass'\n or\n 'claim s t'\n in one line.\n \"\"\"\n n = sites.size\n m = rivers.size\n k = mines.size\n np = num_punters\n edges = []\n cl = {}\n for c in claimed\n cl[[c[1], c[2]]] = c[0]\n end\n for e in rivers\n col = -1\n if cl[[e['source'], e['target']]]\n col = cl[[e['source'], e['target']]]\n end\n edges << [e['source'], e['target'], col]\n end\n io = IO.popen(File.expand_path(File.dirname($0)) + '/core', 'r+')\n io.puts(\"#{n} #{m} #{k} #{pid} #{np} #{rem}\")\n for i in 0 ... m\n io.puts(edges[i].join(' '))\n end\n mine_ids = []\n for i in 0 ... k\n mine_ids << (mines[i]).to_s\n end\n io.puts(mine_ids.join(' '))\n ai_kind = @ai_kind\n if ai_kind == 'hybrid'\n # Choose AI type by np, size, and so on\n if np == 2\n ai_kind = 'two_player_minmax'\n elsif np >= 4\n ai_kind = 'mine_connect'\n else\n ai_kind = 'greedy'\n end\n end\n if setup\n io.puts('setup')\n else\n io.puts('run')\n io.puts(tbl)\n io.puts(ai_kind)\n end\n io.close_write\n eval = 0\n STDERR.puts(\"playing as punter #{pid} (total = #{num_punters})\")\n while answer = io.gets.chomp.split\n if answer[0] != 'info'\n break\n end\n # info eval (turns) (value)\n if answer[1] == 'eval'\n turns = answer[2].to_i\n eval = answer[3].to_i\n if turns >= 0\n STDERR.puts(\"evaluation: turns=#{turns}, value=#{eval}\")\n else\n STDERR.puts(\"full evaluation: value=#{eval}\")\n end\n end\n end\n if answer[0] == 'pass'\n return {'pass' => {'punter' => pid}}, eval\n end\n if answer[0] == 'claim'\n s = answer[1].to_i\n t = answer[2].to_i\n return {'claim' => {'punter' => pid, 'source' => s, 'target' => t}}, eval\n end\n if answer[0] == 'tbl'\n STDERR.puts(\"Got tbl (tbl size = #{answer[1].size})\")\n return answer[1]\n end\n end",
"def update_move\n if !@ch.moving? && @moves.size > 0\n @moves.shift if proccess_move(@moves[0])\n end\n end",
"def process_pathfinding_movement\n return clear_pathfinding_moves if trigger_movement_key?\n return clear_pathfinding_moves if @pathfinding_goal && adjacent?(@pathfinding_goal.x, @pathfinding_goal.y)\n return if moving?\n return unless @pathfinding_moves.size > 0 && @move_poll.empty?\n @move_poll << @pathfinding_moves.shift\n @followers.move if self.is_a?(Game_Player)\n interpret_move\n end",
"def process_moving_entity(entity)\n unless @registry[entity.registry_id]\n puts \"#{entity} not in registry yet, no move to process\"\n yield\n return\n end\n\n before_x, before_y = entity.x, entity.y\n\n yield\n\n if moved = (entity.x != before_x || entity.y != before_y)\n update_grid_for_moved_entity(entity, before_x, before_y)\n # Note: Maybe we should only wake entities in either set\n # and not both. For now we'll wake them all\n (\n entities_bordering_entity_at(before_x, before_y) +\n entities_bordering_entity_at(entity.x, entity.y)\n ).each(&:wake!)\n end\n\n moved\n end",
"def move!\n\t\tbounce! until !will_bounce? #TODO add surroundedness checking\n\t\t@x += @@target_coords[@direction][:dx]\n\t\t@y += @@target_coords[@direction][:dy]\n\tend",
"def advance_move_route_index\n @move_route_index += 1 if @move_succeed || @move_route.skippable\n end",
"def process_ok\n Input.update\n $game_party.target_actor = $game_party.members[index] unless @cursor_all\n call_ok_handler\n end",
"def before_perform_on_forward\n end",
"def do_the_move(argument)\r\n color, row_s, col_s, row_e, col_e = strip_pos_argument(argument)\r\n start_item = @infosquare[row_s][col_s]\r\n end_item = @infosquare[row_e][col_e]\r\n if movetype == :shortcastle or movetype ==:longcastle\r\n move_castle(start_item, end_item)\r\n elsif movetype == :enpassant\r\n col_enp = end_item.col\r\n row_enp = start_item.row\r\n eated_item = @infosquare[row_enp][col_enp]\r\n eated_item.clear\r\n else\r\n BoardInfoItem.exchange(start_item, end_item)\r\n end\r\n @last_moved_item = end_item\r\n \r\n end",
"def process_status(rep)\n\t \taddress = rep[:address]\t#need to process queue for that address\n\t \tret = 0\t\t\n\t\tempty = false\n\n\t \tif address==1\n\t \t\tqueue = @cmd_queue_1\n\t \t\tinjector = @injector_1\n\t\t\tother_injector = @injector_0\n\t \t\tother_queue = @cmd_queue_0\n\t \telse\n\t \t\tqueue = @cmd_queue_0\n\t \t\tinjector = @injector_0\n\t\t\tother_injector = @injector_1\n\t \t\tother_queue = @cmd_queue_1\n\t \tend\n\n\t\t# Write values from status process to the instance representations\n\t \tinjector.syringe.motor = rep[:syringe_motor]\n\t \tinjector.syringe.position = rep[:syringe_position]\n\t \tinjector.valve.motor = rep[:valve_motor]\n\t \tinjector.valve.position = rep[:valve_position]\n\t\t\n\t\tthese_motors = other_injector.valve.motor == 1 && injector.syringe.motor == 1\n\t\tother_motors = other_injector.valve.motor == 1 && other_injector.syringe.motor == 1\n\t\tmotors = these_motors && other_motors\n\t\tempty = queue.empty? && other_queue.empty?\t\t\n\t\t#exit condition - all motors have stopped, all commands have been run\n\t\t\n\t\t#command pending?\n\t \tif queue.empty?#No\n\t \t\t@log.debug \"Queue empty\"\n\t\t\t@log.debug \"Other Queue empty \" + other_queue.empty?.to_s\n\t\t\twrite_command_status(other_queue)\n\t \telse \n\t \t\tif movement_cmd?(queue.first)\n\t \t\t\t@log.debug \"Movement command\"\n\t \t\t\tif these_motors\n\t \t\t\t @log.debug \"Motors idle, running command\"\n\t \t\t\t write(queue.shift[:cmd])\t\n\t \t\t\telse\n\t \t\t\t @log.debug \"Motors still moving switching queue\"\n\t \t\t\t write_command_status(other_queue)\n\t \t\t\tend\n\t \t\telse\n\t \t\t\twrite(queue.shift[:cmd])\n\t \t\tend\n\n\n\t \tend\n\n\t\treturn empty && motors\n\t end",
"def postprocess(groups)\n end",
"def init_private_members\n super\n @move_route = nil # Move route\n @move_route_index = 0 # Move route execution position\n @original_move_route = nil # Original move route\n @original_move_route_index = 0 # Original move route execution position\n @wait_count = 0 # Wait count\n end",
"def forward\n end",
"def setup_camera_move\n if @acts[1].is_a?(String)\n camera = CAM_PRESETUP[@acts[1]]\n if camera.nil?\n ErrorSound.play\n text = \"Camera error on : #{@used_sequence}\\n\" + \n \"Uninitialized camera constant \\\"#{@acts[1]}\\\"\"\n msgbox text\n exit\n end\n @acts = @act[0] + camera\n end\n return TSBS.error(@acts[0], 4, @used_sequence) if @acts.size < 5\n case @acts[1]\n when 0 # Current target\n battlers = target_array\n when 1 # Self\n battlers = [self]\n when 2 # All Enemies\n battlers = opponents_unit.alive_members\n when 3 # All Allies\n battlers = friends_unit.alive_members\n when 4 # Everyone\n battlers = opponents_unit.alive_members + friends_unit.alive_members\n when 5 # Screen\n battlers = nil\n else\n battlers = nil\n end\n unless @acts[2].is_a?(Array)\n ErrorSound.play\n msgbox \"Camera error on : #{@used_sequence}\\n\" + \n \"Second parameter should be array\"\n exit\n end\n point_x = @acts[2][0]\n point_y = @acts[2][1]\n dur = @acts[3]\n zoom = @acts[4]\n method = @acts[5] || DEFAULT_CAM_METHOD\n unless $tsbs_camera.respond_to?(method)\n ErrorSound.play\n msgbox \"Camera error on : #{@used_sequence}\\nWrong method name\"\n exit\n end\n $tsbs_camera.move_camera(battlers, point_x, point_y, dur, zoom, method)\n end",
"def on_input\n @movement.each do |entity|\n entity[:movement]= nil\n end\n\n @player[:action]= case @window.active_input\n when \"h\" then [:move, Vector[-1, 0]]\n when \"j\" then [:move, Vector[ 0, 1]]\n when \"k\" then [:move, Vector[ 0, -1]]\n when \"l\" then [:move, Vector[ 1, 0]]\n when \"y\" then [:move, Vector[-1, -1]]\n when \"b\" then [:move, Vector[-1, 1]]\n when \"u\" then [:move, Vector[ 1, -1]]\n when \"n\" then [:move, Vector[ 1, 1]]\n when \"g\" then [:draw_card]\n when \"f\" then [:play_weapon]\n when \"d\" then [:play_spell]\n when \"s\" then [:play_item]\n when \"a\" then [:replace_item]\n when \"q\" then throw(:game_end)\n else\n return\n end\n\n @ai_method.each do |entity|\n entity[:action] = self.send(entity[:ai_method], entity)\n end\n\n @action.each do |entity|\n action, *args = entity[:action]\n next if action.nil?\n\n self.send(action, entity, *args)\n entity[:action]= nil\n end\n\n @movement.each do |entity|\n next if entity[:movement].nil?\n\n oldpos = entity[:position]\n newpos = entity[:position] + entity[:movement]\n\n next if out_of_bounds?(newpos)\n\n entities_at_pos = @map[:index][newpos]\n obstructed = entities_at_pos.any? do |entity|\n entity[:obstructing] == true\n end\n next if obstructed\n\n b = entity[:position]\n m = entity[:movement] / 5.0\n points = 6.times.map { |t| (b + (m*t)) }\n\n entity[:position]= newpos\n entity[:movement]= nil\n entity[:tween_points]= points\n @map[:index][oldpos].delete(entity)\n @map[:index][newpos].push(entity)\n end\n\n @animating = true\n end",
"def process_move_from(move)\n return unless move[:from]\n team_id = move[:from]\n team = get_delta_team_by_id(team_id)\n team_set = get_team_set_by_team_id(team_id)\n return unless team_set.present?\n team[:original].each do |id|\n review_set = get_review_set_for_ownerable(team_set.id, id)\n review = review_class.find_by(reviewable_id: move[:id], reviewable_type: user_class.name, review_set_id: review_set.id) if review_set.present?\n review.destroy if review.present?\n end\n end",
"def move(buddy)\n x = buddy.x\n y = buddy.y\n\n case\n when buddy.orient == Buddy::NORTH then y += 1\n when buddy.orient == Buddy::SOUTH then y -= 1\n when buddy.orient == Buddy::EAST then x += 1\n when buddy.orient == Buddy::WEST then x -= 1\n end\n\n if validate_pos(x, y)\n # Set buddy position only if the future is valid\n buddy.x = x\n buddy.y = y\n end\n end",
"def bind_process(params = nil)\n if @name_index\n @conf.insert(@name_index + @conf.length, \" \" + \"bind-process \" + params.to_s + \"\\n\")\n else\n puts \"no #{@proxy_type} name assigned\"\n return false\n end\n end",
"def movement_process_end(no_follower_move = false)\n follower_move unless no_follower_move\n particle_push\n if SlideTags.include?(sys_tag = system_tag) ||\n (sys_tag == MachBike && !($game_switches[::Yuki::Sw::EV_Bicycle] && @lastdir4 == 8))\n @sliding = true\n @sliding_parameter = sys_tag\n Scheduler::EventTasks.trigger(:begin_slide, self)\n end\n z_bridge_check(sys_tag)\n detect_swamp\n if jumping?\n Scheduler::EventTasks.trigger(:begin_jump, self)\n elsif moving?\n Scheduler::EventTasks.trigger(:begin_step, self)\n end\n end",
"def postprocess(readers, writers); end",
"def process_pgn_moves(arr_raw_pgn_move)\r\n #@color_on_turn = :white\r\n arr_raw_pgn_move.each do |move_str|\r\n \r\n if move_str == \"1-0\" or \r\n move_str == \"0-1\" or\r\n move_str == \"1/2-1/2\"\r\n @current_match.set_result(move_str)\r\n break\r\n end\r\n argument = trasform_pgn_move_inmymove(move_str)\r\n \r\n @current_match.add_pgn_move(move_str)\r\n @current_match.add_move(argument)\r\n \r\n do_the_move(argument)\r\n swap_color_on_turn\r\n end\r\n end"
] |
[
"0.580114",
"0.57578623",
"0.57086825",
"0.5699426",
"0.5699426",
"0.5660415",
"0.56019205",
"0.5526858",
"0.54920816",
"0.5490215",
"0.547453",
"0.54599464",
"0.5456849",
"0.54387",
"0.54387",
"0.54183704",
"0.5387154",
"0.5384284",
"0.5384211",
"0.5324632",
"0.5316352",
"0.5297798",
"0.5263677",
"0.5257585",
"0.5255698",
"0.5255698",
"0.5253026",
"0.52378994",
"0.5237534",
"0.5204392",
"0.5199592",
"0.51925683",
"0.5182294",
"0.51623446",
"0.5158932",
"0.51552933",
"0.5134522",
"0.51307607",
"0.5111918",
"0.5109734",
"0.5108012",
"0.50994486",
"0.50958633",
"0.50827235",
"0.5069969",
"0.5057468",
"0.50533533",
"0.50441355",
"0.50296855",
"0.50169",
"0.50113696",
"0.49937195",
"0.49819094",
"0.4980824",
"0.49705136",
"0.49632877",
"0.49565995",
"0.4954313",
"0.49519917",
"0.4949673",
"0.49472773",
"0.49472773",
"0.49427906",
"0.4927923",
"0.49264318",
"0.49240464",
"0.49214146",
"0.49077234",
"0.48994285",
"0.48926958",
"0.48809052",
"0.48809052",
"0.4879795",
"0.48712862",
"0.48569164",
"0.48569164",
"0.4854453",
"0.48456386",
"0.48456386",
"0.48329166",
"0.4831246",
"0.48226714",
"0.48124295",
"0.48116207",
"0.48094922",
"0.4792159",
"0.47915924",
"0.47829476",
"0.47733423",
"0.47600734",
"0.47569057",
"0.47564682",
"0.475632",
"0.47562307",
"0.47510803",
"0.47400424",
"0.47374627",
"0.4728892",
"0.47082242",
"0.4705145"
] |
0.5851964
|
0
|
Copy Binders to new location
|
def copyitem
errors = []
@binder = Binder.find(params[:id])
@inherited = inherit_from(params[:folid])
@parenthash = @inherited[:parenthash]
@parentsarr = @inherited[:parentsarr]
@parentperarr = @inherited[:parentperarr]
# src = Mongo.log(current_teacher.id.to_s,
# __method__.to_s,
# params[:controller].to_s,
# @binder.id.to_s,
# params)
if @inherited[:parent].get_access(current_teacher.id.to_s) == 2
# fork will only be set if there is a teacher id mismatch
fav = !params[:favorite].nil?
fork = @inherited[:parent].owner != @binder.owner
@parent_child_count = @inherited[:parent_child_count]
@ppers = @binder.parent_permissions
@new_parent = Binder.new( :title => @binder.title,
:body => @binder.body,
:type => @binder.type,
:format => @binder.type == 2 ? @binder.format : nil,
:files => @binder.files,
:folders => @binder.folders,
:forked_from => fork ? @binder.id.to_s : nil,
:fork_stamp => fork ? Time.now.to_i : nil,
:total_size => @binder.total_size,
:fav_total => @binder.fav_total,
:pub_size => @binder.pub_size,
:priv_size => @binder.priv_size,
:order_index => @parent_child_count,
:parent => (fav ? { 'id'=>'-2', 'title'=>'' } : @parenthash),#@parenthash,
:parents => (fav ? [{ 'id'=>'-2', 'title'=>'' }] : @parentsarr),#@parentsarr,
:permissions => (fav ? [{"type"=>3, "auth_level"=>1}] : @binder.permissions),#@binder.permissions,
:parent_permissions => (fav ? [] : @parentperarr),#@parentperarr,
:owner => current_teacher.id,
:username => current_teacher.username,
:fname => current_teacher.fname,
:lname => current_teacher.lname,
:last_update => Time.now.to_i,
:last_updated_by => current_teacher.id,
:thumbimgids => @binder.thumbimgids)
#@new_parent.format = @binder.format if @binder.type == 2
# @new_parent.versions << Version.new(:owner => @binder.current_version.owner,
# :file_hash => @binder.current_version.file_hash,
# :timestamp => @binder.current_version.timestamp,
# :remote_imgfile_url => @binder.current_version.imgfile.url.to_s,
# :size => @binder.current_version.size,
# :ext => @binder.current_version.ext,
# :data => @binder.current_version.data,
# :croc_uuid => @binder.current_version.croc_uuid,
# :remote_file_url => @binder.format == 1 ? @binder.current_version.file.url.to_s : nil) if @binder.type == 2
@new_parent.versions << @binder.current_version
#TODO: copy related images?
if @new_parent.save
# due to shared functionality, define method var
if fav
method = "favorite"
@binder.inc(:fav_total, 1)
elsif fork
method = "forkitem"
# fork_total is
@binder.inc(:fork_total, 1)
Binder.delay(:queue => "email").sendforkemail(@binder.id.to_s, @new_parent.id.to_s)
# cascade upwards
@binder.parents.each do |f|
Binder.find(f['id'].to_s).inc(:owned_fork_total,1) if f['id'].to_i>0
end
else
method = __method__.to_s
end
src = Mongo.log(current_teacher.id.to_s,
method.to_s,
params[:controller].to_s,
@binder.id.to_s,
params)
Mongo.log( current_teacher.id.to_s,
method.to_s,
params[:controller].to_s,
@new_parent.id.to_s,
params,
{ :copy => @binder.id.to_s, :src => src })
@new_parent.tag = Tag.new( :node_tags => @binder.tag.node_tags)
@new_parent.update_parent_tags()
#Hash table for oldid => newid lookups
@hash_index = {params[:id] => @new_parent.id.to_s}
#If directory, deal with the children
if @binder.type == 1 #Eventually will apply to type == 3 too
@index = @binder.parents.length
#Select old children, order by parents.length
@children = @binder.subtree.sort_by {|binder| binder.parents.length}.reject{|binder| binder.id == @new_parent.id}
#Spawn new children, These children need to have updated parent ids
@children.each do |h|
Mongo.log( current_teacher.id.to_s,
method.to_s,
params[:controller].to_s,
h.id.to_s,
params,
{ :src => src })
@node_parent = {"id" => @hash_index[h.parent["id"]],
"title" => h.parent["title"]}
@node_parents = Binder.find(@hash_index[h.parent["id"]]).parents << @node_parent
@old_permissions = h.parent_permissions
@ppers.each {|p| @old_permissions.delete(p)}
#Swap old folder ids with new folder ids
@old_permissions.each {|op| op["folder_id"] = @hash_index[op["folder_id"]]}
h.inc(:fork_total, 1) if fork
@new_node = Binder.new( :title => h.title,
:body => h.body,
:parent => @node_parent,
:parents => fav ? [{ 'id'=>'-2', 'title'=>'' }] + (h.parents - {'id'=>'0','title'=>''}) : @node_parents,
:permissions => fav ? [] : h.permissions,
:parent_permissions => fav ? @parentperarr : @parentperarr + @old_permissions,
:owner => current_teacher.id,
:username => current_teacher.username,
:fname => current_teacher.fname,
:lname => current_teacher.lname,
:last_update => Time.now.to_i,
:last_updated_by => current_teacher.id,
:type => h.type,
:format => (h.type != 1 ? h.format : nil),
:files => h.files,
:folders => h.folders,
:forked_from => fork ? h.id.to_s : nil,
:fork_stamp => fork ? Time.now.to_i : nil,
:total_size => h.total_size,
:pub_size => h.pub_size,
:priv_size => h.priv_size,
:fav_total => h.fav_total,
:thumbimgids => @binder.thumbimgids,)
# @new_node.versions << Version.new( :owner => h.current_version.owner,
# :file_hash => h.current_version.file_hash,
# :timestamp => h.current_version.timestamp,
# :size => h.current_version.size,
# :ext => h.current_version.ext,
# :data => h.current_version.data,
# :croc_uuid => h.current_version.croc_uuid,
# :imgfile => h.current_version.imgfile,
# :file => h.format == 1 ? h.current_version.file : nil) if h.type == 2
@new_node.versions << h.current_version
#TODO: copy related images?
@new_node.save
Mongo.log( current_teacher.id.to_s,
method.to_s,
params[:controller].to_s,
@new_node.id.to_s,
params,
{ :copy => h.id.to_s, :src => src })
@new_node.tag = Tag.new(:node_tags => h.tag.node_tags)
@new_node.update_parent_tags()
@hash_index[h.id.to_s] = @new_node.id.to_s
end
end
#Update parents' folder/file/size counts
@parents = @new_parent.parents.collect {|x| x["id"] || x[:id]}
@parents.each do |pid|
if pid != "0"
parent = Binder.find(pid)
parent.update_attributes( :files => parent.files + @new_parent.files,
:folders => parent.folders + @new_parent.folders + (@new_parent.type == 1 ? 1 : 0),
:total_size => parent.total_size + @new_parent.total_size,
:pub_size => parent.pub_size + @new_parent.pub_size,
:priv_size => parent.priv_size + @new_parent.priv_size)
end
end
# DELAYTAG
Binder.delay(:queue => 'thumbgen').generate_folder_thumbnail(@new_parent.id)
else
end
else
errors << "You do not have permissions to write to #{@inherited[:parent].title}"
end
rescue BSON::InvalidObjectId
errors << "Invalid Request"
rescue Mongoid::Errors::DocumentNotFound
errors << "Invalid Request"
ensure
respond_to do |format|
format.html {render :text => errors.empty? ? 1 : errors.map{|err| "<li>#{err}</li>"}.join.html_safe}
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def rebind(coordination_model)\n dup\n end",
"def copy\n \n end",
"def deep_copy(new_attributes = {})\n self.class.transaction do\n dup.tap do |blueprint|\n # TODO: there may be other attributes that need to be reset for the new template\n new_attributes.reverse_merge(:status => nil).each do |attr, value|\n blueprint.send(\"#{attr}=\", value)\n end\n copy_service_template(blueprint, bundle, true)\n blueprint.save!\n end\n end\n end",
"def copy\n ref_kanban = Kanban.find(params[:ref_id])\n ref_kanban_panes = KanbanPane.find_all_by_kanban_id(params[:ref_id])\n ref_workflow = KanbanWorkflow.find_all_by_kanban_id(params[:ref_id])\n\n new_kanban = ref_kanban.dup\n new_kanban.project_id = params[:project_id]\n new_kanban.update_attribute(:is_valid, true)\n new_kanban.save!\n ref_kanban_panes.each do |p|\n new_pane = p.dup\n new_pane.kanban_id = new_kanban.id\n new_pane.save!\n end\n\n ref_workflow.each do |w|\n new_w = w.dup\n new_w.kanban_id = new_kanban.id\n new_w.save!\n end\n redirect_to edit_project_kanban_path(new_kanban.project_id, new_kanban.id, :tab => \"Panes\")\n end",
"def to_patch\n { 'op' => 'copy', 'from' => @from, 'path' => @path }\n end",
"def copyWaypoints _obj, _args\n \"_obj copyWaypoints _args;\" \n end",
"def make_copy\n\t\t\tMarshal.load(Marshal.dump(self))\n\t\tend",
"def clone_address_to_user\n if user.present?\n user.build_bill_address(bill_address.clone.attributes) if user.bill_address.blank? && bill_address.present?\n user.build_ship_address(ship_address.clone.attributes) if user.ship_address.blank? && ship_address.present?\n user.save\n end\n end",
"def copy_list \n\n\tend",
"def copy\n self.public_send('|', 'pbcopy')\n self\n end",
"def copy\n obj = self.dup\n obj.attributes = {\n :name => \"Copy of #{name}\",\n :active => false,\n :created_at => nil,\n :updated_at => nil\n }\n obj\n end",
"def copy_values_from(other)\n self.name = other.name\n self.contributor = other.contributor\n self.share_mode = other.share_mode\n self.update_mode = other.update_mode\n self.public_view = other.public_view\n self.public_download = other.public_download\n end",
"def update\n [\"beerlist-name\", \"beerlist-brewery\", \"beerlist-style\"].each{ |f| expire_fragment(f) }\n puts \"haloooooo\"\n puts beer_params\n copy = beer_params\n copy['style'] = Style.find(copy['style'])\n puts copy\n respond_to do |format|\n if @beer.update(copy)\n format.html { redirect_to @beer, notice: 'Beer was successfully updated.' }\n format.json { render :show, status: :ok, location: @beer }\n else\n format.html { render :edit }\n format.json { render json: @beer.errors, notice: :unprocessable_entity }\n end\n end\n end",
"def copy\n move(:copy)\n end",
"def copy\n new_cfn_model = CfnModel.new\n @conditions.each do |k,v|\n new_cfn_model.conditions[k] = v\n end\n @globals.each do |k,v|\n new_cfn_model.globals[k] = v\n end\n @parameters.each do |k,v|\n new_cfn_model.parameters[k] = v\n end\n @resources.each do |k, v|\n new_cfn_model.resources[k] = v\n end\n @mappings.each do |k, v|\n new_cfn_model.mappings[k] = v\n end\n new_cfn_model.raw_model = @raw_model.dup unless @raw_model.nil?\n new_cfn_model\n end",
"def duplicate\n super do |cloned_resource|\n cloned_resource.title = \"Copy #{@resource.title[0...Integral.title_length_maximum - 5]}\"\n cloned_resource.view_count = 0\n cloned_resource.build_active_block_list(content: @resource.active_block_list.content, listable: cloned_resource)\n cloned_resource.tag_list = @resource.tag_list_on(@resource.tag_context)\n cloned_resource.slug = @resource.slug\n cloned_resource.status = :draft\n cloned_resource.published_at = nil\n end\n end",
"def copy_form_builders\n directory \"f3-rails/app/form_builders\", \"app/form_builders\"\n end",
"def copy_attributes(from_object, to_object)\n unless new_record?\n # If copying to a new version, check if attachments have been modified in this page\n # if so, copy to the new version, otherwise give new version same attachments as previous version\n if attachments_changed? or to_object.is_a?(Page)\n copy_attachments(from_object, to_object)\n elsif from_object.is_a?(Page) && latest_version\n # new version gets same attachments as latest version\n copy_attachments(latest_version, to_object)\n end\n end\n super\n end",
"def copy\n new_attributes = self.attributes\n new_attributes.delete(:id)\n file = WSFile.create(new_attributes)\n owner = self.permissions(level: 'owner').user.first\n Permission.create(user: owner, file: file, level: \"owner\")\n self.assets.each do |asset|\n file.assets.push asset\n end\n self.children.each do |child|\n file.children.push child.copy\n end\n file.save\n file.data = self.data\n file\n end",
"def copy_user_attributes\n self.user_firstname = user.firstname\n self.user_lastname = user.lastname\n self.user_street1 = user.street1\n self.user_street2 = user.street2\n self.user_postal_code = user.postal_code\n self.user_city = user.city\n end",
"def duplicate!(bloc_owner = self.newsletter)\n duplicated_bloc = bloc_owner.blocs.build({\n position: self.position,\n type: self.type,\n content: self.content\n })\n\n if self.image?\n duplicated_bloc.remote_image_url = self.image.url\n end\n\n duplicated_bloc.save\n duplicated_bloc\n end",
"def copy_actions\r\n end",
"def paste\n # no authorization applied as the method must always render\n if @section.changeable?(current_visitor)\n @original = clipboard_object(params)\n if @original\n @container = params[:container] || 'section_pages_list'\n if @original.class == Page\n @component = @original.duplicate\n else\n @component = @original.deep_clone :no_duplicates => true, :never_clone => [:uuid, :updated_at,:created_at]\n @component.name = \"copy of #{@original.name}\"\n end\n if (@component)\n # @component.original = @original\n @component.section = @section\n @component.save\n end\n @component.deep_set_user current_visitor\n end\n end\n render :update do |page|\n page.insert_html :bottom, @container, render(:partial => 'page_list_item', :locals => {:page => @component})\n page.sortable :section_pages_list, :handle=> 'sort-handle', :dropOnEmpty => true, :url=> {:action => 'sort_pages', :params => {:section_id => @section.id }}\n page[dom_id_for(@component, :item)].scrollTo()\n page.visual_effect :highlight, dom_id_for(@component, :item)\n end\n end",
"def clone_body; end",
"def copy_from(original)\n self.template = original.template\n self.position = original.position\n self.data = original.data\n self\n end",
"def copy\n @original_theme = TemplateTheme.find(params[:id])\n #copy theme, layout, param_value\n @new_theme = @original_theme.copy_to_new\n \n respond_to do |format|\n format.html { redirect_to(template_themes_url) }\n end \n end",
"def copy_assets; end",
"def sync(source_template)\n [ :template_name, :template_type, :template_outfile, :template_rebuild_me, :template_text,\n :template_linked_file, :template_linked_file_mtime, :template_linked_file_size,\n :template_created_on, :template_modified_on, :template_created_by, :template_modified_by,\n :template_build_dynamic ].each do |attribute|\n self[attribute] = source_template[attribute]\n end\n \n # Linked files must be placed in the filesystem appropriately.\n unless self.linked_file.blank?\n blog_root_regex = Regexp.new('(/var/domain/.*/(beta|www))')\n source_blog_root = blog_root_regex.match(source_template.blog.blog_site_path)[1]\n target_blog_root = blog_root_regex.match(self.blog.blog_site_path)[1]\n self[:template_linked_file].gsub!(source_blog_root, target_blog_root)\n end\n \n # Copy templatemaps ONLY if this template has been previously saved.\n unless self.new_record?\n # Delete existing templatemaps.\n self.templatemaps.destroy_all\n \n # Copy templatemaps.\n source_template.templatemaps.each do |source_templatemap|\n self.templatemaps << MovableType::AR::Templatemap.create(self, source_templatemap)\n end\n end\n end",
"def update\n @binder = Binder.find(params[:id])\n \n authorize! :write, @binder\n\n respond_to do |format|\n if @binder.update_attributes(params[:binder])\n format.html { redirect_to @binder, notice: 'Binder was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action:\"edit\" }\n format.json { render json: @binder.errors, status: :unprocessable_entity }\n end\n end\n end",
"def copy_params\n params.require(:copy).permit(:code, :place)\n end",
"def clone\n copy = super\n transaction do\n copy.save!\n\n %w[\n registration_information support information_source advance_directive\n ].each do |assoc|\n copy.send(\"#{assoc}\\=\", send(assoc).clone) if send(assoc)\n end\n\n %w[\n patient_identifiers languages providers medications allergies conditions\n all_results immunizations encounters procedures medical_equipments social_history insurance_providers\n ].each do |assoc|\n send(assoc).each do |item|\n copy.send(assoc) << item.clone\n end\n end\n\n end\n copy\n end",
"def copy\n self.class.load export\n end",
"def clone_billing_address\n self.ship_address = self.bill_address if self.bill_address\n end",
"def cascade_packed_items_location\n box_items.each(&:save!)\n end",
"def copy_attributes(hsh_copy_to, hsh_copy_from, attr_to_copy_list)\n\t\t\t\tattr_to_copy_list.each do |a_attr_to_copy|\n\t\t\t\t\thsh_copy_to[a_attr_to_copy] = hsh_copy_from[a_attr_to_copy]\n\t\t\t\tend\n\t\t\t\treturn hsh_copy_to\n\t\t\tend",
"def copy_billing_address\n @fields.select { |k, _| k.start_with? 'HPP_BILLING_' }\n .each do |k, v|\n add_field(\"HPP_SHIPPING_#{k.split('HPP_BILLING_')[1]}\", v)\n end\n end",
"def copy_attributes_from(app_id)\n if copy_app = App.find(app_id)\n # Copy fields\n (copy_app.attribute_names - %w(id name created_at updated_at)).each do |k|\n self.send(\"#{k}=\", copy_app.send(k))\n end\n # Clone the embedded objects that can be changed via apps/edit (ignore errs & deploys, etc.)\n %w(watchers issue_tracker notification_service).each do |relation|\n if obj = copy_app.send(relation)\n self.send(\"#{relation}=\", obj.is_a?(Array) ? obj.map(&:clone) : obj.clone)\n end\n end\n end\n end",
"def update\n @binder_contractor = BinderContractor.find(params[:id])\n @binder = Binder.find(@binder_contractor.binder_id)\n authorize! :write, @binder\n\n respond_to do |format|\n if @binder_contractor.update_attributes(params[:binder_contractor])\n @binder_contractors = working_binder.binder_contractors\n format.html { redirect_to @binder_contractor, notice: 'Binder contractor was successfully updated.' }\n format.json { head :no_content }\n format.js\n else\n format.html { render action: \"edit\" }\n format.json { render json: @binder_contractor.errors, status: :unprocessable_entity }\n format.js\n end\n end\n end",
"def create_copy\n #add page at end of survey\n new_page_num = self.survey_version.pages.size + 1\n page_attribs = self.attributes.merge(:page_number => new_page_num)\n page_attribs.delete(\"id\")\n page_attribs.delete(\"next_page_id\")\n new_page = Page.create!(page_attribs)\n\n #Copy current page assetables\n self.survey_elements.each do |se|\n se.copy_to_page(new_page)\n end\n\n new_page\n end",
"def deep_copy\n copy = self.dup\n copy.create_command\n copy.serializer = self.serializer.deep_copy\n copy.deserializer = self.deserializer.deep_copy\n copy.commands = self.commands.dup\n copy.libraries = self.libraries.dup\n copy.bound_objects = self.bound_objects.dup\n copy\n end",
"def paste\n # no authorization applied as the method must always render\n if @activity.changeable?(current_visitor)\n @original = clipboard_object(params)\n if (@original)\n @component = @original.deep_clone :no_duplicates => true, :never_clone => [:uuid, :updated_at,:created_at], :include => :pages\n if (@component)\n # @component.original = @original\n @container = params[:container] || 'activity_sections_list'\n @component.name = \"copy of #{@component.name}\"\n @component.deep_set_user current_visitor\n @component.activity = @activity\n @component.save\n end\n end\n end\n render :update do |page|\n page.insert_html :bottom, @container, render(:partial => 'section_list_item', :locals => {:section => @component})\n page.sortable :activity_sections_list, :handle=> 'sort-handle', :dropOnEmpty => true, :url=> {:action => 'sort_sections', :params => {:activity_id => @activity.id }}\n page[dom_id_for(@component, :item)].scrollTo()\n page.visual_effect :highlight, dom_id_for(@component, :item)\n end\n end",
"def copy_from(other)\n @environment = other.environment\n @load_directories = other.load_directories\n @on_request = other.on_request\n other.request_callbacks.each { |block| self.register_request_callback(&block) }\n other.request_error_callbacks.each { |block| self.register_request_error_callback(&block) }\n other.external_errors.each { |error, block| self.register_external_error(error, &block) }\n end",
"def copy_old_corridors(specializations)\n specializations.map {|c|\n c.clone.save\n c.code = \"%sS\" % c.code\n c.accredited = false\n c.save\n c\n }\n end",
"def copy(defaults=[], context={})\n self.class.find(self.class.rpc_execute('copy', self.id, defaults, context), :context => context)\n end",
"def bc_cloner(item, bc, entity, source, target, replace)\n # Replace: ONLY used when creating a new barclamp from the model!\n debug \"bc_cloner method called with debug option enabled\"\n debug \"bc_cloner args: item=#{item}, bc=#{bc}, entity=#{entity}, source=#{source}, target=#{target}, replace=#{replace}\"\n\n files = []\n new_item = (replace ? bc_replacer(\"#{item}\", bc, entity) : item)\n new_file = File.join target, new_item\n new_source = File.join(source, item)\n debug \"\\tnew_source=#{new_source}\"\n debug \"\\tnew_target=#{new_file} (item is #{new_item})\"\n if File.directory? new_source\n debug \"\\tcreating directory #{new_file}.\"\n FileUtils.mkdir new_file unless File.directory? new_file\n clone = Dir.entries(new_source).find_all { |e| !e.start_with? '.'}\n clone.each do |recurse|\n files += bc_cloner(recurse, bc, entity, new_source, new_file, replace)\n end\n else\n #need to inject into the file (normal copy)\n unless replace\n debug \"\\t\\tcopying file to #{new_file}.\"\n FileUtils.cp new_source, new_file\n files << new_file\n #we need to scrub the file for replacement strings\n else\n debug \"\\t\\tcreating file #{new_file}.\"\n t = File.open(new_file, 'w')\n File.open(new_source, 'r') do |f|\n s = f.read\n t.write(bc_replacer(s, bc, entity))\n end\n t.close\n files << new_file\n end\n end\n return files\nend",
"def after_auto_settings\n if self.user.is_a?(Child) && self.user.parents.sum { |parent| parent.user_locations.count }.zero?\n self.user.parents.each do |parent|\n puts \" clone child address for parent #{parent.user_name}\"\n new_location = self.clone\n new_location.user_id = parent.id\n new_location.save\n end\n end\n\n end",
"def deep_copy\n algorithm_copy = self.dup\n self.general_fields.each{ |field| algorithm_copy.general_fields << field.deep_copy }\n self.input_parameters.each{ |input_parameter| algorithm_copy.input_parameters << input_parameter.deep_copy }\n self.method_fields.each{ |field| algorithm_copy.method_fields << field.deep_copy }\n algorithm_copy.generate_secure_id(true) # Overwrite secure id\n algorithm_copy.save(validate: false) # Can't do validations before the fields are saved(created!) the first time\n self.zip_file.copy_file(algorithm_copy.id) # Need to copy the file, since CarrierWave won't do that for us...\n algorithm_copy.save! # Save it for real!\n algorithm_copy\n end",
"def make_copy(company, fix_ref = true)\n #puts company\n dup = super(company)\n #dup.parent_project = project\n #dup = find_copied_or_make_copy(page_to_attach)\n #pb = AzPageAzProjectBlock.new\n #pb.az_project_block = dup\n #pb.az_page = page_to_attach\n #pb.az_project_block.parent_project = page_to_attach.az_base_project\n #pb.az_project_block.parent_project_id = page_to_attach.az_base_project_id\n #pb.save!\n #dup.az_page = page_to_attach\n\n dup.parent_project_id = nil\n\n commons = [AzCommonsFunctionality,\n AzCommonsRequirementsHosting]\n\n commons.each do |cmc|\n cms = eval(\"#{cmc.to_s.underscore.pluralize}\")\n cms.each do |cm|\n cm.make_copy_common(company, dup)\n end\n end\n\n dup.save!\n\n if fix_ref\n full_pages_list = dup.get_full_pages_list\n dup.fix_page_structure(full_pages_list)\n dup.fix_page_references(full_pages_list)\n end\n\n return dup\n end",
"def clone(klass = self.class)\n cloned_router = klass.new(@default_app, @options)\n @routes.each do |route|\n new_route = route.clone(cloned_router)\n cloned_router.add_route(new_route).compile\n new_route.name(route.named) if route.named\n if route.dest\n begin\n new_route.to route.dest.clone\n rescue\n new_route.to route.dest\n end\n end\n end\n cloned_router\n end",
"def copy\n @bulletin = Bulletin.find(params[:id])\n \n if (newbull = @bulletin.duplicate)\n redirect_to :action => 'edit', :id => newbull.id\n else\n redirect_to :action => 'index'\n end\n end",
"def copy(from, to)\n \n end",
"def set_params_from_omniauth_hash_to_pass_it_to_transfer_to_guest_cmpsr\n @params_from_omniauth_for_transfer_to_guest_cmpsr = pick_fields_from_omniauth_hash_that_will_be_passed_to_transfer_guest_cmpsr_as_params\n end",
"def copy_record\n obj = find_checked_items\n @refresh_partial = \"timeprofile_copy\"\n @redirect_id = obj[0]\n end",
"def new\n authorize! :create, @binder\n \n @binder_contractor = BinderContractor.new(binder_id: @binder.id, created_by: current_user.id)\n @binder_contractor.build_contractor(created_by: current_user.id, verified: false)\n @binder_contractor.contractor.build_address(state: @binder.property.state)\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @binder_contractor }\n format.js\n end\n end",
"def assign_attributes\n entry.attributes = model_params\n end",
"def copied_from\n [ self[:copyfrom_path], self[:copyfrom_rev] ] if copyfrom_known?\n end",
"def duplicate merge_options = {}\n # start to clone\n duplicated_obj = self.clone :except => [:zip_file], :include => [:template_partials, :mail_template_files]\n duplicated_obj.zip_file = File.open(self.zip_file.path) if self.zip_file.path # it will make a copy version of zipfile\n duplicated_obj.attributes = merge_options if merge_options.is_a? Hash # merge custom options\n # without saving can't not create files. so save it first.\n duplicated_obj.save\n\n ### below code is used to clone mail_template_files and replace the new url for cloned template body.\n # pair the mail_template_files and insert into substitution_array.\n substitution_pair_array = []\n self.mail_template_files.each_with_index do |origin_file, index|\n substitution_pair_array << [origin_file, duplicated_obj.mail_template_files[index]]\n end\n\n # replace image or file url with new url.\n original_body = self.body\n\n substitution_pair_array.each do |origin_file, new_file|\n original_body = MailEngine::HtmlDocumentAssetsReplacer.replace_resource_in_html(\n original_body,\n origin_file.file.url,\n new_file.file.url,\n :url\n )\n end\n\n # write back the new body with cloned resource urls.\n duplicated_obj.update_attributes :body => original_body\n duplicated_obj\n end",
"def request_copy\n @reader = Reader.new\n\n respond_to do |format|\n format.html # request_copy.html.erb\n format.json { render json: @reader }\n end\n end",
"def copy_views\n #theoretical support in the future for haml\n extension = \".\" + template_engine\n file_names = %w{index show _pagination _search_form }\n file_names.each do |file_name|\n source = \"views/email_manager/managed_emails/\" + file_name + \".html\" + extension\n destination = \"app/views/email_manager/managed_emails/\" + file_name + \".html\" + extension\n copy_file source, destination\n end\n end",
"def clone_me(target_sv)\n target_sv.pages.create(\n self.attributes.except(\n \"created_at\",\n \"updated_at\",\n \"id\",\n \"survey_version_id\",\n \"survey_version\",\n \"clone_of_id\"\n ).merge(\"clone_of_id\" => self.id)\n )\n end",
"def copy_from(source_list, &block); end",
"def copy(from, to)\n @parent.gemset_copy(from, to)\n end",
"def copy\n @original_theme = TemplateTheme.find(params[:id])\n #copy theme, layout, param_value\n @new_theme = @original_theme.copy_to_new\n \n respond_to do |format|\n format.html { redirect_to(admin_template_themes_url) }\n end \n end",
"def copy\n @original_theme = TemplateTheme.find(params[:id])\n #copy theme, layout, param_value\n @new_theme = @original_theme.copy_to_new\n \n respond_to do |format|\n format.html { redirect_to(admin_template_themes_url) }\n end \n end",
"def copy_attributes(from_object, to_object)\n from_object_attributes = versioned_attributes_from_object(from_object)\n\n # Just setting a Paperclip attachment as an attribute won't work, original file name is lost\n from_object_attributes.each do |k,v| \n if v.is_a?(Paperclip::Attachment)\n # Handle a paperclip attachment\n # If an attribute value is a Paperclip attachment, set the original file name so \n # the correct file name is maintained when copying between object and version or vice-versa\n # When copying between object and version, only write the file name is there is an attachment queued for write\n # It won't be queued for write when publishing back from version to object\n to_object.send(\"#{k}=\", v)\n to_object.send(k).instance_write(:file_name, v.instance_read(:file_name))\n else\n # Handle a regular attribute\n # When copying from a version to a record (publishing a version), all attributes can be copied over\n # When copying to a version, only copy over changed attributes\n if to_object.is_a?(self.class) || changed.include?(k)\n to_object.send(\"#{k}=\", v)\n end\n end\n end\n\n end",
"def destination_replace_from\n @attributes[:destination_replace_from]\n end",
"def initialize_copy(*args)\n super\n\n reset_main_generator\n end",
"def controller_copy(pass_obj=nil)\n from_name = @params[\"from_name\"]\n from_id = @params[\"from_id\"]\n from_rel = @params[\"from_rel\"]\n activity = @params[\"activity\"]\n to_name = @params[\"to_name\"]\n to_rel = @params[\"to_rel\"]\n to_ids = params[\"subjects\"].present? ? params[\"subjects\"].keys.to_a : []\n to_ids += [pass_obj.id.to_s] if (pass_obj.present? and !to_ids.include?(pass_obj.id.to_s))\n from_obj = from_name.singularize==\"user\" ? current_user : current_user.send(from_name.pluralize).find(from_id)\n for to_id in to_ids\n\tto_obj = current_user.send(to_name.pluralize).find(to_id)\n\tobj = to_obj.dup\n\tobj.update(makena(obj, :sender).split(\"_\").first.to_sym => obj.send(makena(obj, :sender).split(\"_\").first)+\"*\")\n\tobj.save\n\tfrom_id = obj.id\n\tif from_name==to_name\n\t sender, hsh = controller_sender_generate(from_name, to_id, from_rel, to_name, from_id, to_rel)\n\telse\n\t sender, hsh = controller_sender_generate(from_name, from_id, from_rel, to_name, to_id, to_rel)\n\tend\n\tcurrent_user.send(sender).find_or_create_by(hsh) if sender\n end\n notice = \"#{activity.upcase} #{from_name.humanize} #{(to_rel||to_name).humanize} processed.\"\n return [obj, notice]\n end",
"def preform_copy_file\n @destination_files.each do |destination|\n copy_file(@sources.pop, destination)\n end\n end",
"def apply\n\t\tunless @already_added\n\t\t\t@space.entities.add @clone\n\t\t\t@already_added = true\n\t\tend\n\t\t\n\t\t@move_action.apply\n\tend",
"def assign_values\n @book.title = @google_book.title\n @book.author = @google_book.authors\n @book = Book.where(title: @book.title, author: @book.author).first_or_create do |book|\n book.photo_url = @google_book.image_link\n book.description = @google_book.description\n book.page_count = @google_book.page_count\n book.isbn = @google_book.isbn\n end\n end",
"def copy_views\n\t\t\t\tfile_list = get_file_list 'haml'\n\t\t\t\tfile_list.each do |filename|\n\t\t\t\t\tbody = get_url filename\n\t\t\t\t\tfilename = filename.gsub('.haml', '.html')\n\t\t\t\t\tdirname = File.dirname(File.join(@dst, filename))\n\t\t\t\t\tFileUtils.mkdir_p(dirname) unless Dir.exist? dirname\n\t\t\t\t\tsave_file \"#{@dst}/#{filename}\", body\n\t\t\t\t\tlog_action \"Copy #{filename.color(:blue)}\"\n\t\t\t\tend\n\t\t\tend",
"def clone\n super\n end",
"def update\n # Populate @ship_from and @new_address here so that renders of the modal are (re)populated correctly.\n @ship_from = ShipFrom.create(@listing, current_user.sorted_shipping_addresses.all)\n @new_address = PostalAddress.new_shipping_address\n\n begin\n address = current_user.postal_addresses.find(params[:ship_from][:address_id]) if params[:ship_from]\n @listing.copy_master_return_address!(address.id)\n data = {\n alert: view_context.bootstrap_flash(:notice, localized_flash_message(:updated)),\n refresh: render_to_string(partial: '/listings/return_address/details.html', locals: {listing: @listing})\n }\n render_jsend(success: data)\n rescue ActiveRecord::RecordNotFound\n # If we couldn't find an address that's already saved to the user's address book, that's an error.\n render_jsend(error: {alert: view_context.bootstrap_flash(:error, localized_flash_message(:error_updating))})\n end\n end",
"def clone\n @map = Map.find(params[:id])\n @new_map = Map.new(@map.attributes)\n @new_map.name += ' clone'\n @new_map.save!\n redirect_to @new_map\n end",
"def copy_service_template(blueprint, service_template, is_top = false, new_attributes = {})\n service_template.dup.tap do |new_template|\n duplicate_resource_actions(service_template, new_template, is_top)\n duplicate_service_resources(blueprint, service_template, new_template)\n update_copied_service_template(blueprint, new_template, new_attributes)\n duplicate_custom_buttons(service_template, new_template) if is_top\n duplicate_custom_button_sets(service_template, new_template) if is_top\n end\n end",
"def copy_missing_attributes(hsh_copy_to, hsh_copy_from, attr_to_copy_list)\n\t\t\t\tattr_to_copy_list.each do |a_attr_to_copy|\n\t\t\t\t\tif hsh_copy_to[a_attr_to_copy].nil?\n\t\t\t\t\t\thsh_copy_to[a_attr_to_copy] = hsh_copy_from[a_attr_to_copy]\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\t\treturn hsh_copy_to\n\t\t\tend",
"def copy_to(registry, **options)\n deference = (registry.find_by_name(self.deference.name) || self.deference.copy_to(registry))\n super(registry, deference: deference, **options)\n end",
"def prepare_and_assign_method_binding(method_binding, record, data)\n prepare_data(method_binding, data)\n\n assign(method_binding, record)\n end",
"def binder; end",
"def binder; end",
"def clone\n super\n end",
"def copy_assets\r\n FileUtils.cd('view') do\r\n %w[style.css napoli.png ferraro.svg].each do |name|\r\n FileUtils.cp(name, File.join('..', 'output', name))\r\n end\r\n end\r\nend",
"def replace(new_attributes)\n @attributes = new_attributes\n load_ab_person\n end",
"def prepare_copies\n return if to.blank?\n \n to do |recipient|\n recipient = User.find(recipient)\n message_copies.build(:recipient_id => recipient.id)\n end\n end",
"def copy_content\n @tocopy.each do |pair|\n src = pair[0]\n dst = File.expand_path(File.join(@temp_path, pair[1] || ''))\n dstdir = File.dirname(dst)\n FileUtils.mkpath(dstdir) unless File.exist?(dstdir)\n FileUtils.cp_r(src, dst)\n end\n\n # clear out the list of things to copy so that snippets can\n # re-load it and call copy_content again if needed\n @tocopy = []\n end",
"def create\n @binder_contractor = BinderContractor.new(params[:binder_contractor])\n @binder = Binder.find(@binder_contractor.binder_id)\n authorize! :create, @binder\n\n respond_to do |format|\n if @binder_contractor.save\n @binder_contractors = working_binder.binder_contractors\n format.html { redirect_to @binder_contractor, notice: 'Binder contractor was successfully created.' }\n format.json { render json: @binder_contractor, status: :created, location: @binder_contractor }\n format.js\n else\n format.html { render action: \"new\" }\n format.json { render json: @binder_contractor.errors, status: :unprocessable_entity }\n format.js\n end\n end\n end",
"def copied(src_item, item)\n end",
"def copy\n copy = self.clone\n copy.delete_all\n @collection.each do |obj|\n copy.add_param(obj.key,obj.value,obj.type)\n end\n return copy\n end",
"def from_b!\n self.replace(from_b)\n end",
"def create\n @location = Location.new(location_params)\n\n respond_to do |format|\n if @location.save\n \n if params[:avatars]\n #===== The magic is here ;)\n params[:avatars].each { |avatar|\n @location.assets.create(avatar: avatar)\n }\n end\n\n format.html { redirect_to @location, notice: 'Gallery was successfully created.' }\n format.json { render json: @location, status: :created, location: @location }\n else\n format.html { render action: \"new\" }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\nend",
"def sync(source_entry)\n [ :entry_status, :entry_author_id, :entry_allow_comments, :entry_allow_pings, \n :entry_convert_breaks, :entry_title, :entry_excerpt, :entry_text, :entry_text_more,\n :entry_to_ping_urls, :entry_pinged_urls, :entry_keywords, :entry_tangent_cache,\n :entry_created_on, :entry_modified_on, :entry_created_by, :entry_modified_by,\n :entry_basename, :entry_week_number ].each do |attribute|\n self[attribute] = source_entry[attribute]\n end\n\n # Sync placements ONLY if this entry has been previously saved.\n unless self.new_record?\n # Add or update placements.\n source_entry.placements.each do |source_placement|\n # Category may not exist yet; copy if so.\n target_category = MovableType::AR::Category.find(:first, :conditions => { :category_blog_id => self.entry_blog_id, :category_label => source_placement.category.category_label })\n target_category = MovableType::AR::Category.create(self.blog, source_placement.category) if target_category.blank?\n target_placement = self.placements.find(:first, :conditions => { :placement_category_id => target_category.category_id })\n target_placement.blank? ?\n self.placements << MovableType::AR::Placement.create(self, source_placement) :\n target_placement.sync!(source_placement)\n end\n \n # Remove old placements.\n if self.placements.size > source_entry.placements.size\n self.placements.each do |target_placement|\n source_category = MovableType::AR::Category.find(:first, :conditions => { :category_blog_id => source_entry.entry_blog_id, :category_label => target_placement.category.category_label })\n if source_category.blank?\n self.placements.delete(target_placement)\n next\n end\n \n source_placement = source_entry.placements.find(:first, :conditions => { :placement_category_id => source_category.category_id })\n self.placements.delete(target_placement) if source_placement.blank?\n end\n end\n \n # Comments need to be synchronized separately (should always flow from production -> beta).\n end\n end",
"def copy object\r\n\tMarshal.load(Marshal.dump(object))\r\nend",
"def copy_changed(**values)\n self.class.new(**self.to_hash.merge!(values))\n end",
"def copy(defaults={}, context={})\n self.class.find(rpc_execute('copy', self.id, defaults, context), context: context)\n end",
"def copy\n create_obj(obj.amoeba_dup)\n build_enabled(obj)\n\n #add (copy) suffix to name/title, etc.\n obj.send(obj.class.columns_for_table[0] + '=', obj.send(obj.class.columns_for_table[0]) + I18n.t('backend.copy_suffix'))\n end",
"def create\n @binder = Binder.new(params[:binder])\n \n respond_to do |format|\n if @binder.save\n # add the binder to the user's list\n current_user.binders << @binder\n \n # set the subscription level for the binder to free\n subscription = Subscription.new(binder_id: @binder.id, plan_id: 'free')\n subscription.save\n \n # make the current user the owner of the binder\n current_user.add_role :owner, @binder\n\n format.html { redirect_to @binder, notice: 'Binder was successfully created.' }\n format.json { render json: @binder, status: :created, location: @binder }\n else\n format.html { render action: \"new\" }\n format.json { render json: @binder.errors, status: :unprocessable_entity }\n end\n end\n end",
"def copy(from_path, to_path, opts = {})\n input_json = {\n from_path: from_path,\n to_path: to_path,\n }\n response = @session.do_rpc_endpoint(\"/#{ @namespace }/copy\", input_json)\n Dropbox::API::File.from_json(Dropbox::API::HTTP.parse_rpc_response(response))\n end",
"def copy object\n\tMarshal.load(Marshal.dump(object))\nend",
"def copy_view_files #do NOT change the name of this method \n # it must be overriding an existing one in a parent class\n base_path = File.join(\"app/views\", class_path, file_name)\n #binding.pry\n empty_directory base_path\n @actions = actions.nil? || actions.empty? ? %w(index new create edit update destroy) : actions\n @attr_cols = GeneratorUtils::attr_cols(table_name)\n @col_count = @attr_cols.count\n @col_count += 1 if @actions.include?(\"edit\")\n @col_count += 1 if @actions.include?(\"destroy\")\n @search_sort = options.search_sort?\n (@actions - %w(create update destroy)).each do |action|\n @action = action\n formats.each do |format|\n @path = File.join(base_path, filename_with_extensions(action, format))\n set_template(@action, @path)\n end\n end\n end"
] |
[
"0.54650736",
"0.5182333",
"0.51592016",
"0.5135206",
"0.5121529",
"0.5023077",
"0.49406013",
"0.49390417",
"0.49344847",
"0.49185508",
"0.49127588",
"0.4889434",
"0.4880044",
"0.48425445",
"0.48312765",
"0.4800621",
"0.47974578",
"0.47799206",
"0.47649682",
"0.47580552",
"0.4744992",
"0.4739912",
"0.47038603",
"0.47025734",
"0.4701444",
"0.4696653",
"0.46897334",
"0.4682599",
"0.46800292",
"0.46790996",
"0.4672042",
"0.46684968",
"0.46683377",
"0.4654948",
"0.46470928",
"0.4639786",
"0.46395573",
"0.46370655",
"0.4636448",
"0.4636012",
"0.46349776",
"0.4633103",
"0.4619375",
"0.4615304",
"0.46149465",
"0.46047506",
"0.4604621",
"0.46012244",
"0.45916584",
"0.4584952",
"0.45814908",
"0.45740703",
"0.45734277",
"0.45708895",
"0.45657697",
"0.456082",
"0.45517084",
"0.45516112",
"0.45515883",
"0.45460662",
"0.45260197",
"0.4516129",
"0.4501406",
"0.4501406",
"0.44953668",
"0.44946215",
"0.44901767",
"0.44817626",
"0.44817156",
"0.44811785",
"0.44758052",
"0.44749922",
"0.4471714",
"0.44686985",
"0.446856",
"0.44639525",
"0.4453895",
"0.4451598",
"0.4451526",
"0.44449496",
"0.44449496",
"0.44425616",
"0.44365206",
"0.44322082",
"0.44308487",
"0.44275016",
"0.4422528",
"0.4416399",
"0.441509",
"0.44116932",
"0.4402826",
"0.43895122",
"0.43862164",
"0.43859595",
"0.43853918",
"0.43824938",
"0.43820614",
"0.43574443",
"0.4354825",
"0.43509528"
] |
0.48131093
|
15
|
This is so nasty.
|
def setpub
error = ""
@binder = Binder.find(params[:id])
# read/write access
if @binder.get_access(current_teacher.id.to_s) == 2
# check if parent binder has any type 3 permissions
if @binder.parent_permissions.find {|p| p["type"] == 3}.nil?
if @binder.permissions.find {|p| p["type"] == 3}.nil?
# this binder has no existing type 3 permissions, inherit!
@binder.permissions << {:type => 3,
:auth_level => params[:enabled] == "true" ? 1 : 0}
@binder.save
else
# set this binder's permissions
@binder.permissions.find {|p| p["type"] == 3}["auth_level"] = params[:enabled] == "true" ? 1 : 0
end
if params[:enabled]=="true"
@binder.pub_size = @binder.pub_size + @binder.priv_size
@binder.priv_size = 0
else
@binder.priv_size = @binder.priv_size + @binder.pub_size
@binder.pub_size = 0
end
@binder.save
src = Mongo.log(current_teacher.id.to_s,
__method__.to_s,
params[:controller].to_s,
@binder.id.to_s,
params)
# deal with the naughty children
@binder.subtree.each do |h|
h.permissions.find{|p| p["type"] == 3}["auth_level"] = params[:enabled] == "true" ? 1 : 0 if !h.permissions.find{|p| p["type"] == 3}.nil?
if h.parent_permissions.find {|p| p["type"] == 3}.nil?
h.parent_permissions << { :type => 3,
:folder_id => params[:id],
:auth_level => params[:enabled] == "true" ? 1 : 0}
else
h.parent_permissions.find {|p| p["type"] == 3}["auth_level"] = params[:enabled] == "true" ? 1 : 0
h.parent_permissions.find {|p| p["type"] == 3}["folder_id"] = params[:id]
end
if params[:enabled]=="true"
h.pub_size = h.pub_size + h.priv_size
current_teacher.pub_size += h.priv_size
h.priv_size = 0
else
h.priv_size = h.priv_size + h.pub_size
current_teacher.priv_size += h.pub_size
h.pub_size = 0
end
current_teacher.save
h.save
Mongo.log( current_teacher.id.to_s,
__method__.to_s,
params[:controller].to_s,
h.id.to_s,
params,
{ :src => src })
end
else
if @binder.parent_permissions.find {|p| p["type"] == 3}["auth_level"] == 1 && params[:enabled] == "false"
error = "Oops! The parent is currently shared."
else
if @binder.permissions.find {|p| p["type"] == 3}.nil?
@binder.permissions << {:type => 3,
:auth_level => params[:enabled] == "true" ? 1 : 0}
#@binder.save
else
@binder.permissions.find {|p| p["type"] == 3}["auth_level"] = params[:enabled] == "true" ? 1 : 0
#@binder.save
end
if params[:enabled]=="true"
@binder.pub_size = @binder.pub_size + @binder.priv_size
@binder.priv_size = 0
@binder.parents.each do |f|
if f['id'].to_s!='0'
g = Binder.find(f['id'].to_s)
g.update_attributes(:pub_size => g.pub_size + @binder.priv_size,
:priv_size => 0)
end
end
else
@binder.priv_size = @binder.priv_size + @binder.pub_size
@binder.pub_size = 0
@binder.parents.each do |f|
if f['id'].to_s!='0'
g = Binder.find(f['id'].to_s)
g.update_attributes(:pub_size => 0,
:priv_size => g.priv_size + @binder.pub_size)
end
end
end
@binder.save
src = Mongo.log(current_teacher.id.to_s,
__method__.to_s,
params[:controller].to_s,
@binder.id.to_s,
params)
# take care of the naughty children
@binder.subtree.each do |h|
h.permissions.find{|p| p["type"] == 3}["auth_level"] = params[:enabled] == "true" ? 1 : 0 if !h.permissions.find{|p| p["type"] == 3}.nil?
if h.parent_permissions.find {|p| p["type"] == 3}.nil?
h.parent_permissions << { :type => 3,
:folder_id => params[:id],
:auth_level => params[:enabled] == "true" ? 1 : 0}
#h.save
else
h.parent_permissions.find {|p| p["type"] == 3}["auth_level"] = params[:enabled] == "true" ? 1 : 0
h.parent_permissions.find {|p| p["type"] == 3}["folder_id"] = params[:id]
#h.save
end
if params[:enabled]=="true"
h.pub_size = h.pub_size + h.priv_size
current_teacher.pub_size += h.priv_size
h.priv_size = 0
else
h.priv_size = h.priv_size + h.pub_size
current_teacher.priv_size += h.pub_size
h.pub_size = 0
end
current_teacher.save
h.save
Mongo.log( current_teacher.id.to_s,
__method__.to_s,
params[:controller].to_s,
h.id.to_s,
params,
{ :src => src })
end
end
end
else
error = "You are not allowed to change permissions on this item."
end
rescue BSON::InvalidObjectId
error = "Invalid Request"
rescue Mongoid::Errors::DocumentNotFound
error = "Invalid Request"
ensure
respond_to do |format|
format.html {render :text => error.empty? ? 1 : error}
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def private; end",
"def probers; end",
"def schubert; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def anchored; end",
"def terpene; end",
"def berlioz; end",
"def suivre; end",
"def escaper=(_); end",
"def internal; end",
"def escaper; end",
"def probers=(_arg0); end",
"def custom; end",
"def custom; end",
"def formation; end",
"def stderrs; end",
"def trd; end",
"def offences_by; end",
"def ibu; end",
"def ignores; end",
"def extra; end",
"def verdi; end",
"def rassoc(p0) end",
"def original; end",
"def refutal()\n end",
"def internship_passed; end",
"def weber; end",
"def final; end",
"def r; end",
"def r; end",
"def loc; end",
"def loc; end",
"def loc; end",
"def same; end",
"def specialty; end",
"def hiss; end",
"def missing; end",
"def wrapper; end",
"def from; end",
"def from; end",
"def from; end",
"def from; end",
"def big_bad; end",
"def isolated; end",
"def isolated; end",
"def used?; end",
"def malts; end",
"def missing?; end",
"def jack_handey; end",
"def internal?; end",
"def gounod; end",
"def sld; end",
"def parslet; end",
"def parslet; end",
"def parslet; end",
"def parslet; end",
"def buzzword; end",
"def buzzword; end",
"def original_result; end",
"def blg; end",
"def bs; end",
"def implementation; end",
"def implementation; end",
"def expanded; end",
"def getc() end",
"def getc() end",
"def getc() end",
"def celebration; end",
"def ext=(_arg0); end",
"def ext=(_arg0); end",
"def ext=(_arg0); end",
"def placebo?; false end",
"def macro; raise NotImplementedError; end",
"def macro; raise NotImplementedError; end",
"def macro; raise NotImplementedError; end",
"def overload; end",
"def sitemaps; end",
"def next() end",
"def next() end",
"def leading; end",
"def semact?; false; end",
"def offences_by=(_arg0); end",
"def returns; end",
"def villian; end",
"def intensifier; end",
"def code_point=(_); end",
"def awaken!\n\t\traise 'Not implemented'\n\tend",
"def who_we_are\r\n end",
"def rest_positionals; end",
"def whiny=(_arg0); end",
"def upc_e; end",
"def fallbacks=(_arg0); end",
"def identify; end",
"def writethis; end",
"def herald; end",
"def pos; end",
"def pos; end",
"def pos; end"
] |
[
"0.7315698",
"0.6497994",
"0.62598854",
"0.6170922",
"0.6170922",
"0.6170922",
"0.6170922",
"0.5990019",
"0.5853454",
"0.5850553",
"0.58309746",
"0.5818816",
"0.5759156",
"0.56814903",
"0.5675477",
"0.5664375",
"0.5664375",
"0.5656127",
"0.5646239",
"0.56439847",
"0.5617267",
"0.5607428",
"0.559314",
"0.5592225",
"0.5585135",
"0.5572909",
"0.5560654",
"0.5559594",
"0.5557761",
"0.55544215",
"0.5546384",
"0.5541249",
"0.5541249",
"0.550437",
"0.550437",
"0.550437",
"0.5503121",
"0.54961",
"0.54855716",
"0.5484392",
"0.5484011",
"0.5475837",
"0.5475837",
"0.5475837",
"0.5475837",
"0.5468452",
"0.5465038",
"0.5465038",
"0.5459265",
"0.54467326",
"0.54435223",
"0.54272896",
"0.54239583",
"0.54237545",
"0.54217535",
"0.541222",
"0.541222",
"0.541222",
"0.541222",
"0.54107887",
"0.54107887",
"0.5407559",
"0.540534",
"0.5380267",
"0.53795016",
"0.53795016",
"0.53779346",
"0.53717494",
"0.53717494",
"0.53717494",
"0.53694516",
"0.53678864",
"0.53678864",
"0.53678864",
"0.53675985",
"0.53637034",
"0.53637034",
"0.53637034",
"0.53618395",
"0.5358758",
"0.5347207",
"0.5347207",
"0.53472066",
"0.53430337",
"0.5341674",
"0.5340507",
"0.533064",
"0.53181374",
"0.53089243",
"0.5308205",
"0.53038406",
"0.5303046",
"0.5296268",
"0.5293077",
"0.5288062",
"0.5284159",
"0.5275075",
"0.5275069",
"0.52750576",
"0.52750576",
"0.52750576"
] |
0.0
|
-1
|
More validation needed, Permissions
|
def destroy
#debugger
errors = []
@binder = Binder.find(params[:id])
if @binder.get_access(current_teacher.id.to_s == 2)
# preserve parent ID before writing over
@parentid = @binder.parent["id"]
@binder.sift_siblings()
@parenthash = { :id => "-1",
:title => ""}
@parentsarr = [@parenthash]
#OP = Original Parent
if @binder.parent["id"] != "0"
@op = Binder.find(@binder.parent["id"])
@op.update_attributes( :owned_fork_total => @op.owned_fork_total - (@binder.fork_total+@binder.owned_fork_total),
:files => @op.files - @binder.files,
:folders => @op.folders - @binder.folders - (@binder.type == 1 ? 1 : 0),
:total_size => @op.total_size - @binder.total_size,
:pub_size => @op.pub_size - @binder.pub_size,
:priv_size => @op.priv_size - @binder.priv_size)
end
@binder.update_attributes( :parent => @parenthash,
:parents => @parentsarr)
src = Mongo.log(current_teacher.id.to_s,
__method__.to_s,
params[:controller].to_s,
@binder.id.to_s,
params)
#If directory, deal with the children
if @binder.type == 1 #Eventually will apply to type == 3 too
@binder.subtree.each do |h|
@current_parents = h.parents
@size = @current_parents.size
h.update_attributes(:parents => @parentsarr + @current_parents[(@current_parents.index({"id" => @binder.id.to_s, "title" => @binder.title}))..(@size - 1)])
Mongo.log( current_teacher.id.to_s,
__method__.to_s,
params[:controller].to_s,
@binder.id.to_s,
params,
{ :src => src })
end
end
@parents = @binder.parents.collect {|x| x["id"] || x[:id]}
@parents.each do |pid|
if pid != "-1"
parent = Binder.find(pid)
parent.update_attributes( :owned_fork_total => parent.owned_fork_total + (@binder.fork_total+@binder.owned_fork_total),
:files => parent.files + @binder.files,
:folders => parent.folders + @binder.folders + (@binder.type == 1 ? 1 : 0),
:total_size => parent.total_size + @binder.total_size,
:pub_size => parent.pub_size + @binder.pub_size,
:priv_size => parent.priv_size + @binder.priv_size)
end
end
current_teacher.total_size -= @binder.total_size
current_teacher.pub_size -= @binder.total_size if @binder.is_pub?
current_teacher.priv_size -= @binder.total_size unless @binder.is_pub?
current_teacher.save
Rails.logger.debug "generating parent "
Binder.delay(:queue => 'thumbgen').generate_folder_thumbnail(@parentid)
else
errors << "You do not have permissions to delete this item"
end
rescue BSON::InvalidObjectId
errors << "Invalid Request"
rescue Mongoid::Errors::DocumentNotFound
errors << "Invalid Request"
ensure
respond_to do |format|
format.html {render :text => errors.empty? ? 1 : errors.map{|err| "<li>#{err}</li>"}.join.html_safe}
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def permissions = {}",
"def permitted?; end",
"def create_access_check\n permission_check('create')\n end",
"def create_access_check\n permission_check('create')\n end",
"def create_access_check\n permission_check('create')\n end",
"def validate_permission\n unless current_user.permissions.include?(:sermons)\n flash[:error] = 'You do not have permission to edit Sermons.'\n redirect_to '/admin'\n end\n end",
"def permission_required \n render_403 unless admin? || @item.is_editable_by?(current_user)\n end",
"def validate_permission\n unless current_user.permissions.include?(:events)\n flash[:error] = 'You do not have permission to edit Events.'\n redirect_to '/admin'\n end\n end",
"def validate_permission\n if self.permission.presence\n if self.motd || self.web\n @errors.add(:permission, 'is not compatible with MOTD or web announcements')\n end\n end\n end",
"def custom_permissions\n # Limits deleting objects to a the admin user\n #\n # if current_user.admin?\n # can [:destroy], ActiveFedora::Base\n # end\nif current_user.admin?\n\t can [:create, :show, :add_user, :remove_user, :index], Role\n\t end\n # Limits creating new objects to a specific group\n #\n # if user_groups.include? 'special_group'\n # can [:create], ActiveFedora::Base\n # end\n\n\n\n end",
"def permission_required \n render_403 unless admin? || @user == current_user\n end",
"def check_permissions\n authorize! :create, Employee\n end",
"def create?\n @current_user.permission('Bid', :clerk)\n end",
"def authorization; end",
"def permission?()\n return nil\n end",
"def check_permissions\n\n case params[:action]\n when 'new'\n @item = @model.new\n action = \"add\" unless can_add? @item\n when 'edit'\n action = \"edit\" unless can_edit? @item\n when 'destroy'\n action = \"destroy\" unless can_destroy? @item\n when 'toggle'\n action = \"toogle\" unless can_toggle? @item\n end\n\n if action\n flash[:notice] = \"You can't #{action} a #{@item.class.to_s.titleize}.\"\n redirect_to :controller => 'typus', :action => 'index', :model => params[:model]\n end\n\n end",
"def user_permissions\n if user_signed_in? && (current_user.is_logistics? || current_user.is_clerical? || current_user.is_vendor? || current_user.is_customer?)\n authorize! :edit, Element\n end\n end",
"def custom_permissions\n # Limits deleting objects to a the admin user\n #\n # if current_user.admin?\n # can [:destroy], ActiveFedora::Base\n # end\n\n # Limits creating new objects to a specific group\n\n if user_groups.include? ['all_project_writers']\n can [:create], PulStore::Base\n can [:create], PulStore::Lae::Box\n can [:create], PulStore::Lae::Folder\n can [:create], Pulstore::Lae::HardDrive\n end\n\n if user_groups.include? ['lae_project_writers']\n can [:create], PulStore::Lae::Box\n can [:create], PulStore::Lae::Folder\n can [:create], Pulstore::Lae::HardDrive\n end \n\n if user_groups.include? ['all_project_writers']\n can [:destroy], PulStore::Base\n end\n\n if user_groups.include? ['lae_project_readers', 'all_project_readers' ]\n can [:show], PulStore::Base\n end\n end",
"def custom_permissions\n can [:file_status, :stage, :unstage], FileSet\n\n if current_user.ingest_from_external_sources?\n end\n\n if current_user.manage_users?\n can [:show, :add_user, :remove_user, :index], Role\n end\n\n if current_user.manage_roles?\n can [:create, :show, :index, :edit, :update, :destroy], Role\n end\n\n if current_user.run_fixity_checks?\n can [:fixity], FileSet\n end\n # Limits deleting objects to a the admin user\n #\n # if current_user.admin?\n # can [:destroy], ActiveFedora::Base\n # end\n\n # Limits creating new objects to a specific group\n #\n # if user_groups.include? 'special_group'\n # can [:create], ActiveFedora::Base\n # end\n end",
"def has_permission?\n return true if administrator?\n \n # Load the Model based on the controller name\n klass = self.controller_name.classify.constantize\n \n # Load the possible parent requested\n @parents = (klass.has_parent?) ? get_parents_from_request_params(klass, params) : nil\n \n # Load the resource requested\n if params[:id]\n if [\"index\", \"destroy\", \"update\"].include?(params[:action]) && klass.respond_to?(:in_set)\n @resource = klass.in_set(params[:id])\n @resource = @resource.first if @resource.size == 1\n else\n @resource = klass.find(params[:id])\n end\n end\n \n # Let's let the Model decide what is acceptable\n # NOTE: It is still the concrete controller's job to filter inaccessible resources (accessed via the index)!\n # This presumably happens in the with_parent named scope\n \n authorized = case params[:action]\n when \"edit\", \"update\"\n if !@resource.is_a?(Array)\n return @resource.updatable_by?(current_user, @parents) # this is 'returned' to authorized\n end\n \n verify_set_accessablility(@resource, :updatable_by?) do |unauthorized_ids|\n permission_denied(\n :status => :conflict,\n :message => \"#{unauthorized_ids.to_a.join(',')} is not available for update.\"\n ) if unauthorized_ids.size > 0\n end\n true # if it gets past verification, authorized is true\n \n when \"destroy\" \n if !@resource.is_a?(Array)\n return @resource.deletable_by?(current_user, @parents)\n end\n \n verify_set_accessablility(@resource, :deletable_by?) do |unauthorized_ids|\n permission_denied(\n :status => :conflict,\n :message => \"#{unauthorized_ids.to_a.join(',')} is not available for deletion.\"\n ) if unauthorized_ids.size > 0\n end\n true # if it gets past verification, authorized is true\n \n when \"index\" then klass.indexable_by?(current_user, @parents)\n when \"new\", \"create\" then klass.creatable_by?(current_user, @parents)\n when \"show\" then @resource.readable_by?(current_user, @parents)\n else check_non_restful_route(current_user, klass, @resource, @parents)\n end\n \n permission_denied unless authorized\n \n #rescue NoMethodError => e\n # Misconfiguration: A RESTful_ACL specific method is missing.\n #raise_error(klass, e)\n #rescue\n # Failsafe: If any funny business is going on, log and redirect\n #routing_error\n #end\n end",
"def check_permissions\n authorize! :create, CargoManifest\n end",
"def check_permissions\n authorize! :create, RoutingSheet\n end",
"def access_control\n \n end",
"def load_permissions\n authorize! :manage, :all\n end",
"def check_permission\n raise ActiveRecord::RecordNotFound if self.user.nil?\n raise ActiveRecord::RecordNotFound if self.group.nil?\n return true if !group.group_type.is_approval_required && self.user.can_join_groups?\n return true if (self.is_user_invited? || self.is_request_approved?) && self.user.can_join_groups?\n raise ApiAccessEvanta::RecordOutOfScope if self.group.secret? && !self.is_user_invited?\n raise ApiAccessEvanta::PermissionDenied\n end",
"def check_permissions\n authorize! :create, Invoice\n end",
"def check_permissions\n redirect_to index_path, alert: lack_permission_msg unless admin_or_organizer?\n end",
"def check_permissions\n authorize! :create, Receiver\n end",
"def define_eccept\n if current_user.info.id==@resource.id || can_manage_has_one(current_user.info, @resource, @model)\n return true\n else\n redirect_to root_path \n end\n end",
"def check_permissions\n authorize! :create, Product\n end",
"def permissions_policy(&block); end",
"def is_admin?\n !self.permissions.empty?\n end",
"def manager_permissions\n can :manage_collection, String do |pid|\n Rails.logger.debug(\"[MANPERM] Checking from STRING\")\n test_manager(pid)\n end\n\n can :manage_collection, DRI::Batch do |obj|\n Rails.logger.debug(\"[MANPERM] Checking from Object\")\n test_manager(obj.id)\n end\n\n can :manage_collection, SolrDocument do |obj|\n Rails.logger.debug(\"[MANPERM] Checking from SolrDoc\")\n cache.put(obj.id, obj)\n test_manager(obj.id)\n end\n\n can :manage, String do |pid|\n Rails.logger.debug(\"[MANPERM] Checking from STRING\")\n test_manager(pid)\n end\n\n can :manage, DRI::Batch do |obj|\n Rails.logger.debug(\"[MANPERM] Checking from Object\")\n test_manager(obj.id)\n end\n\n can :manage, SolrDocument do |obj|\n Rails.logger.debug(\"[MANPERM] Checking from SolrDoc\")\n cache.put(obj.id, obj)\n test_manager(obj.id)\n end\n end",
"def custom_permissions\n # Limits deleting objects to a the admin user\n #\n # if current_user.admin?\n # can [:destroy], ActiveFedora::Base\n # end\n\n # Limits creating new objects to a specific group\n #\n # if user_groups.include? 'special_group'\n # can [:create], ActiveFedora::Base\n # end\n\n if current_user.admin?\n can [:create, :show, :add_user, :remove_user, :index, :edit, :update, :destroy], Role\n end\n\n# if current_user.contentadmin?\n# can [:create, :destroy], GwWork\n# can [:create, :destroy], GwEtd\n# end\n end",
"def smart?; self.permission_level = 2; end",
"def state_permission(permission); end",
"def custom_permissions\n # Limits deleting objects to a the admin user\n #\n # if current_user.admin?\n # can [:destroy], ActiveFedora::Base\n # end\n\n # Limits creating new objects to a specific group\n #\n # if user_groups.include? 'special_group'\n # can [:create], ActiveFedora::Base\n # end\n end",
"def check_permissions\n unless current_user.is_organizer?\n redirect_to index_path, alert: 'You do not have the permissions to visit this section of hardware.'\n end\n end",
"def valid_permission_level?(level)\n level == \"viewer\" or level == \"editor\" or level == \"admin\"\n end",
"def allowed?; true end",
"def require_other_permission\n respond_to_permission_error\n end",
"def read_permissions\n can :read, String do |pid|\n Rails.logger.debug(\"[READPERM] Checking from STRING\")\n test_read(pid)\n end\n\n can :read, [DRI::Batch] do |obj|\n Rails.logger.debug(\"[READPERM] Checking from Object\")\n test_read(obj.id)\n end\n\n\n can :read, SolrDocument do |obj|\n Rails.logger.debug(\"[READPERM] Checking from SolrDoc\")\n cache.put(obj.id, obj)\n test_read(obj.id)\n end\n end",
"def prepare_permissions\n if current_ability.admin?\n else\n # Need to add admin group to current_ability\n # or presenter will not be accessible.\n current_ability.user_groups << \"admin\"\n if presenter.tombstone.present? \n else\n current_ability.user_groups.delete(\"admin\")\n end\n end\n end",
"def require_permission\n set_comentario\n @comentario = @politico.comentarios.find(params[:id])\n if (current_user != @politico.user) and (current_user != @comentario.user)\n flash[:notice] = 'Permissões insuficientes!'\n redirect_to @politico\n end\n end",
"def permissions_correct?\n (self.exists? & self.valid_user? & self.valid_group? & self.valid_mode?)\n end",
"def custom_permissions\n # Limits deleting objects to a the admin user\n #\n # if current_user.admin?\n # can [:destroy], ActiveFedora::Base\n # end\n if current_user.admin?\n can [:create, :show, :add_user, :remove_user, :index, :edit, :update, :destroy], Role\n # Admin user can create works of all work types\n can :create, curation_concerns_models\n end\n # Limits creating new objects to a specific group\n #\n # if user_groups.include? 'special_group'\n # can [:create], ActiveFedora::Base\n # end\n end",
"def authorization_required\n return true if admin?\n\n if !@group.can_edit?(logged_in_user)\n flash[:notice] = \"你沒有權限執行這個動作\"\n permission_denied\n @group = nil\n false\n end\n end",
"def custom_permissions\n #Collection Manager Permissions\n #Higher power than edit user...[Dont want edit users to be able to DELETE a COLLECTION??, (Delete a DO?)]\n if current_user.applicable_policy?(SETTING_POLICY_COLLECTION_MANAGER)\n #Marked as being able to :manage_collection\n can :manage_collection_flag, :all\n can :create, [DRI::Batch, DRI::GenericFile]\n end\n\n\n #Admin Permissions\n if current_user.applicable_policy?(SETTING_POLICY_ADMIN)\n can :admin_flag, :all\n #Disabled for now..\n can :manage, :all\n end\n\n #Create_do flag (alias for :edit collection)\n can :create_do, String do |pid|\n test_create(pid)\n end\n\n can :create_do, DRI::Batch do |collection|\n test_create(collection)\n end\n end",
"def custom_permissions\n # Limits deleting objects to a the admin user\n #\n # if current_user.admin?\n # can [:destroy], ActiveFedora::Base\n # end\n\n if current_user.admin?\n # Role management\n # don't allow :destroy, :edit, :create\n # - destroy adds a 'delete' button that\n # - could be clicked accidentally\n # - would be very infrequently used (if ever)\n # - implications of edit are unclear for associated actions\n # - create is meaningless without associating actions which happens in code.\n can [:read, :add_user, :remove_user], Role\n end\n\n # Limits creating new objects to a specific group\n #\n # if user_groups.include? 'special_group'\n # can [:create], ActiveFedora::Base\n # end\n end",
"def custom_permissions\n # Limits deleting objects to a the admin user\n #\n # if current_user.admin?\n # can [:destroy], ActiveFedora::Base\n # end\n\n # Limits creating new objects to a specific group\n #\n # if user_groups.include? 'special_group'\n # can [:create], ActiveFedora::Base\n # end\n can [:create, :show, :add_user, :remove_user, :index, :edit, :update, :destroy], Role if current_user.admin?\n\n can [:fa_overview], ActiveFedora::Base\n can [:advanced], ActiveFedora::Base\n can [:streets], ActiveFedora::Base\n can [:pdf_page], ActiveFedora::Base\n can [:pdf_page_metadata], ActiveFedora::Base\n can [:bookreader], ActiveFedora::Base\n can [:imageviewer], ActiveFedora::Base\n can [:streetsviewer], ActiveFedora::Base\n can [:fa_series], ActiveFedora::Base\n can [:audio_transcriptonly], ActiveFedora::Base\n can [:video_transcriptonly], ActiveFedora::Base\n end",
"def custom_permissions\n # Limits deleting objects to a the admin user\n #\n # if current_user.admin?\n # can [:destroy], ActiveFedora::Base\n # end\n\n # Limits creating new objects to a specific group\n #\n # if user_groups.include? 'special_group'\n # can [:create], ActiveFedora::Base\n # end\n\n # TODO: This area looks like it needs to be refactored.\n\n if current_user.admin?\n editor_abilities\n upload_abilities\n publish_abilities\n roles_abilities\n hard_delete_abilities\n import_admin_abilities\n user_abilities\n group_abilities\n can [:create, :destroy, :update], FeaturedWork\n can [:manage], Hydra::Admin::Collection\n\n can :create, TinymceAsset\n can [:create, :update], ContentBlock\n can :read, ContentBlock\n can :characterize, GenericFile\n end\n\n\n if current_user.manager?\n upload_abilities\n publish_abilities\n roles_abilities\n import_user_abilities\n can [:manage], Hydra::Admin::Collection do |admin_set|\n # Can manage admin sets within their assigned unit.\n current_user.osul_groups.include? admin_set.unit_group\n end\n can [:manage], Osul::Group do |group|\n # Can manage the groups the user is in or the groups of the units a user is assigned to.\n current_user.osul_groups.include? group or current_user.osul_groups.include? group.unit\n end\n can [:create], Osul::Group\n can [:create, :destroy, :update], FeaturedWork\n end\n\n if current_user.data_entry?\n upload_abilities\n publish_abilities\n no_admin_set_abilities\n end\n\n if current_user.data_entry_student?\n upload_abilities\n no_admin_set_abilities\n end\n\n unless current_user.public?\n can :view_full, GenericFile\n end\n\n if current_user.role.nil?\n no_file_abilities\n no_admin_set_abilities\n end\n end",
"def custom_permissions\n\n campus = \"bakersfield\" if current_user.email.include?(\"bakersfield.edu\")\n campus = \"chancellor\" if current_user.email.include?(\"calstate.edu\")\n campus = \"channel\" if current_user.email.include?(\"ci.edu\")\n campus = \"chico\" if current_user.email.include?(\"chico.edu\")\n campus = \"dominguez\" if current_user.email.include?(\"dh.edu\")\n campus = \"eastbay\" if current_user.email.include?(\"eb.edu\")\n campus = \"fresno\" if current_user.email.include?(\"fresno.edu\")\n campus = \"fullerton\" if current_user.email.include?(\"fullerton.edu\")\n campus = \"humboldt\" if current_user.email.include?(\"humboldt.edu\")\n campus = \"longbeach\" if current_user.email.include?(\"lb.edu\")\n campus = \"losangeles\" if current_user.email.include?(\"la.edu\")\n campus = \"maritime\" if current_user.email.include?(\"maritime.edu\")\n campus = \"mlml\" if current_user.email.include?(\"mlml.edu\")\n campus = \"northridge\" if current_user.email.include?(\"northridge.edu\")\n campus = \"pomona\" if current_user.email.include?(\"bronco.edu\")\n campus = \"sacramento\" if current_user.email.include?(\"sacramento.edu\")\n campus = \"sanfrancisco\" if current_user.email.include?(\"sf.edu\")\n campus = \"sanmarcos\" if current_user.email.include?(\"sanmarcos.edu\")\n campus = \"sonoma\" if current_user.email.include?(\"sonoma.edu\")\n campus = \"stanislaus\" if current_user.email.include?(\"stanislaus.edu\")\n\n user_groups.push(campus)\n\n # admin\n if current_user.admin?\n can [:create, :show, :add_user, :remove_user, :index, :edit, :update, :destroy], Role\n end\n\n # Limits creating new objects to a specific group\n #\n # if user_groups.include? 'special_group'\n # can [:create], ActiveFedora::Base\n # end\n end",
"def create_permissions\n # initial_step is a controller action on some resources for creation...\n if user_groups.include?(HYHULL_USER_GROUPS[:content_creator]) || \n user_groups.include?(HYHULL_USER_GROUPS[:content_access_team]) || \n @current_user.admin?\n can [:initial_step, :create], :all\n end\n\n end",
"def login_required\n raise Forbidden unless @current_member #ログイン状態でないとForbiddenを発生させる\n end",
"def enforce_permissions\n bounce unless is_admin?\n end",
"def ensure_is_authorized_to_view\n @is_member_of_company = (@relation == :company_admin_own_site || @relation == :company_employee || @relation == :rentog_admin_own_site)\n\n # ALLOWED\n return if @relation == :rentog_admin ||\n @relation == :rentog_admin_own_site ||\n @relation == :domain_supervisor ||\n @relation == :company_admin_own_site\n\n\n # NOT ALLOWED\n # with error message\n flash[:error] = t(\"listing_events.you_have_to_be_company_member\")\n redirect_to root\n return false\n end",
"def create?\n @current_user.permission('Ration', :clerk)\n end",
"def edit_permissions\n can [:edit, :update], String do |pid|\n Rails.logger.debug(\"[EDITPERM] Checking from STRING\")\n test_edit(pid)\n end\n\n can [:edit, :update, :destroy], DRI::Batch do |obj|\n Rails.logger.debug(\"[EDITPERM] Checking from Batch\")\n test_edit(obj.id)\n end\n\n can [:edit, :update, :destroy], DRI::GenericFile do |obj|\n Rails.logger.debug(\"[EDITPERM] Checking from GenericFile\")\n test_edit(obj.id)\n end\n\n can :edit, SolrDocument do |obj|\n Rails.logger.debug(\"[EDITPERM] Checking from SOLRDOC\")\n cache.put(obj.id, obj)\n test_edit(obj.id)\n end\n end",
"def check_permission\n redirect_to dashboard_path, notice: 'You are not authorised to perform this action.' unless current_user&.admin?\n end",
"def define_eccept\n if current_user.info.id == @resource.id || can_manage_has_one(current_user.info, @resource, Info)\n true\n else\n redirect_to root_path\n end\n end",
"def build_permissions(perms, other)\n perms.permits! :read\n perms.permits! :write if self == other\n end",
"def authorize_admin\n redirect_to :login unless current_user.permission.manage_app ||\n current_user.permission.manage_attrs ||\n current_user.permission.manage_achievement_categories ||\n current_user.permission.manage_talent_trees ||\n current_user.permission.manage_talents ||\n current_user.permission.manage_quests ||\n current_user.permission.manage_skills ||\n current_user.permission.manage_achievements ||\n current_user.permission.manage_items ||\n current_user.permission.manage_titles\n end",
"def custom_permissions\n if admin?\n can [:confirm_delete], ActiveFedora::Base\n can [:allow_downloads, :prevent_downloads], AdminSet\n\n can :manage, Spotlight::HomePage\n can :manage, Spotlight::Exhibit\n end\n\n can :read, Spotlight::HomePage\n can :read, Spotlight::Exhibit\n\n # Limits creating new objects to a specific group\n #\n # if user_groups.include? 'special_group'\n # can [:create], ActiveFedora::Base\n # end\n end",
"def valid_edit_check(_traversal_env)\n Result::DENY\n end",
"def valid_principals; end",
"def test_permission(permission_type) \n ActiveSupport::Deprecation.warn(\"test_permission has been deprecated. Use can? instead\") \n can? permission_type, @permissions_solr_document\n end",
"def custom_permissions\n if current_user.admin?\n can :manage, :all\n end\n end",
"def authorize_access\n # byebug\n redirect_to root_path, alert: \"Access Denied\" unless can? :modify, Post\n end",
"def create\n success = false;\n error = \"Resource not available.\"\n permissions = nil\n\n if params.key?(:project_id) and params.key?(:permissions)\n project = Project.find_by(id: params[:project_id])\n target_user = nil\n user_needs_placeholder = false\n\n if params[:permissions].key?(:user_id)\n target_user = User.find_by(id: params[:permissions][:user_id])\n elsif params[:permissions].key?(:user_email)\n target_user = User.find_by(email: params[:permissions][:user_email])\n user_needs_placeholder = true unless target_user\n else\n error = \"No user specified.\"\n end\n\n if project and (target_user or user_needs_placeholder)\n\n if target_user and target_user == @current_user\n error = \"User permissions may not be modified.\"\n elsif project and user_can_access_project(project.id, [:can_author])\n\n p = params.require(:permissions).permit(\n :can_author, :can_view, :can_annotate)\n\n ## Decide whether the user_id or user_email field will be used.\n if target_user\n p[:user_id] = target_user.id\n else\n p[:user_email] = params[:permissions][:user_email]\n end\n\n ## Authors get full permissions.\n if get_with_default(p, :can_author, 'false') == 'true'\n p[:can_view] = 'true'\n p[:can_annotate] = 'true'\n ## Annotators get at least viewing and annotation permissions.\n elsif get_with_default(p, :can_annotate, 'false') == 'true'\n p[:can_view] = 'true'\n p[:can_author] = 'false'\n else\n p[:can_view] = 'true'\n p[:can_author] = 'false'\n p[:can_annotate] = 'false'\n end\n\n p[:project_id] = project.id\n\n begin\n permissions = ProjectPermission.create(p)\n rescue\n end\n error = \"Error updating permissions.\" unless permissions\n end\n else\n ## DEBUG\n #error = \"project missing or (target_user missing or user_needs_placeholder false)\"\n end\n else\n ## DEBUG\n #error = \"project_id or permissions missing\"\n end\n\n if permissions\n render json: permissions, serializer: ProjectPermissionSerializer,\n root: \"permissions\"\n else\n render_error error\n end\n end",
"def check_permissions\n require_privilege(Privilege::USE, @environment)\n end",
"def custom_permissions\n discover_permissions\n export_sets_permissions\n batches_permissions\n preservation_events_permissions\n end",
"def has_access?\n true\n end",
"def has_access?\n true\n end",
"def permission_required(*permissions)\n # if no permissions passed use controller level permissions (filter)\n if permissions.size > 0\n return true if user_permitted?(*permissions)\n # redirect to desired location when user does not have permission\n redirect_to :controller => 'main', :action => 'main' \n return\n\tend\n end",
"def check_authorization\r\n params[:table] ||= params[:t] || CmsHelper.form_param(params)\r\n # Only show menu\r\n return login if params[:id].in?(%w(login logout test))\r\n\r\n table = params[:table].to_s.strip.downcase\r\n set_default_guest_user_role if session[:user_roles].nil?\r\n # request shouldn't pass\r\n if table != 'dc_memory' and \r\n (table.size < 3 or !dc_user_can(DcPermission::CAN_VIEW))\r\n return render(action: 'error', locals: { error: t('drgcms.not_authorized')} )\r\n end\r\n dc_form_read\r\n\r\n # Permissions can be also defined on form\r\n #TODO So far only can_view is used. Think about if using other permissions has sense\r\n can_view = @form.dig('permissions','can_view')\r\n if can_view.nil? or dc_user_has_role(can_view)\r\n extend_with_control_module\r\n else\r\n render(action: 'error', locals: { error: t('drgcms.not_authorized')} )\r\n end \r\nend",
"def validate_category # :doc:\n\t\tif !current_user.is_admin?\n\t\t\tredirect_to root_path, alert: \"Solo el administrador tiene este privilegio\"\n\t\tend \n\tend",
"def read_only?; end",
"def read_only?; end",
"def valid_principals=(_arg0); end",
"def set_permission\r\n\r\n render :nothing => true\r\n return if params[:access_id].blank? || params[:set].blank?\r\n @access = Access.find(params[:access_id])\r\n return if @access.nil?\r\n @set = params[:set] == 'true'\r\n if params[:user_id]\r\n @user = User.find(params[:user_id])\r\n h = {:user_id => @user.id, :access_id => @access.id}\r\n if params[:prop]\r\n @ua = UserAccess.first(:conditions => h) || UserAccess.create(h)\r\n @ua.read = @set if params[:prop] == 'read'\r\n @ua.write = @set if params[:prop] == 'write'\r\n @ua.save\r\n else # aktion\r\n if @set\r\n UserAccess.create(h) unless UserAccess.exists?(h)\r\n else\r\n UserAccess.delete_all(h) if UserAccess.exists?(h)\r\n end\r\n end\r\n end\r\n if params[:profile_id]\r\n @profile = Profile.find(params[:profile_id])\r\n h = {:profile_id => @profile.id, :access_id => @access.id}\r\n if params[:prop]\r\n @pa = ProfileAccess.first(:conditions => h) || ProfileAccess.create(h)\r\n @pa.read = @set if params[:prop] == 'read'\r\n @pa.write = @set if params[:prop] == 'write'\r\n @pa.save\r\n else # aktion\r\n if @set\r\n ProfileAccess.create(h) unless ProfileAccess.exists?(h)\r\n else\r\n ProfileAccess.delete_all(h) if ProfileAccess.exists?(h)\r\n end\r\n end\r\n end\r\n end",
"def check_if_should_be_admin\n end",
"def add_user_permission(u)\n\t\t\n\tend",
"def custom_permissions\n if current_user.admin?\n can [:create, :show, :add_user, :remove_user, :index, :edit, :update, :destroy], Role\n can [:create], Collection\n can [:discover], Hydra::AccessControls::Embargo\n can [:discover], Hydra::AccessControls::Lease\n can [:create], [ CurationConcerns.config.curation_concerns ]\n can [:destroy], ActiveFedora::Base\n can [:permissions], [ CurationConcerns.config.curation_concerns ]\n end\n\n # Limits deleting objects to a the admin user\n #\n #if current_user.admin?\n # can [:destroy], ActiveFedora::Base\n #end\n\n if current_user.has_role?('collection.manager')\n # can [:create, :show, :index, :edit, :update, :destroy], Collection\n can [:create], Collection\n end\n\n if current_user.has_role?('collection.depositor') or current_user.has_group_role?('collection.depositor')\n # can [:create, :show, :index, :edit, :update, :destroy], [ CurationConcerns.configuration.curation_concerns ]\n can [:create], [ CurationConcerns.config.curation_concerns ]\n # can [:show], Collection\n end\n\n # Limits creating new objects to a specific group\n #\n # if user_groups.include? 'special_group'\n # can [:create], ActiveFedora::Base\n # end\n end",
"def check_permissions\n unless current_user.is_admin?\n redirect_to index_path, alert: 'You do not have the permissions to visit the admin page'\n end\n end",
"def test_get_permissions\r\n assert_respond_to(File, :get_permissions)\r\n assert_nothing_raised{ File.get_permissions(@file) }\r\n assert_nothing_raised{ File.get_permissions(@file, @host) }\r\n assert_kind_of(Hash, File.get_permissions(@file))\r\n assert(File.get_permissions(@file).has_key?('BUILTIN\\\\Users'))\r\n assert(File.get_permissions(@file).has_key?('BUILTIN\\\\Administrators'))\r\n end",
"def check_authorization\n @can_edit = can_blank_timetable?('edit')\n @can_show = can_blank_timetable?('show')\n end",
"def bulk_create \t\n \tauthorize! :manage, :all #checking authorization who are having all permissions\n\n \tif params[\"permissions\"].present?\n \t\tresource_id = params[\"permissions\"][\"resource_id\"]\n \t\tresource_type = params[\"permissions\"][\"resource_type\"]\n \t\tif resource_id.present? && resource_type.present?\n\t \t\t#Checking model permissions and creating model permissions \n\t \t\tif params[\"permissions\"][\"1\"].present? \n\t \t\t\tactions = params[\"permissions\"][\"1\"]\n\t \t\t\tactions.each do |key,value|\n\t \t\t\t\tvalue.each do |sub|\n\t \t\t\t\t\tsub_values = sub.split('_')\n\t \t\t\t\t\tpermission = Permission.where(:resource_id => resource_id, :resource_type => resource_type,:action=>key,:no_model_permission=>1,:subject_class=>sub_values[0]).first_or_initialize\t\t \t\t\t\n\t\t \t\t\t\tpermission[:status] = sub_values[1]\n\t\t \t\t\t\tpermission[:actions_list] = []\n\t\t \t\t\t\tpermission[:created_by] = current_user.id if current_user\n\t\t \t\t\t\tpermission[:updated_by] = current_user.id if current_user\t \t\t\t\t\n\t\t \t\t\t\tpermission.save\n\t \t\t\t\tend\n\t \t\t\tend \t\t\t\n\t \t\tend\n\t \t\t#Checking controller permissions and creating controller permissions\n\t \t\tif params[\"permissions\"][\"0\"].present? \n\t \t\t\tactions = params[\"permissions\"][\"0\"]\n\t \t\t\tactions.each do |key,value|\n\t \t\t\t\tpermission = Permission.where(:resource_id => resource_id, :resource_type => resource_type,:action=>key,:no_model_permission=>false).first_or_initialize\t \t\t\t\t\t\t\t\n\t \t\t\t\tpermission[:actions_list] = value.reject(&:empty?).map{|x| x.to_sym }\n\t \t\t\t\tpermission[:created_by] = current_user.id if current_user\n\t \t\t\t\tpermission[:updated_by] = current_user.id if current_user\n\t \t\t\t\tpermission.save\n\t \t\t\tend \t\t\t\n\t \t\tend\n\t \t\tflash[:notice] = \"Groups permissions successfully saved\"\n\t \t\tredirect_to_back_or_default\n\t \telse\n\t \t\tflash[:error] = \"permissions not saved , Please fill required fields\"\n \t\t\tredirect_to_back_or_default\n\t \tend\n \telse\n \t\tflash[:error] = \"permissions not saved\"\n \t\tredirect_to_back_or_default\n \tend\n end",
"def check_resource_ownership\n if admin_user.is_not_root?\n\n condition_typus_users = @item.respond_to?(Typus.relationship) && !@item.send(Typus.relationship).include?(admin_user)\n condition_typus_user_id = @item.respond_to?(Typus.user_foreign_key) && !admin_user.owns?(@item)\n\n not_allowed if (condition_typus_users || condition_typus_user_id)\n end\n end",
"def verify_permission\n return if action_permitted?\n\n render(json: format_error(request.path, 'Permiso denegado'), status: 401)\n end",
"def check_permissions\n unless can?(:manage_app_instances, app_instance.owner)\n redirect_to mnoe_home_path, alert: \"You are not authorized to perform this action\"\n return false\n end\n true\n end",
"def create?\n @current_user.permission('Fdp', :clerk)\n end",
"def accountant_allow_edit(permission)\n return accountant_right(permission) == 2\n end",
"def check_permission\n permit \"site_admin\",\n { :login_required_message => I18n.t(\"authorization.login_required_msg\"),\n :permission_denied_message => I18n.t(\"authorization.permission_denied_msg\") }\n end",
"def create?\n @current_user.permission('Department', :clerk)\n end",
"def is_admin?\n\t\tself.permission_level >= 3\n\tend",
"def ensure_proper_permission!\n @chatroom = Chatroom.find params[:chatroom_id]\n\n user = @chatroom.user\n study_group = @chatroom.study_group\n\n unless current_user == user || study_group&.has_member?(current_user)\n head 401\n end\n end",
"def AccessRights=(arg0)",
"def check_permission\n # Check if user is signed in\n signed_in_user\n \n if (params[:topic_id]).nil?\n topic = Post.find(params[:id]).topic\n else\n topic = Topic.find(params[:topic_id])\n end\n\n # Admins have unlimited power\n if !current_user_is_admin?\n # Moderators have unlimited power in their boards\n if !current_user_is_moderator?(topic.board)\n\n # Check that user has the required rank to post in the board\n if !topic.board.required_rank.nil?\n req_rank = Rank.find(topic.board.required_rank)\n unless current_user.rank >= req_rank\n flash[:alert] = \"You do not have the required rank for that board.\" \n redirect_to topic\n return\n end\n end\n\n # Check if the board is unlocked\n if topic.board.locked?\n flash[:alert] = \"That board is currently locked.\"\n redirect_to topic\n return\n end\n\n # Check if the topic is unlocked\n if topic.locked?\n flash[:alert] = \"That topic is currently locked.\" \n redirect_to topic\n return\n end\n end\n end\n end",
"def permissions\n\t\tauthorize @user\n\t\t@permissions = []\n\t\tonly_theirs = \"Only theirs\"\n\t\tyes = \"Yes\"\n\t\tno = \"No\"\n\t\tnames = [\"View positions\", \"Create positions\", \"Edit positions\", \"Delete positions\",\n\t\t \"Apply\", \"View applications\", \"Edit applications\", \"Delete applications\",\n\t\t \"Change application submission status\"]\n\t\tadmin_permissions = [yes, yes, yes, yes, yes, \"All\", yes, yes, yes]\n\t\tmod_permissions = [yes, no, yes, no, yes, \"All but incomplete\", only_theirs, only_theirs, yes]\n\t\tuser_permissions = [yes, no, no, no, yes, only_theirs, only_theirs, only_theirs, no]\n\t\tnames.each_with_index do |permission, index|\n\t\t\t@permissions << { name: names[index], admin: admin_permissions[index], mod: mod_permissions[index], user: user_permissions[index]}\n\t\tend\n\n @title = 'Permissions'\n\tend",
"def paranoid_permissions\n true\n end",
"def check_permissions\n if @user.is_admin? && !current_user.is_admin?\n respond_to do |wants|\n wants.html { redirect_to console_users_path }\n wants.json { render :json => false, :status => 404 }\n end\n false\n end\n end"
] |
[
"0.74618053",
"0.73894244",
"0.7288124",
"0.7288124",
"0.7288124",
"0.67968214",
"0.67613757",
"0.675405",
"0.66822386",
"0.66687113",
"0.66521305",
"0.6628175",
"0.6606342",
"0.65824926",
"0.65687776",
"0.6541755",
"0.65338206",
"0.65215003",
"0.65164065",
"0.65154886",
"0.6503761",
"0.6493501",
"0.6492164",
"0.64762336",
"0.6463856",
"0.6440871",
"0.6436628",
"0.6432729",
"0.6425763",
"0.64247245",
"0.64112794",
"0.63853735",
"0.63853645",
"0.6370071",
"0.63663936",
"0.63586867",
"0.63542086",
"0.6344208",
"0.6318912",
"0.6317907",
"0.63003886",
"0.6295642",
"0.62953246",
"0.6295166",
"0.6289111",
"0.62831545",
"0.62775016",
"0.62698984",
"0.6263676",
"0.62578434",
"0.6249565",
"0.624882",
"0.62443906",
"0.62422234",
"0.6234659",
"0.6230955",
"0.62306505",
"0.6223427",
"0.62226325",
"0.6221594",
"0.62018764",
"0.6195078",
"0.6194207",
"0.61915743",
"0.6182443",
"0.6175522",
"0.6164242",
"0.61594814",
"0.6153289",
"0.6142607",
"0.6140747",
"0.6128277",
"0.6128277",
"0.6124033",
"0.6112778",
"0.6100288",
"0.6094723",
"0.6094723",
"0.6092111",
"0.6088553",
"0.608813",
"0.6085179",
"0.60842025",
"0.6082613",
"0.60765386",
"0.60759515",
"0.60758597",
"0.6075762",
"0.6070805",
"0.6066892",
"0.6062791",
"0.6061894",
"0.6061119",
"0.60538703",
"0.60447514",
"0.6043584",
"0.6041397",
"0.6040124",
"0.6029922",
"0.60279846",
"0.6027815"
] |
0.0
|
-1
|
Because named_binder_route can accept an id or object, so can this check
|
def binder_routing_ok?(binder, action)
return request.path[0..named_binder_route(binder, action).size - 1] == named_binder_route(binder, action)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def has_named_route?(name); end",
"def named_route; end",
"def has_named_route?(name)\n @set.named_routes.key?(name)\n end",
"def route_for(name, *args); end",
"def is_route?\n self.object_type.downcase.to_s == \"route\"\n end",
"def named?\n id.kind_of?(String)\n end",
"def routing_params?\n routing_params.any?\n end",
"def routing_params?\n routing_params.any?\n end",
"def named_routes=(_arg0); end",
"def valid_object model, id\n unless object = model.find_by_id(id)\n errors = {:id => 'no corresponding entry'}\n render :json => {:code => 101, :type => 'wrong_parameters', :parameters => errors}, :status => 400, :method => :get\n return false\n end\n return object\n end",
"def route_eval\n super\n rescue ActiveRecord::RecordNotFound\n not_found\n end",
"def contains?(arg)\n case arg\n when Symbol\n !!lookup_name(arg.id2name)\n when String\n !!lookup_name(arg)\n when Integer\n !!lookup_id(arg)\n when self\n true\n else\n false\n end\n end",
"def has_param?(name)\n\n end",
"def pickup_route(t_obj, value)\n t_obj.pickup_route_id = @routes.detect{|r| r.name == value}.try(:id)\n end",
"def find_by_id_or_name(error_handler=nil)\n error_handler ||= lambda do |msg|\n logger.error \"find_by_id_or_name #{msg}\"\n return redirect_to_error!(msg)\n end\n\n unless params[:id] || params[:name]\n return error_handler.call(\"No id or name parameter given\")\n end\n\n classname = params[:controller].camelize.singularize\n id = params[:id]\n id ||= params[:name]\n method = :find\n\n if id.blank?\n return error_handler.call(\"Empty id or name parameter given\")\n end\n\n begin\n klass = Kernel.const_get(classname)\n if !id.match(/^[0-9]+$/)\n method = :find_by_name!\n end\n\n unless klass.respond_to?(method)\n return error_handler.call(\"#{classname} does not respond to #{method}\")\n end\n rescue => e\n return error_handler.call(\"No such class name #{classname}\")\n end\n\n begin\n obj = klass.send(method, id)\n rescue => e\n return error_handler.call(e.message)\n end\n\n instance_variable_set(\"@#{params[:controller].singularize}\", obj)\n true\n end",
"def route_name; end",
"def route_name; end",
"def validate\n __debug_route\n ids = params[:identifier].presence\n render json: validate_identifiers(ids) if ids\n end",
"def show\n @binder = Binder.find(params[:id])\n \n authorize! :read, @binder\n \n # set this binder into the session for quick access\n session[:binder_id] = params[:id]\n \n respond_to do |format|\n format.html { render layout: 'binder' } # show.html.erb\n format.json { render json: @binder }\n end\n end",
"def named_route(name)\n @named_routes[name]\n end",
"def partial_arguments_check(object, field_name)\n raise ArgumentError, 'Field name is required.' if field_name.blank?\n raise ArgumentError, 'Object is not decorated.' \\\n unless object.is_a? ResourceDecorator\n end",
"def named_binder_route(binder, action = \"show\")\n\n\t\tif binder.class == Binder\n\t\t\tretstr = \"/#{binder.handle}/portfolio\"\n\n\t\t\tif binder.parents.length != 1\n\t\t\t\tretstr += \"/#{CGI.escape(binder.root.gsub(\" \", \"-\"))}\"\n\t\t\tend\n\n\t\t\tretstr += \"/#{CGI.escape(binder.title.gsub(\" \", \"-\"))}/#{binder.id}\"\n\n\t\t\tif action != \"show\"\n\t\t\t\tretstr += \"/#{action}\"\n\t\t\tend\n\n\t\t\treturn retstr\n\t\telsif binder.class == String\n\t\t\treturn named_binder_route(Binder.find(binder), action)\n\t\telse\n\t\t\treturn \"/500.html\"\n\t\tend\n\n\tend",
"def bound?\n return bound_name != nil\n end",
"def can_invoke_method_of_same_name_on_obj?\n method_of_same_name_exists_on_obj? && @field.arguments.size == 0\n end",
"def ensure_param(arg)\n params[arg.to_sym].present?\n end",
"def bound_name?(name)\n type = @names[name.to_sym]\n if type.nil?\n @parent&.bound_name?(name)\n else\n type\n end\n end",
"def resolve_object_ref(id)\n end",
"def undefined_route\n routing_error!\n end",
"def method_missing(meth, *args, &block)\n if object\n begin\n object.send(meth, *args, &block)\n rescue\n if meth.to_sym == :url\n \"/#{object.class.to_s.underscore.pluralize}/#{object.id}\"\n else\n \"No method #{meth} found for decorated #{object.class.to_s}\"\n end\n end\n else\n placeholder(meth)\n end\n end",
"def respond_to? name, priv = false\n key = TRANSLATOR.cocoaify name.to_s.chomp(EQUALS)\n @ref.attributes.include?(key) ||\n @ref.parameterized_attributes.include?(key) ||\n super\n end",
"def include?(arg)\n case arg\n when Symbol\n !lookup_name(arg.id2name).nil?\n when String\n !lookup_name(arg).nil?\n when Integer\n !lookup_id(arg).nil?\n when self\n possible_match = lookup_id(arg.id)\n !possible_match.nil? && possible_match == arg\n else\n false\n end\n end",
"def exist(obj)\n redirect t('redirect.not_found') if obj.nil?\n end",
"def routes_for!(place_or_object_place_was_built_from)\n routes_for(place_or_object_place_was_built_from).tap do |routes|\n routes.each do |route|\n fail_unless_route_is_ok route\n end\n end\n end",
"def method_missing(method_id, args = nil)\n args.nil? && to_h[method_id] || super\n end",
"def endpoint_present?\n endpoint = Endpoint.find_by(user_id: user_id, verb: verb, path: path)\n if endpoint && (id.present? ? id != endpoint[:id] : true)\n errors.add(:verb, \"Endpoint already exist for the combination verb: #{verb} and path: #{path}\")\n errors.add(:path, \"Endpoint already exist for the combination path: #{path} and verb #{verb}\")\n end\n end",
"def id?\n @kind == :id\n end",
"def bad_slug?(object)\n params[:id] != object.to_param\n end",
"def bad_slug?(object)\n params[:id] != object.to_param\n end",
"def show\n # going to get a single post by ID\n @post = Post.find(params[:id]) #dynamic route matcher\n end",
"def named_routes; end",
"def respond_to_missing?(method_name, include_private = false)\n /^(?<id>[^=]+)=?$/ =~ method_name.to_s && self[id] || super\n end",
"def has_arg name\n raise \"has_arg #{name}.#{name.class}\" unless name.is_a? Symbol\n self.arg_names.index_of name\n end",
"def route\n #TODO\n end",
"def try_render(object)\n begin\n render self.route.instance_variable_get('@original_path').gsub(/(\\(|\\/:).+/, '/') + action_name\n rescue\n case content_type\n when :json\n return object.to_json if object.respond_to?(:to_json)\n when :xml\n return object.to_xml if object.respond_to?(:to_xml)\n end\n raise ::Padrino::Responders::ResponderError, \"Couldn't figure out a way to respond to this.\"\n end\n end",
"def handler_bind?\n payload_instance && payload_instance.connection_type == 'bind'\n end",
"def is_exists?(objects, object_value)\n unless objects\n @object = object_value.titleize\n render \"api/v1/errors/404\", status: 404\n end\n end",
"def do_object_path(object, action_or_options = nil, options = {})\n return unless object\n\n if action_or_options.is_a?(Hash)\n options = action_or_options\n action = nil\n else\n action = action_or_options\n end\n\n route_method, route_params, engine, path_prefix = [nil, [], nil, nil]\n\n singular_route = false\n if object.respond_to?(:as_object_path)\n o = object.as_object_path\n route_method = o[:route_method] || nil\n route_params = o[:route_params] || []\n singular_route = o[:singular] || false\n engine = o[:engine] || nil\n\n if o[:path_prefix]\n p = o[:path_prefix]\n prefix_route_method = p[:route_method] || nil\n prefix_route_params = p[:route_params] || []\n prefix_engine = p[:engine] || nil\n path_prefix = yield prefix_route_method, \"\", prefix_route_params, prefix_engine\n end\n end\n\n route_params << object unless singular_route\n\n route = route_method || try_produce_route(route_params)\n if ! object.is_a?(Class) && object.new_record? || action.to_s == 'new'\n action = :new\n route_params.pop\n end\n\n prefix = action ? \"#{action}_\" : \"\"\n\n # add options\n case route_params\n when Hash\n route_params.merge!(options)\n when Array\n route_params << options\n end\n\n [path_prefix, yield(route, prefix, route_params, engine)].compact.join(\"\")\n end",
"def bad_slug?(object)\n params[:id] != object.to_param\nend",
"def named_arg_required(name, obj)\n named_arg_required('name', name) unless name.eql?('name')\n raise ArgumentError, \"Argument \\\"#{name}\\\" cannot be nil\" if obj.nil?\n end",
"def drop_route(t_obj, value)\n t_obj.drop_route_id = @routes.detect{|r| r.name == value}.try(:id)\n end",
"def match?(action, object)\n true\n end",
"def isKindOf _obj, _args\n \"_obj isKindOf _args;\" \n end",
"def check_if_myself(id = params[:id].to_i)\n\t\tunless current_user.id == id.to_i\n\t\t\traise ActionController::RoutingError, 'Not Found'\n\t\tend\n\tend",
"def check_if_myself(id = params[:id].to_i)\n\t\tunless current_user.id == id.to_i\n\t\t\traise ActionController::RoutingError, 'Not Found'\n\t\tend\n\tend",
"def bind_to_object=(_arg0); end",
"def id?\n true\n end",
"def saved_object_exists?(type, id)\n begin\n get_saved_object_by_id(type, id).present?\n rescue ApiExceptions::NotFoundError\n false\n end\n end",
"def route_for(**url_details)\n @routes.select { |rt| url_details <= rt.url_details }.first\n end",
"def accept?(path_info)\n\t\t1\n\tend",
"def respond_to_missing?(method_symbol, *args, &block)\n block.nil? && args.length == 1 && !method_symbol.match(/^to_/) || super\n end",
"def index_pattern_exists?(id)\n saved_object_exists?(\"index-pattern\", id)\n end",
"def respond_to_missing?( id, priv = false ) id != :call; end",
"def method_missing(id, *args, &blk)\n if @resource.respond_to?(id, true)\n @resource.send(id, *args, &blk)\n else\n super\n end\n end",
"def update\n @binder = Binder.find(params[:id])\n \n authorize! :write, @binder\n\n respond_to do |format|\n if @binder.update_attributes(params[:binder])\n format.html { redirect_to @binder, notice: 'Binder was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action:\"edit\" }\n format.json { render json: @binder.errors, status: :unprocessable_entity }\n end\n end\n end",
"def url_for dest, params={}\n\t\t\t\tcase dest\n\t\t\t\twhen :index, nil, false\n\t\t\t\t\tdest = {}\n\t\t\t\twhen String\n\t\t\t\t\tdest = {id: dest}\n\t\t\t\twhen Numeric, Symbol\n\t\t\t\t\tdest = {id: dest}\n\t\t\t\twhen Hash\n\t\t\t\t\ttrue\n\t\t\t\telse\n\t\t\t\t\t# convert dest.id and dest[:id] to their actual :id value.\n\t\t\t\t\tdest = {id: (dest.id rescue false) || (raise TypeError, \"Expecting a Symbol, Hash, String, Numeric or an object that answers to obj[:id] or obj.id\") }\n\t\t\t\tend\n\t\t\t\t::Plezi::Base::HTTPRouter.url_for self, dest, params\n\t\t\tend",
"def route(t_obj, value)\n if self.class.common_route\n route_id = @routes.detect{|r| r.name == value}.try(:id)\n t_obj.pickup_route_id = route_id\n t_obj.drop_route_id = route_id\n end\n end",
"def edit\n @binder=Binder.find(params[:binder_id])\n\n end",
"def command?(name)\n __getobj__.present?(name)\n end",
"def _arg( name )\n\t\tname = name.to_sym\n\t\treturn request.request_parameters[name] || request.query_parameters[name]\n\tend",
"def _arg( name )\n\t\tname = name.to_sym\n\t\treturn request.request_parameters[name] || request.query_parameters[name]\n\tend",
"def id_or_param(id)\n id = id.to_param if id.respond_to?(:to_param)\n id\nend",
"def checkParamInArguments(id)\n in_arguments = false\n @arguments.each { |arg|\n if arg[:id] == id\n in_arguments = true\n break\n end\n }\n if in_arguments\n abort(\"\\nERROR: Argument '#{id}' already defined in the arguments of '#{@scope_location}'\\n\")\n end\n end",
"def try_route(type, name)\n try_route_with_redis(type, name)\n end",
"def if_found(obj)\n if obj\n yield \n else\n render :text => \"Not found.\", :status => \"404 Not Found\"\n false\n end \n end",
"def binder=(_arg0); end",
"def routing_mismatch\n raise ::ActionController::RoutingError,\"URL not supported\"\n end",
"def identifies_as?( object )\n \n return ::IdentifiesAs.object_identifies_as?( self, object ) \n \n end",
"def repel_them\n # I dont need to repel_them if id is nil\n return if (params[:id] == nil)\n\n # Get the model class loaded into an object which can also be a class\n myklass = self.active_scaffold_config.model\n # Use the object-class-beastie to run .find() against the id in the request URL\n the_obj = myklass.find(params[:id])\n # Find out who owns the_obj\n the_usr_id = the_obj.send(:usr_id)\n # Repel them if they dont own the object pointed to by the id in the request URL\n redirect_to(\"/\") unless the_usr_id == session[:usr_id]\n end",
"def repel_them\n # I dont need to repel_them if id is nil\n return if (params[:id] == nil)\n\n # Get the model class loaded into an object which can also be a class\n myklass = self.active_scaffold_config.model\n # Use the object-class-beastie to run .find() against the id in the request URL\n the_obj = myklass.find(params[:id])\n # Find out who owns the_obj\n the_usr_id = the_obj.send(:usr_id)\n # Repel them if they dont own the object pointed to by the id in the request URL\n redirect_to(\"/\") unless the_usr_id == session[:usr_id]\n end",
"def property?(name)\n chain_route(:element_type => :object,\n :pipe_class => Pacer::Pipes::PropertyPipe,\n :pipe_args => [name.to_s, false])\n end",
"def get_binding(param)\n binding\nend",
"def find_by_name\n not_found and return if params[:id].blank?\n\n name = controller_name.singularize\n cond = \"find\" + (params[:id] =~ /\\A\\d+(-.+)?\\Z/ ? \"\" : \"_by_name\")\n not_found and return unless instance_variable_set(\"@#{name}\", resource_base.send(cond, params[:id]))\n end",
"def primary(request, element)\n # TODO: see if it's faster to compare either\n # by `:java_class`, `:instance_of?` or `:code`\n case\n when request.instance_of?(Cf::GETRequest)\n @route.call(:get, request, element)\n when request.instance_of?(Cf::PUTRequest)\n @route.call(:put, request, element)\n when request.instance_of?(Cf::POSTRequest)\n @route.call(:post, request, element)\n when request.instance_of?(Cf::DELETERequest)\n @route.call(:delete, request, element)\n else\n request.respond(CR[:bad_request])\n end\n end",
"def exists?(obj)\n obj.is_a?(String) ? url?(obj) : doc?(obj)\n end",
"def bound_object\n return super if Rib::Anchor.disabled?\n return super if eval_binding.kind_of?(Binding)\n eval_binding\n end",
"def method_undefined(id)\n\t\t\t\treset_routing_cache\n\t\t\tend",
"def binder; end",
"def binder; end",
"def match?(_request)\n fail NotImplementedError\n end",
"def has_param?(name)\n @input.has_key?(name)\n end",
"def get(path_or_id, *args)\n if path_or_id.is_a?(String)\n get_by_path(path_or_id)\n else\n super\n end\n end",
"def method_undefined(id)\n\t\t\t\t\treset_routing_cache\n\t\t\t\tend",
"def call(env)\n route = self.route(env)\n if route\n env['params'] = route.match(env) || {}\n route.call(env)\n else\n env['params'] = {}\n not_found.call(env)\n end\n end",
"def hash_or_parameter?(args)\n args.is_a?(Hash) || args.respond_to?(:to_unsafe_h)\n end",
"def isBind(type, key)\n result = false\n obj = self.bindableObject(type)\n unless obj.nil?\n result = obj.binding_list.include?(key)\n end\n\n return result\n end",
"def routing_key; opt('routing_key'); end",
"def method_missing(sym, *args, &blk)\n # match: actor_entity | actor_id | actor\n match_data = sym.to_s.match(/(.+)_(entity|id)$/)\n entity_name = match_data ? match_data[1].to_sym : sym\n\n if Activr.registry.entities_names.include?(entity_name)\n # ok, don't worry...\n # define an instance method so that future calls on that method do not rely on method_missing\n self.instance_eval <<-RUBY\n def #{sym}(*args, &blk)\n nil\n end\n RUBY\n\n self.__send__(sym, *args, &blk)\n else\n # super Michel !\n super\n end\n end",
"def is?(id)\n self.id == id\n end",
"def exists?\n !new? && self.class.exists?(to_param, :params => prefix_options)\n end",
"def route(index_or_name)\n case index_or_name\n when Integer\n Rails.application.routes.routes[index_or_name]\n when Symbol # named route\n Rails.application.routes.named_routes.get index_or_name\n end\nend"
] |
[
"0.6605092",
"0.6031678",
"0.57937485",
"0.5731123",
"0.5641658",
"0.55204034",
"0.5489443",
"0.54461247",
"0.54316014",
"0.53647286",
"0.5362761",
"0.53321683",
"0.5304792",
"0.5274534",
"0.5248143",
"0.52430207",
"0.52430207",
"0.5232731",
"0.521501",
"0.5214525",
"0.5214336",
"0.5202616",
"0.5163941",
"0.512599",
"0.5107603",
"0.50767004",
"0.50600713",
"0.5054679",
"0.50524163",
"0.5050127",
"0.5038483",
"0.50319475",
"0.5016533",
"0.5013096",
"0.49940693",
"0.49772063",
"0.49756834",
"0.49756834",
"0.49493384",
"0.4942924",
"0.49374413",
"0.49324477",
"0.49175167",
"0.4910657",
"0.48987126",
"0.48972526",
"0.4894695",
"0.48851863",
"0.48827186",
"0.48764455",
"0.48648518",
"0.48596257",
"0.4846567",
"0.4846567",
"0.48400134",
"0.4821466",
"0.48205528",
"0.48203623",
"0.4800829",
"0.47998843",
"0.47861",
"0.47810394",
"0.478012",
"0.4778184",
"0.47740948",
"0.4772443",
"0.4767867",
"0.47645187",
"0.47605687",
"0.47605687",
"0.47555092",
"0.47492388",
"0.47485152",
"0.47456032",
"0.4740454",
"0.4734273",
"0.47300854",
"0.47296447",
"0.47296447",
"0.47267976",
"0.47235084",
"0.4722931",
"0.47191125",
"0.4710917",
"0.4708888",
"0.47087952",
"0.47085136",
"0.47085136",
"0.47071546",
"0.47063196",
"0.47059727",
"0.47023806",
"0.4700737",
"0.4699993",
"0.46991625",
"0.4698822",
"0.46933866",
"0.46918222",
"0.46915707",
"0.4690677"
] |
0.60411155
|
1
|
Function that returns routing given a binder object and action Only works for routes in the format of: /username/portfolio(/root)/title/id/action(s) Binder objects preferred over ids
|
def named_binder_route(binder, action = "show")
if binder.class == Binder
retstr = "/#{binder.handle}/portfolio"
if binder.parents.length != 1
retstr += "/#{CGI.escape(binder.root.gsub(" ", "-"))}"
end
retstr += "/#{CGI.escape(binder.title.gsub(" ", "-"))}/#{binder.id}"
if action != "show"
retstr += "/#{action}"
end
return retstr
elsif binder.class == String
return named_binder_route(Binder.find(binder), action)
else
return "/500.html"
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def binder_routing_ok?(binder, action)\n\n\t\treturn request.path[0..named_binder_route(binder, action).size - 1] == named_binder_route(binder, action)\n\n\tend",
"def action_routes action\n request_methods, route = REQUEST_METHODS, action.to_s\n REQUEST_METHODS.each do |m|\n regex = /\\A#{m}_/i\n if route =~ regex\n request_methods = [m]\n route = route.sub regex, ''\n break\n end\n end\n\n route.size == 0 && raise('wrong action name \"%s\"' % action)\n\n path_rules.keys.sort.reverse.each do |key|\n route = route.gsub(key.is_a?(Regexp) ? key : /#{key}/, path_rules[key])\n end\n\n pages, dirs = [], []\n path = rootify_url(base_url, route)\n pages << {nil => [path, nil]}\n dirs << {nil => [rootify_url(base_url), path]} if route == APPETITE__INDEX_ACTION\n\n ((@action_aliases||{})[action]||[]).each do |url|\n pages << {nil => [rootify_url(base_url, url), nil]}\n end\n\n canonicals.each do |c|\n canonical_path = rootify_url(c, route)\n pages << {nil => [canonical_path, path]}\n dirs << {nil => [rootify_url(c), path]} if route == APPETITE__INDEX_ACTION\n end\n pages.each do |page|\n format?(action).each { |format| page[format] = page[nil].first + format }\n end\n [request_methods, pages + dirs].freeze\n end",
"def action_for route\n raise \"Argument must be an Endpoint\" unless Endpoint === route\n action = @prefix[-1]\n action = PARAM_ROUTES[route[:method]] if self.action_mode == :param\n action = RESOURCE_ROUTES[route[:method]] if self.route_mode == :resource && self.action_mode == :collection\n action\n end",
"def route_to(klass_or_name, action)\n RouteToMatcher.new(klass_or_name, action)\n end",
"def resolve_path_from_action(action)\n case action\n when Symbol then uri.join(action)\n when String then ::Spyke::Path.new(action, fmrest_uri_attributes)\n else uri\n end\n end",
"def verb_path\n return nil if @binding.nil?\n\n {\n get: @binding.get,\n post: @binding.post,\n put: @binding.put,\n patch: @binding.patch,\n delete: @binding.delete\n }.find { |_, value| !value.empty? }\n end",
"def path_of(route_or_controller, action = nil)\n\t\t\tif route_or_controller.is_a?(Flame::Router::Route)\n\t\t\t\troute = route_or_controller\n\t\t\t\tcontroller = route.controller\n\t\t\t\taction = route.action\n\t\t\telse\n\t\t\t\tcontroller = route_or_controller\n\t\t\tend\n\t\t\treverse_routes.dig(controller.to_s, action)\n\t\tend",
"def route(index_or_name)\n case index_or_name\n when Integer\n Rails.application.routes.routes[index_or_name]\n when Symbol # named route\n Rails.application.routes.named_routes.get index_or_name\n end\nend",
"def map route_object\n klass = nil\n route = nil\n action = nil\n\n # map 'root' do\n # ...\n if block_given?\n @lux_action_target = route_object\n yield\n @lux_action_target = nil\n return\n elsif @lux_action_target\n klass = @lux_action_target\n route = route_object\n action = route_object\n\n # map :foo => :some_action\n if route_object.is_a?(Hash)\n route = route_object.keys.first\n action = route_object.values.first\n end\n\n if test?(route)\n call klass, action\n else\n return\n end\n end\n\n case route_object\n when String\n # map 'root#call'\n call route_object\n when Hash\n route = route_object.keys.first\n klass = route_object.values.first\n\n if route.class == Array\n # map [:foo, :bar] => 'root'\n for route_action in route\n if test?(route_action)\n call klass, route_action\n end\n end\n\n return\n elsif route.is_a?(String) && route[0,1] == '/'\n # map '/skils/:skill' => 'main/skills#show'\n return match route, klass\n end\n when Array\n # map [:foo, 'main/root']\n route, klass = *route_object\n else\n Lux.error 'Unsupported route type \"%s\"' % route_object.class\n end\n\n test?(route) ? call(klass) : nil\n end",
"def action_to_path action, path_rules\n path_rules.keys.sort.reverse.each do |key|\n action = action.gsub(/#{key}/, path_rules[key])\n end\n action\n end",
"def apply_action_routing(action, result)\n @last_action_result = result\n action.routing.apply_on_browser(result, self) if action.routing\n result.extend(Waw::Routing::Methods)\n result\n end",
"def path_to *args\n return \"#{args[0]}#{\"?\" << Gin.build_query(args[1]) if args[1]}\" if String === args[0]\n args.unshift(self.class) if Symbol === args[0] &&\n self.class.actions.include?(args[0])\n @app.router.path_to(*args)\n end",
"def lookup_action\n action = template.controller.action_name\n return unless action\n action = action.to_sym\n ACTIONS[action] || action\n end",
"def route_for(name, *args); end",
"def route_name; end",
"def route_name; end",
"def named_route; end",
"def find_action_method( txn, action, *args )\n\t\tself.log.debug \"Mapping %s( %p ) to an action\" % [ action, args ]\n\t\treturn self.method( \"#{action}_action\" )\n\tend",
"def named_routes=(_arg0); end",
"def action_name\n name = self.request.route_obj.instance_variable_get('@named').to_s\n name.gsub!(/^#{controller_name}_?/, '')\n name = 'index' if name == ''\n name\n end",
"def route(stock_url)\n url=stock_url.split(/\\/+/).join(\"/\")\n @routes.keys.each do |x|\n #@logger.msginfo(\"Main:route:Looking at '#{url}' (#{url[0,@routes[x]['path_length']]}) for '#{x}'\")\n if (x == url[0,@routes[x][\"path_length\"]])\n #@logger.msginfo(\"Main:route: #{@routes[x][\"handler\"].class.to_s} will do '#{url}'\")\n return @routes[x][\"handler\"]\n end\n end\n return nil #Bad, nothing matched\n end",
"def search_action_path(*args)\n if ['xbrowse', 'rbrowse'].member?(params[:action])\n url_for(*args)\n else\n super(*args)\n end\n end",
"def routes=(_arg0); end",
"def routes=(_arg0); end",
"def routes=(_arg0); end",
"def get_destination(destination, routing_params = {})\n if destination.respond_to?(:call)\n return destination\n end\n\n #if destination is something like books#welcome\n if destination =~ /^([^#]+)#([^#]+)$/\n #name will be Books\n name = $1.capitalize\n #controller will be the Constant BooksController\n controller = Object.const_get(\"#{name}Controller\")\n #ah, now here we use the class.action from above. passing in\n #welcome as the action, and routing params as the response object\n return controller.action($2, routing_params)\n end\n #otherwise we messed up by coming here\n raise \"Destination no found: #{destination}\"\n end",
"def route_for(**url_details)\n @routes.select { |rt| url_details <= rt.url_details }.first\n end",
"def route\n #TODO\n end",
"def rest\n\t\t\t\tself.class.rest_routes.each do |rest_route|\n\t\t\t\t\taction = rest_route[:action]\n\t\t\t\t\tnext if !@controller.actions.include?(action) || find_reverse_route(action)\n\n\t\t\t\t\tsend(*rest_route.values.map(&:downcase))\n\t\t\t\tend\n\t\t\tend",
"def rest_routes\n\t\t\t\t\t[\n\t\t\t\t\t\t{ method: :GET, path: '/', action: :index },\n\t\t\t\t\t\t{ method: :POST, path: '/', action: :create },\n\t\t\t\t\t\t{ method: :GET, path: '/', action: :show },\n\t\t\t\t\t\t{ method: :PUT, path: '/', action: :update },\n\t\t\t\t\t\t{ method: :DELETE, path: '/', action: :delete }\n\t\t\t\t\t]\n\t\t\t\tend",
"def _find_action_name(action_name); end",
"def route_helper(ctrlr, action = nil, base: false)\n ctr = ctrlr.to_s.underscore\n ctr = ctr.split('/').map(&:singularize).join('_') if ctr.include?('/')\n ctr = ctr.split('.').map(&:singularize).join('_') if ctr.include?('.')\n act = action&.to_sym\n act = base_action(act) if act && base\n if ctr.end_with?('_url', '_path')\n Log.warn(\"#{__method__}: #{ctrlr}: ignoring action #{act}\") if act\n ctr\n elsif ctr == 'home'\n act ? :\"#{act}_path\" : :main_path\n else\n case act\n when :index, nil then :\"#{ctr}_index_path\"\n when :show then :\"#{ctr}_path\"\n else :\"#{act}_#{ctr}_path\"\n end\n end\n end",
"def action_path(e, &block)\n block_given? ? yield(e) : path_args(e)\n end",
"def action_path(e, &block)\n block_given? ? yield(e) : path_args(e)\n end",
"def named_routes; end",
"def get_action_name( txn, id=nil, *args )\n\t\thttp_method = txn.request_method\n\t\tself.log.debug \"Looking up service action for %s %s (%p)\" %\n\t\t\t[ http_method, txn.uri, args ]\n\n\t\ttuple = METHOD_MAPPING[ txn.request_method ] or return :not_allowed\n\t\tself.log.debug \"Method mapping for %s is %p\" % [ txn.request_method, tuple ]\n\n\t\tif args.empty?\n\t\t\tself.log.debug \" URI refers to top-level resource\"\n\t\t\tmsym = tuple[ id ? 1 : 0 ]\n\t\t\tself.log.debug \" picked the %p method (%s ID argument)\" %\n\t\t\t\t[ msym, id ? 'has an' : 'no' ]\n\n\t\telse\n\t\t\tself.log.debug \" URI refers to a sub-resource (args = %p)\" % [ args ]\n\t\t\tops = args.collect {|arg| arg[/^([a-z]\\w+)$/, 1].untaint }\n\n\t\t\tmname = \"%s_%s\" % [ tuple[1], ops.compact.join('_') ]\n\t\t\tmsym = mname.to_sym\n\t\t\tself.log.debug \" picked the %p method (args = %p)\" % [ msym, args ]\n\t\tend\n\n\t\treturn msym, id, *args\n\tend",
"def parse_route(dn, method)\n route, action = @routes.match(\"#{dn},op=#{method.to_s}\")\n if not route or route.empty?\n @logger.warn \"No route defined for \\'#{route}\\'\"\n raise LDAP::ResultError::UnwillingToPerform\n end\n if action.nil?\n @logger.error \"No action defined for route \\'#{route}\\'\"\n raise LDAP::ResultError::UnwillingToPerform\n end\n\n class_name = action.split('#').first\n method_name = action.split('#').last\n\n params = LDAP::Server::DN.new(\"#{dn},op=#{method.to_s}\").parse(route)\n\n return class_name, method_name, params\n end",
"def dispatch_action(request)\n method = request_method(request)\n path = request.path.sub(/\\.\\w+$/, '')\n route = @routing.detect { |r| r[0] == method && r[1] == path }\n route[2] if route\n end",
"def lookup_action; end",
"def route_for(request) #:nodoc:\n index, params = match(request)\n route = routes[index] if index\n if !route\n raise ControllerExceptions::NotFound, \n \"No routes match the request: #{request.uri}\"\n end\n [route, params]\n end",
"def custom_routes; end",
"def get_action(action, args, text = nil)\n\t\t\twhile (alias_action = @aliases[action])\n\t\t\t\taction = alias_action[:action]\n\t\t\t\targs = alias_action[:args].map do |a|\n\t\t\t\t\ta.gsub(/\\$\\{(\\d+)(\\*q?)?\\}/) do |match|\n\t\t\t\t\t\t# expand ${1} to args[0], ${2} to args[1], etc.\n\t\t\t\t\t\t# expand ${4*} to \"#{args[4]} #{args[5]} ...\"\n\t\t\t\t\t\t# expand ${4*q} to \"\\\"#{args[4]}\\\" \\\"#{args[5]}\\\" ...\"\n\t\t\t\t\t\tidx = $1.to_i-1\n\t\t\t\t\t\tif $2 == nil\n\t\t\t\t\t\t\targs[idx] || ''\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\trange = args[idx..-1]\n\t\t\t\t\t\t\trange = range.map { |arg| '\"'+arg.gsub('\"', '\"\"')+'\"' } if $2 == '*q'\n\t\t\t\t\t\t\trange.join(' ')\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\n\t\t\ttext = ([action] + args.map { |a| '\"'+a.gsub('\"', '\"\"')+'\"' }).join(' ') unless text\n\t\t\tfile = @variables['__FILE__']\n\t\t\tline = @variables['__LINE__']\n\n\t\t\tAction.new(self, action, args, text, file, line)\n\t\tend",
"def rest_url_for(*args)\n options = args.at(0)\n case options\n when Hash\n action = options[:action]\n action ||= 'show'\n controller = options[:controller]\n key = ''\n if options[:entity] then\n entity = options[:entity]\n controller ||= entity.model_name\n key = entity.key\n end\n if action && action.include?('/') then\n action = action.split('/')\n controller = action[0]\n action = action[1]\n end\n\n url = \"#{controller}/#{key}\" \n url << \"/#{action}\" if action\n get_params = options.dup\n get_params.delete(:action)\n get_params.delete(:controller)\n get_params.delete(:entity)\n url << get_params.to_get_params if get_params.size > 0\n when Aurita::Model\n entity = args.at(0)\n options = args.at(1)\n options ||= {}\n controller = options[:controller]\n controller ||= entity.model_name\n action = options[:action]\n key = entity.key.values.first\n url = \"#{controller}/#{key}\"\n url << \"/#{action}\" if action\n get_params = options.dup\n get_params.delete(:action)\n get_params.delete(:controller)\n get_params.delete(:entity)\n url << '/' << get_params.to_get_params if get_params.size > 0\n else\n entity = args.at(0)\n options = args.at(1)\n options ||= {}\n controller ||= entity.model_name\n action = options[:action]\n url = \"#{controller}\"\n url << \"/#{action}\" if action\n get_params = options.dup\n get_params.delete(:action)\n url << '/' << get_params.to_get_params if get_params.size > 0\n end\n url\n end",
"def _routes; end",
"def url(name, *args)\n unless Symbol === name\n args.unshift(name)\n name = :default\n end\n \n unless route = Halcyon::Application::Router.named_routes[name]\n raise ArgumentError.new(\"Named route #{name.inspect} not found\")\n end\n \n route.generate(args, {:controller => controller_name, :action => method})\n end",
"def action\n action_name.to_sym\n end",
"def recognize_path(path_info)\n prepare! unless prepared?\n route = @engine.find_by_pattern(path_info).first\n [route.name, route.params_for(path_info, {})]\n end",
"def routing_params\n routing_params_with_patterns.map { |param, _| param }\n end",
"def resolve_path(path, *args)\n # logger.debug \"resolve_path: #{path}, args = #{args}\"\n m = /^(([^_]+)_)?((\\w+?)?)$/.match(path)\n if m\n action_with_underscore = m[1]\n action = m[2]\n resource = m[3]\n\n # logger.debug \"resolve_path: matched pattern: #{m}, action = #{action.inspect}, resource = #{resource}\"\n\n return self.class.routes.match_path(resource, action, *args)\n else\n raise \"unable to match path: #{path}_path\"\n end\n end",
"def get_action\n return @controller&.action_name&.to_sym\n end",
"def routing_number; end",
"def test_routes\n assert_routing(\n { :path => \"/diary\", :method => :get },\n { :controller => \"diary_entry\", :action => \"list\" }\n )\n assert_routing(\n { :path => \"/diary/language\", :method => :get },\n { :controller => \"diary_entry\", :action => \"list\", :language => \"language\" }\n )\n assert_routing(\n { :path => \"/user/username/diary\", :method => :get },\n { :controller => \"diary_entry\", :action => \"list\", :display_name => \"username\" }\n )\n assert_routing(\n { :path => \"/diary/friends\", :method => :get },\n { :controller => \"diary_entry\", :action => \"list\", :friends => true }\n )\n assert_routing(\n { :path => \"/diary/nearby\", :method => :get },\n { :controller => \"diary_entry\", :action => \"list\", :nearby => true }\n )\n\n assert_routing(\n { :path => \"/diary/rss\", :method => :get },\n { :controller => \"diary_entry\", :action => \"rss\", :format => :rss }\n )\n assert_routing(\n { :path => \"/diary/language/rss\", :method => :get },\n { :controller => \"diary_entry\", :action => \"rss\", :language => \"language\", :format => :rss }\n )\n assert_routing(\n { :path => \"/user/username/diary/rss\", :method => :get },\n { :controller => \"diary_entry\", :action => \"rss\", :display_name => \"username\", :format => :rss }\n )\n\n assert_routing(\n { :path => \"/user/username/diary/comments\", :method => :get },\n { :controller => \"diary_entry\", :action => \"comments\", :display_name => \"username\" }\n )\n assert_routing(\n { :path => \"/user/username/diary/comments/1\", :method => :get },\n { :controller => \"diary_entry\", :action => \"comments\", :display_name => \"username\", :page => \"1\" }\n )\n\n assert_routing(\n { :path => \"/diary/new\", :method => :get },\n { :controller => \"diary_entry\", :action => \"new\" }\n )\n assert_routing(\n { :path => \"/diary/new\", :method => :post },\n { :controller => \"diary_entry\", :action => \"new\" }\n )\n assert_routing(\n { :path => \"/user/username/diary/1\", :method => :get },\n { :controller => \"diary_entry\", :action => \"view\", :display_name => \"username\", :id => \"1\" }\n )\n assert_routing(\n { :path => \"/user/username/diary/1/edit\", :method => :get },\n { :controller => \"diary_entry\", :action => \"edit\", :display_name => \"username\", :id => \"1\" }\n )\n assert_routing(\n { :path => \"/user/username/diary/1/edit\", :method => :post },\n { :controller => \"diary_entry\", :action => \"edit\", :display_name => \"username\", :id => \"1\" }\n )\n assert_routing(\n { :path => \"/user/username/diary/1/newcomment\", :method => :post },\n { :controller => \"diary_entry\", :action => \"comment\", :display_name => \"username\", :id => \"1\" }\n )\n assert_routing(\n { :path => \"/user/username/diary/1/hide\", :method => :post },\n { :controller => \"diary_entry\", :action => \"hide\", :display_name => \"username\", :id => \"1\" }\n )\n assert_routing(\n { :path => \"/user/username/diary/1/hidecomment/2\", :method => :post },\n { :controller => \"diary_entry\", :action => \"hidecomment\", :display_name => \"username\", :id => \"1\", :comment => \"2\" }\n )\n assert_routing(\n { :path => \"/user/username/diary/1/subscribe\", :method => :post },\n { :controller => \"diary_entry\", :action => \"subscribe\", :display_name => \"username\", :id => \"1\" }\n )\n assert_routing(\n { :path => \"/user/username/diary/1/unsubscribe\", :method => :post },\n { :controller => \"diary_entry\", :action => \"unsubscribe\", :display_name => \"username\", :id => \"1\" }\n )\n end",
"def anchored_routes; end",
"def action_name\n self.class.name.gsub(/Parameters/, '').underscore.to_sym\n end",
"def routes_generate_options\n {\n :action => action_ref(:class => :controller),\n #TODO named root params\n :controller => controller_ref,\n :generate_all => nil,\n :method => link_to_methods,\n :use_route => nil,\n\n }\n end",
"def get_gist_route(gist)\n try_route(:gist, gist)\n end",
"def routes\n [@name.downcase]\n end",
"def con_pull_action(input, args)\n\t\troute = @routing_table.find { |r| r.name == @context_arg }\n\n\t\tid = args[:action].to_i\n\t\taction = route.actions[id]\n\n\t\tif id >= 1\n\t\t\troute.actions.insert(id - 1, action)\n\t\t\troute.actions.delete_at(id + 1)\n\t\tend\n\tend",
"def cms_path_for( object_or_model, action = :index, params = {} )\n\n # first, cast whatever we get to a class + check it’s useful to us\n klass = object_or_model.is_a?( Class ) ? object_or_model : object_or_model.class\n raise TypeError.new( 'object_or_model must be either an instance of-, or a class extending ActiveRecord::Base' ) unless klass < ActiveRecord::Base\n\n # now get a class name for pathing purposes\n klass_name = klass.to_s.underscore.pluralize.downcase\n\n # load some routes if we’ve not already done so\n load_routes if routes.nil?\n\n # work out the context we’re currently in + append what we think we’re after\n context_stack = Rails.application.routes.recognize_path( request.path, method: request.env['REQUEST_METHOD'] )[:controller].split( '/' )\n context_stack = context_stack.map.with_index{ |seg, idx| context_stack.slice( 0, idx + 1 ).join( '/' ) + \"/#{klass_name}\" }\n\n # search for matching routes\n matched = routes.select{ |r| context_stack.include?( r[:controller] ) and r[:action] == action }\n\n # if that didn’t work, look for anything that matches the wider pattern\n if matched.empty?\n\n # remove our class name from the stack\n context_stack.map!{ |c| c.gsub( \"/#{klass_name}\", '' )}\n\n # perform a wider search, grab the longest match\n matched = routes.select{ |r|\n r[:action] == action and\n r[:controller].ends_with?( klass_name ) and\n context_stack.select{ |c| r[:controller].starts_with?( c ) }.any?\n }.sort{ |b, a| a[:name].length <=> b[:name].length }\n\n end\n\n # if we’re still a failure\n raise \"Cannot find action #{action} for model #{klass.to_s}\" if matched.empty?\n\n # construct our parameters (we’ll use the form context for this, as it should contain everything we have)\n context = ( @form_context[1..-1] << object_or_model ).slice( 0, matched.first[:params].length )\n\n # call the appropriate route\n send( \"#{matched.first[:name]}_path\", *context, params )\n\n end",
"def route_index; end",
"def routing_params\n routing_params_with_patterns.map { |param, _| param }\n end",
"def test_routes\n assert_routing(\n { :path => \"/api/capabilities\", :method => :get },\n { :controller => \"api\", :action => \"capabilities\" }\n )\n assert_recognizes(\n { :controller => \"api\", :action => \"capabilities\" },\n { :path => \"/api/0.6/capabilities\", :method => :get }\n )\n assert_routing(\n { :path => \"/api/0.6/permissions\", :method => :get },\n { :controller => \"api\", :action => \"permissions\" }\n )\n assert_routing(\n { :path => \"/api/0.6/map\", :method => :get },\n { :controller => \"api\", :action => \"map\" }\n )\n assert_routing(\n { :path => \"/api/0.6/trackpoints\", :method => :get },\n { :controller => \"api\", :action => \"trackpoints\" }\n )\n assert_routing(\n { :path => \"/api/0.6/changes\", :method => :get },\n { :controller => \"api\", :action => \"changes\" }\n )\n end",
"def route_for(request)\n index, params = if @around_match\n send(@around_match, request) { match(request) }\n else\n match(request)\n end\n route = routes[index] if index\n if !route\n raise ControllerExceptions::NotFound, \n \"No routes match the request: #{request.uri}\"\n end\n [route, params]\n end",
"def url_for options = {}\n return \"/#{options[:controller].downcase}/#{options[:action]}/#{options[:id]}\" if options[:id].present?\n \"/#{options[:controller.downcase]}/#{options[:action]}\"\nend",
"def routes; end",
"def routes; end",
"def routes; end",
"def routes; end",
"def routes; end",
"def routes; end",
"def routes; end",
"def routes; end",
"def routes; end",
"def routes; end",
"def routes; end",
"def parse_route(path, options, verb)\n path = path.dup if path.kind_of?(String)\n route_options = {}\n\n if options[:params] == true\n options.delete(:params)\n elsif options.include?(:params)\n options[:params] ||= []\n options[:params] |= Array(options[:with]) if options[:with]\n end\n\n # We need check if path is a symbol, if that it's a named route.\n map = options.delete(:map)\n\n # path i.e :index or :show\n if path.kind_of?(Symbol)\n name = path\n path = map ? map.dup : (path == :index ? '/' : path.to_s)\n end\n\n # Build our controller\n controller = Array(@_controller).map(&:to_s)\n\n case path\n when String # path i.e \"/index\" or \"/show\"\n # Now we need to parse our 'with' params\n if with_params = options.delete(:with)\n path = process_path_for_with_params(path, with_params)\n end\n\n # Now we need to parse our provides\n options.delete(:provides) if options[:provides].nil?\n \n options.delete(:accepts) if options[:accepts].nil?\n\n if @_use_format || options[:provides]\n process_path_for_provides(path)\n # options[:add_match_with] ||= {}\n # options[:add_match_with][:format] = /[^\\.]+/\n end\n\n absolute_map = map && map[0] == ?/\n\n unless controller.empty?\n # Now we need to add our controller path only if not mapped directly\n if !map && !absolute_map\n controller_path = controller.join(\"/\")\n path.gsub!(%r{^\\(/\\)|/\\?}, \"\")\n path = File.join(controller_path, path) unless @_map\n end\n end\n\n # Now we need to parse our 'parent' params and parent scope.\n if !absolute_map and parent_params = options.delete(:parent) || @_parent\n parent_params = (Array(@_parent) + Array(parent_params)).uniq\n path = process_path_for_parent_params(path, parent_params)\n end\n\n # Add any controller level map to the front of the path.\n path = \"#{@_map}/#{path}\".squeeze('/') unless absolute_map || !@_map\n\n # Small reformats\n path.gsub!(%r{/\\?$}, '(/)') # Remove index path\n path.gsub!(%r{//$}, '/') # Remove index path\n path[0,0] = \"/\" if path !~ %r{^\\(?/} # Paths must start with a /\n path.sub!(%r{/(\\))?$}, '\\\\1') if path != \"/\" # Remove latest trailing delimiter\n path.gsub!(/\\/(\\(\\.|$)/, '\\\\1') # Remove trailing slashes\n path.squeeze!('/')\n when Regexp\n route_options[:path_for_generation] = options.delete(:generate_with) if options.key?(:generate_with)\n end\n\n name = options.delete(:route_name) if name.nil? && options.key?(:route_name)\n name = options.delete(:name) if name.nil? && options.key?(:name)\n if name\n controller_name = controller.join(\"_\")\n name = \"#{controller_name} #{name}\".to_sym unless controller_name.empty?\n end\n\n options[:default_values] = @_defaults unless options.has_key?(:default_values)\n\n [path, name, parent_params, options, route_options]\n end",
"def search_routing\n space.team_id\n end",
"def route\n @route\n end",
"def url(name, *args)\n options = args.last.is_a?(String) || args.last.is_a?(Numeric) ? nil : args.pop\n match, needs = self.class.route_names[name.to_sym]\n raise RuntimeError, \"Can't seem to find named route #{name.inspect}!\", caller if match.nil? && needs.nil?\n needs = needs.dup\n match = match.source.sub(/^\\^/,'').sub(/\\$$/,'')\n while match.gsub!(/\\([^()]+\\)/) { |m|\n # puts \"M: #{m}\"\n if m == '([^/?&#]+)'\n key = needs.shift\n # puts \"Needs: #{key}\"\n if options.is_a?(Hash)\n # puts \"Hash value\"\n options[key.to_sym] || options[key.to_s] || args.shift\n else\n if options.respond_to?(key)\n # puts \"Getting value from object\"\n options.send(key)\n else\n # puts \"Shifting value\"\n args.shift\n end\n end\n elsif m =~ /^\\(\\?[^\\:]*\\:(.*)\\)$/\n # puts \"matched #{m}\"\n m.match(/^\\(\\?[^\\:]*\\:(.*)\\)$/)[1]\n else\n raise \"Could not generate route :#{name} for #{options.inspect}: need #{args.join(', ')}.\" if args.empty?\n args.shift\n end\n }\n end\n match.gsub(/\\\\(.)/,'\\\\1') # unescapes escaped characters\n end",
"def get_route( request )\n return nil unless defined?( RAILS_ENV ) \n ::ActionController::Routing::Routes.recognize_path( request.path, {:method => request.request_method.downcase.to_sym } )\n end",
"def get_requested_route(env)\n request = Rack::Request.new(env)\n \n http_method = request.request_method.downcase\n path = request.path_info\n\n [http_method, path]\n end",
"def route\n @route ||= Role.available_routes.find {|r| r.conditions[:path_info].to_s == path_info && r.conditions[:request_method].to_s == request_method}\n end",
"def action_from_query_string(query_string)\n logger.debug \"[ApplicationController] Parsing action term from query string #{query_string.inspect}\"\n return '' if query_string.blank?\n\n matched = /^action=(?<act>\\S+)$/.match(query_string)\n matched[:act]\n end",
"def action\n self[:action].to_sym if self[:action]\n end",
"def action\n self[:action].to_sym if self[:action]\n end",
"def url_for_db(db, action = \"show\", item = nil)\n if item && restful_routed?(item)\n return polymorphic_path(item)\n end\n if @vm && %w[Account User Group Patch GuestApplication].include?(db)\n return url_for_only_path(:controller => \"vm_or_template\",\n :action => @lastaction,\n :id => @vm,\n :show => @id)\n elsif @host && %w[Patch GuestApplication].include?(db)\n return url_for_only_path(:controller => \"host\", :action => @lastaction, :id => @host, :show => @id)\n else\n controller, action = db_to_controller(db, action)\n return url_for_only_path(:controller => controller, :action => action, :id => @id)\n end\n end",
"def check_routes path, controller, action \n\t\t\tassert_routing path, { :controller => controller, :action => action} \n\t\tend",
"def route(name = '/', *args)\n hash = {}\n hashes, names = args.partition{|arg| arg.respond_to?(:merge!) }\n hashes.each{|to_merge| hash.merge!(to_merge) }\n\n name = name.to_s.gsub(/__/, '/')\n\n location = route_location(self)\n front = Array[location, name, *names.map{|element|\n Rack::Utils.escape(element) }].join('/').squeeze('/')\n\n return URI(front) if hash.empty?\n\n query = Rack::Utils.build_query(hash)\n URI(\"#{front}?#{query}\")\n end",
"def do_object_path(object, action_or_options = nil, options = {})\n return unless object\n\n if action_or_options.is_a?(Hash)\n options = action_or_options\n action = nil\n else\n action = action_or_options\n end\n\n route_method, route_params, engine, path_prefix = [nil, [], nil, nil]\n\n singular_route = false\n if object.respond_to?(:as_object_path)\n o = object.as_object_path\n route_method = o[:route_method] || nil\n route_params = o[:route_params] || []\n singular_route = o[:singular] || false\n engine = o[:engine] || nil\n\n if o[:path_prefix]\n p = o[:path_prefix]\n prefix_route_method = p[:route_method] || nil\n prefix_route_params = p[:route_params] || []\n prefix_engine = p[:engine] || nil\n path_prefix = yield prefix_route_method, \"\", prefix_route_params, prefix_engine\n end\n end\n\n route_params << object unless singular_route\n\n route = route_method || try_produce_route(route_params)\n if ! object.is_a?(Class) && object.new_record? || action.to_s == 'new'\n action = :new\n route_params.pop\n end\n\n prefix = action ? \"#{action}_\" : \"\"\n\n # add options\n case route_params\n when Hash\n route_params.merge!(options)\n when Array\n route_params << options\n end\n\n [path_prefix, yield(route, prefix, route_params, engine)].compact.join(\"\")\n end",
"def search_action_path(stuff)\n search_catalog_path(stuff)\n end",
"def action\n args.first\n end",
"def named_routes\n return [] unless app_obj.respond_to?(:routes)\n\n app_obj.routes.map { |route|\n request_method = route.request_methods.first\n next if !route.name || request_method == 'HEAD'\n route_name = route.name.to_s\n route_name =\n if route.controller\n route_name.split(\" \", 2).map{|name| \":#{name}\" }.join(\", \")\n else\n \":#{route_name}\"\n end\n name_array = \"(#{route_name})\"\n original_path = route.original_path.is_a?(Regexp) ? route.original_path.inspect : route.original_path\n full_path = File.join(uri_root, original_path)\n OpenStruct.new(:verb => request_method, :identifier => route.name, :name => name_array, :path => full_path)\n }.compact\n end",
"def method_for_action(action_name); end",
"def test_routes\n assert_routing(\n { :path => \"/api/0.6/user/1\", :method => :get },\n { :controller => \"user\", :action => \"api_read\", :id => \"1\" }\n )\n assert_routing(\n { :path => \"/api/0.6/user/details\", :method => :get },\n { :controller => \"user\", :action => \"api_details\" }\n )\n assert_routing(\n { :path => \"/api/0.6/user/gpx_files\", :method => :get },\n { :controller => \"user\", :action => \"api_gpx_files\" }\n )\n\n assert_routing(\n { :path => \"/login\", :method => :get },\n { :controller => \"user\", :action => \"login\" }\n )\n assert_routing(\n { :path => \"/login\", :method => :post },\n { :controller => \"user\", :action => \"login\" }\n )\n assert_recognizes(\n { :controller => \"user\", :action => \"login\", :format => \"html\" },\n { :path => \"/login.html\", :method => :get }\n )\n\n assert_routing(\n { :path => \"/logout\", :method => :get },\n { :controller => \"user\", :action => \"logout\" }\n )\n assert_routing(\n { :path => \"/logout\", :method => :post },\n { :controller => \"user\", :action => \"logout\" }\n )\n assert_recognizes(\n { :controller => \"user\", :action => \"logout\", :format => \"html\" },\n { :path => \"/logout.html\", :method => :get }\n )\n\n assert_routing(\n { :path => \"/user/new\", :method => :get },\n { :controller => \"user\", :action => \"new\" }\n )\n\n assert_routing(\n { :path => \"/user/new\", :method => :post },\n { :controller => \"user\", :action => \"create\" }\n )\n\n assert_routing(\n { :path => \"/user/terms\", :method => :get },\n { :controller => \"user\", :action => \"terms\" }\n )\n\n assert_routing(\n { :path => \"/user/save\", :method => :post },\n { :controller => \"user\", :action => \"save\" }\n )\n\n assert_routing(\n { :path => \"/user/username/confirm\", :method => :get },\n { :controller => \"user\", :action => \"confirm\", :display_name => \"username\" }\n )\n assert_routing(\n { :path => \"/user/username/confirm\", :method => :post },\n { :controller => \"user\", :action => \"confirm\", :display_name => \"username\" }\n )\n assert_routing(\n { :path => \"/user/username/confirm/resend\", :method => :get },\n { :controller => \"user\", :action => \"confirm_resend\", :display_name => \"username\" }\n )\n\n assert_routing(\n { :path => \"/user/confirm\", :method => :get },\n { :controller => \"user\", :action => \"confirm\" }\n )\n assert_routing(\n { :path => \"/user/confirm\", :method => :post },\n { :controller => \"user\", :action => \"confirm\" }\n )\n assert_routing(\n { :path => \"/user/confirm-email\", :method => :get },\n { :controller => \"user\", :action => \"confirm_email\" }\n )\n assert_routing(\n { :path => \"/user/confirm-email\", :method => :post },\n { :controller => \"user\", :action => \"confirm_email\" }\n )\n\n assert_routing(\n { :path => \"/user/go_public\", :method => :post },\n { :controller => \"user\", :action => \"go_public\" }\n )\n\n assert_routing(\n { :path => \"/user/forgot-password\", :method => :get },\n { :controller => \"user\", :action => \"lost_password\" }\n )\n assert_routing(\n { :path => \"/user/forgot-password\", :method => :post },\n { :controller => \"user\", :action => \"lost_password\" }\n )\n assert_routing(\n { :path => \"/user/reset-password\", :method => :get },\n { :controller => \"user\", :action => \"reset_password\" }\n )\n assert_routing(\n { :path => \"/user/reset-password\", :method => :post },\n { :controller => \"user\", :action => \"reset_password\" }\n )\n\n assert_routing(\n { :path => \"/user/suspended\", :method => :get },\n { :controller => \"user\", :action => \"suspended\" }\n )\n\n assert_routing(\n { :path => \"/user/username\", :method => :get },\n { :controller => \"user\", :action => \"view\", :display_name => \"username\" }\n )\n\n assert_routing(\n { :path => \"/user/username/account\", :method => :get },\n { :controller => \"user\", :action => \"account\", :display_name => \"username\" }\n )\n assert_routing(\n { :path => \"/user/username/account\", :method => :post },\n { :controller => \"user\", :action => \"account\", :display_name => \"username\" }\n )\n\n assert_routing(\n { :path => \"/user/username/make_friend\", :method => :get },\n { :controller => \"user\", :action => \"make_friend\", :display_name => \"username\" }\n )\n assert_routing(\n { :path => \"/user/username/make_friend\", :method => :post },\n { :controller => \"user\", :action => \"make_friend\", :display_name => \"username\" }\n )\n assert_routing(\n { :path => \"/user/username/remove_friend\", :method => :get },\n { :controller => \"user\", :action => \"remove_friend\", :display_name => \"username\" }\n )\n assert_routing(\n { :path => \"/user/username/remove_friend\", :method => :post },\n { :controller => \"user\", :action => \"remove_friend\", :display_name => \"username\" }\n )\n\n assert_routing(\n { :path => \"/user/username/set_status\", :method => :get },\n { :controller => \"user\", :action => \"set_status\", :display_name => \"username\" }\n )\n assert_routing(\n { :path => \"/user/username/delete\", :method => :get },\n { :controller => \"user\", :action => \"delete\", :display_name => \"username\" }\n )\n\n assert_routing(\n { :path => \"/users\", :method => :get },\n { :controller => \"user\", :action => \"list\" }\n )\n assert_routing(\n { :path => \"/users\", :method => :post },\n { :controller => \"user\", :action => \"list\" }\n )\n assert_routing(\n { :path => \"/users/status\", :method => :get },\n { :controller => \"user\", :action => \"list\", :status => \"status\" }\n )\n assert_routing(\n { :path => \"/users/status\", :method => :post },\n { :controller => \"user\", :action => \"list\", :status => \"status\" }\n )\n end",
"def search_action_url options = {}\n options = options.to_h if options.is_a? Blacklight::SearchState\n url_for(options.reverse_merge(action: 'index'))\n end",
"def url_for_me(action)\n if action == 'show'\n \"/projects/#{to_param}\"\n else\n \"/projects/#{to_param}/#{action}\"\n end\n end",
"def resources_for http_verb, path\n param_vals = []\n curr_node = @routes_tree[http_verb.to_s.downcase]\n return unless curr_node\n\n path.scan(%r{/([^/]+|$)}) do |(key)|\n next if key.empty?\n\n if curr_node[key]\n curr_node = curr_node[key]\n\n elsif curr_node[\"%s\"]\n param_vals << key\n curr_node = curr_node[\"%s\"]\n\n else\n return\n end\n end\n\n return unless curr_node.value\n rsc = curr_node.value.dup\n\n rsc[-1] = param_vals.empty? ?\n Hash.new :\n rsc[-1].inject({}){|h, name| h[name] = param_vals.shift; h}\n\n rsc\n end",
"def route(controller, action, **args)\n klass = Object.const_get(klass_for(controller)).new(**args)\n klass.send(action)\n end",
"def verb_for_action\n SkinnyControllers.action_map[action_name] || SkinnyControllers.action_map['default']\n end",
"def route() request.route end"
] |
[
"0.65662134",
"0.6253663",
"0.5874944",
"0.5801643",
"0.5786832",
"0.5749082",
"0.5690723",
"0.5687544",
"0.5634518",
"0.5545291",
"0.55431104",
"0.54987216",
"0.54775435",
"0.54440445",
"0.543826",
"0.543826",
"0.54113626",
"0.5399569",
"0.53967315",
"0.53641367",
"0.53518283",
"0.53384566",
"0.53376526",
"0.53376526",
"0.53376526",
"0.53241026",
"0.53133315",
"0.53090703",
"0.5307335",
"0.5271078",
"0.52529305",
"0.52483845",
"0.5205942",
"0.5205942",
"0.5203429",
"0.5199102",
"0.5188849",
"0.5177174",
"0.51726866",
"0.5161418",
"0.512703",
"0.5116917",
"0.51156914",
"0.51109576",
"0.5110774",
"0.51074266",
"0.5105686",
"0.5101923",
"0.5083831",
"0.5077256",
"0.50749993",
"0.507006",
"0.5067673",
"0.50654286",
"0.5065234",
"0.5064357",
"0.50636184",
"0.50554264",
"0.50496477",
"0.5044638",
"0.50333375",
"0.50190055",
"0.5017479",
"0.50146896",
"0.5010357",
"0.5010357",
"0.5010357",
"0.5010357",
"0.5010357",
"0.5010357",
"0.5010357",
"0.5010357",
"0.5010357",
"0.5010357",
"0.5010357",
"0.5007872",
"0.5004352",
"0.49950188",
"0.49873674",
"0.49854326",
"0.4968836",
"0.49545756",
"0.49472004",
"0.4944083",
"0.4944083",
"0.49438208",
"0.49403134",
"0.49382436",
"0.49364415",
"0.4927882",
"0.49255088",
"0.49176428",
"0.49120465",
"0.49063188",
"0.4894131",
"0.4893051",
"0.48889318",
"0.48884994",
"0.48726994",
"0.48667157"
] |
0.76712173
|
0
|
add_product_to_order will call create_new_order by customer_id & add_product_to_order if statement for if order exists
|
def set_field
begin
gets.chomp
rescue SQLite3::Exception => e
p "Exception with set_field: #{e}"
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def add_to_current_order\n\n # get the first open order that the user has\n if current_user.orders.where(status:'Open').first\n current_order = current_user.orders.where(status:'Open').first\n OrderProduct.create({product_id: params[:product],order_id: current_order.id, quantity: params[:order][:orderproduct][:quantity], price: params[:order][:orderproduct][:price],additional_info: params[:order][:orderproduct][:additional_info] })\n\n # If not open and create a new order for the current user\n else\n current_order = current_user.orders.create(order_params)\n current_order.update(status: 'Open')\n OrderProduct.create({product_id: params[:product],order_id: current_order.id, quantity: params[:order][:orderproduct][:quantity], price: params[:order][:orderproduct][:price],additional_info: params[:order][:orderproduct][:additional_info]})\n end\n redirect_to order_path(current_order)\n end",
"def orders_add\n\t\t@product_id = params[:product_id].to_i\n\t\t@quantity = params[:quantity].to_i\n\t\t\n\t\tfound = false\n\t\tsession[:orders].each do |order|\n\t\t\tif (order[\"table\"][\"product_id\"]==@product_id and not found) #session-ized variable uses [table]\n\t\t\t\trespond_to do |format|\n\t\t\t\t\tformat.json { render json: { error: \"Product already ordered. Please check your cart.\"} }\n\t\t\t\tend\n\t\t\t\tfound = true\n\t\t\t\treturn\n\t\t\tend\n\t\tend\n\t\t\n\t\tif (not found)\n\t\t\tif (@quantity>0)\n\t\t\t\tneworder = OpenStruct.new product_id: @product_id, quantity: @quantity\n\t\t\t\tsession[:orders] << neworder\n\t\t\t\t\n\t\t\t\trespond_to do |format| #success\n\t\t\t\t\tformat.json { render json: {} }\n\t\t\t\tend\n\t\t\telse\n\t\t\t\trespond_to do |format|\n\t\t\t\t\tformat.json { render json: { error: \"Invalid quantity to be added to cart.\"} }\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\treturn nil\n\tend",
"def add_product_to_order(product_id)\n begin\n db = SQLite3::Database.open(ENV[\"BANGAZON\"])\n db.execute('INSERT into order_products (product_id, order_id) VALUES (?,?)', [product_id, @id])\n last_row = db.last_insert_row_id\n db.close\n end\n last_row\n end",
"def create\n @customer = CustomerManagement.find(order_params[:customer_id])\n if @customer.cart.address_id\n if @customer.cart_items.length > 0 \n location_same = false\n if @customer.cart.address.city && @customer.cart.address.city.downcase == current_location.downcase\n location_same = true \n end\n \n serve_all = true\n \n if !location_same\n @extra_cart_items = \"\"\n @customer.cart_items.each do |cart_item| \n if !((!cart_item.product_variant.location) || cart_item.product_variant.location == \"\")\n @temp_item = ProductVariant.where(:product_id => cart_item.product_variant.product_id, :location => @customer.cart.address.city, :value => cart_item.product_variant.value).first\n if @temp_item\n cart_item.update_columns(product_id: @temp_item.id, price: (@temp_item.price + (cart_item.include_service ? @temp_item.service_price : 0))) \n else\n @extra_cart_items = @extra_cart_items + \" & \" + cart_item.product.name\n serve_all = false\n end \n end \n end \n end\n \n if location_same || serve_all\n @order = Order.find_or_create_by(:customer_id => order_params[:customer_id],:active => true) \n @customer.cart_items.each do |cart_item| \n @order_to_product = OrderToProduct.where(:product_id => cart_item.product_id, :order_id => @order.id).first_or_create\n @order_to_product.update_price_quantity(cart_item.unit_price, cart_item.quantity,cart_item.include_service)\n cart_item.delete \n end\n @order.save\n @order.update_columns(address_id: @customer.cart.address_id, customer_id: @customer.id, active: true, additional_info: order_params[:additional_info],appointment_time: @customer.cart.appointment_time)\n @customer.cart.delete \n @customer.send_order_confirmation_mail(@order)\n redirect_to action: 'show', id: @order\n else\n redirect_back_or(root_url, notice: @extra_cart_items+\" can not be served at #{@customer.cart.address.city}\")\n end \n else\n redirect_back_or(root_url, notice: 'Empty Cart.')\n end\n else\n redirect_back_or(root_url, notice: 'Kindly select service address')\n end \n end",
"def add_product(params)\n ordered_product = OrderedProduct.find_or_initialize_by(\n self.class.params_object_or_id(:product, params)\n .merge(order: self)\n )\n\n if ordered_product.product.pick_out(params[:amount].to_i)\n ordered_product.update(params)\n update_price\n end\n ordered_product\n end",
"def create\n @order = Order.new(order_params)\n @order.products_inorder << @products\n @order.user = @products.first.user\n\n\n respond_to do |format|\n if @order.save\n format.html { redirect_to_relative_path('inorder') and return }\n format.json { render json: @order, status: :created, location: @order }\n else\n format.html { render template: \"/admin/products/inorder/action\" }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def add_product_to_order\n prod_id = params[:id].to_i\n qty_to_order = params[:qty].to_i\n\n add_or_update_product_qty(prod_id, qty_to_order)\n\n flash[:notice] = 'Product added to cart'\n redirect_back(fallback_location: root_path)\n end",
"def create\n if current_user\n @order = current_user.orders.create(product_id: params[:product_id])\n redirect_to orders_path\n end\n end",
"def createPurchaseOrder(productId, orderAmount)\n created = false\n existingOrder = @purchaseOrders.find {|ord| ord.productId.to_i == productId.to_i}\n if existingOrder == nil\n @purchaseOrders << PurchaseOrder.new(Time.now, productId, orderAmount)\n created = true\n end\n created\n end",
"def create\n @products = Product.all\n order_products = []\n @products.each do |p|\n sym = \"product_#{p.id}\".to_sym\n if params[sym].present?\n count = params[sym].to_i\n if count > 0\n order_product = OrderProduct.new(product: p, count: count)\n order_products << order_product\n end\n end\n end\n\n if order_products.size > 0\n order = Order.new(user: current_user)\n order.save!\n order_products.each do |i|\n i.order = order\n i.save!\n end\n redirect_to order_path(order.id)\n else\n redirect_to new_order_path\n end\n end",
"def create\n @order_product = OrderProduct.new(order_product_params.merge(order_id: @order.id))\n respond_to do |format|\n if @order_product.save\n format.html { redirect_to order_path(@order_product.order), notice: 'product added to order.' }\n format.json { render :show, status: :created, location: @order_product }\n else\n format.html { render :new }\n format.json { render json: @order_product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def add_product\n product = Product.find(params[:product][:id])\n unless @invoice_service.add_product(product)\n redirect_to products_path\n return\n end\n\n redirect_to_origin(params[:origin][:code], product)\n end",
"def create\n @cart = current_cart\n @product = Product.find(params[:product_id])\n @order = Order.add_product(@product, @cart)\n\n respond_to do |format|\n if @order.save\n format.html { redirect_to @order, notice: 'Order was successfully created.' }\n format.json { render action: 'show', status: :created, location: @order }\n else\n format.html { render action: 'new' }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @order = Order.new(order_params)\n @order.user_id = current_user.id if @order.user_id == 0\n @order.price = @order.product.price\n another_order = current_user.orders.in_cart.where(product_id: @order.product_id).first\n logger.debug(\"----------------#{@order.price}..........\")\n if another_order\n another_order.quantity += @order.quantity\n another_order.price += (@order.quantity*@order.price)\n logger.debug(\"----------------#{@order.price}..........\")\n @order = another_order\n end\n respond_to do |format|\n if @order.save\n format.html { redirect_to @order, notice: t('Order was successfully created') }\n format.json { render :show, status: :created, location: @order }\n else\n format.html { render :new }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n # Grabs product_id from hidden form field.\n product_id = params[:product_id].keys[0].to_i\n @order = Order.new(user_id: current_user.id, product_id: product_id, quantity: params[:order][:quantity])\n\n if product_uniqueness(@order)\n if @order.save\n redirect_to root_path\n else\n flash[:danger] = @order.errors.full_messages\n redirect_to \"/products/#{product_id}\"\n end\n else\n flash[:danger] = [\"You already have this item in your cart! Please update the quantity there.\"]\n redirect_to \"/products/#{product_id}\"\n end\n end",
"def add_new_product\n aProduct = Product.new(@product_title, @product_price, @customer_id)\n aProduct.create_new_product\n end",
"def add_package_to_customer_cart\n # get params\n @package_id = params[:id]\n @customer_drink_quantity = params[:quantity].to_i\n \n # get drink info\n if user_signed_in?\n @user = current_user\n else\n # first create an account\n @account = Account.create!(account_type: \"consumer\", number_of_users: 1)\n \n # next create fake user profile\n @fake_user_email = Faker::Internet.unique.email\n @generated_password = Devise.friendly_token.first(8)\n \n # create new user\n @user = User.create(account_id: @account.id, \n email: @fake_user_email, \n password: @generated_password,\n password_confirmation: @generated_password,\n role_id: 4,\n getting_started_step: 0,\n unregistered: true)\n \n if @user.save\n # Sign in the new user by passing validation\n bypass_sign_in(@user)\n #Rails.logger.debug(\"Current user: #{current_user.inspect}\")\n end\n end #end of check whether user is already \"signed in\"\n \n @special_package = SpecialPackage.find_by_id(@package_id)\n \n # find if customer currently has an order in process\n @current_order = OrderPrep.where(account_id: @user.account_id, status: \"order in process\").first\n \n if @current_order.blank? # create a new Order Prep entry\n @current_order = OrderPrep.create!(account_id: @user.account_id, status: \"order in process\")\n end\n \n # now check if this inventory item already exists in the Order Drink Prep table\n @current_drink_order = OrderDrinkPrep.where(user_id: @user.id,\n order_prep_id: @current_order.id,\n special_package_id: @package_id)\n \n if !@current_drink_order.blank? #update entry\n if @customer_drink_quantity != 0\n @current_drink_order.update(quantity: @customer_drink_quantity)\n else\n @current_drink_order[0].destroy!\n end\n else # create a new entry\n OrderDrinkPrep.create!(user_id: @user.id,\n account_id: @user.account_id,\n special_package_id: @package_id,\n order_prep_id: @current_order.id,\n quantity: @customer_drink_quantity,\n drink_price: @special_package.actual_cost)\n end\n\n # find total drink number in cart\n @order_prep_info = OrderDrinkPrep.where(order_prep_id: @current_order.id)\n @customer_number_in_cart = @order_prep_info.sum(:quantity)\n # get total amount in cart so far\n @subtotal = @order_prep_info.sum( \"drink_price*quantity\" ) \n @sales_tax = @subtotal * 0.101\n @total_drink_price = @subtotal + @sales_tax\n\n # if all drinks have been removed, delete the order prep\n if @customer_number_in_cart.to_i == 0\n @current_order.destroy!\n else\n if @current_order.delivery_fee.nil?\n @grand_total = @total_drink_price\n else\n @grand_total = @current_order.delivery_fee + @total_drink_price\n end\n # update Order Prep with cost info\n @current_order.update(subtotal: @subtotal, \n sales_tax: @sales_tax, \n total_drink_price: @total_drink_price,\n grand_total: @grand_total)\n end\n \n # update page\n respond_to do |format|\n format.js\n end # end of redirect to jquery\n \n end",
"def add_product_to_cart(product_id)\n product = look_up_product(reference_number)\n if product != nil\n @shopping_cart << product\n puts \"Yay! Your #{product[:name]} has been added to your cart.\"\n else\n puts \"We don't have that\"\n end\nend",
"def create \n\t\tcarted_products = current _user.\n\t\tcarted_products.where(status: \"carted\")\n\n\t\tcarted_products.each do |carted_products|\n\t\t\tsum += (carted_product.product.product.price\n\t\t\t* carted_product.quantity)\n\t\tend \n\n\t\ttax =subtotal * 0.09\n\t\ttotal = subtotal + tax \n\n\t\torder = Order.create(user_id: current_user_id ,subtotal: subtotal, tax: tax,\n\t\t\ttotal: total)\n\n\t\tcarted_products.update_all (status: \"purchased\",order_id:\"order_id\")\n\n\t\tflash [success:] = \"Order succesfully created\" \n\t\tredirect_to \"/orders/#{order.id}\"\n\tend",
"def create\n @cart = current_cart\n @product = Product.find(params[:id])\n @order_item = @cart.order_items.build\n @order_item.product_id = @product.id\n #@order_item = OrderItem.create!(:cart => current_cart, :product => @product, :qty_ordered => params[:qty_ordered], :qty_ordered_price => @product.price)\n #@order_item = OrderItem.find_or_initialize_by_cart_id(:cart_id => current_cart.id, :cart => current_cart, :product => @product, :qty_ordered => params[:qty_ordered], :qty_ordered_price => @product.price)\n # @order_item = OrderItem.new\n # @order_item.cart_id = current_cart.id\n # @order_item.product_id = @product.id\n @order_item.qty_ordered = params[:qty]\n @order_item.qty_ordered_price = @product.price\n @order_item.save\n flash[:notice] = \"Added #{@product.name} to cart.\"\n redirect_to current_cart_url\n\n # @order = current_order\n # product = Product.find(params[:product_id])\n # # @order_item = OrderItem.new(params[:order_item]) Ian's line\n # @order_item = @order.add_product(product.id)\n \n # if Order.last == nil\n # @order_item.order_id = 1\n # else @order_item.order_id = Order.last.id + 1\n # end\n # @order_item.qty_ordered_price = @order_item.product.price\n\n # respond_to do |format|\n # if @order_item.save\n # format.html { redirect_to @order_item.order, notice: 'Order item was successfully created.' }\n # format.json { render json: @order_item, status: :created, location: @order_item }\n # else\n # format.html { render action: \"new\" }\n # format.json { render json: @order_item.errors, status: :unprocessable_entity }\n # end\n # end\n end",
"def add_product(product)\n\t\titem_to_add = line_items.find_by(product_id: product.id)\n\t\tif item_to_add\n\t\t\titem_to_add.quantity += 1\n\t\telse\n\t\t\t# in this case we create the line_item, the quantity default is 1\n\t\t\titem_to_add = line_items.build(product_id: product.id)\n\t\t\titem_to_add.order = nil\n\t\tend\n\t\titem_to_add\n\tend",
"def prepare_new_order\n @order = Order.new(order_params)\n @order.user_id = current_user.id\n @product = Product.find(params[:orders][:product_id])\n @order.product = @product\n @order.price_cents = @product.price_cents\n end",
"def update\n @order = Order.find(params[:id])\n @order.assign_attributes(params[:order])\n @order.products_inorder << @products\n @order.user = @products.first.user\n \n respond_to do |format|\n if @order.save\n format.html { redirect_to_relative_path('inorder') and return }\n format.json { head :no_content }\n else\n format.html { render template: \"/admin/products/inorder/action\" }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def place_order!()\n if has_order_items?\n order_template = order_object\n order_template = yield order_object if block_given?\n\n @virtual_server.softlayer_client[:Product_Order].placeOrder(order_template)\n end\n end",
"def add_product(product, quantity)\n current_item = OrderItem.find_by(product_id: product.id, order_id: self.id )\n\n if current_item\n current_item.quantity = quantity\n current_item.save\n else\n new_item = OrderItem.new(product_id: product.id, quantity: quantity, order_id: self.id)\n new_item.save\n end\n end",
"def create\n\t\t@customer = current_customer\n @order = Order.new(params[:order].merge!({:customer_id => @customer.id}))\n\t\t@order.add_line_items_from_cart(current_cart)\n\t\n respond_to do |format|\n if @order.save\n\t\t\t\tCart.destroy(session[:cart_id])\n\t\t\t\tsession[:cart_id] = nil\n\t\t\t\tNotifier.order_received(@order).deliver\n format.html { redirect_to(store_url, :notice => I18n.t('.thanks')) }\n format.xml { render :xml => @order, :status => :created, :location => @order }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @order.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def execute\n guest.cart.order_items.create product: product\n end",
"def create\n if current_user\n @carted_products = CartedProduct.where(status: \"Carted\", user_id: current_user.id)\n\n @subtotal = 0\n @tax = 0\n @total = 0\n @carted_products.each do |carted_product|\n @subtotal += carted_product.product.price * carted_product.quantity\n end\n \n @tax = @subtotal * SALES_TAX\n @total = @subtotal + @tax\n\n # quantity = carted_products.quantity\n # price = Product.find_by(id: params[:product_id]).price\n # subtotal = quantity * price\n # tax = subtotal * 0.09\n # total = subtotal + tax\n\n order = Order.create(user_id: current_user.id, subtotal: @subtotal, tax: @tax, total_price: @total) \n\n @carted_products.each do |carted_product|\n carted_product.update(status: \"Purchased\", order_id: order.id)\n end\n\n end\n redirect_to \"/orders/#{order.id}\"\n end",
"def create\n order = Order.find_by(id: session[:order_id])\n \n if session[:order_id].nil? || order.nil?\n order = Order.create\n session[:order_id] = order.id\n end\n \n order_items = {\n product_id: params[:product_id].to_i,\n quantity: params[:quantity].to_i,\n order_id: session[:order_id],\n }\n \n order = Order.find(session[:order_id])\n # if order item already exists in cart, increase quantity.\n order.order_items.each do |oi|\n if oi.product.id == order_items[:product_id]\n if oi.quantity + order_items[:quantity] > oi.product.stock\n flash[:failure] = \"Sorry, there are not enough items in stock.\"\n redirect_to product_path(order_items[:product_id])\n return\n else\n oi.quantity += order_items[:quantity]\n oi.save\n \n flash[:success] = \"Successfully updated quantity.\"\n redirect_to product_path(order_items[:product_id])\n return\n end\n end\n end\n \n order_item = OrderItem.new(order_items)\n if order_item.save\n flash[:success] = \"Successfully added item to your cart.\"\n redirect_to product_path(order_items[:product_id])\n return\n else\n flash[:failure] = \"Item could not be added to your cart.\"\n redirect_to product_path(order_items[:product_id])\n return\n end\nend",
"def add_to_cart\n order = Cart.create(customer_id: @customer.id, hotel_id: params[:cart][:hotel_id], item_id: params[:cart][:item_id],\n item_quantity: params[:cart][:item_quantity], item_name: params[:cart][:item_name], item_price: params[:cart][:item_price], total_price: params[:cart][:total_price] )\n if order\n render json: {\n messages: \"Successfully added to cart!\",\n is_success: true,\n orders: order\n }, status: :created\n else\n render json: {\n messages: \"Unable to add\",\n is_success: false,\n orders: {}\n }, status: :internal_server_error\n end\n end",
"def add_product(product_id)\n \n #Check if the current item is in our current line items\n current_item = line_items.find_by_product_id(product_id)\n if current_item\n #If it is already in our line items, increment the quantity\n current_item.quantity += 1\n else\n #Otherwise, build the relationship\n current_item = line_items.build(product_id: product_id)\n end\n \n #return the current item\n current_item\n end",
"def add_product_to_cart(user, product_or_variant)\n variant = product_or_variant.is_a?(::Spree::Product) ? product_or_variant.master : product_or_variant\n product = product_or_variant.is_a?(::Spree::Product) ? product_or_variant : product_or_variant.product\n if product_or_variant.is_a?(::Spree::Product)\n visit product_path(product)\n # click_button 'Add To Cart' #\n else\n visit variant_path(id: variant.id)\n # TODO: handle selecting variant and Add to Cart\n end\n post populate_orders_path(variant_id: variant.id, quantity: 1)\n\n order = Spree::Order.where(user_id: user.id, state:'cart').last\n expect(order).not_to be_nil\n line_item = order.line_items.where(variant_id: variant.id).last\n expect(line_item).not_to be_nil\n order\nend",
"def create_complete_order(user, product, options={})\n returning(user.orders.create) do |order|\n order.line_items.push create_line_item(product.variants.first)\n order.save\n order.checkout.bill_address = Address.new({\n :firstname => \"First\",\n :lastname => \"Last\",\n :address1 => \"Address1\",\n :city => \"City\",\n :state_name => \"A State\",\n :zipcode => \"00000\",\n :country => Country.new,\n :phone => \"00000000\"\n })\n order.complete\n order.save!\n end\nend",
"def test_create_order\n setup_new_order()\n @o.order_line_items << OrderLineItem.for_product(items(:small_stuff))\n assert @o.save\n end",
"def create\n @order = Order.new(order_params)\n @cart = Cart.find(@order.cart_id)\n\n # @store_products = StoreProduct.all\n # @products = Product.all\n #\n # @store_product = StoreProduct.find(params[:store_product_id])\n # @product = Product.find(params[:product_id])\n #\n # @order.product_id = @product.id\n # @order.store_product_id = @store_product.id\n\n @order.store_product_id = @cart.line_items { |item| item.store_product.store_product_id}\n\n # respond_to do |format|\n if @order.save\n\n session[:cart_id] = nil\n\n # @cart.destroy\n # format.html { redirect_to @order, notice: 'Order was successfully created.' }\n # format.json { render :show, status: :created, location: @order }\n redirect_to '/'\n flash[:notice] = \"Order was successfully created.\"\n\n else\n format.html { render :new }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n # end\n end\n end",
"def create\n @order = Order.new(order_params)\n @total = 0\n current_cart.lineitems.each{|line|\n @total = AddService.call(@total.to_i, line.product.price * line.quantity)\n }\n @order.add_lineitem_from_cart(current_cart)\n @order.customer_id = @current_customer.id\n @order.total = @total\n #Use of logger class to log messages into the log file\n Logger.instance.log(Time.now.to_s + \": Order created by user \\n\")\n\n if @order.save\n Cart.destroy(session[:cart_id])\n session[:cart_id] = nil\n flash[:success] = 'Thank You for your order.'\n redirect_to root_path\n else\n @cart = current_cart\n render 'new'\n end\n end",
"def add_product(product_name, product_cost)\n return successfully_add_product?(product_name, product_cost)\n end",
"def create\n @user = User.find(session[:user_id])\n @order = Order.new(params[:order])\n @order[:User_order] = @user[:id]\n @order.add_line_items_from_cart(current_cart)\n if @order.save\n UserMailer.order_confirmation(@order).deliver\n UserMailer.order_admin(@order).deliver\n render \"_good\"\n end\n end",
"def create\n unless logged_in?\n session[:checking_out] = true\n redirect_to login_path, notice: t('orders.must_log_in') # \"You must log in before placing an order.\"\n else\n @order = current_user.orders.new(order_params)\n @order.earliest_pickup_date = calculate_earliest_pickup_date(:create)\n # User could have place product in cart days ago, make sure still available\n okay = true\n index = (session[:shopping_cart].size - 1)\n while (index >= 0)\n element = session[:shopping_cart][index]\n product = Product.find(element[:product_id])\n quantity = element[:quantity]\n if (product.quantity_in_stock == 0)\n okay = false if (okay)\n session[:shopping_cart].delete_at(index)\n # If cart empty as a result of the deletion, redirect user to product index\n redirect_to(products_path, notice: t('orders.not_in_stock')) and return if session[:shopping_cart].empty? # \"The product(s) ordered are no longer in stock; order cannot be placed.\"\n elsif (product.quantity_in_stock < quantity)\n okay = false if (okay)\n # Update quantity in shopping cart based on quantity available\n new_product_hash = { product_id: product.id, quantity: product.quantity_in_stock }\n session[:shopping_cart][index] = new_product_hash\n end\n index -= 1\n end\n redirect_to(new_order_path, notice: t('orders.please_review')) and return if (!okay) # \"One or more of the products you selected is either out of stock or not available in the desired quantity. Please review the updated order and resubmit if okay.\"\n # Proceed to save order\n respond_to do |format|\n if @order.save\n @order.update_attributes(order_date: Date.today, order_status_id: 1) # set order date to today, status to New\n session[:shopping_cart].each do |element| # create an order_product record for each product in the shopping cart and update quantity in stock of products\n product = Product.find(element[:product_id])\n quantity = element[:quantity]\n @order.order_products.create(product_id: product.id, quantity: quantity)\n new_quantity_in_stock = (product.quantity_in_stock - quantity)\n product.update_attributes(quantity_in_stock: new_quantity_in_stock)\n end\n session[:shopping_cart].clear\n format.html { redirect_to root_path, notice: t('orders.create') } # \"Your order was successfully submitted!\"\n format.json { render action: 'index', status: :created, location: @order }\n else\n format.html { render action: 'new' }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end\n end",
"def add_product(product_id)\n \tcurrent_item = line_items.find_by(product_id: product_id)\n \tif current_item\n \t\tcurrent_item.quantity += 1\n \telse\n \t\tcurrent_item = line_items.build(product_id: product_id)\n current_item.product_price = Product.find(product_id).price\n \tend\n \tcurrent_item\n end",
"def add_product(product)\n current_item = line_items.find_by(product_id: product.id) # find the current item in the line items. find_by() returns an existing LineItem or nil.\n if current_item # if the current item is present...\n current_item.quantity += 1 # ...increment by one.\n else\n current_item = line_items.build(product_id: product.id) # If the item isn't present then build the line_item.\n current_item.price = product.price # Take the current_item and capture the price attribute.\n end\n current_item # Return the current item.\n end",
"def create\n @order = current_order\n # if there already is an order_item with that product_id, then just update the quantity of the order_item\n # if product_in_cart?, redirect to the edit method\n unless product_in_cart?\n @item = @order.order_items.new(item_params)\n @item.save\n @order.save\n session[:order_id] = @order.id\n redirect_to cart_path\n else\n edit\n end\n end",
"def create\n # @order = Order.new() \n total = 0\n \n @order = Order.new()\n for product in params[:_json]\n \n if (product[:quantity].nil? || product[:quantity].to_f < 1 || !isint(product[:quantity]))\n # Handle case when order invalid quantity\n render json: \"\", status: :bad_request\n return\n end\n\n @product = Product.find_by_name_and_size_id(product[:product], product[:size]) \n if @product.nil?\n # Handle case when order invalid products\n render json: \"\", status: :not_found\n return\n end \n total = total + @product.price * product[:quantity].to_f \n @order.orders_products << OrdersProduct.new(:product => @product, :hot => product[:hot], :quantity => product[:quantity]) \n end \n\n @order.total = total\n\n if @order.save\n render json: @order, status: :created, location: @order\n else\n render json: @order.errors, status: :unprocessable_entity\n end\n end",
"def create\n @order = Order.new(order_params)\n @order.buyer = current_user\n @order.product = Product.find(order_params[:product_id])\n # Amount in cents\n @amount = @order.product.price_cents + @order.product.postage_cents\n\n customer = Stripe::Customer.create(\n :email => current_user.email,\n :source => params[:stripeToken]\n )\n\n charge = Stripe::Charge.create(\n :customer => customer.id,\n :amount => @amount,\n :description => @order.product.title,\n :currency => 'aud'\n )\n\n @order.charge_identifier = charge.id\n\n @order.save\n buyer_email = current_user.email\n order_details = {\n title: @order.product.title,\n artist: @order.product.artist,\n total_amount: @amount\n }\n\n OrderMailer.order_confirmation(buyer_email, order_details).deliver_now\n\n redirect_to order_path(@order)\n\n rescue Stripe::CardError => e\n flash[:error] = e.message\n redirect_to new_order_path(product_id: @order.product.id)\n end",
"def complete_customer_order\n \n # call the get_customer_order with product price sum\n customer_order_total = Order.new.get_customer_order(CustomersController.get_active_customer)\n \n if get_customer_order.length == 0\n puts \"You have no products on your order. Please press any key to return to the main menu\"\n \n # if no products in order print \"Please add some products to your order first. Press any key to return to main menu.\"\n else \n # display order total and \"continue with the order? y/n\"\n puts \"Ready to purchase? (Y/N)\"\n @add_payment_to_order = set_field \n \n # add_payment_to_order\n puts \"Please select a payment type:\"\n \n end\n end",
"def create\n #set order and user differs slightly from majority of actions\n @order = Order.new(order_params)\n if @order.save\n @this_user.orders.push(@order)\n redirect_to @this_user, notice: \"Order saved\"\n else\n render action: 'new'\n end\n end",
"def add_product(product_id) #a method that accumulates the quantity of a product that has been added more than twice, using its id\n\t\tcurrent_item = line_items.where(:product_id => product_id).first\n\n\t\tif current_item\n\n\t\t\tcurrent_item.quantity += 1 rescue current_item.quantity\n\t\telse\n\t\t\tcurrent_item = LineItem.new(:product_id=>product_id) #adding a new product to the order line, since its unique to this cart\n\t\t\tline_items << current_item\n\t\tend\n\n\t\tcurrent_item\n\tend",
"def add_product(product_id)\n \t#current_item = line_items.where(product_id: product_id).first\n\n \t# if current_item\n \t# if (current_item.quantity == nil) \n # current_item.quantity = 0\n # end\n # current_item.quantity = 1\n \t# else\n \t# current_item = line_items.build(:product_id => product_id)\n # current_item.quantity += 1\n # end\n #current_item\n line_items.create(:product_id => product_id, :quantity => 1)\n end",
"def add_product(product_name, price)\n if @products.keys.include?(product_name)\n raise ArgumentError,\"The product is already in the order\"\n else\n @products[product_name] = price\n end\n end",
"def create\n @order = Order.new(:customer_id => order_params[:customer_id])\n\n order_params[:line_items].each do |item|\n if !item.empty?\n @order.line_items.new(:product_id => item, :order_id => @order.id)\n @order.update(cost: @order.cost + @order.line_items[0].product.price)\n end\n end\n\n respond_to do |format|\n if @order.save\n format.html { redirect_to @order, notice: 'Order was successfully created.' }\n format.json { render :show, status: :created, location: @order }\n else\n format.html { render :new }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def add_product(product_id)\n current_item = line_item.find_by_product_id(product_id)\n if current_item\n current_item.quantity += 1\n else\n current_item = line_items.build(product_id: product_id)\n end\t\n current_item\nend",
"def add_product(product)\n item = @items.find {|i| i.product_id == product.id}\n if item\n item.quantity += 1\n else\n item = LineItem.for_product(product)\n @items << item\n end\n @total_price += product.price\n end",
"def add_product(product_id)\n \tcurrent_item = line_items.find_by(product_id: product_id)\n if current_item\n current_item.quantity += 1\n else\n current_item = line_items.build(product_id: product_id)\n end\n current_item\n end",
"def add\n add_to_cart_common(:add_product, params[:id])\n end",
"def create\n @season_products = OrderSeasonProduct.where(:order_seasons_id => current_season)\n @products = Product.where(:product_id => @season_products.map(&:products_id)).order(:product_name)\n @order = Order.new(order_params)\n @order.picked_up = false # Set the picked up to false when created\n if @order.save\n flash[:success] = \"#{@order.cust_fname} #{@order.cust_lname}'s order has been added!\"\n redirect_to new_order_path\n else\n render 'new'\n end\n end",
"def add_product(product_id)\n current_item = line_items.where(:product_id => product_id).first\n if current_item\n current_item.quantity += 1\n # Otherwise create a new line_item\n else\n current_item = LineItem.new(:product_id => product_id)\n line_items << current_item # add the current_item to the end of the line_items\n end\n current_item\n end",
"def add_product(name, price)\n new_product = Product.new(name, price)\n @products_in_cart << new_product\n new_product\nend",
"def create\n @order = Order.new(order_params)\n @cart.line_items.each do |i|\n qty = i.quantity\n product = Product.find(i.product_id)\n product.quantity_update(product, qty)\n end\n @order.add_line_items_from_cart(@cart)\n if user_signed_in?\n @order.user_id = current_user.id\n end\n \n respond_to do |format|\n \n # Dynamically update Products quantity (same as in ProdController)\n # dynamically_update_products\n \n if @order.save && @order.pay_type == \"Karta kredytowa\"\n format.html { redirect_to new_charge_url }\n format.json { render :show, status: :created, location: @order }\n elsif @order.save && @order.pay_type != \"Karta kredytowa\"\n Cart.destroy(session[:cart_id])\n session[:cart_id] = nil\n OrderMailer.received(@order).deliver_later\n format.html { redirect_to store_index_url,\n notice: 'Zamówienie zostało złożone.' }\n format.json { render :show, status: :created, location: @order }\n else\n format.html { render :new }\n format.json { render json: @order.line_items.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n candidateOrder = Order.new(email: params[:order][:Email],\n totalCost: cart_total,\n user: curr_user)\n cart.each do |pId, info|\n if (prod = Product.find_by(id: pId))\n if prod.stockCount > info[\"Num\"].to_i\n candidateOrder.order_entries.new(\n product: prod,\n quantity: info[\"Num\"].to_i,\n unitprice: prod.price,\n totalprice: prod.price * info[\"Num\"].to_i,\n order_id: candidateOrder.id\n )\n candidateOrder.order_entries.last.validate!\n if candidateOrder.valid?\n prod.stockCount -= info[\"Num\"].to_i\n Product.update(prod.id, stockCount: prod.stockCount)\n end\n end\n end\n end\n if candidateOrder.save!\n clear_cart\n redirect_to order_path(candidateOrder), notice: t(:order_placed)\n else\n redirect_to carts_path, error: t(:order_failed)\n end\n end",
"def set_order\n @order = Order.find(params[:id])\n @order_product = OrderProduct.where(order_id: params[:id]).first\n if @order_product\n @product = Product.where(id: @order_product.product_id).first\n end\n end",
"def create\n cart = Cart.find_by(user_id: @current_user.id)\n order = Order.new(user_id: @current_user.id,\n date: DateTime.now,\n delivery_address: @current_user.role == \"user\" ? @current_user.addresses.find_by(delivery_address: true).address : \"Walk-in-customer\",\n is_cancel: false,\n total_amount: cart.cart_items.sum(:temp_price))\n if (order.save!)\n cart.cart_items.all.each do |cart_item|\n OrderItem.create!(\n order_id: order.id,\n menu_item_id: cart_item.menu_item_id,\n menu_item_name: cart_item.menu_item_name,\n menu_item_price: cart_item.menu_item_price,\n quantity: cart_item.quantity,\n )\n end\n cart.cart_items.destroy_all\n end\n redirect_to customer_order_details_path(order.id)\n end",
"def create\n @order = Order.new(tl_params)\n\n if @order.save\n if params[:product]\n \t@order.create_order(params[:product])\n end\n render json: @order, status: :created\n else\n render json: @order.errors, status: :unprocessable_entity\n end\n end",
"def add_product(product_id) #why methid in model? not in controller?\n\t\tcurrent_item = line_items.find_by(product_id: product_id) #find_by returns one object, where return array\n\t\tif current_item\n\t\t\tcurrent_item.quantity += 1\n\t\telse\n\t\t\tcurrent_item = line_items.build(product_id: product_id) #you could build it from \"cart\" side as well\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t#rails establishes connections for you\n\t\tend\n\n\t\tcurrent_item\n\tend",
"def create\n @order = Order.new(params[:order])\n @order.user_id = current_user.id\n @order.add_line_items_from_cart(current_cart)\n #logger.debug \"New order: #{@order.attributes.inspect}\"\n #logger.debug \"Order should be valid: #{@order.valid?}\"\n\n respond_to do |format|\n if @order.save\n Cart.destroy(session[:cart_id])\n session[:cart_id] = nil\n format.html { redirect_to(store_url, :notice =>\n 'Thank you for your order.') }\n format.xml { render :xml => @order, :status => :created,\n :location => @order }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @order.errors,\n :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @order = current_user.orders.new(params[:order])\n @order.add_line_items_from_cart(current_cart)\n respond_to do |format|\n if @order.save\n Cart.destroy(session[:cart_id])\n session[:cart_id] = nil\n format.html { redirect_to(\"http://cs410.cs.ualberta.ca:42001/paybuddy/payment.cgi?grp=5&amt=#{@order.total_price}&tx=#{@order.id}&ret=#{paid_url}\") }\n format.json { render json: @order, status: :created, location: @order }\n else\n @cart = current_cart\n format.html { render action: \"new\" }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def add_stock_to_customer_cart\n # get params\n @customer_projected_rating_id = params[:id]\n @customer_drink_quantity = params[:quantity].to_i\n \n # get drink info\n if user_signed_in?\n @user = current_user\n @user_projected_ratings = ProjectedRating.where(user_id: current_user.id)\n else\n # first create an account\n @account = Account.create!(account_type: \"consumer\", number_of_users: 1)\n \n # next create fake user profile\n @fake_user_email = Faker::Internet.unique.email\n @generated_password = Devise.friendly_token.first(8)\n \n # create new user\n @user = User.create(account_id: @account.id, \n email: @fake_user_email, \n password: @generated_password,\n password_confirmation: @generated_password,\n role_id: 4,\n getting_started_step: 0,\n unregistered: true)\n \n if @user.save\n # Sign in the new user by passing validation\n bypass_sign_in(@user)\n #Rails.logger.debug(\"Current user: #{current_user.inspect}\")\n end\n end #end of check whether user is already \"signed in\"\n \n if !@user_projected_ratings.blank?\n @this_projected_rating = ProjectedRating.find_by_id(@customer_projected_rating_id)\n @inventory = Inventory.find_by_id(@this_projected_rating.inventory_id)\n @inventory_id = @inventory.id\n else\n @inventory = Inventory.find_by_id(@customer_projected_rating_id)\n @inventory_id = @inventory.id\n end\n \n # find if customer currently has an order in process\n @current_order = OrderPrep.where(account_id: @user.account_id, status: \"order in process\").first\n \n if @current_order.blank? # create a new Order Prep entry\n @current_order = OrderPrep.create!(account_id: @user.account_id, status: \"order in process\")\n end\n \n # now check if this inventory item already exists in the Order Drink Prep table\n @current_drink_order = OrderDrinkPrep.where(user_id: @user.id,\n order_prep_id: @current_order.id,\n inventory_id: @inventory_id)\n \n if !@current_drink_order.blank? #update entry\n if @customer_drink_quantity != 0\n @current_drink_order.update(quantity: @customer_drink_quantity)\n else\n @current_drink_order[0].destroy!\n end\n else # create a new entry\n OrderDrinkPrep.create!(user_id: @user.id,\n account_id: @user.account_id,\n inventory_id: @inventory.id,\n order_prep_id: @current_order.id,\n quantity: @customer_drink_quantity,\n drink_price: @inventory.drink_price_four_five)\n end\n\n # find total drink number in cart\n @order_prep_info = OrderDrinkPrep.where(order_prep_id: @current_order.id)\n @customer_number_in_cart = @order_prep_info.sum(:quantity)\n # get total amount in cart so far\n @subtotal = @order_prep_info.sum( \"drink_price*quantity\" ) \n @sales_tax = @subtotal * 0.101\n @total_drink_price = @subtotal + @sales_tax\n\n # if all drinks have been removed, delete the order prep\n if @customer_number_in_cart.to_i == 0\n @current_order.destroy!\n else\n if @current_order.delivery_fee.nil?\n @grand_total = @total_drink_price\n else\n @grand_total = @current_order.delivery_fee + @total_drink_price\n end\n # update Order Prep with cost info\n @current_order.update(subtotal: @subtotal, \n sales_tax: @sales_tax, \n total_drink_price: @total_drink_price,\n grand_total: @grand_total)\n end\n \n # update page\n respond_to do |format|\n format.js\n end # end of redirect to jquery\n \n end",
"def add_product(product)\n current_item = line_items.where(:product_id => product.id).first\n if current_item\n current_item.quantity += 1\n else\n current_item = LineItem.new(:product_id => product_id)\n line_items << current_item\n end\n current_item\n end",
"def create\n product = Product.find_by(id: params[:order_item][:product_id])\n if params[:order_item][:qty].to_i > product.inv_qty\n flash[:warning] = \"Quantity selected exceeds amount availabe in inventory\"\n redirect_to product_path(product.id)\n elsif @current_order.nil?\n @current_order = Order.new\n @current_order.save\n end\n\n @order_item = @current_order.order_items.new(order_item_params)\n @order_item.save\n @current_order.save\n @current_order.update(status: \"Pending\")\n session[:order_id] = @current_order.id\n redirect_to cart_path(@current_order.id)\n # else\n # flash[:warning] = \"Item order not placed\"\n # redirect_to root_path\n # # end\n end",
"def add_product(product_id)\n\t\tcurrent_item = line_items.find_by_product_id(product_id)\n\t\tif current_item\n\t\t\tcurrent_item.quantity += 1\n\t\telse\n\t\t\tcurrent_item = line_items.build(:product_id => product_id)\n\t\tend\n\t\tcurrent_item\n\tend",
"def add_product (product_id)\n current_item = line_items.find_by_product_id(product_id)\n if current_item\n current_item.quantity += 1\n else\n # The default quantity is 1. \n current_item = line_items.build(product_id: product_id)\n end\n current_item\n end",
"def add_purchase(customer_id, product_id)\n item = DirectedEdge::Item.new(@database, \"customer#{customer_id}\")\n item.link_to(\"product#{product_id}\")\n item.save\n end",
"def set_orderproduct\n orders =Order.find(params[:order_id])\n @orderproduct = orders.orderproducts.find(params[:id])\n end",
"def product(text)\n ProcessOrders.instance.add_product text\nend",
"def add_item(product_id:, quantity: 1)\n product = Product.find(product_id)\n\n order_item = order.items.find_or_create_by(\n product_id: product_id\n )\n\n order_item.price = product.price\n order_item.quantity = 1\n order_item.save\n end",
"def add_item(product_id:, quantity: 1)\n product = Product.find(product_id)\n order_item = order.items.find_or_initialize_by(\n product_id: product_id,\n price: product.price,\n quantity: quantity\n )\n\n order_item.save!\n end",
"def insert_order\n order = Order.for_remote_insert(params[:customer_id], params[:order_id], params[:lid], request.remote_ip)\n payment = Payment.new(:order => order, :customer => order.customer, :payment_method => 'Customer Service',\n :amount => '0.0', :complete => 1, :successful => 1)\n Order.transaction do\n order.save!\n payment.save!\n end\n render :text => '1'\n rescue => e\n render :text => e.to_s\n end",
"def add_product(product_id)\n\t\tcurrent_item = line_items.find_by(product_id: product_id)\n\t\tif current_item\n\t\t\tcurrent_item.quantity += 1\n\t\telse\n\t\t\tcurrent_item = line_items.build(product_id: product_id)\n\t\tend\n\t\tcurrent_item\n\tend",
"def add_to_customer(name)\n if !@@customers.to_s.include?(self.name)\n @@customers << self #add this new instance of Product to the array of ALL instances\n else\n puts \"#{@name} already exists\"\n raise DuplicateCustomertError, \"'#{@name}' already exists.\"\n end\n end",
"def create\n @customer = current_user.customers.build(params[:customer])\n\n respond_to do |format|\n if @customer.save \n @customer.orders.create(:user_id => @customer.user.id, \n :total => params[:total], :name => @customer.name, :phone => @customer.phone,\n :address => @customer.address, :instruction => params[:instruction]) if params[:order] == 'true'\n format.html { redirect_to(@customer, :notice => 'Customer was successfully created.') }\n format.xml { render :xml => @customer, :status => :created, :location => @customer }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @customer.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def order3\n puts(\"\\n\\n- - - - - - - - - - - - - - - -\\n[SHOP] Executing order 3: ABCD should be $7.25\\n\\n\") \n @shop.reset_order\n @shop.add_product_to_order_by_name('A')\n @shop.add_product_to_order_by_name('B')\n @shop.add_product_to_order_by_name('C')\n @shop.add_product_to_order_by_name('D')\nend",
"def create\n # creates a new order which belongs to the current customer and contains fields which have values equal to\n # parameters accessed from the order_params hash\n @order = current_customer.orders.new(order_params)\n # sets the total_cost of the order to 0\n @order.total_cost = 0\n # calculates the total_cost of the order by calculating the sum of the cost of the line_items which the\n # basket that the current customer owns contains\n current_customer.basket.line_items.each do |item|\n # the total_cost of the order must be increased by the price of the game which the line_item belongs to\n @order.total_cost += item.game.price\n # the order_id of the line_item is equal to the id of the order which is currently being created\n item.order_id = Order.last.id + 1\n # the basket_id of the line_item is set to nil because the line_item is removed from the basket which\n # belongs to the current customer and is added to the order\n item.basket_id = nil\n # the total cost of the basket which the current customer owns is decreased by the price of the game which\n # the line_item belongs to\n current_customer.basket.total_cost -= item.game.price\n # if a game has been released, the delivery_date of the line_item is the next day\n # if a game has not been released, the delivery_date of the line_item is the release_date of the game\n # which the line_item belongs to\n if item.game.release_date <= Date.today\n # the delivery_date of the line_item is the next day\n item.delivery_date = Date.today + 1\n else\n # the delivery_date of the line_item is the release_date of the game which the line_item belongs to\n item.delivery_date = item.game.release_date\n end\n end\n\n respond_to do |format|\n # attempts to save the order\n if @order.save\n # if the order has successfully been saved, each line_item in the basket which the current customer\n # owns is saved because the value of the fields which the line_items contain is updated\n LineItem.transaction do\n current_customer.basket.line_items.each(&:save!)\n end\n # if the order has successfully been saved, the basket which the current customer owns is saved\n # because the total_cost of the basket is updated\n current_customer.basket.save\n # if the order has successfully been saved, the current customer should be redirected to the page which\n # shows the order that the current_customer has made.\n # shows a notice to the customer that the order has successfully been created\n format.html { redirect_to @order, notice: t('.notice') }\n format.json { render :show, status: :created, location: @order }\n else\n # if the order has not successfully been saved, the current customer should not be redirected to another\n # page and should be shown the errors which prevented the order from being saved\n format.html { render :new }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def process_order(order)\n data = order.strip.split(' ')\n return unless (data.size == 2)\n name = data.first.downcase\n return if @products_type[name].nil?\n quantity = is_numerical(data.last)\n return unless quantity && quantity > 0\n if @items_type[name].nil?\n @items_type[name] = Creator.createLineItem(@products_type[name],quantity)\n @line_items << @items_type[name]\n else\n @items_type[name].update_quantity(quantity)\n end\n end",
"def add_product(product)\n current_item = line_items.find_by(product_id: product.id)\n if current_item\n current_item.quantity += 1\n else\n current_item = line_items.build(product_id: product.id)\n end\n current_item\n end",
"def order1 \n puts(\"\\n\\n- - - - - - - - - - - - - - - -\\n[SHOP] Executing order 1: ABCDABA should be $13.25\\n\\n\") \n @shop.reset_order\n @shop.add_product_to_order_by_name('A')\n @shop.add_product_to_order_by_name('B')\n @shop.add_product_to_order_by_name('C')\n @shop.add_product_to_order_by_name('D')\n @shop.add_product_to_order_by_name('A')\n @shop.add_product_to_order_by_name('B')\n @shop.add_product_to_order_by_name('A')\nend",
"def create\n if current_user.current_order\n @order = current_user.current_order\n else\n last_order = Order.last\n order_no = \"\"\n if last_order\n order_no = last_order.order_no\n order_no = \"A#{\"#{(order_no[/\\d+/].to_i + 1)}\".rjust(5,'0')}\"\n else\n order_no = \"A#{\"1\".rjust(5,'0')}\"\n end\n\n @order = current_user.orders.build(order_no: order_no, date: Time.now, closed: false)\n end\n product = Product.where(id: order_line_params[:product_id]).first\n merged = order_line_params.merge({:unit_price => product.price, :total_price => product.price * order_line_params[:qty].to_i})\n @order.order_lines.build(merged)\n\n respond_to do |format|\n if @order.save\n format.html { redirect_to products_path, notice: 'Order line was successfully created.' }\n else\n format.html { render :new }\n end\n end\n end",
"def add_product(product)\n current_item = line_items.find_by(product_id: product.id)\n if current_item\n current_item.quantity += 1\n else\n current_item = line_items.build(product_id: product.id)\n end\n current_item\n end",
"def create\n @order = current_order(create_order_if_necessary: true)\n authorize! :update, @order, cookies.signed[:guest_token]\n product = ::Spree::Product.find(params[:product_id])\n option_values_ids = params[:options].present? ? params[:options].values : []\n option_values = ::Spree::OptionValue.where(id: option_values_ids)\n variant = product.try_variant option_values\n quantity = params[:quantity].present? ? params[:quantity].to_i : 1\n\n # 2,147,483,647 is crazy. See issue https://github.com/spree/spree/issues/2695.\n if !quantity.between?(1, 2_147_483_647)\n @order.errors.add(:base, t('spree.please_enter_reasonable_quantity'))\n else\n begin\n @line_item = @order.contents.add(variant, quantity)\n rescue ActiveRecord::RecordInvalid => error\n @order.errors.add(:base, error.record.errors.full_messages.join(\", \"))\n end\n end\n\n respond_with(@order) do |format|\n format.html do\n if @order.errors.any?\n flash[:error] = @order.errors.full_messages.join(\", \")\n redirect_back_or_default(root_path)\n return\n else\n redirect_to edit_cart_path\n end\n end\n end\n end",
"def add_product(product)\n products << product\n # save\n end",
"def add_product(product)\n\t\tcurrent_item = line_items.find_by(product_id: product.id)\n\t\tif current_item\n\t\t\tcurrent_item.quantity += 1\n\t\telse\n\t\t\tcurrent_item = line_items.build(product_id: product.id)\n\t\tend\n\t\tcurrent_item\n\tend",
"def create\n @order = Order.new(params[:order])\n\n respond_to do |format|\n if @order.save\n format.html { redirect_to(@order, :notice => 'Order was successfully created.') }\n format.xml { render :xml => @order, :status => :created, :location => @order }\n else\n if @order.ordered_products.empty?\n 8.times { @order.ordered_products.build }\n else\n no_times = 8 - @order.ordered_products.size\n no_times.times { @order.ordered_products.build }\n end\n format.html { render :action => \"new\" }\n format.xml { render :xml => @order.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @order = Order.new(order_params)\n @order[:user_id] = current_user.id\n @order.price = params['price']\n a = params[\"product_id\"].split(' ')\n b = a.each_slice(2).to_a\n @order.product_id = b\n @order.save\n respond_to do |format|\n if @order.save\n format.html { redirect_to '/payment/'+@order.id.to_s}\n format.json { render :show, status: :created, location: @order }\n else\n format.html { render :new }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n product = Product.find(params[:product_id])\n qty=params[:quantity].to_i \n @ordered_product = @cart.add_product(product.id,qty)\n @ordered_product.save\n respond_to do |format|\n format.html { redirect_to store_index_url, notice: 'Order placed successfully' }\n format.json { head :no_content }\n end\n end",
"def add_product(product)\n # @type [LineItem, NilClass]\n item = line_items.find_by(product: product)\n if item.present?\n item.quantity += 1\n else\n item = line_items.build(product: product)\n end\n\n item\n end",
"def create\n @order = current_user.orders.build(order_params)\n\n respond_to do |format|\n if @order.save_with_items(current_user)\n format.json { render json: @order, status: :created }\n format.html { redirect_to @order }\n else\n format.html do\n set_feed_back\n set_addresses_add_express_fee\n\n set_wx_cards\n\n flash.now[:error] = @order.errors.full_messages.join(', ')\n\n render :confirmation, status: :unprocessable_entity\n end\n\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_order(order)\n # response = post(\n # 'peatio/market/orders',\n # {\n # market: order.market.downcase,\n # side: order.side.to_s,\n # volume: order.amount,\n # price: order.price\n # }\n # )\n\n return if order.amount < 1e-8\n od = build_order(order)\n return if od.nil?\n\n# Arke::Log.debug \"Skip order creation #{od.to_json}\\n#{order.inspect}\"\n Ordering.new(od).submit\n @open_orders.add_order(order, od.id) if od.id\n Arke::Log.debug \"Order created #{od.to_json}\"\n\n # @open_orders.add_order(order, response.env.body['id']) if response.env.status == 201 && response.env.body['id']\n\n # response\n end",
"def order2\n puts(\"\\n\\n- - - - - - - - - - - - - - - -\\n[SHOP] Executing order 2: CCCCCCC should be $6.00\\n\\n\") \n @shop.reset_order\n 7.times { @shop.add_product_to_order_by_name('C') }\nend",
"def create\n @order = Order.new(order_params)\n @order.add_line_items_from_cart(current_cart)\n @order.user_id = session[:user_id]\n\n respond_to do |format|\n if @order.save\n destroy_cart\n OrderNotifier.received(@order).deliver\n format.html { redirect_to store_url, notice: I18n.t('.thanks') }\n format.json { render action: @order, status: :created, location: @order }\n else\n @cart = current_cart\n format.html { render action: 'new' }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_product_order\n @product_order = ProductOrder.find(params[:id])\n end",
"def set_product_order\n @product_order = ProductOrder.find(params[:id])\n end",
"def collect_order(shop_id, order)\n request(:post, \"shops/#{shop_id}/orders\", body: order).tap do |response|\n raise InvalidResponse, response.body unless response.status == 201\n end\n end",
"def process_order!(options)\n options['product'].create_eventbooking(options['model'])\n end"
] |
[
"0.7470572",
"0.73386693",
"0.714265",
"0.7056163",
"0.70298576",
"0.7024725",
"0.6956932",
"0.68955153",
"0.6814597",
"0.6795522",
"0.67782307",
"0.6738268",
"0.6735118",
"0.6676987",
"0.66629946",
"0.6601308",
"0.658048",
"0.6579002",
"0.6565726",
"0.65618026",
"0.65595996",
"0.6494751",
"0.6487281",
"0.6481795",
"0.6474583",
"0.6473961",
"0.64705104",
"0.6470377",
"0.6464053",
"0.64602023",
"0.64291656",
"0.6417579",
"0.6416624",
"0.6410295",
"0.6402305",
"0.6388279",
"0.6383994",
"0.6376511",
"0.6375868",
"0.6374375",
"0.63738877",
"0.6368543",
"0.63684666",
"0.63678336",
"0.63567287",
"0.6352366",
"0.6347677",
"0.63437724",
"0.6336946",
"0.63369226",
"0.6327737",
"0.63255864",
"0.6322685",
"0.6322388",
"0.63135767",
"0.631151",
"0.6295999",
"0.6289196",
"0.62864643",
"0.6278072",
"0.62730896",
"0.6272347",
"0.62682766",
"0.62600887",
"0.62595636",
"0.6250517",
"0.62489915",
"0.6248391",
"0.6247444",
"0.62470317",
"0.62441653",
"0.62423784",
"0.6241761",
"0.6241051",
"0.6237574",
"0.62333065",
"0.623192",
"0.6229578",
"0.62295735",
"0.62288153",
"0.6220796",
"0.6218973",
"0.6216862",
"0.6207668",
"0.6204166",
"0.6201227",
"0.6193908",
"0.6191645",
"0.6191517",
"0.61849546",
"0.6183676",
"0.61820775",
"0.61785436",
"0.6171323",
"0.61667377",
"0.61627764",
"0.615659",
"0.6150905",
"0.6150905",
"0.6133654",
"0.6132372"
] |
0.0
|
-1
|
complete order would there be an order with no products???????
|
def complete_customer_order
# call the get_customer_order with product price sum
customer_order_total = Order.new.get_customer_order(CustomersController.get_active_customer)
if get_customer_order.length == 0
puts "You have no products on your order. Please press any key to return to the main menu"
# if no products in order print "Please add some products to your order first. Press any key to return to main menu."
else
# display order total and "continue with the order? y/n"
puts "Ready to purchase? (Y/N)"
@add_payment_to_order = set_field
# add_payment_to_order
puts "Please select a payment type:"
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def empty?\n order_items.empty?\n end",
"def empty?\n order_items.empty?\n end",
"def incomplete_products\n return self.products.select do |product|\n !product.passing? && !product.failing?\n end\n end",
"def test_empty\n order = orders(:santa_next_christmas_order)\n assert !order.empty?\n assert order.order_line_items.size > 0\n order.empty!\n assert order.empty?\n assert_equal order.order_line_items.size, 0\n end",
"def pending_purchase_order\n @pending_purchase_order_cache || @pending_purchase_order_cache = if self.purchase_orders\n self.purchase_orders.select(&:pending?).last unless self.purchase_orders.empty?\n end\n end",
"def void_pending_purchase_orders\n self.purchase_orders.select(&:pending?).each {|o| o.void}\n end",
"def orders?\n return orders.any?\n end",
"def empty?\n\t\t\t@ordered.empty?\n\t\tend",
"def is_empty?\n if self.order_details.any? == false\n errors.add(:base,\"order shold have minimum one menu item\")\n end\n end",
"def unappliable_order?\n order.bought? == false\n end",
"def order?\n !order.nil?\n end",
"def complete_orders\n @orders = search_reasult(params).where(\"fulflmnt_state = 'complete'\").order('order_date desc')\n @orders = Kaminari.paginate_array(@orders).page(params[:page]).per(params[:per_page] || Spree::Config[:orders_per_page])\n end",
"def products?\n !products.empty?\n end",
"def test_remove_product\n o = Order.new\n o.expects(:cleanup_promotion).times(4)\n o.add_product(items(:red_lightsaber), 2)\n o.add_product(items(:blue_lightsaber), 2)\n assert_equal o.items.length, 2\n\n # When not specified a quantity all units from the product will be removed.\n o.remove_product(items(:blue_lightsaber))\n assert_equal o.items.length, 1\n\n # When specified a quantity, just these units from the product will be removed.\n o.remove_product(items(:red_lightsaber), 1)\n assert_equal o.items.length, 1\n\n # It should not be empty.\n assert !o.empty?\n\n # Now it should be empty.\n o.remove_product(items(:red_lightsaber), 1)\n assert o.empty?\n end",
"def available_for_order?(_order)\n true\n end",
"def test_when_created_be_empty\n a_cart = Order.new\n \n assert_equal a_cart.items.size, 0\n assert_equal a_cart.tax, 0.0\n assert_equal a_cart.total, 0.0\n assert_equal a_cart.shipping_cost, 0.0\n end",
"def products_not_used\n @products_not_used ||= object\n .products\n .select { |p| p.inventory_id == current_inventory.id && !p.used? }\n end",
"def current_order\n current_customer.incomplete_order\n end",
"def ensure_not_referenced\n if order_items.empty?\n true\n else\n errors.add(:base, 'Line Order present')\n false\n end\n end",
"def no_quantity_type(product)\n\t\treturn (product.um == product.qum)\n\tend",
"def unfulfilled_line_items\n return self.order_line_items.where('status != ?', 'shipped').all\n end",
"def bought_products\n order_details.sum(:quantity)\n end",
"def complete?()\n if (self.order_in_lines.length == 0)\n return false\n end\n self.order_in_lines.each do | line |\n if (line.qty < line.qty_in)\n return false\n end\n end\n return true\n end",
"def complete\n return false if completed || self.empty?\n\n cart_items.collect do |item|\n return false if !item.can_purchase?\n end\n\n cart_items.collect do |item|\n item.purchase\n end\n\n self.update_columns(completed: true)\n true\n end",
"def no_satisfy\n\t @orders.count {|order| order.issue_date.nil?}\n\t end",
"def check_unattended_orders\n if session.delete(:just_logined) == true && @current_user\n if @current_user.is_merchant\n @unattended_orders = @current_user.products.collect(&:orders).first.\n where(\"(status is null OR status = 1) AND orders.created_at >= ?\", @current_user.last_signed_out_at)\n end\n end\n end",
"def empty?\n basket_items.none?\n end",
"def complete_order\n # checks to see if there's an active order, and creates one if not\n @order_status = check_active_order\n # puts \"order status in close_order: #{@order_status}\"\n # retrieves grand total for the active order, if any\n the_total = get_grand_total\n # puts \"the_total: #{the_total}\"\n\n # checks to see if the total is a number or is nil/zero\n if the_total\n if the_total == 0\n # if the total is 0, it requests that the user add items to the cart\n puts \" \"\n puts \"Please add some items to your shopping cart. Press any key to return to main menu.\"\n puts \" \"\n gets.chomp\n else\n # if the total is a number, it asks user if they want to purchase\n puts \" \"\n puts \"Your order total is: $#{the_total}. Ready to purchase? (y/n)\"\n confirm_user_input = gets.chomp\n if confirm_user_input.downcase.to_s == \"y\"\n # if the user wants to check out, it triggers the apply payment method function\n apply_payment_method\n else\n puts \" \"\n puts \"Press any key to return to main menu.\"\n puts \" \"\n gets.chomp\n end\n end\n else\n # if the total is nil, it requests that the user add items to the cart\n puts \" \"\n puts \"Please add some items to your shopping cart. Press any key to return to main menu.\"\n puts \" \"\n gets.chomp\n end\n\n end",
"def auto_dispute_order_details\n nil\n end",
"def create\n @order = Order.new(params[:order])\n\n if @order.save\n\n\n orders = Order.by_manufacture_state(\"0\", @order.product_id)\n\n sum_meterial_manufacutured = @order.product.manufactures.sum(:quantity)\n orders.each do |order|\n\n break if order.quantity > (sum_meterial_manufacutured - Order.by_manufacture_state(\"1\", order.product.id).sum(:quantity))\n\n order.manufacture_flag = 1\n order.processing\n order.save\n\n end\n\n flash.notice = t('order.save')\n redirect_to orders_path\n else\n render :action => \"new\"\n end\n\n end",
"def tested_products\n return self.products.select do |product|\n product.incomplete_tests.count == 0\n end\n end",
"def first_order?\n orders_count <= 1\n end",
"def checkout_allowed?\n order_items.count > 0\n end",
"def order_complete\n load_order\n if @order.state == 'canceled'\n flash[\"notice\"] = 'This order has been canceled - do not process it!'\n elsif @order.packed_at.blank? && (@current_retailer && @current_retailer.id == @order.retailer_id)\n @order.update_attribute(:packed_at, Time.now)\n end\n redirect_to admin_order_url(@order)\n end",
"def checkout \n \t@order_items = current_order.order_items\n end",
"def ensure_not_referenced_by_any_ordered_item\n if ordered_items.empty?\n return true\n else\n errors.add(:base, \"Ordered items present.\")\n return false\n end\n end",
"def e_validate_related_orders\n errors.add(:base, I18n.t('plugins.ecommerce.message.not_deletable_product')) if Plugins::Ecommerce::ProductItem.where(product_id: id).any?\n end",
"def get_unshipped_orders\n @orders = Order.by_state('paid').find(:all, :conditions => ['downloaded_at IS NULL'], :include => [:line_items])\n \n respond_to do |format| \n #format.html\n format.xml\n end\n \n end",
"def check_if_processed\n if self.active == true\n # If you just got rid of your old order, grab a new one\n Order.create(user_id: self.user_id)\n end\n end",
"def complete_order\n @tire_listing = TireListing.find(params[:tire_listing_id])\n\n if !@tire_listing.can_do_ecomm?\n redirect_to @tire_listing, notice: \"Those tires are not eligible for online purchase.\"\n end\n\n @ar_months = Date::MONTHNAMES.each_with_index.collect{|m, i| [m, i.to_s.rjust(2, '0')]}\n @ar_years = [*Date.today.year..Date.today.year + 8]\n\n @qty = params[:qty].to_i\n @order = Order.new(:tire_listing_id => @tire_listing.id, :tire_quantity => @qty)\n @order.status = order_status_array[:created]\n @order.calculate_total_order\n @order.buyer_email = @order.buyer_name = @order.buyer_address1 = @order.buyer_city = @order.buyer_state = @order.buyer_zip = \"unknown\" # to prevent null error\n initialize_order\n @order.save\n end",
"def order_complete\n load_order\n if @order.state == 'canceled' \n flash[\"notice\"] = 'This order has been canceled - do not process it!'\n elsif @order.packed_at.blank? && (@current_retailer && @current_retailer.id == @order.retailer_id)\n \t@order.update_attribute(:packed_at, Time.now)\n end\n redirect_to admin_order_url(@order)\n end",
"def confirm_products_order\n unless @current_admin.is_super_admin\n unless @current_admin.privilages.include? '3'\n flash[:error]=\"You are not authorized to navigate to this page \"\n redirect_to admin_index_path\n return\n end\n end\n @users_sales=Array.new\n @customers_sales=Array.new\n @sales=Sale.where(\"is_delivered='f'\")\n\n @sales.each do |sale|\n if sale.customer\n @customers_sales.push(sale)\n else\n @users_sales.push(sale)\n end\n end\n puts \"user sale count:#{@users_sales.length}\"\n puts \"customer sale count:#{@customers_sales.length}\"\n end",
"def require_quantities\n \tunless self.dishes.count > 0\n \t\terrors.add(:order, \"must have dishes\")\n \tend\n end",
"def on_order?\n !self.paid?\n end",
"def create\n @order = Order.new(params[:order])\n\n respond_to do |format|\n if @order.save\n format.html { redirect_to(@order, :notice => 'Order was successfully created.') }\n format.xml { render :xml => @order, :status => :created, :location => @order }\n else\n if @order.ordered_products.empty?\n 8.times { @order.ordered_products.build }\n else\n no_times = 8 - @order.ordered_products.size\n no_times.times { @order.ordered_products.build }\n end\n format.html { render :action => \"new\" }\n format.xml { render :xml => @order.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def order1 \n puts(\"\\n\\n- - - - - - - - - - - - - - - -\\n[SHOP] Executing order 1: ABCDABA should be $13.25\\n\\n\") \n @shop.reset_order\n @shop.add_product_to_order_by_name('A')\n @shop.add_product_to_order_by_name('B')\n @shop.add_product_to_order_by_name('C')\n @shop.add_product_to_order_by_name('D')\n @shop.add_product_to_order_by_name('A')\n @shop.add_product_to_order_by_name('B')\n @shop.add_product_to_order_by_name('A')\nend",
"def confirm_delivery\n if @order.complete!\n # update the owner with the refilled boxes\n owner = @order.owner # e.g. node\n current_quantity = owner.current_quantity # e.g. node current quantity\n owner.update(current_quantity: current_quantity + @order.quantity)\n\n render json: {}, status: :ok\n else\n render json: {errors: @order.errors.messages}, status: :bad_request\n end\n end",
"def order_present\n if order.nil?\n errors.add(:order, \"is not a valid order.\")\n end\n end",
"def purchase_order_required?\n if self.solution.purchase_order_required && self.purchase_order.blank?\n errors.add(:purchase_order_required, \"PROBLEM: A purchase order is required for solution #{self.solution.name}.\")\n end\n end",
"def ensure_not_referenced_by_any_product\n if products.empty?\n return true\n else\n errors.add(:base, 'Kann nicht geloescht werden! Es gibt Produkte dieser Marke!')\n return false\n end\n end",
"def delivered_products\n @delivered_products ||= begin\n products = order['OrderDetails']['OrderRows']\n products.each do |ol|\n if ol['OrderRowId'].to_s == line_id.to_s\n ol['QuantityToDeliver'] = quantity\n ol['PackageId'] = track_and_trace_reference\n end\n\n if ol['ProductId'] == 'Postage'\n ol['QuantityToDeliver'] = 1\n ol['PackageId'] = track_and_trace_reference\n end\n end\n products.collect do |pr|\n pr.slice 'OrderRowId', 'QuantityToDeliver', 'PackageId'\n end\n end\n end",
"def is_under_process?\n #if true then this sub has got orders which are under process(by payment / shipment)\n self.orders.where('(delivery_date <= ? and delivery_date > ?) or (state = ? and payment_state = ?)', ORDER_UPDATE_LIMIT.days.from_now.to_date, Time.now, 'placed', 'paid').present?\n end",
"def decrement(order)\n order.order_products.each do |order_product|\n order_product.product.available -= order_product.quantity\n end\n end",
"def order_complete\n load_order\n if @order.packed_at.blank? && (@current_retailer && @current_retailer.id == @order.retailer_id)\n \t@order.update_attribute(:packed_at, Time.now)\n end\n redirect_to admin_order_url(@order)\n end",
"def custom_order?\n order_items.all? { |oi| oi.purchasable_type == 'Effective::Product' }\n end",
"def ensure_not_referenced_by_any_invoice_products\n if invoice_products.empty?\n true\n else\n errors.add(:base, 'Invoice products present')\n false\n end\n end",
"def ensure_not_product_item\n\t\tif product_items.empty?\n\t\t\treturn true\n\t\telse\n\t\t\terrors.add(:base, 'This item is in a shopping cart')\n\t\t\treturn false\n\t\tend\n\t\t\t\n\t\t\t\n\tend",
"def unredeemable?\n payment_owed? && !(ProductStrategy === self.order.promotion.strategy) \n end",
"def create_complete_order(user, product, options={})\n returning(user.orders.create) do |order|\n order.line_items.push create_line_item(product.variants.first)\n order.save\n order.checkout.bill_address = Address.new({\n :firstname => \"First\",\n :lastname => \"Last\",\n :address1 => \"Address1\",\n :city => \"City\",\n :state_name => \"A State\",\n :zipcode => \"00000\",\n :country => Country.new,\n :phone => \"00000000\"\n })\n order.complete\n order.save!\n end\nend",
"def ensure_not_referenced_by_any_product\n unless products.empty?\n errors.add(:base, 'Cannot destroy - products present for this sector')\n throw :abort\n end\n end",
"def not_paid_at_all\n\t\tget_cart_pending_balance == get_cart_price\n\tend",
"def un_evalute_tuan_orders_num\n count=0\n self.orders.each do |order|\n if order.tuangou and order.current_order_status.value >1 and order.current_order_status.value<64 and order.product_rank==-2\n count+=1\n end\n end\n count\n end",
"def index\n @product_in_orders = ProductInOrder.all\n end",
"def populate\n order = current_order(create_order_if_necessary: true)\n variant = Spree::Variant.find(params[:variant_id])\n quantity = params[:quantity].to_i\n options = params[:options] || {}\n direccion = params[:direccion]\n aux = variant.product_id\n if aux == 1\n sku = 19\n elsif aux == 2\n sku = 27\n elsif aux == 3\n sku = 40\n elsif aux == 4\n sku = 45\n elsif aux == 5\n sku = 47\n end\n # 2,147,483,647 is crazy. See issue #2695.\n if quantity.between?(1, 2_147_483_647)\n if quantity <= (StockItem.find_by id: aux).count_on_hand\n begin\n order.contents.add(variant, quantity, options)\n rescue ActiveRecord::RecordInvalid => e\n error = e.record.errors.full_messages.join(\", \")\n end\n else\n error = Spree.t(:please_enter_reasonable_quantity)\n end\n else\n error = Spree.t(:please_enter_reasonable_quantity)\n end\n\n if error\n flash[:error] = error\n redirect_back_or_default(spree.root_path)\n else\n total = NuestroProducto.find(aux).precio * quantity\n factura = RestClient.put 'http://moto.ing.puc.cl/facturas/boleta', {:proveedor => '572aac69bdb6d403005fb042', :cliente => 'b2c', :total => total}\n facturaParseada = JSON.parse factura\n boleta = facturaParseada[\"_id\"]\n $idBoleta = boleta\n $iva = facturaParseada[\"iva\"]\n iva = $iva\n $montoBruto = facturaParseada[\"bruto\"]\n bruto = $montoBruto\n $total = facturaParseada[\"total\"]\n total = $total\n urlOk = 'http://integra1.ing.puc.cl/spree/orders/confirmarCompra/' + boleta\n urlFail = 'http://integra1.ing.puc.cl/cancelacion'\n url = 'http://integracion-2016-prod.herokuapp.com/web/pagoenlinea?callbackUrl='+urlOk+'&cancelUrl='+urlFail+'&boletaId=' + boleta\n redirect_to url\n #precio = NuestroProducto.find(aux).precio\n #moverA_Despacho boleta, direccion, quantity, sku, precio\n Ticket.create(idBoleta:boleta, direccion:direccion, sku:sku, cantidad:quantity, iva:iva, bruto:bruto, total:total)\n end\n end",
"def has_shopped?\n self.points_entries.purchases.count > 0\n end",
"def me_order_pending\n object_from_response(self, Artsy::Client::Domain::Order, :get, \"/api/v1/me/order/pending\", {})\n end",
"def create\n @products = Product.all\n order_products = []\n @products.each do |p|\n sym = \"product_#{p.id}\".to_sym\n if params[sym].present?\n count = params[sym].to_i\n if count > 0\n order_product = OrderProduct.new(product: p, count: count)\n order_products << order_product\n end\n end\n end\n\n if order_products.size > 0\n order = Order.new(user: current_user)\n order.save!\n order_products.each do |i|\n i.order = order\n i.save!\n end\n redirect_to order_path(order.id)\n else\n redirect_to new_order_path\n end\n end",
"def before_confirm\n return if defined?(SpreeProductAssembly)\n return unless @order.checkout_steps.include? 'delivery'\n\n packages = @order.shipments.map(&:to_package)\n @differentiator = Spree::Stock::Differentiator.new(@order, packages)\n @differentiator.missing.each do |variant, quantity|\n @order.contents.remove(variant, quantity)\n end\n end",
"def complete_order\n # Get the current user's last order (i.e. the current order)\n @order = @current_user.orders.last\n\n # Invoke an action in order.rb that 'moves' items from a user's cart to the current order\n @order.add_line_items_from_cart @cart\n\n # Invoke action in order.rb that updates stock levels\n @order.update_inventory\n\n # Destroy the user's cart\n @cart.destroy\n\n # Set a flash notification that the order was successful\n flash[:notification] = \"Order successful!!!\"\n\n # Redirect to orders#show\n redirect_to order_path(@order)\n end",
"def subscription_deferred?\n # * trial period will end one day less than trial-period-span-months-window\n # _defer = if (order.cc_months_advance.blank? && order.cc_months_trial.blank?)\n # order.product_cost.recurring_delay.to_i\n # else\n # order.cc_months_advance.to_i + order.cc_months_trial.to_i\n # end\n # \n # Fri May 27 21:59:53 IST 2011, ramonrails\n # * https://redmine.corp.halomonitor.com/issues/4504\n # * when user intake is created directly, this failed on order == nil\n _defer = ( order.blank? ? 0 : ( order.cc_months_advance.to_i + order.cc_months_trial.to_i ))\n !order.blank? && (Date.today < (order.created_at.to_date >> _defer))\n # !order.blank? && !order.product_cost.blank? && (Date.today < (order.created_at.to_date + order.product_cost.recurring_delay.months))\n end",
"def fulfilled_line_items\n return self.order_line_items.where(:status => 'shipped').all\n end",
"def purchased?(product)\n purchase_items.exists?(product_id: product.id)\n end",
"def check_product_dependencies\n # Iterate though the products associated to this SO, that are not deleted.\n products.visible.each do |p|\n # throw(:abort) will make the destroy method return false and the controller will know the destroy didn't work.\n throw(:abort) if p.shippingoptions.count == 1\n end\n end",
"def check_empty_order(items)\r\n flag = items.item.length\r\n items.item.each do |h|\r\n (flag -= 1) if h[:num] == 0\r\n end\r\n return true if flag == 0\r\n return false\r\nend",
"def ensure_not_referenced_by_any_line_item_product\n unless line_item_products.empty?\n errors.add(:base, 'Line Items Products present')\n throw :abort\n end\n end",
"def order\n return nil if return_items.blank?\n return_items.first.inventory_unit.order\n end",
"def confirm_order\n end",
"def completed\n\n #@order = current_order\n \n posted_xml = params[:ROMANCARTXML]\n\n # Remove XHTML character encoding (hopefully won't need to do this when we receive XML message from RomanCart!)\n xml = posted_xml.sub(\"<?xml version='1.0' encoding='UTF-8'?>\", \"\")\n \n xml_doc = Nokogiri::XML(xml) \n \n total_price = xml_doc.xpath(\"/romancart-transaction-data/sales-record-fields/total-price\").first.content\n orders = Spree::Order.where(\"state = ? AND total = ?\", \"cart\",total_price)\n Rails.logger.info \"#{orders.count} orders in 'cart' state with a price of #{total_price}\"\n \n if orders.count == 0\n # 5/3/14 DH: Testing ROMANCARTXML feedback locally so price is something...\n orders = Spree::Order.where(\"state = ? AND total > ?\", \"cart\",\"0.00\")\n end\n\n @order = orders.last\n \n # 6/3/14 DH: Since CSRF checking is removed for ROMANCARTXML feedback then need to check 'storeid' + items match\n if @order and feedbackValid(xml_doc,@order)\n Rails.logger.info \"Order number selected: #{@order.number}\"\n \n @order.email = xml_doc.xpath(\"/romancart-transaction-data/sales-record-fields/email\").first.content\n \n @order.user_id = xml_doc.xpath(\"/romancart-transaction-data/orderid\").first.content\n \n @order.number = xml_doc.xpath(\"/romancart-transaction-data/orderid\").first.content\n #Rails.logger.info \"Keeping Spree Order number rather than taking RomanCart one\"\n \n #flash[:message] = \"Order number taken from current time!\"\n #@order.number = Time.now.to_i.to_s\n \n # ----------------------- Billing Address -------------------------------\n @order.bill_address = romancartAddress(xml_doc)\n # ----------------------- Delivery Address ------------------------------ \n #<delivery-address1/>\n if xml_doc.xpath(\"/romancart-transaction-data/sales-record-fields/delivery-address1\").first.content.empty?\n @order.use_billing = true\n else\n @order.ship_address = romancartAddress(xml_doc, \"delivery-\")\n end\n \n # Spree StateMachine = 1)cart -> 2)address -> 3)delivery -> 4)payment -> 5)confirm -> 6)complete\n\n # If the order is just for samples then it'll be free so no payment is required\n if @order.item_total == 0\n \n while @order.state != \"complete\"\n @order.next!\n end\n \n else\n \n while @order.state != \"payment\"\n @order.next!\n Rails.logger.info \"Order number '#{@order.number}' is in state:#{@order.state}\" \n end\n \n #if xml_doc.xpath(\"/romancart-transaction-data/paid-flag\").first.content.eql?(\"True\")\n if xml_doc.xpath(\"/romancart-transaction-data/paid-flag\").first.content.eql?(\"False\")\n Rails.logger.info \"Testing ROMANCARTXML feedback using cheque payment so '<paid-flag>False</paid-flag>'\"\n\n unless @order.payments.exists?\n # 5/3/14 DH: Previously this worked for 'spree-2.0.4' but the payments system was changed in 'spree-2.1'\n #@order.payments.create!(:amount => @order.total)\n #@order.payments.last.payment_method = Spree::PaymentMethod.find_by_name(\"RomanCart\")\n #@order.payments.last.complete\n\t \n # 5/3/14 DH: Taken this from 'spree/2-1-stable/api/app/models/spree/order_decorator.rb' \n payment = @order.payments.build\n payment.amount = @order.total\n payment.complete\n payment.payment_method = Spree::PaymentMethod.find_by_name(\"RomanCart\")\n payment.save!\n\t \n if @order.payments.last.payment_method\n Rails.logger.info \"Creating #{@order.payments.last.payment_method.name} payment of #{@order.total}\"\n else\n Rails.logger.info \"RomanCart payment method not found!\"\n end\n end\n \n \n @order.payment_total = @order.total\n\n # To 6 - Complete\n #@order.payment_state = \"paid\"\n updater = Spree::OrderUpdater.new(@order)\n updater.update_payment_state\n \n @order.state = \"complete\"\n @order.completed_at = Time.now\n @order.save!\n Rails.logger.info \"Order number '#{@order.number}' is in state:#{@order.state}\"\n end\n end\n\n else # No current order (prob because of the CSRF error preventing Devise access the current order session)\n Rails.logger.info \"Well that's what Devise does since there's no CSRF authenticy...doh!\"\n end\n\n end",
"def out_of_stock_message(product)\r\n \"out of stock\" unless product \r\n end",
"def aqty\n self.qty.reject(&:empty?) rescue []\nend",
"def products_in_cart (complete)\n cart = []\n @total = 0\n Cart.all.each do |item|\n product_total = item.quantity * item.price\n @total += product_total\n cart.append('Name': item.name,\n 'Description': item.description,\n 'Item ID': item.item_id,\n 'Price': item.price,\n 'Quantity': item.quantity,\n 'Subtotal': \"$#{product_total.round(2)}\")\n if complete\n product = Product.find_by(name: item.name)\n product.update_columns(quantity: product.quantity - item.quantity)\n end\n end\n cart.append('Total': \"$#{@total.round(2)}\")\n return cart\n end",
"def has_order_items?\n @cores != nil || @ram != nil || @max_port_speed != nil\n end",
"def buys\n orders[:buys]\n end",
"def show\n @order.update_attribute(:seen, true) unless @order.seen\n @line_items = @order.line_items.includes(:product)\n end",
"def may_purchase?(_company)\n false\n end",
"def pending_financials?\n shop && shop.pending_products.any?\n end",
"def all_orders_sync\n @all_partial_orders = Spree::Order.includes(:line_items).where(\"spree_line_items.id is null\")\n if !@all_partial_orders.present? || @all_partial_orders.count == 0\n flash[:error] = \"No orders found to sync\"\n redirect_to partial_orders_admin_orders_path\n return\n else\n res = view_context.sync_all_orders_qoo10(@all_partial_orders)\n redirect_to partial_orders_admin_orders_path, :notice => \"All orders synced successfully!\"\n end\n end",
"def finalize!\n update_attribute(:completed_at, Time.now)\n update_attribute(:payment_method_name, self.payment_method.name) unless self.payment_method_name\n self.out_of_stock_items = InventoryUnit.assign_opening_inventory(self)\n # lock any optional adjustments (coupon promotions, etc.)\n adjustments.optional.each { |adjustment| adjustment.update_attribute(\"locked\", true) }\n\n self.state_events.create({\n :previous_state => \"cart\",\n :next_state => \"complete\",\n :name => \"order\" ,\n :user_id => (User.respond_to?(:current) && User.current.try(:id)) || self.user_id\n })\n end",
"def is_cart_empty?\n total_price = self.get_total_price\n\n if total_price > 0\n return false\n else\n return true\n end\n end",
"def get_orders\n orders\n end",
"def after_complete\n session[:order_id] = nil\n end",
"def after_complete\n session[:order_id] = nil\n end",
"def after_complete\n session[:order_id] = nil\n end",
"def purchase_stock!\n nil\n end",
"def has_items?\n\t\tget_cart_items.size > 0\n\tend",
"def receive_quietly backordered_units\n \n return if backordered_units.count < 1\n \n # TODO backordered units are not in stock\n \n self.variant.update_column(:count_on_hand, self.variant.on_hand + backordered_units.count)\n self.variant.save\n backordered_units.each(&:fill_backorder)\n \n end",
"def already_notified(order) \r\n @notified_orders_set.include? order[\"order_id\"]\r\nend",
"def get_undelivered_order_ids\n\n #enable this one for previous restricted conditioned(pause/resume)\n #orders =self.orders.select('id, delivery_date').where('spree_orders.delivery_date > ?', Time.now).limit(3)\n orders = self.orders.select('id, delivery_date').where('spree_orders.state in (?) ', ['confirm', 'placed']).limit(3)\n\n order_ids = {}\n\n orders.each_with_index do |order, index|\n order_ids.merge!(index => order.id)\n end\n\n order_ids\n end",
"def check_if_cart_is_empty_or_session_cart_id_is_nil\n\n @cart = Cart.find_by(id: session[:cart_id]) if session[:cart_id] =! nil\n if session[:cart_id] == nil && @cart.order_items.empty?\n redirect_to root_path\n \n flash.notice = \"Please add any product before placing an order\"\n redirect_to root_path\n else\n end\n \n end",
"def order_success\n begin\n @order = (flash[:order_id] ? Order.find(flash[:order_id]) : @customer.orders.last)\n\n flash.keep(:order_id) # Keep the order ID around in case of a reload\n\n if request.post?\n if params[:customer]\n @order.customer.update_attributes( params[:customer] )\n end\n end\n\n rescue Exception => e\n ExceptionNotifier::Notifier.exception_notification(request.env, e).deliver\n @order = nil\n end\n\n @upsell_products = []\n if ! @order.andand.university_id\n @upsell_products = @customer.andand.postcheckout_upsell_recommend(1, 2, @order)\n end\n end"
] |
[
"0.7015277",
"0.7015277",
"0.6753205",
"0.6693969",
"0.6429757",
"0.6401549",
"0.6401493",
"0.63852507",
"0.629773",
"0.6275499",
"0.61900157",
"0.6185921",
"0.61281693",
"0.61037266",
"0.60712636",
"0.606667",
"0.6059033",
"0.6035542",
"0.6034695",
"0.6033788",
"0.6031985",
"0.60256815",
"0.6025358",
"0.6022516",
"0.60184366",
"0.6005887",
"0.6005804",
"0.59957176",
"0.59830433",
"0.5970304",
"0.59647524",
"0.5945377",
"0.5941931",
"0.59282637",
"0.59182125",
"0.5897818",
"0.58820635",
"0.58816236",
"0.58765674",
"0.5862136",
"0.58510745",
"0.5850491",
"0.5832273",
"0.582036",
"0.58152163",
"0.5790213",
"0.5762363",
"0.5760302",
"0.5757262",
"0.5754076",
"0.5750576",
"0.57429725",
"0.57385236",
"0.5733705",
"0.57311773",
"0.5730701",
"0.5713081",
"0.5712966",
"0.57015777",
"0.57005537",
"0.56829613",
"0.56815356",
"0.56793934",
"0.56709427",
"0.5649441",
"0.5644936",
"0.56383336",
"0.5636864",
"0.56313163",
"0.5629291",
"0.56257915",
"0.5622071",
"0.5618307",
"0.5608908",
"0.5599417",
"0.5594168",
"0.5591065",
"0.5590148",
"0.55804956",
"0.558028",
"0.55780435",
"0.5576752",
"0.5574254",
"0.55718726",
"0.5570436",
"0.5569724",
"0.5563777",
"0.55525506",
"0.5545672",
"0.5542917",
"0.5541793",
"0.5541793",
"0.5541793",
"0.55414283",
"0.5540396",
"0.553607",
"0.55348295",
"0.5531969",
"0.553194",
"0.55283356"
] |
0.64728856
|
4
|
Fired when a client is connected.
|
def on_message(msg); @parent.on_message(@env, msg); end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def on_client_connect(client)\n end",
"def client_connected\n end",
"def on_connected\n end",
"def on_connect(socket)\n Utils.logger.info(\"[Client Connected: #{socket.inspect}]\")\n end",
"def on_connect_event(ctx)\n logger.debug(\"Client connect from #{ctx[:server][:remote_ip]}:#{ctx[:server][:remote_port]}\")\n end",
"def connected(client)\n\t\tclient.listen('WHEREAMI?', self)\n\t\tclient.listen('NEARBY?', self)\n\t\tclient.listen('DISTANT?', self)\n\t\tclient.listen('IMOVED', self)\n\t\tclient.listen('NEARBYENT?', self)\n\tend",
"def client_connected\n puts \"client #{current_user.email} connected\"\n current_player = current_user.player || current_user.create_player\n current_player.is_online = true\n current_player.save\n coords = [\n current_player.left,\n current_player.top,\n current_player.id,\n current_player.last_direction\n ]\n send_message :starting_position, coords\n \n # Get an array of the other players, convert to hash keyed on player id\n players = Player.where 'user_id != ? and is_online = ?', current_user, true\n player_hash = {}\n players.each do |player|\n player_hash[player.id] = {\n user_name: player.user.email.sub(/@.+/, ''),\n is_moving: player.is_moving,\n last_direction: player.last_direction,\n left: player.left,\n top: player.top\n }\n end\n send_message :player_list, player_hash\n \n broadcast_message :player_enter, {\n user_name: current_user.email.sub(/@.+/, ''),\n id: current_player.id,\n last_direction: current_player.last_direction,\n left: current_player.left,\n top: current_player.top\n }\n end",
"def on_connect(client_id, ip_address)\n @client_manager.add(client_id, ip_address)\n end",
"def on_open client\n c = controller(client)\n c.instance_variable_set(CLIENT_NAME, client)\n if client.protocol == :sse\n c.on_sse\n else\n c.on_open\n end\n end",
"def on_connect_event(ctx)\n on_logging_event(ctx, Logger::DEBUG, \"Client connect from #{ctx[:server][:remote_ip]}:#{ctx[:server][:remote_port]} to #{ctx[:server][:local_ip]}:#{ctx[:server][:local_port]}\")\n end",
"def on_connect_event(ctx)\n carterdte_logger.info(\"Connection from #{ctx[:server][:remote_ip]}\")\n end",
"def on_open(client)\n client.subscribe \"chat\"\n # let everyone know we arrived\n client.publish \"chat\", \"#{@name} entered the chat.\"\n end",
"def post_init\n puts \"Client connected!\"\n $clients_list ||= {}\n \n # Remember the connection\n connection = Connection.new(self.object_id, self, \"Player #{$pc}\")\n $clients_list.merge!({self.object_id => connection})\n\n # Send this message to the newly connected player\n send_create_yourself()\n \n # Alert all other players that a ship connected\n $clients_list.values.each do |c|\n send_new_entity(c.socket) if c.socket != self\n end\n \n $pc += 1\n end",
"def on_connected( fd, endpoint )\n\t\t\tself.log.debug \"Client socket on FD %d connected\" % [ fd ]\n\t\tend",
"def on_client_connect(cli)\n cli.extend(ServerClient)\n\n cli.init_cli(self)\n end",
"def socket_connected\n post_init\n end",
"def on_open(event)\n logger.debug 'Socket opened'\n @connected = true\n dispatch('command' => 'session_started')\n end",
"def on_open(event)\n logger.debug 'Socket opened'\n @connected = true\n end",
"def on_connecting\n\t\t\t\t@@connected = false\n\t\t\t\tpublish('zk_connecting')\n\t\t\tend",
"def connected\n log :connect, \"+++ #{@ip}:#{@port} (#{@proto}) connected\\n\"\n end",
"def on_connection_established(&block)\n @on_connection_established_block = block\n end",
"def on_open(event)\n logger.debug \"Connection openned as user: #{@user} on channel: #{@channel}.\"\n end",
"def listen_for_client\n puts \"Listening...\"\n @client = @server.accept\n puts \"A client connected.\"\n @client.puts \"Connected to server!\"\n end",
"def client_connected\n @dest_host = @proxy_host\n @dest_port = @proxy_port\n connect_to_dest\n end",
"def on_client_data(client)\n end",
"def connected\n\t\tdo_send('CN1')\t# Connection command - initiate comms\n\t\n\t\t@polling_timer = schedule.every('60s') do\n\t\t\tlogger.debug \"Polling JVC\"\n\t\t\tdo_send('CN1')\t# Connection command\n\t\tend\n\tend",
"def on_connected\n\t\t\t\t@@connected = true\n\t\t\t\twhile not @@ensure.empty?\n\t\t\t\t\tfunc = @@ensure.shift\n\t\t\t\t\tensured func[0], *func[1]\t# func[0] == function name, func[1] == arguments\n\t\t\t\tend\n\t\t\t\tpublish('zk_connected')\n\t\t\tend",
"def post_init\n @connected = true\n end",
"def post_init\n @connected = true\n end",
"def on_connect(&callback)\n @connect_cb = callback\n end",
"def connected\n Rails.logger.debug \"Status#status session[:client] #{session[:client].inspect}\"\n render :json => (session[:client] != nil)\n end",
"def connected?\n client.is_connected?\n end",
"def on_connect(m)\n User(m.user.nick).monitor\n end",
"def on_connected(&block)\n @on_connected_procs << block\n end",
"def connect\n start_listener!\n end",
"def connection_completed\n @connected = true\n Skates.logger.debug {\n \"CONNECTED\"\n } # Very low level Logging\n end",
"def event_new_connection(client)\n client.var[:last_ping] = Time.now # Initialize ping-timeout variable\n if @motd[EMPTY_ROOM]\n select_send(MSG_SERVER, EMPTY_ROOM, @keyring.default.iv,\n server_encrypt(\"motd #{EMPTY_ROOM}#{@motd[EMPTY_ROOM]}\")\n ) { |x| x == client }\n end\nend",
"def connected!\n @connected = true\n\n @network.connected!\n end",
"def on_connection_success &block\n @connection_success_callback = block\n end",
"def start\n @client.on :hello do\n puts \"Successfully connected, welcome '#{@client.self.name}' to the '#{@client.team.name}' team at https://#{@client.team.domain}.slack.com.\"\n end\n @client.on :close do |_data|\n puts \"Client is about to disconnect\"\n end\n @client.on :closed do |_data|\n puts \"Client has disconnected successfully!\"\n end\n\n @client.on :message do |data|\n message = data.text\n bot_id = @client.self.id\n if self.needs_help?(message, bot_id)\n @client.message channel: data.channel, text: self.respond_help\n else\n symbol_doc = self.read(message, bot_id)\n if self.must_respond?(symbol_doc)\n if symbol_doc.success\n @client.message channel: data.channel, text: self.respond_ok(symbol_doc)\n else\n if message.split.count > 1\n @client.message channel: data.channel, text: self.respond_error(symbol_doc)\n end\n end\n end\n end\n end\n\n @client.start!\n end",
"def out_begin_connection(event)\n pass(@password) if @password\n user(event.username, '0.0.0.0', event.address, event.realname)\n nick(@nicknames[0])\n end",
"def on_open(&block)\n define_callback :connect, &block\n end",
"def post_init\n self.dispatch_event(:on_connect, [self])\n self.send_data(SyncMessage.new($listen_port, $uuid).to_sendable)\n end",
"def on_hello(content, client)\n OutputLogger.logger.info \"Bot is online!!!\"\n end",
"def connectionStart(conn)\n\n port, host = conn.peeraddr[1,2]\n client = \"#{host}:#{port}\"\n #puts \"#{client} is connected\"\n $counter=$counter + 1\n $maxConnections = $maxConnections + 1\n puts $counter.to_s+\" clients connected\"\n $logger.info \"#{client} has connected\"\n $logger.info $counter.to_s+\" clients connected\"\nend",
"def ready(packet)\n @connected = true\n\n send_nick()\n end",
"def on_connect(obj=nil, &block)\n @on_connect_obj = obj\n @on_connect = Proc.new { |handle, obj_ptr|\n # On connect, we'll need to re-add all of our change handlers\n @listeners.each_pair do |pattern, (listener, proc)|\n begin\n next if status != :connected\n Klass.set_OnKeyChange_Handler(@handle, listener, pattern, proc, pointer_for(obj)) \n sleep @handler_sleep\n rescue\n Phidgets::Log.error(\"#{self.class}::on_connect\", $!.to_s)\n end\n end\n yield self, object_for(obj_ptr)\n }\n Klass.set_OnServerConnect_Handler(@handle, @on_connect, pointer_for(obj))\n sleep @handler_sleep\n end",
"def connected?; end",
"def connected?; end",
"def connected?; end",
"def connected\n\t\tdo_send(setting(:username), :priority => 0)\n\tend",
"def connect client_id, host, port, &block\n @client_id = client_id\n @ws = WebSocket::EventMachine::Client.connect :uri => 'ws://' + host + ':' + port.to_s\n @ws.onopen {\n @state = :state_connected\n @password = Utils.md5 @password if @md5\n @ws.send ['register', {\n :type => 'client',\n :client_id => @client_id,\n :username => @username,\n :password => @password,\n :md5 => @md5\n }].to_json\n }\n @ws.onmessage { |msg, type|\n begin\n event, msg = parse msg\n case event\n when 'register'\n process_register_msg msg, &block\n when 'client'\n process_client_msg msg\n else\n end\n rescue => err\n end\n }\n @ws.onclose { |code, reason|\n @state = :state_closed\n emit 'close'\n }\n @ws.onerror { |err|\n if @state == :state_inited\n block_given? and yield err\n end\n emit 'error', err\n }\n end",
"def set_basic_listener(on_connected, on_disconnected, on_connect_error)\n @on_connected = on_connected\n @on_disconnected = on_disconnected\n @on_connect_error = on_connect_error\n end",
"def on_connect(&block)\n raise IrcError.new('wrong arity') if block.arity != 4\n self[:connect] << block\n end",
"def connect\n succeed # Triggers all callbacks for class\n end",
"def on_server_connect(obj=nil, &block)\n @on_server_connect_obj = obj\n @on_server_connect = Proc.new { |handle, obj_ptr|\n yield self, object_for(obj_pointer)\n }\n Klass.set_OnServerConnect_Handler(@handle, @on_server_connect, pointer_for(obj))\n end",
"def connection_completed\n @connection_state = :connected\n @connection_state_callback.call if @connection_state_callback\n end",
"def on_connect(*)\n\n TweetStream.configure do |c|\n c.consumer_key = config[:twitter_consumer_key]\n c.consumer_secret = config[:twitter_consumer_secret]\n c.oauth_token = config[:twitter_access_token]\n c.oauth_token_secret = config[:twitter_access_token_secret]\n c.auth_method = :oauth\n end\n\n @client = TweetStream::Client.new\n\n end",
"def connect\n return if @connected && (@socket && !@socket.closed?)\n on_connect\n @connected = true\n end",
"def client_exists(client_id, &callback)\n callback.call(@connected.containsKey(client_id))\n end",
"def on_ready\n end",
"def on_connect(&callback)\n if block_given?\n @on_connect = callback\n elsif @on_connect\n @on_connect.call\n end\n end",
"def establish_connection_with_client\n\t\t# Update help message\n\t\t@help_window.set_text(\"Waiting for client to connect...\", 1)\n\t\tConsole.log \"creating server\"\n\t\t# Create Server\n\t\t$game_server = GameServer.new\n\t\t@connection_thread = Thread.new do\n\t\t\tConsole.log \"waiting for client...\"\n\t\t\tsleep(1)\n\t\t\t$game_server.accept\n\t\t\t# @connection_thread = nil\n\t\t\t$scene = Scene_Pong_Server.new\n\t\tend\n\t\t#Thread.current.priority = 10\n\t\tConsole.log \"Thread is running, returning to normal update cycle\"\n\tend",
"def on_open(env)\n req = ::Rack::Request.new(env)\n @cid = req.params['cid']\n @path = req.path\n @subscription = Firehose::Subscription.new(cid, path)\n\n subscription.subscribe do |message, subscription|\n Firehose.logger.debug \"WS sent `#{message}` to `#{cid}@#{path}`\"\n send_data message\n end\n Firehose.logger.debug \"WS subscribed to `#{cid}@#{path}`\"\n end",
"def on_client_close(client)\n end",
"def pre_connect\n\t\t\ttrue\n\t\tend",
"def initialize_session\n puts 'initializing session with client'\n end",
"def connected?; connection_state == :connected end",
"def register_client(game_id, player, hostname, port)\n game = @game_list[game_id]\n game.proxy = RClient.new(hostname, port, 'hosteventproxy')\n\n game.game_state.on_change.listen {\n Thread.new {\n game.proxy.on_change_fire\n }\n }\n\n game.connect_game.on_win.listen { |winner|\n if (winner == player)\n game.proxy.on_win_fire\n end\n }\n ''\n end",
"def connected(socket, remote_state)\n Distributed.debug { \"#{self}: connected\" }\n register_link(socket)\n local_server.state_update remote_state\n @send_queue = Queue.new\n\t @send_thread = Thread.new(&method(:communication_loop))\n end",
"def connect \n log \"Connecting\"\n @socket = TCPSocket.new(config[:server], 6667)\n write \"USER #{config[:nick]} #{config[:nick]} #{config[:nick]} :#{config[:nick]}\"\n write \"NICK #{config[:nick]}\"\n write \"JOIN ##{config[:channel]}\"\n end",
"def connect!\n EventMachine.run do\n EventMachine::MQTT::ClientConnection.connect(@server) do |c|\n c.subscribe(@topic)\n c.receive_callback do |message|\n handle_incoming_message(message)\n end\n end\n end\n end",
"def on_message client, data\n controller(client).on_message(data)\n end",
"def client_disconnected\n end",
"def connected?\n @conn.connected? && @channel.open?\n end",
"def connected?\n status == CONNECTED\n end",
"def ssl_handshake_completed\n connected!\n end",
"def connected?\n connection_handler.connected?(self)\n end",
"def on_db_client(client)\n\tend",
"def onconnect &blk\n @onconnect = blk unless blk.nil?\n @onconnect\n end",
"def post_init\n puts \"#{self.class}/#{self} client post_init runs\"\n end",
"def init_client(args={}, &on_init)\n host,port = args[:host], args[:port]\n connection = @connections.find { |c| port == c.port && host == c.host }\n connection ||= EventMachine::connect(host, port, TCPConnection, args)\n on_init.call(connection) # TODO move to tcpnode event ?\n end",
"def connected_update(protocol_message)\n # ClientID validity is already checked as part of the incoming message processing\n client.auth.configure_client_id protocol_message.connection_details.client_id\n\n # Update the connection details and any associated defaults\n connection.set_connection_details protocol_message.connection_details\n\n connection.configure_new protocol_message.connection_id, protocol_message.connection_details.connection_key, protocol_message.connection_serial\n\n state_change = Ably::Models::ConnectionStateChange.new(\n current: connection.state,\n previous: connection.state,\n event: Ably::Realtime::Connection::EVENT(:update),\n reason: protocol_message.error,\n protocol_message: protocol_message\n )\n connection.emit :update, state_change\n end",
"def start\n self.connect\n self.login if @connected\n end",
"def connecting(socket)\n add_client( socket.peeraddr[1], socket )\n super\n end",
"def connected?\n Drone::Client.connected?\n end",
"def connections_handler(id, ip)\n\t# show who connected\n\tputs \"[ID #{id}] connected from #{ip}\"\n\t# delete the hash entry if it already exists\n\t@clients.delete_if {|key, value| key == id }\n\t# add the new entry to the clients hash\n\t@clients[id] = { :ip => ip }\n\t#show how many clients we have\n\tputs \"Clients connected: #{@server.clients_count} of #{@server.max_clients}\"\nend",
"def on_session_ended\n @connection = nil\n\n # Automatically reconnect to the server if allowed\n if @reconnect\n reconnect_from(Exception) do\n connect\n trigger(:reconnected)\n end\n end\n end",
"def reconnect\n disconnect rescue nil\n @connected = true\n end",
"def handle_client_connection( socket, client_id )\n info \"Starting new MindControl session for user #{client_id} ...\"\n\n # Client will send us his STDIN and STDOUT\n client_stdin, client_stdout = socket.recv_io, socket.recv_io\n\n # Start REPL\n repl.start client_stdin, client_stdout\n\n info \"MindControl session for user #{client_id} has ended!\"\n rescue Exception => e\n error_message = \"REPL exception: #{e.message} (#{e.class.name})\\n#{e.backtrace.join( \"\\n\" )}\"\n error error_message\n\n # Send error to client\n client_stdout.puts error_message if client_stdout\n end",
"def client\n @client.push()\n end",
"def on_open\n\n # Must pass a nickname\n if params[:name].nil?\n response << {event: :error, from: :system, at: Time.now, message: \"Error: cannot connect without a nickname!\"}.to_json\n response.close\n return false\n end\n\n # Can't use admin nicknames\n message = {from: '', at: Time.now}\n name = params[:name]\n if (name.downcase.match(/admin|admn|system|sys|administrator/i))\n message[:event] = :error\n message[:message] = \"The nickname '#{name}' is already taken.\"\n response << message.to_json\n params[:name] = false\n response.close\n return\n end\n\n # Welcome user to chat\n message = {from: '', at: Time.now}\n message[:event] = :chat\n response << message.to_json\n message[:message] = \"#{params[:name]} joined the chatroom.\"\n broadcast :_send_message, message.to_json\n # Explain who is here or if your the first one here\n #message[:message] = list.empty? ? \"You're the first one here.\" : \"#{list[0..-2].join(', ')} #{list[1] ? 'and' : ''} #{list.last} #{list[1] ? 'are' : 'is'} already in the chatroom\"\n end",
"def connected(protocol_message)\n # ClientID validity is already checked as part of the incoming message processing\n client.auth.configure_client_id protocol_message.connection_details.client_id\n\n # Update the connection details and any associated defaults\n connection.set_connection_details protocol_message.connection_details\n\n if connection.key\n if protocol_message.connection_id == connection.id\n logger.debug { \"ConnectionManager: Connection resumed successfully - ID #{connection.id} and key #{connection.key}\" }\n EventMachine.next_tick { connection.trigger_resumed }\n resend_pending_message_ack_queue\n else\n logger.debug { \"ConnectionManager: Connection was not resumed, old connection ID #{connection.id} has been updated with new connection ID #{protocol_message.connection_id} and key #{protocol_message.connection_details.connection_key}\" }\n nack_messages_on_all_channels protocol_message.error\n force_reattach_on_channels protocol_message.error\n end\n else\n logger.debug { \"ConnectionManager: New connection created with ID #{protocol_message.connection_id} and key #{protocol_message.connection_details.connection_key}\" }\n end\n\n reattach_suspended_channels protocol_message.error\n\n connection.configure_new protocol_message.connection_id, protocol_message.connection_details.connection_key, protocol_message.connection_serial\n end",
"def connect client, *headers\n # I really don't care for this. A core part of the CONNECT/CONNECTED\n # exchange can only be accomplished through subclasses.\n write_frame_nonblock connect_frame(*headers)\n client_con = nil\n until client_con\n io_process_write { |f| client_con ||= f }\n end\n update_last_received\n broker_con = nil\n until broker_con\n io_process_read(true) { |f| broker_con ||= f }\n end\n raise OnStomp::ConnectFailedError if broker_con.command != 'CONNECTED'\n vers = broker_con.header?(:version) ? broker_con[:version] : '1.0'\n raise OnStomp::UnsupportedProtocolVersionError, vers unless client.versions.include?(vers)\n @connection_up = true\n [ vers, broker_con ]\n end",
"def on_reconnect(&callback)\n @reconnect_cb = callback\n @client.on_reconnect(&callback) unless @client.nil?\n end",
"def established?\n @connected == true\n end",
"def initial_message\n Kh.call(:server_connect)\n post @socket, server_name, RPL_WELCOME, @nick, \"Welcome to the Internet Relay Network #{@prefix}\"\n post @socket, server_name, RPL_YOURHOST, @nick, \"Your host is #{server_name}, running version #{server_version}\"\n post @socket, server_name, RPL_CREATED, @nick, \"This server was created #{Time.now}\"\n post @socket, server_name, RPL_MYINFO, @nick, \"#{server_name} #{server_version} #{available_user_modes} #{available_channel_modes}\"\n end",
"def connect\n end",
"def client\n end",
"def connection_established(pid, conn)\n @connections[pid.uuid] ||= conn\n __send__(conn.connected_callback, pid)\n @connections[pid.uuid].remote_pid || pid # looks like hack, but it is not.\n end",
"def connected?\n @status == :connected\n end"
] |
[
"0.8019362",
"0.7960757",
"0.76705307",
"0.7568223",
"0.7376992",
"0.7271038",
"0.7113182",
"0.70947725",
"0.70002866",
"0.6959558",
"0.68677276",
"0.682789",
"0.6827336",
"0.6823648",
"0.6761378",
"0.6718987",
"0.6711217",
"0.6686068",
"0.66635996",
"0.6645629",
"0.66000336",
"0.6501471",
"0.649889",
"0.64609534",
"0.64521694",
"0.6398411",
"0.6360899",
"0.6358484",
"0.6358484",
"0.63445437",
"0.63351846",
"0.6314421",
"0.6297766",
"0.62927943",
"0.6276208",
"0.62671214",
"0.6235071",
"0.6223416",
"0.6162218",
"0.6145478",
"0.6134894",
"0.61214644",
"0.6110751",
"0.606361",
"0.60232365",
"0.5995978",
"0.59735596",
"0.59066623",
"0.59066623",
"0.59066623",
"0.5858039",
"0.58561957",
"0.58379483",
"0.5816787",
"0.5816684",
"0.5799596",
"0.5795586",
"0.5774769",
"0.57709914",
"0.5751379",
"0.57312006",
"0.5727488",
"0.5726953",
"0.5713934",
"0.5706455",
"0.57063836",
"0.56901705",
"0.5682973",
"0.5675058",
"0.56601804",
"0.56565994",
"0.5646064",
"0.56458426",
"0.5645791",
"0.56447494",
"0.56422913",
"0.5632711",
"0.56289244",
"0.5606298",
"0.5605986",
"0.56046253",
"0.5601721",
"0.559221",
"0.559209",
"0.55837405",
"0.55700564",
"0.55636626",
"0.5559205",
"0.55545104",
"0.55508775",
"0.55445147",
"0.5538832",
"0.5534457",
"0.55231166",
"0.55206",
"0.55185944",
"0.550436",
"0.54790235",
"0.54745215",
"0.54731107",
"0.54716325"
] |
0.0
|
-1
|
Fired when a message from a client is received.
|
def on_close; @parent.on_close(@env); end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def on_message client, data\n controller(client).on_message(data)\n end",
"def message_received(client, msg)\n content = JSON.parse msg.data\n\n kind = content['type'] || 'empty message'\n\n OutputLogger.logger.info \"Received a message of the #{kind} type.\"\n OutputLogger.logger.debug content\n\n method = \"on_#{content['type']}\"\n\n send(method, content, client) if respond_to?(method)\n end",
"def handle_message(event)\n sender = @users[event['sender']]\n timestamp = event['origin_server_ts'] || Time.now.to_i\n content = event['content']\n message = Message.new sender, timestamp, content\n broadcast(:message, @room, message)\n Events.processed event\n end",
"def received(message)\n if message.respond_to?(:encoding) && message.encoding != 'UTF-8'\n message.force_encoding 'UTF-8'\n end\n data = JSON.parse message, :symbolize_names => true\n\n case data[:type]\n when 'text'\n return if @nonces.include?(data[:nonce])\n @nonces << data[:nonce]\n room.message @user, data[:text], name_color, data[:client_ts]\n when 'av-invite', 'av-accept', 'av-close'\n return if @nonces.include?(data[:nonce])\n @nonces << data[:nonce]\n av_message data\n when 'sync'\n @last_event_id = data[:last_event_id].to_i\n sync_events\n when 'ping'\n respond pong: { nonce: data[:nonce], client_ts: data[:client_ts] }\n when 'relay'\n return if @nonces.include?(data[:nonce])\n @nonces << data[:nonce]\n room.relay @user, data[:to], data[:body], data[:client_ts]\n end\n end",
"def receive_message(message)\n end",
"def on_receive(message)\n end",
"def on_message(event)\n message = JSON.parse(event.data)\n\n if message['id']\n message['command'] = 'response_received'\n elsif message['message']\n command, *args = *message['message']\n message = {'command' => command, 'args' => args}\n end\n\n logger.debug \"Message received: #{message.inspect}\"\n dispatch(message)\n end",
"def on_message(env, msg)\n log(\"received\", msg)\n Message.new(@connection, msg).dispath\n end",
"def received\n end",
"def on_message\n websocket_client.on(:message) do |event|\n websocket_response = websocket_response_data_class.new(\n data: event.data,\n bot_params_class: bot_params_class\n )\n\n bot.handle_data(websocket_response.bot_params) do |message|\n websocket_request = websocket_request_data_class.new(message: message, data: websocket_response.bot_params)\n websocket_client.send(websocket_request.data_to_send)\n end\n end\n end",
"def on_message(m)\n end",
"def on_message(&block)\n @@message_callback = block\n end",
"def on_client_data(client)\n end",
"def event_incoming_chat(client, msg)\nend",
"def on_message(event)\n data = event.data\n\n response = data.match(/~m~\\d*~m~(.*)/)[1]\n message =\n case response\n when /no_session/\n {'command' => 'no_session'}\n when /~h~([0-9]+)/\n # Send the heartbeat command back to the server\n @socket.send($1)\n {'command' => 'heartbeat'}\n else\n JSON.parse(response)\n end\n message['command'] = 'response_received' if message['msgid']\n\n logger.debug \"Message received: #{message.inspect}\"\n dispatch(message)\n end",
"def message_received(message)\n @message_handlers.each do |block|\n block.call(message)\n end\n end",
"def onmessage(&block)\n super( &proc do |msg|\n msg = JSON.parse(msg)\n Hammer.logger.debug \"Websocket recieved: #{msg}\" if config[:logger][:show_traffic]\n block.call msg\n end)\n end",
"def receive(message)\n info(\"[Smartfocus] Receive -> #{message}\")\n end",
"def on_receive(message)\n update\n end",
"def onmessage(msg)\n Slanger::Statsd.increment(\"messages\")\n Slanger::Statsd.gauge(\"message_size\", msg.bytesize)\n\n msg = Oj.load(msg)\n\n msg[\"data\"] = Oj.load(msg[\"data\"]) if msg[\"data\"].is_a? String\n\n case msg[\"event\"]\n when /\\Aclient-/\n msg[\"socket_id\"] = socket_id\n Channel.send_client_message(msg)\n when \"pusher:ping\"\n pusher_ping(msg)\n when \"pusher:pong\"\n pusher_pong(msg)\n when \"pusher:subscribe\"\n pusher_subscribe(msg)\n when \"pusher:unsubscribe\"\n pusher_unsubscribe(msg)\n end\n rescue JSON::ParserError, Oj::ParseError\n send_error({ code: 5001, message: \"Invalid JSON\" })\n rescue Exception => e\n puts \"Error: #{e.class.name}: #{e.message}\\n#{e.backtrace.join(\"\\n\")}\"\n send_error({ code: 500, message: \"Internal Error\" })\n end",
"def onMessage(event)\n type, client_id = event.getMessageObject().split(':')\n case type\n when 'message'\n @engine.empty_queue(client_id)\n when 'disconnect'\n @engine.server.trigger(:close, client_id)\n else\n @engine.server.debug 'Unknown event ?', type\n end\n end",
"def received message, headers={}\n end",
"def receive_msg msg\n # stub, overwrite this in your handler\n end",
"def receive_msg(msg)\n if msg.command == \"CONNECTED\"\n @log.debug(\"#{self} received CONNECTED : #{msg.inspect}\")\n @connected = true\n else\n @log.debug(\"got a message: #{msg.inspect}\")\n @log.debug(\"#{self} got a message\")\n @data_received << msg # accumulate messages\n end\n end",
"def onmessage(msg)\n msg = JSON.parse msg\n event = msg['event'].gsub(/^pusher:/, 'pusher_')\n\n if event =~ /^client-/\n msg['socket_id'] = @socket_id\n\n Channel.send_client_message msg\n elsif respond_to? event, true\n send event, msg\n end\n\n rescue JSON::ParserError\n error({ code: '5001', message: \"Invalid JSON\" })\n end",
"def onmessage(&blk); super; end",
"def handle_message(message)\n if @response_wait_list.waiting_for?(message)\n @response_wait_list.received(message)\n else\n @listener.receive_message(message)\n end\n end",
"def on_message(delivery, message)\n # Print received message\n if @log_msgs == \"body\"\n Formatters::BasicFormatter.new(message).print\n elsif @log_msgs == \"dict\"\n Formatters::DictFormatter.new(message).print\n end\n # If process reply to\n if @process_reply_to and !message.reply_to.nil?\n self.do_process_reply_to(message)\n end\n # Increase number of received messages\n @received = @received + 1\n # If all messages are received\n if @received == @count\n # Close receiver\n delivery.receiver.close\n # Close connection\n delivery.receiver.connection.close\n end # if\n end",
"def init_message_listener\n begin\n message = @client.gets\n init_message(message)\n end until @client.closed?\n end",
"def on_message_data_receiving_event(ctx) end",
"def on_newmessage(time, userid, username, msg)\n end",
"def on_message(&handler)\n @on_message_handler = handler\n end",
"def listen_for_messages\n @queue.subscribe do |_delivery_info, _metad5ata, payload|\n data = JSON.parse(payload)\n display_message(data['user'], data['message'])\n end\n end",
"def on_msg(msg)\n\n on_message(false, msg)\n end",
"def message_received(&callback)\n @connectivity_checker.message_received(&callback)\n end",
"def receive(message)\n info(\"[Emailvision] Receive -> #{message}\")\n end",
"def receive(websocket_message); end",
"def message(user, message, virtual = false)\n dispatch :received_message, :user => user, :message => message, :target => self unless virtual\n end",
"def receive_object message\n transition_on_recv message_name(message), message\n end",
"def receive_message\n true\n end",
"def on_message_data_event(ctx); end",
"def message_callbacks\n @messagecbs\n end",
"def create_message_event\n this = self\n socket.on(:message) { |msg| this.handle_message(msg) }\n end",
"def observe_events(client)\n return unless enable_listener?\n queue = create_queue(client)\n client.subscribe(queue) do |message|\n event = Event.parse(message)\n handle_event(event)\n end\n end",
"def on_message_data_event(ctx) end",
"def message(event)\n msg = JSON.parse(event.data, :symbolize_names => true) rescue {}\n seq = msg[:message_sequence]\n if msg[:ping] == 'PING'\n Firehose.logger.debug \"WS ping received, sending pong\"\n @ws.send JSON.generate :pong => 'PONG'\n elsif !@subscribed && seq.kind_of?(Integer)\n Firehose.logger.debug \"Subscribing at message_sequence #{seq}\"\n subscribe seq\n end\n end",
"def message_received(type, from, text, time = nil)\n msg = message_db.add(\n type: type,\n to: type == :message ? username : nil,\n from: from,\n text: text,\n time: time\n )\n signal_change(type, msg)\n end",
"def received\n @received ||= message.received\n end",
"def on_client_connect(client)\n end",
"def did_receive_channel_message(stem, sender, channel, msg)\n end",
"def event_incoming_clients_control(client, cmd, *args)\nend",
"def listen(client)\n loop do\n begin\n message = client.receive\n rescue Exception => e\n STDERR.puts \"Error: #{e.message}\"\n return\n end\n\n case message\n when :EOF\n return\n when :SKIP\n next\n when JoinRoom\n created, reason = create_or_join_room message[:name], client\n if created\n client.send Success.build(\"Joined #{message[:name]}.\")\n else\n client.send Error.build(reason)\n end\n when RequestRoomList\n room_list = @client_info_lock.synchronize { @rooms.keys.dup }\n client.send RoomList.build(room_list)\n when LeaveRoom\n left, reason = leave_room message[:name], client\n if left\n client.send Success.build(\"Left #{message[:name]}.\")\n else\n client.send Error.build(reason)\n end\n when RequestRoomMemberList\n client.send room_members(message[:name])\n when Say\n speak(message[:room], message[:message], client)\n room = message[:room]\n when Disconnect\n return\n when Whisper\n recipient, message = whisper(message[:to], client, message[:message])\n recipient.socket.send message\n else\n STDOUT.puts \"[Debug] unrecognized message received:\"\n p message\n end\n end\n end",
"def trigger_on_message(msg); @app.on_message(msg); end",
"def listen_for_user_messages(username, client)\n loop {\n msg = client.gets.chomp\n # send a braodcast message, a message for all connected users, but not to self\n @connections[:clients].each do |other_name, other_client|\n unless other_name == username\n other_client.puts \"#{username}: #{msg}\"\n end\n end\n }\n end",
"def receive_message\n #$>.puts \"Received complete message\"\n true\n end",
"def process_msg_from_client ws, ws_context, msg\n if !ws_context[:registered]\n ws.close\n return\n end\n if ws_context[:type] != 'client'\n return\n end\n if msg[:command]\n # a command from client\n @console_service.command(msg[:command], msg[:module_id], msg[:body]) { |err, res|\n if is_request? msg\n if resp = compose_response(msg, err, res)\n ws.send ['client', resp].to_json\n end\n else\n # notify should not have a callback\n end\n }\n else\n # a request or a notify from client\n @console_service.execute(msg[:module_id], :client_handler, msg[:body]) { |err, res|\n if is_request? msg\n if resp = compose_response(msg, err, res)\n ws.send ['client', resp].to_json\n end\n else\n # notify should not have a callback\n end\n }\n end\n end",
"def on_server_response(connection, message)\n end",
"def on_incoming_message(msg)\n type = msg.operation\n debug \"(#{id}) Deliver message '#{type}': #{msg.inspect}\"\n htypes = [type, :message]\n if type == :inform\n # TODO keep converting itype is painful, need to solve this.\n if (it = msg.itype(:ruby)) # format itype as lower case string\n case it\n when \"creation_ok\"\n htypes << :create_succeeded\n when 'status'\n htypes << :inform_status\n end\n\n htypes << it.to_sym\n end\n end\n\n debug \"(#{id}) Message type '#{htypes.inspect}' (#{msg.class}:#{msg.cid})\"\n hs = htypes.map { |ht| (@handlers[ht] || {}).values }.compact.flatten\n debug \"(#{id}) Distributing message to '#{hs.inspect}'\"\n hs.each do |block|\n block.call msg\n end\n if cbk = @context2cbk[msg.cid.to_s]\n debug \"(#{id}) Distributing message to '#{cbk.inspect}'\"\n cbk[:last_used] = Time.now\n cbk[:block].call(msg)\n end\n end",
"def listen_for_messages\n queue = @channel.queue(\"\")\n\n queue.bind(@exchange).subscribe do |delivery_info, metadata, payload|\n data = JSON.parse(payload)\n display_message(data['user'], data['message'])\n end\n end",
"def on_message(content, client)\n id = content['text'].split(' ').first\n\n id.gsub!(':', '')\n\n return unless id == \"<@#{@bot_id}>\"\n\n OutputLogger.logger.info 'Message to bot detected, redirecting to bot class...'\n\n reply = Bot.process(content, @bot_id)\n\n client.send reply\n\n OutputLogger.logger.info 'Bot message replied'\n end",
"def receive_data data\n rdata = data.split(\"\\n\")\n rdata.each do |line|\n puts \"#{self} received <<< #{line}\"\n # the echo part\n send_data \">>>you sent: #{line}\\n\"\n # Close the connection when the client tells us to.\n close_connection if line =~ /quit/i\n end\n end",
"def receive(data)\n puts \"messages:#{params[:room]} received #{data} from #{current_user}\"\n # we can relay the received message without the model if we want.\n # ActionCable.server.broadcast(\"messages\", data)\n end",
"def on_message(pattern, event, message)\n _, message = event.split(\":\")\n unless message == self.identity\n @logger.debug({context: :monitor, pattern: pattern, event: event, message: message}.to_json)\n data = @client.hgetall(fnamespace)\n self.set(namespace, value)\n end\n end",
"def on_message(raw_event, _sentry_span)\n Rails.logger.debug { \"#{Time.zone.now.getutc.inspect}: Receiving from #{@socket.url}: #{raw_event.data.inspect}\" }\n event = decode(raw_event.data)\n return unless BACKEND_OUTPUT_SCHEMA.valid?(event)\n\n event = event.deep_symbolize_keys\n message_type = event[:type].to_sym\n if WEBSOCKET_MESSAGE_TYPES.include?(message_type)\n __send__(\"handle_#{message_type}\", event)\n else\n @error = Runner::Error::UnexpectedResponse.new(\"Unknown WebSocket message type: #{message_type}\")\n close(:error)\n end\n end",
"def listen_user(client)\n\t\tloop do\n\t\t\t# Revisamos si la conexion se cerro\n\t\t\tbreak if client.eof?\n\t\t\t# optenemos el mensaje del cliente\n\t\t\tmessage = client.gets.chomp\n\t\t\t# Revisamos si es un mensaje\n\t\t\tif message[0] == \"r\"\n\t\t\t\tbroadcast_message(message, client)\n\t\t\telse\n\t\t\t\t# lo retransmitimos a todos los demas clientes\n\t\t\t\tbroadcast(message)\n\t\t\tend\n\t\tend\n\tend",
"def subscribe(&onMessage) # block\n end",
"def event_incoming_client_control(client, peer, cmd, *args)\nend",
"def sendMsgCallBack(msg, client)\n message_arr = msg.getMessage().split(\" \")\n \n # Removes and stores the src and dst from the message\n src = message_arr.shift()\n dst = message_arr.shift()\n to_print = \"SNDMSG: %s --> %s\"\n\n # If the destination reached the right host, it will print out the correct message\n # If not, it will forward it to the next client\n if dst == $hostname\n message_arr = message_arr.join(\" \")\n STDOUT.puts(to_print % [src, message_arr])\n else\n k = $next[dst]\n forward_client = $clients[k]\n sendMessage(forward_client, msg)\n end\nend",
"def receive_line line\n message = IRCParser::Message.parse line\n\n @network.got_message message\n end",
"def on_message_call handler\n @@handler_symbol = handler\n end",
"def receive(websocket_message) # :nodoc:\n send_async :dispatch_websocket_message, websocket_message\n end",
"def on_message(event)\n data = if @inflate\n packed = event.data.pack('c*')\n @inflate << packed\n return unless packed.end_with?(ZLIB_SUFFIX)\n\n @inflate.inflate('')\n else\n event.data\n end\n\n LOGGER.debug { \"[IN] #{data[0].ord == 131 ? data.inspect : data}\" }\n emit(:message, data)\n end",
"def receive_message(message)\n Pantry.logger.debug(\"[#{identity}] Received message #{message.inspect}\")\n\n if message_meant_for_us?(message)\n @last_received_message = message\n results = @commands.process(message)\n\n if message.requires_response?\n Pantry.logger.debug(\"[#{identity}] Responding with #{results.inspect}\")\n send_results_back_to_requester(message, results)\n end\n else\n Pantry.logger.debug(\"[#{identity}] Message discarded, not for us\")\n end\n end",
"def subscribe &handler\n input = \"\"\n response = 0\n #wait for message from pull socket\n while true\n response = @pull.recv_string(input)\n if !error?(response)\n input.chomp!\n\n #Message received\n yield input if block_given?\n Communicator::get_logger.info \"Message received: #{input}\"\n end\n end\n end",
"def on_pre_msg(msg)\n\n on_message(true, msg)\n end",
"def receive_message\n @@parms[:verbose] and $>.puts \"Received complete message\"\n true\n end",
"def received(data)\n RequestsChannel.broadcast_to(@request, {request: @request, users: @request.users, messages: @request.messages})\n end",
"def on_open(client)\n client.subscribe \"chat\"\n # let everyone know we arrived\n client.publish \"chat\", \"#{@name} entered the chat.\"\n end",
"def message_received(jid,text)\n debug \"message received from #{jid}\"\n window = message_window_for(jid)\n window.window.show\n debug \"add msg\"\n window.add_message(text)\n end",
"def recvmessage\n line = @socket.readline\n JSON.parse(line)\n end",
"def broadcast message\n @clients.keys.each do |key|\n notify key, message\n end\n end",
"def recv_callback\n @recv_callback ||= Proc.new {|message|}\n end",
"def listener message\n p message\n case message.downcase\n # add own messages\n when \"start\"\n puts 'Starting'\n when \"end\"\n puts 'Ending'\n stop\n exit 0\n else\n puts \"unknown message:#{message}\"\n end\n publish \"ack\"\n end",
"def on_packet(client_id, data, channel)\n handle_connection(client_id, data, channel)\n end",
"def on_message data\n\t\t\tbroadcast :_push, data\n\t\t\t_push \"your message was sent: #{data.to_s}\"\n\t\tend",
"def receive_data data\n # The first message from the user is its name\n @name ||= data.strip\n\n @@connections.each do |client|\n # Send the message from the client to all other clients\n client.send_data \"#{@name} says: #{data}\"\n end\n end",
"def on_message(message)\n search_for = message.event.split(\"/\")\n raise InvalidBackendEvent(message.event) if search_for.size < 2\n klass = @handlers[search_for[0]] and handler = klass.method(search_for[1])\n raise UndefinedHandler.new(message.event) unless handler\n logger.info(\"#{message.event}, #{message.inspect}\")\n handler.call(message)\n end",
"def on_bytes(ev)\n\t\tclient = @clients[ev.src_addr]\n\t\t# client can only be 0 if it's a connect packet\n\t\tpost_event bytes_to_event(client,ev.bytes)\n\tend",
"def handle_client(client)\n unless @reactor.address_allowed? client.ip\n client.close\n @log.warn { \"Terminated connection from unauthorized client #{client.ip}\" }\n return\n end\n\n client.say(\"ChainReactor v#{VERSION}\")\n\n client_string = ''\n while l = client.read\n client_string += l\n end\n\n @log.debug { \"Read from client #{client.ip}: #{client_string}\" }\n @log.info { \"Finished reading from client #{client.ip}, closing connection\" }\n\n client.close\n\n @reactor.react(client.ip,client_string)\n\n end",
"def on_message(params={}, &proc)\n raise(ArgumentError, 'MessageConsumer::on_message requires a code block to be executed for each message received') unless proc\n\n # Turn on Java class persistence: https://github.com/jruby/jruby/wiki/Persistence\n self.class.__persistent__ = true\n\n @listener = JMS::MessageListenerImpl.new(params, &proc)\n self.setMessageListener(@listener)\n end",
"def handle_subscribe(client, data)\n topic = @engine.subscribe_client_to_topic client, data[0]\n\n trigger(:subscribe, client, topic.uri)\n end",
"def receives_messages\n Messenger.resolve(@@default_messenger).add_message_handler do |message|\n new.received(message)\n end\n end",
"def receive_line (line)\n msg = Message.decode line\n \n receive_message msg\n end",
"def on_readable socket, messages\n @on_read.call messages, socket\n end",
"def on_message(msg); @parent.on_message(@env, msg); end",
"def do_recv()\n data = super()\n message = Hurricane::Message.new()\n message.type = data.data[0].name\n message.destination = data.data[1]\n message.tag = data.data[2]\n message.data = data.data[3]\n message\n end",
"def handle_client_events\n lambda do |envelope|\n m = envelope.message\n case m['event']\n when 'answer'\n handle_question_answer(m['auth_key'], m['data']['answer_id'])\n end\n end\n end",
"def handle_message(request, message)\n #\n end",
"def receive_message(message, socket)\n if message == \"READ\"\n process_outbox\n return\n end\n\n if message == \"GAME_SERVER\"\n destroy_socket(socket)\n return\n end\n\n socket_id = @sockets[socket]\n log_message(\"Received message from socket #{socket_id} : #{message}\")\n pass_message(message, socket)\n end",
"def message( msg, sender )\n @clients.each do |client|\n client.sock.puts \"#{sender}: #{msg}\" unless sender.port == client.port\n end\n log( \"[message] #{sender}: #{msg}\" )\n end",
"def on_request(client)\n @logger.debug \"Client connected, waiting for data from client\"\n\n while(request = read_bson_document(client)) do\n @logger.debug \"\\n****************** Received request\"\n @logger.trace 'Request', request\n break unless request\n\n if reply = on_message(request)\n @logger.debug \"Sending Reply\"\n @logger.trace 'Reply', reply\n client.print(BSON.serialize(reply))\n else\n @logger.debug \"Closing client since no reply is being sent back\"\n @server.close\n client.close\n @logger.debug \"Server closed\"\n #@thread.kill\n @logger.debug \"thread killed\"\n start(2000)\n @logger.debug \"Server Restarted\"\n break\n end\n end\n # Disconnect from the client\n client.close\n @logger.debug \"Disconnected from the client\"\n end"
] |
[
"0.7980777",
"0.7830214",
"0.7153363",
"0.71166396",
"0.70058095",
"0.7004378",
"0.699422",
"0.69365674",
"0.693363",
"0.6925809",
"0.6923524",
"0.691046",
"0.6851135",
"0.6838108",
"0.67898184",
"0.67717254",
"0.675263",
"0.67518604",
"0.67455953",
"0.6707072",
"0.66267747",
"0.66223174",
"0.6615062",
"0.65972584",
"0.65961754",
"0.65714604",
"0.65633875",
"0.6554036",
"0.65354306",
"0.6527889",
"0.6523924",
"0.64859354",
"0.646164",
"0.64477086",
"0.6445844",
"0.6445469",
"0.64016485",
"0.636379",
"0.63594055",
"0.63517153",
"0.6334284",
"0.6327927",
"0.631686",
"0.6288431",
"0.62725735",
"0.6263087",
"0.62570095",
"0.6256659",
"0.6253685",
"0.6249554",
"0.6244713",
"0.6242789",
"0.6240246",
"0.6230736",
"0.62214386",
"0.62168914",
"0.6179215",
"0.61791146",
"0.6173073",
"0.6147238",
"0.61336297",
"0.6130941",
"0.61279637",
"0.61223143",
"0.61194813",
"0.6107359",
"0.6105292",
"0.6097549",
"0.6092899",
"0.6058521",
"0.6044591",
"0.6027668",
"0.60268515",
"0.60169035",
"0.6015362",
"0.6013426",
"0.6009279",
"0.60080993",
"0.59999746",
"0.59992",
"0.59921235",
"0.59890664",
"0.5984657",
"0.5984564",
"0.59685934",
"0.5967576",
"0.59631014",
"0.59619224",
"0.59552926",
"0.5954754",
"0.59530294",
"0.5941495",
"0.5941339",
"0.5940536",
"0.5933586",
"0.5931379",
"0.5913102",
"0.59077454",
"0.589434",
"0.5893998",
"0.5877688"
] |
0.0
|
-1
|
Fired when a client is disconnected.
|
def on_error(error); @parent.on_error(@env, error); end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def client_disconnected\n end",
"def on_disconnect(client_id)\n @client_manager.remove(client_id)\n end",
"def on_disconnect(socket)\n Utils.logger.info(\"[Client Disconnected: #{socket.inspect}]\")\n end",
"def client_disconnected\n puts \"client #{current_user.email} disconnected\"\n current_player = current_user.player\n broadcast_message :player_exit, {\n id: current_player.id\n }\n current_player.is_online = false\n current_player.save\n end",
"def on_disconnect_event(ctx)\n logger.debug(\"Client disconnect from #{ctx[:server][:remote_ip]}:#{ctx[:server][:remote_port]}\")\n end",
"def on_disconnect(&callback)\n @disconnect_cb = callback\n @client.on_disconnect(&callback) unless @client.nil?\n end",
"def on_disconnect(connection, server, reason = nil)\n end",
"def on_disconnected\n end",
"def disconnecting(clientPort)\n remove_client( clientPort )\n super\n end",
"def on_disconnect_event(ctx)\n carterdte_logger.info(\"Disconnect from #{ctx[:server][:remote_ip]}\")\n end",
"def socket_disconnected\n end",
"def on_shutdown\n logger.debug \"Disconnecting user: #{@user} from channel: #{@channel}.\"\n @@connections[@channel].delete(@user)\n end",
"def on_client_close(client)\n end",
"def local_disconnect(body)\n @connection.disconnect\n _network_init\n _notice \"disconnected\", :global\nend",
"def on_disconnect(&callback)\n @disconnect_cb = callback\n end",
"def disconnect\n puts \"Disconnecting MCollective client...\"\n @mc.disconnect\n end",
"def disconnect\n @thread.exit\n @client.disconnect\n @channels.clear\n end",
"def disconnect\n @server = nil\n @status = :disconnected\n end",
"def disconnect\n begin\n @log.info \"Closing '#{@username}' session\"\n @client.close\n @log.info \"Session closed\"\n rescue\n @log.error \"Error disconnecting '#{@username}': #{$!}\"\n end\n end",
"def on_close(ws)\n client = @clients.find{|c| c[:ws] == ws}\n if client\n logger.info \"node #{client[:id]} connection closed\"\n unplug_client(client)\n else\n logger.debug \"ignore close of unplugged client\"\n end\n rescue => exc\n logger.error \"on_close: #{exc.message}\"\n logger.error exc.backtrace.join(\"\\n\") if exc.backtrace\n end",
"def on_close\n websocket_client.on(:close) do |event|\n p [:close, event.code, event.reason]\n end\n end",
"def on_disconnect(&handler)\n @on_disconnect = handler\n end",
"def on_close client\n controller(client).on_close\n end",
"def disconnect(message, local = false, &callback)\n response = make_response(message)\n client_id = message['clientId']\n\n @engine.client_exists(client_id) do |exists|\n response['error'] = Error.client_unknown(client_id) unless exists\n response['error'] = Error.parameter_missing('clientId') if client_id.nil?\n\n response['successful'] = response['error'].nil?\n response.delete('clientId') unless response['successful']\n\n @engine.destroy_client(client_id) if response['successful']\n callback.call(response)\n end\n end",
"def disconnections_handler(id)\n\t# show who left\n\tputs \"#{@clients[id][:ip]} with ID #{id} disconnected\"\n\t# delete its entry in the clients hash\n\t@clients.delete_if {|key, value| key == id }\n\t# sends a packet to all clients informing about the disconnection (data, reliable or not, channel ID)\n\t@server.broadcast_packet(\"#{id} disconnected\", true, 1)\nend",
"def disconnect\n info 'closing connection to host'\n @connected = false\n end",
"def destroy_client(client_id, &callback)\n @connected.delete(client_id)\n @subscriptions.remove(client_id).each do |channel|\n @channels.remove(channel, client_id)\n end\n @messages.remove(client_id)\n @server.debug 'Destroyed client ?', client_id\n @server.trigger(:disconnect, client_id)\n @events.publish(\"disconnect:#{client_id}\")\n callback.call if callback\n end",
"def disconnect_client(data, client)\n info \"disconnecting: '#{data}\"\n data += client.gets # PORT\n data += client.gets # CLIENT_NAME\n info \"got data: '#{data}'\"\n\n client_name = data.scan(/CLIENT_NAME:(..\\w+)/).first[0].strip\n info \"client_name: '#{client_name}'\"\n\n @chat_room.remove_client(client_name)\n end",
"def disown client_handler\n name = client_handler.name\n \n # No need to disown if they're not present.\n # ⎛I realize this is not strictly threadsafe. ⎞\n # ⎝At this point, I also don't particularly care.⎠\n connectedHandler = @circle.get name\n return unless client_handler.equal? connectedHandler\n \n @circle.remove name\n \n \n # Broadcast their departure:\n # (Name may be THE EMPTY STRING if the user never successfully logged in.)\n if name.length > 0\n self.send_public(\n TiscapTransmission.new(:']disconnected', name, nil),\n nil)\n end\n end",
"def on_disconnected( fd, endpoint )\n\t\t\tself.log.debug \"Client socket on FD %d disconnected\" % [ fd ]\n\t\tend",
"def unbind()\n @connected = false\n Skates.logger.debug {\n \"DISCONNECTED\"\n } # Very low level Logging\n begin\n @handler.on_disconnected() if @handler and @handler.respond_to?(\"on_disconnected\")\n rescue\n Skates.logger.error {\n \"on_disconnected failed : #{$!}\\n#{$!.backtrace.join(\"\\n\")}\"\n }\n end\n end",
"def disconnect(kerb_client = client)\n kerb_client.close if kerb_client\n\n if kerb_client == client\n self.client = nil\n end\n end",
"def unbind\n client = $clients_list.delete(self.object_id)\n \n $clients_list.values.each do |c|\n send_client_disconnect(c, client) if c.socket != self\n end\n \n end",
"def websocket_connection_close(ws, client)\n ws.on :close do |event|\n Services::Clients.collection.delete(client)\n ws = nil\n end\n end",
"def disconnect()\r\n @callbacks.each { |block| block.call }.clear()\r\n @conn.close if @conn\r\n @conn = nil\r\n end",
"def remove_client(client)\n session_id = @connections[:clients].key(client)\n @connections[:clients].delete(session_id)\n bixsby_print \"Client #{client.peeraddr.last} disconnected.\" \n end",
"def unbind\n puts \"connection #{@connection.id.to_s} unbound\"\n begin\n unless !@registered\n self.unregister(@user.uuid)\n $ws_notifier.call(\"#{@user.uuid} just left the server\",\"disconnection\")\n else\n puts \"Never registered. So don't try to kill connection data\"\n end\n rescue\n puts \"Error (unbind). Couldn't delete from hash\"\n end\n puts \"Person is no longer connected\"\n end",
"def on_shutdown client\n controller(client).on_shutdown\n end",
"def unbind\n puts \"client a connection has terminated\"\n EventMachine::stop_event_loop() \n end",
"def disconnect!\n @client&.close\n rescue StandardError\n nil\n end",
"def disconnecting?; connection_state == :disconnecting end",
"def on_shutdown(client)\n client.write \"Server shutting down. Goodbye.\"\n end",
"def disconnect\n # Implement in subclass\n end",
"def event_connection_reset(client, msg)\n # Don't send out this notification if they're connected elsewhere\n return nil unless @clients.select do |_,c|\n c.name == client.name and c != client\n end.empty?\n select_send(MSG_SERVER, EMPTY_ROOM, @keyring.default.iv,\n server_encrypt(\"presence offline #{client.name}\" +\n \"12345678#{msg}\")\n ) { |x| x.name }\n\n # Remove this user from any rooms they may be connected to.\n @rooms.each { |_,list| list.reject! { |x| x == client.name } }\nend",
"def disconnected?; connection_state == :disconnected end",
"def on_closed(&block)\n define_callback :disconnect, &block\n end",
"def disconnected!\n disconnected(:aborted)\n end",
"def disconnect!\n disconnect\n end",
"def disconnect\n send_packet(MQTT::Packet::Disconnect.new)\n @state = :disconnected\n close_connection_after_writing\n end",
"def on_disconnect\n # Let others know that the user left\n broadcast :_send_message, {event: :chat, from: '', at: Time.now, message: \"#{params[:name]} left the chatroom.\"}.to_json if params[:name]\n end",
"def disconnect!\n end",
"def destroy\n @client.client.disconnect\n end",
"def disconnect\n @connection.logout\n end",
"def on_close(event)\n logger.debug 'Socket closed'\n @connected = false\n @socket = nil\n dispatch('command' => 'session_ended')\n end",
"def on_close(event)\n logger.debug 'Socket closed'\n @connected = false\n @socket = nil\n dispatch('command' => 'session_ended')\n end",
"def disconnect!\n @connection.logoff rescue nil\n end",
"def disconnect\n @on_disconnected.call if @on_disconnected\n @enable_reconnection = false\n @ws.close\n end",
"def delete_user\n \tputs 'Delete user action'\n users = connection_store.collect_all(:chat_users)\n WebsocketRails[:chatroom].trigger(:client_disconnected, users.to_json) \n end",
"def disconnect\n end",
"def disconnect\n end",
"def unbind\n log.debug { \"Disconnected.\" }\n callback :disconnected\n EM.add_timer(@connection_attempts) do\n @connection_attempts += 1\n reconnect(@host, @port)\n post_init\n end\n end",
"def disconnect_server(server)\n run_script('disconnect', server)\n end",
"def disconnect()\n @connection.stop()\n @timer.stop()\n @broadcast.stop()\n end",
"def disconnect!; end",
"def handle_disconnect *args\n args.each do |c|\n host, port = *c.split(\":\")\n conn = @node.connections.select{|c| c.host == host && c.port == port.to_i}.first\n conn.close_connection if conn\n end\n {:state => \"Disconnected\"}\n end",
"def handle_disconnect( request )\n\t\tself.log.info \"Connection %p closed.\" % [ request.conn_id ]\n\t\treturn nil\n\tend",
"def on_close(env)\n @subscription.delete if @subscription\n logger.debug \"WebSocket closing connection\"\n end",
"def disconnect\n @comm.disconnect(delete_affiliations: true)\n logger.info \"Disconnecting #{hrn}(#{uid}) in #{DISCONNECT_WAIT} seconds\"\n EM.add_timer(DISCONNECT_WAIT) do\n @comm.disconnect\n end\n end",
"def unbind\n raise NoConnection unless @connected\n @client.receive_data @error if @error\n @client.unbind\n end",
"def unbind\n raise NoConnection unless @connected\n\n# @keepalive.cancel\n @state = :stopped\n @client.receive_data @error if @error\n @client.unbind\n end",
"def unbind\n log.info { (outgoing? && !@connection_completed) ? \"Connection failed\" : \"Disconnected\" }\n @node.push_notification(:connection, {type: :disconnected, host: @host, port: @port})\n @state = :disconnected\n @node.connections.delete(self)\n end",
"def disconnect\n @socket.close\n end",
"def disconnect; end",
"def disconnect; end",
"def disconnect\n @interface.disconnect\n end",
"def disconnected(event = :failed) # :nodoc:\n task.emit(event)\n connection_space.deregister_peer(self)\n\n wait_link_alive_sync.synchronize do\n @connection_state = :disconnected\n @send_queue.clear\n @send_queue.push nil\n @send_thread.join\n @send_queue, @send_thread = nil\n socket.close if !socket.closed?\n @socket = nil\n\n wait_link_alive_cond.broadcast\n end\n\n self.clear\n Distributed.info \"#{self}: disconnected (#{event})\"\n end",
"def on_server_disconnect(obj=nil, &block)\n @on_server_disconnect_obj = obj\n @on_server_disconnect = Proc.new { |handle, obj_ptr|\n yield self, object_for(obj_ptr)\n }\n Klass.set_OnServerDisconnect_Handler(@handle, @on_server_disconnect, pointer_for(obj))\n end",
"def disconnected_callback(callback, &block)\n\t\t\t@disconnected = callback || block\n\t\tend",
"def on_disconnect(obj=nil, &block)\n @on_disconnect_obj = obj\n @on_disconnect = Proc.new { |handle, obj_ptr|\n # On disconnect, we'll need to remove all of our change handlers\n @listeners.each_pair do |pattern, (listener, proc)|\n Klass.remove_OnKeyChange_Handler(listener.get_pointer(0))\n sleep @handler_sleep\n end\n yield self, object_for(obj_ptr)\n }\n Klass.set_OnServerDisconnect_Handler(@handle, @on_disconnect, pointer_for(obj))\n sleep @handler_sleep\n end",
"def close(event)\n if event && !event.target.kind_of?(Faye::WebSocket::Client) then\n logger.debug { \"closed connection from #{event.target.env[\"REMOTE_ADDR\"]} (code=#{event.code}; reason=\\\"#{event.reason}\\\")\" }\n end\n if @connected then\n @connected = false\n @handler.new(nil).disconnect(self)\n end\n end",
"def disconnect\n if @socket\n @socket.close\n @socket = nil\n @authed = false\n end\n end",
"def disconnect\n if @socket\n @socket.close\n @socket = nil\n @authed = false\n end\n end",
"def disconnect \n # If the socket's open, close it \n @logger.info \"Disconnecting from Asterisk Manager...Goodbye!\" \n @socket.close if !@socket.nil?\n \n # Reset flags\n @connected = false\n @logged_in = false\n end",
"def disconnect(message = nil)\n @voice.destroy\n delete_dir\n respond(message) if message\n @voice = nil\n @channel = nil\n rescue => e\n LOGGER.error 'An error occured while trying to leave a server.'\n LOGGER.log_exception e\n end",
"def unbind\n log(:info, :socket, 'disconnected')\n end",
"def disconnected(interface)\n\t\t@status_lock.synchronize {\n\t\t\tstatus_array = @connected_interfaces.delete(interface)\n\t\t\tstatus_array.each do |status_hash|\n\t\t\t\tstatus_hash.delete(interface)\n\t\t\tend\n\t\t\t#\n\t\t\t# TODO::Refactor required\n\t\t\t#\tThis still isn't perfect as we could be observing modules we are not using...\n\t\t\t#\n\t\t}\n\t\tlogger.debug \"-- Interface #{interface.class} disconnected\" unless logger.nil?\n\tend",
"def ignore_disconnect; end",
"def disconnect\n\tend",
"def disconnect_connection(conn)\n sync{@connection_timestamps.delete(conn)}\n super\n end",
"def disconnect\n @connect_state = :disconnected\n true\n end",
"def disconnect_connection(conn)\n sync{@size[0] -= 1}\n super\n end",
"def disconnect\n NWRFCLib.close_connection(@handle, @error)\n NWRFC.check_error(@error)\n end",
"def disconnect(host)\n shutdown\n end",
"def unbind()\n Babylon.logger.debug(\"DISCONNECTED\") # Very low level Logging\n EventMachine::stop_event_loop\n end",
"def unbind\n puts \"Connection terminated #{@my_connection_index}) #{@my_address} - #{@signature}\"\n\n pp self.inspect if error?\n\n # TODO: Remove connection from $connection_list\n end",
"def disconnect\n _logout\n @connection.close\n end",
"def client_quit(socket)\n @connections.delete(socket)\n socket.close\n end",
"def disconnect\n raise \"Not connected. did you forget to call connect?\" unless @_socket\n @_socket.close\n @_socket = nil\n print \"Disconnected\\n\" if @_verbose\n EtherShell::ShellDsl.nothing\n end",
"def shutdown\n client.close\n end",
"def unbind\n $dsock_list.delete self\n\n log :info, \"-- #{@player}:#{@addr}:#{@port} disconnected from CoralMUD!\"\n\n if @player\n @player.socket = nil if @player.socket == self\n\n if @player.in_room\n @player.in_room.display([:visual, \"other.can_see?(actor)\"], @player, [@player], \"<%=other.peek(actor)%> has lost their link.\")\n end\n end\n\n end",
"def disconnect; @connection.close end"
] |
[
"0.8104775",
"0.7987144",
"0.7954314",
"0.7841626",
"0.7655153",
"0.75557977",
"0.7487303",
"0.7256721",
"0.7048306",
"0.7036897",
"0.69862056",
"0.6966162",
"0.69268805",
"0.6912349",
"0.6867656",
"0.6845051",
"0.6843968",
"0.6843021",
"0.6824458",
"0.6819914",
"0.6767762",
"0.6703635",
"0.6701246",
"0.6690466",
"0.66815114",
"0.6646722",
"0.6621443",
"0.65692794",
"0.6562026",
"0.65556324",
"0.65197724",
"0.6518733",
"0.65053374",
"0.6501184",
"0.6498025",
"0.6492564",
"0.6489159",
"0.6488598",
"0.64789873",
"0.64504975",
"0.6408833",
"0.6360572",
"0.63451236",
"0.6344505",
"0.6332519",
"0.6321608",
"0.6312074",
"0.63079345",
"0.6307668",
"0.6304864",
"0.629783",
"0.6280902",
"0.62783295",
"0.62739",
"0.62739",
"0.6270647",
"0.6260858",
"0.6257594",
"0.625519",
"0.625519",
"0.6253036",
"0.6251483",
"0.62484217",
"0.62296593",
"0.6226236",
"0.6191827",
"0.61907405",
"0.6188613",
"0.616302",
"0.6162936",
"0.6154769",
"0.61526793",
"0.61340684",
"0.61340684",
"0.61028373",
"0.61007255",
"0.6097119",
"0.6094787",
"0.60807794",
"0.6076972",
"0.6059282",
"0.6059282",
"0.6056123",
"0.6045378",
"0.60339177",
"0.60329515",
"0.60312545",
"0.60211986",
"0.6015571",
"0.6005311",
"0.59921455",
"0.5978327",
"0.5975533",
"0.59556204",
"0.59329766",
"0.5928498",
"0.59267116",
"0.5918068",
"0.59157175",
"0.59038126",
"0.5900978"
] |
0.0
|
-1
|
Fired when error occurs. Set application as parent and forward options
|
def initialize(parent, options = {})
@parent = parent
@options = options[:backend] || {}
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def on_error(error); @parent.on_error(@env, error); end",
"def setup_application\n error_msg = \"#{self.to_s}: you must override setup_application\"\n raise Backdat::Exceptions::Application, error_msg\n end",
"def fail_to_parent(error)\n @__context__.executor << FlowFiber.new { @parent.fail(self, error) }\n end",
"def run_application\n error_msg = \"#{self.to_s}: you must override run_application\"\n raise Backdat::Exceptions::Application, error_msg\n end",
"def load_application_object_failed(err)\n if @mode == :update\n unsubscribe\n end\n super\n end",
"def redirect\n\t\tlogger.error \"CUSTOM_ERROR: Attempt to connect with bad url extension: #{params[:from]}\"\n\t\tredirect_to root_url\n end",
"def errback &block\n super\n end",
"def errback &block\n super\n end",
"def _roda_handle_main_route\n begin\n res = super\n ensure\n _roda_after(res)\n end\n rescue *opts[:error_handler_classes] => e\n _handle_error(e)\n end",
"def life_cycle_failure(app, cause) ; end",
"def life_cycle_failure(app, cause) ; end",
"def failed_path\n\t\t\t\t\t\tmain_app.root_path\n\t\t\t\t\tend",
"def halt_on_error!(error_code = :bad_request)\n on_error { halt error_code }\n self\n end",
"def place_error_app(app_name, err_msg)\n Djinn.log_info(\"Placing error application for #{app_name} because of: #{err_msg}\")\n ea = ErrorApp.new(app_name, err_msg)\n ea.generate() \n end",
"def exceptions_app=(_arg0); end",
"def exceptions_app=(_arg0); end",
"def set_parent_app\n @parent_app = ParentApp.find(params[:id])\n end",
"def redirect_back\n super(fallback_location: root_path)\n end",
"def set_backtrace(*) end",
"def better_errors_hack\n request.env['puma.config'].options.user_options.delete(:app) if request.env.key?('puma.config')\n end",
"def call_failure_app(env, options = {})\n if config.failure_app\n options.merge!(:attempted_path => ::Rack::Request.new(env).fullpath)\n env[\"PATH_INFO\"] = \"/#{options[:action]}\"\n env[\"warden.options\"] = options\n\n _run_callbacks(:before_failure, env, options)\n config.failure_app.call(env).to_a\n else\n raise \"No Failure App provided\"\n end\n end",
"def set_exit_exception; end",
"def set_backtrace(arg0)\n end",
"def set_event_application\n begin\n @application = EventApplication.find(params[:id])\n rescue\n redirect_to event_applications_path, error: 'Error: Unable to load desired page. Please ensure the URL is valid and try again.'\n end\n end",
"def on_error_go_back(&block)\n begin\n block.call\n rescue => e\n Knj::Web.alert(e.message).back\n end\n end",
"def ensure_application\n redirect_to root_url, alert: \"Application not found\" unless current_application\n end",
"def exceptions_app; end",
"def exceptions_app; end",
"def continue_on_error\n @continue_on_error = true\n end",
"def general_error_redirection(caller,error)\n flash[:danger] = t(:general_error) #Set the error message to the user\n Rails.logger.debug \"*[ERROR] @ #{caller}=> #{error}.\" #Log the error\n Rails.logger.debug \"#{error.backtrace}\"\n redirect_to error_general_error_path #Redirect the user to the generic error page\n end",
"def resume_after_fork_in_parent\n super\n end",
"def failure\n redirect_to root_path\n end",
"def failure\n redirect_to root_path\n end",
"def application_root=(_arg0); end",
"def backtrace_on_error=(val)\n\t\tRequestStore.use_backtraces = val\n\tend",
"def backtrace_on_error=(val)\n\t\tRequestStore.use_backtraces = val\n\tend",
"def handle_error(ex)\n if react_to?(ex)\n begin\n ex.command = self\n ex.react!\n rescue Quickl::Error => ex2\n handle_error(ex2)\n end\n else\n raise ex\n end\n end",
"def error\n\tyield\n\tif @changedConfigDir or @changedConfigFile\n\t\tif @opts[:stealth]\n\t\t\tstealth\n\t\telse\n\t\t\tLog.warn \"Permanent changes to the servers configuration have been made, these will have to be undone to stay hidden\"\n\t\tend\n\tend\n\texit 1\nend",
"def errback(&block)\n super do |*args|\n safe_deferrable_block(*args, &block)\n end\n end",
"def handle_exception(e)\n if e.flags.has_key?(:layout) then\n @_layout = e.flags[:layout]\n end\n\n if e.flags.has_key?(:no_after_filters) then\n @_stop_no_after_filters = true\n end\n\n if e.flags.has_key?(:redirect) then\n @_layout = false\n to = e.flags[:redirect]\n clear\n @_content = \"<!DOCTYPE HTML PUBLIC \\\"-//W3C//DTD HTML 4.0 Transitional//EN\\\"><html><head><title>Redirecting...</title><meta http-equiv=\\\"REFRESH\\\" content=\\\"0;url=#{to}\\\"></HEAD></HTML>\"\n @cancel_execution = true\n end\n\n if e.flags.has_key?(:error) then\n @_layout = false\n http_status \"SERVER_ERROR\"\n clear\n @error_message = e.flags[:error]\n @cancel_execution = true\n trace = ''\n if Cuca::App.config['display_errors'] then\n e.backtrace.each do |b|\n trace<< \"<br/>#{b}\"\n end\n end\n mab { html { body { h2 \"Error\"; text @error_message; br; text trace }}}\n end\n \n if e.flags.has_key?(:cancel_execution) then\n @cancel_execution = true\n end\n end",
"def handle_on_error (msg, error)\n\n return false if h.state == 'failing'\n\n oe_parent = lookup_on_error\n\n return false unless oe_parent\n # no parent with on_error attribute found\n\n handler = oe_parent.on_error.to_s\n\n return false if handler == ''\n # empty on_error handler nullifies ancestor's on_error\n\n workitem = msg['workitem']\n\n workitem['fields']['__error__'] = [\n h.fei, Ruote.now_to_utc_s, error.class.to_s, error.message, error.backtrace ]\n\n @context.storage.put_msg(\n 'fail',\n 'fei' => oe_parent.h.fei,\n 'workitem' => workitem)\n\n true # yes, error is being handled.\n end",
"def abort_on_exception=(_arg0); end",
"def process_with_graceful_fail(cmd, options, *klass); end",
"def recover_from(_error)\n end",
"def original_error; end",
"def original_error; end",
"def _roda_handle_main_route\n super\n rescue Sequel::DatabaseDisconnectError, Sequel::DatabaseConnectionError, PG::ConnectionBad\n Process.kill(:QUIT, $$)\n raise\n end",
"def parent; @options[:parent]; end",
"def call_failure_app(env, opts = {})\n if env['warden'].custom_failure?\n opts[:original_response]\n else\n env[\"PATH_INFO\"] = \"/#{opts[:action]}\"\n env[\"warden.options\"] = opts\n\n # Call the before failure callbacks\n Warden::Manager._before_failure.each{|hook| hook.call(env,opts)}\n\n @failure_app.call(env).to_a\n end\n end",
"def recover_from(_error); end",
"def unrecognized_option(err); end",
"def do_fallback action\n do_redirect fallback_path\n end",
"def create\n @parent_app = ParentApp.new(parent_app_params)\n\n respond_to do |format|\n if @parent_app.save\n format.html { redirect_to @parent_app, notice: 'Parent app was successfully created.' }\n format.json { render action: 'show', status: :created, location: @parent_app }\n else\n format.html { render action: 'new' }\n format.json { render json: @parent_app.errors, status: :unprocessable_entity }\n end\n end\n end",
"def callback_failure\n flash[:error] = I18n.t(:connection_failure)\n\t redirect_to root_url\n\tend",
"def correct_parent\r\n @parent = Parent.find(params[:id])\r\n redirect_to(root_url) unless current_parent?(@parent)\r\n end",
"def on_error error\n raise error\n end",
"def close_app\n abort(\"See you next time!\")\n end",
"def handle_error err, env\n delegate = error_delegate\n\n begin\n delegate.exec(self, env){ handle_error(err) }\n\n rescue ::Exception => err\n delegate = Gin::Controller and retry unless delegate == Gin::Controller\n raise\n end\n end",
"def set_redirect_error_status(status)\n end",
"def setFailOnMainUrlError(fail_on_error)\n @fields['fail_on_main_url_error'] = fail_on_error\n self\n end",
"def add_framework_error(error, source)\n if @application_exceptions\n @application_exceptions << [error, source]\n elsif Roby.app.abort_on_application_exception? || error.kind_of?(SignalException)\n raise error, \"in #{source}: #{error.message}\", error.backtrace\n else\n ExecutionEngine.error \"Application error in #{source}\"\n Roby.format_exception(error).each do |line|\n Roby.warn line\n end\n end\n end",
"def setFailOnMainUrlError(fail_on_error)\n @fields['fail_on_main_url_error'] = fail_on_error\n self\n end",
"def correct_parent\n @parent = Parent.find(params[:id])\n redirect_to(root_url) unless current_parent?(@parent)\n end",
"def error\n @referer = request.env['HTTP_REFERER']\n if session[:params]\n @session_params = session[:params]\n session[:params] = nil\n end\n end",
"def propagate_errors\n propagate_errors_to_file if invite_by_file?\n end",
"def propagate_errors\n propagate_errors_to_file if invite_by_file?\n end",
"def propagate_errors\n propagate_errors_to_file if invite_by_file?\n end",
"def app\n parent.app\n end",
"def on_subshell_error(&block)\n @subshell_error_block = block\n end",
"def handle_failed_option param, value\n @options_ok = false\n end",
"def new\n super do\n flash[:alert] = nil if flash[:from_root_path]\n end\n end",
"def redirect_to(*options)\n target = fallback_action[2]\n if target\n target = controller.instance_exec(*options,&target)\n logger.debug \"redirection path: #{target}\" unless target.blank?\n super(target)\n else\n options.empty? ? super(current_user) : super(*options)\n end\n end",
"def parent_command; end",
"def internal_server_error\r\n redirect_to(request.referrer || root_path, alert: 'Internal Server Error', status: 500)\r\n end",
"def run &block\n begin\n\n # check if user has passed window coord in config, else root window\n @window = Canis::Window.root_window\n awin = @window\n catch(:close) do\n @form = Form.new @window\n #@form.bind_key(KEY_F1, 'help'){ display_app_help } # NOT REQUIRED NOW 2012-01-7 since form does it\n @form.bind_key([?q,?q], 'quit' ){ throw :close } if $log.debug?\n\n #@message = Variable.new\n #@message.value = \"\"\n $status_message ||= Variable.new # remember there are multiple levels of apps\n $status_message.value = \"\"\n #$error_message.update_command { @message.set_value($error_message.value) }\n if block\n begin\n yield_or_eval &block if block_given? \n # how the hell does a user trap exception if the loop is hidden from him ? FIXME\n loop\n rescue => ex\n $log.debug( \"APP.rb rescue reached \")\n $log.debug( ex) if ex\n $log.debug(ex.backtrace.join(\"\\n\")) if ex\n ensure\n close\n # putting it here allows it to be printed on screen, otherwise it was not showing at all.\n if ex\n puts \"========== EXCEPTION ==========\"\n p ex \n puts \"===============================\"\n puts(ex.backtrace.join(\"\\n\")) \n end\n end\n nil\n else\n #@close_on_terminate = true\n self\n end #if block\n end # :close\n end\n end",
"def application=(app)\n @application = app\n end",
"def application=(app)\n @application = app\n end",
"def application=(app)\n @application = app\n end",
"def fail!(error_code, app_code = nil, message = '', metadata = {})\n e = error\n e.code = error_code.to_sym\n e.app_code = app_code ? app_code.to_sym : e.code\n e.message = message.to_s\n e.metadata = metadata\n e.fail!(request.active_call)\n end",
"def onerror(&blk); super; end",
"def update\n respond_to do |format|\n if @parent_app.update(parent_app_params)\n format.html { redirect_to @parent_app, notice: 'Parent app was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @parent_app.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show_errors\n # TODO: Needs to redirect to a root not an index of all clubs\n redirect_to clubs_path\n end",
"def original_exception=(_arg0); end",
"def error_and_exit(dup)\n return if dup == \"none\"\n Chef::Log.info \"#########################\"\n Chef::Log.info \"ERROR: #{dup} is mounted twice!!!\"\n Chef::Log.info \"#########################\"\n exit 1\n end",
"def appname=(appname)\n validate_options(appname: appname)\n @appname = appname\n end",
"def forward\n hastur_error! \"Invalid path: '#{request.path_info}'\", 404\n end",
"def return_to_main\n options = main_path_to_return\n # use url_for in case main_path_to_return returns Hash with status param,\n # which would be interpreted as status option to redirect_to instead of url param\n redirect_to options.is_a?(Hash) ? url_for(options) : options\n end",
"def redirect_after_unsuccessful_authentication\n params_hsh = {}\n params_hsh[:client_app] = params[:client_app] if params[:client_app]\n params_hsh[:redirect_back_url] = params[:redirect_back_url] if params[:redirect_back_url]\n redirect_to add_query_params(default_sign_in_url, params_hsh)\n return\n end",
"def handle_start_child_workflow_execution_failed(event)\n handle_event(event, {\n :id_methods => [:workflow_id],\n :consume_symbol => :handle_initiation_failed_event,\n :decision_helper_scheduled => :scheduled_external_workflows,\n :handle_open_request => lambda do |event, open_request|\n workflow_execution = AWS::Flow::MinimalWorkflowExecution.new(\"\",event.attributes.workflow_id, nil)\n workflow_type = event.attributes.workflow_type\n cause = event.attributes.cause\n failure = StartChildWorkflowFailedException.new(event.id, workflow_execution, workflow_type, cause)\n open_request.completion_handle.fail(failure)\n end\n })\n end",
"def errorhandling\n end",
"def cause; end",
"def cause; end",
"def added_parent_object(parent, relations, info)\n super if defined? super\n return if !relations.include?(ExecutionAgent)\n return if used_as_execution_agent?\n\n ready_event.when_unreachable(true, &ExecutionAgentGraphClass.method(:execution_agent_failed_to_start))\n on :stop, &ExecutionAgentGraphClass.method(:pending_execution_agent_failed)\n\n self.used_as_execution_agent = true\n end",
"def app\n @parent_controller ? @parent_controller.app : self\n end",
"def handle_perform_error(_e); end",
"def delegate\n @app.call(@env)\n end",
"def application\n @application ||= parent.application if parent\n end",
"def on_error reason\n puts reason\n close\n end",
"def handle_errors(interactor)\n interactor.call\n rescue Errors::Base => e\n context.fail!(resource: e, status: e.status)\n end",
"def error_notification(options = T.unsafe(nil)); end",
"def redirect_to_error\n render 'posts/404', :status => 404, :layout => false and return\n end"
] |
[
"0.6660884",
"0.60131544",
"0.59758765",
"0.5908009",
"0.56029403",
"0.558656",
"0.55538",
"0.55538",
"0.55464697",
"0.5507478",
"0.5507478",
"0.54956",
"0.54787934",
"0.54689467",
"0.5429748",
"0.5429748",
"0.5393775",
"0.5366113",
"0.5281812",
"0.5271341",
"0.5264333",
"0.5230746",
"0.52274674",
"0.5208947",
"0.5191562",
"0.51897186",
"0.5186662",
"0.5186662",
"0.5166316",
"0.51476824",
"0.51359373",
"0.5116563",
"0.5116563",
"0.51040107",
"0.5098828",
"0.5098828",
"0.5054381",
"0.5045472",
"0.503219",
"0.5032146",
"0.5030823",
"0.5001682",
"0.49931002",
"0.49755874",
"0.4969813",
"0.4969813",
"0.49667794",
"0.49573627",
"0.49539185",
"0.4951132",
"0.49385622",
"0.4918595",
"0.49095088",
"0.4900807",
"0.4880815",
"0.488057",
"0.48801246",
"0.4869114",
"0.48654827",
"0.48590785",
"0.48563588",
"0.48556647",
"0.4850305",
"0.48470157",
"0.48352772",
"0.48352772",
"0.48352772",
"0.48228014",
"0.4816449",
"0.48067462",
"0.4799696",
"0.47916692",
"0.4791221",
"0.47736955",
"0.47730148",
"0.47729856",
"0.47729856",
"0.47729856",
"0.477273",
"0.47687608",
"0.47546148",
"0.4743453",
"0.47354984",
"0.47341016",
"0.4731046",
"0.47300935",
"0.4727941",
"0.47252697",
"0.4722839",
"0.4717093",
"0.47140917",
"0.47140917",
"0.4701957",
"0.46968508",
"0.46930328",
"0.46924642",
"0.46906912",
"0.46896386",
"0.46871093",
"0.4682681",
"0.46770582"
] |
0.0
|
-1
|
Creates a task that uses the various template wrappers to make a wrapped output file. There is some extra complexity because Dojo and YUI use different final locations.
|
def templated_build(name, opts={})
short = name.downcase
source = File.join("wrappers", short)
dependencies = ["mustache.js"] + Dir.glob("#{source}/*.tpl.*")
target_js = opts[:location] ? "mustache.js" : "#{short}.mustache.js"
CLEAN.include(opts[:location] ? opts[:location] : target_js)
desc "Package for #{name}"
task short.to_sym => dependencies do
puts "Packaging for #{name}"
mkdir_p opts[:location] if opts[:location]
files = [
"#{source}/mustache.js.pre",
'mustache.js',
"#{source}/mustache.js.post"
]
open("#{opts[:location] || '.'}/#{target_js}", 'w') do |f|
files.each {|file| f << File.read(file) }
end
puts "Done, see #{opts[:location] || '.'}/#{target_js}"
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def templated_build(name, opts={})\n short = name.downcase\n source = File.join(\"wrappers\", short)\n dependencies = [\"mustache.js\"] + Dir.glob(\"#{source}/*.tpl.*\")\n target_js = opts[:location] ? \"mustache.js\" : \"#{short}.mustache.js\"\n\n CLEAN.include(opts[:location] ? opts[:location] : target_js)\n\n desc \"Package for #{name}\"\n task short.to_sym => dependencies do\n puts \"Packaging for #{name}\"\n\n mkdir_p opts[:location] if opts[:location]\n\n files = [\n \"#{source}/mustache.js.pre\",\n 'mustache.js',\n \"#{source}/mustache.js.post\"\n ]\n\n open(\"#{opts[:location] || '.'}/#{target_js}\", 'w') do |f|\n files.each {|file| f << File.read(file) }\n end\n\n puts \"Done, see #{opts[:location] || '.'}/#{target_js}\"\n end\nend",
"def create_from_task_template\n File.open(file_path, 'w') do |f|\n f.puts build_task_template\n end\n end",
"def build_task_template\n b = binding\n ERB.new(Woro::TaskHelper.read_template_file).result(b)\n end",
"def generate!\n info \"GENERATE\"\n\n f = Generator.new @dbi, @settings, @logger\n xslt = XML::XSLT.new\n xslt.xml = f.generate_root.to_s\n\n default_template_dir = File.dirname(__FILE__) + '/../../data/templates'\n template_dir = @settings['templates'] || default_template_dir\n output_dir = @settings['output']\n\n task \"copy static files\" do\n FileUtils.mkdir_p output_dir\n FileUtils.cp_r Dir[File.join( template_dir, 'static', '*' )], output_dir\n end\n\n begin\n Dir.foreach(template_dir) { |template_file|\n next if template_file =~ /^\\./ || template_file == 'static'\n\n task \"process #{template_file}\" do\n xslt.xsl = File.join( template_dir, template_file )\n File::open( File.join( output_dir, template_file ), 'w') { |f| f.write(xslt.serve) }\n end\n }\n rescue Errno::ENOENT\n warn \"Couldn't find templates directory, fallback to default templates!\"\n template_dir = default_template_dir\n retry\n end\n end",
"def define \n desc @description\n task @name => Array(deps) do\n unless Dir.exist?(@outdir)\n Dir.mkdir(@outdir)\n end\n make_file_list\n @file_list.each do |target|\n js = target.execute\n target_file = File.join(@outdir,File.basename(target.file))\n File.open(target_file, 'w') { |f| f.write(js) }\n end\n end\n\n self\n end",
"def generate_html_task aTask, aPage, aDeps, aRenderOpts = {} #:nodoc:\n dst = File.join('output', aPage.url)\n\n # register subdirs as task deps\n dst.split('/').inject do |base, ext|\n directory base\n aDeps << base\n\n File.join(base, ext)\n end\n\n file dst => aDeps + COMMON_DEPS do\n notify aPage.class, dst\n\n begin\n File.write dst, aPage.render(aRenderOpts)\n rescue Exception\n raise_error \"An error occurred when generating the #{dst.inspect} file\"\n end\n end\n\n task aTask => dst\n CLEAN.include dst\n\n dst\n end",
"def generate()\n objects = []\n\n # generate object file tasks\n files.each do |fname|\n output_file = File.join(@build_dir, File.basename(fname).ext('o'))\n objects.push output_file\n file output_file => [ fname ] do\n get_toolchain().compile( fname, output_file )\n end\n end\n\n # Link object files\n file output_file() => objects do\n get_toolchain().link( objects, output_file() )\n end\n\n # Create top level task\n desc \"Build the #{@name} application\"\n task @name => [ output_file() ]\n end",
"def generate_file(task, &block)\n GenerateFileTask.define_task(task, &block)\n end",
"def generate_rake_tasks\n @rake_tasks = outputs.map do |output, inputs|\n additional_paths = []\n inputs.each do |input|\n\n create_file_task(input.fullpath).dynamic do\n additional_paths += additional_dependencies(input)\n end\n end\n additional_paths.each { |path| create_file_task(path) }\n\n create_file_task(output.fullpath, inputs.map(&:fullpath)) do\n output.create { generate_output(inputs, output) }\n end\n end\n end",
"def generate_bolt_tasks(output_folder)\n target_folder = File.join(output_folder, 'tasks')\n FileUtils.mkpath target_folder\n\n generate_bolt_readme(output_folder)\n\n @config.bolt_tasks.each do |task|\n generate_file(\n name: \"Bolt task #{task.name} (json)\",\n task: task,\n template: 'templates/puppet/bolt~task.json.erb',\n output_folder: output_folder,\n out_file: File.join(target_folder, \"#{task.name}.json\")\n )\n\n generate_bolt_tasks_code(task, output_folder)\n end\n end",
"def add_tool(file, clazz)\n name = File.basename(file).gsub(/.rb$/, '').gsub(/_task/, '')\n doc_file = File.expand_path(File.dirname(file) + \"/#{name}_documentation.rb\")\n content = clazz.new(name, Rake::application).to_rdoc\n\n File.open(doc_file, 'w') do |f|\n f.write content\n end\n\n CLEAN.add(doc_file)\n\n task :package => doc_file\n task :rdoc => doc_file\nend",
"def generate\n template = Template.new\n template.add('timestamp', Time.now.to_s)\n template.add('lib_dir', @lib_dir)\n template.add('bin_dir', @bin_dir)\n template.parse(TEMPLATE)\n end",
"def make_product_wixobj_file_task\n return if Rake::FileTask.task_defined? \"wix/#{name}.wixobj\"\n wixobj = Rake::FileTask.define_task \"wix/#{name}.wixobj\" do |t|\n wix_run 'candle', \"-nologo wix/#{name}.wxs -o #{t.name}\"\n end\n wixobj.comment = \"Create the #{name}.wixobj file\"\n wixobj.enhance [\"wix/#{name}.wxs\"]\n end",
"def make_tasks_in_file(tasknames = [], filepath = '.', task_body = \"\\n\", namespace: '')\n\n indent = \"\"\n filedir = File.dirname(filepath)\n FileUtils.mkdir_p(filedir) unless Dir.exist?(filedir)\n\n File.open(filepath, 'w') do |f|\n unless namespace.empty?\n indent = \" \"\n f.puts namespace_start(namespace)\n end\n\n tasknames.each do |taskname|\n f.puts simple_rake_task(taskname, indent: indent, task_body: task_body)\n end\n\n f.puts namespace_end unless namespace.empty?\n end\n filepath\n end",
"def write_transform_file\n render_template(resource_path(\"doc-transform.erb\"),\n destination: transform_file,\n variables: {\n pathdir: project.install_dir.split(\"/\")[1],\n })\n end",
"def make_product_wxs_file_task\n return if Rake::FileTask.task_defined? \"wix/#{name}.wxs\"\n wxs = Rake::FileTask.define_task \"wix/#{name}.wxs\" do |t|\n template_file = File.join(File.dirname(__FILE__), '..', 'templates', 'product.wxs.erb')\n template_data = File.read template_file\n template = ERB.new template_data\n template_results = template.result send(:binding)\n File.open(t.name, 'w') { |io| io << template_results }\n end\n wxs.comment = \"Create the #{name}.wxs file\"\n wxs.enhance ['wix']\n if Rake::FileTask.task_defined? 'wix/Sourcery.wxs'\n wxs.enhance ['wix/Sourcery.wxs']\n end\n end",
"def file_create(args, &block)\n Rake::FileCreationTask.define_task(args, &block)\nend",
"def create_wrapper!(template_root)\n wrapper = Tempfile.new('lxc-wrapper').tap do |file|\n template = Vagrant::Util::TemplateRenderer.new(\n 'sudoers.rb',\n #:template_root => Vagrant::LXC.source_root.join('templates').to_s,\n #:template_root => \"/usr/share/vagrant/gems/gems/vagrant-lxc-1.1.0/templates\",\n :template_root => template_root,\n :cmd_paths => build_cmd_paths_hash,\n #:pipework_regex => \"#{ENV['HOME']}/\\.vagrant\\.d/gems/gems/vagrant-lxc.+/scripts/pipework\"\n :pipework_regex => \"/usr/share/vagrant/gems/gems/vagrant-lxc.+/scripts/pipework\"\n )\n file.puts template.render\n end\n wrapper.close\n wrapper.path\n end",
"def generate\n template_dir = File.join(File.dirname(__FILE__), \"../templates\")\n proxy_hpp = Generation.render_template template_dir, \"proxies\", \"Task.hpp\", binding\n proxy_cpp = Generation.render_template template_dir, \"proxies\", \"Task.cpp\", binding\n file_proxy_hpp = Generation.save_automatic(project.name, \"/proxies\", \"#{task.basename}.hpp\", proxy_hpp)\n file_proxy_cpp = Generation.save_automatic(project.name, \"/proxies\", \"#{task.basename}.cpp\", proxy_cpp)\n\n forward_hpp = Generation.render_template template_dir, \"proxies\", \"Forward.hpp\", binding\n file_forward_hpp = Generation.save_automatic(project.name, \"proxies\", \"#{task.basename}Forward.hpp\", forward_hpp)\n\n cmake = Generation.render_template template_dir, 'proxies', 'CMakeLists.txt', binding\n Generation.save_automatic(project.name, 'proxies', \"CMakeLists.txt\", cmake)\n \n pc = Generation.render_template template_dir, \"proxies\", \"proxies.pc\", binding\n Generation.save_automatic(project.name, \"proxies\", \"#{project.name}-proxies.pc.in\", pc)\n end",
"def compile_package_task(input, output=input)\n js_tasks = SproutCore::Compiler::Preprocessors::JavaScriptTask.with_input \"packages/#{input}/lib/**/*.js\", \".\"\n SproutCore::Compiler::CombineTask.with_tasks js_tasks, \"#{SproutCore::Compiler.intermediate}/#{output}\"\nend",
"def compile_package_task(input, output=input)\n js_tasks = SproutCore::Compiler::Preprocessors::JavaScriptTask.with_input \"packages/#{input}/lib/**/*.js\", \".\"\n SproutCore::Compiler::CombineTask.with_tasks js_tasks, \"#{SproutCore::Compiler.intermediate}/#{output}\"\nend",
"def build_rake_step\n @rake_task << self.global_config # Open the rake Stek and get General Configuration information\n @rake_task << (self.render self.get_config_template) # get Specific Configuration. Defined in the [tool].rb module file (erb)\n @opt_parser.check_error # stop here if errors found in the configuration\n @rake_task << self.test_validation # step is already done ? Defined in the tool_template.rb file\n @rake_task << (self.render self.tool_template) # get specific Task Code. Defined in the [tool].rb module file (erb)\n @rake_task << self.write_validation # write the check file Defined in the tool_template.rb file\n @rake_task << self.close_step # To close the rake Step Defined in the tool_template.rb file\n end",
"def create_display_template_file(directory)\n html = %{<!-- Template File -->\\n\n<div class=\"myWidget\">Hello World</div>}\n\n File.open(directory, \"w\") do |f|\n f.write(html)\n end\n end",
"def configure_tasks\n super\n all_object_files = []\n all_object_folders = []\n @toolchains.each do |toolchain, sources|\n toolchain.add_include_paths(@api_headers+@configuration_headers)\n object_files, object_folders = toolchain.create_compile_tasks(sources)\n all_object_files |= object_files\n all_object_folders |= object_folders\n end\n\n project_filename = @parent_project.project_name.to_s.gsub(':','-')\n library_files, library_folders = @default_toolchain.create_static_library_tasks(all_object_files, project_filename)\n dependencies = @dependencies+all_object_folders+library_folders+library_files\n\n desc \"Build library '#{@parent_project.project_name}' with configuration '#{@configuration_name}'\"\n new_task = static_library_task @configuration_name => dependencies do |t|\n @post_build.call if @post_build.respond_to? :call\n puts \"built library #{t.name}.\"\n @tests.each do |test|\n if Rake::Task.task_defined? test\n Rake::Task[test].invoke\n else\n $stderr.puts \"warning: Skipping unknown test '#{test}'\"\n end\n end\n end\n new_task.api_headers = @api_headers\n new_task.configuration_headers = @configuration_headers\n new_task.library_files = library_files\n end",
"def cli_execute_make_transform_scaffold\n File.open(File.dirname(__FILE__)+'/data/transform_template.rb.tmpl','r') do |f|\n body = f.readlines.join('')\n body.gsub!('%%timestamp%%',Time.now.strftime(\"%a, %d %b %Y\"));\n body.gsub!('%%app name%%',cli_program_name);\n STDOUT.syswrite body\n end\n end",
"def createTask(project, target)\n task \"#{project}.#{target}\" do\n print \"#######################################################\\n\"\n invokeRake project, target\n end\nend",
"def createTask(project, target)\n task \"#{project}.#{target}\" do\n print \"#######################################################\\n\"\n invokeRake project, target\n end\nend",
"def define_weave_task\n desc \"Weave chunks into HTML\" unless ::Rake.application.last_comment\n ::Rake::Task.define_task(\"codnar_weave\" => @output)\n ::Rake::FileTask.define_task(@output => Rake.chunk_files + Rake.configuration_files(@configurations)) do\n run_weave_application\n end\n end",
"def generate\n proxy_hpp = Generation.render_template \"proxies\", \"Task.hpp\", binding\n proxy_cpp = Generation.render_template \"proxies\", \"Task.cpp\", binding\n file_proxy_hpp = Generation.save_automatic \"proxies\", \"#{task.basename}.hpp\", proxy_hpp\n file_proxy_cpp = Generation.save_automatic \"proxies\", \"#{task.basename}.cpp\", proxy_cpp\n\n cmake = Generation.render_template 'proxies', 'CMakeLists.txt', binding\n Generation.save_automatic('proxies', \"CMakeLists.txt\", cmake)\n \n pc = Generation.render_template \"proxies\", \"proxies.pc\", binding\n Generation.save_automatic \"proxies\", \"#{project.name}-proxies.pc.in\", pc\n end",
"def create_compile_ext_tasks(source_root, dest_root, invoking_task)\n compiled_ext = \"#{source_root}/#{SPECIAL_BUNDLE_NAMES[File.basename(source_root)] || File.basename(source_root)}.bundle\"\n create_copy_file_tasks(FileList[compiled_ext], source_root, dest_root, invoking_task)\n file compiled_ext => FileList[\"#{source_root}/*.c\"] do\n cd source_root do\n `ruby extconf.rb; make >/dev/null 2>&1`\n end\n end\nend",
"def generate( result = TDP.application.result, loader = TDP, engine_class = TDP::Engine)\n\n # Templates defined in tdp files must have actions which evaluate \n # to single quoted strings.\n # Input for the template engine is provided by a blankslate instance\n # evaluation of the action or by loading the corresponding file\n #\n if action\n source = BasicObject.new.instance_eval(&action)\n else\n source = loader.load_template(name)\n end\n engine = engine_class.new(name: name, source: source)\n # Convert and generate with self as context\n engine.convert\n result << engine.generate(self)\n end",
"def generate\n Zip::File.open(@template_path) do |template_zip|\n buffer = Zip::OutputStream.write_buffer do |out|\n template_zip.each do |entry|\n out.put_next_entry entry.name\n if @replaceable_files[entry.name]\n source = entry.get_input_stream.read.sub(/(<w:body>)(.*?)(<w:sectPr)/, \"\\\\1#{@replaceable_files[entry.name]}\\\\3\")\n out.write(source)\n else\n out.write(template_zip.read(entry.name))\n end\n end\n end\n buffer.string\n end\n end",
"def write_erb(source, destination)\n begin\n @task.shell.mute do\n @task.create_file(destination) do\n @project.parse_erb(source)\n end\n end\n rescue Exception => e\n @task.say \"Error while building #{File.basename(source)}:\"\n @task.say e.message + \"\\n\", Thor::Shell::Color::RED\n exit\n end\n end",
"def make_file(tpl_file, dst_file, options, data_files = [], options_processor = nil)\n all_options = make_options(options, data_files)\n options_processor.call(all_options) unless options_processor.nil?\n data = render_file(tpl_file, all_options)\n File.write dst_file, data\n end",
"def makefile\n my_binding = MakefileBinding.new(self).get_binding\n ERB.new(project_type.makefile_template).result(my_binding)\n end",
"def generate_to(control_task, path)\n end",
"def generate(file_name,template,map, overwrite = true)\r\n # make sure the package folder exists\r\n pkg_path = (map['package'] || '').gsub('.','/') \r\n FileUtils.makedirs \"#{target}/#{pkg_path}\"\r\n File.open(\"#{target}/#{pkg_path}/#{file_name}\",'w') do |f|\r\n f << self.process_template(template,map)\r\n log \">> writing #{f.path}\"\r\n end #file\r\n end",
"def initialize(name = nil)\n @tasks = []\n @spec_task = nil\n\n last_desc = ::Rake.application.last_description\n desc nil\n\n yield self if block_given?\n\n if cfndsl_opts\n desc last_desc if last_desc\n task(name || :generate) { |_t, _args| cfndsl_opts[:files].each { |opts| generate(opts) } }\n else\n define_base_tasks(name || :generate, last_desc)\n end\n end",
"def create_rake_files(base_dir)\n\n one_task_fn = File.join(base_dir, 'one_task.rake')\n make_tasks_in_file(['one_task'], one_task_fn) if ok_to_create?(one_task_fn)\n\n another_task_fn = File.join(base_dir, 'another_task.rake')\n make_tasks_in_file(['another_task'], another_task_fn) if ok_to_create?(another_task_fn)\n\n my_tasks_mine_fn = File.join(base_dir, 'my_tasks_all_mine.rake')\n make_tasks_in_file(['task1', 'task2', 'task3', 'task4'], my_tasks_mine_fn, namespace: 'mine') if ok_to_create?(my_tasks_mine_fn)\n\n tasks_run_all_fn = File.join(base_dir, 'other_tasks_run_all.rake')\n make_tasks_in_file(['other_task1_run_me', 'other_task2_run_me', 'other_task3_run_me', 'other_task_not_run_yet'], tasks_run_all_fn) if ok_to_create?(tasks_run_all_fn)\n\n tasks_mixed_duplicates_fn = File.join(base_dir, 'other_tasks_mixed_duplicates.rake')\n make_tasks_in_file(['other_task2_run_me', 'other_task3_run_me'], tasks_mixed_duplicates_fn) if ok_to_create?(tasks_mixed_duplicates_fn)\n\n task2_duplicate_fn = File.join(base_dir, 'task2_duplicate.rake')\n make_tasks_in_file(['task2'], task2_duplicate_fn, namespace: 'mine') if ok_to_create?(task2_duplicate_fn)\n\n task4_duplicate_fn = File.join(base_dir, 'task4_duplicate.rake')\n make_tasks_in_file(['task4'], task4_duplicate_fn, namespace: 'mine') if ok_to_create?(task4_duplicate_fn)\n end",
"def build(wrap = true)\n h = []\n\n h << self.class.start_component_template if wrap\n h << template\n h << self.class.end_component_template if wrap\n\n h = h.join(\"\\n\")\n\n ERB.new(h).result(binding)\n end",
"def file_create(args, &block)\n Rake::FileCreationTask.define_task(args, &block)\n end",
"def generate input_dir, output_dir, templates_dir\n\n backup_output_directory(output_dir)\n metadata = read_input_directory(input_dir)\n create_tree_and_copy_assets(metadata, input_dir, output_dir)\n inflate_content(metadata, metadata, input_dir, output_dir, templates_dir)\n\n # Return metadata, e.g. for RSS Feed\n metadata\n end",
"def render_to_tmp(source)\n basename = File.basename(source)\n output_path = \"tmp/#{basename}\"\n FileUtils.mkdir_p(\"tmp\")\n File.open(output_path, 'w') { |file| file.write(render_tmpl(source, **$vars)) }\n output_path\nend",
"def render_template template_file, out_file = nil # :yield: io\n io_output = out_file && !@dry_run && @file_output\n erb_klass = io_output ? RDoc::ERBIO : ERB\n\n template = template_for template_file, true, erb_klass\n\n if io_output then\n debug_msg \"Outputting to %s\" % [out_file.expand_path]\n\n out_file.dirname.mkpath\n out_file.open 'w', 0644 do |io|\n io.set_encoding @options.encoding\n\n @context = yield io\n\n template_result template, @context, template_file\n end\n else\n @context = yield nil\n\n output = template_result template, @context, template_file\n\n debug_msg \" would have written %d characters to %s\" % [\n output.length, out_file.expand_path\n ] if @dry_run\n\n output\n end\n end",
"def define_codnar_task\n @spec.files.each do |file|\n configurations = Rake.split_configurations(file)\n Codnar::Rake::SplitTask.new([ file ], configurations) unless configurations == []\n end\n Codnar::Rake::WeaveTask.new(\"doc/root.html\", @weave_configurations)\n end",
"def make_msi_file_task\n return if Rake::FileTask.task_defined? \"wix/#{name}.msi\"\n wixobjs = Rake::FileTask.tasks.select { |t| t.name.end_with? '.wixobj' }\n wixobjs.map! { |t| t.name }\n msi = Rake::FileTask.define_task \"wix/#{name}.msi\" do |t|\n wix_run 'light', \"-nologo -sval #{wixobjs.join(' ')} -o #{t.name}\"\n end\n msi.comment = \"Create the #{name}.msi file\"\n msi.enhance wixobjs\n end",
"def build_test_template( design_template, file )\n Rails.logger.info 'design_template_test_helper - build_test_template()'\\\n + ' design_template: ' + design_template.to_s\n\n orig_path = design_template.original_file.path.to_s\n Rails.logger.info 'design_template_test_helper - build_test_template()'\\\n + ' orig_path: ' + orig_path\n\n make_output_folder( design_template )\n FileUtils.cp( file.path.to_s, orig_path )\n end",
"def install_output\n namespace nsprefix do\n task output: [\n :\"#{nsprefix}:init\",\n :\"#{nsprefix}:refresh\"\n ] do |t|\n @before_proc.call(t.name, @tf_dir) unless @before_proc.nil?\n terraform_runner('terraform output')\n @after_proc.call(t.name, @tf_dir) unless @after_proc.nil?\n end\n task output_json: [\n :\"#{nsprefix}:init\",\n :\"#{nsprefix}:refresh\"\n ] do |t|\n @before_proc.call(t.name, @tf_dir) unless @before_proc.nil?\n terraform_runner('terraform output -json')\n @after_proc.call(t.name, @tf_dir) unless @after_proc.nil?\n end\n end\n end",
"def make_sourcery_wixobj_file_task\n return unless Rake::FileTask.task_defined? 'wix/Sourcery.wxs'\n wixobj = Rake::FileTask.define_task 'wix/Sourcery.wixobj' do |t|\n wix_run 'candle', \"-nologo wix/Sourcery.wxs -dSource=wix/src -o #{t.name}\"\n end\n wixobj.comment = 'Create the Sourcery.wixobj file'\n wixobj.enhance ['wix/Sourcery.wxs']\n end",
"def define\n desc \"Create Ruby on Rails plug-in package\"\n task :rails_plugin do\n @dest = \"#@package_dir/#{@name}_#{@version}\"\n makedirs(@dest,:verbose=>false)\n @plugin_files.each do |fn|\n cp(fn, @dest,:verbose=>false)\n add_file(File.basename(fn))\n end\n \n @package_files.each do |fn|\n puts \". #{fn}\" if verbose\n f = File.join(@dest, fn)\n fdir = File.dirname(f)\n unless File.exist?(fdir)\n mkdir_p(fdir,:verbose=>false)\n add_folder(\"#{fdir}/\")\n end\n if File.directory?(fn)\n mkdir_p(f,:verbose=>false)\n add_folder(\"#{fn}/\")\n else\n cp(fn, f, :verbose=>false)\n add_file(fn)\n end\n end\n \n generate_index_files()\n end\n end",
"def build(attrs=nil, filename=nil)\n attrs.each_pair do |key, value|\n send(\"#{key}=\", value)\n end if attrs\n \n @template.filename = filename\n @template.result(binding)\n @_erbout\n end",
"def connect_common_tasks\n desc \"Build the code narrative HTML\"\n ::Rake::Task.define_task(:codnar => \"codnar_weave\")\n desc \"Remove woven HTML documentation\"\n ::Rake::Task.define_task(\"clobber_codnar\") { rm_rf(@output) }\n ::Rake::Task.define_task(:clobber => \"clobber_codnar\")\n end",
"def define\n desc \"Create Rails plug-in package\"\n task :rails_plugin do\n @dest = \"#@package_dir/#{@name}_#{@version}\"\n makedirs(@dest,:verbose=>false)\n @plugin_files.each do |fn|\n cp(fn, @dest,:verbose=>false)\n add_file(File.basename(fn))\n end\n\n @package_files.each do |fn|\n puts \". #{fn}\" if verbose\n f = File.join(@dest, fn)\n fdir = File.dirname(f)\n unless File.exist?(fdir)\n mkdir_p(fdir,:verbose=>false)\n add_folder(\"#{fdir}/\")\n end\n if File.directory?(fn)\n mkdir_p(f,:verbose=>false)\n add_folder(\"#{fn}/\")\n else\n cp(fn, f, :verbose=>false)\n add_file(fn)\n end\n end\n\n generate_index_files()\n end\n end",
"def convert_to_rake()\n object_multitask = prepare_tasks_for_objects()\n archiver = @tcs[:ARCHIVER]\n\n res = typed_file_task Rake::Task::LIBRARY, get_task_name => object_multitask do\n cmd = calc_command_line\n aname = calc_archive_name\n Dir.chdir(@project_dir) do\n FileUtils.rm(aname) if File.exists?(aname)\n# cmd.map! {|c| c.include?(' ') ? \"\\\"#{c}\\\"\" : c }\n rd, wr = IO.pipe\n cmd << {\n :err => wr,\n :out => wr\n }\n sp = spawn(*cmd)\n cmd.pop\n\n consoleOutput = ProcessHelper.readOutput(sp, rd, wr)\n\n process_result(cmd, consoleOutput, @tcs[:ARCHIVER][:ERROR_PARSER], \"Creating #{aname}\")\n\n check_config_file()\n end\n end\n res.tags = tags\n enhance_with_additional_files(res)\n add_output_dir_dependency(get_task_name, res, true)\n\n add_grouping_tasks(get_task_name)\n\n setup_rake_dependencies(res, object_multitask)\n return res\n end",
"def template_for(file); end",
"def create\n file = Tempfile.new(\"onetemplate-#{resource[:name]}\")\n builder = Nokogiri::XML::Builder.new do |xml|\n xml.TEMPLATE do\n xml.NAME resource[:name]\n xml.MEMORY resource[:memory]\n xml.CPU resource[:cpu]\n xml.VCPU resource[:vcpu]\n xml.DESCRIPTION do\n resource[:description]\n end if resource[:description]\n xml.OS do\n resource[:os].each do |k, v|\n xml.send(k.upcase, v)\n end\n end if resource[:os]\n resource[:disks].each do |disk|\n xml.DISK do\n disk.each do |k, v|\n xml.send(k.upcase, v)\n end\n end\n end if resource[:disks]\n resource[:nics].each do |nic|\n xml.NIC do\n nic.each do |k, v|\n xml.send(k.upcase, v)\n end\n end\n end if resource[:nics]\n xml.GRAPHICS do\n resource[:graphics].each do |k, v|\n xml.send(k.upcase, v)\n end\n end if resource[:graphics]\n xml.FEATURES do\n resource[:features].each do |k, v|\n xml.send(k.upcase, v)\n end\n end if resource[:features]\n xml.CONTEXT do\n resource[:context].each do |k, v|\n xml.send(k.upcase, v)\n end\n end if resource[:context]\n end\n end\n tempfile = builder.to_xml\n file.write(tempfile)\n file.close\n self.debug \"Creating template using #{tempfile}\"\n onetemplate('create', file.path)\n file.delete\n @property_hash[:ensure] = :present\n end",
"def generate_decorator\n inside 'app' do\n inside 'decorators' do\n create_file \"#{file_name}.rb\", <<-FILE\nclass #{file_name.camelize} < BaseDecorator\n\nend\n FILE\n end\n end\n end",
"def write_template(template, target, config)\n\n File.write(\n\n target,\n ERB.new(File.read(template)).result(binding)\n )\nend",
"def build\n dir = Dir::pwd + \"/\" + @modname\n if FileTest::directory?(dir)\n abort @options[:modulename] + \" directory already exists.\"\n end\n\n Dir::mkdir(dir)\n @pattern.manitemplates.each do |m|\n target = File.open(dir + \"/\" + m, 'a')\n File.open(@pattern.templatedir + \"/\" + m, 'r').each_line do |s|\n # Write in new parameters on appropriate lines if there are any\n if s.match(/#\\$PARAM/)\n if @options[:parameters]\n @options[:parameters].each do |p|\n temp = s.gsub(/PARAM/, p)\n temp.gsub!(/MODNAME/, @modname)\n temp.sub!(/#/, \"\")\n target.write temp\n end\n else\n ## Does not write template line if no params\n next\n end\n else\n # Otherwise just make sure the module name is correct\n target.write s.gsub(/MODNAME/, @modname)\n end\n end\n target.close\n end\n rescue Errno::EEXIST\n abort @options[:modulename] + \" directory already exists.\"\n end",
"def initialize(*args)\n super\n\n self.targets.each do |tgt|\n tgt_f = application.define_task(Rake::FileTask, File.join(self.to_s, tgt))\n tgt_f.comment = \"Build #{tgt} in #{self}\"\n tgt_f.enhance([self])\n end\n end",
"def build template\n erb = File.read(File.join(VIEWS_DIR, template + \".erb\"))\n content = ERB.new(erb).result(binding)\n File.open(template, 'w') do |f|\n f.write content.gsub(/\\n\\n\\n+/, \"\\n\\n\")\n end\n end",
"def define\n desc \"Generate rokko documentation\"\n task @name do\n # Find README file for `index.html` and delete it from `sources`\n if @options[:generate_index]\n readme_source = @sources.detect { |f| File.basename(f) =~ /README(\\.(md|text|markdown|mdown|mkd|mkdn)$)?/i }\n readme = readme_source ? File.read(@sources.delete(readme_source)) : ''\n end\n\n # Run each file through Rokko and write output\n @sources.each do |filename|\n rokko = Rokko.new(filename, @sources, @options)\n out_dest = File.join(@dest, filename.sub(Regexp.new(\"#{File.extname(filename)}$\"), \".html\"))\n puts \"rokko: #{filename} -> #{out_dest}\"\n FileUtils.mkdir_p File.dirname(out_dest)\n File.open(out_dest, 'wb') { |fd| fd.write(rokko.to_html) }\n end\n\n # Generate index.html if needed\n if @options[:generate_index]\n require 'rokko/index_layout'\n out_dest = File.join(@dest, 'index.html')\n puts \"rokko: #{out_dest}\"\n File.open(out_dest, 'wb') { |fd| fd.write(IndexLayout.new(@sources, readme, @options).render) }\n end\n\n # Run specified file through rokko and use it as index\n if @options[:index] && source_index = @sources.find{|s| s == @options[:index]}\n rokko = Rokko.new(source_index, @sources, @options.merge(preserve_urls: true))\n out_dest = File.join(@dest, 'index.html')\n puts \"rokko: #{source_index} -> index.html\"\n File.open(out_dest, 'wb') { |fd| fd.write(rokko.to_html) }\n end\n\n end\n end",
"def make_copy_file_tasks\n @files.each do |source, destination|\n next if source == destination\n next if Rake::FileTask.task_defined? destination\n type = File.directory?(source) ? 'folder' : 'file'\n task = Rake::FileTask.define_task destination do |t|\n folder = File.dirname(t.name)\n FileUtils.mkpath folder unless File.directory? folder\n FileUtils.copy source, t.name\n end\n task.comment = \"Create the #{destination} #{type}\"\n task.enhance ['wix']\n if Rake::FileTask.task_defined? source\n task.enhance [source]\n end\n end\n end",
"def view_template(source, *args, &block)\n config = args.last.is_a?(Hash) ? args.pop : {}\n destination = args.first || source.sub(/\\.tt$/, '')\n \n source = File.expand_path(source.to_s)\n context = instance_eval('binding')\n \n create_file destination, nil, config do\n content = ERB.new(::File.binread(source), nil, '-', '@output_buffer').result(context)\n content = block.call(content) if block\n content\n end\n end",
"def generate_template()\n\n file_name = @hostname + '.tf'\n check_file_exists(file_name)\n template_path = determine_role()\n\n template = File.read(template_path)\n renderer = ERB.new(template, nil, '-')\n open(file_name, 'w') { |f|\n \tf.puts renderer.result(self.get_binding)\n f.close\n }\n\n end",
"def create_into(directory)\n build_file\n Pathname.new(directory).join(@file).open 'w+' do |file|\n post = self\n file << ERB.new(load_template).result(binding)\n end\n end",
"def create\n output_path = ''\n\n CustomUtils.mktmpdir('knowings_api_file', \"/nfs/tmp/knowings/\") do |dir|\n metapath = create_meta(dir)\n basename = ::File.basename(@file_name, '.pdf')\n output_path = ::File.join(dir, \"#{basename}#{EXTENSION}\")\n\n POSIX::Spawn.system \"zip -j #{output_path} #{metapath} #{@filepath}\"\n end\n\n output_path\n end",
"def define(args, &task_block)\n desc \"Generate Swagger from AppMaps\" unless ::Rake.application.last_description\n\n task(name, *args) do |_, task_args|\n RakeFileUtils.__send__(:verbose, Rake.verbose == true) do\n task_block.call(*[self, task_args].slice(0, task_block.arity)) if task_block\n Command.new(:git_command).tap do |cmd|\n cmd.base = task_args[:base] || self.base\n cmd.swagger_file = task_args[:swagger_file] || self.swagger_file\n end.perform\n end\n end\n end",
"def description_task(dir_path, id, target, display_name)\n description_file = \"#{dir_path}/description.xml\"\n data = String.new TEMPLATE_DESCRIPTION\n data.gsub!(/\\$\\{ID\\}/, id)\n data.gsub!(/\\$\\{VERSION\\}/, VERSION)\n data.gsub!(/\\$\\{TARGET\\}/, target)\n data.gsub!(/\\$\\{DISPLAY_NAME\\}/, display_name)\n open(description_file, \"w\") do |f|\n f.write(data)\n f.flush\n end\nend",
"def template\n @template ||= Template.new name: script_name, out_file: root_ruby_file, type: type\n end",
"def generate\n\t\t\t\tbegin\n\t\t\t\t\ttemplate = @template\n\t\t\t\t\ttemplate_manager = @template_manager\n\n\t\t\t\t\tt = template_manager.find_template_by_name(template)\n\t\t\t\t\tt = t.class.new\n\n\t\t\t\t\tif t.template_info[:renderer] == \"CSV\"\n\t\t\t\t\t\tRisu::Renderers::CSVRenderer.generate(@output_file) do |output|\n\t\t\t\t\t\t\tt = template_manager.find_template_by_name(template)\n\t\t\t\t\t\t\tt = t.class.new\n\t\t\t\t\t\t\tt.output = output\n\t\t\t\t\t\t\tt.render(output) unless t == nil\n\t\t\t\t\t\tend\n\t\t\t\t\telsif t.template_info[:renderer] == \"PDF\"\n\t\t\t\t\t\tPrawn::Document.generate(@output_file, :margin => [75, 50, 75, 50]) do |output|\n\t\t\t\t\t\t\toutput.font_size 10\n\t\t\t\t\t\t\tt = template_manager.find_template_by_name(template)\n\t\t\t\t\t\t\tt = t.class.new\n\t\t\t\t\t\t\tt.output = output\n\t\t\t\t\t\t\tt.render(output) unless t == nil\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\trescue => e\n\t\t\t\t\traise unless Rails.env.production?\n\t\t\t\t\tputs \"Templater Error: #{e.message} \\n #{e.backtrace.join(\"\\n\\t\")}\\n\"\n\t\t\t\tend\n\t\t\tend",
"def createDocbookToXHtmlTask()\n\treturn Schmant::XsltTF.new.\n\t\tsetTransformerFactoryClassName(XSL_TRANSFORMER).\n\t\tsetParameter(\"img.src.path\", \"\").\n\t\tsetParameter(\"use.role.for.mediaobject\", \"1\").\n\t\tsetParameter(\"chunk.section.depth\", \"0\").\n\t\tsetParameter(\"html.ext\", \".xhtml\")\nend",
"def create_copy_file_tasks(source_files, source_root, dest_root, invoking_task)\n source_files.each do |source|\n target = source.pathmap(\"%{#{source_root},#{dest_root}}p\")\n directory File.dirname(target)\n file target => [File.dirname(target), source] do |t|\n cp source, target\n end\n task invoking_task => target\n end\nend",
"def get_task_resources_zip()\n # Get a temp file path\n filename = FileHelper.sanitized_filename(\"task-resources-#{self.code}.zip\")\n result = Tempfile.new(filename)\n # Create a new zip\n Zip::File.open(result.path, Zip::File::CREATE) do | zip |\n task_definitions.each do |td|\n if td.has_task_pdf?\n dst_path = FileHelper.sanitized_path( \"#{td.abbreviation}\") + \".pdf\"\n zip.add(dst_path, td.task_sheet)\n end\n\n if td.has_task_resources?\n dst_path = FileHelper.sanitized_path( \"#{td.abbreviation}\") + \".zip\"\n zip.add(dst_path, td.task_resources)\n end\n end\n end #zip\n result\n end",
"def create_output_file filename # :yields: complete_filename\n output_path = @output_root + filename\n @logger.info \"Writing to #{output_path}#{dry_run ? \" (skipped - dry run)\" : \"\"}\" do\n unless dry_run\n folder = output_path.dirname\n folder.mkpath unless folder.directory?\n yield output_path\n end\n end\n end",
"def generate_targets\n has_metaname = has_version?\n\n %w[clean update fetch configure export build install].each do |target|\n target_name = \"#{@name}_#{target}\".to_sym\n target_metaname = \"#{@metaname}_#{target}\".to_sym if has_metaname\n func = pkg_default_target_func(@name.to_sym, target)\n\n task = Rake::Task.define_task(target_name, &func)\n metatask = Rake::Task.define_task(target_metaname, &func) if has_metaname\n\n # Add per-task dependency\n case target\n when /install/i\n task.enhance([\"#{@name}_build\".to_sym])\n metatask.enhance([\"#{@metaname}_build\".to_sym]) if has_metaname\n when /build/i\n task.enhance([\"#{@name}_export\".to_sym])\n metatask.enhance([\"#{@metaname}_export\".to_sym]) if has_metaname\n\n # Generate package export dependencies\n @build_deps.each do |dep|\n task.enhance([\"#{dep}_export\".to_sym])\n metatask.enhance([\"#{dep}_export\".to_sym]) if has_metaname\n end\n\n # Generate package build dependencies\n @clean_deps.each do |dep|\n task.enhance([\"#{dep}_install\".to_sym])\n metatask.enhance([\"#{dep}_install\".to_sym]) if has_metaname\n end\n when /export/i\n task.enhance([\"#{@name}_configure\".to_sym])\n metatask.enhance([\"#{@metaname}_configure\".to_sym]) if has_metaname\n when /configure/i\n task.enhance([\"#{@name}_fetch\".to_sym])\n metatask.enhance([\"#{@metaname}_fetch\".to_sym]) if has_metaname\n when /clean/i\n # Generate package clean dependencies\n @clean_deps.each do |dep|\n task.enhance([\"#{dep}_clean\".to_sym])\n metatask.enhance([\"#{dep}_clean\".to_sym]) if has_metaname\n end\n end\n\n update_global_task(target, target_name)\n end\n\n # Create the default package task named after the package name\n task = Rake::Task.define_task(\"#{@name}\" => [\"#{@name}_install\".to_sym])\n metatask = Rake::Task.define_task(\"#{@metaname}\" => [\"#{@metaname}_install\".to_sym]) if has_metaname\n end",
"def define_libboost_oxt_task(namespace, output_dir, extra_compiler_flags = nil)\n\toutput_file = \"#{output_dir}.a\"\n\tflags = \"-Iext #{extra_compiler_flags} #{PlatformInfo.portability_cflags} #{EXTRA_CXXFLAGS}\"\n\t\n\t# Define compilation targets for .cpp files in ext/boost/src/pthread.\n\tboost_object_files = []\n\tDir['ext/boost/src/pthread/*.cpp'].each do |source_file|\n\t\tobject_name = File.basename(source_file.sub(/\\.cpp$/, '.o'))\n\t\tboost_output_dir = \"#{output_dir}/boost\"\n\t\tobject_file = \"#{boost_output_dir}/#{object_name}\"\n\t\tboost_object_files << object_file\n\t\t\n\t\tfile object_file => source_file do\n\t\t\tsh \"mkdir -p #{boost_output_dir}\" if !File.directory?(boost_output_dir)\n\t\t\tcompile_cxx(source_file, \"#{flags} -o #{object_file}\")\n\t\tend\n\tend\n\t\n\t# Define compilation targets for .cpp files in ext/oxt.\n\toxt_object_files = []\n\toxt_dependency_files = Dir[\"ext/oxt/*.hpp\"] + Dir[\"ext/oxt/detail/*.hpp\"]\n\tDir['ext/oxt/*.cpp'].each do |source_file|\n\t\tobject_name = File.basename(source_file.sub(/\\.cpp$/, '.o'))\n\t\toxt_output_dir = \"#{output_dir}/oxt\"\n\t\tobject_file = \"#{oxt_output_dir}/#{object_name}\"\n\t\toxt_object_files << object_file\n\t\t\n\t\tfile object_file => [source_file, *oxt_dependency_files] do\n\t\t\tsh \"mkdir -p #{oxt_output_dir}\" if !File.directory?(oxt_output_dir)\n\t\t\tcompile_cxx(source_file, \"#{flags} -o #{object_file}\")\n\t\tend\n\tend\n\t\n\tfile(output_file => boost_object_files + oxt_object_files) do\n\t\tsh \"mkdir -p #{output_dir}/boost #{output_dir}/oxt\"\n\t\tcreate_static_library(output_file,\n\t\t\t\"#{output_dir}/boost/*.o \" <<\n\t\t\t\"#{output_dir}/oxt/*.o\")\n\tend\n\t\n\ttask \"#{namespace}:clean\" do\n\t\tsh \"rm -rf #{output_file} #{output_dir}\"\n\tend\n\t\n\treturn output_file\nend",
"def generate_packaging_artifacts(workdir, name, binding, project)\n [\"pkginfo\", \"depend\", \"preinstall\", \"preremove\", \"postinstall\", \"proto\"].each do |template|\n target_dir = File.join(workdir, 'packaging')\n FileUtils.mkdir_p(target_dir)\n erb_file(File.join(VANAGON_ROOT, \"resources/solaris/10/#{template}.erb\"), File.join(target_dir, template), false, { :binding => binding })\n end\n end",
"def render_and_write_templates\n clean_build_dir()\n\n yard_file_hash = {}\n\n Dir.glob(\"#{Dir.pwd}/projects/*\").select { |f| File.directory? f }.each do|project_dir|\n yard_file = \"#{project_dir}/yard.yaml\"\n\n unless yard_file.empty?\n yard = YAML::load_file(yard_file)\n next if yard['disabled']\n\n apps = yard['apps']\n project_name = yard['project']['name']\n project_pipelines = yard['pipelines']\n\n Dir.mkdir \"#{BUILD_DIR}/#{project_name}\"\n puts project_name\n\n apps.each do |app_name, app_config|\n Dir.mkdir(\"#{BUILD_DIR}/#{project_name}/#{app_name}/\")\n app_pipelines = Hash.new({})\n\n project_pipelines.each do |pipeline|\n app_pipelines[pipeline['name']] = app_pipelines[pipeline['name']].merge(pipeline)\n end\n\n unless app_config.nil? || app_config['pipelines'].nil?\n app_config['pipelines'].each do |pipeline|\n app_pipelines[pipeline['name']] = app_pipelines[pipeline['name']].merge(pipeline)\n end\n end\n\n # puts app_pipelines\n\n base_files = Dir[\"#{Dir.pwd}/base/*\"]\n project_base_files = Dir[\"#{project_dir}/base/*\"]\n app_files = Dir[\"#{project_dir}/#{app_name}/*\"]\n\n app_pipelines.each do|pipeline_name, pipeline_config|\n template_name = pipeline_config['templateName'] ? pipeline_config['templateName'] : \"#{pipeline_name}.json\"\n\n app_files.each do|path|\n render_and_write(\n pipeline_config: pipeline_config,\n path: path,\n template_name: template_name,\n app_name: app_name,\n project_name: project_name,\n app_template_vars: app_config['template_vars']\n )\n end\n project_base_files.each do|path|\n render_and_write(\n pipeline_config: pipeline_config,\n path: path,\n template_name: template_name,\n app_name: app_name,\n project_name: project_name,\n app_template_vars: app_config['template_vars']\n )\n end\n\n base_files.each do|path|\n render_and_write(\n pipeline_config: pipeline_config,\n path: path,\n template_name: template_name,\n app_name: app_name,\n project_name: project_name,\n app_template_vars: app_config['template_vars']\n )\n end\n end\n end\n end\n end\n end",
"def templates_for(file); end",
"def generate_from_templates\r\n %w{package.json _config.yml}.each do |file|\r\n template file\r\n end\r\n end",
"def generate_batch_task_zip(user, tasks, unit)\n download_id = \"#{Time.new.strftime(\"%Y-%m-%d\")}-#{unit.code}-#{current_user.username}\"\n filename = FileHelper.sanitized_filename(\"batch_ready_to_mark_#{current_user.username}.zip\")\n output_zip = Tempfile.new(filename)\n # Create a new zip\n Zip::File.open(output_zip.path, Zip::File::CREATE) do | zip |\n csv_str = mark_csv_headers\n # Add individual tasks...\n tasks.select { |t| t.group_submission.nil? }.each do | task |\n # Skip tasks that do not yet have a PDF generated\n next if task.processing_pdf\n # Add to the template entry string\n student = task.project.student\n if task.status == :need_help\n mark_col = 'need_help'\n else\n mark_col = 'rtm'\n end\n csv_str << \"\\n#{student.username.gsub(/,/, '_')},#{student.name.gsub(/,/, '_')},#{task.project.tutorial.abbreviation},#{task.task_definition.abbreviation.gsub(/,/, '_')},#{task.id},\\\"#{task.last_comment_by(task.project.student).gsub(/\"/, \"\\\"\\\"\")}\\\",\\\"#{task.last_comment_by(user).gsub(/\"/, \"\\\"\\\"\")}\\\",#{mark_col},,\"\n\n src_path = task.portfolio_evidence\n\n next if src_path.nil? || src_path.empty?\n next unless File.exists? src_path\n\n # make dst path of \"<student id>/<task abbrev>.pdf\"\n dst_path = FileHelper.sanitized_path(\"#{task.project.student.username}\", \"#{task.task_definition.abbreviation}-#{task.id}\") + \".pdf\"\n # now copy it over\n zip.add(dst_path, src_path)\n end\n # Add group tasks...\n tasks.select { |t| t.group_submission }.group_by { |t| t.group_submission } .each do | subm, tasks |\n task = tasks.first\n # Skip tasks that do not yet have a PDF generated\n next if task.processing_pdf\n\n # Add to the template entry string\n grp = task.group\n next if grp.nil?\n csv_str << \"\\nGRP_#{grp.id}_#{subm.id},#{grp.name.gsub(/,/, '_')},#{grp.tutorial.abbreviation},#{task.task_definition.abbreviation.gsub(/,/, '_')},#{task.id},\\\"#{task.last_comment_not_by(user).gsub(/\"/, \"\\\"\\\"\")}\\\",\\\"#{task.last_comment_by(user).gsub(/\"/, \"\\\"\\\"\")}\\\",rtm,,\"\n\n src_path = task.portfolio_evidence\n\n next if src_path.nil? || src_path.empty?\n next unless File.exists? src_path\n\n # make dst path of \"<student id>/<task abbrev>.pdf\"\n dst_path = FileHelper.sanitized_path(\"#{grp.name}\", \"#{task.task_definition.abbreviation}-#{task.id}\") + \".pdf\"\n # now copy it over\n zip.add(dst_path, src_path)\n end\n\n # Add marking file\n zip.get_output_stream(\"marks.csv\") { | f | f.puts csv_str }\n\n # Add readme file\n zip.get_output_stream(\"readme.txt\") { | f | f.puts readme_text }\n end\n output_zip\n end",
"def _task_( library, name, ¶ms )\n item = library.get(name)\n item.parent = self\n item.merge_instance_variables(self)\n item.instance_eval(¶ms) if block_given?\n item.generate\n end",
"def create_template\n\n add_breadcrumb \"Download Template\"\n\n # Figure out which approach was used to access this method\n file_content_type = nil\n # From the form. This is managed via a TemplateProxy class\n if params[:template_proxy].present?\n # Inflate the proxy\n template_proxy = TemplateProxy.new(params[:template_proxy])\n Rails.logger.debug template_proxy.inspect\n\n # See if an org was set, use the default otherwise\n if template_proxy.organization_id.blank?\n org = nil\n else\n o = Organization.find(template_proxy.organization_id)\n org = Organization.get_typed_organization(o)\n end\n\n # The form defines the FileContentType which identifies the builder to use\n file_content_type = FileContentType.find(template_proxy.file_content_type_id)\n # asset_types are an array of asset types\n\n elsif params[:targets].present?\n # The request came from the audit results page. We have a list of asset\n # object keys\n file_content_type = FileContentType.find(params[:file_content_type_id])\n assets = Rails.application.config.asset_base_class_name.constantize.operational.where(:object_key => params[:targets].split(','))\n org = nil\n end\n\n is_component = params[:is_component]\n fta_asset_class_id = params[:fta_asset_class_id]\n\n # Find out which builder is used to construct the template and create an instance\n builder = file_content_type.builder_name.constantize.new(:organization => org, :asset_class_name => template_proxy.try(:asset_class_name), :asset_seed_class_id => template_proxy.try(:asset_seed_class_id), :organization_list => @organization_list, :is_component => is_component, :fta_asset_class_id => fta_asset_class_id)\n\n # Generate the spreadsheet. This returns a StringIO that has been rewound\n if params[:targets].present?\n builder.assets = assets\n end\n stream = builder.build\n\n # Save the template to a temporary file and render a success/download view\n file = Tempfile.new ['template', '.tmp'], \"#{Rails.root}/tmp\"\n ObjectSpace.undefine_finalizer(file)\n #You can uncomment this line when debugging locally to prevent Tempfile from disappearing before download.\n @filepath = file.path\n @filename = \"#{org.present? ? org.short_name.downcase : 'MultiOrg'}_#{file_content_type.class_name.underscore}_#{Date.today}.xlsx\"\n begin\n file << stream.string\n rescue => ex\n Rails.logger.warn ex\n ensure\n file.close\n end\n # Ensure you're cleaning up appropriately...something wonky happened with\n # Tempfiles not disappearing during testing\n respond_to do |format|\n format.js\n format.html\n end\n\n end",
"def generate template, file\n if file.kind_of? String then # one file\n write_template(file, ERB.new(load_template(template)).result(binding))\n else # multiple files\n file.each do |f|\n write_template(f, ERB.new(load_template(template)).result(binding))\n end\n end\n end",
"def build_script(hook_type)\n ERB.new(DEFAULT_TEMPLATE).result(binding)\n end",
"def convert_to_rake()\n object_multitask = prepare_tasks_for_objects()\n archiver = @tcs[:ARCHIVER]\n\n res = typed_file_task Rake::Task::LIBRARY, get_task_name => object_multitask do\n dir = @project_dir\n objs = @objects\n aname = get_archive_name\n \n if @output_dir_abs\n dir = @output_dir\n prefix = File.rel_from_to_project(@project_dir, @output_dir)\n objs.map! { |m| m[prefix.length..-1] }\n aname = aname[prefix.length..-1]\n end\n \n Dir.chdir(dir) do\n\n FileUtils.rm(aname) if File.exists?(aname)\n cmd = [archiver[:COMMAND]] # ar\n cmd += archiver[:ARCHIVE_FLAGS].split(\" \")\n cmd += archiver[:FLAGS].split(\" \") # --all_load\n cmd << aname # -o debug/x.exe\n cmd += objs\n\n if Cxxproject::Utils.old_ruby?\n cmdLine = cmd.join(\" \")\n if cmdLine.length > 8000\n inputName = aname+\".tmp\"\n File.open(inputName,\"wb\") { |f| f.write(cmd[1..-1].join(\" \")) }\n consoleOutput = `#{archiver[:COMMAND] + \" @\" + inputName}`\n else\n consoleOutput = `#{cmd.join(\" \")} 2>&1`\n end\n else\n rd, wr = IO.pipe\n cmd << {\n :err=>wr,\n :out=>wr\n }\n sp = spawn(*cmd)\n cmd.pop\n \n consoleOutput = ProcessHelper.readOutput(sp, rd, wr)\n end\n\n process_result(cmd, consoleOutput, archiver[:ERROR_PARSER], \"Creating #{aname}\")\n end\n end\n\n enhance_with_additional_files(res)\n add_output_dir_dependency(get_task_name, res, true)\n\n add_grouping_tasks(get_task_name)\n\n setup_rake_dependencies(res)\n return res\n end",
"def create_tempfile(output = render_template)\n tempfile = Tempfile.new([SecureRandom.uuid, \".#{@template_details[:template_extension]}\"], encoding: 'utf-8')\n tempfile.write(output)\n ObjectSpace.undefine_finalizer(tempfile) # force garbage collector not to remove automatically the file\n tempfile.close\n tempfile_details(tempfile).slice(:filename, :path).values\n end",
"def template(source, *args, &block)\n config = args.last.is_a?(Hash) ? args.pop : {}\n destination = args.first || source.sub(/#{TEMPLATE_EXTNAME}$/, \"\")\n\n source = File.expand_path(find_in_source_paths(source.to_s))\n context = config.delete(:context) || instance_eval(\"binding\")\n\n create_file destination, nil, config do\n content = CapturableERB.new(::File.binread(source), nil, \"-\", \"@output_buffer\").result(context)\n content = yield(content) if block\n content\n end\n end",
"def buildup_template_file(basename, header, hash)\n type = hash[:type] || :script\n filename = filename_for(basename, type)\n\n if File.exist? filename\n exit 0 unless prompt(\"* '#{filename}' already exists, overwrite it? (y/n): \") =~ /^y$/i\n end\n File.open(filename, \"w\") {|file|\n file << \"#!/usr/bin/env ruby\"\n file << \"\\n\"\n file << \"# coding: #{get_encoding}\"\n file << \"\\n\" * 2\n file << get_commented_text(header)\n file << \"\\n\" * 2\n\n case type\n when :script\n file << TEMPLATE_SCRIPT\n when :test\n file << TEMPLATE_TEST_UNIT\n when :rspec\n file << TEMPLATE_RSPEC\n end\n\n file.chmod SCRIPT_MOD\n\n puts \"* Successfully generated: #{filename}\"\n }\n end",
"def file!(*args, &block)\n task = Rake::FileTask.define_task(*args, &block)\n CLEAN.include(task.name)\n task\nend",
"def create_source_files\n empty_directory(File.join(target_dir, \"lib/kitchen/driver\"))\n\n create_template(\n \"version.rb.erb\",\n \"lib/kitchen/driver/#{name}_version.rb\"\n )\n create_template(\n \"driver.rb.erb\",\n \"lib/kitchen/driver/#{name}.rb\"\n )\n end",
"def setup_tasks\n namespace(:npm) do\n desc 'Build package.json from template'\n task :'package.json' do\n template = ERB.new(File.read(File.join(src, 'package.json.erb')))\n generated = template.result_with_hash(scope: SCOPE, gemspec: gemspec, contributors: contributors)\n File.write(File.join(src, 'package.json'), JSON.pretty_generate(JSON.parse(generated)))\n end\n\n desc 'Ensure the destination directory exist'\n task :dest do\n FileUtils.mkdir_p(dest)\n end\n\n desc 'Build package tarball into the pkg directory'\n task build: %i[package.json dest] do\n system(\"cd #{src} && npm pack --pack-destination #{dest}/\")\n end\n\n desc 'Build and push package to npmjs.com'\n task release: %i[build] do\n system(\"npm publish #{tarball} --access public\")\n end\n end\n end",
"def run\n Execution.block 'Creating a custom file', @target, 'root' do |b|\n b.always_run true\n b.run \"mkdir -p #{::File.dirname(@target)}\"\n ::File.open(@target, 'w+') { |file| file.write @content }\n b.run \"chown #{@owner}:#{@owner} #{::File.dirname(@target)}\"\n b.run \"chown #{@owner}:#{@owner} #{@target}\"\n b.run \"chmod #{unix_mode} #{@target}\"\n end\n end",
"def build(name)\n output_path = File.join(__dir__, \"#{name}.yml\")\n File.write(output_path, GENERATED_BANNER + template(name, params: { header: false }))\n end",
"def convert_to_rake()\n object_multitask = prepare_tasks_for_objects()\n\n res = typed_file_task get_rake_task_type(), get_task_name => object_multitask do\n cmd = calc_command_line\n Dir.chdir(@project_dir) do\n mapfileStr = @mapfile ? \" >#{@mapfile}\" : \"\"\n rd, wr = IO.pipe\n cmdLinePrint = cmd\n printCmd(cmdLinePrint, \"Linking #{executable_name}\", false) #OK\n cmd << {\n :out=> @mapfile ? \"#{@mapfile}\" : wr, # > xy.map\n :err=>wr\n }\n sp = spawn(*cmd)\n cmd.pop\n # for console print\n cmd << \" >#{@mapfile}\" if @mapfile\n consoleOutput = ProcessHelper.readOutput(sp, rd, wr)\n\n process_result(cmdLinePrint, consoleOutput, @tcs[:LINKER][:ERROR_PARSER], nil)\n check_config_file()\n post_link_hook(@tcs[:LINKER])\n end\n end\n res.tags = tags\n res.immediate_output = true\n res.enhance(@config_files)\n res.enhance([@project_dir + \"/\" + @linker_script]) if @linker_script\n\n add_output_dir_dependency(get_task_name, res, true)\n add_grouping_tasks(get_task_name)\n setup_rake_dependencies(res, object_multitask)\n\n # check that all source libs are checked even if they are not a real rake dependency (can happen if \"build this project only\")\n begin\n libChecker = task get_task_name+\"LibChecker\" do\n if File.exists?(get_task_name) # otherwise the task will be executed anyway\n all_dependencies.each do |bb|\n if bb and StaticLibrary === bb\n f = bb.get_task_name # = abs path of library\n if not File.exists?(f) or File.mtime(f) > File.mtime(get_task_name)\n def res.needed?\n true\n end\n break\n end\n end\n end\n end\n end\n rescue\n def res.needed?\n true\n end\n end\n libChecker.transparent_timestamp = true\n res.enhance([libChecker])\n\n return res\n end",
"def define\n fail \"Version required (or :noversion)\" if @version.nil?\n @version = nil if :noversion == @version\n\n desc \"Build all the packages\"\n task :package\n\n desc \"Force a rebuild of the package files\"\n task repackage: [:clobber_package, :package]\n\n desc \"Remove package products\"\n task :clobber_package do\n rm_r package_dir rescue nil\n end\n\n task clobber: [:clobber_package]\n\n [\n [need_tar, tgz_file, \"z\"],\n [need_tar_gz, tar_gz_file, \"z\"],\n [need_tar_bz2, tar_bz2_file, \"j\"],\n [need_tar_xz, tar_xz_file, \"J\"]\n ].each do |need, file, flag|\n if need\n task package: [\"#{package_dir}/#{file}\"]\n file \"#{package_dir}/#{file}\" =>\n [package_dir_path] + package_files do\n chdir(working_dir) { sh @tar_command, \"#{flag}cvf\", file, target_dir }\n mv \"#{package_dir_path}/#{target_dir}\", package_dir if without_parent_dir\n end\n end\n end\n\n if need_zip\n task package: [\"#{package_dir}/#{zip_file}\"]\n file \"#{package_dir}/#{zip_file}\" =>\n [package_dir_path] + package_files do\n chdir(working_dir) { sh @zip_command, \"-r\", zip_file, target_dir }\n mv \"#{package_dir_path}/#{zip_file}\", package_dir if without_parent_dir\n end\n end\n\n directory package_dir_path => @package_files do\n @package_files.each do |fn|\n f = File.join(package_dir_path, fn)\n fdir = File.dirname(f)\n mkdir_p(fdir) unless File.exist?(fdir)\n if File.directory?(fn)\n mkdir_p(f)\n else\n rm_f f\n safe_ln(fn, f)\n end\n end\n end\n self\n end",
"def gem_build_task(gem,namespace_name=:gems)\n namespace(namespace_name) do\n gem_dir = CapyBrowser::Rake::RelativePath.new('tmp/gems').path\n directory gem_dir\n\n desc gem.build_description\n task :build => [:directories,gem.name.to_sym ] do |t|\n t.reenable\n end\n\n desc \"Build all gems\"\n task :rebuild do |t|\n rm_rf(gem_dir)\n Rake::Task[\"gems:build\"].reenable\n Rake::Task[\"gems:build\"].invoke\n end\n\n desc gem.build_gemfile_description\n task gem.name.to_sym => [gem.gemfile] do |t|\n t.reenable\n end\n\n file \"tmp/vendor/cache/#{gem.gemfile}\" => [gem.gemfile_path.relative_path]\n file gem.gemfile_path.relative_path => gem.gemfile\n file gem.gemfile => gem_dir do |t|\n puts gem.invoke!\n rm_rf(gem_dir)\n end\n end\nend",
"def execute\n Services::Slog.debug({:message => \"File write for #{@template[:identifier]}\", :module => \"FileTemplate\", :task => \"execute\", :extra => {:template => @template[:identifier], :payload => @template[:payload]}})\n case @template[:payload][:method]\n when 'create'\n begin\n\n @template.users.each do |user|\n File.open(\"data/users/#{user.id}/#{@template[:payload][:uri]}\", \"w+\") { |file| file.write(\"\\n\") }\n response = { :status => \"200\", :message => \"File created.\", :id => @template[:payload][:uri]}\n\n unless @template[:payload][:content].nil? then\n File.open(\"data/users/#{user.id}/#{@template[:payload][:uri]}\", \"w+\") { |file| file.write(@template[:payload][:content]) }\n end\n end\n rescue Exception => e\n Services::Slog.exception e\n response = { :status => \"400\", :message => \"Method not is unsupported, #{e}\" }\n end\n when 'append'\n begin\n @template.users.each do |user|\n unless @template[:payload][:content].nil? then\n File.open(Dir.pwd + \"/data/users/#{user.id}/#{@template[:payload][:uri]}\", \"a+\") { |file| file.write(@template[:payload][:content]) }\n end\n end\n response = { :status => \"200\", :message => \"Content appended to file\", :id => @template[:payload][:uri]}\n rescue Exception => e\n response = { :status => \"403\", :message => \"Error processing file, #{e}\" }\n Services::Slog.exception e\n end\n end\n\n response\n end",
"def create_copy_task srcGlob, targetDir, taskSymbol\n mkdir_p(targetDir, :verbose => false)\n FileList[srcGlob].each do |f|\n target = File.join(targetDir, File.basename(f))\n file target => [f] do |t|\n cp f, target\n end\n task taskSymbol => target\n end\nend"
] |
[
"0.7126494",
"0.69910395",
"0.6898831",
"0.6480727",
"0.63670325",
"0.6307068",
"0.6190587",
"0.611787",
"0.61012465",
"0.60927254",
"0.6072367",
"0.6064941",
"0.60631496",
"0.6052278",
"0.60421336",
"0.6000204",
"0.5987774",
"0.5936244",
"0.5930975",
"0.58978635",
"0.58978635",
"0.5842072",
"0.58136606",
"0.57887083",
"0.5787072",
"0.5781859",
"0.5781859",
"0.5776539",
"0.57414395",
"0.5729313",
"0.57216847",
"0.5703439",
"0.56993836",
"0.56885606",
"0.5684421",
"0.5681537",
"0.56628984",
"0.56586146",
"0.5656029",
"0.5641068",
"0.5638734",
"0.56350005",
"0.56328666",
"0.5630744",
"0.5629575",
"0.5626106",
"0.5624397",
"0.56190807",
"0.5610988",
"0.5605023",
"0.56024766",
"0.5592615",
"0.5588527",
"0.55815464",
"0.55671704",
"0.55658805",
"0.5551123",
"0.5541525",
"0.55321395",
"0.55250275",
"0.5524032",
"0.55175614",
"0.5514475",
"0.5511643",
"0.5511184",
"0.55009305",
"0.5500522",
"0.5494317",
"0.54919684",
"0.5491242",
"0.5488623",
"0.54870886",
"0.5486021",
"0.54829276",
"0.5482341",
"0.5479718",
"0.54765576",
"0.5475402",
"0.5472265",
"0.545618",
"0.54532284",
"0.54490393",
"0.5447485",
"0.54471815",
"0.54324985",
"0.54228497",
"0.5421299",
"0.5419063",
"0.54176986",
"0.5399716",
"0.53929466",
"0.53899896",
"0.53882056",
"0.5383139",
"0.53783095",
"0.5378235",
"0.5373018",
"0.5369998",
"0.53633666",
"0.5356616"
] |
0.7240311
|
0
|
Provides either the passed in HTML, or uses the doc to generate the HTML
|
def html
@html ||= args.dig(:html) || doc.to_html
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def html_markup_rdoc(text); end",
"def html_markup_asciidoc(text); end",
"def documentation_html\n @documentation_html ||= generate_documentation_html\n end",
"def doc\n # get_html beforehand for good output messages\n html = get_html\n print \"Parsing doc...\"\n doc = Nokogiri::HTML(html)\n puts \"done.\"\n puts\n doc\n end",
"def html_markup_html(text); end",
"def wrap(html); end",
"def wrap(html); end",
"def api_html page\n <<-STR\n<html>\n <head>\n <title>#{self.class} Api Documentation</title>\n <style>\n#{API_CSS}\n </style>\n </head>\n <body class=\"indexpage\">\n <div>\n #{RDoc::Markup::ToHtml.new.convert page.to_s}\n </div>\n </body>\n</html>\n STR\n end",
"def html_markup_org(text); end",
"def trans_html\n @doc.to_html\n end",
"def inner_html(*args); end",
"def inner_html(*args); end",
"def html\n @html ||= process_html!\n end",
"def html\n @doc.to_s\n end",
"def html\n @doc.to_s\n end",
"def doc\n return @doc if @doc\n @doc = Nokogiri::HTML(@body) if @body && html? rescue nil\n end",
"def generate_html\n @main_url = main_url\n @sorted_files = @files.sort\n @sorted_classes = @classes.sort\n @sorted_methods = RDoc::Generator::Method.all_methods.sort\n\n # the individual descriptions for files and classes\n gen_into(@files)\n gen_into(@classes)\n\n # and the index files\n gen_file_index\n gen_class_index\n gen_method_index\n gen_main_index\n\n # this method is defined in the template file\n values = {\n :title_suffix => CGI.escapeHTML(\"[#{@options.title}]\"),\n :charset => @options.charset,\n :style_url => style_url('', @options.css),\n }\n\n @template.write_extra_pages(values) if\n @template.respond_to?(:write_extra_pages)\n end",
"def generate_documentation_html\n YARD::Registry.yardoc_file = Dir.mktmpdir('auto_yardoc')\n begin\n YARD::Tags::Library.define_tag('', :request_param, :with_types_and_name)\n YARD::Tags::Library.define_tag('', :request_body, :with_types_and_name)\n YARD::Registry.load([settings.app_file], true)\n template_path = File.join(File.dirname(__FILE__), '../../templates_custom')\n YARD::Templates::Engine.register_template_path(template_path)\n YARD::Templates::Engine.render(:object => YARD::Registry.resolve(nil, self.class.to_s),\n :format => :html)\n ensure\n YARD::Registry.delete_from_disk\n end\n end",
"def doc &b\n\t\t\tdoctype\n\t\t\thtml &b\n\t\tend",
"def doc\n unless @doc\n @doc = Nokogiri::HTML(html)\n end\n @doc\n end",
"def html *args\n @html = true if args.size > 0\n @html\n end",
"def html_markup_text(text); end",
"def generate_html\n # the individual descriptions for files and classes\n gen_into(@files)\n gen_into(@classes)\n # and the index files\n gen_file_index\n gen_class_index\n gen_method_index\n gen_main_index\n\n # this method is defined in the template file\n write_extra_pages if defined? write_extra_pages\n end",
"def html_parser; end",
"def create_html(options)\n if(options[:html_template] && options[:html_template] == :scientific) then\n\n if(options[:language] && options[:language] == :english) then\n html = '<h2>Academic Interests<\\/h2>\\r\\n' +\n '<p>Add information about academic fields of interest.<\\/p>\\r\\n' +\n '<h2>Teaching<\\/h2>\\r\\n' +\n '<ul>\\r\\n' +\n ' <li><Link to programme of study/course><\\/li>\\r\\n' +\n ' <li><Link to programme of study/course><\\/li>\\r\\n' +\n ' <li>...<\\/li>\\r\\n' +\n '<\\/ul>\\r\\n' +\n '<h2>Higher education and employment history<\\/h2>\\r\\n' +\n '<p>Brief introduction to previous education and employment.<\\/p>\\r\\n' +\n '<h2>Honoraria<\\/h2>\\r\\n' +\n '<ul>\\r\\n' +\n ' <li><Name of prize and (if applicable) link 1><\\/li>\\r\\n' +\n ' <li><Name of prize and (if applicable) link 2><\\/li>\\r\\n' +\n ' <li>...<\\/li>\\r\\n' +\n '<\\/ul>\\r\\n' +\n '<h2>Appointments<\\/h2>\\r\\n' +\n '<ul>\\r\\n' +\n ' <li><Title and (if applicable) link 1><\\/li>\\r\\n' +\n ' <li><Title and (if applicable) link 2><\\/li>\\r\\n' +\n ' <li>...<\\/li>\\r\\n' +\n '<\\/ul>\\r\\n' +\n '<h2>Cooperation<\\/h2>\\r\\n' +\n '<p> <\\/p>'\n else\n html = '<h2>Faglige interesser<\\/h2>\\r\\n' +\n '<p>Her kan du skrive om faglige interesser.<\\/p>\\r\\n' +\n '<h2>Undervisning<\\/h2>\\r\\n<p>' +\n '<Lenke til studieprogram/emne> <br />\\r\\n' +\n '<Lenke til studieprogram/emne> <br />\\r\\n...<\\/p>\\r\\n' +\n '<h2>Bakgrunn<\\/h2>\\r\\n' +\n '<p>Kort om tidligere arbeidserfaring og utdanning<\\/p>\\r\\n' +\n '<h2>Priser<\\/h2>\\r\\n' +\n '<p><Navn og eventuelt lenke til pris 1> <br />\\r\\n' +\n '<Navn og eventuelt lenke til pris 2> <br />\\r\\n' +\n '...<\\/p>\\r\\n' +\n '<h2>Verv<\\/h2>\\r\\n<p>' +\n '<Navn og eventuelt lenke til verv 1> <br />\\r\\n' +\n '<Navn og eventuelt lenke til verv 2> <br />\\r\\n...' +\n '<\\/p>\\r\\n' +\n '<h2>Samarbeid<\\/h2>\\r\\n' +\n '<p> <\\/p>'\n end\n else\n\n if(options[:language] && options[:language] == :english) then\n html = '<h2>Tasks performed<\\/h2>\\r\\n' +\n '<p>Add information about job duties, as a short text or a bulleted list:<\\/p>' +\n '\\r\\n<ul>\\r\\n' +\n ' <li><Task 1><\\/li>\\r\\n' +\n ' <li><Task 1><\\/li>\\r\\n' +\n ' <li>...<\\/li>\\r\\n' +\n '<\\/ul>\\r\\n' +\n '<h2>Background<\\/h2>\\r\\n' +\n '<p>Add information about previous education and employment.<\\/p>'\n else\n html = '<h2>Arbeidsområder<\\/h2>\\r\\n' +\n '<p>Her kan du skrive om arbeidsområder, ' +\n 'enten som kort tekst eller som listepunkter:</p>' +\n '\\r\\n' +\n '<ul>\\r\\n' +\n ' <li><Arbeidsområde 1></li>\\r\\n' +\n ' <li><Arbeidsområde 1></li>\\r\\n' +\n ' <li>...</li>\\r\\n' +\n '</ul>' +\n '\\r\\n' +\n '<h2>Bakgrunn</h2>\\r\\n' +\n '<p>Eventuelt kort om tidligere arbeidserfaring og utdanning.</p>'\n end\n end\n return html\n end",
"def description_html\n convert_html description\n end",
"def to_html\n require 'mustache'\n template = File.read(__dir__ + '/app_documentation_tpl.mustache')\n Mustache.render(template, :html_fragment => to_html_fragment)\n end",
"def write_html(html, section)\n filename = \"section-#{section.to_s.rjust(3, '0')}.html\"\n @contents_sections << %Q{<documentation relative-path=\"#{filename}\"/>}\n\n html = html[0, html.length - 2]\n html = erb(@data_dir + '/section.html.erb', { title: filename, content: html })\n File.write(@doc_dir + \"/#{filename}\", html)\n end",
"def with_doc_tester(options = {})\n @with_doc_tester = true\n if options[:html]\n @with_html_doc_tester = true\n end\n yield\n @with_doc_tester = false\n @with_html_doc_tester = false\n end",
"def doc\n @doc ||= @body && html? && Nokogiri::HTML(@body)\n end",
"def viewHtmlDocContent (queries = {} )\r\n closeHtmlDocWithTitle (queries ) \r\n end",
"def documentation_page store, generator, path, req, res\n text_name = path.chomp '.html'\n name = text_name.gsub '/', '::'\n\n if klass = store.find_class_or_module(name) then\n res.body = generator.generate_class klass\n elsif page = store.find_text_page(name.sub(/_([^_]*)\\z/, '.\\1')) then\n res.body = generator.generate_page page\n elsif page = store.find_text_page(text_name.sub(/_([^_]*)\\z/, '.\\1')) then\n res.body = generator.generate_page page\n else\n not_found generator, req, res\n end\n end",
"def rdoc(input)\n markup = RDoc::Markup::ToHtml.new\n markup.convert(input)\n end",
"def md_include_html(html)\n res = \"{::options parse_block_html=\\\"true\\\" /}\\n\"\n res << html\n res << \"\\n{::options parse_block_html=\\\"false\\\" /}\\n\"\n return res\nend",
"def garnish(html)\n template{ html }\n end",
"def html?; end",
"def html?; end",
"def html?; end",
"def doc\n @doc ||= ::Nokogiri::HTML(@html)\n end",
"def process_html(document)\n\t\t\t\n\t\t\t# Add link and raw HTML to a hash as key/value\n\t\t\t# for later storage in database\n\t\t\tunless @raw_html.has_value?(document)\n\t\t \t\tprint \".\"\n\t\t \t\t@raw_html[@document.base_uri.to_s] = document\n\t\t\tend\n\t\t\t\t\n\t\tend",
"def make_html\n @document.encoding = 'UTF-8'\n @best_candidate = nil\n end",
"def html_markup_textile(text); end",
"def html_open; \"<html>\"; end",
"def presentable_html(html)\n # sanitize edited, tags: %w(body p span a h1 h2 h3 h4 h5 h6 ul ol li) if work.file_content_html %> -->\n # doc = Nokogiri::HTML(html_junk)\n # body = doc.at_xpath(\"//body\")\n # body.css('*').remove_attr('class')\n # edited = body.to_html\n return raw html\n end",
"def setup\n @html = <<-TEXTILE\n<h1>Give RedCloth a try!</h1>\n<p>A <strong>simple</strong> paragraph with<br />\na line break, some <em>emphasis</em> and a <a href=\"http://redcloth.org\">link</a></p>\n<ul>\n\t<li>an item</li>\n\t<li>and another</li>\n</ul>\n<ol>\n\t<li>one</li>\n\t<li>two</li>\n</ol>\nTEXTILE\n \n end",
"def html(html)\n @doc = Nokogiri::HTML(html)\n\n # return\n JSON.pretty_generate(serializer(@struct, @doc))\n end",
"def to_html(*args); end",
"def to_html(*args); end",
"def to_html(*args); end",
"def to_html(*args); end",
"def call\n html.gsub(/\\[\\[([^\\]|]*)(\\|([^\\]]*))?\\]\\]/) do\n link = $1\n desc = $3 ? $3 : $1\n\n \"<a href=\\\"#{to_link link}\\\">#{to_description desc}</a>\"\n end\n end",
"def to_html text\n html = (''.encode text.encoding).dup\n\n encoded = RDoc::Text::TO_HTML_CHARACTERS[text.encoding]\n\n s = StringScanner.new text\n insquotes = false\n indquotes = false\n after_word = nil\n\n until s.eos? do\n case\n when s.scan(/<(tt|code)>.*?<\\/\\1>/) then # skip contents of tt\n html << s.matched.gsub('\\\\\\\\', '\\\\')\n when s.scan(/<(tt|code)>.*?/) then\n warn \"mismatched <#{s[1]}> tag\" # TODO signal file/line\n html << s.matched\n when s.scan(/<[^>]+\\/?s*>/) then # skip HTML tags\n html << s.matched\n when s.scan(/\\\\(\\S)/) then # unhandled suppressed crossref\n html << s[1]\n after_word = nil\n when s.scan(/\\.\\.\\.(\\.?)/) then\n html << s[1] << encoded[:ellipsis]\n after_word = nil\n when s.scan(/\\(c\\)/i) then\n html << encoded[:copyright]\n after_word = nil\n when s.scan(/\\(r\\)/i) then\n html << encoded[:trademark]\n after_word = nil\n when s.scan(/---/) then\n html << encoded[:em_dash]\n after_word = nil\n when s.scan(/--/) then\n html << encoded[:en_dash]\n after_word = nil\n when s.scan(/"|\"/) then\n html << encoded[indquotes ? :close_dquote : :open_dquote]\n indquotes = !indquotes\n after_word = nil\n when s.scan(/``/) then # backtick double quote\n html << encoded[:open_dquote]\n after_word = nil\n when s.scan(/(?:'|'){2}/) then # tick double quote\n html << encoded[:close_dquote]\n after_word = nil\n when s.scan(/`/) then # backtick\n if insquotes or after_word\n html << '`'\n after_word = false\n else\n html << encoded[:open_squote]\n insquotes = true\n end\n when s.scan(/'|'/) then # single quote\n if insquotes\n html << encoded[:close_squote]\n insquotes = false\n elsif after_word\n # Mary's dog, my parents' house: do not start paired quotes\n html << encoded[:close_squote]\n else\n html << encoded[:open_squote]\n insquotes = true\n end\n\n after_word = nil\n else # advance to the next potentially significant character\n match = s.scan(/.+?(?=[<\\\\.(\"'`&-])/) #\"\n\n if match then\n html << match\n after_word = match =~ /\\w$/\n else\n html << s.rest\n break\n end\n end\n end\n\n html\n end",
"def html_parser=(_arg0); end",
"def html_parser=(_arg0); end",
"def inner_html(options = T.unsafe(nil)); end",
"def html\n if FUNCTION != 'none'\n if self.md.value != nil\n hm = self.md.value\n else\n hm = INDEX\n end\n @me = YAML.load(self.yaml.value)\n [\n ERB.new(HEAD).result(binding),\n Kramdown::Document.new(ERB.new(hm).result(binding)).to_html,\n \"</body></html>\"\n ].flatten.join('')\n end\n end",
"def htmlify(text, markup = T.unsafe(nil)); end",
"def generate_html_and_make_pdf(folder, html_content, html_name, pdf_name, pdf_options)\n generate_html(folder, html_content, html_name)\n convert_html_to_pdf(folder, html_name, pdf_name, pdf_options)\n end",
"def html=(b); end",
"def generate_html(individual_files=false)\n return self.to_s\n end",
"def generate_html(individual_files=false)\n return self.to_s\n end",
"def html(include_ocr: false)\n return @html if defined? @html\n\n @html = Henkei.read :html, data, include_ocr: include_ocr\n end",
"def doc(new_markup=nil)\n if markup = new_markup || content\n @doc = nil if new_markup\n @doc ||= case parser.to_sym\n when :xml then Nokogiri::XML(markup)\n when :html then Nokogiri::HTML(markup)\n else raise InvalidParser.new(\"Nokogiri cannot parse as '#{parser.inspect}'. Please request :xml or :html.\")\n end\n end\n end",
"def html\n return if self.text.blank?\n\n html = self.text\n \n # s = StringScanner.new(self.text)\n # html = ''\n # while markup = s.scan_until(/\\[code/) do\n # html += RedCloth.new(markup[0..-6]).to_html\n # s.pos= s.pos-5\n # code = s.scan_until(/\\[\\/code\\]/)\n # if code\n # code.gsub!(/\\[code\\]/, '[code lang=\"ruby\"]')\n # html += '<div class=\"syntax\">' + Syntaxi.new(code).process + '</div>' \n # else\n # break\n # end\n # end\n # html += RedCloth.new(s.rest).to_html\n \n html\n end",
"def load_html_template\n template = @options.template\n\n unless template =~ %r{/|\\\\} then\n template = File.join('rdoc', 'generator', @options.generator.key,\n template)\n end\n\n require template\n\n @template = self.class.const_get @options.template.upcase\n @options.template_class = @template\n\n rescue LoadError\n $stderr.puts \"Could not find HTML template '#{template}'\"\n exit 99\n end",
"def fulldoc_template; end",
"def html source=nil\n to_html text(source)\n end",
"def doc=(html)\n @doc = html\n return if html.nil?\n\n @reset_doc_hook = ->(browser) { browser.reset_doc }\n after_hooks.add(@reset_doc_hook)\n end",
"def call\n result = self.class.markdown_renderer.result(schema: schema)\n if @html\n result = self.class.html_renderer.result(body: self.class.redcarpet.render(result))\n result.gsub(/id=\"(.+)\"/) {|text| text.tr(\"/:\", \"\") }\n else\n result\n end\n end",
"def generate_html\n if @strscan.scan SUPPORTED_STYLE_PATTERN\n open_tag\n elsif @strscan.scan END_ESCAPE_SEQUENCE_PATTERN\n CLOSE_SPAN_TAG\n elsif @strscan.scan UNSUPPORTED_STYLE_PATTERN\n OPEN_SPAN_TAG\n else\n @strscan.scan IGNORED_OUTPUT\n end\n end",
"def html_options; @html_opts end",
"def html_markup_markdown(text); end",
"def help_text\n build_html do\n p <<P1\nThis page is a simple presentation of the paths that match the file\nthat was searched for an the fileset that the file was shipped in.\nP1\n end\n end",
"def standard_html( state, encoding = nil, &body_filller )\n html(:language => state.fetch(\"request.language\"), :direction => state.fetch(\"html.direction\", \"ltr\") do\n head do\n meta :charset => @parameters.fetch(:encoding, Encoding.default_internal)\n state.fetch(\"html.headscripts\").each do |script|\n fail_todo \"what now?\"\n end\n state.fetch(\"html.css\").each do |css|\n fail_todo \"what now?\"\n end\n end\n body do\n capture(&body_filler)\n \n state.fetch(\"html.tailscripts\").each do |script|\n fail_todo \"what now?\"\n end\n end\n end\n end\n\n\n #\n # Starts an HTML stream.\n \n def html( attrs = {}, &block )\n @buffer << \"<!DOCTYPE html>\"\n @buffer << \"\\n\" if @pretty_print\n make( :html, attrs, &block )\n flush\n end\n\n\n #\n # Outputs raw text to the stream.\n \n def raw( text )\n @buffer << text\n end",
"def parse!(markup)\n doc(markup)\n end",
"def to_html()\n @html ||= cmark(\"--to\", \"html\")\n @html\n end",
"def html( attrs = {}, &block )\n @buffer << \"<!DOCTYPE html>\"\n @buffer << \"\\n\" if @pretty_print\n make( :html, attrs, &block )\n flush\n end",
"def show_documentation req, res\n store, path = documentation_source req.path\n\n if_modified_since req, res, store.cache_path\n\n generator = generator_for store\n\n case path\n when nil, '', 'index.html' then\n res.body = generator.generate_index\n when 'table_of_contents.html' then\n res.body = generator.generate_table_of_contents\n when 'js/search_index.js' then\n documentation_search store, generator, req, res\n else\n documentation_page store, generator, path, req, res\n end\n ensure\n res.content_type ||= 'text/html'\n end",
"def html\n @html ||= Template.new(\"#{@input_file}:body\", @body).\n render_with(template_ivar => self).to_html\n end",
"def html_postprocess(field,html)\n html\n end",
"def doc(response)\n Nokogiri::HTML(response.body) #selectionne le tag body de la reponse\nend",
"def call\n markdown = markdown_renderer.result(schema: schema)\n if @html\n html = markdown_parser.render(markdown)\n html = html_renderer.result(body: html)\n html.gsub(/id=\"(.+)\"/) {|text| text.tr(\"/:\", \"\") }\n else\n markdown\n end\n rescue Jdoc::Link::ExampleNotFound => exception\n abort(\"Error: #{exception.to_s}\")\n end",
"def html_out(*args, &block)\n self.html_out_proc = block\n self.html_out_args = args\n end",
"def html(*r,&k)\n if ctx = __cheri_ctx\n unless copts = ctx[:html_opts]\n iopts = ctx.ictx[:html_opts] ||= HtmlOptions.new\n copts = ctx[:html_opts] = HtmlOptions.new(iopts)\n end\n if k\n if ctx.tos(HtmlElement)\n HtmlFrame.new(ctx,*r,&k).run\n else\n if r.empty?\n ctx.msend(Cheri::Html,:html,&k)\n else\n copts.ingest_args(*r)\n if args = copts.delete(:args)\n ctx.msend(Cheri::Html,:html,args,&k)\n else\n ctx.msend(Cheri::Html,:html,&k)\n end\n end\n end\n else\n unless r.empty?\n copts.ingest_args(*r)\n copts.delete(:args)\n end\n ctx[:html_proxy] ||= HtmlProxy.new(ctx,*r)\n end\n end\n end",
"def doc( path )\n get \"#{path}.html\" do\n password_protected!\n \n endpoint = path.split('/').last\n \n template_path = File.join( VIEW_PATH, \"#{endpoint}.md\" )\n rendered = GitHub::Markup.render( template_path )\n\n erb :layout, :locals => { :content => rendered }\n end\nend",
"def html\n Markdown.render(self.content)\n end",
"def html\n Markdown.render(self.content)\n end",
"def parse_html(pdoc, data)\n src = ::Nokogiri::HTML(data)\n pdoc.properties[:title] = src.title\n extract_plaintext(src.root, pdoc)\n\n # css, js, images\n src.xpath('//link[@rel=\"stylesheet\"]').each do |t|\n pdoc.add_ext_ref(t[:href], PlanR::ParsedDocument::REF_STYLE)\n end\n\n src.xpath('//script[@src]').each do |t|\n pdoc.add_ext_ref(t[:src], PlanR::ParsedDocument::REF_SCRIPT)\n end\n\n src.xpath('//img[@src]').each do |t|\n pdoc.add_ext_ref(t[:src], PlanR::ParsedDocument::REF_IMAGE)\n end\n\n # links\n src.xpath('//a[@href]').each do |t|\n next if (t[:href].start_with? '#')\n next if (t[:href].start_with? 'mailto:')\n pdoc.add_ext_ref(t[:href], PlanR::ParsedDocument::REF_DOC)\n end\n\n # metadata\n meta = {}\n src.xpath('//meta').each do |t|\n last_name = name = value = nil\n t.attributes.each do |key, attr|\n if attr.name == 'content'\n value = attr.value\n elsif attr.name == 'name'\n name = attr.value\n else\n last_name = attr.value\n end\n end\n name = last_name if not name\n meta[name.downcase] = value if name && value\n end\n meta.fetch('keywords', '').split(',').each do |keyword|\n pdoc.keywords << keyword\n end\n pdoc.properties[:content_type] = meta.fetch('content-type', '')\n pdoc.properties[:description] = meta.fetch('description', '')\n end",
"def initialize_html_tags; end",
"def initialize(html, name, section, tagline, manual=nil, version=nil, date=nil)\n @buf = []\n title_heading name, section, tagline, manual, version, date\n doc = Hpricot(html)\n remove_extraneous_elements! doc\n normalize_whitespace! doc\n block_filter doc\n write \"\\n\"\n end",
"def initialize html\n @doc = to_doc html\n @additional_namespaces = []\n end",
"def to_html\n @html ||= format_html\n end",
"def generate_doc\n\n end",
"def rerdoc_task_description\n \"Rebuild RDoc HTML files\"\n end",
"def html(args)\n str = \"\"\n str << (@inden * level(args)) if pretty?(args)\n str << html_content\n str << @nl if pretty?(args)\n str\n end",
"def render_doc_markup_for(code_object)\n docs = docs_for(code_object)\n\n if code_object.command?\n # command '--help' shouldn't use markup highlighting\n docs\n else\n process_comment_markup(docs)\n end\n end",
"def html_from_template(filename, title, html)\n\t\tlevels = filename.count(\"/\") - 1\n\t\tcss_link = \"./\" + (\"../\" * levels) + \"css/style.css\"\n @template.result(:title => title, :css_link => css_link, :content => html)\n\tend",
"def convert_html(html)\n # Sanitize the html and surround in a <span> tag to make it work with htmltolatex better\n html = \"<span>\" + sanitize(html, :tags => %w(em i sup sub)) + \"</span>\"\n\n # Create the temp files and output the html source to the first one\n raw = Tempfile.new('htmltolatex_html')\n output = Tempfile.new('htmltolatex_tex')\n raw << html; raw.flush\n \n # Run htmltolatex on the source\n path = File.join(RAILS_ROOT, \"lib\", \"htmltolatex\")\n `cd #{path} && #{File.join(path, \"htmltolatex\")} -input #{raw.path} -output #{output.path}`\n\n # Read in the results\n converted = File.open(output.path, \"rb\") { |f| f.read }\n \n # Close and unlink the files\n raw.close!\n output.close!\n \n # Return the results\n converted\n end",
"def purify_html\n doc= Nokogiri::XML::DocumentFragment.parse(self.to_s)\n doc.search(\".//strong\").each do |e|\n e.swap \"<b>#{e.inner_html}</b>\"\n end\n doc.search(\".//h4\").each do |e|\n e.swap \"<b>#{e.inner_html}</b>\"\n end\n doc.search(\".//h3\").each do |e|\n e.swap \"<b>#{e.inner_html}</b>\"\n end\n doc.search(\".//h2\").each do |e|\n e.swap \"<b>#{e.inner_html}</b>\"\n end\n doc.search(\".//h1\").each do |e|\n e.swap \"<b>#{e.inner_html}</b>\"\n end\n\n doc.search(\".//em\").each do |e|\n e.swap \"<i>#{e.inner_html}</i>\"\n end\n\n doc.search(\".//ul\").each do |e|\n e.swap \"#{e.inner_html}\"\n end\n doc.search(\".//ol\").each do |e|\n e.swap \"#{e.inner_html}\"\n end\n doc.search(\".//li\").each do |e|\n e.swap \"<p>#{e.inner_html}</p>\"\n end\n doc.search(\".//span\").each do |e|\n e.swap \"#{e.inner_html}\"\n end\n\n doc.to_xml(:encoding => \"UTF-8\").gsub(/\\n/,\" \").gsub(/\\s+/,\" \")\n end",
"def to_html(content)\n case @parser\n when :kramdown, 'kramdown'\n require 'kramdown'\n Kramdown::Document.new(content).to_html\n when :redcarpet, 'redcarpet'\n require 'redcarpet'\n markdown = Redcarpet::Markdown.new(\n Redcarpet::Render::HTML,\n smart: true,\n no_intra_emphasis: true,\n fenced_code_blocks: true,\n autolink: true,\n tables: true,\n with_toc_data: true\n )\n\n # add smartypants support\n Redcarpet::Render::SmartyPants.render markdown.render(content)\n when :rdiscount, 'rdiscount'\n require 'rdiscount'\n RDiscount.new(content).to_html\n when :gfm, :github, :github_markdown, 'gfm', 'github_markdown'\n require 'github/markdown'\n GitHub::Markdown.render(content)\n end\n end"
] |
[
"0.7058627",
"0.69723195",
"0.6849613",
"0.6786844",
"0.6728627",
"0.6704008",
"0.6704008",
"0.6662671",
"0.65805125",
"0.65707463",
"0.65493983",
"0.65493983",
"0.65206885",
"0.6505184",
"0.6505184",
"0.64965785",
"0.6481695",
"0.64762354",
"0.646726",
"0.6440871",
"0.64143455",
"0.63128203",
"0.62584215",
"0.62529624",
"0.62492496",
"0.62485796",
"0.6210839",
"0.6184422",
"0.6179912",
"0.61712134",
"0.6165538",
"0.61557764",
"0.61445415",
"0.61384887",
"0.6135718",
"0.61347574",
"0.61347574",
"0.61347574",
"0.61308926",
"0.6129775",
"0.61007696",
"0.60998845",
"0.6092791",
"0.6067954",
"0.60353273",
"0.6033738",
"0.6029725",
"0.6029725",
"0.6029725",
"0.6029725",
"0.60291153",
"0.60244125",
"0.6018692",
"0.6018692",
"0.60179305",
"0.6016977",
"0.6001833",
"0.5986613",
"0.59567827",
"0.5945484",
"0.5945484",
"0.5933336",
"0.5929431",
"0.5919747",
"0.5916426",
"0.5913701",
"0.5912288",
"0.5909465",
"0.58826965",
"0.5882677",
"0.5876972",
"0.58527976",
"0.58471054",
"0.5842386",
"0.5833997",
"0.5833587",
"0.58299106",
"0.5817336",
"0.5815632",
"0.58087254",
"0.58035094",
"0.5799828",
"0.5793447",
"0.57812876",
"0.57810205",
"0.57796",
"0.57796",
"0.57770425",
"0.5773003",
"0.5755638",
"0.5748718",
"0.573982",
"0.5734977",
"0.5731886",
"0.57278365",
"0.57260966",
"0.57225055",
"0.5714518",
"0.57064843",
"0.570126"
] |
0.76175046
|
0
|
If the URL is passed in, we have acccess to it
|
def url
@url ||= args.dig(:url)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def get(url); end",
"def url=(_arg0); end",
"def url=(_arg0); end",
"def url=(_arg0); end",
"def url=(_arg0); end",
"def url=(_arg0); end",
"def url=(_arg0); end",
"def url=(_arg0); end",
"def url\n end",
"def consume_url; end",
"def requested_url\n raise \"URL could not be detected.\" unless @args[:request_args][:url]\n @args[:request_args][:url]\n end",
"def URI(url); end",
"def url_provided?\n @url = params[:url]\n @url.present? && @url.strip\n end",
"def uri(the_url)\n case @url_method\n when :graphical\n self.class.uri_graphical(the_url)\n when :text\n case the_url.to_s\n when /^http/\n puts \"USER ACTION: please enter this url in a browser:\\n\"+the_url.to_s.red()+\"\\n\"\n else\n puts \"USER ACTION: open this:\\n\"+the_url.to_s.red()+\"\\n\"\n end\n else\n raise StandardError,\"unsupported url open method: #{@url_method}\"\n end\n end",
"def to(url); end",
"def url; end",
"def url; end",
"def url; end",
"def url; end",
"def url; end",
"def url; end",
"def url; end",
"def url; end",
"def url; end",
"def url; end",
"def url; end",
"def url; end",
"def url; end",
"def url; end",
"def url; end",
"def url; end",
"def url; end",
"def url; end",
"def url; end",
"def url\n raise\n end",
"def url\n end",
"def link() url; end",
"def link() url; end",
"def redirect(url); end",
"def url=(_); end",
"def get(url)\n raise \"Needs to be implemented\"\n end",
"def url\n params.require(:url)\n end",
"def fetch_file_by_url\n if (self.url)\n self.file = self.url\n end\n end",
"def geturl() \n\t\treturn self.response.geturl()\n end",
"def url\n @url ||= params['url']\n end",
"def goto_url(url)\n response = Net::HTTP.get_response(URI.parse(url))\n status = response.code.to_i\n \n if status >= 300 and status < 400\n url = response['Location']\n # TODO - put general url beggining instead\n url = \"http://magiccards.info\" + url unless url.start_with?('http://')\n goto_url(url)\n else\n return url, response.body\n end\n end",
"def get_file(url); end",
"def get_url\n @url\n end",
"def visited_page(url); end",
"def visited_page(url); end",
"def url(url)\n @url = url\n end",
"def url?\n !url.nil?\n end",
"def ensure_http \n url.ensure_http\n end",
"def perform_action_url\n begin\n if @urls.has_key?('Action')\n return request(@urls['Action'], {}, {}, METHOD_GET)\n end\n rescue\n raise RETSException.new(\"Unable to follow action URL: '#{$!}'.\")\n end\n end",
"def url\n raise NotImplementedError, 'this should be overridden by subclass'\n end",
"def do_get url\n\t\turi = URI.parse(url)\n\t\tNet::HTTP.get_response(uri)\n\tend",
"def url\n @url\n end",
"def url\n @url\n end",
"def process_uri(uri)\n # empty --> this is like an abstract class method\n end",
"def option(url, token); end",
"def url\n raise \"Implement in child class\"\n end",
"def url_for(url) url end",
"def set_url\n @url = Url.find(params[:id])\n raise ActiveRecord::RecordNotFound if @url.nil?\n\n authorize @url unless @url.nil?\n @url_identifier = @url.id\n end",
"def open(url)\n Net::HTTP.get(URI.parse(url))\nend",
"def open(url)\n Net::HTTP.get(URI.parse(url))\nend",
"def open(url)\n super\n assert_page_loaded\n end",
"def url\n @url\n end",
"def consume_bad_url; end",
"def original_url; end",
"def url?\n !urn?\n end",
"def set_url\n # @url = Url.find(params[:id])\n end",
"def url_valid?\n uri = URI(full_url)\n Net::HTTP.start(uri.host, uri.port, :use_ssl => full_url.start_with?(\"https\")) do |http|\n response = http.request_get(full_url)\n return response.is_a?(Net::HTTPOK) || response.is_a?(Net::HTTPRedirection)\n end\n end",
"def get(url)\n call(url: url)\n end",
"def process_url(url)\n begin\n\n # the following scans\n url_kind_normalized = is_valid_url(url, nil)\n url_kind = url_kind_normalized[0]\n url = url_kind_normalized[1] ## normalized i.e. canonical format\n\n unless [:ref_static_content, :not_valid_url].include?(url_kind)\n if ::Crawl::Db::SiteMap.internal_links[url] || ::Crawl::Db::SiteMap.non_internal_links[url] || should_skip(url)\n # already scanned, we could bump the count if needed\n # if skip just skip!\n else\n # scan it and all its nested pages\n navigate_to_url_and_validate_that_url_was_found( url )\n page_content = browser.html\n @@page_scanner.scan_content(page_content, url)\n end\n end\n\n rescue StandardError => err\n puts \"Err: on url #{url} received: #{err}\"\n end\n\n end",
"def getURL\r\n\t\t\t\t\treturn @url\r\n\t\t\t\tend",
"def getURL\r\n\t\t\t\t\treturn @url\r\n\t\t\t\tend",
"def getURL\r\n\t\t\t\t\treturn @url\r\n\t\t\t\tend",
"def getURL\r\n\t\t\t\t\treturn @url\r\n\t\t\t\tend",
"def getURL\r\n\t\t\t\t\treturn @url\r\n\t\t\t\tend",
"def perform(url)\n scrape_url(url)\n end",
"def open?(uri); end",
"def valid_url?\n # Not sure if we should make a change in the user initial data, we could just return as invalid.\n my_target_url = target_url.match(/http/) ? target_url : target_url.prepend(\"http://\")\n\n response = HTTParty.get(my_target_url) rescue nil\n\n return if response&.code == 200\n\n errors.add(:short_url)\n end",
"def get url\n url = URI url\n request = HTTP::Get.new url.path\n\n dispatch request, to: url\n end",
"def url; (page.url rescue ''); end",
"def url; (page.url rescue ''); end",
"def error(url); end",
"def get_url path\n\t\t\t\t@browser.get path, {}, {'REQUEST_URI' => ['http://example.org', path].join('/')}\n\t\t\t\tresponse = @browser.last_response\n\t\t\t\tresponse.body\n\t\t\tend",
"def url(*args)\n content.url(*args)\n end",
"def request_url(requirelogin=false, requireuserinfo=false, expirationdays=30, notifyonupload=false)\n end",
"def bind(url); end",
"def setURL(url)\r\n\t\t\t\t\t@url = url\r\n\t\t\t\tend",
"def setURL(url)\r\n\t\t\t\t\t@url = url\r\n\t\t\t\tend",
"def setURL(url)\r\n\t\t\t\t\t@url = url\r\n\t\t\t\tend",
"def setURL(url)\r\n\t\t\t\t\t@url = url\r\n\t\t\t\tend",
"def setURL(url)\r\n\t\t\t\t\t@url = url\r\n\t\t\t\tend",
"def error!(url); end",
"def external_link\n\n url = params[:url]\n if url.nil?\n render :nothing => true\n return\n end\n\n ExternalLinkLog.log url, request, current_user\n\n redirect_to url\n\n end",
"def get_single_url(url)\n\n useragent = \"NotubeMiniCrawler/0.1\"\n u = URI.parse url \n req = Net::HTTP::Get.new(u.request_uri,{'User-Agent' => useragent})\n begin \n res2 = Net::HTTP.new(u.host, u.port).start {|http|http.request(req) }\n end\n\n r = \"\"\n begin\n r = res2.body\n rescue OpenURI::HTTPError=>e\n case e.to_s \n when /^404/\n raise 'Not Found'\n when /^304/\n raise 'No Info'\n end\n end\n return r\n end",
"def is_url?\n path =~ URL_PATHS\n end",
"def sub_url (p)\n res = (p != \"\") ? \"http://\" + request.host + \":3000\" + p.sub(\"/execute/\", \"/rest2/\") : p\n end"
] |
[
"0.7153592",
"0.6825004",
"0.6825004",
"0.6825004",
"0.6825004",
"0.6825004",
"0.6825004",
"0.6825004",
"0.67207295",
"0.67093533",
"0.67057323",
"0.6599387",
"0.6580039",
"0.6557931",
"0.6557606",
"0.65307903",
"0.65307903",
"0.65307903",
"0.65307903",
"0.65307903",
"0.65307903",
"0.65307903",
"0.65307903",
"0.65307903",
"0.65307903",
"0.65307903",
"0.65307903",
"0.65307903",
"0.65307903",
"0.65307903",
"0.65307903",
"0.65307903",
"0.65307903",
"0.65307903",
"0.64618504",
"0.644257",
"0.6428455",
"0.6428455",
"0.64048713",
"0.63198316",
"0.63180226",
"0.62913287",
"0.62823826",
"0.62528497",
"0.6192406",
"0.6187431",
"0.6139214",
"0.6134669",
"0.6111403",
"0.6111403",
"0.61074",
"0.6097493",
"0.6085755",
"0.6068323",
"0.60262525",
"0.60194606",
"0.60164046",
"0.60164046",
"0.60101295",
"0.6005535",
"0.5993351",
"0.5992733",
"0.5989983",
"0.5988446",
"0.5988446",
"0.59748983",
"0.59738684",
"0.5973163",
"0.59697807",
"0.5962735",
"0.5962108",
"0.5959855",
"0.5959318",
"0.5948633",
"0.5943397",
"0.5943397",
"0.5943397",
"0.5943397",
"0.5943397",
"0.5940547",
"0.5936765",
"0.5936032",
"0.5912178",
"0.59028614",
"0.59028614",
"0.590105",
"0.58997756",
"0.5891723",
"0.5889937",
"0.5888707",
"0.58881307",
"0.58881307",
"0.58881307",
"0.58881307",
"0.58881307",
"0.58798045",
"0.5873004",
"0.58706343",
"0.5864245",
"0.58639127"
] |
0.638162
|
39
|
fetching common header for different variations
|
def convert_header(h)
changed_header = h.to_s.downcase.gsub('-', '').gsub(' ','_')
(User::HEADERS[changed_header].present? ? User::HEADERS[changed_header] : changed_header).intern
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def headers; end",
"def headers; end",
"def headers; end",
"def headers; end",
"def headers; end",
"def headers; end",
"def headers; end",
"def headers; end",
"def headers; end",
"def headers; end",
"def headers; return {}; end",
"def headers; return {}; end",
"def read_headers!; end",
"def parse_header_contents; end",
"def getSecondHeader() @header2 end",
"def getHeader() @header1 end",
"def raw_headers; end",
"def headers\n end",
"def get_header(*params); raise('Stub or mock required.') end",
"def parsed_content_type_header; end",
"def headerlist; return ['X-MXL-NoteHash', 'X-MXL-Hash', 'X-MX-Bounce']; end",
"def request_headers; end",
"def request_headers; end",
"def default_headers\n description_look_up do |metadata|\n metadata[:headers] if metadata[:headers]\n end\n end",
"def headers\r\n # give access to helpers to opts with a different name\r\n @opts\r\n end",
"def fill_header(response); end",
"def second_life_header_map\n {\n 'HTTP_X_SECONDLIFE_OBJECT_NAME' => :object_name,\n 'HTTP_X_SECONDLIFE_OBJECT_KEY' => :object_key,\n 'HTTP_X_SECONDLIFE_REGION' => :region,\n # 'HTTP_X_SECONDLIFE_LOCAL_POSITION' => :position,\n 'HTTP_X_SECONDLIFE_OWNER_KEY' => :avatar_key\n }\nend",
"def headers=(_arg0); end",
"def headers=(_arg0); end",
"def headers=(_arg0); end",
"def headers=(_arg0); end",
"def default_http_header; end",
"def pull_headers\n header_str = \"\"\n ['h1','h2','h3'].each do |html_tag|\n html = URI.parse(self.personal_website_url).open\n header_str += Nokogiri::HTML.parse(html).css(html_tag).map(&:text).join(' | ')\n end\n self.headers = header_str\n end",
"def headers(headers); end",
"def ns_headers(long) \n if long\n return { \n \"Content-Type\" => \"application/json\",\n \"Authorization\" => NSConnector::Restlet.auth_header \n }\n else\n return {\n \"Accept\" => \"application/json\" \n }\n end\n end",
"def procore_headers(company_id: nil, token: '')\n if company_id.nil?\n {\n \"Authorization\": \"Bearer #{token}\",\n \"Content-Type\": \"application/json\",\n }\n else\n {\n \"Authorization\": \"Bearer #{token}\",\n \"Content-Type\": \"application/json\",\n \"Procore-Company-Id\": \"#{company_id}\"\n }\n end\nend",
"def headers\n # units and source have to go last, so if we push in a new header, these go\n # at end\n @headers+['units','source']\n end",
"def join_headers; end",
"def get_ordered_headers\n headers = get_headers\n template_headers = get_template_headers\n ordered_headers = ['druid', 'sourceId']\n # Select only headers with values somewhere in the data\n template_headers.each {|th| ordered_headers << th if headers.include?(th)}\n ordered_headers\n end",
"def header(name)\n @response[name]\n end",
"def header(name)\n rack_header = \"http-#{name}\".upcase!.tr('-', '_')\n\n hdr = @env[rack_header]\n\n # Only return the value if it is not an empty string\n hdr if hdr != ''\n end",
"def processed_headers; end",
"def default_headers(current_time)\n {}.tap do |def_headers|\n def_headers['User-Agent'] = Azure::Core::Default::USER_AGENT\n def_headers['x-ms-date'] = current_time\n def_headers['x-ms-version'] = '2014-02-14'\n def_headers['DataServiceVersion'] = '1.0;NetFx'\n def_headers['MaxDataServiceVersion'] = '3.0;NetFx'\n def_headers['Content-Type'] = 'application/atom+xml; charset=utf-8'\n end\n end",
"def get_headers_\n hin = ATS::Headers_in.new\n hin.all.reduce({}) do |memo, pair| \n memo[pair.first.downcase] = pair[1]; memo\n end\n end",
"def get_response_header(response)\n raise \"REST response was nil\" if response == nil\n raise \"REST response had no attached header\" if response.headers == nil\n begin\n header = response.headers # already in Ruby Hash format\n set_all_defaults(body)\n rescue JSON::ParserError => e\n puts \"rescued : ParserError\"\n puts e\n header = response.headers\n end\n header\n end",
"def actual_header\n data.lines.first.chomp\n end",
"def headerlist; return ['X-ZohoMail']; end",
"def get_headers\nheader_values = {}\n i = 1\n # while !params[:header][:type_.to_s + \"#{i}\"].nil?\n while !params[:header_values_.to_s + \"#{i}\"].nil?\n\t value = params[:header_values_.to_s + \"#{i}\"].map!{|i| CGI::unescape(i).gsub(\"\\\"\", \"'\")}\n \theader_values[params[:header][:type_.to_s + \"#{i}\"]] = value\n i += 1\n end\n header_values\nend",
"def get_header(name)\n headers.each do |key,value|\n if key.casecmp(name) == 0\n return value\n end\n end\n nil\n end",
"def get_headers(r_name = nil)\n opts = {}\n if current_service_session\n opts[:l_firm] = current_service_session.assignment.nil? ? current_service_session.user.company_full_name : current_service_session.assignment.user.company_full_name\n opts[:lawyer] = current_service_session.assignment.nil? ? current_service_session.user.try(:full_name) : current_service_session.assignment.try(:user).try(:full_name)\n else\n opts[:l_firm] = current_user.end_user.company.name\n opts[:lawyer] = current_user.end_user.try(:full_name)\n end\n opts[:r_name] = r_name\n opts[:user] = current_user.name.try(:capitalize) if current_user\n opts\n end",
"def str_headers(env, status, headers, res_info, lines, requests, client); end",
"def vary_headers; end",
"def generic_Generate_Headers(body)\n\theaders = ''\n\theaders << \"Server: #{Socket.ip_address_list.select{|x| x.ipv4_private?}[0].ip_address}\\r\\n\"\n\theaders << \"Date: #{Time.now.ctime}\\r\\n\"\n\tif body.length>0\n\t\theaders << \"Content-Type => text/html\\r\\n\"\n\t\theaders << \"Content-Length => #{body.size}\\r\\n\"\n\tend\n\treturn headers\nend",
"def parse_setext_header; end",
"def get\n @keys.each do |key|\n short_name = key.split('.').last\n @header << (@header.include?(short_name) ? key : short_name)\n end\n @header.join(',') + \"\\n\"\n end",
"def header; end",
"def header; end",
"def header; end",
"def provided_headers\n @provided_headers ||= data_file.peek.headers\n end",
"def is_header()\n\t\tend",
"def response_header(node)\n node = node.is_a?(Array) ? node.last : node\n\n {\n 'Content-Type' => 'application/json',\n 'X-Etcd-Index' => node['createdIndex'],\n 'X-Raft-Index' => 300000 * rand,\n 'X-Raft-Term' => 4\n }\n end",
"def getHeader()\n header = \"\"\n\n appendStr(header, \"time\")\n appendStr(header, \"seqno\")\n $cmd_list.each do | name, cmd, type |\n appendStr(header, name)\n end\n return header\nend",
"def get_header name\n request_object.headers[name]\n end",
"def header(name)\n @responseheaders[name.downcase]\n end",
"def add_headers; end",
"def test_data_headers(string)\n\n\t\theaders = test_data_response(string).headers\n\n\tend",
"def header(nheaders,hname)\n\t\t\tnheaders.each_line do |lh|\n\t\t\t\tn,v = lh.split(\": \")\n\t\t\t\tif n == hname\n\t\t\t\t\treturn v\n\t\t\t\tend\n\t\t\tend\n\t\t\treturn hstr\n\t\tend",
"def headers_for_url(url)\n self.hr_config.get_for_url(url, :headers)\n end",
"def headers\n cfg_get(:headers)\n end",
"def headers\n @headers ||= self.class.beautify_headers(@net_http_res.to_hash)\n end",
"def set_header_options(curl)\n summary = summary_for_feed\n \n unless summary.nil?\n curl.headers['If-None-Match'] = summary[:etag] unless summary[:etag].nil?\n curl.headers['If-Modified-Since'] = summary[:last_modified] unless summary[:last_modified].nil?\n end\n \n curl\n end",
"def headers(request)\n raise NotImplementedError\n end",
"def get_headers\n @headers = headers\n @headers\n end",
"def read_header(absfilepath)\n tmp_filename= File.basename(absfilepath)\n \n case File.basename(absfilepath)\n when /^P.{5}\\.7$|^I\\..{3}/\n # check for \n # Try reading Pfiles or Genesis I-Files with GE's printraw\n # printraw works on the new waisman p-files\n # rdgehdr works on wimr p-files, and old waisman p-files \n @current_hdr_reader = PRINTRAW\n #puts \"aaaaaaa absfilepath=\"+absfilepath\n header = `#{PRINTRAW} '#{absfilepath}' 2> /dev/null`\n #header = `#{RDGEHDR} #{absfilepath}`\n # puts \"bbbbb pfile header=\"+header\n header = header.encode(\"UTF-8\", :invalid => :replace, :undef => :replace, :replace => \"\").force_encoding('UTF-8')\n if ( header.chomp != \"\" and\n header.length > MIN_HDR_LENGTH )\n @current_hdr_reader = nil\n return [ header, PRINTRAW ]\n end\n when /^ScanArchive_.{10,}\\.h5\\.json$/\n json_file = File.read(absfilepath)\n data_hash = JSON.parse(json_file)\n ####header =\"se_desc = \"+data_hash[\"SERIES INFORMATION\"][\"Series Desc\"]+\"\n####image_uid = \"+data_hash[\"RHUSER and OPUSER INFORMATION\"][\"imagehead.image_uid\"]+\"\\n\"\n ## if ( header.chomp != \"\" )#and header.length > MIN_HDR_SUMMARY_LENGTH )\n if !data_hash.nil?\n @current_hdr_reader = nil\n # puts data_hash.to_s\n # FAILING IN HEADER READ - WHERE IS THE HEADER TRYING TO GET READ? NOT STOPING AT PRINTRAW_SUMMARY\n # CAN THE data_hash be passed instead of the header, and then read in the header_json_reader?\n return [data_hash, nil] ###PRINTRAW_H5_JSON ]\n ###return [ header, PRINTRAW_H5_JSON ]\n end\n # need to read json\n # create header\n when /^P.{5}\\.7\\.summary/\n # check for \n @current_hdr_reader = PRINTRAW_SUMMARY\n # puts \"aaaaaaa summary absfilepath=\"+absfilepath\n header = `#{PRINTRAW_SUMMARY} '#{absfilepath}' 2> /dev/null`\n header = header.encode(\"UTF-8\", :invalid => :replace, :undef => :replace, :replace => \"\").force_encoding('UTF-8')\n if ( header.chomp != \"\" and\n header.length > MIN_HDR_SUMMARY_LENGTH )\n @current_hdr_reader = nil\n return [ header, PRINTRAW_SUMMARY ]\n end\n\n # Try reading Pfiles or Genesis I-Files with GE's rdgehdr -- rdgehdr newer version needs macos 10.8, adrcdev2 = 10.7.5 - \n # works on old headers, not on new header format\n ###@current_hdr_reader = RDGEHDR\n ###header = `#{RDGEHDR} '#{absfilepath}' 2> /dev/null`\n #header = `#{RDGEHDR} #{absfilepath}`\n ###if ( header.chomp != \"\" and\n ### header.length > MIN_HDR_LENGTH )\n ### @current_hdr_reader = nil\n ### return [ header, RDGEHDR ]\n ### end\n else\n # Try reading with RubyDICOM\n @current_hdr_reader = RUBYDICOM_HDR\n ####header = DICOM::DObject.new(absfilepath) # changing from dicom 0.8.0 to 0.9.5\n header = DICOM::DObject.read(absfilepath)\n\n if defined? header.read_success && header.read_success\n @current_hdr_reader = nil\n return [header, RUBYDICOM_HDR] \n end\n \n # Try reading with AFNI's dicom_hdr\n @current_hdr_reader = DICOM_HDR\n header = `#{DICOM_HDR} '#{absfilepath}' 2> /dev/null`\n #header = `#{DICOM_HDR} #{absfilepath}`\n if ( header.index(\"ERROR\") == nil and \n header.chomp != \"\" and \n header.length > MIN_HDR_LENGTH )\n @current_hdr_reader = nil\n return [ header, DICOM_HDR ]\n end\n end\n\n @current_hdr_reader = nil\n return [ nil, nil ]\n end",
"def find_header(header)\n {}.tap do |returning|\n contents.scan(header_with_content_regexp(header)).flatten.first.split(\"\\n\").each do |setting|\n name, value = *setting.split('=').map(&:strip)\n returning[name] = value\n end\n end\n end",
"def get_header_and_body\n headers, body = {}, \"\"\n until line = @socket.gets and line.chomp.empty?\n if (kv = line.chomp.split(/:\\s+/,2)).size == 2\n headers.store *kv\n end\n end\n if (content_length = headers[\"Content-Length\"].to_i) > 0\n Log.debug \"content_length is #{content_length}, grabbing from socket\"\n body << @socket.read(content_length)\n end\n headers.merge(\"body\" => body.strip)\n end",
"def run\n\n response = http_fetch(@entity.name)\n\n # Shortcut\n if response\n response.each_header do |name,value|\n create_entity(Entities::WebApplicationHeader, {\n :name => \"#{name}: #{value}\", \n :content => \"#{name}: #{value}\" })\n end\n end\n\nend",
"def resolve_headers(view_context); end",
"def formulate_headers(auth_header)\n {\n 'Content-Type' => 'application/json',\n 'Authorization' => auth_header,\n 'Content-Encoding' => 'gzip',\n 'Accept' => 'application/json'\n }\n end",
"def headers(hds = @supplied_heads)\n\n case type\n when \"file\"\n case method\n when \"post\", \"put\"\n hds['Content-Type'] ||= 'binary/octet-stream' if !hds.has_key?('Content-Type')\n hds['Content-MD5'] ||= Digest::MD5.hexdigest(File.read(@filepath)) if !hds.has_key?('Content-MD5')\n hds['Content-Disposition'] ||= \"attachment; filename=\" + File.basename(@filepath).to_s if !hds.has_key?(\"Content-Disposition\")\n #hds['Packaging'] ||= \"http://purl.org/net/sword/package/Binary\" if !hds.has_key?('Packaging')\n end\n\n when \"atom\"\n hds['Content-Type'] ||= \"application/atom+xml\"\n\n when \"multipart\"\n hds['Content-Type'] ||= \"application/zip\"\n hds['X-Packaging'] ||= \"http://purl.org/net/sword-types/METSDSpaceSIP\"\n end\n\n hds\n end",
"def vary_headers=(_arg0); end",
"def get_http_header line\n return nil if not is_http_header? line\n parts = line.split(':')\n {parts[0].strip => parts[1].strip}\n end",
"def header\n return @header\n end",
"def headers\n @headers.tap do |headers|\n headers[:algorithm] = configuration.algorithm if verification?\n case configuration.claim\n when CLAIM_EXPIRATION_TIME\n headers.merge!(exp_headers)\n when CLAIM_NOT_BEFORE_TIME\n headers.merge!(nbf_headers)\n end\n end\n end",
"def get_request_header(hid = false)\n header = Hash.new\n\n case get_carrier()\n when CARRIER_KDDI\n header['X-UP-SUBNO'] = self[:uid]\n when CARRIER_SOFTBANK\n header['X-JPHONE-UID'] = self[:uid]\n end if has_key?(:uid)\n\n header['User-Agent'] = get_useragent(hid)\n\n @props[:exheader].split(\"\\r\\n\").each do |field|\n key,value = field.split(':')\n unless key.nil? || value.nil?\n header[key.strip] = value.strip\n end\n end\n\n header\n end",
"def is_header?(); @type == GRT_HEADER; end",
"def get_header(product_code)\n check_parameter('product_code', product_code, String)\n\n request_url = \"#{@data_api_url}#{product_code}/?format=json&page=1&api_key=#{@api_key}\"\n response = Faraday.get(request_url)\n JSON.parse(response.body)[0].keys\n end",
"def getHTTPHdrs(url)\n uri = URI.parse(url)\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = uri.scheme == 'https'\n request = Net::HTTP::Head.new(uri.request_uri)\n http.request(request)\nend",
"def header(key)\n return false unless headers.key?(key)\n\n headers.fetch(key).first.to_s\n end",
"def seperate_headers()\n\t\t@stream.split(\"\\n\\n\")[0].split(\"\\n\", 2)[1]\n\tend",
"def parse_header(line)\n if (match = line.match(/^(.+?):\\s*(.+)#{@nl}$/))\n key = match[1].downcase\n set_header_special_values(key, match[2])\n parse_normal_header(line, key, match[1], match[2])\n elsif (match = line.match(/^HTTP\\/([\\d\\.]+)\\s+(\\d+)\\s+(.+)$/))\n @response.code = match[2]\n @response.http_version = match[1]\n @http2.on_content_call(@args, line)\n else\n raise \"Could not understand header string: '#{line}'.\"\n end\n end",
"def header(_content)\n raise NotImplementedError\n end",
"def request_headers\n { 'Accept-Encoding'=>'gzip, deflate', 'User-Agent'=>'Ruby'}\n end",
"def get_header(body_bytesize_length)\r\n # We would like each request to be sent with the current time\r\n date = rfc1123date()\r\n\r\n return {\r\n 'Content-Type' => 'application/json',\r\n 'Authorization' => signature(date, body_bytesize_length),\r\n 'Log-Type' => @logstashLoganalyticsConfiguration.custom_log_table_name,\r\n 'x-ms-date' => date,\r\n 'time-generated-field' => @logstashLoganalyticsConfiguration.time_generated_field,\r\n 'x-ms-AzureResourceId' => @logstashLoganalyticsConfiguration.azure_resource_id\r\n }\r\n end",
"def return_headers?() @return_headers end",
"def http_header(field=nil, value=nil)\n @_http_header ||= {}\n @_http_header[field] = value if field\n @_http_header\n end",
"def parse_atx_header; end",
"def headers\n @headers ||= {}\n end",
"def header(haders, name)\n headers[name]\n end",
"def header; message[:header]; end",
"def headers\r\nHttp::Headers.new(@env)\r\nend"
] |
[
"0.6980834",
"0.6980834",
"0.6980834",
"0.6980834",
"0.6980834",
"0.6980834",
"0.6980834",
"0.6980834",
"0.6980834",
"0.6980834",
"0.6933759",
"0.6933759",
"0.6880598",
"0.68688357",
"0.6864616",
"0.6849195",
"0.67337555",
"0.6710942",
"0.66297835",
"0.66213477",
"0.65582484",
"0.65502",
"0.65502",
"0.6516144",
"0.65157086",
"0.65074825",
"0.64986914",
"0.64872485",
"0.64872485",
"0.64872485",
"0.64872485",
"0.64841807",
"0.6476386",
"0.6420249",
"0.64136386",
"0.638162",
"0.63564944",
"0.6340203",
"0.6339728",
"0.6338541",
"0.63351125",
"0.6309545",
"0.6291962",
"0.6268113",
"0.62610054",
"0.62468433",
"0.6245184",
"0.62362736",
"0.6235762",
"0.6199788",
"0.6174875",
"0.6160021",
"0.613762",
"0.61364",
"0.6113473",
"0.61079985",
"0.61079985",
"0.61079985",
"0.60984814",
"0.6094674",
"0.6075023",
"0.6071397",
"0.6065064",
"0.6057519",
"0.60555583",
"0.605044",
"0.60384524",
"0.6036223",
"0.60347366",
"0.6032977",
"0.60284275",
"0.6028352",
"0.602529",
"0.6025227",
"0.6022198",
"0.6012449",
"0.60073775",
"0.60033673",
"0.60022485",
"0.5992087",
"0.598593",
"0.598159",
"0.59810257",
"0.59807426",
"0.59781975",
"0.59736645",
"0.5969242",
"0.5967941",
"0.596133",
"0.5958023",
"0.59549093",
"0.5946784",
"0.5946119",
"0.59448975",
"0.5944531",
"0.59375906",
"0.59354347",
"0.5927342",
"0.5913122",
"0.5907951",
"0.5892308"
] |
0.0
|
-1
|
GET /file_list_items GET /file_list_items.xml
|
def index
@file_list = UploadedFileList.find(params[:uploaded_file_list_id])
@file_list_items = @file_list.file_list_items.find(:all)
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @file_list_items }
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def show\n @file_list = UploadedFileList.find(params[:uploaded_file_list_id])\n @file_list_item = @file_list.file_list_items.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @file_list_item }\n end\n end",
"def index\n @list = List.find(params[:list_id])\n @list_items = @list.list_items.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @list_items }\n end\n end",
"def get_files_list(request)\n http_request = request.to_http_info(@api_client.config)\n make_request(http_request, :GET, 'FilesList')\n end",
"def index\n @uploaded_files = @page.uploaded_files.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @uploaded_files }\n end\n end",
"def file_list\n end",
"def path\n \"/{databaseId}/items/list/\"\n end",
"def list\n call(:get, path)\n end",
"def get_file_listing\n execute!(drive.files.list).data\n end",
"def files_list(params = {})\n response = @session.do_post \"#{SCOPE}.list\", params\n Slack.parse_response(response)\n end",
"def index\n @wx_files = File.all\n end",
"def index\n @list = List.find(params[:list_id])\n @items = @list.items\n\n respond_with @items\n end",
"def parse_list_response(xml)\n [ nodes_for(xml, 'files').collect{ |node| File.new(self, node) },\n nodes_for(xml, 'folders').collect{ |node| Folder.new(@rc, self, node) } ]\n end",
"def index\n @title = \"User uploaded files\"\n get_files(params)\n end",
"def list\n files_mask = \"*.xml\"\n if current_user.role != \"admin\"\n files_mask = \"#{current_user.fileprefix}-*.xml\"\n end\n pending_path = ENV[\"EAD_XML_PENDING_FILES_PATH\"] + \"/#{files_mask}\"\n Rails.logger.info(\"Loading pending files at #{pending_path}\")\n\n file_list = []\n Dir[pending_path].each do |file|\n file_info = {\n name: File.basename(file, \".xml\"),\n timestamp: File.mtime(file),\n display_date: File.mtime(file).strftime(\"%Y-%m-%d %I:%M %p\")\n }\n file_list << file_info\n end\n file_list.sort_by! {|x| x[:timestamp]}.reverse!\n\n @presenter = UploadPresenter.new()\n @presenter.configure(pending_path, file_list, current_user)\n render\n rescue => ex\n render_error(\"list\", ex, current_user)\n end",
"def list\n ret = get()\n return [] if ret.is_a? Hash and ret.has_key? :error\n ret.map{|i| FileItem.new(i)}\n end",
"def index\n raise ArgumentError, 'Missing file parameter' if filename.blank?\n\n @available_in_workspace = Dor::Services::Client.object(params[:item_id]).files.list.include?(filename)\n\n respond_to do |format|\n format.html { render layout: !request.xhr? }\n end\n end",
"def list_files\n User.sync_files!(@context)\n files = user_real_files(params, @context)\n\n if unsafe_params[:limit] && unsafe_params[:offset]\n files = files.limit(unsafe_params[:limit]).offset(unsafe_params[:offset])\n end\n\n search_string = params[:search_string].presence || \"\"\n\n result = files.eager_load(:license, user: :org).\n where(\"nodes.name LIKE ?\", \"%#{search_string}%\").\n order(id: :desc).map do |file|\n describe_for_api(file, unsafe_params[:describe])\n end.compact\n\n render json: unsafe_params[:offset]&.zero? ? { objects: result, count: result.length } : result\n end",
"def index\n @file_attachments = FileAttachment.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @file_attachments }\n end\n end",
"def file_list\n @file_list\n end",
"def index\n @inventory_files = InventoryFile.page(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @inventory_files }\n end\n end",
"def index\n @data_files = DataFile.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @data_files }\n end\n end",
"def index\n @file_uploads = FileUpload.find(:all)\n\n respond_to do |wants|\n wants.html # index.html.erb\n wants.xml { render :xml => @file_uploads }\n end\n end",
"def filelist\n puts_message \"filelist start\" \n\n user = current_user\n\n request = params[:request].force_encoding(\"UTF-8\")\n puts_message \"Requested Path: \" + params[:request]\n \n if user and check_existance_of_path(request) \n if request == nil\n @file_names = 'error'\n elsif request_is_directory?(request)\n fire_the_list(request)\n # @file_names = absolute_path(request)\n elsif request_is_file?(request)\n last = request.split('/').last\n path = absolute_path(request)\n send_file_info(last, request) \n else\n @file_names = 'error'\n end\n else \n @file_names = 'error'\n end\n\n puts_message \"filelist end\" \n \n @output = <<-END\n\n END\n \n if request == \"/images/\"\n @folders = Folder.all(:user_id => current_user.id)\n \n @output << \"photo\" + \"\\n\"\n \n @folders.each do |f|\n @output << f.name + \"\\n\"\n end\n \n @file_names = @output\n end\n \n return @file_names\n\n end",
"def download_list\n task = params[:task]\n files = []\n\n case task\n when DOWNLOAD_ACTION, OPEN_ACTION, COPY_ACTION, COPY_TO_PRIVATE_ACTION\n nodes = Node.accessible_by(@context).where(id: params[:ids])\n nodes.each { |node| files += node.is_a?(Folder) ? node.all_files : [node] }\n when PUBLISH_ACTION\n nodes = Node.editable_by(@context).\n where(id: params[:ids]).\n where.not(scope: UserFile::SCOPE_PUBLIC)\n nodes.each do |node|\n files += if node.is_a?(Folder)\n node.all_files(Node.where.not(scope: UserFile::SCOPE_PUBLIC))\n else\n [node]\n end\n end\n when DELETE_ACTION\n nodes = Node.editable_by(@context).where(id: params[:ids]).to_a\n files += nodes\n nodes.each { |node| files += node.all_children if node.is_a?(Folder) }\n files.filter! { |file| file.scope == params[:scope] }\n else\n raise ApiError, \"Parameter 'task' is not defined!\"\n end\n\n render json: files,\n each_serializer: FileActionsSerializer,\n scope_name: params[:scope] || SCOPE_PRIVATE,\n action_name: task\n end",
"def index\n @file_links = FileLink.all\n end",
"def index\n @inventory_files = InventoryFile.page(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n end\n end",
"def files(params = {}, &block)\n params = convert_params(params)\n return execute_paged!(\n :api_method => self.drive.files.list,\n :parameters => params,\n :converter => proc(){ |af| wrap_api_file(af) },\n &block)\n end",
"def show\n @breadcrumb = 'read'\n @processed_file = ProcessedFile.find(params[:id])\n @processed_file_items = @processed_file.processed_file_items.paginate(:page => params[:page], :per_page => per_page)\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @processed_file }\n end\n end",
"def show\n @file_item = FileItem.cs(self.current_scope).find_by_path(params[:id])\n\n respond_to do |format|\n format.html do\n case @file_item.item_type\n when Saphira::FileItem::TYPE_FOLDER\n @file_items = @file_item.children\n render :action => 'index'\n else\n render\n end\n end\n format.json { render :json => @file_item }\n end\n end",
"def list\n url = prefix + \"list\"\n return response(url)\n end",
"def files\n return get_result('files')\n end",
"def index\n @item_photos = ItemPhoto.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @item_photos }\n end\n end",
"def files\n @files=get_endpoint('extra').keys\n end",
"def index\n @stream_items = StreamItem.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @stream_items }\n end\n end",
"def list_files_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: NsxComponentAdministrationApi.list_files ...\"\n end\n # resource path\n local_var_path = \"/node/file-store\"\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['BasicAuth']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'FilePropertiesListResult')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: NsxComponentAdministrationApi#list_files\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def show\n @list = List.find(params[:list_id])\n @list_item = @list.list_items.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @list_item }\n end\n end",
"def list_items_list(page_id = current_page_id, list_id = current_list_id)\n request \"page/#{page_id}/lists/#{list_id}/items/list\"\n end",
"def index\n @lists = List.find(:all)\n\n respond_to do |format|\n format.html\n format.xml { render :xml => @lists }\n end\n end",
"def index\n @action_items = ActionItem.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @action_items }\n end\n end",
"def list_files\n source_dir = Path.new(params[:source_dir])\n if params.has_key?(:show_catalogues)\n show_catalogues = params[:show_catalogues]\n else\n show_catalogues = false\n end\n if params[:ext].present?\n file_type = params[:ext]\n else\n file_type = nil\n end\n render json: source_dir.files(file_type: file_type, show_catalogues: show_catalogues)\n end",
"def list(client, current_path)\n\n\tfiles = Dir.glob(\"#{current_path}/files/*\")\n\tclient.puts \"\\nList of Files:\"\n\tfiles.each{ |file|\n\tfile.slice! \"#{current_path}/files/\"}\n\tclient.puts files\n\nend",
"def get_items\n response_xml = http_get(@client, \"#{xero_url}/Items\")\n parse_response(response_xml, {}, {:request_signature => 'GET/items'})\n end",
"def index_rest\n @entry_items = EntryItem.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @entry_items }\n end\n end",
"def files options = {}\n ensure_connection!\n resp = connection.list_files name, options\n if resp.success?\n File::List.from_resp resp, connection\n else\n fail ApiError.from_response(resp)\n end\n end",
"def index\n @items_count = Item.count\n @items = Item.find(:all, { :order => 'items.created_at DESC', :include => :user }.merge(@pagination_options))\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @items }\n format.rss { render :layout => false }\n end\n end",
"def list\n url = prefix + \"list\"\n return response(url)\n end",
"def index\n @filedownloads = Filedownload.all\n end",
"def list_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: PublicationsFileApi.list ...'\n end\n # resource path\n local_var_path = '/pulp/api/v3/publications/file/file/'\n\n # query parameters\n query_params = {}\n query_params[:'ordering'] = opts[:'ordering'] if !opts[:'ordering'].nil?\n query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?\n query_params[:'offset'] = opts[:'offset'] if !opts[:'offset'].nil?\n query_params[:'fields'] = opts[:'fields'] if !opts[:'fields'].nil?\n query_params[:'exclude_fields'] = opts[:'exclude_fields'] if !opts[:'exclude_fields'].nil?\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['Basic']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'InlineResponse20015')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: PublicationsFileApi#list\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def index\n @list_items = List.find(params[:list_id]).list_items\n\n render json: @list_items\n end",
"def downloaded\n files_list = []\n files = session[:user].x_files.all(:downloads.gte => 1, uploaded: true)\n files.each { |file| files_list.push(file.description(session[:user])) }\n @result = { files: files_list, success: true }\n end",
"def get_files_list(request)\r\n begin\r\n data, _status_code, _headers = get_files_list_with_http_info(request)\r\n rescue ApiError => e\r\n if e.code == 401\r\n request_token\r\n data, _status_code, _headers = get_files_list_with_http_info(request)\r\n else\r\n raise\r\n end\r\n end\r\n data\r\n end",
"def index\n @uploads = Upload.nw(session[:nw]).all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @uploads }\n end\n end",
"def list\n Lib.list @path, @no_follow\n end",
"def list\n FileOperations.find_all(self)\n end",
"def files\n db = Database.find(params[:id])\n @files = Dir.entries(db.path)\n @files.delete_if{|f| !f.include?'.dat'}\n @results = []\n @files.each do |entry|\n @results << {:name=>entry,:version=>db.version}\n end\n respond_to do |format|\n format.html\n format.json { render json: @results }\n end\n end",
"def index\n @fileclips = Fileclip.all\n \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @fileclips }\n end\n end",
"def index\n @file_descriptions = FileDescription.all\n end",
"def index\n @items = @project.items.ready\n \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @items }\n end\n end",
"def index\n @receiving_items = ReceivingItem.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @receiving_items }\n end\n end",
"def index\n @line_items = LineItem.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @line_items }\n end\n end",
"def list\n client = get_dropbox_client\n unless client\n redirect_to(:action => 'auth_start') and return\n end\n @dropbox_docs = []\n path = \"/\"\n\n metadata = client.metadata(path, file_limit=25000, list=true, hash=nil, rev=nil, include_deleted=false)\n for dfile in metadata['contents']\n \tname = dfile['path']\n \t@dropbox_docs << name[1..-1]\n \tend\n \tgoogle_session = GoogleDrive.login_with_oauth(session[:google_token])\n \t@google_docs = []\n \tfor file in google_session.files\n \t\t@google_docs << file.title \n \tend\n #drivelist = get_dr.slice!(-)\n #render :inline => \"#{metadata['contents']} \\n\\n\\n\"\n #render json: metadata\n\n end",
"def index\n @folders = Folder.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @folders }\n end\n end",
"def index\n @folders = Folder.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @folders }\n end\n end",
"def index\n @list_items = @list.list_items\n end",
"def list\n require_public = ( params[:user].nil? ? false : true )\n user = ( params[:user].nil? ? session[:user] : User.first(id: params[:user]) )\n raise RequestError.new(:bad_params, \"User does not exist\") unless user\n raise RequestError.new(:bad_params, \"Depth not valid\") if params[:depth].to_i < 0\n depth = (params[:depth] ? params[:depth].to_i : -1)\n xfile = ( params[:id].nil? ? user.root_folder : WFolder.get(params[:id]) )\n raise RequestError.new(:internal_error, \"No root directory. Please contact your administrator\") if xfile.nil? && params[:id].nil?\n raise RequestError.new(:folder_not_found, \"File or folder not found\") if xfile.nil?\n if (require_public && params[:id] && session[:user].admin == false) then\n raise RequestError.new(:folder_not_public, \"Folder is not public\") if xfile.folder == true && xfile.public == false\n raise RequestError.new(:folder_not_public, \"File is not public\") if xfile.folder == false && xfile.public == false\n end\n if xfile.folder then\n @result = { folder: crawl_folder(xfile, require_public, depth), success: true }\n else \n @result = { file: xfile.description(session[:user]) , success: true }\n end\n end",
"def file_get(input={}, raw=false)\n response = post('mw/File.Get', input, raw)\n end",
"def index\n @line_items = LineItem.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @line_items }\n end\n end",
"def index\n @line_items = LineItem.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @line_items }\n end\n end",
"def listFiles()\n #N Without this the files won't get listed\n contentHost.listFiles(baseDir)\n end",
"def b2_list_file_names(file)\n\n auth_hash = convert_json(b2_authorize_account)\n api_url = auth_hash[\"apiUrl\"]\n account_authorization_token = auth_hash[\"authorizationToken\"]\n bucket_id = ENV['bucket_id']\n prefix = file\n\n uri = URI(\"#{api_url}/b2api/v1/b2_list_file_names\")\n req = Net::HTTP::Post.new(uri)\n req.add_field(\"Authorization\",\"#{account_authorization_token}\")\n req.body = \"{\\\"bucketId\\\":\\\"#{bucket_id}\\\", \\\"prefix\\\":\\\"#{prefix}\\\"}\"\n http = Net::HTTP.new(req.uri.host, req.uri.port)\n http.use_ssl = true\n res = http.start {|http| http.request(req)}\n\n case res\n when Net::HTTPSuccess then res.body\n when Net::HTTPRedirection then fetch(res['location'], limit - 1)\n else res.error!\n end\n\nend",
"def cmd_list(param)\n send_unauthorised and return unless logged_in?\n send_response \"150 Opening ASCII mode data connection for file list\"\n\n param = '' if param.to_s == '-a'\n\n dir = File.join(@name_prefix.to_s, param.to_s)\n\n now = Time.now\n\n items = list_dir(build_path(param))\n lines = items.map do |item|\n \"#{item.directory ? 'd' : '-'}#{item.permissions || 'rwxrwxrwx'} 1 #{item.owner || 'owner'} #{item.group || 'group'} #{item.size || 0} #{(item.time || now).strftime(\"%b %d %H:%M\")} #{item.name}\"\n end\n send_outofband_data(lines)\n # send_action_not_taken\n end",
"def index\n @resource_import_files = ResourceImportFile.page(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n end\n end",
"def list\n @file_list.to_a\n end",
"def filelist_file(origin_name, dist_name, component_name, packages)\n content = {\n \"filelists\" => {\n :@xmlns => XMLNS_MAP[:filelists],\n :@packages => packages.size,\n :package => packages.map { |package|\n {\n :@pkgid => package[:generated_sha],\n :@name => package[\"NAME\"],\n :@arch => package[\"ARCH\"],\n :version => {\n :@epoch => package[\"EPOCHNUM\"],\n :@ver => package[\"VERSION\"],\n :@rel => package[\"RELEASE\"].split(\".\").first,\n },\n :file => (package[\"FILENAMES\"] + package[\"DIRNAMES\"]).map { |dir|\n {:@type => \"dir\", :_content_ => dir}\n },\n }\n },\n },\n }\n args = [origin_name, dist_name, component_name, \"repodata\", \"filelists.xml\"]\n [\n create_file(*args) do |file|\n file.puts generate_xml(content)\n end,\n compress_file(*args),\n ]\n end",
"def index\n @file_records = FileRecord.all\n end",
"def index\n @file_records = FileRecord.all\n end",
"def index\n @list_items = ListItem.all\n end",
"def index\n @list_items = ListItem.all\n end",
"def show\n @xml_file_names = []\n @content = []\n parse_zip\n render 'show_file' if params[:file_name]\n end",
"def test_get_files_list\n request = GetFilesListRequest.new(path: remote_data_folder)\n\n result = @words_api.get_files_list(request)\n assert_equal false, result.nil?\n end",
"def index\n @playlists = Playlist.find(:all)\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @playlists.to_xml }\n end\n end",
"def index\n @items = Item.found\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @items }\n end\n end",
"def show\n @uplaod_files = UploadFile.where(\"doc_no=?\",params[:doc_no])\n @upload_file = UploadFile.new\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @upload_file }\n end\n end",
"def list\n get('/')\n end",
"def index\n @file_packages = FilePackage.all\n end",
"def index\n @nspirefiles = Nspirefile.all(:order => \"updated_at DESC\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @nspirefiles }\n end\n end",
"def files\n results\n rescue ApiStruct::EntityError\n result\n end",
"def index\n @title = \"ファイル一覧\"\n @stocked_files = StockedFile.order(\"id DESC\").all\n end",
"def show\n @request = Request.find(params[:id])\n @items = @request.items\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @request }\n end\n end",
"def index\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @directories }\n end\n end",
"def index\n @filenames = Filename.all\n end",
"def index\n @items = @list.items.all.order(id: :desc)\n return success_item_index\n end",
"def list\n\t\tfiles.map! { |filename|\n\t\t\t{:title => file_to_pagename(filename), :link => filename.chomp(\".md\")}\n\t\t}\n\tend",
"def list\n\t\tfiles.map! { |filename|\n\t\t\t{:title => file_to_pagename(filename), :link => filename.chomp(\".md\")}\n\t\t}\n\tend",
"def index\n @medusa_premis_file_objects = MedusaPremis::FileObject.all\n\n respond_to do |format|\n format.html {setup_next_and_previous_documents} # index.html.erb\n format.json { render json: @medusa_premis_file_objects }\n end\n end",
"def get_list\n \t@items\n end",
"def index\n @event_import_files = EventImportFile.page(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @event_import_files }\n end\n end",
"def index\n @userfiles = Userfile.all\n end",
"def list_all_files()\n\t\tfiles = Hash.new\n\t\trefresh_access_token()\n\t\trequest_url = \"https://www.googleapis.com/drive/v2/files?access_token=#{@access_token}\"\n\t\tresponse = RestClient.get request_url\n\t\tresponse_body = JSON.parse(response.body)\n\t\tresponse_body['items'].each do |item|\n\t\t\t\tfiles[item['id']] = item['title']\n\t\tend\n\t\treturn files\n\tend",
"def index\n @event_import_files = EventImportFile.page(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @event_import_files }\n end\n end"
] |
[
"0.7253695",
"0.6748305",
"0.67117727",
"0.66492766",
"0.6624679",
"0.65968746",
"0.6535257",
"0.6501938",
"0.6490047",
"0.6489521",
"0.64878076",
"0.6463209",
"0.6425785",
"0.6424752",
"0.6408849",
"0.6391161",
"0.63708115",
"0.6358394",
"0.6340381",
"0.6295728",
"0.62831795",
"0.6281925",
"0.6262913",
"0.6230188",
"0.6217814",
"0.6216316",
"0.6192228",
"0.61695844",
"0.615998",
"0.61569124",
"0.61465514",
"0.6143853",
"0.61419636",
"0.6139398",
"0.6119621",
"0.6113479",
"0.6111171",
"0.61003923",
"0.60769755",
"0.6034059",
"0.60245925",
"0.6012737",
"0.6011856",
"0.60038257",
"0.5992175",
"0.5988664",
"0.5977604",
"0.5970534",
"0.5961852",
"0.59601074",
"0.59594524",
"0.5932595",
"0.5929841",
"0.5927935",
"0.59220135",
"0.5921885",
"0.59218377",
"0.5919169",
"0.5917012",
"0.5910596",
"0.5910356",
"0.5909361",
"0.5909361",
"0.59043443",
"0.5896199",
"0.5889885",
"0.588632",
"0.588632",
"0.5886263",
"0.5872034",
"0.58690774",
"0.5866935",
"0.58637977",
"0.58630204",
"0.58606786",
"0.58606786",
"0.58460003",
"0.58460003",
"0.58451664",
"0.58411413",
"0.5835588",
"0.5824218",
"0.5822216",
"0.5821389",
"0.58210766",
"0.581736",
"0.58093435",
"0.5808257",
"0.580138",
"0.5795283",
"0.57901394",
"0.5788588",
"0.5784694",
"0.5784694",
"0.5781665",
"0.57806545",
"0.57801247",
"0.57743305",
"0.57722145",
"0.5769138"
] |
0.7786718
|
0
|
GET /file_list_items/1 GET /file_list_items/1.xml
|
def show
@file_list = UploadedFileList.find(params[:uploaded_file_list_id])
@file_list_item = @file_list.file_list_items.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @file_list_item }
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def index\n @file_list = UploadedFileList.find(params[:uploaded_file_list_id])\n @file_list_items = @file_list.file_list_items.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @file_list_items }\n end\n end",
"def index\n @list = List.find(params[:list_id])\n @list_items = @list.list_items.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @list_items }\n end\n end",
"def index\n @uploaded_files = @page.uploaded_files.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @uploaded_files }\n end\n end",
"def index\n @file_attachments = FileAttachment.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @file_attachments }\n end\n end",
"def index\n @data_files = DataFile.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @data_files }\n end\n end",
"def show\n @list = List.find(params[:list_id])\n @list_item = @list.list_items.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @list_item }\n end\n end",
"def index\n @file_uploads = FileUpload.find(:all)\n\n respond_to do |wants|\n wants.html # index.html.erb\n wants.xml { render :xml => @file_uploads }\n end\n end",
"def index\n @wx_files = File.all\n end",
"def parse_list_response(xml)\n [ nodes_for(xml, 'files').collect{ |node| File.new(self, node) },\n nodes_for(xml, 'folders').collect{ |node| Folder.new(@rc, self, node) } ]\n end",
"def path\n \"/{databaseId}/items/list/\"\n end",
"def index\n raise ArgumentError, 'Missing file parameter' if filename.blank?\n\n @available_in_workspace = Dor::Services::Client.object(params[:item_id]).files.list.include?(filename)\n\n respond_to do |format|\n format.html { render layout: !request.xhr? }\n end\n end",
"def get_files_list(request)\n http_request = request.to_http_info(@api_client.config)\n make_request(http_request, :GET, 'FilesList')\n end",
"def file_list\n end",
"def show\n @file_item = FileItem.cs(self.current_scope).find_by_path(params[:id])\n\n respond_to do |format|\n format.html do\n case @file_item.item_type\n when Saphira::FileItem::TYPE_FOLDER\n @file_items = @file_item.children\n render :action => 'index'\n else\n render\n end\n end\n format.json { render :json => @file_item }\n end\n end",
"def show\n @uplaod_files = UploadFile.where(\"doc_no=?\",params[:doc_no])\n @upload_file = UploadFile.new\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @upload_file }\n end\n end",
"def index\n @list = List.find(params[:list_id])\n @items = @list.items\n\n respond_with @items\n end",
"def index\n @stream_items = StreamItem.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @stream_items }\n end\n end",
"def index\n @title = \"User uploaded files\"\n get_files(params)\n end",
"def list\n files_mask = \"*.xml\"\n if current_user.role != \"admin\"\n files_mask = \"#{current_user.fileprefix}-*.xml\"\n end\n pending_path = ENV[\"EAD_XML_PENDING_FILES_PATH\"] + \"/#{files_mask}\"\n Rails.logger.info(\"Loading pending files at #{pending_path}\")\n\n file_list = []\n Dir[pending_path].each do |file|\n file_info = {\n name: File.basename(file, \".xml\"),\n timestamp: File.mtime(file),\n display_date: File.mtime(file).strftime(\"%Y-%m-%d %I:%M %p\")\n }\n file_list << file_info\n end\n file_list.sort_by! {|x| x[:timestamp]}.reverse!\n\n @presenter = UploadPresenter.new()\n @presenter.configure(pending_path, file_list, current_user)\n render\n rescue => ex\n render_error(\"list\", ex, current_user)\n end",
"def show\n @xml_file_names = []\n @content = []\n parse_zip\n render 'show_file' if params[:file_name]\n end",
"def index\n @item_photos = ItemPhoto.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @item_photos }\n end\n end",
"def index\n @inventory_files = InventoryFile.page(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @inventory_files }\n end\n end",
"def show\n @breadcrumb = 'read'\n @processed_file = ProcessedFile.find(params[:id])\n @processed_file_items = @processed_file.processed_file_items.paginate(:page => params[:page], :per_page => per_page)\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @processed_file }\n end\n end",
"def index\n @inventory_files = InventoryFile.page(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n end\n end",
"def list\n call(:get, path)\n end",
"def index\n @action_items = ActionItem.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @action_items }\n end\n end",
"def get_file_listing\n execute!(drive.files.list).data\n end",
"def file_get(input={}, raw=false)\n response = post('mw/File.Get', input, raw)\n end",
"def get_file(file_id)\n\tputs \"Getting file: \" + file_id\n\tresponse = request_get('/api/partner/file/' + file_id)\n\tputs response.body\nend",
"def index\n @lists = List.find(:all)\n\n respond_to do |format|\n format.html\n format.xml { render :xml => @lists }\n end\n end",
"def filelist\n puts_message \"filelist start\" \n\n user = current_user\n\n request = params[:request].force_encoding(\"UTF-8\")\n puts_message \"Requested Path: \" + params[:request]\n \n if user and check_existance_of_path(request) \n if request == nil\n @file_names = 'error'\n elsif request_is_directory?(request)\n fire_the_list(request)\n # @file_names = absolute_path(request)\n elsif request_is_file?(request)\n last = request.split('/').last\n path = absolute_path(request)\n send_file_info(last, request) \n else\n @file_names = 'error'\n end\n else \n @file_names = 'error'\n end\n\n puts_message \"filelist end\" \n \n @output = <<-END\n\n END\n \n if request == \"/images/\"\n @folders = Folder.all(:user_id => current_user.id)\n \n @output << \"photo\" + \"\\n\"\n \n @folders.each do |f|\n @output << f.name + \"\\n\"\n end\n \n @file_names = @output\n end\n \n return @file_names\n\n end",
"def index_rest\n @entry_items = EntryItem.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @entry_items }\n end\n end",
"def index\n @file_links = FileLink.all\n end",
"def file_list\n @file_list\n end",
"def show\n @file_upload = FileUpload.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @file_upload }\n end\n end",
"def index\n @line_items = LineItem.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @line_items }\n end\n end",
"def show\n @request = Request.find(params[:id])\n @items = @request.items\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @request }\n end\n end",
"def list\n ret = get()\n return [] if ret.is_a? Hash and ret.has_key? :error\n ret.map{|i| FileItem.new(i)}\n end",
"def get\n file = XFile.get(params[:id])\n raise RequestError.new(:file_not_found, \"File not found\") unless file\n raise RequestError.new(:bad_access, \"No access\") unless file.users.include? session[:user]\n raise RequestError.new(:bad_param, \"Can't get a folder\") if file.folder\n raise RequestError.new(:file_not_uploaded, \"File not completely uploaded\") unless file.uploaded\n raise RequestError.new(:bad_part, \"Incorrect content\") if file.content.nil?\n\n @result = retrieve(file, params[:part].to_i) if (!params[:direct] || params[:direct] != \"true\")\n \tsend_data(full_retrieve(file), filename: file.name) if (params[:direct] == \"true\")\n end",
"def index\n @line_items = LineItem.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @line_items }\n end\n end",
"def index\n @line_items = LineItem.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @line_items }\n end\n end",
"def index\n @uploads = Upload.nw(session[:nw]).all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @uploads }\n end\n end",
"def index\n @receiving_items = ReceivingItem.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @receiving_items }\n end\n end",
"def list_files\n User.sync_files!(@context)\n files = user_real_files(params, @context)\n\n if unsafe_params[:limit] && unsafe_params[:offset]\n files = files.limit(unsafe_params[:limit]).offset(unsafe_params[:offset])\n end\n\n search_string = params[:search_string].presence || \"\"\n\n result = files.eager_load(:license, user: :org).\n where(\"nodes.name LIKE ?\", \"%#{search_string}%\").\n order(id: :desc).map do |file|\n describe_for_api(file, unsafe_params[:describe])\n end.compact\n\n render json: unsafe_params[:offset]&.zero? ? { objects: result, count: result.length } : result\n end",
"def show\n @item_photos = ItemPhoto.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @item_photos }\n end\n end",
"def index\n @fileclips = Fileclip.all\n \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @fileclips }\n end\n end",
"def show\n @data_file = DataFile.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @data_file }\n end\n end",
"def index\n @items_count = Item.count\n @items = Item.find(:all, { :order => 'items.created_at DESC', :include => :user }.merge(@pagination_options))\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @items }\n format.rss { render :layout => false }\n end\n end",
"def index\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @directories }\n end\n end",
"def list_files_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: NsxComponentAdministrationApi.list_files ...\"\n end\n # resource path\n local_var_path = \"/node/file-store\"\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['BasicAuth']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'FilePropertiesListResult')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: NsxComponentAdministrationApi#list_files\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def download_list\n task = params[:task]\n files = []\n\n case task\n when DOWNLOAD_ACTION, OPEN_ACTION, COPY_ACTION, COPY_TO_PRIVATE_ACTION\n nodes = Node.accessible_by(@context).where(id: params[:ids])\n nodes.each { |node| files += node.is_a?(Folder) ? node.all_files : [node] }\n when PUBLISH_ACTION\n nodes = Node.editable_by(@context).\n where(id: params[:ids]).\n where.not(scope: UserFile::SCOPE_PUBLIC)\n nodes.each do |node|\n files += if node.is_a?(Folder)\n node.all_files(Node.where.not(scope: UserFile::SCOPE_PUBLIC))\n else\n [node]\n end\n end\n when DELETE_ACTION\n nodes = Node.editable_by(@context).where(id: params[:ids]).to_a\n files += nodes\n nodes.each { |node| files += node.all_children if node.is_a?(Folder) }\n files.filter! { |file| file.scope == params[:scope] }\n else\n raise ApiError, \"Parameter 'task' is not defined!\"\n end\n\n render json: files,\n each_serializer: FileActionsSerializer,\n scope_name: params[:scope] || SCOPE_PRIVATE,\n action_name: task\n end",
"def show\n @upload_file = UploadFile.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @upload_file }\n end\n end",
"def files(params = {}, &block)\n params = convert_params(params)\n return execute_paged!(\n :api_method => self.drive.files.list,\n :parameters => params,\n :converter => proc(){ |af| wrap_api_file(af) },\n &block)\n end",
"def index\n @filedownloads = Filedownload.all\n end",
"def files_list(params = {})\n response = @session.do_post \"#{SCOPE}.list\", params\n Slack.parse_response(response)\n end",
"def index\n @folders = Folder.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @folders }\n end\n end",
"def index\n @folders = Folder.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @folders }\n end\n end",
"def index\n @nspirefiles = Nspirefile.all(:order => \"updated_at DESC\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @nspirefiles }\n end\n end",
"def index\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @imports }\n end\n end",
"def b2_list_file_names(file)\n\n auth_hash = convert_json(b2_authorize_account)\n api_url = auth_hash[\"apiUrl\"]\n account_authorization_token = auth_hash[\"authorizationToken\"]\n bucket_id = ENV['bucket_id']\n prefix = file\n\n uri = URI(\"#{api_url}/b2api/v1/b2_list_file_names\")\n req = Net::HTTP::Post.new(uri)\n req.add_field(\"Authorization\",\"#{account_authorization_token}\")\n req.body = \"{\\\"bucketId\\\":\\\"#{bucket_id}\\\", \\\"prefix\\\":\\\"#{prefix}\\\"}\"\n http = Net::HTTP.new(req.uri.host, req.uri.port)\n http.use_ssl = true\n res = http.start {|http| http.request(req)}\n\n case res\n when Net::HTTPSuccess then res.body\n when Net::HTTPRedirection then fetch(res['location'], limit - 1)\n else res.error!\n end\n\nend",
"def index\n @items = @project.items.ready\n \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @items }\n end\n end",
"def show\n @file_upload = FileUpload.find(params[:id])\n\n respond_to do |wants|\n wants.html # show.html.erb\n wants.xml { render :xml => @file_upload }\n end\n end",
"def show\n @list = List.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @list }\n end\n end",
"def list\n require_public = ( params[:user].nil? ? false : true )\n user = ( params[:user].nil? ? session[:user] : User.first(id: params[:user]) )\n raise RequestError.new(:bad_params, \"User does not exist\") unless user\n raise RequestError.new(:bad_params, \"Depth not valid\") if params[:depth].to_i < 0\n depth = (params[:depth] ? params[:depth].to_i : -1)\n xfile = ( params[:id].nil? ? user.root_folder : WFolder.get(params[:id]) )\n raise RequestError.new(:internal_error, \"No root directory. Please contact your administrator\") if xfile.nil? && params[:id].nil?\n raise RequestError.new(:folder_not_found, \"File or folder not found\") if xfile.nil?\n if (require_public && params[:id] && session[:user].admin == false) then\n raise RequestError.new(:folder_not_public, \"Folder is not public\") if xfile.folder == true && xfile.public == false\n raise RequestError.new(:folder_not_public, \"File is not public\") if xfile.folder == false && xfile.public == false\n end\n if xfile.folder then\n @result = { folder: crawl_folder(xfile, require_public, depth), success: true }\n else \n @result = { file: xfile.description(session[:user]) , success: true }\n end\n end",
"def files\n @files=get_endpoint('extra').keys\n end",
"def show\n @mylist = Mylist.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @mylist }\n end\n end",
"def files\n db = Database.find(params[:id])\n @files = Dir.entries(db.path)\n @files.delete_if{|f| !f.include?'.dat'}\n @results = []\n @files.each do |entry|\n @results << {:name=>entry,:version=>db.version}\n end\n respond_to do |format|\n format.html\n format.json { render json: @results }\n end\n end",
"def request_item\n if is_downloadable?\n if is_viewable?\n respond_to do |format|\n format.html do\n flash[:notice] = 'File retrieval request received.'\n redirect_to(\n recall_bendo_item_path(id: noid),\n status: :found\n )\n end\n format.json { json_api_response }\n end\n else\n respond_to do |format|\n format.html do\n flash[:alert] = \"You are not permitted to view the item with ID: #{noid}\"\n redirect_to recall_bendo_item_path(id: noid)\n end\n format.json { json_unauthorized_response }\n end\n end\n else\n respond_to do |format|\n format.html do\n flash[:alert] = \"No files can be downloaded for ID: #{noid}\"\n redirect_to recall_bendo_item_path(id: noid)\n end\n format.json { json_not_found_response }\n end\n end\n end",
"def files\n results\n rescue ApiStruct::EntityError\n result\n end",
"def show\n @indexed_file = IndexedFile.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @indexed_file }\n end\n end",
"def index\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render xml: @download_registrations }\n end\n end",
"def list_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: PublicationsFileApi.list ...'\n end\n # resource path\n local_var_path = '/pulp/api/v3/publications/file/file/'\n\n # query parameters\n query_params = {}\n query_params[:'ordering'] = opts[:'ordering'] if !opts[:'ordering'].nil?\n query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?\n query_params[:'offset'] = opts[:'offset'] if !opts[:'offset'].nil?\n query_params[:'fields'] = opts[:'fields'] if !opts[:'fields'].nil?\n query_params[:'exclude_fields'] = opts[:'exclude_fields'] if !opts[:'exclude_fields'].nil?\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['Basic']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'InlineResponse20015')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: PublicationsFileApi#list\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def index\n @uploads = Upload.paginate(:include=>[:file_references],:page=>params[:page],:per_page=>$DEFAULT_PER_PAGE_BE,:order=>\"created_at desc\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @uploads }\n end\n end",
"def index\n @resource_import_files = ResourceImportFile.page(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n end\n end",
"def parseFileslist(doc, params, path)\n prev_commit_hash = (doc.find_first('//xmpp2rest/user/device/files/prev_commit_hash') ? doc.find_first('//xmpp2rest/user/device/files/prev_commit_hash').content : nil) \n commit_hash = (doc.find_first('//xmpp2rest/user/device/files/commit_hash')) ? doc.find_first('//xmpp2rest/user/device/files/commit_hash').content : nil\n \n if not commit_hash\n raise Exception.new(\"Missing element: commit_hash\")\n end\n \n puts \"Prev_commit_hash: \" + prev_commit_hash.to_s\n puts \"Commit_hash: \" + commit_hash.to_s\n \n location = {}\n location['latitude'] = (doc.find_first('//xmpp2rest/user/device/files/location/latitude')) ? doc.find_first('//xmpp2rest/user/device/files/location/latitude').content : \"NULL\"\n location['longitude'] = (doc.find_first('//xmpp2rest/user/device/files/location/longitude')) ? doc.find_first('//xmpp2rest/user/device/files/location/longitude').content : \"NULL\"\n \n filelist = Hash.new\n doc.find('//user/device/files/file').each do |file|\n fullpath = (file.attributes.get_attribute(\"fullpath\")) ? file.attributes.get_attribute(\"fullpath\").value : nil \n filepath = (file.find_first('path')) ? file.find_first('path').content : nil\n filename = (file.find_first('filename')) ? file.find_first('filename').content : nil \n filedate = (file.find_first('filedate')) ? file.find_first('filedate').content : nil\n filetype = (file.find_first('filetype')) ? file.find_first('filetype').content : nil\n filesize = (file.find_first('filesize')) ? file.find_first('filesize').content : nil\n version_hash = (file.find_first('version_hash')) ? file.find_first('version_hash').content : nil\n\n if not filepath or not filename or not filetype or not filesize or not filedate or not version_hash\n raise Exception.new(\"Not all the needed metadata given: filename, filetype, filesize, filedate and version_hash are compulsory!\")\n elsif fullpath.to_s != filepath.to_s + filename.to_s\n raise Exception.new(\"fullpath: #{fullpath.to_s} doesn't match to path + name: #{filepath.to_s + filename.to_s}\")\n elsif fullpath[0,1] != '/' or filepath[0,1] != '/'\n raise Exception.new(\"path must begin with /\")\n end\nputs \"filepath: #{filepath}\"\n filelist.merge!({fullpath => {\"status\" => \"created\", \"blob_hash\" => version_hash, \"name\" => filename, \"path\" => filepath, \"size\" => filesize, \"filetype\" => filetype, \"filedate\" => filedate.to_s}}) \n end\n contains = YAML.dump_stream(filelist)\nputs \"contains: #{contains.to_s}\"\n if prev_commit_hash\n puts \"prev hash added!\"\n params['prev_commit_hash'] = prev_commit_hash\n end\n \n path += \"/files\"\n params.merge!({ 'contains' => contains, 'commit_hash' => commit_hash, 'commit_location' => location})\n return params, path\n end",
"def index\n @playlists = Playlist.find(:all)\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @playlists.to_xml }\n end\n end",
"def index\n @score_files = ScoreFile.all\n \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @score_files }\n end\n end",
"def index\n @file_records = FileRecord.all\n end",
"def index\n @file_records = FileRecord.all\n end",
"def index\n @goods_items = Goods::Item.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @goods_items }\n end\n end",
"def downloaded\n files_list = []\n files = session[:user].x_files.all(:downloads.gte => 1, uploaded: true)\n files.each { |file| files_list.push(file.description(session[:user])) }\n @result = { files: files_list, success: true }\n end",
"def show\n @treq = Treq.find(params[:id])\n @treq_files = @treq.treq_files.all\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @treq }\n end\n end",
"def list(client, current_path)\n\n\tfiles = Dir.glob(\"#{current_path}/files/*\")\n\tclient.puts \"\\nList of Files:\"\n\tfiles.each{ |file|\n\tfile.slice! \"#{current_path}/files/\"}\n\tclient.puts files\n\nend",
"def uploadurls\n @job = Job.find(params[:id])\n respond_to do |format|\n @url_list = @job.uploadurls(params[:upload_type], params[:files])\n if !@url_list.blank?\n format.html \n format.xml { render :xml => { :files => @url_list } }\n else\n @job.errors.add_to_base('Bad files list')\n format.html { render :action => \"show\" }\n format.xml { render :xml => { 'error' => 'bad files list'}, :status => :unprocessable_entity }\n end\n end\n end",
"def filelist_file(origin_name, dist_name, component_name, packages)\n content = {\n \"filelists\" => {\n :@xmlns => XMLNS_MAP[:filelists],\n :@packages => packages.size,\n :package => packages.map { |package|\n {\n :@pkgid => package[:generated_sha],\n :@name => package[\"NAME\"],\n :@arch => package[\"ARCH\"],\n :version => {\n :@epoch => package[\"EPOCHNUM\"],\n :@ver => package[\"VERSION\"],\n :@rel => package[\"RELEASE\"].split(\".\").first,\n },\n :file => (package[\"FILENAMES\"] + package[\"DIRNAMES\"]).map { |dir|\n {:@type => \"dir\", :_content_ => dir}\n },\n }\n },\n },\n }\n args = [origin_name, dist_name, component_name, \"repodata\", \"filelists.xml\"]\n [\n create_file(*args) do |file|\n file.puts generate_xml(content)\n end,\n compress_file(*args),\n ]\n end",
"def index\n @entries = @resource_finder.find(:all)\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @entries }\n end\n end",
"def show\n @file_attachment = FileAttachment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @file_attachment }\n end\n end",
"def files\n return get_result('files')\n end",
"def index\n @nthfiles = Nthfile.all\n end",
"def index\n @email_lists = EmailList.all \n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @email_lists }\n end\n end",
"def show\n @application_file = ApplicationFile.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @application_file }\n end\n end",
"def show\n @raw_data_file = RawDataFile.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @raw_data_file }\n end\n end",
"def show\n @list = List.find(params[:list_id])\n @list_items = @list.list_items.find(params[:list_id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @list_item }\n end\n end",
"def get_xbrl_files(item)\n xbrl_files=item[\"xbrlFiling\"][0][\"xbrlFiles\"][0][\"xbrlFile\"]\n return xbrl_files.select {|e| e[\"edgar:url\"].end_with?(\"xml\") || e[\"edgar:url\"].end_with?(\"xsd\")}\n end",
"def show\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @folder }\n end\n end",
"def do_GET(req,res,filename)\n st = File::stat(filename)\n mtime = st.mtime\n res['etag'] = sprintf(\"%x-%x-%x\", st.ino, st.size, st.mtime.to_i)\n if not_modified?(req, res, mtime, res['etag'])\n res.body = ''\n raise WEBrick::HTTPStatus::NotModified\n else\n res['content-type'] = WEBrick::HTTPUtils::mime_type(filename, @config[:MimeTypes])\n res['content-length'] = st.size\n res['last-modified'] = mtime.httpdate\n res.body = open(filename, \"rb\")\n end\n end",
"def index\n @thing_lists = ThingList.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @thing_lists }\n end\n end",
"def index\n @file_descriptions = FileDescription.all\n end",
"def show\n @download = Download.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @download }\n end\n end",
"def show\n @download = Download.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @download }\n end\n end"
] |
[
"0.7619156",
"0.6602612",
"0.65204906",
"0.6315112",
"0.6245342",
"0.6236728",
"0.62221396",
"0.62152797",
"0.6211031",
"0.6197166",
"0.61592674",
"0.6158384",
"0.6156805",
"0.6125392",
"0.61249447",
"0.60979193",
"0.60489106",
"0.6044213",
"0.6033936",
"0.60173285",
"0.6001017",
"0.59940076",
"0.5993633",
"0.5992261",
"0.5981922",
"0.5911461",
"0.58965373",
"0.58945274",
"0.5871707",
"0.5864865",
"0.58531827",
"0.5834751",
"0.58234954",
"0.5808747",
"0.5798413",
"0.5797083",
"0.57929695",
"0.5790419",
"0.5774155",
"0.5769029",
"0.5769029",
"0.57674015",
"0.5764411",
"0.5761694",
"0.575723",
"0.57500625",
"0.5748164",
"0.5744243",
"0.5740149",
"0.57376534",
"0.57345724",
"0.5730851",
"0.57288396",
"0.57149404",
"0.5692714",
"0.56886065",
"0.56886065",
"0.5678662",
"0.56734306",
"0.566961",
"0.56691605",
"0.5665613",
"0.56607443",
"0.56602174",
"0.5659275",
"0.5649187",
"0.5646682",
"0.5645513",
"0.5644843",
"0.564407",
"0.5639348",
"0.56370616",
"0.5633226",
"0.56260747",
"0.56180525",
"0.5617176",
"0.56168646",
"0.5611841",
"0.5611841",
"0.5606683",
"0.5603392",
"0.5596954",
"0.55933636",
"0.5590202",
"0.5585614",
"0.55809236",
"0.5574236",
"0.55741805",
"0.5571843",
"0.55717677",
"0.5566362",
"0.5563394",
"0.5552001",
"0.55481416",
"0.55404717",
"0.5539585",
"0.553566",
"0.55350393",
"0.55322766",
"0.55322766"
] |
0.73082405
|
1
|
GET /file_list_items/new GET /file_list_items/new.xml
|
def new
@file_list = UploadedFileList.find(params[:uploaded_file_list_id])
@file_list_item = @file_list.file_list_items.build
@page_section = @file_list.page_section
@page = @page_section.page
@site_section = @page.site_section
respond_to do |format|
format.js
format.html # new.html.erb
format.xml { render :xml => @file_list_item }
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => new_vurl }\n end\n end",
"def new\n @title = \"New item\"\n @item = ItemTemplate.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @item }\n end\n end",
"def new\n @list = List.find(params[:list_id])\n @item = @list.items.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @item }\n end\n end",
"def new\n @mylist = Mylist.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @mylist }\n end\n end",
"def new\n @file_upload = FileUpload.new\n\n respond_to do |wants|\n wants.html # new.html.erb\n wants.xml { render :xml => @file_upload }\n end\n end",
"def new_rest\n @entry_item = EntryItem.new\n\n respond_to do |format|\n #format.html # new.html.erb\n format.xml { render :xml => @entry_item }\n end\n end",
"def new\n @file_upload = FileUpload.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @file_upload }\n end\n end",
"def new\n @item = Item.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @item }\n end\n end",
"def new\n @item = Item.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @item }\n end\n end",
"def new\n @item = Item.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @item }\n end\n end",
"def new\n @item = Item.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @item }\n end\n end",
"def new\n @item = Item.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @item }\n end\n end",
"def new\n @item = Item.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @item }\n end\n end",
"def new\n @item = Item.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @item }\n end\n end",
"def new\n @item = Item.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @item }\n end\n end",
"def new\n @item = Item.factory('local')\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @item }\n end\n end",
"def new\n @file_attachment = FileAttachment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @file_attachment }\n end\n end",
"def new\r\n @item = Item.new\r\n\r\n respond_to do |format|\r\n format.html # new.html.erb\r\n format.xml { render :xml => @item }\r\n end\r\n end",
"def new\n @file_info = FileInfo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @file_info }\n end\n end",
"def new\n @list = List.find(params[:list_id])\n @list_item = @list.list_items.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @list_item }\n end\n end",
"def new\n @fileversion = Fileversion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @fileversion }\n end\n end",
"def new_rest\n @item_usage = ItemUsage.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @item_usage }\n end\n end",
"def new\n @parsefile = Parsefile.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @parsefile }\n end\n end",
"def new\n @file_version = FileVersion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @file_version }\n end\n end",
"def new\n @item = Item.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @item }\n format.xml { render xml: @item }\n end\n end",
"def new\n @thing_list = ThingList.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @thing_list }\n end\n end",
"def new\n @item = Item.new(:list_id => params[:list_id])\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @item }\n end\n end",
"def new\n @action_list = ActionList.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @action_list }\n end\n end",
"def new\n @list_view = ListView.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @list_view }\n end\n end",
"def new\n @file_item = FileItem.cs(self.current_scope).new\n @file_item.item_type = params[:type]\n @file_item.parent_id = params[:parent_id]\n\n respond_to do |format|\n format.html { render :action => \"new_#{@file_item.item_type}\" }\n format.json { render :json => @file_item }\n end\n end",
"def new\n @data_file = DataFile.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @data_file }\n end\n end",
"def new_files; end",
"def new\n @folder = Folder.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @folder }\n end\n end",
"def new\n @folder = Folder.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @folder }\n end\n end",
"def new\n @upload_file = UploadFile.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @upload_file }\n end\n end",
"def new\n @upload_file = UploadFile.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @upload_file }\n end\n end",
"def new\n @action_item = ActionItem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @action_item }\n end\n end",
"def new\n @clone_item_request = CloneItemRequest.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @clone_item_request }\n end\n end",
"def new\n @feefile = Feefile.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @feefile }\n end\n end",
"def new\n\t\t@list = List.new\n\n\t\trespond_to do |format|\n\t\t\tformat.html # new.html.erb\n\t\t\tformat.xml\t{ render :xml => @list }\n\t\tend\n\tend",
"def new\n @folder = Folder.new\n @new = true;\n respond_to do |format|\n format.html { render \"edit\" }\n format.xml { render :xml => @folder }\n end\n end",
"def new\n @page_title = \"Task List New\"\n @task_list = TaskList.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @task_list }\n end\n end",
"def new\n @stream_item = StreamItem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @stream_item }\n end\n end",
"def new\n @entry = Entry.new\n @folders = Folder.find(:all, :order => \"updated_at DESC\").map { |f| [f.name, f.id] }\n @new = true;\n\n respond_to do |format|\n format.html { render \"edit\" }\n format.xml { render :xml => @entry }\n end\n end",
"def new\n @application_file = ApplicationFile.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @application_file }\n end\n end",
"def new\n @content_item = ContentItem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @content_item }\n end\n end",
"def new\n @list_record = ListRecord.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @list_record }\n end\n end",
"def new\n @attachment = Attachment.new\n @entries = Entry.find(:all, :order => \"updated_at DESC\").map { |e| [e.title, e.id] }\n\n respond_to do |format|\n format.html\n format.xml { render :xml => @attachment }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @import }\n end\n end",
"def new\n @mfile = Mfile.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @mfile }\n end\n end",
"def index\n @file_list = UploadedFileList.find(params[:uploaded_file_list_id])\n @file_list_items = @file_list.file_list_items.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @file_list_items }\n end\n end",
"def new\n @action_file = ActionFile.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @action_file }\n end\n end",
"def new\n @download = Download.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @download }\n end\n end",
"def new\n @download = Download.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @download }\n end\n end",
"def new\n @network = Network.new\n @service = Fileservice.new(@network)\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @network }\n end\n end",
"def create\n params[:file_item][:parent_id] = nil if params[:file_item][:parent_id].blank?\n @file_item = FileItem.cs(self.current_scope).new(params[:file_item])\n\n respond_to do |format|\n if @file_item.save\n format.html { redirect_to @file_item, :notice => 'File item was successfully created.' }\n format.json { render :json => @file_item, :status => :created, :location => @file_item }\n else\n format.html { render :action => \"new_#{@file_item.item_type}\" }\n format.json { render :json => @file_item.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def new\n @item_photos = ItemPhoto.new\n @item_photos.item_id = params[:item_id]\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @item_photos }\n end\n end",
"def new\n @favourites = Favourites.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @favourites }\n end\n end",
"def new\n return error_status(true, :cannot_create_listitem) unless (ListItem.can_be_created_by(@logged_user, @list))\n \n @list_item = @list.list_items.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @list_item }\n end\n end",
"def new\n @indexed_file = IndexedFile.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @indexed_file }\n end\n end",
"def new\r\n @lineitem = Lineitem.new\r\n\r\n respond_to do |format|\r\n format.html # new.html.erb\r\n format.xml { render :xml => @lineitem }\r\n end\r\n end",
"def new\n @line_item = LineItem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @line_item }\n end\n end",
"def new\n @line_item = LineItem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @line_item }\n end\n end",
"def new\n @line_item = LineItem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @line_item }\n end\n end",
"def new\n @fileclip = Fileclip.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @fileclip }\n end\n end",
"def new\n @up_file = UpFile.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @up_file }\n end\n end",
"def new\n @item = BudgetItem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @item }\n end\n end",
"def new\n @file_record = FileRecord.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @file_record }\n end\n end",
"def new\n @treq = Treq.new\n @treq = @treq.incrament(@treq)\n @treq_file = @treq.treq_files.build\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @treq }\n end\n end",
"def new\n @email_list = EmailList.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @email_list }\n end\n end",
"def new\n @data_list = DataList.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @data_list }\n end\n end",
"def new\n @media_item = MediaItem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @media_item }\n end\n end",
"def new\n @directory = Directory.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @directory }\n end\n end",
"def new\n @directory = Directory.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @directory }\n end\n end",
"def show\n @file_list = UploadedFileList.find(params[:uploaded_file_list_id])\n @file_list_item = @file_list.file_list_items.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @file_list_item }\n end\n end",
"def new\n @receiving_item = ReceivingItem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @receiving_item }\n end\n end",
"def new\n @inventory_file = InventoryFile.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @inventory_file }\n end\n end",
"def item\n @new = New.find(params[:id])\n end",
"def new\n respond_to do |format|\n format.html\n format.xml\n end\n end",
"def new\n @movie_list_item = MovieListItem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @movie_list_item }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml \n end\n end",
"def new\n @file_sequence = FileSequence.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @file_sequence }\n end\n end",
"def new\n @upload = Upload.new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @upload }\n end\n end",
"def new\n @todo_list = TodoList.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @todo_list }\n end\n end",
"def new\n @ordered_item = OrderedItem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @ordered_item }\n format.json { render :json => @ordered_item }\n end\n end",
"def new\n @drop = Drop.new\n @breadcrumbs = [{\"home\" => drops_url}, {\"new file\" => nil}]\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @drop }\n end\n end",
"def new\n @listing = Listing.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @listing }\n end\n end",
"def new\n @list_of_value = Irm::ListOfValue.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @list_of_value }\n end\n end",
"def new\n @mail_item = MailItem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @mail_item }\n end\n end",
"def new\n @raw_file = RawFile.new\n\n respond_to do |format|\n format.html { render :new, :locals => { :raw_file => @raw_file } } # new.html.erb\n format.json { render :json => @raw_file }\n end\n end",
"def new\n @wish_list_item = WishListItem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @wish_list_item }\n end\n end",
"def new\n @item_type = ItemType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @item_type }\n end\n end",
"def new2\n #does not allow attaching a picture\n @listing = Listing.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.fbml # new.fbml.erb\n format.xml { render :xml => @listing }\n end\n end",
"def new\n @list_field_value = ListFieldValue.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @list_field_value }\n end\n end",
"def new\n @test_file = TestFile.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @test_file }\n end\n end",
"def new\n @collection = Collection.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @collection }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render xml: @download_registration }\n end\n end",
"def new\n @miscellaneous_item = MiscellaneousItem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @miscellaneous_item }\n end\n end",
"def new\n @to_do_item = ToDoItem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @to_do_item }\n end\n end",
"def new\n @pgn_file = PgnFile.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @pgn_file }\n end\n end"
] |
[
"0.6757881",
"0.6597636",
"0.6528176",
"0.65258914",
"0.64977515",
"0.64950424",
"0.6481976",
"0.64736533",
"0.64736533",
"0.64736533",
"0.64736533",
"0.64736533",
"0.64736533",
"0.64736533",
"0.64736533",
"0.6468618",
"0.64003515",
"0.6389975",
"0.63756377",
"0.6372262",
"0.6367065",
"0.6364767",
"0.6361239",
"0.634627",
"0.6339684",
"0.6339087",
"0.63333285",
"0.63206947",
"0.6313841",
"0.6309741",
"0.6296335",
"0.629414",
"0.62871546",
"0.62871546",
"0.62784904",
"0.62784904",
"0.627065",
"0.62665653",
"0.626508",
"0.6241498",
"0.6239206",
"0.623746",
"0.62273765",
"0.6222597",
"0.6220135",
"0.6214851",
"0.6213014",
"0.6208946",
"0.6197093",
"0.61931634",
"0.61882687",
"0.61803776",
"0.6179259",
"0.6179259",
"0.6164683",
"0.6161183",
"0.6159853",
"0.61557996",
"0.61540467",
"0.6150471",
"0.61496824",
"0.61488414",
"0.61488414",
"0.61405784",
"0.61256564",
"0.6120572",
"0.6116678",
"0.61146486",
"0.6103008",
"0.61027735",
"0.609779",
"0.6093986",
"0.60905933",
"0.60905933",
"0.6084",
"0.60809654",
"0.6077213",
"0.6053281",
"0.6053205",
"0.6029136",
"0.60283184",
"0.6027864",
"0.6027133",
"0.60096866",
"0.60035145",
"0.6000951",
"0.600057",
"0.59961",
"0.59884036",
"0.59860945",
"0.59704524",
"0.5966046",
"0.59633887",
"0.59619576",
"0.5959155",
"0.59539413",
"0.59488976",
"0.5940595",
"0.59379286",
"0.59368956"
] |
0.63872534
|
18
|
POST /file_list_items POST /file_list_items.xml
|
def create
@file_list = UploadedFileList.find(params[:uploaded_file_list_id])
@file_list_item = @file_list.file_list_items.build(params[:file_list_item])
@page_section = @file_list.page_section
@page = @page_section.page
@site_section = @page.site_section
respond_to do |format|
if @file_list_item.save
flash[:notice] = 'FileListItem was successfully created.'
format.html { redirect_to site_section_page_url(@site_section, @page) }
format.js do
responds_to_parent do
render :js => "$('#page_section_" + @page_section.id.to_s + "').replaceWith('" + @template.escape_javascript(render_to_string(:partial => "page_sections/show")) + "');$('#modal-content').html("");$('#modal').jqmHide();"
end
end
format.xml { render :xml => @file_list_item, :status => :created, :location => @file_list_item }
else
format.html { render :action => "new" }
format.js do
responds_to_parent do
render :js => "$('#modal-content').html('" + @template.escape_javascript(render_to_string(:action => "new")) + "')"
end
end
format.xml { render :xml => @file_list_item.errors, :status => :unprocessable_entity }
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def index\n @file_list = UploadedFileList.find(params[:uploaded_file_list_id])\n @file_list_items = @file_list.file_list_items.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @file_list_items }\n end\n end",
"def add_list_item(content,page_id = current_page_id, list_id = current_list_id)\n # POST /ws/page/#{page_id}/lists/#{list_id}/items/add\n request \"page/#{page_id}/lists/#{list_id}/items/add\", \"item\" => { \"content\" => content }\n end",
"def create\n params[:file_item][:parent_id] = nil if params[:file_item][:parent_id].blank?\n @file_item = FileItem.cs(self.current_scope).new(params[:file_item])\n\n respond_to do |format|\n if @file_item.save\n format.html { redirect_to @file_item, :notice => 'File item was successfully created.' }\n format.json { render :json => @file_item, :status => :created, :location => @file_item }\n else\n format.html { render :action => \"new_#{@file_item.item_type}\" }\n format.json { render :json => @file_item.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def new\n @file_list = UploadedFileList.find(params[:uploaded_file_list_id])\n @file_list_item = @file_list.file_list_items.build\n \n @page_section = @file_list.page_section\n @page = @page_section.page\n @site_section = @page.site_section\n\n respond_to do |format|\n format.js\n format.html # new.html.erb\n format.xml { render :xml => @file_list_item }\n end\n end",
"def create\n item = list.items.create!(item_params)\n render json: item, status: 201\n end",
"def create\n items = []\n\n @upload = Upload.new(params[:upload])\n xml_fl = Hash.from_xml(params[:upload][\"upload\"].read).to_hash\n items = xml_fl[\"DATAPACKET\"][\"ROWDATA\"][\"ROW\"]\n\n respond_to do |format|\n if @upload.save\n #определяем тип содержимого файла по названию файла\n # _json = [@upload.to_jq_upload].to_json\n # \n\n # logger.debug { items }\n unless @upload.upload_file_name.match(/^\\d{5}/).nil?\n logger.debug { '----------------> Ok' }\n create_fackt_pricreplenie(items, @upload.upload_file_name)\n else\n if @upload.upload_file_name.start_with?(\"UPAKOVKA\")\n logger.debug {\"======> fack \"}\n update_numbers_of_polis(items)\n end\n end\n\n format.html {\n render :json => [@upload.to_jq_upload].to_json,\n :content_type => 'text/html',\n :layout => false\n }\n format.json { render json: [@upload.to_jq_upload].to_json, status: :created, location: @upload }\n else\n format.html { render action: \"new\" }\n format.json { render json: @upload.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\n nested = params[:list].delete(:list_items_attributes)\n\n @list = List.new( params[:list] )\n @list.user = current_user\n\n records = nested.collect do |_, fields| \n\n ListItem.new( { \"list\" => @list }.merge( fields ) ) if !item_blank?( fields )\n\n end.compact\n\n respond_to do |format|\n if @list.save && records.map( &:save ).all?\n\n format.html { redirect_to @list, notice: 'List was successfully created.' }\n format.json { render json: @list, status: :created, location: @list }\n\n else\n\n format.html { render action: \"new\" }\n format.json { render json: @list.errors, status: :unprocessable_entity }\n\n end\n end\n end",
"def show\n @file_list = UploadedFileList.find(params[:uploaded_file_list_id])\n @file_list_item = @file_list.file_list_items.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @file_list_item }\n end\n end",
"def file_list\n end",
"def create\n list = List.find(params[:list_id])\n @list_item = list.list_items.new(list_items_params)\n @list_item.save ? json_response(@list_item) : json_response(@list_item.errors, status = :not_acceptable)\n end",
"def create\n @item = Item.create(item_params)\n @items = List.find(item_params[:list_id]).items.order(\"id ASC\")\n @list_id = item_params[:list_id]\n end",
"def create\n @tags = Tag.all\n @list_item = @list.list_items.new(list_item_params)\n\n respond_to do |format|\n if @list_item.save\n format.html { redirect_to list_path(@list), notice: 'List item was successfully created.' }\n format.json { render :show, status: :created, location: @list_item }\n else\n format.html { render :new }\n format.json { render json: @list_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @item = @list.items.create(item_params)\n redirect_to @list\n end",
"def list_item_params\n params[:list_item]\n end",
"def upload_file(item_file)\n upload_response = @server.upload(item_file.file(item_file.metadata_full_path))\n json = JSON.parse(upload_response.body)\n json['files'].map { |f| f['id'] }\n end",
"def userlist_params\n params.require(:userlist).permit(:name, :file)\n end",
"def create\n ListItem.transaction do\n item = Item.new(item_params)\n item.save\n\n @list_item = ListItem.new(list_item_params)\n @list_item.item_id = item.id\n @list_item.list_id = params[:list_id]\n\n\n if @list_item.save\n render json: @list_item, status: :created\n else\n render json: @list_item.errors, status: :unprocessable_entity\n end\n end\n end",
"def parse_list_response(xml)\n [ nodes_for(xml, 'files').collect{ |node| File.new(self, node) },\n nodes_for(xml, 'folders').collect{ |node| Folder.new(@rc, self, node) } ]\n end",
"def upload_packlist(pl_name, pl_count, pl_path)\n upload_packlist_btn.click\n name.set pl_name\n item_count.set pl_count\n # this is needed because the file field is hidden in balance\n Capybara.ignore_hidden_elements = false\n attach_file(\"Packlist File\", File.expand_path(pl_path))\n Capybara.ignore_hidden_elements = true\n continue.click\n accept_mapping.click\n sleep 10\n refresh_browser()\n end",
"def list_item_params\n params.require(:list_item).permit(:list_id, :name, :deleted_at, :deleted, :tag_id)\n end",
"def list_params\n params.require(:list).permit(:title, \n :description, \n :list_type_id, \n :list_type,\n list_items_attributes: [:item, :id, :_destroy]\n )\n end",
"def create\n\n @list_item = @list.list_items.create!(list_item_params)\n #@list_item = @list.list_items.create!(params[:list_item])\n\n respond_to do |format|\n if @list_item.save\n format.html { redirect_to list_path(@list), notice: 'List item was successfully created.' }\n format.json { render :show, status: :created, location: @list_item }\n else\n format.html { render :new }\n format.json { render json: @list_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @listitem = Listitem.new(listitem_params)\n\n if @todolist.listitems << @listitem\n render :show, status: :created, location: todolist_listitem_path(@todolist, @listitem)\n else\n render json: @listitem.errors, status: :unprocessable_entity\n end\nend",
"def list_item_params\n params.require(:list_item).permit(:list_id, :item_name, :description, :size, :number_wanted, :store_name, :url)\n end",
"def list_item_params\n params.require(:list_item).permit(:item_name, :quantity, :list_id)\n end",
"def create_list(params={})\n @obj.post('create-list', @auth.merge(params))\n end",
"def create\n @list_item = ListItem.new(list_item_params)\n\n respond_to do |format|\n if @list_item.save\n format.html { redirect_to @list_item, notice: 'List item was successfully created.' }\n format.json { render :show, status: :created, location: @list_item }\n else\n format.html { render :new }\n format.json { render json: @list_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def list\n ret = get()\n return [] if ret.is_a? Hash and ret.has_key? :error\n ret.map{|i| FileItem.new(i)}\n end",
"def list_item_params\n params.require(:list_item).permit(:name, :description, :status)\n end",
"def create\n upload_item params[params[:item_type]], session['username'], params[:alternative_name], params[:tag_name], params[:item_type], params[:details]\n end",
"def create\n @list = current_user.lists.find params[:list_id]\n @item = @list.items.build(item_params)\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to list_items_path(@list), notice: 'Item was successfully created.' }\n #format.json { render :show, status: :created, location: @item }\n else\n format.html { render :new }\n #format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def createItemOfList\n results1 = checkUser(params[:target_account]) #userid user to give the money\n if results1.code == 200\n parameters={user_id: (@current_user[\"id\"]).to_i, description: (params[:description]), date_pay: params[:date_pay], cost: params[:cost], target_account: params[:target_account], state_pay:params[:state_pay]}\n options = {\n :body => parameters.to_json,\n :headers => {\n 'Content-Type' => 'application/json'\n }\n }\n results = HTTParty.post(\"http://192.168.99.101:4055/lists\", options)\n if results.code == 201\n head 201\n else\n render json: results.parsed_response, status: results.code\n end\n elsif results1.code == 404\n renderError(\"Not Found\", 404, \"The resource does not exist\")\n end\n end",
"def list_item_params\n params.require(:list_item).permit(:list_id, item_id)\n end",
"def parseFileslist(doc, params, path)\n prev_commit_hash = (doc.find_first('//xmpp2rest/user/device/files/prev_commit_hash') ? doc.find_first('//xmpp2rest/user/device/files/prev_commit_hash').content : nil) \n commit_hash = (doc.find_first('//xmpp2rest/user/device/files/commit_hash')) ? doc.find_first('//xmpp2rest/user/device/files/commit_hash').content : nil\n \n if not commit_hash\n raise Exception.new(\"Missing element: commit_hash\")\n end\n \n puts \"Prev_commit_hash: \" + prev_commit_hash.to_s\n puts \"Commit_hash: \" + commit_hash.to_s\n \n location = {}\n location['latitude'] = (doc.find_first('//xmpp2rest/user/device/files/location/latitude')) ? doc.find_first('//xmpp2rest/user/device/files/location/latitude').content : \"NULL\"\n location['longitude'] = (doc.find_first('//xmpp2rest/user/device/files/location/longitude')) ? doc.find_first('//xmpp2rest/user/device/files/location/longitude').content : \"NULL\"\n \n filelist = Hash.new\n doc.find('//user/device/files/file').each do |file|\n fullpath = (file.attributes.get_attribute(\"fullpath\")) ? file.attributes.get_attribute(\"fullpath\").value : nil \n filepath = (file.find_first('path')) ? file.find_first('path').content : nil\n filename = (file.find_first('filename')) ? file.find_first('filename').content : nil \n filedate = (file.find_first('filedate')) ? file.find_first('filedate').content : nil\n filetype = (file.find_first('filetype')) ? file.find_first('filetype').content : nil\n filesize = (file.find_first('filesize')) ? file.find_first('filesize').content : nil\n version_hash = (file.find_first('version_hash')) ? file.find_first('version_hash').content : nil\n\n if not filepath or not filename or not filetype or not filesize or not filedate or not version_hash\n raise Exception.new(\"Not all the needed metadata given: filename, filetype, filesize, filedate and version_hash are compulsory!\")\n elsif fullpath.to_s != filepath.to_s + filename.to_s\n raise Exception.new(\"fullpath: #{fullpath.to_s} doesn't match to path + name: #{filepath.to_s + filename.to_s}\")\n elsif fullpath[0,1] != '/' or filepath[0,1] != '/'\n raise Exception.new(\"path must begin with /\")\n end\nputs \"filepath: #{filepath}\"\n filelist.merge!({fullpath => {\"status\" => \"created\", \"blob_hash\" => version_hash, \"name\" => filename, \"path\" => filepath, \"size\" => filesize, \"filetype\" => filetype, \"filedate\" => filedate.to_s}}) \n end\n contains = YAML.dump_stream(filelist)\nputs \"contains: #{contains.to_s}\"\n if prev_commit_hash\n puts \"prev hash added!\"\n params['prev_commit_hash'] = prev_commit_hash\n end\n \n path += \"/files\"\n params.merge!({ 'contains' => contains, 'commit_hash' => commit_hash, 'commit_location' => location})\n return params, path\n end",
"def files_list(params = {})\n response = @session.do_post \"#{SCOPE}.list\", params\n Slack.parse_response(response)\n end",
"def filelist_file(origin_name, dist_name, component_name, packages)\n content = {\n \"filelists\" => {\n :@xmlns => XMLNS_MAP[:filelists],\n :@packages => packages.size,\n :package => packages.map { |package|\n {\n :@pkgid => package[:generated_sha],\n :@name => package[\"NAME\"],\n :@arch => package[\"ARCH\"],\n :version => {\n :@epoch => package[\"EPOCHNUM\"],\n :@ver => package[\"VERSION\"],\n :@rel => package[\"RELEASE\"].split(\".\").first,\n },\n :file => (package[\"FILENAMES\"] + package[\"DIRNAMES\"]).map { |dir|\n {:@type => \"dir\", :_content_ => dir}\n },\n }\n },\n },\n }\n args = [origin_name, dist_name, component_name, \"repodata\", \"filelists.xml\"]\n [\n create_file(*args) do |file|\n file.puts generate_xml(content)\n end,\n compress_file(*args),\n ]\n end",
"def push_list(stream, *array)\n post stream, 'list' => array.flatten.map{|item| {'listItem' => item}}\n end",
"def add_list_member(f)\n File.open f, 'r' do |file|\n file.each do |email|\n print email\n RestClient.post(\"https://api:key-#{API_KEY}\" \\\n \"@api.mailgun.net/v3/lists/#{LIST}@#{DOMAIN_NAME}/members\",\n :subscribed => true,\n :address => email.chomp!,\n :upsert => true )\n end\n end\nend",
"def import\n Item.import( params[:file])\n redirect_to '/items', notice: 'Items Imported.'\n end",
"def create\n #@file_folder = FileFolder.new(file_folder_params)\n @folder = current_user.folders.where(\"id = ?\", params[:current_folder_id]).first\n @files = @folder.file_folders.build \n io_file = params[:file]\n respond_to do |format|\n if @files.store(io_file)\n @files = [] << @files\n format.js {render \"files_list\", status: 200}\n else\n format.js {render js: \"alert('Could not create file\", status: 400}\n end \n end \n end",
"def upload\n begin\n solve(@viewable_list,@browse_list)\n render :result\n rescue Exception => e\n raise_error INCORRECT_DATA\n end\n end",
"def index\n @list = List.find(params[:list_id])\n @list_items = @list.list_items.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @list_items }\n end\n end",
"def create\n @item = @list.items.build(item_params)\n @item.user = current_user\n\n if @item.save\n return success_item_create\n else\n return error_item_save\n end\n end",
"def create\n lip = list_item_params list_type_id: params[:list_type_id]\n new_item = current_user.list_items.create(lip)\n respond_with new_item\n end",
"def create\n @item = Item.new(params[:item])\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to lists_path, :notice => 'Item was successfully created.' }\n format.json { render :json => lists_path, :status => :created, :location => lists_path }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @item.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n images_arr = params[:images]\n params[:list_item].delete(:image)\n @list_item = ListItem.find(params[:id])\n @image = Image.new(images_arr)\n @list_item.images << @image\n\n respond_to do |format|\n if @list_item.update_attributes(params[:list_item])\n format.html { redirect_to user_url(current_user), notice: t('list_items.updated') }\n format.json { render :json => @list_item }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @list_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @list = List.find(params[:list_id])\n @items = @list.items\n\n respond_with @items\n end",
"def new\n @list = List.find(params[:list_id])\n @item = @list.items.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @item }\n end\n end",
"def list_params\n params.require(:list).permit(:title, :description, :html_id, :html_classes,\n list_items_attributes: [\n :id, :type, :object_type, :object_id, :title, :subtitle, :url, :image_id, :target,\n :priority, :_destroy, :description, :html_classes,\n children_attributes: list_item_attributes\n ])\n end",
"def file_list\n @file_list\n end",
"def build_ftk_file_items(coll_pid, ftk_report, ftk_xml_file_dir, display_derivative_dir)\n assembler = FtkItemAssembler.new(:collection_pid => coll_pid)\n assembler.process(ftk_report, ftk_xml_file_dir, display_derivative_dir)\nend",
"def list_params\n params.require(:list).permit(:name, :permalink, :description, :picurl)\n end",
"def create\n @item = Item.new(params[:item])\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to(items_path) }\n format.xml { render :xml => @item, :status => :created, :location => @item }\n else\n format.html { redirect_to(items_path)}\n format.xml { render :xml => @item.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def index\n @uploaded_files = @page.uploaded_files.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @uploaded_files }\n end\n end",
"def create\n create_params = item_params\n item = Item.new(\n name: create_params[:name], \n is_complete: false, #create_params[:is_complete], \n list_id: create_params[:list_id])\n\n item.save!\n render json: item\n end",
"def create\n return error_status(true, :cannot_create_listitem) unless (ListItem.can_be_created_by(@logged_user, @list))\n \n @list_item = @list.list_items.build(params[:list_item])\n @list_item.created_by = @logged_user\n\n respond_to do |format|\n if @list_item.save\n flash[:notice] = 'ListItem was successfully created.'\n format.html { redirect_to(@list_item) }\n format.js\n format.xml { render :xml => @list_item, :status => :created, :location => page_list_list_item_path(:page_id => @page.id, :list_id => @list.id, :id => @list_item.id) }\n else\n format.html { render :action => \"new\" }\n format.js\n format.xml { render :xml => @list_item.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def list_items_list(page_id = current_page_id, list_id = current_list_id)\n request \"page/#{page_id}/lists/#{list_id}/items/list\"\n end",
"def items_import_params\n # params.require(:items_import).permit(:file_name, :uploaded_by, :uploaded_at, :status)\n params.fetch(:items_import, {}).permit(:file_name, :uploaded_by, :uploaded_at, :status, :file)\n end",
"def list\n files_mask = \"*.xml\"\n if current_user.role != \"admin\"\n files_mask = \"#{current_user.fileprefix}-*.xml\"\n end\n pending_path = ENV[\"EAD_XML_PENDING_FILES_PATH\"] + \"/#{files_mask}\"\n Rails.logger.info(\"Loading pending files at #{pending_path}\")\n\n file_list = []\n Dir[pending_path].each do |file|\n file_info = {\n name: File.basename(file, \".xml\"),\n timestamp: File.mtime(file),\n display_date: File.mtime(file).strftime(\"%Y-%m-%d %I:%M %p\")\n }\n file_list << file_info\n end\n file_list.sort_by! {|x| x[:timestamp]}.reverse!\n\n @presenter = UploadPresenter.new()\n @presenter.configure(pending_path, file_list, current_user)\n render\n rescue => ex\n render_error(\"list\", ex, current_user)\n end",
"def create\n @list_item = ListItem.new(list_item_params)\n\n if @list_item.save\n redirect_to @list_item, notice: 'List item was successfully created.' \n else\n render action: 'new' \n end\n end",
"def postFlatpackSitemap( flatpack_id, filedata)\n params = Hash.new\n params['flatpack_id'] = flatpack_id\n params['filedata'] = filedata\n return doCurl(\"post\",\"/flatpack/sitemap\",params)\n end",
"def create\n @list_of_value = Irm::ListOfValue.new(params[:irm_list_of_value])\n\n respond_to do |format|\n if @list_of_value.save\n format.html { redirect_to({:action => \"index\"}, :notice => t(:successfully_created)) }\n format.xml { render :xml => @list_of_value, :status => :created, :location => @list_of_value }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @list_of_value.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def save_items_data\n @parsed[\"order_items\"].each do |i| \n external_code = i['item']['id']\n item = Item.find_or_create_by(external_code: external_code)\n item.order_id = @order.id\n item.external_code = i['item']['id']\n item.name = i['item']['title']\n item.price = i['unit_price']\n item.quantity = i['quantity']\n item.total = i['full_unit_price']\n @subItems = []\n item.save\n end\n end",
"def item_list_params\n params.require(:item_list).permit(:title, :description, :expected_cost, :image, :contact)\n end",
"def update_list(item_name, item_list, quantity)\n add_list(item_name, item_list, quantity)\nend",
"def create\n puts params\n item_data = {\n :title => params[:title],\n :description => params[:description]\n }\n @item = current_user.items.build(item_data)\n if params[:attachments]\n params[:attachments].each do |att_id|\n @att = Attachment.find(att_id)\n @item.attachments.push(@att)\n if @att.att_type == 'photo'\n @item.photos.build(\n photo_url: @att.url\n )\n end\n end\n end\n if @item.save\n respond_to do |format|\n format.json { render :json => @item.to_json, :status => 200 }\n format.xml { head :ok }\n format.html { redirect_to :action => :index }\n end\n else\n respond_to do |format|\n format.json { render :text => \"Could not create item\", :status => :unprocessable_entity } # placeholder\n format.xml { head :ok }\n format.html { render :action => :new, :status => :unprocessable_entity }\n end\n end\n end",
"def item_params\n params.require(:item).permit(:name, :tag_list, :type_list, :description)\n end",
"def create\n @item_list = ItemList.new(item_list_params)\n @item_list.user_id = current_user.id\n\n respond_to do |format|\n if @item_list.save\n format.html { redirect_to @item_list, notice: 'Item list was successfully created.' }\n format.json { render :show, status: :created, location: @item_list }\n else\n format.html { render :new }\n format.json { render json: @item_list.errors, status: :unprocessable_entity }\n end\n end\n end",
"def files_post(file, opts = {})\n files_post_with_http_info(file, opts)\n end",
"def create\n @treq = Treq.new(params[:treq])\n \n respond_to do |format|\n if @treq.save\n unless params[:treq_files].blank?\n params[:treq_files]['file'].each do |a|\n @treq_file = @treq.treq_files.create!(:file => a, :treq_id => @treq.id)\n end\n end\n TreqNotifier.submit_treq(@treq).deliver\n format.html { redirect_to @treq, notice: 'Treq was successfully created.' }\n format.json { render json: @treq, status: :created, location: @treq }\n else\n format.html { render action: \"new\", alert: \"Test Requset has been submitted.\"}\n format.json { render json: @treq.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_post(api_key, access_token, list, list_item_id, body, opts = {})\n data, _status_code, _headers = set_post_with_http_info(api_key, access_token, list, list_item_id, body, opts)\n return data\n end",
"def post(path = '/files/', params = {})\n request :post, path, params\n end",
"def new\n @list = List.find(params[:list_id])\n @list_item = @list.list_items.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @list_item }\n end\n end",
"def listitem_params\n params.require(:listitem).permit(:task, :todolist_id)\n end",
"def update\n @item = @collection.items.get(params[:id])\n @collection.schema.each do |field|\n if params[:item][field.to_s].blank? && !field.is_file\n @item[field.name]=nil\n elsif field.is_file\n #do nothing\n unless params[:item][field.to_s].nil?\n new_file = @file_collection.items.new()\n new_file.file =params[:item][field.to_s]\n new_file.save\n @item[field.name]='{\"project\":{\"id\": \"'+@project.id+'\"}, \"collection\":{\"id\": \"'+@file_collection.id+'\"},\"item\":{\"id\": \"'+new_file.id.to_s+'\", \"display\": \"'+new_file.original_filename+'\"}}'\n end\n else\n @item[field.name] = params[:item][field.to_s]\n end\n end\n if @item.save\n update_associated_fields(@item, @collection, @project)\n respond_to do |format|\n format.html do\n flash[:notice] = \"Item Updated Successfully!\"\n end\n #format.json { render json: @item.to_json, status: :updated}\n format.js { render :js => '$(\"#message\").html(\"<h2>Item updated. Close window and refresh your page.</h2>\").attr(\"class\",\"message notice\"); $(\"html, body\").animate({scrollTop: \"0px\"})' }\n end\n else\n respond_to do |format|\n format.html do\n flash[:error] = [\"Item failed to save! Errors:\", @item.errors.full_messages].flatten.join(' ')\n end\n format.json { render json: @item.to_json, status: :error}\n format.js { render :js => '$(\"#message\").html(\"<h2>Item failed update.</h2>\").attr(\"class\",\"message error\").scrollTop(0); $(\"html, body\").animate({scrollTop: \"0px\"})' }\n end\n end\n redirect_to :back\n end",
"def create\n @mylist = Mylist.new(params[:mylist])\n\n respond_to do |format|\n if @mylist.save\n format.html { redirect_to(@mylist, :notice => 'Mylist was successfully created.') }\n format.xml { render :xml => @mylist, :status => :created, :location => @mylist }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @mylist.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def item_params\n params.require(:item).permit(:task, :list_id, :due_date, :is_complete, :item_image)\n end",
"def create_todo_item(name, list_id)\n data = {\n item: {\n name: name\n }\n }\n rest(\"post\", \"lists/#{list_id}/items\", data)\n end",
"def upload_item(item, file, parent = '0BxnZXCons72AYXZOTVVrdGk0bTg' )\n tmp_file = Tempfile.new('mendeley').tap do |f|\n f.binmode # must be in binary mode\n f.write file\n f.rewind\n end\n \n metadata = @drive.files.insert.request_schema.new({\n 'title' => item[:title],\n 'description' => item[:description],\n 'mimeType' => 'application/pdf',\n 'parents' => [{'id' => parent}]\n }) \n \n conn = Faraday.default_connection\n conn.options[:timeout] = 500 \n conn.options[:open_timeout] = 2 \n \n media = Google::APIClient::UploadIO.new(tmp_file, 'application/pdf') \n result = @client.execute(:api_method => @drive.files.insert,\n :parameters => { 'uploadType' => 'multipart', 'alt' => 'json' },\n :body_object => metadata,\n :media => media, \n :connection => conn\n )\n tmp_file.close!\n result.data\n end",
"def filelist\n puts_message \"filelist start\" \n\n user = current_user\n\n request = params[:request].force_encoding(\"UTF-8\")\n puts_message \"Requested Path: \" + params[:request]\n \n if user and check_existance_of_path(request) \n if request == nil\n @file_names = 'error'\n elsif request_is_directory?(request)\n fire_the_list(request)\n # @file_names = absolute_path(request)\n elsif request_is_file?(request)\n last = request.split('/').last\n path = absolute_path(request)\n send_file_info(last, request) \n else\n @file_names = 'error'\n end\n else \n @file_names = 'error'\n end\n\n puts_message \"filelist end\" \n \n @output = <<-END\n\n END\n \n if request == \"/images/\"\n @folders = Folder.all(:user_id => current_user.id)\n \n @output << \"photo\" + \"\\n\"\n \n @folders.each do |f|\n @output << f.name + \"\\n\"\n end\n \n @file_names = @output\n end\n \n return @file_names\n\n end",
"def item_params\n params.require(:item).permit(:item_id, :name, :references, :year, :status, :lenght, :height, :width, :thickness, :aquisition_date, :outer_circumference, :inner_circumference, :weight, :conservation_state, :biography, :description, {mediafiles: []})\n end",
"def upload\n document = params[:document]\n service_request_id = params[:service_request_id]\n organization_id = params[:organization_id]\n document_type = params[:document_type]\n\n # let's see how many existing docs we have before we upload\n document_count_before_upload = Alfresco::Document.number_of_documents_for(service_request_id)\n\n ticket = Document.ticket(Alfresco::Document::ALFRESCO_USER, Alfresco::Document::ALFRESCO_PASSWORD)\n\n builder = Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |xml|\n xml.entry(:xmlns => \"http://www.w3.org/2005/Atom\",\n \"xmlns:cmisra\" => \"http://docs.oasis-open.org/ns/cmis/restatom/200908/\",\n \"xmlns:cmis\" => \"http://docs.oasis-open.org/ns/cmis/core/200908/\") {\n xml.title document.original_filename\n xml.summary document_type\n xml.content(:type => document.content_type) {\n xml.text Base64.encode64(document.read)\n }\n }\n end\n\n if !Document.service_request_folder_exists? service_request_id\n Document.create_service_request_folder service_request_id\n end\n\n sub_folders = Document.find_sub_folders_for_service_request service_request_id\n unless sub_folders.include? organization_id\n Document.create_service_request_organization_folder(service_request_id, organization_id)\n end\n\n url = Document::PATH + \"cmis/p/User%20Homes/service_requests/#{service_request_id}/#{organization_id}/children?alf_ticket=\" + ticket\n\n count = 0\n begin\n count = count + 1\n RestClient.post url, builder.to_xml, {:content_type => 'application/atom+xml;type=entry'}\n rescue => e\n Rails.logger.info \"#\"*50\n Rails.logger.info \"Error creating file\"\n Rails.logger.info e.message\n Rails.logger.info \"#\"*50\n end\n\n new_document_count = count + document_count_before_upload\n document_count_after_upload = Alfresco::Document.number_of_documents_for(service_request_id)\n\n while(document_count_after_upload != new_document_count) do\n sleep(0.5)\n document_count_after_upload = Alfresco::Document.number_of_documents_for(service_request_id)\n end\n\n redirect_to :controller => 'related_service_requests', :action => 'show', :anchor => 'documents', :service_request_id => params[:friendly_id], :id => params[:ssr_id]\n end",
"def create(item_attrs = {})\n body = { value: item_attrs }\n Iterable.request(conf, base_path).put(body)\n end",
"def review_items\n @dialog.setSubStatusAndLogIt('Finding items to review')\n @dialog.setSubProgress(0)\n items = add_status('endpoint')\n unless @items['endpoint-attach'].empty?\n items.concat(add_status('endpoint-attach'))\n items.concat(add_attachments)\n end\n @dialog.setSubProgress(1, 1)\n items\n end",
"def create\n @list = List.find(params[:list_id])\n @list_item = @list.list_items.build(params[:list_item])\n @list_item[:user_id] = current_user.id\n\n if @list_item.save\n flash[:success] = \"Item successfully added\"\n redirect_to list_path(@list)\n else\n flash[:error] = \"Item not added\"\n redirect_to list_path(@list)\n end\n end",
"def render_item_list(params)\n docpath = params.fetch(:docpath)\n key = params.fetch(:key)\n klass = params.fetch(:klass, ItemList)\n title = params.fetch(:title, \"Cloud Platform Reports\")\n\n template = docpath.to_sym\n\n item_list = get_data_from_json_file(docpath, key, klass)\n\n locals = {\n title: title,\n updated_at: item_list.updated_at,\n list: item_list.list,\n }\n\n erb template, locals: locals\nend",
"def create\n @uploaded_file = UploadedFile.new(file_name: params[:uploaded_file][:file_name].original_filename)\n respond_to do |format|\n if @uploaded_file.save\n load_imported_items\n format.html { redirect_to root_path, notice: 'Uploaded file was successfully created.' }\n format.json { render :show, status: :created, location: @uploaded_file }\n else\n format.html { render :new }\n format.json { render json: @uploaded_file.errors, status: :unprocessable_entity }\n end\n end\n end",
"def write_filelist(out_file_list)\n result_list.each{|f| log f}\n File.open(out_file_list, \"w\") do |file|\n result_list.each do |item| \n file << item\n file << \"\\n\"\n end\n log \"File list created #{out_file_list}\"\n end \n end",
"def write_filelist(out_file_list)\n result_list.each{|f| log f}\n File.open(out_file_list, \"w\") do |file|\n result_list.each do |item| \n file << item\n file << \"\\n\"\n end\n log \"File list created #{out_file_list}\"\n end \n end",
"def update\n @list.append_items!(params.dig(:list, :items), current_user)\n redirect_to [@project, @randomization_scheme], notice: \"Items successfully added.\"\n end",
"def get_files_list(request)\n http_request = request.to_http_info(@api_client.config)\n make_request(http_request, :GET, 'FilesList')\n end",
"def new\n @list = List.new\n\n @list.list_items.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @list }\n end\n end",
"def create\n @list = List.create!(list_params)\n json_response(@list, :created)\n end",
"def create\n redirect_to user_path(current_user), :notice => t('list_items.title_blank') and return nil if params[:list_item][:title].blank?\n images_arr = params[:images]\n params[:list_item].delete(:image)\n @list_item = current_user.list_items.build(params[:list_item])\n\n #setting up the highiest priority to new list item appears at the top\n biggest_priority = current_user.list_items.where('priority IS NOT NULL').limit(1).order('priority ASC').first\n if biggest_priority\n biggest_priority = biggest_priority.priority\n else\n biggest_priority = 0\n end\n\n @list_item.priority = biggest_priority - 1\n @image = Image.new(images_arr)\n @list_item.images << @image\n\n respond_to do |format|\n if @list_item.save\n format.html { session[:open_edit] = @list_item.id #to open new list item in edit mode in fronend after creation\n redirect_to user_url(current_user) }\n format.json { render json: @list_item, status: :created, location: @list_item }\n else\n format.html { render action: \"new\" }\n format.json { render json: @list_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def item(data, question_ids)\n xml = xml_root(\"items\")\n\n questions = question_ids.inject(XML::Node.new(\"questions\")) do |doc, id|\n question = XML::Node.new(\"question\")\n question[\"id\"] = id.to_s\n doc << question\n end\n\n arrayed(data).each do |name|\n xml.root << (XML::Node.new(\"item\") << (XML::Node.new(\"data\") << name) << questions.copy(true))\n end\n\n send_and_process('items/add', 'items/item', xml)\n end",
"def create\n @item = Item.new(item_params)\n\n respond_to do |format|\n if @item.save\n @item.images.delete_all\n unless params.require(:item)[:images_id].nil?\n params.require(:item)[:images_id].each do |id|\n image = Image.find_by_id(id)\n (@item.images << image) unless image.nil?\n end\n end\n format.html { redirect_to @item, notice: 'Item was successfully created.' }\n format.json { render action: 'show', status: :created, location: @item }\n else\n format.html { render action: 'new' }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def item_params\n params.require(:item).permit(:filename, :name, :item_type, :owner_id, :on_sale, :purchased, :stock, :specs, :price, :comment_id)\n end",
"def create_list(name)\n data = {\n list: {\n name: name\n }\n }\n rest(\"post\", \"lists\", data)\n end",
"def post_file_params\n params.require(:post_file).permit(:name, :item, :type, :image_dimensions,\n :remove_item, :item_cache)\n end",
"def create\n @item = Item.new(item_params)\n\n respond_to do |format|\n if @item.save\n if item_params[:file].present?\n file = item_params[:file]\n file_name = file.original_filename\n result = uploadpdf(file,file_name)\n end\n format.html { redirect_to @item, notice: '投稿に成功しました。' }\n format.json { render :show, status: :created, location: @item }\n else\n format.html { render :new }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def setup_items(selected_items, for_action)\n # Retrieve each file's details. The container_id will be passed if this is a\n # multi container download, otherwise it will be ignored\n selected_items.each do |s|\n container = self.container || Browse.open_container(id: s[:container_id], user: current_user)\n activity_log = self.activity_log || ActivityLog.open_activity_log(s[:activity_log_type], s[:activity_log_id],\n current_user)\n retrieve_file_from(s[:id], s[:retrieval_type], container: container, activity_log: activity_log,\n for_action: for_action)\n end\n end"
] |
[
"0.66802996",
"0.6110032",
"0.6051943",
"0.60313255",
"0.6000208",
"0.5988239",
"0.59490603",
"0.5934109",
"0.5843036",
"0.5824926",
"0.5789077",
"0.57853335",
"0.5763051",
"0.56565714",
"0.5653314",
"0.5647765",
"0.55775994",
"0.5572881",
"0.55692655",
"0.5559203",
"0.5551286",
"0.5543984",
"0.55366796",
"0.5518667",
"0.5513029",
"0.5496576",
"0.5494886",
"0.5489948",
"0.5481075",
"0.5468649",
"0.5458427",
"0.5458109",
"0.54508716",
"0.5449139",
"0.54482055",
"0.5425986",
"0.5421117",
"0.53964704",
"0.53924036",
"0.5383063",
"0.5374198",
"0.5371825",
"0.5360994",
"0.53568494",
"0.53485084",
"0.5344157",
"0.53223574",
"0.5318534",
"0.53130734",
"0.53009045",
"0.52933395",
"0.5289492",
"0.5270475",
"0.5267665",
"0.52675617",
"0.5263514",
"0.52595854",
"0.525627",
"0.5251087",
"0.5250481",
"0.5242522",
"0.52334803",
"0.52316356",
"0.5231284",
"0.5215479",
"0.5209283",
"0.5202617",
"0.5198857",
"0.5198752",
"0.5197025",
"0.5193312",
"0.51888466",
"0.5188428",
"0.518603",
"0.5183348",
"0.5182285",
"0.51809925",
"0.51727754",
"0.51680404",
"0.5164343",
"0.51570666",
"0.51525384",
"0.5151627",
"0.5145573",
"0.51442426",
"0.51418114",
"0.51385736",
"0.5138296",
"0.5138296",
"0.5137576",
"0.51317155",
"0.5126689",
"0.51258636",
"0.51152915",
"0.51144135",
"0.51034003",
"0.5099976",
"0.50993586",
"0.5098593",
"0.5093657",
"0.5092433"
] |
0.0
|
-1
|
PUT /file_list_items/1 PUT /file_list_items/1.xml
|
def update
@file_list = UploadedFileList.find(params[:uploaded_file_list_id])
@file_list_item = @file_list.file_list_items.find(params[:id])
@page_section = @file_list.page_section
@page = @page_section.page
@site_section = @page.site_section
respond_to do |format|
if @file_list_item.update_attributes(params[:file_list_item])
flash[:notice] = 'FileListItem was successfully updated.'
format.html { redirect_to site_section_page_url(@site_section, @page) }
format.js do
responds_to_parent do
render :js => "$('#file_list_item_" + @file_list_item.id.to_s + "').replaceWith('" + @template.escape_javascript(render_to_string(:partial => "file_list_items/show", :locals => { :file_list_item => @file_list_item })) + "');$('#modal-content').html("");$('#modal').jqmHide();"
end
end
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.js do
responds_to_parent do
render :js => "$('#modal-content').html('" + @template.escape_javascript(render_to_string(:action => "edit")) + "')"
end
end
format.xml { render :xml => @file_list_item.errors, :status => :unprocessable_entity }
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def index\n @file_list = UploadedFileList.find(params[:uploaded_file_list_id])\n @file_list_items = @file_list.file_list_items.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @file_list_items }\n end\n end",
"def update\n @file_item = FileItem.cs(self.current_scope).find_by_path(params[:id])\n\n respond_to do |format|\n if @file_item.update_attributes(params[:file_item])\n format.html { redirect_to (params[:redirect_to] || @file_item), :notice => 'File item was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit_#{@file_item.item_type}\" }\n format.json { render :json => @file_item.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def show\n @file_list = UploadedFileList.find(params[:uploaded_file_list_id])\n @file_list_item = @file_list.file_list_items.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @file_list_item }\n end\n end",
"def update\n @item.update_attributes(item_params)\n @items = List.find(item_params[:list_id]).items.order(\"id ASC\")\n @list_id = @item.list.id\n end",
"def update\n item = @list.list_items.find(params[:id])\n\n if item.update_attributes(params[:list_item])\n render json: item\n else\n error(t('messages.list_item.errors.update'))\n end\n end",
"def update\n \n @list_item = ListItem.find(params[:id])\n\n if @list_item.update(list_item_params)\n head :no_content\n else\n render json: @list_item.errors, status: :unprocessable_entity\n end\n end",
"def update_list(item_name, item_list, quantity)\n add_list(item_name, item_list, quantity)\nend",
"def update\n @item = @collection.items.get(params[:id])\n @collection.schema.each do |field|\n if params[:item][field.to_s].blank? && !field.is_file\n @item[field.name]=nil\n elsif field.is_file\n #do nothing\n unless params[:item][field.to_s].nil?\n new_file = @file_collection.items.new()\n new_file.file =params[:item][field.to_s]\n new_file.save\n @item[field.name]='{\"project\":{\"id\": \"'+@project.id+'\"}, \"collection\":{\"id\": \"'+@file_collection.id+'\"},\"item\":{\"id\": \"'+new_file.id.to_s+'\", \"display\": \"'+new_file.original_filename+'\"}}'\n end\n else\n @item[field.name] = params[:item][field.to_s]\n end\n end\n if @item.save\n update_associated_fields(@item, @collection, @project)\n respond_to do |format|\n format.html do\n flash[:notice] = \"Item Updated Successfully!\"\n end\n #format.json { render json: @item.to_json, status: :updated}\n format.js { render :js => '$(\"#message\").html(\"<h2>Item updated. Close window and refresh your page.</h2>\").attr(\"class\",\"message notice\"); $(\"html, body\").animate({scrollTop: \"0px\"})' }\n end\n else\n respond_to do |format|\n format.html do\n flash[:error] = [\"Item failed to save! Errors:\", @item.errors.full_messages].flatten.join(' ')\n end\n format.json { render json: @item.to_json, status: :error}\n format.js { render :js => '$(\"#message\").html(\"<h2>Item failed update.</h2>\").attr(\"class\",\"message error\").scrollTop(0); $(\"html, body\").animate({scrollTop: \"0px\"})' }\n end\n end\n redirect_to :back\n end",
"def update opts = {}\n opts[:headers] ||= {}\n opts[:headers]['Content-Type'] ||= 'text/xml'\n post 'update', opts\n end",
"def update_xml_list\n # No file, we download it\n unless File.exists?(@xml_file) \n download_xml_list()\n end\n\n # File still young enough, we keep it\n if (Time.now() - File.mtime(@xml_file)).to_i < @download_delay\n puts \"Podcast list is up to date\"\n return\n end\n\n # We download a new file\n download_xml_list()\n end",
"def update_list(id, list)\n record \"/todos/update_list/#{id}\", :list => list\n end",
"def update\n images_arr = params[:images]\n params[:list_item].delete(:image)\n @list_item = ListItem.find(params[:id])\n @image = Image.new(images_arr)\n @list_item.images << @image\n\n respond_to do |format|\n if @list_item.update_attributes(params[:list_item])\n format.html { redirect_to user_url(current_user), notice: t('list_items.updated') }\n format.json { render :json => @list_item }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @list_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @treq = Treq.find(params[:id])\n\n respond_to do |format|\n unless params[:treq_files].blank?\n params[:treq_files]['file'].each do |a|\n @treq_file = @treq.treq_files.create!(:file => a, :treq_id => @treq.id)\n end\n end\n if @treq.update_attributes(params[:treq])\n format.html { redirect_to @treq, notice: 'Treq was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @treq.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @list = List.find(params[:id])\n\n nested = params[:list].delete( :list_items_attributes )\n\n new_items = []\n\n if nested then\n nested.each do |i, r|\n\n if !r.key?( \"id\" )\n\n new_items << ListItem.new( { \"list\" => @list }.merge( r ) ) if !item_blank?( r )\n\n nested.delete( i )\n\n else\n\n r[ \"_destroy\" ] = \"true\" if item_blank?( r )\n\n end\n\n end\n end\n\n respond_to do |format|\n if @list.update_attributes( params[ :list ] ) && \n @list.update_attributes( list_items_attributes: (nested || {}) ) &&\n new_items.map( &:save ).all? then\n\n format.html { redirect_to @list, notice: 'List was successfully updated.' }\n format.json { head :no_content }\n\n else\n\n format.html { render action: \"edit\" }\n format.json { render json: @list.errors, status: :unprocessable_entity }\n\n end\n end\n end",
"def update_volumes(username, token, workset_name, volume_ids)\n\n #<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n #<volumes xmlns=\"http://registry.htrc.i3.illinois.edu/entities/workset\">\n # <volume>\n # <id>9999999</id>\n # </volume>\n # <volume>\n # <id>3333333</id>\n # </volume>\n # </volumes>\n volumes_xml =\n \"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"yes\\\"?>\" +\n \"<volumes xmlns=\\\"http://registry.htrc.i3.illinois.edu/entities/workset\\\">\";\n\n for id in volume_ids\n volumes_xml += \"<volume><id>#{id}</id></volume>\"\n end\n volumes_xml += \"</volumes>\"\n\n\n # curl -v --data @new_volumes.xml -X PUT \\\n # -H \"Content-Type: application/vnd.htrc-volume+xml\" \\\n # -H \"Accept: application/vnd.htrc-volume+xml\" \\\n # http://localhost:9763/ExtensionAPI-0.1.0/services/worksets/workset1/volumes?user=fred\n\n url = URI.parse(\"#{APP_CONFIG['registry_url']}/worksets/#{workset_name}/volumes\")\n http = Net::HTTP.new(url.host, url.port)\n if Rails.env.development?\n http.set_debug_output($stdout)\n end\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\n request = Net::HTTP::Put.new(url.request_uri)\n request[\"Content-Type\"] = \"application/vnd.htrc-volume+xml\"\n request.add_field(\"Authorization\", \"Bearer #{token}\")\n\n request.body = volumes_xml\n response = http.request(request)\n\n #xml = response.body\n\n case response\n when Net::HTTPUnauthorized then\n raise Exceptions::SessionExpiredError.new(\"Session expired. Please login again\")\n when Net::HTTPSuccess then\n # Do nothing\n else\n raise Exceptions::SystemError.new(\"Error retrieving worksets (HTTP #{response.code})\")\n end\n\n end",
"def update(list, item, qty)\n add_item(list, item, qty)\nend",
"def update\n @list = List.find(params[:list_id])\n @list_item = @list.list_items.find(params[:id])\n\n if @list_item.update_attributes(params[:list_item])\n flash[:success] = \"List item was successfully updated.\"\n redirect_to list_path(@list) \n else\n flash[:errror] = \"Unable to update item.\"\n redirect_to edit_list_list_item_path(@list, @list_item)\n end\n end",
"def update\n \t@list = current_user.lists.find params[:list_id]\n @item = @list.items.find(params[:id])\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to list_items_path(@list), notice: 'Item was successfully updated.' }\n #format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n #format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n task\n if @item.update(item_params)\n render json: @list.as_json, status: :ok\n else\n render json: {list: @item.errors, status: :unprocessable_entity}\n end\n end",
"def create_update_volumes(username, token, workset_name, volume_ids)\n\n #<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n #<volumes xmlns=\"http://registry.htrc.i3.illinois.edu/entities/workset\">\n # <volume>\n # <id>9999999</id>\n # </volume>\n # <volume>\n # <id>3333333</id>\n # </volume>\n # </volumes>\n volumes_xml =\n \"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"yes\\\"?>\" +\n \"<volumes xmlns=\\\"http://registry.htrc.i3.illinois.edu/entities/workset\\\">\";\n\n for id in volume_ids\n volumes_xml += \"<volume><id>#{id}</id></volume>\"\n end\n volumes_xml += \"</volumes>\"\n\n\n # curl -v --data @new_volumes.xml -X PUT \\\n # -H \"Content-Type: application/vnd.htrc-volume+xml\" \\\n # -H \"Accept: application/vnd.htrc-volume+xml\" \\\n # http://localhost:9763/ExtensionAPI-0.1.0/services/worksets/workset1/volumes?user=fred\n\n url = URI.parse(\"#{APP_CONFIG['registry_url']}/worksets/#{workset_name}\")\n http = Net::HTTP.new(url.host, url.port)\n if Rails.env.development?\n http.set_debug_output($stdout)\n end\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\n request = Net::HTTP::Put.new(url.path)\n request[\"Content-Type\"] = \"application/vnd.htrc-volume+xml\"\n request.add_field(\"Authorization\", \"Bearer #{token}\")\n\n request.body = volumes_xml\n response = http.request(request)\n\n #xml = response.body\n\n case response\n when Net::HTTPUnauthorized then\n raise Exceptions::SessionExpiredError.new(\"Session expired. Please login again\")\n when Net::HTTPSuccess then\n # Do nothing\n else\n raise Exceptions::SystemError.new(\"Error retrieving worksets (HTTP #{response.code})\")\n end\n end",
"def update\n respond_to do |format|\n if @list_item.update(list_item_params)\n format.html { redirect_to @list, notice: 'List item was successfully updated.' }\n format.json { render :show, status: :ok, location: @list_item }\n else\n format.html { render :edit }\n format.json { render json: @list_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @list_item.update(list_item_params)\n format.html { redirect_to list_path(@list), notice: 'List item was successfully updated.' }\n format.json { render :show, status: :ok, location: @list_item }\n else\n format.html { render :edit }\n format.json { render json: @list_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @list_item.update(list_item_params)\n format.html { redirect_to @list_item, notice: 'List item was successfully updated.' }\n format.json { render :show, status: :ok, location: @list_item }\n else\n format.html { render :edit }\n format.json { render json: @list_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\n @item = Item.find(params[:id])\n @item.update(item_params)\n\n redirect_to user_list_path(@item.list.user, @item.list)\n end",
"def update\n respond_to do |format|\n if @item_list.update(item_list_params)\n format.html { redirect_to @item_list, notice: 'Item list was successfully updated.' }\n format.json { render :show, status: :ok, location: @item_list }\n else\n format.html { render :edit }\n format.json { render json: @item_list.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item.update_attributes(params[:item])\n format.html { redirect_to @item }\n format.xml { head :ok }\n else\n \n format.html { render :action => \"edit\" }\n format.xml { render :xml => @item.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def put(path = '/files/', params = {})\n request :put, path, params\n end",
"def update\n @indexed_file = IndexedFile.find(params[:id])\n\n respond_to do |format|\n if @indexed_file.update_attributes(params[:indexed_file])\n format.html { redirect_to @indexed_file, notice: 'Indexed file was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @indexed_file.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @list_of_value = Irm::ListOfValue.find(params[:id])\n\n respond_to do |format|\n if @list_of_value.update_attributes(params[:irm_list_of_value])\n format.html { redirect_to({:action => \"index\"}, :notice => t(:successfully_updated)) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @list_of_value.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @mylist = Mylist.find(params[:id])\n\n respond_to do |format|\n if @mylist.update_attributes(params[:mylist])\n format.html { redirect_to(@mylist, :notice => 'Mylist was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @mylist.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @event_subscription.update(event_subscription_params)\n @event_subscription.save\n\n file_params.each do |requirement|\n if(requirement[\"doc\"])\n requirement.symbolize_keys\n requirement[:doc].symbolize_keys\n path = \"data:#{requirement[:doc][:filetype]};base64, #{requirement[:doc][:base64]}\"\n Document.update(id: requirement[:doc][:id],\n user_id: @event_subscription.user_id,\n requirement_id: requirement[:id],\n state: \"pending_review\",\n path: path\n )\n end\n end\n render json: @event_subscription, status: :updated\n end",
"def update_rest\n @entry_item = EntryItem.find(params[:id])\n\n respond_to do |format|\n if @entry_item.update_attributes(params[:entry_item])\n flash[:notice] = 'EntryItem was successfully updated.'\n #format.html { redirect_to(@entry_item) }\n format.xml { head :ok }\n else\n #format.html { render :action => \"edit\" }\n format.xml { render :xml => @entry_item.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update_list(list_id, name)\n data = {\n list: {\n name: name\n }\n }\n rest(\"patch\", \"lists/#{list_id}\", data)\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n @item.images.delete_all\n unless params.require(:item)[:images_id].nil?\n params.require(:item)[:images_id].each do |id|\n image = Image.find_by_id(id)\n (@item.images << image) unless image.nil?\n end\n end\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @item = Item.find(params[:id])\n\n respond_to do |format|\n if @item.update_attributes(params[:item])\n format.html { redirect_to(@item)}\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @item.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update(file_path, list_type, operation = 'ADD')\n upload = TwitterAds::TONUpload.new(account.client, file_path)\n update_audience(self, upload.perform, list_type, operation)\n reload!\n end",
"def update\n @list = current_user.lists.find(params[:id])\n @list.update_attributes(params[:list])\n respond_with(@list, :location => my_list_url(@list))\n end",
"def update\n @item = Item.find(params[:id])\n\n respond_to do |format|\n if @item.update_attributes(params[:item])\n format.html { redirect_to lists_path, :notice => 'Item was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @item.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @item = Item.find(params[:id])\n\n logger.info \"Item: #{@item}\\nw/ param attr: #{params[:item].inspect}\"\n respond_to do |format|\n @item.attributes = params[:item].select{|k,v| ![:item_photos, :item_photos_attributes, :location].include?(k.to_sym) }\n\n @item.load_item_photos_with_params(params[:item] )\n\n if @item.save\n\n @item.set_by_user(auth_user)\n\n logger.info \" C) after save: attr: #{@item.attributes}\"\n\n if manage_item_photos(@item).present? || @item.changed?\n @item.save\n logger.info \" D) attr: #{@item.attributes}\"\n end\n\n format.html {\n redirect_to inventory_approve_item_path(:user_id => \"#{@item.owner.id}\")\n }\n format.json { render json:{ item: @item, success: true} }\n else\n set_flash_messages_from_errors(@item)\n format.html { render action: \"edit\" }\n format.json { render json: { error: @item.errors.first.join(' ') }, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @audio_file = AudioFile.find(params[:id])\n\n respond_to do |format|\n if @audio_file.update_attributes(params[:audio_file])\n format.xml { head :ok }\n format.json { head :ok }\n else\n format.xml { render :xml => @audio_file.errors, :status => :unprocessable_entity }\n format.json { render :json => @audio_file.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @item = Item.find(params[:id])\n @item.update_attributes(params[:item])\n respond_with @item\n end",
"def update\n\t\t@list = List.find(params[:id])\n\n\t\trespond_to do |format|\n\t\t\tif @list.update_attributes(params[:list])\n\t\t\t\tformat.html\t{ redirect_to(root_url) }\n\t\t\t\tformat.xml\t{ head :ok }\n\t\t\telse\n\t\t\t\tformat.html\t{ render :action => \"edit\" }\n\t\t\t\tformat.xml\t{ render :xml => @list.errors, :status => :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend",
"def update_list\n current_path = '/api/v1/update'\n @conn.get(current_path)\n end",
"def update\n @stream_item = StreamItem.find(params[:id])\n\n respond_to do |format|\n if @stream_item.update_attributes(params[:stream_item])\n format.html { redirect_to([:scaffold, @stream_item], :notice => 'Stream item was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @stream_item.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @movie_list_item = MovieListItem.find(params[:id])\n\n respond_to do |format|\n if @movie_list_item.update_attributes(params[:movie_list_item])\n format.html { redirect_to(@movie_list_item, :notice => 'Movie list item was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @movie_list_item.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @list_item.update(list_item_params)\n format.html { redirect_to @list_item, notice: 'List item was successfully updated.' }\n format.json { render json: @list_item, status: :ok }\n else\n format.html { render :edit }\n format.json { render json: @list_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def override\n document_id = params[:document_id]\n document = params[:document]\n document_type = params[:document_type]\n ticket = Document.ticket(Alfresco::Document::ALFRESCO_USER, Alfresco::Document::ALFRESCO_PASSWORD)\n\n builder = Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |xml|\n xml.entry(:xmlns => \"http://www.w3.org/2005/Atom\",\n \"xmlns:cmisra\" => \"http://docs.oasis-open.org/ns/cmis/restatom/200908/\",\n \"xmlns:cmis\" => \"http://docs.oasis-open.org/ns/cmis/core/200908/\") {\n xml.title document.original_filename if document\n xml.summary document_type\n if document\n xml.content(:type => document.content_type) {\n xml.text Base64.encode64(document.read)\n }\n end\n }\n end\n\n url = Document::PATH + \"cmis/i/#{document_id}?alf_ticket=\" + ticket\n\n begin\n RestClient.put url, builder.to_xml, {:content_type => 'application/atom+xml;type=entry'}\n rescue => e\n Rails.logger.info \"#\"*50\n Rails.logger.info \"Error updating file\"\n Rails.logger.info e.message\n Rails.logger.info \"#\"*50\n end\n\n redirect_to :controller => 'related_service_requests', :action => 'show', :anchor => 'documents', :service_request_id => params[:friendly_id], :id => params[:ssr_id]\n end",
"def update\n @page_title = \"Task List Update\"\n @task_list = TaskList.find(params[:id])\n\n respond_to do |format|\n if @task_list.update_attributes(params[:task_list])\n flash[:notice] = 'TaskList was successfully updated.'\n format.html { redirect_to(@task_list) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @task_list.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update_rest\n @item_usage = ItemUsage.find(params[:id])\n\n respond_to do |format|\n if @item_usage.update_attributes(params[:item_usage])\n flash[:notice] = 'ItemUsage was successfully updated.'\n format.html { redirect_to(@item_usage) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @item_usage.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def rest_update(uri, method: Net::HTTP::Put)\n request = Net::HTTP::Get.new uri\n request.add_field(\"Accept\",\"application/xml\")\n auth_admin(request)\n \n Net::HTTP.start(uri.host, uri.port) do |http|\n response = http.request request\n response.value\n\n doc = REXML::Document.new response.body\n \n doc = strip_class_attributes(yield doc)\n \n request2 = method.new uri\n request2.content_type = 'application/xml'\n auth_admin(request2)\n\n request2.body=doc.to_s\n \n response2 = http.request request2\n response.value\n\n end\n \nend",
"def update\n description = file_params[:description] || @file.description\n\n raise ApiError, \"Can't rename a file.\" unless @file.rename(file_params[:name], description)\n\n render json: @file, adapter: :json\n end",
"def update\n if @listitem.update(listitem_params)\n render :show, status: :ok, location: todolist_listitem_path(@todolist, @listitem)\n else\n render json: @listitem.errors, status: :unprocessable_entity\n end\nend",
"def touch(options={})\n #list = list.to_a\n fileutils.touch(list, options)\n end",
"def update\n @list.update_attributes list_params\n end",
"def update\n if params[:new_check_list_item][:id].present?\n @check_list.check_list_items.create(check_id: params[:new_check_list_item][:id])\n end\n if params[:cli]\n params[:cli].each do |cli_array|\n cli = CheckListItem.find(cli_array[0].to_i)\n cli.position = cli_array[1].to_i\n cli.save\n end\n end\n\n respond_to do |format|\n if @check_list.update(check_list_params)\n format.html { redirect_to :back, notice: 'Check list was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @check_list.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @email_list = EmailList.find(params[:id])\n\n respond_to do |format|\n if @email_list.update_attributes(params[:email_list])\n format.html { redirect_to(@email_list, :notice => 'Email list was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @email_list.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @action_list = ActionList.find(params[:id])\n\n respond_to do |format|\n if @action_list.update_attributes(params[:action_list])\n format.html { redirect_to(@action_list, :notice => 'ActionList was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @action_list.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @item = Item.find(params[:id])\n\n respond_to do |format|\n if @item.update_attributes(params[:item])\n flash[:notice] = 'Item was successfully updated.'\n format.html { redirect_to(@item) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @item.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @item = Item.find(params[:id])\n\n respond_to do |format|\n if @item.update_attributes(params[:item])\n flash[:notice] = 'Item was successfully updated.'\n format.html { redirect_to(@item) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @item.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @item = Item.find(params[:id])\n\n respond_to do |format|\n if @item.update_attributes(params[:item])\n flash[:notice] = 'Item was successfully updated.'\n format.html { redirect_to(@item) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @item.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update \n respond_to do |wants|\n if @item.update_attributes(params[:item])\n flash[:notice] = 'Item was successfully updated.'\n wants.html { redirect_to(admin_items_path) }\n wants.xml { head :ok }\n else\n \n wants.html { render :action => \"edit\" }\n wants.xml { render :xml => @item.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @item = Item.find(params[:id])\n\n respond_to do |format|\n if @item.update_attributes(params[:item])\n flash[:notice] = 'Item was successfully updated.'\n format.html { redirect_to(:action => :index) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @item.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @list_items = args[:list_items] if args.key?(:list_items)\n end",
"def update_metadata(filename, metadata, path, site_path=nil)\n sanitized_filename = sanitize_filename(filename)\n url = computed_web_api_url(site_path)\n server_relative_url = \"#{site_path}#{path}/#{sanitized_filename}\"\n easy = ethon_easy_json_requester\n easy.url = uri_escape \"#{url}GetFileByServerRelativeUrl('#{server_relative_url}')/ListItemAllFields\"\n easy.perform\n\n __metadata = JSON.parse(easy.response_body)['d']['__metadata']\n update_metadata_url = __metadata['uri']\n prepared_metadata = prepare_metadata(metadata, __metadata['type'])\n\n easy = ethon_easy_json_requester\n easy.headers = { 'accept' => 'application/json;odata=verbose',\n 'content-type' => 'application/json;odata=verbose',\n 'X-RequestDigest' => xrequest_digest(site_path),\n 'X-Http-Method' => 'PATCH',\n 'If-Match' => \"*\" }\n easy.http_request(update_metadata_url,\n :post,\n { body: prepared_metadata })\n easy.perform\n check_and_raise_failure(easy)\n easy.response_code\n end",
"def template_update(id, type, filename)\n check_id_or_raise id\n check_template_type_or_raise type\n check_filename_or_raise filename\n response = http_request_multipart :put, @base_url + \"/templates/#{id}.xml\", 200,\n { :provider_key => @provider_key,\n :draft => File.read(filename), \n :multipart => true}\n puts 'at update call'\n _id, _updated_at = parse_response response, type\n response = http_request :put, \"#{@base_url}/templates/#{id}/publish\", 200,\n { :params => { :provider_key => @provider_key } }\n puts 'at publish call'\n parse_response response, 'page'\n end",
"def create\n @<%= file_name %> = <%= class_name %>.new(params[:<%= file_name %>])\n\n respond_to do |format|\n if @<%= file_name %>.save\n flash[:notice] = '<%= class_name %> was successfully created.'\n format.html { redirect_to(@<%= file_name %>) }\n format.xml { render :xml => @<%= file_name %>, :status => :created, :location => @<%= file_name %> }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @<%= file_name %>.errors, :status => :unprocessable_entity }\n end\n end\n end\n\n # PUT /<%= table_name %>/1\n # PUT /<%= table_name %>/1.xml\n def update\n @<%= file_name %> = <%= class_name %>.find(params[:id])\n\n respond_to do |format|\n if @<%= file_name %>.update_attributes(params[:<%= file_name %>])\n flash[:notice] = '<%= class_name %> was successfully updated.'\n format.html { redirect_to(@<%= file_name %>) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @<%= file_name %>.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def upload_file(item_file)\n upload_response = @server.upload(item_file.file(item_file.metadata_full_path))\n json = JSON.parse(upload_response.body)\n json['files'].map { |f| f['id'] }\n end",
"def update\n respond_to do |format|\n if @apiv1_item.update(apiv1_item_params)\n format.html { redirect_to @apiv1_item, notice: 'Item was successfully updated.' }\n format.json { render :show, status: :ok, location: @apiv1_item }\n else\n format.html { render :edit }\n format.json { render json: @apiv1_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @item = Item.find(params[:id])\n\n respond_to do |format|\n if @item.update_attributes(params[:item])\n format.html { redirect_to(@item, :notice => 'Item was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @item.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @item = Item.find(params[:id])\n\n respond_to do |format|\n if @item.update_attributes(params[:item])\n format.html { redirect_to(@item, :notice => 'Item was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @item.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def updating_item(list,item,quantity)\r\n\r\n adding_item(list,item, quantity)\r\n\r\nend",
"def upload\n document = params[:document]\n service_request_id = params[:service_request_id]\n organization_id = params[:organization_id]\n document_type = params[:document_type]\n\n # let's see how many existing docs we have before we upload\n document_count_before_upload = Alfresco::Document.number_of_documents_for(service_request_id)\n\n ticket = Document.ticket(Alfresco::Document::ALFRESCO_USER, Alfresco::Document::ALFRESCO_PASSWORD)\n\n builder = Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |xml|\n xml.entry(:xmlns => \"http://www.w3.org/2005/Atom\",\n \"xmlns:cmisra\" => \"http://docs.oasis-open.org/ns/cmis/restatom/200908/\",\n \"xmlns:cmis\" => \"http://docs.oasis-open.org/ns/cmis/core/200908/\") {\n xml.title document.original_filename\n xml.summary document_type\n xml.content(:type => document.content_type) {\n xml.text Base64.encode64(document.read)\n }\n }\n end\n\n if !Document.service_request_folder_exists? service_request_id\n Document.create_service_request_folder service_request_id\n end\n\n sub_folders = Document.find_sub_folders_for_service_request service_request_id\n unless sub_folders.include? organization_id\n Document.create_service_request_organization_folder(service_request_id, organization_id)\n end\n\n url = Document::PATH + \"cmis/p/User%20Homes/service_requests/#{service_request_id}/#{organization_id}/children?alf_ticket=\" + ticket\n\n count = 0\n begin\n count = count + 1\n RestClient.post url, builder.to_xml, {:content_type => 'application/atom+xml;type=entry'}\n rescue => e\n Rails.logger.info \"#\"*50\n Rails.logger.info \"Error creating file\"\n Rails.logger.info e.message\n Rails.logger.info \"#\"*50\n end\n\n new_document_count = count + document_count_before_upload\n document_count_after_upload = Alfresco::Document.number_of_documents_for(service_request_id)\n\n while(document_count_after_upload != new_document_count) do\n sleep(0.5)\n document_count_after_upload = Alfresco::Document.number_of_documents_for(service_request_id)\n end\n\n redirect_to :controller => 'related_service_requests', :action => 'show', :anchor => 'documents', :service_request_id => params[:friendly_id], :id => params[:ssr_id]\n end",
"def update\n @actionitem = Actionitem.find(params[:id])\n name = params[:actionitem][:pic].original_filename if params[:actionitem][:pic]\n directory = 'public/images/action_items_images'\n\n path = File.join(directory, name) if params[:actionitem][:pic]\n\n if params[:actionitem][:pic].instance_of?(Tempfile)\n FileUtils.cp(params[:actionitem][:pic].local_path, path)\n else\n File.open(path, \"wb\") { |f| f.write(params[:actionitem][:pic].read) } if params[:actionitem][:pic]\n end\n\n respond_to do |format|\n if @actionitem.update_attributes(params[:actionitem])\n @actionitem.pic = name if params[:actionitem][:pic]\n @actionitem.save\n format.html { redirect_to(actionitems_path(:action_id => @actionitem.action_id), :notice => 'Акция была успешно обновлена.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @actionitem.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @list.append_items!(params.dig(:list, :items), current_user)\n redirect_to [@project, @randomization_scheme], notice: \"Items successfully added.\"\n end",
"def update\n @item = Item.find(params[:id])\n\n respond_to do |format|\n if @item.update_attributes(params[@item.class.to_s.downcase.to_sym])\n flash[:notice] = 'Item was successfully updated.'\n format.html { redirect_to(@item) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @item.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @document_item.update(document_item_params)\n format.html { redirect_to @document_item, notice: 'Document item was successfully updated.' }\n format.json { render :show, status: :ok, location: @document_item }\n else\n format.html { render :edit }\n format.json { render json: @document_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_item\n @item = Item.find(params[:id])\n @item.update(params[:item])\n redirect \"/items/#{@item.id}\"\n end",
"def updated(item)\n end",
"def update\n respond_to do |format|\n if @list.update(list_params)\n format.html { redirect_to @list, notice: 'Changes and Additions Successful.' }\n format.json { render :show, status: :ok, location: @list }\n else\n format.html { render :edit }\n format.json { render json: @list.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\r\n @item = Item.find(params[:id])\r\n\r\n respond_to do |format|\r\n if @item.update_attributes(params[:item])\r\n format.html { redirect_to(@item, :notice => 'Item Successfully updated.') }\r\n format.xml { head :ok }\r\n else\r\n format.html { render :action => \"edit\" }\r\n format.xml { render :xml => @item.errors, :status => :unprocessable_entity }\r\n end\r\n end\r\n end",
"def update\n# @fossil = Fossil.find(params[:id])\n\n respond_to do |format|\n if @fossil.update_attributes(params[:fossil])\n format.html { redirect_to([@collection, @fossil], :notice => 'File was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @fossil.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @item = @user.items.find(params[:id])\n\n @item.update(:type_list => \"\", :tag_list => \"\")\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to [@user, @item], notice: 'item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n\n\n end",
"def update\n @item ||= Item.find_by_id_or_name(params[:id])\n\n respond_to do |format|\n if @item.update_attributes(params[:item])\n flash[:notice] = 'Item was successfully updated.'\n format.html { redirect_to(@item) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @item.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n authorize @task\n @task.updated_by = current_user\n\n files = @task.files\n files += task_params[:files] if task_params[:files]\n @task.assign_attributes(task_params)\n @task.files = files\n\n if params[:files_remove]\n\n remain_files = @task.files\n\n params[:files_remove].reverse_each do |file, state|\n if state.to_i == 1\n deleted_files = remain_files.delete_at(file.to_i)\n deleted_files.try(:remove!)\n end\n end\n\n @task.remove_files! if remain_files.empty?\n end\n respond_to do |format|\n if @task.save\n format.html { redirect_back_or_default tasks_url, t('Record has been saved') }\n format.json { render :show, status: :ok, location: @task }\n else\n format.html { render :edit }\n format.json { render json: @task.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @list.update(existing_list_params)\n format.html { redirect_to my_list_path(@list), notice: 'List was successfully updated.' }\n format.json { render :show, status: :ok, location: my_list_path(@list) }\n else\n format.html { render :edit }\n format.json { render json: @list.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @app_list.update(app_list_params)\n @app_list.app_resouces.all.each do |r|\n r.destroy\n end\n params[:app_resouce][:app_pic].each do |p|\n @app_resouce = @app_list.app_resouces.create!(:app_pic=> p,:app_list_id=>@app_list.id)\n end\n format.html { redirect_to @app_list, notice: 'App list was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @app_list.errors, status: :unprocessable_entity }\n end\n end\n end",
"def add_to_list(list,item,quantity)\n\tupdate_item(list,item,quantity)\nend",
"def update(item_attrs = {})\n body = { update: item_attrs }\n Iterable.request(conf, base_path).patch(body)\n end",
"def update\n @item = Item.find(params[:id])\n respond_to do |format|\n if @item.update_attributes(params[:item])\n flash[:notice] = \"Item has been updated\"\n format.json { render :json => @item.to_json, :status => 200 }\n format.xml { head :ok }\n format.html { render :action => :edit }\n else\n format.json { render :text => \"Could not update item\", :status => :unprocessable_entity } #placeholder\n format.xml { render :xml => @item.errors, :status => :unprocessable_entity }\n format.html { render :action => :edit, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @file_upload = FileUpload.find(params[:id])\n\n respond_to do |format|\n if @file_upload.update_attributes(params[:file_upload])\n format.html { redirect_to(@file_upload, :notice => 'FileUpload was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @file_upload.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def multi_update\n errors = false\n return_value = []\n file_infos_params = params.permit(file_infos: [:id, :review_done, :component_id]).require(:file_infos)\n file_infos_params.each do |key, file_info_entry|\n (return_value << nil) and (errors = true) and next unless file_info_entry[:id]\n file_info = FileInfo.find(file_info_entry[:id])\n (return_value << nil) and (errors = true) and next unless file_info\n if file_info.update(file_info_entry)\n return_value << file_info_entry\n else\n return_value << file_info.errors\n errors = true\n end\n end\n respond_to do |format|\n format.json { render json: return_value }\n if errors\n format.html { redirect_to :back, notice: 'Some entries have errors'}\n else\n format.html { redirect_to :back }\n end\n end\n end",
"def updateItem(app, repo_url, item, id)\n headers = defaultHeaders(app[\"token\"])\n data = id.merge(item).to_json\n response = HTTParty.post(repo_url,\n headers: headers,\n body: data)\n response \nend",
"def update\n @thing_list = ThingList.find(params[:id])\n\n respond_to do |format|\n if @thing_list.update_attributes(params[:thing_list])\n format.html { redirect_to(@thing_list, :notice => 'Thing list was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @thing_list.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update \n respond_to do |format|\n if @item.update_attributes(params[:item])\n flash[:notice] = 'Artikel is succesvol ge-update.'\n format.html { redirect_to(@item) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @item.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def finish_item(list_id:, id:)\n path = \"lists/#{list_id}/items/#{id}/finish\"\n request(method: :put, path: path)\n end",
"def update\n @model = Model.find(params[:id])\n\n respond_to do |format|\n if @model.update_attributes(params[:model])\n format.html { redirect_to(@model, :notice => 'Model was successfully updated.') }\n format.xml { head :ok }\n format.csv { head :ok }\n format.json { head :ok }\n else\n format.html { @files = @model.files.paginate :page => params[:page]; render :action => \"edit\" }\n format.xml { render :xml => @model.errors, :status => :unprocessable_entity }\n format.csv { render :csv => @model.errors, :status => :unprocessable_entity }\n format.json { render :json => @model.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @item.update!(item_params)\n end",
"def update\n respond_to do |format|\n if @task_item.update(task_item_params)\n format.html { redirect_to task_list_path(@task_item.list), notice: 'Item was successfully updated.' }\n format.json { render :show, status: :ok, location: @task_item }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @task_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @document_list.update(document_list_params)\n format.html { redirect_to @document_list, notice: 'Document list was successfully updated.' }\n format.json { render :show, status: :ok, location: @document_list }\n else\n format.html { render :edit }\n format.json { render json: @document_list.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @list.update(_list_params)\n format.html { redirect_to @list, notice: \"List was successfully updated.\" }\n format.json { render :show, status: :ok, location: @list }\n else\n format.html { render :edit }\n format.json { render json: @list.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_quantity_of_item(list,item,quantity)\r\n add_item_to_list(list,item,quantity)\r\n list\r\nend"
] |
[
"0.6275611",
"0.60256773",
"0.5959456",
"0.594907",
"0.59464186",
"0.59419596",
"0.5918617",
"0.5908268",
"0.58800936",
"0.58552647",
"0.5847207",
"0.5837163",
"0.5810882",
"0.58047724",
"0.57644105",
"0.5743155",
"0.56985414",
"0.5680712",
"0.5677487",
"0.567688",
"0.5570072",
"0.55561763",
"0.55452645",
"0.5543652",
"0.55420476",
"0.55283135",
"0.5503044",
"0.54988974",
"0.54938984",
"0.5490002",
"0.54899204",
"0.54846174",
"0.5469681",
"0.5468628",
"0.54636776",
"0.54603237",
"0.545921",
"0.5458021",
"0.54533076",
"0.54384816",
"0.543613",
"0.5428838",
"0.5418964",
"0.5411198",
"0.54066014",
"0.540354",
"0.5397267",
"0.53942066",
"0.53838634",
"0.5383454",
"0.5381561",
"0.5378507",
"0.5361138",
"0.5360263",
"0.5360168",
"0.53584915",
"0.53521866",
"0.5335245",
"0.5335245",
"0.5335245",
"0.5333906",
"0.53285897",
"0.53223014",
"0.5318555",
"0.53139764",
"0.5311009",
"0.5299498",
"0.5294258",
"0.5290998",
"0.5290998",
"0.52909887",
"0.52907956",
"0.5289204",
"0.52848357",
"0.52795583",
"0.52756494",
"0.5274801",
"0.5273457",
"0.5270716",
"0.5267266",
"0.52586335",
"0.5252832",
"0.5250593",
"0.52498513",
"0.5245054",
"0.524416",
"0.52388597",
"0.52370644",
"0.5235637",
"0.523436",
"0.5233484",
"0.5230191",
"0.52262866",
"0.5225678",
"0.5224882",
"0.5222574",
"0.52220887",
"0.5221587",
"0.5219425",
"0.52180165",
"0.52180153"
] |
0.0
|
-1
|
DELETE /file_list_items/1 DELETE /file_list_items/1.xml
|
def destroy
@file_list = UploadedFileList.find(params[:uploaded_file_list_id])
@file_list_item = @file_list.file_list_items.find(params[:id])
file_list_item_id = @file_list_item.id
@page_section = @file_list.page_section
@page = @page_section.page
@site_section = @page.site_section
@file_list_item.destroy
respond_to do |format|
format.html { redirect_to site_section_page_url(@site_section, @page) }
format.js { render :js => "$('#page_section_" + @page_section.id.to_s + "').replaceWith('" + @template.escape_javascript(render_to_string(:partial => "page_sections/show")) + "');$('#modal-content').html("");$('#modal').jqmHide();" }
format.xml { head :ok }
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def destroy\n @file_item = FileItem.cs(self.current_scope).find_by_path(params[:id])\n @file_item.destroy\n\n respond_to do |format|\n format.html { redirect_to file_items_url }\n format.json { head :ok }\n end\n end",
"def delete_file_from_database(file_id)\n $db.execute(\"DELETE FROM files WHERE id = ?\", file_id)\n $db.execute(\"DELETE FROM file_share_table WHERE file_id = ?\", file_id)\nend",
"def destroy\n RestClient.delete \"#{REST_API_URI}/contents/#{id}.xml\" \n self\n end",
"def destroy\n @feefile = Feefile.find(params[:id])\n directory= \"uploads\"\n path =File.join(directory,@feefile.feefilename)\n File.delete(path)\n @feefile.destroy\n \n\n respond_to do |format|\n format.html { redirect_to(feefiles_url) }\n format.xml { head :ok }\n end\n end",
"def delete_files(uuids)\n Uploadcare::FileList.batch_delete(uuids)\n end",
"def delete_one(file)\n files_collection.find(:_id => file.id).delete_one\n chunks_collection.find(:files_id => file.id).delete_many\n end",
"def delete_file_from_db(file_id)\n $db.execute(\"DELETE FROM files WHERE file_id = ?\", file_id)\nend",
"def file_delete(node, file)\n _out, _local, _remote, code = node.test_and_store_results_together(\"rm #{file}\", 'root', 500)\n code\nend",
"def file_delete(node, file)\n _out, _local, _remote, code = node.test_and_store_results_together(\"rm #{file}\", 'root', 500)\n code\nend",
"def destroy\n @upload_file = UploadFile.find(params[:id])\n doc_no=@upload_file.doc_no\n @upload_file.destroy\n\n respond_to do |format|\n format.html { redirect_to upload_files_url(:doc_no=>doc_no) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @list_item.destroy\n\n head :no_content\n end",
"def delete_list_item(client, uri, headers)\n # log what we are doing\n log(:info, \"Deleting Sharepoint list item at: #{uri}\")\n\n # send the delete request and return the response\n client.delete(uri, headers)\n end",
"def delete_file\n unless $list_Item.curselection.empty?\n idx = $list_Item.curselection\n idx = idx[0]\n $bucket_item = $bucket_items[idx]\n ok_delete = Tk.messageBox('type' => 'okcancel',\n 'icon' => 'warning',\n 'title' => 'Delete Bucket',\n 'message' => 'Delete item?')\n if ok_delete == 'ok'\n begin\n $s3.bucket($bucket).objects(prefix: $bucket_item).batch_delete!\n $item_text.delete('1.0','end')\n $save_file_button.state = 'disabled'\n $delete_file_button.state = 'disabled'\n $item_public_read.state = 'disabled'\n $item_public_write.state = 'disabled'\n rescue => e\n Tk.messageBox('type' => 'ok',\n 'icon' => 'error',\n 'title' => 'Delete File',\n 'message' => \"Cannot Delete File #{e}\")\n end\n end\n end\n end",
"def file_delete(path)\n params = {\n \"root\" => @root,\n \"path\" => format_path(path, false),\n }\n response = @session.do_post build_url(\"/fileops/delete\", params)\n parse_response(response)\n end",
"def destroy\n @listitem.destroy\n head :no_content\nend",
"def delete(filename); end",
"def delete_fs_item\n d \"^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\"\n d \"Delete a file or folder\"\n d \"vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv\"\n \n err_str = ''\n begin # a one time loop to allow break\n \n generic_ty = Integer(params[:sel_kind]) rescue generic_ty = FSTYPE_INVALID\n elem_id = Integer(params[:sel_id]) rescue elem_id = -1\n if ( elem_id <= 0 )\n err_str = 'Invalid index'\n break\n end\n \n if ( generic_ty == FSTYPE_FILE )\n to_upd = Dfile.find_by_id( elem_id )\n if ( to_upd )\n kindname = to_upd.fileType()\n parent_id = to_upd.directory_id\n our_name = to_upd.name\n if to_upd.destroy\n reponse = { action_id: params[:action_id],\n new_id: elem_id,\n new_name: our_name,\n parent_id: parent_id,\n kind_name: kindname\n }\n render :json => reponse, :layout => false, :status => 200 and return\n else\n err_str = 'Failed to delete file'\n break\n end\n else\n err_str = 'File does not exist'\n break\n end\n elsif ( generic_ty == FSTYPE_DIR )\n to_upd = Directory.find_by_id( elem_id )\n if ( to_upd )\n parent_id = to_upd.parent_id\n our_name = to_upd.name\n if to_upd.destroy\n reponse = { action_id: params[:action_id],\n new_id: elem_id,\n new_name: our_name,\n parent_id: parent_id,\n kind_name: 'directory'\n }\n render :json => reponse, :layout => false, :status => 200 and return\n else\n err_str = 'Failed to delete directory'\n break\n end\n else\n err_str = 'Directory does not exist'\n break\n end\n else\n err_str = 'Invalid entry type'\n break\n end\n \n end until true # a one time loop to allow break\n render json: err_str, status: :unprocessable_entity and return\n end",
"def delete_file(filename,repo)\n curl_delete(\"#{self.host}/api2/repos/#{repo}/file/?p=#{filename}\").body_str\n end",
"def destroy(item)\n raise StandardError unless @mode == :update\n @attached.delete(item)\n @remove_file.puts(XML.generate({ :id => item.is_a?(String) ? item : item.id }, false))\n end",
"def del\n File.delete(@file)\n end",
"def destroy\n @data_file = DataFile.find(params[:id])\n @data_file.destroy\n\n respond_to do |format|\n format.html { redirect_to(data_files_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @mylist = Mylist.find(params[:id])\n @mylist.destroy\n\n respond_to do |format|\n format.html { redirect_to(mylists_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @file_upload = FileUpload.find(params[:id])\n @file_upload.destroy\n\n respond_to do |format|\n format.html { redirect_to(file_uploads_url) }\n format.xml { head :ok }\n end\n end",
"def delete_item(list_id:, id:)\n path = \"lists/#{list_id}/items/#{id}\"\n request(method: :delete, path: path)\n end",
"def rm_f(options={})\n #list = list.to_a\n fileutils.rm_f(list, options)\n end",
"def file_delete(file)\n\t\tputs \"Delete entries to the local site store from file: #{file}\" if @verbose\n\t\traise \"File non-exist. Please check your file path and name again: #{file}\" unless File.exist?(file)\n\t\tsites=file_2_list(file)\n\t\tchanges=Array.new\n\t\tchanges=bulk_delete(sites) unless sites.nil? or sites.empty?\n\trescue => ee\n\t\tputs \"Exception on method file_delete: #{ee} for file: #{file}\" if @verbose\n\tend",
"def deleteFileFromServer(filepath)\n filepath = filepath[1, filepath.length - 1] \n address = @@host + \"/user/\" + @@conf[\"username\"] + \"/device/\" + @@conf[\"dev_name\"] + \"/files/\" + filepath\n \n res = HttpRequest.new(:delete, address).send(@@host) \n puts res\n puts \"CODE: \" + res.code\n\nend",
"def delete_item(list_item)\n @list.delete(list_item)\n @list\n end",
"def destroy\n @upload_file = UploadFile.find(params[:id])\n @upload_file.destroy\n\n respond_to do |format|\n format.html { redirect_to(upload_files_url) }\n format.xml { head :ok }\n end\n end",
"def delete(cloud_file)\n\n payload = {\n root: \"auto\",\n path: cloud_file.path\n }\n\n connexion = Dropbox.start(:delete, access_token)\n response = connexion.post do |req|\n req.url \"fileops/delete\"\n req.body = payload\n end\n response = format_response(response)\n Filetree.new('dropbox').update([response[:path], nil])\n\n end",
"def delete\n Iterable.request(conf, base_path).delete\n end",
"def destroy\n @list_id = @item.list.id\n @item.destroy\n @items = List.find(@list_id).items.order(\"id ASC\")\n end",
"def delete_item(list,item)\n\tlist.delete(item)\nend",
"def delete_file(file_name)\n fail 'No Structure ID defined for structure. Can\\'t delete file' if @structure.id.nil?\n\n data = Hashie::Mash.new\n data.structure_id = @structure.id\n data.file_name = file_name\n\n push_file('api/remove_file', MultiJson.dump(data))\n end",
"def delete_files\n return if id.nil?\n return unless File.exist?(directory_path)\n\n FileUtils.rm_rf(directory_path)\n s3_delete_files\n end",
"def delete\n blacklight_items.each do |r|\n solr.delete_by_id r[\"id\"]\n solr.commit\n end\n end",
"def destroy\n @actionitem = Actionitem.find(params[:id])\n @actionitem.destroy\n\n respond_to do |format|\n format.html { redirect_to(actionitems_url) }\n format.xml { head :ok }\n end\n end",
"def remove_file\n\n @source_files_id = params[:source] + '_files'\n @source = TaliaCore::Source.find(N::URI.from_encoded(params[:source]))\n\n TaliaFile.find(params[:talia_file_uri]).destroy\n end",
"def delete_list_member(f)\n File.open f, 'r' do |file|\n file.each do |email|\n begin\n print email\n email.chomp!\n RestClient.delete(\"https://api:key-#{API_KEY}\" \\\n \"@api.mailgun.net/v3/lists/#{LIST}@#{DOMAIN_NAME}/members/#{email}\")\n rescue\n puts \"--------\\n#{email} Not found..NEXT\\n\"\n next\n end\n end\n end\nend",
"def delete_by_filename(filename)\n result = find_by_filename(filename)\n \n if result.count > 1\n success = true\n result.each { |r| success = false unless delete(r['_id']) }\n success\n else\n result.blank? ? false : delete(result.first['_id'])\n end\n end",
"def delete(path = '/files/', params = {})\n request :delete, path, params\n end",
"def destroy\n @indexed_file = IndexedFile.find(params[:id])\n @indexed_file.destroy\n\n respond_to do |format|\n format.html { redirect_to indexed_files_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n mytemplate = Mytemplate.get(params[:id])\n close_document(mytemplate)\n \n begin\n if mytemplate != nil\n if File.exist?(mytemplate.path) \n FileUtils.rm_rf mytemplate.path\n end\n \n if File.exist?(mytemplate.file_path+mytemplate.id.to_s) \n FileUtils.rm_rf mytemplate.file_path+mytemplate.id.to_s\n end\n\n end\n rescue\n puts_message \"Error! in progress of mytemplate file deletion.\"\n end\n\n mytemplate.destroy\n \n respond_to do |format|\n format.html { redirect_to(mytemplates_url) }\n format.xml { head :ok }\n end\n end",
"def delete_file\n File.unlink file\n end",
"def delete_file\n File.unlink file\n end",
"def delete_item\n\nend",
"def delete_files(files)\n not_found = []\n files.each do |file|\n file_stored = Files.where({ '_id' => file[:uuid]}).first\n if file_stored.nil?\n logger.error 'File not found ' + file.to_s\n not_found << file\n else\n if file_stored['pkg_ref'] == 1\n # Referenced only once. Delete in this case\n file_stored.destroy\n del_ent_dict(file_stored, :files)\n file_md5 = Files.where('md5' => file_stored['md5'])\n if file_md5.size.to_i.zero?\n # Remove files from grid\n grid_fs = Mongoid::GridFs\n grid_fs.delete(file_stored['grid_fs_id'])\n end\n else\n # Referenced above once. Decrease counter\n file_stored.update_attributes(pkg_ref: file_stored['pkg_ref'] - 1)\n end\n # file_stored.destroy\n # del_ent_dict(file_stored, :files)\n #\n # # Remove files from grid\n # grid_fs = Mongoid::GridFs\n # grid_fs.delete(file_stored['grid_fs_id'])\n end\n end\n not_found\n end",
"def destroy\n sf = @site.site_files.find params[:id]\n sf.destroy\n\n flash[:notice] = \"#{sf.path} has been deleted.\"\n respond_to do |format|\n format.html { redirect_to(site_site_files_path(@site)) }\n format.xml { head :ok }\n end\n end",
"def delete_file(file)\n delete_attachment(file)\n end",
"def remove_item(id)\n return nil if self.class.mode == :sandbox\n\n query = { \"type\" => \"delete\", \"id\" => id.to_s, \"version\" => Time.now.to_i }\n doc_request query\n end",
"def delete\n begin \n # file_assets\n file_assets.each do |file_asset|\n file_asset.delete\n end\n # We now reload the self to update that the child assets have been removed...\n reload()\n # Call ActiveFedora Deleted via super \n super()\n rescue Exception => e\n raise \"There was an error deleting the resource: \" + e.message\n end\n end",
"def destroy\n @content_item = ContentItem.find(params[:id])\n @content_item.destroy\n\n respond_to do |format|\n format.html { redirect_to(content_items_url) }\n format.xml { head :ok }\n end\n end",
"def delete(command)\n pp @client.files.delete(clean_up(command[1]))\n end",
"def delete(item, list)\n\tlist.delete(item)\nend",
"def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to(items_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to(items_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to(items_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to(items_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to(items_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to(items_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @file_upload = FileUpload.find(params[:id])\n @file_upload.destroy\n\n respond_to do |wants|\n wants.html { redirect_to(file_uploads_url) }\n wants.xml { head :ok }\n end\n end",
"def destroy\r\n @item = Item.find(params[:id])\r\n\r\n @item.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_to(items_url) }\r\n format.xml { head :ok }\r\n end\r\n end",
"def delete_item(list,item)\n list.delete(item)\nend",
"def delete_item(list,item)\n list.delete(item)\nend",
"def delete_item(item)\r\n @list.delete(item)\r\n end",
"def destroy\n @list = List.find(params[:list_id])\n @list_item = @list.list_items.find(params[:id])\n @list_item.destroy\n\n if @list_item.destroy\n flash[:success] = \"Item deleted\"\n redirect_to list_path(@list)\n else\n flash[:error] = \"Item not deleted\"\n redirect_to list_path(@list)\n end\n end",
"def clear\n if ::File.exists?(@file) \n @log.info(\"Deleted id list file.\")\n ::File.delete(@file)\n end\n end",
"def delete_file_parts\n #TODO implementation\n end",
"def remove\n rows = self.open_import_file\n field = rows.first\n rows.each do |row|\n item_identifier = row['item_identifier'].to_s.strip\n if item = Item.where(:item_identifier => item_identifier).first\n item.destroy\n end\n end\n end",
"def destroy\n @etx_file = EtxFile.find(params[:id])\n \n arr = @etx_file.ques_no.split(\",\")\n Question.destroy(arr)\n @etx_file.update_attributes(status: true)\n #@etx_file.destroy\n\n respond_to do |format|\n format.html { redirect_to etx_files_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @request = Request.find(params[:id])\n @request_items = @request.request_items\n @request_items.each do |ri|\n ri.destroy\n end\n @request.destroy\n\n respond_to do |format|\n format.html { redirect_to(requests_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n #FIXME: Double check auth is working for deletion. Also, maybe should only delete if not associated with any experiments.\n @data_file.destroy\n \n respond_to do |format|\n format.html { redirect_to(data_files_path) }\n format.xml { head :ok }\n end\n end",
"def google_delete_file(client)\n files = []\n [@fields[:files],@fields[:folders]].each do |array|\n if array.is_a?(Array)\n files += array\n elsif !array.nil?\n files.push(array)\n end\n end\n targets = files.collect {|p| CGI::unescape(p)}\n client.delete_files_by_path(targets)\n end",
"def delete_all(xpath); end",
"def destroy\n @action_item = ActionItem.find(params[:id])\n @action_item.destroy\n\n respond_to do |format|\n format.html { redirect_to(action_items_url) }\n format.xml { head :ok }\n end\n end",
"def delete_data(index_name)\n uri = @client.make_uri(\"/#{index_name}/update/\")\n req = HTTP::Post.new(uri)\n req.content_type = 'text/xml'\n req.body = '<delete><query>*:*</query></delete>'\n response = @client.send_http(req, true, ['200'])\n end",
"def delete_file(basepath = MP3_STORAGE_PATH)\n FileUtils.rm_rf(\"#{basepath}/#{id}\")\n end",
"def destroy\n @action_file = ActionFile.find(params[:id])\n @action_file.destroy\n\n respond_to do |format|\n format.html { redirect_to action_files_url }\n format.json { head :no_content }\n end\n end",
"def delete(*uris); end",
"def delete_file(path)\n \n puts \"Sending path via MCollective Files client\"\n @mc.delete(:path => path)\n printrpcstats\n \n end",
"def destroy\n begin\n File.delete( @doc_file.docOwner)\n rescue\n end\n @doc_file.destroy\n \n respond_to do |format|\n format.html { redirect_to doc_files_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n # @list=List.find(params[:list_id])\n @list_item=@list.list_items.find(params[:id])\n @list_item.destroy\n respond_to do |format|\n format.html { redirect_to @list, notice: 'List item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def test_delete_file()\n\n path = 'folder/FileTest.pdf'\n versionId = nil\n storage = 'First Storage'\n request = DeleteFileRequest.new(path, versionId, storage)\n\n result = @storage_api.delete_file(request)\n assert result.code == 200,'Error while deleting document'\n\n end",
"def netdev_resxml_delete( xml )\n top = netdev_resxml_top( xml )\n par = top.instance_variable_get(:@parent)\n par['delete'] = 'delete'\n end",
"def destroy\n @item = item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to(budget_items_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @related_content = RelatedContent.find(params[:id])\n @related_content.destroy\n dirname = \"#{RelatedContent::UPLOAD_DIR}/#{@related_content.id}\"\n FileUtils.rm_rf dirname\t\n redirect_to @related_content.node\t \n\nend",
"def delete_item(list, item)\n list.delete(item)\nend",
"def delete_item(item)\n @get_items.delete(item)\n end",
"def destroy\n @document.destroy\n save_log({ :action => 'DELETE', :document => { :before => @old_document }})\n #TODO delete the file from disk\n respond_to do |format|\n format.html { redirect_to(documents_url) }\n format.xml { head :ok }\n end\n end",
"def delete_service_files(resource)\n file get_service_script_name(resource) do\n action :delete\n only_if { get_service_script_name != nil }\n end\nend",
"def delete_item(list, item)\n\tlist.delete(item)\n\tlist\nend",
"def delete_item(id)\n record \"/todos/delete_item/#{id}\"\n end",
"def destroy\n @action_list = ActionList.find(params[:id])\n @action_list.destroy\n\n respond_to do |format|\n format.html { redirect_to(action_lists_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @list_item = ListItem.find(params[:id])\n @list_item.destroy\n\n respond_to do |format|\n format.html { render :nothing => true}\n format.json { head :no_content }\n end\n end",
"def unshare_file_in_db(file_id, user_id)\n $db.execute(\"DELETE FROM shared_files WHERE file_id = ? AND user_id = ?\", file_id, user_id)\nend",
"def delete(items)\n item_ids = items.collect { |item| item.id }\n args = {ids: item_ids.to_json}\n return @client.api_helper.command(args, \"item_delete\")\n end",
"def destroy\n @instancia_item = InstanciaItem.find(params[:id])\n @instancia_item.destroy\n\n respond_to do |format|\n format.html { redirect_to(instancia_items_url) }\n format.xml { head :ok }\n end\n end",
"def delete(container_name, file_name)\n validate_path_elements(container_name, file_name)\n\n client.request(\n method: :delete,\n path: \"#{container_name}/#{file_name}\",\n expected: 204\n )\n end",
"def destroy_bulk(list_of_native_records)\n #TODO: Investigate why mutiple ids may be returned for the same record\n #Answer Database Corruption\n list_of_native_records.uniq!\n #puts \"List of all records: #{list_of_native_records.map{|r| r['_id']}.inspect}\"\n list_of_native_records.each do |r|\n begin\n att_doc_id = r['_id'] + CouchrestAttachment::AttachmentID\n #puts \"Node ID: #{r['_id'].inspect}\"\n #puts \"DB: #{@db.all.inspect}\"\n @db.delete_doc(r)\n begin\n att_doc = @db.get(att_doc_id)\n rescue\n att_doc = nil\n end\n @db.delete_doc(att_doc) if att_doc\n rescue RestClient::RequestFailed\n puts \"Warning:: Failed to delete document?\"\n end\n end\n nil #TODO ok to return nil if all docs destroyed? also, not verifying\n end",
"def destroy\n \t@list = current_user.lists.find params[:list_id]\n @item = @list.items.find(params[:id])\n @item.destroy\n respond_to do |format|\n format.html { redirect_to list_items_path(@list), notice: 'Item was successfully removed.' }\n #format.json { head :no_content }\n end\n end",
"def deleteItems\n self.items.each do |item|\n item.delete\n end\n end"
] |
[
"0.66513693",
"0.65932494",
"0.65684396",
"0.6538054",
"0.6481305",
"0.6455834",
"0.645138",
"0.6422646",
"0.6422646",
"0.636243",
"0.6337595",
"0.632153",
"0.63033146",
"0.62866277",
"0.62531215",
"0.62372726",
"0.6229872",
"0.6218049",
"0.6202352",
"0.6199747",
"0.6167164",
"0.61635584",
"0.6162193",
"0.615314",
"0.6147713",
"0.61471766",
"0.6131376",
"0.61296415",
"0.612843",
"0.6125629",
"0.6120229",
"0.6109716",
"0.6107165",
"0.61020833",
"0.6092287",
"0.60887253",
"0.60875493",
"0.6086512",
"0.60856986",
"0.6080204",
"0.60799736",
"0.6079517",
"0.6078808",
"0.6077782",
"0.6077782",
"0.60772",
"0.6077001",
"0.60748565",
"0.60719293",
"0.607037",
"0.6068313",
"0.60682654",
"0.60612077",
"0.6058411",
"0.60575825",
"0.60575825",
"0.60575825",
"0.60575825",
"0.60575825",
"0.60575825",
"0.60562897",
"0.6048458",
"0.60450524",
"0.60450524",
"0.60436255",
"0.6038797",
"0.60349905",
"0.6032536",
"0.60315424",
"0.6030886",
"0.60290915",
"0.6027163",
"0.60268044",
"0.6024343",
"0.60174835",
"0.60136914",
"0.60129964",
"0.60093015",
"0.6002749",
"0.5992443",
"0.5990053",
"0.59808755",
"0.59801257",
"0.59777945",
"0.59756935",
"0.5973213",
"0.5971649",
"0.59714717",
"0.59658045",
"0.596415",
"0.59600616",
"0.59597546",
"0.59579617",
"0.59556484",
"0.59534895",
"0.5950502",
"0.59455466",
"0.593731",
"0.59324723",
"0.5927569",
"0.59260106"
] |
0.0
|
-1
|
start random generator threads and writer thread
|
def start
@running = true
gen_threads = start_generators
writer = start_writer
gen_threads.each(&:join)
kill_proccess
writer.join
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def start_generators\n threads = []\n 5.times do |idx|\n thread = Thread.new { contious_generation }\n thread[:id] = idx\n threads << thread\n end\n threads\n end",
"def run\r\n @cordinators.each do |c|\r\n @threads << Thread.new do\r\n c.run\r\n end\r\n end\r\n end",
"def generate\n generations = 0\n loop do\n print\n sleep(0.5)\n newGeneration\n generations += 1\n p \"Number of generations: #{generations} [Ctrl-C to exit]\"\n end\n end",
"def run\n raise Pants::Error, \"No readers added yet\" if @readers.empty?\n\n starter = proc do\n puts \"Pants v#{Pants::VERSION}\"\n puts \">> Reading from #{@readers.size} readers\"\n\n @readers.each_with_index do |reader, i|\n puts \">> reader#{i}: Starting read on: #{reader.read_object}\"\n puts \">> reader#{i}: Writing to #{reader.writers.size} writers\"\n\n reader.writers.each_with_index do |writer, j|\n puts \">> reader#{i}writer#{j}: #{writer.write_object}\"\n end\n end\n\n EM::Iterator.new(@readers).each do |reader, iter|\n reader.start\n iter.next\n end\n end\n\n if EM.reactor_running?\n log \"Joining reactor...\"\n starter.call\n else\n log \"Starting reactor...\"\n EM.run(&starter)\n end\n end",
"def give_others_threads_a_chance_to_run\n sleep(1/(200*1e3))\n end",
"def starter\n @starter = Thread.new do\n sleep_interval(60)\n yield # starter proc in :start \n end\n end",
"def start\n\n @writer = Writer.new.start\n @worker_pool = WorkerPool.new create_listen_socket\n\n sig_init\n master_loop\n shutdown_writer\n\n end",
"def initialize\r\n @threads = []\r\n @cordinators = []\r\n end",
"def start_next\n\t@last_wave_ended = false\n\t@number += 1\n\t@current_monsters = monsters\n\t\n\tthreads << Thread.new do\n\t loop do\n\t sleep Config.push_monster_every\n\t break unless Game.running?\n\t next if Game.paused?\n\t break if @current_monsters.size == 0\n\t \n\t Game.scene.create_monster @current_monsters.pop\n\t end\n\t @last_wave_ended = true\n\tend\n end",
"def start_writer\n Thread.new {\n done = false\n waiting = false\n while !done do\n next_value = WriteQueue.next\n unless next_value.nil?\n waiting = false\n puts \"\\n\"\n puts \"Writer: writing #{next_value}\"\n # Append value to file\n File.open('out.txt', 'a') { |file| file.write(\"#{next_value[:timestamp]}: #{next_value[:value]}\\n\") }\n else\n unless waiting\n puts \"\\n\"\n print \"Writer: waiting\"\n waiting = true\n else\n print \".\"\n sleep(1)\n end\n end\n end\n }\nend",
"def randomStream\n Stream::ImplicitStream.new { |s|\n\t s.set_to_begin_proc = proc {srand 1234}\n\t s.at_end_proc = proc {false}\n\t s.forward_proc = proc {rand}\n\t}\nend",
"def thread; end",
"def thread; end",
"def thread; end",
"def run\n @threads.each(&:join)\n end",
"def _test_threads\n m = Mutex.new \n threads = []\n @custom_number_of_users.times do\n threads << Thread.new do\n m.synchronize {threaded_mage_checkout}\n threaded_mage_checkout\n end\n end\n threads.each {|x| x.join}\n end",
"def threaded_looped_generate_posts\n return Toolbox::run_in_new_thread \"#{__method__}\" do\n Toolbox::looper do\n log \"----------------------threaded_looped_generate_posts----------------------\"\n generate_photo_post(@keywords.sample, @keyword_suffix)\n random_sleep\n log \"----------------------threaded_looped_generate_posts----------------------\"\n end\n end # run_in_new_thread\n end",
"def start!\n Signal.trap(\"INT\") { printer.done; exit }\n\n queue = Test.all_tests\n threads = (thread_count-1).times.map { |i| Thread.new { worker!(queue, i+1) } }\n\n worker!(queue, 0)\n threads.join\n\n printer.done\n end",
"def initialize\n @to_run = []\n @paused = false\n @alerter, @waker = IO.pipe\n @thread = Thread.new{ run! }\n end",
"def simulate(lines,numTrains,passengers,simMonitor)\r\n p_threads = [] #ok\r\n t_threads = [] #ok\r\n stations = {}\r\n trains = {} \r\n \r\n init_lines = {}\r\n ret_lines = {}\r\n lines.each{|k,v|\r\n init_lines[k] = v[1..v.length-1]\r\n } \r\n lines.each{|k,v|\r\n ret_lines[k] = v[0..v.length-2].reverse\r\n }\r\n \r\n @lines = lines\r\n @passengers = passengers\r\n @numTrains = numTrains\r\n \r\n metro_lines = lines.keys #array of the metrolines. red, blue, yellow etc\r\n people = passengers.keys\r\n \r\n metro_lines.each{|i| #access the stations in each metroline\r\n station_names = lines[i]\r\n station_names.each{|j|\r\n if stations[j] == nil\r\n stations[j] = {} #hash for metroline\r\n end\r\n \r\n if stations[j][i] == nil\r\n stations[j][i] = {} #hash for trains at station (for line) CHECK IF POPULATED\r\n end\r\n stations[j][\"passenger\"] = {} #hash for passengers at station \r\n }\r\n }\r\n \r\n @stations = stations\r\n for i in 0...people.length\r\n itin = passengers[people[i]] \r\n first_stop = itin[0]\r\n stations[first_stop][\"passenger\"][people[i]] = true\r\n end \r\n \r\n @passengers.each{|p,val|\r\n @check[p] = false\r\n }\r\n \r\n @simMonitor = simMonitor\r\n @simMonitor.each{|a,b |\r\n @t_cond[a] = b.new_cond\r\n @p_cond[a] = b.new_cond\r\n }\r\n \r\n numTrains.each{|key,val|\r\n index = val\r\n begin\r\n @trains[key + \" \" + index.to_s] = {}\r\n index -= 1\r\n end until(index == 0)\r\n }\r\n\r\nindex = 0\r\n@trains.each{|key,val|\r\n index = index + 1\r\n t_threads.push(\r\n Thread.new do\r\n train_work(@lines, index , numTrains, @passengers, @stations, trains, key, @t_cond, @p_cond)\r\n \r\n if(passengers.empty?)\r\n train_work(ret_lines, index , numTrains, passengers, stations, trains, key, @t_cond, @p_cond)\r\n train_work(init_lines, index , numTrains, passengers, stations, trains, key, @t_cond, @p_cond) \r\n else \r\n until(!@check.values.include?(false))\r\n train_work(ret_lines, index , numTrains, passengers, stations, trains, key, @t_cond, @p_cond)\r\n train_work(init_lines, index , numTrains, passengers, stations, trains, key, @t_cond, @p_cond)\r\n end\r\n end\r\n end\r\n )\r\n }\r\n \r\n @check.each{|p, val|\r\n itinerary = @passengers[p]\r\n p_threads.push(\r\n Thread.new do\r\n passenger_work(itinerary, lines, p)\r\n @check[p] = true\r\n end\r\n \r\n )\r\n }\r\n \r\n \r\n p_threads.each{|x|\r\n x.join\r\n }\r\n t_threads.each{|x|\r\n x.join \r\n }\r\n \r\n end",
"def rand\n Kernel.rand(self)\n end",
"def start(callback)\n start_loop = EM.tick_loop do\n if @writers.empty? || @writers.all?(&:running?)\n :stop\n end\n end\n start_loop.on_stop { callback.call }\n\n log \"Starting writers for reader #{self.__id__}...\"\n EM::Iterator.new(@writers).each do |writer, iter|\n writer.start\n iter.next\n end\n end",
"def santa_generator(num)\n\t@santas = []\n\texample_names = [\"Sarah\", \"Sting\", \"Sigmond\", \"Stella\", \"Stephen\", \"Sidney\", \"Singin\"]\n\texample_genders = [\"agender\", \"female\", \"bigender\", \"male\", \"female\", \"gender fluid\", \"N/A\"]\n\texample_ethnicities = [\"black\", \"Latino\", \"white\", \"Japanese-African\", \"prefer not to say\", \"Mystical Creature (unicorn)\", \"N/A\"]\n\t\n\tnum.times do |num|\n\n\tnew_santa = Santa.new(example_names.sample(example_names.length), example_genders.sample(example_genders.length), example_ethnicities.sample(example_ethnicities.length)) \n\t\t\t\t# name = example_names.rand(example_name.length)\n\t\t\t\t# gender = example_genders.rand(example_genders.length)\n\t\t\t\t# ethnicity = example_ethnicities.rand(example_ethnicities.length)\n\t\t\t\t\n\t\t\t\t\t new_santa.age = (1..140).to_a.sample\n\n\n# Emmanual said these sage words otherwise there is no variable to accept the random number\n\n# [11:21] \n# if you had another method that created age and called it before this that would work too\n\n# [11:21] \n# basically, initialize sets all of the basic information for the class. What needs to exist for this class to exist\n\t@santas << new_santa\n\t\t# index = 0 do |num|\n\t\t# \tuntil num == index \n\t\t# \t\tname = example_names.rand(example_name.length)\n\t\t# \t\tgender = example_genders.rand(example_genders.length)\n\t\t# \t\tethnicity = example_ethnicities.rand(example_ethnicities.length)\n\t\t# \t\tage = Random.rand(141)\n\t\t# \tsantas << Santa.new (name, gender,ethnicity)\n\t\t# \t# name = example_names(rand(example_name.length)\n\t\t# \t# gender = example_genders(rand(example_genders.length)\n\t\t# \t# ethnicity = example_ethnicities(rand(example_ethnicities.length)\n\t\t# \t# age = Random.rand(141)\n\n\t\t# index += 1\n\t\n\tend\nend",
"def start_threads\n \n # generate computers cache model shortcuts\n Main.active.clusters.each do |computers|\n computers.each { |c| Main.active.computers_cache[c.id]=c }\n end\n\n # load user names from yppassed\n # TODO: move to user model class?\n #IO.popen(\"ypcat passwd\").each { |line|\n # Main.active.user_list.add(line.split(\":\").values_at(0, 4)) \n #}\n\n refresh = Thread.new {\n session[:old_timestamp] = 0\n\n while true\n puts \"refresh start\"\n # update prectab data\n if Prectab.changed?\n Main.active.computers_cache.each_value {|computer| computer.prectab = [nil,nil]; computer.color_changed; computer.user_changed }\n Debug.log.debug \"working prectab\"\n scatter_prectab(Prectab.now,0)\n scatter_prectab(Prectab.soon,1)\n end\n\n # update computers_cache\n comps = Computer.updated_after session[:old_timestamp]\n comps.each do |computer| \n cache_computer = Main.active.computers_cache[computer.id]\n if cache_computer\n cache_computer.User = computer.user \n cache_computer.Color = computer.color\n end\n end\n session[:old_timestamp] = Time.now.strftime(\"%j%H%M%S\")\n\n # update printers\n @printers.each { |p| p.update_job_count; p.update_accepts; p.update_snmp }\n puts \"refresh end\"\n sleep 20\n end \n }\n \n # read data from scanner and dispatch\n require 'socket'\n begin\n socket = TCPSocket.new('localhost', 7887)\n rescue Errno::ECONNREFUSED\n Main.active.status = [\"Scanner\", t('scanner.no_connection'), \"important\",-1]\n else\n scanner = Thread.new {\n Debug.log.debug \"starting scanner thread ...\"\n while true\n scan = socket.recvfrom(25)\n type, Main.active.scan_string = check_scanner_string(scan[0])\n Debug.log.debug \"Scanner says #{scan} #{type}, #{Main.active.scan_string}\"\n \n case type\n when :card\n accounts = User.find_accounts_by_barcode(Main.active.scan_string)\n fill_accounts(accounts)\n when :matrikel\n accounts = Account.find_accounts_by_barcode(Main.active.scan_string)\n fill_accounts(accounts)\n when :key\n pc = Main.active.computers_cache[Main.active.scan_string]\n puts pc\n unless Main.active.account_list.empty?\n table_register(pc)\n else\n case pc.user\n when \"\"\n Main.active.status = [\"#{pc.id}\", \"ist schon frei\", \"key\",0] \n else\n Main.active.status = [\"#{pc.user}\", \"von <b>#{pc.id}</b> abgemeldet\", \"trashcan_full\",1]\n end\n key_clear(pc)\n end\n else\n Debug.log.debug \"#{type}, #{Main.active.scan_string}\"\n end\n \n sleep 1 # wait some time for next scan atempt\n end\n }\n end\n end",
"def worker\n # Wait until we have space for you\n sleep(0.1) until (Thread.list.size < @numthreads)\n\n Thread.new do\n yield\n end\n end",
"def thread()\n #This is a stub, used for indexing\n end",
"def run\n return if @files.empty?\n $stderr.write @files.inspect+\"\\n\"; $stderr.flush\n @cores.times do |c|\n @pipes << PipeDream.new\n @children << SafeFork.fork do\n Signal.trap(\"TERM\") { exit }\n Signal.trap(\"HUP\") { exit }\n pipe = @pipes.last\n pipe.identify_as_child\n pipe.write(\"[Worker #{c}] Booted\\n\")\n @result = Test::Unit::TestResult.new\n @result.add_listener(Test::Unit::TestResult::FAULT) do |value|\n $stderr.write value\n $stderr.write \"\\n\\n\"\n $stderr.flush\n end\n while !pipe.eof?\n file = pipe.gets.chomp\n begin\n pipe.write \"[Worker #{c} Starting: #{file}\\n\"\n start = Time.now\n\n klasses = Multitest.find_classes_in_file(file)\n klasses.each{|k| k.suite.run(@result){|status, name| ;}}\n \n finish = Time.now\n pipe.write \"[Worker #{c}] Completed: #{file} (#{finish-start})\\n\"\n rescue => ex\n pipe.write \"[Worker #{c}] Failed: #{file} - #{ex.to_s}\\n\"\n end\n end\n $stderr.write @result.to_s\n $stderr.write \"\\n\"\n $stderr.flush\n pipe.close\n end\n end\n\n total_files = @files.size\n @threads = []\n @pipes.each do |_p|\n @threads << Thread.new(_p) do |p|\n Signal.trap(\"TERM\") { exit }\n p.identify_as_parent\n # boot message\n p.gets\n while !@files.empty? \n # puts \"#{total_files - @files.size}/#{total_files}\"\n # send a file\n p.write(\"#{@files.pop}\\n\")\n # print the start message\n msg = p.gets\n # $stdout.write msg; $stdout.flush\n # wait for the complete message\n msg = p.gets\n # print complete message\n if msg =~ /Completed/\n # $stdout.write msg; $stdout.flush\n else\n $stderr.write msg; $stderr.flush\n end\n end\n p.close\n end\n end\n\n Signal.trap(\"TERM\") do\n puts \"Exiting\"\n @children.each{|c| Process.kill(\"TERM\",c)}\n @threads.each{|t| Thread.kill(t)}\n end\n\n @threads.each{|t| t.join}\n @children.each{|c| Process.wait(c)}\n end",
"def reset\n\t\tself.gen = Random.new(SEED)\n\tend",
"def reset\n\t\tself.gen = Random.new(SEED)\n\tend",
"def random_num_gen()\n #puts 'This is a random number generator. The user will input the minimum \n #and maximum integers to declare the range the generator can output. The user \n #will also input the amount of times the generator will be called. The final\n #results will be stored in a table, which will be displayed after last call \n #to the generator is given.'\n entry = current_entry #set the entry number using \n puts 'Enter minimum value for range:'\n min_int = gets.chomp\n min_num = min_int.to_i\n puts 'Enter maximum value for range:'\n max_int = gets.chomp\n max_num = max_int.to_i\n #ensure that the minimum number is less than the maximum number\n while max_num <= min_num\n puts 'Max number is smaller than minimum number. Enter maximum value for range:'\n max_int = gets.chomp\n max_num = max_int.to_i\n end\n puts 'Enter the number of random numbers you would like to be output:'\n count = gets.chomp\n count = count.to_i\n puts \"\"\n t1 = Time.now\n call_random_server(min_int, max_int, count, entry)\n t2 = Time.now\n puts t2-t1\n return\nend",
"def run_once(timeout = nil)\n readers, writers = select(@readers.keys << @waker.io, @writers.keys, [], timeout)\n return unless readers\n\n yield if readers.include? @waker.io\n\n [[readers, @readers], [writers, @writers]].each do |ios, registered|\n ios.each do |io|\n task = registered.delete io\n task.resume if task\n end\n end\n end",
"def start_thread #does this need to be its own thread?\n @@thread = Thread.new do\n self.run\n end\n end",
"def seed_rng!\n @seed = (ENV['SEED'] || Random.new_seed).to_i\n $stdout.puts \"SEED=#{@seed}\"\n $stdout.flush\n srand(@seed)\n end",
"def seed_rng!\n @seed = (ENV['SEED'] || Random.new_seed).to_i\n $stdout.puts \"SEED=#{@seed}\"\n $stdout.flush\n srand(@seed)\n end",
"def initialize\n srand\n end",
"def run\n test_using_random_sample\n test_using_first_of\n end",
"def start\r\n @log = {}\r\n @population = @size.times.map do\r\n bear(rand(1<<@length))\r\n end\r\n end",
"def call\n FileUtils.mkdir_p(dir)\n CSV.open(file_name, 'wb') do |csv|\n lines.times do\n csv << [random_vrn, *random_time_range, type, la, random_plate, wheelchair?]\n end\n end\n end",
"def four_four\n sample :drum_heavy_kick\n sleep 1\n sample :drum_snare_hard\n sleep 1\nend",
"def four_four\n sample :drum_heavy_kick\n sleep 1\n sample :drum_snare_hard\n sleep 1\nend",
"def seed; end",
"def gen_speed\n rand + 15.0\n end",
"def connect_stream (stream=1)\n\n\t\tlogger.info('Starting Random adapter')\n\t\trandom = RandomPhraseGenerator.new\n\t\ti=0\n\t\twhile true\n\t\t\t\n\t\t\tpersist random.generate\n\n\t\t\ti = i+1\n\t\t\tif i%10 == 0\n\t\t\t\tsleep 10\n\t\t\tend\n\t\t\t\n\t\tend\n\n\tend",
"def start\n return if @thread\n @thread = Thread.new do\n loop do\n sleep\n load_files\n end\n end\n end",
"def start\n @log.info \"starting trader\"\n @should_terminate = false\n iterate()\n end",
"def run_getter_thread\n @thr_getter = Thread.new do\n loop do\n # Get req\n req_min = 0\n req_max = 0\n @getter_lock.synchronize do\n loop do\n if @min > 0 && @max > 0\n req_min = @min\n req_max = @max\n @min = 0\n @max = 0\n break\n else\n @req_ready.wait(@getter_lock)\n end\n end\n end\n # use req_min&req_max to require from master\n get_value = 0\n loop do\n get_value = @mgmt.require_token(@id,req_min,req_max)\n if get_value <= 0\n sleep 0.001\n else\n break\n end\n end\n # got token\n @master.give_token(@id,get_value)\n\n end\n end\n end",
"def generate\n Thread.new do\n process_repo\n end\n msg = { :success => true, :message => \"Please wait while we generate activity for the repository!\" }\n end",
"def rotateWorker()\n\t\t# Pick a worker at random and remove them\n\t\tremoveIdx = (rand() * @workers.length).to_i\n\t\t@workers.delete_at(removeIdx)\n\t\t@weights.delete_at(removeIdx)\n\t\t#puts(\"Removing #{removeIdx}\")\n\n\t\t# Create a new random worker with the given prob of being noise\n\t\tr = rand()\n\t\tif( r < @@Alpha )\n\t\t\t#puts(\"Adding OPTIMAL.\")\n\t\t\t@workers << OptimalWorker.new(@actions)\n\t\telse\n\t\t\t#puts(\"Adding RANDOM.\")\n\t\t\t@workers << RandomWorker.new(@actions)\n\t\tend\n\n\t\t@weights << 1.0\n\tend",
"def cosine_parallel\n @time1 = Time.now\n documents = []\n read_threads = []\n #file1\n thread1 = Thread.new{\n file1 = File.read(Rails.root.join('public/files/d1a7.allKeys')).split(\"\\n\")\n @doc1 = {}\n file1.each_with_index do |line,index| \n data = line.split(\" \")\n @doc1[data[0]] = data[1]\n end\n }\n #file2\n thread2 = Thread.new{\n file2 = File.read(Rails.root.join('public/files/d1au.allKeys')).split(\"\\n\")\n @doc2 = {}\n file2.each_with_index do |line,index| \n data = line.split(\" \")\n @doc2[data[0]] = data[1] \n end\n }\n #file3\n thread3 = Thread.new{\n file3 = File.read(Rails.root.join('public/files/d1dl.allKeys')).split(\"\\n\")\n @doc3 = {}\n file3.each_with_index do |line,index| \n data = line.split(\" \")\n @doc3[data[0]] = data[1]\n end\n }\n #file4\n thread4 = Thread.new{\n file4 = File.read(Rails.root.join('public/files/d1h8.allKeys')).split(\"\\n\")\n @doc4 = {}\n file4.each_with_index do |line,index| \n data = line.split(\" \")\n @doc4[data[0]] = data[1]\n end\n }\n #file5\n thread5 = Thread.new{\n file5 = File.read(Rails.root.join('public/files/d1lt.allKeys')).split(\"\\n\")\n @doc5 = {}\n file5.each_with_index do |line,index| \n data = line.split(\" \")\n @doc5[data[0]] = data[1]\n end\n }\n #file6\n thread6 = Thread.new{\n file6 = File.read(Rails.root.join('public/files/d1q3.allKeys')).split(\"\\n\")\n @doc6 = {}\n file6.each_with_index do |line,index| \n data = line.split(\" \")\n @doc6[data[0]] = data[1]\n end \n }\n thread1.join\n thread2.join\n thread3.join\n thread4.join\n thread5.join\n thread6.join\n @documents = [@doc1,@doc2,@doc3,@doc4,@doc5,@doc6] \n #cosine Similarity\n @similarities = []\n arr = [] \n (0..5).each do |ind|\n data_array = []\n arr[ind] = Thread.new{\n (0..ind).each do |indj|\n num = 0\n denom1 = 0\n denom2 = 0\n @documents[ind].each do |k,v|\n if (!@documents[indj][k].nil?) && (@documents[indj][k].to_i > 0) && (@documents[ind][k].to_i > 0)\n num += @documents[ind][k].to_i*@documents[indj][k].to_i\n denom1 += @documents[ind][k].to_i*@documents[ind][k].to_i\n denom2 += @documents[indj][k].to_i*@documents[indj][k].to_i\n end \n end\n sq_rt_denom1 = Math.sqrt(denom1)\n sq_rt_denom2 = Math.sqrt(denom2)\n @similarity = (num.to_f)/(sq_rt_denom1.to_f * sq_rt_denom2.to_f) #/\n data_array << @similarity\n end\n }\n @similarities << data_array\n end\n arr.each {|t| t.join; }\n @time2 = Time.now\n end",
"def next\n @mutex.lock\n begin\n counter = @counter = (@counter + 1) % 0xFFFFFF\n ensure\n @mutex.unlock rescue nil\n end\n\n generate(Time.new.to_i, counter)\n end",
"def start_game_creator!\n\t\t$threads << @creator = Thread.new() do\n\t\t\tready_players = []\n\t\t\tspectators = []\n\t\t\twhile true\n\t\t\t\t# Check every connection in the waiting queue for a JOIN or SPECTATE\n\t\t\t\t@connections.each do |c|\n\t\t\t\t\tline = c.readline\n\t\t\t\t\tif line =~ /JOIN\\W+(\\w+)/i\t# A player is attempting to join the game, move them from waiting to READY\n\t\t\t\t\t\tputs \"JOIN: #{$1} joined a game\"\n\t\t\t\t\t\tready_players << {:connection => c, :user => $1.strip}\n\t\t\t\t\t\t@connections.delete c\n\t\t\t\t\telsif line =~ /SPECTATE/i\n\t\t\t\t\t\tputs \"Spectator joined\"\n\t\t\t\t\t\tspectators << c\t\t\t# A spectator is ready to watch the next game, move the, to SPECTATORS\n\t\t\t\t\t\t@connections.delete c\n\t\t\t\t\tend\n\t\t\t\t\tif ready_players.size > 1\t# If you have enough players to play\n\t\t\t\t\t\tputs \"Two players have requested a game, spawning new game for:\"\n\t\t\t\t\t\tp1 = ready_players.pop\t# Get the first two ready players\n\t\t\t\t\t\tp2 = ready_players.pop\n\t\t\t\t\t\tspecs = spectators.clone\n\t\t\t\t\t\tspectators = []\t\t\t# Assign all specs to the new game and clear the spec list out\n\t\t\t\t\t\tputs \"\\tHunter: #{p1[:user]}\\n\\tPrey: #{p2[:user]}\"\n\t\t\t\t\t\tnew_game = Evasion.new(p1[:connection], p1[:user], p2[:connection], p2[:user], specs)\n\t\t\t\t\t\t# @games << new_game\t# Leftover comments from multithreading with simultaneous games approach. Does not work well on energon.\n\t\t\t\t\t\t# $threads << Thread.new(new_game) do |game|\n\t\t\t\t\t\t# \tThread.current.priority = 10\t# Escalate the game's thread to always beat ACCEPTOR and CREATOR threads\n\t\t\t\t\t\t\t@results << new_game.play # @results << game.play\n\t\t\t\t\t\t# end\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend",
"def set_rand()\n rdm = Random.new()\n @step = rdm.rand(1..10) * 100\n @rate = rdm.rand(1.2..3.0) \n end",
"def do_sendtrain(train)\n # send the train\n $threadLock.synchronize {\n\twhile $activeThreads >= $maxThreads\n\t\t$threadCond.wait($threadLock)\t# wait until there is one less thread\n\tend\n\t$activeThreads+=1\n\t$stderr.puts \"activeThreads=#{$activeThreads} GRAB\" if ThreadDebug\n }\n Thread.new {\n\t outputbuffer=[]\n \tbegin\n \t sleepTime=rand(0)*$timeoutTime\n\t $stderr.puts \"Sleeping #{sleepTime} s\" if ThreadDebug\n\t sleep(sleepTime)\t# sleep some random interval amount of time to not run over other threads\n\t responses = Scriptroute::send_train( train )\n\t responses.each { |response|\n\t next unless response.probe\t# this won't be set if the pcap buf overflowed\n\t dst = response.probe.packet.ip_dst\n\t if response.response\n\t r = response.response.packet\n\t icmp_src = r.ip_src\n\t icmp_id = r.ip_id.to_s\n\n\t high = (r.ip_id >> 8 ) & 0xFF\n\t low = r.ip_id & 0xFF\n\t swapped_id = (low << 8) + high\n\n\t resp_type = r.class.to_s.sub(/^Scriptroute::/,'')\n\t resp_type += \"_t=#{r.icmp_type}_c=#{r.icmp_code}\" if resp_type == \"Icmp\"\n\t arrive = response.response.time.to_f.to_s\n\t else\n\t icmp_src = '-'\n\t icmp_id = '-'\n\t resp_type= '-'\n\t arrive = '-'\n\t end\n\t # dst icmpsrc arrive id id(hostorder) type\n\t outputbuffer << sprintf(\"%16s %16s %20s %7s %7s %12s\\n\" % [\n\t\t dst,\n\t\t icmp_src,\n\t\t arrive,\n\t\t icmp_id,\n\t\t swapped_id,\n\t\t resp_type])\n\t }\n\t ensure\n\t $threadLock.synchronize {\n\t\toutputbuffer.each { |l|\t\t# flush output while we have the lock\n\t\t\tputs l\t\t\t# actually print the data\n\t\t}\n\t\t$activeThreads-=1\n\t\t$stderr.puts \"activeThreads=#{$activeThreads} RELEASE\" if ThreadDebug\n\t\traise \"Too many Thread deactivates\" unless $activeThreads>=0\n\t\t$threadCond.signal \t# tell another thread it's their turn to go\n\t }\n\t end\n }\n\nend",
"def run\n threads = []\n test_start = Time.now\n puts \"Starting #{options.threads} worker threads at #{test_start}\"\n @options.threads.times do |thread_id|\n threads << Thread.new do\n worker_thread(thread_id)\n end\n end\n threads.each { |t| t.join }\n test_end = Time.now\n puts \"Total test time: #{test_end.to_f - test_start.to_f}\"\n end",
"def producer; end",
"def shufflers()\n a = shufflers1()\n a2 = shufflers2(a)\n l = shufflers3(a,a2[1])\n l2 = shufflers4(l)\n t = shufflers5(l2)\n t2 = shufflers6(t)\n write(t2) \nend",
"def run\n generate_initial_population #Generate initial population\n\n @max_generation.times do |i|\n\n message = \"Generation: #{i}, best fitness: #{@population[0].fitness}\"\n @options[:stats][:gen] ||= []\n @options[:stats][:gen][i] = {\n fitness: @population[0].fitness,\n time: Time.now - @options[:stats][:start_run]\n }\n puts message\n unless @options[:rb_channel].nil?\n @options[:rb_channel].publish({data: message, event: 'output'}.to_json)\n end\n\n selected_to_breed = selection #Evaluates current population\n offsprings = reproduction selected_to_breed #Generate the population for this new generation\n replace_worst_ranked offsprings\n end\n return best_chromosome\n end",
"def index\n t1 = Process.clock_gettime(Process::CLOCK_MONOTONIC)\n limit = rand(20..35)\n randoms = RandomPerson.all(limit: limit)\n t2 = Process.clock_gettime(Process::CLOCK_MONOTONIC)\n render locals: {\n randoms: randoms,\n winner_id: randoms[rand(0...limit)].id,\n elapsed_millis: (t2 - t1) * 1000\n }\n end",
"def start_game\n\t\ti = 0\n\t\tsrand seed.to_i\n\t\t#This is the loop that runs the simulation 5 times.\n\t\tloop do\n\t\t\ti += 1\n\t\t\tnew_run(i)\n\t\t\tif i == 5\n\t\t\t\tbreak\n\t\t\tend\n\t\tend\n\t\ti\n\tend",
"def generator\n printf(\"%-10s %s\\n\",\"generator:\", \"generating.. (*hdls, *bmm, *scr, *prj)\")\n exitcode = 1\n FileUtils.rm_r Dir.glob(\"#{TMPDIR}/hdl/*.vhd\")\n FileUtils.rm_r Dir.glob(\"#{TMPDIR}/synthesis/*.vhd\")\n File.symlink(\"../pcores\", \"#{TMPDIR}/pcores\") unless File.symlink?(\"#{TMPDIR}/pcores\")\n pipe = IO.popen(\"platgen -od #{TMPDIR}/ -p xc4vfx100ff1152-10 -lang vhdl ../system.mhs\", \"r+\")\n # pipe = IO.popen(\"platgen -p xc4vfx12ff668-10 system.mhs\", \"r+\")\n pipe.each do |line|\n # puts line\n # do not synthesize\n if line =~ /Running XST synthesis/\n exitcode = 0\n Process.kill 'TERM', pipe.pid\n break\n end\n end\n unless exitcode == 0\n p \"# Error with platgen - check platgen.log\"\n exit\n end\n\n # he generated files under $PROJECT/TMPDIR/{hdl,synthesis}\n # copy them to $PROJECT/hdl/ under certain conditions (size differs & or abstence)\n FileUtils.mkdir('hdl') unless File.directory? 'hdl'\n FileUtils.mkdir('synthesis') unless File.directory? 'synthesis'\n FileUtils.mkdir_p(BMM_RESULTSDIR) unless File.directory? BMM_RESULTSDIR # output directory\n\n # move_files_if(\"#{TMPDIR}/hdl/*.vhd\")\n move_files_if(\"#{TMPDIR}/implementation/#{TOPLEVEL}.bmm\", BMM_RESULTSDIR)\n move_files_if(\"#{TMPDIR}/synthesis/*.scr\" )\n move_files_if(\"#{TMPDIR}/synthesis/*.prj\")\n Find.find(\"#{TMPDIR}/hdl\") do |path|\n move_files_if(path) if File.file? path\n end\n\n # move logfiles to scratch\n FileUtils.mkdir_p(GEN_SCRATCHDIR) unless File.directory? GEN_SCRATCHDIR\n [\"platgen.log\", \"platgen.opt\", \"#{TMPDIR}/clock_generator*.log\"].each { |t|\n FileUtils.mv(t, \"#{GEN_SCRATCHDIR}/\") if File.file? t\n }\n\n # change timestamps\n\nend",
"def generate\n # Refill the population with children from the mating pool\n @population.each_index do |i|\n partner_a = @mating_pool[rand(0...@mating_pool.size)]\n partner_b = @mating_pool[rand(0...@mating_pool.size)]\n child = partner_a.crossover(partner_b)\n child.mutate(@mutation_rate)\n @population[i] = child\n end\n @generations += 1\n end",
"def generate\n # Refill the population with children from the mating pool\n @population.each_index do |i|\n partner_a = @mating_pool[rand(0...@mating_pool.size)]\n partner_b = @mating_pool[rand(0...@mating_pool.size)]\n child = partner_a.crossover(partner_b)\n child.mutate(@mutation_rate)\n @population[i] = child\n end\n @generations += 1\n end",
"def write_incoming_messages_to_child_processes(master_reader, client_writers)\n Thread.new do\n while incoming = master_reader.gets\n client_writers.each do |writer|\n writer.puts incoming\n end\n end\n end\nend",
"def work\n @w.each{|w|\n @t << Thread.new(w, self){|w, d|\n w.work(d)\n }\n }\n end",
"def spawn_threads!\n @threads = []\n num_worker_threads.times do |thread_num|\n log(:debug) { \"Spawning background worker thread #{thread_num}.\" }\n\n @threads << Thread.new do\n Thread.current[:influxdb] = object_id\n\n until @should_stop\n check_background_queue(thread_num)\n sleep rand(sleep_interval)\n end\n\n log(:debug) { \"Exit background worker thread #{thread_num}.\" }\n end\n end\n end",
"def kick\n rng.rand(value_range)\n end",
"def greet\n ran_nr = rand(100)\n yield ran_nr\nend",
"def run\n super\n\n # TODO - this shouldn't be static\n f = download_and_store \"https://s3.amazonaws.com/public.intrigue.io/top-1m-2018-04-20.csv\"\n\n # Read and split the file up into a list of domains\n lines = File.open(f,\"r\").read.split(\"\\n\")\n domains = lines.map{|l| l.split(\",\").last.chomp }\n\n lammylam = lambda { |d|\n sleep(rand(_get_option(\"max_sleep\")))\n #_log \"Creating sites for domain: #{d}\"\n #_create_entity \"Uri\", { \"name\" => \"http://#{d}\", \"uri\"=>\"https://#{d}\" }\n _create_entity \"Uri\", { \"name\" => \"https://#{d}\", \"uri\"=>\"https://#{d}\" }\n true\n }\n\n # use a generic threaded iteration method to create them,\n # with the desired number of threads\n thread_count = _get_option \"threads\"\n _threaded_iteration(thread_count, domains, lammylam)\n\n end",
"def start\n @publisher = Thread.new do\n while true\n puts \"Command? \"; #thread publishing commands\n publish $stdin.gets\n end\n end\n @reader = Thread.new { subscribe &Proc.new { |message| callback message } } #thread waiting for messages\n\n @publisher.join\n end",
"def random= rnd\n @sampling.random = rnd\n end",
"def next\n Time.now + @min + Random.rand(@max - @min)\n end",
"def run\n @ran = true\n end",
"def generate\n game = fetch_game(options[:game])\n game_data = game.get\n\n if game_data[:current_stage] != GameState::QUESTION_OPEN\n log.error \"question is not open.\"\n exit 0\n end\n question_count = game_data[:active_question_max_answer_id] + 1\n\n player_ids = []\n game.collection('players').where('is_active', '==', true).get.each do |player_snapshot|\n player_ids << player_snapshot.document_id\n end\n player_count = player_ids.size\n\n log.info \"#{player_count} active players.\"\n\n previous_second = nil\n sent_this_second = 0\n loop do\n db.transaction do |tx|\n 5.times do\n player_id = player_ids[rand(player_count)]\n game.collection('player_answers').doc(player_id).set({answer_id: rand(question_count)})\n sent_this_second += 1\n end\n end\n\n this_second = Process.clock_gettime(Process::CLOCK_MONOTONIC).to_i\n if this_second != previous_second\n log.info \"sent #{sent_this_second} this second.\"\n sent_this_second = 0\n previous_second = this_second\n end\n end\n end",
"def start\n stop\n @running = true\n @threads << broadcast_worker_loop\n @threads << read_worker_loop\n end",
"def each_to_thread\n Threaded.new map { |x| Thread.new { yield(x) } }\n end",
"def rand\n warn \"STUB: rand in distribution.rb\"\n end",
"def run\n puts \"Starting run with #{@num_threads} threads looping #{@num_loops} times\" if @print_results \n @num_threads.times do \n @threads << Thread.new do |th|\n @num_loops.times do\n @results << time_operation do \n @work_warmup_proc.call if @work_warmup_proc\n result = @work_block.call \n sleep @loop_delay\n result\n end\n end\n end\n end\n GC.disable unless @garbage_collection\n @threads.each {|th| th.join }\n GC.enable\n display_results(@results) if @print_results \n @results\n end",
"def spawn(random, length, values)\n Individual.new(Array.new(length) { random.rand(values) })\nend",
"def number_generator\n rand(1..20)\n end",
"def addrandomcars(lat0,lon0,lat1,lon1, count )\n Fiber.new do\n count.times do\n lat = (lat1-lat0) * rand() + lat0\n lon = (lon1-lon0) * rand() + lon0\n @pgconn.query(\"insert into cars(lat,lon,avail) values(#{lat},#{lon}, true)\")\n end\n end.resume\n end",
"def santa_generator\r\n# Santa arrays\r\nsantas = []\r\nsanta_genders = [\"male\", \"female\", \"agender\", \"intersex\", \"N/A\", \"gender fluid\", \"bigender\", \"XXY\", \"XXX\", \"neuter\"]\r\nsanta_ethnicities = [\"Caucasian\", \"Latina\", \"Asian\", \"Unicorn\", \"N/A\", \"Black\", \"Middle-Eastern\", \"Native American\", \"Aboriginal\", \"Alien\"]\r\n\r\n#santa_genders.length.times do |i|\r\n#\tsantas << Santa.new(santa_genders[i], santa_genders[i])\r\n#end\r\n\r\ncount = 0\r\nwhile count < 100\r\n\tsantas << Santa.new(santa_genders[rand(10)], santa_ethnicities[rand(10)])\r\n\tcount += 1\r\nend\r\n\r\nsantas.each {|i|\r\n\ti.age = rand(141)\r\n\tputs \"Santa #{count} is #{i.gender}, #{i.ethnicity}, and #{i.age} years old.\"\r\n}\r\n\r\nend",
"def set_rand()\n rdm = Random.new()\n push_hp(rdm.rand(0.2..10.0))\n push_mp(rdm.rand(0.2..10.0))\n push_sp(rdm.rand(0.2..10.0))\n push_str(rdm.rand(0.2..5.0))\n push_vit(rdm.rand(0.2..5.0))\n push_int(rdm.rand(0.2..5.0))\n push_mnd(rdm.rand(0.2..5.0))\n push_dex(rdm.rand(0.2..5.0))\n push_agi(rdm.rand(0.2..5.0))\n push_luk(rdm.rand(0.2..5.0))\n end",
"def srand(seed)\n @prng = Mtwist.new(seed)\n end",
"def run\n calculate_ideal_subject_distribution\n\n #p \"population size >>>>>> \" + @population_size.to_s\n #p \"max generations >>>>>> \" + @max_generation.to_s\n\n result = {}\n best_chromosomes = []\n generate_initial_population #Generate initial population \n @max_generation.times do |g|\n\n selected_to_breed = selection #Evaluates current population \n\n offsprings = reproduction selected_to_breed #Generate the population for this new generation\n\n replace_worst_ranked offsprings\n\n #Sort the chromosomes again by fitness after offsprings\n #being merged\n @population.sort! { |a, b| b.fitness <=> a.fitness}\n\n # fs = @population.collect {|x| x.fitness }\n # File.open(\"fitnesses.txt\", \"a\") do |f|\n # f.puts \"generation (#{fs.size}) #{g.to_s} = \" + fs.join(\", \")\n # end\n\n best_chromosomes << @population[0]\n end\n result[:chromosomes] = best_chromosomes\n result[:population_size] = @population_size\n result[:generations] = @max_generation\n return result\n end",
"def cycle\n @roll = rand(1..@jobs_available)\n i = 0\n until i == @roll\n a = @workers.pop\n @waiting.enqueue(a)\n i += 1\n end\n\n i = 0\n until i == @roll\n b = @waiting.dequeue\n @workers.push(b)\n i += 1\n end\n end",
"def run!\n @size.times do\n schedule { throw :exit }\n end\n @pool.map(&:join)\n end",
"def run\n run_one_instruction while threads.length > 0\n end",
"def test2(iterator, synchronize, sleeper, counter, redis)\n finish_at = Time.now + 5.0\n iterator.call((1..100).map {|i| i/100000.0+0.001}.shuffle, 100) do |i|\n while Time.now - finish_at < 0\n sleeper.call(i)\n synchronize.call do\n # print \".\"\n value = rand(1000000000000000000)\n redis.set(TEST_KEY, value)\n redis.incr(TEST_KEY)\n assert_equal redis.get(TEST_KEY).to_i, value+1\n redis.del(TEST_KEY)\n counter.call\n end\n end\n end\nend",
"def create_workers(num_workers)\n while @workers.count < num_workers.to_i\n thread_index = @workers.keys.count + 1\n @worker_threads[thread_index] = Thread.new do\n if @workers.keys.count < (num_workers.to_i / 2)\n worker = create_worker(thread_index, [Feed, FeedItem])\n else\n worker = create_worker(thread_index, [FeedItem])\n end\n worker.start\n end\n sleep 0.2\n end\n end",
"def process\n t_total = Time.now\n t_reset = Time.now\n puts \"process: resetting\"\n self.reset\n t_reset = Time.now - t_reset\n\n t_read = Time.now\n puts \"process: reading\"\n self.read\n t_read = Time.now - t_read\n\n t_generate = Time.now\n puts \"process: generating\"\n self.generate\n t_generate = Time.now - t_generate\n\n t_render = Time.now\n puts \"process: rendering\"\n self.render\n t_render = Time.now - t_render\n\n t_cleanup = Time.now\n puts \"process: cleanuping\"\n self.cleanup\n t_cleanup = Time.now - t_cleanup\n\n t_write = Time.now\n puts \"process: writing\"\n self.write\n t_write = Time.now - t_write\n\n t_total = Time.now - t_total\n\n puts \"reset: #{t_reset} sec\"\n puts \"read: #{t_read} sec\"\n puts \"generate: #{t_generate} sec\"\n puts \"render: #{t_render} sec\"\n puts \"cleanup: #{t_cleanup} sec\"\n puts \"writing: #{t_write} sec\"\n puts \"total: #{t_total} sec\"\n rescue Exception => e\n puts \"Exception in process: #{e} #{e.backtrace.join(\"\\n\")}\"\n raise e\n end",
"def random_num_generator\n return rand(1..100)\nend",
"def random_num_generator\n return rand(1..100)\nend",
"def random_numbers\n\tputs \"Follow are two random numbers between 0 and 100\"\n\tyield rand(100), rand(100)if block_given?\nend",
"def run\n @logger.debug \"LastId is \" + @last_id.to_s\n tweets = collect_tweets\n\n @generator.generate_rss_file tweets unless tweets.instance_of? NilClass\n\n # the last thing we do:\n @config.write\n @logger.info \"....and we are done.\\n\\n\"\n end",
"def masterrun\n self.workersrun \n self.serverrun \n end",
"def generators; end",
"def generators; end",
"def santa_machine(number)\r\n\t\r\n\texample_genders = [\"male\", \"female\", \"agender\", \"bigender\", \"gender fluid\", \"other\" ]\r\n\texample_ethnicities = [\"black\", \"white\", \"Japanese\", \"lizzard\", \"merpeople\" , \"plant\"]\r\n\tnumber.times do\r\n \t\tsanta = Santa.new(example_genders.sample, example_ethnicities.sample, rand(0..140))\r\n \t\tsanta.reindeer_shuffle\r\n \t\tsanta.about\r\n \t\tend\r\n\r\nend",
"def run_experiment\n test_fitness\n experiment_status\n while !concluded?\n new_generation\n test_fitness\n experiment_status\n end\n end",
"def gen_num\n rand(1..100)\nend"
] |
[
"0.6912321",
"0.5610358",
"0.55341935",
"0.53992677",
"0.5355878",
"0.528509",
"0.5261756",
"0.5258786",
"0.52472353",
"0.5246438",
"0.52297103",
"0.52289003",
"0.52289003",
"0.52289003",
"0.5208914",
"0.5201603",
"0.51988566",
"0.51877767",
"0.51774836",
"0.51246893",
"0.50991136",
"0.5098857",
"0.50690544",
"0.5056933",
"0.5055072",
"0.502829",
"0.5026944",
"0.50231594",
"0.50231594",
"0.5013142",
"0.5006674",
"0.5002646",
"0.49930525",
"0.49930525",
"0.498802",
"0.49853924",
"0.49807882",
"0.49796823",
"0.49721462",
"0.49721462",
"0.49668092",
"0.49625784",
"0.49531376",
"0.4944779",
"0.49370167",
"0.49289012",
"0.49273834",
"0.49240607",
"0.4915619",
"0.48957115",
"0.4893696",
"0.489272",
"0.4887124",
"0.48785907",
"0.486679",
"0.48647076",
"0.48633114",
"0.4857025",
"0.48539",
"0.4844894",
"0.48398417",
"0.48398417",
"0.48383304",
"0.48362452",
"0.48353258",
"0.4825508",
"0.48210126",
"0.48185414",
"0.48146555",
"0.4813779",
"0.48098165",
"0.48089185",
"0.48071778",
"0.48069122",
"0.48049548",
"0.4803654",
"0.47909197",
"0.47899598",
"0.4786017",
"0.47787383",
"0.4778266",
"0.47656447",
"0.47571146",
"0.47551933",
"0.47530973",
"0.47402373",
"0.47355312",
"0.47342238",
"0.47272664",
"0.47245058",
"0.4722782",
"0.4722782",
"0.4721963",
"0.47173452",
"0.47162795",
"0.47143203",
"0.47143203",
"0.4713724",
"0.47117537",
"0.47091073"
] |
0.66465956
|
1
|
returns frequency for last hundred outputs
|
def get_freq
#instantiate with values to ensure consistent ordering
freq = { 1 => 0, 2 => 0, 3 => 0, 4 => 0, 5 => 0 }
#sum up freqencies of each number
last_100 = get_last_100
last_100.each do |item|
freq[item.to_i] += 1
end
# convert to percentage
freq.each do |key, val|
#divide by real length to handle case of less than 100 outputs
freq[key] = val / last_100.length.to_f
end
freq
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def frequency\n growth_rate = 2 ** (1.0 / 12)\n frequency = 440 * (growth_rate ** semitones_from_A4)\n frequency.round(3)\n end",
"def get_frequency()\n return(get_cmd('FA;',0.1,0.5,3).gsub(/^FA/,'').gsub(/;$/,'').to_i)\nend",
"def frequency\n \n end",
"def frequency\n FREQUENCY\n end",
"def past_frequency(history)\n count = 0\n history.each do |past_board|\n count += 1 if compare_board(self, past_board)\n end\n count \n end",
"def highestfrequency\r\n #@counts.group_by { |x| x }.map { |element, matches| [ element, matches ] }.to_h\r\n #@counts.each_with_object({}) { |item, memo| memo[item] ||= 0; memo[item] += 1 }\r\n ##@counts.uniq.map { |x| [x, @counts.count(x)] }.to_h\r\n #freq = @counts.inject(Hash.new(0)) { |h,v| h[v] += 1; h }\r\n @counts.max_by { |k,v| v }\r\n end",
"def frequencies\n inject(Hash.new(0)) { |h,v| h[v] += 1; h }\n end",
"def overall_frequency\n categories.inject(0) { |carry, item| carry + item[1] }\n end",
"def score_freq(cs)\n \" eta\".each_char.map { |c| cs.index(c) || 9999 }.reduce(&:+)\nend",
"def frequency\n opponents_faced.to_f / sample_size\n end",
"def frequency_of( frequency )\n case frequency.to_s\n when 'always'\n (1.0/0.0)\n when 'once'\n 1\n when 'never'\n 0\n else\n Float(frequency).to_i\n end\n end",
"def calcFrequency(freqs)\n\tsum = freqs.reduce(0, :+)\n\tputs sum\nend",
"def total\n total = 0\n for i in 0...size\n total += i * self.frequency[i]\n end\n total\n end",
"def get_tweet_counts_per_frequency(freq, tweet_name, start_time, end_time)\n \n end",
"def calculate_line_with_highest_frequency()\n @highest_count_across_lines = 0\n @highest_count_words_across_lines = []\n for line in @@analyzers\n if line.highest_wf_count >= @highest_count_across_lines\n\n @highest_count_across_lines = line.highest_wf_count\n @highest_count_words_across_lines.push(line)\n \n end\n \n end\n end",
"def twelve\n iter = 1\n trinum_temp = 0\n begin\n factors = count_factors(trinum_temp = (trinum(iter)))\n iter = iter + 1\n\n end until factors > 200\n\n return trinum_temp\nend",
"def angular_frequency\n @angular_frequency ||= 2.0 * Math::PI * frequency\n end",
"def calcCalibrationFrequency(freqs)\n\tsum = 0\n\tsums = []\n\tcycles = 0\n\ti = 0\n\tputs \"Calculating calibration freq\"\n\tputs \"this will take a bit\"\n\twhile (!(sums.include? sum))\n\t\tsums.push(sum)\n\t\tsum += freqs[i]\n\t\tif ((i + 1) >= freqs.length)\n\t\t\ti = 0\n\t\t\tcycles += 1\n\t\telse\n\t\t\ti += 1\n\t\tend\n\tend\n\tputs sum\nend",
"def get_tweet_counts_per_frequency(freq, tweet_name, start_time, end_time)\n s = @hash[tweet_name].bsearch_index { |ele| ele >= start_time }\n arr = (0..(end_time - start_time)/FREQ[freq]).map { 0 }\n return arr if s.nil?\n t = (@hash[tweet_name].bsearch_index { |ele| ele > end_time } || @hash[tweet_name].size) - 1\n return arr if s > t\n @hash[tweet_name][s..t].each do |time|\n tmp = (time - start_time) / FREQ[freq]\n arr[tmp] += 1\n end\n arr\n end",
"def count_freq\n hash = Hash.new(0)\n self.each do |element|\n hash[element] +=1\n end\n return hash\n end",
"def digit_frequency(base=10,place=0,zero_count=true)\n\t\tcounts = self.map {|x| x.to_a[place]}.counts\n\t\tfinal = Hash.new\n\t\t1.upto(base - 1){|d| final[d] = 0} if zero_count\n\t\tcounts.map {|key,value| final[key] = value.to_f/counts.values.element_sum}\n\n\t\treturn final\n\tend",
"def calculate_line_with_highest_frequency()\n maximo = @analyzers.max_by(&:highest_wf_count)\n @highest_count_across_lines = maximo.highest_wf_count\n @highest_count_words_across_lines = []\n @analyzers.each do |linha|\n if linha.highest_wf_count == @highest_count_across_lines\n @highest_count_words_across_lines << linha\n end\n end\n #puts \"maximo dos maximos: #{@highest_count_across_lines}#{highest_count_words_across_lines.flatten}\"\n #@highest_count_words_across_lines = Array.new\n #@analyzers.each do |analyzed| \n # @highest_count_words_across_lines << analyzed.highest_wf_words\n #end\n end",
"def freq_list\n freq_hash = each_with_object(Hash.new(0)) { |v, h| h[v] += 1 }\n freq_hash.sort_by { |k, v| -v }\n end",
"def calculate_line_with_highest_frequency\n @highest_count_across_lines = @analyzers.max_by(&:highest_wf_count).highest_wf_count\n @highest_count_words_across_lines = []\n @analyzers.each do |word|\n @highest_count_words_across_lines << word if word.highest_wf_count == @highest_count_across_lines\n end\n end",
"def calculate_frequencies(target_file)\n\tn_char=0.0\n\n\n\ttext=File.read(target_file)\n\n\t#creo l'hash delle lettere\n\thsh=Hash.new\n\tcode=97\n\twhile code<=122 do\n\t\thsh[code]=Occurrences.new(0,0.000)\n\t\tcode+=1\n\tend\n\t#conto le occorrenze delle lettere\n\ttext.each_byte {|c|\n\t\tif c>=97 and c<=122;\n\t\t\thsh[c].number+=1\n\t\t\tn_char+=1\n\t\tend\n\t}\n\t#creo le frequenze\n\thsh.each {|k, v|\n\t\tv[1]=v[0]/n_char\n\t\t#puts\"number:#{v[0]} - percentage:#{v[1]}\"\n\t}\n\t#print dei valori creati\n\t#i=0\n\t#hsh.each {|k, v| puts \"elemento #{i} ---> #{k} is #{v}\",\n\t#\ti+=1\n\t#}\n\treturn hsh;\nend",
"def frequency\n interval || 1.year\n end",
"def compute_frequencies\n @transitions.map { |value, transition_hash|\n sum = 0.0\n transition_hash.each { |succ_value, occurencies| \n sum += occurencies\n }\n \n transition_hash.each { |succ_value, occurencies|\n @frequencies[value] ||= Hash.new{0}\n @frequencies[value][succ_value] = occurencies/sum \n }\n }\n end",
"def histo_counts\n @histo_counts ||= calculate_histo_counts\n end",
"def percent_high_ranking\n\n count_high = 0\n\n cards.each do |card|\n\n if card.rank >= 11\n count_high += 1\n end\n\n end\n\n\n count_high_f = count_high.to_f\n count_total = cards.length\n count_total_f = count_total.to_f\n\n (100 * (count_high_f/count_total_f)).round(2)\n\n end",
"def getFactoredFreq(i,j)\n if(i == j) then\n return 0 ;\n else\n return (@freqTablePickUp[i] * @freqTableDropOff[j]) ;\n end\n end",
"def period\n 4/frequency\n end",
"def refactoring_reduction_profile events\n events.group_by(&:method_name)\n .map {|_,e| percent_reduction(e) }\n .freq_by {|e| (e * 100 / 10).to_i }\nend",
"def frequency(char)\n return 0 if (@size.nil? || @size <= 0)\n @map[char.upcase] * 100/@size\n end",
"def count_most_often(c)\n numbers = {}\n sorted = []\n (1..42).to_a.each do |e|\n conditions = \"(n1 = #{e} OR n2 = #{e} OR n3 = #{e} OR n4 = #{e} OR n5 = #{e})\"\n conditions += \" AND (no >= #{no-100})\" #if !n.nil?\n r = Result.count(:conditions => conditions,\n :order =>'no DESC')\n numbers[e] = r\n end\n numbers.sort_by{|k,v| v}.reverse.each{|e| sorted << e[0]}\n while numbers[c] == numbers[c+1]\n c += 1\n end\n #p sorted\n return sorted[0..c-1]\n end",
"def frequency(diapason: 440, height: '8')\n index = NOTES.index(@letter)\n (diapason.to_f / height_decimal(height)) * 2**(@octave + ((index - 9.0) / 12))\n end",
"def print_highest_word_frequency_across_lines()\n puts @highest_count_across_lines\n @highest_count_words_across_lines.each do |lineanalyzer|\n lineanalyzer.highest_wf_words.each { |v| puts \"#{v}\" }\n end\n end",
"def solution3(a)\n freq = {}\n a.each do |num|\n num = num.abs\n freq[num] ? next : freq[num] = 1\n end\n freq.size\nend",
"def hit_chance hist, tn \n sum = 0\n \n #are we trying to hit a TN higher than any of our dice rolled?\n if (tn > (hist.length-1)) then \n return 0\n end \n \n #for each entry higher than or equal to our TN (every hit) add together the number of successes\n (tn..hist.length-1).each do |index| \n sum += hist[index]\n end\n \n return sum/@scale \n end",
"def count_freq(array)\n array.each_with_object(Hash.new(0)) { |obj, counts| counts[obj] += 1 }\n end",
"def frequency(number_of_hours)\n word_count = Word.where(\"name = ? AND story_date > ?\", self, Time.now - number_of_hours.hours).count\n total_words = Word.where(\"story_date > ?\", Time.now - number_of_hours.hours).count\n return word_count.to_f / total_words.to_f\n end",
"def kHz\n (self * 1000).Hz\n end",
"def repeat_freq(nums, initial_val)\n sum = initial_val\n past_freqs = Set[initial_val]\n index = 0\n # This is an infinite loop so assumes that the problem has a solution\n while true\n sum += nums[index]\n return sum if past_freqs.add?(sum).nil?\n index += 1\n # Reset the index if it needs to loop\n index = 0 if index == nums.length\n end\nend",
"def inverse_document_frequency(term)\n df = @model.document_count(term)\n if @function == :bm25\n log((documents.size - df + 0.5) / (df + 0.5))\n else\n 1 + log(documents.size / (df + 1.0))\n end\n end",
"def show_total_unattendance_number\n puts 'show_total_unattendance_number'\n total_unattendance_number = @data.inject (0) do |mem, e|\n num_exams = e.size - 1.0\n mem + e.last(num_exams).count('00')\n end\n puts total_unattendance_number.to_s\n end",
"def frequency string\n $frequencies[string]\nend",
"def frequency_length\n if @freq == :daily\n @interval * 1\n elsif @freq == :weekly\n @interval * 7\n elsif @frequency == :monthly\n @interval * 29 # technically this is short, but I think it is fine for now\n end\n end",
"def num_harmonics(f0, fs = 44100)\n (fs / 2.0 / f0.to_f).to_i\nend",
"def occurence(nb)\n nb = nb.to_i\n array = Array.new()\n\n if(nb.is_a? Integer)\n while nb != 0\n if (array[nb % 10].nil?)\n array[nb % 10] = 1\n else array[nb % 10] += 1\n end\n nb = nb / 10\n end\n end\n\n # display\n for i in 0...26\n if (!array[i].nil?)\n puts \"Le chiffre #{i} apparait #{array[i]} fois\"\n end\n end\nend",
"def get_tweet_counts_per_frequency(freq, tweet_name, start_time, end_time)\n case freq\n when \"minute\"\n delta = 60\n when \"hour\"\n delta = 3600\n else\n delta = 86400\n end\n\n t = Hash.new(0)\n if @tweets.key?(tweet_name)\n @tweets[tweet_name].each do |time|\n next if time < start_time || time > end_time\n t[(time - start_time) / delta] += 1\n end\n end\n\n result = []\n (0..((end_time - start_time) / delta)).each do |i|\n result.push(t[i])\n end\n\n result\n end",
"def nb_year(p0, percent, aug, p)\n year_count = 0\n until p0 >= p do\n p0 += (p0 * (percent/100.to_f)) + aug\n year_count += 1\n # binding.pry\n end\n year_count\n # binding.pry\nend",
"def estimate_count\n -(m / k.to_f) * Math.log(1 - (filter.cardinality / m.to_f))\n end",
"def term_frequency(document, term)\n tf = document.term_count(term)\n if @function == :bm25\n (tf * 2.2) / (tf + 0.3 + 0.9 * documents.size / @model.average_document_size)\n else\n sqrt(tf)\n end\n end",
"def alphabet_frequency string, letter\n decode_attempt = c_decode string, letter\n frequency_total_array = []\n $frequencies.each do |key, array|\n frequency_total_array.push((frequency_value(decode_attempt.split(\"\"), key) - $frequencies[key]).abs)\nend\nfrequency_total_array.inject(0, :+)\nend",
"def activityNotifications(expenditure, d)\n # Frequence array to cover all expense amounts $0-200\n freqs = Array.new(201){0}\n # Queue to calculate the median for d trailing days only\n queue = []\n counter = 0\n expenditure.each_with_index do |exp, i|\n # To start (before d items), populate the queue and freq table only\n if i < d\n queue << exp\n else\n # Get median and increase count if necessary\n count += 1 if exp >= 2 * median(freqs, d)\n # Removing outgoing element from queue and freq array\n freqs[queue.shift] -= 1\n # Add incoming element to queue and freq array\n queue << exp\n end\n freqs[exp] += 1\n end\n counter\nend",
"def get_IR_by_count(inst_cnt) \n incon, sample_size = 0.0, 0.0\n \n inst_cnt.values.each do |hcnt|\n cnt = hcnt.values\n incon += cnt.sum-cnt.max\n sample_size += cnt.sum\n end\n \n # inconsistency rate\n (sample_size.zero?) ? 0.0 : incon/sample_size\n end",
"def accum_counts(counts)\n each_byte do |b| counts[b - ?a] += 1 if b >= ?a && b <= ?z end\n end",
"def count(stat, count, sample_rate=1); send stat, count, 'c', sample_rate end",
"def to_hz\n 440.0 * (2.0 ** ((to_i.to_f-69)/12))\n end",
"def appending_no_wins_to_nominee_winner_results_frequency\n winning_count = winning_results_frequency_for_each_nominee\n no_wins_arr = checking_for_no_wins_results_frequency_for_each_nominee\n\n no_wins_arr.each do |loser| \n if (loser != nil) && (loser != 0)\n winning_count[loser] = 0 \n end\n end\n\n return winning_count\n end",
"def findNumCycles(output)\n value = 0\n temp = output.slice(/NUMBER_OF_CYCLES_READ[12]=\\d+/)\n if temp != nil && !temp.eql?(\"\")\n value = Integer(temp.split(\"=\")[1]) - 1\n end\n\n if value > @numCycles\n @numCycles = value\n end \n end",
"def freq_peaks\n return frequency_domain.peaks\n end",
"def freq_intercommit_durations events\n events.map(&:date).sort\n .uniq\n .each_cons(2)\n .map {|before,after| (after.to_i - before.to_i) / 60 }\n .freq_by { |e| e / 5}\n .select {|e| e[0] <= 12 * 8 }\nend",
"def ioc(text)\n c = 26.0\n freqs = frequency(text)\n n = text.length\n\n f = freqs.values.reduce(0) { |a, e| a + (e * (e - 1)) }\n f / ((n * (n - 1)) / c)\n end",
"def frequency_of(gram)\n @frequencies.fetch(gram,0)\n end",
"def histogram(results)\n array = []\n results.each_with_index do |rolls, index|\n if rolls > 0\n array.unshift(\"#{index + 1}|#{\"#\" * rolls} #{rolls}\\n\")\n else\n array.unshift(\"#{index + 1}|#{\"#\" * rolls}\\n\")\n end\n end\n\n array.join\nend",
"def build_frequency_list\n # read the 512 byte chunk into the variable, get the size,\n # and count each value of the 256 possibilites. Stored in @char_frequency\n file_stream = IO.binread(@file_name, @byte_chunk)\n block_size = file_stream.length * 1.0\n file_unpacked = file_stream.unpack('C*').map { |c| c.to_s }\n (0..255).each do |byte|\n counter = 0\n file_unpacked.each do |index|\n counter += 1 if index.to_i == byte\n end\n @char_frequency.insert(byte, counter / block_size)\n end\n end",
"def frequency(cat)\n categories[cat] || 0\n end",
"def note_frequency_calculator base_frequency, steps_to_next_note\n # TODO: Add a multiplier for KHz\n @bf = base_frequency\n @steps = steps_to_next_note\n return (@bf * 1.059463094359 ** @steps).round(2)\n end",
"def set_frequency(hertz)\n puts \"Setting frequency to #{hertz}\" if $verbose\n f='FA'+(('00000000000'+hertz.to_s)[-11..-1])+';'\n puts f if $verbose\n ret=send_cmd(f,'FA;',f,0.5,1.5,3)\n if(ret)\n return(ret.gsub(/^FA/,'').gsub(/;$/,'').to_i)\n else\n return(nil)\n end\nend",
"def how_many_most_often(n)\n a = count_most_often(n)\n lrj = a.join(',')\n c = 0\n [self.n1, self.n2, self.n3, self.n4, self.n5].each do |n|\n c += 1 if a.include?(n)\n end\n return [c, a.size]\n end",
"def print_highest_word_frequency_across_lines\n for line in @highest_count_words_across_lines\n puts \"#{line.highest_wf_words} (appears in line #{line.line_number} )\"\n end\n end",
"def sundays(arr, value)\n count = 0\n arr.each { |n|\n count += 1 if (n + value) % 7 == 0\n }\n return count\nend",
"def frequencies\n notes_range.to_a.map { |note| note.frequency(diapason: @project.diapason, height: @height).round(2) }\n end",
"def count_frequencies s\n s.downcase.split(//).inject(Hash.new(0)) do |hash,item|\n hash[item] += 1\n hash\n end\n end",
"def freqs(cts)\n total = cts.values.inject(0) {|memo, obj| memo + obj}\n freqs = Hash.new()\n cts.each {|k, v|\n freqs[k] = v.to_f / total\n }\n freqs\n end",
"def frequency_score(character_hash)\n frequency_pairs = frequency_order.each_with_index.map {|el, idx| [el, idx]}\n critical_indices = (0..7).to_a + frequency_pairs[-5..-1].map {|el| el[1]}\n frequency_pairs.sort_by do |pair|\n -character_hash[pair[0]] end.each_with_index.map do |pair, idx|\n critical_indices.include?(idx) ? (pair[1] - idx).abs : 0\n end.inject(&:+) * (1 + character_hash.values.inject(&:+)/10)\nend",
"def lengths\n frequencies.map { |frequency| (@project.speed_of_sound / (frequency * 2) * 1000).round(0) }\n end",
"def nb_year(p0, percent, aug, p)\n count = 0\n while p0 < p\n p0 = p0 + (p0 * percent * 0.01).to_i + aug\n count += 1\n end\n \n return count\nend",
"def radio_freq\n return (self.sendcmd(\"main.get_frequency\").to_i+self.get_carrier()).to_i\n end",
"def metric_power\n metric_prefixes.map.with_index { |_item, index| (1000**(index + 1)).to_i }\nend",
"def total\n if @dirty\n @total = 0\n @frequencies.each_value { |freq| @total += freq }\n end\n\n return @total\n end",
"def get_last_100\n last_100 = []\n lines = File.readlines('./output.txt').reverse[0...100]\n lines.each do |line|\n last_100 << line.chomp.split(\", \")[0]\n end\n last_100\n end",
"def most_frequent(nums)\n hash = {}\n max_occurence = 0\n\n nums.each do |num|\n if !hash.has_key?(num.to_s)\n hash[num.to_s] = 1\n else\n hash[num.to_s] += 1\n if max_occurence < hash[num.to_s] \n max_occurence = hash[num.to_s]\n end\n end\n end\n\n hash.select { |key, value| value == max_occurence }\n .map { |key, value| key.to_i} \nend",
"def top25(freqs)\n def fun(w, f)\n puts \"#{w} - #{f.to_s}\"\n end\n\tfreqs.take(25).each{|w,f| fun(w, f)}\nend",
"def get_frequency(frequencies,digit,position)\n frequencies[position][digit]\nend",
"def histogram(lookback)\n histo = Hash.new\n key = [@@start_token] * lookback\n get_text.each do |char|\n ((histo[key.clone] ||= { })[char] ||= 0)\n histo[key.clone][char] += 1\n key.push(char).shift\n end\n histo\n end",
"def burntcals(dist)\n\t\tkcals = dist * 105\n\t\treturn kcals\n\tend",
"def mHz\n (self * 1000_000).Hz\n end",
"def hist\n return [] unless @histogram_buckets\n max = @histogram_buckets.max.to_f\n @histogram_buckets[0..-2].map { | count | { count: count, score: max > 0 ? count / max : 0 } }\n end",
"def cout(n)\n\tw=[0,1,2,3,4,5,6,7,8,9]\n\tx=[]\n\tk=1\n\twhile x!=w do \n\t\tm=n*k\n\t\t\twhile m>0 do\n\t\t\t\tt=m%10\n\t\t\t\tx=x.push(t)\n\t\t\t\tx.sort!\n\t\t\t\tx.uniq!\n\t\t\t\tm=m/10\t\n\t\t\tend\n\t\tk=k+1\n\tend\nreturn (k-1)*n\nend",
"def offense_counts; end",
"def offense_counts; end",
"def seventeen\n acc = 0\n for i in 1..1000\n acc = acc + count_letters(read_numbers(i))\n end\n\n return acc\nend",
"def crunch_stats(value, n)\n\tmean = value.inject(:+)/n.to_f\n\tvariance = 0\t# <= technically, this is actually variance*n\n\tfeed_presence = 0\t\n\tvalue.each do |item|\n\t\tvariance += (item - mean)**2\n\t\tfeed_presence += 1 if item > 0\n\tend\n\tfeed_presence = feed_presence/n.to_f\n\tsd = Math.sqrt(variance/n)\n\treturn [mean,sd,feed_presence]\nend",
"def P_of_c(clazz)\n Math.log(doc_count(clazz).to_f / num_of_docs)\n end",
"def list_count\n\t\tThread.start do\n\t\t\tnotifier = @ts.notify 'write', [:old_n, nil]\n\t\t\tnotifier.each do |_, t|\n\t\t\t #puts t.last\n \t puts \"n: #{@ts.read([:old_n, nil]).sort.last} a: #{@ts.read([:a, nil]).last} b: #{@ts.read([:b, nil]).last} a*b: #{@ts.read([:a, nil]).last.to_i* @ts.read([:b, nil]).last.to_i}\"\n\t\t\tend\n\t\tend\n\tend",
"def falcon (vol)\r\n if vol < 50\r\n return 1\r\n else\r\n tubes = vol / 50\r\n if vol % 50 > 1\r\n return tubes + 1\r\n end\r\n end\r\n end",
"def calculate_histo_counts\n counts = []\n xx = x.dup\n histo_ranges.each do |i|\n counts << xx.size - xx.delete_if { |j| j > i[1] }.size\n end\n counts\n end",
"def score_counts(counts)\n if counts.count > 0\n _num = counts.map { |x| x.obp }\n _num.percentile(90)\n else\n 0.01\n end\n end",
"def counter_effect(hit_count)\n hits = []\n digits = hit_count.split(\"\").map {|num| num.to_i}\n digits.each do |digit|\n \tcurrent_values = []\n \tfor num in 0..digit\n \t\tcurrent_values.push(num)\n \tend\n \thits.push(current_values)\n end\n return hits\nend"
] |
[
"0.6677098",
"0.66134214",
"0.65858567",
"0.6584553",
"0.6405751",
"0.6396108",
"0.63465613",
"0.6335369",
"0.6193089",
"0.616515",
"0.61158615",
"0.6107291",
"0.6054452",
"0.5971618",
"0.5827842",
"0.5822521",
"0.5798948",
"0.5795328",
"0.577622",
"0.5763896",
"0.5726173",
"0.5723082",
"0.5711912",
"0.57019687",
"0.5701721",
"0.5674659",
"0.56541187",
"0.5624996",
"0.561804",
"0.56177235",
"0.56001806",
"0.5595697",
"0.5592887",
"0.5581484",
"0.556916",
"0.55682987",
"0.55652606",
"0.5561602",
"0.55458015",
"0.55317324",
"0.5528146",
"0.55197287",
"0.55139834",
"0.5509807",
"0.5507999",
"0.5503129",
"0.54904205",
"0.5485916",
"0.5479858",
"0.54677635",
"0.5467621",
"0.5463646",
"0.54550546",
"0.54504234",
"0.54373604",
"0.5434244",
"0.5433624",
"0.5432468",
"0.5427381",
"0.54257166",
"0.5411719",
"0.54075444",
"0.5405297",
"0.5404142",
"0.5401924",
"0.5390845",
"0.53906125",
"0.5388046",
"0.5386931",
"0.5386226",
"0.53857774",
"0.5383791",
"0.5380615",
"0.5379205",
"0.5373069",
"0.53572387",
"0.53572303",
"0.5356971",
"0.53558075",
"0.5354713",
"0.5346799",
"0.534334",
"0.5343282",
"0.5340092",
"0.53291684",
"0.5327867",
"0.53203887",
"0.5317504",
"0.53172874",
"0.5317009",
"0.5310454",
"0.5310454",
"0.53096104",
"0.5304059",
"0.5300012",
"0.5299165",
"0.52981097",
"0.5295915",
"0.529564",
"0.52930695"
] |
0.7998869
|
0
|
helper method to return last 100 outputs
|
def get_last_100
last_100 = []
lines = File.readlines('./output.txt').reverse[0...100]
lines.each do |line|
last_100 << line.chomp.split(", ")[0]
end
last_100
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def last_output\n return @output_array[-1]\n end",
"def last_output\n return @output_array[-1]\n end",
"def last_output\n return @output_array[-1]\n end",
"def last_output\n return @output_array[-1]\n end",
"def get_output(num)\n messages = @messages.last(num)\n messages.count < 2 ? messages.first : messages\n end",
"def last_turn_output\n return @output_array[-1]\n end",
"def last_turn_output\n return @output_array[-1]\n end",
"def last_turn_output\n return @output_array[-1]\n end",
"def last_turn_output\n return @output_array[-1]\n end",
"def last\n out = nil\n\n each {|i| out = i }\n\n out\n end",
"def last_ids(number); end",
"def get_Limit()\n \t return @outputs[\"Limit\"]\n \tend",
"def get_Limit()\n \t return @outputs[\"Limit\"]\n \tend",
"def get_Limit()\n \t return @outputs[\"Limit\"]\n \tend",
"def get_Limit()\n \t return @outputs[\"Limit\"]\n \tend",
"def get_Limit()\n \t return @outputs[\"Limit\"]\n \tend",
"def get_Limit()\n \t return @outputs[\"Limit\"]\n \tend",
"def get_Limit()\n \t return @outputs[\"Limit\"]\n \tend",
"def get_Limit()\n \t return @outputs[\"Limit\"]\n \tend",
"def get_Limit()\n \t return @outputs[\"Limit\"]\n \tend",
"def get_Limit()\n \t return @outputs[\"Limit\"]\n \tend",
"def get_Limit()\n \t return @outputs[\"Limit\"]\n \tend",
"def get_Limit()\n \t return @outputs[\"Limit\"]\n \tend",
"def get_Limit()\n \t return @outputs[\"Limit\"]\n \tend",
"def get_Limit()\n \t return @outputs[\"Limit\"]\n \tend",
"def get_Limit()\n \t return @outputs[\"Limit\"]\n \tend",
"def get_Limit()\n \t return @outputs[\"Limit\"]\n \tend",
"def get_Limit()\n \t return @outputs[\"Limit\"]\n \tend",
"def get_Limit()\n \t return @outputs[\"Limit\"]\n \tend",
"def get_Limit()\n \t return @outputs[\"Limit\"]\n \tend",
"def get_Limit()\n \t return @outputs[\"Limit\"]\n \tend",
"def get_Limit()\n \t return @outputs[\"Limit\"]\n \tend",
"def get_Limit()\n \t return @outputs[\"Limit\"]\n \tend",
"def get_Limit()\n \t return @outputs[\"Limit\"]\n \tend",
"def get_Limit()\n \t return @outputs[\"Limit\"]\n \tend",
"def get_Limit()\n \t return @outputs[\"Limit\"]\n \tend",
"def get_Limit()\n \t return @outputs[\"Limit\"]\n \tend",
"def get_Limit()\n \t return @outputs[\"Limit\"]\n \tend",
"def get_Limit()\n \t return @outputs[\"Limit\"]\n \tend",
"def get_Limit()\n \t return @outputs[\"Limit\"]\n \tend",
"def get_Limit()\n \t return @outputs[\"Limit\"]\n \tend",
"def get_Limit()\n \t return @outputs[\"Limit\"]\n \tend",
"def get_Limit()\n \t return @outputs[\"Limit\"]\n \tend",
"def get_Limit()\n \t return @outputs[\"Limit\"]\n \tend",
"def get_Limit()\n \t return @outputs[\"Limit\"]\n \tend",
"def get_Limit()\n \t return @outputs[\"Limit\"]\n \tend",
"def max_history; end",
"def max_history; end",
"def show_last_results\n @last_results ||= \"0\"\n end",
"def get_upper_limit_of(range)\n\tn = 1..20\n\tn.last\nend",
"def avail_out= size\n\t\tsize.times do \n\t\t\tif size > avail_out\n\t\t\t\t@output_buffer.push nil\n\t\t\telse\n\t\t\t\t@output_buffer.pop\n\t\t\tend\n\t\tend\n\tend",
"def last_cmds(n=1)\n puts Readline::HISTORY.entries[-(n+1)..-2].join(\"\\n\")\nend",
"def get_outputs\n outputs = []\n last_layer_nodes = layer_n_nodes(num_layers - 1)\n loop_over_nodes(num_layers - 1) do |i|\n outputs << last_layer_nodes[i].output\n end\n outputs\n end",
"def last\n return each\n end",
"def avail_out= size\n\t\t\tsize.times do\n\t\t\t\tif size > avail_out\n\t\t\t\t\t@output_buffer.push nil\n\t\t\t\telse\n\t\t\t\t\t@output_buffer.pop\n\t\t\t\tend\n\t\t\tend\n\t\tend",
"def problem7\n\tPrime.take(10001).last\nend",
"def output_rows\n return 24 unless @output.tty?\n terminal.terminal_size.last\n rescue NoMethodError\n return 24\n end",
"def how_many_returns\n records = @logs.records.sort_by { |record| record.ip.length - record.ip.uniq.length }.reverse\n @view.display_how_many_returns(records)\n end",
"def get_all_results\n\t\tresult_array = []\n\t\tskip = 0\n\t\ttake = 1000\n\t\tloop do\n\t\t\tcurrent_result = get_data_from_result(execute_request(take, skip)[1])\n\t\t\tresult_array.concat(current_result)\n\t\t\tskip = skip + take\n\t\t\tbreak if current_result.size != take\n\t\tend\n\t\treturn result_array\n\tend",
"def dynamic_chunk(base_ten_num) #=>inncludes first 1 in output\n base_two_num = binarify(base_ten_num)\n base_two_num.slice(static_chunk(base_ten_num).length..(base_two_num.length - 1))\nend",
"def display_last_logs(n: 7)\n @queue.last(n).each do |common_log|\n printf \"%s %-#{columns - 4}s %s\" % [V_SEP, common_log.to_s, V_SEP]\n end\n end",
"def last_output(lines)\n lines.split(/(?:^|\\n).*\\$/).map(&:strip).reject(&:empty?).last\nend",
"def output\n run\n ints[0]\n end",
"def outlinks\n return @outputs\n end",
"def last(limit = 1)\n reverse.take(limit).reverse\n end",
"def last_stdout\n strip_duration(@last_stdout)\n end",
"def last() end",
"def end_result_number\n start_result_number + (results.size) - 1\n end",
"def last(*n) end",
"def fetch_latest(params)\n wines = []\n offset = 0\n limit = 5000\n params_with_defaults = { limit: limit }.merge(params)\n response = auth_then.get(BASE_URL, params: params_with_defaults)\n count = response.parse[\"count\"]\n\n while offset < count\n if response.code == 200\n response.parse[\"results\"].each do |result|\n wines << result\n end\n else\n []\n end\n response = auth_then.get(response.parse[\"next\"]) if response.parse[\"next\"] != nil\n offset += 5000\n end\n wines\n end",
"def last_command_output\n Output.new(@result.stdout)\n end",
"def get_output\n output = []\n tokens = 0\n @queue_mutex.synchronize do\n tokens = @queue.size\n tokens.times { output << @queue.shift }\n end\n @mutex.synchronize do\n @enqueued_tokens -= tokens\n end\n\n # Nil if nothing to process in the pipe.\n # Possible only after flushing the pipe.\n if @enqueued_tokens > 0\n output\n else\n output.any? ? output : nil\n end\n end",
"def last_color_output\n return @output_array[-2]\n end",
"def last_color_output\n return @output_array[-2]\n end",
"def last_color_output\n return @output_array[-2]\n end",
"def last_color_output\n return @output_array[-2]\n end",
"def get_output(options={})\n if io = options.delete(:io)\n options = options.merge :response_block => lambda {|chunk, remaining_bytes, total_bytes| io.write chunk}\n end\n options['Range'] = options.delete :range\n service.get_job_output(vault.id, id, options)\n end",
"def last(n = 1)\n return @history[-n] ;\n end",
"def show_recent_jobs\n\n max_jobs = \"\"\n\n # until max_jobs.to_i.between?(1, FreelancerFinder::Job.all.count)\n # puts \"#{FreelancerFinder::Job.all.count} Total Listings to Choose From!\".magenta\n # print \"How many jobs would you like to see?: \".blue\n # max_jobs = gets.chomp.downcase\n # end\n\n puts \"#{FreelancerFinder::Job.all.count} Total Listings to Choose From!\".magenta\n max_jobs = @prompt.slider('How many jobs would you like to see?', max: FreelancerFinder::Job.all.count, step: 10)\n\n max_jobs = max_jobs.to_i - 1\n\n jobs = []\n\n FreelancerFinder::Job.all.each.with_index do |job, index|\n jobs << job\n break if index >= max_jobs\n end\n\n jobs\n end",
"def avail_out\n\t\t@output_buffer.length - @out_pos\n\tend",
"def out_buffers; @out_buffers; end",
"def recent_commit_shas count\n array_output_of(\"git rev-list HEAD -n #{count}\").reverse\nend",
"def populate_raw_result(temp_file_name)\n @raw_result = `tail -n 500 #{temp_file_name}`\n end",
"def last_rut; end",
"def avail_out\n\t\t\t@output_buffer.length - @out_pos\n\t\tend",
"def tail\n return find_tail.data\n end",
"def bynum results, num=1000\r\n\tfiles = []\r\n\t\r\n\tresults.to_a.each_slice(num).with_index do |res, i|\r\n\t\tnums = \"#{num*i+1}-#{num*i+res.length}\"\r\n\t\t\r\n\t\tfname = \"out-#{nums}.txt\"\r\n\t\tfiles << fname\r\n\t\t\r\n\t\tout = File.open(fname,'w')\r\n\t\t\r\n\t\tres.each do |k,v|\r\n\t\t\tname, images, interwikimap = k, *v\r\n\t\t\t\r\n\t\t\tout.puts \"* [[#{name}]]\" unless images.empty?\r\n\t\t\tout.puts images.to_a.map{|img, langs| \r\n\t\t\t\t\"** [[:commons:File:#{img}|]] na #{langs.uniq.map{|l| \"[[:#{l}:#{interwikimap[l.to_s]}|#{l}]]\"}.join ','}\"\r\n\t\t\t}\r\n\t\tend\r\n\t\t\r\n\t\tout.close\r\n\t\t\r\n\t\tputs nums\r\n\tend\r\n\t\r\n\treturn files\r\nend",
"def next_result()\n #This is a stub, used for indexing\n end",
"def print_output_head(index)\n puts \"\\nPrinting dataset for %.2f\" %\n (@meta_data.domain_z.lower + (index * @meta_data.domain_z.step))\n puts \"\\n\"\n end",
"def get_max_results\n @max_results\n end",
"def read_output()\n if outputs.size > 0\n outputs.shift\n else\n nil\n end\n end",
"def collect1 pages\n id = 'joshuabaer'\n results = []\n 1.upto pages do |page|\n results += http_get id, page\n end\n results\nend",
"def last; end",
"def last; end",
"def last; end",
"def last\n all[all.size - 1]\n end",
"def get_Next()\n \t return @outputs[\"Next\"]\n \tend",
"def get_Next()\n \t return @outputs[\"Next\"]\n \tend",
"def get_Next()\n \t return @outputs[\"Next\"]\n \tend",
"def get_Next()\n \t return @outputs[\"Next\"]\n \tend"
] |
[
"0.6402576",
"0.6402576",
"0.6402576",
"0.6402576",
"0.61115795",
"0.5949863",
"0.5949863",
"0.5949863",
"0.5949863",
"0.5788936",
"0.5780951",
"0.5760885",
"0.5760885",
"0.5760885",
"0.5760885",
"0.5760885",
"0.5760885",
"0.5760885",
"0.5760885",
"0.5760885",
"0.5760885",
"0.5760885",
"0.5760885",
"0.5760885",
"0.5760885",
"0.5760885",
"0.5760885",
"0.5760885",
"0.5760885",
"0.5760885",
"0.5760885",
"0.5760885",
"0.5760885",
"0.5760885",
"0.5760362",
"0.5760362",
"0.5760362",
"0.5760362",
"0.5760362",
"0.5760362",
"0.5760362",
"0.5760362",
"0.5760362",
"0.5758608",
"0.5758608",
"0.5758608",
"0.5744635",
"0.5744635",
"0.57231873",
"0.5703605",
"0.56708485",
"0.56344897",
"0.56159467",
"0.5603517",
"0.55551034",
"0.5549698",
"0.55300355",
"0.550117",
"0.5499973",
"0.5493717",
"0.5462744",
"0.54571134",
"0.54541796",
"0.5444132",
"0.5410296",
"0.54072315",
"0.5398785",
"0.53984785",
"0.53897935",
"0.53676903",
"0.5358016",
"0.5339154",
"0.53269494",
"0.53269494",
"0.53269494",
"0.53269494",
"0.5323393",
"0.5316396",
"0.5315807",
"0.53149205",
"0.5309323",
"0.5308939",
"0.52953905",
"0.52911615",
"0.5283812",
"0.5274422",
"0.52662086",
"0.5246078",
"0.52456737",
"0.5234287",
"0.5228027",
"0.5217553",
"0.5217499",
"0.5217499",
"0.5217499",
"0.5217304",
"0.52126354",
"0.52126354",
"0.52126354",
"0.52126354"
] |
0.73927873
|
0
|
creates a Binary Min Heap to ensure ordered output
|
def setup_heap
@heap = BinaryMinHeap.new
@thread_queues.each do |queue|
@heap.push(queue.shift)
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def build_minheap\n\t\ti = @heap.length/2\n\t\twhile i >= 0\n\t\t\tminheapify(i)\n\t\t\ti -= 1\n\t\tend\n\tend",
"def heapsort(list)\n sorted_arr = []\n heap = MinHeap.new()\n list.each do |value|\n heap.add(value, value)\n end \n\nlist.length.times do |i|\n min = heap.remove()\n sorted_arr.push(min)\nend \nreturn sorted_arr\nend",
"def insert_into_min_heap(heap, element)\n heap << element\n current_index = heap.length\n\n while current_index > 1 && element < heap[(current_index / 2) - 1]\n larger_element = heap[(current_index / 2) - 1]\n\n heap[(current_index / 2) - 1] = element\n heap[current_index - 1] = larger_element\n\n current_index = (current_index / 2)\n end\n\n heap\nend",
"def heapsort(list)\n array = []\n myHeap = MinHeap.new()\n #return myHeap.store\n list.each do |item|\n myHeap.add(item)\n puts item \n end\n\n until myHeap.empty?\n array << myHeap.remove()\n end\n return array\nend",
"def heapsort_NOT_REALLY_inPlace(list)\n puts \"\\n\\nSTARTING WITH list = #{list}\"\n \n heap = MinHeap.new()\n list.unshift(heap)\n # now list = [heap, e1, e2, e3, ...] but heap is empty\n # so far space is still O(1) no matter how big the arg list is\n \n \n # list[0] is the heap, and list[1..end] is the unsorted numbers\n # the heap will grow by adding in whatever is at list[1], which will get deleted as they get added to the heap\n # the heap at list[0] will grow while the unsorted numbers will shrink in size until they're gone\n while list[1]\n addThisToHeap = list[1]\n puts \"\\nadding new node: #{addThisToHeap}\"\n heap.add(addThisToHeap)\n puts \"\\theap at list[0] is now #{heap}\"\n \n list.delete_at(1)\n \n puts \"\\tlist[1] onwards is now #{list[1..-1]}\"\n end\n \n # now that list[0] is the heap and list[1] don't exist anymore...\n # start plucking out the roots from the MinHeap, and append it onto the end of list\n puts \"\\n------ Now start kicking out the root/min from heap and return it to end of list\"\n until heap.empty?\n kickOutOfHeap = heap.remove()\n list << kickOutOfHeap\n \n puts \"\\nKicking out #{kickOutOfHeap}\"\n puts \"\\theap at list[0] is now #{heap}\"\n puts \"\\tlist[1] onwards is now #{list[1..-1]}\"\n end\n \n # now get rid of the empty Heap at list[0], and all that's left should be the sorted numbers\n list.shift()\n \n return list\nend",
"def minheapify(i=0)\n\t\tn_heapify(@min, i)\n\t\t@heap\n\tend",
"def build_heap\n @heap_size = length\n (length / 2).floor.downto(1) do |i| \n heapify_downward i \n end\n end",
"def heapsort()\n\t\tbuild_minheap()\n\t\ti = @heap.length-1\n\t\twhile i >= 1\n\t\t\ttemp = @heap[i]\n\t\t\t@heap[i] = @heap[0]\n\t\t\t@heap[0] = temp\n\t\t\tminheapify_heapsort(i)\n\t\t\ti -= 1\n\t\tend\n\t\t@heap\n\tend",
"def heap_sort(list)\n heap_sort = MinHeap.new()\n\n list.each do |number|\n heap_sort.add(number, number)\n end\n\n sorted = Array.new\n until heap_sort.empty?\n sorted << heap_sort.remove\n end\n\n return sorted\nend",
"def ensure_order_and_write\n fill_queues\n unless @heap.empty?\n #extract the minimum element from the heap \n extracted_el = @heap.extract\n write_to_disk(extracted_el)\n #add the next element from the same thread to the heap\n from_queue = extracted_el[:thread]\n fill_queues\n next_el = @thread_queues[from_queue].shift\n if next_el\n @heap.push(next_el) \n end\n end\n end",
"def heapsort(list)\n min_heap = MinHeap.new()\n until list.empty?\n min_heap.add(list.pop)\n end\n\n while !min_heap.empty?\n list << min_heap.remove()\n end\n\n return list\nend",
"def heap_sort(list)\n return [] if list.nil?\n return list if list.length == 1\n \n heap = MinHeap.new \n \n list.each do |node|\n heap.add(node)\n end\n \n sorted_heap = []\n \n list.length.times do \n node = heap.remove \n sorted_heap << node\n end\n return sorted_heap\nend",
"def heap_sort(list)\n heap = MinHeap.new\n\n list.each do |int|\n heap.add(int)\n end\n\n i = 0 \n \n until i == list.length\n list[i] = heap.remove\n i += 1\n end\n\n return list;\nend",
"def heapsort(list)\n heap = MinHeap.new()\n\n list.each do |element|\n heap.add(element)\n end\n\n result = []\n while !heap.empty?\n node = heap.remove\n result.push(node)\n end\n\n return result\nend",
"def extract_min\n @nodes.shift.tap do\n # Move the last node to the root position and then heapify down\n @nodes.unshift @nodes.pop unless @nodes.size.zero?\n heapify_down\n end\n end",
"def heapsort(list)\n heap = MinHeap.new\n sorted_list = []\n\n list.each do |item|\n heap.add(item)\n end\n\n list.length.times do \n sorted_list << heap.remove()\n end\n\n return sorted_list\nend",
"def heapsort(list)\n return list if list.empty? || list.length == 1\n\n minHeap = MinHeap.new()\n\n until list.empty?\n minHeap.add(list.pop)\n end\n\n until minHeap.empty?\n list << minHeap.remove\n end\n\n return list\nend",
"def build_heap\n unless @elements.empty?\n i = (@elements.size-1)/2\n while i>=0\n heapify(i)\n i -= 1\n end\n end\n end",
"def build_heap(array)\n first_parent_index = (array.length - 2) / 2\n (first_parent_index..0).each do |current_index|\n sift_down(current_index, array.length - 1, array)\n end\n end",
"def heapsort(list)\n heap = MinHeap.new\n result = []\n \n list.each do |val|\n heap.add(val, val)\n end\n\n result << heap.remove until heap.empty?\n \n return result\nend",
"def heapsort(list)\n heap = MinHeap.new\n list.each do |number|\n # apply the .add instance method \n heap.add(number)\n end\n\n list.each_with_index do |number, index|\n list[index] = heap.remove()\n end \n return list\nend",
"def heapsort(list)\n heap = MinHeap.new()\n \n # add each element onto MinHeap\n list.each do |element|\n heap.add(element)\n end\n \n # start plucking out the roots from the MinHeap\n sortedList = []\n until heap.empty?\n sortedList << heap.remove()\n end\n \n return sortedList\nend",
"def extract_min\n extract_key = peek_min.key\n min_head = new_heap_from_children\n remove_min_from_heap\n\n # Union\n @head = union(self, BinomialHeap.new(min_head))\n h_next = head.sibling\n consolidate(head, h_next)\n # get new @min\n\n extract_key\n end",
"def heapsort(list)\n min_heap = MinHeap.new()\n list.each do |item|\n min_heap.add(item)\n end\n empty_arr = []\n\n list.length.times do\n empty_arr << min_heap.remove()\n end\n return empty_arr\nend",
"def heapify(min_heap, hash_table, index)\n smallest = index\n left_child = 2 * index + 1\n right_child = 2 * index + 2\n if (left_child < min_heap.length) && (min_heap[left_child][1] < min_heap[smallest][1])\n smallest = left_child\n end\n if (right_child < min_heap.length) && (min_heap[right_child][1] < min_heap[smallest][1])\n smallest = right_child\n end\n if smallest != index\n hash_table[min_heap[index][0] - 1][1] = smallest\n hash_table[min_heap[smallest][0] - 1][1] = index\n min_heap[smallest], min_heap[index] = min_heap[index], min_heap[smallest]\n heapify(min_heap, hash_table, smallest)\n end\nend",
"def heapsort(list)\n heap = MinHeap.new()\n list.each do |num|\n heap.add(num)\n end\n res = []\n list.length.times do \n res << heap.remove()\n end\n return res\nend",
"def build_heap(array)\n first_parent_idx = (array.length - 1) / 2\n (first_parent_idx).downto(0).each { |current_idx| \n self.sift_down(current_idx, array.length - 1, array)\n }\n return array\n end",
"def build_maxheap\n\t\ti = @heap.length/2\n\t\twhile i >= 0\n\t\t\tn_heapify(@max, i)\n\t\t\ti -= 1\n\t\tend\n\tend",
"def heap_sort(list)\n #add elements to a heap\n #remove elements from heap one-by one, placing them in order\n sort_heap = MinHeap.new\n sorted = []\n list.each{|element| sort_heap.add(element)}\n list.length.times{|i| sorted.push(sort_heap.remove)}\n return sorted\nend",
"def heapsort(list)\n new_heap = MinHeap.new\n return list if list.nil? || list.length == 1\n\n until list.empty?\n new_heap.add(list.pop)\n end\n\n index = 0\n until new_heap.empty?\n list[index] = new_heap.remove()\n index += 1\n end\n\n \n return list\n \n\nend",
"def heapsort(list)\n return list if list.length <= 1\n\n heap = MinHeap.new\n list.each do |e|\n heap.add(e)\n end\n \n result = heap.store.map! { |e| e = e.value }\n\n return result\nend",
"def heap_sort(list)\n return list if list == []\n \n heap = MinHeap.new()\n new_array = []\n \n until list.empty?\n removed = list.pop\n heap.add(removed)\n end\n \n until heap.empty?\n new_addition = heap.remove\n new_array << new_addition\n end\n \n return new_array\nend",
"def create_max_heap\n (0..@heap_size/2-1).to_a.reverse.each do |indx|\n fix_one_error(indx)\n end\n end",
"def create_max_heap(unsorted_array)\r\n (unsorted_array.length / 2).downto(1) do |node_num|\r\n fix_max_heap(node_num, unsorted_array)\r\n end\r\nend",
"def heapsort(list)\n return list if list.length < 2\n\n heap = MinHeap.new\n\n i = 0\n list.each do\n heap.add(list[i])\n i += 1\n end\n\n i = 0\n until i == list.length\n list[i] = heap.remove\n i += 1\n end\n\n return list\nend",
"def heapsort(list)\n return list if list.length <= 1\n \n heap = MinHeap.new\n \n until list.empty?\n popped = list.pop\n heap.add(popped)\n end\n \n until heap.empty?\n list << heap.remove\n end\n \n return list\nend",
"def heapsort(list)\n return list if list.length < 2\n\n heap = MinHeap.new\n\n until list.empty?\n heap.add(list.pop)\n end\n\n until heap.empty?\n list << heap.remove\n end\n\n return list\nend",
"def min_heapify(idx)\n l = left(idx)\n r = right(idx)\n smaller = idx\n smaller = l if l <= @size && elem(l) < elem(idx)\n smaller = r if r <= @size && elem(r) < elem(smaller)\n swap(smaller, idx) if smaller != idx\n min_heapify(smaller) if smaller != idx\n end",
"def minheapify_heapsort(p, i = 0)\n\t\tn_heapify_heapsort(@min, p, i)\n\tend",
"def heapify(index)\n #Assume the left and right subroots are already valid heaps\n\n return if(leftChild(index)==nil && rightChild(index)==nil)\n\n if leftChild(index)!=nil && @store[index]<leftChild(index) then\n mini=index\n else\n mini=2*index\n end\n\n if rightChild(index)!=nil && @store[mini]>rightChild(index) then\n mini=2*index+1\n end\n\n if mini!=index then\n swap(index,mini)\n #call heapfiy recursively on minindex\n heapify(mini) \n end\n end",
"def heap_sort (list)\r\n sl = []\r\n heap = build_heap(list)\r\n heap.size.times do\r\n sl << heap.shift\r\n heap = heapify(heap, 0)\r\n end\r\n sl.reverse\r\nend",
"def construct_by_down_heap(ary)\n n = ary.size\n k = n/2 - 1\n k.downto(0).each do |k|\n down_heap(ary, k, n)\n end\nend",
"def getMin()\n element=@store[1]\n\n #copy last element to the first...\n @store[1]=@store[@store.length-1]\n @store.delete_at(@store.length-1) #delete the last element \n\n #We need to restore the Heap Structure if altered\n heapify(1)\n return element\n end",
"def heap_sort(arr)\n 2.upto(arr.length - 1).each do |heap_size|\n BinaryMinHeap.heapify_up(arr, heap_size - 1, heap_size)\n end\n\n arr.length.downto(2).each do |heap_size|\n arr[heap_size - 1], arr[0] = arr[0], arr[heap_size - 1]\n BinaryMinHeap.heapify_down(arr, 0, heap_size - 1)\n end\n\n arr.reverse\nend",
"def heap_sort(arr)\n (arr.length - 1).downto(1).each do |i|\n p \"i = #{i},arr[i] = #{arr[i]},arr[0] is #{arr[0]},arr = #{arr}\"\n # 打乱顺序\n # 然后上一轮的最小值\n # 就永远回不去顶端了\n # 因为 i 值不断缩小\n # 比较的范围越来越小\n arr[i], arr[0] = arr[0], arr[i]\n p \"---arr = #{arr}\"\n min_heap_fixdown(arr, 0, i)\n p \"===arr = #{arr}\"\n end\n arr\nend",
"def heap_sort(array) \n size = array.length\n #Adding an empty element at beginning of array to be the root\n root_array = [nil] + array \n \n i = size / 2 \n while i > 0 do\n heapify(root_array, i, size) \n i -= 1 \n end \n\n while size > 1 do\n root_array[1], root_array[size] = root_array[size], root_array[1] \n size -= 1 \n heapify(root_array, 1, size) \n end \n root_array.shift #getting rid of the initial nil\n root_array \nend",
"def remove_max\n\n if @max_heap.length == 1\n return @max_heap.pop\n end\n\n # Replace the first element with the last element\n last_node = @max_heap.pop\n max_node = @max_heap.shift\n @max_heap.unshift(last_node)\n\n parent_idx = 0\n\n # Sink down the current first node to its correct position\n while parent_idx < @max_heap.length\n left_child_idx = (parent_idx * 2) + 1\n right_child_idx = (parent_idx * 2) + 2\n\n # Compare the values if the right and left child are in the correct index\n swap = nil\n if left_child_idx < @max_heap.length\n swap = left_child_idx if @max_heap[left_child_idx] > @max_heap[parent_idx]\n end\n\n if right_child_idx < @max_heap.length\n if swap.nil? && @max_heap[right_child_idx] > @max_heap[parent_idx] || swap != nil? && @max_heap[right_child_idx] > @max_heap[left_child_idx]\n swap = right_child_idx\n end\n end\n\n break if swap.nil?\n\n @max_heap[parent_idx], @max_heap[swap] = @max_heap[swap], @max_heap[parent_idx]\n\n parent_idx = swap\n\n end\n\n max_node\nend",
"def max_heap_insert(key)\n\t\t@heap.push(-1)\n\t\theap_incease_key(@heap.length-1, key)\n\tend",
"def heapsort_inPlace(list)\n return list if list.length <= 1\n\n puts \"\\nSTARTING with #{list}\"\n\n # build a max heap\n list.length.times do |i|\n heap_up(list, i)\n puts \"\\tlist = #{list}\"\n end\n\n puts \"\\nREADY to pluck out Max and put start populating from end of list\"\n last = list.length - 1\n\n # pop off the top of the heap\n # place it in the last unsorted slot\n # re-heap the unsorted list\n list.length.times do |i|\n swap(list, 0, last)\n puts \"\\tpost swap,\\tlist = #{list}\"\n heap_down(list, 0, last)\n puts \"\\t\\t\\t adj = #{list}\"\n\n last -= 1\n end\n\n return list\nend",
"def heapsort(list)\n # raise NotImplementedError, \"Method not implemented yet...\"\n heap = MinHeap.new\n return list if list.nil? || list.length == 1\n\n until list.empty?\n heap.add(list.pop)\n end\n sorted_list = []\n list.length.times do \n sorted_list << heap.remove\n end\n return sorted_list\nend",
"def heapify\n for i in (0..(@ary.size-1)).to_a.reverse\n upheap(i)\n downheap(i)\n end\n end",
"def union(heap_x, heap_y)\n return heap_y if !heap_x.root_head\n return heap_x if !heap_y.root_head\n\n y_head = heap_y.root_head\n heap_x.root_tail.r = y_head\n y_head.l = heap_x.root_tail\n heap_x.root_tail = heap_y.root_tail\n heap_x.min = heap_y.min if heap_x.min.key > heap_y.min.key\n heap_x.size = heap_x.size + heap_y.size \n return heap_x \n end",
"def k_largest_elements2(array, k) \n result = BinaryMinHeap.new\n k.times do\n result.push(array.pop)\n end\n until array.empty?\n result.push(array.pop)\n result.extract\n end\n result.store\nend",
"def mk_tree(ch_arr)\n\t# set up top node based on smallest 2 values\n\ttop = Node.new # initial top node; no values yet\n\tmins = min_vals(ch_arr, 2)\n\tputs mins[0], mins[1]\n\tputs ch_arr[mins[0]]\n\tputs ch_arr[mins[1]]\n\ttop.set_left(Node.new(ch_arr[mins[0]], mins[0]))\n\ttop.set_right(Node.new(ch_arr[mins[1]], mins[1]))\n\ttop.set_count(ch_arr[mins[0]] + ch_arr[mins[1]])\n\tch_arr.delete(mins[0])\n\tch_arr.delete(mins[1])\n\t# build tree based upon current top node and next smallest value; repeat until no values left in hash\n\twhile(ch_arr.length >= 1)\n\t\ttemp = Node.new # temporary new node; this will become the top node\n\t\tmin = min_vals(ch_arr, 1)\n\t\tputs min\n\t\tputs ch_arr[min]\n\t\t# if top node's value is less than lowest number, put it on left; otherwise, put it on right\n\t\t#puts top.get_count, ch_arr[min]\n\t\tif(top.get_count <= ch_arr[min])\n\t\t\ttemp.set_left(top)\n\t\t\ttemp.set_right(Node.new(ch_arr[min], min))\n\t\telse\n\t\t\ttemp.set_left(Node.new(ch_arr[min], min))\n\t\t\ttemp.set_right(top)\n\t\tend\n\t\ttemp.set_count(ch_arr[min] + top.get_count)\n\t\ttop = temp\n\t\tch_arr.delete(min)\n\tend\n\t# return reference to top node\n\treturn top\nend",
"def heapify(queue)\n (queue.length - 1).downto(1) do |i|\n if queue[i].value > queue[i-1].value\n queue[i], queue[i-1] = queue[i-1], queue[i]\n else\n break\n end\n end\n end",
"def heap_sort(list)\n return [] if list.empty?\n\n heap = MinHeap.new\n list.each do |item|\n heap.add(item)\n end\n\n array = []\n heap_to_array(heap, array)\n\n return array\nend",
"def sort\n\n arr_len = @data.length\n start_build_idx = arr_len / 2 - 1 # The last half of the array is just leaves\n\n for i in (start_build_idx).downto(0)\n\n max_heapify(@data, arr_len, i) # Build the heap from the array\n end\n\n for i in (arr_len-1).downto(0)\n\n swap(@data, i, 0) # Move the current root to the end of the array\n max_heapify(@data, i, 0) # Heapify the remaining part of the array excluding the root which was just sorted to the end\n end\n\n puts(@data)\n end",
"def remove_max\n return nil if heap.empty?\n deleted = @heap.delete_at 0\n last_one = @heap.pop\n if last_one #ei ole false tai nil\n @heap.insert 0, last_one\n heapify_down 0\n end\n deleted\n end",
"def heap_sort!(data)\n h = Heap.new\n while data.any?\n h << data.pop\n end\n\n while h.any?\n data << h.pop\n end\n\n return data\nend",
"def buildMaxHeap(start = (@heapsize/2-1),finish = 0)\r\n\t\t#why count down and not up? (count up would be like 7 + 5 +3 +2 +1, up would be like 1 + 1 +2 +1 + 2 ? )\r\n\t\t(start).downto(finish) do |index|\r\n\t\t\tmaxHeapify(index)\r\n\t\tend\r\n\tend",
"def get_heap\n @heap\n end",
"def initialize(&block)\n # We default to a priority queue that returns the largest value\n block ||= lambda { |x, y| (x <=> y) == 1 }\n @heap = Containers::Heap.new(&block)\n end",
"def remove_top\n return raise EMPTY_HEAP_EXCEPTION if @root.nil?\n\n new_root = remove_node\n value = @root.value\n if root?(new_root)\n @root = nil\n @size = 0\n return value\n end\n if relationship(new_root.parent, new_root) == BinaryNodeRelationship::LEFT_CHILD\n new_root.parent.left = nil\n else\n new_root.parent.right = nil\n end\n new_root.parent = nil\n new_root.left = @root.left\n new_root.right = @root.right\n\n current = new_root\n did_swap = false\n until leaf?(current)\n # Because of the insertion strategy,\n # it is impossible for the left child to not exist if the current is not a leaf.\n left_priority = priority(current.left, current)\n right_priority = current.right.nil? ? nil : priority(current.right, current)\n\n if right_priority.nil? # There is only a left child.\n break unless left_priority.negative?\n\n swap(current, current.left)\n else # Both children exist.\n # Node is in the correct position.\n break if priority(current, current.left).negative? && priority(current, current.right).negative?\n\n # Otherwise, keep bubbling.\n left_right_priority = priority(current.left, current.right)\n # Bubble towards the smaller priority.\n swap(current, left_right_priority.negative? ? current.left : current.right)\n end\n did_swap = true\n end\n # New root was immediately placed in the correct position, swap pointers manually.\n # This can only occur when deleting from a heap of size 3 (resulting in size 2).\n unless did_swap\n @root = new_root\n @root.parent = nil\n # No need to check the right child, since it cannot exist in a heap of size 3.\n @root.left.parent = @root unless @root.left.nil?\n end\n @size -= 1\n value\n end",
"def heapify(node)\n parent = node.parent\n left_child = parent.left\n right_child = parent.right\n until node.rating > parent.rating\n if ![left_child, right_child].include?(nil)\n if left_child.rating < right_child.rating\n swap_node(parent, left_child)\n else\n swap_node(parent, right_child)\n end\n else\n swap_node(parent, right_child) if left_child.nil?\n swap_node(parent, left_child) if right_child.nil?\n end\n heapify(parent) unless parent.id == 1\n end\n end",
"def heapify_down\n # Swap the current_node (starting with root) with its smallest child until it's smaller than both of its children\n previous_current_node = nil\n current_node = 0\n # When the current_node is not changing, then it has swapped as many times as it can\n until previous_current_node == current_node\n previous_current_node = current_node\n right_child = right_child_node current_node\n left_child = left_child_node current_node\n\n # Bounds check for when current_node is one of the last two nodes\n # Or if there are only two nodes total\n if right_child >= @nodes.size\n # Correctly order nodes if there are only two nodes\n if @nodes.size == 2 && @nodes[left_child] < @nodes[current_node]\n @nodes[current_node], @nodes[left_child] = @nodes[left_child], @nodes[current_node] \n end\n break\n end\n\n # If current_node is greater than either of its children\n if @nodes[current_node] > @nodes[left_child] || @nodes[current_node] > @nodes[right_child]\n # Swap with the smallest child\n if @nodes[left_child] <= @nodes[right_child]\n @nodes[current_node], @nodes[left_child] = @nodes[left_child], @nodes[current_node]\n current_node = left_child\n else\n @nodes[current_node], @nodes[right_child] = @nodes[right_child], @nodes[current_node]\n current_node = right_child\n end\n end\n end\n end",
"def push(val)\n @store << val\n idx = count - 1\n @store = BinaryMinHeap.heapify_up(@store, idx, &prc)\n end",
"def sort_heaped_list(list)\n last_pos = list.length - 1\n while last_pos > 0\n remove_max(list, last_pos)\n last_pos -= 1\n end\nend",
"def prims(graph)\n start = graph.getVertex # assume returns arbitrary vertex in graph\n pq = PriorityQueue.new\n pq.enqueue(0, start)\n start.set_status(2)\n start.set_parent(nil)\n mst = Graph.new\n \n while (!pq.empty?)\n current = pq.dequeue\n current.set_status(2)\n mst.add_vertex(current)\n mst.add_edge(current, current.parent) if !current.parent.nil?\n current.getNeighbours.each do |neighbour|\n if (neighbour.get_status == 0)\n # found new unseen vertex\n neighbour.set_status(1)\n neighbour.set_parent(current)\n pq.enqueue(current.neighbours[neighbour], neighbour)\n elsif (neighbour.get_status == 1)\n # encountered previously seen fringe vertex\n current_edge_weight = pg.get_priority(neighbour)\n new_edge_weight = current.neighbours[neighbour]\n if (new_edge_weight < current_edge_weight)\n # found smaller weight edge, so update\n neighbour.set_parent(current)\n pq.update_priority(new_edge_weight, current)\n end\n# current_weight = neighbour.get_pqweight\n# if (current.neighbours[neighbour] < current_weight)\n # found smaller weight edge, so update\n# end\n end\n end\n end\n return mst\nend",
"def heapify(index)\n left = @tree[left(index)]\n right = @tree[right(index)]\n current = @tree[index]\n if !left && !right # if no children exist nothing to compare with\n nil\n elsif left && !right\n if left.rating < current.rating\n temp = @tree[index]\n @tree[index] = @tree[left]\n @tree[left] = temp\n #no need to heapify at a leaf\n end\n elsif left.rating < current.rating || right.rating < current.rating\n if @tree[left].rating <= @tree[right].rating\n temp = @tree[index] #current index and left swap if it's the smaller of two children\n @tree[index] = @tree[left]\n @tree[left] = temp\n heapify(left(index))\n elsif @tree[right].rating < @tree[left].rating\n temp = @tree[index] #current index and left swap if it's the smaller of two children\n @tree[index] = @tree[right]\n @tree[right] = temp\n heapify(right(index))\n end\n end\n end",
"def remove()\n return nil if empty? \n swap(0, @store.length - 1) # swap last element with root, O(n) to calc length\n old_top = @store.pop() # remove former root with O(1) time\n\n heap_down(0) unless empty?# bubble down new top element so lowest element in 0 index\n\n return old_top.value # return old min's value\n end",
"def heap_sort(list)\n length = list.length \n build_max_heap(list)\n\n last_el = length - 1\n while last_el > 0 do \n swap(list, 0, last_el)\n heapify(list, last_el, 0)\n last_el -= 1\n end \n\n return list\nend",
"def heapsort(list)\n heapify(list, parent(list.length - 1)) if list.length > 1\n sort_heaped_list(list)\n return list\nend",
"def heapify(num)\n left = num * 2\n right = num * 2 + 1\n\n if left <= @heapSize && @heap[left] > @heap[num]\n largest = left\n else\n largest = num\n end\n\n if right <= @heapSize && @heap[right] > @heap[largest]\n largest = right\n end\n\n if(largest != num)\n tmp = @heap[num]\n @heap[num] = @heap[largest]\n @heap[largest] = tmp\n heapify(largest)\n end\n end",
"def heap_up(index)\n return if index == 0\n parent = (index - 1 ) / 2\n # Compare the new node with it's parent\n # If they are out of order swap and heap-up\n if @store[parent].key > @store[index].key\n #swap\n swap(index, parent)\n #continue heap-up\n heap_up(parent)\n end\n \n end",
"def heapify(key = 0)\n # Assume left and right children follow heap property\n value = get(key)\n return if value == nil\n\n larger_child_key = larger_child(key)\n larger_value = get(larger_child_key)\n\n if larger_value != nil && larger_value > value\n @data[key] = @data[larger_child_key]\n @data[larger_child_key] = key\n heapify(larger_child_key)\n end\n end",
"def max_heapify(index)\n if self.left_i(index) > (self.size - 1) && self.right_i(index) > (self.size - 1)\n self.max_heapify_bottom_up(index)\n else\n self.max_heapify_top_down(index)\n end\n end",
"def breadth_first\n return do_breadth_first( [Node.new(@start)], Set.new, @dest)\n end",
"def insert!(key)\n if self.min == nil\n @root_head = FibonacciNode.new key\n @min = @root_head\n @root_tail = @root_head\n else\n new_node = FibonacciNode.new key\n @root_tail = get_root_tail\n @root_tail.r = new_node\n new_node.l = @root_tail\n @root_tail = new_node\n self.min = new_node if min.key > new_node.key\n end\n @size += 1 \n end",
"def mm_upheap(j, upper)\n while true\n return if j <= 0\n i = (j-1) >> 1\n return if upper.call(i, j)\n swap(j, i)\n j = i\n end\n end",
"def heapify_up\n # Swap the current_node (starting with last child) with it's parent if it is smaller\n previous_current_node = nil\n current_node = @nodes.size - 1\n # When the current_node is not changing, then it has swapped as many times as it can\n until previous_current_node == current_node\n previous_current_node = current_node\n parent_node = parent(current_node)\n \n # Bounds check for when the current_node is the root\n break if current_node.zero? \n\n # Swap with the parent if the parent is bigger\n if @nodes[current_node] < @nodes[parent_node]\n @nodes[current_node], @nodes[parent_node] = @nodes[parent_node], @nodes[current_node]\n current_node = parent_node\n end\n end\n end",
"def max_heapify_bottom_up(index)\n if parent_i(index) && self[parent_i(index)] < self[index] \n self.swap(parent_i(index), index)\n max_heapify_bottom_up(parent_i(index))\n end\n end",
"def heapify!\n (length / 2).downto(1) { |i| sink(i) }\n end",
"def up_heap(ary, k)\n p = (k - 1)/2\n down = ary[k]\n while (k-1)/2 >= 0 and ary[(k-1)/2] < down\n ary[k] = ary[(k-1)/2]\n k = (k-1).abs/2\n break if k == 0 \n end\n ary[k] = down\nend",
"def heapify(i)\n left = left(i)\n right = right(i)\n target = i\n if left < @elements.size and @comparator.call(@elements[i],@elements[left]) < 0\n target = left\n end\n if right < @elements.size and @comparator.call(@elements[target],@elements[right]) < 0\n target = right\n end\n\n unless target == i\n swap(target,i)\n heapify(target)\n end\n end",
"def heapsort(array)\r\n\t#create a heap from an array\r\n\theap = MaxHeap.new(array)\r\n\theap.buildMaxHeap\r\n\t\r\n\t#puts heap.array\r\n\t#puts \"_____\"\r\n\t#puts \"array size = #{heap.arraysize}\"\r\n\t\r\n\t(heap.arraysize).downto(2) do |i|\r\n\t\t#exchange of largest data point with end of the array\r\n\t\ttemp = heap.array[0]\r\n\t\theap.array[0] = heap.array[i-1]\r\n\t\theap.array[i-1] = temp\r\n\t\t\r\n\t\t#decrement size of the heap so that the last value stays in the array, but does not get sorted\r\n\t\theap.heapsize -=1\r\n\t\theap.maxHeapify(0)\r\n\t\t#puts \"**____**\"\r\n\t\t#puts \"i is equal to #{i}\"\r\n\t\r\n\t\t#puts heap.array\r\n\t\t#puts \"**_~~_**\"\r\n\tend\r\n\tputs heap.array\r\nend",
"def heapify(array, heap_size, index)\n return if index >= heap_size\n\n l = index * 2 + 1\n r = index * 2 + 2\n\n largest = index\n\n largest = l if l < heap_size && array[l] > array[largest]\n largest = r if r < heap_size && array[r] > array[largest]\n\n if largest != index\n swap(array, index, largest)\n\n # propogate change on subtree\n heapify(array, heap_size, largest)\n end\n\n array\nend",
"def child_index_left index\n [@d * index + 1, @heap.length-1].min\n end",
"def heap_down(index)\n left_index = index * 2 + 1\n right_index = index * 2 + 2\n\n if right_index < @store.length\n min_child = @store[left_index].key < @store[right_index].key ? left_index : right_index\n if @store[index].key > @store[min_child].key\n swap(index, min_child)\n heap_down(min_child)\n end\n elsif left_index < @store.length\n if @store[index].key > @store[left_index].key\n swap(index, left_index)\n end\n end\n end",
"def min\n return nil if @root.nil?\n n = @root\n while n.left\n n = n.left\n end\n splay(n.key)\n return [n.key, n.value]\n end",
"def heap_up(index)\n parent_index = (index - 1) / 2\n\n unless @store[parent_index].key < @store[index].key || index <= 0 \n swap(parent_index, index)\n heap_up(parent_index)\n end\n end",
"def heapify!(array)\n @data = array\n (0..(@data.size / 2 - 1)).to_a.reverse.each { |i| percolate_down i }\n return self\n end",
"def minheap?\n\t\theaptype(@min, @heap)\n\tend",
"def heap_down(parentIndex)\n # compare node @ parentIndex to its children\n # if parent <= both children, min heap :-) base case\n # if parent > either/both child, swap places with the smaller child, then min_heap_down(childIndex), recursion!\n # when no more children to compare to, base case :-)\n \n # first find out if parent has LC or RC\n indexLC = parentIndex * 2 + 1 \n indexRC = indexLC + 1\n \n if @store.length > indexRC\n # both LC & RC exist, need to compare with both children\n if (@store[parentIndex].key > @store[indexLC].key) && (@store[parentIndex].key > @store[indexRC].key)\n # both LC & RC broke the heap property, which one is smaller?\n @store[indexLC].key > @store[indexRC].key ? (indexOfSmallerChild = indexRC) : (indexOfSmallerChild = indexLC)\n swap(parentIndex, indexOfSmallerChild)\n heap_down(indexOfSmallerChild)\n \n elsif @store[parentIndex].key > @store[indexLC].key\n # only LC broke the heap property\n swap(parentIndex, indexLC)\n heap_down(indexLC)\n \n elsif @store[parentIndex].key > @store[indexRC].key\n # only RC broke the heap property\n swap(parentIndex, indexRC)\n heap_down(indexRC)\n \n else \n # both children are bigger than parent -> min heap :-) base case\n return\n end\n \n elsif @store.length > indexLC\n # only LC exists\n if @store[parentIndex].key <= @store[indexLC].key\n # min heap :-) base case\n return \n else\n swap(parentIndex, indexLC)\n heap_down(indexLC)\n end\n \n else\n # no children, base case\n return\n end\n end",
"def push(x)\n @stack.push(x)\n @min_stack.push(x) if @min_stack.empty? || @min_stack[-1] >= x\n end",
"def heap!(list)\n\t\tlen = list.length-1\n\t\t#heapify\n\t\t((len)/2).downto(0) { |b| heapify(list, b, list.length-1) }\n\n\t\t(len).downto(1) do |e|\n\t\t\tlist[0], list[e] = list[e], list[0]\n\t\t\theapify(list, 0, e-1)\n\t\tend\n\tend",
"def heap_up(index)\n until index == 0 || @store[index].key >= @store[((index - 1) / 2)].key\n parent = (index - 1) / 2\n swap(parent, index) if @store[parent].key > @store[index].key\n index = parent\n end\n end",
"def heap_sort2(a)\r\n size = a.length\r\n temp = 0\r\n i = (size/2)-1\r\n\r\n while i >= 0\r\n sift_down(a,i,size)\r\n i-=1\r\n end\r\n\r\n i=size-1\r\n while i >= 1\r\n a[0], a[1] = a[1], a[0]\r\n sift_down(a, 0, i-1)\r\n i-=1\r\n end\r\n return a\r\nend",
"def heapify(index)\n item = @items[index]\n parent = parent(index)\n left_child = left_child(index)\n right_child = right_child(index)\n if (parent && parent.attrib > item.attrib)\n swap(parent.index, index)\n elsif (left_child && right_child && left_child.attrib < item.attrib &&\n right_child.attrib < item.attrib)\n if (left_child.attrib < right_child.attrib)\n swap(index, left_child.index)\n else\n swap(index, right_child.index)\n end\n elsif (left_child && left_child.attrib < item.attrib)\n swap(index, left_child.index)\n elsif (right_child && right_child.attrib < item.attrib)\n swap(index, right_child.index)\n end\n end",
"def heapify(list, sub_root, counter = 0)\n max_child = max_child(right_child(sub_root, list.length), left_child(sub_root, list.length), list)\n if max_child && list[max_child] > list[sub_root]\n swap(max_child, sub_root, list)\n heapify(list, max_child, counter + 1)\n elsif max_child\n heapify(list, sub_root - 1, counter + 1)\n end \n return \nend",
"def fixBTree( node, index)\n # If the left sibling has more than min keys.\n if (index != 0 && node.arr[index - 1].n > self.min)\n self.borrowFromLeft(node, index)\n elsif (index != node.n && node.arr[index + 1].n > self.min)\n self.borrowFromRight(node, index)\n else\n if (index != node.n)\n self.merge(node, index)\n else\n self.merge(node, index - 1)\n end\n end\n end"
] |
[
"0.8019722",
"0.69423044",
"0.679937",
"0.67993397",
"0.6789338",
"0.673547",
"0.664021",
"0.6619815",
"0.65664506",
"0.6561262",
"0.6552848",
"0.6548553",
"0.65336025",
"0.65301573",
"0.6496905",
"0.6485607",
"0.648445",
"0.6480424",
"0.6470397",
"0.6465959",
"0.64640635",
"0.6459648",
"0.64591885",
"0.64554673",
"0.6441668",
"0.6437698",
"0.6425671",
"0.64211506",
"0.64166707",
"0.638245",
"0.6349864",
"0.634864",
"0.6343083",
"0.6329006",
"0.6323063",
"0.63172954",
"0.6314256",
"0.6300252",
"0.6299606",
"0.6289304",
"0.6272542",
"0.6262934",
"0.62363905",
"0.6226202",
"0.6195614",
"0.616933",
"0.61568385",
"0.6142401",
"0.6135298",
"0.6131319",
"0.61120045",
"0.6052175",
"0.60500735",
"0.6025112",
"0.6024991",
"0.6018907",
"0.59595454",
"0.59145236",
"0.59004974",
"0.5891586",
"0.5875775",
"0.5870195",
"0.5848991",
"0.5837995",
"0.5837287",
"0.58241254",
"0.5804685",
"0.5802895",
"0.5783765",
"0.57315737",
"0.57139915",
"0.57120407",
"0.57103753",
"0.5692328",
"0.56910497",
"0.56794715",
"0.567897",
"0.56590855",
"0.56528914",
"0.5650028",
"0.56367004",
"0.56353074",
"0.5631651",
"0.56260866",
"0.5624366",
"0.56214327",
"0.5618735",
"0.5610724",
"0.5606461",
"0.55958545",
"0.55957896",
"0.558706",
"0.557431",
"0.5566562",
"0.5562551",
"0.5562408",
"0.5561654",
"0.55611664",
"0.5557976",
"0.5540549"
] |
0.6629703
|
7
|
ensure all queues remain filled until the generators are done generating and and the output queue has been emmptied
|
def fill_queues
while @thread_queues.any?(&:empty?) && (@running || !@output_queue.empty?)
el = @output_queue.shift
@thread_queues[el[:thread]] << el if el
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def flusher_loop\n loop do\n # Blocks waiting for the flusher to be kicked...\n @flush_queue.pop\n\n should_bail = synchronize do\n @status != CONNECTED || @status == CONNECTING\n end\n return if should_bail\n\n # Skip in case nothing remains pending already.\n next if @pending_queue.empty?\n\n # FIXME: should limit how many commands to take at once\n # since producers could be adding as many as possible\n # until reaching the max pending queue size.\n cmds = []\n cmds << @pending_queue.pop until @pending_queue.empty?\n begin\n @io.write(cmds.join) unless cmds.empty?\n rescue => e\n synchronize do\n @last_err = e\n @err_cb.call(e) if @err_cb\n end\n\n process_op_error(e)\n return\n end if @io\n\n synchronize do\n @pending_size = 0\n end\n end\n end",
"def flush\n Thread.exclusive do\n while !output_queue.empty? do\n write_message(output_queue.pop)\n end\n end\n end",
"def flush\n while !@queue.empty? || @consumer.is_requesting?\n sleep(0.1)\n end\n end",
"def flush(queue)\n sizeof(queue).times do\n v = get(queue)\n yield v if block_given?\n end\n end",
"def flush; queue.close end",
"def complete_order\n @queue.dequeue\n end",
"def queue\n @queue ||= produce_queue\n end",
"def flush\n until @work_queue.empty? && @requests.zero?\n @main_queue.drain!\n sleep 0.1\n end\n end",
"def flush\n while !@queue.empty? || @worker.is_requesting?\n ensure_worker_running\n sleep(0.1)\n end\n end",
"def flush\n @queue.clear\n end",
"def reset!\n @queue = []\n @consumers = []\n end",
"def flush\n while !@queue.empty? || @worker.is_requesting?\n ensure_worker_running\n sleep(0.1)\n end\n end",
"def do_work\n until @worker_input_queue.empty?\n @output_queue << yield(@worker_input_queue.pop)\n end\n end",
"def clear\n @gate.synchronize do\n @queue = []\n @has_faulted = true\n end\n end",
"def empty\n @queue1.empty? && @queue2.empty?\n end",
"def _process_queue\n [@queue.length, @max_minifiers - @working_minifiers.length].min.times {\n _spawn_minifier\n }\n end",
"def clear\n queue.clear\n end",
"def flushQueue() \n done=0\n while (!@data.empty?) do\n done=done+1\n @sender_plugin.send_data(@data.pop)\n end\n @@log.info \"Flushed \"+done.to_s\n end",
"def process_queue\n logger.debug(\"process queue: enter\")\n loop_again = true\n while loop_again\n loop_again = false\n\n # We try to find the next proposal to commit.\n # Remove list contains proposals that were either deleted\n # or should be re-queued?\n # Proposals which reference non-ready nodes are also skipped.\n proposal_to_commit = nil\n begin\n lock = acquire_lock(\"queue\")\n\n queued_proposals = ProposalQueue.ordered.all\n\n if queued_proposals.empty?\n logger.debug(\"process queue: exit: empty queue\")\n return\n end\n\n logger.debug(\"process queue: queue: #{queued_proposals.inspect}\")\n\n # Test for ready\n remove_list = []\n queued_proposals.each do |item|\n prop = Proposal.where(barclamp: item.barclamp, name: item.name).first\n\n if prop.nil?\n remove_list << { barclamp: item.barclamp, inst: item.name }\n next\n end\n\n next unless dependencies_satisfied?(item.properties[\"deps\"])\n\n nodes_map, pre_cached_nodes = elements_to_nodes_to_roles_map(\n prop[\"deployment\"][item.barclamp][\"elements\"],\n prop[\"deployment\"][item.barclamp][\"element_order\"]\n )\n delay, = elements_not_ready(nodes_map.keys, pre_cached_nodes)\n proposal_to_commit = { barclamp: item.barclamp, inst: item.name } if delay.empty?\n end\n\n # Update the queue. Drop all proposals that we can process now (list) and those\n # that are deleted (remove_list). This leaves in the queue only proposals\n # which are still waiting for nodes (delay not empty), or for which deps are not\n # ready/created/deployed (queue_me = true).\n remove_list.each do |iii|\n dequeue_proposal_no_lock(iii[:barclamp], iii[:inst])\n end\n\n dequeue_proposal_no_lock(\n proposal_to_commit[:barclamp],\n proposal_to_commit[:inst]\n ) if proposal_to_commit\n rescue StandardError => e\n logger.error(\"Error processing queue: #{e.message} #{e.backtrace.join(\"\\n\")}\")\n logger.debug(\"process queue: exit: error\")\n return\n ensure\n lock.release if lock\n end\n\n unless proposal_to_commit.nil?\n result = commit_proposal(proposal_to_commit[:barclamp], proposal_to_commit[:inst])\n\n # 202 means some nodes are not ready, bail out in that case\n # We're re-running the whole apply continuously, until there\n # are no items left in the queue.\n # We also ignore proposals who can't be committed due to some error\n # (4xx) with the proposal or some internal error (5xx).\n # FIXME: This is lame, because from the user perspective, we're still\n # applying the first barclamp, while this part was in fact already\n # completed and we're applying next item(s) in the queue.\n loop_again = result != 202 && result < 400\n end\n\n # For each ready item, apply it.\n logger.debug(\"process queue: loop again\") if loop_again\n end\n logger.debug(\"process queue: exit\")\n end",
"def queues\n register_classes\n register_bus\n sorted_queues\n end",
"def clear\n @queue.clear\n end",
"def queue; end",
"def queue; end",
"def ensure_order_and_write\n fill_queues\n unless @heap.empty?\n #extract the minimum element from the heap \n extracted_el = @heap.extract\n write_to_disk(extracted_el)\n #add the next element from the same thread to the heap\n from_queue = extracted_el[:thread]\n fill_queues\n next_el = @thread_queues[from_queue].shift\n if next_el\n @heap.push(next_el) \n end\n end\n end",
"def setup_queues\n logger.info 'setting up queues'\n vetted = @consumers.reject { |c| group_configured? && group_restricted?(c) }\n vetted.each do |c|\n setup_queue(c)\n end\n end",
"def flush\n return true unless block_given?\n yield\n ensure\n workers.values.each(&:flush)\n end",
"def empty()\n @queue.empty?\n end",
"def empty()\n @push_queue.empty? and @pop_queue.empty?\n end",
"def _q\n @queue||=[]\n end",
"def flush\n @queued = {}\n end",
"def flush_check\n flush if @item_array.size >= BATCH_SIZE\n end",
"def each_queue\n @cache.each do |queue|\n yield queue\n end\n end",
"def process_queue \n\t\twhile !@fiber_queue.empty? && @checked_out.size < @connections.size\n\t\t\tfiber = @fiber_queue.shift\n\t\t\t# What is really happening here?\n\t\t\t# we are resuming a fiber from within\n\t\t\t# another, should we call transfer instead?\n fiber.resume checkout_existing_connection\n\t\tend\n\tend",
"def refresh\n add_queue = nil\n delete_queue = nil\n \n @queues_mutex.synchronize do\n add_queue = Array.new(@add_queue)\n delete_queue = Array.new(@delete_queue)\n @add_queue.clear\n @delete_queue.clear\n end\n \n @monitor.synchronize do\n modified = ! add_queue.empty? || ! delete_queue.empty?\n delete_queue.each { |file| FileUtils.rm_f(file) }\n \n add_queue.each do |package, dest_path|\n package.lock do\n FileUtils.mkdir_p(File.dirname(dest_path))\n FileUtils.mv(package.file, dest_path, :force => true)\n package.update(:file => dest_path)\n end\n end\n yield(modified)\n end\n end",
"def pour_out\n @queue.deq\n end",
"def queue(*queues)\n end",
"def handle_queue_clear(args)\n @queue = [[]]\n end",
"def flush!\n # Check for finished jobs\n @jobs_running.select! do |job|\n r = (job[:ds].nil? ? project : job[:ds]).add_result(job[:job], false)\n say \"Completed pid:#{job[:pid]} for #{job[:task_name]}.\" unless r.nil?\n r.nil?\n end\n # Avoid single datasets hogging resources\n @jobs_to_run.rotate! rand(jobs_to_run.size)\n # Launch as many +jobs_to_run+ as possible\n while jobs_running.size < maxjobs\n break if jobs_to_run.empty?\n launch_job @jobs_to_run.shift\n end\n end",
"def clear_data\n self.mutex.synchronize do\n self.seq = 0\n self.beg = 0\n self.cur = 0\n self.queue = Array.new( self.size )\n end\n end",
"def test_three\n print \"Test three (enqueue batch of messages): \"\n msg_ary = (1..14).map{|i| i.to_s}\n EZQ.enqueue_batch(msg_ary,[{'EZQ'=>nil}],'test_queue')\n q = EZQ.get_queue('test_queue')\n 14.times do\n q.receive_message do |msg|\n msg_ary -= [EZQ.strip_preamble(msg.body)]\n end\n end\n puts msg_ary\n if msg_ary.empty?\n puts 'pass'\n else\n puts 'fail'\n end\nend",
"def purge_queues\n [incoming_queue_url, outgoing_queue_url].each do |queue_url|\n while true\n messages = client.receive_message(queue_url: queue_url, max_number_of_messages: 10).messages\n break unless messages.first\n messages.each do |message|\n client.delete_message(queue_url: queue_url, receipt_handle: message.receipt_handle)\n end\n end\n end\n end",
"def drain\n # run the jobs in a separate thread so assumptions of synchronous\n # jobs are caught in test mode.\n consumer.drain\n end",
"def reset\n writeln('reset')\n clearQueue()\n end",
"def clear\n synchronize do\n @queue.clear\n end\n end",
"def clear\n synchronize do\n @queue.clear\n end\n end",
"def refill_all_queues!\n # Dla POST musi byc jakies 'body' requestu, bo serwery czesto rzucaja wyjatkami (WEBrick w szczegolnosci).\n post '/queues/refill_all', :body => ' '\n true\n end",
"def queue_full?\n free_slots == 0\n end",
"def clear\n @queue.clear\n true\n end",
"def flush()\n wakeup()\n @flows.each_value { |f| f.flush() }\n while busy?\n sleep(0.2)\n end\n end",
"def create_queues\n queue\n exchange\n end",
"def clear\n synchronize do\n @queue.clear\n end\n end",
"def is_full()\n @queue.count { _1 } == @queue.size\n end",
"def should_flush?\n (!queue.blank? && count >= size)\n end",
"def queue\n @queue ||= []\n end",
"def clear_queue_values\n @queue_values = {}\n end",
"def queues_cmd\n return @unique_queues.dup << TIMEOUT if @strictly_ordered_queues\n queues = @queues.sample(@unique_queues.size).uniq\n queues.concat(@unique_queues - queues)\n queues << TIMEOUT\n end",
"def setup_queues\n setup_identity_queue\n setup_shared_queue if @shared_queue\n true\n end",
"def test_orderOfElements\n @queue.enqueue(100)\n @queue.enqueue(200)\n assert_equal( 100, @queue.dequeue )\n assert_equal( 200, @queue.dequeue )\n end",
"def avail_out= size\n\t\tsize.times do \n\t\t\tif size > avail_out\n\t\t\t\t@output_buffer.push nil\n\t\t\telse\n\t\t\t\t@output_buffer.pop\n\t\t\tend\n\t\tend\n\tend",
"def each\n\t\tyield dequeue while @last != 0\n\tend",
"def flush\n messages_for_broker = {}\n\n @buffered_messages.each do |message|\n broker = @broker_pool.get_leader(message.topic, message.partition)\n\n messages_for_broker[broker] ||= []\n messages_for_broker[broker] << message\n end\n\n messages_for_broker.each do |broker, messages|\n @logger.info \"Sending #{messages.count} messages to broker #{broker}\"\n\n message_set = MessageSet.new(messages)\n\n response = broker.produce(\n messages_for_topics: message_set.to_h,\n required_acks: @required_acks,\n timeout: @timeout * 1000, # Kafka expects the timeout in milliseconds.\n )\n\n if response\n response.topics.each do |topic_info|\n topic_info.partitions.each do |partition_info|\n Protocol.handle_error(partition_info.error_code)\n end\n end\n end\n end\n\n @buffered_messages.clear\n\n nil\n end",
"def queues\n\t\t\t@queues ||= {}\n\t\tend",
"def process_queue\n\t\t\t\twhile !@connections.empty? and !@queue.empty?\n\t\t\t\t\tfiber = @queue.shift\n\t\t\t\t\t# What is really happening here?\n\t\t\t\t\t# we are resuming a fiber from within\n\t\t\t\t\t# another, should we call transfer insted?\n\t\t\t\t\tfiber.resume @busy_connections[fiber] = @connections.shift\n\t\t\t\tend\n\t\t\tend",
"def drain_queues(buy_orders, sell_orders, official_spread, order_filler)\n drain_with_price buy_orders[1], official_spread.last, order_filler \n drain_with_price sell_orders[1], official_spread.first, order_filler\n drain_with_limit_price buy_orders[0], official_spread.last, :<,\n order_filler \n drain_with_limit_price sell_orders[0], official_spread.first, :>,\n order_filler\n end",
"def all_done?\n return false if $producers.any?{|_thr| _thr.alive?}\n return false if $consumers.any?{|_proc| _proc.busy?}\n return true\nend",
"def each(&block)\n @queues.each(&block)\n end",
"def merge!\n\t\t\twhile handle = @queue.pop\n\t\t\t\tnext if handle.cancelled?\n\t\t\t\t\n\t\t\t\t@sequence.push(handle)\n\t\t\tend\n\t\tend",
"def send_commands_from_queue\n synchronize do\n return unless can_write?\n\n while @can_send > 0 && @send_queue.length > 0\n send_to_printer(@send_queue.pop)\n end\n end\n end",
"def eof?; queue.closed? && queue.empty? end",
"def step\n @queue.enq nil\n end",
"def flush_jobs\n queued_jobs&.each(&:call)&.clear\n end",
"def merge_queues(buy_orders, sell_orders, official_spread)\n trades = []\n order_filler = lambda do |queue, trade, price, quantity|\n fill_order queue, trade, price, quantity, trades\n end\n \n nil while merge_step buy_orders, sell_orders, official_spread, order_filler\n drain_queues buy_orders, sell_orders, official_spread, order_filler\n return trades\n end",
"def empty()\n @queue.size == 0\n end",
"def flush\n flushed_queue = nil\n @mutex.synchronize do\n flushed_queue = @queue.dup\n @queue.clear\n end\n return flushed_queue\n end",
"def dequeue_many\n number = multi.easy_handles.count\n until number == max_concurrency || queued_requests.empty?\n add(queued_requests.shift)\n number += 1\n end\n end",
"def redis_queues_cleanup!\n Gitlab::Redis::Queues.with(&:flushall)\n end",
"def clean\n clean_queued\n clean_running\n end",
"def is_full()\n @queue.size == @size\n end",
"def get_queues\n @gem_queue = get_queue 'gem'\n @md5_queue = get_queue 'md5'\n @sha512_queue = get_queue 'sha512'\n end",
"def drain\n begin\n grouped = @operations.group_by {|_, val| val.first }\n grouped.keys.sort.each do |priority|\n group = grouped[priority]\n MagLev.logger.info \"Draining queue priority #{priority} containing #{group.size} operations...\"\n MagLev::Try.new(group).each do |key, block|\n MagLev.logger.info \"Performing operation \\\"#{key}\\\"\"\n block.last.call\n end\n end\n ensure\n @operations = {}\n end\n end",
"def flush_async\n @last_async_flush = Time.now\n msgs = @msg_queue.flush\n return if msgs.empty?\n\n req = build_request(msgs)\n if !req.nil?\n Timber::Config.instance.debug { \"New request placed on queue\" }\n request_attempt = RequestAttempt.new(req)\n @request_queue.enq(request_attempt)\n end\n end",
"def clear\n LOCK.synchronize do\n @queue.each { |_, jes| jes.each(&:close) }\n @queue.clear\n end\n end",
"def deq(&proc)\n loop do\n batch = @out_queue.deq\n if batch == CLOSE_BATCH\n break\n end\n proc.call(batch)\n end\n end",
"def fill_queue\n if @queue.num_waiting > 0\n Thread.new do\n while @queue.num_waiting > 0 && (conn = try_make_new)\n @queue.push(conn)\n end\n end\n end\n end",
"def avail_out= size\n\t\t\tsize.times do\n\t\t\t\tif size > avail_out\n\t\t\t\t\t@output_buffer.push nil\n\t\t\t\telse\n\t\t\t\t\t@output_buffer.pop\n\t\t\t\tend\n\t\t\tend\n\t\tend",
"def queue(_); end",
"def queue(_); end",
"def empty?\n @queue.empty?\n end",
"def empty?\n @queue.empty?\n end",
"def empty?\n @queue.empty?\n end",
"def empty?\n @queue.empty?\n end",
"def empty?\n @queue.empty?\n end",
"def clear()\n @result = \"\"\n @queue.clear\n @pipeline.pause\n end",
"def writeloop\n while @running || !@wqueue.empty?\n s = @queue.pop\n write_(s)\n sleep(@conf['queue_delay'])\n end\n end",
"def flush\n # avoid flush cycles via the @flushing flag\n if @flushing.nil?\n @flushing = true\n local_flush\n @outputs.each {|o| o.flush}\n end\n @flushing = nil\n end",
"def clearQueue\n @itemList.clear()\n end",
"def doing_array\n consumer = Fiber.new do |producer, queue|\n #f = open(\"./lib/fiber_output.txt\", \"a\") do |f|\n #f = open(\"./lib/files_to_textual/fibering_files_output.txt\", \"a\") do |f|\n #f = open(\"./lib/databasers/fibered_files_output.txt\", \"a\") do |f|\n #f = open(\"./lib/databasers/fibered_files_output.txt\", \"a\") do |f| \n a = open(\"./lib/databasers/fibering_files_output.txt\", \"a\") do |f| \n loop do\n queue = producer.transfer(consumer, queue)\n #puts queue\n #puts \"queue : \" + \"#{queue}\"\n #puts queue\n #puts queue.to_s\n #puts queue.to_s.chomp\n #puts queue.to_s.strip\n #puts queue.to_s.strip.downcase\n #puts queue.to_s.strip.downcase.to_textual\n a << f << queue.to_s.chomp.to_textual\n queue.clear\n end\n raise StopIteration\n end\n end\n producer = Fiber.new do |consumer, queue|\n b = IO.readlines(\"./lib/databasers/fibered_files_input.txt\")\n #b = IO.readlines(file_name)\n #b = IO.readlines(ARGV)\n #b = IO.readlines(\"./lib/the_input.txt\")\n loop do\n while queue = b.shift\n consumer.transfer queue\n queue.clear\n end\n raise StopIteration\n end\n end\n consumer.transfer(producer, [])\n after_break\n end",
"def flush_queue()\n until @log_entries_queue.empty?\n self.send(@log_entries_queue.pop())\n sleep(SLEEP_TIME)\n end\n end",
"def de_queue\n unless is_empty\n @q[@tail] = nil\n @tail = (@tail + 1) % @size\n @openings += 1\n true\n else\n false\n end\n end",
"def clear()\n \t\t@result = \"\"\n \t\t@queue.clear\n \t\t#@pipeline.pause\n \tend"
] |
[
"0.6355712",
"0.624103",
"0.6221606",
"0.6195629",
"0.6195026",
"0.6186957",
"0.61763436",
"0.61226183",
"0.60938627",
"0.6083213",
"0.60723025",
"0.6056801",
"0.60308313",
"0.6007526",
"0.6001148",
"0.6000283",
"0.59885955",
"0.5984256",
"0.5965351",
"0.58838326",
"0.58790267",
"0.5876531",
"0.5876531",
"0.5812839",
"0.5802681",
"0.58020884",
"0.580187",
"0.5798876",
"0.5792715",
"0.579222",
"0.5777896",
"0.5776168",
"0.5775749",
"0.5773001",
"0.5767493",
"0.5762089",
"0.5755389",
"0.5753627",
"0.5752953",
"0.5744609",
"0.5742357",
"0.5736106",
"0.5727468",
"0.5722908",
"0.5722908",
"0.5711751",
"0.5707754",
"0.57038033",
"0.5691479",
"0.5686715",
"0.568594",
"0.5679747",
"0.56728464",
"0.56674004",
"0.5644396",
"0.5642343",
"0.5635592",
"0.5633815",
"0.5626985",
"0.56265944",
"0.56233245",
"0.5620174",
"0.5614687",
"0.5607824",
"0.5599754",
"0.5597789",
"0.55920154",
"0.558473",
"0.5573908",
"0.5568065",
"0.5559542",
"0.5556925",
"0.55448216",
"0.55446154",
"0.5535581",
"0.5532162",
"0.55260247",
"0.5524394",
"0.5517699",
"0.5515861",
"0.54978746",
"0.54926246",
"0.5490786",
"0.5480909",
"0.54736716",
"0.5472106",
"0.5472106",
"0.5470611",
"0.5470196",
"0.5470196",
"0.5470196",
"0.54691225",
"0.54685134",
"0.5467842",
"0.54655516",
"0.5457191",
"0.5451637",
"0.54507804",
"0.5442425",
"0.54379946"
] |
0.7514605
|
0
|
uses a minheap to ensure ordered data output before writing to disc
|
def ensure_order_and_write
fill_queues
unless @heap.empty?
#extract the minimum element from the heap
extracted_el = @heap.extract
write_to_disk(extracted_el)
#add the next element from the same thread to the heap
from_queue = extracted_el[:thread]
fill_queues
next_el = @thread_queues[from_queue].shift
if next_el
@heap.push(next_el)
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def build_minheap\n\t\ti = @heap.length/2\n\t\twhile i >= 0\n\t\t\tminheapify(i)\n\t\t\ti -= 1\n\t\tend\n\tend",
"def heapsort(list)\n array = []\n myHeap = MinHeap.new()\n #return myHeap.store\n list.each do |item|\n myHeap.add(item)\n puts item \n end\n\n until myHeap.empty?\n array << myHeap.remove()\n end\n return array\nend",
"def files_500(files)\n prc = Proc.new { |x, y| x[0] <=> y[0] }\n heap = BinaryMinHeap.new()\n result = []\n\n files.length.time do |i|\n heap.push([files[i][0], i, 0])\n end\n\n while heap.count > 0\n min = heap.extract\n result << min[0]\n\n next_arr_i = min[1]\n next_idx = min[2] + 1\n next_el = files[next_arr_i][next_idx]\n\n heap.push([next_el, next_arr_i, next_idx]) if next_el\n end\n result\nend",
"def heapsort(list)\n sorted_arr = []\n heap = MinHeap.new()\n list.each do |value|\n heap.add(value, value)\n end \n\nlist.length.times do |i|\n min = heap.remove()\n sorted_arr.push(min)\nend \nreturn sorted_arr\nend",
"def minheapify(i=0)\n\t\tn_heapify(@min, i)\n\t\t@heap\n\tend",
"def heapsort_NOT_REALLY_inPlace(list)\n puts \"\\n\\nSTARTING WITH list = #{list}\"\n \n heap = MinHeap.new()\n list.unshift(heap)\n # now list = [heap, e1, e2, e3, ...] but heap is empty\n # so far space is still O(1) no matter how big the arg list is\n \n \n # list[0] is the heap, and list[1..end] is the unsorted numbers\n # the heap will grow by adding in whatever is at list[1], which will get deleted as they get added to the heap\n # the heap at list[0] will grow while the unsorted numbers will shrink in size until they're gone\n while list[1]\n addThisToHeap = list[1]\n puts \"\\nadding new node: #{addThisToHeap}\"\n heap.add(addThisToHeap)\n puts \"\\theap at list[0] is now #{heap}\"\n \n list.delete_at(1)\n \n puts \"\\tlist[1] onwards is now #{list[1..-1]}\"\n end\n \n # now that list[0] is the heap and list[1] don't exist anymore...\n # start plucking out the roots from the MinHeap, and append it onto the end of list\n puts \"\\n------ Now start kicking out the root/min from heap and return it to end of list\"\n until heap.empty?\n kickOutOfHeap = heap.remove()\n list << kickOutOfHeap\n \n puts \"\\nKicking out #{kickOutOfHeap}\"\n puts \"\\theap at list[0] is now #{heap}\"\n puts \"\\tlist[1] onwards is now #{list[1..-1]}\"\n end\n \n # now get rid of the empty Heap at list[0], and all that's left should be the sorted numbers\n list.shift()\n \n return list\nend",
"def heapify(queue)\n (queue.length - 1).downto(1) do |i|\n if queue[i].value > queue[i-1].value\n queue[i], queue[i-1] = queue[i-1], queue[i]\n else\n break\n end\n end\n end",
"def heapsort()\n\t\tbuild_minheap()\n\t\ti = @heap.length-1\n\t\twhile i >= 1\n\t\t\ttemp = @heap[i]\n\t\t\t@heap[i] = @heap[0]\n\t\t\t@heap[0] = temp\n\t\t\tminheapify_heapsort(i)\n\t\t\ti -= 1\n\t\tend\n\t\t@heap\n\tend",
"def heapsort(list)\n heap = MinHeap.new\n sorted_list = []\n\n list.each do |item|\n heap.add(item)\n end\n\n list.length.times do \n sorted_list << heap.remove()\n end\n\n return sorted_list\nend",
"def heapsort(list)\n min_heap = MinHeap.new()\n list.each do |item|\n min_heap.add(item)\n end\n empty_arr = []\n\n list.length.times do\n empty_arr << min_heap.remove()\n end\n return empty_arr\nend",
"def heapsort(list)\n heap = MinHeap.new\n list.each do |number|\n # apply the .add instance method \n heap.add(number)\n end\n\n list.each_with_index do |number, index|\n list[index] = heap.remove()\n end \n return list\nend",
"def insert_into_min_heap(heap, element)\n heap << element\n current_index = heap.length\n\n while current_index > 1 && element < heap[(current_index / 2) - 1]\n larger_element = heap[(current_index / 2) - 1]\n\n heap[(current_index / 2) - 1] = element\n heap[current_index - 1] = larger_element\n\n current_index = (current_index / 2)\n end\n\n heap\nend",
"def minheapify_heapsort(p, i = 0)\n\t\tn_heapify_heapsort(@min, p, i)\n\tend",
"def setup_heap\n @heap = BinaryMinHeap.new\n @thread_queues.each do |queue|\n @heap.push(queue.shift)\n end\n end",
"def delete_key key\n # decrease that key to new minimum, and extract it out.\n decrease_key key, min.key - 1\n extract_min\n print_heap\n end",
"def five_hundred_files(arr_of_arrs)\n prc = Proc.new { |el1, el2| el1[0] <=> el2[0] }\n heap = BinaryMinHeap.new(&prc)\n result = []\n\n # populate with first elements\n arr_of_arrs.length.times do |i|\n heap.push([arr_of_arrs[i][0], i, 0])\n end\n\n # Extract the minimum element and use the meta-data to select the\n # next element \n while heap.count > 0\n min = heap.extract\n result << min[0]\n\n next_arr_i = min[1]\n next_idx = min[2] + 1\n next_el = arr_of_arrs[next_arr_i][next_idx]\n\n heap.push([next_el, next_arr_i, next_indx]) if next_el\n end\n result\nend",
"def heap_sort!(data)\n h = Heap.new\n while data.any?\n h << data.pop\n end\n\n while h.any?\n data << h.pop\n end\n\n return data\nend",
"def heap_sort(list)\n #add elements to a heap\n #remove elements from heap one-by one, placing them in order\n sort_heap = MinHeap.new\n sorted = []\n list.each{|element| sort_heap.add(element)}\n list.length.times{|i| sorted.push(sort_heap.remove)}\n return sorted\nend",
"def heapify!\n (length / 2).downto(1) { |i| sink(i) }\n end",
"def heap_sort(list)\n heap_sort = MinHeap.new()\n\n list.each do |number|\n heap_sort.add(number, number)\n end\n\n sorted = Array.new\n until heap_sort.empty?\n sorted << heap_sort.remove\n end\n\n return sorted\nend",
"def sort_heaped_list(list)\n last_pos = list.length - 1\n while last_pos > 0\n remove_max(list, last_pos)\n last_pos -= 1\n end\nend",
"def heap_sort(list)\n heap = MinHeap.new\n\n list.each do |int|\n heap.add(int)\n end\n\n i = 0 \n \n until i == list.length\n list[i] = heap.remove\n i += 1\n end\n\n return list;\nend",
"def heapsort(list)\n return list if list.length <= 1\n\n heap = MinHeap.new\n list.each do |e|\n heap.add(e)\n end\n \n result = heap.store.map! { |e| e = e.value }\n\n return result\nend",
"def heapsort(list)\n heap = MinHeap.new()\n list.each do |num|\n heap.add(num)\n end\n res = []\n list.length.times do \n res << heap.remove()\n end\n return res\nend",
"def max_heap_insert(key)\n\t\t@heap.push(-1)\n\t\theap_incease_key(@heap.length-1, key)\n\tend",
"def heapsort(list)\n min_heap = MinHeap.new()\n until list.empty?\n min_heap.add(list.pop)\n end\n\n while !min_heap.empty?\n list << min_heap.remove()\n end\n\n return list\nend",
"def heapsort(list)\n heap = MinHeap.new\n result = []\n \n list.each do |val|\n heap.add(val, val)\n end\n\n result << heap.remove until heap.empty?\n \n return result\nend",
"def heap_up(index)\n puts to_s\n parent_index = find_parent(index)\n if @store[parent_index].key <= @store[index].key || index == 0\n return\n end \n if @store[parent_index].key > @store[index].key\n # puts @store[index].value\n swap(parent_index, index)\n index = parent_index\n heap_up(index)\n end\n end",
"def sort\n\n arr_len = @data.length\n start_build_idx = arr_len / 2 - 1 # The last half of the array is just leaves\n\n for i in (start_build_idx).downto(0)\n\n max_heapify(@data, arr_len, i) # Build the heap from the array\n end\n\n for i in (arr_len-1).downto(0)\n\n swap(@data, i, 0) # Move the current root to the end of the array\n max_heapify(@data, i, 0) # Heapify the remaining part of the array excluding the root which was just sorted to the end\n end\n\n puts(@data)\n end",
"def extract_min\n extract_key = peek_min.key\n min_head = new_heap_from_children\n remove_min_from_heap\n\n # Union\n @head = union(self, BinomialHeap.new(min_head))\n h_next = head.sibling\n consolidate(head, h_next)\n # get new @min\n\n extract_key\n end",
"def heapsort(list)\n new_heap = MinHeap.new\n return list if list.nil? || list.length == 1\n\n until list.empty?\n new_heap.add(list.pop)\n end\n\n index = 0\n until new_heap.empty?\n list[index] = new_heap.remove()\n index += 1\n end\n\n \n return list\n \n\nend",
"def build_heap(array)\n first_parent_index = (array.length - 2) / 2\n (first_parent_index..0).each do |current_index|\n sift_down(current_index, array.length - 1, array)\n end\n end",
"def streaming_quicksort(file)\n # If the file is a meg or less in size, finish the sorting in memory\n if file.size < 1_048_576 \n puts \"in-memory quicksort #{file.size}\"\n\n sorted = quicksort(file.read.split(',').map { |x| x.to_i })\n file.close\n\n # Write to a file for merging\n Tempfile.new(\"sorted\").tap do |temp|\n temp << sorted.join(',')\n temp << ','\n temp.flush\n temp.open\n end\n else\n puts \"streaming quicksort #{file.size}\"\n\n # We are using the first number as the pivot\n pivot = next_number(file)\n\n equal = Tempfile.new(\"equal\")\n less = Tempfile.new(\"less\")\n greater = Tempfile.new(\"greater\")\n\n add_number(equal, pivot)\n\n # Split up the numbers\n while ((e = next_number(file)) != nil)\n add_number(less, e) if e < pivot\n add_number(greater, e) if e > pivot\n add_number(equal, e) if e == pivot\n end\n\n # Make sure everything is flushed to the filesystem\n less.flush\n equal.flush\n greater.flush\n\n # Open for reading\n less.open\n equal.open\n greater.open\n\n # Close the file, will delete the file if it is a temp file\n file.close\n\n merge_files(streaming_quicksort(less), equal, streaming_quicksort(greater))\n end\nend",
"def build_heap\n unless @elements.empty?\n i = (@elements.size-1)/2\n while i>=0\n heapify(i)\n i -= 1\n end\n end\n end",
"def heapsort(array)\r\n\t#create a heap from an array\r\n\theap = MaxHeap.new(array)\r\n\theap.buildMaxHeap\r\n\t\r\n\t#puts heap.array\r\n\t#puts \"_____\"\r\n\t#puts \"array size = #{heap.arraysize}\"\r\n\t\r\n\t(heap.arraysize).downto(2) do |i|\r\n\t\t#exchange of largest data point with end of the array\r\n\t\ttemp = heap.array[0]\r\n\t\theap.array[0] = heap.array[i-1]\r\n\t\theap.array[i-1] = temp\r\n\t\t\r\n\t\t#decrement size of the heap so that the last value stays in the array, but does not get sorted\r\n\t\theap.heapsize -=1\r\n\t\theap.maxHeapify(0)\r\n\t\t#puts \"**____**\"\r\n\t\t#puts \"i is equal to #{i}\"\r\n\t\r\n\t\t#puts heap.array\r\n\t\t#puts \"**_~~_**\"\r\n\tend\r\n\tputs heap.array\r\nend",
"def build_heap(array)\n first_parent_idx = (array.length - 1) / 2\n (first_parent_idx).downto(0).each { |current_idx| \n self.sift_down(current_idx, array.length - 1, array)\n }\n return array\n end",
"def get_heap\n @heap\n end",
"def heapify(min_heap, hash_table, index)\n smallest = index\n left_child = 2 * index + 1\n right_child = 2 * index + 2\n if (left_child < min_heap.length) && (min_heap[left_child][1] < min_heap[smallest][1])\n smallest = left_child\n end\n if (right_child < min_heap.length) && (min_heap[right_child][1] < min_heap[smallest][1])\n smallest = right_child\n end\n if smallest != index\n hash_table[min_heap[index][0] - 1][1] = smallest\n hash_table[min_heap[smallest][0] - 1][1] = index\n min_heap[smallest], min_heap[index] = min_heap[index], min_heap[smallest]\n heapify(min_heap, hash_table, smallest)\n end\nend",
"def extract_min\n @nodes.shift.tap do\n # Move the last node to the root position and then heapify down\n @nodes.unshift @nodes.pop unless @nodes.size.zero?\n heapify_down\n end\n end",
"def build_heap\n @heap_size = length\n (length / 2).floor.downto(1) do |i| \n heapify_downward i \n end\n end",
"def heap_sort (list)\r\n sl = []\r\n heap = build_heap(list)\r\n heap.size.times do\r\n sl << heap.shift\r\n heap = heapify(heap, 0)\r\n end\r\n sl.reverse\r\nend",
"def heapsort(list)\n return list if list.length < 2\n\n heap = MinHeap.new\n\n i = 0\n list.each do\n heap.add(list[i])\n i += 1\n end\n\n i = 0\n until i == list.length\n list[i] = heap.remove\n i += 1\n end\n\n return list\nend",
"def doing_phrases_file_sort_and_unique\n a = File.readlines(\"./tmp/database_doings/doing_phrases/phrases_sorted.txt\")\n @megadeta = a.sort do |x,y|\n x.downcase <=> y.downcase\n end\n consumer = Fiber.new do |producer, queue|\n f = open(\"./tmp/database_doings/doing_phrases/phrases_ready_to_load.txt\", \"a\") do |f| \n loop do\n queue = producer.transfer(consumer, queue)\n puts f << queue\n queue.clear\n end\n raise StopIteration\n end\n end\n producer = Fiber.new do |consumer, queue|\n queue = \"\"\n puts queue\n\t @megadata_unique = @megadata.uniq\n queue << \"#{@megadata_unique}\"\n break unless @megadata_uniq\n consumer.transfer queue\n queue.clear\n raise StopIteration\n end \n consumer.transfer(producer, [])\n after_break\n end",
"def heap_sort(list)\n return [] if list.nil?\n return list if list.length == 1\n \n heap = MinHeap.new \n \n list.each do |node|\n heap.add(node)\n end\n \n sorted_heap = []\n \n list.length.times do \n node = heap.remove \n sorted_heap << node\n end\n return sorted_heap\nend",
"def heap_sort(arr)\n (arr.length - 1).downto(1).each do |i|\n p \"i = #{i},arr[i] = #{arr[i]},arr[0] is #{arr[0]},arr = #{arr}\"\n # 打乱顺序\n # 然后上一轮的最小值\n # 就永远回不去顶端了\n # 因为 i 值不断缩小\n # 比较的范围越来越小\n arr[i], arr[0] = arr[0], arr[i]\n p \"---arr = #{arr}\"\n min_heap_fixdown(arr, 0, i)\n p \"===arr = #{arr}\"\n end\n arr\nend",
"def heap_up(index)\n until index == 0 || @store[index].key >= @store[((index - 1) / 2)].key\n parent = (index - 1) / 2\n swap(parent, index) if @store[parent].key > @store[index].key\n index = parent\n end\n end",
"def heapsort(list)\n heap = MinHeap.new()\n\n list.each do |element|\n heap.add(element)\n end\n\n result = []\n while !heap.empty?\n node = heap.remove\n result.push(node)\n end\n\n return result\nend",
"def push(val)\n @store << val\n idx = count - 1\n @store = BinaryMinHeap.heapify_up(@store, idx, &prc)\n end",
"def min_heapify(idx)\n l = left(idx)\n r = right(idx)\n smaller = idx\n smaller = l if l <= @size && elem(l) < elem(idx)\n smaller = r if r <= @size && elem(r) < elem(smaller)\n swap(smaller, idx) if smaller != idx\n min_heapify(smaller) if smaller != idx\n end",
"def remove_max\n return nil if heap.empty?\n deleted = @heap.delete_at 0\n last_one = @heap.pop\n if last_one #ei ole false tai nil\n @heap.insert 0, last_one\n heapify_down 0\n end\n deleted\n end",
"def heap_sort(list)\n return list if list == []\n \n heap = MinHeap.new()\n new_array = []\n \n until list.empty?\n removed = list.pop\n heap.add(removed)\n end\n \n until heap.empty?\n new_addition = heap.remove\n new_array << new_addition\n end\n \n return new_array\nend",
"def sortFile( filename, numberOfValuesToOutput )\n nodeController = NodeController.new( numberOfValuesToOutput )\n # Load each line into memory and add it to the right place in the nodes \n file = File.open( filename, \"r\" )\n file.each_line do | line |\n nodeController.addValueToNodes( line.to_s.chomp.to_f)\n end\n \n # Write the output nodes to disk bottom-up, but only up to a specified number of values\n outFile = File.new( \"output-#{filename}\", \"w\" )\n node = nodeController.lowestValue\n numberOfValuesToOutput.times do\n # Travel the right nodes upwards from the node with the lowest value found\n outFile.puts node.payload.to_s\n node = node.rightNode\n end\n \nend",
"def create_max_heap\n (0..@heap_size/2-1).to_a.reverse.each do |indx|\n fix_one_error(indx)\n end\n end",
"def insert(data, index)\r\n\t\t#initial insertion\r\n\t\tfirstarray = @array[0..index]\r\n\t\tsecondarray = @array[index+1..@array.length]\r\n\t\t@array = firstarray + data + secondarray\r\n\t\t\r\n\t\t\r\n\t\t#is there a faster way to do this?\r\n\t\tbuildMaxHeap\r\n\t\t#if data <= @array[parent(index)]\r\n\t\t#\tmaxHeapify(index)\r\n\t\t#else\r\n\t\t#\t#it would be nice to have a function that says \"max heapify the parent if it needs it, else move upwards\" which is recursive\r\n\t\t#end\r\n\t\t\r\n\tend",
"def heapsort(list)\n return list if list.empty? || list.length == 1\n\n minHeap = MinHeap.new()\n\n until list.empty?\n minHeap.add(list.pop)\n end\n\n until minHeap.empty?\n list << minHeap.remove\n end\n\n return list\nend",
"def heap_sort(arr)\n 2.upto(arr.length - 1).each do |heap_size|\n BinaryMinHeap.heapify_up(arr, heap_size - 1, heap_size)\n end\n\n arr.length.downto(2).each do |heap_size|\n arr[heap_size - 1], arr[0] = arr[0], arr[heap_size - 1]\n BinaryMinHeap.heapify_down(arr, 0, heap_size - 1)\n end\n\n arr.reverse\nend",
"def heapify!(array)\n @data = array\n (0..(@data.size / 2 - 1)).to_a.reverse.each { |i| percolate_down i }\n return self\n end",
"def getMin()\n element=@store[1]\n\n #copy last element to the first...\n @store[1]=@store[@store.length-1]\n @store.delete_at(@store.length-1) #delete the last element \n\n #We need to restore the Heap Structure if altered\n heapify(1)\n return element\n end",
"def heapsort(list)\n heap = MinHeap.new()\n \n # add each element onto MinHeap\n list.each do |element|\n heap.add(element)\n end\n \n # start plucking out the roots from the MinHeap\n sortedList = []\n until heap.empty?\n sortedList << heap.remove()\n end\n \n return sortedList\nend",
"def heap_up(index)\n parent_index = (index - 1) / 2\n\n unless @store[parent_index].key < @store[index].key || index <= 0 \n swap(parent_index, index)\n heap_up(parent_index)\n end\n end",
"def put d, q, p = nil;\n\t\tdelete q;\n\t\tk, kk = @heap.size, ();\n\t\twhile 0 < k && d < @heap[kk = (k - 1) >> 1][0];\n\t\t\t@heap[k] = @heap[kk];\n\t\t\t@hash[@heap[k][1]] = k;\n\t\t\tk = kk;\n\t\tend;\n\t\t@heap[k] = [d, q, p];\n\t\t@hash[q] = k;\n\t\treturn;\n\tend",
"def heapsort_inPlace(list)\n return list if list.length <= 1\n\n puts \"\\nSTARTING with #{list}\"\n\n # build a max heap\n list.length.times do |i|\n heap_up(list, i)\n puts \"\\tlist = #{list}\"\n end\n\n puts \"\\nREADY to pluck out Max and put start populating from end of list\"\n last = list.length - 1\n\n # pop off the top of the heap\n # place it in the last unsorted slot\n # re-heap the unsorted list\n list.length.times do |i|\n swap(list, 0, last)\n puts \"\\tpost swap,\\tlist = #{list}\"\n heap_down(list, 0, last)\n puts \"\\t\\t\\t adj = #{list}\"\n\n last -= 1\n end\n\n return list\nend",
"def heap_sort(list)\n return [] if list.empty?\n\n heap = MinHeap.new\n list.each do |item|\n heap.add(item)\n end\n\n array = []\n heap_to_array(heap, array)\n\n return array\nend",
"def heapsort(list)\n # raise NotImplementedError, \"Method not implemented yet...\"\n heap = MinHeap.new\n return list if list.nil? || list.length == 1\n\n until list.empty?\n heap.add(list.pop)\n end\n sorted_list = []\n list.length.times do \n sorted_list << heap.remove\n end\n return sorted_list\nend",
"def heap_down(index)\n n = @store.size\n while index * 2 + 1 < n\n j = index * 2 + 1\n\n j += 1 if j < n - 1 && @store[j + 1].key < @store[j].key\n\n break if @store[index].key <= @store[j].key\n\n @store[index], @store[j] = @store[j], @store[index]\n index = j\n end\n end",
"def avail_out= size\n\t\tsize.times do \n\t\t\tif size > avail_out\n\t\t\t\t@output_buffer.push nil\n\t\t\telse\n\t\t\t\t@output_buffer.pop\n\t\t\tend\n\t\tend\n\tend",
"def sort_pieces\n @headings = Heap.new\n cont = true\n while cont do\n piece = []\n begin\n @piece_size.times { piece << @source.next }\n rescue StopIteration\n cont = false\n end\n piece.sort!\n @headings.insert(ExtStream.new(piece))\n end\n end",
"def heapsort(list)\n return list if list.length <= 1\n \n heap = MinHeap.new\n \n until list.empty?\n popped = list.pop\n heap.add(popped)\n end\n \n until heap.empty?\n list << heap.remove\n end\n \n return list\nend",
"def heapsort(list)\n return list if list.length < 2\n\n heap = MinHeap.new\n\n until list.empty?\n heap.add(list.pop)\n end\n\n until heap.empty?\n list << heap.remove\n end\n\n return list\nend",
"def heap_down(index)\n puts 'heap down'\n puts to_s\n child_index = 2*index + 1\n if index >= @store.length - 1 || child_index >= @store.length - 1\n return\n end\n if @store[child_index].key >= @store[index].key\n return\n end \n if @store[child_index].key < @store[index].key\n swap(child_index, index)\n index = child_index\n heap_down(index)\n end\n end",
"def heap_up(index)\n return if index == 0\n parent = (index - 1 ) / 2\n # Compare the new node with it's parent\n # If they are out of order swap and heap-up\n if @store[parent].key > @store[index].key\n #swap\n swap(index, parent)\n #continue heap-up\n heap_up(parent)\n end\n \n end",
"def create_max_heap(unsorted_array)\r\n (unsorted_array.length / 2).downto(1) do |node_num|\r\n fix_max_heap(node_num, unsorted_array)\r\n end\r\nend",
"def heap_sort(array) \n size = array.length\n #Adding an empty element at beginning of array to be the root\n root_array = [nil] + array \n \n i = size / 2 \n while i > 0 do\n heapify(root_array, i, size) \n i -= 1 \n end \n\n while size > 1 do\n root_array[1], root_array[size] = root_array[size], root_array[1] \n size -= 1 \n heapify(root_array, 1, size) \n end \n root_array.shift #getting rid of the initial nil\n root_array \nend",
"def build_maxheap\n\t\ti = @heap.length/2\n\t\twhile i >= 0\n\t\t\tn_heapify(@max, i)\n\t\t\ti -= 1\n\t\tend\n\tend",
"def heapify\n for i in (0..(@ary.size-1)).to_a.reverse\n upheap(i)\n downheap(i)\n end\n end",
"def heap_up(index)\n parent = (index - 1) / 2\n bottom = @store[index]\n\n if index > 0 && @store[parent].key > bottom.key \n swap(index, parent)\n heap_up(parent)\n end \n end",
"def bigSorting(unsorted)\n\nend",
"def minheap?\n\t\theaptype(@min, @heap)\n\tend",
"def insert(data)\n @nodes << data\n heapify_up\n end",
"def heap_sort(array)\n heap = Heap.new(array)\n heap.heap_sort\nend",
"def k_largest_elements2(array, k) \n result = BinaryMinHeap.new\n k.times do\n result.push(array.pop)\n end\n until array.empty?\n result.push(array.pop)\n result.extract\n end\n result.store\nend",
"def median_maintain(array)\n max_heap = []\n min_heap = []\n if array[0] > array[1]\n max_heap = [array[1]]\n min_heap = [array[0]]\n else\n max_heap = [array[0]]\n min_heap = [array[1]]\n end\n m = [array[0], max_heap[0]]\n (2..array.count - 1).each do |i|\n if array[i] > max_heap[0]\n min_heap << array[i]\n balance_min(min_heap, min_heap.count - 1)\n if min_heap.count > max_heap.count + 1\n max_heap << min_heap[0]\n extract_min(min_heap)\n balance_max(max_heap, max_heap.count - 1)\n end\n else\n max_heap << array[i]\n balance_max(max_heap, max_heap.count - 1)\n if max_heap.count > min_heap.count + 1\n min_heap << max_heap[0]\n extract_max(max_heap)\n balance_min(min_heap, min_heap.count - 1)\n end\n end\n m << if max_heap.count == min_heap.count\n max_heap[0]\n elsif max_heap.count > min_heap.count\n max_heap[0]\n else\n min_heap[0]\n end\n end\n sum = 0\n (0..m.count - 1).each do |i|\n sum += m[i]\n end\n sum % 10_000\nend",
"def up_heap(ary, k)\n p = (k - 1)/2\n down = ary[k]\n while (k-1)/2 >= 0 and ary[(k-1)/2] < down\n ary[k] = ary[(k-1)/2]\n k = (k-1).abs/2\n break if k == 0 \n end\n ary[k] = down\nend",
"def heapify(index)\n #Assume the left and right subroots are already valid heaps\n\n return if(leftChild(index)==nil && rightChild(index)==nil)\n\n if leftChild(index)!=nil && @store[index]<leftChild(index) then\n mini=index\n else\n mini=2*index\n end\n\n if rightChild(index)!=nil && @store[mini]>rightChild(index) then\n mini=2*index+1\n end\n\n if mini!=index then\n swap(index,mini)\n #call heapfiy recursively on minindex\n heapify(mini) \n end\n end",
"def max_heapify_bottom_up(index)\n if parent_i(index) && self[parent_i(index)] < self[index] \n self.swap(parent_i(index), index)\n max_heapify_bottom_up(parent_i(index))\n end\n end",
"def heapsort(list)\n heapify(list, parent(list.length - 1)) if list.length > 1\n sort_heaped_list(list)\n return list\nend",
"def en_queue(value)\n if self.openings > 0\n self.openings -= 1\n @head = @head == nil ? 0 : (@head + 1) % @size\n @q[@head] = value \n true\n else\n false\n end\n end",
"def enqueue(el)\n @maxqueue.push(el) if @maxqueue.length.zero?\n\n @store.push(el)\n while @maxqueue[0] < el\n @maxqueue.pop\n break if @maxqueue.length.zero?\n end\n @maxqueue.push(el)\n end",
"def next\n @heap.next\n end",
"def heapify(index)\n item = @items[index]\n parent = parent(index)\n left_child = left_child(index)\n right_child = right_child(index)\n if (parent && parent.attrib > item.attrib)\n swap(parent.index, index)\n elsif (left_child && right_child && left_child.attrib < item.attrib &&\n right_child.attrib < item.attrib)\n if (left_child.attrib < right_child.attrib)\n swap(index, left_child.index)\n else\n swap(index, right_child.index)\n end\n elsif (left_child && left_child.attrib < item.attrib)\n swap(index, left_child.index)\n elsif (right_child && right_child.attrib < item.attrib)\n swap(index, right_child.index)\n end\n end",
"def insert(value)\n @heap << value\n perc_up(@heap.length - 1)\n end",
"def union(heap_x, heap_y)\n return heap_y if !heap_x.root_head\n return heap_x if !heap_y.root_head\n\n y_head = heap_y.root_head\n heap_x.root_tail.r = y_head\n y_head.l = heap_x.root_tail\n heap_x.root_tail = heap_y.root_tail\n heap_x.min = heap_y.min if heap_x.min.key > heap_y.min.key\n heap_x.size = heap_x.size + heap_y.size \n return heap_x \n end",
"def dij(linkPackageMap, native)\nputs \"start dij\"\ndist = Hash.new();\nprevNode = Hash.new();\ntraversed = Array.new;\nallNodes = linkPackageMap.keys;\n#for i in 0..allNodes.length - 1\n#\tdist[allNodes[i]] = -1;\n#\tprevNode[allNodes[i]] = nil;\n#end\ndist[native] = 0;\nprevNode[native] = native;\n#q = PriorityQueue.new\n#q[native] = 0;\n\nq = Pqueue.new();\nq.push(native, 0);\n\n\nuntil q.isEmpty()\n\tu, distance = q.pop();\n\ttraversed.push(u);\n\t#puts u;\n\t#puts distance;\n\tuNeighborMap = linkPackageMap[u].map();\n\t#puts uNeighborMap.keys;\n\tuNeighbors = uNeighborMap.keys\n\tfor i in 0..uNeighbors.length - 1\n\t\t#puts uNeighbors[i]\n\t\tif !traversed.include?(uNeighbors[i]) then\n\t\t\tnewDistance = dist[u].to_i + uNeighborMap[uNeighbors[i]].to_i;\n\t\t\tif dist[uNeighbors[i]] == nil then\n\t\t\t\tdist[uNeighbors[i]] = newDistance\n\t\t\t\tprevNode[uNeighbors[i]] = u;\n\t\t\telse \n\t\t\t\tif newDistance < dist[uNeighbors[i]] then\n\t\t\t\tdist[uNeighbors[i]] = newDistance\n\t\t\t\tprevNode[uNeighbors[i]] = u;\n\t\t\t\tend\n\t\t\tend\n\t\t\tq.push(uNeighbors[i], dist[uNeighbors[i]].to_i);\n\t\t\t#q[uNeighbors[i]] = dist[uNeighbors[i]].to_i;\n\t\tend\n\t\t\t\n\tend\n\nend\n\n\n\nnodes = prevNode.keys;\n#puts nodes;\nnativeNeighbor = linkPackageMap[native].map();\n#nativeNeighbor.each{|key, value| puts \"key : #{key} value : #{value}\"}\nfor i in 0 .. nodes.length - 1\n\tif prevNode[nodes[i]] == native then\n\t\tprevNode[nodes[i]] = nodes[i];\n\telse\n\t\twhile(!nativeNeighbor.include?(prevNode[nodes[i]]) )\n\t\t\tprevNode[nodes[i]] = prevNode[prevNode[nodes[i]]];\n\t\tend\t\n\tend\nend\n\nreturn dist, prevNode;\nend",
"def heapify_up(custom_start_index = nil)\n current_index = custom_start_index.nil? ? (self.heap_container.length - 1) : custom_start_index \n while(self.has_parent(current_index) && \n self.pair_is_in_correct_order(current_index, self.get_parent_index(current_index)))\n \n self.swap(current_index, self.get_parent_index(current_index))\n current_index = self.get_parent_index(current_index)\n end\n end",
"def heapify(key = 0)\n # Assume left and right children follow heap property\n value = get(key)\n return if value == nil\n\n larger_child_key = larger_child(key)\n larger_value = get(larger_child_key)\n\n if larger_value != nil && larger_value > value\n @data[key] = @data[larger_child_key]\n @data[larger_child_key] = key\n heapify(larger_child_key)\n end\n end",
"def visualize\n require 'rviz'\n g = Rviz::Graph.new\n frontier = [1] # Add nodes to graph via BFS, starting with root\n until frontier.empty?\n index = frontier.shift\n unless index == 1 # Connect to parent unless root\n g.add_edge(@nodeset[parent index].to_s, '', @nodeset[index], '')\n end\n frontier.concat(children index)\n end\n g.output('bin_heap.dot')\n `dot -o bin_heap.png -Tpng bin_heap.dot`\n end",
"def topological_sort(vertices)\n #Kahn's Algorithm\n #queue keeps the nodes that have not been sorted yet\n #whatever is popped off the stack goes to sorted and is done\n queue = []\n sorted = []\n\n #loop through vertices\n vertices.each do |vertex|\n #find vertices with no dependencies and push to queue\n queue << vertex if vertex.in_edges.empty?\n end\n\n #pop off from queue and check the out edges of each\n #after pop, delete the vertex all its out edges\n #push that vertex into the sorted array\n #look at each of the destination nodes and push them onto queue if no in edges\n #do this until the queue is empty\n until queue.empty?\n curr_node = queue.shift\n\n sorted << curr_node\n to_vertices = []\n\n #grabs all the vertices connected to the out edges of the curr_node\n curr_node.out_edges.reverse.each do |out_edge|\n # until curr_node.out_edges.empty?\n\n\n # p out_edge.to_vertex.value\n to_vertices << out_edge.to_vertex\n\n #destroy the edge after using it up\n #destroy not working like how I thought it would, maybe save destroy for after\n\n # out_edge.destroy!\n out_edge.destroy!\n end\n\n #need to check if these vertices are connected to anything after\n #curr_node's out edge deletion\n to_vertices.each do |vertex|\n queue << vertex if vertex.in_edges.empty?\n end\n\n #check all vertices connected by curr_node's out_edges\n #if those\n end\n\n if sorted.length == vertices.length\n return sorted\n else\n return []\n end\n\n \n # easy_read = []\n # sorted.each do |vertex|\n # easy_read << vertex.value\n # end\n # p easy_read\n\n\n\n #Tarjan's Algorithm\nend",
"def delete_min_locator\n return nil if empty?\n use_min\n loc = mode_call(:find_min_loc)\n @heapsize = mode_call(:delete_loc, loc)\n loc\n end",
"def avail_out= size\n\t\t\tsize.times do\n\t\t\t\tif size > avail_out\n\t\t\t\t\t@output_buffer.push nil\n\t\t\t\telse\n\t\t\t\t\t@output_buffer.pop\n\t\t\t\tend\n\t\t\tend\n\t\tend",
"def insert(element)\n insertindex=@store.length\n\n @store[@store.length]=element\n return if insertindex==1\n\n #For even inserts parent index is insertedindex/2-1 otherwise its juts insertedindex/2\n\n parentindex=insertindex/2\n\n #Incase it does not fit in(violating Heap Property)\n while insertindex!=1 && @store[parentindex] > @store[insertindex]\n swap(parentindex,insertindex)\n insertindex=parentindex\n parentindex=insertindex/2\n end\n\n end"
] |
[
"0.6689746",
"0.6371679",
"0.6280897",
"0.6259608",
"0.62022924",
"0.61617696",
"0.58815265",
"0.58796775",
"0.586939",
"0.58582425",
"0.5832433",
"0.58265454",
"0.57960653",
"0.5789457",
"0.57412255",
"0.5741173",
"0.5735473",
"0.5730162",
"0.5729206",
"0.5724106",
"0.5706628",
"0.5695575",
"0.5695151",
"0.5671032",
"0.56647015",
"0.5653635",
"0.5646242",
"0.5638252",
"0.56244177",
"0.55989176",
"0.55946916",
"0.5585423",
"0.5575391",
"0.55676436",
"0.5562486",
"0.55550706",
"0.5552936",
"0.5543566",
"0.55346096",
"0.5533025",
"0.55196285",
"0.55140823",
"0.54842615",
"0.54821664",
"0.5477937",
"0.5460922",
"0.5453347",
"0.54454523",
"0.544068",
"0.5440626",
"0.54322654",
"0.5427941",
"0.54158247",
"0.5415634",
"0.5412262",
"0.54023397",
"0.5381124",
"0.5380456",
"0.53751326",
"0.5363035",
"0.5355022",
"0.5340613",
"0.5319098",
"0.53067416",
"0.53056073",
"0.5298673",
"0.52900106",
"0.52881265",
"0.52858466",
"0.52773863",
"0.5274928",
"0.5270447",
"0.5265445",
"0.5260869",
"0.5254392",
"0.52409524",
"0.5239722",
"0.5237111",
"0.52331614",
"0.5229947",
"0.52222395",
"0.52049047",
"0.5204494",
"0.5202158",
"0.5198068",
"0.51952064",
"0.5191725",
"0.51717603",
"0.5170314",
"0.51642066",
"0.5158486",
"0.51546824",
"0.51511735",
"0.514808",
"0.5125509",
"0.5117918",
"0.51178527",
"0.51171434",
"0.5116032",
"0.5114098"
] |
0.73906064
|
0
|
write rand val and timestamp to disc
|
def write_to_disk(output)
path = "./output.txt"
time = output[:time].strftime("%H:%M:%S:%N")
output_string = output[:value].to_s + ", " + time + "\n"
File.open(path, 'a') { |file| file.write(output_string) }
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def store_results_file\r\n\taFile = File.new(\"./random_number_result.txt\", \"r+\")\r\n\taFile.truncate(0)\r\n\tnumber = generate_random_number\r\n\tputs aFile.syswrite(\"#{number}\")\r\nend",
"def create_timestamp_file\n timestamp = Time.now.utc\n timestamp_file = File.new(report_timing_file, 'w')\n timestamp_file.puts(timestamp)\n timestamp_file.close\n end",
"def generate_timestamp_file(filename)\n now = Time.now.to_i\n output_path = \"#{@archive_root}/#{filename}\"\n File.write(output_path, now)\n end",
"def write_last_measurement(line, filename = '/tmp/currentcost')\n File.open(filename, \"w\") do |file|\n file.puts Time.now,(line)\n end\nend",
"def get_rand\n rand = \"\";\n File.open(\"/dev/urandom\").read(20).each_byte{|x| rand << sprintf(\"%02x\",x)}\n rand\nend",
"def timestamp() @timestamp ||= Time.now.strftime(\"%Y%m%d%H%M%SZ\") end",
"def write_timestamp\n filepath = \"#{Dir.tmpdir}/govpay_request_refund_service_last_run_time\"\n # FileUtils.touch seems unreliable in VM so need to write/read the actual time\n File.write(filepath, Time.zone.now)\n end",
"def generate_uid\n [Time.now.strftime('%Y%m%d%H%M%S'), \"%05d\" % rand(10000)].join\n end",
"def write_stmt_file(acct_numbers_array, number_stmt_fields)\r\n file_name = \"data/statements\"\r\n output_file = File.open(file_name,\"w\")\r\n \r\n stmt_start_year = 2015\r\n stmt_end_year= 2015\r\n stmt_start_month = 4\r\n stmt_end_month = 9\r\n stmt_start_day = 01\r\n stmt_end_day = 21\r\n \r\n for i in 1..number_stmt_fields\r\n stmt_date = random_date(stmt_start_year,stmt_end_year, stmt_start_month, stmt_end_month, stmt_start_day,stmt_end_day)\r\n acct_num = acct_numbers_array.sample\r\n output_file.puts \"#{acct_num}\" + \"\\001\" + \"#{stmt_date}\" \r\n end\r\n output_file.close\r\nend",
"def createFile(file,time)\n\t\tFile.open(file, \"w+\") do |f|\n\t\t\tf.print time\n\t\tend\n\tend",
"def makelog(string)\n time = Time.new().to_s\n file = File.open(\"#{$path}logs\",'a')\n file.puts time+\"\\t\"+string\n file.close\nend",
"def generate_id(_)\n accurate_timestamp = (Time.now.to_f * 1000).round\n time_part = (accurate_timestamp - DISCORD_EPOCH) << 22\n random_part = rand(0...2**22)\n\n time_part | random_part\n end",
"def make_id\n Time.now.to_f.to_s.ljust(16, '0') + rand(10).to_s\n end",
"def generate_log(timestamp)\n\n customer_id = rand(1000000) + 1\n resource_id = rand(10) + 1\n qty = rand(100)\n\n #cost is in cents, could be zero\n cost = rand(200) - 20\n cost = 0 if cost < 0\n\n logline = \"#{timestamp},#{customer_id},#{resource_id},#{qty},#{cost}\"\n #puts logline\n\n ## generate JSON format\n #dict = {\"timestamp\" => timestamp,\n #\"customer_id\" => customer_id,\n #\"resource_id\" => resource_id,\n #\"qty\" => zone_id,\n #\"cost\" => cost\n #}\n #logline = JSON::generate(dict)\n\n\n logline\nend",
"def generateTestFile( filename )\n File.new(filename, \"w\")\n file = File.open(filename, \"w\")\n 100.times do # For expediency's sake I'll use a set of 100\n file.puts rand().to_s\n end\n file.close\nend",
"def generate_timestamp\n Time.now.strftime(\"%Y-%m-%dT%T.%N%:z\")\n end",
"def generate\n raise \"The secret file #{path} already exists.\" if File.exist?(path)\n\n set SecureRandom.hex(16)\n end",
"def write_trxn_file(acct_numbers_array, number_trxn_fields)\r\n file_name = \"data/transactions\"\r\n output_file = File.open(file_name,\"w\")\r\n \r\n trxn_start_year = 2015\r\n trxn_end_year= 2015\r\n trxn_start_month = 4\r\n trxn_end_month = 9\r\n trxn_start_day = 01\r\n trxn_end_day = 21\r\n \r\n min_ammt = 0.00\r\n max_ammt = 10000.00\r\n \r\n for i in 1..number_trxn_fields\r\n acct_num = acct_numbers_array.sample\r\n trxn_date = random_date(trxn_start_year,trxn_end_year, trxn_start_month, trxn_end_month, trxn_start_day, trxn_end_day)\r\n deb_cred_indicator = random_debit_credit_indicator()\r\n merch_catg = random_merchant_category()\r\n trxn_amnt = random_ammount(min_ammt,max_ammt)\r\n prch_code = random_purchase_code()\r\n output_file.puts \"#{acct_num}\" + \"\\001\" + \"#{trxn_date}\" + \"\\001\" + \"#{deb_cred_indicator}\" + \"\\001\" + \"#{merch_catg}\" + \"\\001\" + \"#{trxn_amnt}\" + \"\\001\" + \"#{prch_code}\"\r\n end \r\n output_file.close\r\nend",
"def file_num_generate\n \t\t_random(6) + \"#{file_uid}\"\n\tend",
"def uuid\n time = Time.now.to_i.to_s(16)\n second = rand(10000..99999).to_s(16)\n third = rand(10000..99999).to_s(16)\n fourth = rand(10000..99999).to_s(16)\n fifth = rand(10000000000000..99999999999999).to_s(16)\n\n \"#{time}-#{second}-#{third}-#{fourth}-#{fifth}\"\nend",
"def rand\n warn \"STUB: rand in distribution.rb\"\n end",
"def manual_file\n f = File.open(\"#{Time.new.strftime('%Y-%m-%dT%H:%M:%S')}.txt\", 'w')\n f.write('Hello')\n f.flush\n f.close\nend",
"def add_entropy addition, e=ENTROPY_FILE\n require 'digest/sha1'\n old = entropy e\n returning sha_to_b64(Digest::SHA1.hexdigest(\"#{Time.now.to_f}#{addition}#{rand}#{old}\")) do |new_entropy|\n File.open e, \"w\" do |f|\n f.write new_entropy\n end\n end\nend",
"def write_noise\n file = @date.strftime '%Y-%m-%d-noise.csv'\n\n $stderr.puts \"output: #{file}\"\n\n mday = @date.strftime '%d'\n\n open file, 'w' do |io|\n noise do |time, station, dBs|\n /(.{4})(.{2})(.{2})(.{2})(.{2})(.{2})/ =~ time\n\n next unless $3 == mday\n\n io.puts \"#{$1}-#{$2}-#{$3}T#{$4}:#{$5}:#{$6}-0700,#{station},#{dBs}\"\n end\n end\n end",
"def writeNextStartTimeFile\n fileName = makeSiteFileName\n file = File.new(fileName,\"w+\")\n @startTimeHash.each do |key,value|\n time = Time.now.utc.iso8601\n file.puts(\"#{key}=\" + time)\n end\n file.close()\n end",
"def gen_speed\n rand + 15.0\n end",
"def write(name, value)\n File.open(path(name), 'w') do |f|\n f.write(Oj.dump(value, mode: :compat, time_format: :ruby))\n end\n end",
"def generate_id\n synchronize do\n n = (get_random() % @@MOD_LEN) + @@MOD_LEN\n time_val = Time.now.to_i\n t = ((time_val / 2) % @@MAX_TICKS) + @@MAX_TICKS\n if time_val != @@last_time_val\n @@session_count = 0\n @@last_time_val = time_val\n end\n @@session_count += 1\n \"#{n.to_s(36)[1..-1]}#{t.to_s(36)[1..-1]}#{@@session_count.to_s(36)}\"\n end\n end",
"def store_activity_end_time\n File.open(MAIN_DIR + \"prev_end_time\", \"w\") do |timeFile|\n timeFile.syswrite(current_time)\n end\nend",
"def save_game(file)\n \n score = 1000\n \n open(file, \"w\") do |f|\n f.puts(score)\n f.puts(Time.new.to_i)\n end\nend",
"def log_input\n File.open('./log/ultimo_registro.txt', 'w+') do |f| \n f.puts Time.now.strftime(\"%Y%m%d-%H:%M\").to_s\n end \n end",
"def write(val)\n @file.seek(@address)\n @file.putc(val)\n @file.flush\n end",
"def generate(time, counter = 0)\n [time, @machine_id, Process.pid, counter << 8].pack(\"N NX lXX NX\")\n end",
"def generate_id\n now = Time.now\n parts = [now.to_i, now.usec, $$, rand(16**8)]\n parts.map {|i| i.to_s(16)}.join('-')\n end",
"def write; end",
"def write; end",
"def time_stamp(event)\n file_local_write(@logfile,\"\\nKeylog Recorder #{event} at #{Time.now.to_s}\\n\\n\")\n end",
"def number\n\t\"#{Time.now.to_i}-#{rand(1_000_000)}\"\n end",
"def call\n FileUtils.mkdir_p(dir)\n CSV.open(file_name, 'wb') do |csv|\n lines.times do\n csv << [random_vrn, *random_time_range, type, la, random_plate, wheelchair?]\n end\n end\n end",
"def write_temp_file(name_template, contents)\n to = File.join(\n BUILDDIR,\n name_template.gsub('RAND') {rand(10000)}\n )\n File.open(to, 'w') {|fp| fp.print contents}\n\n to\n end",
"def rand_data(min, max, readable=true)\n count = min + ((rand(max)+1) *10).to_i\n res = count.to_s + \"/\"\n \n if readable\n res << Digest::SHA1.hexdigest(rand(count * 100).to_s) * (count / 40)\n else\n res << Digest::SHA1.digest(rand(count * 100).to_s) * (count / 20)\n end\n\n return res\n end",
"def create_file(filename, size)\n File.open(filename, \"w\") do |f|\n 1.upto(size) do\n f.putc(rand(256))\n end\n end\nend",
"def write_to_graphite(key, value, time = Time.now)\n logger.info \"write_to_graphite:start: key = #{key}, value = #{value}, time = #{time.to_i}\"\n\n if (@tcp_sockets.length > 0)\n\n @tcp_sockets.each do |tcp_socket|\n\n begin\n tcp_socket.write(\"#{key} #{value.to_f} #{time.to_i}\\n\")\n #puts key, value, time.to_i\n rescue Exception => e\n logger.error \"write_to_graphite:exception: #{e}\"\n end\n end\n\n end\n logger.info 'write_to_graphite:end: Completed'\n\n end",
"def rand_data(min, max, readable=true)\n count = min + ((rand(max)+1) *10).to_i\n res = count.to_s + \"/\"\n\n if readable\n res << Digest(:SHA1).hexdigest(rand(count * 100).to_s) * (count / 40)\n else\n res << Digest(:SHA1).digest(rand(count * 100).to_s) * (count / 20)\n end\n\n res\n end",
"def _file_num_generate\n\t\t_random(6) + \"#{_user[:uid]}\"\n\tend",
"def last_tweet_id=(val)\n File.write(File.expand_path('last_tweet_id.txt', @options.data_dir), val.to_s + \"\\n\")\n @last_tweet_id = val\n end",
"def get_random\n File.read(\"/dev/urandom\", 8).unpack(\"H*\")[0].hex\n rescue\n rand(9117854927)\n end",
"def new_random_trace_id\n val = rand 0x100000000000000000000000000000000\n val &= 0xffffffffffff0fffcfffffffffffffff\n val |= 0x00000000000040008000000000000000\n format \"%032x\", val\n end",
"def randkey\n timeout_retry(3, 3){\n write \"RANDOMKEY\\r\\n\"\n single_line_reply\n }\n end",
"def write\n write_data\n end",
"def create_timestamp(offset: rand(0..(TIMESTAMP_MAX-TIMESTAMP_MIN)))\n Time.at(TIMESTAMP_MIN+offset).strftime('%Y-%m-%d %H:%M:%S')\n end",
"def save!; File.write @path, @data end",
"def write_date(time)\n\t\twrite_byte(11)\n\t\twrite_double(time.to_f * 1000)\n\t\toffset = Time.zone_offset(Time.now.zone)\n\t\twrite_int16_network(offset / 60 * -1)\n\tend",
"def append (sample,k,v,bucket)\n config = sample[:config]\n\n dstype = config[\"#{k}-dstype\"]\n if dstype == \"gauge\" || dstype.nil?\n val = v.to_f\n else\n if !config.has_key?(\"#{k}-last_counter_value\")\n sample[:next][\"#{k}-last_counter_value\"] = v\n return \n end\n last_update = config[\"last_update\"].to_i\n last_counter_value = config[\"#{k}-last_counter_value\"].to_i\n delta_sec = sample[:time] - last_update\n delta_val = v.to_f - last_counter_value\n if delta_val < 0\n val = 0.0/0\n else\n val = delta_val / delta_sec\n end\n sample[:next][\"#{k}-last_counter_value\"] = v\n end\n bucket_file = \"#{config[:dir]}/#{k}-#{bucket}\"\n File.open(bucket_file, \"a\") do |f|\n if !val.nan?\n f.write sample[:time].to_s+\":\"+val.to_s+\"\\n\"\n end\n end\nend",
"def random_number\n t = Time.now.to_f / (Time.now.to_f % Time.now.to_i)\n random_seed = t * 1103515245 + 12345;\n (random_seed / 65536) % 32768;\nend",
"def generate_sid\n \"%0#{@default_options[:sidbits] / 4}x\" %\n rand(2**@default_options[:sidbits] - 1)\n end",
"def generate_reference\n \"#{Time.now.strftime('%y%m')}-#{SecureRandom.hex(3).upcase}\"\n end",
"def serialize(val)\n if ::Time.now.respond_to?(:nsec)\n val.to_i.to_s + '.' + val.nsec.to_s ##strait to_f loses precision\n else\n val.to_i.to_s + '.' + val.usec.to_s ##strait to_f loses precision\n end\n end",
"def write_point(key, value, timestamp, precision = DEFAULT_PRECISION)\n db.write_point(key, { value: value, time: precise_float(timestamp, precision) }, false, precision)\n end",
"def random(_, output_binary_p, num_bytes, status_p)\n write_binary_string_and_set_status(output_binary_p, status_p) do\n Hooks.random(num_bytes)\n end\n end",
"def out_val(field)\n output_type = field.output_type.to_sym\n return \"'#{SecureRandom.hex[1..10]}'\" if output_type == :random\n\tif FakeLib.methods(false).include?(output_type)\n return FakeLib.send(output_type).sample\n end\nend",
"def generate_token\n\t\tUUIDTools::UUID.timestamp_create.to_s\n\tend",
"def write(value)\n # pass\n end",
"def write\n end",
"def gen_uid\n \"#{rand(100000)}-#{Time.now.to_i}-#{rand(100000)}\"\n end",
"def write_to_file(timestamp, csv_record)\n return if storage_dir == File::NULL\n\n filename = filename(timestamp)\n storage_path = Pathname.new(storage_dir).join(filename)\n\n create_file(storage_path, csv_record) unless storage_path.exist?\n write_row(storage_path, csv_record)\n end",
"def write(data); end",
"def write(data); end",
"def write(data); end",
"def write(data); end",
"def randomkey; end",
"def randomkey; end",
"def generate_test_data()\n CSV.open(\"testdata.csv\", \"w\") do |csv|\n (1..1_000_000).each do |i|\n csv << [rand(100), rand(10_000), rand(100_000)]\n end\n end\nend",
"def write_token\n 'ddbc8384eaf4b6f0e70d66b606ccbf7ad4bb22bfe113'\n end",
"def asctime() end",
"def generate\n\t\tif self.token == nil\n\t\t\tself.token = SecureRandom.hex\n\t\tend\n\t\ta = Mashup.create! name: 'temporal'\n\t\tself.mashup_id = a.id\n\tend",
"def random= rnd\n @sampling.random = rnd\n end",
"def random_id\n rand(1000000) + 20000\nend",
"def stamp(primary_file, stamp_file, output); end",
"def get_timestamp(time)\r\n srandom_r time\r\n t0 = random_r\r\n t1 = 0x17dc65df;\r\n hi = (t0 * t1) >> 32;\r\n t2 = t0 >> 31;\r\n t3 = hi >> 23;\r\n t3 = t3 - t2;\r\n t4 = t3 * 0x55d4a80;\r\n t0 = t0 - t4;\r\n t0 = t0 + 0x989680;\r\n\r\n ieee754_round(t0)\r\n end",
"def write_exit_time\n begin\n File.open(exit_time_file, 'wb') do |f|\n f.write(Time.now.to_f)\n end\n rescue\n warn(\"Failed to write exit_time.tmp: #{$!}\")\n end\n end",
"def dump\n out = StringIO.new\n @track.recalc_times\n @seq.write(out)\n out.string\n end",
"def get_uuid\n rand_str = SecureRandom.hex\n timestamp = Time.now.to_i.to_s\n\n rand_str + timestamp\n end",
"def write(file,content,timestamp=nil)\n\n f = File.join(path(:destination),file)\n log(\"writing '#{f}'\")\n\n # write the file \n File.open(f, 'w') {|f| f.write(content) }\n\n # Time-stamp the file if required\n File.utime(Time.now,timestamp,f) unless timestamp.nil?\n\n end",
"def create(filename)\n time = Time.now\n @files[filename] = time\n puts \"#{filename} was created by #{@username} at #{time}.\"\n end",
"def insertReading()\n\n #@reading_id = SecureRandom.uuid\n\n DataReading.insertReading(@client_id, @sensor_type, @value, @location, @timestamp)\n\n end",
"def data_file(counter)\n # create a temp file\n t = File.open(File.join(base,\"data\", \"#{counter}.data\"), 'w')\n t << self.data\n t.close\n t.path\n end",
"def gen_date(from=0.0, to=Time.now)\n Time.at(from + rand * (to.to_f - from.to_f))\nend",
"def create clock=nil, time=nil, mac_addr=nil\nc = t = m = nil\nDir.chdir Dir.tmpdir do\nunless FileTest.exist? STATE_FILE then\n# Generate a pseudo MAC address because we have no pure-ruby way\n# to know the MAC address of the NIC this system uses. Note\n# that cheating with pseudo arresses here is completely legal:\n# see Section 4.5 of RFC4122 for details.\nsha1 = Digest::SHA1.new\n256.times do\nr = [rand(0x100000000)].pack \"N\"\nsha1.update r\nend\nstr = sha1.digest\nr = rand 14 # 20-6\nnode = str[r, 6] || str\nnode[0] |= 0x01 # multicast bit\nk = rand 0x40000\nopen STATE_FILE, 'w' do |fp|\nfp.flock IO::LOCK_EX\nwrite_state fp, k, node\nfp.chmod 0o777 # must be world writable\nend\nend\nopen STATE_FILE, 'r+' do |fp|\nfp.flock IO::LOCK_EX\nc, m = read_state fp\nc = clock % 0x4000 if clock\nm = mac_addr if mac_addr\nt = time\nif t.nil? then\n# UUID epoch is 1582/Oct/15\ntt = Time.now\nt = tt.to_i*10000000 + tt.tv_usec*10 + 0x01B21DD213814000\nend\nc = c.succ # important; increment here\nwrite_state fp, c, m\nend\nend\n \ntl = t & 0xFFFF_FFFF\ntm = t >> 32\ntm = tm & 0xFFFF\nth = t >> 48\nth = th & 0x0FFF\nth = th | 0x1000\ncl = c & 0xFF\nch = c & 0x3F00\nch = ch >> 8\nch = ch | 0x80\npack tl, tm, th, cl, ch, m\nend",
"def write_uuid\n write_var(:gear, \"OPENSHIFT_GEAR_UUID\", @uuid)\n end",
"def set_id\n\t\t\trand(111111111...999999999)\n\t\tend",
"def timestamp\n time = Time.now.getutc\n\n secs = time.to_i\n millis = time.nsec/1000000\n\n return @last if @millis == millis && @secs == secs\n\n unless secs == @secs\n @secs = secs\n @date = time.strftime('%Y-%m-%d %H:%M:%S.')\n end\n\n @millis = millis\n @last = @date + \"00#{millis}\"[-3..-1]\n end",
"def save_seed\n File.open(cache_file, 'w') do |file|\n file.puts MultiJson.dump(@seed)\n end\n true\n end",
"def save_to_file\n\t\tFile.open(@output, \"w+\") do |file|\n\t\t\tfile.puts \"[b][align=center]\"\n\t\t\trandomize if @random\n\t\t\t@output_data.each_line { |line| line.delete('\\n') }\n\t\t\tfile.puts @output_data\n\t\t\tfile.puts \"[/align][/b][align=center][sup]Made with [user]kryszanek[/user]'s [url=http://github.com/kryszan/cloudy]cloudy[/url]\\\\m/ [/sup][/align]\"\n\t\tend\n\tend",
"def generate_id(t=nil)\n t ||= Time.new.to_i\n buf = ByteBuffer.new\n buf.put_int(t & 0xffffffff)\n buf.put_array(MACHINE)\n buf.put_array(PID)\n i = index_for_time(t)\n buf.put(i & 0xff)\n buf.put((i >> 8) & 0xff)\n buf.put((i >> 16) & 0xff)\n\n buf.rewind\n buf.to_a.dup\n end",
"def rand\n Kernel.rand(self)\n end",
"def create_token\n begin\n token = random_token\n end while repository[token] && repository[token] > Time.now - 172800\n repository[token] = Time.now\n token\n end",
"def write(value)\n record.send(\"#{name}_data=\", value)\n end",
"def generate_random_time\n\t\trandom_value = Random.rand(0.0..1.0)\n\t\t(0..(@nbTSInOneDay - 1)).each do |ts|\n\t\t\treturn ts if @demandOverTimeCumulatedAndNormalised[ts] >= random_value\n\t\tend\n\tend",
"def generate(site)\n @site = site\n @site.config[\"time\"] = Time.new\n unless feed_exists?\n write\n @site.keep_files ||= []\n @site.keep_files << path\n end\n end"
] |
[
"0.6358565",
"0.6044772",
"0.6030461",
"0.59834987",
"0.586772",
"0.5866691",
"0.57375175",
"0.57369983",
"0.57033104",
"0.5701967",
"0.5700457",
"0.5687286",
"0.56427246",
"0.5635373",
"0.5618079",
"0.56139666",
"0.55950683",
"0.55936855",
"0.55716926",
"0.5564042",
"0.5557238",
"0.553631",
"0.55285364",
"0.5524387",
"0.5516223",
"0.5473887",
"0.5452101",
"0.5450774",
"0.5441447",
"0.5434731",
"0.54236066",
"0.5399957",
"0.53981644",
"0.53820294",
"0.5369745",
"0.5369745",
"0.5364102",
"0.53529674",
"0.5335007",
"0.5325359",
"0.53179485",
"0.5311308",
"0.53079903",
"0.5307773",
"0.5291959",
"0.5260932",
"0.5247767",
"0.5245653",
"0.5238868",
"0.523008",
"0.5216749",
"0.5213066",
"0.52110845",
"0.52096087",
"0.5195025",
"0.51934695",
"0.5191488",
"0.5190207",
"0.5188215",
"0.5187608",
"0.51821756",
"0.5175678",
"0.5173209",
"0.5172118",
"0.51690584",
"0.51606315",
"0.5155775",
"0.5155775",
"0.5155775",
"0.5155775",
"0.515452",
"0.515452",
"0.515185",
"0.5139413",
"0.5139294",
"0.5138454",
"0.5120204",
"0.5111846",
"0.51113987",
"0.5100374",
"0.50926614",
"0.508992",
"0.5089819",
"0.50876004",
"0.5084975",
"0.5080183",
"0.50752497",
"0.50746346",
"0.50737107",
"0.5064431",
"0.50599444",
"0.5059466",
"0.5054645",
"0.5054174",
"0.5053259",
"0.5052657",
"0.50515205",
"0.50465703",
"0.50460154",
"0.5043972"
] |
0.5515903
|
25
|
Generator Methods Creats 5 seperate writer generator threads
|
def start_generators
threads = []
5.times do |idx|
thread = Thread.new { contious_generation }
thread[:id] = idx
threads << thread
end
threads
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def create_intelligent_generator(jobs)\n jobs_gen = jobs.lazy.each\n Fiber.new do\n (jobs.length-1).times do\n Fiber.yield jobs_gen.next\n end\n jobs_gen.next\n end\n end",
"def start\n @running = true\n gen_threads = start_generators\n writer = start_writer\n gen_threads.each(&:join)\n kill_proccess\n writer.join\n end",
"def generators; end",
"def generators; end",
"def create_workers(num_workers)\n while @workers.count < num_workers.to_i\n thread_index = @workers.keys.count + 1\n @worker_threads[thread_index] = Thread.new do\n if @workers.keys.count < (num_workers.to_i / 2)\n worker = create_worker(thread_index, [Feed, FeedItem])\n else\n worker = create_worker(thread_index, [FeedItem])\n end\n worker.start\n end\n sleep 0.2\n end\n end",
"def generators(&blk); end",
"def generators(&blk); end",
"def parallel(number_of_lanes, reader: last_pipe, writer: next_pipe)\n @port ||= MQUEUE_START_PORT\n ventilator = format('>{localhost:%d', @port)\n input = format('<{localhost:%d', @port)\n @port += 1\n sink = format('<}localhost:%d', @port)\n output = format('>}localhost:%d', @port)\n @port += 1\n\n spawn_process(Processes::Identity.new, process_name: 'Ventilator', readers: [reader], writers: [ventilator])\n spawn_process(Processes::Identity.new, process_name: 'Sink', readers: [sink], writers: [writer])\n on_subnet do\n number_of_lanes.times { yield input, output }\n end\n end",
"def create_work\n @files.each do |file|\n executor.queue { file.copy_file(@output_dir) }\n end\n end",
"def each_to_thread\n Threaded.new map { |x| Thread.new { yield(x) } }\n end",
"def generate\n generations = 0\n loop do\n print\n sleep(0.5)\n newGeneration\n generations += 1\n p \"Number of generations: #{generations} [Ctrl-C to exit]\"\n end\n end",
"def generate\n generators.each do |generator|\n start = Time.now\n generator.generate(self)\n Jekyll.logger.debug \"Generating:\",\n \"#{generator.class} finished in #{Time.now - start} seconds.\"\n end\n nil\n end",
"def generate_devices device_count\n return if upstream_sessions.count >= device_count\n print \"Generating #{device_count} devices...\" if Rails.env.development?\n needed_devices = device_count - upstream_sessions.count\n needed_devices.times.each do |i|\n generate_upstream_session\n report_progress = (needed_devices >= 10) && (i % (needed_devices/10).to_i == 0)\n yield \"Generated #{i} devices.\" if report_progress && block_given?\n end\n puts 'done.' if Rails.env.development?\n end",
"def create_and_run_workers\n Kernel.print \"Creating #{@orders.number} orders... \"\n Array.new(@threads_number) do\n Thread.new do\n loop do\n order = @orders_injector.pop\n break unless order\n @user_api_client.create_order(order, @users.sample)\n rescue => e\n Kernel.puts e.inspect\n end\n end\n end.each(&:join)\n end",
"def threaded_looped_generate_posts\n return Toolbox::run_in_new_thread \"#{__method__}\" do\n Toolbox::looper do\n log \"----------------------threaded_looped_generate_posts----------------------\"\n generate_photo_post(@keywords.sample, @keyword_suffix)\n random_sleep\n log \"----------------------threaded_looped_generate_posts----------------------\"\n end\n end # run_in_new_thread\n end",
"def workers(count); end",
"def generate!\n generator.invoke_all\n end",
"def initialize\r\n @threads = []\r\n @cordinators = []\r\n end",
"def generator\n printf(\"%-10s %s\\n\",\"generator:\", \"generating.. (*hdls, *bmm, *scr, *prj)\")\n exitcode = 1\n FileUtils.rm_r Dir.glob(\"#{TMPDIR}/hdl/*.vhd\")\n FileUtils.rm_r Dir.glob(\"#{TMPDIR}/synthesis/*.vhd\")\n File.symlink(\"../pcores\", \"#{TMPDIR}/pcores\") unless File.symlink?(\"#{TMPDIR}/pcores\")\n pipe = IO.popen(\"platgen -od #{TMPDIR}/ -p xc4vfx100ff1152-10 -lang vhdl ../system.mhs\", \"r+\")\n # pipe = IO.popen(\"platgen -p xc4vfx12ff668-10 system.mhs\", \"r+\")\n pipe.each do |line|\n # puts line\n # do not synthesize\n if line =~ /Running XST synthesis/\n exitcode = 0\n Process.kill 'TERM', pipe.pid\n break\n end\n end\n unless exitcode == 0\n p \"# Error with platgen - check platgen.log\"\n exit\n end\n\n # he generated files under $PROJECT/TMPDIR/{hdl,synthesis}\n # copy them to $PROJECT/hdl/ under certain conditions (size differs & or abstence)\n FileUtils.mkdir('hdl') unless File.directory? 'hdl'\n FileUtils.mkdir('synthesis') unless File.directory? 'synthesis'\n FileUtils.mkdir_p(BMM_RESULTSDIR) unless File.directory? BMM_RESULTSDIR # output directory\n\n # move_files_if(\"#{TMPDIR}/hdl/*.vhd\")\n move_files_if(\"#{TMPDIR}/implementation/#{TOPLEVEL}.bmm\", BMM_RESULTSDIR)\n move_files_if(\"#{TMPDIR}/synthesis/*.scr\" )\n move_files_if(\"#{TMPDIR}/synthesis/*.prj\")\n Find.find(\"#{TMPDIR}/hdl\") do |path|\n move_files_if(path) if File.file? path\n end\n\n # move logfiles to scratch\n FileUtils.mkdir_p(GEN_SCRATCHDIR) unless File.directory? GEN_SCRATCHDIR\n [\"platgen.log\", \"platgen.opt\", \"#{TMPDIR}/clock_generator*.log\"].each { |t|\n FileUtils.mv(t, \"#{GEN_SCRATCHDIR}/\") if File.file? t\n }\n\n # change timestamps\n\nend",
"def generate_program(function)\n File.write(\"submit.rb\", generate_program_submit(function))\n File.write(\"consumer_progenitor.rb\", generate_queue_progenitor(function))\n File.write(\"consumer_duplicate.rb\", generate_queue_duplicate(function))\nend",
"def _test_threads\n m = Mutex.new \n threads = []\n @custom_number_of_users.times do\n threads << Thread.new do\n m.synchronize {threaded_mage_checkout}\n threaded_mage_checkout\n end\n end\n threads.each {|x| x.join}\n end",
"def thread_writer(*names)\n ThreadAccessor.each(*names) do |key, meth|\n define_method(\"#{meth}=\"){|obj| Thread.current[key] = obj }\n end\n end",
"def generate *args\n generator = generator_for *args\n generator.generate\n end",
"def generate *args\n generator = generator_for *args\n generator.generate\n end",
"def worker\n # Wait until we have space for you\n sleep(0.1) until (Thread.list.size < @numthreads)\n\n Thread.new do\n yield\n end\n end",
"def build_threads\n @queue_threads.times { @threads << Queue.new }\n @retry_threads.times { @threads << Retry.new }\n end",
"def start_writer\n Thread.new {\n done = false\n waiting = false\n while !done do\n next_value = WriteQueue.next\n unless next_value.nil?\n waiting = false\n puts \"\\n\"\n puts \"Writer: writing #{next_value}\"\n # Append value to file\n File.open('out.txt', 'a') { |file| file.write(\"#{next_value[:timestamp]}: #{next_value[:value]}\\n\") }\n else\n unless waiting\n puts \"\\n\"\n print \"Writer: waiting\"\n waiting = true\n else\n print \".\"\n sleep(1)\n end\n end\n end\n }\nend",
"def write_incoming_messages_to_child_processes(master_reader, client_writers)\n Thread.new do\n while incoming = master_reader.gets\n client_writers.each do |writer|\n writer.puts incoming\n end\n end\n end\nend",
"def generate_thread(source_url)\n begin\n source_url.each_slice(@@thread_size) do |batch|\n threads = []\n batch.each do |u|\n threads << Thread.new { get_all_links(u) }\n end\n threads.each { |thr| thr.join }\n end\n Thread.list.each do |thread|\n thread.exit unless thread == Thread.current\n end\n rescue Exception => e\n puts \"Exception occurred In Thread #{e.message}\"\n unless @@retry_counter != 0\n puts \"Retrying .....\"\n @@retry_counter = 1\n retry\n end\n end\n end",
"def bulk_generate\n\n end",
"def setup_runners\n @runners = (0...@number_of_threads).map do |i|\n Thread.new(abort_on_exception: true) do\n @logger.debug(\"UPDATE HANDLER\") { \"Runner #{i} ready for duty\" }\n loop do\n change = subject = index_types = type = nil\n begin\n @mutex.synchronize do\n if @queue.length > 0 && (DateTime.now - @queue[0][:timestamp]) > @min_wait_time\n change = @queue.shift\n subject = change[:subject]\n type = change[:type]\n index_types = @subject_map.delete(subject)\n end\n end\n if !change.nil?\n large_queue = 500\n if (@queue.length > large_queue) && (large_queue % @number_of_threads == 0)\n # log only once per nb_of_threads\n @logger.warn(\"UPDATE HANDLER\") { \"Large number of updates (#{@queue.length}) in queue\" }\n end\n @logger.debug(\"UPDATE HANDLER\") { \"Handling update of #{subject}\" }\n handler(subject, index_types, type)\n end\n rescue StandardError => e\n @logger.error(\"UPDATE HANDLER\") { \"Update of subject <#{subject}> failed\" }\n @logger.error(\"UPDATE HANDLER\") { e.full_message }\n end\n sleep 5\n end\n end\n end\n end",
"def generate_pages(count: , &block)\n dir = @dir.join(\"pages\")\n FileUtils.mkdir_p dir.join(\"pages\")\n next_page_name.take(count).map do |page_name|\n path = dir.join(page_name)\n block ? block.call(path) : File.write(path, '<h1>Some glorius content!</h1>')\n @pages.push path\n end\n end",
"def generate\n puts @root\n \n puts \"Processing files ...\"\n start_time = Time.now\n puts \"start --\"\n\n # getting list of committers\n puts \"Getting list of committers ...\"\n @committers = `git log --raw | grep \"^Author:\" | sort | uniq | sed -e 's/^Author: //g' -e 's/<.*//g'`.split(\"\\n\")\n @committers.uniq!\n\n # creaing an html file\n html_composer = HtmlComposer.new(@root, @report_path)\n html_composer.write_html_header\n\n files = FileList.new() do |f|\n @excluded_files.each { |e| \n f.exclude(e)\n puts \"Excluded #{e}\" \n }\n end\n @included_files.each do |i|\n files.add(i)\n end\n\n FileUtils.mkdir_p \"#{@root}/gs_temp\"\n Parallel.each(files, :in_processes => @config[:in_processes]) do |path|\n process_file(html_composer, path)\n end\n FileUtils.rm_r \"#{@root}/gs_temp\"\n\n # closing the html file\n html_composer.write_html_footer\n\n puts \"\"\n puts \"-- end\"\n\n elapsed_time = (Time.now - start_time).round(2)\n puts \"Processed in #{elapsed_time} secs\"\n end",
"def run\n return if @files.empty?\n $stderr.write @files.inspect+\"\\n\"; $stderr.flush\n @cores.times do |c|\n @pipes << PipeDream.new\n @children << SafeFork.fork do\n Signal.trap(\"TERM\") { exit }\n Signal.trap(\"HUP\") { exit }\n pipe = @pipes.last\n pipe.identify_as_child\n pipe.write(\"[Worker #{c}] Booted\\n\")\n @result = Test::Unit::TestResult.new\n @result.add_listener(Test::Unit::TestResult::FAULT) do |value|\n $stderr.write value\n $stderr.write \"\\n\\n\"\n $stderr.flush\n end\n while !pipe.eof?\n file = pipe.gets.chomp\n begin\n pipe.write \"[Worker #{c} Starting: #{file}\\n\"\n start = Time.now\n\n klasses = Multitest.find_classes_in_file(file)\n klasses.each{|k| k.suite.run(@result){|status, name| ;}}\n \n finish = Time.now\n pipe.write \"[Worker #{c}] Completed: #{file} (#{finish-start})\\n\"\n rescue => ex\n pipe.write \"[Worker #{c}] Failed: #{file} - #{ex.to_s}\\n\"\n end\n end\n $stderr.write @result.to_s\n $stderr.write \"\\n\"\n $stderr.flush\n pipe.close\n end\n end\n\n total_files = @files.size\n @threads = []\n @pipes.each do |_p|\n @threads << Thread.new(_p) do |p|\n Signal.trap(\"TERM\") { exit }\n p.identify_as_parent\n # boot message\n p.gets\n while !@files.empty? \n # puts \"#{total_files - @files.size}/#{total_files}\"\n # send a file\n p.write(\"#{@files.pop}\\n\")\n # print the start message\n msg = p.gets\n # $stdout.write msg; $stdout.flush\n # wait for the complete message\n msg = p.gets\n # print complete message\n if msg =~ /Completed/\n # $stdout.write msg; $stdout.flush\n else\n $stderr.write msg; $stderr.flush\n end\n end\n p.close\n end\n end\n\n Signal.trap(\"TERM\") do\n puts \"Exiting\"\n @children.each{|c| Process.kill(\"TERM\",c)}\n @threads.each{|t| Thread.kill(t)}\n end\n\n @threads.each{|t| t.join}\n @children.each{|c| Process.wait(c)}\n end",
"def create_executor_threads(queue, id, reporter_factory)\n Thread.new do\n begin\n while file = queue.pop(true)\n runner = TestRunner::SingleTestRunner.new(\n file, id, reporter_factory, $root_dir, $report_dir)\n runner.process_single\n end\n rescue ThreadError => e # for queue.pop, suppress\n rescue Interrupt => e\n TestRunner.print_exception e\n interrupted = true\n rescue SignalException => e\n TestRunner.print_exception e\n interrupted = true\n rescue Exception => e\n TestRunner.print_exception e\n interrupted = true\n end\n end\nend",
"def run\r\n @cordinators.each do |c|\r\n @threads << Thread.new do\r\n c.run\r\n end\r\n end\r\n end",
"def create_workers\n MAX_WORKERS.times do\n @workers.push(DownloadWorker.new(self))\n end\n end",
"def generate_me(generator)\n generator.generate self\n end",
"def player_token_generators\n (1..@player_count).map { |player| player_token_generator(player) }\n end",
"def bulk_writer request_threads: nil, batch_threads: nil, retries: nil\n BulkWriter.new self, @service, request_threads: request_threads,\n batch_threads: batch_threads, retries: retries\n end",
"def generate; end",
"def generate; end",
"def cosine_parallel\n @time1 = Time.now\n documents = []\n read_threads = []\n #file1\n thread1 = Thread.new{\n file1 = File.read(Rails.root.join('public/files/d1a7.allKeys')).split(\"\\n\")\n @doc1 = {}\n file1.each_with_index do |line,index| \n data = line.split(\" \")\n @doc1[data[0]] = data[1]\n end\n }\n #file2\n thread2 = Thread.new{\n file2 = File.read(Rails.root.join('public/files/d1au.allKeys')).split(\"\\n\")\n @doc2 = {}\n file2.each_with_index do |line,index| \n data = line.split(\" \")\n @doc2[data[0]] = data[1] \n end\n }\n #file3\n thread3 = Thread.new{\n file3 = File.read(Rails.root.join('public/files/d1dl.allKeys')).split(\"\\n\")\n @doc3 = {}\n file3.each_with_index do |line,index| \n data = line.split(\" \")\n @doc3[data[0]] = data[1]\n end\n }\n #file4\n thread4 = Thread.new{\n file4 = File.read(Rails.root.join('public/files/d1h8.allKeys')).split(\"\\n\")\n @doc4 = {}\n file4.each_with_index do |line,index| \n data = line.split(\" \")\n @doc4[data[0]] = data[1]\n end\n }\n #file5\n thread5 = Thread.new{\n file5 = File.read(Rails.root.join('public/files/d1lt.allKeys')).split(\"\\n\")\n @doc5 = {}\n file5.each_with_index do |line,index| \n data = line.split(\" \")\n @doc5[data[0]] = data[1]\n end\n }\n #file6\n thread6 = Thread.new{\n file6 = File.read(Rails.root.join('public/files/d1q3.allKeys')).split(\"\\n\")\n @doc6 = {}\n file6.each_with_index do |line,index| \n data = line.split(\" \")\n @doc6[data[0]] = data[1]\n end \n }\n thread1.join\n thread2.join\n thread3.join\n thread4.join\n thread5.join\n thread6.join\n @documents = [@doc1,@doc2,@doc3,@doc4,@doc5,@doc6] \n #cosine Similarity\n @similarities = []\n arr = [] \n (0..5).each do |ind|\n data_array = []\n arr[ind] = Thread.new{\n (0..ind).each do |indj|\n num = 0\n denom1 = 0\n denom2 = 0\n @documents[ind].each do |k,v|\n if (!@documents[indj][k].nil?) && (@documents[indj][k].to_i > 0) && (@documents[ind][k].to_i > 0)\n num += @documents[ind][k].to_i*@documents[indj][k].to_i\n denom1 += @documents[ind][k].to_i*@documents[ind][k].to_i\n denom2 += @documents[indj][k].to_i*@documents[indj][k].to_i\n end \n end\n sq_rt_denom1 = Math.sqrt(denom1)\n sq_rt_denom2 = Math.sqrt(denom2)\n @similarity = (num.to_f)/(sq_rt_denom1.to_f * sq_rt_denom2.to_f) #/\n data_array << @similarity\n end\n }\n @similarities << data_array\n end\n arr.each {|t| t.join; }\n @time2 = Time.now\n end",
"def process\n self.generate\n end",
"def generate(depth=0)\n return \"Task\" if depth>7\n return \"seq #{generate(depth+1)} end\" if depth==0\n which = rand(OPERATORS.length)\n case which\n when 0\n \"Task\"\n else\n raise unless OPERATORS[which]\n buffer = \"#{OPERATORS[which]} \"\n 0.upto(rand(5)+1) do \n buffer << generate(depth+1) << \" \"\n end\n buffer << \"end\"\n buffer\n end\n end",
"def generate_users\n User.destroy_all\n Profile.destroy_all\n\n puts 'Generating users'\n\n MULTIPLIER.times do\n first_name = Faker::Name.first_name\n last_name = Faker::Name.last_name\n username = Faker::Company.name\n email = Faker::Internet.free_email(\"#{first_name} #{last_name}\")\n\n user = User.new(email: email, password: 'qwerqwer')\n user.build_profile(first_name: first_name, last_name: last_name, username: username)\n user.save!\n end\nend",
"def fibering_files_lines_output\n# include ApplicationHelper # uncomment for console use\n# require './lib/sequencerings/textualfibers.rb' # uncomment for console use\n# include Textualfibers # uncomment for console use\n consumer = Fiber.new do |producer, queue|\n f = File.open(\"./lib/databasers/fibered_files_output.txt\", \"a\") do |f|\n queue = \"linezero\"\n loop do\n queue = producer.transfer(consumer, queue)\n break unless queue\n f.puts << queue\n queue.clear\n end\n raise StopIteration\n end\n end\n producer = Fiber.new do |consumer, queue|\n queue = \"firststring\"\n puts queue\n open(\"./tmp/insert_research_lines.txt\", \"r\") do |f|\n #open(\"./tmp/insert_research_lines-02.txt\", \"r\") do |f|\n #open(\"./lib/databasers/fibered_files_input.txt\", \"r\") do |f|\n f.each do |line|\n sequence_text = line.to_textual.de_comma \n sequence_creation = sequence_text.to_textual.de_comma.de_space\n sequence_complete = sequence_text.to_textual.de_comma.split(//).sort.join('').strip unless nil\n sequence_lexigram = lexigram_sequencer(sequence_text) unless nil\n sequence_singular = sequence_complete.squeeze\n description = \"research materials\"\n reference = \"net\"\n anagram = 0\n name = 0\n phrase = 0\n research = 1\n external = 0\n internal = 0\n queue = \"#{sequence_text}\\t#{sequence_creation}\\t#{sequence_complete}\\t#{sequence_lexigram}\\t#{sequence_singular}\\t#{description}\\t#{reference}\\t#{anagram}\\t#{name}\\t#{phrase}\\t#{research}\\t#{external}\\t#{internal}\\t#{Time.now}\"\n break unless f\n consumer.transfer queue\n queue.clear\n end\n raise StopIteration\n end\n end\n consumer.transfer(producer, [])\n after_break\n end",
"def generate()\n\t\t\t@out = []\n\t\t\t@context = []\n\n\t\t\ttrim_nil_lines\n\n\t\t\t@lines.each_with_index do |line, i|\n\t\t\t\twrite_with_context(line.line, line.context, next_context(i))\n\t\t\tend\n\t\t\twrite_with_context(nil, [], [])\n\t\t\treturn @out.join\n\t\tend",
"def generate_next\n @block.call(@so_far)\n end",
"def create_workers\n job_queue = create_work_queue\n\n POOL_SIZE.times.map do\n Thread.new { worker_method(job_queue) }\n end\n end",
"def walk_user_threads\n user_threads_lock.synchronize do\n user_threads.each do |user_id, user_thread|\n yield(user_id, user_thread)\n end\n end\n end",
"def spawn_threads!\n @threads = []\n num_worker_threads.times do |thread_num|\n log(:debug) { \"Spawning background worker thread #{thread_num}.\" }\n\n @threads << Thread.new do\n Thread.current[:influxdb] = object_id\n\n until @should_stop\n check_background_queue(thread_num)\n sleep rand(sleep_interval)\n end\n\n log(:debug) { \"Exit background worker thread #{thread_num}.\" }\n end\n end\n end",
"def generate\n # Refill the population with children from the mating pool\n @population.each_index do |i|\n partner_a = @mating_pool[rand(0...@mating_pool.size)]\n partner_b = @mating_pool[rand(0...@mating_pool.size)]\n child = partner_a.crossover(partner_b)\n child.mutate(@mutation_rate)\n @population[i] = child\n end\n @generations += 1\n end",
"def generate\n # Refill the population with children from the mating pool\n @population.each_index do |i|\n partner_a = @mating_pool[rand(0...@mating_pool.size)]\n partner_b = @mating_pool[rand(0...@mating_pool.size)]\n child = partner_a.crossover(partner_b)\n child.mutate(@mutation_rate)\n @population[i] = child\n end\n @generations += 1\n end",
"def producer; end",
"def run\n super\n\n # TODO - this shouldn't be static\n f = download_and_store \"https://s3.amazonaws.com/public.intrigue.io/top-1m-2018-04-20.csv\"\n\n # Read and split the file up into a list of domains\n lines = File.open(f,\"r\").read.split(\"\\n\")\n domains = lines.map{|l| l.split(\",\").last.chomp }\n\n lammylam = lambda { |d|\n sleep(rand(_get_option(\"max_sleep\")))\n #_log \"Creating sites for domain: #{d}\"\n #_create_entity \"Uri\", { \"name\" => \"http://#{d}\", \"uri\"=>\"https://#{d}\" }\n _create_entity \"Uri\", { \"name\" => \"https://#{d}\", \"uri\"=>\"https://#{d}\" }\n true\n }\n\n # use a generic threaded iteration method to create them,\n # with the desired number of threads\n thread_count = _get_option \"threads\"\n _threaded_iteration(thread_count, domains, lammylam)\n\n end",
"def work\n @w.each{|w|\n @t << Thread.new(w, self){|w, d|\n w.work(d)\n }\n }\n end",
"def generate(depth=0)\n return \"Task\" if depth>7\n return \"seq #{generate(depth+1)} end\" if depth==0\n which = rand(OPERATORS.length)\n case which\n when 0\n \"Task\"\n else\n raise unless OPERATORS[which]\n buffer = \"#{OPERATORS[which]} \"\n 0.upto(rand(4)+1) do \n buffer << generate(depth+1) << \" \"\n end\n buffer << \"end\"\n buffer\n end\n end",
"def next\n @mutex.lock\n begin\n counter = @counter = (@counter + 1) % 0xFFFFFF\n ensure\n @mutex.unlock rescue nil\n end\n\n generate(Time.new.to_i, counter)\n end",
"def concurrently\n map{ |item| Thread.new{ yield item } }.each{ |t| t.join }\n end",
"def initialize(options = {})\n @options = options\n @lock = Mutex.new\n @generators = @options[\"generators\"].map do |h|\n generator_name = h[\"name\"]\n \"Nagoriyuki::Generators::#{generator_name.classify}\".constantize.new(h)\n end\n end",
"def simulate(lines,numTrains,passengers,simMonitor)\r\n p_threads = [] #ok\r\n t_threads = [] #ok\r\n stations = {}\r\n trains = {} \r\n \r\n init_lines = {}\r\n ret_lines = {}\r\n lines.each{|k,v|\r\n init_lines[k] = v[1..v.length-1]\r\n } \r\n lines.each{|k,v|\r\n ret_lines[k] = v[0..v.length-2].reverse\r\n }\r\n \r\n @lines = lines\r\n @passengers = passengers\r\n @numTrains = numTrains\r\n \r\n metro_lines = lines.keys #array of the metrolines. red, blue, yellow etc\r\n people = passengers.keys\r\n \r\n metro_lines.each{|i| #access the stations in each metroline\r\n station_names = lines[i]\r\n station_names.each{|j|\r\n if stations[j] == nil\r\n stations[j] = {} #hash for metroline\r\n end\r\n \r\n if stations[j][i] == nil\r\n stations[j][i] = {} #hash for trains at station (for line) CHECK IF POPULATED\r\n end\r\n stations[j][\"passenger\"] = {} #hash for passengers at station \r\n }\r\n }\r\n \r\n @stations = stations\r\n for i in 0...people.length\r\n itin = passengers[people[i]] \r\n first_stop = itin[0]\r\n stations[first_stop][\"passenger\"][people[i]] = true\r\n end \r\n \r\n @passengers.each{|p,val|\r\n @check[p] = false\r\n }\r\n \r\n @simMonitor = simMonitor\r\n @simMonitor.each{|a,b |\r\n @t_cond[a] = b.new_cond\r\n @p_cond[a] = b.new_cond\r\n }\r\n \r\n numTrains.each{|key,val|\r\n index = val\r\n begin\r\n @trains[key + \" \" + index.to_s] = {}\r\n index -= 1\r\n end until(index == 0)\r\n }\r\n\r\nindex = 0\r\n@trains.each{|key,val|\r\n index = index + 1\r\n t_threads.push(\r\n Thread.new do\r\n train_work(@lines, index , numTrains, @passengers, @stations, trains, key, @t_cond, @p_cond)\r\n \r\n if(passengers.empty?)\r\n train_work(ret_lines, index , numTrains, passengers, stations, trains, key, @t_cond, @p_cond)\r\n train_work(init_lines, index , numTrains, passengers, stations, trains, key, @t_cond, @p_cond) \r\n else \r\n until(!@check.values.include?(false))\r\n train_work(ret_lines, index , numTrains, passengers, stations, trains, key, @t_cond, @p_cond)\r\n train_work(init_lines, index , numTrains, passengers, stations, trains, key, @t_cond, @p_cond)\r\n end\r\n end\r\n end\r\n )\r\n }\r\n \r\n @check.each{|p, val|\r\n itinerary = @passengers[p]\r\n p_threads.push(\r\n Thread.new do\r\n passenger_work(itinerary, lines, p)\r\n @check[p] = true\r\n end\r\n \r\n )\r\n }\r\n \r\n \r\n p_threads.each{|x|\r\n x.join\r\n }\r\n t_threads.each{|x|\r\n x.join \r\n }\r\n \r\n end",
"def serve(*use_tasks)\n Thread.current[:name] = 'main'\n begin\n @startt = @global_startt = Time.now\n #\n # Create a list of tasks taken from the topoligically sorted chain of tasks, start with the initial task\n # and ending with the terminal task\n #\n if use_tasks.empty?\n tasks = config.tsort.map { |name| config.lookup_task(name) }\n else\n tasks = config.tsort.map { |name| use_tasks.include?(name) ? config.lookup_task(name) : nil }\n tasks.compact!\n end\n\n Task::Config::Compile::TaskDecl.attach_logger(logger)\n\n logger.info \"Number of tasks: #{tasks.length}\"\n\n #\n # Extract producers and consumers from task topoloty\n #\n @ptasks = tasks.select { |task| task.producer? && proc_id == proc_count - 1 }\n @ctasks = tasks.select { |task| task.consumer? }\n #\n # Set up the connection pool\n #\n @@con_pool = @con_pool = ConnectionPool.new(ctasks.map(&:name), 1, csettings)\n #\n # Set up the main Producer and Consumer objects\n #\n @consumers = @ctasks.map { |task| Consumer.new(task, con_pool, jobq) }\n @producers = @ptasks.map { |task| Producer.new(task, con_pool, thpool) }\n #\n # Invoke the producers\n #\n producers.each { |p| p.start }\n #\n # Fire up the consumers\n #\n consumers.each { |c| c.start }\n #\n # Print statistics every 10 secs\n #\n print_reocurring_status()\n #\n # Main loop\n #\n logger.info \"Entering Main Loop\"; flush()\n loop {\n thpool.run_deferred_callbacks()\n thpool.defer(*jobq.pop) until jobq.empty?\n break if complete\n sleep(0.001)\n }\n finish()\n #\n # And that's all folks...\n #\n rescue => e\n error \"#{e.class}: #{e.message}\"\n error e.backtrace.join(\"\\n\")\n raise\n end\n end",
"def generate()\n objects = []\n\n # generate object file tasks\n files.each do |fname|\n output_file = File.join(@build_dir, File.basename(fname).ext('o'))\n objects.push output_file\n file output_file => [ fname ] do\n get_toolchain().compile( fname, output_file )\n end\n end\n\n # Link object files\n file output_file() => objects do\n get_toolchain().link( objects, output_file() )\n end\n\n # Create top level task\n desc \"Build the #{@name} application\"\n task @name => [ output_file() ]\n end",
"def iterateCrawlerTable\n step_size = 15\n (0..getCrawlerCount).step(step_size) do |i|\n db.execute(\"SELECT * FROM #{@crawlerTable} LIMIT #{step_size} OFFSET #{i}\").each do |beer|\n yield BeerModel.new(beer)\n end\n end\n end",
"def generators\n @generators ||= []\n end",
"def generators\n @generators ||= []\n end",
"def generate()\n prepare\n ::Dir.mkdir(@output_path) unless ::File.exists? @output_path\n\n @pages.each do |name, page|\n SiteLog.debug(\"Starting page generation - #{name}\")\n page.generate(@output_path, @version, @preserve_tree)\n SiteLog.debug(\"Finished page generation - #{name}\")\n end\n\n @files.each do |path, data|\n path = ::File.join(@output_path, path)\n ::FileUtils.mkdir_p(::File.dirname(path))\n ::File.open(path, \"w\") do |f|\n f.write(data)\n end\n end\n end",
"def serve(*use_tasks)\n begin\n Signal.trap('INT') { con_pool.shutdown if con_pool; EM.stop; }\n Signal.trap('TERM'){ con_ppol.shutdown if con_pool; EM.stop; }\n #\n #\n #\n @connection_count = 10\n startt = global_startt = Time.now\n #\n # Enable fiber away methods\n #\n #con.fiber!\n #\n # Create a list of tasks taken from the topoligically sorted chain of tasks, start with the initial task\n # and ending with the terminal task\n #\n if use_tasks.empty?\n tasks = config.tsort.map { |name| config.lookup_task(name) }\n else\n tasks = config.tsort.map { |name| use_tasks.include?(name) ? config.lookup_task(name) : nil }\n tasks.compact!\n end\n\n info \"Number of tasks: #{tasks.length}\"\n\n EM.error_handler { |e| puts \"[#{proc_id}] Error raised during event loop: #{e.message}\" }\n #\n # Extract producers and consumers from task topoloty\n #\n producers = tasks.select { |task| task.parent.nil? && proc_id.zero? }\n @consumers = tasks.select { |task| task.parent }\n #\n # Set up the connection pool\n #\n @con_pool = ConnectionPool.new(consumers, connection_count)\n #\n # Invode the producers\n #\n EM.add_timer(2) {\n producers.each do |task|\n logger.debug \"Producer #{task.name} invoked\" if verbose\n task.eval_body([])\n end\n }\n #\n # Set up the callbacks and the queue for each consumer task\n #\n @stats_hash = consumers.inject({}) { |m,k| m[k.name] = OpenStruct.new(:recv => 0, :completed => 0, :results_len => 0); m }\n\n 2.times do |i|\n consumers.each do |task|\n completer = proc do |results|\n unless task.targets.empty?\n if results.respond_to?(:each) && results.length > 0\n @stats_hash[task.name].results_len += results.length\n @spawned_procs <<\n [ EM.spawn { |task, con_pool, results|\n results.each do |result|\n outgoing_msg = Message.new(task, result)\n outgoing_msg.deliver(con_pool)\n end\n }, task, con_pool, results ]\n elsif not results.is_a? Enumerable\n @stats_hash[task.name].results_len += 1\n outgoing_msg = Message.new(task, results)\n outgoing_msg.deliver(con_pool)\n end\n end\n @stats_hash[task.name].completed += 1\n adjust_deferred_jobs(-1)\n end\n\n $stderr.puts \"Creating #{task.name} input queue ##{i}\"\n channel = con_pool.take(task)\n channel.con.async_each_job do |job|\n adjust_deferred_jobs(1)\n msg = Message.receive(task, job.body)\n @stats_hash[task.name].recv += 1\n job.delete\n EM.defer(nil, completer) do\n begin\n task.eval_body(msg.restored_obj) #returns results\n rescue => e\n $stderr.puts \"#{e.class}: #{e.message}\"\n $stderr.puts(e.backtrace.join(\"\\n\"))\n raise\n end\n end\n end\n end\n end\n\n EM.add_periodic_timer(0.01) do\n while (tuple = @spawned_procs.shift) do\n sproc, task, con_pool, results = tuple\n sproc.notify(task, con_pool, results)\n end\n end\n\n stat_timer = EM.add_periodic_timer(5) do\n print_stats(:timeseries_args, :rsi_trigger_14)\n end\n\n tcount = 0\n EM.add_periodic_timer(10) do\n iqlen = delivery_q.size\n $stderr.puts(\"[#{proc_id}:#{tcount +=1}:#{iqlen}] Defers: #{adjust_deferred_jobs(0)}\\t \"+\n \"Msg: #{Message.sent_messages}:#{Message.received_messages}\")\n if no_activity?(Message.sent_messages, Message.received_messages)\n puts \"No message activity...initiating stop\"\n stat_timer.cancel\n finish(startt)\n end\n end\n\n postman = proc { |msg|\n msg.deliver(con_pool)\n delivery_q.pop(&postman)\n }\n delivery_q.pop(&postman)\n\n rescue => e\n $stderr.puts \"#{e.class}: #{e.message}\"\n $stderr.puts(e.backtrace.join(\"\\n\"))\n raise\n end\n end",
"def gen_128_16_std_breqd_benchmark(folder)\n 10.times do | size |\n 10.times do | seed |\n # 2048 * (2**0) = 2048 = 2**11 ~= 2*10^3\n # ...\n # 2048 * (2**9) = 1048576 = 2**20 ~= 10^6\n n = 2048 * (2**size)\n inst_str = gen_128_16_std_breqd_instance(n, seed)\n filepath = File.expand_path(\"128_16_std_breqd-n#{n}-s#{seed}.ukp\", folder)\n File.open(filepath, 'w+') do | f |\n f.write(inst_str)\n end\n end\n end\nend",
"def genFileNames\n\t\t@x = self.gen(@num).join()\n\t\t@num += 1\n\t\treturn @x\n\tend",
"def process_all_db(blast_result_hash,gbff_dir,seq_dir,flanking_res)\n gbff_files = Array.new\n numbThreads = 3\n gbff_files =Dir.glob(\"#{seq_dir}/*.seq\")\n gbff_files.concat(Dir.glob(\"#{gbff_dir}/*.gbff\"))\n gbff_files.each do |gbff_file|\n process_single_db(blast_result_hash,flanking_res,gbff_file)\n #print(\"#{Thread.list.size}\\n\")\n # if(Thread.list.size < numbThreads)\n # a = Thread.new{process_single_db(blast_result_hash,flanking_res,gbff_file)}\n # a.run\n #else\n # Thread.list.each do |thr|\n # thr.join\n # end\n #end\n end\n #output all the unseen items in the database to the insufficient DNA database\n blast_result_hash.each do |key,value|\n if(value.output_to_db == false)\n output_blast_hit(value)\n end\n end\nend",
"def i_generate\n yield 1\n yield 2\nend",
"def process(io_stream)\n settings.fill_in_defaults!\n\n count = 0\n start_time = batch_start_time = Time.now\n logger.debug \"beginning Indexer#process with settings: #{settings.inspect}\"\n\n reader = self.reader!(io_stream)\n writer = self.writer!\n\n\n processing_threads = settings[\"processing_thread_pool\"].to_i\n thread_pool = Traject::ThreadPool.new(processing_threads)\n\n logger.info \" Indexer with #{processing_threads} processing threads, reader: #{reader.class.name} and writer: #{writer.class.name}\"\n\n log_batch_size = settings[\"log.batch_size\"] && settings[\"log.batch_size\"].to_i\n\n reader.each do |record; position|\n count += 1\n\n # have to use a block local var, so the changing `count` one\n # doesn't get caught in the closure. Weird, yeah.\n position = count\n\n thread_pool.raise_collected_exception!\n\n if settings[\"debug_ascii_progress\"].to_s == \"true\"\n $stderr.write \".\" if count % settings[\"solr_writer.batch_size\"].to_i == 0\n end\n\n if log_batch_size && (count % log_batch_size == 0)\n batch_rps = log_batch_size / (Time.now - batch_start_time)\n overall_rps = count / (Time.now - start_time)\n logger.send(settings[\"log.batch_size.severity\"].downcase.to_sym, \"Traject::Indexer#process, read #{count} records at id:#{id_string(record)}; #{'%.0f' % batch_rps}/s this batch, #{'%.0f' % overall_rps}/s overall\")\n batch_start_time = Time.now\n end\n\n # we have to use this weird lambda to properly \"capture\" the count, instead\n # of having it be bound to the original variable in a non-threadsafe way.\n # This is confusing, I might not be understanding things properly, but that's where i am.\n #thread_pool.maybe_in_thread_pool &make_lambda(count, record, writer)\n thread_pool.maybe_in_thread_pool(record, settings, position) do |record, settings, position|\n context = Context.new(:source_record => record, :settings => settings, :position => position)\n context.logger = logger\n map_to_context!(context)\n if context.skip?\n log_skip(context)\n else\n writer.put context\n end\n\n end\n\n end\n $stderr.write \"\\n\" if settings[\"debug_ascii_progress\"].to_s == \"true\"\n\n logger.debug \"Shutting down #processing mapper threadpool...\"\n thread_pool.shutdown_and_wait\n logger.debug \"#processing mapper threadpool shutdown complete.\"\n\n thread_pool.raise_collected_exception!\n\n\n writer.close if writer.respond_to?(:close)\n\n @after_processing_steps.each do |step|\n begin\n step.execute\n rescue Exception => e\n logger.fatal(\"Unexpected exception #{e} when executing #{step}\")\n raise e\n end\n end\n\n elapsed = Time.now - start_time\n avg_rps = (count / elapsed)\n logger.info \"finished Indexer#process: #{count} records in #{'%.3f' % elapsed} seconds; #{'%.1f' % avg_rps} records/second overall.\"\n\n if writer.respond_to?(:skipped_record_count) && writer.skipped_record_count > 0\n logger.error \"Indexer#process returning 'false' due to #{writer.skipped_record_count} skipped records.\"\n return false\n end\n\n return true\n end",
"def generate\n end",
"def generators\n @generators ||= {}\n end",
"def iterate &block\r\n threads = []\r\n @providers.each do |browser|\r\n threads << Thread.new do\r\n yield browser\r\n end\r\n end\r\n threads.each {|thread| thread.join}\r\n end",
"def generate_and_stream_segments\n NewRelic::Agent::InfiniteTracing::Client.any_instance.stubs(:handle_close).returns(nil)\n unstub_reconnection\n server_context = nil\n with_config fake_server_config do\n # Suppresses intermittent fails from server not ready to accept streaming\n # (the retry loop goes _much_ faster)\n Connection.instance.stubs(:retry_connection_period).returns(0.01)\n nr_freeze_time\n nr_freeze_process_time\n\n simulate_connect_to_collector fake_server_config do |simulator|\n # starts server and simulated agent connection\n server_context = ServerContext.new FAKE_SERVER_PORT, InfiniteTracer\n simulator.join\n\n yield\n\n # ensures all segments consumed\n NewRelic::Agent.agent.infinite_tracer.flush\n server_context.flush\n server_context.stop\n\n return server_context.spans\n ensure\n Connection.instance.unstub(:retry_connection_period)\n NewRelic::Agent.agent.infinite_tracer.stop\n server_context.stop unless server_context.nil?\n reset_infinite_tracer\n nr_unfreeze_time\n nr_unfreeze_process_time\n end\n end\n end",
"def start_next\n\t@last_wave_ended = false\n\t@number += 1\n\t@current_monsters = monsters\n\t\n\tthreads << Thread.new do\n\t loop do\n\t sleep Config.push_monster_every\n\t break unless Game.running?\n\t next if Game.paused?\n\t break if @current_monsters.size == 0\n\t \n\t Game.scene.create_monster @current_monsters.pop\n\t end\n\t @last_wave_ended = true\n\tend\n end",
"def test_off_thread_creation\n counter = 0\n @loop.add_once {\n Thread.new {\n @loop.add_fiber {\n counter += 3\n @loop.yield\n counter += 5\n counter += @loop.yield { |task| task.done(7) }\n counter += @loop.yield_from_thread {\n sleep 0.1\n @loop.add_once(0.2) { @loop.quit }\n 11\n }\n }\n }\n }\n\n @loop.run\n\n assert_equal 26, counter\n end",
"def worker_pool; end",
"def worker_pool; end",
"def initialize\n @threads = []\n end",
"def generate\n map(&:generate)\n end",
"def write_nonblock\n end",
"def run_these_cases(current_task_files)\n\n \n $RunResults = Hash.new \n $choicefiles = Array.new\n $PIDS = Array.new\n $FinishedTheseFiles = Hash.new \n $RunNumbers = Array.new\n \n $CompletedRunCount = 0 \n $FailedRunCount = 0 \n \n ## Create working directories \n \n $headerline = \"\" \n $outputHeaderPrinted = false \n \n \n current_task_files.each do |choicefile|\n $FinishedTheseFiles[choicefile] = false \n end \n \n $choicefileIndex = 0 \n numberOfFiles = $FinishedTheseFiles.count {|k| k.include?(false)}\n\n \n stream_out (\" - HTAP-prm: begin runs ----------------------------\\n\\n\")\n \n $choicefileIndex = 0 \n $RunsDone = false \n \n $csvColumns = Array.new \n \n # Loop until all files have been processed. \n $GiveUp = false \n \n while ! $RunsDone \n\n $batchCount = $batchCount + 1 \n\n \n stream_out (\" + Batch #{$batchCount} ( #{$choicefileIndex}/#{numberOfFiles} files processed so far...) \\n\" )\n if ( $batchCount == 1 && $snailStart ) then \n \n stream_out (\" |\\n\") \n stream_out (\" +-> NOTE: \\\"SnailStart\\\" is active. Waiting for #{$snailStartWait} seconds between threads (on first batch ONLY!) \\n\\n\")\n \n end \n\n # Empty arrays for current batch. \n $choicefiles.clear\n $PIDS.clear \n $SaveDirs.clear\n \n \n # Compute the number of threads we will start: lesser of a) files remaining, or b) threads allowed.\n $ThreadsNeeded = [$FinishedTheseFiles.count {|k| k.include?(false)}, $gNumberOfThreads].min \n \n #=====================================================================================\n # Multi-threaded runs - Step 1: Spawn threads. \n for thread in 0..$ThreadsNeeded-1 \n \n # For this thread: Get the next choice file in the batch. \n $choicefiles[thread] = current_task_files[$choicefileIndex] \n \n # Get the name of the .h2k file for this thread. \n $H2kFile = $gArchetypeHash[$choicefiles[thread]]\n $Ruleset = $gRulesetHash[$choicefiles[thread]]\n $Location = $gLocationHash[$choicefiles[thread]]\n \n count = thread + 1 \n #stream_out (\" - Starting thread : #{count}/#{$ThreadsNeeded} for file #{$choicefiles[thread]} \")\n stream_out (\" - Starting thread #{count}/#{$ThreadsNeeded} for sim ##{$choicefileIndex+1} \")\n \n \n # For this thread: Get the next choice file in the batch. \n #$choicefiles[thread] = $RunTheseFiles[$choicefileIndex] \n \n \n # Make sure that's a real choice file ( this just duplicates a test above )\n if ( $choicefiles[thread] =~ /.*choices$/ )\n \n # Increment run number and create name for unique simulation directory\n $RunNumber = $RunNumber + 1 \n $RunDirectory = $RunDirs[thread]\n \n \n $SaveDirectory = \"#{$SaveDirectoryRoot}-#{$RunNumber}\"\n \n # Store run number and directory for this thread \n $RunNumbers[thread] = $RunNumber\n $SaveDirs[thread] = $SaveDirectory \n\n # create empty run directory\n if ( ! Dir.exist?($RunDirectory) )\n if ( ! Dir.mkdir($RunDirectory) )\n fatalerror( \" Fatal Error! Could not create #{$RunDirectory} below #{$gMasterPath}!\\n MKDir Return code: #{$?}\\n\" )\n end \n \n else \n # Delete contents, but not H2K folder\n FileUtils.rm_r Dir.glob(\"#{$RunDirectory}/*.*\") \n end \n \n \n \n \n # Copy choice and options file into intended run directory...\n if $choicesInMemory\n choicefile = File.open(\"#{$RunDirectory}/#{$choicefiles[thread]}\", 'w')\n choicefile.write ($ChoiceFileContents[$choicefiles[thread]])\n choicefile.close\n else \n FileUtils.cp($choicefiles[thread],$RunDirectory)\n end \n \n \n FileUtils.cp($gOptionFile,$RunDirectory) \n FileUtils.cp(\"#{$gArchetypeDir}\\\\#{$H2kFile}\",$RunDirectory)\n \n if ( $gComputeCosts ) then \n # Think about error handling. \n FileUtils.cp($gCostingFile,$RunDirectory)\n end \n # ... And get base file names for insertion into the substitute-h2k.rb command.\n $LocalChoiceFile = File.basename $choicefiles[thread] \n $LocalOptionsFile = File.basename $gOptionFile\n \n\n \n # CD to run directory, spawn substitute-h2k thread and save PID \n Dir.chdir($RunDirectory)\n\n if ( $gDebug ) \n FileUtils.cp(\"#{$H2kFile}\",\"#{$H2kFile}-p0\")\n end \n \n \n\n # Possibly call another script to modify the .h2k and .choice files \n \n case $Ruleset\n when /936_2015_AW_HRV/\n subcall = \"perl C:\\\\HTAP\\\\NRC-scripts\\\\apply936-AW.pl #{$H2kFile} #{$LocalChoiceFile} #{$LocalOptionsFile} #{$Location} 1 \"\n system (subcall) \n when /936_2015_AW_noHRV/\n subcall = \"perl C:\\\\HTAP\\\\NRC-scripts\\\\apply936-AW.pl #{$H2kFile} #{$LocalChoiceFile} #{$LocalOptionsFile} #{$Location} 0 \"\n system (subcall) \n end \n\n if ( $gDebug ) \n FileUtils.cp(\"#{$H2kFile}\",\"#{$H2kFile}-p1\")\n end \n \n $SubCostFlag = \"\"\n if ($gComputeCosts ) then \n $SubCostFlag = \"--auto_cost_options\"\n end \n cmdscript = \"ruby #{$gSubstitutePath} -o #{$LocalOptionsFile} -c #{$LocalChoiceFile} -b #{$H2kFile} --report-choices --prm #{$gExtendedOutputFlag} #{$SubCostFlag}\"\n \n # Save command for invoking substitute [ useful in debugging ] \n $cmdtxt = File.open(\"cmd.txt\", 'w') \n $cmdtxt.write cmdscript\n $cmdtxt.close\n \n #debug_out(\" ( cmd: #{cmdscript} | \\n\") \n \n \n pid = Process.spawn( cmdscript, :out => File::NULL, :err => \"substitute-h2k-errors.txt\" ) \n \n\n \n\n $PIDS[thread] = pid \n \n stream_out(\"(PID #{$PIDS[thread]})...\")\n \n \n \n \n # Cd to root, move to next choice file. \n Dir.chdir($gMasterPath)\n \n end \n\n # Snail-Start: \n # This patch is a workaround for instability observed with highly-thread (20+) runs on machines with slow I/O. \n # On the first batch, the substitute script copies the contents of the h2k folder into the working directories (HTAP-work-X),\n # and these folders are subsequently re-used on the following batches. I suspect that windows struggles when 40+ threads are all \n # trying to copy 80+ MB simultaneously to a slow disk; some folders are not created correctly, some files are missing. The \n # result is a bunch of failed runs. \n #\n # Specifying command line option '--snailStart X' causes prm to pause for X seconds after spawning a thread - * on the first batch only *\n # It seems to give a magnetic disk a fighting chance of keeping up with the copy requests. It doesn't appear to slow the simulation \n # down too much, because it only affects the first batch, the H2K folder copy operation appears to be the most expensive part of that first run.\n\n # In tests with 40 threads writing to a magnetic disk, `-- snailStart 6` produces stable runs. \n # A future improvement might modify substitute-h2k.rb to take a hash of the h2k directory content, and verify its integrity before proceeding. \n \n if ( $batchCount == 1 && $snailStart ) then \n \n stream_out (\" *SS-Wait\")\n for wait in 1..5\n \n stream_out (\".\")\n \n sleep($snailStartWait/5)\n \n end \n \n stream_out( \"*\")\n \n end \n \n \n stream_out (\" done. \\n\")\n $choicefileIndex = $choicefileIndex + 1\n \n # Create hash to hold results \n $RunResults[\"run-#{thread}\"] = Hash.new \n \n end \n \n \n # Multi-threaded runs - Step 2: Monitor thread progress\n \n #=====================================================================================\n # Wait for threads to complete \n \n for thread2 in 0..$ThreadsNeeded-1 \n \n count = thread2 + 1 \n \n stream_out (\" - Waiting on PID: #{$PIDS[thread2]} (#{count}/#{$ThreadsNeeded})...\")\n \n Process.wait($PIDS[thread2], 0)\n \n status = $?.exitstatus \n \n if ( status == 0 ) \n \n stream_out (\" done.\\n\")\n \n else \n \n stream_out (\" FAILED! (Exit status: #{status})\\n\")\n \n $RunResults[\"run-#{thread2}\"][\"s.success\"] = \"false\"\n $RunResults[\"run-#{thread2}\"][\"s.errors@99\"] = \" Run failed - substitute-h2k.rb returned status #{status}\"\n \n end \n \n end \n \n #=====================================================================================\n # Multi-threaded runs - Step 3: Post-process and clean up. \n \n \n \n for thread3 in 0..$ThreadsNeeded-1 \n count = thread3 + 1 \n stream_out (\" - Reading results files from PID: #{$PIDS[thread3]} (#{count}/#{$ThreadsNeeded})...\")\n \n Dir.chdir($RunDirs[thread3])\n \n\n $RunResults[\"run-#{thread3}\"][\"c.RunNumber\"] = \"#{$RunNumbers[thread3].to_s}\"\n $RunResults[\"run-#{thread3}\"][\"c.RunDirectory\"] = \"#{$RunDirs[thread3].to_s}\"\n $RunResults[\"run-#{thread3}\"][\"c.SaveDirectory\"] = \"#{$SaveDirs[thread3].to_s}\"\n $RunResults[\"run-#{thread3}\"][\"c.ChoiceFile\"] = \"#{$choicefiles[thread3].to_s}\"\n \n $runFailed = false\n \n # Parse contents of substitute-h2k-errors.txt, which may contain ruby errors if substitute-h2k.rb did \n # not execute correctly. \n $RunResults[\"run-#{thread3}\"][\"s.substitute-h2k-err-msgs\"] = \"nil\"\n \n if ( File.exist?(\"substitute-h2k-errors.txt\") )\n $errmsgs= File.read(\"substitute-h2k-errors.txt\")\n $errmsgs_chk = $errmsgs\n if ( ! $errmsgs_chk.gsub(/\\n*/,\"\").gsub( / */, \"\").empty? ) \n $RunResults[\"run-#{thread3}\"][\"s.substitute-h2k-err-msgs\"] = $errmsgs \n end \n \n end \n \n \n if ( File.exist?($RunResultFilename) ) \n \n contents = File.open($RunResultFilename, 'r') \n \n \n ec=0\n wc=0 \n \n \n \n lineCount = 0\n contents.each do |line|\n lineCount = lineCount + 1\n line_clean = line.gsub(/ /, '')\n line_clean = line.gsub(/\\n/, '')\n if ( ! line_clean.to_s.empty? ) \n $contents = Array.new \n $contents = line_clean.split('=')\n token = $contents[0].gsub(/\\s*/,'') \n value = $contents[1].gsub(/^\\s*/,'') \n value = $contents[1].gsub(/^ /,'')\n value = $contents[1].gsub(/ +$/,'')\n \n \n # add prefix to \n case token \n when /s.error/ \n token.concat(\"@#{ec}\")\n ec = ec + 1\n when /s.warning/\n token.concat(\"@#{wc}\")\n wc=wc+1 \n end \n $RunResults[\"run-#{thread3}\"][token] = value\n end \n \n end \n contents.close\n\n if $RunResults[\"run-#{thread3}\"][\"s.success\"] =~ /false/ then \n $runFailed = true\n stream_out (\" done (with errors).\\n\")\n else\n stream_out (\" done.\\n\")\n end \n \n \n \n \n\n \n else \n \n stream_out (\" Output couldn't be found! \\n\")\n $runFailed = true \n \n #stream_out (\" RUN FAILED! (see dir: #{$SaveDirs[thread3]}) \\n\")\n $failures.write \"#{$choicefiles[thread3]} (dir: #{$SaveDirs[thread3]}) - no output from substitute-h2k.rb\\n\"\n $FailedRuns.push \"#{$choicefiles[thread3]} (dir: #{$SaveDirs[thread3]}) - no output from substitute-h2k.rb\"\n $FailedRunCount = $FailedRunCount + 1\n \n $RunResults[\"run-#{thread3}\"][\"s.success\"] = \"false\"\n $RunResults[\"run-#{thread3}\"][\"s.errors@99\"] = \" Run failed - no output generated\"\n \n $LocalChoiceFile = File.basename $gOptionFile\n if ( ! FileUtils.rm_rf(\"#{$RunDirs[thread3]}/#{$LocalChoiceFile}\") )\n warn_out(\" Warning! Could delete #{$RunDirs[thread3]} rm_fr Return code: #{$?}\\n\" )\n end \n \n \n end \n \n Dir.chdir($gMasterPath) \n \n # Save files from runs that failed, or possibly all runs. \n if ( $gSaveAllRuns || $runFailed ) \n \n if ( ! Dir.exist?($SaveDirs[thread3]) ) \n \n Dir.mkdir($SaveDirs[thread3]) \n \n else \n \n FileUtils.rm_rf Dir.glob(\"#{$SaveDirs[thread3]}/*.*\") \n \n end \n \n FileUtils.mv( Dir.glob(\"#{$RunDirs[thread3]}/*.*\") , \"#{$SaveDirs[thread3]}\" ) \n FileUtils.rm_rf (\"#{$RunDirs[thread3]}/sim-output\")\n end \n \n #Update status of this thread. \n $FinishedTheseFiles[$choicefiles[thread3]] = true \n \n \n end \n \n errs = \"\" \n stream_out (\" - Post-processing results... \") \n\n $outputlines = \"\"\n \n row = 0 \n \n \n # Alternative output in JSON format. Can be memory-intensive\n if ( $gJSONize ) \n \n \n $RunResults.each do |run,data|\n \n $gJSONAllData[$gHashLoc] = Hash.new\n $gJSONAllData[$gHashLoc] = { \"result-number\" => $gHashLoc+1, \n \"status\" => Hash.new,\n \"archetype\" => Hash.new, \n \"input\" => Hash.new, \n \"output\" => Hash.new, \n \"configuration\" => Hash.new,\n \"miscellaneous_info\" => Hash.new } \n \n # Storage for arrays. \n $gJSONAllData[$gHashLoc][\"status\"] = { \"warnings\" => Array.new, \"errors\" => Array.new } \n \n # Storage for binned data\n if ( $gExtendedOutputFlag =~ /-e/ ) \n $gJSONAllData[$gHashLoc][\"output\"] = { \"BinnedData\" => Hash.new } \n $gJSONAllData[$gHashLoc][\"output\"][\"BinnedData\"] = Array.new \n for counter in 0..31\n $gJSONAllData[$gHashLoc][\"output\"][\"BinnedData\"][counter] = Hash.new \n $gJSONAllData[$gHashLoc][\"output\"][\"BinnedData\"][counter][\"bin\"] = counter+1\n end\n else \n $gJSONAllData[$gHashLoc][\"output\"] = { \"BinnedData\" => \"No binned data to report for run ##{$gHashLoc}. Run htap-prm with '-e' to enable\" } \n end \n\n data.each do |token,value|\n \n \n #Detect the type of this token from prefix\n $col_tmp = token.to_s.gsub(/\\s*/, '') \n \n case $col_tmp\n when /^input\\./ , /^i\\./ \n $col_type = \"input\"\n when /^output\\./ , /^o\\./ \n $col_type = \"output\"\n when /^arch\\./ , /^a\\./ \n $col_type = \"archetype\" \n when /^config\\./ , /^c\\./ \n $col_type = \"configuration\" \n when /^status\\./ , /^s\\./ \n $col_type = \"status\" \n else \n $col_type = \"miscellaneous_info\"\n end \n \n # And get remaining text after the '.'\n $col_txt = $col_tmp.to_s.gsub(/^[^\\.]+\\./,'')\n \n # Then store data in the appropriate location \n case $col_txt \n when /error/ \n \n $gJSONAllData[$gHashLoc][\"status\"][\"errors\"].push( value.to_s.gsub(/\"/,'') )\n \n when /warning/ \n \n $gJSONAllData[$gHashLoc][\"status\"][\"warnings\"].push( value.to_s.gsub(/\"/,'') ) \n \n when /BIN-data/\n # format is 'BIN-data-TYPE-##'; Split out TYPE and ##\n $bin_type = Array.new\n $bin_type = $col_txt.gsub(/BIN-data-/, '').split(\"-\") \n $bin_row = $bin_type[1].to_i - 1 \n # Store data in array, based on type.\n \n case $bin_type[0].to_s\n when /HRS/ \n $gJSONAllData[$gHashLoc][\"output\"][\"BinnedData\"][$bin_row][\"CumulativeHrs\"] = value.to_f\n \n when /TMP/ \n $gJSONAllData[$gHashLoc][\"output\"][\"BinnedData\"][$bin_row][\"Temperature_oC\"] = value.to_f\n \n when /HLR/ \n $gJSONAllData[$gHashLoc][\"output\"][\"BinnedData\"][$bin_row][\"HeatLossRateW\"] = value.to_f\n \n when /T2cap/ \n $gJSONAllData[$gHashLoc][\"output\"][\"BinnedData\"][$bin_row][\"Type2Capacity\"] = value.to_f\n \n when /T2PLR/ \n $gJSONAllData[$gHashLoc][\"output\"][\"BinnedData\"][$bin_row][\"Type2PartLoadRatio\"] = value.to_f \n \n when /T1PLR/ \n $gJSONAllData[$gHashLoc][\"output\"][\"BinnedData\"][$bin_row][\"Type1PartLoadRatio\"] = value.to_f \n end \n \n else \n \n \n # format according to data type \n case value.to_s.gsub(/\\s*/, '') \n when /^[0-9\\-]+$/ \n $gJSONAllData[$gHashLoc][\"#{$col_type}\"][\"#{$col_txt}\"] = value.to_i\n \n when /^[0-9\\.\\-E]+$/ \n $gJSONAllData[$gHashLoc][\"#{$col_type}\"][\"#{$col_txt}\"] = value.to_f\n \n else \n $gJSONAllData[$gHashLoc][\"#{$col_type}\"][\"#{$col_txt}\"] = value.to_s.gsub(/^\\s*/, '').gsub( /\\s*$/,'')\n\n end\n \n \n \n end \n \n \n end # ends data.each do \n \n # Arr err/warn empty? if so, put 'nil'\n if ( $gJSONAllData[$gHashLoc][\"status\"][\"errors\"].empty? ) \n \n $gJSONAllData[$gHashLoc][\"status\"][\"errors\"].push \"nil\"\n \n end \n \n if ( $gJSONAllData[$gHashLoc][\"status\"][\"warnings\"].empty? ) \n \n $gJSONAllData[$gHashLoc][\"status\"][\"warnings\"].push \"nil\"\n \n end \n \n \n \n # Test to see if the run was successful. Flag if not, otherwise increment completed counter. \n \n if ( $gJSONAllData[$gHashLoc][\"status\"][\"success\"] == \"false\" ) then \n \n $runFailed = true \n errs=\" *** simulation errors found ***\"\n $msg = \"#{$gJSONAllData[$gHashLoc][\"configuration\"][\"ChoiceFile\"]} (dir: #{$gJSONAllData[$gHashLoc][\"configuration\"][\"SaveDirectory\"]}) - substitute-h2k.rb reports errors\"\n $failures.write \"$msg\\n\"\n $FailedRuns.push $msg \n $FailedRunCount = $FailedRunCount + 1\n\n else \n \n $CompletedRunCount = $CompletedRunCount + 1 \n \n end \n\n \n # Increment hash increment too. \n $gHashLoc = $gHashLoc + 1 \n\n if ( $runFailed && $StopOnError ) then \n $RunsDone = true \n $GiveUp = true \n end \n\n\n \n \n end # ends $RunResults.each do\n \n \n end # Ends if JSON.\n \n \n $RunResults.each do |run,data|\n \n # Only write out data from successful runs - this helps prevent corrupted databae \n \n \n if ( data['s.success'] =~ /true/ ) then\n \n if ( ! $outputHeaderPrinted ) then \n # Deal with header first \n data.sort.to_h \n data.each do |column,value|\n \n case column \n when /s\\.error/, /s\\.warning/, /BIN-data/\n # Do nothing \n else \n \n $csvColumns.push column\n $headerline.concat(\"#{column.to_s},\")\n end \n end \n $outputHeaderPrinted = true \n $headerline.concat(\"\\n\")\n $outputCSV.write($headerline) \n end \n \n $csvColumns.each do |key|\n \n $outputlines.concat(\"#{data[key]},\")\n \n end\n \n $outputlines.concat(\"\\n\")\n \n end \n \n end \n \n $outputCSV.write($outputlines) \n $outputCSV.flush\n $failures.flush \n \n $RunResults.clear\n \n stream_out (\"done.#{errs}\\n\\n\")\n\n if ( ! $FinishedTheseFiles.has_value?(false) ) \n \n $RunsDone = true \n \n end \n \n\n end \n \n \n if ( $GiveUp ) then \n stream_out(\" - HTAP-prm: runs terminated due to error ----------\\n\\n\")\n else \n stream_out(\" - HTAP-prm: runs finished -------------------------\\n\\n\")\n end \n \n if ($gJSONize )\n stream_out(\" - Writing JSON output to HTAP-prm-output.json... \")\n $JSONoutput = File.open($gOutputJSON, 'w') \n $JSONoutput.write(JSON.pretty_generate($gJSONAllData))\n $JSONoutput.close \n stream_out(\"done.\\n\\n\")\n end \n \n \n if ( ! $gDebug ) then \n stream_out (\" - Deleting working directories... \") \n FileUtils.rm_rf Dir.glob(\"HTAP-work-*\") \n stream_out(\"done.\\n\\n\")\n end\n \nend",
"def start_generation\n Nanite.request(\"/nanny/generate\", self.id)\n end",
"def initialize\n @queue = Queue.new\n @workers = []\n @workers_count = 5\n end",
"def generate_comprehensive\n\n end",
"def get_urls()\n generate_thread(@@source_url)\n end",
"def create_workers\n @workers.times do |id|\n pid = fork { Worker.new(@options.merge(id: id)).start }\n @forks << { id: id, pid: pid }\n end\n end",
"def threads(min, max); end",
"def gen\n @genFlag = true\n res = ln((@overrideFlag ? '@Override ' : '') + 'public '+ (@static ? 'static ' : '') + @type + ' ' + @name + '(' +\n @args.collect {|var| (var.className.nil? ? var.type : var.className.name) + (var.instance_of?(Arr) ? '[]' * var.ndim : '') + ' ' + var.name}.join(', ') +\n ') {') + \"\\n\"\n shift(1)\n res+=ln('if ('+@args[0].name+'.length > 0) FuzzerUtils.seed('+rand(100000000).to_s+' + Long.parseLong('+@args[0].name+'[0]));') if @mainTestFlag and $conf.outer_control\n res+=ln('instanceCount++;') if @constructorFlag\n res += @context.genDeclarations() if !@mainFlag # no declarations should be generated for main method\n @rootStmt.nestedStmts['body'].each {|st| res += st.gen()} if !@mainFlag # no statements should be generated for main method\n res += ln('FuzzerUtils.joinThreads();') if @mainTestFlag && $run_methods>0\n res += (@mainTestFlag ? @context.genResPrint() + @methClass.context.genResPrint() : '')\n res += (!(@mainTestFlag||@mainFlag) ? genEnding() : '')\n glob = (@mainTestFlag ? @methClass.genGlobCheckSums() : '')\n#main method:\n if @mainFlag \n res += ln(\"try {\")\n shift(1)\n res += ln(@methClass.name + \" _instance = new \" + @methClass.name + \"();\")\n res += ln(\"for (int i = 0; i < \" + $conf.mainTest_calls_num.to_s + \"; i++ ) {\")\n shift(1)\n res += ln(\"_instance.\" + @methClass.methMainTest.name + \"(\" + @args[0].name + \");\")\n shift(-1)\n res += ln(\"}\")\n if ($conf.time_sleep_complete_tier1 > 0)\n res += ln(\"try {\") + ln(\"Thread.sleep(\" + $conf.time_sleep_complete_tier1.to_s + \");\") + ln(\" } catch (InterruptedException ie) {\") \n shift(1)\n res += ln(\"ie.printStackTrace();\") \n shift(-1)\n res += ln(\"}\")\n end\n if $conf.mainTest_calls_num_tier2 > 0\n res += ln(\"for (int i = 0; i < \" + $conf.mainTest_calls_num_tier2.to_s + \"; i++ ) {\")\n\n shift(1)\n res += ln(\"_instance.\" + @methClass.methMainTest.name + \"(\" + @args[0].name + \");\")\n shift(-1)\n res = res + ln(\"}\")\n end\n shift(-1)\n res += ln(\" } catch (Exception ex) {\")\n shift(1)\n res += ln(\"FuzzerUtils.out.println(ex.getClass().getCanonicalName());\")\n shift(-1)\n res += ln(\" }\")\n\n end\n \n res += \"\\n\" + glob unless glob.empty?\n\n shift(-1)\n res + ln(\"}\")\n end",
"def create_work\n @files.each do |file|\n executor.queue do\n chown(file)\n chmod(file)\n end\n end\n end",
"def create_authors\n transaction { 100.times { Author.create first_name: rand_name, last_name: rand_name } }\n create_message Author\nend",
"def run!\n @size.times do\n schedule { throw :exit }\n end\n @pool.map(&:join)\n end",
"def initialize(files, output_dir, threads)\n @files = files\n @output_dir = output_dir\n @executor = CopyPasta::Executor.new(threads)\n end",
"def start_game_creator!\n\t\t$threads << @creator = Thread.new() do\n\t\t\tready_players = []\n\t\t\tspectators = []\n\t\t\twhile true\n\t\t\t\t# Check every connection in the waiting queue for a JOIN or SPECTATE\n\t\t\t\t@connections.each do |c|\n\t\t\t\t\tline = c.readline\n\t\t\t\t\tif line =~ /JOIN\\W+(\\w+)/i\t# A player is attempting to join the game, move them from waiting to READY\n\t\t\t\t\t\tputs \"JOIN: #{$1} joined a game\"\n\t\t\t\t\t\tready_players << {:connection => c, :user => $1.strip}\n\t\t\t\t\t\t@connections.delete c\n\t\t\t\t\telsif line =~ /SPECTATE/i\n\t\t\t\t\t\tputs \"Spectator joined\"\n\t\t\t\t\t\tspectators << c\t\t\t# A spectator is ready to watch the next game, move the, to SPECTATORS\n\t\t\t\t\t\t@connections.delete c\n\t\t\t\t\tend\n\t\t\t\t\tif ready_players.size > 1\t# If you have enough players to play\n\t\t\t\t\t\tputs \"Two players have requested a game, spawning new game for:\"\n\t\t\t\t\t\tp1 = ready_players.pop\t# Get the first two ready players\n\t\t\t\t\t\tp2 = ready_players.pop\n\t\t\t\t\t\tspecs = spectators.clone\n\t\t\t\t\t\tspectators = []\t\t\t# Assign all specs to the new game and clear the spec list out\n\t\t\t\t\t\tputs \"\\tHunter: #{p1[:user]}\\n\\tPrey: #{p2[:user]}\"\n\t\t\t\t\t\tnew_game = Evasion.new(p1[:connection], p1[:user], p2[:connection], p2[:user], specs)\n\t\t\t\t\t\t# @games << new_game\t# Leftover comments from multithreading with simultaneous games approach. Does not work well on energon.\n\t\t\t\t\t\t# $threads << Thread.new(new_game) do |game|\n\t\t\t\t\t\t# \tThread.current.priority = 10\t# Escalate the game's thread to always beat ACCEPTOR and CREATOR threads\n\t\t\t\t\t\t\t@results << new_game.play # @results << game.play\n\t\t\t\t\t\t# end\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend",
"def generate_combiner(graph,combiners)\r\n \r\n puts\"--- COMBINER ------\"\r\n \r\n @Jobs.each do |current_job| \r\n\r\n if combiners.size == 0\r\n return\r\n end\r\n \r\n fields = combiners.first.split('.')\r\n \r\n # se il job da analizzare é uguale a quello corrente\r\n if current_job == fields[0] \r\n combiner_name = current_job + \".\" + \"COMBINER_\" + fields[1].split('(')[1]\r\n \r\n #aggiungo il nodo combiner\r\n graph.add_node(combiner_name,\"is_combiner\")\r\n puts \"aggiunto combiner:\" + combiner_name\r\n \r\n # chiudo i nodi pendenti ( job per job) \r\n Close_ALL_pending_links(graph,current_job,combiner_name)\r\n \r\n # memorizzo i link aperti (per creare i futuri link)\r\n puts \"sto aggiungendo\" + combiner_name\r\n @OpenLink.push(combiner_name);\r\n \r\n end \r\n end #do jobs\r\n \r\n end",
"def scrape(num)\n num.times do\n single_scrape()\n end\nend"
] |
[
"0.6066507",
"0.5867134",
"0.5854366",
"0.5854366",
"0.5746162",
"0.5625355",
"0.5625355",
"0.5599094",
"0.55290556",
"0.55165744",
"0.5508261",
"0.54867053",
"0.5431468",
"0.5417689",
"0.54154974",
"0.5393715",
"0.5393553",
"0.53817165",
"0.5380286",
"0.53742003",
"0.53692514",
"0.53207695",
"0.52988994",
"0.52988994",
"0.52972156",
"0.52940875",
"0.5288312",
"0.5282337",
"0.5275293",
"0.52707213",
"0.52629656",
"0.52531743",
"0.52454895",
"0.524393",
"0.52288514",
"0.5210364",
"0.5206949",
"0.5197698",
"0.5189921",
"0.5180555",
"0.516817",
"0.516817",
"0.51623094",
"0.5126206",
"0.51242214",
"0.5118135",
"0.51177055",
"0.510823",
"0.51011866",
"0.5093439",
"0.5088808",
"0.5075716",
"0.5070472",
"0.5070472",
"0.5056171",
"0.50560665",
"0.5054063",
"0.5044949",
"0.5044797",
"0.5041765",
"0.50322807",
"0.5023394",
"0.50200546",
"0.50159514",
"0.5015231",
"0.5013126",
"0.5013126",
"0.50062793",
"0.4997009",
"0.4993029",
"0.49903873",
"0.4987711",
"0.49796548",
"0.49775976",
"0.49717283",
"0.49670634",
"0.4958139",
"0.49496076",
"0.4949053",
"0.49483067",
"0.49412358",
"0.49412358",
"0.49345922",
"0.4932263",
"0.4914652",
"0.49132586",
"0.4900326",
"0.48990023",
"0.4898785",
"0.48960635",
"0.4894412",
"0.48903322",
"0.48857987",
"0.48853374",
"0.48846817",
"0.4884509",
"0.488253",
"0.4878962",
"0.48747337",
"0.4874616"
] |
0.76342887
|
0
|
genertes numbers in the specifiied proportions
|
def rand_gen
rand100 = rand(1..100)
if (0..50).cover?(rand100)
output_val = 1
elsif (51..75).cover?(rand100)
output_val = 2
elsif (76..90).cover?(rand100)
output_val = 3
elsif (91..95).cover?(rand100)
output_val = 4
elsif (96..100).cover?(rand100)
output_val = 5
end
handle_output(output_val)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def possible_proportions\n arr = Array.new(4, 0)\n proportions = []\n (0..100).to_a.each do |index0|\n arr[0] = index0\n (0..100 - index0).to_a.each do |index1|\n arr[1] = index1\n (0..100 - index0 - index1).to_a.each do |index2|\n arr[2] = index2\n arr[3] = 100 - index0 - index1 - index2\n proportions << arr.dup\n end\n end\n end\n proportions\nend",
"def spec_prob prob, num_probs\n count = 0\n pages = []\n\n num_probs.each do |x|\n num = x / prob\n leftover = x % prob\n if x >= prob\n num.times{ pages.push(prob) }\n end\n if leftover != 0\n pages.push(leftover)\n end\n end\n\n # p num_probs\n # p pages\n\n the_pages = []\n num_probs.each do |x|\n pr = (1..x).to_a\n the_pages.push(pr)\n end\n\n the_pages.flatten!.reverse!\n # p the_pages\n\n pages_to_probs = []\n\n pages.each_with_index do |x, i|\n page = the_pages.pop(x)\n pages_to_probs << page\n end\n\n # p pages_to_probs\n\n pages_to_probs.each_with_index do |x,i|\n if x.include?(i+1)\n count += 1\n end\n end\n\n p count\n\nend",
"def calculate_portions(order)\n amount = order.total.to_f\n ret = []\n\n portions_number = preferred_max_portion\n minimum_value = preferred_minimum_value.to_f\n tax = preferred_tax_value.to_f\n\n ret.push({portion: 1, value: amount, total: amount, tax_message: :komerci_without_tax})\n\n (2..portions_number).each do |number|\n if tax <= 0 or number <= preferred_portion_without_tax\n value = amount / number\n tax_message = :komerci_without_tax\n else\n value = (amount * ((1 + tax / 100) ** number)) / number\n tax_message = :komerci_with_tax\n end\n\n if value >= minimum_value\n value_total = value * number\n ret.push({portion: number, value: value, total: value_total, tax_message: tax_message})\n end\n end\n\n ret\n end",
"def por_prote\n\t\t\t(@proteinas/suma_gramos)*100\n\t\tend",
"def get_proteinas\n @_100=((@proteinas*100)/@peso)\n @ir_100=(@_100/50)*100\n @porcion=((@proteinas*@gramos_porciones)/@peso)\n @ir_porcion=(@porcion/50)*100\n\t\t#p\"| #{@proteinas} | #{@_100} | #{@ir_100.round(1)}% | #{@porcion} | #{@ir_porcion.round(1)}% |\"\n [ @proteinas , @_100 , @ir_100.round(1) , @porcion , @ir_porcion.round(1) ]\n end",
"def gen_probs(num, from=0, to=1)\n step = (to - from) / num.to_f\n ((from + step)...to).step(step).to_a\nend",
"def prot\n\t\tsuma = 0\n\t\tx = 0\n\t\tcantidad = 0\n\n\t\t@alimentos.each do |i|\n\t\t\tcantidad = @gramos[x].valor / (i.proteinas + i.lipidos + i.carbohidratos)\n\t\t\tsuma += i.proteinas * cantidad\n\t\t\tx += 1\n\t\tend\t\n\n\t\treturn ((suma * 100) / gramos_total).round(2)\n\tend",
"def prot\n\t\tgrtotal = 0\n\t\tsum = 0\n\t\t#itera en las dos listas a la vez para poder calcular las\n\t\t#proteinas dependiendo de la cantidad y tambien suma\n\t\t#todas las cantidades para poder calcular el porcentaje\n\t\t#despues\n\t\t@lista.zip(@listagr).each do |normal, gr|\n\t\t\tgrtotal += gr\n\t\t\tcant = gr/1000.0\n\t\t\tsum += normal.prot*cant \n\t\tend\n\t\t(sum*100)/grtotal\n\tend",
"def obtener_promedio(hash)\n hash.values.inject(0) { |sum, n| sum + n }.to_f / hash.length\nend",
"def gramos\r\n grams = 0\r\n @lista_alimentos.each do |i|\r\n grams += 100\r\n end\r\n return grams\r\n end",
"def porcentajeGlucidos\r\n total_glucidos = 0.0\r\n la = @listaAlimentos.head\r\n lg = @listaGramos.head\r\n while la != nil do\r\n total_glucidos += (la.value.carbohidratos * lg.value) / 100\r\n la = la.next\r\n lg = lg.next\r\n end\r\n total_gramos = listaGramos.reduce(:+)\r\n porcentajeGlucidos = ((total_glucidos / total_gramos)*100).round(2)\r\n end",
"def por_proteinas\n\t\taux_proteinas = 0.0\n\t\ti = 0\n\t\twhile i < @lista_alimentos.size do\n\t\t\taux_proteinas += @lista_alimentos[i].proteinas * @lista_cantidades[i]\n\t\t\ti+=1\n\t\tend\n\t\treturn ((aux_proteinas/total_nutrientes)*100.0).round(2) \n\tend",
"def prop_g\n bases_g / length.to_f\n end",
"def proteinsPercent()\n\t\t\t\tplato = @alimentsList.head\n\t\t\t\tgrams = @gramsList.head\n\t\t\t\ttotalEnergy = 0.0\n\t\t\t\ttotalProteinsEnergy = 0.0\n\n\t\t\t\twhile plato != nil\n\t\t\t\t\ttotalEnergy += (plato.value.get_energia * grams.value) / 100\n\t\t\t\t\ttotalProteinsEnergy += (plato.value.get_energia_proteins * grams.value) / 100\n\n\t\t\t\t\tplato = plato.next\n\t\t\t\t\tgrams = grams.next\n\t\t\t\tend\n\n\t\t\t\treturn (totalProteinsEnergy * 100) / totalEnergy\n\t\t\tend",
"def per_person\n (total_bill / @party_size).ceil.to_i\n end",
"def pProteina \n\t\tprot = 0\n\t\ttotal = 0\n\t\t@platos.each do |alimento|\n\t\t\ttotal += (alimento.proteinas + alimento.lipidos + alimento.carbohidratos)\n\t\t\tprot += alimento.proteinas\n\t\tend\n\t\treturn ((prot/total)*100).round\t\n\tend",
"def promedio(num, arreglo)\n puts promedio = num.fdiv(arreglo.count).floor(2)\nend",
"def irproteinas\n vag=(proteinas * 100) / 50\n vag.round(2)\n end",
"def size\n\n @population_density/50\n\n mod_factor = 0.0\n if @population_density >= 200\n mod_factor = 4.0\n elsif @population_density >= 150\n mod_factor = 3.0\n elsif @population_density >= 100\n mod_factor = 2.0\n elsif @population_density >= 50\n mod_factor = 1.0\n else\n mod_factor = 0.5\n end\n return mod_factor\n end",
"def alg4(max_value)\n perimeters = Hash.new 0\n (6..max_value/2).each do |p_sub|\n p = p_sub * 2\n (p_sub-1..3).each do |a|\n b = p * (p - 2*a) / (2.0 * (p-a))\n # avoid double counting\n break if b > a\n\n if b > 0 && b == b.to_i\n #puts \"debug: adding perimeter #{p} = #{a} + #{b} + ...\"\n perimeters[p] += 1\n end\n end\n end\n return perimeters\nend",
"def grams\n gram_equivalent / amount\n end",
"def por_lip\n\t\t\t(@lipidos/suma_gramos)*100\n\t\tend",
"def cantidadPrimosRango(rangoInicial, rangoFinal)\n contador = 0\n x = rangoInicial\n y = rangoFinal\n if x >= 4\n z = x - 1\n else\n z = x\n end\n for i in z..y\n if y % i == 0\n contador = contador + 1\n end\n end\n return contador\nend",
"def calc_density(percent)\n (@population * percent).floor\n\n end",
"def calculate_probability_distribution\n\t\t\tnumber_of_possible_combinations = (@sides**@count)\n\t\t\t#puts \"Number of possible combinations: #{number_of_possible_combinations}\"\n\t\t\tresult = {}\n\t\t\t# weep softly: http://mathworld.wolfram.com/Dice.html\n\t\t\t(min..max).each { |p|\n\t\t\t\tif p > (max + min) / 2\n\t\t\t\t\tresult[p] = result[max - p + min]\n\t\t\t\telse\n\t\t\t\t\tthing = (BigDecimal.new(p - @count) / BigDecimal.new(@sides)).floor\n\n\t\t\t\t\tc = BigDecimal.new(0)\n\t\t\t\t\t((0..thing).each { |k|\n\t\t\t\t\t\tn1 = ((-1)**k) \n\t\t\t\t\t\tn2 = BigDecimal.new(Internal_Utilities::Math_Utilities.Choose(@count, k))\n\t\t\t\t\t\tn3 = BigDecimal.new(Internal_Utilities::Math_Utilities.Choose(p - (@sides * k) - 1, @count - 1))\t\t\t\t\t\t\n\t\t\t\t\t\tt = BigDecimal.new(n1 * n2 * n3)\n\n\t\t\t\t\t\tc += t\n\t\t\t\t\t})\n\n\t\t\t\t\t#result = result.abs\n\n\t\t\t\t\tresult[p] = BigDecimal.new(c) / BigDecimal.new(number_of_possible_combinations)\n\t\t\t\tend\n\n\t\t\t\t#puts \"\\tProbability of #{p}: #{@probability_distribution[p].add(0, 5).to_s('F')}\" \n\t\t\t}\n\t\t\t@probability_distribution = result\n\t\t\t#puts \"Sum of probability_distribution: \" + (@probability_distribution.inject(BigDecimal.new(0)) {|total, (k,v)| BigDecimal.new(total + v) }).add(0, 5).to_s('F')\n\t\tend",
"def pHidratos\n\t\thidr = 0\n\t\ttotal = 0\n\t\t@platos.each do |alimento|\n\t\t\ttotal += alimento.proteinas + alimento.lipidos + alimento.carbohidratos\n\t\t\thidr += alimento.carbohidratos\n\t\tend\n\t\treturn ((hidr/total)*100).round\n\n\t\n\tend",
"def promedio(h)\n suma = h.values.inject(0) {|sum, x| sum + x}\n p suma\n suma / h.count.to_f\nend",
"def per(num)\n scoped\n end",
"def promedio arr\n sum = 0 \n arr.each{|i| sum += i}\n prom = sum/arr.length\n puts prom\nend",
"def get_grasas\n @_100=((@grasas*100)/@peso)\n @ir_100=(@_100/70)*100\n @porcion=((@grasas*@gramos_porciones)/@peso)\n @ir_porcion=(@porcion/70)*100\n [ @grasas , @_100 , @ir_100.round(1) , @porcion , @ir_porcion.round(1) ]\n end",
"def calc_generator_size(val1= chp_salable_elec, val2 = 364 * 24)\n\t\t(val1 / val2).round 3\n\tend",
"def porcentaje_proteinas\n auxNodo1 = @lista_alimentos.head\n auxNodo2 = @gramos.head\n porcentaje_prot = 0\n while(auxNodo1 != nil && auxNodo2 != nil)\n porcentaje_prot += (auxNodo1.value.proteinas * auxNodo2.value) / 100\n auxNodo1 = auxNodo1.next\n auxNodo2 = auxNodo2.next\n end\n return porcentaje_prot.round(1)\n end",
"def prolificness\n # prolificness = num_paintings / years_experience\n paintings.size / years_experience.to_f\n end",
"def death_percentage(num)\n (@population * num).floor\n end",
"def prob(n)\n n = n\n x = n/2\n as, ae = fact_sig_exp(n)\n bs, be = fact_sig_exp(x)\n bs *= bs\n be *= 2\n cs, ce = power_sig_exp(2, n)\n\n s = as / bs / cs\n e = ae - be - ce\n s*10**e\nend",
"def promedio_edades(n)\n\tedades = [19,20,22,25,30]\n\tsuma = 0.0\n\tfor i in 0..edades.size\n\t\tsuma = suma + (edades[i]).to_i\n\tend\n\treturn (suma / n).round(2)\nend",
"def pmt(i, n, pv)\n return pv / ((1 - (1 / (1 + i) ** n )) / i)\n end",
"def get_number_of_pages(numrec)\n return ((numrec + 50) / 50 * 50) / 50\nend",
"def solve112(target_proportion)\n bouncy_proportion = 0\n total_bouncy = 0\n num = 0\n while bouncy_proportion < target_proportion\n num += 1\n if bouncy?(num)\n total_bouncy += 1\n bouncy_proportion = 1.0*total_bouncy/num\n end\n end\n puts target_proportion, num\nend",
"def macro_percentages\n \n if self.total_calories!=nil and self.protein_grams != nil and self.carbohydrate_grams!=nil and self.fat_grams!=nil\n return {:protein=>protein_grams.to_f/total_calories, :carbohydrate => carbohydrate_grams.to_f/total_calories, :fat=> fat_grams.to_f/total_calories}\n end\n\n return nil\n end",
"def percentage_of_promoters\n calculator.percentage_of_promoters\n end",
"def per_person\n (total_cost / @guests).round(2)\n end",
"def ir_proteina\n @ir_proteina = (@proteinas/50.to_f)*100\n @ir_proteina.round(1)\n end",
"def new_classroom(new_class_size)\n new_class_size.each_value do |value|\n puts value + (value *= 0.05).to_i\n end\nend",
"def porcentaje_glucidos\n auxNodo1 = @lista_alimentos.head\n auxNodo2 = @gramos.head\n porcentaje_gluc = 0\n while(auxNodo1 != nil && auxNodo2 != nil)\n porcentaje_gluc += (auxNodo1.value.glucidos * auxNodo2.value) / 100\n auxNodo1 = auxNodo1.next\n auxNodo2 = auxNodo2.next\n end\n return porcentaje_gluc.round(1)\n end",
"def calculate_probability(useful_results, reroll_count)\n return 100.0 * useful_results / ( 6 ** reroll_count )\n end",
"def problem_80(size = 100)\n total = 0\n (2..100).each do |n|\n n,d = n.sqrt_frac(2*size)\n next unless n\n r = n * (10 ** (size * 1.1).to_i) / d\n r = r.to_s[0,size].split(//).map(&:to_i).reduce(&:+)\n total += r\n# puts r.inspect\n end\n total\nend",
"def probability m, n\r\n\t\t\treturn 1.0 * combination( @p, m ) * combination( @q, ( n - m ) ) / combination( ( @p + @q ), n )\r\n\t\tend",
"def proportion_confidence_interval(p, sam,pop , x)\n #f=sam.quo(pop)\n one_range=x * Math::sqrt((qf(sam, pop) * p * (1-p)).quo(sam-1)) + (1.quo(sam * 2.0))\n [p-one_range, p+one_range]\n end",
"def covered_percentages; end",
"def nb_dig(n, d)\n #create an array of sqaures from d up to and including n\n numbers = (d..n).to_a\n #issue was here: should've made the range 0..n instead of d..n\n squares = numbers.map do |num|\n num * num\n end\n #for each square...\n count = 0\n binding.pry\n squares.each do |square|\n #count and add to a tally if d is present\n count += square.to_s.count(d.to_s)\n end\n #turn it into a string\n #return the tally\n count\nend",
"def crearProbabilidad\n\t\t@probabilidad.clear\n\t\tsumaFitness = @fitness.inject {|sum,x| sum+=x }\n\t\t@fitness.each do |fitnes|\n\t\t\t@probabilidad << fitnes / sumaFitness\n\t\tend\n\t\tindex=1\n\t\t@qsubm.clear\n\t\t@probabilidad.each do\n\t\t\t@qsubm << sumarCant(index,@probabilidad)\n\t\t\tindex+=1\n\t\tend\n\tend",
"def poisson_calc(expected, prng) #expected number of occurences\n\t\tl = Math.exp(-expected) #(P|X = 0) \n\t\tk = 0.0 #(number of occurences)\n\t\tp = 1.0 #The product of the urandoms\n\t\tk = 1.0 unless p > l # need because 1.0 !> 1.0\n\t\twhile p > l \n\t\t\tu = prng.rand\n\t\t\tp *= u\n\t\t\tk += 1 \n\t\tend\n\t (k - 1)\n\tend",
"def por_carbohidratos\n \taux_carbohidratos = 0.0\n\t\ti = 1\n\t \twhile i < @lista_alimentos.size do\n\t\t\taux_carbohidratos += @lista_alimentos[i].carbohidratos * @lista_cantidades[i]\n\t\t\ti+=1\n\t\tend\n\t\treturn ((aux_carbohidratos/total_nutrientes)*100.0).round(2)\n\tend",
"def nchooser(n, r)\n\n (1..n).reduce(:*) / ( (1..r).reduce(:*) * (1..(n-r)).reduce(:*) )\n\nend",
"def rpkm(counts, total_mapped_reads, gene_length)\n if counts && gene_length\n sprintf(\"%.2f\",(1e9*counts.to_f)/(total_mapped_reads*gene_length)).to_f\n else\n 0.0\n end\nend",
"def calcule_nombre_pages\n @pages_count ||= Hash.new\n @pages_count.merge!({\n signes: (length / NUMBER_SIGNES_PER_PAGE) + 1,\n mots: (mots.count / NUMBER_MOTS_PER_PAGE) + 1\n })\n @pages_count.merge!(moy: (@pages_count[:signes] + @pages_count[:mots]) / 2)\n end",
"def por_lipidos\n\t\taux_lipidos = 0.0\n\t\ti = 1\n\t\twhile i < @lista_alimentos.size do\n\t\t\taux_lipidos += @lista_alimentos[i].lipidos * @lista_cantidades[i]\n\t\t\ti+=1\n\t\tend\n\t\treturn ((aux_lipidos/total_nutrientes)*100.0).round(2)\n\tend",
"def var_base_frac\n hash = self.bases_hash\n snp_hash = {}\n coverage = self.coverage\n return snp_hash if coverage < Options.mindepth\n # calculate proportion of each base in coverage\n hash.each_key do | base |\n freq = hash[base].to_f/coverage.to_f\n next if freq <= Options.noise\n snp_hash[base] = freq\n end\n snp_hash\n end",
"def formata_percentual_multa(tamanho = 4)\n format_value(:percentual_multa, tamanho)\n end",
"def giniA(xs)\n\t1 - xs.group_by {|x| x }.inject(0) {|a, (k, v)| a + (v.size.to_f / xs.size) ** 2 }\nend",
"def prom_weight\n if pet_histories.length > 0\n promw= pet_histories.sum(:weight)\n promw/pet_histories.length\n else\n \"0\"\n end\n end",
"def p206\n re = /1.2.3.4.5.6.7.8.9.0/\n max = Math.sqrt(1929394959697989990).floor\n\n # Round since only squares of multiples of 30 and 70 end with 9_0 (e.g. 900)\n i = round_up Math.sqrt(1020304050607080900).floor, 100\n while i < max\n p30 = (i+30) ** 2\n p70 = (i+70) ** 2\n\n if re === \"#{p30}\"\n return \"#{i+30}^2 = #{p30}\"\n elsif re === \"#{p70}\"\n return \"#{i+70}^2 = #{p70}\"\n end\n\n i += 100\n end\nend",
"def points_partion_array(member_counts)\n division = (0...member_counts).map {|i| points / member_counts }\n (0...points%member_counts).each {|i| division[0] += 1}\n division\n end",
"def por_carbo\n\t\t\t(@carbohidratos/suma_gramos)*100\n\t\tend",
"def build_distribution\n dist = Array.new(NUM_DICE * SIDES + 1, 0)\n (1..SIDES).each do |i|\n (1..SIDES).each do |j|\n dist[i+j] += 1\n end\n end\n\n # normalize to a probability\n (NUM_DICE..NUM_DICE * SIDES).each do |k|\n dist[k] = dist[k].to_f / 36.to_f\n end\n dist\nend",
"def calc_percent(n, total)\n (n.to_f/total.to_f) * 100.0\nend",
"def promedio(visitas_diarias)\n visitas_diarias.sum / visitas_diarias.count #suma de los datos dividido la cantidad de datos\nend",
"def count_percentage(array,decimal = 2)\n hash1 = Hash.new(0)\n array.each do |element|\n hash1[element] += 1\n end\n total_elements = array.size\n hash2 = Hash.new(0)\n hash1.each do |key,value|\n hash2[key] = (value/total_elements.to_f).round(decimal)\n end\n return hash2\nend",
"def prodenum(n)\n $primitives ||= primitives(90)\n $new_number_products_cache ||= Array.new(4, [])\n\n result = (4..n).to_a.flat_map { |i| primitives_combinations(i) }\n (result | [1].concat($primitives.select { |pr| pr <= n })).sort\n end",
"def porcentaje_proteinas\n recorrido = lista_alimentos.head\n acumulador = 0\n porcentaje = 0\n\n while recorrido != nil\n acumulador = acumulador + recorrido.value.proteinas + recorrido.value.carbohidratos + recorrido.value.lipidos\n porcentaje = porcentaje + recorrido.value.proteinas\n\n recorrido = recorrido.next\n end\n\n ((porcentaje * 100)/acumulador).round(2)\n end",
"def get_probs(mps)\n result = []\n mps.each_with_index do |mp,i|\n mp[1].each_with_index do |e,j|\n result << [[mp[0], e[0]].join(\".\"), e[1]]\n end\n end\n result\n end",
"def probability_n_of_a_kind(minimum_count, actual_count)\n debug = false\n gap = [(minimum_count - actual_count), 0].max # number of dice needed for minimum\n puts \"minimum count: #{minimum_count}, actual count: #{actual_count}, gap: #{gap}\" if debug\n if gap == 0 \n useful_results = 1\n reroll_count = 0\n else\n case [minimum_count, gap]\n when [3, 1] # need 1 of 3 to match\n # sequences with 1 of 3 dice: --*, -*-, *--\n # sequences with 2 of 3 dice: -**, *-*, **-\n # sequences with 3 of 3 dice: *** \n useful_results = (3*5*5)+(3*5)+1 \n when [3, 2] # need 2 of 4 to match\n # sequences with 2 of 4 dice: --**, -*-*, -**-, *--*, *-*-, **--\n # sequences with 3 of 4 dice: -***, *-**, ***-\n # sequences with 4 of 4 dice: ****\n useful_results = (6*5*5)+(4*5)+1\n when [3, 3] # need 3 of 5 to match\n # sequences with 3 of 5: --***, -**-*, -***-, *--**, *-*-*, *-**-, **--*, **-*-, ***--\n # sequences with 4 of 5: -****, *-***, ***-*, ****-\n # sequences with 5 of 5: ***** \n useful_results = (9*5*5)+(4*5)+1\n when [4, 1] # need 1 of 2 to match\n # sequences with 1 of 2 dice: -*, *-\n # sequences with 2 of 2 dice: **\n useful_results = (2*5)+1 \n when [4, 2] # need 2 of 3 to match\n # sequences with 2 of 3: -**, *-*, **-\n # sequences with 3 of 3: ***\n useful_results = (4*5)+1\n when [4, 3] # need 3 of 4 dice to match\n # sequences with 3 of 4 dice: -***, *-**, ***-\n # sequences with 4 of 4 dice: ****\n useful_results = (3*5)+1\n when [4, 4] # need 4 of 5 dice to match\n # sequences with 4 of 5: -****, *-***, ***-*, ****-\n # sequences with 5 of 5: ***** \n useful_results = (4*5)+1 \n else\n raise \"pair [#{minimum_count}, #{gap}] not expected\"\n end\n reroll_count = 5 - actual_count\n end\n puts \"useful results: #{useful_results}, reroll count: #{reroll_count}\" if debug\n p = calculate_probability(useful_results, reroll_count)\n return p\n end",
"def promedio(valor)\n valor.values.sum / valor.values.length\nend",
"def prom_ele(a)\n sum = 0\n a.each do |i|\n sum += i.to_i\n end\n puts sum / a.length.to_f\nend",
"def kcalproteinas\n\t\t\t@proteinas * 4\n\t\tend",
"def maxMinProm arr\n hash = {}\n hash[:max] = arr.max\n hash[:min] = arr.min\n sum = 0 \n arr.each{|i| sum += i}\n hash[:promedio] = sum/arr.length\n puts hash\nend",
"def hash(p)\n\t\tp.map{|x| (x/@grid_size).round.to_i}\n\tend",
"def calculate_probability\n @value.denominator.fdiv(@value.denominator + @value.numerator)\n end",
"def gradeDistribution( grades )\n # replace the following line with whatever gets a desired array of numerical grades\n gradeDistArray = { \"A\" => 0, \"B\" => 0, \"C\" => 0, \"D\" => 0, \"F\"=> 0 }\n gradeLetter = \"\"\n\n grades.each{ |grade| \n gradeLetter = getGradeLetter( grade )\n gradeDistArray[gradeLetter] += 1\n }\n return gradeDistArray\n end",
"def percent_ptn(kcal)\n (kcal * 100 / tee(kcal)).round(2)\n end",
"def pLipidos\n\t\tlip = 0\n\t\ttotal = 0\n\t\t@platos.each do |alimento|\n\t\t\ttotal += alimento.proteinas + alimento.lipidos + alimento.carbohidratos\n\t\t\tlip += alimento.lipidos\n\t\tend\n\t\treturn ((lip/total)*100).round\n\t\n\tend",
"def pyramid_sum(base)\n\nend",
"def total_digestate_nitrogen\n\t\t(calculations.collect(&:calc_digestate_nitrogen).sum).round 3\n\tend",
"def get_energia_proteins\n\t\t\t\t@proteins * 4\n\t\t\tend",
"def tally( p, first, x, lgx, prod, found )\n mult, log = 1, (lgx / Math.log( p[first] )).floor\n\n while 0 <= log\n pm = prod * mult\n break if pm > x\n\n if first < p.size - 1\n tally( p, first + 1, x, lgx, pm, found )\n else\n found[pm] = true\n end\n\n mult *= p[first]\n log -= 1\n end\n \n found.size\n end",
"def boys_to_girls(families)\n num_boys = families.map { |family| family[:num_boys] }.sum\n num_girls = families.map { |family| family[:num_girls] }.sum\n\n num_boys.to_f / num_girls.to_f\n end",
"def number_of_kcal_per_meal\n kcal_per_recipe = recipe_ingredients.each.sum do |recipe_ingredient|\n calories_per_gram = recipe_ingredient.ingredient.calories / 100 \n kilograms_of_ingredient = recipe_ingredient.calculated_weight_in_grams / 1000\n (calories_per_gram * kilograms_of_ingredient) #kcal\n end\n kcal_per_recipe / num_people\n end",
"def pyramid_height(cost, total)\n cans = total / cost\n n = 0\n n += 1 while (n*(n+1)*(2*n+1)) / 6 <= cans\n n - 1\nend",
"def top_n_to_percentage(percent)\n top = top_n\n total = top.map(&:last).sum\n cumulative_count = 0.0\n top_to_percentage = []\n\n while (cumulative_count / total) * 100 < percent\n result = top.shift\n top_to_percentage << result\n cumulative_count += result[1]\n end\n top_to_percentage\n end",
"def totient4 n\n Prime.prime_division(n).each do |factor, _|\n n = n * (factor - 1) / factor\n end\n return n\nend",
"def multiple_tables(max)\n (1..max).map{ |y| (1..max).map{ |x| (\"%4d\" % (x*y)).to_i } }\nend",
"def prime_factorize(target)\r\n factorize(target).group_by{|x| x}.map{|k,v| [k, v.length]}\r\n end",
"def get_num_students_per_grade(num_students)\n min = @scenarioYAML[\"MINIMUM_GRADE_PERCENTAGE\"]\n max = @scenarioYAML[\"MAXIMUM_GRADE_PERCENTAGE\"]\n\n if min.nil?\n @log.error \"MINIMUM_GRADE_PERCENTAGE must be set for a world to be created --> Exiting...\"\n abort\n end\n if max.nil?\n @log.error \"MAXIMUM_GRADE_PERCENTAGE must be set for a world to be created --> Exiting...\"\n abort\n end\n\n ((random_on_interval(min, max) / 100) * num_students).round\n end",
"def lip\n\t\tsuma = 0\n\t\tx = 0\n\t\tcantidad = 0\n\n\t\t@alimentos.each do |i|\n\t\t\tcantidad = @gramos[x].valor / (i.proteinas + i.lipidos + i.carbohidratos)\n\t\t\tsuma += i.lipidos * cantidad\n\t\t\tx += 1\n\t\tend\t\n\n\t\treturn ((suma * 100) / gramos_total).round(2)\n\tend",
"def proteinas\n food = @ingredientes.head\n protein = 0.0\n while food != nil do\n protein += food[:value].proteinas * (food[:value].gramos / 1000.0)\n food = food[:next]\n end\n protein * (100.0 / @total_nutricional)\n end",
"def pyramid_height(cost, total)\n cans = total / cost\n i = 0\n sum = 0\n while sum + (i+1)**2 <= cans\n i += 1\n sum += i**2\n end\n i\nend",
"def divide(how_many)\n me = self.dup\n (1..how_many).to_a.reverse.inject([]) do |parts,i|\n part,me = me.break((me.size.to_f / i).ceil)\n parts.push(part)\n end\n end",
"def proportion_total_sd_ep_wor(prop, sam, pop)\n fsc=((pop - sam).to_f / ( sam - 1))\n Math::sqrt(fsc*pop*prop*(1-prop))\n end",
"def die_distribution\n (1..6).each_with_object(Hash.new(0)) { |i, hash| hash[i] = 1 / 6.0 }\n end",
"def lipidsPercent()\n\t\t\t\tplato = @alimentsList.head\n\t\t\t\tgrams = @gramsList.head\n\t\t\t\ttotalEnergy = 0.0\n\t\t\t\ttotalLipidsEnergy = 0.0\n\n\t\t\t\twhile plato != nil\n\t\t\t\t\ttotalEnergy += (plato.value.get_energia * grams.value) / 100\n\t\t\t\t\ttotalLipidsEnergy += (plato.value.get_energia_lipidos * grams.value) / 100\n\n\t\t\t\t\tplato = plato.next\n\t\t\t\t\tgrams = grams.next\n\t\t\t\tend\n\n\t\t\t\treturn (totalLipidsEnergy * 100) / totalEnergy\n\t\t\tend"
] |
[
"0.7365413",
"0.6766243",
"0.6511807",
"0.64483833",
"0.64081544",
"0.6401411",
"0.6336636",
"0.6294464",
"0.62422097",
"0.62414074",
"0.62299377",
"0.6219277",
"0.6203855",
"0.62036914",
"0.6195573",
"0.61904097",
"0.6149979",
"0.6086585",
"0.6047143",
"0.6022688",
"0.6001526",
"0.5970458",
"0.5962825",
"0.59476733",
"0.5933256",
"0.58860296",
"0.58853185",
"0.5885281",
"0.58804727",
"0.58780444",
"0.58767164",
"0.5863347",
"0.58613765",
"0.5860709",
"0.5856381",
"0.5849879",
"0.58396333",
"0.58209634",
"0.5802611",
"0.5793039",
"0.5789224",
"0.57837397",
"0.5774994",
"0.57523495",
"0.5748207",
"0.5745337",
"0.57418287",
"0.5714681",
"0.57146543",
"0.57134646",
"0.5707525",
"0.5688087",
"0.5686303",
"0.56833416",
"0.5679598",
"0.5675053",
"0.5674369",
"0.56708634",
"0.566833",
"0.5666164",
"0.56629765",
"0.5655958",
"0.5653979",
"0.56528574",
"0.56513685",
"0.56508976",
"0.564569",
"0.5635085",
"0.5630851",
"0.5622786",
"0.5615763",
"0.5615362",
"0.56030655",
"0.5600095",
"0.5595873",
"0.55942386",
"0.55891013",
"0.5588657",
"0.5588644",
"0.55869687",
"0.5583039",
"0.5579491",
"0.55777895",
"0.5566457",
"0.5566194",
"0.5561941",
"0.55587167",
"0.55489117",
"0.5547221",
"0.5545366",
"0.5540479",
"0.55345345",
"0.5532157",
"0.5522887",
"0.55153507",
"0.55080795",
"0.55043125",
"0.5492948",
"0.54871255",
"0.5486278",
"0.5483625"
] |
0.0
|
-1
|
handles output random number adds to last 100 and output queue
|
def handle_output(val)
thread_id = nil
while thread_id.nil?
thread_id = Thread.current[:id]
end
p val
output = { value: val, thread: thread_id, time: Time.now }
@output_queue << output
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def random_num_gen()\n #puts 'This is a random number generator. The user will input the minimum \n #and maximum integers to declare the range the generator can output. The user \n #will also input the amount of times the generator will be called. The final\n #results will be stored in a table, which will be displayed after last call \n #to the generator is given.'\n entry = current_entry #set the entry number using \n puts 'Enter minimum value for range:'\n min_int = gets.chomp\n min_num = min_int.to_i\n puts 'Enter maximum value for range:'\n max_int = gets.chomp\n max_num = max_int.to_i\n #ensure that the minimum number is less than the maximum number\n while max_num <= min_num\n puts 'Max number is smaller than minimum number. Enter maximum value for range:'\n max_int = gets.chomp\n max_num = max_int.to_i\n end\n puts 'Enter the number of random numbers you would like to be output:'\n count = gets.chomp\n count = count.to_i\n puts \"\"\n t1 = Time.now\n call_random_server(min_int, max_int, count, entry)\n t2 = Time.now\n puts t2-t1\n return\nend",
"def call_out_update\n @call_out[0] = letters.sample\n @call_out[1] = rand 1..100\n p @call_out\n end",
"def next_output_id\n next_id = @last_output_id\n @last_output_id += 1\n next_id\n end",
"def output\n run\n ints[0]\n end",
"def enqueue_pending_output; end",
"def random(_, output_binary_p, num_bytes, status_p)\n write_binary_string_and_set_status(output_binary_p, status_p) do\n Hooks.random(num_bytes)\n end\n end",
"def gen\n until @output_history.empty? || @history_continuations.key?( @output_history )\n @output_history.shift\n end\n # history contunuation counters table\n contunuations = @history_continuations[ @output_history ]\n # number of all possible continuations\n r = contunuations.values.inject(0){ |sum, val| val+sum }\n # select random continuation (key from hash)\n r, item = rand(r), nil\n contunuations.each{ |key, val|\n if (r -= val) < 0\n # add item to output history\n @output_history << ( item = key )\n break\n end\n }\n item\n end",
"def avail_out= size\n\t\tsize.times do \n\t\t\tif size > avail_out\n\t\t\t\t@output_buffer.push nil\n\t\t\telse\n\t\t\t\t@output_buffer.pop\n\t\t\tend\n\t\tend\n\tend",
"def rand_gen\n rand100 = rand(1..100)\n if (0..50).cover?(rand100)\n output_val = 1\n elsif (51..75).cover?(rand100)\n output_val = 2\n elsif (76..90).cover?(rand100)\n output_val = 3\n elsif (91..95).cover?(rand100)\n output_val = 4\n elsif (96..100).cover?(rand100)\n output_val = 5\n end\n handle_output(output_val)\n end",
"def avail_out= size\n\t\t\tsize.times do\n\t\t\t\tif size > avail_out\n\t\t\t\t\t@output_buffer.push nil\n\t\t\t\telse\n\t\t\t\t\t@output_buffer.pop\n\t\t\t\tend\n\t\t\tend\n\t\tend",
"def flush_next_out\n\t\t@out_pos = @output_buffer.length\n\t\t@finished = true\n\t\tret = @output_buffer.pack(\"c*\")\n\t\t@output_buffer = []\n\t\tret\n\tend",
"def flush_next_out\n\t\t\t@out_pos = @output_buffer.length\n\t\t\t@finished = true\n\t\t\tret = @output_buffer.pack(\"c*\")\n\t\t\t@output_buffer = []\n\t\t\tret\n\t\tend",
"def generate_number\r\n return randomNumber = 1 + rand(100)\r\n end",
"def generate_number\r\n \r\n #Generate and return a random number between 1 and 100\r\n return randomNo = 1 + rand($maxChallengeRange)\r\n \r\n end",
"def generate_number\n \n #generate and return a random number from 1 to 100\n return randomNO = 1 + rand(1000)\n\n end",
"def random_no\n rand(5000)\nend",
"def blastoff\n\tprint \"Initiating... \"\n\t10.times do |i| \n\t\treturn if i == 9\n\t\tprint i.to_s + \" \"\n\tend\n\tprint \"...blastoff!\\n\" # This never gets printed :(\nend",
"def generate_number\r\n \r\n #Generate and return a random number between 1 and 1000\r\n return randomNo = 1 + rand(1000)\r\n \r\n end",
"def output(non_block=false)\n @outputQueue.pop(non_block) \n end",
"def dicks (n)\n n.times do\n puts \"#{BALLS}#{SHAFT * (rand(10)+1)}#{HEAD}\"\n end\nend",
"def random_num_generator\n return rand(1..100)\nend",
"def random_num_generator\n return rand(1..100)\nend",
"def gen_num\n rand(1..100)\nend",
"def num_gen\n \n numbers = []\n \n puts \"NUMBER GENERATOR PROGRAM-APPLICATION\"\n puts \"how many numbers to generate ?\"\n print \":\"\n amount = gets.to_i\n \n puts \"Largest number in set ?\"\n size = gets.to_i\n \n puts \"GENERATING NUMBERS ZERO to #{size}\"\n amount.times do \n numbers << rand(size)\n end\n return numbers\n\n end",
"def take_a_number(queue, name)\n queue << name\n puts \"Welcome, #{name}. You are number #{queue.length} in line.\"\nend",
"def printRandom(duration)\n st = \"q,w,e,r,t,y,u,i,o,p,a,s,d,f,g,h,j,k,l,z,x,c,v,b,n,m,Q,W,E,R,T,Y,U,I,O,P,A,S,D,F,G,H,J,K,L,Z,X,C,V,B,N,M,1,2,3,4,5,6,7,8,9,0,!,@,#,$,%,^,&,*,(,),_,+,[,],|,{,}\"\n x = st.split(\",\")\n currentTime = Time.now.to_i\n futureTime = currentTime + duration\n while (currentTime <= futureTime) do\n print \"#{isMe(onMe( x[$prng.rand(0...x.length())] ))}\"\n currentTime = Time.now.to_i\n end\n menu()\nend",
"def roll\n result = rand(1..6)\n print result\n result\nend",
"def random_number_max(msg, maximum)\n return if Variables::Constants::IGNORED_USERS.include?(msg.user.nick)\n number = rand(maximum.to_i)\n @last_numbers = [] if @last_numbers.nil?\n number = rand(maximum.to_i) while @last_numbers.include?(number)\n @last_numbers.prepend_capped(number, 5)\n number.to_s.separate if number > 999\n msg.reply(number)\n end",
"def get_output(num)\n messages = @messages.last(num)\n messages.count < 2 ? messages.first : messages\n end",
"def output_buffer; end",
"def output_buffer; end",
"def run()\r\n rounds.times do |i|\r\n round(i+1)\r\n end\r\n #$stderr.puts \"#{name} Finished!\\n\"\r\n #below codes is used to output report\r\n output()\r\n end",
"def form\n @max = params[:max]\n @@numbers = rand params[:max].to_i\n render :result\n end",
"def roll\n @numberShowing = 1 + rand(6)\n end",
"def randomize\n\t\tlines = Array.new\n\t\t@output_data.each do |line|\n\t\t\tlines << line.chomp\n\t\tend\n\t\tshuffle_array(lines)\n\t\t@output_data = lines.to_s\n\tend",
"def generate\n generations = 0\n loop do\n print\n sleep(0.5)\n newGeneration\n generations += 1\n p \"Number of generations: #{generations} [Ctrl-C to exit]\"\n end\n end",
"def receive(number)\n puts \"received number #{number}\"\n @queue << number\n end",
"def random\n (0...20).each do |i|\n randoms = Array.new\n randoms << rand(100)\n puts randoms\n end\nend",
"def response\n\t\tputs @answers[rand(@answers.length - 1)]\n\tend",
"def generate_order_number\n record = true\n while record\n random = \"R#{Array.new(9){rand(9)}.join}\"\n record = self.class.where(:number => random).first\n end\n self.number = random if self.number.blank?\n self.number\n end",
"def main\n\t\n\tsubtract_random_number\t\n\nend",
"def roll_dice\n fired_peeps = \" \"\n new_hires = \" \"\n dice = rand(1..5) + 1\n puts \"Boss rolled #{dice}:\"\n puts \"List of fired \\t\\t List of Hired\"\n dice.times do\n fired_peeps = @employed.pop\n new_hires = @temp.dequeue\n puts \"#{fired_peeps} \\t\\t\\t\\t #{new_hires}\"\n @employed.push(new_hires)\n @temp.enqueue(fired_peeps)\nend\nend",
"def randomizer\n number = rand(0..1)\n return number\nend",
"def randomizer\n output = []\n max = (@size * @size) - 1\n i = 0\n while i < @num_mines\n num = Random.new.rand(max)\n unless output.include?(num)\n output << num\n i += 1\n end\n end\n output.sort\n end",
"def number\n\t\"#{Time.now.to_i}-#{rand(1_000_000)}\"\n end",
"def generate_number\n record = true\n while record\n random = \"O#{Array.new(9){rand(9)}.join}\"\n record = Order.find(:first, :conditions => [\"number = ?\", random])\n end\n self.number = random\n end",
"def roll\n @number = rand(1..6)\n audit\n @number\n end",
"def gen_rand b\n p = rand(2**b)+2**b-1\n while ! rand_test p\n# puts p\n p += 1\n end\n p\nend",
"def get_random\n @number_list[Random.new.rand(@number_list.length)]\n end",
"def runner\n welcome\n current_total = initial_round # rand1 + rand 2 p \"total = 14\" =>14\n # puts \"initializing until loop...\"\n until current_total > 21\n # puts \"INCREMENT\"\n current_total = hit?(current_total) # \"h or s?\" h--> 14 + 4 s--> \n display_card_total(current_total)\n end\n end_game(current_total)\nend",
"def show\n @random_number = 1 + rand(10)\n @result = Number.compare_numbers(@number.input, @random_number)\n end",
"def beer_song number\r\n\r\n\twhile number != 0\r\n\t\tputs number.to_s + \" bottles of beer on the wall, \" + number.to_s + \" bottles of beer.\"\r\n\t\tnumber -= 1\r\n\t\tputs \"Take one down and pass it around, \" + number.to_s + \" bottles of beer on the wall.\"\r\n\t\tputs\r\n\tend\r\nend",
"def unique_command_resp_queue\n \"wamp:#{self.name}:response:#{SecureRandom.hex(12)}\"\n end",
"def get_random()\n rand(@count).times { @cur = @cur.next }\n @cur.val\n end",
"def kick\n rng.rand(value_range)\n end",
"def result\n user_number = params[:number1].to_i\n number = @@numbers\n if number < user_number\n @result = \"Make it less\"\n elsif number>user_number\n @result = \"Make it more\"\n else\n @result = \"Yes, The secret number is #{number}\"\n # if the player could guess the secret number, this will gonna change-\n # the number as player can play again\n # @@number_rand = rand 500\n @@numbers = rand params[:max]\n end\n end",
"def take_a_number(queue, person)\n queue << person\n puts \"Welcome, #{person}. You are number #{queue.length} in line.\"\nend",
"def rand(max=0) end",
"def generatePrintPMQuadtree(times_to_gen, genRandom)\n\n\txml_result = \"\"\n\ttimes_to_gen.times {\n\n\t\t# generating random or custom values\n\t\tif (genRandom)\n\t\t\tremoteX = rand($remote_width.to_i + 5)\n\t\t\tremoteY = rand($remote_height.to_i + 5)\n\t\telse\n\t\t\tprint(\"\\nEnter a remoteX: \")\n\t\t\tremoteX = $stdin.readline.chomp\n\t\t\tprint(\"\\nEnter a remoteY: \")\n\t\t\tremoteY = $stdin.readline.chomp\n\t\tend\n\n\t\txml_result += \"\\n<printPMQuadtree id=\\\"10\\\" remoteX=\\\"#{remoteX}\\\" remoteY=\\\"#{remoteY}\\\" />\" \n\t\n\t}\n\n\treturn xml_result\n\nend",
"def roll\n @number = rand(1..6)\n end",
"def take\n @dummy_num -= 1\n refresh\n end",
"def increment\n if @seed < @max\n @seed += 1\n else\n @seed = 0\n end\nend",
"def temp_count\n @count = rand(0..10)\n end",
"def store_results_file\r\n\taFile = File.new(\"./random_number_result.txt\", \"r+\")\r\n\taFile.truncate(0)\r\n\tnumber = generate_random_number\r\n\tputs aFile.syswrite(\"#{number}\")\r\nend",
"def generate_number\n begin\n begin\n num = rand(10)\n end while @guessed_number.include?(num)\n @guessed_number.push(num)\n end while @guessed_number.size < 4\n end",
"def terrors_allot\r\n randomnums = Random.new\r\n for num in (1..6) do\r\n roomn = randomnums.rand(1...19)\r\n num += 1\r\n while roomn == 6 or roomn == 11 or roomn == 9 or get_some_room_stuff(roomn,6) != 0\r\n roomn = randomnums.rand(1...19)\r\n end\r\n num-=1\r\n set_at_room(roomn,6,num)\r\n #puts $ooms_map[roomn]\r\n #puts(\"----------------terror\")\r\n end\r\nend",
"def after_resolution\n output.puts\n end",
"def increment(input, add_frequency = 10000)\n if rand(add_frequency) == 5\n add_one input\n else\n change_one input\n end\n end",
"def update_input_number\n @waiter += 1 if @waiter < MAX_WAIT\n return super\n end",
"def next_value\n if @randcnt == 0\n isaac\n @randcnt = 256\n end\n @randcnt -= 1\n @randrsl[@randcnt].int\n end",
"def get_random_number\n\t\trandom_num = rand(@deck.length)\n\tend",
"def consume_number; end",
"def next\n Time.now + @min + Random.rand(@max - @min)\n end",
"def roll\n range = [1,2,3,4,5,6]\n result = range[rand(0..5)]\n print result\n print \"\\n\"\n return result\nend",
"def delay\n sleep(rand / 100)\n end",
"def get_rand range\n\t\t@random_number = rand(range)\n\tend",
"def roll\n random_nums = rand(1..6)\n random_nums\nend",
"def pbRockSmashRandomEncounter\n if rand(100)<25\n pbEncounter(EncounterTypes::RockSmash)\n end\nend",
"def printStringS(printMe, duration)\n x = printMe.split(\", \")\n currentTime = Time.now.to_i\n futureTime = currentTime + duration\n while (currentTime <= futureTime) do\n print \"#{isMe(onMe(x[$prng.rand(0...x.length())]))}\"\n currentTime = Time.now.to_i\n end\n menu()\nend",
"def roll_dice(upper_limit)\n number = rand(1..upper_limit)\n puts \"You rolled a \" + number.to_s\nend",
"def roll\n\t\t\t@number = rand(1..6)\n\t\t\taudit\n\t\t\t@number \t# return the number as the caller expect a return number\n\t\tend",
"def index\n \n @randomNumber1 = 0;\n @randomNumber2 = 55;\n\n end",
"def handle_output_on_tick(value)\n if block_given?\n yield value, index\n else\n if value.nil?\n fail \"Options musn't be empty\" if @options.nil?\n @send_command ||= begin\n log.debug \"Animation ended, sending transition command, target: #{@options[:goto_target]} state: #{@options[:goto_state]}\"\n NixonPi::Messaging::CommandSender.new.send_command(@options[:goto_target], state: @options[:goto_state])\n log.debug 'already sent transistion command'\n end\n else\n log.debug \"animation value: #{value}\"\n @driver.write(value)\n end\n\n end\n end",
"def roll\n # code goes here\n random_num = rand(6) + 1\n return random_num\nend",
"def writer(buffer_max, interval)\n last_sent = Time.now\n buffered = []\n store_logger_name\n loop do\n msg = @q.pop\n buffered.push(msg) unless control_msg?(msg)\n now = Time.new\n if buffered.count >= buffer_max || (now - last_sent) > interval || msg == :exit\n write_batch(buffered)\n return if msg == :exit\n last_sent = Time.now\n buffered = []\n end\n end\n end",
"def make_next_seq_no\n if EdiHelper.current_out_is_cumulative || @return_a_string\n @out_seq = 1\n else\n @out_seq = MesControlFile.next_seq_edi(MesControlFile.const_get(\"EDI_#{@flow_type.upcase}\"))\n @seq_increased = true\n end\n @formatted_seq = sprintf('%03d', @out_seq)\n end",
"def stream_result(out, work)\n buffer = Rubinjam::HEADER.dup\n loop do\n break if buffer.empty?\n 20.times do # check often -> don't hang for long\n if !work.alive?\n out.print buffer # we are done, write the remaining buffer\n out.print work.value.sub(Rubinjam::HEADER, '')\n return\n end\n sleep 1\n end\n out.print buffer.slice!(0, 1)\n out.flush\n end\n\n # we already sent the '200 OK' ... tell the user something useful ...\n out.print \"\\nraise 'code generation took too long'\"\nend",
"def generate_totalrand\n return @challenges[0] if @challenges.size == 1\n loop do\n rand_index = rand(@challenges.size)\n chall = @challenges[rand_index]\n if Lecode_BattleChallenge::Use_Frequency\n if rand(100) < chall.freq\n update_lastlyUsed(chall)\n return chall\n end\n else\n update_lastlyUsed(chall)\n return chall\n end\n end\n end",
"def get_random\n @num.sample.first\n end",
"def output\n puts \"\\n\"\n 0.upto(@order - 1) do |r|\n row_for(@order, r)\n puts \"\\n\\n\"\n end\n end",
"def generate_output_of ( job )\n @job = job\n generate_output\n end",
"def random\n 1 + (10 * rand(0))\n end",
"def queue; end",
"def queue; end",
"def roll\n randomValue = rand(6)+1\n randomValue\nend",
"def randomize_count()\n @rand_count\n end",
"def roll\n 1 + rand(6)\n # the code below also works! Keep in mind for the deli counter problem.\n # my_array = (1..6).to_a \n # random_sample = my_array.sample\nend",
"def treasures_allot\r\n randomnums = Random.new\r\n for num in (1..4) do\r\n roomn = randomnums.rand(1...19)\r\n num += 1\r\n while roomn == 6 or roomn == 11 or roomn == 9 or get_some_room_stuff(roomn,6) != 0\r\n roomn = randomnums.rand(1...19)\r\n end\r\n num-=1\r\n set_at_room(roomn,6, randomnums.rand(10...109))\r\n #puts $ooms_map[roomn]\r\n #puts(\"----------------treasure\")\r\n end\r\nend",
"def first_roll\n # code goes here\n num = rand(1..6)\n num\nend",
"def get_totp(totp_size = 6)\n totp = \"\"\n totp_size.times { totp << Random.rand(10).to_s }\n return totp\nend"
] |
[
"0.63140595",
"0.6294203",
"0.60098594",
"0.59087336",
"0.5782824",
"0.57827455",
"0.5767869",
"0.5752885",
"0.56497514",
"0.56010026",
"0.55951005",
"0.5588491",
"0.55883473",
"0.5511223",
"0.548834",
"0.54845077",
"0.5483907",
"0.5456574",
"0.5448022",
"0.5412136",
"0.5408621",
"0.5408621",
"0.53935564",
"0.5331831",
"0.5329263",
"0.5319124",
"0.52924514",
"0.52913344",
"0.5276399",
"0.5263972",
"0.5263972",
"0.5249019",
"0.5236786",
"0.5231882",
"0.52092737",
"0.52082914",
"0.52067304",
"0.5193539",
"0.51811796",
"0.5175981",
"0.5172039",
"0.5159491",
"0.5156814",
"0.5149331",
"0.51413125",
"0.5131998",
"0.5122454",
"0.51146346",
"0.51083666",
"0.5106376",
"0.50946206",
"0.5086739",
"0.50805384",
"0.5078707",
"0.5065637",
"0.5053054",
"0.5048401",
"0.5045889",
"0.5037893",
"0.50281215",
"0.5026236",
"0.5014745",
"0.50102234",
"0.50064903",
"0.50056183",
"0.49971667",
"0.4992016",
"0.49883276",
"0.49850202",
"0.49845985",
"0.49835718",
"0.4983333",
"0.49745396",
"0.49744934",
"0.4972526",
"0.4971925",
"0.497192",
"0.49698555",
"0.49663463",
"0.4964921",
"0.49624157",
"0.49613225",
"0.49600628",
"0.49516538",
"0.49475116",
"0.49458185",
"0.49450472",
"0.49435064",
"0.4942657",
"0.4932463",
"0.4930402",
"0.4927617",
"0.49220037",
"0.49220037",
"0.4921358",
"0.49204984",
"0.49195936",
"0.49158955",
"0.49153727",
"0.49112302"
] |
0.58664846
|
4
|
need things for the
|
def request_quote
@title = "Request a Quote"
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def probers; end",
"def private; end",
"def extra; end",
"def checks; end",
"def requirements; end",
"def requirements; end",
"def requirements; end",
"def requirements; end",
"def stderrs; end",
"def used?; end",
"def operations; end",
"def operations; end",
"def prerequisites\n\tsuper\n end",
"def prerequisites\n\tsuper\n end",
"def weber; end",
"def who_we_are\r\n end",
"def specie; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def schubert; end",
"def berlioz; end",
"def processor; end",
"def manufacture; end",
"def variables; end",
"def variables; end",
"def sitemaps; end",
"def parts; end",
"def parts; end",
"def parts; end",
"def common\n \n end",
"def dependencies; end",
"def dependencies; end",
"def dependencies; end",
"def available; end",
"def available; end",
"def terpene; end",
"def runnables; end",
"def blg; end",
"def custom; end",
"def custom; end",
"def extra_state; end",
"def placebo?; false end",
"def malts; end",
"def registers; end",
"def usable?; end",
"def nasa_space_craft; end",
"def anatomy; end",
"def suivre; end",
"def pausable; end",
"def appraisals; end",
"def appraisals; end",
"def required_data() [] end",
"def components; end",
"def refutal()\n end",
"def hints; end",
"def prep\n\tend",
"def parameters; end",
"def parameters; end",
"def parameters; end",
"def parameters; end",
"def parameters; end",
"def parameters; end",
"def parameters; end",
"def parameters; end",
"def process_and_build_components \n end",
"def ready; end",
"def ready; end",
"def guct\n end",
"def internship_passed; end",
"def prepare admr\n \n end",
"def check_bingo\n\t\t\n\tend",
"def methods() end",
"def trd; end",
"def precheck\n end",
"def anchored; end",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"def passes; end",
"def passes; end",
"def usage; end",
"def usage; end",
"def defs; end",
"def defs; end",
"def internal; end",
"def mitch_hedberg; end",
"def flags; end",
"def strain; end",
"def extra; @extra; end",
"def incomplete\r\n\r\n end",
"def intensifier; end",
"def strategy; end",
"def check\n \n end",
"def check\n \n end"
] |
[
"0.6832558",
"0.6722757",
"0.62319183",
"0.6226191",
"0.6166615",
"0.6166615",
"0.6166615",
"0.6166615",
"0.6164982",
"0.6152642",
"0.609288",
"0.609288",
"0.6076976",
"0.6076976",
"0.6045996",
"0.60317576",
"0.6024511",
"0.6024511",
"0.6024511",
"0.6024511",
"0.60048133",
"0.59602153",
"0.5932006",
"0.5923491",
"0.59053844",
"0.59053844",
"0.59010583",
"0.588657",
"0.588657",
"0.588657",
"0.5880027",
"0.5825597",
"0.5825597",
"0.5825597",
"0.58009213",
"0.58009213",
"0.57803637",
"0.57757246",
"0.5772174",
"0.57633704",
"0.57633704",
"0.5752934",
"0.57463276",
"0.57461536",
"0.57187074",
"0.5717971",
"0.5708559",
"0.570439",
"0.5693989",
"0.5686985",
"0.56800294",
"0.56800294",
"0.5669471",
"0.5665043",
"0.56636125",
"0.5649181",
"0.564761",
"0.5626386",
"0.5626386",
"0.5626386",
"0.5626386",
"0.5626386",
"0.5626386",
"0.5626386",
"0.5626386",
"0.5625445",
"0.5615247",
"0.5615247",
"0.5610476",
"0.5603771",
"0.55972254",
"0.55828965",
"0.55795187",
"0.5575938",
"0.55719215",
"0.5567957",
"0.55529267",
"0.55529267",
"0.55529267",
"0.55529267",
"0.55529267",
"0.55529267",
"0.55529267",
"0.55529267",
"0.55529267",
"0.554922",
"0.554922",
"0.5548557",
"0.5548557",
"0.55460244",
"0.55460244",
"0.5541122",
"0.5539564",
"0.55269355",
"0.5525008",
"0.55195314",
"0.55099076",
"0.55033827",
"0.55029655",
"0.5500512",
"0.5500512"
] |
0.0
|
-1
|
GET /children GET /children.json
|
def index
if !signed_in?
redirect_to root_path
end
@children = Child.all
if !params[:search].nil?
@result = Child.search(params[:search])
end
if @result.nil? && params[:search].nil?
@result = Child.all
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def children\n @pages = @page.children\n \n respond_to do |format|\n format.json { render :json => @pages }\n format.xml { render :xml => @pages }\n end\n end",
"def children\n render json: { status: 'ok', content: [] }\n end",
"def children\n @resource.children\n end",
"def get_children\n @children\n end",
"def children\n @id = fix_id(params[:id], params[:format], params[:extra])\n if params[:root]==\"source\" then\n @isRoot = true;\n @work = DcmWork.new(@id)\n @children = [@work.pi]\n else\n @isRoot = false;\n @children = get_children(\"nla.\"+params[:root])\n end\n render :action => \"children.json\"\n end",
"def get_children\n \t@children\n end",
"def children\n params[:scope] ||= \"private\"\n\n children = if params[:scope] == Scopes::SCOPE_PRIVATE\n @folder&.children ||\n current_user.nodes.where(parent_folder_id: nil)\n elsif params[:scope] == Scopes::SCOPE_PUBLIC\n @folder&.children ||\n Node.where(scope: params[:scope], parent_folder_id: nil)\n end\n\n if [Scopes::SCOPE_PRIVATE, Scopes::SCOPE_PUBLIC].include?(params[:scope])\n children = children.where.not(sti_type: \"Asset\")\n end\n\n children = children.where(scope: params[:scope]).order(:sti_type, :name)\n\n render json: children, root: \"nodes\", adapter: :json\n end",
"def children_get()\n @children\n end",
"def children\n\t@child = Child.find(params[:id])\n\t@parents = @child.parents.all\n\trespond_to do |format|\n\t\tformat.js { }\n\tend\n end",
"def children\n @children\n end",
"def children\n @children\n end",
"def _children\n @children\n end",
"def _children\n @children\n end",
"def _children\n @children\n end",
"def _children\n @children\n end",
"def _children\n @children\n end",
"def children\n return @children if !@children.nil?\n @children = all_children.find_all{|collection| collection.url.count('/') == self.url.count('/') + 1}\n end",
"def children\n parent_id = params['parent_id']\n\n children = Child.includes(:bursts).where(parent_id: parent_id).map{ |child|\n last_burst = child.bursts.last\n burst_rate = last_burst.present? ? calc_burst_rate(last_burst) : 0\n\n {\n id: child.id,\n name: child.name,\n burst_rate: burst_rate\n }\n }\n\n render json: children\n end",
"def get_children\n return @children\n end",
"def _children\n @children\n end",
"def children\n _children\n end",
"def children\n attributes.fetch(:children)\n end",
"def get_children\n return children\n end",
"def children(*args)\n return call_ancestry_method(:children) if use_ancestry?\n\n Relationship.resources(child_rels(*args))\n end",
"def children()\n #Ressource.filter(:parent_id => self.id, :parent_service_id => self.service_id).all\n end",
"def children\n @children ||= []\n end",
"def children\n EarLogger.instance.log \"Finding children for #{self}\"\n ObjectManager.instance.find_children(self.id, self.class.to_s)\n end",
"def get_children(params)\n scope_data_class(params) do\n params[:limit] = config[:rows_per_page] if config[:enable_pagination] && (params[:id].nil? || params[:id] == 'root')\n params[:scope] = config[:scope]\n data_adapter.get_records(params, final_columns)\n end\n end",
"def children\n @children ||= {}.with_indifferent_access\n end",
"def get_children(h, n)\n rr = h[n[:id]]\n if !rr.nil?\n rr[:children]\n else\n []\n end\n end",
"def get_children(h, n)\n rr = h[n[:id]]\n if !rr.nil?\n rr[:children]\n else\n []\n end\n end",
"def list_children id\n\t\traw_output = @fred.category( 'children', category_id: id.to_s )\n\n\t\traw_output.categories.category\n\tend",
"def children\n []\n end",
"def children\n []\n end",
"def show\n if(params.has_key?(:children))\n if(params[:children] == \"true\")\n @node = Node.find(params[:id]).children\n end\n else\n @node = Node.find(params[:id])\n end\n render json: @node\n end",
"def get_children()\n {}\n end",
"def children\n []\n end",
"def children\n []\n end",
"def children\n []\n end",
"def index\n children = []\n base_uri = 'https://postjson-d117c.firebaseio.com/'\n @firebase = Firebase::Client.new(base_uri)\n childrenjs = @firebase.get(\"Child\")\n parsed = JSON.parse(childrenjs.raw_body)\n kids = parsed.deep_symbolize_keys\n\n kids.uniq.each do |key, value|\n value.each do |key2, value2|\n children << value\n end\n end \n \n@children = children.flatten.uniq\n # render :json => @children\n\n end",
"def children\n []\n end",
"def children\n []\n end",
"def children(options={})\n @global_page.children.all options\n end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def get_paged_org_unit_children(org_unit_id, bookmark = '')\n path = \"/d2l/api/lp/#{$lp_ver}/orgstructure/#{org_unit_id}/children/paged/\"\n path += \"?bookmark=#{bookmark}\" if bookmark != ''\n _get(path)\n # return json of org_unit children\nend",
"def children\n entries\n end",
"def children\n return [] if child_count <= 0\n with_cache(:children) do\n @od.request(\"#{api_path}/children?$top=1000\")['value'].map do |child|\n OneDriveItem.smart_new(@od, child)\n end\n end\n end",
"def show\n @children = Children.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @children }\n end\n end",
"def fetch_children\n @children = []\n for item in self.listex\n if item[\"type\"] == \"folder\" and item[\"id\"]!=@id #sharefile API includes self in list\n @children << Folder.new(item[\"id\"], @authid, @subdomain, false, item)\n elsif item[\"type\"] == \"file\"\n @children << File.new(item[\"id\"], @authid, @subdomain, item)\n end\n end\n end",
"def children\n self.class.children(self) \n end",
"def index\n @pages = @parent_page.children\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @pages }\n end\n end",
"def children\n children_tree.values\n end",
"def children\n children_tree.values\n end",
"def get_children(name, options)\n children = hash[name]\n children = children.is_a?(Hash) ? children : {}\n\n create_hash_children(children, options)\n end",
"def children()\r\n raise \"get_children is not implemented for class #{self.class}\"\r\n end",
"def get_children(args = '', output = :OBJECT)\n kids = {}\n if args.blank?\n if $GLOBALS['post']\n args = { post_parent: $GLOBALS['post'].post_parent }\n else\n return kids\n end\n elsif args.is_a? Integer\n args = { post_parent: args}\n elsif args.is_a? String\n args = { post_parent: args.to_i}\n elsif args.is_a? Railspress::WpPost\n args = { post_parent: args.post_parent }\n end\n\n defaults = {\n numberposts: -1,\n post_type: 'any',\n post_status: 'any',\n post_parent: 0,\n }\n\n r = defaults.merge args\n\n children = get_posts(r)\n\n return kids if children.nil?\n\n return children unless r[:fields].blank?\n\n # update_post_cache(children)\n\n children.each do |child|\n kids[child.id] = child\n end\n\n if output == :OBJECT\n kids\n elsif output == :ARRAY_A\n weeuns = {}\n kids.values.each do |kid|\n weeuns[kid.id] = kid.attributes\n end\n return weeuns\n elsif output == :ARRAY_N\n babes = {}\n kids.values.each do |kid|\n babes[kid.id] = kid.attributes.values\n end\n return babes\n else\n kids\n end\n end",
"def children\n ie = index_entry\n ie.children.collect{ |child| child.resource } if ie\n end",
"def all_children\n children(all: true)\n end",
"def all_children\n find_all_children_with_dotted_ids\n end",
"def children(path)\n # r = nil\n # zk_call do\n # r = @zk.get_children(path: path)\n # end\n # debug \"ZK: Children '#{path}' => '#{r}'\"\n # raise NonExistingPathException.new(path) unless r[:stat].exists?\n # r[:children]\n end",
"def getAllChildren\n children = Tree.where(\"tree_type_id = ? AND version_id = ? AND subject_id = ? AND grade_band_id = ? AND code like ?\", tree_type_id, version_id, subject_id, grade_band_id, code+'.%')\n Rails.logger.debug(\"*** tree children: #{children.inspect}\")\n return children\n end",
"def children\n unless defined? @children\n @children = Array.new\n end\n return @children\n end",
"def index\n @dec_form_children = DecFormChild.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @dec_form_children }\n end\n end",
"def children\n node.children\n end",
"def children\n Array.new\n end",
"def index\n @parents = Parent.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @parents }\n end\n end",
"def list_children(path)\n path = \"#{Paths::VFS}/#{path}\" unless path.start_with?(Paths::VFS)\n path = sanitize_path(path)\n\n @api.get(path)\n end",
"def children\n properties \n end",
"def get_children_folders(folder_id)\n url = URI(\"#{$base_url}/api/projects/#{$project_id}/folders/#{folder_id}/children\")\n\n http = Net::HTTP.new(url.host, url.port)\n http.use_ssl = true\n request = Net::HTTP::Get.new(url)\n request[\"accept\"] = 'application/vnd.api+json; version=1'\n request[\"access-token\"] = $access_token\n request[\"uid\"] = $uid\n request[\"client\"] = $client\n response = http.request(request)\n\n folders_json = ''\n\n if response.code == 200.to_s\n folders_json = JSON.parse(response.read_body)['data']\n else\n puts \"Problem with getting folders. Status: #{response.code}\"\n puts response.body\n end\n folders_json\nend",
"def children\n @ref.children.to_ruby\n end",
"def index\n @traumatized_children = TraumatizedChild.all\n end",
"def children(*args)\n self.class.send(:with_scope, :find=>{:conditions=>['parent_node_id=?', self.child_node_id]}) do\n self.class.find(:all, *args)\n end\n end",
"def children\n kids = []\n each_child { |kid| kids << kid }\n kids\n end",
"def children\n\t\treturn self.search( :one, '(objectClass=*)' )\n\tend",
"def roots\n @objects = Node.roots\n respond_to do |format|\n format.html\n format.json {render json: @objects}\n end\n end",
"def show\n children = []\n base_uri = 'https://postjson-d117c.firebaseio.com/'\n @firebase = Firebase::Client.new(base_uri)\n childrenjs = @firebase.get(\"Child\")\n parsed = JSON.parse(childrenjs.raw_body)\n kids = parsed.deep_symbolize_keys\n\n kids.uniq.each do |key, value|\n value.each do |key2, value2|\n \n children << key\n end\n end\n parsed.each do |key, value|\n children << key\n value.each do |key3, value3|\n children << value3\n end\n end\n \n response = @firebase.get(\"Child/\").raw_body\n #@child = eval(response)\n \n render :json => response\n end",
"def children\n # return students\n return offerings\n end",
"def index\n @child = Child.all\n end",
"def index\n @pages = Page.paginate(page: params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: Page.roots.map{|r| r.node}}\n end\n end",
"def children\n raise NotImplementedError\n end",
"def get_children(pi)\n response = Net::HTTP.get_response URI.parse(URI.escape(SERVICE_DCMDB + \"work/\" + pi + \"/children\"))\n children = Array.new\n case response\n when Net::HTTPSuccess\n doc = Document.new(response.body)\n XPath.each(doc, \"//workpid\") { |el|\n children.push(el.text)\n } \n end\n\n return children\n\n end",
"def all_children\n return @all_children if !@all_children.nil?\n @all_children = PhotoCollection.all_urls.find_all{|url| url[self.url] && url != self.url}.collect{|url| PhotoCollection.find_by_url(url)}\n end",
"def getObjectChildren _obj, _args\n \"_obj getObjectChildren _args;\" \n end",
"def children(entity)\n self.all(:parent_id => entity.id)\n end",
"def children\n Feature.find(:all, :conditions => [ 'parent_id=?', self.id] )\n end",
"def current_children\n\t p @children\n\tend",
"def children\n self.class.where('? = ANY(parent_ids)', id.to_s)\n end",
"def get_children()\n return @space.get_children()\n end",
"def children\n child_objects(Dependency)\n end",
"def all_activities_children\n @activity_children = ActivityChild.includes(:child)\n end"
] |
[
"0.80130404",
"0.7882042",
"0.7781168",
"0.7538884",
"0.7376999",
"0.73671556",
"0.7354207",
"0.73513156",
"0.7289584",
"0.72810805",
"0.72810805",
"0.7223111",
"0.7223111",
"0.7223111",
"0.7223111",
"0.7161739",
"0.71592",
"0.7154487",
"0.7149481",
"0.7119744",
"0.7077208",
"0.70744425",
"0.7068363",
"0.7006868",
"0.69452524",
"0.69406825",
"0.6889751",
"0.68373454",
"0.68228793",
"0.68163884",
"0.68163884",
"0.6803557",
"0.6790239",
"0.6766579",
"0.6755903",
"0.67295414",
"0.6718265",
"0.6718265",
"0.6718265",
"0.6708626",
"0.6691721",
"0.6691721",
"0.66737634",
"0.66289145",
"0.66289145",
"0.66289145",
"0.66289145",
"0.66289145",
"0.66289145",
"0.66289145",
"0.66289145",
"0.66289145",
"0.66289145",
"0.66289145",
"0.66289145",
"0.6623755",
"0.6600997",
"0.65841967",
"0.6583331",
"0.65787333",
"0.6553719",
"0.6547198",
"0.6526974",
"0.6526974",
"0.650869",
"0.6508471",
"0.64918905",
"0.6484928",
"0.64784974",
"0.6475587",
"0.64754194",
"0.64605445",
"0.64591956",
"0.64560896",
"0.6446656",
"0.6431386",
"0.64251655",
"0.6422385",
"0.640457",
"0.63998264",
"0.639431",
"0.6370573",
"0.63604105",
"0.6343819",
"0.6332041",
"0.63188386",
"0.6318659",
"0.6307421",
"0.6272279",
"0.6260352",
"0.62424135",
"0.62353426",
"0.62263495",
"0.62246186",
"0.62223494",
"0.6210727",
"0.62099445",
"0.6199819",
"0.61997926",
"0.6198872",
"0.61537963"
] |
0.0
|
-1
|
GET /children/1 GET /children/1.json
|
def show
if !signed_in?
redirect_to root_path
end
if !@child.dob.blank?
@child.age_years = ageYears(@child)
@child.age_months = ageMonths(@child)
@child.age_total_months = ageTotalMonths(@child)
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def children\n @pages = @page.children\n \n respond_to do |format|\n format.json { render :json => @pages }\n format.xml { render :xml => @pages }\n end\n end",
"def children\n @id = fix_id(params[:id], params[:format], params[:extra])\n if params[:root]==\"source\" then\n @isRoot = true;\n @work = DcmWork.new(@id)\n @children = [@work.pi]\n else\n @isRoot = false;\n @children = get_children(\"nla.\"+params[:root])\n end\n render :action => \"children.json\"\n end",
"def children\n render json: { status: 'ok', content: [] }\n end",
"def get_children\n @children\n end",
"def children\n @resource.children\n end",
"def show\n if(params.has_key?(:children))\n if(params[:children] == \"true\")\n @node = Node.find(params[:id]).children\n end\n else\n @node = Node.find(params[:id])\n end\n render json: @node\n end",
"def children_get()\n @children\n end",
"def children\n @children\n end",
"def children\n @children\n end",
"def get_children\n \t@children\n end",
"def children\n\t@child = Child.find(params[:id])\n\t@parents = @child.parents.all\n\trespond_to do |format|\n\t\tformat.js { }\n\tend\n end",
"def show\n @children = Children.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @children }\n end\n end",
"def children\n parent_id = params['parent_id']\n\n children = Child.includes(:bursts).where(parent_id: parent_id).map{ |child|\n last_burst = child.bursts.last\n burst_rate = last_burst.present? ? calc_burst_rate(last_burst) : 0\n\n {\n id: child.id,\n name: child.name,\n burst_rate: burst_rate\n }\n }\n\n render json: children\n end",
"def _children\n @children\n end",
"def _children\n @children\n end",
"def _children\n @children\n end",
"def _children\n @children\n end",
"def children\n return @children if !@children.nil?\n @children = all_children.find_all{|collection| collection.url.count('/') == self.url.count('/') + 1}\n end",
"def get_children(h, n)\n rr = h[n[:id]]\n if !rr.nil?\n rr[:children]\n else\n []\n end\n end",
"def get_children(h, n)\n rr = h[n[:id]]\n if !rr.nil?\n rr[:children]\n else\n []\n end\n end",
"def children\n attributes.fetch(:children)\n end",
"def _children\n @children\n end",
"def children\n params[:scope] ||= \"private\"\n\n children = if params[:scope] == Scopes::SCOPE_PRIVATE\n @folder&.children ||\n current_user.nodes.where(parent_folder_id: nil)\n elsif params[:scope] == Scopes::SCOPE_PUBLIC\n @folder&.children ||\n Node.where(scope: params[:scope], parent_folder_id: nil)\n end\n\n if [Scopes::SCOPE_PRIVATE, Scopes::SCOPE_PUBLIC].include?(params[:scope])\n children = children.where.not(sti_type: \"Asset\")\n end\n\n children = children.where(scope: params[:scope]).order(:sti_type, :name)\n\n render json: children, root: \"nodes\", adapter: :json\n end",
"def list_children id\n\t\traw_output = @fred.category( 'children', category_id: id.to_s )\n\n\t\traw_output.categories.category\n\tend",
"def children()\n #Ressource.filter(:parent_id => self.id, :parent_service_id => self.service_id).all\n end",
"def _children\n @children\n end",
"def index\n @pages = @parent_page.children\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @pages }\n end\n end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def get_children\n return @children\n end",
"def index\n @child = Child.all\n end",
"def get_children(params)\n scope_data_class(params) do\n params[:limit] = config[:rows_per_page] if config[:enable_pagination] && (params[:id].nil? || params[:id] == 'root')\n params[:scope] = config[:scope]\n data_adapter.get_records(params, final_columns)\n end\n end",
"def index\n @parents = Parent.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @parents }\n end\n end",
"def children(*args)\n return call_ancestry_method(:children) if use_ancestry?\n\n Relationship.resources(child_rels(*args))\n end",
"def children\n []\n end",
"def index\n children = []\n base_uri = 'https://postjson-d117c.firebaseio.com/'\n @firebase = Firebase::Client.new(base_uri)\n childrenjs = @firebase.get(\"Child\")\n parsed = JSON.parse(childrenjs.raw_body)\n kids = parsed.deep_symbolize_keys\n\n kids.uniq.each do |key, value|\n value.each do |key2, value2|\n children << value\n end\n end \n \n@children = children.flatten.uniq\n # render :json => @children\n\n end",
"def children\n _children\n end",
"def show\n @child = Child.find(params[:id])\n #used to determine layout used\n @child_crud = true\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @child }\n end\n end",
"def children\n @children ||= []\n end",
"def get_children\n return children\n end",
"def children\n []\n end",
"def get_paged_org_unit_children(org_unit_id, bookmark = '')\n path = \"/d2l/api/lp/#{$lp_ver}/orgstructure/#{org_unit_id}/children/paged/\"\n path += \"?bookmark=#{bookmark}\" if bookmark != ''\n _get(path)\n # return json of org_unit children\nend",
"def get_children()\n {}\n end",
"def index\n @dec_form_children = DecFormChild.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @dec_form_children }\n end\n end",
"def children\n return [] if child_count <= 0\n with_cache(:children) do\n @od.request(\"#{api_path}/children?$top=1000\")['value'].map do |child|\n OneDriveItem.smart_new(@od, child)\n end\n end\n end",
"def children\n EarLogger.instance.log \"Finding children for #{self}\"\n ObjectManager.instance.find_children(self.id, self.class.to_s)\n end",
"def repair_children\n @obj = Node.find(params[:id])\n @obj.repair_children\n respond_to do |format|\n format.html {redirect_to nodes_url}\n format.json {render json: @obj}\n end\n end",
"def current_children\n\t p @children\n\tend",
"def fetch_children\n @children = []\n for item in self.listex\n if item[\"type\"] == \"folder\" and item[\"id\"]!=@id #sharefile API includes self in list\n @children << Folder.new(item[\"id\"], @authid, @subdomain, false, item)\n elsif item[\"type\"] == \"file\"\n @children << File.new(item[\"id\"], @authid, @subdomain, item)\n end\n end\n end",
"def index(child); end",
"def show\n respond_to do |format|\n format.html # show.html.haml\n format.xml { render :xml => @children }\n end\n end",
"def index\n @traumatized_children = TraumatizedChild.all\n end",
"def show\n children = []\n base_uri = 'https://postjson-d117c.firebaseio.com/'\n @firebase = Firebase::Client.new(base_uri)\n childrenjs = @firebase.get(\"Child\")\n parsed = JSON.parse(childrenjs.raw_body)\n kids = parsed.deep_symbolize_keys\n\n kids.uniq.each do |key, value|\n value.each do |key2, value2|\n \n children << key\n end\n end\n parsed.each do |key, value|\n children << key\n value.each do |key3, value3|\n children << value3\n end\n end\n \n response = @firebase.get(\"Child/\").raw_body\n #@child = eval(response)\n \n render :json => response\n end",
"def children\n []\n end",
"def children\n []\n end",
"def children\n []\n end",
"def children\n @children ||= {}.with_indifferent_access\n end",
"def find_child!(children, child_id)\n child = find_child(children, child_id)\n error 404, convert(body_for(:not_found)) unless child\n child\n end",
"def children\n Feature.find(:all, :conditions => [ 'parent_id=?', self.id] )\n end",
"def new\n @children = Children.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @children }\n end\n end",
"def get_children(args = '', output = :OBJECT)\n kids = {}\n if args.blank?\n if $GLOBALS['post']\n args = { post_parent: $GLOBALS['post'].post_parent }\n else\n return kids\n end\n elsif args.is_a? Integer\n args = { post_parent: args}\n elsif args.is_a? String\n args = { post_parent: args.to_i}\n elsif args.is_a? Railspress::WpPost\n args = { post_parent: args.post_parent }\n end\n\n defaults = {\n numberposts: -1,\n post_type: 'any',\n post_status: 'any',\n post_parent: 0,\n }\n\n r = defaults.merge args\n\n children = get_posts(r)\n\n return kids if children.nil?\n\n return children unless r[:fields].blank?\n\n # update_post_cache(children)\n\n children.each do |child|\n kids[child.id] = child\n end\n\n if output == :OBJECT\n kids\n elsif output == :ARRAY_A\n weeuns = {}\n kids.values.each do |kid|\n weeuns[kid.id] = kid.attributes\n end\n return weeuns\n elsif output == :ARRAY_N\n babes = {}\n kids.values.each do |kid|\n babes[kid.id] = kid.attributes.values\n end\n return babes\n else\n kids\n end\n end",
"def children\n []\n end",
"def children\n []\n end",
"def children\n self.class.children(self) \n end",
"def index\n @pages = Page.paginate(page: params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: Page.roots.map{|r| r.node}}\n end\n end",
"def get_child(index)\n @children[index]\n end",
"def index\n authorize! :index, nil\n @parents = Parent.by_name\n end",
"def get_children_folders(folder_id)\n url = URI(\"#{$base_url}/api/projects/#{$project_id}/folders/#{folder_id}/children\")\n\n http = Net::HTTP.new(url.host, url.port)\n http.use_ssl = true\n request = Net::HTTP::Get.new(url)\n request[\"accept\"] = 'application/vnd.api+json; version=1'\n request[\"access-token\"] = $access_token\n request[\"uid\"] = $uid\n request[\"client\"] = $client\n response = http.request(request)\n\n folders_json = ''\n\n if response.code == 200.to_s\n folders_json = JSON.parse(response.read_body)['data']\n else\n puts \"Problem with getting folders. Status: #{response.code}\"\n puts response.body\n end\n folders_json\nend",
"def show\n @parent = Parent.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @parent }\n end\n end",
"def show\n @parent = Parent.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @parent }\n end\n end",
"def children\n entries\n end",
"def get_child!(children)\n children[1] || children\n end",
"def tree_children\n\n tree[2]\n end",
"def get_children(name, options)\n children = hash[name]\n children = children.is_a?(Hash) ? children : {}\n\n create_hash_children(children, options)\n end",
"def get_child(index)\n \t@children[index]\n end",
"def child\n @folder = Folder.new\n @folder.parent = Folder.find(params[:id])\n @folder.user = @current_user\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @folder }\n end\n end",
"def show\n @animal = Animal.find(params[:id])\n \n @zoo = Zoo.find(params[:zoo_id])\n @father = @animal.father\n @mother = @animal.mother\n @children = @animal.children\n @siblings = @animal.siblings\n \n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @animal }\n end\n end",
"def children(*args)\n self.class.send(:with_scope, :find=>{:conditions=>['parent_node_id=?', self.child_node_id]}) do\n self.class.find(:all, *args)\n end\n end",
"def children\n ie = index_entry\n ie.children.collect{ |child| child.resource } if ie\n end",
"def show\n @category = Category.by_alias params[:alias]\n raise ActionController::RoutingError, 'Not found' if @category.nil?\n\n @children = @category.children\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @category }\n end\n end",
"def children\n properties \n end",
"def children\n # return students\n return offerings\n end",
"def index\n @stories = Story.all#.each{|story| story.parentId = \"1\"}\n stories_with_parent_id = @stories.map {|story| story.add_parent_id_info}\n puts stories_with_parent_id\n render json: stories_with_parent_id\n end",
"def children(path)\n # r = nil\n # zk_call do\n # r = @zk.get_children(path: path)\n # end\n # debug \"ZK: Children '#{path}' => '#{r}'\"\n # raise NonExistingPathException.new(path) unless r[:stat].exists?\n # r[:children]\n end",
"def index\n @ministry_children = MinistryChild.all\n end",
"def children\n Array.new\n end",
"def children\n @ref.children.to_ruby\n end",
"def children()\r\n raise \"get_children is not implemented for class #{self.class}\"\r\n end",
"def index\n # @cloud_resources = CloudResource.all\n root = CloudResource.find_root\n root = params[:id] || root.id\n @cloud_resource = CloudResource.find root.to_i\n @cloud_resources = @cloud_resource.children(params[:page] || 1).order(\"name DESC\")\n end",
"def show\n #Find the employee with id supplied from the front-end and return direct subtree of that node including the parent node\n begin @employees = Employee.find(params[:id]).subtree.arrange_serializable(:order => :id)\n render json: @employees\n rescue => err \n render json: {error: err}\n end\n end",
"def create\n @children = Children.new(params[:children])\n\n respond_to do |format|\n if @children.save\n flash[:notice] = 'Children was successfully created.'\n format.html { redirect_to(@children) }\n format.xml { render :xml => @children, :status => :created, :location => @children }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @children.errors, :status => :unprocessable_entity }\n end\n end\n end"
] |
[
"0.7499588",
"0.7324712",
"0.72646785",
"0.71289086",
"0.70389336",
"0.7035334",
"0.69792575",
"0.6978602",
"0.6978602",
"0.6977394",
"0.6936022",
"0.6908084",
"0.68532836",
"0.6773779",
"0.6773779",
"0.6773779",
"0.6773779",
"0.6759537",
"0.66919076",
"0.66919076",
"0.6675221",
"0.66204584",
"0.6561765",
"0.65326124",
"0.65014976",
"0.6498514",
"0.64820653",
"0.64660233",
"0.64660233",
"0.64660233",
"0.64660233",
"0.64660233",
"0.64660233",
"0.64660233",
"0.64660233",
"0.64660233",
"0.64660233",
"0.64660233",
"0.64660233",
"0.6457498",
"0.64434445",
"0.64413947",
"0.64401454",
"0.642735",
"0.6419071",
"0.64089596",
"0.63958883",
"0.63737947",
"0.63490814",
"0.6338526",
"0.6303782",
"0.6292829",
"0.62910485",
"0.62758267",
"0.6272027",
"0.6250028",
"0.62233096",
"0.6219041",
"0.6213546",
"0.62109345",
"0.6203497",
"0.61905587",
"0.6175378",
"0.61751354",
"0.61751354",
"0.61751354",
"0.61745447",
"0.61664397",
"0.6156154",
"0.61514115",
"0.6135286",
"0.61290455",
"0.61290455",
"0.612592",
"0.6111869",
"0.61114144",
"0.61113137",
"0.6109511",
"0.6100155",
"0.6100155",
"0.6071668",
"0.60700035",
"0.6064136",
"0.6053379",
"0.60519755",
"0.60513294",
"0.60422444",
"0.6034892",
"0.60308266",
"0.60244244",
"0.6017053",
"0.6006388",
"0.5987268",
"0.5968957",
"0.59682417",
"0.596643",
"0.59562147",
"0.59456116",
"0.5938397",
"0.59356517",
"0.59344524"
] |
0.0
|
-1
|
POST /children POST /children.json
|
def create
@child = Child.new(child_params)
respond_to do |format|
if @child.save
format.html { redirect_to @child, notice: 'Child was successfully created.' }
format.json { render action: 'show', status: :created, location: @child }
else
format.html { render action: 'new' }
format.json { render json: @child.errors, status: :unprocessable_entity }
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def create_post!(params)\n @children.create! params\n end",
"def create\n @children = Children.new(params[:children])\n\n respond_to do |format|\n if @children.save\n flash[:notice] = 'Children was successfully created.'\n format.html { redirect_to(@children) }\n format.xml { render :xml => @children, :status => :created, :location => @children }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @children.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def children\n @pages = @page.children\n \n respond_to do |format|\n format.json { render :json => @pages }\n format.xml { render :xml => @pages }\n end\n end",
"def repair_children\n @obj = Node.find(params[:id])\n @obj.repair_children\n respond_to do |format|\n format.html {redirect_to nodes_url}\n format.json {render json: @obj}\n end\n end",
"def children\n render json: { status: 'ok', content: [] }\n end",
"def create\n @child = Child.new(child_params)\n\n respond_to do |format|\n if @child.save\n format.html { redirect_to children_path, notice: \"Child was successfully created.\" }\n format.json { render :show, status: :created, location: @child }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @child.errors, status: :unprocessable_entity }\n end\n end\n end",
"def children\n @id = fix_id(params[:id], params[:format], params[:extra])\n if params[:root]==\"source\" then\n @isRoot = true;\n @work = DcmWork.new(@id)\n @children = [@work.pi]\n else\n @isRoot = false;\n @children = get_children(\"nla.\"+params[:root])\n end\n render :action => \"children.json\"\n end",
"def children_for page, title\n page.children.create({\n :title => title,\n :deletable => true,\n :status => 'live',\n :show_in_menu => true,\n :parent_id => page.id\n })\nend",
"def add_children\n parent = Event.find(params[:parent_id])\n parent.missing_children.each do |child|\n child.parent = parent\n child.save!\n end\n redirect_to(edit_admin_event_path(parent))\n end",
"def create\n @provider = Provider.find(params[:provider_id])\n @child = @provider.children.create(child_params)\n # @child = Child.new(child_params)\n\n respond_to do |format|\n if @child.save\n format.html { redirect_to :back, notice: 'Child was successfully created.' }\n format.json { render :show, status: :created, location: @child }\n else\n format.html { render :new }\n format.json { render json: @child.errors, status: :unprocessable_entity }\n end\n end\n end",
"def add_children children\n children.each { |child| add_child child }\n end",
"def children\n\t@child = Child.find(params[:id])\n\t@parents = @child.parents.all\n\trespond_to do |format|\n\t\tformat.js { }\n\tend\n end",
"def children\n parent_id = params['parent_id']\n\n children = Child.includes(:bursts).where(parent_id: parent_id).map{ |child|\n last_burst = child.bursts.last\n burst_rate = last_burst.present? ? calc_burst_rate(last_burst) : 0\n\n {\n id: child.id,\n name: child.name,\n burst_rate: burst_rate\n }\n }\n\n render json: children\n end",
"def create\n @child = Child.new(child_params)\n\n respond_to do |format|\n if @child.save\n format.html { redirect_to @child, notice: 'Child was successfully created.' }\n format.json { render :show, status: :created, location: @child }\n else\n format.html { render :new }\n format.json { render json: @child.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_children(&block)\n if respond_to?(:response)\n self.response &block\n else\n block.call if block_given?\n end\n end",
"def create\n @kid = Kid.create(kid_params)\n @parent = Parent.find(params[:parent_id])\n @parent.kids << @kid\n redirect_to parent_kids_path\n # render json: @kid, status: 201\n end",
"def index\n children = []\n base_uri = 'https://postjson-d117c.firebaseio.com/'\n @firebase = Firebase::Client.new(base_uri)\n childrenjs = @firebase.get(\"Child\")\n parsed = JSON.parse(childrenjs.raw_body)\n kids = parsed.deep_symbolize_keys\n\n kids.uniq.each do |key, value|\n value.each do |key2, value2|\n children << value\n end\n end \n \n@children = children.flatten.uniq\n # render :json => @children\n\n end",
"def add_children(child_ids)\n\t\tchild_ids.each do |child_id|\n\t\t\tself.passoc.create(:child_id => child_id)\n\t\tend\n\tend",
"def new\n @children = Children.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @children }\n end\n end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def add_children(kids)\n i = 0\n while i < kids.size\n t = kids.get(i)\n add_child(t)\n i += 1\n end\n end",
"def _children\n @children\n end",
"def _children\n @children\n end",
"def _children\n @children\n end",
"def _children\n @children\n end",
"def create\n @child = Child.new(params[:child])\n @child_crud = true\n\n respond_to do |format|\n if @child.save\n format.html { redirect_to children_url, notice: 'Child was successfully created.' }\n format.js { @current_child = @child}\n format.json { render json: @child, status: :created, location: @child }\n else\n format.html { render :layout => false, action: \"new\"}\n format.json { render json: @child.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @child = Child.new(child_params)\n\n respond_to do |format|\n if @child.save\n format.html { redirect_to @child, notice: \"Child was successfully created.\" }\n format.json { render :show, status: :created, location: @child }\n format.js {}\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @child.errors, status: :unprocessable_entity }\n format.js {}\n end\n end\n end",
"def update_children\n self.children.each do |child|\n child.update_children\n unless child.new_record?\n child.save\n child.move_to_child_of(self) if child.parent_id != self.id\n end\n end if self.changed?\n end",
"def children\n @children\n end",
"def children\n @children\n end",
"def get_children\n @children\n end",
"def get_children\n \t@children\n end",
"def children\n @resource.children\n end",
"def add_new_child(name)\n\tnew_child = Child.new(name)\n\tnew_hash = {}\n\tnew_child.instance_variables.each {|item| new_hash[item.to_s.delete('@')] = new_child.instance_variable_get(item)}\n\tChildren[\"children\"].push(new_hash)\n\tupdate_file('children.yaml', Children)\nend",
"def create\n @traumatized_child = TraumatizedChild.new(traumatized_child_params)\n\n respond_to do |format|\n if @traumatized_child.save\n format.html { redirect_to @traumatized_child, notice: \"Traumatized child was successfully created.\" }\n format.json { render :show, status: :created, location: @traumatized_child }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @traumatized_child.errors, status: :unprocessable_entity }\n end\n end\n end",
"def children\n attributes.fetch(:children)\n end",
"def create_from_children\n single_day_event = Event.find(params[:id])\n new_parent = MultiDayEvent.create_from_children(single_day_event.multi_day_event_children_with_no_parent)\n expire_cache\n redirect_to(action: :edit, id: new_parent.to_param)\n end",
"def children\n @children ||= []\n end",
"def _children\n @children\n end",
"def _children\n @children\n end",
"def addChildren(child)\n\t\tfm = Family.new\n\t\tfm.person_id = child.id\n\t\tfm.parent_id = id\n\t\tif fm.save\n\t\t\tputs 'children was added successfully!'\n\t\telse \n\t\t\tputs 'children was added unsuccessfully!'\n\t\tend\n\tend",
"def index\n @dec_form_children = DecFormChild.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @dec_form_children }\n end\n end",
"def new\n @child = Child.new\n @child_crud = true\n\n respond_to do |format|\n format.html # new.html.erb\n format.html {render}\n format.json { render json: @child }\n end\n end",
"def add_child name\n @children << name\n end",
"def children\n @children ||= {}.with_indifferent_access\n end",
"def json_post\n @content_type = 'text/plain'\n @render_nothing = true\n @rendered_template = true\n @current_layout = nil\n puts \"json_post: submitting #{params[:path]}\" if @@debug\n path = params[:path]\n if path\n puts \"json_post: path is #{path} l=#{path.length}\" if @@debug\n path = path.split('/').compact()\n path.delete('')\n # you cannot make rooted nodes via json atm... fix? xxx\n if path.length > 1\n name = path.pop\n nodes = Note.make_path @user,path\n puts \"json_post: making at path #{path.join('/')}\" if @@debug\n if nodes\n note = nodes.last.make_child @user,params,name\n puts \"json_post: made child #{note} from #{name} l=#{name.length}\"\n params[:path] = path.join('/') # for call to json_query\n # it is important to do a query rather than returning the note; to get freshest order\n json_query\n return\n #write_json note if note\n end\n end\n end\n render :nothing => true\n end",
"def update\n @children = Children.find(params[:id])\n\n respond_to do |format|\n if @children.update_attributes(params[:children])\n flash[:notice] = 'Children was successfully updated.'\n format.html { redirect_to(@children) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @children.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def children\n []\n end",
"def add_children(more_children)\n @children.push(*more_children)\n end",
"def create\n @child = Child.new(child_params)\n base_uri = 'https://postjson-d117c.firebaseio.com/'\n @firebase = Firebase::Client.new(base_uri)\n kid = []\n child_params.each do |k,v|\n kid << k\n kid<< v\n \n end\n \n # render :json => kid\n\n response = @firebase.push(\"Child\", :name => kid[1.to_i].to_s, :age => kid[3.to_i].to_s)\n \n respond_to do |format|\n if response.success?\n format.html { redirect_to @child, notice: 'Child was successfully created.' }\n format.json { render :show, status: :created, location: @child }\n else\n format.html { render :new }\n format.json { render json: @child.errors, status: :unprocessable_entity }\n end \n end\n \n \n end",
"def show\n if(params.has_key?(:children))\n if(params[:children] == \"true\")\n @node = Node.find(params[:id]).children\n end\n else\n @node = Node.find(params[:id])\n end\n render json: @node\n end",
"def child\n @folder = Folder.new\n @folder.parent = Folder.find(params[:id])\n @folder.user = @current_user\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @folder }\n end\n end",
"def add_child\n category_id = params[:id].gsub('category_', '')\n @category = Category.find(category_id)\n parent_id = params[:parent_id]\n if parent_id\n @parent = Category.find(parent_id)\n @category.parent = @parent \n else\n @category.parent = nil\n end\n @category.save!\n render :update do |page|\n page.remove(\"category_#{@category.id}_row\")\n if @parent\n if @parent.name == ASSOCIATION.short_name\n page.replace_html(\"category_root\", :partial => \"category\", :collection => @parent.children.sort)\n else\n page.call(:expandDisclosure, parent_id)\n end\n end\n if @parent.nil?\n page.replace_html(\"unknown_category_root\", :partial => \"category\", :collection => Category.find_all_unknowns.sort)\n end\n end\n end",
"def create_child_items\n category.path.each do |category|\n create_child_item_for_category category\n end\n end",
"def children(max_distance=@default_distance)\n @children[0] = [@entity] if @children[0].empty?\n add_relatives(@children,1,max_distance,:children)\n @children\n end",
"def children; []; end",
"def visit_children(parent)\n parent.children.each do |child|\n child.node_parent = parent\n visit(child)\n end\n end",
"def visit_children(parent)\n parent.children.each do |child|\n child.node_parent = parent\n visit(child)\n end\n end",
"def children_get()\n @children\n end",
"def create\n @user = current_user.children.create(params[:user].merge :email => \"design+parent_id#{current_user.id}_child_count#{current_user.children.count + 1}@newint.com.au\")\n\n respond_to do |format|\n if @user.save\n format.html { redirect_to user_path(current_user), notice: 'User was successfully created.' }\n format.json { render json: [:institution, @user], status: :created, location: @user }\n else\n format.html { render action: \"new\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def destroy\n @children = Children.find(params[:id])\n @children.destroy\n\n respond_to do |format|\n format.html { redirect_to(childrens_url) }\n format.xml { head :ok }\n end\n end",
"def child_params\n params.require(:child).permit(:id, :age, :name)\n end",
"def children\n []\n end",
"def create_instance_children(instance)\n # Add children to component\n if children\n children.each do |child|\n instance.add_child(child.create())\n end\n end\n end",
"def sync_child_pages\n children.each{ |p| p.save! } if full_path_changed?\n end",
"def create\n if params[:tag][:parent]==nil then params[:tag][:parent]=0 end\n if params[:tag][:parent].to_i>0\n parent=Tag.find(params[:tag][:parent])\n parent.children+=1\n parent.save\n end\n @tag = Tag.create(params[:tag])\n @tag.type_id=params[:tag][:type_id]\n @tag.save\n respond_to do |format|\n if @tag.valid?\n format.html { redirect_to(:action=>'new') }\n else\n format.html { redirect_to(:action=>'new') }\n format.xml { render :xml => @tag.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n child = Assembly.find(params[:child_id])\n @relationship = @assembly.relationships.build(child: child)\n child = @relationship.child\n child.used = true\n child.save\n\n respond_to do |format|\n if @relationship.save\n format.html { redirect_to [@plan, @assembly], notice: 'Relationship was successfully created.' }\n format.json { render json: @relationship, status: :created, location: @relationship }\n else\n format.html { render action: \"new\" }\n format.json { render json: @relationship.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_relationship_within\n authorize! :read, form_params[:child_id]\n\n if form.save\n notice = I18n.t('create_within', scope: 'hyrax.dashboard.nest_collections_form', child_title: form.child.title.first, parent_title: form.parent.title.first)\n redirect_to redirect_path(item: form.child), notice: notice\n else\n redirect_to redirect_path(item: form.child), flash: { error: form.errors.full_messages }\n end\n end",
"def new_child\n @parent = Comment.find(params[:id])\n @comment = @parent.children.new(user_id: current_user.id, task_id: @task.id)\n\n end",
"def add_child(child)\n \t\t@children << child\n \tend",
"def add_child\n @portfolio = @site.portfolios.build\n @parent_id = params[:id]\n render :action => 'new'\n end",
"def create\n parent = Location.find(params[:location][:parent_id])\n @location = parent.children_class.new(params[:location])\n\n respond_to do |format|\n if @location.save\n flash[:notice] = 'Admin::Location was successfully created.'\n format.html { redirect_to(admin_location_path(@location)) }\n format.xml { render :xml => @location, :status => :created, :location => [:admin,@location] }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @location.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create_child(name, file_contents)\n # Parse the contents to ensure they are valid JSON\n begin\n object = Chef::JSONCompat.parse(file_contents)\n rescue Chef::Exceptions::JSON::ParseError => e\n raise Chef::ChefFS::FileSystem::OperationFailedError.new(:create_child, self, e, \"Parse error reading JSON creating child '#{name}': #{e}\")\n end\n\n # Create the child entry that will be returned\n result = make_child_entry(name, true)\n\n # Normalize the file_contents before post (add defaults, etc.)\n if data_handler\n object = data_handler.normalize_for_post(object, result)\n data_handler.verify_integrity(object, result) do |error|\n raise Chef::ChefFS::FileSystem::OperationFailedError.new(:create_child, self, nil, \"Error creating '#{name}': #{error}\")\n end\n end\n\n # POST /api_path with the normalized file_contents\n begin\n rest.post(api_path, object)\n rescue Timeout::Error => e\n raise Chef::ChefFS::FileSystem::OperationFailedError.new(:create_child, self, e, \"Timeout creating '#{name}': #{e}\")\n rescue Net::HTTPClientException => e\n # 404 = NotFoundError\n if e.response.code == \"404\"\n raise Chef::ChefFS::FileSystem::NotFoundError.new(self, e)\n # 409 = AlreadyExistsError\n elsif $!.response.code == \"409\"\n raise Chef::ChefFS::FileSystem::AlreadyExistsError.new(:create_child, self, e, \"Failure creating '#{name}': #{path}/#{name} already exists\")\n # Anything else is unexpected (OperationFailedError)\n else\n raise Chef::ChefFS::FileSystem::OperationFailedError.new(:create_child, self, e, \"Failure creating '#{name}': #{e.message}\")\n end\n end\n\n # Clear the cache of children so that if someone asks for children\n # again, we will get it again\n @children = nil\n\n result\n end",
"def children\n []\n end",
"def children\n []\n end",
"def children\n []\n end",
"def index\n @traumatized_children = TraumatizedChild.all\n end",
"def destroy\n @child.destroy\n respond_to do |format|\n format.html { redirect_to children_url }\n format.json { head :no_content }\n end\n end",
"def create\n parent_id = params[:parent_id]\n if parent_id\n @category = Category.new(category_params.except(:edge))\n @edge = Edge.new(:weight => category_params[:edge][:weight])\n @parent_category = Category.find(parent_id)\n if @parent_category.children.create category_params.except(:edge)\n @category.id = @parent_category.children.where(:name => category_params[:name].upcase).first.id\n @edge.update_attributes(:start_node_id => parent_id.to_i, :end_node_id => @category.id)\n render :json => {:message => 'Category was successfully created.', :parent_id => parent_id, :id => @category.id, :name => @category.name}, :status => 200, :layout => false\n else\n render :json => {:message => 'Category failed to create.'}, :status => 400, :layout => false\n end\n end\n end",
"def descendant_params\n params.require(:descendant).permit(:name, :child_id)\n end",
"def create\n \t\tif current_user.donor?\n\t\t\t@parent_child = current_user.parent_parent_children.new(parent_child_params)\n\t\telse\n\t\t\t@parent_child=current_user.build_child_parent_child(parent_child_params)\n\t\tend\n\n\t\trespond_to do |format|\n\t \t\tif @parent_child.save\n\t \t\t\tuser=User.find(@parent_child[:child_id])\n\t \t\t\tif current_user.student?\n\t \t\t\t\tuser.add_role :parent\n\t \t\t\t\tcurrent_user.add_role :child\n\t \t\t\t\tuser.add_role :parent,@parent_child\n\t \t\t\t\tcurrent_user.add_role :child,@parent_child\n\t \t\t\telse\n\t \t\t\t\tuser.add_role :child\n\t \t\t\t\tcurrent_user.add_role :parent\n\t \t\t\t\tuser.add_role :child,@parent_child\n\t \t\t\t\tcurrent_user.add_role :parent,@parent_child\n\t \t\t\tend\n\t\t\t\tformat.html { redirect_to @parent_child, notice: 'Parent child was successfully created.' }\n\t\t\t\tformat.json { render :show, status: :created, location: @parent_child }\n\t \t\telse\n\t\t\t\tformat.html { render :new }\n\t\t\t\tformat.json { render json: @parent_child.errors, status: :unprocessable_entity }\n\t \t\tend\n\t\tend\n \tend",
"def children=(_arg0); end",
"def children=(_arg0); end",
"def set_children\n all_mentees = self.mentees\n new_mentees = all_mentees\n\n while new_mentees.length > 0\n to_add = []\n new_mentees.each do |new_mentee|\n to_add << new_mentee.mentees.to_a\n end\n new_mentees = to_add.flatten!\n all_mentees << to_add\n end\n\n all_mentees.each do |mentee|\n mentee.lineage_id = self.lineage_id\n mentee.save\n end\n end",
"def child_params\n params.require(:child).permit(:name, :surname, :birthday, :lang, :hand, :school, :school_type, :school_lvl, :imagepath, :note, :archived, :version, :id_child, :id)\n end",
"def apply_children\n \n end",
"def children\n params[:scope] ||= \"private\"\n\n children = if params[:scope] == Scopes::SCOPE_PRIVATE\n @folder&.children ||\n current_user.nodes.where(parent_folder_id: nil)\n elsif params[:scope] == Scopes::SCOPE_PUBLIC\n @folder&.children ||\n Node.where(scope: params[:scope], parent_folder_id: nil)\n end\n\n if [Scopes::SCOPE_PRIVATE, Scopes::SCOPE_PUBLIC].include?(params[:scope])\n children = children.where.not(sti_type: \"Asset\")\n end\n\n children = children.where(scope: params[:scope]).order(:sti_type, :name)\n\n render json: children, root: \"nodes\", adapter: :json\n end",
"def download_children(children, path)\n children.each do |child|\n new_path = \"#{path}/#{child.title}\"\n backup_folder_rec child.id, new_path if child.mimeType == FOLDER\n download_if_allowed_child child, new_path\n end\n end",
"def create\n @child = Child.new_with_user_name(current_user_name, params[:child])\n respond_to do |format|\n if @child.save\n flash[:notice] = 'Child record successfully created.'\n format.html { redirect_to(@child) }\n format.xml { render :xml => @child, :status => :created, :location => @child }\n else\n format.html {\n @form_sections = get_form_sections_for_child @child\n render :action => \"new\"\n }\n format.xml { render :xml => @child.errors, :status => :unprocessable_entity }\n end\n end\n end"
] |
[
"0.74252766",
"0.7309307",
"0.68554646",
"0.666492",
"0.66533995",
"0.65639085",
"0.6544793",
"0.6512353",
"0.6507447",
"0.64626294",
"0.6390514",
"0.63477474",
"0.622188",
"0.61944646",
"0.6185938",
"0.61740005",
"0.6149718",
"0.6137717",
"0.61081606",
"0.6088241",
"0.6088241",
"0.6088241",
"0.6088241",
"0.6088241",
"0.6088241",
"0.6088241",
"0.6088241",
"0.6088241",
"0.6088241",
"0.6088241",
"0.6088241",
"0.6081714",
"0.60767406",
"0.60767406",
"0.60767406",
"0.60767406",
"0.6041261",
"0.60148233",
"0.59902954",
"0.5983302",
"0.5983302",
"0.5972425",
"0.59720147",
"0.59709764",
"0.59607625",
"0.5960334",
"0.59544796",
"0.59404445",
"0.593836",
"0.59370816",
"0.5915098",
"0.59131986",
"0.5893744",
"0.58647496",
"0.5813852",
"0.57917535",
"0.57916105",
"0.5790766",
"0.5789024",
"0.5773853",
"0.5762615",
"0.5761029",
"0.57582057",
"0.57297456",
"0.57195675",
"0.5715005",
"0.5700785",
"0.569156",
"0.569156",
"0.5664604",
"0.5647138",
"0.56410724",
"0.5631254",
"0.5628482",
"0.5620105",
"0.5611252",
"0.56075346",
"0.5596894",
"0.55945885",
"0.5594118",
"0.55848354",
"0.5584253",
"0.558371",
"0.5579813",
"0.55789685",
"0.55789685",
"0.55789685",
"0.55742675",
"0.5573236",
"0.55679923",
"0.55631745",
"0.5562513",
"0.5561822",
"0.5561822",
"0.5561504",
"0.55603",
"0.5551047",
"0.5549734",
"0.5544168",
"0.5542761"
] |
0.6166014
|
16
|
PATCH/PUT /children/1 PATCH/PUT /children/1.json
|
def update
respond_to do |format|
if @child.update(child_params)
format.html { redirect_to @child, notice: 'Child was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: 'edit' }
format.json { render json: @child.errors, status: :unprocessable_entity }
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def update\n @children = Children.find(params[:id])\n\n respond_to do |format|\n if @children.update_attributes(params[:children])\n flash[:notice] = 'Children was successfully updated.'\n format.html { redirect_to(@children) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @children.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @child.update(child_params)\n format.html { redirect_to children_path, notice: \"Child was successfully updated.\" }\n format.json { render :show, status: :ok, location: @child }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @child.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @child.update(child_params)\n format.html { redirect_to @child, notice: 'Child was successfully updated.' }\n format.json { render :show, status: :ok, location: @child }\n else\n format.html { render :edit }\n format.json { render json: @child.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @child.update(child_params)\n format.html { redirect_to @child, notice: 'Child was successfully updated.' }\n format.json { render :show, status: :ok, location: @child }\n else\n format.html { render :edit }\n format.json { render json: @child.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @child.update(child_params)\n format.html { redirect_to @child, notice: \"Child was successfully updated.\" }\n format.json { render :show, status: :ok, location: @child }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @child.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @child = args[:child] if args.key?(:child)\n end",
"def update!(**args)\n @child = args[:child] if args.key?(:child)\n end",
"def update!(**args)\n @child = args[:child] if args.key?(:child)\n end",
"def update\n respond_to do |format|\n if @child.update(child_params)\n format.html { redirect_to :back, notice: 'Child was successfully updated.' }\n format.json { render :show, status: :ok, location: @child }\n else\n format.html { render :edit }\n format.json { render json: @child.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @child_resource = ChildResource.find(params[:id])\n # require modify permissions for this object\n require_privilege(Alberich::Privilege::MODIFY, @child_resource)\n\n respond_to do |format|\n if @child_resource.update_attributes(params[:child_resource])\n format.html { redirect_to @child_resource, notice: 'Child resource was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @child_resource.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_children\n self.children.each do |child|\n child.update_children\n unless child.new_record?\n child.save\n child.move_to_child_of(self) if child.parent_id != self.id\n end\n end if self.changed?\n end",
"def repair_children\n @obj = Node.find(params[:id])\n @obj.repair_children\n respond_to do |format|\n format.html {redirect_to nodes_url}\n format.json {render json: @obj}\n end\n end",
"def update\n @parent = Parent.find(params[:id])\n\n respond_to do |format|\n if @parent.update_attributes(params[:parent])\n format.html { redirect_to parents_url, notice: 'Parent was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @parent.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @child = Child.find(params[:id])\n\n respond_to do |format|\n if @child.update_attributes(params[:child])\n format.html { redirect_to children_url, notice: 'Child was successfully updated.' }\n format.js { @current_child = @child}\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @child.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_children\n return if children_attribs.nil?\n\n reload # Ancestry doesn't seem to work properly without this.\n\n # Symbolize keys if regular Hash. (not needed for HashWithIndifferentAccess)\n children_attribs.each{ |a| a.symbolize_keys! if a.respond_to?(:symbolize_keys!) }\n\n self.ranks_changed = false # Assume false to begin.\n self.options_added = false\n self.options_removed = false\n\n # Index all children by ID for better performance\n children_by_id = children.index_by(&:id)\n\n # Loop over all children attributes.\n # We use the ! variant of update and create below so that validation\n # errors on children and options will cascade up.\n (children_attribs || []).each_with_index do |attribs, i|\n\n # If there is a matching (by id) existing child.\n attribs[:id] = attribs[:id].to_i if attribs.key?(:id)\n if attribs[:id] && matching = children_by_id[attribs[:id]]\n self.ranks_changed = true if matching.rank != i + 1\n matching.update_attributes!(attribs.merge(rank: i + 1))\n copy_flags_from_subnode(matching)\n\n # Remove from hash so that we'll know later which ones weren't updated.\n children_by_id.delete(attribs[:id])\n else\n attribs = copy_denormalized_attribs_to_attrib_hash(attribs)\n self.options_added = true\n\n # We need to strip ID in case it's present due to a node changing parents.\n children.create!(attribs.except(:id).merge(rank: i + 1))\n end\n end\n\n # Destroy existing children that were not mentioned in the update.\n self.options_removed = true unless children_by_id.empty?\n children_by_id.values.each{ |c| c.destroy_with_copies }\n\n # Don't need this anymore. Nullify to prevent duplication on future saves.\n self.children_attribs = nil\n end",
"def update\n if @thema.try(:new_parent_id)\n @thema.parent = Thema.find(@thema.new_parent_id)\n end\n\n respond_to do |format|\n if @thema.update(thema_params)\n format.html { redirect_to @thema, notice: 'Thema was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @thema.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\t\t @tree = current_user.trees.find(params[:tree_id])\n\n\t if @tree.nil?\n\t \trender json: { errors: [\"No such tree found\"], success: false }, status: :bad_request\n\t end\n\n\t @person = @tree.people.find(params[:id])\n\n \tif @person.nil?\n \t\trender json: { errors: [\"No such person found\"], success: false }, status: :bad_request\n \tend\n\n \tparams.delete :_id\n\n\t relations = {}\n\t\t \tmodified_people = []\n\n\t\t \tif params[:person][:spouses]\n\t\t \t\trelations[:spouses] = params[:person][:spouses]\n\t\t \t\tparams[:person].delete :spouses\n\t\t \tend\n\n\t\t \tif params[:person][:children]\n\t\t \t\trelations[:children] = params[:person][:children]\n\t\t \t\tparams[:person].delete :children\n\t\t \tend\n\n\t\t \tif params[:person][:parents]\n\t\t \t\trelations[:parents] = params[:person][:parents]\n\t\t \t\tparams[:person].delete :parents\n\t\t \tend\n\n \tif @person.update_attributes(params[:person])\n \t\tmodified_people << @person\n\n \t\trelations.each do |k,v|\n\t\t \t\tv.each do |p|\n\t\t \t\t\tputs \"RELATIONS\", relations\n\t\t \t\t\tputs \"HERE\", k, v, p\n\t\t \t\t\trelative = @tree.people.find(p)\n\t\t \t\t\tputs \"THERE\", relative[k], relative.to_json\n\t\t \t\t\trelative.send(k) << @person\n\t\t \t\t\trelative.save\n\t\t \t\t\tmodified_people << relative\n\t\t \t\tend\n\t\t \tend\n\n \trender json: { person: @person, people: modified_people }, status: :accepted\n \telse\n \trender json: { errors: @person.errors, success: false }, status: :unprocessable_entity\n \tend\n\t\t end",
"def update\n\t\trespond_to do |format|\n\t \t\tif @parent_child.update(parent_child_params)\n\t\t\t\tformat.html { redirect_to @parent_child, notice: 'Parent child was successfully updated.' }\n\t\t\t\tformat.json { render :show, status: :ok, location: @parent_child }\n\t \t\telse\n\t\t\t\tformat.html { render :edit }\n\t\t\t\tformat.json { render json: @parent_child.errors, status: :unprocessable_entity }\n\t \t\tend\n\t\tend\n \tend",
"def update_memberships\n update_children\n update_parents\n end",
"def update\n respond_to do |format|\n if @parent.update(parent_params)\n format.html { redirect_to @parent, notice: 'Parent was successfully updated.' }\n format.json { render :show, status: :ok, location: @parent }\n else\n format.html { render :edit }\n format.json { render json: @parent.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @parent.update(parent_params)\n format.html { redirect_to @parent, notice: 'Parent was successfully updated.' }\n format.json { render :show, status: :ok, location: @parent }\n else\n format.html { render :edit }\n format.json { render json: @parent.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @parent.update(parent_params)\n format.html { redirect_to @parent, notice: 'Parent was successfully updated.' }\n format.json { render :show, status: :ok, location: @parent }\n else\n format.html { render :edit }\n format.json { render json: @parent.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @parent.update(parent_params)\n format.html { redirect_to @parent, notice: 'Parent was successfully updated.' }\n format.json { render :show, status: :ok, location: @parent }\n else\n format.html { render :edit }\n format.json { render json: @parent.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @parent.update(parent_params)\n format.html { redirect_to @parent, notice: 'Parent was successfully updated.' }\n format.json { render :show, status: :ok, location: @parent }\n else\n format.html { render :edit }\n format.json { render json: @parent.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @child_link = args[:child_link] if args.key?(:child_link)\n @created = args[:created] if args.key?(:created)\n @id = args[:id] if args.key?(:id)\n @kind = args[:kind] if args.key?(:kind)\n @name = args[:name] if args.key?(:name)\n @permissions = args[:permissions] if args.key?(:permissions)\n @self_link = args[:self_link] if args.key?(:self_link)\n @starred = args[:starred] if args.key?(:starred)\n @updated = args[:updated] if args.key?(:updated)\n end",
"def update!(**args)\n @child_type = args[:child_type] if args.key?(:child_type)\n end",
"def update\n respond_to do |format|\n if @traumatized_child.update(traumatized_child_params)\n format.html { redirect_to @traumatized_child, notice: \"Traumatized child was successfully updated.\" }\n format.json { render :show, status: :ok, location: @traumatized_child }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @traumatized_child.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @leaf.update(leaf_params)\n format.html { redirect_to leaf_path(@leaf), notice: EDIT_SUCCESS }\n format.json { render :show, status: :ok, location: @leaf }\n else\n format.html { render :edit }\n format.json { render json: @leaf.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\t\t@parent = Parent.find(params[:id])\n respond_to do |format|\n if @parent.update(parent_params)\n format.html { redirect_to @parent, notice: 'Parent was successfully updated.' }\n format.json { render :show, status: :ok, location: @parent }\n else\n format.html { render :edit }\n format.json { render json: @parent.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_bobchildren(bobchildren_ids)\n bobchildren_ids.reject! {|x| x.empty? }\n \n remove_bobchild_relationships(bobchildren_ids)\n # add the newly checked children\n add_bobchild_reationships(bobchildren_ids)\n end",
"def update\n respond_to do |format|\n if @parent_of.update(parent_of_params)\n format.html { redirect_to @parent_of, notice: 'Parent of was successfully updated.' }\n format.json { render :show, status: :ok, location: @parent_of }\n else\n format.html { render :edit }\n format.json { render json: @parent_of.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tree.update(tree_params)\n format.html { redirect_to @tree, notice: 'Tree was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @tree.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tree.update(tree_params)\n format.html { redirect_to @tree, notice: 'Tree was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @tree.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @tree = Tree.find(params[:id])\n\n respond_to do |format|\n if @tree.update_attributes(params[:tree])\n format.html { redirect_to @tree, notice: 'Tree was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render \"edit\" }\n format.json { render json: @tree.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n \n @tag = Tag.find(params[:id])\n\n respond_to do |format|\n if @tag.update_attributes(params[:tag])\n if params[:tag][:parent].to_i>0\n parent=Tag.find(params[:tag][:parent])\n parent.children+=1\n parent.save\n end\n format.html { redirect_to(:action=>'index') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @tag.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update_children_moderation_flag\n if self.changed.include?('moderation_flag') and self.content.has_children?\n self.content.children.each do |child|\n similiar_submissions = Submission.where(:content_id => child.id, :feed_id => self.feed_id, :moderation_flag => self.moderation_flag_was)\n similiar_submissions.each do |child_submission|\n child_submission.update_attributes({:moderation_flag => self.moderation_flag, :moderator_id => self.moderator_id})\n end\n end\n end\n end",
"def update \n pastry = Pastry.find(params[:id])\n pastry.update(pastry_params)\n render json: pastry\n end",
"def update!(**args)\n @children_locations = args[:children_locations] if args.key?(:children_locations)\n @parent_chain = args[:parent_chain] if args.key?(:parent_chain)\n @parent_location = args[:parent_location] if args.key?(:parent_location)\n end",
"def update\n respond_to do |format|\n if @leaf.update(leaf_params)\n format.html { redirect_to @leaf, notice: 'Leaf was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @leaf.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_children_with_new_parent\n if path_changed? and not new_record? then\n old_path = (path_was.blank? ? id.to_s : \"#{path_was}.#{id}\")\n self.class.where(\"path <@ ?\", old_path).update_all([ \"path = TEXT2LTREE(REPLACE(LTREE2TEXT(path), ?, ?))\", old_path, my_path ])\n end\n end",
"def update\n respond_to do |format|\n if @leaf.update(leaf_params)\n format.html { redirect_to @leaf, notice: t('common.message.updated_success')}\n format.json { render :show, status: :ok, location: @leaf }\n else\n format.html { render :edit }\n format.json { render json: @leaf.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @child_record.update(child_record_params)\n format.html { redirect_to @child_record, notice: 'Child record was successfully updated.' }\n format.json { render :show, status: :ok, location: @child_record }\n else\n format.html { render :edit }\n format.json { render json: @child_record.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_child_moderation\n if self.changed.include?('moderation_flag') and self.content.has_children?\n self.content.children.each do |child|\n similiar_submissions = Submission.where(content_id: child.id, feed_id: self.feed_id, moderation_flag: self.moderation_flag_was)\n similiar_submissions.each do |child_submission|\n child_submission.update_attributes({moderation_flag: self.moderation_flag, moderator_id: self.moderator_id})\n end\n end\n end\n end",
"def update!(**args)\n @parent = args[:parent] if args.key?(:parent)\n @permission = args[:permission] if args.key?(:permission)\n end",
"def update\n @childmaster = Childmaster.find(params[:id])\n\n respond_to do |format|\n if @childmaster.update_attributes(params[:childmaster])\n format.html { redirect_to @childmaster, notice: 'Childmaster was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @childmaster.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @parent_info.update(parent_info_params)\n format.html { redirect_to @parent_info, notice: 'Parent info was successfully updated.' }\n format.json { render :show, status: :ok, location: @parent_info }\n else\n format.html { render :edit }\n format.json { render json: @parent_info.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @child_asset_id = args[:child_asset_id] if args.key?(:child_asset_id)\n @id = args[:id] if args.key?(:id)\n @kind = args[:kind] if args.key?(:kind)\n @parent_asset_id = args[:parent_asset_id] if args.key?(:parent_asset_id)\n end",
"def update\n @athletes_parent = AthletesParent.find(params[:id])\n\n respond_to do |format|\n if @athletes_parent.update_attributes(params[:athletes_parent])\n format.html { redirect_to(@athletes_parent, :notice => 'Athletes parent was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @athletes_parent.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @child = Child.get(params[:id])\n new_photo = params[:child].delete(:photo)\n @child.update_properties_with_user_name current_user_name, new_photo, params[:child]\n \n respond_to do |format|\n if @child.save\n flash[:notice] = 'Child was successfully updated.'\n format.html { redirect_to(@child) }\n format.xml { head :ok }\n else\n format.html {\n @form_sections = get_form_sections_for_child @child\n render :action => \"edit\"\n }\n format.xml { render :xml => @child.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\r\n @post = Post.find(params[:id])\r\n @root_post = root_post_of(@post)\r\n\r\n respond_to do |format|\r\n if @post.update_attributes(params[:post])\r\n @root_post.touch(:updated_at)\r\n update_child_posts(@post)\r\n\r\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\r\n format.json { head :no_content }\r\n else\r\n format.html { render action: \"edit\" }\r\n format.json { render json: @post.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def update\n respond_to do |format|\n begin\n cp = child_params\n cp[:code] = cp[:code].strip\n updated = @child.update(cp)\n rescue ActiveRecord::RecordNotUnique => e\n @child.errors[:base] << e.message\n updated = false\n rescue => e\n @child.errors[:base] << e.message\n updated = false\n end\n if updated\n format.html { redirect_to @child, notice: tr(\"child_updated\")}\n else\n format.html { render :edit }\n end\n end\n end",
"def test_nested_collection_replace\n # Parent.children\n old_children = @parent.children\n\n data = [{ '_type' => 'Child', 'name' => 'newc1' },\n { '_type' => 'Child', 'name' => 'newc2' },]\n\n childcontroller = ChildController.new(params: {\n owner_viewmodel: 'parent',\n association_name: 'children',\n parent_id: @parent.id,\n data: data,\n })\n childcontroller.invoke(:replace)\n\n assert_equal(200, childcontroller.status, childcontroller.hash_response)\n\n @parent.reload\n\n assert_equal(%w[newc1 newc2], @parent.children.order(:position).pluck(:name))\n assert_predicate(Child.where(id: old_children.map(&:id)), :empty?)\n\n assert_all_hooks_nested_inside_parent_hook(childcontroller.hook_trace)\n end",
"def update\n @father = Father.find(params[:id])\n\n respond_to do |format|\n if @father.update_attributes(params[:father])\n format.html { redirect_to @father, notice: 'Father was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @father.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @ministry_child.update(ministry_child_params)\n format.html { redirect_to @ministry_child, notice: 'Ministry child was successfully updated.' }\n format.json { render :show, status: :ok, location: @ministry_child }\n else\n format.html { render :edit }\n format.json { render json: @ministry_child.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @parent = Parent.find(params[:parent][:id])\n\n \t# check that the issuer of the request has both the username and ID, prevent attack\n if params[:parent][:login].gsub(/ /,'') != @parent.login.gsub(/ /,'')\n \tlog_attack \"Error parent update \" + params[:parent][:id] + \" : \" + params[:parent][:login] + \" - @parent.login = \" + @parent.login \t\n respond_to do |format|\n format.xml { render :xml => errorRsp( \"Security error\" ) }\n end\n \treturn\n end\n \n respond_to do |format|\n if @parent.update_attributes(params[:parent])\n format.xml { head :ok }\n else\n log_DB_errors( \"parent\", @parent.errors ) \n format.xml { render :xml => errorRsp( \"Failed to update\" ) }\n end\n end\n end",
"def update_inherited_members\n if parent\n if inherit_members? && !inherit_members_before_last_save\n remove_inherited_member_roles\n remove_inherited_member_functions # PATCH\n add_inherited_member_roles\n add_inherited_member_functions # PATCH\n elsif !inherit_members? && inherit_members_before_last_save\n remove_inherited_member_roles\n remove_inherited_member_functions # PATCH\n end\n end\n end",
"def update\n @miscellaneous_child = MiscellaneousChild.find(params[:id])\n\n respond_to do |format|\n if @miscellaneous_child.update_attributes(params[:miscellaneous_child])\n format.html { redirect_to(@miscellaneous_child, :notice => 'MiscellaneousChild was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @miscellaneous_child.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n\n @parent_types = ParentType.all\n @parent_type = ParentType.find(params[:id])\n\n @parent_type.update_attributes(parent_type_params)\n\n=begin\n respond_to do |format|\n if @parent_type.update(parent_type_params)\n format.html { redirect_to @parent_type, notice: 'Parent type was successfully updated.' }\n format.json { render :show, status: :ok, location: @parent_type }\n else\n format.html { render :edit }\n format.json { render json: @parent_type.errors, status: :unprocessable_entity }\n end\n end\n=end\n end",
"def update\n respond_to do |format|\n if @tree.update(tree_params)\n format.html { redirect_to @tree, notice: 'Tree was successfully updated.' }\n format.json { render :show, status: :ok, location: @tree }\n else\n format.html { render :edit }\n format.json { render json: @tree.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n \trespond_to do |format|\n \t\tif @tree.update(tree_params)\n \t\t\tformat.html { redirect_to @tree, notice: 'Nome da arvore atualizado com sucesso.' }\n \t\t\tformat.json { render :show, status: :ok, location: @tree }\n \t\telse\n \t\t\tformat.html { render :edit }\n \t\t\tformat.json { render json: @tree.errors, status: :unprocessable_entity }\n \t\tend\n \tend\n end",
"def update\n respond_to do |format|\n if @child_actor.update(child_actor_params)\n format.html { redirect_to @child_actor, notice: \"Child actor was successfully updated.\" }\n format.json { render :show, status: :ok, location: @child_actor }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @child_actor.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @medium = Medium.find(params[:id])\n @medium.update_attributes(params[:medium])\n @parent = @medium.multimedia\n respond_to do |format|\n format.html { render edit_medium(@medium) }\n format.json { head :no_content }\n end\n end",
"def update\n respond_to do |format|\n if @parent.update(parent_params)\n @user = User.where(email: @parent.students.first.father_email)\n @user.update(student_id: @parent.id) if @user\n format.html { redirect_to @parent, notice: 'Parent was successfully updated.' }\n format.json { render :show, status: :ok, location: @parent }\n else\n format.html { render :edit }\n format.json { render json: @parent.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @foster_parent.update(foster_parent_params)\n format.html { redirect_to @foster_parent, notice: 'Foster parent was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @foster_parent.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @author_name = args[:author_name] if args.key?(:author_name)\n @children = args[:children] if args.key?(:children)\n @date = args[:date] if args.key?(:date)\n @docid = args[:docid] if args.key?(:docid)\n @parent = args[:parent] if args.key?(:parent)\n end",
"def update\n @shape_type = ShapeType.find(params[:id])\n\n\t\t# get the parent shape type\n\t\tparent = ShapeType.find(params[:parent_shape])\n\n respond_to do |format|\n\t\t\tif parent.nil?\n\t format.html { render action: \"edit\" }\n\t format.json { render json: @shape_type.errors, status: :unprocessable_entity }\n\t\t\telse\n\t\t\t\t# see if the parent shape changed\n\t\t\t\tanc_ary = @shape_type.ancestry.split(\"/\")\n\t\t\t\tif (anc_ary.length == 1 && parent.id.to_s == anc_ary[0]) || parent.id.to_s == anc_ary[anc_ary.length-1]\n\t\t\t\t\t# parent shape did not change, do nothing\n\t\t\t\telse\n\t\t\t\t\t# parent shape did change. update the ancestry value\n\t\t\t\t\tnew_anc = parent.ancestor_ids.join(\"/\")\n\t\t\t\t\tnew_anc += \"/\" + parent.id.to_s\n\t\t\t\t\tparams[:shape_type][:ancestry] = new_anc\n\t\t\t\tend\n\n\t\t if @shape_type.update_attributes(params[:shape_type])\n\t\t\t\t\tmsg = I18n.t('app.msgs.success_updated', :obj => I18n.t('app.common.shape_type'))\n\t\t\t\t\tsend_status_update(I18n.t('app.msgs.cache_cleared', :action => msg))\n\t\t format.html { redirect_to admin_shape_type_path(@shape_type), notice: msg }\n\t\t format.json { head :ok }\n\t\t else\n\t\t format.html { render action: \"edit\" }\n\t\t format.json { render json: @shape_type.errors, status: :unprocessable_entity }\n\t\t end\n\t end\n end\n end",
"def update_parents(person_id, attributes)\n\t\tif attributes.include?(:father_id) then\n\t \tnew_father_id = attributes[:father_id]\n\t \tif new_father_id and !@people.key?(new_father_id)\n\t \t\tputs \"warning: update person #{person_id} - ignored invalid father_id #{new_father_id}.\"\n\t \telse\n\t \t\t# delete the person from the previous father\n\t \t\told_father_id = @people[person_id].father_id\n\t \t\t@people[old_father_id].children_ids.delete(person_id) if old_father_id\n\t \t\t# add the person to the new father\n\t \t\t@people[new_father_id].children_ids << person_id if new_father_id\n\t \t\t# set the new father id to the child\n\t \t\t@people[person_id].father_id = new_father_id\n\t \tend\n\t end \n\t if attributes.include?(:mother_id) then\n\t \tnew_mother_id = attributes[:mother_id]\n\t \tif new_mother_id and !@people.key?(new_mother_id)\n\t \t\tputs \"warning: update person #{person_id} - ignored invalid mother_id #{new_mother_id}.\"\n\t \telse\n\t \t\t# delete the person from the previous mother\n\t\t\t old_mother_id = @people[person_id].mother_id\n\t \t\t@people[old_mother_id].children_ids.delete(person_id) if old_mother_id\n\t \t\t# add the person to the new mother\n\t \t\t@people[new_mother_id].children_ids << person_id if new_mother_id\n\t \t\t# set the new mother id to the person\n\t\t\t @people[person_id].mother_id = new_mother_id\n\t \tend\n\t end \n\t if attributes.include?(:children_ids) then\n\t \tnew_children_ids = attributes[:children_ids]\n\t \told_children_ids = @people[person_id].children_ids\n\t \tadd_list = new_children_ids - old_children_ids # children to add to this person\n\t \tremove_list = old_children_ids - new_children_ids # children to delete from this person\n\t \tcase @people[person_id].sex # determine if this person is a father or mother\n\t \twhen \"M\", \"F\"\n\t \t\t@people[person_id].sex == \"M\" ? parent_type = :father_id : parent_type = :mother_id\n\t \t\tadd_list.each { | child | update_parents( child, { parent_type => person_id } ) }\n\t \t\tremove_list.each { | child | update_parents( child, { parent_type => nil } ) }\n\t \telse\n\t \t\tputs \"warning: update person #{person_id} - ignored children due to invalid sex #{@people[person_id].sex}\"\n\t \tend\n\t end\n\tend",
"def update\n @ministry_child = MinistryChild.find(params[:id])\n\n respond_to do |format|\n if @ministry_child.update_attributes(params[:ministry_child])\n format.html { redirect_to ministry_path(@ministry_child.ministry.id), notice: 'Ministry child was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @ministry_child.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @childmaster = Childmaster.find(params[:id])\n\n respond_to do |format|\n if @childmaster.update_attributes(params[:childmaster])\n format.html { redirect_to(@childmaster, :notice => 'Childmaster was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @childmaster.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update_for_parent_insert( parent_array, requested_parent_index, parent_index, object )\n\n local_index = @cascade_controller.parent_insert( parent_array, parent_index, 1 )\n undecorated_insert( local_index, nil )\n @children.each { |this_array| this_array.update_for_parent_insert( self, local_index, local_index, object ) }\n\n return self\n \n end",
"def update\n respond_to do |format|\n if @descendant.update(descendant_params)\n format.html { redirect_to @descendant, notice: 'Descendant was successfully updated.' }\n format.json { render :show, status: :ok, location: @descendant }\n else\n format.html { render :edit }\n format.json { render json: @descendant.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @quest_tree = QuestTree.find(params[:id])\n\n respond_to do |format|\n if @quest_tree.update_attributes(params[:quest_tree])\n format.html { redirect_to @quest_tree, notice: 'Quest tree was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @quest_tree.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @monitor_child_relationship = MonitorChildRelationship.find(params[:id])\n\n respond_to do |format|\n if @monitor_child_relationship.update_attributes(params[:monitor_child_relationship])\n format.html { redirect_to @monitor_child_relationship, notice: 'Monitor child relationship was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @monitor_child_relationship.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @child_model = ChildModel.find(params[:id])\n\n respond_to do |format|\n if @child_model.update_attributes(params[:child_model])\n flash[:notice] = 'ChildModel was successfully updated.'\n format.html { redirect_to(@child_model) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @child_model.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update_for_parent_set( parent_array, parent_index, object )\n \n parent_local_map = @cascade_controller.parent_local_map( parent_array )\n \n if @cascade_controller.parent_controls_parent_index?( parent_array, parent_index, parent_local_map ) or\n parent_index >= parent_local_map.size\n local_index = @cascade_controller.parent_set( parent_array, parent_index )\n undecorated_set( local_index, nil )\n @children.each { |this_array| this_array.update_for_parent_set( local_index, object ) }\n end\n \n return self\n\n end",
"def update\n authorize! :manage, @node\n\n respond_to do |format|\n if @node.update_attributes(params[:node])\n format.html { redirect_to @node, notice: 'Node was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @node.errors, status: :unprocessable_entity }\n end\n end\n end",
"def rest_edit(path, options={}, &blk)\n callback = Proc.new { |*args|\n @object = yield(*args) or pass\n rest_params.each { |k, v| @object.send :\"#{k}=\", v unless k == 'id' }\n\n return 400, @object.errors.to_json unless @object.valid?\n\n @object.save\n rest_respond @object\n }\n\n # Make it work with `Backbone.emulateHTTP` on.\n put path, &callback\n post path, &callback\n end",
"def rest_edit(path, options={}, &blk)\n callback = Proc.new { |*args|\n @object = yield(*args) or pass\n rest_params.each { |k, v| @object.send :\"#{k}=\", v unless k == 'id' }\n\n return 400, @object.errors.to_json unless @object.valid?\n\n @object.save\n rest_respond @object\n }\n\n # Make it work with `Backbone.emulateHTTP` on.\n put path, &callback\n post path, &callback\n end",
"def update_and_save\n self.last_update = Time.now\n self.save!\n\n self.parents.each do |parent|\n parent.update_and_save\n end\n end",
"def update\n @obj = Node.find(params[:id])\n\n respond_to do |format|\n if @obj.update_attributes(params[:node])\n format.html { redirect_to @obj, notice: 'Node was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @obj.errors, status: :unprocessable_entity }\n end\n end\n end",
"def patch\n headers = {\"If-Match\" => @version}\n response = @context.request :patch, \"#{@path}/#{@id}\", @data.to_json, headers\n @version += 1\n response\n # 'X-HTTP-Method-Override' => 'PATCH'\n end",
"def update_subtree\n children.find_all {|child| child.kind_of?(NonLeafNode)}.each do |child|\n child.update_subtree\n end\n update_shash(false)\n end",
"def update_tenant_circle(args = {}) \n put(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n if @post.parent_id?\n parent_post = Post.find(@post.parent_id)\n parent_post.updated_at = @post.updated_at\n parent_post.save\n format.html { redirect_to parent_post, notice: 'Post was successfully created.' }\n format.json { head :no_content }\n else\n #flash[:notice] = \"Successfully created post.\"\n #redirect_to \"/posts\"\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { head :no_content }\n end\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @fieldset_child = DynamicFieldsets::FieldsetChild.find(params[:id])\n respond_to do |format|\n if @fieldset_child.update_attributes(params[:dynamic_fieldsets_fieldset_child])\n format.html { redirect_to(dynamic_fieldsets_children_dynamic_fieldsets_fieldset_path(@fieldset_child.root_fieldset), :notice => \"Successfully updated a child\")}\n else\n format.html { render :action => \"edit\" }\n end\n end\n end",
"def update_child_devices\n if self.parent_id.blank? && !['assigned', 'instock'].include?(self.status)\n params_attr = {status: 'instock', parent_id: nil} \n else\n params_attr = {status: self.status, parent_id: self.id}\n end\n self.child_devices.update_all(params_attr)\n end",
"def update!(**args)\n @content = args[:content] if args.key?(:content)\n @derived_struct_data = args[:derived_struct_data] if args.key?(:derived_struct_data)\n @id = args[:id] if args.key?(:id)\n @json_data = args[:json_data] if args.key?(:json_data)\n @name = args[:name] if args.key?(:name)\n @parent_document_id = args[:parent_document_id] if args.key?(:parent_document_id)\n @schema_id = args[:schema_id] if args.key?(:schema_id)\n @struct_data = args[:struct_data] if args.key?(:struct_data)\n end",
"def update\n respond_to do |format|\n if @adult_children_trait.update(adult_children_trait_params)\n format.html { redirect_to @adult_children_trait, notice: 'Adult children trait was successfully updated.' }\n format.json { render :show, status: :ok, location: @adult_children_trait }\n else\n format.html { render :edit }\n format.json { render json: @adult_children_trait.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @child_fatality.update(child_fatality_params)\n format.html { redirect_to @child_fatality, notice: 'Child fatality was successfully updated.' }\n format.json { render :show, status: :ok, location: @child_fatality }\n else\n format.html { render :edit }\n format.json { render json: @child_fatality.errors, status: :unprocessable_entity }\n end\n end\n end",
"def sync_child_pages\n children.each{ |p| p.save! } if full_path_changed?\n end",
"def update\n respond_to do |format|\n if @condominium_child.update(condominium_child_params)\n format.json { render :show, status: :ok, object: @condominium_child }\n else\n format.json { render json: @condominium_child.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @added_parents = args[:added_parents] if args.key?(:added_parents)\n @removed_parents = args[:removed_parents] if args.key?(:removed_parents)\n end",
"def update\n\n @bookid = params[:id]\n @childid = params[:hire][:childid]\n\n respond_to do |format|\n if @hire.update(hire_params)\n format.html { redirect_to @hire, notice: \"Updated! Nice work.\" }\n format.js.coffee { }\n format.json { render :show, status: :ok, location: @hire }\n else\n format.html { render :edit }\n format.json { render json: @hire.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @index_of_sub_tree_with_splitting_feature = args[:index_of_sub_tree_with_splitting_feature] if args.key?(:index_of_sub_tree_with_splitting_feature)\n @index_of_sub_tree_without_splitting_feature = args[:index_of_sub_tree_without_splitting_feature] if args.key?(:index_of_sub_tree_without_splitting_feature)\n @parent = args[:parent] if args.key?(:parent)\n @path_from_root = args[:path_from_root] if args.key?(:path_from_root)\n @pattern_id = args[:pattern_id] if args.key?(:pattern_id)\n @payload = args[:payload] if args.key?(:payload)\n @splitting_feature = args[:splitting_feature] if args.key?(:splitting_feature)\n @splitting_feature_score = args[:splitting_feature_score] if args.key?(:splitting_feature_score)\n end",
"def update\n # Draft or Publish buttons support\n params[:resource][:status] = 'PUBLISHED' if params[:publish_button]\n params[:resource][:status] = 'DRAFT' if params[:draft_button]\n params[:resource][:status] = 'ARCHIVED' if params[:archive_button]\n\n @resource = Resource.find(params[:id])\n @resource_type = @resource.resource_type\n Website.associate_website(@resource, session[:website])\n tree_node = params[:resource][:tree_nodes_attributes]['0']\n if tree_node\n @tree_node = TreeNode.find_by_id_and_resource_id(tree_node[:id],params[:id])\n end\n\n # # ******************\n # # Check permissions!\n # if not (@tree_node && @tree_node.can_edit?)\n # flash[:notice] = \"Access denied. User can't edit this node\"\n # redirect_to session[:referer]\n # end\n # # ******************\n\n parent_id = tree_node[:parent_id]\n unless parent_id == '0' && AuthenticationModel.current_user_is_admin?\n # parent_tree_node = TreeNode.find(parent_id)\n if not (@tree_node && @tree_node.can_edit?)\n flash[:notice] = \"Access denied. User can't create tree node\"\n redirect_to session[:referer]\n end\n end\n \n params[:resource].merge!(:updated_at => Time.now)\n respond_to do |format|\n if @resource.update_attributes(params[:resource])\n flash[:notice] = 'Resource was successfully updated.'\n format.html { redirect_to session[:referer] || :back}\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" } #:text => params.inspect } # }\n format.xml { render :xml => @resource.errors.to_xml }\n end\n end\n end",
"def update\n if parent_params[:password].blank?\n parent_params.delete(:password)\n parent_params.delete(:password_confirmation)\n end\n\n successfully_updated = if needs_password?(@parent, parent_params)\n @parent.update(parent_params)\n else\n @parent.update_without_password(parent_params)\n end\n\n respond_to do |format|\n if successfully_updated\n format.html { redirect_to @parent, notice: 'Parent was successfully updated.' }\n format.json { render :show, status: :ok, location: @parent }\n else\n format.html { render :edit }\n format.json { render json: @parent.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @child = args[:child] if args.key?(:child)\n @label = args[:label] if args.key?(:label)\n @phrase = args[:phrase] if args.key?(:phrase)\n end",
"def update!(**args)\n @parent_id = args[:parent_id] if args.key?(:parent_id)\n @title = args[:title] if args.key?(:title)\n end",
"def set_child\n @child = Child.find(params[:id])\n end",
"def update\n @dec_form_child = DecFormChild.find(params[:id])\n\n respond_to do |format|\n if @dec_form_child.update_attributes(params[:dec_form_child])\n format.html { redirect_to @dec_form_child, notice: 'Dec form child was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @dec_form_child.errors, status: :unprocessable_entity }\n end\n end\n end"
] |
[
"0.7087602",
"0.6747008",
"0.64609504",
"0.64609504",
"0.6425298",
"0.64243084",
"0.64243084",
"0.64243084",
"0.6372172",
"0.6325486",
"0.6317983",
"0.62796867",
"0.6267304",
"0.62311465",
"0.62205744",
"0.60959387",
"0.6091433",
"0.6057536",
"0.6040286",
"0.6024075",
"0.6024075",
"0.6024075",
"0.6024075",
"0.6024075",
"0.6023704",
"0.60204136",
"0.60074073",
"0.5994434",
"0.59914416",
"0.59838134",
"0.5950626",
"0.5920443",
"0.5920443",
"0.59200495",
"0.5917418",
"0.59065515",
"0.58870304",
"0.5860601",
"0.5859861",
"0.58587927",
"0.58541083",
"0.5852415",
"0.58459187",
"0.5832026",
"0.5829888",
"0.58202827",
"0.5802289",
"0.579409",
"0.5785354",
"0.57504773",
"0.5745518",
"0.5735438",
"0.5733038",
"0.57064545",
"0.57033044",
"0.56995124",
"0.56993055",
"0.5698329",
"0.5696435",
"0.5692403",
"0.5668593",
"0.5667523",
"0.5667472",
"0.5662286",
"0.56597227",
"0.56495094",
"0.5630989",
"0.56283206",
"0.56221277",
"0.5616827",
"0.56101745",
"0.5588311",
"0.5586519",
"0.5583061",
"0.55803597",
"0.5572421",
"0.55656713",
"0.55656713",
"0.5557125",
"0.5555217",
"0.55487454",
"0.554146",
"0.55390006",
"0.5534551",
"0.55291927",
"0.552212",
"0.55177116",
"0.5505107",
"0.5492217",
"0.5491129",
"0.54808885",
"0.54761904",
"0.54740566",
"0.54717463",
"0.5469538",
"0.54447424",
"0.54446405",
"0.5443932",
"0.5439373",
"0.54324496"
] |
0.65239745
|
2
|
DELETE /children/1 DELETE /children/1.json
|
def destroy
@child.destroy
respond_to do |format|
format.html { redirect_to children_url }
format.json { head :no_content }
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def destroy\n @children = Children.find(params[:id])\n @children.destroy\n\n respond_to do |format|\n format.html { redirect_to(childrens_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @child = Child.find(params[:id])\n @child.destroy\n\n respond_to do |format|\n format.html { redirect_to children_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @child = Child.find(params[:id])\n @child.destroy\n\n respond_to do |format|\n format.html { redirect_to(children_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @child.destroy\n respond_to do |format|\n format.html { redirect_to children_url, notice: \"Child was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @child.destroy\n respond_to do |format|\n format.html { redirect_to children_url, notice: \"Child was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @child.destroy\n respond_to do |format|\n format.html { redirect_to children_url, notice: 'Child was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @child.destroy\n respond_to do |format|\n format.html { redirect_to children_url, notice: 'Child was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @child.destroy\n respond_to do |format|\n format.html { redirect_to :back, notice: 'Child was successfully deleted.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @descendant.destroy\n respond_to do |format|\n format.html { redirect_to descendants_url, notice: 'Descendant was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @traumatized_child.destroy\n respond_to do |format|\n format.html { redirect_to traumatized_children_url, notice: \"Traumatized child was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def delete(path)\n path = normalize_path(path)\n if path.empty?\n raise 'Empty path'\n elsif path.size == 1\n child = @children.delete(path.first)\n @modified = true if child\n child\n else\n tree = @children[path.first]\n raise 'Not a tree' if tree.type != :tree\n tree.delete(path[1..-1])\n end\n end",
"def destroy\n @tree.destroy\n respond_to do |format|\n format.html { redirect_to trees_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tree.destroy\n respond_to do |format|\n format.html { redirect_to trees_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @miscellaneous_child = MiscellaneousChild.find(params[:id])\n @miscellaneous_child.destroy\n\n respond_to do |format|\n format.html { redirect_to(miscellaneous_children_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @branch = Branch.find(params[:id])\n @parentTitle = Branch.find(params[:id]).uid\n Branch.where(parent: @parentTitle).delete_all\n @branch.destroy\n render :json => @branch.to_json\n end",
"def destroy\n @leaf.destroy\n respond_to do |format|\n format.html { redirect_to leafs_url, notice: DELETE_SUCCESS }\n format.json { head :no_content }\n end\n end",
"def destroy\n @child_resource = ChildResource.find(params[:id])\n # require modify permissions for this object\n require_privilege(Alberich::Privilege::MODIFY, @child_resource)\n @child_resource.destroy\n\n respond_to do |format|\n format.html { redirect_to child_resources_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @parent = Parent.find(params[:id])\n @parent.destroy\n\n respond_to do |format|\n format.html { redirect_to parents_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @condominium_child.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n @tree = Tree.find(params[:id])\n @tree.destroy\n\n respond_to do |format|\n format.html { redirect_to trees_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n\t\t@parent_child.destroy\n\t\trespond_to do |format|\n\t \t\tformat.html { redirect_to parent_children_url, notice: 'Parent child was successfully destroyed.' }\n\t \t\tformat.json { head :no_content }\n\t\tend\n \tend",
"def destroy\n @leaf.destroy\n respond_to do |format|\n format.html { redirect_to leaves_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @childmaster = Childmaster.find(params[:id])\n @childmaster.destroy\n\n respond_to do |format|\n format.html { redirect_to childmasters_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n \t@tree.destroy\n \trespond_to do |format|\n \t\tformat.html { redirect_to trees_url, notice: 'Arvore deletado com sucesso.' }\n \t\tformat.json { head :no_content }\n \tend\n end",
"def destroy\n @parent_of.destroy\n respond_to do |format|\n format.html { redirect_to parent_ofs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @leaf.destroy\n respond_to do |format|\n format.html { redirect_to leafs_url, notice: t('common.message.destroyed_success')}\n format.json { head :no_content }\n end\n end",
"def destroy\n @taxonomy = Taxonomy.find(params[:id])\n taxonomy_type = @taxonomy.taxonomy_type \n @taxonomy.delete_node_keep_sub_nodes\n @taxonomy.reload\n @taxonomy.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_taxonomies_url(:taxonomy_type => taxonomy_type) }\n format.json { head :no_content }\n end\n end",
"def destroy\n @pharmacy_payment_child = PharmacyPaymentChild.find(params[:id])\n @pharmacy_payment_child.destroy\n\n respond_to do |format|\n format.html { redirect_to(pharmacy_payment_children_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @athletes_parent = AthletesParent.find(params[:id])\n @athletes_parent.destroy\n\n respond_to do |format|\n format.html { redirect_to(athletes_parents_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @ministry_child.destroy\n respond_to do |format|\n format.html { redirect_to ministry_children_url, notice: 'Ministry child was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete_folder_children_request(folder_id)\n url = URI(\"#{$base_url}/api/projects/#{$project_id}/folders/#{folder_id}/children\")\n\n http = Net::HTTP.new(url.host, url.port)\n http.use_ssl = true\n request = Net::HTTP::Delete.new(url)\n request[\"accept\"] = 'application/vnd.api+json; version=1'\n request[\"access-token\"] = $access_token\n request[\"uid\"] = $uid\n request[\"client\"] = $client\n response = http.request(request)\n\n if response.code == 304.to_s\n puts \"Folder is empty. Status: #{response.code}\"\n elsif response.code == 504.to_s\n puts \"Gateway Time-out. Status: #{response.code}\"\n puts response.body\n end\n\n response.code\nend",
"def destroy\n @dec_form_child = DecFormChild.find(params[:id])\n @dec_form_child.destroy\n\n respond_to do |format|\n format.html { redirect_to dec_form_children_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @quest_tree = QuestTree.find(params[:id])\n @quest_tree.destroy\n\n respond_to do |format|\n format.html { redirect_to quest_trees_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @comment = Comment.find(params[:id])\n \n \n if @comment.has_children?\n @comment.children.each do |child|\n child.destroy\n end\n end\n @comment.destroy\n\n respond_with do |format|\n flash.now[:notice] = 'Comment was successfully deleted.'\n end\n end",
"def destroy\n @monitor_child_relationship = MonitorChildRelationship.find(params[:id])\n @monitor_child_relationship.destroy\n\n respond_to do |format|\n format.html { redirect_to monitor_child_relationships_url }\n format.json { head :no_content }\n end\n end",
"def test_nested_collection_destroy\n old_child = @parent.children.first\n childcontroller = ChildController.new(params: { id: old_child.id })\n childcontroller.invoke(:destroy)\n\n assert_equal(200, childcontroller.status, childcontroller.hash_response)\n\n @parent.reload\n\n assert_equal(%w[c2], @parent.children.order(:position).pluck(:name))\n assert_predicate(Child.where(id: old_child.id), :empty?)\n end",
"def destroy\n @tree.destroy\n respond_to do |format|\n format.html { redirect_to trees_url, notice: 'Tree was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @orphan.destroy\n respond_to do |format|\n format.html { redirect_to orphans_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @question = Question.find(params[:id])\n @question.destroy\n @children = Question.find_all_by_parentid(params[:id])\n if @children != nil\n \tfor child in @children\n \t\tchild.destroy\n \tend\n end\n respond_to do |format|\n flash[:notice] = 'Question was successfully deleted.'\n format.html { redirect_to(:back) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @child_record.destroy\n respond_to do |format|\n format.html { redirect_to child_records_url, notice: 'Child record was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete_tenant_circle(args = {}) \n delete(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def destroy\n @parent = Parent.find_by_id(params[:id])\n @parent.destroy\n\n respond_to do |format|\n format.html { redirect_to(parents_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @product_tree = ProductTree.find(params[:id])\n @product_tree.destroy if @product_tree.is_childless?\n\n respond_to do |format|\n format.html { redirect_to product_trees_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @relationship = @assembly.relationships.find(params[:id])\n child = @relationship.child\n child.used = false\n child.save\n @relationship.destroy\n\n respond_to do |format|\n format.html { redirect_to [@plan, @assembly], notice: 'Relationship was deleted.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n family = @child.family\n @child.destroy\n respond_to do |format|\n format.html { redirect_to family, notice: tr(\"child_deleted\") }\n end\n end",
"def destroy\n @childmaster = Childmaster.find(params[:id])\n @childmaster.destroy\n\n respond_to do |format|\n format.html { redirect_to(childmasters_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n n = Node.find_key(params[:id] || params[:name])\n render api_delete Node\n end",
"def destroy\n\t\t@parent = Parent.find(params[:id])\n @parent.destroy\n respond_to do |format|\n format.html { redirect_to '/parent', notice: 'Parent was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def recursively_destroy!\n children.each { |c| c.recursively_destroy! }\n destroy\n end",
"def destroy\n @category = Category.by_alias params[:alias]\n raise ActionController::RoutingError, 'Not found' if @category.nil?\n\n parent_url = @category.parent_url\n @category.destroy_tree\n\n respond_to do |format|\n format.html { redirect_to parent_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @child_dupa2 = ChildDupa2.find(params[:id])\n @child_dupa2.destroy\n\n respond_to do |format|\n format.html { redirect_to(child_dupa2s_url) }\n format.xml { head :ok }\n end\n end",
"def recursive_delete(path: nil)\n raise ArgumentError, \"path is a required argument\" if path.nil?\n\n result = zk.get_children(path: path)\n raise Kazoo::Error, \"Failed to list children of #{path} to delete them. Result code: #{result.fetch(:rc)}\" if result.fetch(:rc) != Zookeeper::Constants::ZOK\n\n threads = result.fetch(:children).map do |name|\n Thread.new do\n Thread.abort_on_exception = true\n recursive_delete(path: File.join(path, name))\n end\n end\n threads.each(&:join)\n\n result = zk.delete(path: path)\n raise Kazoo::Error, \"Failed to delete node #{path}. Result code: #{result.fetch(:rc)}\" if result.fetch(:rc) != Zookeeper::Constants::ZOK\n end",
"def destroy\n @fnss_simple_kary_tree.destroy\n respond_to do |format|\n format.html { redirect_to fnss_simple_kary_trees_url, notice: 'Fnss simple kary tree was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @child_model = ChildModel.find(params[:id])\n @child_model.destroy\n\n respond_to do |format|\n format.html { redirect_to(child_models_url) }\n format.xml { head :ok }\n end\n end",
"def delete_child_at(index)\n # NOTE: All deleting uses this method so that subclasses can override default behaviour when deleting a child\n @children.delete_at(index)\n end",
"def destroy\n @obj = Node.find(params[:id])\n @obj.destroy\n\n respond_to do |format|\n format.html { redirect_to :back}\n format.json { head :no_content }\n end\n end",
"def destroy\n @parent.destroy\n respond_to do |format|\n format.html { redirect_to parents_url, notice: 'Parent was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @parent.destroy\n respond_to do |format|\n format.html { redirect_to parents_url, notice: 'Parent was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @parent.destroy\n respond_to do |format|\n format.html { redirect_to parents_url, notice: 'Parent was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @parent.destroy\n respond_to do |format|\n format.html { redirect_to parents_url, notice: 'Parent was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @parent.destroy\n respond_to do |format|\n format.html { redirect_to parents_url, notice: 'Parent was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @parent.destroy\n respond_to do |format|\n format.html { redirect_to parents_url, notice: 'Parent was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @parent.destroy\n respond_to do |format|\n format.html { redirect_to parents_url, notice: 'Parent was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @node = Node.find_key(params[:id] || params[:name])\n @node.destroy\n respond_to do |format|\n format.html { redirect_to deployment_path(@node.deployment_id) }\n format.json { render api_delete @node }\n end\n end",
"def destroy\n @child_fatality.destroy\n respond_to do |format|\n format.html { redirect_to child_fatalities_url, notice: 'Child fatality was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tree.destroy\n redirect_to user_url(current_user), notice: '削除しました'\n end",
"def delete; rest_delete(link('self')); end",
"def delete; rest_delete(link('self')); end",
"def destroy_children()\n # self.children.each do |c|\n # class_const = Service.class_map[c.service_id]\n # raise NoClassError.new(\"Pas de classe rattachée au service=#{c.service_id}\") if class_const.nil?\n # child = class_const[c.id]\n # child.destroy()\n # end\n end",
"def remove_child child\n @children.delete child\n end",
"def destroy\n\t\tparent = @fallacyfolder.parent\n\t\t@fallacyfolder.destroy\n\n\t\trespond_to do |format|\n\t\t\tformat.html { }\n\t\t\tformat.json { render :json => {:parent => parent.id}.to_json }\n\t\tend\n\tend",
"def destroy\n @key_donor_child.destroy\n respond_to do |format|\n format.html { redirect_to key_donor_children_url, notice: 'Key donor child was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @container = Container.get(params[:id])\n @container.destroy if(@container && !@container.root?)\n\n respond_to do |format|\n format.html { redirect_to(container_url(@container.parent.id)) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @resource = Resource.find(params[:id])\n\n # # ******************\n # # Check permissions!\n # main_tree_node = @resource.tree_nodes.select{ |e| e.is_main == true }.first\n # if not (main_tree_node && main_tree_node.can_administrate?)\n # flash[:notice] = \"Access denied. User can't delete tree node\"\n # redirect_to session[:referer]\n # end\n # # ******************\n\n @resource.destroy\n respond_to do |format|\n format.html { redirect_to session[:referer] }\n format.xml { head :ok }\n end\n end",
"def delete_children(id, tube_rack)\n @session.tube_rack_slot.dataset.filter(:tube_rack_id => id).delete\n end",
"def delete_children(id, flowcell)\n Lane::dataset(@session).filter(:flowcell_id => id).delete\n end",
"def destroy\n @child_guardian_relationship = ChildGuardianRelationship.find(params[:id])\n @child_guardian_relationship.destroy\n\n respond_to do |format|\n format.html { redirect_to child_guardian_relationships_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @father = Father.find(params[:id])\n @father.destroy\n\n respond_to do |format|\n format.html { redirect_to fathers_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @nested_page = Nested::Page.find(params[:id])\n @nested_page.destroy\n\n respond_to do |format|\n format.html { redirect_to nested_pages_url }\n format.json { head :no_content }\n end\n end",
"def delete_relationship_of_child_with_parent(parent_ou_id, child_ou_id)\n path = \"/d2l/api/lp/#{$lp_ver}/orgstructure/#{parent_ou_id}/children/#{child_ou_id}\"\n _delete(path)\nend",
"def destroy\n b.node.destroy\n respond_to do |format|\n format.html { redirect_to nodes_url, notice: 'Node was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n RestClient.delete \"#{REST_API_URI}/contents/#{id}.xml\" \n self\n end",
"def destroy\n @node = Node.find(params[:id])\n @node.destroy\n \n Action.log :controller => params[:controller], :action => params[:action], :target_id => params[:id], :user => current_user\n\n respond_to do |format|\n format.html { redirect_to :root, notice: 'Node was successfully deleted.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n authorize! :destroy, @node\n\n @node.destroy\n respond_to do |format|\n format.html { redirect_to nodes_url }\n format.json { head :no_content }\n end\n end",
"def delete_branch\n #we'll get all descendants by level descending order. That way we'll make sure deletion will come from children to parents\n children_to_be_deleted = self.class.find(:all, :conditions => \"id_path like '#{self.id_path},%'\", :order => \"level desc\")\n children_to_be_deleted.each {|d| d.destroy}\n #now delete my self :)\n self.destroy\n end",
"def destroy\n #If image has parent, update children and vice versa\n if image.root_version? then\n newroot = image.child_versions.order(:created_at).last\n image.child_versions.delete(newroot)\n image.child_versions.each do |v| v.parent_image = newroot and v.save end\n else\n image.child_versions.each do |v| v.parent_image = image.parent_image and v.save end\n end\n\n image.destroy\n respond_to do |format|\n format.html { redirect_to images_url, notice: 'Image was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete_child(index)\n dup_children = children.dup\n dup_children.delete_at(index)\n emit_type(*dup_children)\n end",
"def destroy\n super\n\n @children.each do |_child_name, child_group|\n child_group.each(&:destroy)\n end\n\n @children = {}\n end",
"def destroy\n @foster_parent.destroy\n respond_to do |format|\n format.html { redirect_to foster_parents_url }\n format.json { head :no_content }\n end\n end",
"def delete_children(id, gel)\n element_dataset.filter(container_id_sym => id).delete\n end",
"def destroy\n @corporate_health_package_child = CorporateHealthPackageChild.find(params[:id])\n @corporate_health_package_child.destroy\n\n respond_to do |format|\n format.html { redirect_to(corporate_health_package_children_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @node = Node.find(params[:id])\n @node.destroy\n\n respond_to do |format|\n format.html { redirect_to nodes_path }\n format.json { head :ok }\n end\n end",
"def destroy\n @node = Node.find(params[:id])\n @node.destroy\n\n respond_to do |format|\n format.html { redirect_to nodes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @node = Node.find(params[:id])\n @node.destroy\n\n respond_to do |format|\n format.html { redirect_to nodes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @node = Node.find(params[:id])\n @node.destroy\n\n respond_to do |format|\n format.html { redirect_to nodes_url }\n format.json { head :no_content }\n end\n end",
"def ajax_delete_node\n\n # Get the Node from the DB\n node = Node.find(params[:node_id])\n\n # If node exits, then remove the node\n if !node.nil?\n node.destroy\n end\n\n end",
"def destroy\n @page_hierarchy.destroy\n respond_to do |format|\n format.html { redirect_to page_hierarchies_url, notice: 'Page hierarchy was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @three_child_history.destroy\n respond_to do |format|\n format.html { redirect_to three_child_histories_url, notice: 'Three child history was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete_children(id, flowcell)\n @session.flowcell_lane.dataset.filter(:flowcell_id => id).delete\n end",
"def destroy\n @ministry_child = MinistryChild.find(params[:id])\n \n redirect_id = @ministry_child.ministry_id\n @ministry_child.destroy\n \n respond_to do |format|\n format.html { redirect_to ministry_path(redirect_id) }\n format.json { head :no_content }\n end\n end"
] |
[
"0.7690423",
"0.754166",
"0.7339654",
"0.7039886",
"0.7039886",
"0.70389456",
"0.70389456",
"0.68095887",
"0.67939544",
"0.6781426",
"0.6747409",
"0.67131644",
"0.67131644",
"0.6713039",
"0.6677913",
"0.667762",
"0.667456",
"0.66403186",
"0.6628512",
"0.6609712",
"0.660891",
"0.66086495",
"0.6545574",
"0.6530928",
"0.651468",
"0.6498822",
"0.6497765",
"0.6469963",
"0.64461195",
"0.64205235",
"0.6417793",
"0.6400747",
"0.63929784",
"0.6388104",
"0.63875276",
"0.63845944",
"0.6369013",
"0.6365629",
"0.6359086",
"0.6356818",
"0.635345",
"0.63515",
"0.6342332",
"0.6337743",
"0.6336979",
"0.6334274",
"0.6327439",
"0.6319878",
"0.6313386",
"0.6306602",
"0.6303897",
"0.6294284",
"0.62932044",
"0.62929255",
"0.62894577",
"0.62691826",
"0.62570906",
"0.62570906",
"0.62570906",
"0.62570906",
"0.62570906",
"0.62570906",
"0.62570906",
"0.62463367",
"0.6243071",
"0.6237375",
"0.6223659",
"0.6223659",
"0.6200477",
"0.6199492",
"0.6198046",
"0.6193476",
"0.6191674",
"0.61908126",
"0.61835223",
"0.6181566",
"0.6176485",
"0.6175338",
"0.61704797",
"0.6170465",
"0.6168177",
"0.61643505",
"0.6161934",
"0.61529696",
"0.61503863",
"0.6149149",
"0.6143242",
"0.61337614",
"0.6130515",
"0.6107287",
"0.6105793",
"0.61033267",
"0.610195",
"0.610195",
"0.610195",
"0.61019075",
"0.6094525",
"0.6078253",
"0.60755724",
"0.6072033"
] |
0.7553778
|
1
|
Use callbacks to share common setup or constraints between actions.
|
def set_child
@child = Child.find(params[:id])
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end",
"def add_actions; end",
"def callbacks; end",
"def callbacks; end",
"def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end",
"def define_action_helpers; end",
"def post_setup\n end",
"def action_methods; end",
"def action_methods; end",
"def action_methods; end",
"def before_setup; end",
"def action_run\n end",
"def execute(setup)\n @action.call(setup)\n end",
"def define_action_helpers?; end",
"def set_actions\n actions :all\n end",
"def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end",
"def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end",
"def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end",
"def before_actions(*logic)\n self.before_actions = logic\n end",
"def setup_handler\n end",
"def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end",
"def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def workflow\n end",
"def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end",
"def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end",
"def before(action)\n invoke_callbacks *self.class.send(action).before\n end",
"def process_action(...)\n send_action(...)\n end",
"def before_dispatch(env); end",
"def after_actions(*logic)\n self.after_actions = logic\n end",
"def setup\n # override and do something appropriate\n end",
"def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end",
"def setup(_context)\n end",
"def setup(resources) ; end",
"def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end",
"def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end",
"def determine_valid_action\n\n end",
"def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end",
"def startcompany(action)\n @done = true\n action.setup\n end",
"def init_actions\n am = action_manager()\n am.add_action(Action.new(\"&Disable selection\") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } )\n am.add_action(Action.new(\"&Edit Toggle\") { @edit_toggle = !@edit_toggle; $status_message.value = \"Edit toggle is #{@edit_toggle}\" })\n end",
"def event_callbacks(event, metadata={})\n case event\n when :reset, :review\n if confirmed\n update_attributes(confirmed: false)\n end\n when :confirm\n confirm\n # trigger :order for all applicable items\n # NOTE: :order event is common to both physical and digital items\n items.each do |i|\n if i.event_permitted(:order)\n user_id = last_transition.user_id\n i.trigger!(:order, { order_id: id, user_id: user_id })\n end\n end\n when :complete_work\n request = metadata[:request]\n work_complete_notification(request)\n when :close\n close\n end\n if event != :close && !open\n reopen\n end\n end",
"def setup_action\n return unless PONY::ERRNO::check_sequence(current_act)\n new_sequence = @action_sequence[@sequence_index+1...@action_sequence.size]\n @sequence_index = 0\n new_sequence = DND::SkillSequence::ACTS[@acts[1]] + new_sequence\n execute_sequence\n end",
"def define_tasks\n define_weave_task\n connect_common_tasks\n end",
"def setup(&block)\n define_method(:setup, &block)\n end",
"def setup\n transition_to(:setup)\n end",
"def setup\n transition_to(:setup)\n end",
"def action\n end",
"def setup( *args )\n\t\t\tself.class.setupBlocks.each {|sblock|\n\t\t\t\tdebugMsg \"Calling setup block method #{sblock}\"\n\t\t\t\tself.send( sblock )\n\t\t\t}\n\t\t\tsuper( *args )\n\t\tend",
"def config(action, *args); end",
"def setup\n @setup_proc.call(self) if @setup_proc\n end",
"def before_action \n end",
"def setup_callbacks\n defined_callbacks.each do |meth|\n unless respond_to?(\"call_#{meth}_callbacks\".to_sym)\n self.class.module_eval <<-EOE\n def call_#{meth}_callbacks(*args)\n plugin_store.each {|a| a.call_#{meth}_callbacks(*args) } if respond_to?(:plugin_store) && plugin_store\n self.send :#{meth}, *args if respond_to?(:#{meth})\n end\n EOE\n end\n end\n end",
"def action\n end",
"def matt_custom_action_begin(label); end",
"def setup\n # override this if needed\n end",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def action(options,&callback)\n new_action = Action===options ? options : Action.new(options,&callback)\n # replace any with (shared name/alias or both default) + same arity\n @actions.delete_if do |existing_action|\n ((existing_action.names & new_action.names).size > 0 ||\n existing_action.default? && new_action.default?) &&\n existing_action.required.size == new_action.required.size &&\n existing_action.optional.size <= new_action.optional.size\n end\n @actions = (@actions + [new_action]).sort\n new_action\n end",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action\n end",
"def after(action)\n invoke_callbacks *options_for(action).after\n end",
"def pre_task\n end",
"def setup(server)\n server.on('beforeMethod', method(:before_method), 10)\n end",
"def add_actions\n attribute = machine.attribute\n name = self.name\n \n owner_class.class_eval do\n define_method(name) {self.class.state_machines[attribute].events[name].fire(self)}\n define_method(\"#{name}!\") {self.class.state_machines[attribute].events[name].fire!(self)}\n define_method(\"can_#{name}?\") {self.class.state_machines[attribute].events[name].can_fire?(self)}\n end\n end",
"def init_actions\n @select_action = SelectAction.new\n @endpoint_mouse_action = EndpointMouseAction.new\n @move_action = MoveAction.new\n end",
"def setup_signals; end",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action.respond_to?('weak!') ? action.weak! : action\n end",
"def initialize(*args)\n super\n @action = :set\nend",
"def after_set_callback; end",
"def setup\n #implement in subclass;\n end",
"def lookup_action; end",
"def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end",
"def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end",
"def release_actions; end",
"def around_hooks; end",
"def save_action; end",
"def setup(easy)\n super\n easy.customrequest = @verb\n end",
"def action_target()\n \n end",
"def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end",
"def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end",
"def before_setup\n # do nothing by default\n end",
"def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end",
"def default_action; end",
"def setup(&blk)\n @setup_block = blk\n end",
"def callback_phase\n super\n end",
"def advice\n end",
"def _handle_action_missing(*args); end",
"def duas1(action)\n action.call\n action.call\nend",
"def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end",
"def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end",
"def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend"
] |
[
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576",
"0.53124547",
"0.529654",
"0.5296262",
"0.52952296",
"0.52600986",
"0.52442724",
"0.52385926",
"0.52385926",
"0.52385926",
"0.52385926",
"0.52385926",
"0.5232394",
"0.523231",
"0.5227454",
"0.52226824",
"0.52201617",
"0.5212327",
"0.52079266",
"0.52050185",
"0.51754695",
"0.51726824",
"0.51710224",
"0.5166172",
"0.5159343",
"0.51578903",
"0.51522785",
"0.5152022",
"0.51518047",
"0.51456624",
"0.51398855",
"0.5133759",
"0.5112076",
"0.5111866",
"0.5111866",
"0.5110294",
"0.5106169",
"0.509231",
"0.50873137",
"0.5081088",
"0.508059",
"0.50677156",
"0.50562143",
"0.5050554",
"0.50474834",
"0.50474834",
"0.5036181",
"0.5026331",
"0.5022976",
"0.5015441",
"0.50121695",
"0.5000944",
"0.5000019",
"0.4996878",
"0.4989888",
"0.4989888",
"0.49864885",
"0.49797225",
"0.49785787",
"0.4976161",
"0.49683493",
"0.4965126",
"0.4958034",
"0.49559742",
"0.4954353",
"0.49535993",
"0.4952725",
"0.49467874",
"0.49423352",
"0.49325448",
"0.49282882",
"0.49269363",
"0.49269104",
"0.49252945",
"0.4923091",
"0.49194667",
"0.49174926",
"0.49173003",
"0.49171105",
"0.4915879",
"0.49155936"
] |
0.0
|
-1
|
Never trust parameters from the scary internet, only allow the white list through.
|
def child_params
params.require(:child).permit(:created_at, :updated_at, :last_name, :first_name, :gender, :dob, :age_years, :age_months, :age_total_months, :location, :no_parent_present, :parental_permission_given, :allergies, :allergies_information, :immunization_utd, :dtap, :hib, :pneumovax, :hepa, :hepb, :influenza, :mmr, :immunization_needed, :revelant_information, :absences, :height_feet, :height_inches, :height_total_inches, :height_total_cm, :weight_lbs, :weight_oz, :weight_kg, :bmi_result, :bmi_percentile, :systolic_1, :diastolic_1, :systolic_2, :diastolic_2, :systolic_3, :diastolic_3, :hemoglobin, :blood_glucose, :hearing_hz_left_1, :hearing_db_left_1, :ear_left_pass_1, :hearing_hz_right_1, :hearing_db_right_1, :ear_right_pass_1, :hearing_hz_left_2, :hearing_db_left_2, :ear_left_pass_2, :hearing_hz_right_2, :hearing_db_right_2, :ear_right_pass_2, :hearing_hz_left_3, :hearing_db_left_3, :ear_left_pass_3, :hearing_hz_right_3, :hearing_db_right_3, :ear_right_pass_3, :hearing_comments, :vision_acuity_left_1, :vision_acuity_right_1, :vision_acuity_both_1, :vision_acuity_right_2, :vision_acuity_left_2, :vision_acuity_both_2, :vision_acuity_right_3, :vision_acuity_left_3, :vision_acuity_both_3, :vision_color_blindness, :cover_test_left, :cover_test_right, :cover_test_both, :wears_corrective_lenses, :vision_comments, :general_appearance, :general_appearance_c, :head, :head_c, :skin, :skin_c, :eyes, :eyes_c, :ears, :ears_c, :nose, :nose_c, :mouth, :mouth_c, :throat, :throat_c, :thyroid, :thyroid_c, :lymph_all_normal, :lymph_pre_auricular, :lymph_post_auricular, :lymph_anterior_cervical, :lymph_posterior_cervical, :lymph_occipital, :lymph_axillary, :lymph_c, :vascular, :vascular_c, :heart, :heart_c, :lungs, :lungs_c, :abdomen, :abdomen_c, :musculoskeletal, :musculoskeletal_c, :scoliosis, :scoliosis_c, :neuro, :neuro_c, :well_child_check, :children_01, :children_02, :children_03, :children_04, :children_05, :children_06, :children_07, :children_08, :children_09, :children_10, :follow_up_01, :follow_up_02, :follow_up_03, :follow_up_04, :follow_up_05, :follow_up_06, :follow_up_07, :follow_up_08, :follow_up_09, :follow_up_10, :text, :guidance, :chart_complete, :np_signature, :faculty_signature, :other_np_signature, :form_id_number)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def param_whitelist\n [:role, :title]\n end",
"def expected_permitted_parameter_names; end",
"def safe_params\n params.except(:host, :port, :protocol).permit!\n end",
"def strong_params\n params.require(:team_member).permit(param_whitelist)\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def strong_params\n params.require(:community).permit(param_whitelist)\n end",
"def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end",
"def strong_params\n params.require(:education).permit(param_whitelist)\n end",
"def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end",
"def allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\n end",
"def param_whitelist\n [:rating, :review]\n end",
"def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end",
"def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end",
"def user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end",
"def user_params\n params.permit(:name, :phoneNumber, :address, :postalCode, :local, :link, :counter, :latitude, :longitude) \n end",
"def valid_params_request?; end",
"def strong_params\n params.require(:experience).permit(param_whitelist)\n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def whitelist_url_params\n params.require(:whitelist_url).permit(:domain)\n end",
"def allowed_params\n params.require(:allowed).permit(:email)\n end",
"def permitted_params\n []\n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\n end",
"def query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend",
"def strong_params\n params.require(:success_metric).permit(param_whitelist)\n end",
"def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end",
"def whitelisted_user_params\n params.require(:user).\n permit( :first_name, :last_name, :email,:password,:password_confirmation,:birthday,:gender)\n end",
"def user_params\n ActionController::Parameters.permit_all_parameters = true\n params.require(:user) #.permit(:name, :surname, :phone, :password, :email, :time_zone)\n end",
"def strong_params\n params.require(:metric_change).permit(param_whitelist)\n end",
"def safe_params\n params.require(:user).permit(:name)\n end",
"def get_params\n\t\treturn ActionController::Parameters.new(self.attributes).permit(\"account_id\", \"title\", \"category\", \"introduction\", \"tags\", \"segment_type\", \"visible\", \"status\", \"main_image\")\n\tend",
"def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end",
"def check_params; true; end",
"def param_whitelist\n whitelist = [\n :description,\n :progress,\n :kpi_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:kpi_id)\n end\n \n whitelist\n end",
"def quote_params\n params.permit!\n end",
"def valid_params?; end",
"def paramunold_params\n params.require(:paramunold).permit!\n end",
"def user_params\n\t\tparams.permit(:nickname, :avatar, :description, :password, :gender, :birthday, :email, :phone, :qq_id, :wechat_id)\n\tend",
"def filtered_parameters; end",
"def user_params\n params.permit(\n \t:id,\n \t:email, \n \t:first_name, \n \t:last_name, \n \t:password, \n \t:confirm_token, \n \t:phone_number,\n \t:facebook_link,\n \t:car_model,\n \t:license_plate)\n end",
"def filtering_params\n params.permit(:email, :name)\n end",
"def check_params\n true\n end",
"def wx_public_params\n params.require(:wx_public).permit(:nickname, :manager, :alias)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def listing_params\n\t\tparams.permit(:address, :transit_info, :rules, :other_info, :lat, :lng)\n\tend",
"def social_account_params\n\t\t\tparams.require(:social_account).permit!\n\t\tend",
"def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end",
"def url_params\n params.require(:url).permit(:short_url, :original_url, :clicks, :ip_addresses)\n end",
"def user_params\n params.require(:user).permit(:uri, :username, :password, :realname, :email, :publicvisible)\n end",
"def model_params\n\t\tparams.require(:manager).permit(\n\t :user_name,\n :password,\n :email,\n \t\t\t)\n\tend",
"def article_params_whitelist\n params.require(:article).permit(:title, :description, category_ids: [])\n end",
"def college_whitelist_params\n params.require(:college_whitelist).permit(:status)\n end",
"def active_code_params\n params[:active_code].permit\n end",
"def filtering_params\n params.permit(:email)\n end",
"def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end",
"def ip_address_params\n\t\t\tparams.require(:ip_address).permit!\n end",
"def pull_request_params\n whitelist = [\n :url,\n :id,\n :html_url,\n :diff_url,\n :patch_url,\n :issue_url,\n :number,\n :state,\n :locked,\n :title\n ]\n params.require(:pull_request).permit(whitelist)\n end",
"def reserved_params\n params.require(:reserved).permit(:name, :email, :pax, :address, :KTP, :title)\n end",
"def post_params\n if current_user.admin? \n params.permit(:title, :body, :city, :country, :gps_location, :privacy, :visible, :latitude, :longitude, images: [], files: [])\n else \n params.permit(:title, :body, :city, :country, :gps_location, :privacy,:latitude, :longitude, images: [], files: [])\n end \n end",
"def list_params\n params.permit(:name)\n end",
"def filter_parameters; end",
"def filter_parameters; end",
"def vineyard_params\n params.permit(:vineyard_name, :email, :website_url, :phone, :address, :city, :region, :postcode, :country, :specialty, :description, :pet_friendly, :holiday, :tours, :events, :family_friendly, :cover_image, :image_one, :image_two, :image_three, :image_four, :user_id, :base64)\n end",
"def available_activity_params\n # params.require(:available_activity).permit(:type,:geometry,:properties)\n whitelisted = ActionController::Parameters.new({\n type: params.require(:available_activity)[:type],\n geometry: params.require(:available_activity)[:geometry].try(:permit!).to_h,\n properties: params.require(:available_activity)[:properties].try(:permit!).to_h\n }).try(:permit!)\n end",
"def user_params\n params.permit(:name, :username, :email, :password, :img_url, :bg_url, :coinbank)\n end",
"def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end",
"def user_params\n params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\n :user, :color, :solde)\n end",
"def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end",
"def param_whitelist\n [\n :title,\n :description,\n :organization,\n :team_id,\n :started_at,\n :finished_at,\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n end",
"def url_whitelist; end",
"def admin_social_network_params\n params.require(:social_network).permit!\n end",
"def filter_params\n params.require(:filters).permit(:letters)\n end",
"def origin_params\n params.permit(:country, :state, :city, :postal_code, :address, :description)\n end",
"def valid_params(params)\n params.permit(:login, :first_name, :last_name, \n :password, :password_confirmation)\n end",
"def sensitive_params=(params)\n @sensitive_params = params\n end",
"def permit_request_params\n params.permit(:address)\n end",
"def user_params\n # Ensure a user can't give themselves admin priveleges\n params.delete(:admin) if current_user.admin?\n params.require(:user).permit(:name, :email, :admin, :image)\n end",
"def secure_params\n params.require(:location).permit(:name)\n end",
"def strong_params\n params.require( :setting ).\n permit( :global_scan_limit, :per_user_scan_limit,\n :target_whitelist_patterns, :target_blacklist_patterns )\n end",
"def question_params\n params.require(:survey_question).permit(question_whitelist)\n end",
"def case_insensitive_params\n params.require(:case_insensitive).permit(:name)\n end",
"def empire_master_no_match_params\n params.require(:empire_master_no_match).permit(:uid, :last_name, :list, :search_date, :double, :source)\n end",
"def maintenance_request_params\n params[:maintenance_request].permit! #allow all parameters for now\n end",
"def unwanted_params\n params.require(:unwanted).permit(:title, :description, :image)\n end",
"def url_params\n params[:url].permit(:full)\n end",
"def backend_user_params\n params.permit!\n end",
"def filter_params\n\t\treturn params[:candidate].permit(:name_for_filter)\n\tend",
"def speed_measurement_params\n\n #fuckit, to lazy to deal with permit crap right now\n ActionController::Parameters.permit_all_parameters = true\n\n params[:speed_measurement]\n end",
"def user_params\n params.permit(:name, :age, :username, :display_photo, :password)\n end",
"def get_params\r\n #params.require(:article).permit(:title, :permalink, :content, :source_site, :introtext, :type_id, :order_by, :searchable, :created_by, :edited_by, :published_by, :published_on, :user_id)\r\n params.require(:article).permit!\r\n\r\n end",
"def pub_params\n params.require(:pub).permit(:name, :description, :phone, :email, :hidden, :city_id, :address)\n end",
"def pass_params\n params[:pass].permit(:name, :price, :description, :colour, :events)\n end",
"def droptraining_params\n params.permit(:training_id,:user_id, :utf8, :authenticity_token, :commit)\n end",
"def person_params\n # params whitelist does *not* include admin, sub, remember_token\n # TBD: share this whitelist with the list used by configuration_permitted_parameters\n # TBD: should current_password be on this list? -- for now, leaving off, since it seems to work without\n # NOTE: do not include 'admin' in this list!\n params.require(:person).permit(\n :name, \n :email, \n :description,\n :password, \n :password_confirmation\n )\n end",
"def parameter_params\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\n end"
] |
[
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",
"0.62894756",
"0.6283177",
"0.6242471",
"0.62382483",
"0.6217549",
"0.6214457",
"0.6209053",
"0.6193042",
"0.6177802",
"0.6174604",
"0.61714715",
"0.6161512",
"0.6151757",
"0.6150663",
"0.61461",
"0.61213595",
"0.611406",
"0.6106206",
"0.6105114",
"0.6089039",
"0.6081015",
"0.6071004",
"0.60620916",
"0.6019971",
"0.601788",
"0.6011056",
"0.6010898",
"0.6005122",
"0.6005122",
"0.6001556",
"0.6001049",
"0.59943926",
"0.5992201",
"0.59909594",
"0.5990628",
"0.5980841",
"0.59669393",
"0.59589154",
"0.5958826",
"0.5957911",
"0.5957385",
"0.5953072",
"0.59526145",
"0.5943361",
"0.59386164",
"0.59375334",
"0.59375334",
"0.5933856",
"0.59292704",
"0.59254247",
"0.5924164",
"0.59167904",
"0.59088355",
"0.5907542",
"0.59064597",
"0.5906243",
"0.5898226",
"0.589687",
"0.5896091",
"0.5894501",
"0.5894289",
"0.5891739",
"0.58860534",
"0.5882406",
"0.587974",
"0.58738774",
"0.5869024",
"0.58679986",
"0.5867561",
"0.5865932",
"0.5864461",
"0.58639693",
"0.58617616",
"0.5861436",
"0.5860451",
"0.58602303",
"0.5854586",
"0.58537364",
"0.5850427",
"0.5850199"
] |
0.0
|
-1
|
Generates a random query
|
def random_query
# Use a fake query
# TODO: better random queries
'query ' + (rand*5000).to_i.to_s
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def get_random_quick_queries(types)\n allTypes = types.collect {|type| type.get_quick_queries}.flatten\n prng = Random.new\n random_qq = allTypes.sort {|item1, item2| prng.rand(-1 .. 1) }.slice(0, 5)\n random_qq.collect {|qq| render_quick_query(qq)}\n end",
"def random\n db = ActiveRecord::Base.connection.adapter_name\n if db == 'MySQL'\n find(:first, :order => 'rand()')\n elsif db == 'PostgreSQL'\n find(:first, :order => 'random()') # not efficient because pg fetches all records\n else\n raise \"Getting a random is not supported for #{db}\"\n end\n end",
"def getFirst_i_rand( selection, query, args )\n # Double our args since we are querying twice\n \n args = [ args ] if not args.is_a? Array\n\n nargs = Array.new args\n args.each do |a|\n nargs << a \n end\n\n args = nargs\n \n return( self.getFirst_i( \"SELECT \" + selection + \" FROM \" + query + \" OFFSET floor(RANDOM() * (SELECT count(*) FROM \" + query + \")) LIMIT 1\", args ) )\n end",
"def randomize_query(query)\n if @rand_key.empty?\n return query\n end\n toks = query.split(\" \")\n new_query = \"\"\n toks.each do |token|\n if Keywords[token.downcase] == true\n token << @rand_key\n end\n new_query << token << \" \"\n end\n new_query\n end",
"def random_quote\n quote = @db.get_first_value(\"SELECT quote FROM quotes ORDER BY RANDOM() LIMIT 1;\")\n return quote\n end",
"def sample_question\n get_all_from_database.sample\n end",
"def random_row(table, where)\n @db\n .fetch(\"SELECT * FROM #{table} WHERE #{where} ORDER BY RANDOM() LIMIT 1\")\n .to_a[0]\n end",
"def operand\n rand(1..20)\n end",
"def getFirst_array_rand( selection, query, args )\n # Double our args since we are querying twice\n \n args = [ args ] if not args.is_a? Array\n\n nargs = Array.new args\n args.each do |a|\n nargs << a \n end\n\n args = nargs\n \n r = self.getArray( \"SELECT \" + selection + \" FROM \" + query + \" OFFSET floor(RANDOM() * (SELECT count(*) FROM \" + query + \")) LIMIT 1\", args ) \n \n r = r[0] if r.is_a? Array and r.size == 1\n\n r\n end",
"def get_sample\n if @options.blank?\n model.order('RAND()').first\n else\n if @options.has_key?(\"id\")\n find @options[\"id\"]\n elsif @options.has_key?(\"conditions\")\n model.order('RAND()').where(@options[\"conditions\"]).first\n end\n end\n end",
"def generate_question\n a = rand(11)\n b = rand(11)\n \"#{a} + #{b}\"\nend",
"def random \n # in the off case where a segment doesn't have a full set and we pick an offset \n # that results in a nil response, we just run another query. This is slower than\n # my previous method, in theory, but faster if we assume our db has contiguous sets\n # more often than it does not.\n result = nil\n while result.nil?\n r, i = rand(RANDOM_SEGMENT_SIZE), rand(RANDOM_SEGMENT_SIZE)\n result = where(randomizer: r).skip(i).first\n end\n result\n end",
"def generate_results\n Result.destroy_all\n\n puts 'Generating results'\n\n (MULTIPLIER * 3).times do\n user_id = User.all.sample.id\n question_id = Question.all.sample.id\n result = ['true', 'false'].sample\n Result.create(user_id: user_id, question_id: question_id, result: result)\n end\nend",
"def random_user\n\t\tUser.find([*1..40].sample)\n\tend",
"def build_random_question(params = {})\n # default values\n params[:previous_question] ||= nil\n params[:duration] ||= 600\n\n # build and return the question\n question = Question.generate_random(params.slice(:number_of_goods))\n question.user = self\n question.duration = params[:duration]\n question\n end",
"def random _args\n \"random _args;\" \n end",
"def random_result(id)\n result = settings.db[:cfg_map].where('map_key = ?', id).order(Sequel.lit('rand()')).limit(1)\n sql = result.sql\n result = result.first \n\n logger.debug \"searching for #{id}\"\n if !result\n raise \"Can't find a record for $#{id}\"\n else\n logger.debug \"#{sql} #=> #{result[:map_val]}\"\n result[:map_val]\n end\n end",
"def get_random()\n \n end",
"def get_random()\n \n end",
"def rand_math\n mathphrase(rand(1..20))\nend",
"def gen_query(item, qtype = :document, o = {})\n o[:length] ||= 3\n case qtype\n when :document\n begin\n query = item.get_index().lm.p.sample_pdist(o[:length]).join(' ')\n rescue Exception => e\n error \"Error in query generation\", e\n return nil\n end \n end\n search_result = @ss.search_by_keyword(query, :doc_only=>true, :page=>1, :per_page=>100)\n return nil if !search_result || !search_result[0]\n tgt_item = choose_position(search_result, item.id)\n History.create(:htype=>'query', :basetime=>Time.now, :item_id=>tgt_item, :src_item_id=>item.id, :user_id=>@user_id,\n :game_id=>@game_id, :metadata=>{:query=>query, :rank=>get_search_rank(search_result, item.id)})\n end",
"def make_music isbn, title\n\n music_type = [ 'CD', 'SHEET', 'MP3' ].shuffle.first\n\n %{INSERT INTO music VALUES (\n '#{title}',\n #{isbn},\n '#{music_type}',\n '#{vendors.shuffle.first}',\n '#{genre.shuffle.first}',\n #{rand(23) + 1990},\n #{rand(99) + 50},\n #{rand(50.00) + 5.00},\n #{rand(100)});\n }\nend",
"def query_data_from_db(num_workers, restart)\n restart_cond = restart ? 'WHERE random IS NULL' : ''\n\n connection.exec <<-SQL\n SELECT array_agg(rand.id) FROM (\n SELECT id, id % #{num_workers} AS worker_id\n FROM randoms #{restart_cond}\n ) rand GROUP BY rand.worker_id;\n SQL\n end",
"def random\n if (c = count) != 0\n find(:first, :offset => rand(c))\n end\n end",
"def rand()\n return MicrosoftGraph::Drives::Item::Items::Item::Workbook::Functions::Rand::RandRequestBuilder.new(@path_parameters, @request_adapter)\n end",
"def generate\n expr = \"\"\n expr << rand(self.floor..self.top).to_s\n expr << (SIGNAL[rand(0..1)]).to_s\n expr << (rand(self.floor..self.top)).to_s\n end",
"def rand1\n rand(MAX_PK) + 1\n end",
"def random_arv_numbers(emastercard_db, count)\n emastercard_db[:patient_identifier]\n .order(Sequel.lit('RAND()'))\n .limit(count)\n .select(:patient_id, :identifier)\n .map(%i[patient_id identifier])\nend",
"def generate_query_list\n print_step 'Generating query list'\n\n raise WordsEmpty if @words.blank?\n\n level = 1\n queries = []\n\n while queries.count < (@options[:number] * 10)\n queries += @words.combination(level).to_a.map { |each| each.join(' ') }\n queries = queries.uniq\n level += 1\n end\n\n @queries = queries\n\n self\n end",
"def random_friends\n query = \"\n (SELECT companies.* FROM companies as companies \n JOIN company_relationships as destinies \n ON (companies.id = destinies.company_origin_id and confirmed=true) \n JOIN layouts as layouts\n ON (companies.id = layouts.company_id)\n WHERE (destinies.company_destiny_id=#{self.id.to_s}))\"\n query << \" \n UNION (SELECT companies.* \n FROM companies as companies \n JOIN company_relationships as origins \n ON (companies.id = origins.company_destiny_id and confirmed=true) \n JOIN layouts as layouts\n ON (companies.id = layouts.company_id)\n WHERE (origins.company_origin_id=#{self.id.to_s}))\"\n query << \" order by rand()\"\n Company.paginate_by_sql(query, :page => 1, :per_page => 6)\n end",
"def generate\n (0..30).sort{ rand() } .take(@conf)\n end",
"def random_straight\n name = [\"2\", \"3\", \"4\", \"5\", \"6\"].sample\n straight = []\n straight << Card.where(\"name = ? AND suit = ?\", (name), ([\"♠\", \"♣\", \"♡\", \"♢\"].sample))\n straight << Card.where(\"name = ? AND suit = ?\", ((name.to_i)+1).to_s, ([\"♠\", \"♣\", \"♡\", \"♢\"].sample))\n straight << Card.where(\"name = ? AND suit = ?\", ((name.to_i)+2).to_s, ([\"♠\", \"♣\", \"♡\", \"♢\"].sample))\n straight << Card.where(\"name = ? AND suit = ?\", ((name.to_i)+3).to_s, ([\"♠\", \"♣\", \"♡\", \"♢\"].sample))\n straight << Card.where(\"name = ? AND suit = ?\", ((name.to_i)+4).to_s, ([\"♠\", \"♣\", \"♡\", \"♢\"].sample))\n straight\nend",
"def call_random_server(small, large, count, run_num)\n\tdb = SQLite3::Database.open \"rand_int.db\"\n #call the server and give min and max variables\n\t#call generator (web server)\n\t(0..(count-1)).each do |i| #iterate count # of times\n #t2 = Time.now #end timer 2 \n #response.to_str = the html results on page\n response = RestClient.get 'localhost:4567/random/integer', {:params => {:min =>small, :max => large}} \n #prepare statement is faster than running query every time\n sql = db.prepare(\"INSERT INTO Random(entry, min, max, result) VALUES(#{run_num}, #{small}, #{large}, #{response.to_str} )\")\n #insert into sql table\n sql.execute\n #output the results to terminal\n puts \"response #{i+1}: #{response.to_str}\"\n\tend\n\n #close db connection\n\trescue SQLite3::Exception => e\n\t\tputs \"Exception occured\"\n\t\tputs e\n\n\tensure\n sql.close if sql\n\t\tdb.close if db\n\treturn\nend",
"def peers_random(query={},count=20)\n\t\t\twarn \"Hive plugin must override this!\"\n\t\t\treturn nil\n\t\tend",
"def random_hugs\n huglist_sample = []\n 5.times { huglist_sample.push(Huglist.all.sample[:id]) }\n return huglist_sample.uniq\nend",
"def random_quote\r\n print Scraper.quotes(self.url).sample\r\n end",
"def random\n Client.get(\"/patterns/random\")\n end",
"def randomise\n @random_articles = Article.limit(5).order(\"RANDOM()\")\n @random_users = User.limit(5).order(\"RANDOM()\")\n @random_diarys = Diary.limit(5).order(\"RANDOM()\")\n @random_groups = Group.limit(5).order(\"RANDOM()\")\n end",
"def random \n if params[:random]\n @card = Card.where(:first => params[:random]).sample\n else\n # @card = Card.all.sample\n rand_id = rand(Card.count)\n @card = Card.first(:conditions => ['id >= ?', rand_id])\n end\n\n respond_to do |format|\n format.html #first.html.erb\n format.json { render json: @card }\n end\n end",
"def initial_query; end",
"def random_user_address(user_id)\n Address.where(\"user_id = ?\", user_id).sample[:id]\nend",
"def random\n prompts = PromptDatum.all\n \n num = rand(1...prompts.length)\n\n render json: prompts[num]\n end",
"def base_query\n DataServicesApi::QueryGenerator.new\n end",
"def object_query_generator(data)\n # query header\n query = \"PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>\n PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\n PREFIX owl: <http://www.w3.org/2002/07/owl#>\n PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>\n PREFIX : <http://www.semanticweb.org/simon/ontologies/2016/1/medienprojekt#>\n \n SELECT *\n {\"\n \n # combine the parameters with the query\n data.each {\n |hash| if hash.has_key?(:predicate)\n # its possible to have predicate and object parameters \n query = query << \"?name \" << hash[:predicate] << \" :\" << hash[:object] << \" .\\n\"\n else\n # or just an object parameter\n query = query << \"?name ?predicate :\" << hash[:object] << \" .\\n\"\n end\n }\n\n # query footer\n query = query << \" }\\nLIMIT 400\"\n # return the resulting query\n return query\n end",
"def create_rows_and_query(number_rows, number_query, str_length)\n File.open(\"../benchmark/benchmark_#{number_query}_queries.sql\", 'a+') do |file|\n CSV.open(\"./#{number_rows}_rows_data.csv\", 'a+') do |csv|\n number_rows.times do |time|\n random_str1 = random_str(str_length)\n csv << [time + 1, random_str1]\n file.write(\"select * from test_data where random_str = '#{random_str1}';\") if time < number_query\n end\n end\n end\n puts \"CREATE #{number_rows} ROWS DONE\"\nend",
"def generate_valid_qrda_text\n Random.new.rand(1..4).times do\n measure = HealthDataStandards::CQM::Measure.find_by(_id: measure_ids.sample)\n Document.create(\n name: HOSPITALS.sample,\n expected_result: :accept,\n test_execution: self,\n measure_id: measure.hqmf_id,\n qrda: generate_qrda_text(measure)\n )\n end\n update_qrda_progress\n end",
"def mysql_random_keywords_comment\n def randomizer(string)\n randstr=String.new\n string.scan(/./) do |char|\n chance=rand(2); \n if chance.to_i == 0; \n randstr += char\n else\n randstr += \"/*#{char}*/\"\n end\n end\n return randstr\n end\n\n if self =~ /(select)/i\n foo=$1\n bar=randomizer(foo.to_s)\n newstr = self.gsub(foo, bar)\n else\n newstr = self\n end\n if newstr =~ /(update)/i\n foo=$1\n bar=randomizer(foo.to_s)\n newstr = newstr.gsub!(foo, bar)\n end\n if newstr =~ /(insert)/i\n foo=$1\n bar=randomizer(foo.to_s)\n newstr = newstr.gsub!(foo, bar)\n end\n if newstr =~ /(delete)/i\n foo=$1\n bar=randomizer(foo.to_s)\n newstr = newstr.gsub!(foo, bar)\n end\n if newstr =~ /(union)/i\n foo=$1\n bar=randomizer(foo.to_s)\n newstr = newstr.gsub!(foo, bar)\n end\n if newstr =~ /[, ](concat)/i\n foo=$1\n bar=randomizer(foo.to_s)\n newstr = newstr.gsub!(foo, bar)\n end\n if newstr =~ /(group_concat)/i\n foo=$1\n bar=randomizer(foo.to_s)\n newstr = newstr.gsub!(foo, bar)\n end\n if newstr =~ /(information_schema)/i\n foo=$1\n bar=randomizer(foo.to_s)\n newstr = newstr.gsub!(foo, bar)\n end\n if newstr =~ /(cast)/i\n foo=$1\n bar=randomizer(foo.to_s)\n newstr = newstr.gsub!(foo, bar)\n end\n if newstr =~ /(convert)/i\n foo=$1\n bar=randomizer(foo.to_s)\n newstr = newstr.gsub!(foo, bar)\n end\n if newstr =~ /(substring)/i\n foo=$1\n bar=randomizer(foo.to_s)\n newstr = newstr.gsub!(foo, bar)\n end\n if newstr =~ /(sleep)/i\n foo=$1\n bar=randomizer(foo.to_s)\n newstr = newstr.gsub!(foo, bar)\n end\n if newstr =~ /(benchmark)/i\n foo=$1\n bar=randomizer(foo.to_s)\n newstr = newstr.gsub!(foo, bar)\n end\n return newstr\n end",
"def generate_random_id\n random_id = ''\n 10.times do\n random_id << rand(0..9).to_s\n end\n\n self.msg_id = random_id\n\n #query = \"UPDATE #{self.class.table_name}\n \t#\t\t SET msg_id = #{random_id}\n \t#\t\t WHERE sql_id = #{self.sql_id}\"\n\n #self.class.connection.execute(query)\n end",
"def random\n all[rand(count)]\n end",
"def query; end",
"def generate_random_user_id(db)\r\n # Get all the existing user ids\r\n ids = []\r\n table = db.execute 'select user_id from users;'\r\n table.each do |row|\r\n ids.push row[0]\r\n end\r\n\r\n # Generate a user id that doesn't exist in ids\r\n counter = 0\r\n while counter < 999999 do\r\n val = 1000000 + Random.rand(999999)\r\n unless ids.include? val\r\n return val\r\n end\r\n counter += 1\r\n end\r\nend",
"def next_id!\n\t\t\t# Using sequential numbers for the query ID is generally a bad thing because over UDP they can be spoofed. 16-bits isn't hard to guess either, but over UDP we also use a random port, so this makes effectively 32-bits of entropy to guess per request.\n\t\t\tSecureRandom.random_number(2**16)\n\t\tend",
"def generate(minlen=20)\n if @db.nil?\n return \"database failed to open\"\n end\n\n phrase = [\"\"]*PARTS\n\n until phrase.length - PARTS >= minlen && phrase[-1] == \"\"\n first = phrase.last(PARTS)\n\n row = @count.execute! first.join(\" \")\n if row.empty?\n return \"failed to generate phrase\"\n end\n\n unless row[0][0] > 0\n return \"nothing in database\"\n end\n\n sample = rand(row[0][0])\n row = @fetch.execute! first.join(\" \"), sample\n if row.empty?\n return \"failed to generate phrase\"\n end\n\n nextsym = row[0][0]\n if nextsym == \"\"\n phrase.concat [\"\"]*PARTS\n else\n phrase.push nextsym\n end\n end\n\n return phrase.join(\" \").gsub(/\\s+/, \" \").strip\n end",
"def random_cursor()\n cursor = [\"14\", \"13\"].sample\n cursor += Integer(Random.rand * 10**17).to_s\n return Integer(cursor)\nend",
"def generate_around_site\n return Video.order(\"RAND()\").limit(4)\n end",
"def generate\n game = fetch_game(options[:game])\n game_data = game.get\n\n if game_data[:current_stage] != GameState::QUESTION_OPEN\n log.error \"question is not open.\"\n exit 0\n end\n question_count = game_data[:active_question_max_answer_id] + 1\n\n player_ids = []\n game.collection('players').where('is_active', '==', true).get.each do |player_snapshot|\n player_ids << player_snapshot.document_id\n end\n player_count = player_ids.size\n\n log.info \"#{player_count} active players.\"\n\n previous_second = nil\n sent_this_second = 0\n loop do\n db.transaction do |tx|\n 5.times do\n player_id = player_ids[rand(player_count)]\n game.collection('player_answers').doc(player_id).set({answer_id: rand(question_count)})\n sent_this_second += 1\n end\n end\n\n this_second = Process.clock_gettime(Process::CLOCK_MONOTONIC).to_i\n if this_second != previous_second\n log.info \"sent #{sent_this_second} this second.\"\n sent_this_second = 0\n previous_second = this_second\n end\n end\n end",
"def fake_data_generator(query, output_document)\n ############\n # Removed this, as it is not necessary\n ############\n #uris_hash = Hash.new\n #uris_hash.default_proc = proc {|k| k}\n #File.foreach(query_document_location) {|line|\n # case line\n # when /^PREFIX (\\w+:) (<.+)>/i #if the line starts with PREFIX, find the prefix and its full URI and store them in a hash\n # uris_hash[$1] = $2\n # \n # when /^SELECT|CONSTRUCT|ASK|DESCRIBE/i #This line corresponds to the first line of the final query\n # query = line\n # when /(^\\n|})/\n # query << line\n # else \n # uris_hash.each { |k, v| \n # line[k] &&= v } #changes all occurances of a prefix with the full URI\n # line.match(/(<\\S+)/)\n # line[$1] &&= $1.concat(\">\")\n # line.gsub!(/\\ba\\b/, \"<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>\") #changes \"a\" with the whole URI of rdf:type\n # query << line\n # end\n #}\n \n $stderr.puts query\n parsed = SPARQL.parse(query) # this is a nightmare method, that returns a wide variety of things! LOL!\n \n rdf_query=''\n if parsed.is_a?(RDF::Query) # we need to get the RDF:Query object out of the list of things returned from the parse\n rdf_query = parsed\n else\n parsed.each {|c| rdf_query = c if c.is_a?(RDF::Query) }\n end\n\n patterns = rdf_query.patterns # returns the triple patterns in the query\n\n variables = Hash.new # we're going to create a random string for every variable in the query\n patterns.each do |p| \n vars = p.unbound_variables # vars contains e.g. [:s, #<RDF::Query::Variable:0x6a400(?s)>] \n vars.each {|var| variables[var[0]] = RDF::URI(\"http://fakedata.org/\" + (0...10).map { ('a'..'z').to_a[rand(26)] }.join)}\n # now variables[:s] = <http://fakedata.org/adjdsihfrke>\n end\n\n File.open(output_document, \"w\") {|file|\n #now iterate over the patterns again, and bind them to their new value\n patterns.each do |triple| # we're going to create a random string for every variable\n if triple.subject.variable?\n var_symbol = triple.subject.to_sym # covert the variable into a symbol, since that is our hash key\n triple.subject = variables[var_symbol] # assign the random string for that symbol\n end\n\n if triple.predicate.variable?\n var_symbol = triple.predicate.to_sym # covert the variable into a symbol, since that is our hash key\n triple.predicate = variables[var_symbol] # assign the random string for that symbol\n end\n \n # special case for objects, since they can be literals\n if triple.object.variable?\n var_symbol = triple.object.to_sym # covert the variable into a symbol, since that is our hash key\n triple.object = variables[var_symbol] # assign the random string for that symbol\n file.write triple.to_rdf\n file.write \"\\n\"\n ########\n # What will you do with triples that have a literal as their value, rather than a <URI>?\n ########\n else # this ensures that it is written even if the object is not a variable\n file.write triple.to_rdf\n file.write \"\\n\"\n end\n end\n }\n\nend",
"def get_random(limit)\n pids = []\n if limit == nil || limit.to_i==0\n limit = 50\n end\n\n # this is the object returned \n rec_results = {}\n\n## we want some suggestions\n## we get one from each series and then randomise those\n## gives better results than pure random\n\n si = 767 #distinct series\n arr = limit.times.map{ rand(si) } \n arr = arr.sort_by{ rand }.slice(0...12)\n st = arr.join(\",\")\n\n suggestions = []\n q0 = \"select distinct series_crid from just_series where id in (#{st})\"\n puts q0\n arr = []\n results3 = query(q0)\n results3.each do |r3|\n p = r3[0]\n arr.push(\"'#{p}'\")\n end\n txt = arr.join(\",\")\n\n q = \"select pids.* from pids,series where series.pid=pids.pid and series.series_crid in (#{txt}) group by series_crid\"\n\n puts q\n results4 = query(q)\n results4.each do |r4|\n sugg = {}\n ddtt = r4[6]\n crid = r4[3]\n pid = r4[4]\n pids.push(pid)\n desc = r4[5]\n prog1 = r4[1].to_s\n chan = r4[8]\n ct = r4[9].to_s\n st = r4[10].to_s\n\n text_date = process_date(ddtt)\n\n if(ddtt)\n sugg[\"date_time\"] = ddtt\n end\n if(text_date)\n sugg[\"text_date\"] = text_date\n end\n if(chan)\n sugg[\"channel\"] = chan\n end\n\n sugg[\"core_title\"] = ct.strip\n sugg[\"series_title\"] = st.strip\n sugg[\"pid\"] = pid\n sugg[\"description\"] = desc\n img = \"http://dev.notu.be/2011/04/danbri/crawler/images/#{pid}_512_288.jpg\"\n\n sugg[\"image\"] = img\n\n suggestions.push(sugg)\n\n end\n rec_results[\"suggestions\"]=suggestions\n rec_results[\"title\"]=\"Shuffled\"\n\n return rec_results,pids\nend",
"def genQuestionaire\n #Table \"questions\" from the database through instance variable \"roster\"\n roster=@DB[:questions]\n #Limit for the iterator that will generate the list of questions\n lim=@number-1\n #Space available\n available=[]\n #This iterator stores the whole database in the \"available\" variable\n #in the form of several \"Question\" objects\n (1..40).each do |index|\n #Paramters for the \"Question\" class are set\n #Question text\n q=roster.first(id: index)[:question].to_s\n #Answer a\n a=roster.first(id: index)[:answerA].to_s\n #Answer b\n b=roster.first(id: index)[:answerB].to_s\n #Answer c\n c=roster.first(id: index)[:answerC].to_s\n #Correct answer\n corr=roster.first(id: index)[:correct].to_s\n #Questions are built\n available.push Question.new q, a, b, c, corr\n end\n \n #The \"available\" variable is randomized and stored in the \"scrambled\" variable\n scrambled=available.shuffle\n \n #This iterator takes the number of questions specified by the users and stores \n #them in the final questionaire\n (0..lim).each do |question|\n @questions.push scrambled[question]\n end\n puts \n end",
"def generate_sql(columns)\n [\"SELECT #{columns} FROM #{@from}\", @where, @group, @having, @order, @limit, @offset].join\n end",
"def generate(column, options={})\n options[:values] ||= @options[:values]\n options[:chars] ||= @options[:chars]\n if options[:values]\n options[:values][rand(options[:values].length)]\n else\n s = ''\n chars = (options[:chars] || ('a'..'z').to_a + ('A'..'Z').to_a)\n 0.upto(column.limit - 1) do |n|\n s << chars[rand(chars.length)]\n end\n s\n end\n end",
"def query\n end",
"def random_user_address(user_id)\n address_choices = (Address.select(:id).where(:user_id => user_id)).to_a\n address_choices[0] ? address_choices.sample[:id] : nil\nend",
"def random_movie(db)\r\n\t\tputs \"\\tRandom Movie Generator\"\r\n\t\tputs \" - - Title - - Rating - - Comments - - \"\r\n\t\trandom = db.execute(\"SELECT title, rating, comments FROM movies ORDER BY RANDOM() LIMIT 1\")\r\n\t\trandom.each do |mov|\r\n\t\t\tprintf \" * %-13s| %-4s| %-5s\\n\", \"#{mov['title']}\", \"#{mov['rating']}\", \"#{mov['comments']}\"\r\n\t\tend\r\n\t\tputs\"-\"*60\r\n\tend",
"def get_sample_non_opt_in_client_numbers\n the_max_pbd_id = PolicyBenefitDetails.last.identity\n puts the_max_pbd_id \n min_pbd_identity = the_max_pbd_id - Faker::Number.between(from: 200000, to: 202000)\n max_pbd_identity = the_max_pbd_id - Faker::Number.between(from: 170000, to: 190000)\n \nnon_opt_in_client_query = <<EOM\nSELECT DISTINCT TOP 100 PI.PIz_Client, PI.Num FROM (\n SELECT PIz_Client, MAX(PId_Effective) Num\n FROM Policy_Benefit_Dtls\t\t\t\t\t \n\t\t\t WHERE PIz_Status='CU' AND PIz_Insurance_Cat='CA'\n AND PIz_Benefit_Type='I' AND PIz_Benefit_Feature = 'U'\n\t\t\t AND PIi_Identity > #{min_pbd_identity} AND PIi_Identity < #{max_pbd_identity} \n\t\t\t GROUP BY PIz_Client\n ) AS PI\nWHERE NOT EXISTS (\n SELECT SBz_Client FROM Mbr_Supplementry_Hst AS MSH\n WHERE PI.PIz_Client = MSH.SBz_Client \n AND MSH.SBz_User_Def_Strg02='Y' \n)\nEOM\n puts(\"Query to find a client:\\n\" + non_opt_in_client_query)\n \n results = PolicyBenefitDetails.find_by_sql(non_opt_in_client_query)\n client_numbers = results.pluck(\"PIz_Client\")\n end",
"def pick\n @gommis_count = Gommi.count\n @gommis = Gommi.offset(rand(Gommi.count)).first\nend",
"def fuzz_random(host)\n print_status(\"#{host}:#{rport} fuzzing random messages\")\n 0.upto(5) do\n # TODO: is there a better way to pick this size? Should more than one be tried?\n request = SecureRandom.random_bytes(48)\n what = \"random #{request.size}-byte message\"\n vprint_status(\"#{host}:#{rport} probing with #{what}\")\n responses = probe(host, datastore['RPORT'].to_i, request)\n handle_responses(host, request, responses, what)\n Rex.sleep(sleep_time)\n end\n end",
"def pull_food_from_db\n PlaylistFood.order(\"random()\").first\n end",
"def resultado\n\t\tsalida_dado = rand(1..6)\n\t\tsalida_dado\n\tend",
"def set_random_filters\n change_endpoint(:search)\n\n dd_author = browser.select_list(id: 'author')\n dd_tag = browser.select_list(id: 'tag')\n update_action_log(\n :select_list,\n [\n !dd_author.nil? && dd_author.present? && dd_author.respond_to?(:options),\n !dd_tag.nil? && dd_tag.present? && dd_tag.respond_to?(:options)\n ].all?\n )\n\n dd_author_options = dd_author.options\n update_action_log(:options, dd_author_options.size == 50)\n\n author = dd_author_options[(0..dd_author_options.size).to_a.sample].text\n dd_author.select_value(author)\n update_action_log(:select_value, dd_author.value == author)\n update_action_log(:value, !dd_author.value.empty?)\n\n tag = dd_tag.option(index: (1..dd_tag.options.size - 1).to_a.sample)\n tag.select\n update_action_log(:select, dd_tag.value == tag.text)\n\n browser.button(name: 'submit_button').click\n sleep 2\n update_action_log(:button_click, !page_quotes.to_a.empty?)\n dd_author.value == author && dd_tag.value == tag\n end",
"def querysetstate(s)\n @s = s\n @a = rand(4)\n end",
"def to_sparql(**options)\n distinct = operands.first == :distinct\n args = distinct ? operands[1..-1] : operands\n \"SAMPLE(#{'DISTINCT ' if distinct}#{args.to_sparql(**options)})\"\n end",
"def random(*args); end",
"def index\n @quotecount = Quote.count('id')\n\t\n\tr = Random.new\n\t\n\tif @quotecount > 0\n\t\t@rid = r.rand(0...@quotecount) + 1\n\t\t@quote = Quote.find(@rid)\n\telse\n\t\t@rid = 0\n\tend\n\t\n respond_to do |format|\n format.html # index.html.erb\n end\n end",
"def realistic_random(n, wmin, wmax, pmin, pmax, c, seed)\n str = \"# realistic random -- n: #{n}; wmin: #{wmin}; wmax: #{wmax}; pmin: #{pmin}; pmax: #{pmax}; c: #{c}; seed: #{seed}\\n\"\n str << \"n: #{n}\\nc: #{c}\\n\"\n str << \"begin data\\n\"\n\n rng = Random.new(seed)\n w = (wmin..wmax).to_a.sample(n, random: rng).sort!\n p = (pmin..pmax).to_a.sample(n, random: rng).sort!\n wp = []\n n.times { |i| wp << \"#{w[i]} #{p[i]}\" }\n str << wp.shuffle!(random: rng).join(\"\\n\") << \"\\n\"\n str << \"end data\\n\"\n\n str\nend",
"def tirar_dado\r\n\trand 1..6\r\nend",
"def question_statement(r)\n\tstatement = \" What do you think this one\"\n\tcase r.rand(4).to_i\n\twhen 0\n\t\tstatement << \" is?\"\n\twhen 1\n\t\tstatement << \" means?\"\n\twhen 2\n\t\tstatement << \" wants?\"\n\telse\n\t\tstatement << \" is for?\"\n\tend\n\treturn statement\nend",
"def generate_products\n departments = Department.all\n promo_codes = PromoCode.all\n prng = Random.new\n\n 10_000.times do\n promo_code = promo_codes.first\n\n if prng.rand(1..2) == 1\n promo_code = promo_codes[prng.rand(promo_codes.length)]\n end\n\n Product.create(\n name: Faker::Commerce.unique.product_name,\n price: Faker::Commerce.price,\n department: departments[prng.rand(departments.length)],\n promo_code: promo_code\n )\n end\n# Just in case Faker has less data than I imagine\nrescue Faker::UniqueGenerator::RetryLimitExceeded\nend",
"def generate_non_array_query\n \"SELECT DISTINCT #{self.big_query_id_column} AS id, #{self.big_query_name_column} AS name FROM #{CellMetadatum::BIGQUERY_TABLE}\"\n end",
"def show\n @q = Q.find_by_unique_id(params[:id])\n\n @q_next = Q.offset(rand(Q.count)).first\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @q }\n end\n end",
"def random_skills(skills, count)\n Skill.where(name: skills.sample(count))\nend",
"def random_for(opts)\n connection = opts[:connection]\n adapter_name = connection.adapter_name\n if adapter_name =~ /(sqlite)/i\n random_for_sqlite(opts)\n elsif adapter_name =~ /(postgres|postgis)/i\n random_for_postgres(opts)\n elsif adapter_name =~ /mysql/i\n random_for_mysql(opts)\n else\n raise Exception, \"ActiveRecord adapter: '#{adapter_name}' not supported by randumb. Send a pull request or open a ticket: https://github.com/spilliton/randumb\"\n end\n end",
"def nostalgia; return rand end",
"def recite_random\n number = rand(1..@size)\n return recite(number)\n end",
"def randomkey; end",
"def randomkey; end",
"def random\n 1 + (10 * rand(0))\n end",
"def generate_bq_query_string(accessions: [])\n if is_array_based\n generate_array_query(accessions: accessions)\n elsif is_numeric?\n generate_minmax_query\n else\n generate_non_array_query(accessions: accessions)\n end\n end",
"def run_query(q)\n return sky_table.query(q)\n end",
"def generate_bq_query_string\n if self.is_array_based\n self.generate_array_query\n elsif self.is_numeric?\n self.generate_minmax_query\n else\n self.generate_non_array_query\n end\n end",
"def random_snippet\n create_snippets if snippets_created_at.nil?\n return nil if pending_snippet_count.nil? or pending_snippet_count.zero?\n ids = snippets.pending.map { |snippet| snippet.id }\n random_id = ids[rand(ids.length)]\n snippets.pending.find(random_id)\n end",
"def take(num=1)\n if num > 1\n rows = connection.execute <<-SQL\n SELECT #{columns.join \",\"} FROM #{table}\n ORDER BY random()\n LIMIT #{num};\n SQL\n\n rows_to_array(rows)\n else\n take_one\n end\n end",
"def random\n @shop = Shop.find(params[:shop_id])\n @random = @shop.items.all.sample\n end",
"def random\n active.order(\"RAND()\").first\n end",
"def generate_question\n\n @num1 = rand(1...10)\n @num2 = rand(1...10)\n\n operators = [:*, :+, :- ]\n @op = operators.sample\n @result = @num1.send(@op, @num2).round(2)\n\nend",
"def generate_non_array_query(accessions: [])\n \"SELECT DISTINCT #{big_query_id_column} AS id, #{big_query_name_column} AS name FROM #{CellMetadatum::BIGQUERY_TABLE} \" \\\n \"WHERE #{big_query_id_column} IS NOT NULL #{accessions.any? ? \"AND #{format_accession_list(accessions)} \" : nil}\" \\\n \"ORDER BY LOWER(#{big_query_name_column})\"\n end",
"def random(count: nil, collections: nil, featured: nil, user: nil, query: nil, orientation: nil)\n Unsplash.configuration.logger.warn \"You cannot combine 'collections' and 'query' parameters. 'query' will be ignored.\" if collections && query\n\n params = {\n collections: (collections && collections.join(\",\")),\n featured: featured,\n username: user,\n query: query,\n orientation: orientation\n }.select { |k,v| v }\n if count\n params[:count] = count\n photos = parse_list connection.get(\"/photos/random/\", params).body\n photos.map { |photo|\n photo.user = Unsplash::User.new photo[:user]\n photo\n }\n else\n photo = Unsplash::Photo.new JSON.parse(connection.get(\"/photos/random\", params).body)\n photo.user = Unsplash::User.new photo.user\n photo\n end\n end",
"def rand_choice \n Random.rand(0...6)\n end",
"def randn(n)\n (1..MAX_PK).to_a.shuffle!.take(n)\n end",
"def initialize_random_q_table\n @q_table = Array.new(game.map_size) { Array.new(actions.length) }\n\n game.map_size.times do |s|\n actions.length.times do |a|\n q_table[s][a] = r.rand\n end\n end\n end"
] |
[
"0.67428267",
"0.6579714",
"0.65100694",
"0.6459899",
"0.61614513",
"0.61167294",
"0.59826595",
"0.5957069",
"0.5907958",
"0.58903813",
"0.58845556",
"0.58440024",
"0.58408374",
"0.58172655",
"0.5815573",
"0.580951",
"0.5803809",
"0.5801294",
"0.5801294",
"0.5800222",
"0.5792224",
"0.57879454",
"0.57861555",
"0.57838094",
"0.5771977",
"0.57694733",
"0.5758987",
"0.5757414",
"0.5750465",
"0.57424486",
"0.57289565",
"0.57090884",
"0.56924707",
"0.5683439",
"0.5673441",
"0.56669337",
"0.56630975",
"0.5638566",
"0.5637799",
"0.5631148",
"0.56221884",
"0.56219476",
"0.56194943",
"0.5599994",
"0.55901515",
"0.55883133",
"0.558667",
"0.55784494",
"0.55437785",
"0.5534353",
"0.55227405",
"0.5522571",
"0.552154",
"0.5512639",
"0.55101794",
"0.55011094",
"0.54935294",
"0.54776746",
"0.54723305",
"0.5468167",
"0.5462898",
"0.5459411",
"0.5454928",
"0.54547024",
"0.54540235",
"0.5444387",
"0.5441109",
"0.54408956",
"0.5421528",
"0.5420854",
"0.5414434",
"0.5411873",
"0.5404285",
"0.5403459",
"0.5401801",
"0.5395557",
"0.5388921",
"0.537584",
"0.5375592",
"0.5368377",
"0.5365952",
"0.5354141",
"0.5353682",
"0.53473395",
"0.5338062",
"0.5338062",
"0.5336626",
"0.5336268",
"0.5335585",
"0.5335463",
"0.5334065",
"0.5332116",
"0.53298026",
"0.53210175",
"0.5318268",
"0.53154063",
"0.5304477",
"0.52967674",
"0.52960783",
"0.5294618"
] |
0.8608336
|
0
|
Generates a random (category, action) pair for an event
|
def random_category_action
category = (QuickSearch::Engine::APP_CONFIG['searchers'] + ['spelling-suggestion', 'result-types', 'doi-trap', 'more-options']).sample.dasherize
# Default action is a click
action = 'click'
# Typically, serves only happen for these categories
if category == 'best-bets' || category == 'spelling-suggestion'
action = ['click', 'serve'].sample
end
return category, action
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def random_event\n clear\n center \"Random Event\"\n new_line\n display_event(Event.all.sample)\n wait_and_clear\n end",
"def random_act *acts\n act acts[rand(acts.length)]\n end",
"def generateEventID\n Random.rand(10000)\n end",
"def random_event_by_tag_menu\n clear\n while @input != \"back\"\n center \"Random Event By Tag\"\n new_line\n puts \"What tag would you like to search? \\nType 'list' to get a list of tag names\\nType 'back' to return or 'exit' to quit the program\"\n get_input\n tag = Tag.find_by(name: @input)\n case\n when tag\n display_event(tag.events.sample)\n wait_and_clear\n when @input == \"list\"\n list_tags(tag)\n when @input == 'back'\n clear\n when @input == 'exit'\n exit_program\n else\n puts \"Invalid input\"\n end\n end\n end",
"def event(category, action, label = nil, value = nil, utmni = false, utmhid = random_id)\n check_account_params\n hey(event_params(category, action, label, value, utmni, utmhid))\n end",
"def send_random(event)\n # Parse message parameters\n msg = event.content\n type = parse_type(msg) || Level\n tabs = parse_tabs(msg)\n amount = [msg[/\\d+/].to_i || 1, NUM_ENTRIES].min\n\n # Retrieve list of maps\n maps = tabs.empty? ? type.all : type.where(tab: tabs)\n\n # Format and send response\n if amount > 1\n tabs = format_tabs(tabs)\n type = format_type(type).downcase.pluralize\n event << \"Random selection of #{amount} #{tabs} #{type}:\".squish\n event << format_block(maps.sample(amount).map(&:name).join(\"\\n\"))\n else\n map = maps.sample\n send_screenshot(event, map)\n end\nrescue => e\n lex(e, \"Error getting random sample.\", event: event)\nend",
"def create_random_intent\n intents = []\n sw = @switches.shuffle[0]\n rest = @switches - [sw]\n intents = _create_intent sw, rest, intents\n post_slice intents, true\n end",
"def test05_EventWithCategories\n\t\tlogin $user_1_email, $master_password\n\t\t$browser.goto($patch_new_event)\n\n \t\t$post_event_title.when_present.set(\"Super fun run #{random}\")\n \t\t$post_event_calendar_start_text.when_present.set(\"#{next_year}-07-04\") #make dynamic?\n \t\t$post_event_time_start_field.when_present.click\n \t\t$post_event_select_time.when_present.select(\"8:00 AM\")\n \t\t$post_event_location.when_present.set(\"Location #{random}\")\n \t\t$browser.execute_script(\"jQuery('iframe.wysihtml5-sandbox').contents().find('body').prepend('lava is hot.')\")\n\t\tsleep 4\n\t\t$post_event_type_family.when_present.click\n\t\t$post_event_category_sport.when_present.click\n\t\t$post_now_event.fire_event(\"onclick\")\n\t\tsleep 3\n\t\tassert $post_new_post.exists?\n\t\t#verify details?\n\tend",
"def test03_EventWithCategories\n\t\tlogin $user_1_email, $master_password\n\t\t$browser.goto($patch_new_event)\n\n \t\t$post_event_title.when_present.set(\"Super fun run #{random}\")\n \t\t$post_event_calendar_start_text.when_present.set(\"#{next_year}-11-15\") #make dynamic?\n \t\t$post_event_time_start_field.when_present.click\n \t\t$post_event_select_time.when_present.select(\"8:00 AM\")\n \t\t$post_event_location.when_present.set(\"Location #{random}\")\n \t\t$browser.execute_script(\"jQuery('iframe.wysihtml5-sandbox').contents().find('body').prepend('lava is hot.')\")\n\t\tsleep 4\n\t\t$post_event_type_family.when_present.click\n\t\t$post_now_event.fire_event(\"onclick\")\n\t\tsleep 3\n\t\tassert $post_new_post.exists?\n\t\t#verify details?\n\tend",
"def test04_EventWithCategories\n\t\tlogin $user_1_email, $master_password\n\t\t$browser.goto($patch_new_event)\n\n \t\t$post_event_title.when_present.set(\"Super fun run #{random}\")\n \t\t$post_event_calendar_start_text.when_present.set(\"#{next_year}-12-05\") #make dynamic?\n \t\t$post_event_time_start_field.when_present.click\n \t\t$post_event_select_time.when_present.select(\"8:00 AM\")\n \t\t$post_event_location.when_present.set(\"Location #{random}\")\n \t\t$browser.execute_script(\"jQuery('iframe.wysihtml5-sandbox').contents().find('body').prepend('lava is hot.')\")\n\t\tsleep 4\n\t\t$post_event_category_sport.when_present.click\n\t\t$post_now_event.fire_event(\"onclick\")\n\t\tsleep 3\n\t\tassert $post_new_post.exists?\n\t\t#verify details?\n\tend",
"def create_event_tickets(event)\n # Ensures that the event creator doesn't request to join his own event and no users request twice.\n unused_users = User.all.to_a.reject!{ |u| u == event.user}\n rand(4..6).times do\n ticket = Ticket.new(\n event: event,\n user: unused_users.sample\n )\n unused_users.delete(ticket.user)\n ticket.status = ['pending', 'accepted'].sample\n ticket.save\n end\nend",
"def random_op\n op = rand(1..3)\n case op\n when 1\n 'add'\n when 2\n 'subtract'\n when 3\n 'multiply'\n end\nend",
"def next_event\n return [nil,[]] unless location.feature\n f = location.feature\n @next = self.priority\n begin\n @next = f.next_priority(@next)\n return [nil,nil] unless @next\n @choices, @autos = f.available_events(@next, location, player_character.id)\n end while @autos.size + @choices.size == 0\n \n if @autos.size > 0 && @choices.size > 0\n @pick = rand(@autos.size + @choices.size)\n if @pick < @autos.size\n return @next, @autos[@pick]\n else\n return @next, @choices\n end\n elsif @autos.size > 0\n return @next, @autos[rand(@autos.size).to_i]\n else #@choices.size > 0\n return @next, @choices\n end\n end",
"def event_data(category, action, label = nil, value = nil)\n data = \"5(#{category}*#{action}\" + (label ? \"*#{label})\" : \")\")\n data += \"(#{value})\" if value\n data\n end",
"def add_random_actions(actions)\n \n # Need to add few random actions\n # All the visits will start when the visitor is created\n time = created_at\n \n # The number of actions is random\n nactions = 1 + rand(actions.size)\n \n # The time of the visit is also random, \n times = []\n nactions.times do\n times << time + rand(100).seconds\n end\n \n # Sort the time of each visit\n times.sort!\n \n \n i = 0\n as = []\n nactions.times do\n # Add a random action\n# a = Action.new_random\n self.add_action(actions[rand(nactions)])\n \n # Since the action is added \"now\", it will have the wrong creation time...\n # We are supposing that the visitor was also created with a random time,\n # so all the his visits will be after his \"creation time\"\n # Now let's change the time of this visit\n visit = visits.last\n visit.created_at = times[i] # Change the time of the visit according to times\n visit.save\n i = i + 1\n end\n #Calculate the time spent on the website\n self.first_action_time = visits.first.created_at\n self.last_action_time = visits.last.created_at \n self.time_spent = self.last_action_time - self.first_action_time\n self.save\n\n end",
"def random_rule\n RULES.keys.sample\n end",
"def event_data(category, action, label = nil, value = nil)\n data = \"5(#{category}*#{action}\" + (label ? \"*#{label})\" : \")\")\n data += \"(#{value})\" if value\n data\n end",
"def random_item(category)\n if category == 'best-bets'\n # Sample a random Best Bet type from a static list\n ['webofscience', 'googlescholar', 'ieee', 'pubmed', 'morningstar', 'wgsn', 'standards', 'dissertation', 'refworks', 'ibis', 'proquest',\n 'psychinfo', 'sciencemagazine', 'sciencedirect', 'petition', 'compendex', 'jstor', 'software', 'naturejournal'].sample\n elsif category == 'doi-trap'\n # Sample a random DOI from a static list\n ['10.1080/10510974.2013.797483', '10.1111/j.1468-2958.1996.tb00379.x', 'http://dx.doi.org/10.1063/1.2741534', 'DOI: 10.1007/BF02887151',\n '10.1039/C4RA16247A', '10.1002/sce.3730670213', 'DOI: 10.1007/s40596-014-0241-5', '10.1080/15348423.2012.697437',\n 'http://dx.doi.org/10.3168/jds.S0022-0302(86)80552-5', 'DOI: 10.1023/A:1005204727421', '10.1039/C3TA00019B', 'doi:10.1038/leu.2016.163',\n 'DOI: 10.1007/s10853-013-7374-x', 'doi: 10.1016/0167-2738(91)90233-2', 'doi: 10.1179/000705992798268927', '10.1038/nphys3794',\n 'doi: 10.1149/1.1393288', '10.1080/1554480X.2014.926052', '10.1002/adma.201506234', '10.1080/00958972.2016.1176158'].sample\n elsif category == 'result-types'\n # Use a defined searcher for found types\n (QuickSearch::Engine::APP_CONFIG['searchers']).sample.dasherize\n elsif category == 'more-options'\n # Use a result number for more-options\n ['result-1', 'result-2', 'result-3', 'result-4'].sample\n elsif category == 'spelling-suggestion'\n # Use a fake string\n 'spelling suggestion ' + (rand*200).to_i.to_s\n else\n # Use one of the typical options for a searcher click (or anything else we haven't handled above)\n ['heading', 'result-1', 'result-2', 'result-3', 'see-all-results', 'no-results', 'error'].sample\n end \nend",
"def create_action\n case @a_string\n when \"merge\"\n Helpers::log \"Instanciating Action: #{@a_string}\"\n Run_Picard.new(\"merge\")\n when \"dups\"\n Helpers::log \"Instanciating Action: #{@a_string}\"\n Run_Picard.new(\"dups\")\n when \"cap_dup\"\n Helpers::log \"Instanciating Action: #{@a_string}\"\n Cap_Stats.new(\"cap_dup\")\n when \"cap_nodup\"\n Helpers::log \"Instanciating Action: #{@a_string}\"\n Cap_Stats.new(\"cap_nodup\")\n when \"snps\"\n Helpers::log \"Instanciating Action: #{@a_string}\"\n Call_SNPs.new(\"snps\")\n when \"rg\"\n Helpers::log \"Instanciating Action: #{@a_string}\"\n RG_Fix.new(\"rg\")\n else\n Helpers::log(\"ERROR: cannot find action: #{@a_string}\", 1)\n exit 1\n end\n end",
"def build_analytics_events_payload\n events = []\n 1000.times do\n event = {\n 'timestamp' => Process.clock_gettime(Process::CLOCK_REALTIME),\n 'name' => +'Controller/foo/bar',\n 'type' => +'Transaction',\n 'duration' => rand,\n 'databaseDuration' => rand,\n 'databaseCallCount' => rand,\n 'gcCumulative' => rand,\n 'host' => +'lo-calhost',\n 'color' => +'blue-green',\n 'shape' => +'squarish',\n 'texture' => +'sort of lumpy like a bag of frozen peas'\n }\n events << [event, {}]\n end\n [rand(1000000), events]\n end",
"def create\n concept = (0..3).map { ('A'..'Z').to_a[rand(26)] }.join\n puts concept\n return concept\n end",
"def forecast_future(question, responses)\n random_key = responses.keys[rand(responses.size)]\n puts responses[random_key].sample\nend",
"def acquire_action\n case @event['action']\n when 'create'\n 'error'\n when 'resolve'\n 'success'\n end\n end",
"def create_action\n case @a_string\n when \"update\"\n Helpers::log \"Instanciating Action: #{@a_string}\"\n SEA_update.new\n when \"submit\"\n Helpers::log \"Instanciating Action: #{@a_string}\"\n SEA_submit.new\n when \"validate\"\n SEA_validate.new\n else\n Helpers::log(\"ERROR: cannot find action: #{@a_string}\", 1)\n exit 1\n end\n end",
"def mutate\n @dog_count = rand(2) == 0 ? 1 + rand(6) : dog_count\n @cat_count = rand(2) == 0 ? 1 + rand(85) : cat_count\n @mouse_count = rand(2) == 0 ? 1 + rand(336) : mouse_count\n end",
"def generate_category\n category = Category.new\n category[:name] = Faker::Commerce.department\n category[:description] = Faker::Lorem.sentence\n category.save\nend",
"def food_types(category_name)\n case category_name\n when \"Fruit\"\n Faker::Food.fruit\n when \"Spice\"\n Faker::Food.herb_or_spice\n when \"Ingredient\"\n Faker::Food.ingredient\n when \"Meat\"\n Faker::Food.meat\n when \"Vegetable\"\n Faker::Food.vegetable\n else\n Faker::Product.product\n end\nend",
"def get_rnd_category(id)\n p \"starting #{id}\"\n result = db_connection().execute('SELECT id FROM categories WHERE id NOT IN (SELECT cat_id FROM passwords p JOIN pass_cat pc ON p.id=pc.pass_id JOIN categories c ON pc.cat_id=c.id WHERE p.user_id=?)', id)\n p \"result #{result}\"\n rnd = result.sample\n p rnd\n return rnd[\"id\"].to_i\n end",
"def explore\n roll = rand(100) - depletion\n if roll < 0\n nil\n else\n increment! :depletion\n opportunity_base.generate_event\n end\n end",
"def choice\n rand\n end",
"def operand\n rand(1..20)\n end",
"def generate\n (0..30).sort{ rand() } .take(@conf)\n end",
"def generate_random_color\n COLORS[rand(6)]\n end",
"def random_show\n @category = params[:category]\n if @category == \"morning\"\n @slogans = Slogan.where(\"(category = ?) OR (category = ?)\", '朝', '朝夕')\n elsif params[:category] == \"evening\"\n @slogans = Slogan.where(\"(category = ?) OR (category = ?)\", '夕', '朝夕')\n end\n @slogan = @slogans[rand(@slogans.size)]\n end",
"def event_action_tuple(event)\n params = common_event_params(event)\n params[:_type] = get_event_type(event) if use_event_type?(nil)\n\n if @parent\n if @join_field\n join_value = event.get(@join_field)\n parent_value = event.sprintf(@parent)\n event.set(@join_field, { \"name\" => join_value, \"parent\" => parent_value })\n params[routing_field_name] = event.sprintf(@parent)\n else\n params[:parent] = event.sprintf(@parent)\n end\n end\n\n action = event.sprintf(@action || 'index')\n raise UnsupportedActionError, action unless VALID_HTTP_ACTIONS.include?(action)\n\n if action == 'update'\n params[:_upsert] = LogStash::Json.load(event.sprintf(@upsert)) if @upsert != \"\"\n params[:_script] = event.sprintf(@script) if @script != \"\"\n params[retry_on_conflict_action_name] = @retry_on_conflict\n end\n\n params[:version] = event.sprintf(@version) if @version\n params[:version_type] = event.sprintf(@version_type) if @version_type\n\n EventActionTuple.new(action, params, event)\n end",
"def title\n \"#{event.kind} #{action}\"\n end",
"def generate_question\n a = rand(11)\n b = rand(11)\n \"#{a} + #{b}\"\nend",
"def random_merchant_category\r\n array_merch_catg = [5732, 5944, 4829, 5678, 2314, 9487]\r\n merch_catg = array_merch_catg.sample\r\n return merch_catg\r\n end",
"def rand_interactable_unit\n class_sym = interactable_units.shuffle.first\n Units.const_get(class_sym).new\nend",
"def make_new_event\n event = Hash.new\n event[:event_game_type] = 2 # 1=Pairs, 2=Teams.\n event\nend",
"def getRandomColor()\n num = Random.rand(1..6)\n if num == 1 then return :red\n elsif num == 2 then return :blue\n elsif num == 3 then return :green\n elsif num == 4 then return :yellow\n elsif num == 5 then return :cyan\n elsif num == 6 then return :magenta\n end\nend",
"def create\r\n\r\n @event = Event.new(event_params)\r\n \r\n if(@event.category_id == nil)\r\n @event.category_id = 1\r\n end\r\n\r\n respond_to do |format|\r\n if @event.save\r\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\r\n format.json { render :show, status: :created, location: @event }\r\n else\r\n format.html { render :new }\r\n format.json { render json: @event.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def create_awe_test_for(category)\n awe_priority_test = nil\n \n #puts 'CREATE TEST'\n\n if category[:target_priorities][:test_type] == :no_test # NO TEST\n \n #puts 'CREATE NO TEST'\n \n awe_priority_test = Battle::NoTest.new\n category[:target_priorities][:results][0].each do | target |\n awe_priority_test.pushCategoryToPriority(target)\n end\n \n elsif category[:target_priorities][:test_type] == :line_size_test # LINE SIZE TEST\n \n #puts 'CREATE LINE SIZE TEST'\n \n awe_priority_test = Battle::LineSizeTest.new(category[:target_priorities][:test_category])\n category[:target_priorities][:results][0].each do | target |\n awe_priority_test.pushCategoryToPriorityOnSuccess(target)\n end \n category[:target_priorities][:results][1].each do | target |\n awe_priority_test.pushCategoryToPriorityOnFail(target)\n end \n end\n \n awe_priority_test\n end",
"def pick_food()\n if block_given?\n # Can be used to simulate experiences?\n yield @qvalues\n else\n # Default food behavior\n r = rand()\n\n # NOTE: N% of the time pick randomly (after exploration)\n if r < @epsilon or @days_lived < @exploration\n WELLS.keys.sample\n else\n @qvalues.max_by { |k, v| v }[0]\n end\n end\n end",
"def game_action(num)\n\t\t\t\n\t\t\tnet_ball = rand(5..15)\n\t\t\treturn \"net\" if num == net_ball\n\t\t\treturn \"oob\" if num <= 3\n\t\t\treturn \"hit\" if num > 3 && num <=17\n\t\t\treturn \"miss\" if num > 17\n\t\tend",
"def make_actions(events, index, height)\n events.each_cons(2).map do |event, next_event|\n Action.new(\n state: event.state,\n start: Time.at(event.stamp),\n x: event.offset,\n y: (index + 1) * height,\n width: next_event.stamp - event.stamp,\n height: height\n )\n end\nend",
"def event\n @event ||= Hyrax::Event.create( action, Time.current.to_i )\n end",
"def set_counter_action(current)\n if current['type'] == 1 and current['id'].is_a?(Array)\n available_skills = []\n for skill_id in current\n available_skills << skill_id if skill_can_use?(skill_id) or not current['cost']\n end\n action = available_skills[rand(available_skills.size)]\n elsif current['type'] == 2 and current['id'].is_a?(Array)\n available_skills = []\n for item_id in current\n available_skills << skill_id if $game_party.item_can_use?(item_id) or not\n current['cost'] or not self.actor?\n end\n action = available_skills[rand(available_skills.size)]\n else\n action = current['id']\n end\n return current.dup\n end",
"def escape\n choices = @animals.keys\n @animals[choices[rand(choices.length)]]\n end",
"def generate_fighter(name, initial_health, type)\n if type == \"Runner\"\n Fighter.new(name, initial_health, rand(200..300), rand(20..50))\n elsif type == \"Viking\"\n Fighter.new(name, initial_health, rand(1..50), rand(50..100))\n else\n puts \"check fighter type...\"\n end\nend",
"def generate_product\n p = Product.new\n p[:name] = Faker::Commerce.product_name\n p[:category_id] = Category.pluck(:id).sample\n p[:description] = Faker::Lorem.sentence\n p[:sku] = Faker::Code.ean\n p[:price] = random_price\n p.save\nend",
"def gen_color()\n random = Random.new\n\n colorname = Array.new(9)\n colorname = [ 'red', 'blue', 'lightblue', 'pink', 'gold', 'white', 'yellow', 'green', 'lightgreen', 'orange', 'grey', 'black' ]\n\n return colorname[random.rand(9)]\nend",
"def meow()\n punctuations = '.!?'\n \"#{CAT_FACES[rand(CAT_FACES.length)]} Meow#{punctuations[rand(punctuations.length)]}\"\n end",
"def event_template # rubocop:disable Metrics/MethodLength\n one_second_ago = epoch - 1\n {\n id: ::SecureRandom.uuid,\n client: client_template,\n check: check_template,\n last_ok: one_second_ago,\n last_state_change: one_second_ago,\n occurrences: 1,\n occurrences_watermark: 1,\n action: :create\n }\n end",
"def random(string)\n random_key = @colours.keys.sample\n\n self.send(random_key, string)\n end",
"def do_stuff more_actions=[], num_actions=5\n actions = []\n num_actions.times do\n actions.push ((['move', 'eat', 'nap'] + more_actions).sample)\n end\n actions.each do |action|\n m = method action\n m.call\n end\n puts \"#{@name} is done doing stuff!\"\n end",
"def randomkey; end",
"def randomkey; end",
"def random_role\n ['admin', 'player'].sample\n end",
"def random\n CYCLE * rand\nend",
"def generate_random_characteristic\n self.characteristic = Faker::Lorem.sentences(Random.rand(1..50)).join if Random.rand(9).even?\n end",
"def by_action(events)\n return events unless Event::ACTIONS[params[:action]]\n\n events.where(action: Event::ACTIONS[params[:action]])\n end",
"def create_event(id, category, text, extras)\n event = {}\n event['id'] = id\n event['ctime'] = Time.now.to_i * 1000\n event['category'] = category\n event['text'] = text\n event.merge!(extras) { |_key, v1, _v2| v1 }\n\n http_post('/events', event)\n end",
"def pick_actor\n ACTOR.sample\nend",
"def create\n @event_category = EventCategory.new(event_category_params)\n @event_category.event = @event\n\n respond_to do |format|\n if @event_category.save\n format.html { redirect_to convention_setup_event_event_categories_path(@event), notice: 'Event Category was successfully created.' }\n else\n load_categories\n format.html { render action: \"index\" }\n end\n end\n end",
"def random_item(electives)\n electives[rand(electives.length)]\nend",
"def random_animal\n\t animals.sample\n end",
"def gentest; catdet.button(:name, 'testEvent'); end",
"def create_event(user)\n event = Event.new(\n title: \"#{Faker::Food.dish} with friends\",\n description: \"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.\",\n datetime: rand(Time.zone.now .. 4.days.from_now),\n venue: Faker::Restaurant.name,\n capacity: rand(2..8),\n category: Faker::Restaurant.type,\n )\n file = URI.open(\"https://source.unsplash.com/1600x900/?japanese/food&#{rand(10000)}\")\n event.photo.attach(io: file, filename: \"#{event.title}.png\", content_type: 'image/png')\n event.end_time = event.datetime + rand(1..3).hours\n event.user = user\n event.save\nend",
"def category_actions\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 10 )\n array = nil\n act = nil\n next_act = nil\n # - - - - @init action - - - -\n array = Array.new\n\n begin\n # at line 84:10: ';' ( WS )? 'actions' '=' '\\\"' act= action_location ( ( WS )? next_act= action_location )* '\\\"'\n match(T__11, TOKENS_FOLLOWING_T__11_IN_category_actions_441)\n # at line 84:14: ( WS )?\n alt_16 = 2\n look_16_0 = @input.peek(1)\n\n if (look_16_0 == WS)\n alt_16 = 1\n end\n case alt_16\n when 1\n # at line 84:14: WS\n match(WS, TOKENS_FOLLOWING_WS_IN_category_actions_443)\n\n end\n match(T__20, TOKENS_FOLLOWING_T__20_IN_category_actions_446)\n match(T__13, TOKENS_FOLLOWING_T__13_IN_category_actions_448)\n match(T__14, TOKENS_FOLLOWING_T__14_IN_category_actions_450)\n @state.following.push(TOKENS_FOLLOWING_action_location_IN_category_actions_454)\n act = action_location\n @state.following.pop\n # --> action\n array << (act && @input.to_s(act.start, act.stop))\n # <-- action\n # at line 85:10: ( ( WS )? next_act= action_location )*\n while true # decision 18\n alt_18 = 2\n look_18_0 = @input.peek(1)\n\n if (look_18_0.between?(WS, DIGIT) || look_18_0 == T__10 || look_18_0 == T__13 || look_18_0.between?(T__28, T__42))\n alt_18 = 1\n\n end\n case alt_18\n when 1\n # at line 85:12: ( WS )? next_act= action_location\n # at line 85:12: ( WS )?\n alt_17 = 2\n look_17_0 = @input.peek(1)\n\n if (look_17_0 == WS)\n alt_17 = 1\n end\n case alt_17\n when 1\n # at line 85:12: WS\n match(WS, TOKENS_FOLLOWING_WS_IN_category_actions_470)\n\n end\n @state.following.push(TOKENS_FOLLOWING_action_location_IN_category_actions_475)\n next_act = action_location\n @state.following.pop\n # --> action\n array << (next_act && @input.to_s(next_act.start, next_act.stop))\n # <-- action\n\n else\n break # out of loop for decision 18\n end\n end # loop for decision 18\n match(T__14, TOKENS_FOLLOWING_T__14_IN_category_actions_482)\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__, 10 )\n\n end\n\n return array\n end",
"def pick\n rand = Random.new\n index = rand.rand(0...@emotions.length)\n @emotions[index]\n end",
"def create_event(action, todo, meta={})\n Event.create(\n user_id: todo.creator_id,\n action: action,\n target: todo,\n project_id: todo.project_id,\n meta: meta,\n )\n end",
"def category(num=(0...round.categories.count).to_a.sample)\n round.categories[num]\n end",
"def get_random_artist()\n today = Time.now.strftime('%Y-%m-%d')\n\n randArtist = Artist.find_by(id: rand(Artist.count))\n while randArtist == nil || randArtist.events.where('date >= ?', today).length < 20 do\n randArtist = Artist.find_by(id: rand(Artist.count))\n end\n return randArtist\n end",
"def generate(project, user_id)\n timestamp = DateTime.iso8601(\"2000-01-01T00:00:00Z\")\n\n events.each do |event|\n bounce_rate = event[\"bounce_rate\"] || 0.0\n traits = event[\"traits\"] || {}\n properties = event[\"properties\"] || {}\n properties[\"channel\"] = event[\"channel\"] if event.has_key?(\"channel\")\n properties[\"resource\"] = event[\"resource\"] if event.has_key?(\"resource\")\n properties[\"action\"] = event[\"action\"] if event.has_key?(\"action\")\n\n # Randomly determine the duration.\n min_duration, max_duration = *event[\"duration\"]\n duration = min_duration + ((max_duration - min_duration) * rand)\n\n # Track the event.\n project.track(user_id, traits, properties, timestamp:timestamp)\n\n # Increment the timestamp.\n timestamp = timestamp + duration.seconds\n\n # Exit based on the bounce rate.\n return if rand() < bounce_rate\n end\n end",
"def random_face_emoji\n %w[cool goofy monocle sly smile think].sample\n end",
"def random_skill\n rand(70..90)\nend",
"def generate_random_trade_items(bonus_rate = 0, categories = [])\n rate = ShopsSettings::TRADE_REFLOW_RATE + bonus_rate\n items = []\n trade_flow.each { |ary|\n next if ary[1] == 1 and !categories.include?(:items)\n next if ary[1] == 2 and !categories.include?(:weapons)\n next if ary[1] == 3 and !categories.include?(:armors)\n if rand(100) <= rate\n arx = [ary[0], ary[1], 1]\n items.push(arx)\n ary[2] -= 1\n trade_flow.delete(ary) if ary[2] <= 0\n end\n }\n items\n end",
"def random_type; end",
"def gcmake_event\n Event.create :user_id => self.user_id, :gamecall_tag => self.id, :installgc_event_id => self.event_id, :title => self.title, :start_time => self.start_time, :end_time => self.end_time, :event_type => \"Gamecall\"\n end",
"def category_scores(event)\n probabilities = {}\n categories.each do |cat|\n probabilities[cat] = event_probability(event, cat)\n end\n probabilities.map { |k, v| [k, v] }\n end",
"def create_random_name\n String.new(Faker::Games::ElderScrolls.creature)\n end",
"def random _args\n \"random _args;\" \n end",
"def randomize\n @dog_count = rand(6) + 1;\n @cat_count = rand(85) + 1;\n @mouse_count = rand(336) + 1;\n return self\n end",
"def random_colors\n colors = [\"blue\",\"red\",\"green\",\"black\",\"yellow\",\"pink\",\"white\",\"grey\"]\n color = colors[rand(colors.length)]\nend",
"def group_creator\n group = Random.new.rand(1..3)\n return group\nend",
"def determine_category_from_event_type(event_type_code)\n return nil if event_type_code.blank?\n case event_type_code\n when Event.household_enumeration_code\n NcsCode.for_list_name_and_local_code('EVENT_DSPSTN_CAT_CL1', 1)\n when Event.pregnancy_screener_code\n NcsCode.for_list_name_and_local_code('EVENT_DSPSTN_CAT_CL1', 2)\n when Event.provider_recruitment_code\n NcsCode.for_list_name_and_local_code('EVENT_DSPSTN_CAT_CL1', 7)\n when Event.pbs_eligibility_screener_code\n NcsCode.for_list_name_and_local_code('EVENT_DSPSTN_CAT_CL1', 8)\n else\n nil\n end\n end",
"def randomly( word )\n send( [ :point, :delete, :insert ].random, word )\n end",
"def eat_milk_and_cookies\n if Random.rand(5) == 0\n p \"MMMMM #{@name} just ate an Chocolatechip Cookie\"\n elsif Random.rand(5)== 1\n p \"MMMMM #{@name} just ate an Snickerdoodle Cookie\"\n elsif Random.rand(5) == 2\n p \"MMMMM #{@name} just ate an Oreo Cookie\"\n elsif Random.rand(5) == 3\n p \"MMMMM #{@name} just ate an Sugar Cookie\"\n else\n p \"MMMMM #{@name} just ate an Almond Cookie\"\n end\n end",
"def events(count = 1, options = {}, recurring = false)\n count.times do\n attributes = { name: Faker::Lorem.word,\n location: Location.all.sample,\n category_id: Category.where(name: REG).first.id, \n adm: 20+Random.rand(11),\n start_dt: Faker::Time.between(Time.now, 180.days.from_now, :night), \n description: Faker::Lorem.paragraph(2),\n photo: Faker::Avatar.image }.merge(options)\n event = Event.new(attributes)\n event.save\n if recurring\n event.update_attributes(listed_type: OCCURRENCE.sample,\n listed_day: DAYNAMES.sample,\n listed_month: MONTHNAMES.sample,\n category: Category.where.not(name: REG).sample)\n end\n \n end\n self.report.increment(:events, count)\n end",
"def create_specific_event(user:, title:, venue:, category:, number:, datetime:)\n event = Event.new(\n title: title,\n description: \"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.\",\n datetime: datetime,\n venue: venue,\n capacity: 5,\n category: category,\n )\n url = \"app/assets/images/dine_#{number}.jpg\"\n file = File.open(url)\n event.photo.attach(io: file, filename: \"#{event.title}.png\", content_type: 'image/png')\n event.end_time = event.datetime + rand(1..3).hours\n event.user = user\n event.save\nend",
"def call(context, *args)\n case args.size\n when 1\n context.random.rand(args.first)\n when 2\n context.random.rand(args.first...args.last)\n else\n raise Exceptions::InvalidFunctionError.new\n end\n end",
"def set_event\n @category = Category.find(params[:id])\n end",
"def cointoss\n\t\t\tnumber = rand(1..10)\n\t\t\t\treturn \"heads\" if number <= 5\n\t\t\t\treturn \"tails\" if number > 5\n\t\tend",
"def get_event_name\n \"(#{event_order}) #{event_type.i18n_short} #{get_category_type_code} #{gender_type.i18n_short}\"\n end",
"def generate\n expr = \"\"\n expr << rand(self.floor..self.top).to_s\n expr << (SIGNAL[rand(0..1)]).to_s\n expr << (rand(self.floor..self.top)).to_s\n end",
"def random_character\n random_class = Character.const_get(character_classes[rand(character_classes.length)])\n random_class.new\n end",
"def event!(category_name, event_name, additional_properties = { })\n event_data = effective_properties(category_name, event_name, additional_properties)\n event_data[:properties] = { 'time' => Time.now.to_i }.merge(event_data[:properties])\n\n self.event_receivers.each do |receiver|\n receiver.track(event_data[:distinct_id], event_data[:external_name], event_data[:properties])\n end\n end",
"def to_s\n \"<Event #{name.inspect} of #{category}>\"\n end",
"def random(tg,faulty,replacements,n)\n get_mappings(faulty,replacements).sample\nend"
] |
[
"0.63106525",
"0.5994892",
"0.59504735",
"0.57473546",
"0.57009965",
"0.5692117",
"0.561502",
"0.5579096",
"0.5573902",
"0.5560656",
"0.5553878",
"0.55440325",
"0.5471812",
"0.5457403",
"0.5446332",
"0.5434204",
"0.54228395",
"0.531166",
"0.5303271",
"0.5282809",
"0.5277814",
"0.5258584",
"0.5230797",
"0.51638246",
"0.516175",
"0.5140812",
"0.51363087",
"0.5124019",
"0.51194334",
"0.5081608",
"0.5066308",
"0.50589347",
"0.50551033",
"0.5054439",
"0.50503",
"0.50338995",
"0.5008939",
"0.50086653",
"0.5003418",
"0.5001825",
"0.49970597",
"0.49861714",
"0.4972515",
"0.49634692",
"0.4958184",
"0.4948526",
"0.49335223",
"0.49295256",
"0.49289587",
"0.49287322",
"0.49260008",
"0.4913777",
"0.4899201",
"0.4888724",
"0.48885697",
"0.48876962",
"0.48868445",
"0.48868445",
"0.48866808",
"0.4885608",
"0.48838603",
"0.48792362",
"0.48753744",
"0.48732522",
"0.4867343",
"0.48593625",
"0.48493385",
"0.4846866",
"0.48455855",
"0.48307806",
"0.48249474",
"0.48162374",
"0.4809334",
"0.48080876",
"0.48070988",
"0.48051035",
"0.48015317",
"0.47992086",
"0.47975022",
"0.47960198",
"0.47872463",
"0.4785015",
"0.47815233",
"0.47807986",
"0.47796842",
"0.47601956",
"0.47568175",
"0.4744991",
"0.4744251",
"0.47436947",
"0.47432646",
"0.4741073",
"0.47348583",
"0.4734009",
"0.47328356",
"0.47286823",
"0.47176477",
"0.4712161",
"0.47114322",
"0.47107595"
] |
0.7117247
|
0
|
Generates a random item for an event, based on the category
|
def random_item(category)
if category == 'best-bets'
# Sample a random Best Bet type from a static list
['webofscience', 'googlescholar', 'ieee', 'pubmed', 'morningstar', 'wgsn', 'standards', 'dissertation', 'refworks', 'ibis', 'proquest',
'psychinfo', 'sciencemagazine', 'sciencedirect', 'petition', 'compendex', 'jstor', 'software', 'naturejournal'].sample
elsif category == 'doi-trap'
# Sample a random DOI from a static list
['10.1080/10510974.2013.797483', '10.1111/j.1468-2958.1996.tb00379.x', 'http://dx.doi.org/10.1063/1.2741534', 'DOI: 10.1007/BF02887151',
'10.1039/C4RA16247A', '10.1002/sce.3730670213', 'DOI: 10.1007/s40596-014-0241-5', '10.1080/15348423.2012.697437',
'http://dx.doi.org/10.3168/jds.S0022-0302(86)80552-5', 'DOI: 10.1023/A:1005204727421', '10.1039/C3TA00019B', 'doi:10.1038/leu.2016.163',
'DOI: 10.1007/s10853-013-7374-x', 'doi: 10.1016/0167-2738(91)90233-2', 'doi: 10.1179/000705992798268927', '10.1038/nphys3794',
'doi: 10.1149/1.1393288', '10.1080/1554480X.2014.926052', '10.1002/adma.201506234', '10.1080/00958972.2016.1176158'].sample
elsif category == 'result-types'
# Use a defined searcher for found types
(QuickSearch::Engine::APP_CONFIG['searchers']).sample.dasherize
elsif category == 'more-options'
# Use a result number for more-options
['result-1', 'result-2', 'result-3', 'result-4'].sample
elsif category == 'spelling-suggestion'
# Use a fake string
'spelling suggestion ' + (rand*200).to_i.to_s
else
# Use one of the typical options for a searcher click (or anything else we haven't handled above)
['heading', 'result-1', 'result-2', 'result-3', 'see-all-results', 'no-results', 'error'].sample
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def random_item\n items.to_a.sample\n end",
"def random_item\n return @items[rand(@items.length)]\n end",
"def random_event\n clear\n center \"Random Event\"\n new_line\n display_event(Event.all.sample)\n wait_and_clear\n end",
"def random_item(electives)\n electives[rand(electives.length)]\nend",
"def test_item\n 20.times do |i|\n new_item = Item.new\n new_item.title = Faker::Name.name\n new_item.description = Faker::Lorem.paragraph(8)\n new_item.price = Faker::Number.decimal(2)\n new_item.image_url = Faker::Avatar.image\n # temporaly, add item to first category\n new_item.category_id = Category.first.id\n new_item.save\n end\nend",
"def random_category_action\n category = (QuickSearch::Engine::APP_CONFIG['searchers'] + ['spelling-suggestion', 'result-types', 'doi-trap', 'more-options']).sample.dasherize\n # Default action is a click\n action = 'click'\n\n # Typically, serves only happen for these categories\n if category == 'best-bets' || category == 'spelling-suggestion'\n action = ['click', 'serve'].sample\n end\n\n return category, action\nend",
"def populate_items\n return if @items.size >= 15\n\n type = rand\n if type < 0.010\n @items.push(Goody.new(:apple))\n elsif type < 0.040\n @items.push(Goody.new(:merde))\n end\n end",
"def generate_product\n p = Product.new\n p[:name] = Faker::Commerce.product_name\n p[:category_id] = Category.pluck(:id).sample\n p[:description] = Faker::Lorem.sentence\n p[:sku] = Faker::Code.ean\n p[:price] = random_price\n p.save\nend",
"def food_types(category_name)\n case category_name\n when \"Fruit\"\n Faker::Food.fruit\n when \"Spice\"\n Faker::Food.herb_or_spice\n when \"Ingredient\"\n Faker::Food.ingredient\n when \"Meat\"\n Faker::Food.meat\n when \"Vegetable\"\n Faker::Food.vegetable\n else\n Faker::Product.product\n end\nend",
"def generate_category\n category = Category.new\n category[:name] = Faker::Commerce.department\n category[:description] = Faker::Lorem.sentence\n category.save\nend",
"def generate_random_trade_items(bonus_rate = 0, categories = [])\n rate = ShopsSettings::TRADE_REFLOW_RATE + bonus_rate\n items = []\n trade_flow.each { |ary|\n next if ary[1] == 1 and !categories.include?(:items)\n next if ary[1] == 2 and !categories.include?(:weapons)\n next if ary[1] == 3 and !categories.include?(:armors)\n if rand(100) <= rate\n arx = [ary[0], ary[1], 1]\n items.push(arx)\n ary[2] -= 1\n trade_flow.delete(ary) if ary[2] <= 0\n end\n }\n items\n end",
"def random_animal\n\t animals.sample\n end",
"def find_random_item(sample:, object_type:)\n raise ItemActionError, 'Sample is nil' unless sample.present?\n\n raise ItemActionError, 'Object type is nil' unless object_type.present?\n\n ot = object_type.is_a?(ObjectType) ? object_type : ObjectType.find_by_name(object_type)\n\n unless ot.is_a? ObjectType\n raise ItemActionError, \"Object Type is Nil #{object_type}\"\n end\n\n ite = Item.where(sample_id: sample.id,\n object_type: ot).last\n\n return ite if ite.present?\n\n raise ItemActionError, \"Item Not found sample: #{sample.id}, ot: #{ot.name}\"\n end",
"def choose_item_and_on_whom(enemy)\n C[@inventory.random_item, [self, enemy].sample]\n end",
"def random_merchant_category\r\n array_merch_catg = [5732, 5944, 4829, 5678, 2314, 9487]\r\n merch_catg = array_merch_catg.sample\r\n return merch_catg\r\n end",
"def send_random(event)\n # Parse message parameters\n msg = event.content\n type = parse_type(msg) || Level\n tabs = parse_tabs(msg)\n amount = [msg[/\\d+/].to_i || 1, NUM_ENTRIES].min\n\n # Retrieve list of maps\n maps = tabs.empty? ? type.all : type.where(tab: tabs)\n\n # Format and send response\n if amount > 1\n tabs = format_tabs(tabs)\n type = format_type(type).downcase.pluralize\n event << \"Random selection of #{amount} #{tabs} #{type}:\".squish\n event << format_block(maps.sample(amount).map(&:name).join(\"\\n\"))\n else\n map = maps.sample\n send_screenshot(event, map)\n end\nrescue => e\n lex(e, \"Error getting random sample.\", event: event)\nend",
"def pick_food()\n if block_given?\n # Can be used to simulate experiences?\n yield @qvalues\n else\n # Default food behavior\n r = rand()\n\n # NOTE: N% of the time pick randomly (after exploration)\n if r < @epsilon or @days_lived < @exploration\n WELLS.keys.sample\n else\n @qvalues.max_by { |k, v| v }[0]\n end\n end\n end",
"def get_random_artist()\n today = Time.now.strftime('%Y-%m-%d')\n\n randArtist = Artist.find_by(id: rand(Artist.count))\n while randArtist == nil || randArtist.events.where('date >= ?', today).length < 20 do\n randArtist = Artist.find_by(id: rand(Artist.count))\n end\n return randArtist\n end",
"def random_event_by_tag_menu\n clear\n while @input != \"back\"\n center \"Random Event By Tag\"\n new_line\n puts \"What tag would you like to search? \\nType 'list' to get a list of tag names\\nType 'back' to return or 'exit' to quit the program\"\n get_input\n tag = Tag.find_by(name: @input)\n case\n when tag\n display_event(tag.events.sample)\n wait_and_clear\n when @input == \"list\"\n list_tags(tag)\n when @input == 'back'\n clear\n when @input == 'exit'\n exit_program\n else\n puts \"Invalid input\"\n end\n end\n end",
"def generateEventID\n Random.rand(10000)\n end",
"def generate_item(item)\n item\n end",
"def random_hugs\n huglist_sample = []\n 5.times { huglist_sample.push(Huglist.all.sample[:id]) }\n return huglist_sample.uniq\nend",
"def get_rnd_category(id)\n p \"starting #{id}\"\n result = db_connection().execute('SELECT id FROM categories WHERE id NOT IN (SELECT cat_id FROM passwords p JOIN pass_cat pc ON p.id=pc.pass_id JOIN categories c ON pc.cat_id=c.id WHERE p.user_id=?)', id)\n p \"result #{result}\"\n rnd = result.sample\n p rnd\n return rnd[\"id\"].to_i\n end",
"def rand_one(item_type)\n\t\t\tnum = rand(1..MAX_RATE)\n\n\t\t\tconst(item_type.to_i).each do |key, val|\n\t\t\t\tif num.in?(key)\n\t\t\t\t\treturn val\n\t\t\t\tend\n\t\t\tend\n\t\tend",
"def choose_item_and_on_whom(enemy)\n item = @inventory[Random.rand(@inventory.length)].first\n whom = [self, enemy].sample\n return C[item, whom]\n end",
"def pull_food_from_db\n PlaylistFood.order(\"random()\").first\n end",
"def create_random_name\n String.new(Faker::Games::ElderScrolls.creature)\n end",
"def create_event_tickets(event)\n # Ensures that the event creator doesn't request to join his own event and no users request twice.\n unused_users = User.all.to_a.reject!{ |u| u == event.user}\n rand(4..6).times do\n ticket = Ticket.new(\n event: event,\n user: unused_users.sample\n )\n unused_users.delete(ticket.user)\n ticket.status = ['pending', 'accepted'].sample\n ticket.save\n end\nend",
"def skill_key\n return item_in_use.seq_key[rand(item_in_use.seq_key.size)]\n end",
"def skill_key\n return item_in_use.seq_key[rand(item_in_use.seq_key.size)]\n end",
"def roll\n roll = [1,2,3,4,5,6]\nitem = roll[rand(roll.length)]\nend",
"def rand_interactable_unit\n class_sym = interactable_units.shuffle.first\n Units.const_get(class_sym).new\nend",
"def create_event(user)\n event = Event.new(\n title: \"#{Faker::Food.dish} with friends\",\n description: \"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.\",\n datetime: rand(Time.zone.now .. 4.days.from_now),\n venue: Faker::Restaurant.name,\n capacity: rand(2..8),\n category: Faker::Restaurant.type,\n )\n file = URI.open(\"https://source.unsplash.com/1600x900/?japanese/food&#{rand(10000)}\")\n event.photo.attach(io: file, filename: \"#{event.title}.png\", content_type: 'image/png')\n event.end_time = event.datetime + rand(1..3).hours\n event.user = user\n event.save\nend",
"def randomItem\n return self[rand(self.length)] # zero based, so this works math-wise...\n end",
"def test04_EventWithCategories\n\t\tlogin $user_1_email, $master_password\n\t\t$browser.goto($patch_new_event)\n\n \t\t$post_event_title.when_present.set(\"Super fun run #{random}\")\n \t\t$post_event_calendar_start_text.when_present.set(\"#{next_year}-12-05\") #make dynamic?\n \t\t$post_event_time_start_field.when_present.click\n \t\t$post_event_select_time.when_present.select(\"8:00 AM\")\n \t\t$post_event_location.when_present.set(\"Location #{random}\")\n \t\t$browser.execute_script(\"jQuery('iframe.wysihtml5-sandbox').contents().find('body').prepend('lava is hot.')\")\n\t\tsleep 4\n\t\t$post_event_category_sport.when_present.click\n\t\t$post_now_event.fire_event(\"onclick\")\n\t\tsleep 3\n\t\tassert $post_new_post.exists?\n\t\t#verify details?\n\tend",
"def random\n @shop = Shop.find(params[:shop_id])\n @random = @shop.items.all.sample\n end",
"def test03_EventWithCategories\n\t\tlogin $user_1_email, $master_password\n\t\t$browser.goto($patch_new_event)\n\n \t\t$post_event_title.when_present.set(\"Super fun run #{random}\")\n \t\t$post_event_calendar_start_text.when_present.set(\"#{next_year}-11-15\") #make dynamic?\n \t\t$post_event_time_start_field.when_present.click\n \t\t$post_event_select_time.when_present.select(\"8:00 AM\")\n \t\t$post_event_location.when_present.set(\"Location #{random}\")\n \t\t$browser.execute_script(\"jQuery('iframe.wysihtml5-sandbox').contents().find('body').prepend('lava is hot.')\")\n\t\tsleep 4\n\t\t$post_event_type_family.when_present.click\n\t\t$post_now_event.fire_event(\"onclick\")\n\t\tsleep 3\n\t\tassert $post_new_post.exists?\n\t\t#verify details?\n\tend",
"def test05_EventWithCategories\n\t\tlogin $user_1_email, $master_password\n\t\t$browser.goto($patch_new_event)\n\n \t\t$post_event_title.when_present.set(\"Super fun run #{random}\")\n \t\t$post_event_calendar_start_text.when_present.set(\"#{next_year}-07-04\") #make dynamic?\n \t\t$post_event_time_start_field.when_present.click\n \t\t$post_event_select_time.when_present.select(\"8:00 AM\")\n \t\t$post_event_location.when_present.set(\"Location #{random}\")\n \t\t$browser.execute_script(\"jQuery('iframe.wysihtml5-sandbox').contents().find('body').prepend('lava is hot.')\")\n\t\tsleep 4\n\t\t$post_event_type_family.when_present.click\n\t\t$post_event_category_sport.when_present.click\n\t\t$post_now_event.fire_event(\"onclick\")\n\t\tsleep 3\n\t\tassert $post_new_post.exists?\n\t\t#verify details?\n\tend",
"def random\n if (c = count) != 0\n find(:first, :offset => rand(c))\n end\n end",
"def random_item(elective_array)\n return elective_array[rand(elective_array.length-1)]\nend",
"def get_random_content\n random_content = []\n fetch_all_categories.each do |link_to_send|\n random_content = link_to_send.url\n\n end\n random_content.sample\n end",
"def random_weapon\n weapons = [\"sword\",\"bow and arrow\",\"laser gun\",\"Jungle Sword\",\"Lunar Cue\",\"Crimson Blaster\",\"Quake Hammer\",\"Drive Vortex\",\"Drive Defender\",\" Road Blaster\",\"Turbo Axe\",\"Rocket Blaster \"]\n weapon = weapons[rand(weapons.length)]\nend",
"def forecast_future(question, responses)\n random_key = responses.keys[rand(responses.size)]\n puts responses[random_key].sample\nend",
"def random_item (array)\n item_index = rand(0...array.length)\n array[item_index]\n array.delete_at(item_index)\nend",
"def generateCart\n cart = []\n rand(20).times do\n cart.push(ITEMS.sample) \n end\n cart\nend",
"def random_show\n @category = params[:category]\n if @category == \"morning\"\n @slogans = Slogan.where(\"(category = ?) OR (category = ?)\", '朝', '朝夕')\n elsif params[:category] == \"evening\"\n @slogans = Slogan.where(\"(category = ?) OR (category = ?)\", '夕', '朝夕')\n end\n @slogan = @slogans[rand(@slogans.size)]\n end",
"def initial_categories\n category_array = Array.new\n 10.times do\n category_array << Faker::Hacker.noun\n end\n add_additional_titles(category_array)\nend",
"def random_element\n sample\n end",
"def category(num=(0...round.categories.count).to_a.sample)\n round.categories[num]\n end",
"def fetch_fandom(fandom)\r\n # grab the category if it exists, if not make it empty array\r\n @fandoms.keys.include?(fandom) ? @fandoms[fandom] : @fandoms[fandom] = []\r\n end",
"def meal_generator(food)\n food\nend",
"def next_event\n return [nil,[]] unless location.feature\n f = location.feature\n @next = self.priority\n begin\n @next = f.next_priority(@next)\n return [nil,nil] unless @next\n @choices, @autos = f.available_events(@next, location, player_character.id)\n end while @autos.size + @choices.size == 0\n \n if @autos.size > 0 && @choices.size > 0\n @pick = rand(@autos.size + @choices.size)\n if @pick < @autos.size\n return @next, @autos[@pick]\n else\n return @next, @choices\n end\n elsif @autos.size > 0\n return @next, @autos[rand(@autos.size).to_i]\n else #@choices.size > 0\n return @next, @choices\n end\n end",
"def escape\n choices = @animals.keys\n @animals[choices[rand(choices.length)]]\n end",
"def explore\n roll = rand(100) - depletion\n if roll < 0\n nil\n else\n increment! :depletion\n opportunity_base.generate_event\n end\n end",
"def random_act *acts\n act acts[rand(acts.length)]\n end",
"def create_specific_event(user:, title:, venue:, category:, number:, datetime:)\n event = Event.new(\n title: title,\n description: \"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.\",\n datetime: datetime,\n venue: venue,\n capacity: 5,\n category: category,\n )\n url = \"app/assets/images/dine_#{number}.jpg\"\n file = File.open(url)\n event.photo.attach(io: file, filename: \"#{event.title}.png\", content_type: 'image/png')\n event.end_time = event.datetime + rand(1..3).hours\n event.user = user\n event.save\nend",
"def add_random_article(data)\n rpg_article = RPG::Shop_Article.new(data)\n shop_article = Shop_Article.new(rpg_article)\n @custom_articles.push(shop_article)\n end",
"def order_item\n @items.sample\n end",
"def create_random_contract\n return nil if contracts.offered.count > 3\n create_third_party_mission available_contract_missions.sample\n end",
"def price(date)\n rand(1..100)\n end",
"def get_random_article(date)\n articles = scrape_on_this_day(date)\n\n if articles != nil\n article = articles.sample\n end\n\n article ||= Time.now.strftime(\"%Y\") + \" – Conor's noticed that an has error happened\"\n\n return article\n end",
"def get_random()\n @a.sample\n end",
"def get_random()\n @a.sample\n end",
"def random_items(items)\r\n\t\trandom_items = Document.has_photos.find(:all, :limit => items, :order => \"RAND()\")\r\n\tend",
"def random_block\n type = %w(p p p p ul ol dl).sample\n case type\n when 'p'\n self.random_p\n when 'ul'\n self.random_list( 'ul', (rand(2) == 1) )\n when 'ol'\n self.random_list( 'ol', (rand(2) == 1) )\n when 'dl'\n self.random_dl\n end\n end",
"def get_random_foods(how_many_foods, array)\n random_foods = []\n until random_foods.length == how_many_foods\n random_food_num = rand(0..array.length-1) # get a random number for the food\n food = array[random_food_num]\n while random_foods.include?(food)\n random_food_num = rand(0..array.length-1) # get a random number for the food\n food = array[random_food_num]\n end\n random_foods << food\n end\n return random_foods\nend",
"def choice\n rand\n end",
"def randomize\n @dog_count = rand(6) + 1;\n @cat_count = rand(85) + 1;\n @mouse_count = rand(336) + 1;\n return self\n end",
"def similarly_purchased_item(item = nil)\n if item.present?\n # first we have to determine if this is a stuffed_animal or if this\n # is an accessory\n other_line_items = []\n if item.class.name == \"StuffedAnimal\"\n other_line_items = LineItem.where(stuffed_animal_id: item.id)\n else\n other_line_items = LineItem.where(accessory: item.id)\n end\n\n # extract an array of similar items\n similar_items = self.other_products_purchased item, other_line_items\n\n # take a random sampling of 1 item\n similar_items.sample(1)\n end\n end",
"def mutate\n @dog_count = rand(2) == 0 ? 1 + rand(6) : dog_count\n @cat_count = rand(2) == 0 ? 1 + rand(85) : cat_count\n @mouse_count = rand(2) == 0 ? 1 + rand(336) : mouse_count\n end",
"def pick\n rand = Random.new\n index = rand.rand(0...@emotions.length)\n @emotions[index]\n end",
"def random_move probability = 1\n return if rand > probability\n\n room = get_object self.container\n area = room.area\n unless room.nil?\n exits = room.exits.select do |e|\n other_side = get_object e.exit_room\n not other_side.nil? and other_side.area == area\n end.map {|e| e.alt_names[0] }\n\n if exits.respond_to? :shuffle\n exits = exits.shuffle\n else\n exits = exits.sort_by { rand }\n end\n\n go exits[rand(exits.length)]\n end\n end",
"def pick_from(options,histogram = nil)\n random_item_with_histogram(options,histogram)\nend",
"def group_creator\n group = Random.new.rand(1..3)\n return group\nend",
"def grocery_item_guess(list)\n list.sample\nend",
"def market_price_for_drug\n rand(500) + 10\n end",
"def random_type; end",
"def get_related_event_types(category, id, quantity)\n all_events = KeventerReader.instance.catalog_events()\n\n all_events.select{|e| e.event_type.categories.any?{|c| c == category}}\n .select{|e| e.event_type.id != id}\n .uniq{ |e| e.event_type.id}\n .first(quantity)\nend",
"def random_rule\n RULES.keys.sample\n end",
"def generate_random_sale\n s_types = ShopsSettings::DISCOUNT_TYPES\n sales = [0]\n bonus = fidelity_level_bonus / 100.0 + 1\n bonus += sales_rate_bonus\n s_types.each_pair { |key, value|\n sales.push(key) if value * bonus >= rand(100)\n }\n sales.max\n end",
"def random_venue_yml\n puts \"venue#{@ctr}:\"\n @ctr = @ctr+1\n \n puts \" venue_id: #{@ctr}\"\n puts \" venue_name: #{@venues.random_item.to_s}\"\n puts \" venue_description: Description for #{@venues.random_item.to_s}\"\n puts \" contactinfo_id: 1\"\n puts\n \n \n \n end",
"def index\n @posts = Post.all.order(\"RANDOM()\")\n @categories = Category.all\n\n end",
"def build_random_question(params = {})\n # default values\n params[:previous_question] ||= nil\n params[:duration] ||= 600\n\n # build and return the question\n question = Question.generate_random(params.slice(:number_of_goods))\n question.user = self\n question.duration = params[:duration]\n question\n end",
"def get_damage\n 1 + Random.rand(3)\n end",
"def sample\n at(rand(size))\n end",
"def artifact type \n cheeses=[\"Camembert\",\"Parmesan\",\"Cheddar\",\"Wisconsin\",\"Brie\",\"Stinky\",\"Blue\",\"Gorgonzola\",\"Goat\",\"Gouda\"]\n bones=[\"human\",\"neanderthal\",\"sasquatch\",\"velociraptor\",\"human child\",\"buffalo\",\"alien\"]\n civs=[\"Mayan\",\"Greek\",\"Chinese\",\"Collector's Edition\",\"Persian\",\"Roman\"]\n animals=[\"Aaron the Aardvark\",\"Wile E. Coyote\",\"killer rabbit\",\"Chupacabra\",\"Tobbits the Hobbit\",\"Pikachu\",\"Ling-Ling\"]\n if type==\"cheese\"\n return cheeses[rand(10)] #change to cheeses.length\n elsif type==\"bones\"\n return bones[rand(7)]\n elsif type==\"coin\"\n return civs[rand(6)]\n elsif type==\"animal\"\n return animals[rand(7)]\n end\nend",
"def item_effect_hit_result(item) \r\n return (rand(100) < item.hit)\r\n end",
"def random_skill\n rand(70..90)\nend",
"def random_snippet\n create_snippets if snippets_created_at.nil?\n return nil if pending_snippet_count.nil? or pending_snippet_count.zero?\n ids = snippets.pending.map { |snippet| snippet.id }\n random_id = ids[rand(ids.length)]\n snippets.pending.find(random_id)\n end",
"def sample(count=MaglevUndefined, options=MaglevUndefined)\n return at Kernel.rand(size)\n end",
"def make_item(sample:, object_type:, lot_number: nil, association_map: nil)\n raise ItemActionError, 'Sample ID is nil' if sample.nil?\n\n object_type = ObjectType.find_by_name(object_type) if object_type.is_a? String\n item = nil\n if object_type.handler == 'collection' # TODO find out why some ObjectTypes dont have .collection_type?\n item = Collection.new_collection(object_type)\n length = association_map.present? ? association_map.length : item.get_empty.length\n samples = Array.new(length, sample)\n zipped_map = if association_map.present?\n samples.zip(association_map)\n else\n samples\n end\n zipped_map.each do |samp, map|\n next if samp.nil?\n\n if map.nil?\n item.add_one(samp)\n next\n end\n item.set(map[:to_loc][0], map[:to_loc][1], samp)\n end\n else\n item = sample.make_item(object_type.name.to_s)\n end\n item.associate(LOT_NUM, lot_number) if lot_number.present?\n item\n end",
"def new_description\n @dungeon.room_list[rand(0...@dungeon.room_list.length)]\n end",
"def rand()\n return MicrosoftGraph::Drives::Item::Items::Item::Workbook::Functions::Rand::RandRequestBuilder.new(@path_parameters, @request_adapter)\n end",
"def recite_random_subject\n number = rand(1..@size)\n return recite_subject(number)\n end",
"def generateCart\n cart = []\n rand(20).times do\n cart.push(ITEMS.sample)\n end\n ap cart \nend",
"def random_question\n QuestionWrapper.new(current_group.questions.random, view_context)\n end",
"def random_weather_pick\n Rails.cache.fetch(\"random_weather_pick.#{id}\", :expires_in => 10.minutes) do\n rand(1..5)\n end\n end",
"def random\n offset = rand(@ingredients.count)\n render json: @ingredients.offset(offset).first.as_json\n end",
"def random_product_image_filename\n [\"img_1.png\",\"img_2.png\", \"img_3.png\", \"img_4.jpg\", \"img_5.jpg\", \n \"img_6.jpg\", \"img_7.jpg\", \"img_8.jpg\", \"img_9.jpg\", \"img_10.jpg\" ].shuffle.first\nend",
"def randomkey; end"
] |
[
"0.67726845",
"0.6486088",
"0.6484776",
"0.6410702",
"0.63882387",
"0.63415533",
"0.6227323",
"0.60879976",
"0.60795176",
"0.60710055",
"0.6042241",
"0.59937316",
"0.5938571",
"0.59200454",
"0.5870675",
"0.5853965",
"0.58490855",
"0.581952",
"0.58074826",
"0.5737065",
"0.57104",
"0.5656362",
"0.56310487",
"0.56150514",
"0.5614318",
"0.56074023",
"0.5581334",
"0.5559174",
"0.55336565",
"0.55336565",
"0.5509532",
"0.55041754",
"0.5503242",
"0.55018234",
"0.54971194",
"0.5496083",
"0.5494698",
"0.5491566",
"0.5472454",
"0.54575765",
"0.5455707",
"0.5449359",
"0.5441308",
"0.5437318",
"0.54298025",
"0.5411204",
"0.5399679",
"0.539165",
"0.53887045",
"0.5383496",
"0.53817666",
"0.5379961",
"0.5375747",
"0.53686136",
"0.5367466",
"0.53622115",
"0.5355258",
"0.53462225",
"0.53434217",
"0.53386253",
"0.5331226",
"0.5324861",
"0.5324861",
"0.53240913",
"0.53195065",
"0.5307978",
"0.5299409",
"0.529278",
"0.52911544",
"0.52825356",
"0.52763414",
"0.52653015",
"0.5264363",
"0.52586406",
"0.5251204",
"0.5249098",
"0.52433825",
"0.52318156",
"0.5209084",
"0.5193902",
"0.5189974",
"0.5187929",
"0.5179558",
"0.5171496",
"0.515108",
"0.5145376",
"0.51435626",
"0.514219",
"0.5138332",
"0.5136711",
"0.5126056",
"0.51258206",
"0.5124246",
"0.5122995",
"0.5119724",
"0.51171905",
"0.5105546",
"0.5105079",
"0.5089648",
"0.5085038"
] |
0.7389499
|
0
|
Save to file TODO: delete files in cms/Blocks/Modules
|
def dump (filepath = BLOCKS_PATH)
# Compare saved Hash with existing files in cms/Blocks/Modules
# Delete files which are not in the Hash anymore
self.compare true
# Save the .yaml
File.open(filepath, 'w') do |out|
YAML::dump(@source, out)
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def save_level\n File.open(@file_name, 'w') do |file|\n @blocks_array.each do |block|\n new_block = Block.new block.relative_position\n puts new_block.to_s\n end\n end\n end",
"def save_to(path); end",
"def save\n file_path = self.class.file_path(@save_id)\n File.open(file_path, 'w') { |file| \n bytes = file.write @items.inspect\n if bytes > 0\n puts \"saved to #{file_path}\"\n else\n puts \"save to #{file_path} failed\"\n end\n }\n end",
"def save_as(name)\n File.open(name, \"wb\") { |f| f.write self.render }\n end",
"def save_file\n if self.file then\n self.file.save\n end\n end",
"def save!; File.write @path, @data end",
"def save(path)\n File.open(path, \"w\") { |outfile| outfile.print self.render }\n end",
"def save(filename=@filename)\n backup_filename = filename + '~'\n File.delete(backup_filename) if File.exist? backup_filename\n FileUtils.mv(filename, backup_filename)\n File.open(filename, 'w') do |f|\n f.puts @header\n f.puts @body\n f.puts @gem_dependencies\n f.puts @dev_dependencies\n f.puts @footer\n end\n end",
"def save\n save_to_file(@output_file, @contents)\n end",
"def save # :nodoc:\n if @file\n File.open(SAVE_FILE, 'w') do |f|\n Marshal.dump(file, f)\n end\n else\n forget\n end\n end",
"def save # :nodoc:\n if @file\n File.open(SAVE_FILE, 'w') do |f|\n Marshal.dump(file, f)\n end\n else\n forget\n end\n end",
"def save\n receipt = File.new(@save_path, 'w')\n receipt.write(render)\n receipt.close\n end",
"def save_file\r\n @saved = true\r\n saving\r\n Dir.mkdir(\"saves\") unless Dir.exists? \"saves\"\r\n File.open(\"my_save.yaml\", \"w\") {|f| f.puts YAML::dump(self) }\r\n end",
"def save(name = @name)\n raise OneCfg::Config::Exception::NoContent if @content.nil?\n\n file_operation(name, 'w') {|file| file.write(to_s) }\n end",
"def save_to_file(file_name = @current_file_name)\n # Loop on all dirline widgets\n File.open(file_name, 'wb') do |file|\n file.write(FILE_HEADER)\n file.write(Zlib::Deflate.deflate(RubySerial::dump({\n :dest_dir_names => @main_widget.get_dest_dirlines.map { |dirline_widget| dirline_widget.get_dir_name },\n :src_dir_names => @main_widget.get_src_dirlines.map { |dirline_widget| dirline_widget.get_dir_name },\n :data => @data\n })))\n end\n notify(\"File #{file_name} saved correctly\")\n @current_file_name = file_name\n invalidate_current_loaded_file\n end",
"def update_file\n output = (@blocks[:before] + @blocks[:attributes] + @blocks[:after]).join(\"\\n\").strip + \"\\n\"\n File.open(@filename,'w') { |f| f.write(output) } if output != @file\n end",
"def save\n File.open(@test_name, \"w+\") do |file|\n file.write(render)\n end\n end",
"def save\n File.open(path, 'w+') { |f| f.write(to_rb + \"\\n\") }\n end",
"def save\n load_cache\n\n all_classes_and_modules.each do |klass|\n save_class klass\n\n klass.each_method do |method|\n save_method klass, method\n end\n\n klass.each_attribute do |attribute|\n save_method klass, attribute\n end\n end\n\n all_files.each do |file|\n save_page file\n end\n\n save_cache\n end",
"def save\n file_name = ask_save_file\n save_file = File.open(file_name, 'w')\n save_file.puts(serialize)\n save_file.close\n puts \"Game has been saved to Save File #{file_name[-5]}!\"\n puts \"\\n\\n\"\n end",
"def save!\n @shell_file.exports = @commands\n @shell_file.write!\n end",
"def save_game\n Dir.mkdir(\"../saves\") unless Dir.exists?(\"../saves\")\n @@save_count += 1\n binding.pry\n log_saves\n savefile = \"../saves/save_#{@@save_count}.yml\"\n File.open(savefile, 'w') do | file |\n file.write(self.to_yaml)\n end\n end",
"def save_as(path)\n contents = generate\n path.open('w') do |f|\n f.write(contents)\n end\n end",
"def save_as(path)\n contents = generate\n path.open('w') do |f|\n f.write(contents)\n end\n end",
"def save_as(path)\n contents = generate\n path.open('w') do |f|\n f.write(contents)\n end\n end",
"def save_as(path)\n contents = generate\n path.open('w') do |f|\n f.write(contents)\n end\n end",
"def save_as(path)\n contents = generate\n path.open('w') do |f|\n f.write(contents)\n end\n end",
"def save_to_file\n f = File.open(\"#{IMAGE_DATA_DIR}/#{self.id}\",\"w\")\n f.write(self.data)\n f.close\n end",
"def save\n\n playerset('')\n $savefile = File.new(\"../Resources/Saves/save.txt\", \"w\")\n $savefile.puts(@@hand, @@ehand)\n cputs(\"saved\", \"green\")\n\nend",
"def save_student(filename)\n File.open(filename, \"w\") do |file|\n @students.each do |student|\n parse_to_save_file(student, file)\n puts \"File saved!\"\n interactive_menu\n end\n end\nend",
"def save_file\n\t\t\tfile_hash = Digest::MD5.hexdigest(File.read(@file))\n\t\t\tif file = @db.find_html_file(@filename)\n\t\t\t\t@file_changed = @db.check_or_update_if_file_changed(file, @filename, file_hash)\n\t\t\telse\n\t\t\t\t@db.create_html_file(@filename, file_hash)\n\t\t\tend\n\t\tend",
"def save(file=nil)\n file = file || path \n text = format.render(number)\n ::File.open(file, 'w'){ |f| f << text }\n end",
"def save_file(xml)\n\t\tFile.open(Rails.root.to_s + '/public/system/rsm.xml', \"w+\") do |f|\n\t\t\tf.write(xml)\t\n\t\tend\t\t\n\tend",
"def save!\n begin\n case filename\n when STDOUT_FLAG\n $stdout.write(contents)\n else\n ::File.open(@filename,\"w\") do |f|\n f.write(contents)\n end\n end\n @dirty = false\n rescue => e\n raise FileAccessError, \"Error saving file #{@filename} : #{e.message}\"\n end\n end",
"def save\n pathname.open('w') { |file| file.write(data) }\n end",
"def save_file\n raise ArgumentError, 'Need a Path to save the file' if @path.nil?\n File.open(@path, 'w') do |f|\n f.write to_s\n end\n end",
"def save!\n FileUtils.mkdir_p File.dirname(self.file)\n\n File.open(self.file, \"w+\") do |f|\n f << %(#{self.namespace}.translations || (#{self.namespace}.translations = {});\\n)\n self.translations.each do |locale, translations_for_locale|\n f << %(#{self.namespace}.translations[\"#{locale}\"] = #{translations_for_locale.to_json};\\n);\n end\n end\n end",
"def save\n create_file\n true\n end",
"def save_thank_you_letters(id,form_letter)\n Dir.mkdir(\"output\") unless Dir.exists?(\"output\")\n filename = \"output/thanks_#{id}.html\"\n File.open(filename,'w') do |file|\n file.puts form_letter\n end\nend",
"def save_to_file(path = nil)\n content\n file = Store::File.find_by(id: store_file_id)\n if !file\n raise \"No such file #{store_file_id}!\"\n end\n\n if !path\n path = Rails.root.join('tmp', filename)\n end\n ::File.open(path, 'wb') do |handle|\n handle.write file.content\n end\n path\n end",
"def save(data)\n File.open(@local_file_path, \"wb\") {|file| file.write(data) }\n end",
"def save_as(path)\n generate.save_as(path)\n end",
"def save_as(path)\n generate.save_as(path)\n end",
"def save_and_close( filename = clean_name )\n result.parent.export filename\n end",
"def save! path\n File.open(path, 'w') do |file|\n file.write(to_s)\n end\n end",
"def save_thank_you_letters(id, form_letter)\n Dir.mkdir(\"output\") unless Dir.exists? \"output\"\n\n filename = \"output/thanks_#{id}.html\"\n\n File.open(filename, 'w') do |file|\n file.puts form_letter\n end\nend",
"def save!\n filepath.dirname.mkpath\n filepath.open( \"w\" ) do |f|\n f << YAML.dump( @entries )\n end\n clear_modified\n true\n end",
"def save_module\n uni_module = UniModule.find(params[:module_par])\n if(current_user.uni_modules.include?(uni_module))\n current_user.unsave_module(uni_module)\n else\n current_user.save_module(uni_module)\n end\n end",
"def save_file \n Grit.debug = true\n contents = params[:contents]\n message = params[:commit_message]\n @node = Node.new(:name => params[:name], :git_repo_id => params[:git_repo_id], :git_repo_path => params[:git_repo_path])\n save_file_to_disk(contents, @node.abspath)\n stage_and_commit_file(@node.repo_base_path, @node.git_repo_path, message)\n flash[:notice] = \"Created New Version\"\n render :action => :file\n end",
"def save_to(path)\n File.open(path, \"w\") do |file|\n I18n.with_locale(meta.locale) do\n file << render\n end\n end\n end",
"def write(block)\n @filemgr.write(block, @contents)\n end",
"def save_file\n if platinum_user_and_above?\n uid = current_user.id\n data_dir = Rails.root.join('shared','data')\n @file = data_dir.join('domains')\n file = File.open(@file, 'r')\n @restore = ''\n file.each_line { |line| @restore += line }\n file.close\n file = File.open(@file, 'w+')\n file.write(params[:file_content])\n file.close\n domain_table_reload(uid,data_dir.to_s)\n render json: { message: 'Saving successful.' }\n else\n render json: { message: 'Saving failed, please check your file again.' }\n end\n rescue Psych::SyntaxError\n file = File.open(@file, 'w+')\n file.write(@restore)\n file.close\n render json: { message: 'Saving failed, please check your file again.' }\n end",
"def savePage(fileName = \"testPage.yml\")\n\t\t#File.open(\"file.rb\") if File::exists?( \"file.rb\" )\n\t\tfile = File.new(@@pageDirectory + fileName, \"w+\")\n\t\tserializedPage = YAML::dump(@currentHTMLPage)\n\t\tfile.puts(serializedPage)\n\t\tfile.close\n\t\t#puts(\"saved page: #{fileName}\")\n\tend",
"def save(filename)\n File.write(filename, self.to_s)\n end",
"def save_to(path)\n (File.open(path, 'w') << to_s).close\n path\n end",
"def save_to(path)\n (File.open(path, 'w') << to_s).close\n path\n end",
"def save_to_sites\n if Site.where(:id => self.site_id).count == 0\n p self\n return\n end\n STDERR.puts \"save_to_sites: Site: #{site}\"\n site_dir = Rails.root.join(\"sites\", site.name)\n unless Dir.exists? site_dir\n Dir.mkdir site_dir\n end\n payload_dir = site_dir.join(self.name)\n unless Dir.exists? payload_dir\n Dir.mkdir payload_dir\n end\n STDERR.puts \"Writing: #{payload_dir}\"\n File.open(payload_dir.join(\"client_script.rb\"), \"wb\") do |f|\n f.write self.client_script\n end \n File.open(payload_dir.join(\"data_generator.rb\"), \"wb\") do |f|\n f.write self.data_generator\n end \n end",
"def save(flatten = false)\n tmp_file = SecureRandom.uuid\n save_as(tmp_file, flatten)\n File.rename tmp_file, @file\n end",
"def save\n ::File.open(@file, \"w\") { |file| file << self.to_hash.to_yaml }\n end",
"def save filename = nil\n filename = find_free_name filename\n save! filename\n end",
"def save_model( model )\n file = model_filename model\n file_path = File.join(Dir.home,'tempo', file)\n File.delete( file_path ) if File.exists?( file_path )\n\n File.open( file_path,'a' ) do |f|\n model.index.each do |m|\n f.puts YAML::dump( m.freeze_dry )\n end\n end\n end",
"def save!\n raise Informative, 'This XCScheme object was not initialized ' \\\n 'using a file path. Use save_as instead.' unless @file_path\n File.open(@file_path, 'w') do |f|\n f.write(to_s)\n end\n end",
"def save\n \tdata = self\n \t\n \tFile.open('store.yml','w') do |f|\n \t\tf.write(data.to_yaml)\n \tend\n \tputs data\n \tputs \"Saved!\"\n \tputs \"\"\n end",
"def write_to_file\n File.open(config.block_list_path, 'a') do |f|\n block_count = old_newest_block ? (block_list.size - old_newest_block.height - 1) : block_list.size\n block_list = self.block_list.sort{|(k1, v1), (k2, v2)| v1.height <=> v2.height}\n block_list = block_list[(old_newest_block.height + 1)..-1] if old_newest_block\n block_list.each_with_index do |(k, b), index|\n f.write(b.to_payload)\n f.flush\n print \"\\r#{(((index + 1).to_f / block_count) * 100).to_i}% done write parsed block to #{config.block_list_path}.\"\n end\n f.write(newest_block.to_payload)\n puts\n end\n end",
"def save\n File.open(file_path, 'w') do |file|\n YAML.dump(data, file)\n end\n end",
"def save\n ApplicationDatabase.new.save_compressed_to_file(@file.path)\n end",
"def save(path)\n File.open(path,\"w\"){|out| out.puts Marshal.dump(self) }\n end",
"def save!\n Powirb.log.debug(\"[#{wid}] saving on #{@filename}\")\n File.open(@filename, 'w+') {|io| io.puts @doc}\n end",
"def save\n repository.create_contents(path, \"Upload #{path}\", content)\n end",
"def save(path, mode = ::File::WRONLY|::File::CREAT|::File::TRUNC, **options)\n\t\t\t\t\tif @body\n\t\t\t\t\t\t::File.open(path, mode, **options) do |file|\n\t\t\t\t\t\t\tself.each do |chunk|\n\t\t\t\t\t\t\t\tfile.write(chunk)\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\tend",
"def save(overwrite=true)\n write_file(overwrite, @filename)\n end",
"def save_settings\n File.open(@path, \"w\") do |file|\n file.write @settings.to_yaml\n end\n end",
"def save_content(title, content)\n\tFile.open(\"pages/#{title}.txt\" , \"w\") do |file|\n\t file.print(content)\n end \t\t\nend",
"def save\n entries = []\n entries << '#'\n entries << '# This file is managed by Chef, using the hostsfile cookbook.'\n entries << '# Editing this file by hand is highly discouraged!'\n entries << '#'\n entries << '# Comments containing an @ sign should not be modified or else'\n entries << '# hostsfile will be unable to guarantee relative priority in'\n entries << '# future Chef runs!'\n entries << '#'\n entries << ''\n entries += unique_entries.map(&:to_line)\n entries << ''\n\n contents = entries.join(\"\\n\")\n contents_sha = Digest::SHA512.hexdigest(contents)\n\n # Only write out the file if the contents have changed...\n if contents_sha != current_sha\n ::File.open(hostsfile_path, 'w') do |f|\n f.write(contents)\n end\n end\n end",
"def save(filename)\n SGF::Writer.new.save(@root, filename)\n end",
"def save\n File.open( @plugins_file, 'w' ) do |out|\n YAML.dump( @plugins, out )\n end\n end",
"def save_locally(dir)\n FileUtils.mkdir_p(dir) unless File.exists? dir\n \n # remove HTML BASE tag if it exists\n @contents.xpath('//base').each { |t| t.remove }\n # remove head tag\n @contents.xpath('//head').each { |t| t.remove }\n # remove link tags\n @contents.xpath('//link').each { |t| t.remove }\n # remove script tags\n @contents.xpath('//script').each { |t| t.remove }\n # remove comments\n @contents.xpath('//comment()').each { |t| t.remove }\n # remove mediawiki meta tag\n @contents.xpath('//meta').each { |t| t.remove if t['name'] == \"generator\" }\n # remove sitesub h3 tag\n @contents.xpath('//h3').each { |t| t.remove if t['id'] == \"siteSub\" }\n\n # get lastmod/viewcount values\n @contents.xpath('//li').each do |t|\n if t['id'] == \"lastmod\"\n @lastmod = t.text.strip\n end\n if t['id'] == \"viewcount\"\n @viewcount = t.text.strip\n end\n end\n\n # remove unneeded divs\n @contents.xpath('//div').each do |t|\n t.remove if t['id'] == \"column-one\"\n t.remove if t['id'] == \"footer\"\n t.remove if t['id'] == \"catlinks\"\n t.remove if t['id'] == \"contentSub\"\n t.remove if t['id'] == \"jump-to-nav\"\n t.remove if t['class'] == \"printfooter\"\n t.remove if t['class'] == \"visualClear\"\n end\n\n if @main_page == true\n save_path = File.join(dir, \"index\")\n title = 'Dublin Core Metadata Initiative Media-Wiki Archive'\n else\n save_path = File.join(dir, File.basename(uri.to_s))\n title = File.basename(uri.to_s).gsub(\"_\", \" \")\n end\n save_path += '.html' if save_path !~ /\\.((html?)|(txt))$/\n File.open(save_path, 'w') { |f| f.write(\"<!DOCTYPE html>\\n<html>\\n<head>\\n<meta http-equiv=\\\"Content-Type\\\" content=\\\"text/html; charset=UTF-8\\\">\\n<meta http-equiv=\\\"Content-Language\\\" content=\\\"en-us\\\">\\n<title>#{title}</title>\\n</head>\\n<body>\\n<p><b>This is an archived MediaWiki page.</b><br />#{@lastmod}<br />#{@viewcount}</p>\\n#{@contents.xpath('//div[@id=\"bodyContent\"]').to_html}\\n</body>\\n</html>\") }\n # File.open(save_path, 'w') { |f| f.write(\"---\\nlayout: page\\ntitle: #{title}\\n---\\n\\n#{@contents.xpath('//div[@id=\"bodyContent\"]').to_html}\") }\n end",
"def write\n file_name = \"course_#{@file_term}.json\"\n # Write the JSON to the course_work_content folder where the app will pick it up later\n Rails.root.join(\"lib/course_work_content\", file_name).write(@courses.to_json)\n end",
"def save_to(filepath)\n File.open(filepath, \"w\") do |fp|\n fp.write(self.to_s)\n end\n end",
"def save_thank_you_letters(id,form_letter)\r\n\tDir.mkdir(\"output\") unless Dir.exist?(\"output\")\r\n\r\n\tfilename = \"output/thanks_#{id}.html\"\r\n\r\n\tFile.open(filename, \"w\") do |file|\r\n\t\tfile.puts form_letter\r\n\tend\r\nend",
"def save\n if file\n # Ensure the current store has been loaded before we try to re-write it, this\n # is necessary if the program generator has crashed before creating a test\n store\n p = Pathname.new(file)\n FileUtils.mkdir_p(p.dirname)\n File.open(p, 'w') { |f| f.puts JSON.pretty_generate(store) }\n end\n end",
"def save\n Dir.chdir(@gl_admin.working_dir)\n\n #Process config file\n new_conf = @config.to_file(@confdir)\n @gl_admin.add(new_conf)\n\n #Process ssh keys\n files = list_keys(@keydir).map{|f| File.basename f}\n keys = @ssh_keys.values.map{|f| f.map {|t| t.filename}}.flatten\n\n to_remove = (files - keys).map { |f| File.join(@keydir, f)}\n @gl_admin.remove(to_remove)\n\n @ssh_keys.each_value do |key|\n key.each do |k|\n @gl_admin.add(k.to_file(@keydir))\n end\n end\n end",
"def write_file\n \n # if dirty?\n generate\n \n delete_file\n File.open(absolute_path.gsub(/\\.txt$/, \"\"), 'w+') do |f| \n f.write(generated_header)\n f.write(generated_content)\n end\n # not_dirty\n # end\n end",
"def saveFile(saveTag)\n aFile = File.new(\"config.version\", \"w+\")\n if aFile\n aFile.syswrite(\"version=#{saveTag}\")\n aFile.close\n else\n puts \"Unable to write a config.version file!\"\n end\n end",
"def save! filename = nil\n filename ||= @filename\n dirname = File.dirname filename\n FileUtils.mkdir_p dirname\n\n ::File.open(filename, 'wb')do |io|\n until @body_io.eof? do\n io.write @body_io.read 16384\n end\n end\n\n filename\n end",
"def make_save_contents\n contents = rm_extender_make_save_contents\n contents[:self_vars] = $game_self_vars\n contents[:labels] = $game_labels\n contents[:self_labels] = $game_self_labels\n contents\n end",
"def save\n File.open(@path, \"w\") do |file|\n Psych.dump({version: VERSION}, file)\n doc = {}\n @stats.each_pair do |article_path, article_stat|\n doc[article_path] = {\n stat: article_stat,\n related: @related[article_path] || [],\n }\n end\n Psych.dump(doc, file)\n end\n end",
"def save\n prepare\n h = {}\n h[:title] = @title\n h[:sequence] = @sequence.map(&:export)\n outfile = File.join(@basedir, \"#{@name}.json\")\n File.open(outfile, 'w') do |f|\n f.write JSON.pretty_generate(h)\n end\n end",
"def save!\n delete_file\n save\n end",
"def save!\n if save\n self\n else\n raise FileNotSaved\n end\n end",
"def save\n @filename = @filename || gen_filename\n file = File.open(File.join(@dir, @filename), 'w') { |f|\n f.puts @issue.to_yaml\n }\n end",
"def save args={}\n raise ArgumentError, \"No file name provided\" if args[:filename].nil?\n @savable_sgf = \"(\"\n @root.children.each { |child| write_node child }\n @savable_sgf << \")\"\n\n File.open(args[:filename], 'w') { |f| f << @savable_sgf }\n end",
"def create_save\n @save_data = {:turns => @turns,:guesses => @guesses,:secret_word => @secret_word, :hidden_word => @hidden_word}\n save = File.new(\"./lib/save.txt\", \"w+\")\n save.puts JSON::dump(save_data)\n save.close\n end",
"def save\n return if File.exists?(file)\n\n # Create parent directories\n FileUtils.mkdir_p(File.dirname(file))\n\n File.open(file, \"w\") do |f|\n f.write(compressed_contents)\n end\n\n puts \"Wrote blob #{file}\"\n end",
"def save\n # Nothing in base class. This should be used to persist settings in\n # subclasses that use files.\n end",
"def save(flatten: false)\n tmp_file = SecureRandom.uuid\n save_as(tmp_file, flatten: flatten)\n File.rename tmp_file, @file_path\n end",
"def log_saves \n s_log = File.open(\"../saves/log.yml\", \"w\")\n s_log.puts @@save_count\n s_log.close\n end",
"def save_to_file\n File.open(@output, 'w+') do |file|\n file.puts HEADER if @additional_html\n file.puts @data_for_output.join(\"\\n\")\n file.puts FOOTER if @additional_html\n end\n end",
"def save( file )\n begin\n File.open( file, 'w' ) { |f| f.write( YAML.dump( self ) ) }\n rescue\n File.open( file, 'wb' ) { |f| f.write( Marshal.dump( self ) ) }\n end\n end",
"def write_save_data(file)\r\n write_characters(file)\r\n write_frame(file)\r\n write_setup(file)\r\n write_data(file)\r\n end"
] |
[
"0.6641077",
"0.65292114",
"0.64409125",
"0.6439034",
"0.6398398",
"0.63938165",
"0.6368766",
"0.63551515",
"0.6353025",
"0.63507384",
"0.63507384",
"0.6347216",
"0.633548",
"0.6319227",
"0.63181955",
"0.63129777",
"0.626229",
"0.6230679",
"0.61614186",
"0.6137314",
"0.61341715",
"0.61245465",
"0.61183846",
"0.61183846",
"0.61183846",
"0.61183846",
"0.61183846",
"0.61076087",
"0.6096923",
"0.60868853",
"0.60614496",
"0.6060777",
"0.60555714",
"0.6044059",
"0.60396093",
"0.60187685",
"0.6018744",
"0.6015993",
"0.60060596",
"0.5973682",
"0.59713715",
"0.59646136",
"0.59646136",
"0.5960724",
"0.59571207",
"0.59478295",
"0.5947521",
"0.5945718",
"0.5944475",
"0.5931853",
"0.5931819",
"0.5921644",
"0.5917886",
"0.5916626",
"0.5914412",
"0.5914412",
"0.5910779",
"0.58929753",
"0.588671",
"0.5881589",
"0.5875327",
"0.5864776",
"0.5850503",
"0.58432",
"0.583981",
"0.5838091",
"0.58345246",
"0.58292764",
"0.5828106",
"0.58214587",
"0.5819482",
"0.58178586",
"0.580824",
"0.580457",
"0.5801516",
"0.5795164",
"0.57876956",
"0.57860804",
"0.57816195",
"0.57814485",
"0.5779362",
"0.5778619",
"0.57666624",
"0.57638675",
"0.57604474",
"0.57580996",
"0.57538265",
"0.5751477",
"0.5746361",
"0.57461107",
"0.5744265",
"0.5740651",
"0.574015",
"0.5739268",
"0.5720729",
"0.5720296",
"0.5716366",
"0.570738",
"0.5703118",
"0.5702513"
] |
0.5701149
|
100
|
Raise error if no such block
|
def check_block name
raise "No such block: #{name}" unless @source.key? name
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def has_block(blk_hash)\n raise \"Not implemented\"\n end",
"def raise_if_block(obj, name, has_block, type)\n return unless has_block\n\n puts \"Type passed in: #{type}\"\n puts \"#{obj.class}##{name} does not accept blocks\"\n\n raise Appom::UnsupportedBlockError\n end",
"def try\n if block_given?\n yield\n else\n puts 'no block'\n end\nend",
"def try\n if block_given?\n yield\n else\n puts \"no block\"\n end\nend",
"def block?; end",
"def get_block(blk_hash)\n raise \"Not implemented\"\n end",
"def require_block(block_given)\n raise ArgumentError, \"Must provide a block\" unless block_given\n end",
"def get_block name\n name = name.to_sym\n block = @blocks.find {|b| b.name == name}\n raise \"No block found for #{name} (in #{blocks.collect{|b|b.name}.join(':')})\" unless block\n block\n end",
"def block_valid?(block)\n # ...\n end",
"def block_checker\n block_given?\nend",
"def has_block(name)\n @blocks.key?(name.to_s)\n end",
"def verify_block(&blk)\n begin\n return true if yield\n rescue\n false\n end\n end",
"def block_given?() end",
"def i_check_if_block\n if block_given?\n yield\n else\n puts \"no block\"\n end\nend",
"def were_we_given_a_block?\n\tif block_given?\n\t\t\"WE GOT A BLOCK\"\n\telse\n\t\t\"WE DIDN'T GET A BLOCK\"\n\tend\nend",
"def candidate_block(block)\n return unless (my_index = block.parent.blocks.find_index block)\n\n next_block = block.parent.blocks[my_index + 1]\n return unless next_block && next_block.context == :pass\n\n next_block\n end",
"def block(_hash)\n raise Sibit::NotSupportedError, 'block() doesn\\'t work here'\n end",
"def test_bad_block\r\n\t\ts = \"SYSTEM>Gaozu(100)\"\r\n\t\ttb = Block.new(\"0\", \"0\", s, \"1518893687.329767000\", \"fd19\")\r\n\t\t\r\n\t\tassert_equal 0, tb.validate_block\r\n\tend",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def compute_f_e(yielded, &block)\n return block.(yielded) if block_given?\n\n do_not_exist.nil? NameError\n rescue \n\n block.nil?\nend",
"def block?\n !!block\n end",
"def block\n blockable.blocks.detect{|b| b.identifier == self.identifier.to_s} || \n blockable.blocks.build(:identifier => self.identifier.to_s)\n end",
"def test_block_empty\n check(C::Block, <<-EOS)\n | {\n | }\n EOS\n end",
"def check_block_num(curr_block)\n # make sure number of blocks is in order starting at 0\n return unless curr_block.block_number.to_i != @curr_count\n\n @block_num_error = true\n puts \"Line #{curr_count}: Invalid block number #{curr_block.block_number}, should be #{curr_count} \"\n puts 'BLOCKCHAIN INVALID'\n exit 1\n end",
"def get_block(*params); raise('Stub or mock required.') end",
"def test_check_bad_block\n assert_raises SystemExit do\n assert_output \"Line 1: Invalid block, missing or extra element(s)\\nBLOCKCHAIN INVALID\" do\n line = ['0', '0', 'SYSTEM>569274(100)', '1553184699.650330000', '288d', '']\n line_num = 1\n @verify.check_block(line, line_num)\n end\n end\n end",
"def block(_hash)\n raise Sibit::NotSupportedError, 'Blockchair doesn\\'t implement block()'\n end",
"def verify_block_num\r\n unless @block_number == @@total_block_number\r\n raise \"Line #{@@total_block_number}: invalid block number #{@block_number}, should be #{@@total_block_number}\"\r\n\r\n end\r\n\r\n true\r\n end",
"def block_node; end",
"def block_node; end",
"def require_block; end",
"def is_block?\n get_metadata(:for_block)\n end",
"def block\n true\n end",
"def check_block_number(index_num, block)\n if index_num != block.block_number\n puts \"Line #{index_num}: Invalid block number #{block.block_number}, should be #{index_num}\"\n return false\n end\n true\n end",
"def get_block_by_id(block_id)\n raise \"Not implemented\"\n end",
"def test_check_good_block\n line = ['0', '0', 'SYSTEM>569274(100)', '1553184699.650330000', '288d']\n line_num = 1\n assert_output(nil) { @verify.check_block(line, line_num) }\n end",
"def method1\n return \"ERROR Method1: no block given\" unless block_given?\n yield\n yield\n yield\nend",
"def may_fail # block\n begin\n yield\n rescue\n end\nend",
"def invalid?(&_block)\n end",
"def test_invalid_block\n chain = \"SYSTEM>Kurt(50)\"\n block = Blockchain.new(\"5\", \"5\", chain, \"1518892051.812065000\", \"ch78\")\n\n assert_equal 0, block.is_valid\n end",
"def get_block id\n block = self.blocks_get_by_id id\n if block[\"success\"]\n return block[\"block\"]\n else\n return nil\n end\n end",
"def if_block_given\n p \"hoge\"\n yield if block_given?\n p \"end\"\nend",
"def block_caller\n if block_given?\n result_of_block = yield\n return result_of_block\n else\n return 'no block'\n end\nend",
"def rblock\n if block_given?\n # yield execute the block\n yield\n else\n puts \"No block\"\n end\n end",
"def valid()\n if (@block) then @block.call(true) end\n end",
"def blocks() end",
"def test_good_block\r\n\t\ts = \"SYSTEM>Gaozu(100)\"\r\n\t\ttb = Block.new(\"0\", \"0\", s, \"1518893687.329767000\", \"fd18\")\r\n\t\t\r\n\t\tassert_equal 1, tb.validate_block\r\n\tend",
"def not_found(&block)\n error 404, &block\n end",
"def validate_block(block)\n # check block ready conditions\n # 1. parent block must already be accepted.\n parent_block = get_block(block.parent_hash)\n raise BlockNotReadyError.new(\"can't find parent block by hash #{block.parent_hash.to_hex}\") unless parent_block\n # TODO 2. pow_chain_ref block must already be accepted.\n # 3. local time must greater or equal than minimum timestamp.\n unless (local_timestamp = Time.now.to_i) >= (minimum_timestamp = genesis_time + block.slot_number * SLOT_DURATION)\n raise BlockNotReadyError.new(\"local_timestamp(#{local_timestamp}) must greater than or equal with minimum_timestamp(#{minimum_timestamp})\")\n end\n end",
"def call_block\n puts \"start\"\n yield \"foobar\" if block_given?\n puts \"end\"\nend",
"def f(&block)\n # The block is a proc.\n block.class == Proc or raise\n block.call\n end",
"def header(&block)\n puts \"This is our hedaer\"\n block.call\nrescue\n puts \"This is where we would rescue an error.\"\nensure\n puts \"This is our footer.\"\nend",
"def after_block_boundary?; end",
"def empty?; super && @block.empty? end",
"def block_method\nputs \"called outside block in block_method\"\n#add method, to check if there is a block on this method\nyield if block_given? #predicate method, it have question mark on end\nputs \"now we are returning again to block\"\nend",
"def safe_call(&block)\n begin\n block.call\n rescue NoMethodError => e\n nil\n end\n end",
"def blocks; end",
"def blocks; end",
"def blocks; end",
"def test_check_block_num_unequal\r\n assert_nil nil, @g.check_block_num(1, 0)\r\n end",
"def validate_first_block(f_info)\r\n\t\terror_msg = \"\"\r\n\t\tsuccess = true\r\n\r\n\t\t# verifies the timestamps\r\n\t\tsuccess, error_msg = validate_timestamps(f_info)\r\n\t\treturn success, error_msg unless success\r\n\r\n\t\tif f_info['id'] != 0\r\n\t\t\terror_msg = \"Invalid block number #{f_info['id']}, should be 0\"\r\n\t\t\tsuccess = false\r\n\t\t\treturn success, error_msg\r\n\t\telsif f_info['prev_hash'] != \"0\"\r\n\t\t\terror_msg = \"Previous hash was #{f_info['prev_hash']}, should be 0\"\r\n\t\t\tsuccess = false\r\n\t\t\treturn success, error_msg\r\n\t\telsif f_info['transaction'].length != 1\r\n\t\t\terror_msg = \"Transaction count for first block was #{f_info['transaction'].length}, should be 1\"\r\n\t\t\tsuccess = false\r\n\t\t\treturn success, error_msg\r\n\t\telsif not validate_hash(f_info)\r\n\t\t\terror_msg = \"String #{f_info['original'].strip} hash set to #{f_info['self_hash'].strip}, should be #{get_hash(get_string_to_hash(f_info))}\"\r\n\t\t\tsuccess = false\r\n\t\t\treturn success, error_msg\r\n\t\telse\t\t\t\r\n\t\t\t# updates the transaction logs\r\n\t\t\tsuccess, error_msg = update_billcoins(f_info)\r\n\t\t\t#error_msg = \"\" unless not success\r\n\t\t\treturn success, error_msg unless success\r\n\t\tend\r\n\r\n\t\treturn success, error_msg\r\n\tend",
"def check_if_block_exists(miner, timestamp)\r\n block_exists = false\r\n winning_miner = nil\r\n $blockchain.length.times do |i|\r\n ts = $blockchain[i].timestamp\r\n block_exists = true if ts == timestamp\r\n winning_miner = $blockchain[i].miner\r\n break if block_exists\r\n end\r\n if block_exists\r\n $status = \"Miner #{miner} is late, block already mined by #{winning_miner}\"\r\n puts \"Miner #{miner} is late, block already mined by #{winning_miner}\".red\r\n end\r\n return block_exists\r\nend",
"def block_checker(param) \n [ param , block_given? ]\nend",
"def test_blocks_nil\n hash_ = ::Hash.new\n block_ = ::Proc.new do\n set_value1(:a)\n set_value2(:b)\n end\n ::Blockenspiel.invoke(block_) do\n add_method(:set_value1, :block => :first) do |bl_, key_|\n assert_nil(bl_)\n end\n add_method(:set_value2, :block => :last) do |key_, bl_|\n assert_nil(bl_)\n end\n end\n assert_nil(hash_[:a])\n assert_nil(hash_[:b])\n end",
"def safely(&block)\r\n begin\r\n yield\r\n rescue Exception => e\r\n if e.message =~ /connection was aborted/\r\n puts \" [yp searcher] Error: #{e} #{e.message}. Continuing.\"\r\n end\r\n end\r\n end",
"def optional\n puts 'A code block isn\\'t required, but it\\'s nice.'\n yield if block_given? #Kernel#block_given?\n puts 'I\\'m happy either way, really.'\nend",
"def ensure(&block)\n raise \"catch or each must be called before ensure\" unless @used\n block.call\n raise_if_failures\n end",
"def supports_block_expectations?\n true\n end",
"def make_block_reservation(hotel)\n show_blocks(hotel)\n return if hotel.blocks.size == 0\n puts \"\\nEnter the data for the block reservation.\"\n start_date = get_date(\"Start date: \")\n end_date = get_date(\"End date: \")\n room = get_integer(\"Room to reserve: \", 1, 20)\n begin\n block = hotel.blocks_by_room(start_date, end_date, room).first\n rescue => exception\n puts \"Error: #{exception.message}\"\n block = nil\n end\n if block == nil\n puts \"\\nCould not find that block.\"\n else\n begin\n hotel.reserve_from_block(block, room)\n rescue => exception\n puts \"Error: #{exception.message}\"\n end\n end\nend",
"def error_hander\n @error_block\n end",
"def block_class() Block; end",
"def blocks?\n !@blocks.empty?\n end",
"def defined?(name)\n !blocks[name].nil?\n end",
"def on_missing(&block)\n missing_events << {type: :block, block: block}\n self\n end",
"def foo\n if block_given?\n # Call the block\n yield\n else\n puts \"Sem parâmetro do tipo bloco\"\n end\nend",
"def last_block?\n return @last_block\n end",
"def one\n too { yield }\nendbegin;1;rescue => e1;e1;end",
"def maybe_block\n case @take_block\n when true then @take_block = :taken; '&block'\n when nil, false, :taken then nil\n else\n fail TypeError, \"unexpected @take_block value\"\n end\n end",
"def validate_block_chain()\r\n\t\t# exits if file doesn't exist\r\n\t\tif not File.exist? @path\r\n\t\t\tputs 'The file does not exist, the program will exit' ; exit \r\n\t\tend\r\n\r\n\r\n\t\tfirst_line = File.open(@path).first\r\n\t\t# first line block number must be 0, and must only have one transaction\r\n\t\tfirst_block = parse_info(first_line)\r\n\t\ts, e = validate_first_block(first_block)\r\n\t\tif not s\r\n\t\t\tputs \"Line 0: #{e}\"\r\n\t\t\tputs \"BLOCKCHAIN INVALID\"\r\n\t\t\texit()\r\n\t\tend\r\n\r\n\t\t# update the values\r\n\t\t@prev_hash = first_block['self_hash']\r\n\r\n\t\tFile.readlines(@path).drop(1).each.with_index do |line, line_num|\r\n\t\t\t# line_num will be used to check the block number\r\n\t\t\t# line_num + 1 == block number\r\n\r\n \t\t\tblock = parse_info(line)\r\n \t\t\ts, e = validate_block(block, line_num + 1)\r\n \t\t\tif not s\r\n\t\t\t\tputs \"Line #{line_num + 1}: #{e}\"\r\n\t\t\t\tputs \"BLOCKCHAIN INVALID\"\r\n\t\t\t\texit()\r\n\t\t\tend\r\n\r\n\t\t\t# update the values\r\n\t\t\t@prev_hash = block['self_hash']\r\n\r\n\t\tend\r\n\r\n\t\treturn nil\r\n\tend",
"def blockFun2(arg1, &aBlock)\n if aBlock\n aBlock.call(arg1)\n \"HAVE BLOCK\"\n else\n \"NO BLOCK\"\n end\nend",
"def called_with_block?\n if block_given?\n p \"You called me with a block\"\n end\nend"
] |
[
"0.7198107",
"0.7087166",
"0.68876505",
"0.6871596",
"0.6851032",
"0.6637109",
"0.6561613",
"0.654849",
"0.6518731",
"0.6463298",
"0.64455473",
"0.6403784",
"0.63923097",
"0.6387925",
"0.6384271",
"0.63789093",
"0.63658184",
"0.6271281",
"0.62580335",
"0.62580335",
"0.62580335",
"0.62580335",
"0.62580335",
"0.62580335",
"0.62580335",
"0.62580335",
"0.62580335",
"0.62580335",
"0.62580335",
"0.62580335",
"0.62580335",
"0.62580335",
"0.62580335",
"0.62580335",
"0.62580335",
"0.62580335",
"0.62580335",
"0.62580335",
"0.62475014",
"0.62269086",
"0.6212692",
"0.62094843",
"0.62008554",
"0.6196696",
"0.6150897",
"0.6145066",
"0.6137986",
"0.612432",
"0.612432",
"0.6107249",
"0.61066926",
"0.6102568",
"0.60892683",
"0.6080626",
"0.60651183",
"0.606122",
"0.6028461",
"0.60099787",
"0.60097533",
"0.6000983",
"0.59718686",
"0.5964992",
"0.5958269",
"0.5948977",
"0.5915084",
"0.5901399",
"0.5871629",
"0.58696413",
"0.5869055",
"0.58655846",
"0.5864201",
"0.58304703",
"0.582861",
"0.5823883",
"0.5805286",
"0.5801996",
"0.5801996",
"0.5801996",
"0.57954794",
"0.57882684",
"0.57833093",
"0.57759434",
"0.5767094",
"0.5766238",
"0.57607144",
"0.5756598",
"0.57279116",
"0.5726537",
"0.5711904",
"0.5690188",
"0.5686287",
"0.56845784",
"0.56823575",
"0.56811666",
"0.5677261",
"0.56670934",
"0.56618226",
"0.5639861",
"0.56388444",
"0.5635187"
] |
0.7525429
|
0
|
Raise error if no such module
|
def check_type type
raise "No such type: #{type}" unless Modules.constants.include? type
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def check_module_exists(module_name)\n @forge.check_module_exists(module_name)\n end",
"def check_module_exists(module_name)\n @forge.check_module_exists(module_name)\n end",
"def check_module_exists(module_name)\n !get_module_data(module_name).nil?\n end",
"def get_module()\n raise NoMethodError, 'This method needs to be overridden'\n end",
"def check_module_name\n case\n when @arguments.empty?; puts 'Module name required.'; exit 3\n when !@arguments[0].match(/^[a-z][\\w]+/); puts 'Invalid module name.'; exit 4\n else @module = @arguments[0]\n end\n end",
"def require_perl_module(name)\n print \"Checking for Perl module #{name}... \"\n\n output = `perl -M#{name} -e 'print \"exists\";' 2>&1`.strip\n\n if output == 'exists'\n puts 'yes'\n else\n abort 'no'\n end\n end",
"def require_if_available(name)\n require name\nrescue LoadError\n false\nend",
"def failed\n\t\treturn module_failed\n\tend",
"def gem_available?(name)\n Gem::Specification.find_by_name(name)\nrescue Gem::LoadError\n false\nend",
"def gem_error(server)\n if(!server.command_available?)\n puts \"ERROR: The #{server.server} gem does not appear to be installed\"\n exit(1)\n end\n end",
"def check_gem # --- CHECK FOR MISSING GEMS\n begin\n\t gem 'em-websocket'\n rescue Gem::LoadError\n\t puts \"IT APPEARS YOU ARE MISSING THE SOCKET GEM\"\n puts \"TO INSTALL IT TYPE 'gem install em-websocket'\"\n\telse\n\t\t#donothing\n\tend\n\n\tbegin\n\t\tgem 'net-ping', '>=1.7.8'\n\trescue Gem::LoadError\n\t\tputs \"IT APPEARS THAT YOU ARE MISSING THE NET-PING GEM\"\n puts \"TO INSTALL IT TYPE 'gem install net-ping'\"\n\telse\n\t\t#donothing\n\tend\nend",
"def require?(path)\n require path\nrescue LoadError => e\n # HACK: ( because we should raise on syntax errors but\n # not if the file doesn't exist. TODO make robust!\n raise unless e.to_s.include? path\nend",
"def gem_available?(name)\n Gem::Specification.find_by_name(name)\nrescue Gem::LoadError\n false\nrescue\n Gem.available?(name) #for backwards compatibility\nend",
"def have_gem? name\n Gem::Specification.find_by_name name.to_s\n rescue Gem::LoadError\n false\n end",
"def load_plugin_failed(name, exception); end",
"def got_hpricot? # ERGO help tests pass without it\n require 'hpricot'\n return true\nrescue MissingSourceFile\n return false\nend",
"def module_loaded? mod\n Bot::Modules.include? mod\n end",
"def gem_available?(name)\n Gem::Specification.find_by_name(name)\nrescue Gem::LoadError\n puts \"[*] - esearchy requires #{name}.\"\n if RUBY_PLATFORM =~ /mingw|mswin/\n \tsystem \"gem install #{name}\"\n else\n \tsystem \"sudo gem install #{name}\"\n end\nend",
"def is_module_presents?(modulename)\n abort \"No ssh session found\" if @ssh.nil?\n r = @ssh.do_ssh_cmd(\n \"ls #{@puppetfolder}/#{@modulesfolder}/#{modulename}\"\n )\n r[:exit_code] == 0 ? true : false\n end",
"def try_require(name)\n if found = find_helper(name.to_s)\n require(found) || true\n else\n raise(LoadError, \"Helper #{name} not found\")\n end\n end",
"def check_package(item)\n package = \"Packages/\"+ item +\".rb\"\n result = File.exists?(package)\n if result == true\n require package\n else\n puts \"the monkeys can't find your package\"\n exit\n end\nend",
"def node_module_exists(command, install_instructions = 'npm install -g')\n cmd = `if hash #{command} 2>/dev/null; then echo \"true\"; else echo \"false\"; fi`\n if cmd.include? \"false\"\n command_msg = \"Missing command #{command}\"\n abort \"#{command_msg}: Please run `#{install_instructions} #{command}` And try again\\n\"\n exit 1\n end\n end",
"def assert_module_not_installed_on_disk(host, module_name, moduledir=nil)\n moduledir ||= get_modulepaths_for_host(host)\n modulepath = moduledir.is_a?(Array) ? moduledir : [moduledir]\n moduledir= nil\n\n modulepath.each do |i|\n # module directory should not exist\n on host, %Q{[ ! -d \"#{i}/#{module_name}\" ]}\n end\n end",
"def optionally\n begin\n yield\n rescue LoadError; end\nend",
"def module_loaded?\n /^#{new_resource.modname}/.match?(::File.read(\"/proc/modules\"))\n end",
"def require_dependency_with_check(dependency)\n begin\n require dependency\n rescue LoadError => e\n puts \"You need to install #{dependency} before we can proceed\"\n end\nend",
"def ensure_module_defined(module_name)\n module_name.split('::').reduce(Object) do |last_module, next_module|\n last_module.const_set(next_module, Module.new) unless last_module.const_defined?(next_module)\n last_module.const_get(next_module)\n end\nend",
"def require_library_or_gem(library_name)\n begin\n require library_name\n rescue LoadError => cannot_require\n # 1. Requiring the module is unsuccessful, maybe it's a gem and nobody required rubygems yet. Try.\n begin\n require 'rubygems'\n rescue LoadError => rubygems_not_installed\n raise cannot_require\n end\n # 2. Rubygems is installed and loaded. Try to load the library again\n begin \n require library_name\n rescue LoadError => gem_not_installed\n raise cannot_require\n end\n end\nend",
"def wrong; require 'unknown_file'; end",
"def try_load_puppet\n require 'puppet'\n rescue LoadError\n nil\n end",
"def ensure_module_defined(module_name)\n module_name.split('::').reduce(Object) do |last_module, next_module|\n last_module.const_set(next_module, Module.new) unless last_module.const_defined?(next_module, false)\n last_module.const_get(next_module, false)\n end\nend",
"def ensure_module_defined(module_name)\n module_name.split('::').reduce(Object) do |last_module, next_module|\n last_module.const_set(next_module, Module.new) unless last_module.const_defined?(next_module, false)\n last_module.const_get(next_module, false)\n end\nend",
"def ensure_module_defined(module_name)\n module_name.split('::').reduce(Object) do |last_module, next_module|\n last_module.const_set(next_module, Module.new) unless last_module.const_defined?(next_module, false)\n last_module.const_get(next_module, false)\n end\nend",
"def check_for_executable; end",
"def [](module_name)\n out = nil\n @modules.each { |the_module| out = the_module if the_module.name == module_name }\n raise \"No such module '#{module_name}'\" if out.nil?\n out\n end",
"def require_derivative( mod_name )\n\n\t\t# See if we have a list of special subdirs that derivatives\n\t\t# live in\n\t\tif ( self.respond_to?(:derivative_dirs) )\n\t\t\tsubdirs = self.derivative_dirs\n\n\t\telsif ( self.respond_to?(:derivativeDirs) )\n\t\t\tsubdirs = self.derivativeDirs\n\n\t\t# If not, just try requiring it from $LOAD_PATH\n\t\telse\n\t\t\tsubdirs = ['']\n\t\tend\n\n\t\tsubdirs = [ subdirs ] unless subdirs.is_a?( Array )\n\t\tPluginFactory::log :debug, \"Subdirs are: %p\" % [subdirs]\n\t\tfatals = []\n\n\t\tPluginFactory::log :debug, \"Working directory is: %s\" % Dir.getwd\n\t\t\n\n\t\t# Iterate over the subdirs until we successfully require a\n\t\t# module.\n\t\tcatch( :found ) {\n\t\t\tsubdirs.collect {|dir| dir.strip}.each do |subdir|\n\t\t\t\tself.make_require_path( mod_name, subdir ).each {|path|\n\t\t\t\t\tPluginFactory::log :debug, \"Trying #{path}...\"\n\n\t\t\t\t\t# Try to require the module, saving errors and jumping\n\t\t\t\t\t# out of the catch block on success.\n\t\t\t\t\tbegin\n\t\t\t\t\t\trequire( path.untaint )\n\t\t\t\t\trescue LoadError => err\n\t\t\t\t\t\tPluginFactory::log :debug,\n\t\t\t\t\t\t\t\"No module at '%s', trying the next alternative: '%s'\" %\n\t\t\t\t\t\t\t[ path, err.message ]\n\t\t\t\t\trescue ScriptError,StandardError => err\n\t\t\t\t\t\tfatals << err\n\t\t\t\t\t\tPluginFactory::log :error,\n\t\t\t\t\t\t\t\"Found '#{path}', but encountered an error: %s\\n\\t%s\" %\n\t\t\t\t\t\t\t[ err.message, err.backtrace.join(\"\\n\\t\") ]\n\t\t\t\t\telse\n\t\t\t\t\t\t#PluginFactory::log :debug, \n\t\t\t\t\t\t#\t\"Found '#{path}'. Throwing :found\"\n\t\t\t\t\t\tthrow :found\n\t\t\t\t\tend\n\t\t\t\t}\n\t\t\tend\n\n\t\t\t#PluginFactory::log :debug, \"fatals = %p\" % [ fatals ]\n\n\t\t\t# Re-raise is there was a file found, but it didn't load for\n\t\t\t# some reason.\n\t\t\tif ! fatals.empty?\n\t\t\t\t#PluginFactory::log :debug, \"Re-raising first fatal error\"\n\t\t\t\tKernel::raise( fatals.first )\n\t\t\tend\n\n\t\t\tnil\n\t\t}\n\tend",
"def module?\n true\n end",
"def module?\n true\n end",
"def require_with_grace(r) require r; rescue LoadError; block_given? ? yield : abort(\"#{$!.message}\\n\\n try executing: gem install '#{r}'\") end",
"def module_info(module_name)\n #note: we may need to match something like \"romedia.Flash Player.plugin\" to\n #0x16cda000 - 0x172dfff3 +com.macromedia.Flash Player.plugin 10.0.12.36 (1.0.4f362) <776944fd51654ca2b59ab26a33d8f9b3> /Library/Internet Plug-Ins/Flash Player.plugin/Contents/MacOS/Flash Player\n # \"com.apple.QuickTime\" in the stack trace should match com.apple.QuickTime 7.6.3 (1584) \n #in the module list, but NOT com.apple.QuickTimeFireWireDV.component 7.6.3 (1584)\n if module_name == \"???\"\n return [nil, nil]\n elsif @log_string =~ /(0x[[:xdigit:]]+)\\s+-\\s+(0x[[:xdigit:]]+)\\s+[^\\n]+#{Regexp.escape(module_name)} [^\\/]+(\\/[^\\n]+)$/\n module_base = $1\n crashed_module_path = $3\n return module_base, crashed_module_path\n else\n raise \"Unable to get full path of #{module_name} from log #{@log_path}\"\n end \n \n \n end",
"def module?\n false\n end",
"def try_load_semantic_puppet\n require 'semantic_puppet'\n rescue LoadError\n nil\n end",
"def const_missing(symbol)\n # final implementation in delta/Module.rb , this implementation avoids MNU\n # while constructing the exception\n raise NameError, 'uninitialized constant during bootstrap'\n end",
"def get_options(name)\n if $array_modules.key? name\n return $array_modules[name]\n else\n puts \"The module doesn't exist\"\n return false\n end\nend",
"def is_dtk_common_core_gem_installed?\n begin\n # if no exception gem is found\n gem 'dtk-common-core'\n return true\n rescue Gem::LoadError\n return false\n end\nend",
"def plugin_installed?(name)\n raise \"Not Implemented\"\n end",
"def loaded_correctly?\n !!@module\n end",
"def loaded_correctly?\n !!@module\n end",
"def modules\n raise CapabilitiesExceeded\n end",
"def verify_haml_existence\n begin\n require 'haml'\n rescue LoadError\n say \"HAML is not installed, or it is not specified in your Gemfile.\"\n exit\n end\n end",
"def check\n raise NoCheckMethodError\n end",
"def load_error; end",
"def should_run?\n raise NoMethodError\n end",
"def should_run?\n raise NoMethodError\n end",
"def should_run?\n raise NoMethodError\n end",
"def find_module_named name\n @modules_hash[name]\n end",
"def incomplete_install?\n builtin_module_list = %w[aggregate canary puppetdb_fact secure_env_vars puppet_connect]\n (Dir.children(Bolt::Config::Modulepath::MODULES_PATH) - builtin_module_list).empty?\n end",
"def exists?(module_name)\n const_name = module_name.to_s.camel_case\n slice_names.include?(const_name) && Object.const_defined?(const_name)\n end",
"def require_plugin(name, version='>= 0')\n unless Vagrant.has_plugin?(name, version)\n # This displays the error twice. I'm not sure how to fix that. I don't want to\n # use raise because that throws up a huge stack-trace which is overwhelming.\n abort \"'#{name} is not installed!\"\n end\nend",
"def check_for_libraries; end",
"def module_path\n nil\n end",
"def check_for_node\n unless executable_path('node')\n $stderr.puts \"node.js is not installed\"\n throw Exception.new('node.js is not installed')\n end\n end",
"def non_existing_script?\n return false if program\n\n print_error(\"The script doesn't exist\")\n true\n end",
"def in_drupal_root?\n File.exist?(File.expand_path('modules/system/system.module'))\nend",
"def load_module(module_file_name)\n begin\n # If dynamic loading fails for module name created with facility name, it moves to the rescue block\n p \"Trying to load module name created based on facility name\"\n load module_file_name rescue nil\n facility.name\n rescue Exception => e\n # If dynamic loading fails for module name created with facility name, the module name is created with client name\n if @client == \"ORBOGRAPH\" or @client == \"ORB TEST FACILITY\"\n translation_module_file_name = File.dirname(__FILE__) + \"/templates/\" + facility.client.name.downcase.gsub(' ','_') + \"_#{@module_name}_template_variable_translations.rb\"\n else\n translation_module_file_name = File.dirname(__FILE__) + \"/templates/\" + facility.client.name.downcase.gsub(' ','_') + \"_template_variable_translations.rb\"\n end\n \n p \"Trying to load module name created based on client name\"\n load translation_module_file_name\n facility.client.name\n end\n end",
"def phantom_load_raise?(e); end",
"def gem_installed?(gem_name)\n found_gem = false\n begin\n found_gem = Gem::Specification.find_by_name(gem_name)\n rescue Gem::LoadError\n return false \n else\n return true \n end\nend",
"def _dependency_error(req, src, msg)\n raise LoadError, sprintf(msg, req, src)\n end",
"def dependency(lib = nil)\n lib ? require(lib) : yield\n rescue LoadError, NameError => e\n self.load_error = e\n end",
"def built_in_module?(name)\n true if platform_family?('suse') &&\n %w(systemd unixd http so access_compat core mpm_event mpm_prefork mpm_worker).include?(name)\n end",
"def testNonRubyFile\n assert_raise(LoadError) do\n requireFile('NonRubyFile.so')\n end\n end",
"def eprotonosupport?() EPROTONOSUPPORT == @error_code; end",
"def check_package_and_module(proj, path, pkg_name, module_id)\n pkg, id = proj.package_and_module_from_path(path)\n pkg.name.should == pkg_name\n id.should == module_id\n end",
"def load_implementation_module!\n impl_modules = [ 'oj', 'jrjackson', 'multi_json', 'ruby_json' ]\n\n load_success = impl_modules.any? { |impl_module|\n begin\n require_relative impl_module\n true\n rescue LoadError\n # Could not load +impl_module+; try the next one\n false\n end\n }\n\n if load_success\n BEL::Extension::Format::JSONImplementation\n else\n mod_s = impl_modules.join(', ')\n msg = \"Could not load any JSON implementation (tried: #{mod_s}).\"\n raise LoadError.new(msg)\n end\n end",
"def try_require(name)\n require(\"sketchdown/renderer/#{name.downcase}\")\n true\n rescue LoadError\n true\n end",
"def plugin_check(plugin_name)\n unless Vagrant.has_plugin?(plugin_name)\n raise \"#{plugin_name} is not installed, please run: vagrant plugin \" \\\n \"install #{plugin_name}\"\n end\nend",
"def check_orm\n return true if include_component_module_for(:orm)\n\n say \"<= You need an ORM adapter for run this generator. Sorry!\"\n raise SystemExit\n end",
"def ensure_class_exist(class_name)\n # Ensure Process class exists ---------------\n Object.const_get(class_name)\n rescue => e\n raise Lorj::PrcError.new, format('Lorj::Core: Unable to find class'\\\n \" '%s'\\n%s\", class_name, e.message)\n end",
"def load_error=(_arg0); end",
"def validate(modulename)\n success = (modulename =~ /[a-z0-9_][\\/-][a-z0-9_]/i)\n $stderr.puts \"'#{modulename}' is not a valid module name. Skipping.\".red unless success\n success\n end",
"def any_direct_access_except?(module_model_name)\n case module_model_name\n when :component_module then has_direct_access?(:service_module)\n when :service_module then has_direct_access?(:component_module)\n else fail Error.new(\"Illegal module model name (#{module_model_name})\")\n end\n end",
"def failing_modules\n modules.reject {|m| %w(passed softfailed running none).include? m['result']}.map {|m| m['name'] }\n end",
"def pre_hard_load(mod); end",
"def module?\n @type == :module\n end",
"def module?\n @type == :module\n end",
"def mod(name, args = nil)\n puts \"INFO: validating module '#{name}'\"\n if args.is_a? Hash and args.has_key?(:git) and args.has_key?(:ref)\n if validate_repo(args[:git])\n if args[:ref] == 'master' or args[:ref] =~ /stable\\/.*/ or validate_ref(args[:git], args[:ref])\n puts \"INFO: module '#{name}' is valid\"\n else\n @valid = false\n puts \"ERROR: module '#{name}' is not referencing a tag (#{args[:ref]})\"\n end\n else\n @valid = false\n puts \"ERROR: module '#{name}' doesn't reference a valid repo\"\n end\n else\n @valid = false\n puts \"ERROR: module '#{name}' doesn't have a git repo or ref\"\n end\n end",
"def check_module_deprecated(module_name)\n module_name = module_name.sub('/', '-')\n module_data = get_module_data(module_name)\n version = get_current_version(module_name)\n version.to_s.eql?('999.999.999') || version.to_s.eql?('99.99.99') || !module_data.attribute('deprecated_at').nil?\n end",
"def has_command!(name, referer = self.class)\n name.split(':').inject(referer){|cur,look|\n cur.const_get(command2module(look))\n }\n rescue NameError => ex\n raise NoSuchCommand, \"No such command #{name}\", ex.backtrace\n end",
"def node_modules?\n !!name.match(/node_modules\\//)\n end",
"def test_bad_chicken_deps\n check_deps_fail \"notapackage\" => :chicken if which('csc')\n end",
"def test_bad_chicken_deps\n check_deps_fail \"notapackage\" => :chicken if which('csc')\n end",
"def gem_is_available?\n @thor.say(\"Check if #{@name} is available as a gem name.\", :yellow)\n uri = URI.parse(\"https://rubygems.org/api/v1/gems/#{@name}.json\")\n\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = true\n\n request = Net::HTTP::Get.new(uri.request_uri)\n response = http.request(request)\n\n return response.code == '404'\n rescue SocketError => e\n # rubygems is down, skip check\n return true\n end",
"def gem_is_available?\n @thor.say(\"Check if #{@name} is available as a gem name.\", :yellow)\n uri = URI.parse(\"https://rubygems.org/api/v1/gems/#{@name}.json\")\n\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = true\n\n request = Net::HTTP::Get.new(uri.request_uri)\n response = http.request(request)\n\n return response.code == '404'\n rescue SocketError => e\n # rubygems is down, skip check\n return true\n end",
"def test_bad_rubinius_deps\n check_deps_fail \"notapackage\" => :rbx if which('rbx')\n end",
"def test_bad_rubinius_deps\n check_deps_fail \"notapackage\" => :rbx if which('rbx')\n end",
"def uses_mocha(test_name)\n require 'mocha'\n yield\nrescue LoadError\n $stderr.puts \"Skipping #{test_name} tests. `gem install mocha` and try again.\"\nend",
"def allow_missing?(dependency)\n false\n end",
"def sayGreeting()\r\n raise NoMethodError\r\n end",
"def allow_missing?(dependency)\n # Puppet dependencies must _always_ be resolvable\n return false if dependency.is_a?(Models::PuppetDependency)\n # Explicit Puppetfile dependencies must _always_ be resolvable\n return false if dependency.is_a?(Models::PuppetfileDependency)\n @allow_missing_modules\n end",
"def is_module_package?(name)\n filename = File.expand_path(name)\n filename =~ /.tar.gz$/\n end",
"def greeting\r\n\t\traise NoMethodError\r\n\tend"
] |
[
"0.7106743",
"0.71055895",
"0.6870879",
"0.66052145",
"0.65267307",
"0.645325",
"0.622519",
"0.6125707",
"0.5913256",
"0.59077585",
"0.58327234",
"0.5758508",
"0.57405955",
"0.5727051",
"0.57244843",
"0.5713424",
"0.571274",
"0.57011473",
"0.56903917",
"0.56863034",
"0.56545186",
"0.56539345",
"0.5641113",
"0.5638948",
"0.5633907",
"0.56329197",
"0.560767",
"0.55936235",
"0.5585357",
"0.55801135",
"0.55695635",
"0.55695635",
"0.55695635",
"0.5556083",
"0.55425566",
"0.5539138",
"0.55334467",
"0.55334467",
"0.5527189",
"0.55101764",
"0.550101",
"0.5493652",
"0.5489092",
"0.54841423",
"0.5483715",
"0.5461567",
"0.5434697",
"0.5434697",
"0.54170775",
"0.5412839",
"0.53788704",
"0.5372119",
"0.5364471",
"0.5364471",
"0.5364471",
"0.5363214",
"0.536161",
"0.53598773",
"0.53557485",
"0.5348555",
"0.534559",
"0.53423995",
"0.5340189",
"0.53317434",
"0.5325053",
"0.5323616",
"0.531962",
"0.5317252",
"0.530838",
"0.53078157",
"0.5273074",
"0.52681744",
"0.5266687",
"0.5261583",
"0.52550155",
"0.5249795",
"0.5226038",
"0.52104086",
"0.51980746",
"0.51920396",
"0.51909816",
"0.5166089",
"0.5163793",
"0.5162675",
"0.5162675",
"0.51403886",
"0.513913",
"0.51364285",
"0.5134287",
"0.5130633",
"0.5130633",
"0.51204383",
"0.51204383",
"0.51148003",
"0.51148003",
"0.5101041",
"0.50919944",
"0.50800925",
"0.507895",
"0.5070873",
"0.50642055"
] |
0.0
|
-1
|
range of years and outputs those years which do not have any repeated digits. You should probably write a helper function, `no_repeat?(year)` which returns true/false if a single year doesn't have a repeat. Difficulty: 1/5
|
def no_repeats(year_start, year_end)
result = []
(year_start..year_end).each do |yr|
result << yr if no_repeat?(yr)
end
result
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def no_repeat_years(first_yr, last_yr)\n result = []\n (first_yr..last_yr).each do |num|\n if not_repeat_year?(num)\n result << num\n end\n end\n result\nend",
"def no_repeat_years(first_yr, last_yr)\n years = (first_yr..last_yr)\n years.select { |year| year.to_s.chars.uniq == year.to_s.chars }\nend",
"def no_repeat_years(first_yr, last_yr)\n (first_yr..last_yr).select { |e| not_repeat_year?(e) }\nend",
"def no_repeat_years(first_yr, last_yr)\n (first_yr..last_yr).select { |year| not_repeat_year?(year) }\nend",
"def no_repeat_years(first_yr, last_yr)\n (first_yr..last_yr).select {|x| not_repeat_year?(x) }\nend",
"def no_repeat_years(first_yr, last_yr)\n (first_yr..last_yr).select{|yr|not_repeat_year?(yr)}\nend",
"def no_repeat?(year)\n numbers = year.to_s.split(//)\n numbers.uniq.length == numbers.length\nend",
"def no_repeat_years(first_yr, last_yr)\n\n result = []\n (first_yr..last_yr).each do |year|\n str = year.to_s\n result << year if not_repeat_year?(str)\n end\n\n result\nend",
"def no_repeats(year_start, year_end)\n\tyear = year_start\n\tnon_repeat_years = []\n\twhile year <= year_end\n\t\tif no_repeat_year?(year)\n\t\t\tnon_repeat_years.push(year)\n\t\tend\n\t\tyear += 1\n\tend\n\tnon_repeat_years\nend",
"def no_repeat_years(first_yr, last_yr)\n years = (first_yr..last_yr).to_a\n years.select {|year| not_repeat_year?(year)}\n\nend",
"def no_repeat_years(first_yr, last_yr)\n (first_yr..last_yr).to_a.select { |year| not_repeat_year?(year) }\nend",
"def no_repeat_years(first_yr, last_yr)\n return (first_yr..last_yr).to_a.select { |y| y.to_s.chars.uniq == y.to_s.chars }\nend",
"def no_repeat?(year)\n digits = year.to_s.chars # Break year into digits\n digits.each do |x| # If any digit repeats, return false\n return false if digits.count(x) > 1\n end\n true # Otherwise return true \nend",
"def no_repeats(start_year, end_year)\n (start_year..end_year).to_a.select { |year| no_repeat?(year) }\nend",
"def no_repeat?(year)\n digits = year.to_s.split(\"\")\n counter = Array.new(10, 0) \n \n digits.each do |digit|\n counter[digit.to_i] += 1\n return false if counter[digit.to_i] > 1\n end\n \n true\nend",
"def no_repeat_years(first_yr, last_yr)\n array = []\n (first_yr..last_yr).each do |year|\n array << year if not_repeat_year?(year)\n end\n array\nend",
"def silly_years(year)\n years = []\n until years.length == 10\n year_str = year.to_s\n if (year_str[0..1].to_i + year_str[2..3].to_i == year_str[1..2].to_i)\n years << year\n end\n year += 1\n end\n\n years\nend",
"def no_repeats(year_start, year_end)\n no_repeats = []\n (year_start..year_end).each do |yr|\n no_repeats << yr if no_repeat?(yr)\n end\n\n no_repeats\nend",
"def no_repeats(year_start, year_end)\n\n\tyear = year_start\n\tresults = []\n\n\twhile year <= year_end\n\t\tresults << year if no_repeat?(year)\n\t\tyear += 1\n\tend\n\n\tresults\nend",
"def no_repeats(year_start, year_end)\nanswer = []\n\n for year in year_start..year_end do\n if no_repeat?(year)\n answer << year\n end\n end\n return answer\nend",
"def no_repeats(year_start, year_end)\n (year_start..year_end).to_a.select do |year|\n if year.to_s.split(\"\").uniq == year.to_s.split(\"\")\n year\n end\n end\nend",
"def silly_years(year)\n silly_years = []\n year = year + 1\n\n while silly_years.length != 10\n year_str = year.to_s\n if year_str[0..1].to_i + year_str[2..3].to_i == year_str[1..2].to_i\n silly_years.push(year)\n end\n year += 1\n end\n\n return silly_years\nend",
"def no_repeats(first_year, year_end)\n result = []\n (first_year..year_end).each do |year| if repeat?(year) == true\n result.push(year) end\n end\n\n return result\nend",
"def no_repeats(year_start, year_end)\n return if year_start > year_end\n results = []\n \n (year_start .. year_end).each do |year|\n results << year if no_repeat?(year) \n end\n \n results\nend",
"def silly_years(year)\n years = []\n\n until years.length == 10\n year += 1\n digits = year.to_s\n\n first_two, middle_two, last_two = [\n digits[0..1], digits[1..2], digits[2..-1]\n ].map { |pair| pair.to_i }\n\n years << year if (first_two + last_two) == middle_two\n\n end\n\n years\nend",
"def no_repeat?(year)\n chars_seen = []\n\n years.to_s.each_char do |char|\n return false if chars_seen.include?(char)\n chars_seen << char\n end\n\n return true \nend",
"def no_repeat_years(first_year, last_year)\nend",
"def not_repeat_year?(year) \n str = year.to_s\n str.each_char do |ele| \n if str.count(ele) > 1\n return false\n end\n end\n true\nend",
"def no_repeat?(year)\n str=year.to_s\n res=[]\n str.each_char do |ch|\n return false if res.include?(ch)\n res << ch\n end\n return true\nend",
"def no_repeat_years(first_yr, last_yr)\n (first_yr..last_yr).reduce([]) do |output, el|\n if not_repeat_year?(el)\n output << el\n else\n output\n end\n end\nend",
"def no_repeat_years(first_yr, last_yr)\n (first_yr..last_yr).reduce([]) do |arr, year|\n if not_repeat_year?(year)\n arr << year\n else\n arr\n end\n end\nend",
"def repeats?(year)\n x = []\n year.to_s.each_char do |a|\n return false if x.include?(a)\n x << a\n end\n return true\nend",
"def no_repeat?(year,mem = [])\n return true if (year % 10 == 0)\n if mem.include? year % 10\n return false\n else\n mem << (year % 10)\n return no_repeat?(year / 10, mem)\n end\nend",
"def no_repeats(start, finish)\n\n years = (start..finish).to_a\n years.select {|year| unique(year)}\n\nend",
"def silly_years(year)\n result = []\n while result.length < 10\n result << year if silly_year?(year)\n year += 1\n end\n result\nend",
"def silly_years(year)\n result_arr = []\n # retrieves first two digits\n first_half = year.to_s.split('')[0..1].join('').to_i\n while result_arr.length < 10\n first_half += 1\n mid = first_half%10\n next if mid*10 - first_half < 0\n \n mid = mid*10 + (((mid*10) - first_half)/10)\n second_half = mid - first_half\n year = first_half.to_s\n if second_half.to_s.length == 1\n year += \"0\" + second_half.to_s\n else\n year += second_half.to_s\n end\n \n \n result_arr << year.to_i\n end\n\n result_arr\nend",
"def years\n years_range = 2000..2100\n found_palindromes = 0\n years_range.each do |year|\n year_string = year.to_s(2)\n match_last_zeros = (/[0]+?$/).match(year_string).to_s\n @palindrome.palindrome?(match_last_zeros + year_string) && found_palindromes += 1\n end\n puts \"Between 2000 and 2100 are #{found_palindromes} palindromic years as binary.\"\n end",
"def divisible_by?(number)\n @year % number == 0\n end",
"def next_happy_year(year)\n loop do\n year += 1\n return year if year.digits.uniq == year.digits\n end\nend",
"def all_year\n beginning_of_year..end_of_year\n end",
"def associated_years\n years = \"\"\n \n\t start_date = event_start\n\t start_date = entry_deadline if is_opportunity?\n\t \n years << start_date.year.to_s if !start_date.blank?\n years << ' '\n years << event_finish.year.to_s if !event_finish.blank?\n \n #remove duplicates and trim off spaces\n unique_years = years.strip.split(' ').uniq.sort\n result = unique_years\n if unique_years.length > 1\n result = []\n for y in unique_years[0]..unique_years[1]\n result << y\n end\n end\n result\n #now we have the 2004-2008 case to deal with, we wish to create [2004,2005,...2008]\n \n end",
"def yn(year)\n return year if year.size == 4\n\n y = Date.today.year.to_s[2..4].to_i + 1\n case year.to_i\n when 0...y then \"20#{year}\"\n when y..99 then \"19#{year}\"\n end\n end",
"def could_be_year?(year); end",
"def year(year_range = (1930..1950))\n rand(year_range)\nend",
"def all_same_year?(tags)\n all_same_tag?(tags, :year)\n end",
"def year_only?(date)\n\t\tdate.length == 4 && @@year_rgx.match(date)\n\tend",
"def valid_year?(y, min, max)\n return false unless y\n return false if y.length != 4\n\n year = y.to_i\n year >= min && year <= max \n end",
"def get_year\n valid_yr = false\n while !valid_yr\n print \"Please enter the year you would like statistics for: \"\n user_year = gets.chomp\n yr_reg_ex = Regexp.new /^[1-9]\\d\\d\\d$/\n if user_year =~ yr_reg_ex\n valid_yr = true\n else\n puts \"Sorry, that doesn't look like a valid year.\"\n end\n end\n return user_year.to_i\nend",
"def multi_year?\n (multi_year)\n end",
"def year(string)\n return if string.blank?\n return string if string.is_a?(Range)\n\n components = string\n .split(\"-\")\n .map(&:to_i)\n .map { |y| y.zero? ? nil : y }\n\n return if components.empty?\n\n # Set end if only one year\n components << components.first if components.count == 1\n\n components[0]..components[1]\n end",
"def leap_year\n#ask for starting year\nputs \"What is the starting year?\"\nstart_year = gets.chomp.to_i\n\n#ask for ending year\nputs \"What is the ending year?\"\nend_year = gets.chomp.to_i\n\n#loop through array of years from start_year to end_year and select leap years based on given conditions\nleap_arr = []\n\n(start_year..end_year).select do |leap| \n leap_arr = leap % 4 == 0 || leap % 400 == 0\nend\nend",
"def bissextille(year)\n if(year.is_a? Integer)\n if( (year % 400 == 0) || ((year % 100 != 0) && (year % 4 == 0)) )\n puts \"L'Année #{year} bissextile.\"\n else puts \"L'Annnée #{year} est NON bissextile.\"\n end\n else \"L'Année n'est pas un entier.\"\n end\nend",
"def isValidYear?(year)\n\t\tyear =~ /^\\d{4}$/\n\tend",
"def validate_year(input, year)\n max_year = Date.today.year + 2\n year <= max_year && year >= 1900\n end",
"def year_name(number); end",
"def year_only(dates)\n dates.length == 2 && dates.first.end_with?(\"-01-01T00:00:00Z\") && dates.last.end_with?(\"-12-31T23:59:59Z\")\n end",
"def validate_year(value, valname, min, max)\n\tputs \"Testing for \" + valname.to_s + \": \" + value.to_s\n\tif not ( value and value.match(/\\p{Nd}{4}/).to_s.to_i.between?(min, max) )\n\t\tputs \"Fails \" + valname.to_s\n\t\treturn false\n\tend\n\treturn true\nend",
"def leap_years\n puts \"Enter a start year:\"\n\tstart_year = gets.chomp.to_i\n\tputs \"Enter an ending year:\"\n\tending_year = gets.chomp.to_i\n\n\tleap_years = (start_year..ending_year).select do |year|\n\t\tleap_year?(year)\n\tend\n\tputs \"#{leap_years}\"\nend",
"def valid_year?\n oldest_year = Time.zone.now.year - 5\n latest_year = Time.zone.now.year + 5\n return if (oldest_year..latest_year).cover?(graduation_year.to_i)\n errors.add(:graduation_year, 'Invalid graduation year')\n end",
"def year_not_valid?\n if (@year > 1899) && (@year < 2020)\n return false\n end\n return true\n end",
"def copyright_notice_year_range(start_year)\n\t\t# In case the input was not a number (nil.to_i will return a 0)\n\t\tstart_year = start_year.to_i\n\n\t\t# Get the current year from the system\n\t\tcurrent_year = Time.new.year\n\n\t\t# When the current year is more recent than the start year, return a string \n\t\t# of a range (e.g., 2010 - 2012). Alternatively, as long as the start year \n\t\t# is reasonable, return it as a string. Otherwise, return the current year \n\t\t# from the system.\n\t\tif current_year > start_year && start_year > 2000\n\t\t\t\"#{start_year} - #{current_year}\"\n\t\telsif start_year > 2000\n\t\t\t\"#{start_year}\"\n\t\telse\n\t\t\t\"#{current_year}\"\n\t\tend\n\tend",
"def bracket_years\n gsub(/(?<!\\()\\b(?:19|20)\\d\\d\\b(?!\\))/, \"(\\\\0)\")\n end",
"def copyright_years(start_year)\n end_year = Date.today.year\n if start_year == end_year\n start_year.to_s\n else\n start_year.to_s + '-' + end_year.to_s\n end\n end",
"def leap_year?(year)\n #PSEUDOCODE\n #every four years is a leap year\n #2012,2016,2020 are leap years\n #check if input is divisble 4\n #2000 is a leap year because it is divisible by 400\n #1900 is NOT a leap year because its divisble by 100 but not 400\n\n year % 4 == 0 && (year % 100 !=0 || year % 400 ==0)\n\nend",
"def remediation_in_year(year)\n if valid_year?(year)\n pupil_enrollment_select_data = @remediation.find_all { |hash| hash[:timeframe] == \"#{year}\" && hash[:data] }\n truncate(pupil_enrollment_select_data[0][:data])\n end\n end",
"def dog_years(year)\n\t\tp year*7\n\tend",
"def get_years\n year = slice_year\n till_year = year.to_i - @past_years\n years = []\n year.to_i.downto(till_year) { |y| years << y }\n years\n end",
"def year? = unit == 'year'",
"def checkAge birthyear, age\r\n\treturn (age..age+1) === (Time.new.year - birthyear) \r\nend",
"def leapyear(n)\n start = (n % 100 != 0 && n % 4 == 0) || (n % 100 == 0 && n % 400 == 0) ? n : n + (4 - (n % 4))\n (0...100).step(4).each do |e|\n year = start + e\n if year % 100 != 0\n puts year\n elsif year % 400 == 0\n puts year\n end\n end\nend",
"def valid_advent_year?(year:)\n min_year <= year && year <= max_year\n end",
"def years_needed\n 30\n end",
"def sred_range_for_date(date=today_as_date)\n start_of_year = (Date.new(date.year, 1, 1)..Date.new(date.year, 7, 31))\n if start_of_year.include?(date)\n return \"#{(date.year - 1)}/#{date.year}\"\n else\n return \"#{date.year}/#{date.year + 1}\"\n end\n end",
"def year\n\tprint \"Enter a Starting Year: \"\n\tyear1 = gets.chomp.to_i\n\t\n\tprint \"Enter an Ending Year: \"\n\tyear2 = gets.chomp.to_i\n\t\n\twhile year2 >= year1\n\t\tisLeap(year1)\n\t\tyear1 += 1\n\tend\nend",
"def years() 365 * days end",
"def get_year_ary\n (Date.today.year-99..Date.today.year).inject([]){|x,y| x << y}.reverse\n end",
"def hours_in_year(year)\n hours = 365 * 24\n hours += 24 if year % 4 == 0 && (year % 100 != 0 || year % 400 == 0)\n hours\nend",
"def format_year(year)\n \"#{year}-#{year+1}\"\n end",
"def YearCodes(year)\n\tif year =~ /freshman/\n\t\treturn 1\n\telsif year =~ /sophomore/\n\t\treturn 2\n\telsif year =~ /junior/\n\t\treturn 3\n\telsif year =~ /senior/\n\t\treturn 4\n\telse\n\t\treturn 0\n\tend\nend",
"def try_other_years(country_path)\n [1, -1, 2, -2, 3, -3].map { |y| year_path(@year + y).join(\"output/\") }\n .detect(&:exist?)\n end",
"def validate_year_date(field)\n date = nil\n formats = [\"%d/%m/%Y\",\"%d-%m-%Y\",\"%d %m %Y\",\"%m/%d/%Y\",\"%m-%d-%Y\",\"%m %d %Y\"]\n formats.each do |format|\n if(Date.strptime(field, format) rescue false)\n date = Date.strptime(field, format)\n break\n end\n end\n unless date.nil?\n field = date.to_s.scan(/\\d*/) # Return an array with patterns matching with only numbers in it\n if field[0].length == 4\n return true\n else\n return false\n end\n else\n return false\n end\n end",
"def julian_calendar(year)\n if year % 4 == 0 \n return true \n end \n return false\n end",
"def participation_in_year(year)\n if valid_year?(year)\n pupil_enrollment_select_data = @pupil_enrollment.find_all { |hash| hash[:timeframe] == \"#{year}\" && hash[:data] }\n truncate(pupil_enrollment_select_data[0][:data])\n end\n end",
"def leap_year?(num)\n if num%4 == 0 && num%100 !=0\n true\n elsif num%400 == 0\n true\n elsif num%4 == 0 && num%100 == 0 && num%400 != 0\n false\n elsif num%4 != 0\n false\n end\nend",
"def year() end",
"def next_years\n current_year = Time.now.year\n current_year..(current_year + 4)\n end",
"def acceptable_years_in_school\n Array(min_year_in_school..max_year_in_school)\n end",
"def normalized\n expanded = length == 2 ? \"20#{self}\".to_i : self.to_i # Assume no 3-digit years\n expanded >= Time.now.year ? expanded : Time.now.year\n end",
"def list_leap_years(current, future)\n while current <= future do\n if current % 4 != 0\n puts \"#{current} is a common year.\"\n elsif current % 100 == 0 and current % 400 != 0\n puts \"#{current} is a common year.\"\n else\n puts \"#{current} is a leap year!!!\"\n end\n current += 1\n end\n end",
"def no_repeat?(number)\n digits = number.to_s.chars\n seen = []\n digits.each do |digit|\n return false if seen.include?(digit)\n seen << digit\n end\n true\nend",
"def same_year? \n same_year_songs = Song.all.select{|song| song.release_year == release_year}\n same_year_songs.select!{|song| song.title == title}\n !same_year_songs.nil?\n end",
"def facet_year_group_for_solr\n result = \"\"\n years = associated_years\n logger.debug \"CHECKING: #{years}\"\n current_year = Time.now.year\n if years.length > 0\n #logger.debug \"YGFS:T1\"\n for year_string in years\n # logger.debug \"YGFS:T2\"\n year = year_string.to_i\n if year == current_year\n # logger.debug \"YGFS:T3 - current year match\"\n result << \"current \"\n elsif year == (current_year+1)\n # logger.debug \"YGFS:T4 - next year match\"\n result << \"next \"\n elsif year < (current_year)\n # logger.debug \"YGFS:T5 - previous years\"\n result << \"previous \"\n elsif year >> (current_year + 1)\n # logger.debug \"YGFS:T6 - future past next\"\n result << \"future \"\n end\n end\n #no years found\n else \n # logger.debug \"YGFS:T7 - none found\"\n result = \"none \"\n end\n \n # logger.debug \"YGFS: #{years} => #{result}\"\n result.strip.split(' ').uniq.sort.join(' ')\n end",
"def leap_year?(yr1)\r\n if yr1 % 4 > 0\r\n false\r\n elsif yr1 % 100 == 0\r\n if yr1 % 400 == 0\r\n true\r\n else\r\n false\r\n end\r\n elsif yr1 % 4 == 0\r\n true\r\n end\r\nend",
"def year\n puts \"Please enter a year:\"\n year = gets.chomp.to_s\n puts \"Fantasic! You have answered #{year}\".colorize(:light_blue)\n year = year.to_i\n\n case year\n when 0..500\n puts \"year 0 to 500AD\"\n return 1\n when 501..1000\n puts \"year 501AD to 1000AD\"\n return 2\n when 1001..1500\n puts \"year 1001 to the 1500\"\n return 3\n when 1501..2000\n puts \"1501 to 2000\"\n return 4\n when 2001..2020\n puts \"Current time : 2001 to 2020\"\n return 5\n when 2020..3000\n puts \"The future 2020 to 3000 and beyond!\"\n return 6\n end\n#might be better to put the case in here for the years\nend",
"def year?(v)\n normalize(v).to_s.match?(MATCH_PATTERN[:year])\n end",
"def makeYearList(entries)\n # Find the range of the years\n years = entries.map {|entry| entry.year}\n entriesList = []\n years.max.downto(years.min) { |year|\n yearEntries = matchEntries(entries, \"year\", year)\n next if yearEntries.size == 0\n entriesList << [year, yearEntries]\n }\n entriesList\nend",
"def dog_years(integer)\n dog_years = integer*7\n puts \"#{integer} human years is equal to #{dog_years} dog years.\"\n end",
"def copyright_years(start_year)\n end_year = Date.today.year\n if start_year == end_year\n \"\\#{start_year}\"\n else\n \"\\#{start_year}–\\#{end_year}\"\n end\n end",
"def get_three_digit_year(dates)\n dates.each do |f_date|\n matches = f_date.scan(/\\d{3}/)\n return matches.first unless matches.empty?\n end\n nil\n end",
"def valid?(v)\n year?(v)\n end"
] |
[
"0.8224817",
"0.8201339",
"0.8183692",
"0.817629",
"0.8149809",
"0.8136984",
"0.81052613",
"0.80987054",
"0.80939925",
"0.80634737",
"0.80312055",
"0.7970726",
"0.79629904",
"0.78959644",
"0.78614205",
"0.784222",
"0.78334177",
"0.7761601",
"0.7754601",
"0.77396744",
"0.77393377",
"0.77005064",
"0.76713955",
"0.75476354",
"0.75111735",
"0.7508156",
"0.7488449",
"0.74690443",
"0.74643236",
"0.74572337",
"0.7434117",
"0.73139703",
"0.7263813",
"0.7172972",
"0.7065734",
"0.68931437",
"0.6655595",
"0.65186554",
"0.64636374",
"0.62136257",
"0.6131347",
"0.60375315",
"0.60177445",
"0.6010674",
"0.6010096",
"0.59048116",
"0.58836275",
"0.5856139",
"0.5848575",
"0.57887286",
"0.57753164",
"0.5746806",
"0.57339674",
"0.5728823",
"0.57285017",
"0.56861156",
"0.5678173",
"0.56734055",
"0.5672622",
"0.56170946",
"0.5613077",
"0.55893296",
"0.5585698",
"0.55843264",
"0.55805117",
"0.55778915",
"0.5576925",
"0.5557413",
"0.5555318",
"0.5541552",
"0.553965",
"0.549803",
"0.5489767",
"0.5481789",
"0.5477152",
"0.5476771",
"0.54697233",
"0.546874",
"0.5466793",
"0.542918",
"0.5425389",
"0.5424002",
"0.5411739",
"0.54113895",
"0.5407294",
"0.54053605",
"0.540426",
"0.53995794",
"0.5379114",
"0.5377252",
"0.53503036",
"0.5345504",
"0.533162",
"0.53188574",
"0.5317932",
"0.53149664",
"0.5309682",
"0.5307376",
"0.5304941",
"0.52976245"
] |
0.7623361
|
23
|
GET /groups GET /groups.json
|
def index
@user = User.find(current_user.id)
@groups = @user.groups.all
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def GetGroups params = {}\n\n params = params.merge(path: 'groups.json')\n APICall(params)\n\n end",
"def groups\n \n \n @groups = @current_user.groups\n render 'groups.json.jbuilder', status: :ok\n end",
"def index\n @groups = Group.all\n\n respond_to do |format|\n format.html\n format.json { render json: @groups }\n end\n end",
"def index\n @groups = current_user.groups\n render json: @groups\n end",
"def get_groups\n @course = Course.find(params[:course_id])\n render json: @course.groups\n end",
"def index\n @groups = Group.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @groups }\n end\n end",
"def index\n @groups = Group.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @groups }\n end\n end",
"def index\n @groups = Group.all\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @groups }\n end\n end",
"def list_groups()\n response = HTTParty.get(\"https://graph.microsoft.com/v1.0/groups\", { \n headers: {\n \"Authorization\" => \"Bearer #{bearerToken}\",\n \"Host\" => 'graph.microsoft.com' \n }\n })\n return JSON.parse response.read_body\n end",
"def groups(params = {})\n @api.get(\"#{@api.path}/List/#{@id}/Groups\", params: params)\n end",
"def index\n @groups = Group.all\n render_json_serializer(@groups)\n end",
"def GetGroup id\n\n APICall(path: \"groups/#{id}.json\")\n\n end",
"def groups(options = {})\n params = { :limit => 200 }.update(options)\n response = get(PATH['groups_full'], params)\n parse_groups response_body(response)\n end",
"def list_groups\n if @user.permission_level.value == PermissionLevel.order(\"value DESC\").first.value\n render :json => Group.find(:all).map{|g| g}\n else\n render :json => @user.groups.map{|g| g}\n end\n end",
"def groups(inherited = false)\n uri = build_uri('groups', inherited: inherited.to_s)\n req = Net::HTTP::Get.new(uri, DEFAULT_HEADERS)\n resp = request(req)\n obj = if resp.code == '200'\n JSON.parse(resp.body)\n else\n raise_on_non_200(resp, 200)\n end\n obj\n end",
"def get_groups(params)\n send_get \"get_groups\", params\n end",
"def list_groups(optional={})\n\t\targs = self.class.new_params\n\t\targs[:query]['Action'] = 'ListGroups'\n\t\targs[:region] = optional[:_region] if (optional.key? :_region)\n\t\targs[:scheme] = 'https'\n\t\tif optional.key? :_method\n\t\t\traise ArgumentError, '_method must be GET|POST' unless 'GET|POST'.split('|').include? optional[:_method]\n\t\t\targs[:method] = optional[:_method]\n\t\tend\n\t\tif optional.key? :marker\n\t\t\targs[:query]['Marker'] = optional[:marker]\n\t\tend\n\t\tif optional.key? :max_items\n\t\t\targs[:query]['MaxItems'] = optional[:max_items]\n\t\tend\n\t\tself.run(args)\n\tend",
"def show_group\n\t\t@student = Student.find(params[:student_id])\n\t\trender json: @student.groups.find_by(course_id: params[:course_id])\n\tend",
"def getGroups\n groups = $gm.get(\"/groups\", @token, \"per_page=100\")\n group_ids = Array.new\n\n groups['response'].each do |group|\n group_ids.push({\n 'name' => group['name'],\n 'group_id' => group['id'],\n 'image' => group['image_url']})\n end\n\n return group_ids\n end",
"def index\n @title = \"Группы характеристик\"\n @groups = Group.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @groups }\n end\n end",
"def list_groups\n groups = CanvasSpaces.GroupCategory.groups.active.order(:name)\n # filter out non-public groups for non-admins\n groups = groups.where(join_level: 'parent_context_auto_join') unless @current_user.account.site_admin?\n groups_json = Api.paginate(groups, self, api_v1_canvas_spaces_groups_url).map do |g|\n include = @current_user.account.site_admin? || @current_user.id == g.leader_id ? ['users'] : []\n group_formatter(g, { include: include })\n end\n render :json => groups_json\n end",
"def show\n group = Group.find(params[:id])\n\n render json: group\n end",
"def index\n render json: current_user.membered_groups\n end",
"def index\n @groups = current_user.groups\n @groups = @groups.where('name LIKE ?', \"%#{params[:q]}%\") if params[:q].present?\n @groups = current_user.groups_sorted_by_admin_state_and_name(@groups)\n @groups_pictures = Group.group_images_hash_for_groups @groups\n\n respond_to do |format|\n format.html { render :index }\n format.json { render json: @groups }\n end\n end",
"def groups\n UserGroups.new(:id => id).get.items\n end",
"def index\n\n @groups = Group.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @groups }\n format.json { render :json => @groups }\n end\n end",
"def show\n render json: @group\n end",
"def show\n #@group = Group.find(params[:id])\n \n @users = @group.users\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @group }\n end\n end",
"def index\n @groups = Group.all\n\n @host_groups = Group.where \"groupable_type = 'HostGroup'\"\n @fan_groups = Group.where \"groupable_type = 'FanGroup'\"\n @artist_groups = Group.where \"groupable_type = 'ArtistGroup'\"\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @groups }\n end\n end",
"def list\n @groups = Group.find(:all, :order => 'name')\n end",
"def index\n @groupsIds = GroupsProssumer.where(prossumer_id: params[:prossumer_id]).pluck(:group_id)\n @groups = Group.where(id: @groups)\n render json: @groups\n end",
"def list_groups\n BrickFTP::API::Group.all\n end",
"def list_groups\n BrickFTP::API::Group.all\n end",
"def index\n\n\t\t@groups = Group.find_paginate({:user=> current_user, :page => params[:page], :query => params[:query], :sort => params[:sort], :nb_items => get_nb_items(params[:nb_items]) })\n\n\t\trespond_to do |format|\n\t\t\tformat.html # index.html.erb\n\t\t\tformat.xml { render :xml => @groups }\n\t\t\tformat.json { render :json => @groups }\n\t\tend\n\tend",
"def index\n authorize Group\n render :json => @group.group_memberships\n end",
"def group_info\n group_id_param = params[:group_id]\n\n if group_id_param.nil? || group_id_param.blank?\n render json: { error: 'group_id not specified.' }, status: :bad_request\n return\n end\n\n group = CanvasSpaces.GroupCategory\n .groups\n .where('groups.id = ?', group_id_param)\n .eager_load(:users)\n .first\n if group.nil?\n render json: { error: 'No such group found.' }, status: :not_found\n else\n maillist = get_maillist_for_space(group.id)\n render json: { id: group.id,\n name: group.name,\n description: group.description,\n maillist: maillist,\n leader_id: group.leader_id,\n created_at: group.created_at,\n join_type: display_join_type(group.join_level),\n size: group.users.count\n },\n status: :ok\n end\n end",
"def show\n #logger.info \"GroupsController Get Parameters: #{params}\"\n if @group\n render json: @group.to_json(:include => {:memberships => {:only => [:admin], :include => {:user => {:only => [:id, :first_name, :last_name, :email]}}}})\n else\n render json: {error: \"YOU MUST BE MEMBER OF THIS GROUP TO SEE IT\"}, status: :unprocessable_entity\n end\n end",
"def showgrp\n @grp = params[:id].to_s\n @groups=Group.where(\"kls_parent=\"+@grp).order(\"name asc\")\n render json: @groups\n end",
"def index\n @groups = query(GROUP, :name)\n\n # restrict the groups to the groups of the current user\n # unless the current user is allowed to create groups\n # and need to see all\n unless allowed(:create)\n allowed_group_ids = current_user.groups.collect {|g| g.id }\n @groups.delete_if do |g|\n ! allowed_group_ids.member?(g.id)\n end\n end\n\n respond_to do |format|\n format.html\n format.xml { render :xml => @groups }\n end\n end",
"def index\n respond_with @project do |format|\n format.json { render json: decorate_groups }\n end\n end",
"def belonging_groups\n contact_groups = []\n @contact.contact_groups.each do |group|\n contact_groups << { _id: group['_id'].to_s, lbl: group['label'] }\n end\n\n respond_to do |format|\n format.js {}\n format.json { render json: contact_groups }\n end\n end",
"def get_groups\n users = User.where('is_group =? and institution_id=? and center_id=? and edutorid like ?',true,params[:institution_id],params[:center_id],\"%SG-%\").select(:id)\n list = Profile.find_all_by_user_id(users).map {|u| Hash[value: u.user_id, name: u.firstname]}\n render json: list\n end",
"def show\n @group = Group.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @group }\n end\n end",
"def show\n @group = Group.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @group }\n end\n end",
"def index\n @groups = Group.accessible_by(current_ability)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @groups }\n format.xml { render xml: @groups }\n end\n end",
"def index\n @group_users = GroupUser.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @group_users }\n end\n end",
"def get_group\n send_request(FUNCTION_GET_GROUP, [], '', 4, 'k4')\n end",
"def index\n @groups = Group.all\n end",
"def index\n @groups = Group.all\n end",
"def index\n @groups = Group.all\n end",
"def index\n @groups = Group.all\n end",
"def index\n @groups = Group.all\n end",
"def index\n @groups = Group.all\n end",
"def index\n @groups = Group.all\n end",
"def index\n @groups = Group.all\n end",
"def index\n @groups = Group.all\n end",
"def index\n @groups = Group.all\n end",
"def index\n @groups = Group.all\n end",
"def index\n @groups = Group.all\n end",
"def index\n @groups_all = current_user.groups.paginate(page: params[:page]).order('name ASC')\n\n @owner = current_user\n @users = User.where(\"owner_id = ?\", current_user).order('lastname ASC')\n\n respond_to do |format|\n format.html { render @groups }\n format.json { render json: @groups }\n end\n end",
"def show\n @group = Group.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @group }\n end\n end",
"def show\n @group = Group.find(params[:id])\n @members = Member.find(:all, :conditions => [\"group_id = ? and deleted = 0\", params[:id]])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @group }\n end\n end",
"def show\n @user_group = UserGroup.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @user_group }\n end\n end",
"def show\n @group = Group.find(params[:id])\n respond_to do |format|\n # format.html # show.html.erb\n format.json { render :json => @group}\n end\n end",
"def index\n @students = current_user.groups[0].students\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @students }\n end\n end",
"def get_group_by_id(id)\n get(\"/groups/#{id}\")\n end",
"def index\n objs = ManagingGroup.all.order(:position)\n if objs\n render json: {managing_groups: objs}, status: 200\n else\n render json: {}, status: 500\n end\n rescue => error\n render json: {}, status: 500\n end",
"def index\n @groupons = Groupon.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @groupons }\n end\n end",
"def index\n @groups = Group.display_for_user(current_user)\n end",
"def read (group_id = nil)\n\n url = @app_url + \"/api/groups\"\n url = url << \"/#{group_id}\" unless group_id == nil\n\n response = RestClient.get url, {\"X-Token\" => @api_token, :accept => :json}\n\n json_obj = nil\n\n if response.code == 200\n json_obj = JSON.parse(response.body.to_s)\n else\n raise RuntimeError.new(\"Invalid response: #{response.code.to_s}\")\n end\n\n json_obj\n end",
"def index\n respond_to do |format|\n format.html { @groups = Group.get_groups(current_user, params) }\n format.xml { render :xml => Group.get_groups(params.merge({:show => 'all'})) }\n end\n end",
"def index\n respond_to do |format|\n format.html { @groups = Group.get_groups(current_user, params) }\n format.xml { render :xml => Group.get_groups(params.merge({:show => 'all'})) }\n end\n end",
"def index\n @user_groups = UserGroup.accessible_by(current_ability)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @user_groups }\n end\n end",
"def get_groups_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: GroupsApi.get_groups ...\"\n end\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n if opts[:'sort_order'] && !['ascending', 'descending'].include?(opts[:'sort_order'])\n fail ArgumentError, 'invalid value for \"sort_order\", must be one of ascending, descending'\n end\n \n \n \n \n # resource path\n local_var_path = \"/api/v2/groups\".sub('{format}','json')\n\n # query parameters\n query_params = {}\n query_params[:'pageSize'] = opts[:'page_size'] if opts[:'page_size']\n query_params[:'pageNumber'] = opts[:'page_number'] if opts[:'page_number']\n query_params[:'id'] = @api_client.build_collection_param(opts[:'id'], :multi) if opts[:'id']\n query_params[:'jabberId'] = @api_client.build_collection_param(opts[:'jabber_id'], :multi) if opts[:'jabber_id']\n query_params[:'sortOrder'] = opts[:'sort_order'] if opts[:'sort_order']\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n local_header_accept = ['application/json']\n local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result\n\n # HTTP header 'Content-Type'\n local_header_content_type = ['application/json']\n header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n \n auth_names = ['PureCloud OAuth']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'GroupEntityListing')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: GroupsApi#get_groups\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def show_group(id)\n get(\"groups/#{id}\")\n end",
"def index\n authorize! :see, Group\n @groups = Group.all\n end",
"def getGroup( group_id)\n params = Hash.new\n params['group_id'] = group_id\n return doCurl(\"get\",\"/group\",params)\n end",
"def index\n @groups = Group.all.includes(:user)\n end",
"def show\n @group = Group.find(params[:id])\n\n render json: @group.to_json(:include => {:memberships => {:only => [:admin], :include => {:user => {:only => [:id, :first_name, :last_name, :email]}}}})\n end",
"def groups\r\n @groups ||= fetch_groups\r\n end",
"def groups\n #@groups = Kaminari.paginate_array(current_user.publications(Group)).page(params[:page])\n @groups = current_user.publications(Group)\n @in_search_page = true\n respond_to do |format|\n format.any(:html, :wml) {\n # render :template=>'groups/index'\n }\n format.json { render :json => @groups }\n end\n end",
"def list_users\n group_id_param = params[:group_id]\n\n if group_id_param.nil? || group_id_param.blank?\n render json: { error: 'group_id not specified.' }, status: :bad_request\n return\n end\n\n group = CanvasSpaces.GroupCategory.groups.find_by_id(group_id_param)\n if group.nil?\n render json: { error: 'No such group found.' }, status: :bad_request\n else\n if @current_user.account.site_admin? || group.leader_id == @current_user.id\n render json: { size: group.users.count, users: group.users.map { |user| user.as_json(only: [:id, :name], include_root: false) } }, status: :ok\n else\n # doesn't have access to the group\n render json: { error: \"Can't list users. Not owner.\" }, status: :forbidden\n end\n end\n end",
"def show\n respond_with @project do |format|\n format.json { render json: decorate_group(@group) }\n end\n end",
"def show_groups(search = nil, **params)\n params[:search] = search\n\n get('groups', params)\n end",
"def get_groups(person_id,params={})\n @restv9.get_groups(person_id,params)\n end",
"def groups(params = {})\n params = params.with_indifferent_access\n # compose params into a string\n # See http://code.google.com/apis/contacts/docs/3.0/reference.html#Parameters\n # alt, q, max-results, start-index, updated-min,\n # orderby, showdeleted, requirealldeleted, sortorder\n params[\"max-results\"] = 100000 unless params.key?(\"max-results\")\n url = \"groups/default/full\"\n # TODO: So weird thing, version 3 doesn't return system groups\n # When it does, uncomment this line and use it to request instead\n # response = @api.get(url, params)\n response = @api.get(url, params, {\"GData-Version\" => \"2\"})\n\n case defined?(response.code) ? response.code : response.status\n when 401; raise\n when 403; raise\n when 404; raise\n when 400...500; raise\n when 500...600; raise\n end\n GoogleContactsApi::GroupSet.new(response.body, @api)\n end",
"def show\n save_navi_state(['groups_title', 'browse_groups'])\n begin\n @group = Group.find(params[:id])\n @members = @group.members(session[:cookie]).paginate :page => params[:page], :per_page => per_page\n rescue RestClient::ResourceNotFound => e\n flash[:error] = :group_not_found\n redirect_to groups_path\n rescue ActiveRecord::RecordNotFound => e\n flash[:error] = :group_not_found\n redirect_to groups_path\n end\n end",
"def index\n @reagent_groups = ReagentGroup.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @reagent_groups }\n end\n end",
"def index\n groupname = params[:groupname]\n @groups = Group.all\n @users = User.all\n end",
"def my_groups\n groups = Group.joins(:group_users).where(:group_users => {user_id: params[:user_id]})\n\n paginate json: groups\n end",
"def index\n @groups = @flr.groups.all\n end",
"def read ()\n groups_validate\n\n gid = @options[:groupId]\n\n client = GroupsClient.new\n client.api_token = @options[:api_token]\n client.app_url = @options[:app_url]\n\n resp = client.read( gid)\n print_json resp\n end",
"def my_groups\n @tasks_groups = current_user.tasks_groups.where(removed: false)\n respond_to do |format|\n format.html\n format.json do\n render json: {type: @tasks_groups.class.to_s, value: @tasks_groups}\n end\n end\n end",
"def index\n\n @groups = Group.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @groups }\n end\n end",
"def index\n if request.xhr?\n organization_id = params[\"organization_id\"]\n per_page = params[:iDisplayLength] || Settings.per_page\n page = params[:iDisplayStart] ? ((params[:iDisplayStart].to_i/per_page.to_i) + 1) : 1\n params[:iSortCol_0] = 1 if params[:iSortCol_0].blank?\n sort_field = SORT_GROUP_MAP[params[:iSortCol_0].to_i]\n @user_groups = UserGroup.get_all_user_groups(page, per_page, params[:sSearch], sort_field + \" \" + params[:sSortDir_0],organization_id)\n render :json => @user_groups\n return\n end\n end",
"def index\n @item_groups = ItemGroup.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @item_groups }\n end\n end",
"def to_json(*_args)\n get_groups.to_json\n end",
"def battlegroups\r\n BnetApi::make_request('/wow/data/battlegroups/')\r\n end",
"def list\n @contact_groups = Admin::ContactGroup.names\n\n render json: { contactGroups: @contact_groups }\n end",
"def get_all_groups_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: GroupControllerApi.get_all_groups ...'\n end\n allowable_values = [\"ASC\", \"DESC\"]\n if @api_client.config.client_side_validation && opts[:'sort'] && !allowable_values.include?(opts[:'sort'])\n fail ArgumentError, \"invalid value for \\\"sort\\\", must be one of #{allowable_values}\"\n end\n # resource path\n local_var_path = '/groups/paginated'\n\n # query parameters\n query_params = opts[:query_params] || {}\n query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?\n query_params[:'size'] = opts[:'size'] if !opts[:'size'].nil?\n query_params[:'sort'] = opts[:'sort'] if !opts[:'sort'].nil?\n query_params[:'since'] = opts[:'since'] if !opts[:'since'].nil?\n query_params[:'before'] = opts[:'before'] if !opts[:'before'].nil?\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['*/*'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:body] \n\n # return_type\n return_type = opts[:return_type] || 'PageGroupProjection' \n\n # auth_names\n auth_names = opts[:auth_names] || ['API_KEY']\n\n new_options = opts.merge(\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: GroupControllerApi#get_all_groups\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def index\n @groups = Group.where(:user_id => current_user)\n end"
] |
[
"0.8286577",
"0.8278107",
"0.7801243",
"0.7762667",
"0.77249485",
"0.765602",
"0.765602",
"0.76541275",
"0.7636101",
"0.7561083",
"0.7547335",
"0.74825233",
"0.74768126",
"0.7467619",
"0.74643844",
"0.73794276",
"0.7367821",
"0.7351049",
"0.7334809",
"0.72987163",
"0.7240665",
"0.72341496",
"0.72240275",
"0.72093844",
"0.71999973",
"0.71918154",
"0.71852154",
"0.71806425",
"0.7151056",
"0.71137816",
"0.71062684",
"0.7101395",
"0.7101395",
"0.7099279",
"0.7095029",
"0.70821005",
"0.7081378",
"0.705995",
"0.70575756",
"0.7020953",
"0.7009819",
"0.6993755",
"0.69828355",
"0.69828355",
"0.6981142",
"0.69761527",
"0.69528085",
"0.69503367",
"0.69503367",
"0.69503367",
"0.69503367",
"0.69503367",
"0.69503367",
"0.69503367",
"0.69503367",
"0.69503367",
"0.69503367",
"0.69503367",
"0.69503367",
"0.6944941",
"0.6923423",
"0.6919615",
"0.6909292",
"0.6883891",
"0.6873299",
"0.68704486",
"0.6867646",
"0.68592393",
"0.68547857",
"0.685231",
"0.6829983",
"0.6829983",
"0.6828063",
"0.6809969",
"0.68076944",
"0.6799788",
"0.6793489",
"0.67876714",
"0.6752881",
"0.6747022",
"0.6741434",
"0.6734172",
"0.67285085",
"0.6728095",
"0.67232233",
"0.6713065",
"0.6708964",
"0.6706439",
"0.67028767",
"0.67022896",
"0.66955376",
"0.66941154",
"0.6683999",
"0.6672888",
"0.6667764",
"0.66631126",
"0.6653767",
"0.66525614",
"0.66492444",
"0.66426736",
"0.66383356"
] |
0.0
|
-1
|
GET /groups/1 GET /groups/1.json
|
def show
@users = User.all
@group = Group.find(params[:id])
@contents = @group.contents.all
@usergroups = GroupsUser.all
@groupcategory = GroupCategory.where(:group_id => params[:id])
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def GetGroup id\n\n APICall(path: \"groups/#{id}.json\")\n\n end",
"def groups\n \n \n @groups = @current_user.groups\n render 'groups.json.jbuilder', status: :ok\n end",
"def show\n group = Group.find(params[:id])\n\n render json: group\n end",
"def GetGroups params = {}\n\n params = params.merge(path: 'groups.json')\n APICall(params)\n\n end",
"def index\n @groups = Group.all\n\n respond_to do |format|\n format.html\n format.json { render json: @groups }\n end\n end",
"def index\n @groups = Group.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @groups }\n end\n end",
"def index\n @groups = Group.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @groups }\n end\n end",
"def index\n @groups = Group.all\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @groups }\n end\n end",
"def show\n @group = Group.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @group }\n end\n end",
"def show\n @group = Group.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @group }\n end\n end",
"def index\n @groups = current_user.groups\n render json: @groups\n end",
"def show\n @group = Group.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @group }\n end\n end",
"def show\n render json: @group\n end",
"def get_groups\n @course = Course.find(params[:course_id])\n render json: @course.groups\n end",
"def show_group\n\t\t@student = Student.find(params[:student_id])\n\t\trender json: @student.groups.find_by(course_id: params[:course_id])\n\tend",
"def get_group_by_id(id)\n get(\"/groups/#{id}\")\n end",
"def show\n @group = Group.find(params[:id])\n respond_to do |format|\n # format.html # show.html.erb\n format.json { render :json => @group}\n end\n end",
"def index\n @groups = Group.all\n render_json_serializer(@groups)\n end",
"def show\n @user_group = UserGroup.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @user_group }\n end\n end",
"def show\n #@group = Group.find(params[:id])\n \n @users = @group.users\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @group }\n end\n end",
"def show_group(id)\n get(\"groups/#{id}\")\n end",
"def index\n @title = \"Группы характеристик\"\n @groups = Group.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @groups }\n end\n end",
"def showgrp\n @grp = params[:id].to_s\n @groups=Group.where(\"kls_parent=\"+@grp).order(\"name asc\")\n render json: @groups\n end",
"def show\n @group = Group.find(params[:id])\n @members = Member.find(:all, :conditions => [\"group_id = ? and deleted = 0\", params[:id]])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @group }\n end\n end",
"def get_group\n send_request(FUNCTION_GET_GROUP, [], '', 4, 'k4')\n end",
"def show\n #logger.info \"GroupsController Get Parameters: #{params}\"\n if @group\n render json: @group.to_json(:include => {:memberships => {:only => [:admin], :include => {:user => {:only => [:id, :first_name, :last_name, :email]}}}})\n else\n render json: {error: \"YOU MUST BE MEMBER OF THIS GROUP TO SEE IT\"}, status: :unprocessable_entity\n end\n end",
"def index\n\n @groups = Group.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @groups }\n format.json { render :json => @groups }\n end\n end",
"def getGroup( group_id)\n params = Hash.new\n params['group_id'] = group_id\n return doCurl(\"get\",\"/group\",params)\n end",
"def group_info\n group_id_param = params[:group_id]\n\n if group_id_param.nil? || group_id_param.blank?\n render json: { error: 'group_id not specified.' }, status: :bad_request\n return\n end\n\n group = CanvasSpaces.GroupCategory\n .groups\n .where('groups.id = ?', group_id_param)\n .eager_load(:users)\n .first\n if group.nil?\n render json: { error: 'No such group found.' }, status: :not_found\n else\n maillist = get_maillist_for_space(group.id)\n render json: { id: group.id,\n name: group.name,\n description: group.description,\n maillist: maillist,\n leader_id: group.leader_id,\n created_at: group.created_at,\n join_type: display_join_type(group.join_level),\n size: group.users.count\n },\n status: :ok\n end\n end",
"def list_groups\n if @user.permission_level.value == PermissionLevel.order(\"value DESC\").first.value\n render :json => Group.find(:all).map{|g| g}\n else\n render :json => @user.groups.map{|g| g}\n end\n end",
"def show\n respond_with @project do |format|\n format.json { render json: decorate_group(@group) }\n end\n end",
"def get_group\n @group = Group.find(params[:id])\n end",
"def list_groups()\n response = HTTParty.get(\"https://graph.microsoft.com/v1.0/groups\", { \n headers: {\n \"Authorization\" => \"Bearer #{bearerToken}\",\n \"Host\" => 'graph.microsoft.com' \n }\n })\n return JSON.parse response.read_body\n end",
"def groups(params = {})\n @api.get(\"#{@api.path}/List/#{@id}/Groups\", params: params)\n end",
"def show\n @title = \"Группа характеристик\"\n @group = Group.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @group }\n end\n end",
"def show\n objid = params[:id]\n obj = ManagingGroup.find_by_id(objid)\n if obj\n render json: {managing_group: obj}, status: 200\n else\n render json: {}, status: 404\n end\n rescue => error\n render json: {}, status: 500\n end",
"def index\n authorize Group\n render :json => @group.group_memberships\n end",
"def read (group_id = nil)\n\n url = @app_url + \"/api/groups\"\n url = url << \"/#{group_id}\" unless group_id == nil\n\n response = RestClient.get url, {\"X-Token\" => @api_token, :accept => :json}\n\n json_obj = nil\n\n if response.code == 200\n json_obj = JSON.parse(response.body.to_s)\n else\n raise RuntimeError.new(\"Invalid response: #{response.code.to_s}\")\n end\n\n json_obj\n end",
"def index\n render json: current_user.membered_groups\n end",
"def index\n @groupsIds = GroupsProssumer.where(prossumer_id: params[:prossumer_id]).pluck(:group_id)\n @groups = Group.where(id: @groups)\n render json: @groups\n end",
"def show\n @groupon = Groupon.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @groupon }\n end\n end",
"def show\n @groupaddrobj = Groupaddrobj.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @groupaddrobj }\n end\n end",
"def show\n save_navi_state(['groups_title', 'browse_groups'])\n begin\n @group = Group.find(params[:id])\n @members = @group.members(session[:cookie]).paginate :page => params[:page], :per_page => per_page\n rescue RestClient::ResourceNotFound => e\n flash[:error] = :group_not_found\n redirect_to groups_path\n rescue ActiveRecord::RecordNotFound => e\n flash[:error] = :group_not_found\n redirect_to groups_path\n end\n end",
"def show\n @group = Group.find(params[:id])\n\n render json: @group.to_json(:include => {:memberships => {:only => [:admin], :include => {:user => {:only => [:id, :first_name, :last_name, :email]}}}})\n end",
"def groups(options = {})\n params = { :limit => 200 }.update(options)\n response = get(PATH['groups_full'], params)\n parse_groups response_body(response)\n end",
"def index\n @groups = Group.all\n\n @host_groups = Group.where \"groupable_type = 'HostGroup'\"\n @fan_groups = Group.where \"groupable_type = 'FanGroup'\"\n @artist_groups = Group.where \"groupable_type = 'ArtistGroup'\"\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @groups }\n end\n end",
"def group(group_id)\n get(\"/v1/groups/#{group_id}\")\n end",
"def index\n @students = current_user.groups[0].students\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @students }\n end\n end",
"def index\n @group = current_user.groups.find_by(id: params[:group_id]) || @groups.first\n end",
"def index\n @groups = Group.accessible_by(current_ability)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @groups }\n format.xml { render xml: @groups }\n end\n end",
"def index\n @groups = current_user.groups\n @groups = @groups.where('name LIKE ?', \"%#{params[:q]}%\") if params[:q].present?\n @groups = current_user.groups_sorted_by_admin_state_and_name(@groups)\n @groups_pictures = Group.group_images_hash_for_groups @groups\n\n respond_to do |format|\n format.html { render :index }\n format.json { render json: @groups }\n end\n end",
"def index\n @groups = Group.all\n end",
"def index\n @groups = Group.all\n end",
"def index\n @groups = Group.all\n end",
"def index\n @groups = Group.all\n end",
"def index\n @groups = Group.all\n end",
"def index\n @groups = Group.all\n end",
"def index\n @groups = Group.all\n end",
"def index\n @groups = Group.all\n end",
"def index\n @groups = Group.all\n end",
"def index\n @groups = Group.all\n end",
"def index\n @groups = Group.all\n end",
"def index\n @groups = Group.all\n end",
"def index\n respond_with @project do |format|\n format.json { render json: decorate_groups }\n end\n end",
"def show\n\n @group = Group.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @group }\n format.json { render :json => @group }\n end\n end",
"def show\n @group_user = GroupUser.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @group_user }\n end\n end",
"def show\n @group_stat = GroupStat.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @group_stat }\n end\n end",
"def show\n @image_group = ImageGroup.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @image_group }\n end\n end",
"def index\n @groupons = Groupon.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @groupons }\n end\n end",
"def show\n @group = Group.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @group }\n format.xml { render xml: @group }\n end\n end",
"def read ()\n groups_validate\n\n gid = @options[:groupId]\n\n client = GroupsClient.new\n client.api_token = @options[:api_token]\n client.app_url = @options[:app_url]\n\n resp = client.read( gid)\n print_json resp\n end",
"def show_group(id)\n BrickFTP::API::Group.find(id)\n end",
"def show_group(id)\n BrickFTP::API::Group.find(id)\n end",
"def get_groups(params)\n send_get \"get_groups\", params\n end",
"def show\n @group = GROUP.first_or_get!(params[:id])\n\n # restrict the groups to the groups of the current user\n # unless the current user is allowed to create groups\n # and need to see all\n unless allowed(:create)\n allowed_groups = current_user.groups\n end\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @group }\n end\n end",
"def groups\n UserGroups.new(:id => id).get.items\n end",
"def new\n @user = User.find(params[:user_id])\n @groups = @user.groups.new\n\n #@group = Group.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @group }\n end\n end",
"def index\n @groups = query(GROUP, :name)\n\n # restrict the groups to the groups of the current user\n # unless the current user is allowed to create groups\n # and need to see all\n unless allowed(:create)\n allowed_group_ids = current_user.groups.collect {|g| g.id }\n @groups.delete_if do |g|\n ! allowed_group_ids.member?(g.id)\n end\n end\n\n respond_to do |format|\n format.html\n format.xml { render :xml => @groups }\n end\n end",
"def fetch_group\n @group = Group.find(params[:group_id])\n end",
"def groups(inherited = false)\n uri = build_uri('groups', inherited: inherited.to_s)\n req = Net::HTTP::Get.new(uri, DEFAULT_HEADERS)\n resp = request(req)\n obj = if resp.code == '200'\n JSON.parse(resp.body)\n else\n raise_on_non_200(resp, 200)\n end\n obj\n end",
"def show\n @item_group = ItemGroup.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item_group }\n end\n end",
"def index\n @group_users = GroupUser.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @group_users }\n end\n end",
"def show_group\n group_name = params[:name]\n @group = $iam.groups[group_name]\n @users = @group.users\n @policies = @group.policies\n end",
"def show\n @pgroup = Pgroup.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @pgroup }\n end\n end",
"def show\n @pgroup = Pgroup.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @pgroup }\n end\n end",
"def show\n @group = Group.find(params[:id])\n return render 'index'\n end",
"def list\n @groups = Group.find(:all, :order => 'name')\n end",
"def new\n @group = Group.new\n render json: @group\n end",
"def index\n @group_stats = GroupStat.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @group_stats }\n end\n end",
"def retrieve_group\n @group = Group.find(params[:group_id])\n end",
"def new\n @group = Group.new\n\n render json: @group\n end",
"def index\n\n\t\t@groups = Group.find_paginate({:user=> current_user, :page => params[:page], :query => params[:query], :sort => params[:sort], :nb_items => get_nb_items(params[:nb_items]) })\n\n\t\trespond_to do |format|\n\t\t\tformat.html # index.html.erb\n\t\t\tformat.xml { render :xml => @groups }\n\t\t\tformat.json { render :json => @groups }\n\t\tend\n\tend",
"def view_group(group)\n @uri = URI.parse(\"#{@api_url}/group/#{group}\")\n body = make_get_request\n @doc = Nokogiri::HTML(body)\n {\n title: get_title,\n description: get_description,\n name: get_name,\n regid: get_regid,\n contact: get_contact\n }\n end",
"def index\n objs = ManagingGroup.all.order(:position)\n if objs\n render json: {managing_groups: objs}, status: 200\n else\n render json: {}, status: 500\n end\n rescue => error\n render json: {}, status: 500\n end",
"def show\n @group = Group.find(params[:id])\n @meetups = Meetup.where(\"group_id = ?\", @group.id)\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @group }\n end\n end",
"def call(id)\n res = client.get(\"/api/rest/v1/groups/#{id}.json\")\n return nil if !res || res.empty?\n\n BrickFTP::Types::Group.new(**res.symbolize_keys)\n end",
"def get_group(group_id = 0)\n current_path = \"/api/v1/groups/#{group_id}\"\n @conn.get(current_path)\n end",
"def belonging_groups\n contact_groups = []\n @contact.contact_groups.each do |group|\n contact_groups << { _id: group['_id'].to_s, lbl: group['label'] }\n end\n\n respond_to do |format|\n format.js {}\n format.json { render json: contact_groups }\n end\n end",
"def index\n authorize! :see, Group\n @groups = Group.all\n end",
"def get_group_by_id(id)\n $r.hgetall(\"group:#{id}\")\n end",
"def index\n @groups_all = current_user.groups.paginate(page: params[:page]).order('name ASC')\n\n @owner = current_user\n @users = User.where(\"owner_id = ?\", current_user).order('lastname ASC')\n\n respond_to do |format|\n format.html { render @groups }\n format.json { render json: @groups }\n end\n end"
] |
[
"0.7906696",
"0.77682996",
"0.77013576",
"0.7696094",
"0.76500016",
"0.7552326",
"0.7552326",
"0.7536221",
"0.74999285",
"0.74999285",
"0.74628925",
"0.7451343",
"0.7425182",
"0.7417058",
"0.7410386",
"0.7380656",
"0.73710245",
"0.7351068",
"0.7332308",
"0.73154056",
"0.73041874",
"0.7259142",
"0.7220922",
"0.7218451",
"0.7196568",
"0.71804935",
"0.7121687",
"0.71006715",
"0.7074818",
"0.7069269",
"0.7044283",
"0.70384675",
"0.70349926",
"0.7023915",
"0.7022536",
"0.7012563",
"0.700895",
"0.7008147",
"0.7006355",
"0.7002014",
"0.69844866",
"0.6974681",
"0.69541264",
"0.6951915",
"0.69517905",
"0.6940479",
"0.6937168",
"0.69370544",
"0.6934413",
"0.6919165",
"0.6916966",
"0.6916647",
"0.6916647",
"0.6916647",
"0.6916647",
"0.6916647",
"0.6916647",
"0.6916647",
"0.6916647",
"0.6916647",
"0.6916647",
"0.6916647",
"0.6916647",
"0.6913781",
"0.6894839",
"0.68865305",
"0.6883544",
"0.6876438",
"0.6866893",
"0.6864539",
"0.68559825",
"0.68430847",
"0.68430847",
"0.6841058",
"0.68378866",
"0.6824608",
"0.68153054",
"0.6803746",
"0.6803179",
"0.6802538",
"0.6772432",
"0.6771751",
"0.6768379",
"0.6760629",
"0.6760629",
"0.6759607",
"0.6743094",
"0.67302626",
"0.67240983",
"0.67234683",
"0.6714438",
"0.67116153",
"0.6711012",
"0.670776",
"0.67049",
"0.6701797",
"0.6699015",
"0.66940516",
"0.66907996",
"0.66902673",
"0.66890997"
] |
0.0
|
-1
|
POST /groups POST /groups.json
|
def create
@user = User.find(current_user.id)
@group = Group.new(group_params)
@group.title = params[:title]
@group.description = params[:description]
@group.groupProfile = params[:groupProfile]
@group.groupCover = params[:groupCover]
respond_to do |format|
if @group.save
@user.groups << @group
GroupCategory.new(group_id: @group.id , category_id: params[:category]).save
format.html { redirect_to user_group_path(current_user.id, @group.id) }
format.json { render :show, status: :created, location: @group }
else
format.html { render :new }
format.json { render json: @group.errors, status: :unprocessable_entity }
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def CreateGroup params = {}\n \n APICall(path: 'groups.json',method: 'POST',payload: params.to_json)\n \n end",
"def create\n #logger.info \"Post parameters: #{params}\"\n @group = Group.new(name: params[:group][:name], expiration: params[:group][:expiration], owner: current_user)\n if @group.save\n @group.memberships.create!(user: current_user, admin: true)\n if params[:group][:users]\n params[:group][:users].each do |u|\n @group.memberships.create!(user: User.where(\"id = ? OR email = ?\", u[:id], u[:email]).first, admin:u[:admin])\n end\n end\n render json: @group, status: :created, location: @group\n else\n render json: @group.errors, status: :unprocessable_entity\n end\n end",
"def create\n #logger.info \"Post parameters: #{params}\"\n @group = Group.new(name: params[:group][:name], expiration: params[:group][:expiration])\n if @group.save\n params[:group][:users].each do |u|\n Membership.create(group: @group, user: User.where(\"id = ? OR email = ?\", u[:id], u[:email]).first, admin:u[:admin])\n end\n render json: @group, status: :created, location: @group\n else\n render json: @group.errors, status: :unprocessable_entity\n end\n end",
"def create\n group = Group.new(group_params)\n if group.save\n render json: group\n else\n render json: group.errors.full_messages, status: :unprocessable_entity\n end\n end",
"def createGroup(groupName, gid)\r\n uri = sprintf(\"/api/v1/group_categories/%d/groups\", gid) \r\n \r\n dbg(\"POST #{uri}\")\r\n dbg(\"name=#{groupName}\")\r\n newGroup = $canvas.post(uri, {'name' => groupName})\r\n dbg(newGroup)\r\n return newGroup\r\nend",
"def createGroup(groupName, gid)\r\n uri = sprintf(\"/api/v1/group_categories/%d/groups\", gid) \r\n \r\n dbg(\"POST #{uri}\")\r\n dbg(\"name=#{groupName}\")\r\n newGroup = $canvas.post(uri, {'name' => groupName})\r\n dbg(newGroup)\r\n return newGroup\r\nend",
"def create_group(path, name)\n puts \"creating #{name} on path #{path}\"\n \n ret = RestClient.post \"#{@url}/groups\", \n { path: path, name: name }, \n { \"Private-Token\": @token } \n json = JSON.parse(ret.body)\n\n json['id']\n end",
"def create\n @group = Group.new(group_params)\n\n if @group.save\n render_json_message({:success => t('.success')}, 201, {id: @group.id})\n else\n render_json_message({:errors => @group.errors.messages}, 422)\n end\n\n end",
"def create\n ip = request.location\n @user = current_user\n @group = @user.groups_as_owner.new(params[:group])\n params[:group][:member_ids] = (params[:group][:member_ids] << @group.member_ids).flatten\n @group.school_id = @user.school_id\n respond_to do |format|\n if @group.save\n format.html { redirect_to @group, notice: 'Group was successfully created.' }\n format.json { render json: @group, status: :created, location: @group }\n else\n format.html { render action: \"new\" }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def add_new_groups(params = {})\n post(\"/groups\", params)\n end",
"def create\n new_group = Group.new(name: params[:name])\n\n if new_group.save\n render json: { \"notice\"=>\"new group #{params[:name]} successfully created\" }\n else\n render json: { \"alert\"=>\"group creation failed. check params.\" }\n end\n end",
"def create\n @group = Group.new(group_params)\n @group.owner = current_user\n\n if @group.save\n @group.add!(current_user)\n \n render json: @group, status: :created, location: @group\n else\n render json: @group.errors, status: :unprocessable_entity\n end\n end",
"def create\n @group = Group.new(params[:group])\n\n respond_to do |format|\n if @group.save\n format.html { redirect_to @group, :notice => 'Group was successfully created.' }\n format.json { render :json => @group, :status => :created, :location => @group}\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @group.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @group = Group.new(group_params)\n\n respond_to do |format|\n if @group.save\n format.html { redirect_to groups_path, notice: 'Group was successfully created.' }\n format.json { render :show, status: :created, location: @group }\n else\n format.html { render :new }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @group = @current_user.create_group(params[:group])\n # @group = @current_user.groups.build(params[:group])\n # @group = Group.new(params[:group])\n\n respond_to do |format|\n if @group.valid?\n format.html { redirect_to circle_groups_path, notice: 'Group was successfully created.' }\n format.json { render json: @group, status: :created, location: @group }\n else\n format.html { render action: \"new\" }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @group = Group.new(group_params)\n\n respond_to do |format|\n if @group.save\n format.json { render json: @group, status: :created }\n else\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @group = Group.new(params[:group])\n @group.owner = current_user\n\n group_name_exists = false\n current_user.owned_groups.each do |g|\n if g.name == @group.name\n group_name_exists = true\n break\n end\n end\n \n respond_to do |format|\n if group_name_exists\n format.html { redirect_to groups_path, :alert => \"You already have a list by the name '#{@group.name}'.\" }\n format.json { render :json => @group, :status => :created, :location => @group }\n elsif @group.save\n format.html { redirect_to @group, :notice => 'Group was successfully created.' }\n format.json { render :json => @group, :status => :created, :location => @group }\n else\n error_msg = 'Unexpected error while creating group.'\n if @group.errors.messages.count > 0\n error_msg = 'Following error(s) prevented the group from being saved: '\n multiple = false\n @group.errors.full_messages.each do |msg|\n if multiple\n error_msg += ', '\n end\n error_msg += msg\n multiple = true\n end\n end\n format.html { redirect_to groups_path, :action => 'index', :alert => error_msg }\n format.json { render :json => @group.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @group = Group.new(params[:group])\n\n respond_to do |format|\n if @group.save\n format.html { redirect_to @group, notice: 'Group was successfully created.' }\n format.json { render json: @group, status: :created, location: @group }\n else\n format.html { render action: \"new\" }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @group = Group.new(params[:group])\n\n respond_to do |format|\n if @group.save\n format.html { redirect_to @group, notice: 'Group was successfully created.' }\n format.json { render json: @group, status: :created, location: @group }\n else\n format.html { render action: \"new\" }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @group = Group.new(params[:group])\n\n respond_to do |format|\n if @group.save\n format.html { redirect_to @group, notice: 'Group was successfully created.' }\n format.json { render json: @group, status: :created, location: @group }\n else\n format.html { render action: \"new\" }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @group = Group.new(params[:group])\n\n respond_to do |format|\n if @group.save\n format.html { redirect_to @group, notice: 'Group was successfully created.' }\n format.json { render json: @group, status: :created, location: @group }\n else\n format.html { render action: \"new\" }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @group = Group.new(params[:group])\n\n respond_to do |format|\n if @group.save\n format.html { redirect_to @group, notice: 'Group was successfully created.' }\n format.json { render json: @group, status: :created, location: @group }\n else\n format.html { render action: \"new\" }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_group(attributes)\n post(\"/v1/groups\", attributes)\n end",
"def create\n @group = Group.new(group_params)\n\n respond_to do |format|\n if @group.save\n format.html { redirect_to @group, notice: 'Group was successfully created.' }\n format.json { render :show, status: :created, location: @group }\n else\n format.html { render :new }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @group = Group.new(group_params)\n\n respond_to do |format|\n if @group.save\n format.html { redirect_to @group, notice: 'Group was successfully created.' }\n format.json { render :show, status: :created, location: @group }\n else\n format.html { render :new }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @group = Group.new(group_params)\n\n respond_to do |format|\n if @group.save\n format.html { redirect_to @group, notice: 'Group was successfully created.' }\n format.json { render :show, status: :created, location: @group }\n else\n format.html { render :new }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @group = Group.new(group_params)\n\n respond_to do |format|\n if @group.save\n format.html { redirect_to @group, notice: 'Group was successfully created.' }\n format.json { render :show, status: :created, location: @group }\n else\n format.html { render :new }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @group = Group.new(group_params)\n\n respond_to do |format|\n if @group.save\n format.html { redirect_to @group, notice: 'Group was successfully created.' }\n format.json { render :show, status: :created, location: @group }\n else\n format.html { render :new }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @group = Group.new(group_params)\n\n respond_to do |format|\n if @group.save\n format.html { redirect_to @group, notice: 'Group was successfully created.' }\n format.json { render :show, status: :created, location: @group }\n else\n format.html { render :new }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n #should expire groups page cache\n \n # expire the cache of the grouplist of this user\n Rails.cache.delete(Person.groups_cache_key(@current_user.id, session[:cookie]))\n \n @group = Group.new\n begin\n @group = Group.create(params[\"group\"], session[:cookie])\n flash[:notice] = :group_created_successfully\n redirect_to group_path(@group) and return\n rescue RestClient::RequestFailed => e\n @group.add_errors_from(e)\n @group.form_title = params[:group][:title]\n @group.form_description = params[:group][:description]\n render :action => :new and return\n rescue RestClient::Unauthorized => e\n @group.add_errors_from(e)\n @group.form_title = params[:group][:title]\n @group.form_description = params[:group][:description]\n render :action => :new and return \n end\n end",
"def create\n @group = Group.new(group_params)\n respond_to do |format|\n if @group.save\n @group.users.push(current_user)\n UserGroup.set_is_admin(@group.id, current_user.id, true)\n invite_members\n format.html { redirect_to @group, notice: t('flash.notice.groups.successfully_created') }\n format.json { render :show, status: :created, location: @group }\n else\n format.html { render :new }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @group = Group.new(group_params)\n\n respond_to do |format|\n if @group.save\n format.html { redirect_to @group, notice: 'Group was successfully created.' }\n format.json { render action: 'show', status: :created, location: @group }\n else\n format.html { render action: 'new' }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @group = Group.new(group_params)\n\n respond_to do |format|\n if @group.save\n format.html { redirect_to @group, notice: 'Le groupe a été créé.' }\n format.json { render :show, status: :created, location: @group }\n else\n format.html { render :new }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @user.create_group!(new_group_params[:group_user_ids], {name: new_group_params[:name]})\n end",
"def create\n @group = Group.new(group_params)\n @group.user = @user\n respond_to do |format|\n if @group.save\n format.html { redirect_to @group, notice: 'Group was successfully created.' }\n format.json { render :show, status: :created, location: @group }\n else\n format.html { render :new }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def generate(groups)\n groups_params = groups.inject({}) do |params, (k, v)|\n params[\"groups[#{k}]\"] = 1\n params\n end\n\n response = RouteNGN.put self.class.base_url, {:id => self.id}.merge!(groups_params)\n response.success?\n end",
"def create\n @group = Group.new(params[:group])\n new_sort = Configurations.get_sort('group')\n @group.sort = new_sort\n @group.deleted = 0\n\n respond_to do |format|\n if @group.save\n format.html { redirect_to :groups, notice: 'Group was successfully created.' }\n format.json { render json: @group, status: :created, location: @group }\n else\n format.html { render action: \"new\" }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @group = Group.new(group_params)\n @group.create_robotsurvey()\n @group.create_signupsurvey()\n @group.create_poststudysurvey()\n respond_to do |format|\n if @group.save\n \n format.html { redirect_to @group, notice: 'Group was successfully created.' }\n format.json { render action: 'show', status: :created, location: @group }\n else\n format.html { render action: 'new' }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new_nodegroup(nodegroup_json)\n nodemgr_rest_call(\"POST\", \"classifier\", \"groups\", $credentials, id=\"\", nodegroup_json)\nend",
"def create\n @group = Group.new(params[:group])\n\t\t@group.user_id = session[:user_id]\n\n respond_to do |format|\n if @group.save\n\n\t\t\t\t@page = Page.create(:owner => @group.id, :category => 'group')\n\t\t\t\t@group_member = GroupMember.create(:group_id => @group.id, :user_id => session[:user_id], :moderator => true)\n format.html { redirect_to groups_url, :notice => 'Group was successfully created.' }\n format.json { render :json => @group, :status => :created, :location => @group }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @group.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n \n @group = Group.new(group_params)\n @group.owner_id = current_user.id\n @group.users << current_user\n\n respond_to do |format|\n if @group.save\n format.html { redirect_to @group, notice: 'Group was successfully created.' }\n format.json { render :show, status: :created, location: @group }\n else\n format.html { render :new }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @group = Group.new(group_params)\n @group.owner = current_user\n\n respond_to do |format|\n if @group.save\n format.html { redirect_to group_path(@group), notice: \"Group was successfully created.\" }\n format.json { render :show, status: :created, location: @group }\n else\n format.html { render :new }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @user_group = UserGroup.new(params[:user_group])\n\n respond_to do |format|\n if @user_group.save\n format.html { redirect_to @user_group, notice: 'User group was successfully created.' }\n format.json { render json: @user_group, status: :created, location: @user_group }\n else\n format.html { render action: \"new\" }\n format.json { render json: @user_group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @user_group = UserGroup.new(params[:user_group])\n\n respond_to do |format|\n if @user_group.save\n format.html { redirect_to @user_group, notice: 'User group was successfully created.' }\n format.json { render json: @user_group, status: :created, location: @user_group }\n else\n format.html { render action: \"new\" }\n format.json { render json: @user_group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def groups\n \n \n @groups = @current_user.groups\n render 'groups.json.jbuilder', status: :ok\n end",
"def create\n @resource = Group.new(group_params)\n\n respond_to do |format|\n if @resource.save\n index\n\n flash[:success] = t('notices.saved_successfully')\n format.html { redirect_to @resource, notice: 'Group was successfully created.' }\n format.json { render :show, status: :created, location: @resource }\n else\n format.html { render :new }\n format.json { render json: @resource.errors, status: :unprocessable_entity }\n end\n format.js\n end\n end",
"def create\n @user = current_user\n @group = Group.new(group_params)\n @group.save\n respond_with(@group)\n end",
"def create\n if(params[:group][:name].nil?) or (params[:group][:name] == \"\")\n flash[:notice] = \"Group must have a name and description\"\n redirect_to new_group_path\n else\n \n #create a new group\n @group = Group.new(group_params)\n user = User.find(session[:user_id]) \n respond_to do |format|\n if @group.save\n #generate a code for the group\n o = [('a'..'z'), ('A'..'Z')].map(&:to_a).flatten\n new_code = (0...8).map { o[rand(o.length)] }.join\n @group.update(code: new_code)\n #after group is created add creator to group as leader\n Membership.create!(user_id: session[:user_id], group_id: @group.id, member_type: 'leader', username: user.username)\n format.html {redirect_to @group, notice: \"Group was successfully created.\"}\n format.json {render :show, status: :created, location: @group}\n else\n format.html {render :new, status: :unprocessable_entity}\n format.json {render json: @group.errors, status: :unprocessable_entity}\n end\n end\n end\n end",
"def create\n @group = Group.new(params[:group])\n\n respond_to do |format|\n if @group.save\n flash[:success] = \"Группа успешно добавлена.\"\n format.html { redirect_to @group }\n format.json { render json: @group, status: :created, location: @group }\n else\n flash.now[:error] = \"Группа с таким названием не может быть добавлена!\"\n format.html { render action: \"new\" }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @group = Group.new(group_params)\n\n respond_to do |format|\n if @group.save\n format.html { redirect_to @group, notice: 'Новая группа создана!' }\n format.json { render :show, status: :created, location: @group }\n else\n format.html { render :new }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n #redirect_to new_grouping_path if params[:grouping][:name] == ''\n #@grouping = Grouping.new(params[:grouping])\n @grouping.company_id = current_user.company_id\n\n if @grouping.save\n gflash :success => 'Group created.' \n else\n @users = []\n @root = false\n end\n \n #redirect_to edit_grouping_path(@grouping)\n respond_with(@grouping)\n end",
"def create\n @group = Group.new(group_params)\n @group.admin_id = current_user.id\n respond_to do |format|\n if @group.save\n\tUserGroup.create(admin: true, user_id: current_user.id, group_id: @group.id)\n\tflash[:success] = \"Group was successfully created!\"\n format.html { redirect_to @group }\n format.json { render action: 'show', status: :created, location: @group }\n else\n format.html { render action: 'new' }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @group = Group.new(params[:group])\n\n if @group.save\n flash[:notice] = t('flash_msg46')\n @groups = Group.all\n else\n @error = true\n end\n end",
"def to_groups\n message = AssignTasksToGroups.new(params).perform\n json_response({message: message}, :created)\n end",
"def create\n name = params[:name]\n @group = Group.new(name: name)\n @group.creator_id = @current_user.id\n if @group.save\n @current_user.creator_join!(@group)\n respond_with(@group, only: [:id, :name, :creator_id, :admin_id])\n else\n render_error(404, request.path, 20101, @group.errors.as_json)\n end\n end",
"def create\n @group = Group.new(group_params)\n respond_to do |format|\n if @group.save\n @membership = Membership.create!(group_id: @group.id, user_id: current_user.id, admin: true)\n format.html { redirect_to @group, notice: 'Group was successfully created.' }\n format.json { render :show, status: :created, location: @group }\n else\n format.html { render :new }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def add_to_group\n if request.post?\n @user_id = params[:user_id]\n @group = params[:group_ids]\n @created_g_u= Array.new\n @group.each do |g|\n #g_user = GroupUser.find(:all,:conditions=>[\"user_id=#{@user_id.to_i} and group_id=#{g.to_i}\"])\n group_user = GroupUser.create(:user_id=>@user_id.to_i,:group_id=>g.to_i)# if g_user.blank?\n @created_g_u << group_user if group_user.id\n end\n @notice = \"Successfully added to group.\"\n respond_to do |format|\n format.js\n end\n \n else\n render :partial=>\"add_to_group_form\", :locals=>{:user=>@login_user,:user_id=>params[:id]}, :layout=>false\n end\n end",
"def create\n\n @group = Group.new(group_params)\n\n respond_to do |format|\n if @group.save\n\n @course = Course.find([@group.course_id]).first\n\n @course.cfolders.each do |cfolder|\n gfolder = @group.gfolders.create(name: cfolder.name, group_id: @group.id)\n cfolder.cposts.each do |cpost|\n gpost = gfolder.gposts.create(title: cpost.id, body: cpost.body, link: cpost.link, gfolder_id: gfolder.id)\n end\n end\n\n format.html { redirect_to [@group], notice: 'group was successfully created.' }\n format.json { render :show, status: :created, location: [@group] }\n else\n format.html { render :new }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @group = @group_model.new(group_params)\n respond_to do |format|\n if @group.save\n @course.groups<< @group\n format.html { redirect_to course_group_path(@course,@group), notice: \"#{@group_model.to_s} was successfully created.\" }\n format.json { render :show, status: :created, location: @group }\n else\n format.html { render :new }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_group(groupname)\n current_path = '/api/v1/groups'\n payload = { 'group_name' => groupname }.to_json\n @conn.post(current_path, payload)\n end",
"def create\n @group = Group.new(group_params)\n respond_to do |format|\n if @group.save\n @group.memberships.create(user_id: current_user.id, state: \"owner\")\n format.html { redirect_to @group, notice: 'Group was successfully created.' }\n format.json { render action: 'show', status: :created, location: @group }\n else\n format.html { render action: 'new' }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @group = Course.groups.new(group_params)\n\n respond_to do |format|\n if @group.save\n format.html { redirect_to @group, notice: 'Group was successfully created.' }\n format.json { render :show, status: :created, location: @group }\n else\n format.html { render :new }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @usergroup = Usergroup.new(usergroup_params)\n\n respond_to do |format|\n if @usergroup.save\n format.html { redirect_to @usergroup, notice: 'User group was successfully created.' }\n format.json { render :show, status: :created, location: @usergroup }\n else\n format.html { render :new }\n format.json { render json: @usergroup.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_group\n\t\t@group = Group.new(params[:group])\n\t\t@group.cardsort_id = params[:cardsort_id]\n\t\trespond_to do |format|\n\t\t\tif (@group.save)\n\t\t\t\tformat.js {render \"new_group\", :status => :created}\n\t\t\telse\n\t\t\t\tformat.js {render \"new_group\", :status => :ok}\n\t\t\tend\n\t\tend\n\tend",
"def create\n @usergroup = Usergroup.new(usergroup_params)\n\n respond_to do |format|\n if @usergroup.save\n format.html { redirect_to @usergroup, notice: 'Usergroup was successfully created.' }\n format.json { render :show, status: :created, location: @usergroup }\n else\n format.html { render :new }\n format.json { render json: @usergroup.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_group\n name_param = params[:name]\n description_param = params[:description]\n members_param = params[:members] || []\n maillists_param = params[:maillists] || []\n leader_id_param = params[:leader_id]\n join_type_param = params[:join_type]\n\n if name_param.nil? || name_param.blank?\n render json: { field: 'name', error: 'You must provide a name for your space' }, status: :bad_request\n return\n end\n\n unless group_name_is_unique? name_param\n render json: { field: 'name', error: \"A Space named \\\"#{name_param}\\\" already exists\" }, status: :bad_request\n return\n end\n\n if description_param.nil? || description_param.blank?\n render json: { field: 'description', error: 'No description specified' }, status: :bad_request\n return\n end\n\n if join_type_param.nil? || join_type_param.blank?\n render json: { field: 'join_type', error: 'No join_type specified' }, status: :bad_request\n return\n end\n\n if (!params[:maillist].empty? && !maillist_is_valid?(params[:maillist]))\n render json: { field: 'maillist', error: \"\\\"#{params[:maillist]}\\\" is not a valid maillist\" }, status: :bad_request\n return\n end\n\n # concat maillist members into the members array so they get added for the initial load\n members_param.concat maillist_members(params[:maillist]) unless params[:maillist].empty?\n\n # filter out non-canvas users\n members = members_param.map do | member |\n pseudonym = Pseudonym.active.by_unique_id member\n pseudonym.first.user unless pseudonym.empty?\n end\n members.compact.uniq!\n\n if @current_user.account.site_admin?\n if leader_id_param && !leader_id_param.blank?\n leader = User.find_by_id(leader_id_param)\n if leader.nil?\n render json: { error: \"Can't find user specified for leader\" }, status: :bad_request\n return\n end\n else\n leader = @current_user\n end\n else\n # if a non-admin is creating the group then\n # the leader is that user and that id is used to determine who \"owns\"\n # the group and can make changes to it\n leader = @current_user\n end\n\n if join_type_param == 'free_to_join'\n join_type = 'parent_context_auto_join'\n elsif join_type_param == 'request'\n join_type = 'parent_context_request'\n elsif join_type_param == 'invite_only'\n join_type = 'invitation_only'\n else\n render json: { field: 'join_type', error: 'Invalid join_type value. Valid: request, free_to_join, invite_only' }, status: :bad_request\n return\n end\n\n group = @domain_root_account.groups.create( name: name_param,\n group_category: CanvasSpaces.GroupCategory,\n leader: leader,\n join_level: join_type,\n description: description_param )\n group.add_user(leader)\n group.save\n members.each { |member| group.add_user(member) } unless members.empty?\n\n add_maillist = set_maillist_for_space(group.id, params[:maillist]) unless params[:maillist].empty?\n\n render json: group.as_json(only: [ :id, :name, :description, :leader_id, :created_at ],\n include_root: false)\n .merge({ size: 0, join_type: join_type_param }), status: :ok\n end",
"def create\n @group = current_user.groups.new(group_params)\n\n if (@group.save)\n flash[:success] = \"Found a new group!\"\n else\n flash[:warning] = \"Could not create group\"\n end\n\n redirect_to @group\n end",
"def create\n @group = Group.new(group_params)\n #On vérifie que la liste de droits d'un groupe est effacé\n @group.rights.clear\n\n #On ajoute les droits choisis par un utilisateur\n params[:group][:right_ids] ||= []\n params[:group][:right_ids].each do |right|\n if !(right.blank?)\n @group.add_right(Right.find_by_id(right))\n end\n end\n\n respond_to do |format|\n if @group.save\n format.html { redirect_to @group, notice: t('group.created_msg') }\n format.json { render action: 'show', status: :created, location: @group }\n else\n format.html { render action: 'new' }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n create_params = params_for_create\n\n if group_exists?(create_params[:name])\n render_error_with_message(t('controllers.api.v1.groups.group_found'), :bad_request)\n return\n end\n\n group = @project.groups.new(name: create_params[:name])\n errors = update_article_groups(group, create_params)\n if errors\n render_errors(errors)\n return\n end\n\n respond_with @project do |format|\n format.json { render json: decorate_group(group) }\n end\n end",
"def create\n\t\t@group = current_user.groups.create(group_params)\n\t\tif params[:users].present?\n\t\t\tparams[:users].each do |user_id|\n\t\t\t\t@group.user_groups.create(user_id: user_id)\n\t\t\tend\n\t\tend\n\t\tredirect_to :groups, notice: 'Group created successfully'\n\tend",
"def create\n @group = Group.new(params[:group])\n\n if @group.save\n redirect_to(list_groups_path(:page => params[:page]), :notice => t(\"group.created\"))\n else\n render :action => :new\n end\n end",
"def create\n @group = Group.new(group_params)\n\n respond_to do |format|\n if @group.save\n format.html { redirect_to @group, notice: 'Group was successfully created.' }\n format.json { render :show, status: :created, location: @group }\n format.js\n else\n format.html { render :new }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n format.js\n end\n end\n end",
"def create\n @city = City.find(params[:city_id])\n @group = @city.groups.new(params[:group])\n @group.user = current_user\n\n respond_to do |format|\n if @group.save\n gflash :success => \"Group page was successfully created.\"\n format.html { redirect_to [@city, @group] }\n format.json { render action: 'show', status: :created, location: @group }\n else\n format.html { render action: 'new' }\n format.json { render json: city_group_path.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @group = Group.new(group_params)\n token = params[:token]\n\n # use the user login instance and match emails to find current user\n @user_login = UserLogin.where(token: token).take\n @current_user = User.where(email: @user_login.email).take\n\n respond_to do |format|\n if @group.save\n\n # create a new group membership for new group w/ current user as admin\n @new_membership = GroupMembership.create(group_id: @group.id, user_id: @current_user.id, is_admin: true)\n\n # associate new membership with the group and the user\n @group.group_memberships << @new_membership\n @current_user.group_memberships << @new_membership\n\n format.html { redirect_to group_path(:id => @group.id), notice: 'Group was successfully created.' }\n format.json { render :show, status: :created, location: @group }\n else\n format.html { render :new }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @group = Group.new(new_group_params)\n if @group.save\n redirect_to groups_url\n else\n render :template => \"groups/new\"\n end\n end",
"def create\n @group = Group.new(group_params)\n @group.owner = current_user\n\n respond_to do |format|\n if @group.save && @group.add_user!(current_user, :admin)\n audit(@group, \"create\", @group.name)\n format.html { redirect_to :back, notice: 'Group was successfully created.' }\n format.json { render :show, status: :created, location: @group }\n else\n format.html { render :new }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def postEntityGroup( entity_id, group_id)\n params = Hash.new\n params['entity_id'] = entity_id\n params['group_id'] = group_id\n return doCurl(\"post\",\"/entity/group\",params)\n end",
"def create\n @group = Group.new(group_params)\n if current_user\n @group.user_id = current_user.id\n end\n \n respond_to do |format|\n if @group.save\n format.html { redirect_to @group, notice: 'Group was successfully created.' }\n format.json { render action: 'show', status: :created, location: @group }\n else\n format.html { render action: 'new' }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n authorize! :create, Group\n @group = Group.new(group_params)\n @group.creator = current_user\n respond_to do |format|\n if @group.save\n format.html { redirect_to @group, notice: 'Group was successfully created.' }\n format.json { render action: 'show', status: :created, location: @group }\n else\n format.html { render action: 'new' }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n params[:group].delete(:domain) unless current_group.shapado_version.has_custom_domain?\n @group = Group.new\n if params[:group][:languages]\n params[:group][:languages].reject! { |lang| lang.blank? }\n end\n @group.safe_update(%w[languages name legend description default_tags subdomain logo forum enable_mathjax enable_latex custom_favicon language theme signup_type custom_css wysiwyg_editor], params[:group])\n\n @group.safe_update(%w[isolate domain private], params[:group]) if current_user.admin?\n\n @group.owner = current_user\n @group.state = \"active\"\n\n respond_to do |format|\n if @group.save\n @group.create_default_widgets\n\n Jobs::Images.async.generate_group_thumbnails(@group.id)\n @group.add_member(current_user, \"owner\")\n flash[:notice] = I18n.t(\"groups.create.flash_notice\")\n format.html { redirect_to(domain_url(:custom => @group.domain, :controller => \"admin/manage\", :action => \"properties\")) }\n format.json { render :json => @group.to_json, :status => :created, :location => @group }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @group.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n\n group = Group.create(group_parm.merge(account_id: current_user.id)) #group creater current user will be the admin of group\n if group.save!\n render :json => Base64.encode64(group.id.to_s) and return\n else\t\t \n render :json => group.errors.full_messages.first and return\n end \n end",
"def new\n @group = Group.new\n render json: @group\n end",
"def create\n @group = Group.new(group_params)\n member = Member.create\n @group.members << member\n current_user.members << member\n\n @group.owner = member\n\n respond_to do |format|\n if @group.save\n format.html { redirect_to @group, notice: 'Group was successfully created.' }\n format.json { render action: 'show', status: :created, location: @group }\n else\n format.html { render action: 'new' }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n group = params[:group] || {}\n group.delete(:locales)\n group.delete(:domains)\n @group = GROUP.new(group)\n @group.current_user = current_user\n\n respond_to do |format|\n if @group.save\n flash[:notice] = 'Group was successfully created.'\n format.html { redirect_to(group_url(@group.id)) }\n format.xml { render :xml => @group, :status => :created, :location => group_url(@group.id) + \".xml\" }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @users = User.where(\"owner_id = ?\", current_user).order('lastname ASC')\n @group = current_user.groups.create(group_params)\n @owner = current_user\n if @group.persisted?\n flash[:green] = \"Group created!\"\n redirect_to groups_path\n else\n render root_path\n end\n end",
"def create\n if params[:member_id].nil?\n @group = Group.new(params[:group])\n respond_to do |format|\n if @group.save\n flash[:notice] = 'Group was successfully created.'\n format.html { redirect_to(@group) }\n format.xml { render :xml => @group, :status => :created, :location => @group }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n end\n end\n else\n # Add member to an group.\n # POST /members/:member_id/groups\n RAILS_DEFAULT_LOGGER.debug(\"Add member #{params[:member_id]} to group #{params[:post][:group_id]}.\")\n @member = Member.find(params[:member_id])\n @member.group << Group.find(params[:post][:group_id])\n\n respond_to do |format|\n flash[:notice] = 'Group was successfully added.'\n format.html { redirect_to(@member) }\n format.xml { render :xml => @member, :status => :created, :location => @member }\n end\n end\n end",
"def create\n @group = Group.new(group_params)\n\n respond_to do |format|\n if @group.save\n format.html { redirect_to [:admin, @group], notice: t('activerecord.models.group') + '创建成功!' }\n format.json { render action: 'show', status: :created, location: @group }\n else\n format.html { render action: 'new' }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @user = User.find(params[:user_id])\n @groups = @user.groups.new\n\n #@group = Group.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @group }\n end\n end",
"def create\n \n @group = Group.new(params[:group])\n\n respond_to do |format|\n if @group.save\n flash[:notice] = 'Group was successfully created.'\n format.html { redirect_to(@group) }\n format.xml { render :xml => @group, :status => :created, :location => @group }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @add_group_to_user = AddGroupToUser.new(params[:add_group_to_user])\n\n respond_to do |format|\n if @add_group_to_user.save\n format.html { redirect_to @add_group_to_user, notice: 'Add group to user was successfully created.' }\n format.json { render json: @add_group_to_user, status: :created, location: @add_group_to_user }\n else\n format.html { render action: \"new\" }\n format.json { render json: @add_group_to_user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @group = Group.new(params[:group])\n\n respond_to do |format|\n if @group.save\n format.html { redirect_to(view_group_path(@group.label), :notice => 'Group was successfully created.') }\n format.xml { render :xml => @group, :status => :created, :location => @group }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def new\n @group = Group.new\n\n render json: @group\n end",
"def create #:nodoc:\n @group = Group.new(params[:group])\n\n respond_to do |format|\n if @group.save\n flash[:notice] = I18n.t(\"{{value}} was successfully created.\", :default => \"{{value}} was successfully created.\", :value => I18n.t(\"Group\", :default => \"Group\"))\n if params[:create_and_new_button]\n format.html { redirect_to new_group_url }\n else\n format.html { redirect_to groups_url }\n # format.xml { render :xml => @group, :status => :created, :location => @group }\n end\n else\n format.html { render :action => \"new\" }\n # format.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def group_create(element)\n name = element[\"group\"]\n auth = element[\"auth\"]\n body = {\n \"jsonrpc\" => \"2.0\",\n \"method\" => \"hostgroup.create\",\n \"params\" => {\n \"name\" => name\n },\n \"auth\" => auth,\n \"id\" => rand(9999)\n }\n result = json_body(body)\n # puts result\n result = result[\"groupids\"]\n result = result[0]\n # puts result\n # return will be group id\n return result\nend",
"def create_group(optional={})\n\t\targs = self.class.new_params\n\t\targs[:query]['Action'] = 'CreateGroup'\n\t\targs[:region] = optional[:_region] if (optional.key? :_region)\n\t\targs[:scheme] = 'https'\n\t\tif optional.key? :_method\n\t\t\traise ArgumentError, '_method must be GET|POST' unless 'GET|POST'.split('|').include? optional[:_method]\n\t\t\targs[:method] = optional[:_method]\n\t\tend\n\t\tif optional.key? :comments\n\t\t\targs[:query]['Comments'] = optional[:comments]\n\t\tend\n\t\tif optional.key? :group_name\n\t\t\targs[:query]['GroupName'] = optional[:group_name]\n\t\tend\n\t\tself.run(args)\n\tend",
"def create\n @request_group = RequestGroup.new(request_group_params)\n\n respond_to do |format|\n if @request_group.save\n format.html { redirect_to @request_group, \n\t\t\t\t\t\t\t\t\t\t\tnotice: 'Request group was successfully created.' }\n format.json { render action: 'show', status: :created, \n\t\t\t\t\t\t\t\t\t\t\tlocation: @request_group }\n else\n format.html { render action: 'new' }\n format.json { render json: @request_group.errors, \n\t\t\t\t\t\t\t\t\t\t\tstatus: :unprocessable_entity }\n end\n end\n end",
"def create\n @group = current_user.groups.build(:name => params[:group][:name])\n @group.set_members(params[:member])\n\n if @group.save\n redirect_to root_path\n else\n render 'new'\n end\n\n end",
"def create\n # @group = Group.create(group_params)\n # @group.save\n @group = Group.new\n puts @group\n @group.name = params['name']\n puts params['user_id']\n @group.user_id = params['user_id']\n\n respond_to do |format|\n if @group.save\n # format.html { redirect_to @group, notice: 'Group was successfully created.' }\n format.json { render :show, status: :created, location: @group }\n # else\n # format.html { render :new }\n # format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def groups\r\n save_default_group(params)\r\n delete_group(params)\r\n end",
"def create\n @group = Group.new(params[:group])\n @group.users.push @current_user\n \n respond_to do |format|\n if @group.save\n @group.invite params[:invite_emails].split(',')\n format.html { redirect_to @group, notice: 'Group was successfully created.' }\n format.json { render json: @group, status: :created, location: @group }\n else\n format.html { render action: \"new\" }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end"
] |
[
"0.77380043",
"0.7621419",
"0.751383",
"0.74283075",
"0.738724",
"0.738724",
"0.7202902",
"0.7202091",
"0.7180679",
"0.71750224",
"0.71592236",
"0.71332103",
"0.7128259",
"0.70654404",
"0.7040274",
"0.7027708",
"0.70119005",
"0.70049846",
"0.70049846",
"0.70049846",
"0.70049846",
"0.70049846",
"0.6991635",
"0.6989256",
"0.6989256",
"0.6989256",
"0.6989256",
"0.6989256",
"0.6989256",
"0.69766337",
"0.69560546",
"0.69349176",
"0.69156563",
"0.68802303",
"0.6874159",
"0.68667656",
"0.6851745",
"0.6836405",
"0.68163615",
"0.681253",
"0.6811545",
"0.6802349",
"0.67915213",
"0.67915213",
"0.67897373",
"0.67816883",
"0.6781481",
"0.6758737",
"0.6756241",
"0.674582",
"0.6733436",
"0.67256737",
"0.67196375",
"0.6710457",
"0.6707849",
"0.67056745",
"0.669631",
"0.6692559",
"0.6688851",
"0.66885924",
"0.6687798",
"0.6687246",
"0.6681375",
"0.667439",
"0.6666229",
"0.6663665",
"0.66619027",
"0.66573006",
"0.6642936",
"0.6634381",
"0.6627641",
"0.66174024",
"0.6613057",
"0.66067255",
"0.65972394",
"0.6584677",
"0.6582228",
"0.658166",
"0.6578726",
"0.6572917",
"0.6560621",
"0.6547395",
"0.6543169",
"0.6532531",
"0.6523663",
"0.65131384",
"0.6503465",
"0.64901984",
"0.64864665",
"0.64743984",
"0.64724493",
"0.64681584",
"0.64673424",
"0.64665025",
"0.64567894",
"0.64466774",
"0.64435637",
"0.6442807",
"0.644218",
"0.64343405"
] |
0.6687562
|
61
|
PATCH/PUT /groups/1 PATCH/PUT /groups/1.json
|
def update
@user = User.find(current_user.id)
@group = @user.groups.find(params[:id])
@group.title = params[:title]
@group.description = params[:description]
@group.groupProfile = params[:groupProfile]
@group.groupCover = params[:groupCover]
@groupcategory = GroupCategory.where(:group_id => params[:id])
@groupcategory.update(group_id: @group.id , category_id: params[:category])
respond_to do |format|
if @group.update(title: params[:title], description: params[:description])
format.html { redirect_to user_group_path(current_user.id, @group.id) }
format.json { render :show, status: :ok, location: @group }
else
format.html { render :edit }
format.json { render json: @group.errors, status: :unprocessable_entity }
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def update\n logger.info \"Put parameters: #{params.to_json}\"\n @group = Group.find(params[:id])\n\n if @group.update_attributes(params[:group])\n head :no_content\n else\n render json: @group.errors, status: :unprocessable_entity\n end\n end",
"def UpdateGroup params = {}\n \n APICall(path: 'groups.json',method: 'PUT',payload: params.to_json)\n \n end",
"def update\n group = Group.find(params[:id])\n if group.update(group_params)\n render json: group\n else\n render json: group.errors.full_messages, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @api_v1_group_update.update(api_v1_group_update_params)\n format.html { redirect_to @api_v1_group_update, notice: 'Group update was successfully updated.' }\n format.json { render :show, status: :ok, location: @api_v1_group_update }\n else\n format.html { render :edit }\n format.json { render json: @api_v1_group_update.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @group.update(group_params)\n format.json { head :no_content }\n else\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @group = Group.find(params[:id])\n\n respond_to do |format|\n if @group.update_attributes(params[:group])\n format.html { redirect_to @group, :notice => 'Group was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @group.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @group = Group.find(params[:id])\n\n respond_to do |format|\n if @group.update_attributes(params[:group])\n format.html { redirect_to @group, :notice => 'Group was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @group.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n\n if @group.update(group_params)\n head :no_content\n else\n render json: @group.errors, status: :unprocessable_entity\n end\n end",
"def update\n @group = Group.find(params[:id])\n\n respond_to do |format|\n if @group.update_attributes(params[:group])\n format.html { redirect_to @group, notice: 'Group was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @group = Group.find(params[:id])\n\n respond_to do |format|\n if @group.update_attributes(params[:group])\n format.html { redirect_to @group, notice: 'Group was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @group = Group.find(params[:id])\n\n respond_to do |format|\n if @group.update_attributes(params[:group])\n format.html { redirect_to @group, notice: 'Group was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @group = Group.find(params[:id])\n\n respond_to do |format|\n if @group.update_attributes(params[:group])\n format.html { redirect_to @group, notice: 'Group was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @group = Group.find(params[:id])\n\n respond_to do |format|\n if @group.update_attributes(params[:group])\n format.html { redirect_to @group, notice: 'Group was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @group.update_attributes(params[:group])\n respond_with(@group, only: [:id, :name, :creator_id, :admin_id])\n else\n render_error(404, request.path, 20103, \"Failed to update group info\")\n end\n end",
"def update\n @group.update(group_params)\n respond_with(@group)\n end",
"def update\n authorize! :update, @group\n @group.creator = current_user\n respond_to do |format|\n if @group.update(group_params)\n format.html { redirect_to @group, notice: 'Group was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @group.update(group_params)\n format.html { redirect_to @group, notice: 'Group was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @group.update(group_params)\n format.html { redirect_to @group, notice: 'Group was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @group.update(group_params)\n format.html { redirect_to @group, notice: 'Group was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @group.update(group_params)\n format.html { redirect_to @group, notice: 'Group was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @group.update(group_params)\n format.html { redirect_to @group, notice: 'Le groupe a été modifié.' }\n format.json { render :show, status: :ok, location: @group }\n else\n format.html { render :edit }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @group.update(group_params)\n render_json_message({success: t('.success')}, 200)\n else\n render_json_message({errors: @group.errors.messages}, 422)\n end\n end",
"def update\n respond_to do |format|\n if @request_group.update(request_group_params)\n format.html { redirect_to @request_group, \n\t\t\t\t\t\t\t\t\t\t\tnotice: 'Request group was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @request_group.errors, \n\t\t\t\t\t\t\t\t\t\t\tstatus: :unprocessable_entity }\n end\n end\n end",
"def update\n @group.name = params['name']\n @group.save\n respond_to do |format|\n format.json { render :show, status: :ok, location: @group }\n end\n end",
"def update\n @group = Group.find(params[:id])\n\n respond_to do |format|\n if @group.update_attributes(params[:group])\n format.html { redirect_to @group, notice: 'Group was successfully updated.' }\n# format.json { head :no_content }\nformat.json { render :json=>{'statusCode'=>'200','message'=>'Edit Group Success!','navTableId'=>'','rel'=>'','callbackType'=>'','forwardUrl'=>'','confirmMsg'=>''} }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @group = Group.find(params[:id])\n\n respond_to do |format|\n if @group.update_attributes(params[:group])\n format.html { redirect_to params[:back_to], notice: 'Group was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n redirect_to :action => :index and return unless is_owner?\n respond_to do |format|\n if @group.update(group_params)\n format.html { redirect_to @group, notice: 'Group was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @group.update(group_params)\n audit(@group, \"update\", @group.name)\n format.html { redirect_to group_path(@group), notice: 'Group was successfully updated.' }\n format.json { render :show, status: :ok, location: @group }\n else\n format.html { render :edit }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @group.update(params[:group])\n format.html { redirect_to [@hub, @group], :notice => 'Group was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @group.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n authorize @group\n respond_to do |format|\n if @group.update(group_params)\n format.html { redirect_to group_path(@group), notice: \"Group was successfully updated.\" }\n format.json { render :show, status: :ok, location: @group }\n else\n format.html { render :edit }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @group.update(group_params)\n format.html { redirect_to @group, notice: 'Group was successfully updated.' }\n format.json { render :show, status: :ok, location: @group }\n else\n format.html { render :edit }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @group.update(group_params)\n format.html { redirect_to @group, notice: 'Group was successfully updated.' }\n format.json { render :show, status: :ok, location: @group }\n else\n format.html { render :edit }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @group.update(group_params)\n format.html { redirect_to @group, notice: 'Group was successfully updated.' }\n format.json { render :show, status: :ok, location: @group }\n else\n format.html { render :edit }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @group.update(group_params)\n format.html { redirect_to @group, notice: 'Group was successfully updated.' }\n format.json { render :show, status: :ok, location: @group }\n else\n format.html { render :edit }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @group.update(group_params)\n format.html { redirect_to @group, notice: 'Group was successfully updated.' }\n format.json { render :show, status: :ok, location: @group }\n else\n format.html { render :edit }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @group.update(group_params)\n format.html { redirect_to @group, notice: 'Group was successfully updated.' }\n format.json { render :show, status: :ok, location: @group }\n else\n format.html { render :edit }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @group.update(group_params)\n format.html { redirect_to @group, notice: 'Group was successfully updated.' }\n format.json { render :show, status: :ok, location: @group }\n else\n format.html { render :edit }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @group.update(group_params)\n format.html { redirect_to @group, notice: 'Group was successfully updated.' }\n format.json { render :show, status: :ok, location: @group }\n else\n format.html { render :edit }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @group.update(group_params)\n format.html { redirect_to @group, notice: 'Group was successfully updated.' }\n format.json { render :show, status: :ok, location: @group }\n else\n format.html { render :edit }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @group.update(group_params)\n format.html { redirect_to @group, notice: 'Group was successfully updated.' }\n format.json { render :show, status: :ok, location: @group }\n else\n format.html { render :edit }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @group.update(group_params)\n format.html { redirect_to @group, notice: 'Group was successfully updated.' }\n format.json { render :show, status: :ok, location: @group }\n else\n format.html { render :edit }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @group.update(group_params)\n format.html { redirect_to @group, notice: 'Group was successfully updated.' }\n format.json { render :show, status: :ok, location: @group }\n else\n format.html { render :edit }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @group = Group.find_by_guid(params[:id])\n respond_to do |format|\n if @group.update_attributes(update_params)\n format.html { redirect_to @group, notice: 'Group was successfully updated.' }\n format.json { render json: @group }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @group.update(group_params)\n format.html { redirect_to [@group], notice: 'group was successfully updated.' }\n format.json { render :show, status: :ok, location: [@group] }\n else\n format.html { render :edit }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @api_v1_group_field.update(api_v1_group_field_params)\n format.html { redirect_to @api_v1_group_field, notice: 'Group field was successfully updated.' }\n format.json { render :show, status: :ok, location: @api_v1_group_field }\n else\n format.html { render :edit }\n format.json { render json: @api_v1_group_field.errors, status: :unprocessable_entity }\n end\n end\n end",
"def put(obj, which=:groups)\n path = \"/#{which}\"\n path += \"/#{obj['ID']}\" unless obj['ID'].nil? \n resp = self.class.post(path, { :body => obj })\n check_errors resp\n res = resp.parsed_response['Response']['Entry']\n rebuild_groups! res\n res\n end",
"def update\n\n respond_to do |format|\n if @group.update_attributes(group_params)\n format.html { redirect_to @group.becomes(Group), notice: 'Group was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n \n @group = Group.find(params[:id])\n\n respond_to do |format|\n if @group.update_attributes(params[:group])\n format.html { redirect_to(@group, :notice => 'Group was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n #logger.info \"Put parameters: #{params.to_json}\"\n\n if @membership.admin \n if @group.update_attributes(params[:group])\n head :no_content\n else\n render json: @group.errors, status: :unprocessable_entity\n end\n else \n render json: {error: \"YOU MUST BE AN ADMINISTRATOR TO COMPLETE THIS ACTION\"}, status: :unprocessable_entity\n end \n end",
"def update\n respond_to do |format|\n if @group.update(group_params)\n format.html { redirect_to @group, notice: I18n.t(:group_update) }\n format.json { render :show, status: :ok, location: @group }\n else\n flash[:alert] = @group.errors.full_messages.to_sentence\n format.html { render :edit }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @group_request.update(group_request_params)\n format.html { redirect_to @group_request, notice: 'Group request was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @group_request.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @group.update(group_params)\n invite_members\n format.html { redirect_to @group, notice: t('flash.notice.groups.successfully_updated') }\n format.json { render :show, status: :ok, location: @group }\n else\n format.html { render :edit }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @user_group = UserGroup.find(params[:id])\n\n respond_to do |format|\n if @user_group.update_attributes(params[:user_group])\n format.html { redirect_to @user_group, notice: 'User group was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user_group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @tasks_group = @tasks_group.do_before_update\n respond_to do |format|\n if @tasks_group.update(tasks_group_params)\n format.html { redirect_to @tasks_group, notice: 'Tasks group was successfully updated.' }\n format.json { render :show, status: :ok, location: @tasks_group }\n else\n format.html { render :edit }\n format.json { render json: @tasks_group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n begin\n group = Group.find(params[:id])\n if params[:name] and group.update_attributes(name: params[:name])\n render json: { \"notice\"=>\"group name updated to #{params[:name]}\" }\n else\n render json: { \"alert\"=>\"record not updated. check your params.\" }\n end\n rescue ActiveRecord::RecordNotFound\n render json: { \"alert\"=>\"did not specify a valid id. no record updated.\" }\n end\n end",
"def update\n @user_group = UserGroup.find(params[:id])\n\n respond_to do |format|\n if @user_group.update_attributes(params[:user_group])\n format.html { redirect_to @user_group, notice: 'User group was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user_group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @group.update(group_params)\n format.html { redirect_to @group, notice: 'Группа обновлена!' }\n format.json { render :show, status: :ok, location: @group }\n else\n format.html { render :edit }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n Group.rebuild! if nil.|Group.find(:first).rgt\n\t @group = Group.find(params[:id])\n\n respond_to do |format|\n if @group.update_attributes(params[:group])\n flash[:notice] = 'Group was successfully updated.'\n format.html { redirect_to(@group) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @group = Group.find(params[:id])\n @users = @group.users\n respond_to do |format|\n if @group.update_attributes(params[:group])\n format.html { redirect_to edit_user_registration_path, notice: 'Group was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @group = Group.find(params[:id])\n\n respond_to do |format|\n if @group.update_attributes(params[:group])\n format.html { redirect_to( view_group_path(@group.label), :notice => 'Group was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n newparam= checker()\n respond_to do |format|\n if @group.update(newparam)\n format.html { redirect_to @group, notice: 'Group was successfully updated.' }\n format.json { render :show, status: :ok, location: @group }\n else\n format.html { render :edit }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @groupaddrobj = Groupaddrobj.find(params[:id])\n\n respond_to do |format|\n if @groupaddrobj.update_attributes(params[:groupaddrobj])\n format.html { redirect_to @groupaddrobj, notice: 'Groupaddrobj was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @groupaddrobj.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\n respond_to do |format|\n if @group.update_attributes(params[:group])\n flash[:notice] = '{object} was successfully {action}.'[:object_action_notice, \"Group\"[], \"updated\"[]]\n format.html { redirect_to(@group) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @group = Group.find(params[:id])\n \n respond_to do |format|\n if @group.update_attributes(params[:group])\n flash[:notice] = 'Group was successfully updated.'\n format.html { redirect_to(admin_groups_url) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @group = Group.find(params[:id])\n\n respond_to do |format|\n if @group.update_attributes(params[:group])\n flash[:success] = \"Группа успешно отредактирована.\"\n format.html { redirect_to @group }\n format.json { head :no_content }\n else\n flash.now[:error] = \"Введены некорректные данные!\"\n format.html { render action: \"edit\" }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @resource.update(group_params)\n # Load records in order to refresh index page\n index\n flash[:success] = t('notices.updated_successfully')\n format.html { redirect_to @resource, warning: 'Group was successfully updated.'}\n format.json { render :show, status: :ok, location: @resource }\n else\n format.html { render :edit }\n format.json { render json: @resource.errors, status: :unprocessable_entity }\n end\n format.js\n end\n end",
"def update\n @group = Group.find(params[:id])\n params[:group][:member_ids] = (params[:group][:member_ids] << @group.member_ids).flatten\n\n respond_to do |format|\n if @group.update_attributes(params[:group])\n format.html { redirect_to root_path }\n format.js\n # format.html { redirect_to @group, notice: 'Group was successfully updated.' }\n # format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @collection_group.update(collection_group_params)\n format.html { redirect_to @collection_group, notice: 'Collection group was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @collection_group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @group.update_attributes(params[:group])\n flash[:notice] = 'Group was successfully updated.'\n format.html { redirect_to groups_path }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @groupon = Groupon.find(params[:id])\n\n respond_to do |format|\n if @groupon.update_attributes(params[:groupon])\n format.html { redirect_to @groupon, notice: 'Groupon was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @groupon.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @group = Group.find_by_param(params[:id])\n\n respond_to do |format|\n if @group.update_attributes(params[:group])\n format.html { redirect_to(@group, :notice => 'Group was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def set_api_v1_group_update\n @api_v1_group_update = Api::V1::GroupUpdate.find(params[:id])\n end",
"def update\n\n @group = Group.find(params[:id])\n\n respond_to do |format|\n if @group.update_attributes(params[:group])\n flash[:notice] = 'Group was successfully updated.'\n format.html { redirect_to(@group) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n\n @group = Group.find(params[:id])\n\n respond_to do |format|\n if @group.update_attributes(params[:group])\n flash[:notice] = 'Group was successfully updated.'\n format.html { redirect_to(@group) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @group = Group.find(params[:id])\n \n respond_to do |format|\n if @group.update_attributes(params[:group])\n flash[:notice] = 'Group was successfully updated.'\n format.html { redirect_to(@group) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def test_update_group_basic_success\n\n client = create_mock_client\n refute_nil client, \"Client object couldn't be created.\"\n\n stub_request(:patch, mock_uri('Groups', '17'))\n .to_return(status: 202, body: { 'Success' => true,\n 'Message' => \"Operation succeeded\",\n 'ApiId' => API_ID }.to_json)\n\n status, = client.group.update_group(17, 'bogus')\n refute_nil status, \"No status object returned.\"\n assert status.success, \"Status did not indicate success: \" + status.message\n\n end",
"def update\r\n respond_to do |format|\r\n if @agroup.update(agroup_params)\r\n format.html { redirect_to @agroup, notice: 'Agroup was successfully updated.' }\r\n format.json { head :no_content }\r\n else\r\n format.html { render action: 'edit' }\r\n format.json { render json: @agroup.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def update\n @entry = Entry.find(params[:id])\n\n if (a = params.delete(:group))\n params[:entry][:group_id] = set_group(a)\n end\n\n respond_to do |format|\n if @entry.update_attributes(params[:entry])\n format.html { 'Entry was successfully updated.' }\n format.json { head :ok }\n else\n format.html { 'Foo' }\n format.json { render json: @entry.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @group = SuperSimpleCms::Group.find(params[:id])\n\n respond_to do |format|\n if @group.update_attributes(params[:group])\n flash[:notice] = 'Group was successfully updated.'\n format.html { redirect_to super_simple_group_path(@group) } \n format.js { redirect_to formatted_super_simple_group_path(@group, :js) }\n format.xml { render :xml => @group, :status => :created, :location => @group }\n else\n format.html { render :action => \"new\" }\n format.js { render :action => \"new\", :layout=>false}\n format.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @group = Group.find(params[:id])\n\n respond_to do |format|\n if @group.update_attributes(params[:group])\n flash[:notice] = 'Group was successfully updated.'\n format.html { redirect_to(@group) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @group = Group.find(params[:id])\n\n respond_to do |format|\n if @group.update_attributes(params[:group])\n flash[:notice] = 'Group was successfully updated.'\n format.html { redirect_to(@group) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @group = Group.find(params[:id])\n\n respond_to do |format|\n if @group.update_attributes(params[:group])\n flash[:notice] = 'Group was successfully updated.'\n format.html { redirect_to(@group) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @group = Group.find(params[:id])\n\n respond_to do |format|\n if @group.update_attributes(params[:group])\n flash[:notice] = 'Group was successfully updated.'\n format.html { redirect_to(@group) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @group = Group.find(params[:id])\n\n respond_to do |format|\n if @group.update_attributes(params[:group])\n flash[:notice] = 'Group was successfully updated.'\n format.html { redirect_to(@group) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @group = Group.find(params[:id])\n\n respond_to do |format|\n if @group.update_attributes(params[:group])\n flash[:notice] = 'Group was successfully updated.'\n format.html { redirect_to(@group) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n if GroupsController.group_owner? current_user.id, params[:id]\n set_group\n respond_to do |format|\n if @group.update(group_params)\n format.html { redirect_to group_path(@group), alert: 'Group was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n else\n respond_to do |format|\n format.html { redirect_to groups_path, alert: \"Not updated. You are not the group owner\" }\n format.json { render json: \"Only owners can edit the respective group page\", status: :unauthorized }\n end\n end\n end",
"def update\n respond_to do |format|\n if @group.update_attributes(params[:group])\n flash[:notice] = \"Group was successfully updated.\"\n format.html { redirect_to(@group) }\n format.js # update.js.rjs\n format.xml { head :ok }\n format.json { head :ok }\n else\n flash[:error] = \"Group could not be updated.\"\n format.html { render 'edit' }\n format.js # update.js.rjs\n format.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n format.json { render :json => @group.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @issue_group = IssueGroup.find(params[:id])\n\n respond_to do |format|\n if @issue_group.update_attributes(params[:issue_group])\n format.html { redirect_to @issue_group, notice: 'Issue group was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @issue_group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @group_user = GroupUser.find(params[:id])\n\n respond_to do |format|\n if @group_user.update_attributes(params[:group_user])\n format.html { redirect_to @group_user, notice: 'Group user was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @group_user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n #確定編輯後的id一定是編輯者本人\n @group.user = @user\n if @group.update(group_params)\n format.html { redirect_to @group, notice: 'Group was successfully updated.' }\n format.json { render :show, status: :ok, location: @group }\n else\n format.html { render :edit }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @add_group_to_user = AddGroupToUser.find(params[:id])\n\n respond_to do |format|\n if @add_group_to_user.update_attributes(params[:add_group_to_user])\n format.html { redirect_to @add_group_to_user, notice: 'Add group to user was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @add_group_to_user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @group = Group.find(params[:id])\n if !@group.admin.empty?\n @user=User.find(@group.admin)\n puts \"///////group controller update//////////\"+ @user.to_json\n @user.update_attributes(role: '1')\n @user.update_attributes(group_id: @group._id)\n end\n @group.update_attributes(params[:group])\n #format.html { redirect_to @group, notice: 'Group was successfully updated.' }\n #format.json { render json: @group, status: :accepted, location: @group }\n render 'show'\n #format.html { render action: \"edit\" }\n #format.json { render json: @group.errors, status: :unprocessable_entity } \n end",
"def update\n respond_to do |format|\n if @group.update(group_params)\n format.html { redirect_to [:admin, @group], notice: t('activerecord.models.group') +'更新成功!' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n update_params = params_for_update\n\n errors = update_article_groups(@group, update_params)\n if errors\n render_errors(errors)\n return\n end\n\n respond_with @project do |format|\n format.json { render json: decorate_group(@group) }\n end\n end",
"def update\n respond_to do |format|\n if @group.update_attributes(params[:group])\n flash[:notice] = 'Group was successfully updated.'\n format.html { redirect_to((current_user and current_user.is_site_admin? and current_user != @group.users.owners.first) ? by_user_groups_path(:user_id => @group.users.owners.first.id) : groups_path) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @no_group.update(no_group_params)\n format.html { redirect_to @no_group, notice: 'No group was successfully updated.' }\n format.json { render :show, status: :ok, location: @no_group }\n else\n format.html { render :edit }\n format.json { render json: @no_group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_group(optional={})\n\t\targs = self.class.new_params\n\t\targs[:query]['Action'] = 'UpdateGroup'\n\t\targs[:region] = optional[:_region] if (optional.key? :_region)\n\t\targs[:scheme] = 'https'\n\t\tif optional.key? :_method\n\t\t\traise ArgumentError, '_method must be GET|POST' unless 'GET|POST'.split('|').include? optional[:_method]\n\t\t\targs[:method] = optional[:_method]\n\t\tend\n\t\tif optional.key? :group_name\n\t\t\targs[:query]['GroupName'] = optional[:group_name]\n\t\tend\n\t\tif optional.key? :new_comments\n\t\t\targs[:query]['NewComments'] = optional[:new_comments]\n\t\tend\n\t\tif optional.key? :new_group_name\n\t\t\targs[:query]['NewGroupName'] = optional[:new_group_name]\n\t\tend\n\t\tself.run(args)\n\tend",
"def update\n @client = Client.find(params[:id])\n @client.campaign_id = session[:campaign_id]\n @groups = Group.all.map {|g| [g.name, g.id]}\n\n respond_to do |format|\n if @client.update_attributes(params[:client])\n format.html { redirect_to @client, :notice => 'Client was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @client.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @esol_group = EsolGroup.find(params[:id])\n\n respond_to do |format|\n if @esol_group.update_attributes(params[:esol_group])\n format.html { redirect_to @esol_group, notice: 'Esol group was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @esol_group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n group_ids = params[:group_id]\n org_id = params[:organization_id]\n @user = User.find_by_id(params[:user_id])\n current_group_ids = @user.user_group_ids\n\n respond_to do |format|\n if @user.update_attributes(full_name: params[:full_name], abbreviation: params[:abbreviation], email: params[:email], status: params[:status], staff_number: params[:employee_id], career_path: params[:career_path])\n\n is_logged = !@user.previous_changes.blank?\n if current_group_ids != group_ids\n @user.user_group_ids = group_ids\n format.json { render json: @user }\n end\n else\n format.json { render json: @user.errors.messages, status: :unprocessable_entity }\n end\n end\n end"
] |
[
"0.7466507",
"0.74578977",
"0.74070287",
"0.7302792",
"0.7140245",
"0.7124225",
"0.7098948",
"0.70921224",
"0.7057236",
"0.7057236",
"0.70501083",
"0.70501083",
"0.70501083",
"0.70233816",
"0.6994502",
"0.6980002",
"0.69751716",
"0.69751716",
"0.69751716",
"0.69751716",
"0.69678557",
"0.69506794",
"0.69306016",
"0.69253594",
"0.69226253",
"0.6901647",
"0.68934464",
"0.6885159",
"0.68788725",
"0.68676364",
"0.6853446",
"0.6853446",
"0.6853446",
"0.6853446",
"0.6853446",
"0.6853446",
"0.6853446",
"0.6853446",
"0.6853446",
"0.6853446",
"0.6853446",
"0.6853446",
"0.685203",
"0.6847377",
"0.68338454",
"0.6818223",
"0.6809429",
"0.6806685",
"0.6782648",
"0.6775632",
"0.6766755",
"0.6759992",
"0.6752977",
"0.6749781",
"0.6742425",
"0.67408144",
"0.6738634",
"0.6734576",
"0.67040855",
"0.66949445",
"0.6677965",
"0.66694844",
"0.6656397",
"0.66518277",
"0.6651297",
"0.6646452",
"0.66339946",
"0.6628826",
"0.66274035",
"0.6608205",
"0.66016746",
"0.66005605",
"0.6584307",
"0.6584307",
"0.6582094",
"0.6572852",
"0.6570511",
"0.656095",
"0.65531033",
"0.65475726",
"0.65475726",
"0.65475726",
"0.65475726",
"0.65475726",
"0.65475726",
"0.6544807",
"0.6537766",
"0.65375197",
"0.6535156",
"0.6531732",
"0.6528827",
"0.65274537",
"0.65235645",
"0.6522404",
"0.6503497",
"0.64972156",
"0.6497165",
"0.6491869",
"0.64913803",
"0.64903796"
] |
0.64932644
|
97
|
DELETE /groups/1 DELETE /groups/1.json
|
def destroy
@content = Content.where("user_id = ? and group_id = ?" , params[:user_id] , params[:id])
# Delete All Comments Made Contents On User
@content.each do |c|
Comment.where(content_id: c.id).destroy_all()
end
# Delete All Contents Made On User
Content.where("user_id = ? and group_id = ?" , params[:user_id] , params[:id]).destroy_all
# Delete All Push In User On Group
Push.where("user_id = ? and pusher_id = ? and push_num = 1" ,params[:user_id] , params[:id]).destroy_all
# Delete Group
if GroupsUser.where(:group_id => params[:id]).count() == 1
Group.find(params[:id]).destroy
else
GroupsUser.where("user_id = ? and group_id = ?" , params[:user_id] , params[:id]).delete_all
end
respond_to do |format|
format.html { redirect_to home_index_path, notice: 'Group was successfully destroyed.' }
format.json { head :no_content }
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def DeleteGroup id\n \n APICall(path: \"groups/#{id}.json\",method: 'DELETE')\n \n end",
"def destroy\n group = Group.find(params[:id])\n group.destroy\n render json: {}\n end",
"def deleteGroup( group_id)\n params = Hash.new\n params['group_id'] = group_id\n return doCurl(\"delete\",\"/group\",params)\n end",
"def destroy\n @group.destroy\n\n respond_to do |format|\n format.html { redirect_to groups_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @group.destroy\n\n respond_to do |format|\n format.html { redirect_to groups_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @group = Group.find(params[:id])\n @group.destroy\n\n respond_to do |format|\n format.html { redirect_to groups_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @group = Group.find(params[:id])\n @group.destroy\n\n respond_to do |format|\n format.html { redirect_to groups_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @group.destroy\n respond_to do |format|\n format.html { redirect_to groups_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @group.destroy\n respond_to do |format|\n format.html { redirect_to groups_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @group.destroy\n respond_to do |format|\n format.html { redirect_to groups_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @group.destroy\n respond_to do |format|\n format.html { redirect_to groups_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @group.destroy\n respond_to do |format|\n format.html { redirect_to groups_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @group = Group.find(params[:id])\n @group.destroy\n\n respond_to do |format|\n format.html { redirect_to groups_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @group = Group.find(params[:id])\n @group.destroy\n\n respond_to do |format|\n format.html { redirect_to groups_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @group = Group.find(params[:id])\n @group.destroy\n\n respond_to do |format|\n format.html { redirect_to groups_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @group = Group.find(params[:id])\n @group.destroy\n\n respond_to do |format|\n format.html { redirect_to groups_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @group = Group.find(params[:id])\n @group.destroy\n\n respond_to do |format|\n format.html { redirect_to groups_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @group = Group.find(params[:id])\n @group.destroy\n\n respond_to do |format|\n format.html { redirect_to groups_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n begin\n group = Group.find(params[:id])\n group.destroy\n render json: { \"notice\"=>\"group deleted successfully\" }\n rescue ActiveRecord::RecordNotFound\n render json: { \"alert\"=>\"did not specify a valid id. no record deleted.\" }\n end\n end",
"def destroy\n # @group = @hub.groups.get(params[:id])\n @group.destroy\n\n respond_to do |format|\n format.html { redirect_to hub_groups_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @group = Group.find_by_guid(params[:id])\n @group.destroy\n\n respond_to do |format|\n format.html { redirect_to groups_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @group = Group.find(params[:id])\n @group.destroy\n\n respond_to do |format|\n format.html { redirect_to groups_url }\n format.json { head :ok }\n format.xml { head :ok }\n end\n end",
"def destroy\n @groups = Group.find(params[:id])\n @groups.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @group = Group.find_by_slug_or_id(params[:id])\n @group.destroy\n\n respond_to do |format|\n format.html { redirect_to(groups_url) }\n format.json { head :ok }\n end\n end",
"def destroy\n authorize! :destroy, @group\n @group.destroy\n respond_to do |format|\n format.html { redirect_to groups_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @group = Group.find(params[:id])\n @group.destroy\n\n head :no_content\n end",
"def destroy\n @api_v1_group_update.destroy\n respond_to do |format|\n format.html { redirect_to api_v1_group_updates_url, notice: 'Group update was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @request_group.destroy\n respond_to do |format|\n format.html { redirect_to request_groups_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @group.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n @group_request.destroy\n respond_to do |format|\n format.html { redirect_to group_requests_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @group.destroy\n respond_to do |format|\n format.html { redirect_to groups_path, notice: 'group was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n Group.destroy(params[:id])\n\n respond_to do |format|\n format.html { redirect_to(groups_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @group.destroy\n respond_to do |format|\n format.html { redirect_to groups_url, notice: 'Группа удалена!' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user_group = UserGroup.find_by_id(params[:id])\n @user_group.destroy\n render :json=>{:status =>t('users.destroy.success')}\n end",
"def destroy\n @group = Group.find(params[:id])\n @group.destroy\n\n respond_to do |format|\n flash[:success] = \"Группа успешно удалена.\"\n format.html { redirect_to groups_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @group.destroy\n respond_to do |format|\n format.html { redirect_to root_path, notice: 'Le groupe a été supprimé.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @group.destroy\n respond_to do |format|\n format.html { redirect_to groups_url, notice: 'Group was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @group.destroy\n respond_to do |format|\n format.html { redirect_to groups_url, notice: 'Group was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @group.destroy\n respond_to do |format|\n format.html { redirect_to groups_url, notice: 'Group was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @group.destroy\n respond_to do |format|\n format.html { redirect_to groups_url, notice: 'Group was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @group.destroy\n respond_to do |format|\n format.html { redirect_to groups_url, notice: 'Group was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @group.destroy\n respond_to do |format|\n format.html { redirect_to groups_url, notice: 'Group was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @group.destroy\n respond_to do |format|\n format.html { redirect_to groups_url, notice: 'Group was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @group.destroy\n respond_to do |format|\n format.html { redirect_to groups_url, notice: 'Group was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @group.destroy\n respond_to do |format|\n format.html { redirect_to groups_url, notice: 'Group was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @group.destroy\n respond_to do |format|\n format.html { redirect_to groups_url, notice: 'Group was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @group.destroy\n respond_to do |format|\n format.html { redirect_to groups_url, notice: 'Group was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @group.destroy\n respond_to do |format|\n format.html { redirect_to groups_url, notice: 'Group was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @group.destroy\n respond_to do |format|\n format.html { redirect_to groups_url, notice: 'Group was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @group.destroy\n respond_to do |format|\n format.html { redirect_to groups_url, notice: 'Group was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @group.destroy\n respond_to do |format|\n format.html { redirect_to groups_url, notice: 'Group was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user_group = UserGroup.find(params[:id])\n @user_group.destroy\n\n respond_to do |format|\n format.html { redirect_to user_groups_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @user_group = UserGroup.find(params[:id])\n @user_group.destroy\n\n respond_to do |format|\n format.html { redirect_to user_groups_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @group.destroy\n respond_to do |format|\n flash[:success] = \"Group successfully deleted\"\n format.html { redirect_to groups_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @group.destroy\n respond_to do |format|\n format.html { redirect_to groups_url, notice: t('flash.notice.groups.successfully_destroyed') }\n format.json { head :no_content }\n end\n end",
"def destroy\n @group.destroy\n respond_to do |format|\n # format.html { redirect_to groups_url, notice: 'Group was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @group = Group.find(params[:id])\n @user_id = @group.user_id\n @group.destroy\n\n respond_to do |format|\n format.html { redirect_to groups_url(:user_id=>@user_id) }\n # format.html { redirect_to groups_sidebartab_url(:user_id=>@user_id) }\n format.json { head :no_content }\n end\n end",
"def destroy\n @groupon = Groupon.find(params[:id])\n @groupon.destroy\n\n respond_to do |format|\n format.html { redirect_to groupons_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @group.destroy\n\n head :no_content\n end",
"def destroy\n @group_key.destroy\n respond_to do |format|\n format.html { redirect_to group_keys_url }\n format.json { head :no_content }\n end\n end",
"def delete_group \n Group.destroy(params[:id])\n\n respond_to do |format|\n format.html {redirect_to dashboard_path}\n end\n end",
"def destroy\n @group = Group.find(params[:id])\n @group.destroy\n \n respond_to do |format|\n format.html { redirect_to(groups_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n Group.rebuild! if nil.|Group.find(:first).rgt\n\t @group = Group.find(params[:id])\n @group.destroy\n\n respond_to do |format|\n format.html { redirect_to(groups_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @group.destroy\n audit(@group, \"destroy\", @group.name )\n respond_to do |format|\n format.html { redirect_to groups_path, notice: 'Group was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\r\n @agroup.destroy\r\n respond_to do |format|\r\n format.html { redirect_to agroups_url }\r\n format.json { head :no_content }\r\n end\r\n end",
"def destroy\n @group = Group.find(params[:id])\n @group.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_groups_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n\n @group = Group.find(params[:id])\n @group.destroy\n\n respond_to do |format|\n format.html { redirect_to(groups_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n\n @group = Group.find(params[:id])\n @group.destroy\n\n respond_to do |format|\n format.html { redirect_to(groups_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @groupaddrobj = Groupaddrobj.find(params[:id])\n @groupaddrobj.destroy\n\n respond_to do |format|\n format.html { redirect_to groupaddrobjs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @current_user.quit_group(@group)\n respond_to do |format|\n format.html { redirect_to groups_path }\n format.json { head :no_content }\n end\n end",
"def destroy\n @group = Group.find(params[:id])\n @group.destroy\n\n respond_to do |format|\n format.html { redirect_to(groups_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @group = Group.find(params[:id])\n @group.destroy\n\n respond_to do |format|\n format.html { redirect_to(groups_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @group = Group.find(params[:id])\n @group.destroy\n\n respond_to do |format|\n format.html { redirect_to(groups_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @group = Group.find(params[:id])\n @group.destroy\n\n respond_to do |format|\n format.html { redirect_to(groups_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @group = Group.find(params[:id])\n @group.destroy\n\n respond_to do |format|\n format.html { redirect_to(groups_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @group = Group.find(params[:id])\n @group.destroy\n\n respond_to do |format|\n format.html { redirect_to(groups_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @group = Group.find(params[:id])\n @group.destroy\n\n respond_to do |format|\n format.html { redirect_to(groups_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @group = Group.find(params[:id])\n @group.destroy\n\n respond_to do |format|\n format.html { redirect_to(groups_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @esol_group = EsolGroup.find(params[:id])\n @esol_group.destroy\n\n respond_to do |format|\n format.html { redirect_to esol_groups_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n if @group.destroy\n render json: {result: 1}\n else\n render json: {result: 0}\n end\n end",
"def destroy\n @reagent_group = ReagentGroup.find(params[:id])\n @reagent_group.destroy\n\n respond_to do |format|\n format.html { redirect_to reagent_groups_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @group = Group.find(params[:id])\n authorize @group, :destroy?\n @group.destroy\n\n respond_to do |format|\n format.html { redirect_to(browse_groups_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @group = @course.groups.find(params[:id])\n @group.destroy\n respond_to do |format|\n format.html { redirect_to groups_url, notice: 'Group was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @group.destroy\n respond_to do |format|\n format.html { redirect_to groups_url, notice: 'Asset was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @group = Group.find(params[:id])\n @group.destroy\n\n redirect_to groups_path\n end",
"def destroy\n @group = Group.find(params[:id])\n @group.destroy\n\n redirect_to groups_path\n end",
"def destroy\n if @group.destroy\n render_json_message({:success => t('.success')}, 200)\n else\n render_json_message({:errors => @group.errors.messages}, 422)\n end\n end",
"def delete(group_id)\n if expired?(@begin_time)\n @auth = get_auth(@api_key)\n end\n Log.debug(\"#{@base_url}#{@get_post_delete_url}#{group_id}\")\n user_group = RestClient.delete \"#{@base_url}#{@get_post_delete_url}#{group_id}\", header\n end",
"def destroy\n @group.destroy\n respond_to do |format|\n format.html { redirect_to admin_groups_url, notice: t('activerecord.models.group') +'删除成功!' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @group_stat = GroupStat.find(params[:id])\n @group_stat.destroy\n\n respond_to do |format|\n format.html { redirect_to group_stats_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n authorize @group\n @group.destroy\n respond_to do |format|\n format.html { redirect_to groups_url, notice: \"Group was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @group = Group.find(params[:id])\n u1 = User.where(:login=>@group.name).select(:id)\n @u2 = User.find(u1)\n @u2.destroy\n @group.destroy\n respond_to do |format|\n format.html { redirect_to groups_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @api_v1_group_field.destroy\n respond_to do |format|\n format.html { redirect_to api_v1_group_fields_url, notice: 'Group field was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @group.destroy\n respond_to do |format|\n format.html { redirect_to @index_url, notice: \"#{@group_model.to_s} was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy #:nodoc:\n @group = Group.find(params[:id])\n @group.destroy\n\n respond_to do |format|\n format.html { redirect_to groups_url }\n # format.xml { head :ok }\n end\n end",
"def delete_group(client, options)\n if options[:directory].nil? or options[:group].nil?\n puts \"Missing arguments\"\n return\n end\n\n groups = client.groups\n group = groups.get options[:group]\n group.delete\n puts \"Group deleted.\"\n return\nend",
"def destroy\n @member_group.destroy\n respond_to do |format|\n format.html { redirect_to member_groups_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @access_group = AccessGroup.find(params[:id])\n @access_group.destroy\n\n respond_to do |format|\n format.html { redirect_to access_groups_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @no_group.destroy\n respond_to do |format|\n format.html { redirect_to no_groups_url, notice: 'No group was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @group = Group.find(params[:id])\n\n mbs = Membership.where \"group_id = ?\", @group.id\n\n mbs.each do |m|\n m.destroy\n end\n\n @group.destroy\n\n respond_to do |format|\n format.html { redirect_to groups_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @contact_group.destroy\n\n render json: @contact_group, status: :ok\n end"
] |
[
"0.80822545",
"0.79805106",
"0.79167783",
"0.786261",
"0.786261",
"0.7848193",
"0.7848193",
"0.78414327",
"0.78414327",
"0.78414327",
"0.78414327",
"0.78414327",
"0.7832357",
"0.7832357",
"0.7832357",
"0.7832357",
"0.7832357",
"0.7832357",
"0.7808105",
"0.7787947",
"0.7787941",
"0.7775968",
"0.7753868",
"0.77335536",
"0.76834154",
"0.7666779",
"0.76541406",
"0.7650491",
"0.76401937",
"0.76328784",
"0.7587671",
"0.7582359",
"0.7571545",
"0.75693494",
"0.7555517",
"0.75527126",
"0.75448126",
"0.75448126",
"0.75448126",
"0.75448126",
"0.75448126",
"0.75448126",
"0.75448126",
"0.75448126",
"0.75448126",
"0.75448126",
"0.75448126",
"0.75448126",
"0.75448126",
"0.75448126",
"0.75448126",
"0.75374043",
"0.7530815",
"0.7530724",
"0.7516523",
"0.7514574",
"0.7507416",
"0.750637",
"0.7505967",
"0.7501832",
"0.7494603",
"0.74856704",
"0.74809206",
"0.74798495",
"0.74786437",
"0.747171",
"0.7469876",
"0.7469876",
"0.7450597",
"0.7449988",
"0.74402887",
"0.74402887",
"0.74402887",
"0.74402887",
"0.74402887",
"0.74402887",
"0.74402887",
"0.74402887",
"0.74371374",
"0.74211216",
"0.74121547",
"0.7405527",
"0.74011123",
"0.7395265",
"0.73889756",
"0.73889756",
"0.73880774",
"0.7384338",
"0.7384112",
"0.73812103",
"0.73809385",
"0.7366125",
"0.7362234",
"0.7356031",
"0.73535824",
"0.73487324",
"0.733849",
"0.7328249",
"0.7324329",
"0.7321351",
"0.73169076"
] |
0.0
|
-1
|
Use callbacks to share common setup or constraints between actions.
|
def set_group
@group = Group.find(params[:id])
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end",
"def add_actions; end",
"def callbacks; end",
"def callbacks; end",
"def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end",
"def define_action_helpers; end",
"def post_setup\n end",
"def action_methods; end",
"def action_methods; end",
"def action_methods; end",
"def before_setup; end",
"def action_run\n end",
"def execute(setup)\n @action.call(setup)\n end",
"def define_action_helpers?; end",
"def set_actions\n actions :all\n end",
"def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end",
"def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end",
"def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end",
"def before_actions(*logic)\n self.before_actions = logic\n end",
"def setup_handler\n end",
"def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end",
"def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def workflow\n end",
"def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end",
"def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end",
"def before(action)\n invoke_callbacks *self.class.send(action).before\n end",
"def process_action(...)\n send_action(...)\n end",
"def before_dispatch(env); end",
"def after_actions(*logic)\n self.after_actions = logic\n end",
"def setup\n # override and do something appropriate\n end",
"def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end",
"def setup(_context)\n end",
"def setup(resources) ; end",
"def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end",
"def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end",
"def determine_valid_action\n\n end",
"def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end",
"def startcompany(action)\n @done = true\n action.setup\n end",
"def init_actions\n am = action_manager()\n am.add_action(Action.new(\"&Disable selection\") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } )\n am.add_action(Action.new(\"&Edit Toggle\") { @edit_toggle = !@edit_toggle; $status_message.value = \"Edit toggle is #{@edit_toggle}\" })\n end",
"def event_callbacks(event, metadata={})\n case event\n when :reset, :review\n if confirmed\n update_attributes(confirmed: false)\n end\n when :confirm\n confirm\n # trigger :order for all applicable items\n # NOTE: :order event is common to both physical and digital items\n items.each do |i|\n if i.event_permitted(:order)\n user_id = last_transition.user_id\n i.trigger!(:order, { order_id: id, user_id: user_id })\n end\n end\n when :complete_work\n request = metadata[:request]\n work_complete_notification(request)\n when :close\n close\n end\n if event != :close && !open\n reopen\n end\n end",
"def setup_action\n return unless PONY::ERRNO::check_sequence(current_act)\n new_sequence = @action_sequence[@sequence_index+1...@action_sequence.size]\n @sequence_index = 0\n new_sequence = DND::SkillSequence::ACTS[@acts[1]] + new_sequence\n execute_sequence\n end",
"def define_tasks\n define_weave_task\n connect_common_tasks\n end",
"def setup(&block)\n define_method(:setup, &block)\n end",
"def setup\n transition_to(:setup)\n end",
"def setup\n transition_to(:setup)\n end",
"def action\n end",
"def setup( *args )\n\t\t\tself.class.setupBlocks.each {|sblock|\n\t\t\t\tdebugMsg \"Calling setup block method #{sblock}\"\n\t\t\t\tself.send( sblock )\n\t\t\t}\n\t\t\tsuper( *args )\n\t\tend",
"def config(action, *args); end",
"def setup\n @setup_proc.call(self) if @setup_proc\n end",
"def before_action \n end",
"def setup_callbacks\n defined_callbacks.each do |meth|\n unless respond_to?(\"call_#{meth}_callbacks\".to_sym)\n self.class.module_eval <<-EOE\n def call_#{meth}_callbacks(*args)\n plugin_store.each {|a| a.call_#{meth}_callbacks(*args) } if respond_to?(:plugin_store) && plugin_store\n self.send :#{meth}, *args if respond_to?(:#{meth})\n end\n EOE\n end\n end\n end",
"def action\n end",
"def matt_custom_action_begin(label); end",
"def setup\n # override this if needed\n end",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def action(options,&callback)\n new_action = Action===options ? options : Action.new(options,&callback)\n # replace any with (shared name/alias or both default) + same arity\n @actions.delete_if do |existing_action|\n ((existing_action.names & new_action.names).size > 0 ||\n existing_action.default? && new_action.default?) &&\n existing_action.required.size == new_action.required.size &&\n existing_action.optional.size <= new_action.optional.size\n end\n @actions = (@actions + [new_action]).sort\n new_action\n end",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action\n end",
"def after(action)\n invoke_callbacks *options_for(action).after\n end",
"def pre_task\n end",
"def setup(server)\n server.on('beforeMethod', method(:before_method), 10)\n end",
"def add_actions\n attribute = machine.attribute\n name = self.name\n \n owner_class.class_eval do\n define_method(name) {self.class.state_machines[attribute].events[name].fire(self)}\n define_method(\"#{name}!\") {self.class.state_machines[attribute].events[name].fire!(self)}\n define_method(\"can_#{name}?\") {self.class.state_machines[attribute].events[name].can_fire?(self)}\n end\n end",
"def init_actions\n @select_action = SelectAction.new\n @endpoint_mouse_action = EndpointMouseAction.new\n @move_action = MoveAction.new\n end",
"def setup_signals; end",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action.respond_to?('weak!') ? action.weak! : action\n end",
"def initialize(*args)\n super\n @action = :set\nend",
"def after_set_callback; end",
"def setup\n #implement in subclass;\n end",
"def lookup_action; end",
"def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end",
"def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end",
"def release_actions; end",
"def around_hooks; end",
"def save_action; end",
"def setup(easy)\n super\n easy.customrequest = @verb\n end",
"def action_target()\n \n end",
"def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end",
"def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end",
"def before_setup\n # do nothing by default\n end",
"def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end",
"def default_action; end",
"def setup(&blk)\n @setup_block = blk\n end",
"def callback_phase\n super\n end",
"def advice\n end",
"def _handle_action_missing(*args); end",
"def duas1(action)\n action.call\n action.call\nend",
"def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end",
"def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end",
"def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend"
] |
[
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576",
"0.53124547",
"0.529654",
"0.5296262",
"0.52952296",
"0.52600986",
"0.52442724",
"0.52385926",
"0.52385926",
"0.52385926",
"0.52385926",
"0.52385926",
"0.5232394",
"0.523231",
"0.5227454",
"0.52226824",
"0.52201617",
"0.5212327",
"0.52079266",
"0.52050185",
"0.51754695",
"0.51726824",
"0.51710224",
"0.5166172",
"0.5159343",
"0.51578903",
"0.51522785",
"0.5152022",
"0.51518047",
"0.51456624",
"0.51398855",
"0.5133759",
"0.5112076",
"0.5111866",
"0.5111866",
"0.5110294",
"0.5106169",
"0.509231",
"0.50873137",
"0.5081088",
"0.508059",
"0.50677156",
"0.50562143",
"0.5050554",
"0.50474834",
"0.50474834",
"0.5036181",
"0.5026331",
"0.5022976",
"0.5015441",
"0.50121695",
"0.5000944",
"0.5000019",
"0.4996878",
"0.4989888",
"0.4989888",
"0.49864885",
"0.49797225",
"0.49785787",
"0.4976161",
"0.49683493",
"0.4965126",
"0.4958034",
"0.49559742",
"0.4954353",
"0.49535993",
"0.4952725",
"0.49467874",
"0.49423352",
"0.49325448",
"0.49282882",
"0.49269363",
"0.49269104",
"0.49252945",
"0.4923091",
"0.49194667",
"0.49174926",
"0.49173003",
"0.49171105",
"0.4915879",
"0.49155936"
] |
0.0
|
-1
|
Never trust parameters from the scary internet, only allow the white list through.
|
def group_params
# params.require(:group).permit(:title, :description)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def param_whitelist\n [:role, :title]\n end",
"def expected_permitted_parameter_names; end",
"def safe_params\n params.except(:host, :port, :protocol).permit!\n end",
"def strong_params\n params.require(:team_member).permit(param_whitelist)\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def strong_params\n params.require(:community).permit(param_whitelist)\n end",
"def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end",
"def strong_params\n params.require(:education).permit(param_whitelist)\n end",
"def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end",
"def allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\n end",
"def param_whitelist\n [:rating, :review]\n end",
"def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end",
"def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end",
"def user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end",
"def user_params\n params.permit(:name, :phoneNumber, :address, :postalCode, :local, :link, :counter, :latitude, :longitude) \n end",
"def valid_params_request?; end",
"def strong_params\n params.require(:experience).permit(param_whitelist)\n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def whitelist_url_params\n params.require(:whitelist_url).permit(:domain)\n end",
"def allowed_params\n params.require(:allowed).permit(:email)\n end",
"def permitted_params\n []\n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\n end",
"def query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend",
"def strong_params\n params.require(:success_metric).permit(param_whitelist)\n end",
"def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end",
"def whitelisted_user_params\n params.require(:user).\n permit( :first_name, :last_name, :email,:password,:password_confirmation,:birthday,:gender)\n end",
"def user_params\n ActionController::Parameters.permit_all_parameters = true\n params.require(:user) #.permit(:name, :surname, :phone, :password, :email, :time_zone)\n end",
"def strong_params\n params.require(:metric_change).permit(param_whitelist)\n end",
"def safe_params\n params.require(:user).permit(:name)\n end",
"def get_params\n\t\treturn ActionController::Parameters.new(self.attributes).permit(\"account_id\", \"title\", \"category\", \"introduction\", \"tags\", \"segment_type\", \"visible\", \"status\", \"main_image\")\n\tend",
"def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end",
"def check_params; true; end",
"def param_whitelist\n whitelist = [\n :description,\n :progress,\n :kpi_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:kpi_id)\n end\n \n whitelist\n end",
"def quote_params\n params.permit!\n end",
"def valid_params?; end",
"def paramunold_params\n params.require(:paramunold).permit!\n end",
"def user_params\n\t\tparams.permit(:nickname, :avatar, :description, :password, :gender, :birthday, :email, :phone, :qq_id, :wechat_id)\n\tend",
"def filtered_parameters; end",
"def user_params\n params.permit(\n \t:id,\n \t:email, \n \t:first_name, \n \t:last_name, \n \t:password, \n \t:confirm_token, \n \t:phone_number,\n \t:facebook_link,\n \t:car_model,\n \t:license_plate)\n end",
"def filtering_params\n params.permit(:email, :name)\n end",
"def check_params\n true\n end",
"def wx_public_params\n params.require(:wx_public).permit(:nickname, :manager, :alias)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def listing_params\n\t\tparams.permit(:address, :transit_info, :rules, :other_info, :lat, :lng)\n\tend",
"def social_account_params\n\t\t\tparams.require(:social_account).permit!\n\t\tend",
"def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end",
"def url_params\n params.require(:url).permit(:short_url, :original_url, :clicks, :ip_addresses)\n end",
"def user_params\n params.require(:user).permit(:uri, :username, :password, :realname, :email, :publicvisible)\n end",
"def model_params\n\t\tparams.require(:manager).permit(\n\t :user_name,\n :password,\n :email,\n \t\t\t)\n\tend",
"def article_params_whitelist\n params.require(:article).permit(:title, :description, category_ids: [])\n end",
"def college_whitelist_params\n params.require(:college_whitelist).permit(:status)\n end",
"def active_code_params\n params[:active_code].permit\n end",
"def filtering_params\n params.permit(:email)\n end",
"def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end",
"def ip_address_params\n\t\t\tparams.require(:ip_address).permit!\n end",
"def pull_request_params\n whitelist = [\n :url,\n :id,\n :html_url,\n :diff_url,\n :patch_url,\n :issue_url,\n :number,\n :state,\n :locked,\n :title\n ]\n params.require(:pull_request).permit(whitelist)\n end",
"def reserved_params\n params.require(:reserved).permit(:name, :email, :pax, :address, :KTP, :title)\n end",
"def post_params\n if current_user.admin? \n params.permit(:title, :body, :city, :country, :gps_location, :privacy, :visible, :latitude, :longitude, images: [], files: [])\n else \n params.permit(:title, :body, :city, :country, :gps_location, :privacy,:latitude, :longitude, images: [], files: [])\n end \n end",
"def list_params\n params.permit(:name)\n end",
"def filter_parameters; end",
"def filter_parameters; end",
"def vineyard_params\n params.permit(:vineyard_name, :email, :website_url, :phone, :address, :city, :region, :postcode, :country, :specialty, :description, :pet_friendly, :holiday, :tours, :events, :family_friendly, :cover_image, :image_one, :image_two, :image_three, :image_four, :user_id, :base64)\n end",
"def available_activity_params\n # params.require(:available_activity).permit(:type,:geometry,:properties)\n whitelisted = ActionController::Parameters.new({\n type: params.require(:available_activity)[:type],\n geometry: params.require(:available_activity)[:geometry].try(:permit!).to_h,\n properties: params.require(:available_activity)[:properties].try(:permit!).to_h\n }).try(:permit!)\n end",
"def user_params\n params.permit(:name, :username, :email, :password, :img_url, :bg_url, :coinbank)\n end",
"def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end",
"def user_params\n params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\n :user, :color, :solde)\n end",
"def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end",
"def param_whitelist\n [\n :title,\n :description,\n :organization,\n :team_id,\n :started_at,\n :finished_at,\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n end",
"def url_whitelist; end",
"def admin_social_network_params\n params.require(:social_network).permit!\n end",
"def filter_params\n params.require(:filters).permit(:letters)\n end",
"def origin_params\n params.permit(:country, :state, :city, :postal_code, :address, :description)\n end",
"def valid_params(params)\n params.permit(:login, :first_name, :last_name, \n :password, :password_confirmation)\n end",
"def sensitive_params=(params)\n @sensitive_params = params\n end",
"def permit_request_params\n params.permit(:address)\n end",
"def user_params\n # Ensure a user can't give themselves admin priveleges\n params.delete(:admin) if current_user.admin?\n params.require(:user).permit(:name, :email, :admin, :image)\n end",
"def secure_params\n params.require(:location).permit(:name)\n end",
"def strong_params\n params.require( :setting ).\n permit( :global_scan_limit, :per_user_scan_limit,\n :target_whitelist_patterns, :target_blacklist_patterns )\n end",
"def question_params\n params.require(:survey_question).permit(question_whitelist)\n end",
"def case_insensitive_params\n params.require(:case_insensitive).permit(:name)\n end",
"def empire_master_no_match_params\n params.require(:empire_master_no_match).permit(:uid, :last_name, :list, :search_date, :double, :source)\n end",
"def maintenance_request_params\n params[:maintenance_request].permit! #allow all parameters for now\n end",
"def unwanted_params\n params.require(:unwanted).permit(:title, :description, :image)\n end",
"def url_params\n params[:url].permit(:full)\n end",
"def backend_user_params\n params.permit!\n end",
"def filter_params\n\t\treturn params[:candidate].permit(:name_for_filter)\n\tend",
"def speed_measurement_params\n\n #fuckit, to lazy to deal with permit crap right now\n ActionController::Parameters.permit_all_parameters = true\n\n params[:speed_measurement]\n end",
"def user_params\n params.permit(:name, :age, :username, :display_photo, :password)\n end",
"def get_params\r\n #params.require(:article).permit(:title, :permalink, :content, :source_site, :introtext, :type_id, :order_by, :searchable, :created_by, :edited_by, :published_by, :published_on, :user_id)\r\n params.require(:article).permit!\r\n\r\n end",
"def pub_params\n params.require(:pub).permit(:name, :description, :phone, :email, :hidden, :city_id, :address)\n end",
"def pass_params\n params[:pass].permit(:name, :price, :description, :colour, :events)\n end",
"def droptraining_params\n params.permit(:training_id,:user_id, :utf8, :authenticity_token, :commit)\n end",
"def person_params\n # params whitelist does *not* include admin, sub, remember_token\n # TBD: share this whitelist with the list used by configuration_permitted_parameters\n # TBD: should current_password be on this list? -- for now, leaving off, since it seems to work without\n # NOTE: do not include 'admin' in this list!\n params.require(:person).permit(\n :name, \n :email, \n :description,\n :password, \n :password_confirmation\n )\n end",
"def parameter_params\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\n end"
] |
[
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",
"0.62894756",
"0.6283177",
"0.6242471",
"0.62382483",
"0.6217549",
"0.6214457",
"0.6209053",
"0.6193042",
"0.6177802",
"0.6174604",
"0.61714715",
"0.6161512",
"0.6151757",
"0.6150663",
"0.61461",
"0.61213595",
"0.611406",
"0.6106206",
"0.6105114",
"0.6089039",
"0.6081015",
"0.6071004",
"0.60620916",
"0.6019971",
"0.601788",
"0.6011056",
"0.6010898",
"0.6005122",
"0.6005122",
"0.6001556",
"0.6001049",
"0.59943926",
"0.5992201",
"0.59909594",
"0.5990628",
"0.5980841",
"0.59669393",
"0.59589154",
"0.5958826",
"0.5957911",
"0.5957385",
"0.5953072",
"0.59526145",
"0.5943361",
"0.59386164",
"0.59375334",
"0.59375334",
"0.5933856",
"0.59292704",
"0.59254247",
"0.5924164",
"0.59167904",
"0.59088355",
"0.5907542",
"0.59064597",
"0.5906243",
"0.5898226",
"0.589687",
"0.5896091",
"0.5894501",
"0.5894289",
"0.5891739",
"0.58860534",
"0.5882406",
"0.587974",
"0.58738774",
"0.5869024",
"0.58679986",
"0.5867561",
"0.5865932",
"0.5864461",
"0.58639693",
"0.58617616",
"0.5861436",
"0.5860451",
"0.58602303",
"0.5854586",
"0.58537364",
"0.5850427",
"0.5850199"
] |
0.0
|
-1
|
Save pem encoded content to a file. If the file doesn't exist, it will be created. Otherwise, the file will be overwritten. In both cases the contents will be overwritten atomically so other processes don't see a partially written file.
|
def save_pem(pem, path, owner: nil, group: nil, mode: 0644)
Puppet::FileSystem.replace_file(path, mode) do |f|
f.set_encoding('UTF-8')
f.write(pem.encode('UTF-8'))
end
if !Puppet::Util::Platform.windows? && Puppet.features.root? && (owner || group)
FileUtils.chown(owner, group, path)
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def write_pem(filename_or_io)\n write_data(filename_or_io, @cert.to_pem)\n end",
"def write_pem(filename_or_io)\n write_data(filename_or_io, @spki.to_pem)\n end",
"def write\n File.open(path, 'w') { |file|\n file.write(FILE_HEADER + \"\\n\")\n file.write(encoded_body)\n }\n end",
"def save_file(data, fspec = @config_json_spec)\n does_fileexist = File.exists?(fspec)\n File.open(fspec, \"w\") do |file|\n Puppet.debug \"saving file #{fspec}\"\n file.puts JSON.pretty_generate(data)\n # we want to set the initial permissions only if we're creating the file\n file.chmod(0664) unless does_fileexist\n end\n FileUtils.chown @config_json_owner, @config_json_group, fspec unless does_fileexist\n end",
"def write_file(path, content)\n file_exists = File.exists?(path)\n if file_exists and not @force\n fail \"File #{path} already exists. Not overwritten. Use --force to overwrite\"\n end\n save_file(path,content)\n message = file_exists ? \"File #{path} overwriten with new content\" : \"File #{path} created\"\n Puppet.notice message\n end",
"def save_to_file(path)\n fullpath = File.expand_path(path)\n lines = []\n\n @content.each_pair do |key,value|\n k = \"lxc.#{key.gsub('_', '.')}\"\n\n if value.kind_of?(Array)\n lines << value.map { |v| \"#{k} = #{v}\" }\n else\n lines << \"#{k} = #{value}\"\n end\n end\n\n File.open(path, \"w\") do |f|\n f.write(lines.flatten.join(\"\\n\"))\n end\n end",
"def save\n pathname.open('w') { |file| file.write(data) }\n end",
"def save_file(path, content)\n File.open(path, 'w') do |f|\n f.write content\n end\n end",
"def save\n ::File.open(@file, \"w\") { |file| file << self.to_hash.to_yaml }\n end",
"def save!\n begin\n case filename\n when STDOUT_FLAG\n $stdout.write(contents)\n else\n ::File.open(@filename,\"w\") do |f|\n f.write(contents)\n end\n end\n @dirty = false\n rescue => e\n raise FileAccessError, \"Error saving file #{@filename} : #{e.message}\"\n end\n end",
"def write_new_key\n File.open(full_key_path, 'w') do |f|\n f.write OpenSSL::PKey::RSA.generate(1024).export()\n end\n end",
"def save\n save_to_file(@output_file, @contents)\n end",
"def write_pem(filename_or_io)\n write_data(filename_or_io, @req.to_pem)\n end",
"def key_file\n write_file(\"request-#{domain}.key\", key.to_pem)\n end",
"def save # :nodoc:\n if @file\n File.open(SAVE_FILE, 'w') do |f|\n Marshal.dump(file, f)\n end\n else\n forget\n end\n end",
"def save # :nodoc:\n if @file\n File.open(SAVE_FILE, 'w') do |f|\n Marshal.dump(file, f)\n end\n else\n forget\n end\n end",
"def save\n File.open(file_path, 'w') do |file|\n YAML.dump(data, file)\n end\n end",
"def write_file(path, contents)\n file = @sftp.file\n file.open(path.to_s, 'w') do |file|\n file.puts contents.force_encoding('binary')\n end\n end",
"def write_email\n dir = @mailbox.dir\n Dir.mkdir dir, 0o755 unless Dir.exist? dir\n File.write File.join(dir, @hash), @raw, encoding: Encoding::BINARY\n end",
"def save\n File.open(file, \"w\") {|f| f.write(to_hash.to_yaml) }\n end",
"def save_to_file(path = nil)\n content\n file = Store::File.find_by(id: store_file_id)\n if !file\n raise \"No such file #{store_file_id}!\"\n end\n\n if !path\n path = Rails.root.join('tmp', filename)\n end\n ::File.open(path, 'wb') do |handle|\n handle.write file.content\n end\n path\n end",
"def save\n File.open(path, 'w') do |out|\n YAML.dump(data, out)\n end\n end",
"def save_as(path)\n contents = generate\n path.open('w') do |f|\n f.write(contents)\n end\n end",
"def save_as(path)\n contents = generate\n path.open('w') do |f|\n f.write(contents)\n end\n end",
"def save_as(path)\n contents = generate\n path.open('w') do |f|\n f.write(contents)\n end\n end",
"def save_as(path)\n contents = generate\n path.open('w') do |f|\n f.write(contents)\n end\n end",
"def save_as(path)\n contents = generate\n path.open('w') do |f|\n f.write(contents)\n end\n end",
"def export_to_pem(key, password)\n pem_file = key.gsub('.key', '.pem')\n\n if File.exist?(pem_file)\n return pem_file\n else\n command = \"openssl pkcs8 -inform DER -in someKey.key -passin pass:somePassword -out key.pem\"\n\n pem_file = key.gsub('.key', '.pem')\n\n command.gsub! 'someKey.key', key\n command.gsub! 'somePassword', password\n command.gsub! 'key.pem', pem_file\n\n result = system( command )\n return pem_file\n end\n\n\n end",
"def write_to_file(file_name, data)\n key_path = ::File.dirname(file_name)\n ::FileUtils.mkdir_p(key_path) unless ::File.directory?(key_path)\n ::File.rename(file_name, \"#{file_name}.#{Time.now.to_i}\") if ::File.exist?(file_name)\n ::File.open(file_name, \"wb\", 0o600) { |file| file.write(data) }\n end",
"def write key, value\n @content[key] = value\n File.open(@file_path, 'w') { |f| YAML.dump(@content, f) }\n end",
"def write_file(filename, content)\n FileUtils.mkdir_p File.dirname(filename)\n IO.binwrite(filename, content)\n end",
"def save_file\n raise ArgumentError, 'Need a Path to save the file' if @path.nil?\n File.open(@path, 'w') do |f|\n f.write to_s\n end\n end",
"def save\n File.open(file, \"w\") {|f| f.write(to_hash.to_yaml) }\n end",
"def write(filename, hash)\n File.open(filename, \"a\") do |f|\n f.write(yaml(hash))\n end\nend",
"def write_key!\n dir = Tinc.config['key_dir']\n File.open(\"#{dir}/#{node.mac}\", 'w') do |f|\n f.write(self.cert_data) \n end\n end",
"def write_content_to_file(file_name, content)\n File.open(file_name, 'w') { |file| file.write(content); file.flush }\nend",
"def save_to(path)\n (File.open(path, 'w') << to_s).close\n path\n end",
"def save_to(path)\n (File.open(path, 'w') << to_s).close\n path\n end",
"def atomic_write(data, path, name, options = {})\n main_file = File.join(path, name) + '.yml'\n dup_file = File.join(path, name) + '.yml2'\n \n # append verification info at the end of the file to guard from incomplete writes\n ts = Time.now\n ts_checksum = Digest::MD5.hexdigest(\"#{ts.tv_sec}.#{ts.tv_usec}\")\n if options[:owner]\n # secure the file\n File.open(dup_file, 'w').close\n uid = uid_for_username options[:owner]\n gid = gid_for_username options[:owner]\n File.chown uid, gid, dup_file\n File.chmod options[:permissions] || 0660, dup_file\n end\n File.open(dup_file, 'w') { |f| YAML::dump [data, ts.tv_sec, ts.tv_usec, ts_checksum], f }\n \n # move the file atomically to the main copy\n FileUtils.mv(dup_file, main_file)\n end",
"def write_to_file(path)\n File.open(path, \"w\") do |f|\n f.print serialize\n end\n end",
"def save_file(path, content)\n FileUtils.mkdir_p(File.expand_path(\"..\", path))\n File.open(path, \"w\") do |f|\n f.write(content)\n end\n end",
"def save_public_key(pub_key_file_data, dev_id) \n pub_key_save_path = File.join(@@gitolite_keydir_path, \"#{dev_id}.pub\")\n if !File.exists?(pub_key_save_path)\n File.open(pub_key_save_path, \"wb\") { |f| f.write pub_key_file_data}\n else\n LOGGER.debug \"Public key file already exists at #{pub_key_save_path}; this will not be overwritten\"\n end\n return pub_key_save_path\n end",
"def write_file(content, path)\n File.delete path if File.exists? path\n\n file = File.new path, 'w+'\n file.write content\n\n file.close\n end",
"def write_signature\n self.message = \"#{real_message.chomp}\\n\\n#{SIG_KEY}: #{signature}\\n\"\n IO.write(@message_file, message, 0, mode: 'w') unless @message_file.nil?\n end",
"def encrypt_to_file(file_path, value, encode_base64=true)\r\n\r\n # encrypt value.\r\n enc_value = encrypt(value, encode_base64)\r\n\r\n # save file.\r\n File.write(file_path, enc_value)\r\n enc_value\r\n end",
"def save\n file = File.new(@file, 'w+')\n @properties.each { |key, value| file.puts \"#{key}=#{value}\\n\" }\n end",
"def save\n file = File.new(@file,\"w+\")\n @properties.each {|key,value| file.puts \"#{key}=#{value}\\n\" }\n file.close\n end",
"def write_file(path)\n File.open(path, 'w') {|f| write_io(f)}\n end",
"def write_file filename,content\n mkdir_p(File.dirname(filename),:verbose=>false)\n File.open(filename, 'wb') {|f| f.write(content) }\n end",
"def write_content_to_file(file_path, content)\n File.open(file_path, 'w') do |f|\n f.write content\n end\n end",
"def save(filename, content)\n File.open(\"#{filename}.json\", 'w') do |f|\n f.write(JSON.pretty_generate(content))\n end\n end",
"def save\n File.open(path, \"w+\") do |f|\n f.write(FFI_Yajl::Encoder.encode(to_hash, pretty: true))\n end\n\n true\n end",
"def write_file(path, content)\r\n f = File.new(path, \"w+\")\r\n f.puts content\r\n f.close\r\n end",
"def save\n if file\n # Ensure the current store has been loaded before we try to re-write it, this\n # is necessary if the program generator has crashed before creating a test\n store\n p = Pathname.new(file)\n FileUtils.mkdir_p(p.dirname)\n File.open(p, 'w') { |f| f.puts JSON.pretty_generate(store) }\n end\n end",
"def write_to_file(target=nil, maintain_keys=false)\n save_to = target.nil? ? file_path : target\n keys_to_write = maintain_keys ? keys_from_file(save_to) : keys\n Translate::File.new(save_to).write(keys_to_write)\n end",
"def write_content\n File.open(absolute_path,'w') do |file|\n file << content if content\n end\n # TODO git functionality\n end",
"def save(path_or_io)\n yaml = YAML.dump(to_yaml_hash)\n\n case path_or_io\n when String, Pathname\n File.open(path_or_io, 'w') { |f| f.write(yaml) }\n else\n path_or_io.write(yaml)\n end\n end",
"def save! path\n File.open(path, 'w') do |file|\n file.write(to_s)\n end\n end",
"def save_as(path, overwrite=true)\n write_file(overwrite, path)\n end",
"def save\n FileUtils.mkdir_p(File.dirname(path)) unless File.directory?(File.dirname(path))\n File.open(path, \"w+\") { |f| f.puts(JSON.pretty_generate(secrets_hash)) }\n true\n end",
"def save_certificate(certificate)\n if !ENV['DYNO'].nil?\n Rails.logger.info('You are running this script on Heroku, please copy-paste certificates to your local machine')\n Rails.logger.info('and then follow https://devcenter.heroku.com/articles/ssl-endpoint guide:')\n\n Rails.logger.info(\"====== #{CONFIG[:domain]}-cert.pem ======\")\n puts certificate.to_pem\n\n Rails.logger.info(\"====== #{CONFIG[:domain]}-key.pem ======\")\n puts certificate.request.private_key.to_pem\n\n Rails.logger.info(\"====== #{CONFIG[:domain]}-chain.pem ======\")\n puts certificate.chain_to_pem\n\n Rails.logger.info(\"====== #{CONFIG[:domain]}-fullchain.pem ======\")\n puts certificate.fullchain_to_pem\n\n elsif File.directory?(File.join(Rails.root, CONFIG[:output_cert_dir]))\n Rails.logger.info('Saving certificates and key...')\n File.write(File.join(Rails.root, CONFIG[:output_cert_dir], \"#{CONFIG[:domain]}-cert.pem\"), certificate.to_pem)\n File.write(File.join(Rails.root, CONFIG[:output_cert_dir], \"#{CONFIG[:domain]}-key.pem\"), certificate.request.private_key.to_pem)\n File.write(File.join(Rails.root, CONFIG[:output_cert_dir], \"#{CONFIG[:domain]}-chain.pem\"), certificate.chain_to_pem)\n File.write(File.join(Rails.root, CONFIG[:output_cert_dir], \"#{CONFIG[:domain]}-fullchain.pem\"), certificate.fullchain_to_pem)\n else\n Rails.logger.error(\"Output directory: '#{File.join(Rails.root, CONFIG[:output_cert_dir])}' does not exist!\")\n end\n end",
"def save\n @filename = @filename || gen_filename\n file = File.open(File.join(@dir, @filename), 'w') { |f|\n f.puts @issue.to_yaml\n }\n end",
"def write path\n File.open(path, 'w') do |io|\n io.print serialize\n end\n end",
"def save\n # get a new KEK\n kek = OpenSSL::Random.random_bytes(32)\n \n # set up a cipher to encrypt the keystore\n cipher = get_cipher\n cipher.encrypt(kek)\n iv = cipher.random_iv\n\n # dump the keystore and pad it with a random length\n ksdata = OpenSSL::Random.random_bytes(2)\n len = ksdata.unpack(\"n\").first\n ksdata << OpenSSL::Random.random_bytes(len)\n ksdata << Marshal.dump(@ks)\n\n # encrypt the keystore with its KEK\n ciphertext = cipher.update(ksdata)\n ciphertext << cipher.final\n\n # encrypt the KEK\n public_rsa = @config[:SSLPrivateKey].public_key\n encrypted_key = public_rsa.public_encrypt(kek)\n\n # write out the encrypted KEK, the IV and the ciphertext\n File.open(@config[:filename], \"w\") do |fp| \n fp << encrypted_key\n fp << iv\n fp << ciphertext\n end\n end",
"def save_file_to_disk(new_content, filepath) \n File.open(filepath, 'w') { |f| f.write(new_content)}\n end",
"def save_as(file)\n File.open(file, \"wb\") { |f| f.write to_s }\n end",
"def save_as(file)\n File.open(file, \"wb\") { |f| f.write to_s }\n end",
"def save_file\r\n @saved = true\r\n saving\r\n Dir.mkdir(\"saves\") unless Dir.exists? \"saves\"\r\n File.open(\"my_save.yaml\", \"w\") {|f| f.puts YAML::dump(self) }\r\n end",
"def write_pkcs12(filename_or_io,password,friendly_name='r509 pkcs12')\n if @key.nil?\n raise R509::R509Error, \"Writing a PKCS12 requires both key and cert\"\n end\n pkcs12 = OpenSSL::PKCS12.create(password,friendly_name,@key.key,@cert)\n write_data(filename_or_io, pkcs12.to_der)\n end",
"def saveTempKey\n File.open(\"tempOut.txt\", 'w') {|f| f.write($publicKey) }\nend",
"def write_to_file(payload, stack)\n raise NotImplementedError\n if config[:path]\n full_path = File.join(\n config[:path],\n export_file_name(stack)\n )\n _, bucket, path = full_path.split(\"/\", 3)\n directory = provider.service_for(:storage,\n :provider => :local,\n :local_root => \"/\").directories.get(bucket)\n file_store(payload, path, directory)\n end\n end",
"def write_to_file(text)\n open(file_path, 'w') do |f|\n f.write(text)\n end\n file_update\n rescue Errno::ENOENT\n raise InvalidCache\n end",
"def write\n open(@fname,\"wb\") do |file|\n Marshal.dump(@data,file)\n end\n end",
"def write_pkcs12(filename_or_io, password, friendly_name = 'r509 pkcs12')\n if @key.nil?\n raise R509::R509Error, \"Writing a PKCS12 requires both key and cert\"\n end\n pkcs12 = OpenSSL::PKCS12.create(password, friendly_name, @key.key, @cert)\n write_data(filename_or_io, pkcs12.to_der)\n end",
"def write(file, content)\n file = remove_prefix(file)\n return if File.exist?(file)\n `mkdir -p #{File.dirname(file)}`\n File.open(file, \"w+\") { |f|\n f.write(remove_prefix(JSON.pretty_generate(content)))\n }\n end",
"def save( file )\n begin\n File.open( file, 'w' ) { |f| f.write( YAML.dump( self ) ) }\n rescue\n File.open( file, 'wb' ) { |f| f.write( Marshal.dump( self ) ) }\n end\n end",
"def save\n return if File.exists?(file)\n\n # Create parent directories\n FileUtils.mkdir_p(File.dirname(file))\n\n File.open(file, \"w\") do |f|\n f.write(compressed_contents)\n end\n\n puts \"Wrote blob #{file}\"\n end",
"def write(path)\n File.open(path, 'w') {|f| f.write(pack) }\n end",
"def write_to_file(member_details)\n begin\n file = File.open(\"./data/members.yml\",\"a+\"){ |file| file.write(member_details.to_yaml)}\n if file\n puts \"Welcome, your details have been saved for next time\".colorize(:green)\n end\n rescue\n puts \"Couldn't locate member\".colorize(:red)\n puts \"Could not save member details to the file\".colorize(:red)\n end\nend",
"def write_file\n \n # if dirty?\n generate\n \n delete_file\n File.open(absolute_path.gsub(/\\.txt$/, \"\"), 'w+') do |f| \n f.write(generated_header)\n f.write(generated_content)\n end\n # not_dirty\n # end\n end",
"def save!(file_path)\n File.open(file_path, \"w\") do |f|\n f.write(YAML.dump(@log))\n end\n end",
"def persist!\n raise \"Robut::Storage::YamlStore.file must be set\" unless file\n File.open(file, \"w\") do |f|\n f.puts internal.to_yaml\n end\n end",
"def ssh_public=(key_content)\n @ssh_public_file = temp_file_manager.path('key.pub')\n IO.write(@ssh_public_file, key_content)\n end",
"def save(overwrite=true)\n write_file(overwrite, @filename)\n end",
"def file_write(file, content)\n \n instructions = \"echo #{content.inspect} >> #{file}\"\n r = @ssh ? @ssh.exec!(instructions) : `#{instructions}`\n puts 'r: ' + r.inspect if @debug\n \n @results[:file_write] = r\n\n end",
"def write!\n new_file = !File.exists?(path)\n File.open(path, File::CREAT | File::RDWR) do |file|\n file.flock(File::LOCK_EX)\n if !new_file && init_mtime != file.mtime\n file.rewind\n content.deep_merge!(\n MultiJson.load(\n file.read\n )\n )\n file.rewind\n end\n pos = file.write MultiJson.dump(content, :pretty => true)\n file.truncate(pos)\n end\n end",
"def write_file_at(file, content)\n\t\tFileUtils.mkdir_p(File.dirname(file))\n\t\tFile.open(file, 'w') do |file|\n\t\t\tfile.write(content)\n\t\tend\n\tend",
"def write_content(file)\n (content = property(:content)) && content.write(file)\n end",
"def write\n file = ::File.open(@file, 'w')\n file.write(Bencode.encode(@data))\n file.close\n end",
"def write_file!\n file = File.new( path, \"w\")\n \n file.write(@source)\n file.close\n end",
"def write(property)\n remove_existing(:file)\n\n use_temporary_file = write_temporary_file?\n if use_temporary_file\n path = \"#{self[:path]}.puppettmp_#{rand(10000)}\"\n path = \"#{self[:path]}.puppettmp_#{rand(10000)}\" while ::File.exists?(path) or ::File.symlink?(path)\n else\n path = self[:path]\n end\n\n mode = self.should(:mode) # might be nil\n umask = mode ? 000 : 022\n mode_int = mode ? symbolic_mode_to_int(mode, 0644) : nil\n\n content_checksum = Puppet::Util.withumask(umask) { ::File.open(path, 'wb', mode_int ) { |f| write_content(f) } }\n\n # And put our new file in place\n if use_temporary_file # This is only not true when our file is empty.\n begin\n fail_if_checksum_is_wrong(path, content_checksum) if validate_checksum?\n ::File.rename(path, self[:path])\n rescue => detail\n fail \"Could not rename temporary file #{path} to #{self[:path]}: #{detail}\"\n ensure\n # Make sure the created file gets removed\n ::File.unlink(path) if FileTest.exists?(path)\n end\n end\n\n # make sure all of the modes are actually correct\n property_fix\n\n end",
"def save\n File.open(file, 'w') do |f|\n self.attributes.each {|key, value| f.write \"#{key}: '#{value}'\\n\" }\n end\n end",
"def file_write(path, content, append = false)\n dddebug('file_write', [path, '...', append])\n\n append == true ? mode = 'a' : mode = 'w'\n\n ::File.open(prefixed(path), mode) do |file|\n file.write(content)\n end\n end",
"def save!; File.write @path, @data end",
"def dump(file_path = nil)\n file_path ||= File.join(@config.data_path, \"#{Time.now.to_i.to_s}.bin\")\n File.open(file_path, 'wb') do |io|\n io << MessagePack.pack(to_hash)\n end\n file_path\n end",
"def save_pdf_file(pdf_content)\n File.open('data/test-generated/pdf/test.pdf', 'wb') { |file| file.puts(pdf_content) }\nend",
"def save(domain, pair)\n crt = File.expand_path(\"#{domain}.crt\", dir)\n key = File.expand_path(\"#{domain}.key\", dir)\n File.open(crt, 'w') {|f| f.write(pair.cert) }\n File.open(key, 'w') {|f| f.write(pair.key) }\n [crt, key]\n end",
"def write(contents = {})\n File.open(file_path, 'w+') do |file|\n @metadata = contents\n @metadata.merge!('downloaded_at' => Time.now.utc.iso8601)\n\n file.write(metadata.to_json)\n end\n end",
"def save(data: content, name: subject + '.html')\n filename = 'tmp/' + name\n\n File.open(filename, 'w+') do |f|\n f.write(data)\n end\n end",
"def save_to(path)\n unless File.exists?(File.dirname(path))\n raise ArgumentError, \"Output path does not exist!\"\n end\n if File.directory?(path)\n raise ArgumentError, \"Output path should be a file!\"\n end\n File.open(path, 'w') { |f| f.write(@content) }\n end"
] |
[
"0.63669235",
"0.6342067",
"0.58729726",
"0.5854523",
"0.5818254",
"0.5799773",
"0.578276",
"0.57702744",
"0.576625",
"0.57602286",
"0.5708695",
"0.5687255",
"0.5687134",
"0.5685794",
"0.56578064",
"0.56578064",
"0.5649476",
"0.56432116",
"0.56415886",
"0.5636437",
"0.5625253",
"0.5621234",
"0.5618267",
"0.5618267",
"0.5618267",
"0.5618267",
"0.5618267",
"0.5580314",
"0.5568826",
"0.55669266",
"0.5563154",
"0.55562603",
"0.55537677",
"0.55334854",
"0.5519178",
"0.5516517",
"0.5512794",
"0.5512794",
"0.55008256",
"0.5491993",
"0.5486619",
"0.54757303",
"0.54328126",
"0.54298526",
"0.5419828",
"0.5416669",
"0.5406451",
"0.53990555",
"0.53970325",
"0.5388181",
"0.5386131",
"0.53773755",
"0.5375073",
"0.53700346",
"0.5369798",
"0.5361797",
"0.5357913",
"0.5353461",
"0.53494954",
"0.5343569",
"0.53416806",
"0.53338206",
"0.532564",
"0.5322416",
"0.53157353",
"0.5307654",
"0.5307654",
"0.530694",
"0.53045756",
"0.5302456",
"0.52990043",
"0.5289192",
"0.5279123",
"0.5277114",
"0.5274384",
"0.5272222",
"0.5272209",
"0.52660483",
"0.52626187",
"0.52548987",
"0.52530783",
"0.5246756",
"0.52404326",
"0.52402943",
"0.5232358",
"0.52317804",
"0.52313143",
"0.5227066",
"0.5222516",
"0.52170587",
"0.5212464",
"0.5212058",
"0.5209789",
"0.52056986",
"0.5201131",
"0.52006054",
"0.51936406",
"0.5192743",
"0.51924664",
"0.518987"
] |
0.71479607
|
0
|
Delete a pem encoded object, if it exists.
|
def delete_pem(path)
Puppet::FileSystem.unlink(path)
true
rescue Errno::ENOENT
false
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def destroy\n @pem = Pem.find(params[:id])\n @pem.destroy\n\n respond_to do |format|\n format.html { redirect_to pems_url }\n format.json { head :no_content }\n end\n end",
"def delete\n result = exists\n raise RubyAem::Error.new('Certificate chain not found', result) if result.data == false\n\n @client.call(self.class, __callee__.to_s, @call_params)\n end",
"def destroy\n @public_key.destroy\n # PublicKey.regenerate_authorized_keys\n GitWit.remove_authorized_key(@public_key.raw_content)\n\n respond_to do |format|\n format.html { redirect_to public_keys_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @public_key.destroy\n respond_to do |format|\n format.html { redirect_to public_keys_url, notice: 'Public key was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete\n begin\n object = bucket.objects.find(@path)\n object.destroy\n true\n rescue Exception => e\n # If the file's not there, don't panic\n nil\n end\n end",
"def destroy\n if resource[:serial]\n serial_number = resource[:serial]\n elsif resource[:file]\n certificate_raw = File.read resource[:file]\n certificate_infos = OpenSSL::X509::Certificate.new(certificate_raw)\n serial_number = certificate_infos.serial.to_i\n end\n\n return false if serial_number.nil?\n\n certificate = client(resource).certificate(serial_number)\n result = certificate.delete\n\n handle(result)\n end",
"def destroy\n certificate_chain = client(resource).certificate_chain(resource[:private_key_alias], resource[:intermediate_path], resource[:authorizable_id])\n result = certificate_chain.delete\n\n handle(result)\n end",
"def s3_delete object_url\n begin\n key = URI.decode object_url.sub(/^.*\\/\\/.+?\\//,'')\n AWS.s3.buckets[ENV['AWS_S3_BUCKET']].objects[key].delete\n rescue Exception => e\n logger.error \"S3 Error: #{e.inspect}\"\n return false\n end\n end",
"def delete\n path = @p.path\n File::unlink path\n end",
"def delete(name)\r\n key = convert_key(name)\r\n return false unless has(key)\r\n @p.delete(key)\r\n true\r\n end",
"def destroy\n @authority = Certify::Authority.find(params[:certify_authority_id])\n @keypair = @authority.key_pairs.find(params[:id])\n @keypair.destroy\n\n respond_to do |format|\n format.html { redirect_to certify_authority_path(@authority), notice: 'Private key was successfully removed.' }\n format.json { head :no_content }\n end\n end",
"def delete(obj)\n true\n end",
"def delete_object(object_key)\n object_key_escaped = S3::Object.escape_key(object_key)\n \n unless object = get_object(object_key)\n raise S3Error::NoSuchKey, 'The specified key does not exist'\n end\n \n @cache.delete(:objects)\n \n return true unless @s3.error?(@s3.request_delete(\n \"/#{@name}/#{object_key_escaped}\"))\n end",
"def delete\n conn.delete(escaped_path)\n true\n rescue StandardError => e\n puts \"carrierwave-upyun delete failed: #{e.inspect}\"\n nil\n end",
"def delete\n object.destroy rescue nil\n end",
"def delete(obj) ; end",
"def aws_obj_delete(opts)\n opts[:obj].delete\n end",
"def delete(key)\n log \"deleting #{key} from #{container_path}\"\n object_path = File.join(container_path, Raca::Util.url_encode(key))\n response = storage_client.delete(object_path)\n (200..299).cover?(response.code.to_i)\n end",
"def delete(o); removeObject o end",
"def delete!\n client.delete_provisioning_profile!(self.id, mac: mac?)\n end",
"def delete_s3_contents\n S3Connection.new(:email).bucket.delete self.s3_key if self.uploaded?\n end",
"def delete_key_pair\n @os_aws.delete_key_pair\n end",
"def delete_object(bucket, key, options = {})\n bucket_data(bucket, options[:type])[:keys].delete(key)\n true\n end",
"def delete_key_pair(name)\n delete(\"tenants/#{tenant}/sshkeys/#{name}\")\n end",
"def delete\n conn = @client.authorized_connection(url: @client.object_api_url)\n res = conn.delete do |req|\n req.url resource_uri\n end\n if res.success?\n data = JSON.parse(res.body)\n reload\n else\n nil\n end\n end",
"def delete(object); end",
"def key_pair_deleted?(ec2_client, key_pair_name)\n ec2_client.delete_key_pair(key_name: key_pair_name)\n return true\nrescue StandardError => e\n puts \"Error deleting key pair: #{e.message}\"\n return false\nend",
"def destroy\n @ssh_public_key = SshPublicKey.destroy(params[:id])\n xml=@ssh_public_key.to_xml\n json=@ssh_public_key.to_json\n @ssh_public_key.destroy\n\n respond_to do |format|\n format.html { redirect_to(ssh_public_keys_url) }\n format.json { render :json => json}\n format.xml { render :xml => xml}\n end\n end",
"def destroy\n @aws_certificate.destroy\n respond_to do |format|\n format.html { redirect_to aws_certificates_url, notice: 'Aws certificate was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete_from_permanent_storage\n return if self.permanent_key.blank?\n PersistentStore.instance.delete_object(key: self.permanent_key)\n self.update!(permanent_key: nil)\n rescue Aws::S3::Errors::NotFound\n self.update!(permanent_key: nil)\n end",
"def destroy\n @certificate.destroy\n respond_to do |format|\n format.html { redirect_to certificates_path}\n format.json { head :no_content }\n end\n end",
"def destroy\n @certificado.destroy\n respond_to do |format|\n format.html { redirect_to certificados_url,\n notice: 'El certificado fue eliminado exitosamente.'}\n format.json { head :no_content }\n end\n end",
"def delete\n response = WebPay.client.delete(path)\n response['deleted']\n end",
"def destroy\n onesecgroup('delete', resource[:name])\n @property_hash.clear\n end",
"def aws_instance_S3_object_delete(bucket, name, attribute)\n obj = aws_call('aws_S3_obj_get', bucket: bucket, name: name)\n if aws_call('aws_obj_exists?', obj: obj)\n log \"AWS: deleting S3Object '#{obj.key}'\"\n aws_call('aws_obj_delete', obj: obj)\n else\n return false\n end\n self.update_attribute(attribute, \"\")\n true\n end",
"def destroy\n @key_pair = KeyPair.find(params[:id])\n @key_pair.destroy\n\n respond_to do |format|\n format.html { redirect_to key_pairs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n delete_object\n true\n end",
"def delete\n begin\n conn.delete(escaped_path)\n true\n rescue => e\n puts \"carrierwave-ucloud delete failed: #{e.inspect}\"\n nil\n end\n end",
"def destroy\n @certificado = Certificado.find(params[:id])\n @certificado.destroy\n\n respond_to do |format|\n format.html { redirect_to(certificados_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @paquet_key.destroy\n respond_to do |format|\n format.html { redirect_to paquet_keys_url, notice: 'Paquet key was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @privatejp = Privatejp.find(params[:id])\n @privatejp.destroy\n\n respond_to do |format|\n format.html { redirect_to(privatejps_url) }\n format.xml { head :ok }\n end\n end",
"def delete_certificate(name)\n client.delete(\"/v1/auth/cert/certs/#{encode_path(name)}\")\n return true\n end",
"def destroy\n @poem.destroy\n respond_to do |format|\n format.html { redirect_to poems_url, notice: 'Poem was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy!\r\n self.class.service_instance.delete_blob(path)\r\n end",
"def deleteRepositoryObject(path)\n begin\n File.delete(path+\".obj\")\n rescue DefaultException => e\n puts \"Failed to delete repository object : #{path}\"\n end\n end",
"def destroy\n @key_person = KeyPerson.find(params[:id])\n @key_person.destroy\n\n respond_to do |format|\n format.html { redirect_to key_people_url }\n format.json { head :ok }\n end\n end",
"def destroy_attachment\n a = Attachment.find(1) rescue nil\n if !a.nil?\n a.destroy\n end\n end",
"def destroy\n @certificate.destroy\n respond_to do |format|\n format.html { redirect_to certificates_url, notice: 'Certificate was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy_email_receipt\n self.email_receipt.destroy!\n end",
"def delete\n status = Sec.SecKeychainDelete(self)\n Sec.check_osstatus(status)\n self\n end",
"def destroy\n @pmkb.destroy\n respond_to do |format|\n format.html { redirect_to pmkbs_url, notice: 'Pmkb was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def purge obj, msg\n Dir.chdir(working_dir) do\n if File.file?(obj.blob.name)\n FileUtils.rm(obj.blob.name)\n end\n remove(obj.blob.name)\n end\n commit_index(msg)\n end",
"def delete(key)\n bucket.objects[key].delete\n rescue AWS::S3::Errors::NoSuchKey\n nil\n end",
"def destroy\n # get the ca\n @authority = Certify::Authority.find(params[:certify_authority_id])\n\n # get the certificate\n @certificate = Certify::Certificate.find(params[:id])\n @certificate.destroy\n\n respond_to do |format|\n format.html { redirect_to certify_authority_path(@authority), notice: 'Certificate removed' }\n format.json { head :no_content }\n end\n end",
"def delete_request(name)\n path = to_path(@requestdir, name)\n delete_pem(path)\n rescue SystemCallError => e\n raise Puppet::Error.new(_(\"Failed to delete certificate request for '%{name}'\") % {name: name}, e)\n end",
"def destroy\n @resume.destroy\n\n head :no_content\n end",
"def destroy\n @rsa.destroy\n respond_to do |format|\n format.html { redirect_to rsas_url, notice: 'Rsa was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @rsa_full.destroy\n respond_to do |format|\n format.html { redirect_to rsa_fulls_url, notice: 'Rsa full was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @pattachment = Pattachment.find(params[:id])\n @pattachment.destroy\n\n respond_to do |format|\n format.html { redirect_to pattachments_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @prossumer.destroy\n head :no_content\n end",
"def delete\n profile = profile_by_name(args.first)\n\n if profile.blank?\n display \"Please supply the name of the profile you'd like to delete\"\n self.list\n return false\n end\n\n if args[1] == \"yes\"\n puts profile['strongspace_path'][12..-1]\n begin\n strongspace.rm(profile['strongspace_path'][12..-1])\n rescue\n end\n end\n\n delete_profile(profile)\n\n display \"#{args.first} has been deleted\"\n end",
"def destroy\n @digital_object_identifier.destroy\n respond_to do |format|\n format.html { redirect_to digital_object_identifiers_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @envelope.destroy\n\n respond_to do |format|\n format.html { redirect_to :root }\n format.json { head :ok }\n end\n end",
"def destroy\n @certificate = Certificate.find(params[:id])\n @certificate.destroy\n\n respond_to do |format|\n format.html { redirect_to(certificates_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @cert.destroy\n respond_to do |format|\n format.html { redirect_to certs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n get_message().delete\n end",
"def destroy\n @sshkey.destroy\n respond_to do |format|\n format.html { redirect_to sshkeys_url }\n format.json { head :no_content }\n end\n end",
"def remove_key!(rsa)\n refresh_keys\n\n # loop through arrays checking against 'key'\n @keys.each do |key|\n if key[\"key\"] == rsa\n return remove_key_by_id!(key[\"id\"])\n end\n end\n\n return false # key not found\n end",
"def destroy_file\n object = self.class.bucket.objects.find(full_filename)\n object.destroy\n end",
"def remove_existing_keychain_item\n keychain_item = PiggyCash::Core::Keychain::piggy_cash_keychain_item\n if keychain_item\n if $force\n keychain_item.delete\n else\n puts \"Error: There is a corresponding Keychain Item for PiggyCash\\nUse --force to override\".red\n return\n end\n end\n end",
"def destroy(sobject, id)\n destroy!(sobject, id)\n rescue *exceptions\n false\n end",
"def delete_cert(imagename)\n stdout, stderr, status = Open3.capture3('/usr/local/bin/bolt', 'command', 'run', \"/usr/local/bin/puppet cert clean #{imagename}\", '-n', 'slice-master', '-u', 'root', '--tty') \n if stdout.include? 'Revoked'\n delete_hash = '###'.yellow\n delete_msg = \"Node #{imagename} certificate has been revoked.\"\n puts \"#{delete_hash} \" + \"#{delete_msg}\"\n end\nend",
"def destroy(data)\n delete(data)\n end",
"def destroy(data)\n delete(data)\n end",
"def destroy\n @prov_composer_bios = ProvComposerBios.find(params[:id])\n @prov_composer_bios.destroy\n\n respond_to do |format|\n format.html { redirect_to prov_composer_bios_url }\n format.xml { head :ok }\n end\n end",
"def delete(obj, tag)\n if not obj.tags.include?(tag)\n return false\n else\n obj[tag] = '' # Set to Nothing to Wipe Tag\n if obj.save\n return true\n else\n return false\n end\n end\nend",
"def destroy\n @alphasignup = Alphasignup.find(params[:id])\n @alphasignup.destroy\n\n respond_to do |format|\n format.html { redirect_to(alphasignups_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @pkhd.destroy\n respond_to do |format|\n format.html { redirect_to pkhds_url, notice: 'Pkhd was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @certificate.destroy\n respond_to do |format|\n format.html { redirect_to certificates_url, notice: 'Довідка видалена.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @key_pair = KeyPair.find(params[:id])\n @key_pair.destroy\n\n respond_to do |format|\n format.html { redirect_to(key_pairs_url) }\n format.xml { head :ok }\n end\n end",
"def delete(file_name)\n key = key_from_filename(file_name)\n puts \"Deleting object from s3 with key #{key}\"\n Aws::S3::Object.new(key: key, bucket_name: bucket, client: s3_client).tap do |obj|\n obj.delete\n obj.wait_until_not_exists\n end\n sync_down\n end",
"def destroy\n @pin_attachment.destroy\n respond_to do |format|\n format.html { redirect_to pin_attachments_url, notice: 'Pin attachment was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete(path)\n bucket.objects.delete(path)\n end",
"def delete_from(object_or_sash)\n sash = sash_from(object_or_sash)\n if sash.badge_ids.include?(id)\n sash.rm_badge(id)\n true\n else\n false\n end\n end",
"def destroy\n authorizable_keystore = client(resource).authorizable_keystore(resource[:intermediate_path], resource[:authorizable_id])\n result = authorizable_keystore.delete\n\n handle(result)\n end",
"def destroy\n @cert.destroy\n respond_to do |format|\n format.html { redirect_to certs_url, notice: 'Cert was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @epembash.destroy\n respond_to do |format|\n format.html { redirect_to epembashes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @resume.destroy\n end",
"def destroy\n @resume.destroy\n end",
"def destroy\n @email = DirectEmail.find(params[:id])\n @email.destroy\n head :no_content\n end",
"def destroys(object,*args,&block)\n opts = args.last.is_a?(Hash) ? args.pop.symbolize_keys : {}\n deletes_to(path_for(object,args),opts,&block)\n end",
"def bucket_delete_object(key)\n http.delete(\"/#{key}\", bucket: bucket, key: key)\n end",
"def delete(path_info)\n @file_store.delete path_info\n\n @bucket.objects[gem_object_name(path_info)].delete\n end",
"def destroy\n @keystore.destroy\n respond_to do |format|\n format.html { redirect_to keystores_url, notice: 'Keystore was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete(o)\n @hash.delete(o)\n self\n end",
"def delete(o)\n @hash.delete(o)\n self\n end",
"def destroy\n onevnet('delete', resource[:name])\n @property_hash.clear\n end",
"def delete\n response = client[\"/vaults/#{vault_id}/blobs/#{blob_id}\"].delete\n response.code == 200\n end",
"def destroy\n @propiedad.destroy\n respond_to do |format|\n format.html { redirect_to pmc_propiedades_path, notice: 'La propiedad se borró correctamente.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @paper = Paper.from_hash_name(params[:hash_name])\n @paper.destroy\n respond_to do |format|\n format.html { redirect_to papers_url, notice: 'Trabalho excluído com sucesso.' }\n format.json { head :no_content }\n end\n end"
] |
[
"0.6298715",
"0.62234724",
"0.6163683",
"0.601336",
"0.5942083",
"0.5860491",
"0.5818211",
"0.5764124",
"0.5761303",
"0.5738464",
"0.5720538",
"0.5691599",
"0.5683437",
"0.5671624",
"0.5642392",
"0.5637462",
"0.5621646",
"0.56120807",
"0.5608047",
"0.5607176",
"0.559704",
"0.5587234",
"0.557935",
"0.55416423",
"0.55254877",
"0.5518838",
"0.54992664",
"0.54944533",
"0.5492642",
"0.5477357",
"0.5467705",
"0.5464697",
"0.5458557",
"0.54583997",
"0.54497874",
"0.5448424",
"0.54480284",
"0.54455614",
"0.5428622",
"0.5414403",
"0.54032564",
"0.5400967",
"0.5398535",
"0.53915745",
"0.5388212",
"0.537863",
"0.5377905",
"0.5373374",
"0.5371617",
"0.5370707",
"0.5358483",
"0.5357561",
"0.5351058",
"0.53437525",
"0.5342754",
"0.53350616",
"0.5332813",
"0.53267765",
"0.53254306",
"0.532154",
"0.53198564",
"0.531843",
"0.5316355",
"0.531251",
"0.5309949",
"0.5305356",
"0.530528",
"0.53038645",
"0.5303439",
"0.5301923",
"0.5301197",
"0.53004396",
"0.52975184",
"0.52975184",
"0.5293044",
"0.5293044",
"0.52899754",
"0.52899057",
"0.5289411",
"0.5286331",
"0.5283856",
"0.5281506",
"0.5278973",
"0.52773577",
"0.5273094",
"0.52729034",
"0.5268674",
"0.5251778",
"0.5251778",
"0.52475536",
"0.5246039",
"0.5245128",
"0.52424496",
"0.52409935",
"0.52391255",
"0.52391255",
"0.52388364",
"0.5235833",
"0.5233436",
"0.5231995"
] |
0.7268935
|
0
|
GET /albums GET /albums.json
|
def index
@albums = Album.all
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def index\n @albums = Album.all\n render json: @albums\n end",
"def albums\n if params[:artist_id]\n albums = Artist.find(params[:artist_id]).albums\n else\n albums = Album.all\n end\n render json: albums\n end",
"def get_albums(url)\n # should return albums\n # List of Hashes\n \n # must implement \n # - custom site parser\n end",
"def album\n album = Album.find(params[:id])\n render json: album\n end",
"def get_album album_id\n get(\"/albums/#{album_id}\")\n end",
"def index\n @albums = @user.albums\n end",
"def artist_albums(artist, options = {})\n get \"artists/#{artist}/albums\", options\n end",
"def index\n @albums = Album.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @albums }\n end\n end",
"def albums(options={})\n call_pageable('library.getalbums', :albums, Album, {:user => @user.name}.merge(options))\n end",
"def get_albums(person_id, params={})\n @restv9.get_albums(person_id,params)\n end",
"def show\n @albums = Artist.find(params[\"id\"]).albums\n end",
"def albums\n @albums ||= response.albums.uniq(&:name)\n end",
"def show\n @album = Album.find(params[:id])\n @albums_count = Album.count\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @album }\n end\n end",
"def index\n @albums = current_user.albums\n end",
"def index\n\t\t@albums = Album.all\n\tend",
"def index\n @albums = @user.albums\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @albums }\n end\n end",
"def albums( options=nil )\n params = default_params.merge( \n :method => 'smugmug.albums.get',\n :heavy => 1\n ) \n\n params = params.merge( options ) if( options )\n xml = RestClient.post BASE, params\n \n Smile::Album.from_xml( xml, session_id )\n rescue\n nil\n end",
"def index\n @albums = @artist.albums.all.page(params[:page] || 1).per(18)\n end",
"def index\n @albums = current_user.albums.page(params[:page]).per(10)\n end",
"def picasa_albums(options = {})\n return [] unless current_user.has_provider_auth('google')\n PicasaPhoto.picasa_request_with_refresh(current_user.picasa_identity) do\n goog = GooglePhotosApi.new( current_user.picasa_identity.token )\n goog.albums[\"albums\"]\n end\n end",
"def index\n @album = Album.find(params[:album_id])\n @photos = @album.photos.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @photos }\n end\n end",
"def top_albums(tag)\n get(:standard, {:method => \"tag.getTopAlbums\", :tag => tag})\n end",
"def show\n @album = Album.find(params[:id])\n render json: AlbumSerializer.new(@album)\n end",
"def index\n @galleries_albums = Galleries::Album.all\n end",
"def create_albums\n url = 'https://stg-resque.hakuapp.com/albums.json'\n uri = URI(url)\n response = Net::HTTP.get(uri)\n albums = JSON.parse(response)\n\n albums.each do |album|\n Album.create!(album.except('id'))\n end\nend",
"def top_albums(user, options={})\n get(:standard, {:method => \"user.getTopAlbums\", :user => user}.merge(options))\n end",
"def show\n @album = Album.where(id: params[:id]).first\n if @album\n render json: @album, status: 200\n else\n return_not_found \n end\n end",
"def show\n \n @album = @user.albums.find(params[:id])\n\n respond_to do |format|\n \n format.html # show.html.erb\n format.js { render 'show'}\n format.json { render json: @album }\n end\n end",
"def albums( params={} )\n albums = get_connections(\"albums\", params)\n return map_connections albums, :to => Facebook::Graph::Album\n end",
"def albums( params={} )\n albums = get_connections(\"albums\", params)\n return map_connections albums, :to => Facebook::Graph::Album\n end",
"def album_tracks(album, options = {})\n get \"albums/#{album}/tracks\", options\n end",
"def show\n @album = Album.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @album }\n end\n end",
"def index\n if params[:album_id]\n @artists = Album.resolve(params[:album_id]).artist\n else\n @artists = Artist.order(:name)\n end\n\n render json: @artists\n end",
"def index\n params[:q]||={:s => \"name asc\"}\n unless current_user.admin.present?\n @albums = current_user.albums\n end\n @q = @albums.search(params[:q])\n @albums = @q.result.page(params[:page]).limit(params[:per_page]||10)\n end",
"def index\n @albums = Album.page(params[:page])\n\n respond_to do |format|\n format.html\n format.json { render json: @albums.to_json }\n format.xml { render xml: @albums.to_xml }\n end\n end",
"def album(album_id_or_url, options = {})\n options = make_options(:album_id, album_id_or_url, options)\n get(options)\n end",
"def index\n @albums = current_account.albums.find(:all, :order => 'position')\n \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @albums }\n end\n end",
"def top_albums(artist)\n get(:standard, {:method => \"artist.getTopAlbums\", :artist => artist})\n end",
"def index\n @albums = Album.page(params[:page]).per(10).order(created_at: :desc)\n\n respond_to do |format|\n format.html\n format.json { render json: @albums.to_json }\n format.xml { render xml: @albums.to_xml }\n end\n end",
"def show\n @user_album = UserAlbum.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @user_album }\n end\n end",
"def albums\n link :top_albums, :Album, name\n end",
"def show\r\n @album = Album.find(params[:id])\r\n\r\n respond_to do |format|\r\n format.html # show.html.erb\r\n format.json { render json: @album }\r\n end\r\n end",
"def show\n @user = User.find(@artist.user_id)\n @albums = @artist.albums\n end",
"def show\n album = Album.includes(:album_images).find(params[:id])\n return_hash = album.attributes\n return_hash['album_images'] = album.album_images\n render json: return_hash\n end",
"def index\n authorize! :read, Album\n \n @albums = Album.order(\"created_at DESC\").paginate(:page => params[:page], :per_page => 10)\n end",
"def picasa_albums(user, picasa_user_id=nil)\n return [] unless user.picasa_identity\n picasa = user.picasa_client\n user_data = picasa.user(picasa_user_id) \n albums = []\n unless user_data.nil?\n user_data.albums.select{|a| a.numphotos.to_i > 0}.each do |a|\n albums << {\n 'aid' => a.id,\n 'name' => a.title,\n 'cover_photo_src' => a.thumbnails.first.url\n }\n end\n end\n return albums\n end",
"def picasa_albums(options = {})\n return [] unless current_user.has_provider_auth('google')\n PicasaPhoto.picasa_request_with_refresh(current_user.picasa_identity) do\n picasa_user_id = options[:picasa_user_id] || current_user.picasa_identity.provider_uid\n picasa_identity = current_user.picasa_identity\n user_data = if picasa_user_id && picasa_identity\n PicasaPhoto.picasa_request_with_refresh(picasa_identity) do\n picasa_identity.reload\n picasa = Picasa.new(picasa_identity.token)\n picasa.user(picasa_user_id)\n end\n end\n albums = []\n unless user_data.nil?\n user_data.albums.select{|a| a.numphotos.to_i > 0}.each do |a|\n albums << {\n 'aid' => a.id,\n 'name' => a.title,\n 'cover_photo_src' => a.thumbnails.first.url\n }\n end\n end\n albums\n end\n rescue RubyPicasa::PicasaError => e\n raise e unless e.message =~ /authentication/\n Rails.logger.error \"[ERROR #{Time.now}] Failed to refresh access token for #{user.picasa_identity}\"\n []\n end",
"def show\n @albumm = Albumm.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @albumm }\n end\n end",
"def show\n if !session[:access_token]\n redirect_to :controller => 'sessions', :action => 'connect'\n end\n\n pmocampo = \"30792403\"\n client = Instagram.client(:access_token => session[:access_token])\n \n @user = client.user(pmocampo)\n \n @album = Album.find(params[:id])\n @photos = client.user_recent_media(pmocampo)\n @photos = @photos.select {|p| p.tags.include?(@album.tag)}\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @album }\n end\n end",
"def new\n @album = current_user.albums.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @album }\n end\n end",
"def index\n @item_albums = ItemAlbum.all\n end",
"def index\n @user = User.find(params[:id])\n raise \"not found\" if @user.blank? \n @albums = @user.albums.all(:order => :title)\n rescue\n redirect_to root_url, :notice => \"Can't find this user.\"\n end",
"def index\n @pictures = @album.pictures #JRD111115\n\n respond_to do |format|\n format.html #index.html.erb\n format.json { render json: @pictures}\n end\n end",
"def show\n @album_owned = AlbumOwned.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @album_owned }\n end\n end",
"def index\n @band = Band.find(params[:band_id])\n @albums = @band.albums\n end",
"def index\r\n @photos = Photo.all\r\n\r\n @albums = Album.all\r\n @albums_map = {}\r\n @albums.each do |album| \r\n @albums_map[album.TITLE] = album.ID\r\n end\r\n\r\n respond_to do |format|\r\n format.html # index.html.erb\r\n format.json { render json: @photos }\r\n end\r\n end",
"def index\n @private_albums = PrivateAlbum.all\n end",
"def show\r\n @photo = Photo.find(params[:id])\r\n\r\n @albums = Album.all\r\n @albums_map = {}\r\n @albums.each do |album| \r\n @albums_map[album.TITLE] = album.ID\r\n end\r\n\r\n respond_to do |format|\r\n format.html # show.html.erb\r\n format.json { render json: @photo }\r\n end\r\n end",
"def index\n\t\t@useralbums = current_user.albums\n\t\t@albums = Album.all\n\t\t# @useralbum = UserAlbum.where\n\tend",
"def index\n @interior_albums = InteriorAlbum.all\n end",
"def show\n @album = Album.find(params[:id])\n @potential_songs = Song.where(:artist_id => @album.artist.id)\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @album }\n end\n end",
"def index\n unless @user = User.first(:conditions => {:id => params[:user_id].to_i})\n redirect_to(root_url)\n return\n end\n \n @photo_albums = @user.photo_albums \n \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @photo_albums }\n end\n end",
"def show\n @photo = Photo.find(params[:id])\n\t@album = Album.find(@photo.album_id)\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @photo }\n end\n end",
"def get_albums\n sql = \"SELECT * FROM albums WHERE artist_id = $1\"\n values = [@id]\n albums_data = SqlRunner.run(sql, values)\n albums = albums_data.map { |albums_data| Album.new(albums_data)}\n return albums\n end",
"def find_album_by_id(client, album_id)\n client.api(:album, :show, album_id)\nend",
"def info(options={})\n get(:standard, {:method => \"album.getInfo\"}.merge(options))\n end",
"def show\n @album = Album.find_by_slug(params[:album_id])\n @album_item = @album.album_items.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @album_item }\n end\n end",
"def index\n @albums = Album.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @albums }\n end\n end",
"def index\n if logged_in?\n @favorites = current_user.favorites\n @albums = Album.all\n\n render json: AlbumSerializer.new(@albums) \n end\n end",
"def fetch_album(args)\n search = AlbumFetch.new(args)\n response = APIRequest.post(search.query, Configuration.instance.api_url(@format))\n parse_response(response)\n end",
"def albums\n self.album\n end",
"def artists\n # TODO: add param for albums and songs\n a = Artist.all\n render json: a\n end",
"def show\n\t\t@album = Album.find(params[:id])\n\tend",
"def resource\n\t\t@album\n\tend",
"def album\n\t\talbums == nil ? nil : albums.first\n\tend",
"def index\n @albums = Album.where(\"group_id = ?\", params[:group_id])\n\n respond_to do |format|\n format.html # index.html.erb\n format.js\n format.json { render json: @albums }\n end\n end",
"def image_list\n @images = Picture.where(album_id: params[:album_id])\n respond_to do |format|\n format.json { render json: @images.to_json(methods: [:path])}\n end\n end",
"def index\n @albums = Album.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @albums }\n end\n end",
"def index\n @albums = Album.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @albums }\n end\n end",
"def show\n @photos = @album.photos.includes(:album).page(params[:page])\n\n respond_to do |format|\n format.html do\n @page = @site.pages.find_by_name 'albums'\n @pages = @site.pages\n end\n format.js {}\n end\n end",
"def index\n @songs = @album.songs.all\n end",
"def index\n @images = @album.images.all\n end",
"def index\n @albums = Album.search(params[:search]).order(sort_column + ' ' + sort_direction).paginate(:per_page => 5, :page => params[:page])\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @albums }\n end\n end",
"def index\n @pictures = @album.pictures.all\n end",
"def show\n respond_to do |format|\n format.html { redirect_to action: 'edit', id: @album.id }\n format.json do\n render json: { rows: (@album.nil? ? [] : [@album.marshall]),\n status: (@album.nil? ? 404 : 200),\n total: (@album.nil? ? 0 : 1) }\n end\n end\n end",
"def index\r\n jump_to(\"/albums/list/#{session[:account_id]}\")\r\n end",
"def get_album_videos album_id\n get(\"/albums/#{album_id}/videos\")\n end",
"def index\n @albums = @other_user.shared_albums(@login_user.id)\n end",
"def top_albums \n lfm_path = \"artist.topAlbums&artist=#{@name}\"\n lfm_data = LastFm::fetch_data(lfm_path)\n return Album.create_from_hash(Hash.from_xml(lfm_data)['lfm']['topalbums']['album'])\n end",
"def index\n @album_photos = AlbumPhoto.all\n end",
"def new\n @group = Group.find(params[:group_id])\n @album = @group.albums.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @album }\n end\n end",
"def show\n @album = Album.find(params[:id])\n if @album.artist != nil\n @songs = get_songs_from_album @album.artist.name, @album.name\n @song_list = []\n if @songs\n @songs.each do |song|\n entry = Hash.new\n entry['rank'] = song['rank']\n entry['title'] = song['name']\n entry['artist'] = @album.artist.name\n song_in_db = lookup_song song['name'], @album.artist.name\n if song_in_db != nil\n entry['available'] = true\n entry['song_id'] = song_in_db.id\n else\n entry['available'] = false\n end\n entry['duration'] = seconds_to_duration(song['duration'].to_i)\n @song_list << entry\n end\n end\n @album_cover = get_album_cover @album.artist.name, @album.name\n @description = get_description_from_album @album.artist.name, @album.name\n end\n\n @songs = [] if @songs == nil\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @album }\n end\n end"
] |
[
"0.8048931",
"0.7923151",
"0.79193866",
"0.78014976",
"0.77844",
"0.7780223",
"0.77119625",
"0.7673395",
"0.7659477",
"0.75729513",
"0.75276154",
"0.75228256",
"0.74572295",
"0.74433213",
"0.7395577",
"0.7365708",
"0.73508006",
"0.7322036",
"0.73183537",
"0.7268043",
"0.72548515",
"0.7249786",
"0.7175557",
"0.7175306",
"0.7089282",
"0.7075508",
"0.7073862",
"0.7067561",
"0.70535755",
"0.70535755",
"0.70502895",
"0.70499504",
"0.7047336",
"0.7032099",
"0.70225596",
"0.70105404",
"0.70034266",
"0.69994",
"0.6987544",
"0.6985915",
"0.6984598",
"0.6972868",
"0.6965573",
"0.69099265",
"0.6905971",
"0.68562675",
"0.6855567",
"0.6851585",
"0.683983",
"0.6834951",
"0.68117255",
"0.6807393",
"0.6805671",
"0.6789684",
"0.6784436",
"0.6763833",
"0.673881",
"0.67276573",
"0.6721126",
"0.67204297",
"0.67168653",
"0.67144895",
"0.6705079",
"0.67041105",
"0.668878",
"0.66841644",
"0.66815466",
"0.6652078",
"0.66365373",
"0.66180295",
"0.6605053",
"0.6587493",
"0.6585956",
"0.6585598",
"0.6581055",
"0.6573792",
"0.65665317",
"0.6562288",
"0.6562288",
"0.6547021",
"0.6542613",
"0.65358865",
"0.65275455",
"0.6508044",
"0.6507622",
"0.650405",
"0.64990586",
"0.64814615",
"0.6476974",
"0.64626926",
"0.64476",
"0.6447495"
] |
0.73407245
|
23
|
GET /albums/1 GET /albums/1.json
|
def show
@artist = @album.artist
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def album\n album = Album.find(params[:id])\n render json: album\n end",
"def get_album album_id\n get(\"/albums/#{album_id}\")\n end",
"def index\n @albums = Album.all\n render json: @albums\n end",
"def albums\n if params[:artist_id]\n albums = Artist.find(params[:artist_id]).albums\n else\n albums = Album.all\n end\n render json: albums\n end",
"def index\n @albums = Album.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @albums }\n end\n end",
"def index\n @albums = @user.albums\n end",
"def show\n @albums = Artist.find(params[\"id\"]).albums\n end",
"def show\n @album = Album.find(params[:id])\n @albums_count = Album.count\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @album }\n end\n end",
"def get_albums(url)\n # should return albums\n # List of Hashes\n \n # must implement \n # - custom site parser\n end",
"def show\n @album = Album.where(id: params[:id]).first\n if @album\n render json: @album, status: 200\n else\n return_not_found \n end\n end",
"def get_albums(person_id, params={})\n @restv9.get_albums(person_id,params)\n end",
"def show\n @album = Album.find(params[:id])\n render json: AlbumSerializer.new(@album)\n end",
"def artist_albums(artist, options = {})\n get \"artists/#{artist}/albums\", options\n end",
"def show\n @album = Album.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @album }\n end\n end",
"def index\n @album = Album.find(params[:album_id])\n @photos = @album.photos.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @photos }\n end\n end",
"def show\r\n @album = Album.find(params[:id])\r\n\r\n respond_to do |format|\r\n format.html # show.html.erb\r\n format.json { render json: @album }\r\n end\r\n end",
"def index\n @albums = @user.albums\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @albums }\n end\n end",
"def index\n\t\t@albums = Album.all\n\tend",
"def show\n @user_album = UserAlbum.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @user_album }\n end\n end",
"def show\n \n @album = @user.albums.find(params[:id])\n\n respond_to do |format|\n \n format.html # show.html.erb\n format.js { render 'show'}\n format.json { render json: @album }\n end\n end",
"def index\n @albums = current_user.albums\n end",
"def albums\n @albums ||= response.albums.uniq(&:name)\n end",
"def index\n @albums = Album.all\n end",
"def index\n @albums = Album.all\n end",
"def index\n @albums = Album.all\n end",
"def index\n @albums = Album.all\n end",
"def index\n @albums = Album.all\n end",
"def index\n @albums = Album.all\n end",
"def index\n @albums = Album.all\n end",
"def index\n @albums = Album.all\n end",
"def index\n @albums = Album.all\n end",
"def index\n @albums = @artist.albums.all.page(params[:page] || 1).per(18)\n end",
"def index\n @albums = current_user.albums.page(params[:page]).per(10)\n end",
"def show\n @albumm = Albumm.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @albumm }\n end\n end",
"def show\n @photo = Photo.find(params[:id])\n\t@album = Album.find(@photo.album_id)\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @photo }\n end\n end",
"def create_albums\n url = 'https://stg-resque.hakuapp.com/albums.json'\n uri = URI(url)\n response = Net::HTTP.get(uri)\n albums = JSON.parse(response)\n\n albums.each do |album|\n Album.create!(album.except('id'))\n end\nend",
"def albums(options={})\n call_pageable('library.getalbums', :albums, Album, {:user => @user.name}.merge(options))\n end",
"def find_album_by_id(client, album_id)\n client.api(:album, :show, album_id)\nend",
"def index\n @pictures = @album.pictures #JRD111115\n\n respond_to do |format|\n format.html #index.html.erb\n format.json { render json: @pictures}\n end\n end",
"def album(album_id_or_url, options = {})\n options = make_options(:album_id, album_id_or_url, options)\n get(options)\n end",
"def new\n @album = current_user.albums.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @album }\n end\n end",
"def show\n @album_owned = AlbumOwned.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @album_owned }\n end\n end",
"def index\n if params[:album_id]\n @artists = Album.resolve(params[:album_id]).artist\n else\n @artists = Artist.order(:name)\n end\n\n render json: @artists\n end",
"def index\n @galleries_albums = Galleries::Album.all\n end",
"def show\n @album = Album.find_by_slug(params[:album_id])\n @album_item = @album.album_items.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @album_item }\n end\n end",
"def show\r\n @photo = Photo.find(params[:id])\r\n\r\n @albums = Album.all\r\n @albums_map = {}\r\n @albums.each do |album| \r\n @albums_map[album.TITLE] = album.ID\r\n end\r\n\r\n respond_to do |format|\r\n format.html # show.html.erb\r\n format.json { render json: @photo }\r\n end\r\n end",
"def show\n album = Album.includes(:album_images).find(params[:id])\n return_hash = album.attributes\n return_hash['album_images'] = album.album_images\n render json: return_hash\n end",
"def show\n @user = User.find(@artist.user_id)\n @albums = @artist.albums\n end",
"def index\n @albums = Album.page(params[:page])\n\n respond_to do |format|\n format.html\n format.json { render json: @albums.to_json }\n format.xml { render xml: @albums.to_xml }\n end\n end",
"def show\n if !session[:access_token]\n redirect_to :controller => 'sessions', :action => 'connect'\n end\n\n pmocampo = \"30792403\"\n client = Instagram.client(:access_token => session[:access_token])\n \n @user = client.user(pmocampo)\n \n @album = Album.find(params[:id])\n @photos = client.user_recent_media(pmocampo)\n @photos = @photos.select {|p| p.tags.include?(@album.tag)}\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @album }\n end\n end",
"def top_albums(tag)\n get(:standard, {:method => \"tag.getTopAlbums\", :tag => tag})\n end",
"def show\n\t\t@album = Album.find(params[:id])\n\tend",
"def index\n @albums = current_account.albums.find(:all, :order => 'position')\n \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @albums }\n end\n end",
"def albums( options=nil )\n params = default_params.merge( \n :method => 'smugmug.albums.get',\n :heavy => 1\n ) \n\n params = params.merge( options ) if( options )\n xml = RestClient.post BASE, params\n \n Smile::Album.from_xml( xml, session_id )\n rescue\n nil\n end",
"def index\n @albums = Album.page(params[:page]).per(10).order(created_at: :desc)\n\n respond_to do |format|\n format.html\n format.json { render json: @albums.to_json }\n format.xml { render xml: @albums.to_xml }\n end\n end",
"def show\n @album = Album.find(params[:id])\n @potential_songs = Song.where(:artist_id => @album.artist.id)\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @album }\n end\n end",
"def index\r\n @photos = Photo.all\r\n\r\n @albums = Album.all\r\n @albums_map = {}\r\n @albums.each do |album| \r\n @albums_map[album.TITLE] = album.ID\r\n end\r\n\r\n respond_to do |format|\r\n format.html # index.html.erb\r\n format.json { render json: @photos }\r\n end\r\n end",
"def index\n params[:q]||={:s => \"name asc\"}\n unless current_user.admin.present?\n @albums = current_user.albums\n end\n @q = @albums.search(params[:q])\n @albums = @q.result.page(params[:page]).limit(params[:per_page]||10)\n end",
"def resource\n\t\t@album\n\tend",
"def index\n unless @user = User.first(:conditions => {:id => params[:user_id].to_i})\n redirect_to(root_url)\n return\n end\n \n @photo_albums = @user.photo_albums \n \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @photo_albums }\n end\n end",
"def index\n @band = Band.find(params[:band_id])\n @albums = @band.albums\n end",
"def top_albums(artist)\n get(:standard, {:method => \"artist.getTopAlbums\", :artist => artist})\n end",
"def show\n @album = Album.find(params[:id]) #find takes one id\n render :show\n end",
"def index\n @user = User.find(params[:id])\n raise \"not found\" if @user.blank? \n @albums = @user.albums.all(:order => :title)\n rescue\n redirect_to root_url, :notice => \"Can't find this user.\"\n end",
"def picasa_albums(options = {})\n return [] unless current_user.has_provider_auth('google')\n PicasaPhoto.picasa_request_with_refresh(current_user.picasa_identity) do\n goog = GooglePhotosApi.new( current_user.picasa_identity.token )\n goog.albums[\"albums\"]\n end\n end",
"def show\n @album2photo = Album2photo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @album2photo }\n end\n end",
"def top_albums(user, options={})\n get(:standard, {:method => \"user.getTopAlbums\", :user => user}.merge(options))\n end",
"def show\n respond_to do |format|\n format.html { redirect_to action: 'edit', id: @album.id }\n format.json do\n render json: { rows: (@album.nil? ? [] : [@album.marshall]),\n status: (@album.nil? ? 404 : 200),\n total: (@album.nil? ? 0 : 1) }\n end\n end\n end",
"def index\n authorize! :read, Album\n \n @albums = Album.order(\"created_at DESC\").paginate(:page => params[:page], :per_page => 10)\n end",
"def info(options={})\n get(:standard, {:method => \"album.getInfo\"}.merge(options))\n end",
"def index\n @item_albums = ItemAlbum.all\n end",
"def show\n @picture = @album.pictures.find(params[:id]) #JRD111115\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @picture}\n end\n end",
"def new\n @group = Group.find(params[:group_id])\n @album = @group.albums.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @album }\n end\n end",
"def album\n\t\talbums == nil ? nil : albums.first\n\tend",
"def show\n # Pull the selected photo album.\n @photo_tag = PhotoTag.find(params[:id])\n\n respond_to do |format|\n format.json do\n render json: @photo_tag\n end\n end\n end",
"def album_tracks(album, options = {})\n get \"albums/#{album}/tracks\", options\n end",
"def index\r\n jump_to(\"/albums/list/#{session[:account_id]}\")\r\n end",
"def index\n @albums = Album.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @albums }\n end\n end",
"def index\n @private_albums = PrivateAlbum.all\n end",
"def index\n @images = @album.images.all\n end",
"def index\n @albums = Album.where(\"group_id = ?\", params[:group_id])\n\n respond_to do |format|\n format.html # index.html.erb\n format.js\n format.json { render json: @albums }\n end\n end",
"def new\r\n\r\n @album = Album.new\r\n\r\n respond_to do |format|\r\n format.html # new.html.erb\r\n format.json { render json: @album }\r\n end\r\n end",
"def show\n @album = Album.find(params[:id])\n if @album.artist != nil\n @songs = get_songs_from_album @album.artist.name, @album.name\n @song_list = []\n if @songs\n @songs.each do |song|\n entry = Hash.new\n entry['rank'] = song['rank']\n entry['title'] = song['name']\n entry['artist'] = @album.artist.name\n song_in_db = lookup_song song['name'], @album.artist.name\n if song_in_db != nil\n entry['available'] = true\n entry['song_id'] = song_in_db.id\n else\n entry['available'] = false\n end\n entry['duration'] = seconds_to_duration(song['duration'].to_i)\n @song_list << entry\n end\n end\n @album_cover = get_album_cover @album.artist.name, @album.name\n @description = get_description_from_album @album.artist.name, @album.name\n end\n\n @songs = [] if @songs == nil\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @album }\n end\n end",
"def picasa_albums(user, picasa_user_id=nil)\n return [] unless user.picasa_identity\n picasa = user.picasa_client\n user_data = picasa.user(picasa_user_id) \n albums = []\n unless user_data.nil?\n user_data.albums.select{|a| a.numphotos.to_i > 0}.each do |a|\n albums << {\n 'aid' => a.id,\n 'name' => a.title,\n 'cover_photo_src' => a.thumbnails.first.url\n }\n end\n end\n return albums\n end",
"def index\n @interior_albums = InteriorAlbum.all\n end",
"def show\n @photo = @allbum.photos.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @photo }\n end\n end",
"def albums\n link :top_albums, :Album, name\n end",
"def get_albums\n sql = \"SELECT * FROM albums WHERE artist_id = $1\"\n values = [@id]\n albums_data = SqlRunner.run(sql, values)\n albums = albums_data.map { |albums_data| Album.new(albums_data)}\n return albums\n end",
"def image_list\n @images = Picture.where(album_id: params[:album_id])\n respond_to do |format|\n format.json { render json: @images.to_json(methods: [:path])}\n end\n end",
"def set_album\n begin\n @album = Album.find(params[:id])\n rescue ActiveRecord::RecordNotFound => e\n render :json => {error: 'record not found'}, status: :not_found\n end\n end",
"def new\n @album = Album.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @album }\n end\n end",
"def new\n @album = Album.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @album }\n end\n end",
"def show\n @album = current_account.albums.find(params[:id])\n @page_title = @album.name\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @album }\n end\n end",
"def show\n @photos = @album.photos.includes(:album).page(params[:page])\n\n respond_to do |format|\n format.html do\n @page = @site.pages.find_by_name 'albums'\n @pages = @site.pages\n end\n format.js {}\n end\n end",
"def fetch_album(args)\n search = AlbumFetch.new(args)\n response = APIRequest.post(search.query, Configuration.instance.api_url(@format))\n parse_response(response)\n end",
"def index\n @pictures = @album.pictures.all\n end",
"def show\n song = Song.find(params[:id])\n render json: song.to_json(only: [:id, :title, :artist], methods: :path, include: {category: {only: [:id, :name]}})\n end",
"def albums( params={} )\n albums = get_connections(\"albums\", params)\n return map_connections albums, :to => Facebook::Graph::Album\n end",
"def albums( params={} )\n albums = get_connections(\"albums\", params)\n return map_connections albums, :to => Facebook::Graph::Album\n end",
"def index\n @albums = Album.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @albums }\n end\n end",
"def index\n @albums = Album.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @albums }\n end\n end"
] |
[
"0.8010893",
"0.79601175",
"0.7838933",
"0.76931643",
"0.7598457",
"0.7579601",
"0.7575355",
"0.75562096",
"0.75089633",
"0.7500134",
"0.74333906",
"0.7426798",
"0.7391768",
"0.73389864",
"0.7287336",
"0.7271081",
"0.72389615",
"0.7209903",
"0.7200635",
"0.7192762",
"0.719262",
"0.7190189",
"0.71899974",
"0.7189037",
"0.7189037",
"0.7189037",
"0.7189037",
"0.7189037",
"0.7189037",
"0.7189037",
"0.7189037",
"0.7174694",
"0.71160007",
"0.7078915",
"0.7077601",
"0.70660496",
"0.7058713",
"0.7049489",
"0.70435",
"0.7025857",
"0.70171344",
"0.70086575",
"0.6976009",
"0.69755596",
"0.697138",
"0.69670695",
"0.6944127",
"0.6941958",
"0.69266605",
"0.68857",
"0.68773973",
"0.68753034",
"0.6860878",
"0.68499345",
"0.6849906",
"0.68468356",
"0.68297654",
"0.6786572",
"0.67595285",
"0.67595005",
"0.6749892",
"0.67452264",
"0.6735612",
"0.67324764",
"0.6729119",
"0.67173696",
"0.6716952",
"0.67097074",
"0.6707279",
"0.67051023",
"0.6698686",
"0.66937566",
"0.66767585",
"0.66571563",
"0.6642816",
"0.6640607",
"0.6622478",
"0.6604973",
"0.6604935",
"0.659947",
"0.65925467",
"0.6589441",
"0.6587322",
"0.65821093",
"0.657914",
"0.6577139",
"0.6574047",
"0.6572037",
"0.65698504",
"0.6569401",
"0.6568482",
"0.6568482",
"0.6557697",
"0.65519524",
"0.6551283",
"0.6549354",
"0.65431345",
"0.651043",
"0.651043",
"0.6497524",
"0.6497524"
] |
0.0
|
-1
|
POST /albums POST /albums.json
|
def create
label_params = {:name => params[:new_label]}
artist_params = {:name => params[:artist_name]}
@labels = Label.all
@label = Label.new(label_params)
@artist = Artist.new(artist_params)
@album = Album.new(album_params)
if @label.name != ''
if Label.exists?(:name => label_params[:name])
@label = Label.where(:name => label_params[:name]).first
@album.label = @label
else
@album.label = @label
end
end
if @artist.name != ''
if Artist.exists?(:name => artist_params[:name])
@artist = Artist.where(:name => artist_params[:name]).first
@album.artist = @artist
else
@album.artist = @artist
end
end
if Album.exists?(:title => album_params[:title])
if Album.exists?(:artist => album_params[:artist])
@album = Album.where(:title => album_params[:title], :artist => album_params[:artist]).first
redirect_to @album and return
end
end
if @album.save
redirect_to @album and return
else
render 'new' and return
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def create_albums\n url = 'https://stg-resque.hakuapp.com/albums.json'\n uri = URI(url)\n response = Net::HTTP.get(uri)\n albums = JSON.parse(response)\n\n albums.each do |album|\n Album.create!(album.except('id'))\n end\nend",
"def create\n @album = current_user.albums.build(album_params)\n\n respond_to do |format|\n if @album.save\n format.html { redirect_to @album, notice: 'Album was successfully created.' }\n format.json { render :show, status: :created, location: @album }\n else\n format.html { render :new }\n format.json { render json: @album.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @album = current_user.albums.new(album_params)\n\n respond_to do |format|\n if @album.save\n format.html { redirect_to @album, notice: 'El album a sido creado satisfactoriamente.' }\n format.json { render :show, status: :created, location: @album }\n else\n format.html { render :new }\n format.json { render json: @album.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @album = current_user.albums.new(params[:album])\n\n respond_to do |format|\n if @album.save\n format.html { redirect_to @album, notice: 'You created a #Album. Now share your #album around the internets' }\n format.json { render json: @album, status: :created, location: @album }\n else\n format.html { render action: \"new\" }\n format.json { render json: @Album.errors, status: :unprocessable_entity }\n end\n end\n end",
"def album\n album = Album.find(params[:id])\n render json: album\n end",
"def create\n @album = Album.new(params[:album])\n\n respond_to do |format|\n if @album.save\n format.html { redirect_to @album, notice: 'Album was successfully created.' }\n format.json { render json: @album, status: :created, location: @album }\n else\n format.html { render action: \"new\" }\n format.json { render json: @album.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @album = Album.new(params[:album])\n\n respond_to do |format|\n if @album.save\n format.html { redirect_to @album, notice: 'Album was successfully created.' }\n format.json { render json: @album, status: :created, location: @album }\n else\n format.html { render action: \"new\" }\n format.json { render json: @album.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @album = Album.new(params[:album])\n\n respond_to do |format|\n if @album.save\n format.html { redirect_to @album, notice: 'Album was successfully created.' }\n format.json { render json: @album, status: :created, location: @album }\n else\n format.html { render action: \"new\" }\n format.json { render json: @album.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @album = Album.new(album_params)\n\n respond_to do |format|\n if @album.save\n format.html { redirect_to @album, notice: 'Album was successfully created.' }\n format.json { render :show, status: :created, location: @album }\n else\n format.html { render :new }\n format.json { render json: @album.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @album = Album.new(album_params)\n\n respond_to do |format|\n if @album.save\n format.html { redirect_to @album, notice: 'Album was successfully created.' }\n format.json { render :show, status: :created, location: @album }\n else\n format.html { render :new }\n format.json { render json: @album.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @album = Album.new(album_params)\n\n respond_to do |format|\n if @album.save\n format.html { redirect_to action: 'index', notice: 'Album was successfully created.' }\n format.json { render action: 'index', status: :created, location: @album }\n else\n format.html { render action: 'index' }\n format.json { render json: @album.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\t\talbum = Album.create(album_params)\n\n\t\tif !album.errors.any?\n\t\t\trender json: album\n\t\telse\n\t\t\trender json: {message: \"Error occurred\"}\n\t\tend\n\tend",
"def create\n @album = Album.new(album_params)\n\n respond_to do |format|\n if @album.save\n format.html { redirect_to @album, notice: \"Album was successfully created.\" }\n format.json { render :show, status: :created, location: @album }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @album.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @album = Album.new(params[:album])\n respond_to do |format|\n if @user.albums << @album\n flash[:notice] = 'Album was successfully created.'\n format.html { redirect_to user_albums_path(@user) }\n format.xml { render :xml => @album, :status => :created, :location => @album }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @album.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @album = Album.new(album_params)\n\n respond_to do |format|\n if @album.save\n format.html { redirect_to @album, notice: 'Album was successfully created.' }\n format.json { render action: 'show', status: :created, location: @album }\n else\n format.html { render action: 'new' }\n format.json { render json: @album.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @album = current_user.albums.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @album }\n end\n end",
"def create\n @album = current_user.albums.build(params[:album])\n if @album.save\n flash[:notice] = 'Album was successfully created.'\n redirect_to(album_pictures_path(@album))\n else\n render :action => \"new\"\n end\n end",
"def create\n @album = Album.new(params[:album])\n\n respond_to do |format|\n if @album.save\n format.html { redirect_to group_url(@album.group), notice: 'Album was successfully created.' }\n format.json { render json: @album, status: :created, location: @album }\n else\n format.html { render action: \"new\" }\n format.json { render json: @album.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n ActiveRecord::Base.transaction do\n @album = Album.create!(album_params)\n # 画像登録数が多くなるUIになったらSQLの負荷を減らすためにactiverecord-importを入れる\n # https://github.com/zdennis/activerecord-import\n params[:urls].each do |image_url|\n AlbumImage.create!(album_id: @album.id, url: image_url)\n end\n end\n\n render json: @album\n end",
"def create\n @album_ownership = AlbumOwnership.new\n @album_ownership.album = @album\n @album_ownership.user = current_user\n\n unless @album_ownership.save\n render json: @album_ownership.errors, status: :unprocessable_entity\n end\n end",
"def create\n @album = Album.new(allowed_params_album)\n\n respond_to do |format|\n if @album.save\n format.html { redirect_to @album, notice: 'Album was successfully created.' }\n format.json { render :show, status: :created, location: @album }\n else\n format.html { render :new }\n format.json { render json: @album.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @album = current_user.albums.build(album_params)\n \n\n respond_to do |format|\n if @album.save\n format.html { redirect_to @album, notice: 'Album was successfully created.' }\n else\n format.html { render :new }\n end\n end\n end",
"def create\n @user_album = UserAlbum.new(params[:user_album])\n\n respond_to do |format|\n if @user_album.save\n format.html { redirect_to @user_album, notice: 'User album was successfully created.' }\n format.json { render json: @user_album, status: :created, location: @user_album }\n else\n format.html { render action: \"new\" }\n format.json { render json: @user_album.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @album = current_account.albums.new(params[:album])\n\n respond_to do |format|\n if @album.save\n flash[:notice] = 'album was successfully created.'\n format.html { redirect_to( :action => 'edit', :id => @album.id) }\n format.xml { render :xml => @album, :status => :created, :location => @album }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @album.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def albums\n if params[:artist_id]\n albums = Artist.find(params[:artist_id]).albums\n else\n albums = Album.all\n end\n render json: albums\n end",
"def index\n @albums = Album.all\n render json: @albums\n end",
"def create\n @album = Album.new(album_params)\n respond_to do |format|\n if @album.save\n flash[:success] = 'The album was successfully created.'\n format.html { redirect_to albums_path }\n format.json { render json: { rows: [@album.marshall], status: 200, total: 1 } }\n else\n @albums = Album.all\n notice = \"An error occured while creating the album. #{@album.errors.full_messages.to_sentence}.\"\n flash[:error] = notice\n format.html { render action: 'index', alert: notice }\n format.json { render json: { errors: @album.errors, status: :unprocessable_entity } }\n end\n end\n end",
"def create\n\t\tAlbum.create({\n\t\t\tname: params[:name]\n\t\t\t})\n\t\tredirect_to albums_path\n\tend",
"def create\n respond_to do |format|\n @album.user = current_user\n if @album.save\n format.html { redirect_to artist_album_path(@artist,@album), notice: 'album was successfully created.' }\n format.json { render action: 'show', status: :created, location: artist_album_path(@artist,@album) }\n else\n format.html { render action: 'new' }\n format.json { render json: @album.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @group = Group.find(params[:group_id])\n @album = @group.albums.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @album }\n end\n end",
"def create\n @album = Album.new(album_params)\n @album.user_id = current_user.id\n\n respond_to do |format|\n if @album.save\n format.html { redirect_to @album, notice: 'Album erfolgreich erstellt.' }\n format.json { render :show, status: :created, location: @album }\n else\n format.html { render :new }\n format.json { render json: @album.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @album = Album.new(album_params)\n\n not_blank_photos = @album.photos.select do |photo|\n ! photo.title.blank?\n end\n @album.photos = not_blank_photos\n\n respond_to do |format|\n if @album.save\n format.html { redirect_to @album, notice: 'Album was successfully created.' }\n format.json { render action: 'show', status: :created, location: @album }\n else\n format.html { render action: 'new' }\n format.json { render json: @album.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n \n @album = Album.new(params[:album])\n \n respond_to do |format|\n if @album.save\n flash[:notice] = 'Album was successfully created.'\n format.html { redirect_to(@album) }\n format.xml { render :xml => @album, :status => :created, :location => @album }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @album.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @album = Album.new(album_params)\n if @album.save\n redirect_to albums_path\n else \n render 'new'\n end\n end",
"def index\n @albums = @user.albums\n end",
"def albums( options=nil )\n params = default_params.merge( \n :method => 'smugmug.albums.get',\n :heavy => 1\n ) \n\n params = params.merge( options ) if( options )\n xml = RestClient.post BASE, params\n \n Smile::Album.from_xml( xml, session_id )\n rescue\n nil\n end",
"def new\n @album = Album.new\n\n 3.times do\n @album.tracks.build\n end\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @album }\n end\n end",
"def create\n @galleries_album = Galleries::Album.new(galleries_album_params)\n @galleries_album.user = current_user\n respond_to do |format|\n if @galleries_album.save\n format.html { redirect_to @galleries_album, notice: 'Album was successfully created.' }\n format.json { render :show, status: :created, location: @galleries_album }\n else\n format.html { render :new }\n format.json { render json: @galleries_album.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @album_owned = AlbumOwned.new(params[:album_owned])\n\n respond_to do |format|\n if @album_owned.save\n format.html { redirect_to @album_owned, notice: 'Album owned was successfully created.' }\n format.json { render json: @album_owned, status: :created, location: @album_owned }\n else\n format.html { render action: \"new\" }\n format.json { render json: @album_owned.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @album = Album.find(params[:album_id])\n @photo = @album.photos.new(params[:photo])\n\n respond_to do |format|\n if @photo.save\n format.html { redirect_to album_photo_path(@album,@photo), :notice => 'Photo was successfully created.' }\n format.json { render :json => @photo, :status => :created, :location => @photo }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @photo.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @photoalbum = Photoalbum.new(params[:photoalbum])\n\n respond_to do |format|\n if @photoalbum.save\n format.html { redirect_to edit_photoalbum_path @photoalbum, notice: 'Photoalbum was successfully created.' }\n format.json { render json: @photoalbum, status: :created, location: @photoalbum }\n else\n format.html { render 'new' }\n format.json { render json: @photoalbum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @album = Album.find_by_slug(params[:album_id])\n @album_item = @album.album_items.create(params[:album_item])\n\n respond_to do |format|\n if @album_item.save\n format.html { redirect_to @album, notice: 'Album item was successfully created.' }\n format.json { render json: @album_item, status: :created, location: @album_item }\n else\n format.html { render action: \"new\" }\n format.json { render json: @album_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def destroy\n @album.destroy\n render json: @album\n end",
"def create\n @albumm = Albumm.new(params[:albumm])\n\n respond_to do |format|\n if @albumm.save\n format.html { redirect_to @albumm, notice: 'Albumm was successfully created.' }\n format.json { render json: @albumm, status: :created, location: @albumm }\n else\n format.html { render action: \"new\" }\n format.json { render json: @albumm.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @album = Album.new(params[:album])\n \n respond_to do |format|\n images = [params[:images]].flatten\n @album.images << Image.find(images) unless images[0].nil?\n \n if @album.save\n format.html { redirect_to(albums_path, :notice => 'Album was successfully created.') }\n format.xml { render :xml => albums_path, :status => :created, :location => @album }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @album.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def index\n @albums = Album.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @albums }\n end\n end",
"def create\n @album = Album.new(params[:album])\n \n respond_to do |format|\n if @album.save\n flash[:notice] = 'Album was successfully created.'\n format.html { redirect_to(@album) }\n format.xml { render :xml => @album, :status => :created, :location => @album }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @album.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @photo = Photo.new(photo_params)\n @albums = get_current_albums\n\n respond_to do |format|\n if @photo.save\n format.html { redirect_to photos_url, notice: 'Фотография была успешно добавлена.' }\n format.json { render action: 'show', status: :created, location: @photo }\n else\n format.html { render action: 'new' }\n format.json { render json: @photo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def to_api_json\n Jbuilder.encode do |json|\n json.albums do\n json.array! @albums do |album|\n json.call(album, :name, :uuid)\n json.set!(:artist, album.artist_name)\n json.set!(:artist_twitter_screen_name, twitter_screen_name(album))\n json.set!(:thumbnail_url, album.image || album.thumbnail)\n json.set!(:release_date, album.release_date.in_time_zone.to_i)\n json.set!(:release_date_string, album.release_date.to_s)\n json.set!(:age, album.anniversary.count)\n json.set!(:day_of_week, album.anniversary.current.strftime('%A'))\n json.set!(:anniversary, album.anniversary.current.in_time_zone.to_i)\n json.set!(:anniversary_string, album.anniversary.current.to_s)\n json.set!(:review_link, album.link)\n json.set!(:rating, album.rating)\n json.set!(:generated_fun_fact_description, album.generated_fun_fact_description)\n json.set!(:fun_fact_description, album.fun_fact_description)\n json.set!(:fun_fact_source, album.fun_fact_source)\n json.set!(:link, \"/albums/#{album.slug}\")\n json.set!(:update, \"/v1/admin/albums/#{album.id}\")\n end\n end\n end\n end",
"def new\n @album = Album.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @album }\n end\n end",
"def new\n @album = Album.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @album }\n end\n end",
"def new\r\n\r\n @album = Album.new\r\n\r\n respond_to do |format|\r\n format.html # new.html.erb\r\n format.json { render json: @album }\r\n end\r\n end",
"def create\n authorize! :create, Album\n @album = Album.new(album_params)\n @album.user_id = current_user.id\n\n respond_to do |format|\n if @album.save\n format.html { redirect_to edit_admin_album_path(@album.id), notice: 'Album was successfully created.' }\n format.json { render :show, status: :created, location: @album }\n else\n format.html { render :new }\n format.json { render json: @album.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n \t@album = Album.find(params[:album_id])\n \t@photo = @album.photos.create!(params[:photo])\n \tredirect_to @album, :notice => 'Photo created'\n end",
"def create\n redirect_to new_album_path, alert: \"You have to select at least one artist.\" and return if params[:album][:album_artists].size == 1 && params[:album][:album_artists][0].empty? # TODO: Find a better way to do this, it does not play nicely with json and xml\n @album = Album.new(album_params)\n album_artists\n album_cover if params[:search_online]\n\n respond_to do |format|\n if @album.save\n format.html { redirect_to @album, notice: 'Album was successfully created.' }\n format.json { render :show, status: :created, location: @album }\n format.xml { render xml: @album, status: :created }\n else\n format.html { render :new }\n format.json { render json: @album.errors, status: :unprocessable_entity }\n format.xml { render xml: @album.errors, status: :unprocessable_entity }\n end\n end\n end",
"def artist_albums(artist, options = {})\n get \"artists/#{artist}/albums\", options\n end",
"def create\n @album = Album.new(params[:album])\n\n respond_to do |format|\n if @album.save\n flash[:notice] = 'Album was successfully created.'\n format.html { redirect_to(@album) }\n format.xml { render :xml => @album, :status => :created, :location => @album }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @album.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @photo = Photo.new(params[:photo])\n @photo.user_id=session[:user_id]\n @photo.album_id= params[:photo][:album_id]\n respond_to do |format|\n if @photo.save\n format.html { redirect_to @photo, notice: 'Photo was successfully created.' }\n format.json { render json: @photo, status: :created, location: @photo }\n else\n format.html { render action: \"new\" }\n format.json { render json: @photo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n new_album = Album.new\n new_album.title = params[:title]\n new_album.artist = params[:artist]\n new_album.year = params[:year]\n new_album.album_art = params[:album_art]\n new_album.save\n end",
"def create\n @band = Band.find(params[:band_id])\n @album = Band.find(params[:band_id]).albums.build(album_params)\n\n respond_to do |format|\n if @album.save\n format.html { redirect_to new_band_album_song_path(@album.band.id, @album.id), notice: 'Album was successfully created.' }\n format.json { render :show, status: :created, location: @album }\n else\n format.html { render :new }\n format.json { render json: @album.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @album = Album.new(params[:album])\n\n respond_to do |format|\n if @album.save\n format.html { redirect_to @album, notice: 'Albumi loomine õnnestus.' }\n format.json { render json: @album, status: :created, location: @album }\n else\n format.html { render action: \"new\" }\n format.json { render json: @album.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @album = Album.new\n\n respond_to do |format|\n format.html # new.html.erb\n #format.json { render json: @album }\n end\n end",
"def new\n @album = Album.new\n @photo = @album.photos.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @photo }\n end\n end",
"def create_album(name, description=nil)\n body = {}\n body['name'] = name\n body['description'] = description\n post(\"/albums\", body: body, code: 201 )\n end",
"def new\n \n @album = @user.albums.new\n respond_to do |format|\n format.js { render 'new' }\n format.html # show.html.erb\n end\n end",
"def new\n @user_album = UserAlbum.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user_album }\n end\n end",
"def create\n @album = Album.new(params[:album])\n\n respond_to do |format|\n if @album.save\n #Dir.chdir(\"public/images\")\n Dir.mkdir(@album['directory'])\n flash[:notice] = 'Album was successfully created.'\n #flash[:notice] = Dir.pwd\n format.html { redirect_to @album }\n #format.json { render json: @album, status: :created, location: @album }\n else\n format.html { render action = \"new\" }\n #format.json { render json: @album.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @song = Song.new(song_params)\n\n respond_to do |format|\n if @song.save\n album_id = params[\"album\"]\n \n if not album_id.nil?\n album = Album.find_by(id: album_id)\n if not album.nil?\n album.songs << @song\n album.save\n\n artist = album.artist\n\n if not artist.nil?\n artist_id = artist.id\n if not artist_id.nil?\n artist.songs << @song\n artist.save\n end\n end\n end\n end\n\n format.html { redirect_to @song, notice: 'Song was successfully created.' }\n format.json { render :show, status: :created, location: @song }\n else\n format.html { render :new }\n format.json { render json: @song.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create \n \n respond_to do |format|\n @photo_album = current_user.photo_albums.build(params[:photo_album])\n if @photo_album.save\n flash[:notice] = 'Новый альбом создан.'\n format.html {\n # if current_user.photo_albums.size > 1\n # redirect_to(@photo_album)\n # else\n redirect_to(new_photo_path)\n # end\n }\n format.xml { render :xml => @photo_album, :status => :created, :location => @photo_album }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @photo_album.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @album = @student.albums.new(album_params)\n authorize @album\n if @album.save\n redirect_to new_album_photo_path(@album), notice: 'Album was successfully created.'\n else\n render :new\n end\n end",
"def album_tracks(album, options = {})\n get \"albums/#{album}/tracks\", options\n end",
"def create\n @album = Pagealbum.new(album_params)\n @images=album_params[:images_attributes].values.map {|x| Image.new(x)} rescue []\n\n respond_to do |format|\n if @album.save\n page=Page.first\n page.albums << @album\n format.html { redirect_to my_album_page_path(id: @album.id), notice: \"Pagealbum was successfully created.\" }\n format.json { render :show, status: :created, location: @album }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @album.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n @album = Album.find(params[:id])\n @albums_count = Album.count\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @album }\n end\n end",
"def upload\n @album = Album.find( params[:album_id].to_i)\n end",
"def create\n @interior_album = InteriorAlbum.new(interior_album_params)\n\n respond_to do |format|\n if @interior_album.save\n format.html { redirect_to @interior_album, notice: 'Interior design album was successfully created.' }\n format.json { render :show, status: :created, location: @interior_album }\n else\n format.html { render :new }\n format.json { render json: @interior_album.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\r\n @album = Album.new(:account_id => session[:account_id])\r\n \r\n @album.name = params[:album_name]\r\n @album.description = params[:album_description]\r\n if @album.save\r\n return jump_to(\"/albums/#{@album.id}/upload\")\r\n else\r\n flash.now[:error_msg] = \"操作失败, 再试一次吧\"\r\n end\r\n \r\n render(:action => \"new\")\r\n end",
"def index\n @albums = Album.all\n end",
"def index\n @albums = Album.all\n end",
"def index\n @albums = Album.all\n end",
"def index\n @albums = Album.all\n end",
"def index\n @albums = Album.all\n end",
"def index\n @albums = Album.all\n end",
"def index\n @albums = Album.all\n end",
"def index\n @albums = Album.all\n end",
"def index\n @albums = Album.all\n end",
"def new\n @album = current_account.albums.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @album }\n end\n end",
"def new_album(set_albumName, params = {})\n params = { :cmd => 'new-album', :set_albumName => set_albumName }.merge(params)\n send_request(params)\n end",
"def new\n @photo = Photo.new\n @photo.album_id = params[:album_id]\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @photo }\n end\n end",
"def new\n @albumm = Albumm.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @albumm }\n end\n end",
"def new\n @album = Album.new\n 1.upto(3) { @album.photos.build }\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @album }\n end\n end",
"def albums\n @albums ||= response.albums.uniq(&:name)\n end",
"def get_album album_id\n get(\"/albums/#{album_id}\")\n end",
"def create\n @albumsix = Albumsix.new(albumsix_params)\n\n respond_to do |format|\n if @albumsix.save\n format.html { redirect_to @albumsix, notice: 'Albumsix was successfully created.' }\n format.json { render :show, status: :created, location: @albumsix }\n else\n format.html { render :new }\n format.json { render json: @albumsix.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @albums = current_user.albums\n end",
"def set_album\n if token = album_token\n @album = Album.find_or_create_by(token: token)\n else\n @album = Album.find_by(uuid: params[:id])\n end\n end",
"def create\n \n @album = @user.albums.new(params[:album])\n \n if @album.save\n flash[:notice] = 'User was successfully created.'\n if params[:album][:avatar].blank?\n redirect_to @album\n else\n \n render :action => 'cropping'\n end\n else\n render :action => 'new'\n end\n end",
"def show\n @album = Album.find(params[:id])\n render json: AlbumSerializer.new(@album)\n end",
"def create_album\n @other_user=@login_user\n @albums = @login_user.albums\n @album = Album.new(:name=>params[:album][:name], :user_id=>@login_user.id, :share_type => 0)\n @notice = @album.save ? \"Album created successfully.\": activerecord_error_list(@album.errors)\n\n respond_to do |format|\n format.js\n end\n end",
"def create\n @private_album = PrivateAlbum.new(private_album_params)\n\n respond_to do |format|\n if @private_album.save\n format.html { redirect_to @private_album, notice: 'Private album was successfully created.' }\n format.json { render action: 'show', status: :created, location: @private_album }\n else\n format.html { render action: 'new' }\n format.json { render json: @private_album.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @albums = Pagealbum.all.joins(:pagehavingalbums)\n redirect_to \"/beautyvip/create_album\"\n end",
"def index\n @albums = @user.albums\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @albums }\n end\n end"
] |
[
"0.77528495",
"0.7283492",
"0.7234256",
"0.71961457",
"0.7179153",
"0.70808494",
"0.70808494",
"0.70808494",
"0.7003637",
"0.7003637",
"0.69838834",
"0.6972035",
"0.697075",
"0.6958249",
"0.69494504",
"0.6927158",
"0.68965065",
"0.6890949",
"0.6846395",
"0.6823431",
"0.6823243",
"0.6805188",
"0.68006617",
"0.6783471",
"0.6780751",
"0.6744856",
"0.67399913",
"0.6703513",
"0.66474885",
"0.6614327",
"0.66008705",
"0.65916294",
"0.6586136",
"0.6576275",
"0.6574894",
"0.65735185",
"0.65718293",
"0.65695035",
"0.65057874",
"0.6504347",
"0.6487022",
"0.64768714",
"0.6468198",
"0.64659685",
"0.64646834",
"0.6463741",
"0.6448549",
"0.64485276",
"0.63998497",
"0.6386238",
"0.6386238",
"0.63813585",
"0.6380879",
"0.6356562",
"0.63548636",
"0.6351672",
"0.63231444",
"0.63163716",
"0.63135",
"0.6309164",
"0.6292462",
"0.6279711",
"0.6274554",
"0.6271388",
"0.6267765",
"0.6266342",
"0.6239959",
"0.623754",
"0.6225732",
"0.62210894",
"0.6217303",
"0.6209731",
"0.6206741",
"0.620647",
"0.6191023",
"0.61875355",
"0.61841935",
"0.6182571",
"0.6182571",
"0.6182571",
"0.6182571",
"0.6182571",
"0.6182571",
"0.6182571",
"0.6182571",
"0.6178229",
"0.6176458",
"0.61556894",
"0.6155587",
"0.61546636",
"0.61544496",
"0.6150628",
"0.6143432",
"0.61402255",
"0.61357373",
"0.61339444",
"0.6124057",
"0.6123519",
"0.6118628",
"0.61185163",
"0.61165434"
] |
0.0
|
-1
|
PATCH/PUT /albums/1 PATCH/PUT /albums/1.json
|
def update
label_params = {:name => params[:new_label]}
artist_params = {:name => params[:artist_name]}
@labels = Label.all
@label = (@album.label.nil?) ? Label.new(label_params) : @album.label
@artist = (@album.artist.nil?) ? Artist.new(artist_params) : @album.artist
if Label.exists?(:name => label_params[:name])
@label = Label.where(:name => label_params[:name]).first
@album.label_id = @label.id
else
@label.save
@album.label_id = @label.id
end
if Artist.exists?(:name => artist_params[:name])
@artist = Artist.where(:name => artist_params[:name]).first
@album.artist = @artist
else
@artist.save
@album.artist = @artist
end
respond_to do |format|
if @album.update(album_params)
format.html { redirect_to @album, notice: 'Album was successfully updated.' }
format.json { render :show, status: :ok, location: @album }
else
format.html { render :edit }
format.json { render json: [@album.errors, @album.artist.errors, @album.label.errors], status: :unprocessable_entity }
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def update\n @album = current_user.albums.find(params[:id])\n\n respond_to do |format|\n if @Album.update_attributes(params[:album])\n format.html { redirect_to @album, notice: 'album was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @Album.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @album = Album.find(params[:id])\n\n respond_to do |format|\n if @album.update_attributes(params[:album])\n format.html { redirect_to @album, notice: 'Album was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @album.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @albums = get_current_albums\n respond_to do |format|\n if @photo.update(photo_params)\n format.html { redirect_to photos_url, notice: 'Фотография была успешно обновлена.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @photo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @album.update_attributes(params[:album])\n format.html { redirect_to album_url(@album), notice: 'Album was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @album.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n \n @album = Album.find(params[:album_id])\n @photo = @album.photos.find(params[:id])\n\n respond_to do |format|\n if @photo.update_attributes(params[:photo])\n format.html { redirect_to album_photo_path(@album,@photo), :notice => 'Photo was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @photo.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @album = Album.find(params[:id])\n\n respond_to do |format|\n if @album.update_attributes(params[:album])\n format.html { redirect_to @album, notice: 'Album was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @album.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @album = Album.find(params[:id])\n\n respond_to do |format|\n if @album.update_attributes(params[:album])\n format.html { redirect_to @album, notice: 'Album was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @album.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @album.update(album_params)\n format.html { redirect_to @album, notice: 'Album was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @album.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @album.update(album_params)\n format.html { redirect_to @album, notice: 'Album was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @album.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @album.update(album_params)\n format.html { redirect_to @album, notice: 'Album was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @album.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @album.update(album_params)\n format.html { redirect_to @album, notice: 'Album was successfully updated.' }\n format.json { render :show, status: :ok, location: @album }\n else\n format.html { render :edit }\n format.json { render json: @album.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @album.update(album_params)\n format.html { redirect_to @album, notice: 'Album was successfully updated.' }\n format.json { render :show, status: :ok, location: @album }\n else\n format.html { render :edit }\n format.json { render json: @album.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @album.update(album_params)\n format.html { redirect_to @album, notice: 'Album was successfully updated.' }\n format.json { render :show, status: :ok, location: @album }\n else\n format.html { render :edit }\n format.json { render json: @album.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @album.update(album_params)\n format.html { redirect_to @album, notice: \"Album was successfully updated.\" }\n format.json { render :show, status: :ok, location: @album }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @album.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @album = Album.find(params[:id])\n\n respond_to do |format|\n if @album.update_attributes(params[:album])\n flash[:notice] = 'Album was successfully updated.'\n format.html { redirect_to @album }\n format.json { head :no_content }\n else\n format.html { render action = \"edit\" }\n # format.json { render json: @album.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @album.update(album_params)\n format.html { redirect_to @album, notice: 'El album a sido actualizado satisfactoriamente.' }\n format.json { render :show, status: :ok, location: @album }\n else\n format.html { render :edit }\n format.json { render json: @album.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @album = current_account.albums.find(params[:id])\n\n respond_to do |format|\n if @album.update_attributes(params[:album])\n flash[:notice] = 'album was successfully updated.'\n format.html { redirect_to(@album) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @album.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @album.update(album_params)\n format.html { redirect_to artist_album_url(@artist,@album), notice: 'album was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @album.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @album.update(allowed_params_album)\n format.html { redirect_to @album, notice: 'Album was successfully updated.' }\n format.json { render :show, status: :ok, location: @album }\n else\n format.html { render :edit }\n format.json { render json: @album.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @photo = Photo.find(params[:id])\n @photo.user_id=session[:user_id]\n @photo.album_id= params[:photo][:album_id]\n respond_to do |format|\n if @photo.update_attributes(params[:photo])\n format.html { redirect_to @photo, notice: 'Photo was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @photo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @album = Album.find(album_params[:id])\n respond_to do |format|\n if @album.update_attributes(album_params)\n flash[:success] = 'The album was successfully updated.'\n format.html { redirect_to edit_album_url(@album.id) }\n format.json { render json: { rows: [@album.marshall], status: 200, total: 1 } }\n else\n base = 'Failed to save the album. '\n flash[:error] = 'An error occured while updating the album.'\n format.html { render action: 'edit', alert: base + @album.errors.full_messages.to_sentence + '.' }\n format.json { render json: { errors: @album.errors, status: :unprocessable_entity } }\n end\n end\n end",
"def update\n authorize! :update, @album\n respond_to do |format|\n if @album.update(album_params)\n format.html { redirect_to edit_admin_album_path(@album.id), notice: 'Album was successfully updated.' }\n format.json { render :show, status: :ok, location: @album }\n else\n format.html { render :edit }\n format.json { render json: @album.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @album = Album.find(params[:id])\n \n respond_to do |format|\n if @album.update_attributes(params[:album])\n @album.images.clear\n @album.images << Image.find([params[:images]].flatten)\n @album.save!\n format.html { redirect_to(albums_path, :notice => 'Album was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @album.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @user_album = UserAlbum.find(params[:id])\n\n respond_to do |format|\n if @user_album.update_attributes(params[:user_album])\n format.html { redirect_to @user_album, notice: 'User album was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user_album.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @albumone.update(albumone_params)\n format.html { redirect_to @albumone, notice: 'Albumone was successfully updated.' }\n format.json { render :show, status: :ok, location: @albumone }\n else\n format.html { render :edit }\n format.json { render json: @albumone.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @galleries_album.update(galleries_album_params)\n format.html { redirect_to @galleries_album, notice: 'Album was successfully updated.' }\n format.json { render :show, status: :ok, location: @galleries_album }\n else\n format.html { render :edit }\n format.json { render json: @galleries_album.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @album.update(album_params)\n format.html { redirect_to band_albums_path(@album.band.id), notice: 'Album was successfully updated.' }\n format.json { render :show, status: :ok, location: @album }\n else\n format.html { render :edit }\n format.json { render json: @album.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @album.update(album_params)\n format.html { redirect_to @album, notice: 'アルバム情報を更新しました。' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @album.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @album_photo.update(album_photo_params)\n format.html { redirect_to @album_photo, notice: 'Album photo was successfully updated.' }\n format.json { render :show, status: :ok, location: @album_photo }\n else\n format.html { render :edit }\n format.json { render json: @album_photo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @album = Album.find(params[:id])\n\n respond_to do |format|\n if @album.update_attributes(params[:album])\n format.html { redirect_to(@album, :notice => 'Album was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @album.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n ActiveRecord::Base.transaction do\n @album.update!(name: params[:name])\n @album.album_images.destroy_all\n # 画像登録数が多くなるUIになったらSQLの負荷を減らすためにactiverecord-importを入れる\n # https://github.com/zdennis/activerecord-import\n params[:urls].each do |image_url|\n AlbumImage.create!(album_id: @album.id, url: image_url)\n end\n end\n\n render json: @album\n end",
"def update\n respond_to do |format|\n if @private_album.update(private_album_params)\n format.html { redirect_to @private_album, notice: 'Private album was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @private_album.errors, status: :unprocessable_entity }\n end\n end\n end",
"def album\n album = Album.find(params[:id])\n render json: album\n end",
"def update\n respond_to do |format|\n if @item_album.update(item_album_params)\n format.html { redirect_to @item_album, notice: 'Item album was successfully updated.' }\n format.json { render :show, status: :ok, location: @item_album }\n else\n format.html { render :edit }\n format.json { render json: @item_album.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @user = current_user\n @customer = @user.customers.find(params[:customer_id])\n @album = @customer.albums.find(params[:album_id])\n @photo = @album.photos.find(params[:id])\n\n respond_to do |format|\n if @photo.update_attributes(params[:photo])\n format.html { redirect_to user_customer_album_photos_url(@user, @customer, @album), notice: 'Photo was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @photo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @album = Album.find(params[:id])\n\n respond_to do |format|\n if @album.update_attributes(params[:album])\n format.html { redirect_to @album, notice: 'Albumi uuendamine õnnestus' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @album.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @album = Album.find_by_id_and_user_id(params[:id], @user)\n\n respond_to do |format|\n if @album.update_attributes(params[:album])\n flash[:notice] = 'Album was successfully updated.'\n format.html { redirect_to user_albums_path(@user) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @album.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @album = Album.find(params[:id])\n\n respond_to do |format|\n if @album.update_attributes(params[:album])\n flash[:notice] = 'Album was successfully updated.'\n format.html { redirect_to(@album) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @album.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @album = Album.find(params[:id])\n\n respond_to do |format|\n if @album.update_attributes(params[:album])\n flash[:notice] = 'Album was successfully updated.'\n format.html { redirect_to(@album) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @album.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n authorize @album\n if @album.update(album_params)\n redirect_to @album, notice: 'Album was successfully updated.'\n else\n render :edit\n end\n end",
"def update\n @track_file = TrackFile.find(params[:id])\n\n if @track_file.update(track_file_params)\n @album = Album.find(@track_file.track.album.id)\n render json: @album\n else\n render json: @track_file.errors.full_messages, status: 422\n end\n end",
"def update\n respond_to do |format|\n if @song.update(song_params)\n album_id = params[\"album\"]\n \n if not album_id.nil?\n album = Album.find_by(id: album_id)\n if not album.nil?\n album.songs << @song\n album.save\n\n artist = album.artist\n\n if not artist.nil?\n artist_id = artist.id\n if not artist_id.nil?\n artist.songs << @song\n artist.save\n end\n end\n end\n end\n \n format.html { redirect_to @song, notice: 'Song was successfully updated.' }\n format.json { render :show, status: :ok, location: @song }\n else\n format.html { render :edit }\n format.json { render json: @song.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_album(person_id,album_id, caption, location='', privacy='Everyone')\n @restv9.update_album(person_id,album_id, caption, location, privacy)\n end",
"def update\n @album = Album.find(params[:id])\n\n if @album.update(album_params)\n flash[:success] = \"Album updated!\"\n redirect_to albums_path\n else\n render 'edit'\n end\n end",
"def update\n \n @album = @user.albums.find(params[:id])\n respond_to do |format|\n format.js { render 'new' }\n format.html{\n if @album.update_attributes params[:album]\n @album.avatar.reprocess!\n flash[:notice] = 'User was successfully updated.'\n if params[:album][:avatar].blank?\n redirect_to @album\n else\n \n render :action => 'cropping'\n end\n else\n render :action => \"edit\"\n end}\n end\n end",
"def update\n respond_to do |format|\n if @albumsix.update(albumsix_params)\n format.html { redirect_to @albumsix, notice: 'Albumsix was successfully updated.' }\n format.json { render :show, status: :ok, location: @albumsix }\n else\n format.html { render :edit }\n format.json { render json: @albumsix.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @photo_album = PhotoAlbum.find(params[:id])\n\n respond_to do |format|\n if @photo_album.update_attributes(params[:photo_album])\n flash[:notice] = 'PhotoAlbum was successfully updated.'\n format.html { redirect_to(user_photo_albums_url(current_user)) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @photo_album.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @album = Album.find(params[:id])\n\n respond_to do |format|\n if @album.update_attributes(params[:album])\n expire_fragment :action_suffix => 'homepage_albums'\n flash[:notice] = 'Album was successfully updated.'\n format.html { redirect_to(@album) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @album.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @album = Album.find(params[:id])\n if @album.update(album_params)\n flash[:success] = 'Album updated successfully.'\n path = albums_path\n else\n flash[:error] = 'Problem updating album.'\n path = root_path\n end\n redirect_to path\n end",
"def update\n @albumm = Albumm.find(params[:id])\n\n respond_to do |format|\n if @albumm.update_attributes(params[:albumm])\n format.html { redirect_to @albumm, notice: 'Albumm was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @albumm.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @photo = @allbum.photos.find(params[:id])\n#\n respond_to do |format|\n if @photo.update_attributes(params[:photo])\n format.html { redirect_to edit_allbum_photos_path(@allbum,@photo), notice: 'Photo was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @photo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @photo.update(photo_params)\n format.html { redirect_back fallback_location: @photo.album, notice: 'Photo was successfully updated.' }\n format.json { render :show, status: :ok, location: @photo }\n else\n format.html { render :edit }\n format.json { render json: @photo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @album_item = AlbumItem.find(params[:id])\n\n respond_to do |format|\n if @album_item.update_attributes(params[:album_item])\n format.html { redirect_to @album_item, notice: 'Album item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @album_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @album_owned = AlbumOwned.find(params[:id])\n\n respond_to do |format|\n if @album_owned.update_attributes(params[:album_owned])\n format.html { redirect_to @album_owned, notice: 'Album owned was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @album_owned.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @photo_album = PhotoAlbum.find(params[:id])\n\n respond_to do |format|\n if @photo_album.update_attributes(params[:photo_album])\n flash[:notice] = 'PhotoAlbum was successfully updated.'\n format.html { redirect_to(@photo_album) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @photo_album.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @photo.update(photo_params)\n format.html { redirect_to [@photo.album, @photo], notice: '写真情報を変更しました。' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @photo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\n respond_to do |format|\n if @photo_album.update_attributes(params[:photo_album])\n flash[:notice] = 'PhotoAlbum was successfully updated.'\n format.html { redirect_to(@photo_album) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @photo_album.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @albumfife.update(albumfife_params)\n format.html { redirect_to @albumfife, notice: 'Albumfive was successfully updated.' }\n format.json { render :show, status: :ok, location: @albumfife }\n else\n format.html { render :edit }\n format.json { render json: @albumfife.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if current_user\n if current_user.role == \"admin\"\n \n @album = Album.find(params[:id])\n\n respond_to do |format|\n if @album.update_attributes(params[:album])\n format.html { redirect_to @album, flash: {success: \"Gratulacje! Zaktualizowano album '#{@album.tytul}\"}}\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @album.errors, status: :unprocessable_entity }\n end\n end\n \n else\n \tredirect_to root_url, flash: {error: t('errors.messages.permissions')}\n end\n else\n redirect_to :login, flash: {notice: t('errors.messages.login_to_see')}\n end\n end",
"def update\n respond_to do |format|\n if @interior_album.update(interior_album_params)\n format.html { redirect_to @interior_album, notice: 'Interior design album was successfully updated.' }\n format.json { render :show, status: :ok, location: @interior_album }\n else\n format.html { render :edit }\n format.json { render json: @interior_album.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n album_artists\n album_cover if params[:search_online]\n\n respond_to do |format|\n if @album.update(album_params)\n format.html { redirect_to @album, notice: 'Album was successfully updated.' }\n format.json { render :show, status: :ok, location: @album }\n format.xml { render xml: @album, status: :ok }\n else\n format.html { render :edit }\n format.json { render json: @album.errors, status: :unprocessable_entity }\n format.xml { render xml: @album.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n authorize @song\n\n respond_to do |format|\n if @song.update(song_params)\n format.html { redirect_to user_album_path(@user, @album), notice: 'Song was successfully updated!' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @song.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @album.update(album_params)\n redirect_to @album, notice: 'Альбом успешно изменён.'\n else\n render :edit\n end\n end",
"def update\n respond_to do |format|\n if @album_information.update(album_information_params)\n format.html { redirect_to @album_information, notice: 'Album information was successfully updated.' }\n format.json { render :show, status: :ok, location: @album_information }\n else\n format.html { render :edit }\n format.json { render json: @album_information.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n \n \n respond_to do |format|\n updated_params = song_params\n if (@song.artist != song_params[:artist] || @song.songname != song_params[:songname])\n uri = 'http://developer.echonest.com/api/v4/song/search?api_key=6XUOAXHJOW28GGGRH&format=json&results=1&artist=' + Rack::Utils.escape(song_params[:artist]) + '&title=' + Rack::Utils.escape(song_params[:songname]) + '&bucket=audio_summary'\n result = open(uri).read\n parsed = JSON.parse(result)\n if parsed[\"response\"][\"songs\"].length > 0\n updated_params[:bpm] = parsed[\"response\"][\"songs\"][0][\"audio_summary\"][\"tempo\"]\n updated_params[:key] = parsed[\"response\"][\"songs\"][0][\"audio_summary\"][\"key\"]\n notice = \"Song found on EchoNest!\"\n else\n notice = \"Could not find updated song on EchoNest.\"\n end\n \n end\n if @song.update(updated_params)\n format.html { redirect_to @song, notice: \"#{notice} #{updated_params} \" }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @song.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_photo(album_id, photo_id, file, filename)\n \n end",
"def update\n respond_to do |format|\n if @albumseven.update(albumseven_params)\n format.html { redirect_to @albumseven, notice: 'Albumseven was successfully updated.' }\n format.json { render :show, status: :ok, location: @albumseven }\n else\n format.html { render :edit }\n format.json { render json: @albumseven.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n puts y params['photo'].keys\n params['photo'].keys.each do |photo_id|\n photo = Photo.find(photo_id)\n photo.update_attributes(params['photo'][photo_id])\n end\n respond_to do |format|\n if true \n format.html { redirect_to photos_path, notice: 'Photos were successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"index\" }\n format.json { render json: @photo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @photo = Photo.find( params[:id])\n if @photo.update_attributes(params[:photo])\n flash[:notice] = \"Photo updated!\"\n if params[:bucket_id]\n redirect_to bucket_album_photo_path( params[:bucket_id], params[:album_id], @photo )\n elsif params[:album_id]\n redirect_to album_photo_path( params[:album_id], @photo )\n else\n redirect_to @photo\n end\n else\n render :action => :edit\n end\n end",
"def update\n @album2photo = Album2photo.find(params[:id])\n\n respond_to do |format|\n if @album2photo.update_attributes(params[:album2photo])\n format.html { redirect_to @album2photo, notice: 'Album2photo was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @album2photo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n render json: Company.update(params[\"id\"], params[\"company\"])\n end",
"def update\n\n artist_id = update_artist_exist_or_new(params[:artist_name])\n\n album_id = update_album_exist_or_new(params[:album_name], params[:genre], artist_id)\n\n respond_to do |format|\n\n @song.album_id = album_id\n a = @song.album\n a.artist_id = artist_id\n a.save\n\n if @song.update(song_params)\n format.html { redirect_to @song, notice: 'Song was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @song.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @album = Album.find(params[:id])\n\n respond_to do |format|\n if @album.update_attributes(params[:album])\n #flash[:notice] = 'Article was successfully updated.'\n format.html { redirect_to :album=>@album, :action=>\"edit\", :id=>@album.album_id }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @album.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @photoalbum = Photoalbum.find(params[:id])\n\n respond_to do |format|\n if @photoalbum.update_attributes(params[:photoalbum], :as => (current_user.admin? ? :admin : :default))\n format.html { redirect_to @photoalbum, notice: 'Photoalbum was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @photoalbum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update(url, data)\n RestClient.put url, data, :content_type => :json\nend",
"def edit\n @album = Album.find(params[:id])\n render :edit\nend",
"def update\n @gallery = Gallery.find(params[:gallery_id])\n @photo = Photo.find(params[:id])\n\n respond_to do |format|\n if @photo.update_attributes(params[:photo])\n format.html { redirect_to gallery_path(@photo.gallery), notice: 'Photo was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @photo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @image = @album.images.find(params[:id])\n @image.update(image_params)\n redirect_to album_path(@image.album.id)\n end",
"def update \n @song = Song.find_by(id: params[:id])\n if @song.update(song_params)\n \n render 'api/songs/show'\n else\n # debugger\n render json: @song.errors.full_messages, status: 401\n end\n end",
"def update\n @gallery = Gallery.find(params[:id])\n @gallery.update_attributes(params[:gallery])\n respond_with(@gallery, :status => :updated)\n end",
"def update\n @picture = @album.pictures.find(params[:id]) #JRD111115\n\n respond_to do |format|\n if @album.pictures.find(params[:id]).update_attributes(picture_params)\n format.html { redirect_to album_pictures_url(@album), notice: 'Picture was successfully updated.' }\n format.json { render :show, status: :ok, location: @album.picture }\n else\n format.html { render :edit }\n format.json { render json: @album.picture.errors, status: :unprocessable_entity }\n end\n end\n end",
"def put!\n request! :put\n end",
"def update\r\n \r\n unless request.xhr? || params[:c] == \"true\"\r\n o_name = @album.name\r\n @album.name = params[:album_name]\r\n @album.description = params[:album_description]\r\n end\r\n \r\n # validate the cover photo\r\n cover_photo_changed = false\r\n old_cover_photo_id = @album.cover_photo_id\r\n @album.cover_photo_id = params[:album_cover_photo_id]\r\n if @album.cover_photo_id && @album.cover_photo_id != old_cover_photo_id\r\n photo = @album.cover_photo\r\n if photo && photo.album_id == @album.id\r\n @cover_photo = photo\r\n cover_photo_changed = true\r\n else\r\n @album.cover_photo_id = old_cover_photo_id\r\n end\r\n end\r\n \r\n if @album.save\r\n @album.set_cover_photo_cache(@cover_photo) if cover_photo_changed\r\n flash.now[:message] = \"已成功保存\"\r\n else\r\n flash.now[:error_msg] = \"操作失败, 再试一次吧\"\r\n @old_name = o_name\r\n end\r\n \r\n render(:action => \"edit\")\r\n end",
"def update\n respond_to do |format|\n if @favorite_album.update(favorite_album_params)\n format.html { redirect_to @favorite_album, notice: 'Favorite album was successfully updated.' }\n format.json { render :show, status: :ok, location: @favorite_album }\n else\n format.html { render :edit }\n format.json { render json: @favorite_album.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_radios_for_array(args = {}) \n put(\"/radios.json/#{args[:arrayId]}\", args)\nend",
"def set_album\n begin\n @album = Album.find(params[:id])\n rescue ActiveRecord::RecordNotFound => e\n render :json => {error: 'record not found'}, status: :not_found\n end\n end",
"def update\n @photo = current_user.photos.find_by_id(params[:id])\n if @photo.nil?\n render json: {error: 'foto no encontrada'}, status: :not_found\n elsif @photo.update(photo_params)\n render json: @photo\n else\n render json: @photo.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @song.update(song_params)\n format.html { redirect_to artist_album_song_url(@artist,@album,@song), notice: 'song was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @song.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n animal = Animal.find(params[:id])\n\n if validate_params(animal_params)\n animal.update(animal_params)\n render json: animal, status: 200, location: [:api, animal]\n else\n render json: { errors: animal.errors }, status: 422\n end\n end",
"def updateartists\n @album = Album.find(params[:id])\n album_param = params[:albums]\n @album.artists.delete_all \n album_param[:artists].each do |artist_id|\n artist = Artist.find(artist_id)\n @album.artists << artist \n end \n respond_to do |format|\n format.html { redirect_to(:action => :show) }\n format.xml { head :ok }\n end \n end",
"def update\n @foto_album = FotoAlbum.find(params[:id])\n\n respond_to do |format|\n if @foto_album.update_attributes(params[:foto_album])\n flash[:notice] = 'Фотоальбом успешно обновлен.'\n format.html { redirect_to(@foto_album) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @foto_album.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update options={}\n client.put(\"/#{id}\", options)\n end",
"def update\n @photo = Photo.find(params[:id])\n\n respond_to do |format|\n if @photo.update_attributes(params[:photo])\n flash[:notice] = 'Photo was successfully updated.'\n format.html { redirect_to user_album_photos_url(@user, @album) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @photo.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @album_follow.update(album_follow_params)\n format.html { redirect_to @album_follow, notice: 'Album follow was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @album_follow.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_description\n @album = Album.find(params[:album_id])\n @photo = @album.photos.find(params[:id])\n @photo.description = params[:description]\n @photo.save()\n render :json => @photo\n end",
"def update\n respond_to do |format|\n if @album_listing.update(album_listing_params)\n format.html { redirect_to @album_listing, notice: 'Album listing was successfully updated.' }\n format.json { render :show, status: :ok, location: @album_listing }\n else\n format.html { render :edit }\n format.json { render json: @album_listing.errors, status: :unprocessable_entity }\n end\n end\n end",
"def patch\n headers = {\"If-Match\" => @version}\n response = @context.request :patch, \"#{@path}/#{@id}\", @data.to_json, headers\n @version += 1\n response\n # 'X-HTTP-Method-Override' => 'PATCH'\n end",
"def album=(v)\n if @album != v\n @needs_commit = true\n @album = v\n end\n end",
"def set_album\n @album = Album.find(params[:id])\n end",
"def set_album\n @album = Album.find(params[:id])\n end",
"def set_album\n @album = Album.find(params[:id])\n end"
] |
[
"0.6955096",
"0.67836237",
"0.67753136",
"0.677528",
"0.67684835",
"0.67597175",
"0.67597175",
"0.6732082",
"0.6732082",
"0.6732082",
"0.6701589",
"0.6701589",
"0.6701589",
"0.6662536",
"0.6628176",
"0.65705246",
"0.65516347",
"0.65429837",
"0.6537242",
"0.6532796",
"0.6501009",
"0.64921004",
"0.64388597",
"0.64261717",
"0.6410329",
"0.63939947",
"0.6393366",
"0.63494825",
"0.63427806",
"0.6295601",
"0.62313855",
"0.6222294",
"0.6203181",
"0.61980957",
"0.6194863",
"0.61940545",
"0.61863714",
"0.61787564",
"0.61787564",
"0.6173303",
"0.616422",
"0.61574787",
"0.61565584",
"0.6144641",
"0.613185",
"0.60944843",
"0.60853505",
"0.6077902",
"0.6070008",
"0.6066555",
"0.60539335",
"0.6038376",
"0.60362256",
"0.6032389",
"0.60322857",
"0.60186124",
"0.601154",
"0.59924346",
"0.5976665",
"0.59629476",
"0.59579116",
"0.59508294",
"0.5938568",
"0.593716",
"0.5936466",
"0.5936088",
"0.593079",
"0.59286433",
"0.5913096",
"0.5903492",
"0.5892077",
"0.5879443",
"0.5876797",
"0.5870148",
"0.5867494",
"0.58623886",
"0.5854405",
"0.5834038",
"0.58185023",
"0.58150023",
"0.580449",
"0.5796548",
"0.57928824",
"0.5784567",
"0.5784542",
"0.577121",
"0.57672936",
"0.57669204",
"0.5755018",
"0.5754043",
"0.5752638",
"0.5741964",
"0.5740639",
"0.57250655",
"0.57174677",
"0.57046163",
"0.5689662",
"0.5677614",
"0.56725574",
"0.56725574",
"0.56725574"
] |
0.0
|
-1
|
DELETE /albums/1 DELETE /albums/1.json
|
def destroy
@albums = Album.all
@album = Album.find(params[:id])
@album.destroy
respond_to do |format|
format.html { redirect_to albums_url, notice: 'Album was successfully destroyed.' }
format.json { head :no_content }
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def destroy\n\n @album = @user.albums.find(params[:id])\n @album.destroy\n\n respond_to do |format|\n format.html { redirect_to albums_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @album.destroy\n render json: @album\n end",
"def destroy\n @album = Album.find(params[:id])\n @album.destroy\n\n respond_to do |format|\n format.html { redirect_to albums_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @album = Album.find(params[:id])\n @album.destroy\n\n respond_to do |format|\n format.html { redirect_to albums_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @album = Album.find(params[:id])\n @album.destroy\n\n respond_to do |format|\n format.html { redirect_to albums_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @album = Album.find(params[:id])\n @album.destroy\n\n respond_to do |format|\n format.html { redirect_to albums_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @album = Album.find(params[:id])\n @album.destroy\n\n respond_to do |format|\n format.html { redirect_to albums_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @album = Album.find(params[:id])\n @album.destroy\n\n respond_to do |format|\n format.html { redirect_to albums_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @album = current_user.albums.find(params[:id])\n @Album.destroy\n\n respond_to do |format|\n format.html { redirect_to albums_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @album.destroy\n\n respond_to do |format|\n format.html { redirect_to albums_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @album.destroy\n respond_to do |format|\n format.html { redirect_to albums_url }\n format.json { render json: { status: 200 } }\n end\n end",
"def destroy\n @album.destroy\n respond_to do |format|\n format.html { redirect_to albums_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @album.destroy\n respond_to do |format|\n format.html { redirect_to albums_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @album.destroy\n respond_to do |format|\n format.html { redirect_to albums_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n \t@album = Album.find(params[:album_id])\n @photo = @album.photos.find(params[:id])\n @photo.destroy\n\n respond_to do |format|\n format.html { redirect_to albums_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @album = current_account.albums.find(params[:id])\n @album.destroy\n\n respond_to do |format|\n format.html { redirect_to(albums_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @user_album = UserAlbum.find(params[:id])\n @user_album.destroy\n\n respond_to do |format|\n format.html { redirect_to user_albums_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @photoalbum = Photoalbum.find(params[:id])\n @photoalbum.destroy\n\n respond_to do |format|\n format.html { redirect_to photoalbums_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @album.destroy\n respond_to do |format|\n format.html { redirect_to albums_url, notice: 'Album erfolgreich gelöscht.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @album.destroy\n respond_to do |format|\n format.html { redirect_to albums_url, notice: 'Album was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @album.destroy\n respond_to do |format|\n format.html { redirect_to albums_url, notice: 'Album was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @album.destroy\n respond_to do |format|\n format.html { redirect_to albums_url, notice: 'Album was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @album.destroy\n respond_to do |format|\n format.html { redirect_to albums_url, notice: 'Album was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @album.destroy\n respond_to do |format|\n format.html { redirect_to albums_url, notice: 'Album was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @album.destroy\n respond_to do |format|\n format.html { redirect_to albums_url, notice: \"Album was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @album.destroy\n respond_to do |format|\n format.html { redirect_to albums_url, notice: 'El album a sido removido satisfactoriamente.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @album = Album.find(params[:id])\n @album.destroy\n\n respond_to do |format|\n format.html { redirect_to(albums_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @album = Album.find(params[:id])\n @album.destroy\n\n respond_to do |format|\n format.html { redirect_to(albums_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @album = Album.find(params[:id])\n @album.destroy\n\n respond_to do |format|\n format.html { redirect_to(albums_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @album = Album.find(params[:id])\n @album.destroy\n\n respond_to do |format|\n format.html { redirect_to(albums_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n# @album = Album.find(params[:id])\n# @album.destroy\n\n respond_to do |format|\n format.html { redirect_to(albums_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @private_album.destroy\n respond_to do |format|\n format.html { redirect_to private_albums_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @photo = Photo.find(params[:id])\n\t@album = Album.find(@photo.album_id)\n @photo.destroy\n\n respond_to do |format|\n format.html { redirect_to album_path(@album) }\n format.json { head :ok }\n end\n end",
"def destroy\n @album = Album.find(params[:id])\n @album.destroy\n\n respond_to do |format|\n format.html { redirect_to user_albums_path(@user) }\n format.xml { head :ok }\n end\n end",
"def destroy\r\n @album = Album.find(params[:id])\r\n @album.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_to user_albums_path(session[:user_id]),:notice => \"Your Album has been successfully Deleted\" }\r\n format.json { head :no_content }\r\n end\r\n end",
"def destroy\n album=@photo.album\n @photo.destroy\n save_to_json\n respond_to do |format|\n format.html { redirect_to album_path(album), notice: 'Photo was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete_album album_id\n delete(\"/albums/#{album_id}\", code: 204)\n end",
"def destroy\n @photo = Photo.find(params[:id])\n @album = @photo.album\n @photo.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_album_url(@album) }\n format.json { head :no_content }\n end\n end",
"def destroy\n @album.destroy\n\n respond_to do |format|\n format.html { redirect_to albums_url, notice: 'Album was successfully destroyed.' }\n format.json { head :no_content }\n format.xml { head :no_content }\n end\n end",
"def destroy\n @album = Album.find(params[:id])\n @album.destroy\n redirect_to root_url\n end",
"def destroy\n @albumone.destroy\n respond_to do |format|\n format.html { redirect_to albumones_url, notice: 'Albumone was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @album.destroy\n respond_to do |format|\n format.html { redirect_to albums_url, notice: \"Pagealbum was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @albumm = Albumm.find(params[:id])\n @albumm.destroy\n\n respond_to do |format|\n format.html { redirect_to albumms_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @galleries_album.destroy\n respond_to do |format|\n format.html { redirect_to galleries_albums_url, notice: 'Album was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @photo = Photo.find(params[:id])\n @album = @photo.album_id\n @photo.destroy\n respond_to do |format|\n format.html { redirect_to album_photos_path, notice: \"Photo was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item_album.destroy\n respond_to do |format|\n format.html { redirect_to(:back) }\n format.json { head :no_content }\n end\n end",
"def destroy\n @albumsix.destroy\n respond_to do |format|\n format.html { redirect_to albumsixes_url, notice: 'Albumsix was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @photo_album.destroy\n\n respond_to do |format|\n format.html { redirect_to(photo_albums_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @album_owned = AlbumOwned.find(params[:id])\n @album_owned.destroy\n\n respond_to do |format|\n format.html { redirect_to album_owneds_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @album_item = AlbumItem.find(params[:id])\n @album_item.destroy\n\n respond_to do |format|\n format.html { redirect_to album_items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @photo.destroy\n @album = @photo.album\n\n respond_to do |format|\n format.html { redirect_to @album, notice: \"写真を削除しました。\" }\n format.json { head :ok }\n end\n end",
"def destroy\n @album = Album.find(params[:id])\n @album.destroy\n\n respond_to do |format|\n format.html { redirect_to(@album) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @photo_album = PhotoAlbum.find(params[:id])\n @photo_album.destroy\n\n respond_to do |format|\n format.html { redirect_to(photo_albums_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @album_photo.destroy\n respond_to do |format|\n format.html { redirect_to album_photos_url, notice: 'Album photo was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n alb=@photo.album\n @photo.destroy\n respond_to do |format|\n format.html { redirect_to alb, notice: 'Фотография успешно удалена.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @albumfife.destroy\n respond_to do |format|\n format.html { redirect_to albumfives_url, notice: 'Albumfive was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @album = Album.find(params[:id])\n \n album_path = ALBUMS_ROOT + @album.name\n if(File.exists?(album_path))\n FileUtils.remove_dir(album_path)\n end\n\n @album.destroy\n\n respond_to do |format|\n format.html { redirect_to(albums_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n # authorize\n authorize! :delete, @album\n @album.destroy\n \n render nothing:true\n flash[:notice] = 'Xóa album thành công.'\n end",
"def destroy\n @album = Album.find(params[:id])\n @album.destroy\n # Dir.chdir(\"public/images\")\n Dir.delete(@album['directory'])\n\n respond_to do |format|\n format.html { redirect_to albums_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @foto_album = FotoAlbum.find(params[:id])\n @foto_album.destroy\n\n respond_to do |format|\n format.html { redirect_to(foto_albums_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @albumseven.destroy\n respond_to do |format|\n format.html { redirect_to albumsevens_url, notice: 'Albumseven was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n respond_to do |format|\n if @album.destroy\n format.html { redirect_to artist_albums_url, notice: 'album was successfully destroyed.' }\n format.json { head :no_content }\n else\n format.html { render action: 'delete' }\n format.json { render json: @album.errors, status: :unprocessable_entity }\n end\n end\n end",
"def destroy\n @album2photo = Album2photo.find(params[:id])\n @album2photo.destroy\n\n respond_to do |format|\n format.html { redirect_to album2photos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @interior_album.destroy\n respond_to do |format|\n format.html { redirect_to interior_albums_url, notice: 'Interior design album was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @albumfour.destroy\n respond_to do |format|\n format.html { redirect_to albumfours_url, notice: 'Albumfour was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete()\n sql = \"DELETE FROM albums\n WHERE id = $1;\"\n values = [@id]\n SqlRunner.run( sql, values )\n end",
"def destroy\n @album_follow.destroy\n respond_to do |format|\n format.html { redirect_to album_follows_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @album.destroy\n redirect_to albums_url, notice: 'Альбом успешно удалён.'\n end",
"def destroy\n\t\t# binding.pry\n\t\t@useralbum.destroy_all\n\t\tredirect_to user_albums_path\n \tend",
"def destroy\n @photo = @allbum.photos.find(params[:id])\n @photo.destroy\n\n respond_to do |format|\n format.html { redirect_to allbum_photos_path }\n format.json { head :no_content }\n end\n end",
"def destroy\n @album.destroy\n flash[:notice] = 'Album was successfully removed.'\n redirect_to(albums_url)\n end",
"def destroy\n @album = Album.find(params[:id])\n @album.images.clear\n @album.save!\n @album.destroy\n Image.all(:conditions => {:album_id => params[:id]}).each do |x| \n x.album_id = nil\n x.save\n end\n respond_to do |format|\n format.html { redirect_to(albums_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @user = current_user\n @customer = @user.customers.find(params[:customer_id])\n @album = @customer.albums.find(params[:album_id])\n @photo = @album.photos.find(params[:id])\n @photo.destroy\n\n render :json => true\n end",
"def destroy\n @private_album_image.destroy\n respond_to do |format|\n format.html { redirect_to private_album_images_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n AlbumOwnership.find_by({album_id: @album.id, user_id: current_user.id}).destroy\n end",
"def destroy\n @album_information.destroy\n respond_to do |format|\n format.html { redirect_to album_informations_url, notice: 'Album information was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete_album\n @album = Album.find(params[:id])\n @album.destroy\n \n respond_to do |format|\n format.js\n end\n end",
"def destroy\n @artist.destroy_songs\n @artist.albums.destroy_all\n @artist.destroy\n respond_to do |format|\n format.html { redirect_to artists_url, notice: 'Artist was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @palbum = Palbum.find(params[:id])\n @palbum.destroy\n \n end",
"def destroy\n @album = @track.album\n @track.destroy\n redirect_to album_tracks_url(@album)\n end",
"def destroy\n @album.destroy\n @activity = PublicActivity::Activity.find_by(trackable_id: (params[:id]), trackable_type: controller_path.classify)\n @activity.destroy\n respond_to do |format|\n format.html { redirect_to band_albums_url(@album.band.id), notice: 'Album was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @photo = Photo.find( params[:id])\n @album = @photo.album\n if @photo.destroy\n if params[:bucket_id]\n redirect_to bucket_album_path( params[:bucket_id], @album )\n else\n redirect_to @album\n end\n else\n redirect_to @photo\n end\n end",
"def destroy\n @album = Album.find(params[:album_id])\n @photo = @album.photos.find(params[:id])\n @comments = @photo.comments.all\n @comments.each do |cmt|\n cmt.destroy\n end\n @photo.destroy\n\n respond_to do |format|\n format.html { redirect_to album_path(@album) }\n format.json { head :no_content }\n end\n end",
"def destroy\n @photo = Photo.find(params[:id])\n @photo.destroy\n\n respond_to do |format|\n format.html { redirect_to user_album_photos_url(@user, @album) }\n format.xml { head :ok }\n end\n end",
"def delete\n sql = \"DELETE FROM albums WHERE id = $1\"\n values = [@id]\n SqlRunner.run(sql, values)\nend",
"def destroy\n @album_pub.destroy\n respond_to do |format|\n format.html { redirect_to album_pubs_url, notice: 'Album pub was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n unless editable(current_user, @album.user)\n redirect_back fallback_location: root_path, alert: '削除権限がありません。'\n return\n end\n @album.destroy\n\n respond_to do |format|\n format.html { redirect_to albums_url, notice: 'アルバムを削除しました' }\n format.json { head :ok }\n end\n end",
"def destroy\n @album_genre = AlbumGenre.find(params[:id])\n @album_genre.destroy\n\n respond_to do |format|\n format.html { redirect_to album_genres_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @wedding_album.destroy\n respond_to do |format|\n format.html { redirect_to wedding_albums_url, notice: 'Wedding album was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @album_listing.destroy\n respond_to do |format|\n format.html { redirect_to album_listings_url, notice: 'Album listing was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @favorite_album.destroy\n respond_to do |format|\n format.html { redirect_to favorite_albums_url, notice: 'Favorite album was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @picture = @album.pictures.find(params[:id]) #JRD111115\n @picture.destroy\n respond_to do |format|\n format.html { redirect_to album_pictures_url(@album), notice: 'Picture was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @photo = Photo.find(params[:id])\n gallery = @photo.gallery\n @photo.destroy\n\n respond_to do |format|\n format.html { redirect_to gallery_path(gallery) }\n format.json { head :no_content }\n end\n end",
"def destroy\n @photo.destroy\n respond_to do |format|\n format.html { redirect_back fallback_location: @photo.album, notice: 'Photo was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete\n client.delete(\"/#{id}\")\n end",
"def destroy\n @album = Album.find(params[:album_id])\n @image = @album.images.find(params[:id])\n @image.destroy\n redirect_to album_path(@image.album.id), notice: \"The image #{@image.name} has been deleted.\"\n end",
"def destroy\n @album = Album.find(params[:id])\n @album.destroy\n expire_fragment :action_suffix => 'homepage_albums'\n\n respond_to do |format|\n format.html { redirect_to(albums_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @musica.audios.purge\n @musica.destroy\n respond_to do |format|\n format.html { redirect_to musicas_url, notice: 'Álbum apagado com sucesso!' }\n format.json { head :no_content }\n end\n end",
"def delete\n render json: Alien.delete(params[\"id\"])\n end",
"def destroy\n @photo.destroy\n\n respond_to do |format|\n format.html { redirect_to photos_url }\n format.json { head :no_content }\n end\n end"
] |
[
"0.801051",
"0.79122156",
"0.7840477",
"0.77915406",
"0.77915406",
"0.77915406",
"0.77915406",
"0.77915406",
"0.7785304",
"0.7780388",
"0.77713436",
"0.77632475",
"0.77632475",
"0.77632475",
"0.7684608",
"0.7640788",
"0.7640206",
"0.76009154",
"0.7557025",
"0.75467694",
"0.754556",
"0.754556",
"0.754556",
"0.754556",
"0.7542386",
"0.752702",
"0.7499952",
"0.7499952",
"0.7499952",
"0.7499952",
"0.74923575",
"0.7473925",
"0.745713",
"0.7453086",
"0.7441748",
"0.7432717",
"0.74241966",
"0.740804",
"0.740734",
"0.7402739",
"0.7400599",
"0.73883563",
"0.7375271",
"0.7359508",
"0.7351968",
"0.7349126",
"0.733627",
"0.73284274",
"0.7318021",
"0.73037946",
"0.730107",
"0.7288504",
"0.7287806",
"0.72454154",
"0.7213201",
"0.7207476",
"0.7203538",
"0.720169",
"0.71876234",
"0.71851456",
"0.71678424",
"0.7157683",
"0.7132293",
"0.7116471",
"0.7114639",
"0.71000147",
"0.7087597",
"0.70812315",
"0.70593905",
"0.7039737",
"0.70346594",
"0.7022105",
"0.701625",
"0.6952559",
"0.6939667",
"0.69383836",
"0.69328195",
"0.6927591",
"0.69084555",
"0.6903124",
"0.6884039",
"0.68836343",
"0.6882491",
"0.6863932",
"0.6799133",
"0.67975944",
"0.6787477",
"0.6779844",
"0.67683417",
"0.6759638",
"0.67548805",
"0.6750414",
"0.6749929",
"0.67497134",
"0.6745255",
"0.6701014",
"0.66926056",
"0.66847914",
"0.66363126",
"0.66154945"
] |
0.7775917
|
10
|
Use callbacks to share common setup or constraints between actions.
|
def set_album
@album = Album.find(params[:id])
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end",
"def add_actions; end",
"def callbacks; end",
"def callbacks; end",
"def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end",
"def define_action_helpers; end",
"def post_setup\n end",
"def action_methods; end",
"def action_methods; end",
"def action_methods; end",
"def before_setup; end",
"def action_run\n end",
"def execute(setup)\n @action.call(setup)\n end",
"def define_action_helpers?; end",
"def set_actions\n actions :all\n end",
"def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end",
"def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end",
"def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end",
"def before_actions(*logic)\n self.before_actions = logic\n end",
"def setup_handler\n end",
"def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end",
"def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def workflow\n end",
"def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end",
"def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end",
"def before(action)\n invoke_callbacks *self.class.send(action).before\n end",
"def process_action(...)\n send_action(...)\n end",
"def before_dispatch(env); end",
"def after_actions(*logic)\n self.after_actions = logic\n end",
"def setup\n # override and do something appropriate\n end",
"def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end",
"def setup(_context)\n end",
"def setup(resources) ; end",
"def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end",
"def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end",
"def determine_valid_action\n\n end",
"def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end",
"def startcompany(action)\n @done = true\n action.setup\n end",
"def init_actions\n am = action_manager()\n am.add_action(Action.new(\"&Disable selection\") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } )\n am.add_action(Action.new(\"&Edit Toggle\") { @edit_toggle = !@edit_toggle; $status_message.value = \"Edit toggle is #{@edit_toggle}\" })\n end",
"def event_callbacks(event, metadata={})\n case event\n when :reset, :review\n if confirmed\n update_attributes(confirmed: false)\n end\n when :confirm\n confirm\n # trigger :order for all applicable items\n # NOTE: :order event is common to both physical and digital items\n items.each do |i|\n if i.event_permitted(:order)\n user_id = last_transition.user_id\n i.trigger!(:order, { order_id: id, user_id: user_id })\n end\n end\n when :complete_work\n request = metadata[:request]\n work_complete_notification(request)\n when :close\n close\n end\n if event != :close && !open\n reopen\n end\n end",
"def setup_action\n return unless PONY::ERRNO::check_sequence(current_act)\n new_sequence = @action_sequence[@sequence_index+1...@action_sequence.size]\n @sequence_index = 0\n new_sequence = DND::SkillSequence::ACTS[@acts[1]] + new_sequence\n execute_sequence\n end",
"def define_tasks\n define_weave_task\n connect_common_tasks\n end",
"def setup(&block)\n define_method(:setup, &block)\n end",
"def setup\n transition_to(:setup)\n end",
"def setup\n transition_to(:setup)\n end",
"def action\n end",
"def setup( *args )\n\t\t\tself.class.setupBlocks.each {|sblock|\n\t\t\t\tdebugMsg \"Calling setup block method #{sblock}\"\n\t\t\t\tself.send( sblock )\n\t\t\t}\n\t\t\tsuper( *args )\n\t\tend",
"def config(action, *args); end",
"def setup\n @setup_proc.call(self) if @setup_proc\n end",
"def before_action \n end",
"def setup_callbacks\n defined_callbacks.each do |meth|\n unless respond_to?(\"call_#{meth}_callbacks\".to_sym)\n self.class.module_eval <<-EOE\n def call_#{meth}_callbacks(*args)\n plugin_store.each {|a| a.call_#{meth}_callbacks(*args) } if respond_to?(:plugin_store) && plugin_store\n self.send :#{meth}, *args if respond_to?(:#{meth})\n end\n EOE\n end\n end\n end",
"def action\n end",
"def matt_custom_action_begin(label); end",
"def setup\n # override this if needed\n end",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def action(options,&callback)\n new_action = Action===options ? options : Action.new(options,&callback)\n # replace any with (shared name/alias or both default) + same arity\n @actions.delete_if do |existing_action|\n ((existing_action.names & new_action.names).size > 0 ||\n existing_action.default? && new_action.default?) &&\n existing_action.required.size == new_action.required.size &&\n existing_action.optional.size <= new_action.optional.size\n end\n @actions = (@actions + [new_action]).sort\n new_action\n end",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action\n end",
"def after(action)\n invoke_callbacks *options_for(action).after\n end",
"def pre_task\n end",
"def setup(server)\n server.on('beforeMethod', method(:before_method), 10)\n end",
"def add_actions\n attribute = machine.attribute\n name = self.name\n \n owner_class.class_eval do\n define_method(name) {self.class.state_machines[attribute].events[name].fire(self)}\n define_method(\"#{name}!\") {self.class.state_machines[attribute].events[name].fire!(self)}\n define_method(\"can_#{name}?\") {self.class.state_machines[attribute].events[name].can_fire?(self)}\n end\n end",
"def init_actions\n @select_action = SelectAction.new\n @endpoint_mouse_action = EndpointMouseAction.new\n @move_action = MoveAction.new\n end",
"def setup_signals; end",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action.respond_to?('weak!') ? action.weak! : action\n end",
"def initialize(*args)\n super\n @action = :set\nend",
"def after_set_callback; end",
"def setup\n #implement in subclass;\n end",
"def lookup_action; end",
"def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end",
"def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end",
"def release_actions; end",
"def around_hooks; end",
"def save_action; end",
"def setup(easy)\n super\n easy.customrequest = @verb\n end",
"def action_target()\n \n end",
"def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end",
"def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end",
"def before_setup\n # do nothing by default\n end",
"def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end",
"def default_action; end",
"def setup(&blk)\n @setup_block = blk\n end",
"def callback_phase\n super\n end",
"def advice\n end",
"def _handle_action_missing(*args); end",
"def duas1(action)\n action.call\n action.call\nend",
"def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end",
"def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end",
"def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend"
] |
[
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576",
"0.53124547",
"0.529654",
"0.5296262",
"0.52952296",
"0.52600986",
"0.52442724",
"0.52385926",
"0.52385926",
"0.52385926",
"0.52385926",
"0.52385926",
"0.5232394",
"0.523231",
"0.5227454",
"0.52226824",
"0.52201617",
"0.5212327",
"0.52079266",
"0.52050185",
"0.51754695",
"0.51726824",
"0.51710224",
"0.5166172",
"0.5159343",
"0.51578903",
"0.51522785",
"0.5152022",
"0.51518047",
"0.51456624",
"0.51398855",
"0.5133759",
"0.5112076",
"0.5111866",
"0.5111866",
"0.5110294",
"0.5106169",
"0.509231",
"0.50873137",
"0.5081088",
"0.508059",
"0.50677156",
"0.50562143",
"0.5050554",
"0.50474834",
"0.50474834",
"0.5036181",
"0.5026331",
"0.5022976",
"0.5015441",
"0.50121695",
"0.5000944",
"0.5000019",
"0.4996878",
"0.4989888",
"0.4989888",
"0.49864885",
"0.49797225",
"0.49785787",
"0.4976161",
"0.49683493",
"0.4965126",
"0.4958034",
"0.49559742",
"0.4954353",
"0.49535993",
"0.4952725",
"0.49467874",
"0.49423352",
"0.49325448",
"0.49282882",
"0.49269363",
"0.49269104",
"0.49252945",
"0.4923091",
"0.49194667",
"0.49174926",
"0.49173003",
"0.49171105",
"0.4915879",
"0.49155936"
] |
0.0
|
-1
|
Never trust parameters from the scary internet, only allow the white list through.
|
def album_params
params.require(:album).permit(:user, :user_id, :label, :label_id, :title, :artist, :artist_id, :genre, :year, :added, :plays, :label_attributes => [:label, :id, :name], :artist_attributes => [:id, :artist_id, :name])
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def param_whitelist\n [:role, :title]\n end",
"def expected_permitted_parameter_names; end",
"def safe_params\n params.except(:host, :port, :protocol).permit!\n end",
"def strong_params\n params.require(:team_member).permit(param_whitelist)\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def strong_params\n params.require(:community).permit(param_whitelist)\n end",
"def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end",
"def strong_params\n params.require(:education).permit(param_whitelist)\n end",
"def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end",
"def allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\n end",
"def param_whitelist\n [:rating, :review]\n end",
"def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end",
"def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end",
"def user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end",
"def user_params\n params.permit(:name, :phoneNumber, :address, :postalCode, :local, :link, :counter, :latitude, :longitude) \n end",
"def valid_params_request?; end",
"def strong_params\n params.require(:experience).permit(param_whitelist)\n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def whitelist_url_params\n params.require(:whitelist_url).permit(:domain)\n end",
"def allowed_params\n params.require(:allowed).permit(:email)\n end",
"def permitted_params\n []\n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\n end",
"def query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend",
"def strong_params\n params.require(:success_metric).permit(param_whitelist)\n end",
"def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end",
"def whitelisted_user_params\n params.require(:user).\n permit( :first_name, :last_name, :email,:password,:password_confirmation,:birthday,:gender)\n end",
"def user_params\n ActionController::Parameters.permit_all_parameters = true\n params.require(:user) #.permit(:name, :surname, :phone, :password, :email, :time_zone)\n end",
"def strong_params\n params.require(:metric_change).permit(param_whitelist)\n end",
"def safe_params\n params.require(:user).permit(:name)\n end",
"def get_params\n\t\treturn ActionController::Parameters.new(self.attributes).permit(\"account_id\", \"title\", \"category\", \"introduction\", \"tags\", \"segment_type\", \"visible\", \"status\", \"main_image\")\n\tend",
"def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end",
"def check_params; true; end",
"def param_whitelist\n whitelist = [\n :description,\n :progress,\n :kpi_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:kpi_id)\n end\n \n whitelist\n end",
"def quote_params\n params.permit!\n end",
"def valid_params?; end",
"def paramunold_params\n params.require(:paramunold).permit!\n end",
"def user_params\n\t\tparams.permit(:nickname, :avatar, :description, :password, :gender, :birthday, :email, :phone, :qq_id, :wechat_id)\n\tend",
"def filtered_parameters; end",
"def user_params\n params.permit(\n \t:id,\n \t:email, \n \t:first_name, \n \t:last_name, \n \t:password, \n \t:confirm_token, \n \t:phone_number,\n \t:facebook_link,\n \t:car_model,\n \t:license_plate)\n end",
"def filtering_params\n params.permit(:email, :name)\n end",
"def check_params\n true\n end",
"def wx_public_params\n params.require(:wx_public).permit(:nickname, :manager, :alias)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def listing_params\n\t\tparams.permit(:address, :transit_info, :rules, :other_info, :lat, :lng)\n\tend",
"def social_account_params\n\t\t\tparams.require(:social_account).permit!\n\t\tend",
"def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end",
"def url_params\n params.require(:url).permit(:short_url, :original_url, :clicks, :ip_addresses)\n end",
"def user_params\n params.require(:user).permit(:uri, :username, :password, :realname, :email, :publicvisible)\n end",
"def model_params\n\t\tparams.require(:manager).permit(\n\t :user_name,\n :password,\n :email,\n \t\t\t)\n\tend",
"def article_params_whitelist\n params.require(:article).permit(:title, :description, category_ids: [])\n end",
"def college_whitelist_params\n params.require(:college_whitelist).permit(:status)\n end",
"def active_code_params\n params[:active_code].permit\n end",
"def filtering_params\n params.permit(:email)\n end",
"def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end",
"def ip_address_params\n\t\t\tparams.require(:ip_address).permit!\n end",
"def pull_request_params\n whitelist = [\n :url,\n :id,\n :html_url,\n :diff_url,\n :patch_url,\n :issue_url,\n :number,\n :state,\n :locked,\n :title\n ]\n params.require(:pull_request).permit(whitelist)\n end",
"def reserved_params\n params.require(:reserved).permit(:name, :email, :pax, :address, :KTP, :title)\n end",
"def post_params\n if current_user.admin? \n params.permit(:title, :body, :city, :country, :gps_location, :privacy, :visible, :latitude, :longitude, images: [], files: [])\n else \n params.permit(:title, :body, :city, :country, :gps_location, :privacy,:latitude, :longitude, images: [], files: [])\n end \n end",
"def list_params\n params.permit(:name)\n end",
"def filter_parameters; end",
"def filter_parameters; end",
"def vineyard_params\n params.permit(:vineyard_name, :email, :website_url, :phone, :address, :city, :region, :postcode, :country, :specialty, :description, :pet_friendly, :holiday, :tours, :events, :family_friendly, :cover_image, :image_one, :image_two, :image_three, :image_four, :user_id, :base64)\n end",
"def available_activity_params\n # params.require(:available_activity).permit(:type,:geometry,:properties)\n whitelisted = ActionController::Parameters.new({\n type: params.require(:available_activity)[:type],\n geometry: params.require(:available_activity)[:geometry].try(:permit!).to_h,\n properties: params.require(:available_activity)[:properties].try(:permit!).to_h\n }).try(:permit!)\n end",
"def user_params\n params.permit(:name, :username, :email, :password, :img_url, :bg_url, :coinbank)\n end",
"def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end",
"def user_params\n params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\n :user, :color, :solde)\n end",
"def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end",
"def param_whitelist\n [\n :title,\n :description,\n :organization,\n :team_id,\n :started_at,\n :finished_at,\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n end",
"def url_whitelist; end",
"def admin_social_network_params\n params.require(:social_network).permit!\n end",
"def filter_params\n params.require(:filters).permit(:letters)\n end",
"def origin_params\n params.permit(:country, :state, :city, :postal_code, :address, :description)\n end",
"def valid_params(params)\n params.permit(:login, :first_name, :last_name, \n :password, :password_confirmation)\n end",
"def sensitive_params=(params)\n @sensitive_params = params\n end",
"def permit_request_params\n params.permit(:address)\n end",
"def user_params\n # Ensure a user can't give themselves admin priveleges\n params.delete(:admin) if current_user.admin?\n params.require(:user).permit(:name, :email, :admin, :image)\n end",
"def secure_params\n params.require(:location).permit(:name)\n end",
"def strong_params\n params.require( :setting ).\n permit( :global_scan_limit, :per_user_scan_limit,\n :target_whitelist_patterns, :target_blacklist_patterns )\n end",
"def question_params\n params.require(:survey_question).permit(question_whitelist)\n end",
"def case_insensitive_params\n params.require(:case_insensitive).permit(:name)\n end",
"def empire_master_no_match_params\n params.require(:empire_master_no_match).permit(:uid, :last_name, :list, :search_date, :double, :source)\n end",
"def maintenance_request_params\n params[:maintenance_request].permit! #allow all parameters for now\n end",
"def unwanted_params\n params.require(:unwanted).permit(:title, :description, :image)\n end",
"def url_params\n params[:url].permit(:full)\n end",
"def backend_user_params\n params.permit!\n end",
"def filter_params\n\t\treturn params[:candidate].permit(:name_for_filter)\n\tend",
"def speed_measurement_params\n\n #fuckit, to lazy to deal with permit crap right now\n ActionController::Parameters.permit_all_parameters = true\n\n params[:speed_measurement]\n end",
"def user_params\n params.permit(:name, :age, :username, :display_photo, :password)\n end",
"def get_params\r\n #params.require(:article).permit(:title, :permalink, :content, :source_site, :introtext, :type_id, :order_by, :searchable, :created_by, :edited_by, :published_by, :published_on, :user_id)\r\n params.require(:article).permit!\r\n\r\n end",
"def pub_params\n params.require(:pub).permit(:name, :description, :phone, :email, :hidden, :city_id, :address)\n end",
"def pass_params\n params[:pass].permit(:name, :price, :description, :colour, :events)\n end",
"def droptraining_params\n params.permit(:training_id,:user_id, :utf8, :authenticity_token, :commit)\n end",
"def person_params\n # params whitelist does *not* include admin, sub, remember_token\n # TBD: share this whitelist with the list used by configuration_permitted_parameters\n # TBD: should current_password be on this list? -- for now, leaving off, since it seems to work without\n # NOTE: do not include 'admin' in this list!\n params.require(:person).permit(\n :name, \n :email, \n :description,\n :password, \n :password_confirmation\n )\n end",
"def parameter_params\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\n end"
] |
[
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",
"0.62894756",
"0.6283177",
"0.6242471",
"0.62382483",
"0.6217549",
"0.6214457",
"0.6209053",
"0.6193042",
"0.6177802",
"0.6174604",
"0.61714715",
"0.6161512",
"0.6151757",
"0.6150663",
"0.61461",
"0.61213595",
"0.611406",
"0.6106206",
"0.6105114",
"0.6089039",
"0.6081015",
"0.6071004",
"0.60620916",
"0.6019971",
"0.601788",
"0.6011056",
"0.6010898",
"0.6005122",
"0.6005122",
"0.6001556",
"0.6001049",
"0.59943926",
"0.5992201",
"0.59909594",
"0.5990628",
"0.5980841",
"0.59669393",
"0.59589154",
"0.5958826",
"0.5957911",
"0.5957385",
"0.5953072",
"0.59526145",
"0.5943361",
"0.59386164",
"0.59375334",
"0.59375334",
"0.5933856",
"0.59292704",
"0.59254247",
"0.5924164",
"0.59167904",
"0.59088355",
"0.5907542",
"0.59064597",
"0.5906243",
"0.5898226",
"0.589687",
"0.5896091",
"0.5894501",
"0.5894289",
"0.5891739",
"0.58860534",
"0.5882406",
"0.587974",
"0.58738774",
"0.5869024",
"0.58679986",
"0.5867561",
"0.5865932",
"0.5864461",
"0.58639693",
"0.58617616",
"0.5861436",
"0.5860451",
"0.58602303",
"0.5854586",
"0.58537364",
"0.5850427",
"0.5850199"
] |
0.0
|
-1
|
execute linux shell command return array with command result [execute status, execute result]
|
def run_command(shell, whether_show_log=true, whether_reject_empty=true)
result = IO.popen(shell) do |stdout|
stdout.readlines#.reject(&method)
end.map { |l| l.is_a?(String) ? string_format(l) : l }
status = $?.exitstatus.zero?
if !status or whether_show_log
shell = string_format(shell).split(/\n/).map { |line| "\t`" + line + "`" }.join("\n")
result = ["bash: no output"] if result.empty?
if result.length > 100
resstr = "\t\tbash: output line number more than 100 rows."
else
resstr = result.map { |line| "\t\t" + line }.join
end
puts "%s\n\t\t==> %s\n%s\n" % [shell, status, resstr]
end
return result.unshift(status)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def execute\n { 'output' => `#{@cmd}`, 'process_status' => $? }\n end",
"def execute(cmd)\n captured_stdout = ''\n captured_stderr = ''\n exit_status = Open3.popen3(ENV, cmd) do |stdin, stdout, stderr, wait_thr|\n stdin.close\n captured_stdout = stdout.read\n captured_stderr = stderr.read\n wait_thr.value\n end\n [exit_status, captured_stdout, captured_stderr]\n end",
"def execute(cmd)\n error_message=\"\"\n exception = false\n # execute\n begin\n #output = ` #{cmd} `\n output = %x( #{cmd})\n #output = system(call \"#{cmd}\")\n retcode = $?.exitstatus\n rescue Exception => e\n error_message= e.message.red\n exception = true\n end\n #retcode = $?.exitstatus\n return { \"output\" => output, \"error\" => error_message,\n \"retcode\" => retcode, \"exception\" => exception }\nend",
"def execute(command_array, with_stderr = false)\n command_array << \"2>/dev/null\" unless with_stderr\n command_array << \"2>&1\" if with_stderr\n command = command_array.join(\" \")\n\n output = []\n IO::popen command do |f|\n line = \"\"\n f.each_char do |c|\n if \"\\n\" == c || \"\\r\" == c\n output << line\n yield line if block_given?\n line = \"\"\n else\n line << c\n end\n end\n output << line\n end\n output\nend",
"def exec(command, &on_output)\n status = nil\n shell.execute(command) do |process|\n process.on_output(&on_output)\n process.on_error_output(&on_output)\n process.on_finish { |p| status = p.exit_status }\n end\n shell.session.loop(1) { status.nil? }\n status\n end",
"def execute(node, command)\n params = {}\n params[:exceptiononfailure] = false\n params[:exitcode] = true\n (exitcode, output) = node.execute(command, params)\n return [exitcode.to_i, output]\n end",
"def exec\n processes, error = [], nil\n\n stdout_str, stderr_str, status = Open3.capture3(to_s)\n if status.success?\n processes = parse(stdout_str)\n else\n error = \"Command '#{to_s}' exited with error: #{stderr_str}\"\n end\n\n [processes, error]\n\n rescue => e\n [processes, e.message]\n end",
"def execute(*cmd)\n yield \"$ #{cmd.join(' ')}\" if block_given?\n output = ''\n\n Open3.popen2e(*cmd) do |_stdin, stdout_err, wait_thread|\n loop do\n line = stdout_err.gets\n break unless line\n\n output << line\n yield line if block_given?\n end\n\n exit_status = wait_thread.value\n raise ExecutionError, \"#{cmd.join(' ')} failed\" unless exit_status.success?\n end\n output\n end",
"def shell_command(command)\n system(command)\n\n result = $?\n\n reporter.info\n if result.exitstatus == 0\n reporter.exclaim(\"Command exited with status code: 0\")\n else\n reporter.error(\"Command exited with status code: #{result.exitstatus}\")\n end\n end",
"def _run_command(command)\n require \"posix-spawn\"\n\n pid, stdin, stdout, stderr = POSIX::Spawn.popen4(command)\n Process.waitpid(pid)\n\n # $?.exitstatus contains exit status do something with it if non zero raise error maybe\n end",
"def popen(cmd, path = nil, vars = {}, &block)\n result = popen_with_detail(cmd, path, vars, &block)\n\n [\"#{result.stdout}#{result.stderr}\", result.status&.exitstatus]\n end",
"def exec_cmd(var)\n # In bash, the exit value of the last command is the exit value of the\n # entire pipeline\n out = execute(\"echo \\\"#{var[:input]}\\\" | #{var[:cmd]}\", failonfail: false, combine: true)\n st = $CHILD_STATUS.exitstatus\n { out: out, exit: st }\n end",
"def run_command(cmd)\n IO.popen(cmd) do |f|\n while ! f.eof\n puts f.gets\n end\n end\n $?\n end",
"def exec!(command, status: T.unsafe(nil), &block); end",
"def shell_execute(command)\n require 'open3'\n stdout, stderr, status = Open3.capture3(command.chomp)\n if status.success? && status.exitstatus.zero?\n stdout\n else\n msg = \"Shell command failed: [#{command}] caused by <STDERR = #{stderr}>\"\n msg << \" STDOUT = #{stdout}\" if stdout && stdout.length.positive?\n raise(StandardError, msg)\n end\n rescue SystemCallError => e\n msg = \"Shell command failed: [#{command}] caused by #{e.inspect}\"\n raise(StandardError, msg)\n end",
"def call(command)\n $log.debug(\"exec #{command}\")\n\n stdout, stderr, exit_status = Open3::capture3(ENV, command)\n $log.debug(\"stderr = #{stderr}\") if stderr\n $log.debug(\"stdout = #{stdout}\")\n $log.debug(\"exit status = #{exit_status}\")\n\n status = Status.from_plowshare(exit_status.exitstatus)\n $log.debug(\"status = #{status}\")\n\n return nil, status unless exit_status.success?\n return stdout, status\n end",
"def run_command(shell, whether_show_log=true, whether_reject_empty=true)\n result = IO.popen(shell) do |stdout| \n stdout.readlines#.reject(&method) \n end.map { |l| l.is_a?(String) ? string_format(l) : l }\n status = $?.exitstatus.zero?\n if !status or whether_show_log\n shell = string_format(shell).split(/\\n/).map { |line| \"\\t`\" + line + \"`\" }.join(\"\\n\")\n resstr = (result || [\"bash: no output\"]).map { |line| \"\\t\\t\" + line }.join\n puts \"%s\\n\\t\\t==> %s\\n%s\\n\" % [shell, status, resstr]\n end\n return result.unshift(status)\n end",
"def run\n system(command)\n $?\n end",
"def run\n system(command)\n $?\n end",
"def run_and_examine(command)\n response = IO.popen(command).readlines\n response.each { |response_line| @errors << response_line if response_line =~ /Error/i }\n puts \">#{command}\\n#{response.join}\" if $verbose || (@errors.size > 0)\n @errors.size == 0\n end",
"def run_command(cmd)\n IO.popen(cmd) do |stdout|\n stdout.reject(&:empty?)\n end.unshift($?.exitstatus.zero?)\nend",
"def run_command(cmd)\n IO.popen(cmd) do |stdout|\n stdout.reject(&:empty?)\n end.unshift($?.exitstatus.zero?)\nend",
"def sh_exec(*args)\n unless args.last.kind_of? Hash\n args << {}\n end\n\n opts = args.last\n opts[:err] = [:child, :out] # write stdout and stderr to pipe, so we can read it later\n\n out = IO.popen(args, 'r') {|io| io.read}\n success = $? == 0\n\n return success, out\n end",
"def run_command(*command)\n print_command command\n result = system *command\n if result.nil?\n puts \"Failed to run command.\"\n exit 255\n elsif !result\n exit $?.exitstatus\n end\nend",
"def `(cmd)\n $shell_result\n end",
"def p_exec!(command, status: nil)\n status ||= {}\n channel = exec(command, status: status) do |ch, type, data|\n ch[:result] ||= String.new\n ch[:result] << data\n end\n channel.promise.then do\n channel[:result] ||= \"\"\n channel[:result] &&= channel[:result].force_encoding(\"UTF-8\")\n\n StringWithExitstatus.new(channel[:result], status[:exit_code])\n end\n end",
"def run_command(command)\n command = \"true\" if command.to_s.strip.empty?\n with_shell_instance do\n stdin.puts wrapped_command(command)\n stdin.close\n out, err = stdout.read, stderr.read\n out, status, _ = raw_stdout_to_parts(out)\n return status, out, err\n end\n end",
"def run_command(cmd)\n IO.popen(cmd) do |stdout|\n stdout.reject(&:empty?)\n end.unshift($CHILD_STATUS.exitstatus.zero?)\nend",
"def execute!(command=nil)\n @command = command if command\n @result = \"\"\n if @ruby_impl\n # pure ruby implementation call\n rsh_ruby do |line|\n yield(line) if block_given?\n @result << line\n end\n else\n # OS'es rsh(1) call\n open \"|#{@executable} #{\"-n\" if @nullr} -l#{@ruser} -t#{@to} #{@host} #{@command}\" do |io|\n io.each do |line|\n yield(line) if block_given?\n @result << line\n end\n end\n end\n @result\n end",
"def execute(*command)\n UI.say \"=> #{command.join(' ')}\".color(:green)\n success = system(*command)\n unless success\n UI.error(command.join(' '))\n exit 1\n end\n end",
"def sh(command)\n output = \"\"\n IO.popen(command) do |io|\n until io.eof?\n buffer = io.gets\n output << buffer\n puts buffer\n end\n end\n error \"Command #{command} failed #{$?}\" unless $? == 0\n output\nend",
"def exec_command(command)\n log = ''\n puts \"\\n=> Executing \\\"#{command}\\\"\"\n log += \"\\n\\n=> Executing \\\"#{command}\\\"\\n\"\n Open3.popen2e(command) { |stdin, stdout_and_stderr, wait_thr|\n stdout_and_stderr.each {|line|\n puts line\n log += line\n }\n }\n return log\nend",
"def run_and_return(cmd)\n output = []\n run cmd do |ch, st, data|\n output << data\n end\n return output.to_s\n end",
"def run_and_return(cmd)\n output = []\n run cmd do |ch, st, data|\n output << data\n end\n return output.to_s\n end",
"def run_and_return(cmd)\n output = []\n run cmd do |ch, st, data|\n output << data\n end\n return output.to_s\n end",
"def commandResult\n\t\t\t%x(#{@cmd} 2> /dev/null)\n\t\tend",
"def exec_shell(command, error_message, options = {})\n puts \"Running command: #{command}\" unless options[:silent] == true\n result = `#{command}`\n if options[:dont_fail_on_error] == true\n puts error_message unless $?.success?\n else\n fail_script_unless($?.success?, \"#{error_message}\\nShell failed: #{command}\\n#{result}\")\n end\n\n return result\n end",
"def run(command)\n if !command.kind_of?(Array)\n cmd = [command]\n else\n cmd = command\n end\n\n cmd.each { |line|\n puts line\n IO.popen(line) { |io|\n io.each_char do |c|\n print c\n end\n }\n }\n\nend",
"def sh(command,options={},&block)\n sh_logger.debug(\"Executing '#{command}'\")\n\n stdout,stderr,status = execution_strategy.run_command(command)\n process_status = OptparsePlus::ProcessStatus.new(status,options[:expected])\n\n sh_logger.warn(\"stderr output of '#{command}': #{stderr}\") unless stderr.strip.length == 0\n\n if process_status.success?\n sh_logger.debug(\"stdout output of '#{command}': #{stdout}\") unless stdout.strip.length == 0\n call_block(block,stdout,stderr,process_status.exitstatus) unless block.nil?\n else\n sh_logger.info(\"stdout output of '#{command}': #{stdout}\") unless stdout.strip.length == 0\n sh_logger.warn(\"Error running '#{command}'\")\n end\n\n process_status.exitstatus\n rescue *exception_meaning_command_not_found => ex\n sh_logger.error(\"Error running '#{command}': #{ex.message}\")\n 127\n end",
"def list_exec(session,cmdlst)\n\tprint_status(\"Running Command List ...\")\n\ttmpout = \"\"\n\tcmdout = \"\"\n\tr=''\n\tsession.response_timeout=120\n\tcmdlst.each do |cmd|\n\t\tbegin\n\t\t\tprint_status \"\\trunning command #{cmd}\"\n\t\t\ttmpout = \"\"\n\t\t\ttmpout << \"*****************************************\\n\"\n\t\t\ttmpout << \" Output of #{cmd}\\n\"\n\t\t\ttmpout << \"*****************************************\\n\"\n\t\t\tr = session.sys.process.execute(cmd, nil, {'Hidden' => true, 'Channelized' => true})\n\t\t\twhile(d = r.channel.read)\n\n\t\t\t\ttmpout << d\n\t\t\tend\n\t\t\tcmdout << tmpout\n\t\t\tr.channel.close\n\t\t\tr.close\n\t\trescue ::Exception => e\n\t\t\tprint_status(\"Error Running Command #{cmd}: #{e.class} #{e}\")\n\t\tend\n\tend\n\tcmdout\nend",
"def pexec(cmd)\n `#{cmd} 2>&1`\n $?\nend",
"def test_ls\n cmd=ShellCommand.new(:cmd=>\"ls\")\n assert(!cmd.run?)\n assert(!cmd.success?)\n assert(cmd.run)\n assert(cmd.run?)\n if cmd.success?\n refute_equal(\"\", cmd.output)\n else\n refute_equal(\"\", cmd.error)\n end\n end",
"def sh( cmd )\n logger.info( cmd )\n\n io = IO.popen( \"#{cmd} 2>&1\" )\n io.each_line do |l|\n logger.debug( l.strip )\n end\n end",
"def sh(cmd)\n\t# Print the command to stdout.\n\tif(cmd.is_a?(Array))\n\t\tp cmd\n\telse\n\t\tputs cmd\n\tend\n\t# Run it.\n\tsuccess = system(cmd)\n\traise \"Command failed\" unless(success)\nend",
"def list_exec(session, cmdlst) #session is our meter sessions, cmdlst is our array of commands to run on target\n\tr=''\n\tsession.response_timeout=120\n\tcmdlst.each do |cmd|\n\t\tbegin\n\t\t\tprint_status(\"Executing: #{cmd}\")\n\t\t\tr = session.sys.process.execute(\"cmd.exe /c #{cmd}\", nil, {'Hidden' => true, 'Channelized' => true})\n\t\t\twhile(d = r.channel.read)\n\t\t\t\tbreak if d == \"\"\n\t\t\tend\n\t\t\tr.channel.close\n\t\t\tr.close\n\t\trescue ::Exception => e\n\t\t\tprint_error(\"Error Running Command #{cmd}: #{e.class} #{e}\")\n\t\tend\n\tend\nend",
"def shell_commands(cmd, args); end",
"def do_ssh_cmd(cmd='uname -a')\n stdout_data = \"\"\n stderr_data = \"\"\n exit_code = nil\n \n begin\n @ssh.open_channel do |channel|\n channel.exec(cmd) do |ch, success|\n unless success\n abort \"FAILED: couldn't execute command (ssh.channel.exec)\"\n end\n channel.on_data do |ch,data|\n stdout_data += data\n end\n \n channel.on_extended_data do |ch,type,data|\n stderr_data+=data\n end\n \n channel.on_request(\"exit-status\") do |ch,data|\n exit_code = data.read_long\n end\n end\n end\n @ssh.loop\n rescue Net::SSH::Exception => e\n abort \"Net:SSH Exception : #{e.message}\"\n rescue Exception => e\n abort \"Unknown Exception : #{e.message}\"\n end\n {:stdout => stdout_data, :stderr => stderr_data, :exit_code => exit_code}\n end",
"def sh(cmd)\n output = `#{cmd}`\n if !$?.success?\n puts \"Command exited with failure code: #{cmd}\"\n puts \"Aborting.\"\n exit(1)\n end\n output\nend",
"def exec_cmd(cmd, str)\n return cmd.execute(@pl, str.split(\" \"))\nend",
"def system_exec(cmd)\n Open3.popen3(RSpec::Support::Env.env, cmd) do |stdin, stdout, stderr, wait_thr|\n yield stdin, stdout, wait_thr if block_given?\n stdin.close\n\n @exitstatus = wait_thr && wait_thr.value.exitstatus\n @out = Thread.new { stdout.read }.value.strip\n @err = Thread.new { stderr.read }.value.strip\n end\n\n (@all_output ||= \"\") << [\n \"$ #{cmd.to_s.strip}\",\n out,\n err,\n @exitstatus ? \"# $? => #{@exitstatus}\" : \"\",\n \"\\n\"\n ].reject(&:empty?).join(\"\\n\")\n\n @out\n end",
"def sys_exec!(\n *cmd_list,\n verbose: true, error_display: :failure, raise_error: true\n)\n SysExec.new(cmd_list, verbose, error_display, raise_error).run\nend",
"def run_cmd(command, arguments = [], &block)\n reset if command_count_exceeded?\n ensure_open_shell!\n\n @command_count += 1\n result = nil\n service.run_command(shell, command, arguments) do |command_id|\n result = service.get_command_output(shell, command_id, &block)\n end\n result\n end",
"def run_command_via_connection(command)\n command = command.shelljoin if command.is_a? Array\n command = ['sh', '-c', command]\n res = lxd.execute(command)\n CommandResult.new res.stdout, res.stderr, res.exitstatus\n end",
"def exec_sys_cmd(cmd)\n log.debug(\">> #{cmd}\")\n output = %x{#{cmd} 2>&1}\n raise CommandError, \"#{cmd} failed, #{$?.describe}, #{output.strip}\" unless $?.success?\n end",
"def run_cmd cmd\n info cmd\n status = system(cmd)\n if status\n info(\"Woot! Woot! - command succeeded #{cmd}\")\n else\n error(\"Gahhhh! Bad status from #{cmd}\")\n end\n status\n end",
"def run_shell_cmd(args)\n system(*args)\n raise \"command exited with a nonzero status code #{$?.exitstatus} (command: #{args.join(' ')})\" if !$?.success?\n end",
"def run_command(*command)\n\t\t\t#stdout, stderr, status\n\t\t\treturn Open3.capture3(*command)\n\t\tend",
"def execute(cmd)\n puts \"TRACE: executing '#{cmd}'\" if verbose\n require 'open3'\n out_err, st = Open3.capture2e(*cmd.split(' '))\n if st.exitstatus != 0\n puts \"ERROR: #{cmd} exited with #{st.exitstatus}\\n\\n#{out_err}\"\n exit st.exitstatus\n end\n out_err\nend",
"def gp( cmd )\n stdout = stderr = wt = nil\n Open3.popen3( \"bundle exec bin/gp #{cmd}\" ) do |i, o, e, w|\n i.close\n stdout = o.readlines.map!(&:chomp!)\n stderr = e.readlines.map!(&:chomp!)\n wt = w\n end\n [stdout, stderr, wt.value.exitstatus]\nend",
"def execute_command\n # initializing output with command name\n @output = { 'name' => @command, 'stdout' => [] }\n # where command converted into method will store it's return\n command_output = []\n\n case\n when @helper_methods.include?(@command)\n # only calling method name\n command_output << public_send(@command)\n when @check_methods.include?(@command)\n # reseting all the buffers we accumulate for a given check\n reset_status_buffer\n reset_metrics_buffer\n # calling method with command name\n command_output << public_send(@command)\n # collecting output of status methods (from GoDutch::Status)\n @output.merge!(read_status_buffer)\n # collecting metrics (from GoDutch::Metrics)\n @output['metrics'] = read_metrics_buffer\n else\n fail \"[ERROR] Invalid command: '#{@command}'\"\n end\n\n # final return on method is saved on the bottom of this flat array\n @output['stdout'] << command_output.flatten\n @output['stdout'] = @output['stdout'].flatten\n end",
"def xe_open(cmd)\n a = Array.new\n popen4(cmd) do |pid, stdin, stdout, stderr|\n stdin.close\n stdout.each {|line| a << line.chomp}\n end\n return a\nend",
"def run(cmd)\n ENV['LANG'] = 'C'\n log \"Run: #{cmd}\"\n if dry_run\n return ['', 0]\n end\n stdout = `#{cmd} 2>&1`\n return_code = $?.exitstatus\n puts stdout\n puts \"Return: #{return_code}\"\n [stdout, return_code]\n end",
"def execute(*command, &block)\n # Get the options hash if it exists\n opts = {}\n opts = command.pop if command.last.is_a?(Hash)\n\n tries = 0\n tries = 3 if opts[:retryable]\n\n sleep = opts.fetch(:sleep, 1)\n\n # Variable to store our execution result\n r = nil\n\n retryable(:on => LXC::Errors::ExecuteError, :tries => tries, :sleep => sleep) do\n # Execute the command\n r = raw(*command, &block)\n\n # If the command was a failure, then raise an exception that is\n # nicely handled by Vagrant.\n if r.exit_code != 0\n if @interrupted\n raise LXC::Errors::SubprocessInterruptError, command.inspect\n else\n raise LXC::Errors::ExecuteError,\n command: command.inspect, stderr: r.stderr, stdout: r.stdout, exitcode: r.exit_code\n end\n end\n end\n\n # Return the output, making sure to replace any Windows-style\n # newlines with Unix-style.\n stdout = r.stdout.gsub(\"\\r\\n\", \"\\n\")\n if opts[:show_stderr]\n { :stdout => stdout, :stderr => r.stderr.gsub(\"\\r\\n\", \"\\n\") }\n else\n stdout\n end\n end",
"def sh(cmd)\n #TODO: optimize by removing the extra shell\n #the Process class should be useful.\n $stderr.puts cmd\n if (!system(cmd)) then\n error \"Command failed: '#{$?}'\"\n end\nend",
"def exec(command, options={}, args=[])\n options[:boom] = true if (options[:boom].nil?)\n options[:stderr_redirect] = StdErrRedirect::NONE if (options[:stderr_redirect].nil?)\n options[:background_exec] = BackgroundExec::NONE if (options[:background_exec].nil?)\n # build command line\n command_line = [\n @tool_executor_helper.background_exec_cmdline_prepend( options ),\n command.strip,\n args,\n @tool_executor_helper.stderr_redirect_cmdline_append( options ),\n @tool_executor_helper.background_exec_cmdline_append( options ),\n ].flatten.compact.join(' ')\n\n @streaminator.stderr_puts(\"Verbose: #{__method__.to_s}(): #{command_line}\", Verbosity::DEBUG)\n\n shell_result = {}\n\n # depending on background exec option, we shell out differently\n time = Benchmark.realtime do\n if (options[:background_exec] != BackgroundExec::NONE)\n shell_result = @system_wrapper.shell_system( command_line, options[:boom] )\n else\n shell_result = @system_wrapper.shell_backticks( command_line, options[:boom] )\n end\n end\n shell_result[:time] = time\n\n #scrub the string for illegal output\n unless shell_result[:output].nil?\n shell_result[:output] = shell_result[:output].scrub if \"\".respond_to?(:scrub)\n shell_result[:output].gsub!(/\\033\\[\\d\\dm/,'')\n end\n\n @tool_executor_helper.print_happy_results( command_line, shell_result, options[:boom] )\n @tool_executor_helper.print_error_results( command_line, shell_result, options[:boom] )\n\n # go boom if exit code isn't 0 (but in some cases we don't want a non-0 exit code to raise)\n raise ShellExecutionException.new(shell_result) if ((shell_result[:exit_code] != 0) and options[:boom])\n\n return shell_result\n end",
"def exec_cmd cmd\n t = Time.now\n results = \"\"\n @ssh.open_channel do |channel|\n channel.exec(cmd) do |ch,success|\n unless success\n Logger.<<(__FILE__,\"INFO\",\"Could Not execute command #{cmd}\")\n abort\n end\n # stdout\n channel.on_data do |ch,data|\n results += data\n end\n # stderr\n channel.on_extended_data do |ch,type,data|\n Logger.<<(__FILE__,\"ERROR\",\"Error from the cmd #{cmd} : #{data}\")\n abort\n end\n channel.on_close do |ch|\n end\n end\n end\n # wait for the command to finish\n @ssh.loop\n Logger.<<(__FILE__,\"DEBUG\",\"SFTP Command executed in #{Time.now - t} sec\") if @opts[:v]\n results.split\n end",
"def sys_exec_cmd(dbc, cmd)\n begin\n q = dbc.query(\"SELECT sys_exec('#{cmd}');\")\n q.each do |x|\n if x[0].to_i == 0\n return true\n else\n return false\n end\n end\n rescue Mysql::Error => e\n puts \"Problem Executing Command\".light_red + \"!\".white\n puts \"\\t=> \".white + \"#{e}\".light_red\n return false\n end\nend",
"def execute_command(cmd, verbose = true)\n puts \"Executing: #{cmd}\" if verbose\n cmd += \" > /dev/null 2>&1\" if verbose\n %x[#{cmd}]\n success = $?.success?\n puts success if verbose\n success\n end",
"def execute(command)\r\n system \"#{command}\"\r\nend",
"def exec_command(command_string)\n io = IO.popen(command_string)\n raise Indy::Source::Invalid, \"No data returned from command string execution\" if io.eof?\n io\n end",
"def run(cmd)\n rtn = nil\n\n Open3.popen3(cmd) do |_, o, e, t|\n out_reader = Thread.new { o.read }\n err_reader = Thread.new { e.read }\n\n rtn = [out_reader.value, err_reader.value, t.value]\n end\n\n rtn\nend",
"def shell_commands(cmd, *args); end",
"def execCommands(*commands)\n logging(:debug){\n (\"enter: execCommands(\" +\n commands.map{|com| com.class.name}.inspect +\n \")\") ; } ;\n logging(:debug, \"execCommands: commands:\"){ commands.pretty_inspect } ;\n # get message body\n comBuffer = \"\" ;\n commands.each{|com|\n comBuffer << com.genMessage() ;\n }\n # send message exactly\n sendExact(comBuffer) ;\n # receive response exactly\n resBuffer = recvExact() ;\n # scan and set result code\n resList = []\n commands.each{|com|\n res = com.scanResponse(resBuffer) ;\n resList.push(res) ;\n }\n logging(:debug, \"execCommands: responses:\"){\n commands.map{|com| [com.class.name, \n com._resultCode, \n com._response]}.pretty_inspect }\n logging(:debug){\n (\"exit: execCommands(\" +\n commands.map{|com| com.class.name}.inspect +\n \")\") ; } ;\n return resList ;\n end",
"def exec(cmd, *rest) end",
"def get_from_shell_cmd(cmd, proc_id)\n stdout, stderr, status = Open3.capture3(cmd)\n if not status.success?\n cancel_job(\"error executing command '#{cmd}' - #{stderr}\", proc_id)\n end\n return stdout.strip!\nend",
"def execute(*command, &block)\n # Get the options hash if it exists\n opts = {}\n opts = command.pop if command.last.is_a?(Hash)\n\n tries = 0\n tries = 3 if opts[:retryable]\n\n sleep = opts.fetch(:sleep, 1)\n\n # Variable to store our execution result\n r = nil\n\n retryable(:on => LXC::Errors::ExecuteError, :tries => tries, :sleep => sleep) do\n # Execute the command\n r = raw(*command, &block)\n\n # If the command was a failure, then raise an exception that is\n # nicely handled by Vagrant.\n if r.exit_code != 0\n if @interrupted\n @logger.info(\"Exit code != 0, but interrupted. Ignoring.\")\n else\n raise LXC::Errors::ExecuteError, :command => command.inspect\n end\n end\n end\n\n # Return the output, making sure to replace any Windows-style\n # newlines with Unix-style.\n r.stdout.gsub(\"\\r\\n\", \"\\n\")\n end",
"def execute(command)\n system \"#{command}\"\nend",
"def execute(command)\n system \"#{command}\"\nend",
"def cmd(*args)\n command = Shellwords.join(args)\n out = `#{command}`.strip\n fail!(puts \"command failed: #{command}\", $?.exitstatus) unless $?.success?\n out\nend",
"def execute\n raise errors.to_sentences unless valid?\n\n # default failing command\n result = false\n\n # protect command from recursion\n mutex = Mutagem::Mutex.new('revenc.lck')\n lock_successful = mutex.execute do\n result = system_cmd(cmd)\n end\n\n raise \"action failed, lock file present\" unless lock_successful\n result\n end",
"def _execute_build_command command\n puts command.green\n process = IO.popen(command) do |io|\n io.each {|line| puts line}\n io.close\n end\n\n ec = $?\n @exit_code = ec.exitstatus\n return @exit_code == 0\n end",
"def execute(command)\n system(command)\n end",
"def `(cmd)\n result = bkquotes(cmd)\n if $? != 0\n print \"Last command **#{cmd}** :: Exit Status => #{$?.exitstatus}\"\n end\n return result\nend",
"def vagrant_command(command)\n\n output = []\n\n r, io = IO.pipe # For system command\n r2, io2 = IO.pipe # For exitcode\n\n fork do\n system(\"#{command}\", out: io, err: :out)\n io2.puts($?.exitstatus.to_s)\n end\n io.close\n io2.close\n\n r.each_line{|l| puts l; output << l.chomp}\n exitcode = r2.read.gsub(\"\\n\", '').gsub('\"', '').to_i\n\n return {\"output\" => output.join(\"\\n\"), \"exitcode\" => exitcode }\nend",
"def execute\n final_command = \"#{@command} 2>&1\"\n puts \":: #{final_command}\"\n duration = 0\n Transcoder.logger.info(\"\\nExecuting Command: #{final_command}\\n\")\n if block_given?\n @raw_result = ''\n IO.popen(final_command) do |pipe|\n pipe.each(\"\\r\") do |line| \n new_progress, duration = parse_progress(line, duration)\n if new_progress != @progress\n @progress = new_progress\n yield @progress\n $defout.flush\n end\n @raw_result += line + \"\\r\" \n end\n end\n else\n @raw_result = `#{final_command}`\n end\n Transcoder.logger.info(\"Result: \\n#{@raw_result}\")\n parse_result(@raw_result)\n end",
"def sys cmd\n puts cmd\n system cmd\n raise \"Running '#{cmd}' failed\" if $? != 0\nend",
"def execute(cmd, jbosscmd)\n lines = exec_command(cmd)\n result = last_execute_result\n code = result.exitstatus\n success = result.success?\n\n PuppetX::Coi::Jboss::Internal::State::ExecutionState.new(\n code,\n success,\n lines,\n jbosscmd\n )\n end",
"def exec cmd\n puts cmd\n system cmd or die\nend",
"def run_cmd(command, arguments = [], &block)\r\n command_output = nil\r\n open_shell do |shell_id|\r\n run_command(shell_id, command, arguments) do |command_id|\r\n command_output = get_command_output(shell_id, command_id, &block)\r\n end\r\n end\r\n command_output\r\n end",
"def execute(command)\n sh('-c',command)\n end",
"def exec_read\n lines = []\n MEX.synchronize do\n puts \"% \" + to_s\n end\n IO.popen(to_s, mode=\"r\") do |cmdout|\n lines = cmdout.readlines\n end\n raise CmvcError.new(\"Failed to exec '#{to_s}'\") unless $?.success?\n return lines\n end",
"def run(cmd)\n puts \"=== running: #{cmd} \".ljust(terminal_columns, '=').cyan\n pid, _, stdout, stderr = Open4::popen4 cmd\n _, status = Process::waitpid2 pid\n puts \"===\".ljust(terminal_columns, '=').cyan\n {:status => status, :stdout => stdout.read.strip, :stderr => stderr.read.strip}\n end",
"def execute(connection, command)\n stdout = \"\"\n stderr = \"\"\n connection.exec!(command) do |ch, stream, data|\n stderr << data if stream == :stderr\n stdout << data if stream == :stdout\n end\n [stdout, stderr]\n rescue Net::SSH::Exception => ex\n logger.error \"There was an exception in method execute for SSHConnection. Details #{ex}:\\n#{ex.backtrace}\"\n kill_connection(connection)\n raise NoFreeConnectionError\n rescue SystemCallError => ex\n logger.error \"There was an system error in method get_new for SSConnection. Details #{ex}:\\n#{ex.backtrace}\"\n kill_connection(connection)\n raise NoFreeConnectionError\n end",
"def run\n COMMANDS.each do |cmd_group|\n cmd_group.each do |cmd|\n ret_code = self.send(\"operate_#{cmd_group[0]}\", @argv) if @argv[0] == cmd\n return ret_code if (ret_code == ARG_ERROR or ret_code == SUCCESS)\n end\n end\n\n print_unrecognizable_error\n return CMD_ERROR\n end",
"def knife_output_as_array(sub_cmd)\n execute(knife_cmd(sub_cmd)).split(/\\n/).reject(&:empty?)\nend",
"def execute_and_get(cmd, runasdomain, ctrlcfg, try)\n state = run_jboss_command(cmd, runasdomain, ctrlcfg, try)\n if state.success?\n read_output state.output\n else\n final_result false, state.output\n end\n end",
"def runshell(cmd, ignoreerrors=false)\r\n log = !!(Cucumber.logger)\r\n\r\n Cucumber.logger.debug(\"+ #{cmd}\") if log\r\n\r\n IO.popen(\"#{cmd} 2>&1\", 'r') do |output|\r\n output.sync = true\r\n done = false\r\n while !done\r\n begin\r\n Cucumber.logger.debug(output.readline) if log\r\n rescue EOFError\r\n done = true\r\n end\r\n end\r\n end\r\n\r\n raise ShellCommandFailed, \"Exit code #{$?.exitstatus}\" unless (ignoreerrors || $?.success?)\r\n return $?.exitstatus\r\n end",
"def ssh_exec!(ssh, command)\n stdout_data = ''\n stderr_data = ''\n exit_code = nil\n exit_signal = nil\n ssh.open_channel do |channel|\n channel.exec(command) do |_ch, success|\n unless success\n abort 'FAILED: couldn\\'t execute command (ssh.channel.exec)'\n end\n channel.on_data do |_ch, data|\n stdout_data += data\n puts stdout_data\n end\n\n channel.on_extended_data do |_ch, _type, data|\n stderr_data += data\n puts stderr_data\n end\n\n channel.on_request('exit-status') do |_ch, data|\n exit_code = data.read_long\n end\n\n channel.on_request('exit-signal') do |_ch, data|\n exit_signal = data.read_long\n end\n end\n end\n ssh.loop\n [stdout_data, stderr_data, exit_code, exit_signal]\nend",
"def exec\n projectStorageStats, error = [], nil\n\n stdout_str, stderr_str, status = Open3.capture3(to_s)\n if status.success?\n projectStorageStats = stdout_str\n else\n error = \"Command '#{to_s}' exited with error: #{stderr_str}\"\n end\n\n [projectStorageStats, error]\n end",
"def execute_and_get_result(cmd, runasdomain, ctrlcfg, try)\n @cli_executor.execute_and_get(cmd, runasdomain, ctrlcfg, try)\n end"
] |
[
"0.73241246",
"0.726022",
"0.7168577",
"0.7034433",
"0.6871474",
"0.6863881",
"0.68520886",
"0.68465436",
"0.6747318",
"0.67449206",
"0.67040825",
"0.66577643",
"0.66012233",
"0.6589939",
"0.6570259",
"0.65511197",
"0.65262365",
"0.65232456",
"0.65232456",
"0.6510444",
"0.6507344",
"0.6507344",
"0.65013003",
"0.6499498",
"0.64665926",
"0.64631134",
"0.6441091",
"0.644107",
"0.643477",
"0.6430458",
"0.63979185",
"0.6382139",
"0.63781947",
"0.63781947",
"0.6376507",
"0.6354752",
"0.6352827",
"0.63399076",
"0.6339087",
"0.63314605",
"0.63133585",
"0.62945044",
"0.62944573",
"0.62784123",
"0.62748134",
"0.62601495",
"0.6251778",
"0.6249089",
"0.6245482",
"0.6242595",
"0.62398493",
"0.62227696",
"0.62189925",
"0.6211964",
"0.62091035",
"0.62064",
"0.62029403",
"0.6193571",
"0.61926514",
"0.6181945",
"0.6157836",
"0.6155456",
"0.61541307",
"0.6148665",
"0.6130499",
"0.612872",
"0.6126722",
"0.6119602",
"0.6117947",
"0.6114158",
"0.61103976",
"0.6104416",
"0.6095833",
"0.60854584",
"0.6074287",
"0.60621667",
"0.605902",
"0.605902",
"0.60588753",
"0.6050908",
"0.60493594",
"0.6048369",
"0.60407346",
"0.6040498",
"0.60341036",
"0.6029376",
"0.60278666",
"0.60234445",
"0.601338",
"0.60121274",
"0.60109806",
"0.60067767",
"0.5993261",
"0.59927076",
"0.5989282",
"0.5988176",
"0.59801066",
"0.59795684",
"0.5976992",
"0.5976611"
] |
0.6565941
|
15
|
GET /academic_informations GET /academic_informations.json
|
def index
@academic_informations = AcademicInformation.all
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def show\r\n @academic_work = AcademicWork.find(params[:id])\r\n\r\n respond_to do |format|\r\n format.html # show.html.erb\r\n format.json { render json: @academic_work }\r\n end\r\n end",
"def index\n @educations = Education.all\n render json: @educations\n end",
"def show\n @anniversary = Anniversary.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @anniversary }\n end\n end",
"def new\r\n @academic_work = AcademicWork.new\r\n\r\n respond_to do |format|\r\n format.html # new.html.erb\r\n format.json { render json: @academic_work }\r\n end\r\n end",
"def set_academic_information\n @academic_information = AcademicInformation.find(params[:id])\n end",
"def index\n @undergraduate_majors = UndergraduateMajor.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @undergraduate_majors }\n end\n end",
"def show\n @assembly_guide = AssemblyGuide.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @assembly_guide }\n end\n end",
"def index\n @citations = Citation.all\n\n render json: @citations\n end",
"def show\n @research = Research.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @research }\n end\n end",
"def index\n @guides = Guide.page(1)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: {:guides => @guides.as_json} }\n end\n end",
"def publications\n @publications = Publication.all\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @administration }\n end\n end",
"def show\n @institution = Institution.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @institution }\n end\n end",
"def show\n @institution = Institution.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @institution }\n end\n end",
"def new\n @anniversary = Anniversary.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @anniversary }\n end\n end",
"def show\n @inschool = Inschool.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @inschool }\n end\n end",
"def show\n @filial = Filial.find(params[:id])\n @instructors = @filial.instructors\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @filial }\n end\n end",
"def new\n @assembly_guide = AssemblyGuide.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @assembly_guide }\n end\n end",
"def show\n @accreditation = Accreditation.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @accreditation }\n end\n end",
"def show\n @institution_ad = InstitutionAd.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @institution_ad }\n end\n end",
"def show\n @resource = Resource.find(params[:id])\n @terms = Term.all_iit_subjects\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @resource }\n end\n end",
"def show\n @guide = Guide.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @guide.as_json(:root => true) }\n end\n end",
"def show\n @analyst = Analyst.find(params[:id])\n\n render json: @analyst\n end",
"def index\n @expertises = Expertise.all\n\n render json: @expertises\n end",
"def show\n @initiative = Initiative.find(params[:id])\n\n respond_to do |format|\n format.html # _show.html.erb\n format.json { render json: @initiative }\n end\n end",
"def index\n @education_levels = EducationLevel.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @education_levels }\n end\n end",
"def show\n @laboratory = Laboratory.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @laboratory }\n end\n end",
"def index\n @ideas = Idea.current_ideas_for(current_user).entries\n respond_with(@ideas) do |format|\n format.json { render json: @ideas }\n end\n end",
"def show\n @undergraduate_major = UndergraduateMajor.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @undergraduate_major }\n end\n end",
"def index\n @informations = Information.all\n end",
"def index\n @informations = Information.all\n end",
"def show\n @learn = Learn.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @learn }\n end\n end",
"def show\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @life_insurance }\n end\n end",
"def show\n @college = College.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @college }\n end\n end",
"def show\n @assist = Assist.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @assist }\n end\n end",
"def show\n @advocacy = Advocacy.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @advocacy }\n end\n end",
"def show\r\n @attestation = Attestation.find(params[:id])\r\n\r\n respond_to do |format|\r\n format.html # show.html.erb\r\n format.json { render json: @attestation }\r\n end\r\n end",
"def show\n render json: @educations\n end",
"def show\n @institution = Institution.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @institution }\n format.json {render :json => {\"success\"=>true,\"data\"=>@institution} }\n \n end\n end",
"def new\n @research = Research.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @research }\n end\n end",
"def show\n @experiment_biomechanical = ExperimentBiomechanical.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @experiment_biomechanical }\n end\n end",
"def show\n @formulary = Formulary.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @formulary }\n end\n end",
"def show\n @university = University.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @university }\n end\n end",
"def show\n @university = University.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @university }\n end\n end",
"def new\n @institution = Institution.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @institution }\n end\n end",
"def show\n @anuncio = Anuncio.find(params[:id])\n\n respond_to do |format|\n format.html\n format.json { render json: @anuncio }\n end\n end",
"def index\n @one_reg_institutions = OneRegInstitution.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @one_reg_institutions }\n end\n end",
"def index\n @exhibition = Exhibition.find(params[:exhibition_id])\n @exhibition_informations = @exhibition.exhibition_informations\n end",
"def show\n @colaboration = Colaboration.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @colaboration }\n end\n end",
"def index\n @educations = Education.all\n end",
"def index\n @educations = Education.all\n end",
"def show\n @financial_institution = FinancialInstitution.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @financial_institution }\n end\n end",
"def new\n @inschool = Inschool.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @inschool }\n end\n end",
"def index\n @education_accomplishments = EducationAccomplishment.all\n end",
"def show\n raise Exceptions::EducatorNotAuthorized unless current_educator.districtwide_access\n educator = Educator.find(params[:id])\n render json: educator.as_json({\n :only => [\n :id,\n :email,\n :full_name,\n :staff_type,\n :restricted_to_sped_students,\n :restricted_to_english_language_learners,\n :can_view_restricted_notes,\n :schoolwide_access,\n :districtwide_access,\n :grade_level_access,\n :admin\n ],\n :methods => [:labels],\n :include => {\n :school => { :only => [:id, :name] },\n :sections => {\n :only => [:id, :section_number],\n :methods => [:course_description]\n },\n :homeroom => { :only => [:id, :name] }\n }\n })\n end",
"def show\n @examination = Examination.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @examination }\n end\n end",
"def index\n @academic_degrees = AcademicDegree.all\n end",
"def index\n @analyses = Analysis.order(:analysis_name, :publication_year)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @analyses }\n end\n end",
"def index\n @education_details = EducationDetail.all\n end",
"def index\n @laboratories = Laboratory.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @laboratories }\n end\n end",
"def show\n @education_level = EducationLevel.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @education_level }\n end\n end",
"def show\n @fundamentals_history = @company.fundamentals_histories.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @fundamentals_history }\n end\n end",
"def show\n render json: @citation\n end",
"def show\n render json: @citation\n end",
"def show\n json_response(@faculty)\n end",
"def show\n @knowledge = Knowledge.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @knowledge }\n end\n end",
"def index\n @educations = Education.all\n\n end",
"def index\n @appeals = @conference.appeals\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @appeals }\n end\n end",
"def show\n @designation = Designation.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @designation }\n end\n end",
"def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @examination }\n end\n end",
"def show\n @exam_category = ExamCategory.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @exam_category }\n end\n end",
"def show\n @admin_interview = Interview.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @admin_interview }\n end\n end",
"def show\n @explaination = Explaination.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @explaination }\n end\n end",
"def show\n @oferta_academica = OfertaAcademica.find(params[:id])\n\n render json: @oferta_academica\n end",
"def index\n @affiliates = Affiliate.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @affiliate }\n end\n end",
"def index\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @life_insurances }\n end\n end",
"def show\n @education = Education.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @education }\n end\n end",
"def show\n @idiom = Idiom.find(params[:id])\n @essays = Essay.where(idiom_id: params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @idiom }\n end\n end",
"def index\n @fiction = Fiction.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @fiction }\n end\n end",
"def new\n @institution_ad = InstitutionAd.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @institution_ad }\n end\n end",
"def index\n @fundamentals_histories = @company.fundamentals_histories.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @fundamentals_histories }\n end\n end",
"def show\n @intention = Intention.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @intention }\n end\n end",
"def index\n @issuing_institutions = IssuingInstitution.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @issuing_institutions }\n end\n end",
"def show\n @frais_annex = FraisAnnex.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @frais_annex }\n end\n end",
"def show\n @research_c = ResearchC.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @research_c }\n end\n end",
"def index\r\n @attestations = Attestation.all\r\n\r\n respond_to do |format|\r\n format.html # index.html.erb\r\n format.json { render json: @attestations }\r\n end\r\n end",
"def show\n @annual_stat = AnnualStat.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @annual_stat }\n end\n end",
"def show #:nodoc:\n @academic_level = AcademicLevel.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.haml\n # format.xml { render :xml => @academic_level }\n end\n end",
"def show\n @design_method = DesignMethod.find(params[:id])\n @categories = @design_method.method_categories\n @citations = @design_method.citations\n @back = redirect_back\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @design_method }\n end\n end",
"def show\n @auditoria = Auditoria.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @auditoria }\n end\n end",
"def new\n @publication = Publication.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @publication }\n end\n end",
"def show\n @exhibitior_category = ExhibitiorCategory.find(params[:id])\n @exhibitor = @exhibitior_category.exhibitors\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @exhibitior_category }\n end\n end",
"def show\n @publication = Publication.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @publication }\n end\n end",
"def show\n @exam = Exam.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @exam }\n end\n end",
"def show\n @hospitalization = Hospitalization.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @hospitalization }\n end\n end",
"def index\n @universities = University.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @universities }\n end\n end",
"def index\n @q = Citation.search(params[:q])\n @q.sorts = 'id asc' if @q.sorts.empty?\n if params[:page] != \"false\"\n @citations = @q.result(distinct: true).page(params[:page])\n else\n @citations = @q.result(distinct: true)\n end\n\n respond_to do |format|\n format.html { render :index }\n format.json { render :json => @citations.to_json(\n :only => [:title, :author, :bibtex, :journal, :year,\n :volume, :pages, :month, :note, :key]\n )\n }\n end\n end",
"def show\n @familiar = Familiar.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @familiar }\n end\n end",
"def show\n @exhibition = Exhibition.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @exhibition }\n end\n end",
"def show\n if params[:bib_id].present?\n @manifestation = Manifestation.where(:bib_id => params[:bib_id]).first\n raise ActiveRecord::RecordNotFound unless @manifestation\n else\n @manifestation = Manifestation.find(params[:id])\n end\n @catalogs = Catalog.all\n\n respond_to do |format|\n format.html # show.html.erb\n format.json #{ render json: @manifestation }\n end\n end",
"def new\n @assist = Assist.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @assist }\n end\n end"
] |
[
"0.6775217",
"0.65797335",
"0.65763885",
"0.6488956",
"0.64393044",
"0.63317746",
"0.631652",
"0.6284111",
"0.6239812",
"0.6193898",
"0.61796737",
"0.61765236",
"0.61765236",
"0.6160649",
"0.61407167",
"0.6119435",
"0.6099538",
"0.60833544",
"0.608291",
"0.6081734",
"0.6077755",
"0.6065513",
"0.6053317",
"0.60478705",
"0.6045508",
"0.6036772",
"0.60293263",
"0.6019702",
"0.6017452",
"0.6017452",
"0.60070825",
"0.60044277",
"0.5982497",
"0.5975964",
"0.5969226",
"0.59640604",
"0.59586066",
"0.5952821",
"0.5946783",
"0.5946496",
"0.5943742",
"0.5940134",
"0.5940134",
"0.5939302",
"0.59378827",
"0.59366006",
"0.59359586",
"0.59328765",
"0.59319353",
"0.59319353",
"0.5928539",
"0.59276706",
"0.5926131",
"0.5921596",
"0.5919665",
"0.5919255",
"0.59106314",
"0.59094626",
"0.5906322",
"0.5901294",
"0.5900325",
"0.58996326",
"0.58996326",
"0.589893",
"0.58987194",
"0.58962196",
"0.58950824",
"0.58935404",
"0.58758426",
"0.5867333",
"0.58640015",
"0.5863586",
"0.58634174",
"0.5858644",
"0.58580774",
"0.58568525",
"0.58560777",
"0.5855392",
"0.58527386",
"0.5852461",
"0.5849866",
"0.5848728",
"0.5848111",
"0.5847526",
"0.58468676",
"0.5843669",
"0.5841578",
"0.58389336",
"0.583238",
"0.5832058",
"0.5829752",
"0.58271194",
"0.58264786",
"0.5821553",
"0.58214045",
"0.58199143",
"0.58137506",
"0.581211",
"0.5811054",
"0.58097774"
] |
0.74520576
|
0
|
GET /academic_informations/1 GET /academic_informations/1.json
|
def show
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def index\n @academic_informations = AcademicInformation.all\n end",
"def show\r\n @academic_work = AcademicWork.find(params[:id])\r\n\r\n respond_to do |format|\r\n format.html # show.html.erb\r\n format.json { render json: @academic_work }\r\n end\r\n end",
"def show\n @anniversary = Anniversary.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @anniversary }\n end\n end",
"def new\r\n @academic_work = AcademicWork.new\r\n\r\n respond_to do |format|\r\n format.html # new.html.erb\r\n format.json { render json: @academic_work }\r\n end\r\n end",
"def show\n @research = Research.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @research }\n end\n end",
"def show\n @assembly_guide = AssemblyGuide.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @assembly_guide }\n end\n end",
"def set_academic_information\n @academic_information = AcademicInformation.find(params[:id])\n end",
"def show\n @institution = Institution.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @institution }\n end\n end",
"def show\n @institution = Institution.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @institution }\n end\n end",
"def show\n @formulary = Formulary.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @formulary }\n end\n end",
"def index\n @educations = Education.all\n render json: @educations\n end",
"def show\n @initiative = Initiative.find(params[:id])\n\n respond_to do |format|\n format.html # _show.html.erb\n format.json { render json: @initiative }\n end\n end",
"def new\n @anniversary = Anniversary.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @anniversary }\n end\n end",
"def show\n @undergraduate_major = UndergraduateMajor.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @undergraduate_major }\n end\n end",
"def show\n @accreditation = Accreditation.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @accreditation }\n end\n end",
"def show\n @institution_ad = InstitutionAd.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @institution_ad }\n end\n end",
"def show\n @colaboration = Colaboration.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @colaboration }\n end\n end",
"def index\n @undergraduate_majors = UndergraduateMajor.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @undergraduate_majors }\n end\n end",
"def show\n @inschool = Inschool.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @inschool }\n end\n end",
"def show\n @laboratory = Laboratory.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @laboratory }\n end\n end",
"def show\n @resource = Resource.find(params[:id])\n @terms = Term.all_iit_subjects\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @resource }\n end\n end",
"def show\n @guide = Guide.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @guide.as_json(:root => true) }\n end\n end",
"def show\n @experiment_biomechanical = ExperimentBiomechanical.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @experiment_biomechanical }\n end\n end",
"def show\n @analyst = Analyst.find(params[:id])\n\n render json: @analyst\n end",
"def new\n @assembly_guide = AssemblyGuide.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @assembly_guide }\n end\n end",
"def show\n @college = College.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @college }\n end\n end",
"def index\n @citations = Citation.all\n\n render json: @citations\n end",
"def show\n @research_c = ResearchC.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @research_c }\n end\n end",
"def new\n @research = Research.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @research }\n end\n end",
"def show\n @university = University.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @university }\n end\n end",
"def show\n @university = University.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @university }\n end\n end",
"def show\n @annual_stat = AnnualStat.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @annual_stat }\n end\n end",
"def show\n @learn = Learn.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @learn }\n end\n end",
"def new\n @institution = Institution.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @institution }\n end\n end",
"def show\n @one_reg_institution = OneRegInstitution.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @one_reg_institution }\n end\n end",
"def show\n @financial_institution = FinancialInstitution.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @financial_institution }\n end\n end",
"def show\n @advocacy = Advocacy.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @advocacy }\n end\n end",
"def show\n @institution = Institution.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @institution }\n format.json {render :json => {\"success\"=>true,\"data\"=>@institution} }\n \n end\n end",
"def show\n @anuncio = Anuncio.find(params[:id])\n\n respond_to do |format|\n format.html\n format.json { render json: @anuncio }\n end\n end",
"def show\n @examination = Examination.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @examination }\n end\n end",
"def show\n @exam_category = ExamCategory.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @exam_category }\n end\n end",
"def index\n @guides = Guide.page(1)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: {:guides => @guides.as_json} }\n end\n end",
"def index\n @one_reg_institutions = OneRegInstitution.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @one_reg_institutions }\n end\n end",
"def show\n @knowledge = Knowledge.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @knowledge }\n end\n end",
"def show\n @research_appointment = ResearchAppointment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @research_appointment }\n end\n end",
"def show\n @intention = Intention.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @intention }\n end\n end",
"def show\n @hospitalization = Hospitalization.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @hospitalization }\n end\n end",
"def show\n if params[:bib_id].present?\n @manifestation = Manifestation.where(:bib_id => params[:bib_id]).first\n raise ActiveRecord::RecordNotFound unless @manifestation\n else\n @manifestation = Manifestation.find(params[:id])\n end\n @catalogs = Catalog.all\n\n respond_to do |format|\n format.html # show.html.erb\n format.json #{ render json: @manifestation }\n end\n end",
"def show\n @publication = Publication.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @publication }\n end\n end",
"def show\n @exam = Exam.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @exam }\n end\n end",
"def show\n @familiar = Familiar.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @familiar }\n end\n end",
"def show\n @fundamentals_history = @company.fundamentals_histories.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @fundamentals_history }\n end\n end",
"def show\n @oferta_academica = OfertaAcademica.find(params[:id])\n\n render json: @oferta_academica\n end",
"def show\n @filial = Filial.find(params[:id])\n @instructors = @filial.instructors\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @filial }\n end\n end",
"def show\r\n @attestation = Attestation.find(params[:id])\r\n\r\n respond_to do |format|\r\n format.html # show.html.erb\r\n format.json { render json: @attestation }\r\n end\r\n end",
"def show\n @admin_interview = Interview.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @admin_interview }\n end\n end",
"def show\n @explaination = Explaination.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @explaination }\n end\n end",
"def show\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @life_insurance }\n end\n end",
"def show\n @frais_annex = FraisAnnex.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @frais_annex }\n end\n end",
"def new\n @publication = Publication.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @publication }\n end\n end",
"def show\n @education_level = EducationLevel.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @education_level }\n end\n end",
"def show\n @institution = Institution.find(params[:id])\n\n render json: @institution\n\n rescue ActiveRecord::RecordNotFound\n render json: {message: 'Resource not found'}, status: 404\n\n end",
"def show\n @auditoria = Auditoria.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @auditoria }\n end\n end",
"def show\n @general_information = GeneralInformation.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @general_information }\n end\n end",
"def new\n @inschool = Inschool.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @inschool }\n end\n end",
"def show\n @learning_modality = LearningModality.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @learning_modality }\n end\n end",
"def show\n @learning_modality = LearningModality.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @learning_modality }\n end\n end",
"def new\n @institution_ad = InstitutionAd.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @institution_ad }\n end\n end",
"def show\n @idiom = Idiom.find(params[:id])\n @essays = Essay.where(idiom_id: params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @idiom }\n end\n end",
"def show\n @fiction = Fiction.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @fiction }\n end\n end",
"def show\n @exam_code = ExamCode.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @exam_code }\n end\n end",
"def show\n @designation = Designation.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @designation }\n end\n end",
"def publications\n @publications = Publication.all\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @administration }\n end\n end",
"def show\n @clinical_course = ClinicalCourse.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @clinical_course }\n end\n end",
"def show\n @assessment_olympiad = AssessmentOlympiad.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json:@assessment_olympiad }\n end\n end",
"def show\n @program_attendance = ProgramAttendance.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @program_attendance }\n end\n end",
"def show\n institution = Institution.find(params[:id])\n render json: { status: '200', message: \"Loaded Institution with id #{params[:id]}\", data: institution }, status: :ok\n rescue ActiveRecord::RecordNotFound\n render json: { status: '404', error: \"No Institution with id #{params[:id]}\", data: institution }, status: :not_found\n end",
"def index\n @analyses = Analysis.order(:analysis_name, :publication_year)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @analyses }\n end\n end",
"def show\n json_response(@faculty)\n end",
"def show\n @assist = Assist.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @assist }\n end\n end",
"def show\n @uni_major = UniMajor.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @uni_major }\n end\n end",
"def show\n @enrollment = Enrollment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @enrollment }\n end\n end",
"def show\n @law = Law.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @law }\n end\n end",
"def show\n @assessment = Assessment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @assessment }\n end\n end",
"def new\n @historial = Historial.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @historial }\n end\n end",
"def show\n @announcement = Announcement.find(params[:id])\n render json:@announcement\n end",
"def show\n @college_fee = CollegeFee.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @college_fee }\n end\n end",
"def show\n @my_exam = MyExam.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @my_exam }\n end\n end",
"def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @examination }\n end\n end",
"def show\n @education = Education.where(:resource_id => current_user.id, :id => params[:id]).first\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @education }\n end\n end",
"def show #:nodoc:\n @academic_level = AcademicLevel.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.haml\n # format.xml { render :xml => @academic_level }\n end\n end",
"def show\n @medium_research_allotment = MediumResearchAllotment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @medium_research_allotment }\n end\n end",
"def show\n @announce_c = AnnounceC.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @announce_c }\n end\n end",
"def new\n @accreditation = Accreditation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @accreditation }\n end\n end",
"def index\n @expertises = Expertise.all\n\n render json: @expertises\n end",
"def show\n @chiropractic_assessment = ChiropracticAssessment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @chiropractic_assessment }\n end\n end",
"def index\n @education_levels = EducationLevel.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @education_levels }\n end\n end",
"def new\n @financial_institution = FinancialInstitution.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @financial_institution }\n end\n end",
"def show\n @addimition = Addimition.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @addimition }\n end\n end",
"def show\n @affiliate_link = AffiliateLink.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @affiliate_link }\n end\n end",
"def new\n @knowledge = Knowledge.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @knowledge }\n end\n end"
] |
[
"0.73284096",
"0.708885",
"0.6798916",
"0.6777726",
"0.66206247",
"0.65678155",
"0.65272915",
"0.649892",
"0.649892",
"0.6420348",
"0.6413071",
"0.6399599",
"0.6377764",
"0.6376341",
"0.63746935",
"0.63714933",
"0.63566154",
"0.6355441",
"0.63545996",
"0.6344604",
"0.63325095",
"0.632551",
"0.6318486",
"0.6311158",
"0.63080853",
"0.63065183",
"0.63040173",
"0.62981945",
"0.62948763",
"0.628113",
"0.628113",
"0.6262658",
"0.6258982",
"0.6254437",
"0.6254437",
"0.62522066",
"0.6248942",
"0.6248485",
"0.62473",
"0.62304664",
"0.62296784",
"0.62101555",
"0.6208163",
"0.6197936",
"0.61937994",
"0.61931133",
"0.61921006",
"0.6183355",
"0.6181253",
"0.6178382",
"0.6176092",
"0.61744326",
"0.61703056",
"0.6167039",
"0.61657447",
"0.6162218",
"0.61597127",
"0.6159667",
"0.6159323",
"0.6158194",
"0.61580706",
"0.6145253",
"0.6139562",
"0.6139465",
"0.61339605",
"0.6132045",
"0.6132045",
"0.61286753",
"0.6128286",
"0.61260116",
"0.61065996",
"0.6103293",
"0.61000365",
"0.6098672",
"0.6098233",
"0.6098051",
"0.60967547",
"0.6094947",
"0.6094317",
"0.6088656",
"0.60874575",
"0.60871637",
"0.6076582",
"0.60717565",
"0.60714054",
"0.60696965",
"0.6068636",
"0.6067127",
"0.60561424",
"0.6055678",
"0.6052585",
"0.604997",
"0.6049745",
"0.6046798",
"0.6036108",
"0.6034322",
"0.6033258",
"0.6033214",
"0.6031225",
"0.60241866",
"0.60227615"
] |
0.0
|
-1
|
POST /academic_informations POST /academic_informations.json
|
def create
@academic_information = AcademicInformation.new(institution_id: academic_information_params[:institution_id],
academic_degree_id: academic_information_params[:academic_degree_id],
grade: academic_information_params[:grade],
description: academic_information_params[:description]
)
course = Course.where(name: academic_information_params[:course],institution_id: academic_information_params[:institution_id]).first_or_create!
@academic_information.course = course
begin
@academic_information.b_date = Date.parse(academic_information_params[:b_date])
rescue ArgumentError
return redirect_to new_academic_information_path(@academic_information)
end
if !academic_information_params[:e_date].blank?
begin
@academic_information.e_date = Date.parse(academic_information_params[:e_date])
rescue ArgumentError
return redirect_to new_academic_information_path(@academic_information)
end
end
@academic_information.teacher = Teacher.find(current_teacher.id)
respond_to do |format|
if @academic_information.save
format.html { redirect_to :home, notice: 'Academic information was successfully created.' }
format.json { render action: 'show', status: :created, location: @academic_information }
else
format.html { render action: 'new' }
format.json { render json: @academic_information.errors, status: :unprocessable_entity }
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def index\n @academic_informations = AcademicInformation.all\n end",
"def new\r\n @academic_work = AcademicWork.new\r\n\r\n respond_to do |format|\r\n format.html # new.html.erb\r\n format.json { render json: @academic_work }\r\n end\r\n end",
"def academic_information_params\n params.require(:academic_information).permit(:b_date, :e_date, :description, :grade, :academic_degree_id, :course, :institution_id)\n end",
"def create\n @academic_work = AcademicWork.new(academic_work_params)\n\n respond_to do |format|\n if @academic_work.save\n format.html { redirect_to @academic_work, notice: t('notice.created') }\n format.json { render :show, status: :created, location: @academic_work }\n else\n format.html { render :new }\n format.json { render json: @academic_work.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @education = Education.new(education_params)\n\n if @education.save\n render json: @education, status: :created, location: @education\n else\n render json: @education.errors, status: :unprocessable_entity\n end\n end",
"def create\r\n @academic_work = AcademicWork.new(params[:academic_work])\r\n\r\n respond_to do |format|\r\n if @academic_work.save\r\n format.html { redirect_to @academic_work, notice: 'Academic work was successfully created.' }\r\n format.json { render json: @academic_work, status: :created, location: @academic_work }\r\n else\r\n format.html { render action: \"new\" }\r\n format.json { render json: @academic_work.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def create\n @incarnation = Incarnation.new(incarnation_params)\n\n respond_to do |format|\n if @incarnation.save\n format.html { redirect_to @incarnation, notice: 'Incarnation was successfully created.' }\n format.json { render :show, status: :created, location: @incarnation }\n else\n format.html { render :new }\n format.json { render json: @incarnation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @analise = Analisis.new(analise_params)\n\n respond_to do |format|\n if @analise.save\n format.html { redirect_to @analise, notice: 'Analisis was successfully created.' }\n format.json { render action: 'show', status: :created, location: @analise }\n else\n format.html { render action: 'new' }\n format.json { render json: @analise.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_academic_information\n @academic_information = AcademicInformation.find(params[:id])\n end",
"def create\n @academic_degree = AcademicDegree.new(academic_degree_params)\n\n respond_to do |format|\n if @academic_degree.save\n format.html { redirect_to '/maestricos/prueba?titulo=Grado+Academico&tabla=AcademicDegree' }\n format.json { render action: 'show', status: :created, location: @academic_degree }\n else\n flash[:success] = \"Welcome to the Sample App!\"\n format.html { redirect_to '/maestricos/prueba?titulo=Grado+Academico&tabla=AcademicDegree' }\n format.json { render json: @academic_degree.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @assoziation = Assoziation.new(assoziation_params)\n\n respond_to do |format|\n if @assoziation.save\n format.html { redirect_to moderator_faculty_assoziations_path(params[:faculty_id]), \n notice: 'Assoziation was successfully created.' \n }\n format.json { render :show, status: :created, location: @assoziation }\n else\n format.html { render :new }\n format.json { render json: @assoziation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n if params[:education][:accomplishment][\"0\"] != \"\"\n @education = Education.new(education_params)\n if @education.save\n params[:education][:accomplishment].each do |i, acc|\n EducationAccomplishment.create(description: acc, education_id: @education.id)\n end\n redirect_to '/'\n else\n redirect_to :back, flash: {alert: @education.errors.full_messages}\n end\n else\n redirect_to :back, flash: {alert: \"Must have at least one accomplishment\"}\n end\n end",
"def new\n @assembly_guide = AssemblyGuide.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @assembly_guide }\n end\n end",
"def create\n @indication_for_meal = IndicationForMeal.new(indication_for_meal_params)\n\n respond_to do |format|\n if @indication_for_meal.save\n format.html { redirect_to @indication_for_meal, notice: 'Indication for meal was successfully created.' }\n format.json { render action: 'show', status: :created, location: @indication_for_meal }\n else\n format.html { render action: 'new' }\n format.json { render json: @indication_for_meal.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @education_accomplishment = EducationAccomplishment.new(education_accomplishment_params)\n\n respond_to do |format|\n if @education_accomplishment.save\n format.html { redirect_to @education_accomplishment, notice: 'Education accomplishment was successfully created.' }\n format.json { render :show, status: :created, location: @education_accomplishment }\n else\n format.html { render :new }\n format.json { render json: @education_accomplishment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @education = Education.new(education_params)\n\n respond_to do |format|\n if @education.save\n format.html { redirect_to @education, notice: \"Education was successfully created.\" }\n format.json { render :show, status: :created, location: @education }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @education.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @anniversary = Anniversary.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @anniversary }\n end\n end",
"def new\n @research = Research.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @research }\n end\n end",
"def new\r\n @academic_work=AcademicWork.find(params[:academic_work_id])\r\n @disciplines_study = @academic_work.disciplines_studies.build\r\n\r\n respond_to do |format|\r\n format.html # new.html.erb\r\n format.json { render json: @disciplines_study }\r\n end\r\n end",
"def create\n respond_to do |format|\n if @employer_study.save\n format.html { redirect_to @employer_study, notice: t2('create.notice') }\n format.json { render json: @employer_study, status: :created, location: @employer_study }\n else\n format.html { render action: \"new\" }\n format.json { render json: @employer_study.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @formality = Formality.new(formality_params)\n\n respond_to do |format|\n if @formality.save\n format.html { redirect_to @formality, notice: 'Formality was successfully created.' }\n format.json { render :show, status: :created, location: @formality }\n else\n format.html { render :new }\n format.json { render json: @formality.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @informal_care_provider = @senior.informal_care_providers.create(informal_care_provider_params)\n redirect_to senior_path(@senior)\n # # respond_to do |format|\n # # if @informal_care_provider.save\n # # format.html { redirect_to senior_path(@senior), notice: 'informal_care_provider was successfully created.' }\n # # format.json { render :show, status: :created, location: @informal_care_provider }\n # # else\n # # format.html { render :new }\n # # format.json { render json: @informal_care_providers.errors, status: :unprocessable_entity }\n # # end\n # end\n end",
"def create\n @education_detail = EducationDetail.new(education_detail_params)\n\n respond_to do |format|\n if @education_detail.save\n format.html { redirect_to @education_detail, notice: 'Education detail was successfully created.' }\n format.json { render :show, status: :created, location: @education_detail }\n else\n format.html { render :new }\n format.json { render json: @education_detail.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\r\n @attestation = Attestation.new\r\n\r\n respond_to do |format|\r\n format.html # new.html.erb\r\n format.json { render json: @attestation }\r\n end\r\n end",
"def create\n @expertise = Expertise.new(expertise_params)\n\n if @expertise.save\n render json: @expertise, status: :created, location: @expertise\n else\n render json: @expertise.errors, status: :unprocessable_entity\n end\n end",
"def create\n @analise = current_user.analises.build(analise_params)\n\n respond_to do |format|\n if @analise.save\n format.html { redirect_to @analise, notice: 'Analise was successfully created.' }\n format.json { render :show, status: :created, location: @analise }\n else\n format.html { render :new }\n format.json { render json: @analise.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @asignacion_familiar = AsignacionFamiliar.new(asignacion_familiar_params)\n\n respond_to do |format|\n if @asignacion_familiar.save\n format.html { redirect_to @asignacion_familiar, notice: 'Asignacion familiar creada exitosamente.' }\n format.json { render :show, status: :created, location: @asignacion_familiar }\n else\n format.html { render :new }\n format.json { render json: @asignacion_familiar.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @inschool = Inschool.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @inschool }\n end\n end",
"def create\n @exhibition_information = ExhibitionInformation.new(exhibition_information_params)\n @exhibition_information.exhibition_id = Exhibition.find(params[:exhibition_id]).id\n\n respond_to do |format|\n if @exhibition_information.save\n format.html { redirect_to exhibition_exhibition_informations_path(@exhibition_information.exhibition_id), notice: 'Exhibition information was successfully created.' }\n format.json { render :show, status: :created, location: @exhibition_information }\n else\n format.html { render :new }\n format.json { render json: @exhibition_information.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @general_information = GeneralInformation.new(params[:general_information])\n\n respond_to do |format|\n if @general_information.save\n format.html { redirect_to @general_information.personal_detail, notice: 'General information was successfully created.' }\n format.json { render json: @general_information, status: :created, location: @general_information }\n else\n format.html { render action: \"new\" }\n format.json { render json: @general_information.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @inschool = Inschool.new(params[:inschool])\n\n respond_to do |format|\n if @inschool.save\n format.html { redirect_to @inschool, notice: 'Inschool was successfully created.' }\n format.json { render json: @inschool, status: :created, location: @inschool }\n else\n format.html { render action: \"new\" }\n format.json { render json: @inschool.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @attestation = Attestation.new(attestation_params)\n\n respond_to do |format|\n if @attestation.save\n format.html { redirect_to @attestation, notice: 'Attestation was successfully created.' }\n format.json { render :show, status: :created, location: @attestation }\n else\n format.html { render :new }\n format.json { render json: @attestation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @education = Education.new(education_params)\n\n respond_to do |format|\n if @education.save\n format.html { redirect_to educations_url, notice: 'Education was successfully created.' }\n else\n format.html { render :new }\n end\n end\n end",
"def create\r\n @academic_work=AcademicWork.find(params[:academic_work_id])\r\n @disciplines_study = @academic_work.disciplines_studies.new(params[:disciplines_study])\r\n\r\n respond_to do |format|\r\n if @disciplines_study.save\r\n format.html { redirect_to @disciplines_study, notice: 'Disciplines study was successfully created.' }\r\n format.json { render json: @disciplines_study, status: :created, location: @disciplines_study }\r\n else\r\n format.html { render action: \"new\" }\r\n format.json { render json: @disciplines_study.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def create\n @educational_institution = EducationalInstitution.new(educational_institution_params)\n\n respond_to do |format|\n if @educational_institution.save\n format.html { redirect_to @educational_institution, notice: 'Educational institution was successfully created.' }\n format.json { render :show, status: :created, location: @educational_institution }\n else\n format.html { render :new }\n format.json { render json: @educational_institution.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @meta_title = meta_title 'Daily Afformations - Create your own personal afformations'\n\n @afformation = Afformation.new(afformation_params)\n @afformation.user_id = current_user.id if !current_user.admin?\n\n respond_to do |format|\n if @afformation.save\n format.html { redirect_to afformations_url, notice: 'Afformation was successfully created.' }\n format.json { render :index, status: :created, location: @afformation }\n else\n format.html { render :new }\n format.json { render json: @afformation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @explaination = Explaination.new(params[:explaination])\n\n respond_to do |format|\n if @explaination.save\n format.html { redirect_to @explaination, notice: 'Explaination was successfully created.' }\n format.json { render json: @explaination, status: :created, location: @explaination }\n else\n format.html { render action: \"new\" }\n format.json { render json: @explaination.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @additional_information = AdditionalInformation.new(additional_information_params)\n\n respond_to do |format|\n if @additional_information.save\n format.html { redirect_to @additional_information, notice: 'Additional information was successfully created.' }\n format.json { render action: 'show', status: :created, location: @additional_information }\n else\n format.html { render action: 'new' }\n format.json { render json: @additional_information.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @fundamental_announcement = Fundamental::Announcement.new(params[:fundamental_announcement])\n @fundamental_announcement.author = current_backend_user\n\n respond_to do |format|\n if @fundamental_announcement.save\n format.html { redirect_to @fundamental_announcement, notice: 'Announcement was successfully created.' }\n format.json { render json: @fundamental_announcement, status: :created, location: @fundamental_announcement }\n else\n format.html { render action: \"new\" }\n format.json { render json: @fundamental_announcement.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @publication = Publication.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @publication }\n end\n end",
"def create\n @affiliation = Affiliation.new(affiliation_params)\n\n respond_to do |format|\n if @affiliation.save\n format.html { redirect_to affiliations_url, notice: 'Affiliation was successfully created.' }\n # format.json { render :show, status: :created, location: @affiliation }\n else\n format.html { render :new }\n format.json { render json: @affiliation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @accreditation = Accreditation.new(params[:accreditation])\n\n respond_to do |format|\n if @accreditation.save\n format.html { redirect_to @accreditation, notice: 'Accreditation was successfully created.' }\n format.json { render json: @accreditation, status: :created, location: @accreditation }\n else\n format.html { render action: \"new\" }\n format.json { render json: @accreditation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @accreditation = Accreditation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @accreditation }\n end\n end",
"def create\n @indivisual = Indivisual.new(indivisual_params)\n\n respond_to do |format|\n if @indivisual.save\n format.html { redirect_to @indivisual, notice: 'Indivisual was successfully created.' }\n format.json { render :show, status: :created, location: @indivisual }\n else\n format.html { render :new }\n format.json { render json: @indivisual.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @aki_diagnosis = AkiDiagnosis.new(aki_diagnosis_params)\n\n respond_to do |format|\n if @aki_diagnosis.save\n format.html { redirect_to @aki_diagnosis, notice: 'Diagnosis aki was successfully created.' }\n format.json { render :show, status: :created, location: @aki_diagnosis }\n else\n format.html { render :new }\n format.json { render json: @aki_diagnosis.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @accreditation = Accreditation.new(accreditation_params)\n\n respond_to do |format|\n if @accreditation.save\n format.html { redirect_to @accreditation, notice: 'Accreditation was successfully created.' }\n format.json { render :show, status: :created, location: @accreditation }\n else\n format.html { render :new }\n format.json { render json: @accreditation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @historial = Historial.new(historial_params)\n\n respond_to do |format|\n if @historial.save\n format.html { redirect_to @historial, notice: 'Historial was successfully created.' }\n format.json { render :show, status: :created, location: @historial }\n else\n format.html { render :new }\n format.json { render json: @historial.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @education_entry = EducationEntry.new(education_entry_params)\n\n respond_to do |format|\n if @education_entry.save\n format.html { redirect_to @education_entry, notice: 'Education entry was successfully created.' }\n format.json { render action: 'show', status: :created, location: @education_entry }\n else\n format.html { render action: 'new' }\n format.json { render json: @education_entry.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @examination = Examination.new(params[:examination])\n respond_to do |format|\n if @examination.save\n format.html { redirect_to @examination, notice: 'Examination was successfully created.' }\n format.json { render json: @examination, status: :created, location: @examination }\n else\n format.html { render action: \"new\" }\n format.json { render json: @examination.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @designation = Designation.new(params[:designation])\n\n respond_to do |format|\n if @designation.save\n format.html { redirect_to designations_path, notice: 'Designation was successfully created.' }\n format.json { render json: @designation, status: :created, location: @designation }\n else\n format.html { render action: \"new\" }\n format.json { render json: @designation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @appreciation = Appreciation.new(appreciation_params)\n\n respond_to do |format|\n if @appreciation.save \n @appreciation.parse\n \n format.html { redirect_to @appreciation, notice: 'Appreciation was successfully created.' }\n format.json { render :show, status: :created, location: @appreciation }\n else\n format.html { render :new }\n format.json { render json: @appreciation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @regulatory = Regulatory.new(regulatory_params)\n\n respond_to do |format|\n if @regulatory.save\n format.html { redirect_to @regulatory, notice: 'Regulatory was successfully created.' }\n format.json { render action: 'show', status: :created, location: @regulatory }\n else\n format.html { render action: 'new' }\n format.json { render json: @regulatory.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n if !params[\"edu_history\"].blank?\n params[\"edu_history\"].each do |edu|\n if edu[\"name\"] != \"\"\n @education = Education.create(education_params(edu))\n @education.user_id = current_user.id\n @education.save\n end\n end\n else\n @education = Education.new(education_params(params[\"education\"]))\n @education.user_id = current_user.id\n @education.save\n\n end\n @email = current_user.profile.official_email.split(\"@\").first\n respond_to do |format|\n if params[:caller] == 'reg'\n format.html { redirect_to '/registeration_steps?step=3&name='+ @email}\n else\n format.html { redirect_to educations_url, notice: 'Education ....' }\n end\n format.json { head :no_content }\n format.js\n end\n end",
"def create\n @information = Information.new(information_params)\n\n if @information.save\n render json: :ok\n else\n render json: @information.errors, status: :unprocessable_entity\n end\n end",
"def create\n @beautician = Beautician.new(beautician_params)\n\n respond_to do |format|\n if @beautician.save\n format.html { redirect_to @beautician, notice: 'Beautician was successfully created.' }\n format.json { render :show, status: :created, location: @beautician }\n else\n format.html { render :new }\n format.json { render json: @beautician.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @undergraduate_major = UndergraduateMajor.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @undergraduate_major }\n end\n end",
"def create\n @knowledge = Knowledge.new(knowledge_params)\n\n respond_to do |format|\n if @knowledge.save\n format.html { redirect_to knowledges_path , notice: 'Área do conhecimento cadastrada com sucesso.' }\n format.json { render :show, status: :created, location: @knowledge }\n else\n format.html { render :new }\n format.json { render json: @knowledge.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @assembly_guide = AssemblyGuide.new(params[:assembly_guide])\n\n respond_to do |format|\n if @assembly_guide.save\n format.html { redirect_to @assembly_guide, notice: 'Assembly guide was successfully created.' }\n format.json { render json: @assembly_guide, status: :created, location: @assembly_guide }\n else\n format.html { render action: \"new\" }\n format.json { render json: @assembly_guide.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @informations = Information.order('created_at desc')\n @information = Information.new(information_params)\n\n respond_to do |format|\n if @information.save\n format.html { redirect_to kegiatan_path, notice: 'Information was successfully created.' }\n format.json { render :show, status: :created, location: @information }\n else\n format.html { render :new }\n format.json { render json: @information.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @frais_annex = FraisAnnex.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @frais_annex }\n end\n end",
"def new\n @institution = Institution.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @institution }\n end\n end",
"def create\n @institution = Institution.new(params[:institution])\n\n respond_to do |format|\n if @institution.save\n format.html { redirect_to @institution, notice: 'Institution was successfully created.' }\n format.json { render json: @institution, status: :created, location: @institution }\n else\n format.html { render action: \"new\" }\n format.json { render json: @institution.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @institution = Institution.new(params[:institution])\n\n respond_to do |format|\n if @institution.save\n format.html { redirect_to @institution, notice: 'Institution was successfully created.' }\n format.json { render json: @institution, status: :created, location: @institution }\n else\n format.html { render action: \"new\" }\n format.json { render json: @institution.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\r\n @attestation = Attestation.new(params[:attestation])\r\n\r\n respond_to do |format|\r\n if @attestation.save\r\n format.html { redirect_to @attestation, notice: 'Attestation was successfully created.' }\r\n format.json { render json: @attestation, status: :created, location: @attestation }\r\n else\r\n format.html { render action: \"new\" }\r\n format.json { render json: @attestation.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def create\n @knowledge = current_user.knowledges.new(params[:knowledge])\n\n respond_to do |format|\n if @knowledge.save\n format.html { redirect_to @knowledge, notice: 'Knowledge was successfully created.' }\n format.json { render json: @knowledge, status: :created, location: @knowledge }\n else\n format.html { render action: \"new\" }\n format.json { render json: @knowledge.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @designation = Designation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @designation }\n end\n end",
"def new\n @laboratory = Laboratory.new\n @municipalities = Municipality.all\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @laboratory }\n end\n end",
"def new\n @guide = Guide.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @guide.as_json(:root => true) }\n end\n end",
"def new\n @institution_ad = InstitutionAd.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @institution_ad }\n end\n end",
"def new\n @assist = Assist.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @assist }\n end\n end",
"def create\n @cms_affiliation = Cms::Affiliation.new(cms_affiliation_params)\n\n respond_to do |format|\n if @cms_affiliation.save\n format.html { redirect_to @cms_affiliation, notice: 'Affiliation was successfully created.' }\n format.json { render :show, status: :created, location: @cms_affiliation }\n else\n format.html { render :new }\n format.json { render json: @cms_affiliation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @informacao = Informacao.new(informacao_params)\n\n respond_to do |format|\n if @informacao.save\n format.html { redirect_to @informacao, notice: 'Informacao was successfully created.' }\n format.json { render action: 'show', status: :created, location: @informacao }\n else\n format.html { render action: 'new' }\n format.json { render json: @informacao.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @knowledge = Knowledge.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @knowledge }\n end\n end",
"def update\n respond_to do |format|\n if @academic_information.update(academic_information_params)\n format.html { redirect_to @academic_information, notice: 'Academic information was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @academic_information.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @info_practice = InfoPractice.new(info_practice_params)\n\n respond_to do |format|\n if @info_practice.save\n format.html { redirect_to info_practices_url, notice: 'Info practice was successfully created.' }\n format.json { render :show, status: :created, location: @info_practice }\n else\n format.html { render :new }\n format.json { render json: @info_practice.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @freelancer_knowledge = FreelancerKnowledge.new(freelancer_knowledge_params)\n\n respond_to do |format|\n if @freelancer_knowledge.save\n format.html { redirect_to @freelancer_knowledge, notice: 'Freelancer knowledge was successfully created.' }\n format.json { render :show, status: :created, location: @freelancer_knowledge }\n else\n format.html { render :new }\n format.json { render json: @freelancer_knowledge.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @education_program = EducationProgram.new(education_program_params)\n\n respond_to do |format|\n if @education_program.save\n format.html { redirect_to @education_program, notice: 'Education program was successfully created.' }\n format.json { render :show, status: :created, location: @education_program }\n else\n format.html { render :new }\n format.json { render json: @education_program.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @academic_unit = AcademicUnit.new(academic_unit_params)\n\n respond_to do |format|\n if @academic_unit.save\n format.html { redirect_to @academic_unit, notice: 'Academic unit was successfully created.' }\n format.json { render :show, status: :created, location: @academic_unit }\n else\n format.html { render :new }\n format.json { render json: @academic_unit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @institution = Institution.new(params[:institution])\n @institution.parametres_cabinet_id = current_user.parametres_cabinet.id\n respond_to do |format|\n if @institution.save\n format.html { redirect_to(@institution, :notice => 'Institution was successfully created.') }\n format.xml { render :xml => @institution, :status => :created, :location => @institution }\n format.json {render :json => {\"success\"=>true,\"data\"=>@institutions} }\n \n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @institution.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def assoziation_params\n params.require(:assoziation).permit(:code, :instructor, :category_id, :courseofstudy_id, :lecture_id)\n end",
"def create\n @institution_ad = InstitutionAd.new(params[:institution_ad])\n\n respond_to do |format|\n if @institution_ad.save\n format.html { redirect_to ([:administrator, @institution_ad]), notice: 'Institution ad was successfully created.' }\n format.json { render json: @institution_ad, status: :created, location: @institution_ad }\n else\n format.html { render action: \"new\" }\n format.json { render json: @institution_ad.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @knowledge = current_user.knowledges.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @knowledge }\n end\n end",
"def create\n @institution = Institution.new(institution_params)\n\n respond_to do |format|\n if @institution.save\n format.html { redirect_to @institution, notice: 'Instituição cadastrada com sucesso.' }\n format.json { render :show, status: :created, location: @institution }\n else\n format.html { render :new }\n format.json { render json: @institution.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @learning = Learning.new(learning_params)\n\n respond_to do |format|\n if @learning.save\n format.html { redirect_to @learning, notice: 'Learning was successfully created.' }\n format.json { render :show, status: :created, location: @learning }\n else\n format.html { render :new }\n format.json { render json: @learning.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @anticipation = Anticipation.new(anticipation_params)\n\n respond_to do |format|\n if @anticipation.save\n format.html { redirect_to @anticipation, notice: 'Anticipation was successfully created.' }\n format.json { render :show, status: :created, location: @anticipation }\n else\n format.html { render :new }\n format.json { render json: @anticipation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @infection = Infection.new(infection_params)\n\n respond_to do |format|\n if @infection.save\n format.html { redirect_to @infection, notice: 'Infection was successfully created.' }\n format.json { render :show, status: :created, location: @infection }\n else\n format.html { render :new }\n format.json { render json: @infection.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @analysis = Analysis.new\n\n respond_to do |format|\n format.html\n format.json { render json: @analysis }\n end\n end",
"def create\n @analysis = current_user.analyses.new(analysis_params)\n\n respond_to do |format|\n if @analysis.save\n format.html { redirect_to @analysis, notice: 'Analysis was successfully created.' }\n format.json { render action: 'show', status: :created, location: @analysis }\n else\n format.html { render action: 'new' }\n format.json { render json: @analysis.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\n @anuncio = Anuncio.new(anuncio_params)\n\n if @anuncio.save\n render :show, status: :created, location: @anuncio\n else\n render json: @anuncio.errors, status: :unprocessable_entity\n end\n end",
"def new\n @research_appointment = ResearchAppointment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @research_appointment }\n end\n end",
"def create\n @climber_education = ClimberEducation.new(climber_education_params)\n\n respond_to do |format|\n if @climber_education.save\n format.html { redirect_to @climber_education, notice: 'Climber education was successfully created.' }\n format.json { render :show, status: :created, location: @climber_education }\n else\n format.html { render :new }\n format.json { render json: @climber_education.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @attendence_info = AttendenceInfo.new(attendence_info_params)\n\n respond_to do |format|\n if @attendence_info.save\n format.html { redirect_to @attendence_info, notice: 'Attendence info was successfully created.' }\n format.json { render :show, status: :created, location: @attendence_info }\n else\n format.html { render :new }\n format.json { render json: @attendence_info.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @affiliation = Affiliation.new(affiliation_params)\n\n respond_to do |format|\n if @affiliation.save\n format.html { redirect_to :back }\n #format.json { render :show, status: :created, location: @affiliation }\n else\n format.html { redirect_to :back }\n #format.json { render json: @affiliation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @intention = Intention.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @intention }\n end\n end",
"def create\n @academia = Academia.new(academia_params)\n\n respond_to do |format|\n if @academia.save\n format.html { redirect_to @academia, notice: 'Academia was successfully created.' }\n format.json { render :show, status: :created, location: @academia }\n else\n format.html { render :new }\n format.json { render json: @academia.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @learn = Learn.new(params[:learn])\n\n respond_to do |format|\n if @learn.save\n format.html { redirect_to @learn, notice: 'Learn was successfully created.' }\n format.json { render json: @learn, status: :created, location: @learn }\n else\n format.html { render action: \"new\" }\n format.json { render json: @learn.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @educations = Education.all\n render json: @educations\n end",
"def create\n @laboratory = Laboratory.new(params[:laboratory])\n @municipalities = Municipality.all\n respond_to do |format|\n if @laboratory.save\n format.html { redirect_to @laboratory, notice: 'Laboratory was successfully created.' }\n format.json { render json: @laboratory, status: :created, location: @laboratory }\n else\n format.html { render action: \"new\" }\n format.json { render json: @laboratory.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @alumni = Alumni.new(alumni_params)\n @alumni.grad_semester = Alumni.grad_semester(params[:grad_season], params[:grad_year])\n # params[:grad_season] is Spring or Fall\n # params[:grad_year] is the actual year\n # This is so hacky. grad_season and grad_year are separate from the\n # other Alumni attributes when we're processing the form input because\n # it would be silly to have grad_season, grad_year, and grad_semester\n # when grad_semester is just the concatenation of grad_season and grad_year.\n # Similar funny business in update.\n respond_to do |format|\n if @alumni.save and @current_user.save\n # TODO: Actually subscribe them to the mailing list through Google Apps\n #if @alumni.mailing_list\n #end\n\n format.html { redirect_to(@alumni, notice: 'Alumni was successfully created.') }\n format.xml { render xml: @alumni, status: :created, location: @alumni }\n else\n format.html { render action: \"new\" }\n format.xml { render xml: @alumni.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @admitting = Admitting.new(admitting_params)\n\n if @admitting.save\n render json: @admitting, status: :created, location: @admitting\n else\n render json: @admitting.errors, status: :unprocessable_entity\n end\n end"
] |
[
"0.65599",
"0.6471721",
"0.6466419",
"0.64598775",
"0.6459526",
"0.63923293",
"0.6364742",
"0.63430816",
"0.62972397",
"0.6289171",
"0.62624806",
"0.62569124",
"0.62409043",
"0.6226442",
"0.6211132",
"0.6203712",
"0.62025344",
"0.6106263",
"0.60670465",
"0.6022282",
"0.602103",
"0.601703",
"0.60156375",
"0.60133797",
"0.6006148",
"0.5999512",
"0.5989264",
"0.5987653",
"0.5982796",
"0.596828",
"0.5946527",
"0.5937655",
"0.59308964",
"0.59186023",
"0.59163076",
"0.5912028",
"0.5909962",
"0.5908291",
"0.5900099",
"0.58981663",
"0.58962864",
"0.5889324",
"0.58815295",
"0.5879743",
"0.58793527",
"0.58792734",
"0.587815",
"0.5872893",
"0.5869887",
"0.58683485",
"0.5866103",
"0.5865263",
"0.5862257",
"0.5859754",
"0.58592546",
"0.5857564",
"0.58569753",
"0.5852959",
"0.5848067",
"0.5846618",
"0.58430594",
"0.5834106",
"0.5834106",
"0.58339363",
"0.5830721",
"0.5827775",
"0.5826678",
"0.58262336",
"0.5817114",
"0.58126056",
"0.5810167",
"0.58084464",
"0.5802827",
"0.58019155",
"0.5785801",
"0.57788146",
"0.57781184",
"0.5776623",
"0.57732815",
"0.57703495",
"0.5770236",
"0.5764686",
"0.5762832",
"0.5762794",
"0.57592666",
"0.57588893",
"0.5755134",
"0.5751403",
"0.57508266",
"0.5747555",
"0.5746616",
"0.5744238",
"0.5742542",
"0.57383573",
"0.57347476",
"0.57336324",
"0.57319444",
"0.5727778",
"0.5727625",
"0.57249534"
] |
0.61950046
|
17
|
PATCH/PUT /academic_informations/1 PATCH/PUT /academic_informations/1.json
|
def update
respond_to do |format|
if @academic_information.update(academic_information_params)
format.html { redirect_to @academic_information, notice: 'Academic information was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: 'edit' }
format.json { render json: @academic_information.errors, status: :unprocessable_entity }
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def update\n @initiative = Initiative.find(params[:id])\n \n respond_to do |format|\n if @initiative.update_attributes(params[:initiative])\n \n format.html { redirect_to @initiative, notice: 'Initiative was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @initiative.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @api_v1_initiative.update(api_v1_initiative_params)\n format.html { redirect_to @api_v1_initiative, notice: 'Initiative was successfully updated.' }\n format.json { render :show, status: :ok, location: @api_v1_initiative }\n else\n format.html { render :edit }\n format.json { render json: @api_v1_initiative.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\r\n @academic_work = AcademicWork.find(params[:id])\r\n\r\n respond_to do |format|\r\n if @academic_work.update_attributes(params[:academic_work])\r\n format.html { redirect_to @academic_work, notice: 'Academic work was successfully updated.' }\r\n format.json { head :no_content }\r\n else\r\n format.html { render action: \"edit\" }\r\n format.json { render json: @academic_work.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def update\n respond_to do |format|\n if @api_v1_initiative_update.update(api_v1_initiative_update_params)\n format.html { redirect_to @api_v1_initiative_update, notice: 'Initiative update was successfully updated.' }\n format.json { render :show, status: :ok, location: @api_v1_initiative_update }\n else\n format.html { render :edit }\n format.json { render json: @api_v1_initiative_update.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @assessment_info.update(assessment_info_params)\n format.html { redirect_to edit_concept_url(@assessment_info.concept_id), notice: 'assessment_info was successfully updated.' }\n format.json { render :show, status: :ok, location: @assessment_info }\n else\n format.html { render :edit }\n format.json { render json: @assessment_info.errors, status: :unprocessable_entity }\n end\n end\nend",
"def update\n\n @laboratory = Laboratory.find(params[:id])\n\n if @laboratory.update!(laboratory_params)\n render json: @laboratory\n else \n render json: @laboratory.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @formulary.update(formulary_params)\n format.html { redirect_to formularies_url, alert: I18n.t('activerecord.models.formulary') + I18n.t('helpers_locale.models.updated') }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @formulary.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @analyst = Analyst.find(params[:id])\n\n if @analyst.update(params[:analyst])\n head :no_content\n else\n render json: @analyst.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @analise.update(analise_params)\n format.html { redirect_to @analise, notice: 'Analisis was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @analise.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @academic_work.update(academic_work_params)\n format.html { redirect_to @academic_work, notice: t('notice.updated') }\n format.json { render :show, status: :ok, location: @academic_work }\n else\n format.html { render :edit }\n format.json { render json: @academic_work.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n official = Official.find(params[:id])\n if official.update(official_params)\n render json: official, status: 200, location: [:api, official]\n else\n failed_to_update(official, \"official\")\n end\n end",
"def update\n\n @foaf.interests.clear\n\n if(foaf_params.has_key?(:interests_attributes))\n interest_ids = foaf_params[:interests_attributes].split(\",\").map { |s| s.to_i }\n interest_ids.each do |i|\n @foaf.interests << Interest.find(i)\n #@foaf.update(Interest.find(i))\n end\n \n end\n\n respond_to do |format|\n if @foaf.update(name: foaf_params[:name], work: foaf_params[:work], \n slug: foaf_params[:slug], birthday: foaf_params[:birthday])\n format.html { redirect_to @foaf, notice: 'Foaf was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @foaf.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @formulary = Formulary.find(params[:id])\n\n respond_to do |format|\n if @formulary.update_attributes(params[:formulary])\n format.html { redirect_to @formulary, notice: 'Formulario actualizado exitosamente.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @formulary.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @education.update(education_params)\n render :show, status: :ok, location: @education\n else\n render json: @education.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @climber_education.update(climber_education_params)\n format.html { redirect_to @climber_education, notice: 'Climber education was successfully updated.' }\n format.json { render :show, status: :ok, location: @climber_education }\n else\n format.html { render :edit }\n format.json { render json: @climber_education.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @research = Research.find(params[:id])\n\n respond_to do |format|\n if @research.update_attributes(params[:research])\n format.html { redirect_to @research, notice: 'Research was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @research.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @academic_degree.update(academic_degree_params)\n format.html { redirect_to '/maestricos/prueba?titulo=Grado+Academico&tabla=AcademicDegree' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @academic_degree.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @education_accomplishment.update(education_accomplishment_params)\n format.html { redirect_to @education_accomplishment, notice: 'Education accomplishment was successfully updated.' }\n format.json { render :show, status: :ok, location: @education_accomplishment }\n else\n format.html { render :edit }\n format.json { render json: @education_accomplishment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\n @foaf.interests.clear\n\n if(foaf_params.has_key?(:interests_attributes))\n interest_ids = foaf_params[:interests_attributes].split(\",\").map { |s| s.to_i }\n interest_ids.each do |i|\n @foaf.interests << Interest.find(i)\n #@foaf.update(Interest.find(i))\n end\n \n end\n\n respond_to do |format|\n if @foaf.update(name: foaf_params[:name], work: foaf_params[:work], \n slug: foaf_params[:slug], birthday: foaf_params[:birthday])\n format.html { redirect_to @foaf, notice: 'FOAF was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @foaf.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @research_appointment = ResearchAppointment.find(params[:id])\n\n respond_to do |format|\n if @research_appointment.update_attributes(params[:research_appointment])\n format.html { redirect_to @research_appointment, notice: 'Research appointment was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @research_appointment.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 @indication_for_meal.update(indication_for_meal_params)\n format.html { redirect_to @indication_for_meal, notice: 'Indication for meal was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @indication_for_meal.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @asformulary.update(asformulary_params)\n format.html { redirect_to @asformulary, notice: 'Asformulary was successfully updated.' }\n format.json { render :show, status: :ok, location: @asformulary }\n else\n format.html { render :edit }\n format.json { render json: @asformulary.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @regulatory.update(regulatory_params)\n format.html { redirect_to @regulatory, notice: 'Regulatory was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @regulatory.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @education.update(education_params)\n format.html { redirect_to @education, notice: \"Education was successfully updated.\" }\n format.json { render :show, status: :ok, location: @education }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @education.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @persona = Persona.find(params[:id])\n \n respond_to do |format|\n if @persona.update_attributes(params[:persona])\n format.json { head :ok }\n else\n format.json { render :json => @persona.errors,\n :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @oferta_academica = OfertaAcademica.find(params[:id])\n\n if @oferta_academica.update(params[:oferta_academica])\n head :no_content\n else\n render json: @oferta_academica.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @education_service_provided_typology.update(education_service_provided_typology_params)\n format.html { redirect_to @education_service_provided_typology, notice: 'Education service provided typology was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @education_service_provided_typology.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @education_detail.update(education_detail_params)\n format.html { redirect_to @education_detail, notice: 'Education detail was successfully updated.' }\n format.json { render :show, status: :ok, location: @education_detail }\n else\n format.html { render :edit }\n format.json { render json: @education_detail.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @avaliation.update(avaliation_params)\n format.html { redirect_to @avaliation, notice: 'Avaliation was successfully updated.' }\n format.json { render :show, status: :ok, location: @avaliation }\n else\n format.html { render :edit }\n format.json { render json: @avaliation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @familiar = Familiar.find(params[:id])\n\n respond_to do |format|\n if @familiar.update_attributes(params[:familiar])\n format.html { redirect_to @familiar, notice: 'Familiar was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @familiar.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @major.update(major_params)\n format.html { redirect_to @major, notice: 'Major was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @major.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @academic_focus = AcademicFocus.find(params[:id])\n\n respond_to do |format|\n if @academic_focus.update_attributes(params[:academic_focus])\n format.html { redirect_to(@academic_focus, :notice => 'Academic focu was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @academic_focus.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @education_entry.update(education_entry_params)\n format.html { redirect_to @education_entry, notice: 'Education entry was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @education_entry.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @interesting = Interesting.find(params[:id])\n\n respond_to do |format|\n if @interesting.update_attributes(params[:interesting])\n format.html { redirect_to @interesting, notice: 'Interesting was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @interesting.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @conceptual_entity = ConceptualEntity.find(params[:id])\n\n respond_to do |format|\n if @conceptual_entity.update_attributes(params[:conceptual_entity])\n format.html { redirect_to @conceptual_entity, notice: 'Conceptual entity was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @conceptual_entity.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n logger.info('PUT Update:')\n logger.info(request_body)\n new_pub = hashed_request\n old_pub = Publication.find_by(id: params[:id])\n if old_pub.blank?\n head :not_found\n return\n elsif old_pub.deleted?\n head :gone\n return\n end\n if old_pub.harvested_pub? # only manually entered (i.e. non-harvested) publications may be updated with this method\n render json: {\n error: \"This record SulPubID #{old_pub.id} may not be modified. If you had originally entered details for the record, \" \\\n 'it has been superceded by a central record.'\n },\n status: :forbidden, format: 'json'\n return\n elsif !validate_or_create_authors(new_pub[:authorship])\n render json: { error: 'You have not supplied a valid authorship record.' }, status: :not_acceptable,\n format: 'json'\n return\n end\n logger.info(\"Update manual publication #{old_pub.inspect} with BibJSON:\")\n logger.info(request_body)\n old_pub.update_manual_pub_from_pub_hash(new_pub, request_body)\n old_pub.save!\n old_pub.reload\n logger.debug(\"resulting pub hash: #{old_pub.pub_hash}\")\n render json: old_pub.pub_hash, status: :accepted\n end",
"def update\n respond_to do |format|\n if @model_acronym.update(model_acronym_params)\n format.html { redirect_to @model_acronym, notice: 'Model acronym was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @model_acronym.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @fundamental_announcement = Fundamental::Announcement.find(params[:id])\n\n respond_to do |format|\n if @fundamental_announcement.update_attributes(params[:fundamental_announcement])\n format.html { redirect_to @fundamental_announcement, notice: 'Announcement was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @fundamental_announcement.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @afformation.update(afformation_params)\n format.html { redirect_to afformations_url, notice: 'Afformation was successfully updated.' }\n format.json { render :index, status: :ok, location: @afformations }\n else\n format.html { render :edit }\n format.json { render json: @afformation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @relation_industry.update(relation_industry_params)\n format.html { redirect_to @relation_industry, notice: 'Relation industry was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @relation_industry.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @expertise = Expertise.find(params[:id])\n\n if @expertise.update(expertise_params)\n head :no_content\n else\n render json: @expertise.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @education_program.update(education_program_params)\n format.html { redirect_to @education_program, notice: 'Education program was successfully updated.' }\n format.json { render :show, status: :ok, location: @education_program }\n else\n format.html { render :edit }\n format.json { render json: @education_program.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @anniversary = Anniversary.find(params[:id])\n\n respond_to do |format|\n if @anniversary.update_attributes(params[:anniversary])\n format.html { redirect_to @anniversary, notice: 'Anniversary was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @anniversary.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @formality.update(formality_params)\n format.html { redirect_to @formality, notice: 'Formality was successfully updated.' }\n format.json { render :show, status: :ok, location: @formality }\n else\n format.html { render :edit }\n format.json { render json: @formality.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n # { clinic: {id: references, \"license_id\"=>nil, \"name\"=>string } }\n \n if @clinic.update_attributes(params[:clinic].except(:api_license_id))\n head :no_content\n else\n render json: clinic.errors.full_messages, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @appraisal_fee.update(appraisal_fee_params)\n format.html { redirect_to appraisal_fees_path, notice: 'Appraisal fee was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @appraisal_fee.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @api_v1_initiative_field.update(api_v1_initiative_field_params)\n format.html { redirect_to @api_v1_initiative_field, notice: 'Initiative field was successfully updated.' }\n format.json { render :show, status: :ok, location: @api_v1_initiative_field }\n else\n format.html { render :edit }\n format.json { render json: @api_v1_initiative_field.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @major = Major.find(params[:id])\n\n respond_to do |format|\n if @major.update_attributes(params[:major])\n format.html { redirect_to @major, notice: 'Major was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @major.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @analise.update(analise_params)\n format.html { redirect_to @analise, notice: 'Analise was successfully updated.' }\n format.json { render :show, status: :ok, location: @analise }\n else\n format.html { render :edit }\n format.json { render json: @analise.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @appraisal_model.update(appraisal_model_params)\n format.html { redirect_to @appraisal_model, notice: 'Appraisal model was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @appraisal_model.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @concept.update(concept_params)\n format.html { redirect_to @concept, notice: 'Concept was successfully updated.' }\n format.json { render :show, status: :ok, location: @concept }\n else\n format.html { render :edit }\n format.json { render json: @concept.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @employ = Employ.find(params[:id])\n\n respond_to do |format|\n if @employ.update_attributes(params[:employ])\n format.html { redirect_to @employ, notice: 'Employ was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @employ.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @concept = Concept.find(params[:id])\n\n respond_to do |format|\n if @concept.update_attributes(params[:concept])\n format.html { redirect_to @concept, notice: 'Concept was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @concept.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @concept = Concept.find(params[:id])\n\n respond_to do |format|\n if @concept.update_attributes(params[:concept])\n format.html { redirect_to @concept, notice: 'Concept was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @concept.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @loanformulary.update(loanformulary_params)\n format.html { redirect_to @loanformulary, notice: 'Loanformulary was successfully updated.' }\n format.json { render :show, status: :ok, location: @loanformulary }\n else\n format.html { render :edit }\n format.json { render json: @loanformulary.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @icome = Icome.find(params[:id])\n\n respond_to do |format|\n if @icome.update_attributes(params[:icome])\n format.html { redirect_to @icome, notice: 'Icome was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @icome.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @yearly_info.update(yearly_info_params)\n format.html { redirect_to @yearly_info, notice: 'Yearly info was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @yearly_info.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @employment = Employment.find(params[:id])\n\n respond_to do |format|\n if @employment.update_attributes(params[:employment])\n format.html { redirect_to @employment, notice: 'Employment was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @employment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n authorize! :edit, @questionnaire\n\n @questionnaire.load_JSON(params[:questionnaire], current_user)\n\n respond_to do |format|\n# if @questionnaire.update_attributes(params[:questionnaire])\n format.html { redirect_to @questionnaire, notice: 'Kysymyslomakkeen muokkaaminen onnistui.' }\n format.json { head :no_content }\n# else\n# format.html { render action: \"edit\" }\n# format.json { render json: @questionnaire.errors, status: :unprocessable_entity }\n# end\n\n end\n end",
"def update\n respond_to do |format|\n if @knowledge.update(knowledge_params)\n format.html { redirect_to knowledges_path, notice: 'Knowledge was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @knowledge.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @callout.update(callout_params)\n format.html { redirect_to @callout, notice: 'Callout was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @callout.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @guide_taxon.update(params[:guide_taxon])\n format.html { redirect_to @guide_taxon, notice: 'Guide taxon was successfully updated.' }\n format.json { render :json => @guide_taxon.as_json(:root => true, :methods => [:html]) }\n else\n format.html do\n load_data_for_edit\n render action: \"edit\"\n end\n format.json { render json: @guide_taxon.errors.full_messages, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @exam.update(exam_params)\n format.html { redirect_to @exam, notice: 'Exam was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @exam.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @informe = Informe.find(params[:id])\n\n respond_to do |format|\n if @informe.update_attributes(params[:informe])\n format.html { redirect_to @informe, notice: 'Informe was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @informe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @learn = Learn.find(params[:id])\n\n respond_to do |format|\n if @learn.update_attributes(params[:learn])\n format.html { redirect_to @learn, notice: 'Learn was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @learn.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @applicant_field_of_study.update(applicant_field_of_study_params)\n format.html { redirect_to applicant_field_of_studies_url, notice: 'Applicant field of study was successfully updated.' }\n format.json { render :show, status: :ok, location: @applicant_field_of_study }\n else\n format.html { render :edit }\n format.json { render json: @applicant_field_of_study.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @assembly_guide = AssemblyGuide.find(params[:id])\n\n respond_to do |format|\n if @assembly_guide.update_attributes(params[:assembly_guide])\n format.html { redirect_to @assembly_guide, notice: 'Assembly guide was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @assembly_guide.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @alumni = Alumni.find(params[:id])\n\n respond_to do |format|\n if @alumni.update_attributes(params[:alumni])\n format.html { redirect_to @alumni, notice: 'Alumni was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @alumni.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @explaination = Explaination.find(params[:id])\n\n respond_to do |format|\n if @explaination.update_attributes(params[:explaination])\n format.html { redirect_to @explaination, notice: 'Explaination was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @explaination.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @editorial.update(editorial_params)\n format.html { redirect_to @editorial, notice: 'Article was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @editorial.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @undergraduate_major = UndergraduateMajor.find(params[:id])\n\n respond_to do |format|\n if @undergraduate_major.update_attributes(params[:undergraduate_major])\n format.html { redirect_to @undergraduate_major, notice: 'Undergraduate major was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @undergraduate_major.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @formalizacao.update(formalizacao_params)\n format.html { redirect_to @formalizacao, notice: 'Formalizacao was successfully updated.' }\n format.json { render :show, status: :ok, location: @formalizacao }\n else\n format.html { render :edit }\n format.json { render json: @formalizacao.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @fascicle.update(fascicle_params)\n format.html { redirect_to @fascicle, notice: 'Fascicle was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @fascicle.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @exam = Exam.find(params[:id])\n\n respond_to do |format|\n if @exam.update_attributes(params[:exam])\n format.html { redirect_to @exam, notice: 'Exam was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @exam.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @person = Person.find(params[:id])\n\n populate_attributes(@person, params[:person])\n respond_to do |format|\n \n if @person.save && @person.identifiable_entries.each(&:save!)\n format.html { redirect_to @person, notice: 'Person was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @person.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @alumno = Alumno.find(params[:id])\n\n respond_to do |format|\n if @alumno.update_attributes(params[:alumno])\n head :no_content\n else\n render json: @alumno.errors, status: :unprocessable_entity\n end\n end\n end",
"def update\n @familium = Familium.find(params[:id])\n\n respond_to do |format|\n if @familium.update_attributes(params[:familium])\n format.html { redirect_to @familium, notice: 'Familia fue actualizada existosamente.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @familium.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @education = Education.where(:resource_id => current_user.id, :id => params[:id]).first\n\n respond_to do |format|\n if @education.update_attributes(params[:education])\n format.html { redirect_to(@education, :notice => 'Education was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @education.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n debugger\n if @best_practice.update(best_practice_params)\n format.html { redirect_to @best_practice, notice: 'Best practice was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @best_practice.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @my_exam = MyExam.find(params[:id])\n\n respond_to do |format|\n if @my_exam.update_attributes(params[:my_exam])\n format.html { redirect_to @my_exam, notice: 'My exam was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @my_exam.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n #debugger\n if @enrollment.update(update_params)\n head :no_content\n else\n render json: @enrollment.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @thesis_examination.update(thesis_examination_params)\n format.html { redirect_to @thesis_examination, notice: 'Thesis examination was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @thesis_examination.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @university = UniversityDecorator.decorate @employer_study.university\n respond_to do |format|\n if @employer_study.update_attributes(params[:employer_study])\n format.html { redirect_to @employer_study, notice: t2('update.notice') }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @employer_study.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @office_career.update(office_career_params)\n head :no_content\n end",
"def update\n render json: Company.update(params[\"id\"], params[\"company\"])\n end",
"def update\n respond_to do |format|\n if @major.update(major_params)\n format.html { redirect_to @major, notice: 'Major was successfully updated.' }\n format.json { render :show, status: :ok, location: @major }\n else\n format.html { render :edit }\n format.json { render json: @major.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @requisition = Requisition.find(params[:id])\n\n respond_to do |format|\n if @requisition.update_attributes(params[:requisition])\n format.html { redirect_to @requisition, notice: 'Requisition was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @requisition.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @specification = Specification.find(params[:id])\n\n respond_to do |format|\n if @specification.update_attributes(params[:specification])\n format.html { redirect_to @specification, notice: 'Specification was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @specification.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @exam = Exam.find(params[:id])\n\n respond_to do |format|\n if @exam.update_attributes(params[:exam])\n format.html { redirect_to exams_path, notice: 'Exam was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @exam.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @experiment_biomechanical = ExperimentBiomechanical.find(params[:id])\n\n respond_to do |format|\n if @experiment_biomechanical.update_attributes(params[:experiment_biomechanical])\n format.html { redirect_to @experiment_biomechanical, notice: 'Experiment biomechanical was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @experiment_biomechanical.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @taxon_determination.update(taxon_determination_params)\n format.html { redirect_to @taxon_determination, notice: 'Taxon determination was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @taxon_determination.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @documentation.update(documentation_params)\n format.html { redirect_to @documentation, notice: 'Documentation was successfully updated.' }\n format.json { render :show, status: :ok, location: @documentation }\n else\n format.html { render :edit }\n format.json { render json: @documentation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @medical.update(medical_params)\n format.html { redirect_to @medical, notice: 'Medical was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @medical.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n # respond_to do |format|\n # if @attention.update(attention_params)\n # format.html { redirect_to @attention, notice: 'Attention was successfully updated.' }\n # format.json { render :show, status: :ok, location: @attention }\n # else\n # format.html { render :edit }\n # format.json { render json: @attention.errors, status: :unprocessable_entity }\n # end\n # end\n end",
"def update\n @knowledge = Knowledge.find(params[:id])\n\n respond_to do |format|\n if @knowledge.update_attributes(params[:knowledge])\n format.html { redirect_to @knowledge, notice: 'Knowledge was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @knowledge.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @college = College.find(params[:id])\n\n respond_to do |format|\n if @college.update_attributes(params[:college])\n format.html { redirect_to '/colleges', notice: 'College was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @college.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @uni_major = UniMajor.find(params[:id])\n\n respond_to do |format|\n if @uni_major.update_attributes(params[:uni_major])\n format.html { redirect_to @uni_major, notice: 'Uni major was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @uni_major.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @persona = Persona.find(params[:id])\n\n respond_to do |format|\n if @persona.update_attributes(params[:persona])\n format.html { redirect_to personas_path, notice: 'Persona was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @persona.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @referent.update(referent_params)\n format.html { redirect_to referent_path(@referent, :refId => params[:reforganismId]), notice: 'Referent was successfully updated.'}\n format.json { render :show, status: :ok, location: @referent }\n else\n format.html { render :edit }\n format.json { render json: @referent.errors, status: :unprocessable_entity }\n end\n end\n end"
] |
[
"0.67717165",
"0.67710716",
"0.6747215",
"0.6719126",
"0.66927475",
"0.66288173",
"0.66251254",
"0.66123307",
"0.6592651",
"0.65728956",
"0.6527749",
"0.65249974",
"0.6524159",
"0.6519908",
"0.6508089",
"0.65058064",
"0.6497485",
"0.64962745",
"0.64820474",
"0.64405894",
"0.64400065",
"0.64390016",
"0.6425929",
"0.64190114",
"0.6414749",
"0.64035267",
"0.63954955",
"0.63918805",
"0.6388511",
"0.6383686",
"0.638097",
"0.6379261",
"0.637545",
"0.63648075",
"0.6358821",
"0.6357343",
"0.6351737",
"0.6349579",
"0.63479096",
"0.63454205",
"0.6338719",
"0.6337445",
"0.6325926",
"0.63245445",
"0.63240916",
"0.63196146",
"0.6316109",
"0.63101584",
"0.63057107",
"0.63037336",
"0.6299219",
"0.6294913",
"0.6288447",
"0.62832516",
"0.62832516",
"0.6282645",
"0.62796247",
"0.62769467",
"0.6272736",
"0.6267718",
"0.62655354",
"0.62623525",
"0.62612236",
"0.6260504",
"0.62593484",
"0.6258099",
"0.62573063",
"0.62569815",
"0.62568706",
"0.625555",
"0.6254988",
"0.6250815",
"0.6248497",
"0.62476003",
"0.6246398",
"0.62461793",
"0.62430036",
"0.62424713",
"0.6239186",
"0.6237829",
"0.62377036",
"0.62346387",
"0.6233402",
"0.62320286",
"0.6230292",
"0.6226868",
"0.62260234",
"0.62248755",
"0.6222689",
"0.62212396",
"0.6214906",
"0.6214582",
"0.6213644",
"0.62109023",
"0.6210187",
"0.6208882",
"0.6206819",
"0.6202041",
"0.6201782",
"0.619644"
] |
0.71921223
|
0
|
DELETE /academic_informations/1 DELETE /academic_informations/1.json
|
def destroy
@academic_information.destroy
respond_to do |format|
format.html { redirect_to academic_informations_url }
format.json { head :no_content }
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def destroy\n @education_entry.destroy\n respond_to do |format|\n format.html { redirect_to education_entries_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @academic_degree.destroy\n respond_to do |format|\n format.html { redirect_to '/maestricos/prueba?titulo=Grado+Academico&tabla=AcademicDegree' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @explaination = Explaination.find(params[:id])\n @explaination.destroy\n\n respond_to do |format|\n format.html { redirect_to explainations_url }\n format.json { head :no_content }\n end\n end",
"def delete_analysis(analysis_id); rest_delete(\"#{link('analyses')}/#{analysis_id}\"); nil; end",
"def destroy\n @education_accomplishment.destroy\n respond_to do |format|\n format.html { redirect_to education_accomplishments_url, notice: 'Education accomplishment was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @education_detail.destroy\n respond_to do |format|\n format.html { redirect_to education_details_url, notice: 'Education detail was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @thesis_examination.destroy\n respond_to do |format|\n format.html { redirect_to thesis_examinations_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @assessment_info.destroy\n respond_to do |format|\n format.html { redirect_to edit_concept_url(@assessment_info.concept_id), notice: 'assessment_info was successfully destroyed.' }\n format.json { head :no_content }\n end\nend",
"def destroy\n @climber_education.destroy\n respond_to do |format|\n format.html { redirect_to climber_educations_url, notice: 'Climber education was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @historial = Historial.find(params[:id])\n @historial.destroy\n\n respond_to do |format|\n format.html { redirect_to historials_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @enrollment.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n @education_service_provided_typology.destroy\n respond_to do |format|\n format.html { redirect_to education_service_provided_typologies_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @analise.destroy\n respond_to do |format|\n format.html { redirect_to analises_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @formulary = Formulary.find(params[:id])\n @formulary.destroy\n\n respond_to do |format|\n format.html { redirect_to formularies_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @education.destroy\n respond_to do |format|\n format.html { redirect_to educations_url, notice: \"Education was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @education.destroy\n respond_to do |format|\n format.html { redirect_to educations_url, notice: 'Education was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @education.destroy\n respond_to do |format|\n format.html { redirect_to educations_url, notice: 'Education was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @undergraduate_major = UndergraduateMajor.find(params[:id])\n @undergraduate_major.destroy\n\n respond_to do |format|\n format.html { redirect_to undergraduate_majors_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @api_v1_initiative.destroy\n respond_to do |format|\n format.html { redirect_to api_v1_initiatives_url, notice: 'Initiative was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @research.destroy\n respond_to do |format|\n format.html { redirect_to menu_investigacion_3_path, notice: 'La actividad se elimino con exito.' }\n format.json { head :no_content }\n end\n\n end",
"def destroy\n @api_v1_initiative_update.destroy\n respond_to do |format|\n format.html { redirect_to api_v1_initiative_updates_url, notice: 'Initiative update was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @taxon_determination.destroy\n respond_to do |format|\n format.html { redirect_to taxon_determinations_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n official = Official.find(params[:id])\n official.destroy\n head 204\n end",
"def destroy\r\n @academic_work = AcademicWork.find(params[:id])\r\n @academic_work.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_to academic_works_url }\r\n format.json { head :no_content }\r\n end\r\n end",
"def destroy\n @addimition = Addimition.find(params[:id])\n @addimition.destroy\n\n respond_to do |format|\n format.html { redirect_to addimitions_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @admintreatmentmechanical.destroy\n respond_to do |format|\n format.html { redirect_to admintreatmentmechanicals_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @additional_information.destroy\n respond_to do |format|\n format.html { redirect_to additional_informations_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @academic_unit.destroy\n respond_to do |format|\n format.html { redirect_to academic_units_url, notice: 'Academic unit was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @analise.destroy\n respond_to do |format|\n format.html { redirect_to analises_url, notice: 'Analise was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @admission.destroy\n respond_to do |format|\n format.html { redirect_to admissions_url, notice: 'Admission information was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @assembly_guide = AssemblyGuide.find(params[:id])\n @assembly_guide.destroy\n\n respond_to do |format|\n format.html { redirect_to assembly_guides_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @my_exam = MyExam.find(params[:id])\n @my_exam.destroy\n\n respond_to do |format|\n format.html { redirect_to my_exams_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @exam_category = ExamCategory.find(params[:id])\n @exam_category.destroy\n\n respond_to do |format|\n format.html { redirect_to exam_categories_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @general_information = GeneralInformation.find(params[:id])\n @general_information.destroy\n\n respond_to do |format|\n format.html { redirect_to @general_information.personal_detail }\n format.json { head :no_content }\n end\n end",
"def delete\n render json: Alien.delete(params[\"id\"])\n end",
"def destroy\n @initiative = Initiative.find(params[:id])\n @initiative.destroy\n\n respond_to do |format|\n format.html { render :nothing => true }\n #format.html { redirect_to initiatives_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @accreditation = Accreditation.find(params[:id])\n @accreditation.destroy\n\n respond_to do |format|\n format.html { redirect_to accreditations_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @aki_diagnosis.destroy\n respond_to do |format|\n format.html { redirect_to aki_diagnoses_url, notice: 'Diagnosis aki was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @examination = Examination.find(params[:id])\n @examination.destroy\n\n respond_to do |format|\n format.html { redirect_to examinations_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @datos_personal.destroy\n respond_to do |format|\n format.html { redirect_to datos_personals_url, notice: 'Datos personal was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @advocacy = Advocacy.find(params[:id])\n @advocacy.destroy\n\n respond_to do |format|\n format.html { redirect_to advocacies_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @analysis.destroy\n respond_to do |format|\n format.html { redirect_to analyses_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @personal_info = PersonalInfo.find(params[:id])\n @personal_info.destroy\n\n respond_to do |format|\n format.html { redirect_to personal_info_index_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @initiative = Initiative.find(params[:id])\n @initiative.destroy\n\n respond_to do |format|\n format.html { redirect_to initiatives_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @alumni = Alumni.find(params[:id])\n @alumni.destroy\n\n respond_to do |format|\n format.html { redirect_to alumnis_url }\n format.json { head :no_content }\n end\n end",
"def delete\n @guide = Guide.find(params[:id])\n @guide.destroy\n respond_to do |format|\n format.html { redirect_to guides_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @applicant_field_of_study.destroy\n respond_to do |format|\n format.html { redirect_to applicant_field_of_studies_url, notice: 'Applicant field of study was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @analysis = Analysis.find(params[:id])\n @analysis.destroy\n\n respond_to do |format|\n format.html { redirect_to analyses_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @personal.destroy\n respond_to do |format|\n format.html { redirect_to personals_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @accion.destroy\n respond_to do |format|\n format.html { redirect_to accions_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @hospitalization = Hospitalization.find(params[:id])\n @hospitalization.destroy\n\n respond_to do |format|\n format.html { redirect_to client_hospitalizations_url(@client) }\n format.json { head :ok }\n end\n end",
"def destroy\n @historial.destroy\n respond_to do |format|\n format.html { redirect_to historials_url, notice: 'Historial was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @education_class.destroy\n respond_to do |format|\n format.html { redirect_to education_classes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @fundamental_announcement = Fundamental::Announcement.find(params[:id])\n @fundamental_announcement.destroy\n\n respond_to do |format|\n format.html { redirect_to fundamental_announcements_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @life_insurance.destroy\n\n respond_to do |format|\n format.html { redirect_to life_insurances_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @early_access_request.destroy\n respond_to do |format|\n format.html { redirect_to early_access_requests_url, notice: 'Anfrage wurde gelöscht.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n if @academic_work.destroy\n render json: nil, status: :ok\n else\n render json: nil, status: :internal_server_error\n end\n end",
"def destroy\n @referralmedical.destroy\n respond_to do |format|\n format.html { redirect_to referralmedicals_url, notice: 'Referralmedical was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n respond_to do |format|\n format.html { redirect_to :controller => 'design_data', :action => 'index' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @admission.destroy\n respond_to do |format|\n format.html { redirect_to admissions_url, notice: 'Admission was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @academic_year = AcademicYear.find(params[:id])\n @academic_year.destroy\n\n respond_to do |format|\n format.html { redirect_to(academic_years_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @exam = Exam.find(params[:id])\n @exam.destroy\n\n respond_to do |format|\n format.html { redirect_to exams_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @remission_guide.destroy\n respond_to do |format|\n format.html { \n flash[:notice] = 'La Guía de Remisión se eliminó satisfactoriamente.'\n redirect_to remission_guides_path\n }\n format.json { head :no_content }\n end\n end",
"def destroy\n @familium = Familium.find(params[:id])\n @familium.destroy\n\n respond_to do |format|\n format.html { redirect_to familia_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @colaboration = Colaboration.find(params[:id])\n @colaboration.destroy\n\n respond_to do |format|\n format.html { redirect_to colaborations_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @incarnation.destroy\n respond_to do |format|\n format.html { redirect_to incarnations_url, notice: 'Incarnation was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @afformation.destroy\n respond_to do |format|\n format.html { redirect_to afformations_url, notice: 'Afformation was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete\n render json: Company.delete(params[\"id\"])\n end",
"def destroy\n @education_program.destroy\n respond_to do |format|\n format.html { redirect_to education_programs_url, notice: 'Education program was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @assoziation.destroy\n respond_to do |format|\n format.html { redirect_to moderator_faculty_assoziations_url(params[:faculty_id]), \n notice: 'Assoziation was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @education_level = EducationLevel.find(params[:id])\n @education_level.destroy\n\n respond_to do |format|\n format.html { redirect_to education_levels_url, :notice => t('controllermessage.delete') }\n format.json { head :no_content }\n end\n end",
"def destroy\n @examination.destroy\n\n respond_to do |format|\n format.html { redirect_to @examination.project }\n format.json { head :no_content }\n end\n end",
"def destroy\n @exam.destroy\n respond_to do |format|\n format.html { redirect_to exams_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @life_insurance.destroy\n respond_to do |format|\n format.html { redirect_to life_insurances_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @humanidades1 = Humanidades1.find(params[:id])\n @humanidades1.destroy\n\n respond_to do |format|\n format.html { redirect_to humanidades1s_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @persona = Persona.find(params[:id])\n @persona.destroy\n\n respond_to do |format|\n format.json { head :ok }\n end\n \n end",
"def destroy\n @analisis = Analisis.find(params[:id])\n @analisis.destroy\n\n respond_to do |format|\n format.html { redirect_to(analisis_index_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\r\n @attestation = Attestation.find(params[:id])\r\n @attestation.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_to attestations_url }\r\n format.json { head :no_content }\r\n end\r\n end",
"def destroy\n @asignacion_familiar.destroy\n respond_to do |format|\n format.html { redirect_to asignacion_familiars_url, notice: 'Asignacion familiar eliminada exitosamente.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @anniversary = Anniversary.find(params[:id])\n @anniversary.destroy\n\n respond_to do |format|\n format.html { redirect_to anniversaries_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @first_exam.destroy\n respond_to do |format|\n format.html { redirect_to first_exams_url, notice: 'First exam was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @news_agency = NewsAgency.find(params[:id])\n @news_agency.destroy\n\n respond_to do |format|\n format.html { redirect_to news_agencies_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @admin_interview = Interview.find(params[:id])\n @admin_interview.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_interviews_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @accident_item.destroy\n respond_to do |format|\n format.html { redirect_to accident_items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @attestation.destroy\n respond_to do |format|\n format.html { redirect_to attestations_url, notice: 'Attestation was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @consultation.destroy\n respond_to do |format|\n format.html { redirect_to consultations_url, notice: 'Consulta apagada' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @asformulary.destroy\n respond_to do |format|\n format.html { redirect_to asformularies_url, notice: 'Asformulary was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @asignatura.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n @introexam.destroy\n respond_to do |format|\n format.html { redirect_to introexams_url, notice: 'Introexam was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n # workaround\n @manifestation.identifiers.destroy_all\n @manifestation.creators.destroy_all\n @manifestation.contributors.destroy_all\n @manifestation.publishers.destroy_all\n @manifestation.bookmarks.destroy_all if defined?(EnjuBookmark)\n @manifestation.reload\n @manifestation.destroy\n\n respond_to do |format|\n format.html { redirect_to manifestations_url, notice: t('controller.successfully_deleted', model: t('activerecord.models.manifestation')) }\n format.json { head :no_content }\n end\n end",
"def destroy\n @exhibitior_category = ExhibitiorCategory.find(params[:id])\n @exhibitior_category.destroy\n\n respond_to do |format|\n format.html { redirect_to exhibitior_categories_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @research_c = ResearchC.find(params[:id])\n @research_c.destroy\n\n respond_to do |format|\n format.html { redirect_to research_cs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @hospital_referral.destroy\n respond_to do |format|\n format.html { redirect_to hospital_referrals_url, notice: 'Hospital referral was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @teaching.destroy\n respond_to do |format|\n format.html { redirect_to menu_docencia_4_path, notice: 'La actividad se elimino con exito.' }\n format.json { head :no_content }\n end\n\n end",
"def destroy\n @requisition.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 @oferta_academica = OfertaAcademica.find(params[:id])\n @oferta_academica.destroy\n\n head :no_content\n end",
"def destroy\n @yearly_info.destroy\n respond_to do |format|\n format.html { redirect_to yearly_infos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @headline.destroy\n respond_to do |format|\n format.html { redirect_to headlines_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @headline.destroy\n respond_to do |format|\n format.html { redirect_to headlines_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n # @exam.destroy\n respond_to do |format|\n format.html { redirect_to exams_url, notice: 'Exam was successfully destroyed.' }\n format.json { head :no_content }\n end\n end"
] |
[
"0.716151",
"0.7134487",
"0.71005076",
"0.7094043",
"0.7063016",
"0.69871086",
"0.69762254",
"0.6955557",
"0.69534886",
"0.69499236",
"0.6947348",
"0.6929999",
"0.6906631",
"0.68977445",
"0.6897173",
"0.68924636",
"0.68924636",
"0.68848974",
"0.68766606",
"0.68683016",
"0.6867234",
"0.68668467",
"0.6865232",
"0.6864551",
"0.68596435",
"0.68584865",
"0.6854622",
"0.6851141",
"0.6850839",
"0.68438417",
"0.68356794",
"0.6832521",
"0.6832289",
"0.6829259",
"0.6828742",
"0.6828535",
"0.681796",
"0.6813555",
"0.6811385",
"0.68079287",
"0.68079185",
"0.68070185",
"0.68042034",
"0.6801646",
"0.6800481",
"0.67942905",
"0.67939407",
"0.67929024",
"0.679157",
"0.6790718",
"0.67906594",
"0.67892677",
"0.677619",
"0.6773625",
"0.67715293",
"0.6767964",
"0.6764755",
"0.67641217",
"0.67616785",
"0.6761476",
"0.675697",
"0.6754598",
"0.6754564",
"0.67486143",
"0.6748361",
"0.6746269",
"0.67459506",
"0.6745301",
"0.67450345",
"0.674235",
"0.6741746",
"0.67414176",
"0.6735012",
"0.67346686",
"0.673415",
"0.6733216",
"0.6733074",
"0.67328566",
"0.6732762",
"0.6731317",
"0.67306536",
"0.6728917",
"0.67282903",
"0.67282104",
"0.67277217",
"0.6725254",
"0.672094",
"0.6720845",
"0.6719424",
"0.67136335",
"0.67114544",
"0.6710161",
"0.6705892",
"0.6705561",
"0.6703566",
"0.6700665",
"0.6698397",
"0.6697792",
"0.6697792",
"0.66927254"
] |
0.78330463
|
0
|
Use callbacks to share common setup or constraints between actions.
|
def set_academic_information
@academic_information = AcademicInformation.find(params[:id])
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end",
"def add_actions; end",
"def callbacks; end",
"def callbacks; end",
"def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end",
"def define_action_helpers; end",
"def post_setup\n end",
"def action_methods; end",
"def action_methods; end",
"def action_methods; end",
"def before_setup; end",
"def action_run\n end",
"def execute(setup)\n @action.call(setup)\n end",
"def define_action_helpers?; end",
"def set_actions\n actions :all\n end",
"def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end",
"def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end",
"def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end",
"def before_actions(*logic)\n self.before_actions = logic\n end",
"def setup_handler\n end",
"def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end",
"def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def workflow\n end",
"def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end",
"def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end",
"def before(action)\n invoke_callbacks *self.class.send(action).before\n end",
"def process_action(...)\n send_action(...)\n end",
"def before_dispatch(env); end",
"def after_actions(*logic)\n self.after_actions = logic\n end",
"def setup\n # override and do something appropriate\n end",
"def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end",
"def setup(_context)\n end",
"def setup(resources) ; end",
"def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end",
"def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end",
"def determine_valid_action\n\n end",
"def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end",
"def startcompany(action)\n @done = true\n action.setup\n end",
"def init_actions\n am = action_manager()\n am.add_action(Action.new(\"&Disable selection\") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } )\n am.add_action(Action.new(\"&Edit Toggle\") { @edit_toggle = !@edit_toggle; $status_message.value = \"Edit toggle is #{@edit_toggle}\" })\n end",
"def event_callbacks(event, metadata={})\n case event\n when :reset, :review\n if confirmed\n update_attributes(confirmed: false)\n end\n when :confirm\n confirm\n # trigger :order for all applicable items\n # NOTE: :order event is common to both physical and digital items\n items.each do |i|\n if i.event_permitted(:order)\n user_id = last_transition.user_id\n i.trigger!(:order, { order_id: id, user_id: user_id })\n end\n end\n when :complete_work\n request = metadata[:request]\n work_complete_notification(request)\n when :close\n close\n end\n if event != :close && !open\n reopen\n end\n end",
"def setup_action\n return unless PONY::ERRNO::check_sequence(current_act)\n new_sequence = @action_sequence[@sequence_index+1...@action_sequence.size]\n @sequence_index = 0\n new_sequence = DND::SkillSequence::ACTS[@acts[1]] + new_sequence\n execute_sequence\n end",
"def define_tasks\n define_weave_task\n connect_common_tasks\n end",
"def setup(&block)\n define_method(:setup, &block)\n end",
"def setup\n transition_to(:setup)\n end",
"def setup\n transition_to(:setup)\n end",
"def action\n end",
"def setup( *args )\n\t\t\tself.class.setupBlocks.each {|sblock|\n\t\t\t\tdebugMsg \"Calling setup block method #{sblock}\"\n\t\t\t\tself.send( sblock )\n\t\t\t}\n\t\t\tsuper( *args )\n\t\tend",
"def config(action, *args); end",
"def setup\n @setup_proc.call(self) if @setup_proc\n end",
"def before_action \n end",
"def setup_callbacks\n defined_callbacks.each do |meth|\n unless respond_to?(\"call_#{meth}_callbacks\".to_sym)\n self.class.module_eval <<-EOE\n def call_#{meth}_callbacks(*args)\n plugin_store.each {|a| a.call_#{meth}_callbacks(*args) } if respond_to?(:plugin_store) && plugin_store\n self.send :#{meth}, *args if respond_to?(:#{meth})\n end\n EOE\n end\n end\n end",
"def action\n end",
"def matt_custom_action_begin(label); end",
"def setup\n # override this if needed\n end",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def action(options,&callback)\n new_action = Action===options ? options : Action.new(options,&callback)\n # replace any with (shared name/alias or both default) + same arity\n @actions.delete_if do |existing_action|\n ((existing_action.names & new_action.names).size > 0 ||\n existing_action.default? && new_action.default?) &&\n existing_action.required.size == new_action.required.size &&\n existing_action.optional.size <= new_action.optional.size\n end\n @actions = (@actions + [new_action]).sort\n new_action\n end",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action\n end",
"def after(action)\n invoke_callbacks *options_for(action).after\n end",
"def pre_task\n end",
"def setup(server)\n server.on('beforeMethod', method(:before_method), 10)\n end",
"def add_actions\n attribute = machine.attribute\n name = self.name\n \n owner_class.class_eval do\n define_method(name) {self.class.state_machines[attribute].events[name].fire(self)}\n define_method(\"#{name}!\") {self.class.state_machines[attribute].events[name].fire!(self)}\n define_method(\"can_#{name}?\") {self.class.state_machines[attribute].events[name].can_fire?(self)}\n end\n end",
"def init_actions\n @select_action = SelectAction.new\n @endpoint_mouse_action = EndpointMouseAction.new\n @move_action = MoveAction.new\n end",
"def setup_signals; end",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action.respond_to?('weak!') ? action.weak! : action\n end",
"def initialize(*args)\n super\n @action = :set\nend",
"def after_set_callback; end",
"def setup\n #implement in subclass;\n end",
"def lookup_action; end",
"def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end",
"def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end",
"def release_actions; end",
"def around_hooks; end",
"def save_action; end",
"def setup(easy)\n super\n easy.customrequest = @verb\n end",
"def action_target()\n \n end",
"def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end",
"def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end",
"def before_setup\n # do nothing by default\n end",
"def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end",
"def default_action; end",
"def setup(&blk)\n @setup_block = blk\n end",
"def callback_phase\n super\n end",
"def advice\n end",
"def _handle_action_missing(*args); end",
"def duas1(action)\n action.call\n action.call\nend",
"def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end",
"def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end",
"def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend"
] |
[
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576",
"0.53124547",
"0.529654",
"0.5296262",
"0.52952296",
"0.52600986",
"0.52442724",
"0.52385926",
"0.52385926",
"0.52385926",
"0.52385926",
"0.52385926",
"0.5232394",
"0.523231",
"0.5227454",
"0.52226824",
"0.52201617",
"0.5212327",
"0.52079266",
"0.52050185",
"0.51754695",
"0.51726824",
"0.51710224",
"0.5166172",
"0.5159343",
"0.51578903",
"0.51522785",
"0.5152022",
"0.51518047",
"0.51456624",
"0.51398855",
"0.5133759",
"0.5112076",
"0.5111866",
"0.5111866",
"0.5110294",
"0.5106169",
"0.509231",
"0.50873137",
"0.5081088",
"0.508059",
"0.50677156",
"0.50562143",
"0.5050554",
"0.50474834",
"0.50474834",
"0.5036181",
"0.5026331",
"0.5022976",
"0.5015441",
"0.50121695",
"0.5000944",
"0.5000019",
"0.4996878",
"0.4989888",
"0.4989888",
"0.49864885",
"0.49797225",
"0.49785787",
"0.4976161",
"0.49683493",
"0.4965126",
"0.4958034",
"0.49559742",
"0.4954353",
"0.49535993",
"0.4952725",
"0.49467874",
"0.49423352",
"0.49325448",
"0.49282882",
"0.49269363",
"0.49269104",
"0.49252945",
"0.4923091",
"0.49194667",
"0.49174926",
"0.49173003",
"0.49171105",
"0.4915879",
"0.49155936"
] |
0.0
|
-1
|
Never trust parameters from the scary internet, only allow the white list through.
|
def academic_information_params
params.require(:academic_information).permit(:b_date, :e_date, :description, :grade, :academic_degree_id, :course, :institution_id)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def param_whitelist\n [:role, :title]\n end",
"def expected_permitted_parameter_names; end",
"def safe_params\n params.except(:host, :port, :protocol).permit!\n end",
"def strong_params\n params.require(:team_member).permit(param_whitelist)\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def strong_params\n params.require(:community).permit(param_whitelist)\n end",
"def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end",
"def strong_params\n params.require(:education).permit(param_whitelist)\n end",
"def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end",
"def allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\n end",
"def param_whitelist\n [:rating, :review]\n end",
"def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end",
"def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end",
"def user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end",
"def user_params\n params.permit(:name, :phoneNumber, :address, :postalCode, :local, :link, :counter, :latitude, :longitude) \n end",
"def valid_params_request?; end",
"def strong_params\n params.require(:experience).permit(param_whitelist)\n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def whitelist_url_params\n params.require(:whitelist_url).permit(:domain)\n end",
"def allowed_params\n params.require(:allowed).permit(:email)\n end",
"def permitted_params\n []\n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\n end",
"def query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend",
"def strong_params\n params.require(:success_metric).permit(param_whitelist)\n end",
"def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end",
"def whitelisted_user_params\n params.require(:user).\n permit( :first_name, :last_name, :email,:password,:password_confirmation,:birthday,:gender)\n end",
"def user_params\n ActionController::Parameters.permit_all_parameters = true\n params.require(:user) #.permit(:name, :surname, :phone, :password, :email, :time_zone)\n end",
"def strong_params\n params.require(:metric_change).permit(param_whitelist)\n end",
"def safe_params\n params.require(:user).permit(:name)\n end",
"def get_params\n\t\treturn ActionController::Parameters.new(self.attributes).permit(\"account_id\", \"title\", \"category\", \"introduction\", \"tags\", \"segment_type\", \"visible\", \"status\", \"main_image\")\n\tend",
"def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end",
"def check_params; true; end",
"def param_whitelist\n whitelist = [\n :description,\n :progress,\n :kpi_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:kpi_id)\n end\n \n whitelist\n end",
"def quote_params\n params.permit!\n end",
"def valid_params?; end",
"def paramunold_params\n params.require(:paramunold).permit!\n end",
"def user_params\n\t\tparams.permit(:nickname, :avatar, :description, :password, :gender, :birthday, :email, :phone, :qq_id, :wechat_id)\n\tend",
"def filtered_parameters; end",
"def user_params\n params.permit(\n \t:id,\n \t:email, \n \t:first_name, \n \t:last_name, \n \t:password, \n \t:confirm_token, \n \t:phone_number,\n \t:facebook_link,\n \t:car_model,\n \t:license_plate)\n end",
"def filtering_params\n params.permit(:email, :name)\n end",
"def check_params\n true\n end",
"def wx_public_params\n params.require(:wx_public).permit(:nickname, :manager, :alias)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def listing_params\n\t\tparams.permit(:address, :transit_info, :rules, :other_info, :lat, :lng)\n\tend",
"def social_account_params\n\t\t\tparams.require(:social_account).permit!\n\t\tend",
"def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end",
"def url_params\n params.require(:url).permit(:short_url, :original_url, :clicks, :ip_addresses)\n end",
"def user_params\n params.require(:user).permit(:uri, :username, :password, :realname, :email, :publicvisible)\n end",
"def model_params\n\t\tparams.require(:manager).permit(\n\t :user_name,\n :password,\n :email,\n \t\t\t)\n\tend",
"def article_params_whitelist\n params.require(:article).permit(:title, :description, category_ids: [])\n end",
"def college_whitelist_params\n params.require(:college_whitelist).permit(:status)\n end",
"def active_code_params\n params[:active_code].permit\n end",
"def filtering_params\n params.permit(:email)\n end",
"def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end",
"def ip_address_params\n\t\t\tparams.require(:ip_address).permit!\n end",
"def pull_request_params\n whitelist = [\n :url,\n :id,\n :html_url,\n :diff_url,\n :patch_url,\n :issue_url,\n :number,\n :state,\n :locked,\n :title\n ]\n params.require(:pull_request).permit(whitelist)\n end",
"def reserved_params\n params.require(:reserved).permit(:name, :email, :pax, :address, :KTP, :title)\n end",
"def post_params\n if current_user.admin? \n params.permit(:title, :body, :city, :country, :gps_location, :privacy, :visible, :latitude, :longitude, images: [], files: [])\n else \n params.permit(:title, :body, :city, :country, :gps_location, :privacy,:latitude, :longitude, images: [], files: [])\n end \n end",
"def list_params\n params.permit(:name)\n end",
"def filter_parameters; end",
"def filter_parameters; end",
"def vineyard_params\n params.permit(:vineyard_name, :email, :website_url, :phone, :address, :city, :region, :postcode, :country, :specialty, :description, :pet_friendly, :holiday, :tours, :events, :family_friendly, :cover_image, :image_one, :image_two, :image_three, :image_four, :user_id, :base64)\n end",
"def available_activity_params\n # params.require(:available_activity).permit(:type,:geometry,:properties)\n whitelisted = ActionController::Parameters.new({\n type: params.require(:available_activity)[:type],\n geometry: params.require(:available_activity)[:geometry].try(:permit!).to_h,\n properties: params.require(:available_activity)[:properties].try(:permit!).to_h\n }).try(:permit!)\n end",
"def user_params\n params.permit(:name, :username, :email, :password, :img_url, :bg_url, :coinbank)\n end",
"def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end",
"def user_params\n params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\n :user, :color, :solde)\n end",
"def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end",
"def param_whitelist\n [\n :title,\n :description,\n :organization,\n :team_id,\n :started_at,\n :finished_at,\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n end",
"def url_whitelist; end",
"def admin_social_network_params\n params.require(:social_network).permit!\n end",
"def filter_params\n params.require(:filters).permit(:letters)\n end",
"def origin_params\n params.permit(:country, :state, :city, :postal_code, :address, :description)\n end",
"def valid_params(params)\n params.permit(:login, :first_name, :last_name, \n :password, :password_confirmation)\n end",
"def sensitive_params=(params)\n @sensitive_params = params\n end",
"def permit_request_params\n params.permit(:address)\n end",
"def user_params\n # Ensure a user can't give themselves admin priveleges\n params.delete(:admin) if current_user.admin?\n params.require(:user).permit(:name, :email, :admin, :image)\n end",
"def secure_params\n params.require(:location).permit(:name)\n end",
"def strong_params\n params.require( :setting ).\n permit( :global_scan_limit, :per_user_scan_limit,\n :target_whitelist_patterns, :target_blacklist_patterns )\n end",
"def question_params\n params.require(:survey_question).permit(question_whitelist)\n end",
"def case_insensitive_params\n params.require(:case_insensitive).permit(:name)\n end",
"def empire_master_no_match_params\n params.require(:empire_master_no_match).permit(:uid, :last_name, :list, :search_date, :double, :source)\n end",
"def maintenance_request_params\n params[:maintenance_request].permit! #allow all parameters for now\n end",
"def unwanted_params\n params.require(:unwanted).permit(:title, :description, :image)\n end",
"def url_params\n params[:url].permit(:full)\n end",
"def backend_user_params\n params.permit!\n end",
"def filter_params\n\t\treturn params[:candidate].permit(:name_for_filter)\n\tend",
"def speed_measurement_params\n\n #fuckit, to lazy to deal with permit crap right now\n ActionController::Parameters.permit_all_parameters = true\n\n params[:speed_measurement]\n end",
"def user_params\n params.permit(:name, :age, :username, :display_photo, :password)\n end",
"def get_params\r\n #params.require(:article).permit(:title, :permalink, :content, :source_site, :introtext, :type_id, :order_by, :searchable, :created_by, :edited_by, :published_by, :published_on, :user_id)\r\n params.require(:article).permit!\r\n\r\n end",
"def pub_params\n params.require(:pub).permit(:name, :description, :phone, :email, :hidden, :city_id, :address)\n end",
"def pass_params\n params[:pass].permit(:name, :price, :description, :colour, :events)\n end",
"def droptraining_params\n params.permit(:training_id,:user_id, :utf8, :authenticity_token, :commit)\n end",
"def person_params\n # params whitelist does *not* include admin, sub, remember_token\n # TBD: share this whitelist with the list used by configuration_permitted_parameters\n # TBD: should current_password be on this list? -- for now, leaving off, since it seems to work without\n # NOTE: do not include 'admin' in this list!\n params.require(:person).permit(\n :name, \n :email, \n :description,\n :password, \n :password_confirmation\n )\n end",
"def parameter_params\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\n end"
] |
[
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",
"0.62894756",
"0.6283177",
"0.6242471",
"0.62382483",
"0.6217549",
"0.6214457",
"0.6209053",
"0.6193042",
"0.6177802",
"0.6174604",
"0.61714715",
"0.6161512",
"0.6151757",
"0.6150663",
"0.61461",
"0.61213595",
"0.611406",
"0.6106206",
"0.6105114",
"0.6089039",
"0.6081015",
"0.6071004",
"0.60620916",
"0.6019971",
"0.601788",
"0.6011056",
"0.6010898",
"0.6005122",
"0.6005122",
"0.6001556",
"0.6001049",
"0.59943926",
"0.5992201",
"0.59909594",
"0.5990628",
"0.5980841",
"0.59669393",
"0.59589154",
"0.5958826",
"0.5957911",
"0.5957385",
"0.5953072",
"0.59526145",
"0.5943361",
"0.59386164",
"0.59375334",
"0.59375334",
"0.5933856",
"0.59292704",
"0.59254247",
"0.5924164",
"0.59167904",
"0.59088355",
"0.5907542",
"0.59064597",
"0.5906243",
"0.5898226",
"0.589687",
"0.5896091",
"0.5894501",
"0.5894289",
"0.5891739",
"0.58860534",
"0.5882406",
"0.587974",
"0.58738774",
"0.5869024",
"0.58679986",
"0.5867561",
"0.5865932",
"0.5864461",
"0.58639693",
"0.58617616",
"0.5861436",
"0.5860451",
"0.58602303",
"0.5854586",
"0.58537364",
"0.5850427",
"0.5850199"
] |
0.0
|
-1
|
GET /repondres GET /repondres.json
|
def index
@repondres = Repondre.all
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def index\n @repas = Repa.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @repas }\n end\n end",
"def show\n @repuesto = Repuesto.find(params[:id])\n respond_to do |format|\n format.html { render :show }\n format.json { render json: @repuesto.to_json }\n end\n end",
"def show\n @respuesta = Respuesta.find(params[:id])\n\n render json: @respuesta\n end",
"def getOrden \n \t@orden = Orden.where(:rest => params[:id_res])\n \trender json: @orden\n end",
"def show\n @respuesta = Respuesta.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @respuesta }\n end\n end",
"def show\n render json: { comment: @comment, replaies: @comment.replaies }, status: :ok\n end",
"def index\n @frais_repas = FraisRepa.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @frais_repas }\n end\n end",
"def show\n @relogio = Relogio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @relogio }\n end\n end",
"def show\n @repa = Repa.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @repa }\n end\n end",
"def show\n @repa = Repa.find(params[:id])\n \n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @repa }\n end\n end",
"def show\n @repuestum = Repuestum.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @repuestum }\n end\n end",
"def show\n @pessoa_receber = PessoaReceber.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @pessoa_receber }\n end\n end",
"def show\n @remito = Remito.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @remito }\n end\n end",
"def serv_json\n \"http://api.dribbble.com/shots/popular?page=1\"\n end",
"def show\n @reconocimiento = Reconocimiento.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @reconocimiento }\n end\n end",
"def index\n @recipies = Recipy.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @recipies }\n end\n end",
"def show\n @receipe = Receipe.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @receipe }\n end\n end",
"def show\n @frais_repa = FraisRepa.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @frais_repa }\n end\n end",
"def show\n @reparacion = Reparacion.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @reparacion }\n end\n end",
"def index\n @mesasredondas = Mesasredonda.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @mesasredondas }\n end\n end",
"def json_url\n \"#{REDDIT_URL_PREFIX}#{permalink}.json\"\n end",
"def index\n @relaciones_articulos_medida = RelacionArticuloMedida.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @relaciones_articulos_medida }\n end\n end",
"def index\n \treclamos = Reclamo.all\n \trender json: reclamos.to_json(include: [:tipo_reclamo, :ubicacion, :user], methods: [:valoracion])\n end",
"def index\n @repuestos = Repuesto.all\n end",
"def listRestaurants\n _restaurants = Restaurant.all\n render json: _restaurants\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 @puntaje = Puntaje.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @puntaje }\n end\n end",
"def show\n @puntaje = Puntaje.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @puntaje }\n end\n end",
"def show\n @premio = Premio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @premio }\n end\n end",
"def show\n @recurso = Recurso.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @recurso }\n end\n end",
"def show\n @recoleccion = Recoleccion.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @recoleccion }\n end\n end",
"def show\n render json: @parish\n end",
"def index\n @notadedebito = Notadedebito.find(params[:notadecredito_id])\n @renglon_notadebitos = @notadedebito.renglon_notadebitos\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @renglon_notadebitos }\n end\n end",
"def index\n @parishes = Parish.all\n\n render json: @parishes\n end",
"def show\n @reel = Reel.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @reel }\n end\n end",
"def show\n @retro = Retro.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @retro }\n end\n end",
"def get_from_npr(user_ingredients)\n raw_response=RestClient.get('http://api.npr.org/query?id=1139&fields=title,teaser,storyDate,byline,text&date&searchTerm=' + user_ingredients + '&dateType=story&output=JSON&apiKey=MDE5MDExNzc1MDE0MzA0MDE1NTViZDViOQ001')\n response = JSON.load(raw_response)\n\n if response[\"list\"][\"story\"] == nil\n puts \"Your search did not find any recipes...\"\n else\n recipes = response[\"list\"][\"story\"].map do |recipe|\n Recipe.new(\n title = recipe[\"title\"][\"$text\"],\n teaser = recipe[\"teaser\"][\"$text\"],\n link = recipe[\"link\"].first[\"$text\"],\n storyDate = recipe[\"storyDate\"][\"$text\"]\n )\n end\n end\n\nend",
"def show\n @lore = Lore.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @lore }\n end\n end",
"def show\n @renter = Renter.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @renter }\n end\n end",
"def set_repondre\n @repondre = Repondre.find(params[:id])\n end",
"def show\n @tipo_pregunta = TipoPregunta.find(params[:id])\n\n render json: @tipo_pregunta\n end",
"def get\n @cine = Cine.find(params[:cine_id], :select => [\"nombre\",\"id\",\"direccion\",\"localidad\"])\n render :json => [ @cine, :peliculas => @cine.peliculas.select('titulo,horas,pelicula_id') ]\n end",
"def new\n @respuesta = Respuesta.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @respuesta }\n end\n end",
"def index\n @reprogramaciones = Reprogramacion.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @reprogramaciones }\n end\n end",
"def index\n @puntajes = Puntaje.order('created_at DESC').all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @puntajes }\n end\n end",
"def index\n @recipes = Recipe.all\n render json: @recipes\n end",
"def show\n @referee = Referee.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @referee }\n end\n end",
"def show\n @drip = Drip.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @drip }\n end\n end",
"def index\n @preparatoria_o_universidad_de_origens = PreparatoriaOUniversidadDeOrigen.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @preparatoria_o_universidad_de_origens }\n end\n end",
"def index\n @repertoires = Repertoire.all\n end",
"def index\r\n @respuesta = Respuestum.all\r\n end",
"def show\n @rebate = Rebate.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @rebate }\n end\n end",
"def new\n @repa = Repa.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @repa }\n end\n end",
"def index\n @patrocinios = Patrocinio.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @patrocinios }\n end\n end",
"def index\n logement = Logement.find_by(id:params[:logement_id])\n equipement = logement.equi_securites[0].title\n equipements = logement.equi_securites[0]\n\n render json: {\n securites:equipement,\n fichier:equipements\n }\n end",
"def show\n @remedio = Remedio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @remedio }\n end\n end",
"def get_todo_restaurants\n @profile = Profile.find(params[:id])\n @restaurants = @profile.todos\n\n render status: 200, json: @restaurants\n end",
"def index\n find_dependencias\n respond_to do |format|\n format.html\n format.json { render :json => @dependencias.to_json(:methods => :alias_or_fullname, :only => [:id, :codigo, :nombre])}\n\n end\n end",
"def index\n @chores = Chore.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @chores }\n end\n end",
"def index\n @chores = Chore.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @chores }\n end\n end",
"def show\n @ridol = Ridol.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @ridol }\n end\n end",
"def index\n @ores = Ore.all\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ores }\n end\n end",
"def index\n @respuestas = Respuesta.all\n end",
"def index\n @prueba_jsons = PruebaJson.all\n end",
"def index\n @current_page = 'recettes'\n @recettes = Recette.includes(:photo_files).all.order('id desc').limit(15)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @recettes }\n end\n end",
"def create\n @repondre = Repondre.new(repondre_params)\n\n respond_to do |format|\n if @repondre.save\n format.html { redirect_to @repondre, notice: 'Repondre was successfully created.' }\n format.json { render :show, status: :created, location: @repondre }\n else\n format.html { render :new }\n format.json { render json: @repondre.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n render json: reservations\n end",
"def show\n @addre = Addre.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @addre }\n end\n end",
"def index\n # @donor_titles = DonorTitle.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @donor_titles }\n end\n end",
"def show\n @restaurant = Restaurant.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @restaurant.to_json(except: [ :created_at, :updated_at ], methods: [ :partial_dishes, :partial_comments, :busy, :partial_recommendations ]) }\n end\n end",
"def show\n @reprogramacion = Reprogramacion.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @reprogramacion }\n end\n end",
"def show\n @rechnung = Rechnung.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @rechnung }\n end\n end",
"def index\n users = @fun.get_reposts.limit(5).reposters\n users.map! do |user|\n user = user.info_to_json\n user[:user_path] = user_path user[:login]\n user\n end\n render json: users\n end",
"def new\n @presenza = Presenza.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @presenza }\n end\n end",
"def index\n json_response(Restaurant.all)\n end",
"def index\n @palestrantes = Palestrante.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @palestrantes }\n end\n end",
"def index\n @premios = Premio.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @premios }\n end\n end",
"def show\n @receita_medica = ReceitaMedica.find(params[:id])\n @item_receitas = @receita_medica.item_receitas.all\n respond_to do |format|\n format.html # show.html.erb \n format.json { render json: {\n :receita => @receita_medica, \n :medicamentos => @receita_medica.item_receitas.collect {|t| [t.medicamento.nome, t.posologia, t.quantidade]} } }\n end\n end",
"def show\n @recipy = Recipy.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @recipy }\n end\n end",
"def index\n @puntajes = Puntaje.paginate(:page => params[:page], :per_page => 10)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @puntajes }\n end\n end",
"def show\n @rrold = Rrold.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @rrold }\n end\n end",
"def show\n @precinct = Precinct.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @precinct }\n end\n end",
"def index\n @recipes = Recipe.all\n respond_to do |format|\n format.html {}\n format.json { render json: @recipes }\n end\n end",
"def index\n @rents = Rent.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @rents }\n end\n end",
"def new\n @relogio = Relogio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @relogio }\n end\n end",
"def index\n @regrapontos = Regraponto.all\n end",
"def index\n @simple_chores = SimpleChore.all\n respond_to do |format|\n format.html\n format.json { render :json => @simple_chores }\n end\n end",
"def show\n @preguntum = Preguntum.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @preguntum }\n end\n end",
"def show\n @historial = Historial.find(params[:id])\n @receta = Recete.histori(@historial.id)\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @historial }\n end\n end",
"def show\r\n\r\n url = URI(\"https://spoonacular-recipe-food-nutrition-v1.p.rapidapi.com/recipes/#{params[:id]}/information\")\r\n\r\n http = Net::HTTP.new(url.host, url.port)\r\n http.use_ssl = true\r\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\r\n\r\n request = Net::HTTP::Get.new(url)\r\n request[\"x-rapidapi-key\"] = ENV[\"SPOONACULAR_API_KEY\"] # hidden API key\r\n request[\"x-rapidapi-host\"] = 'spoonacular-recipe-food-nutrition-v1.p.rapidapi.com'\r\n\r\n response = http.request(request)\r\n @recipe = JSON.parse response.read_body # gets the recipe\r\n\r\n p url_ingredients = URI(\"https://spoonacular-recipe-food-nutrition-v1.p.rapidapi.com/recipes/#{params[:id]}/ingredientWidget.json\")\r\n\r\n http_ingredients = Net::HTTP.new(url_ingredients.host, url_ingredients.port)\r\n http_ingredients.use_ssl = true\r\n http_ingredients.verify_mode = OpenSSL::SSL::VERIFY_NONE\r\n\r\n request_ingredients = Net::HTTP::Get.new(url_ingredients)\r\n request_ingredients[\"x-rapidapi-key\"] = ENV[\"SPOONACULAR_API_KEY\"]\r\n request[\"x-rapidapi-host\"] = 'spoonacular-recipe-food-nutrition-v1.p.rapidapi.com'\r\n\r\n response_ingredients = http.request(request_ingredients)\r\n # puts response_ingredients.read_body\r\n @ingredients = JSON.parse # data is a string (which looks like a hash -> convert to hash) response_ingredients.read_body\r\n p \"RECIPES\"\r\n # p @recipe\r\n p \"INGREDIENTS\"\r\n p @ingredients\r\n\r\n end",
"def new\n @pessoa_receber = PessoaReceber.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @pessoa_receber }\n end\n end",
"def index\n @tipo_denuncia = TipoDenuncium.all\n\n render json: @tipo_denuncia\n end",
"def show\n @ventas_presupuesto = Ventas::Presupuesto.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @ventas_presupuesto }\n end\n end",
"def index\n # @prenotations = Prenotation.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @prenotations }\n end\n end",
"def index\n @recibo = Recibo.find(params[:recibo_id])\n @renglon_recdetalles = @recibo.renglon_recdetalles.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @renglon_recdetalles }\n end\n end",
"def show\n @redpack = Redpack.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @redpack }\n end\n end",
"def show\n @parlamentarian = Parlamentarian.find_by_id(params[:rdf_uri])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @parlamentarian }\n end\n end",
"def index\n respond_with Genre.all\n end",
"def index\n @pictures = Picture.where(foodscape_id: params[:foodscape_id])\n render json: @pictures\n end",
"def show\n @notadedebito = Notadedebito.find(params[:notadecredito_id])\n @renglon_notadebito = @notadedebito.renglon_notadebitos.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @renglon_notadebito }\n end\n end"
] |
[
"0.66810554",
"0.66384983",
"0.65938544",
"0.65374804",
"0.63630056",
"0.6361198",
"0.6354697",
"0.63461787",
"0.6306491",
"0.629827",
"0.6254358",
"0.6228207",
"0.6131714",
"0.6119192",
"0.60912645",
"0.6084219",
"0.6056029",
"0.60557944",
"0.60557836",
"0.6034126",
"0.60206145",
"0.6009363",
"0.6006951",
"0.5968355",
"0.5958934",
"0.59404796",
"0.5935674",
"0.5935674",
"0.5915874",
"0.59138787",
"0.5906323",
"0.5900248",
"0.5892878",
"0.58714163",
"0.58710766",
"0.5865547",
"0.5862045",
"0.58501333",
"0.58441395",
"0.5836381",
"0.582687",
"0.5818367",
"0.5801162",
"0.57833105",
"0.5774919",
"0.5772899",
"0.57709104",
"0.5768881",
"0.576165",
"0.5760766",
"0.5758633",
"0.5757465",
"0.57559353",
"0.5750826",
"0.5748837",
"0.5745216",
"0.5737445",
"0.5736153",
"0.57345897",
"0.57345897",
"0.5731614",
"0.57306826",
"0.57291335",
"0.5727826",
"0.5724179",
"0.572173",
"0.57196736",
"0.5719515",
"0.57189304",
"0.5716164",
"0.571401",
"0.57138205",
"0.5710193",
"0.57071435",
"0.57057494",
"0.57038754",
"0.56991047",
"0.5695165",
"0.56893724",
"0.5687594",
"0.56865764",
"0.56833625",
"0.5683151",
"0.56792235",
"0.5672696",
"0.5670741",
"0.56703156",
"0.56686455",
"0.5668549",
"0.56669855",
"0.5666689",
"0.56661826",
"0.5665659",
"0.56649226",
"0.56640893",
"0.5663197",
"0.56624883",
"0.56611425",
"0.5659371",
"0.56429136"
] |
0.69111854
|
0
|
GET /repondres/1 GET /repondres/1.json
|
def show
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def show\n @respuesta = Respuesta.find(params[:id])\n\n render json: @respuesta\n end",
"def getOrden \n \t@orden = Orden.where(:rest => params[:id_res])\n \trender json: @orden\n end",
"def show\n @repuesto = Repuesto.find(params[:id])\n respond_to do |format|\n format.html { render :show }\n format.json { render json: @repuesto.to_json }\n end\n end",
"def index\n @repas = Repa.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @repas }\n end\n end",
"def index\n @repondres = Repondre.all\n end",
"def show\n @respuesta = Respuesta.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @respuesta }\n end\n end",
"def show\n @repa = Repa.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @repa }\n end\n end",
"def show\n @relogio = Relogio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @relogio }\n end\n end",
"def show\n @repa = Repa.find(params[:id])\n \n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @repa }\n end\n end",
"def show\n @repuestum = Repuestum.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @repuestum }\n end\n end",
"def show\n @remito = Remito.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @remito }\n end\n end",
"def show\n @pessoa_receber = PessoaReceber.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @pessoa_receber }\n end\n end",
"def show\n @reconocimiento = Reconocimiento.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @reconocimiento }\n end\n end",
"def show\n @receipe = Receipe.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @receipe }\n end\n end",
"def index\n @recipies = Recipy.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @recipies }\n end\n end",
"def show\n @reparacion = Reparacion.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @reparacion }\n end\n end",
"def show\n @frais_repa = FraisRepa.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @frais_repa }\n end\n end",
"def index\n @frais_repas = FraisRepa.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @frais_repas }\n end\n end",
"def show\n @retro = Retro.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @retro }\n end\n end",
"def show\n @recipy = Recipy.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @recipy }\n end\n end",
"def show\n @recurso = Recurso.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @recurso }\n end\n end",
"def show\n @recoleccion = Recoleccion.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @recoleccion }\n end\n end",
"def show\n @reprogramacion = Reprogramacion.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @reprogramacion }\n end\n end",
"def show\n @premio = Premio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @premio }\n end\n end",
"def show\n render json: { comment: @comment, replaies: @comment.replaies }, status: :ok\n end",
"def serv_json\n \"http://api.dribbble.com/shots/popular?page=1\"\n end",
"def show\n @reel = Reel.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @reel }\n end\n end",
"def show\n @historial = Historial.find(params[:id])\n @receta = Recete.histori(@historial.id)\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @historial }\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 @tipo_pregunta = TipoPregunta.find(params[:id])\n\n render json: @tipo_pregunta\n end",
"def show\n @lore = Lore.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @lore }\n end\n end",
"def show\n @renter = Renter.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @renter }\n end\n end",
"def index\n logement = Logement.find_by(id:params[:logement_id])\n equipement = logement.equi_securites[0].title\n equipements = logement.equi_securites[0]\n\n render json: {\n securites:equipement,\n fichier:equipements\n }\n end",
"def show\n @rechnung = Rechnung.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @rechnung }\n end\n end",
"def show\n @remedio = Remedio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @remedio }\n end\n end",
"def show\n @ridol = Ridol.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @ridol }\n end\n end",
"def show\n @autore = Autore.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @autore }\n end\n end",
"def show\n @referee = Referee.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @referee }\n end\n end",
"def index\n @current_page = 'recettes'\n @recettes = Recette.includes(:photo_files).all.order('id desc').limit(15)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @recettes }\n end\n end",
"def show\n @uchronia = Uchronia.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @uchronia }\n end\n end",
"def show\n @preguntum = Preguntum.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @preguntum }\n end\n end",
"def set_repondre\n @repondre = Repondre.find(params[:id])\n end",
"def show\n @addre = Addre.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @addre }\n end\n end",
"def new\n @repa = Repa.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @repa }\n end\n end",
"def json_url\n \"#{REDDIT_URL_PREFIX}#{permalink}.json\"\n end",
"def show\n @precinct = Precinct.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @precinct }\n end\n end",
"def new\n @respuesta = Respuesta.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @respuesta }\n end\n end",
"def show\n @requerimiento ||= Requerimiento.where(:numero => params[:id]).first\n @areas = Area.where(\" nombre like '%DIT%' \")\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @requerimiento }\n end\n end",
"def get\n @cine = Cine.find(params[:cine_id], :select => [\"nombre\",\"id\",\"direccion\",\"localidad\"])\n render :json => [ @cine, :peliculas => @cine.peliculas.select('titulo,horas,pelicula_id') ]\n end",
"def show\n @rebate = Rebate.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @rebate }\n end\n end",
"def index\n @relaciones_articulos_medida = RelacionArticuloMedida.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @relaciones_articulos_medida }\n end\n end",
"def show\n @redpack = Redpack.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @redpack }\n end\n end",
"def index\n @reprogramaciones = Reprogramacion.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @reprogramaciones }\n end\n end",
"def show\n recipe = Recipe.find(params[:id])\n # recipes = Recipe.find_by(params[:id])\n # render json: recipe\n render json: recipe\n end",
"def show\n @puntaje = Puntaje.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @puntaje }\n end\n end",
"def show\n @puntaje = Puntaje.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @puntaje }\n end\n end",
"def show\n @roadcrime = Roadcrime.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @roadcrime }\n end\n end",
"def show\n @agronomiaquimica = Agronomiaquimica.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @agronomiaquimica }\n end\n end",
"def show\n # proxy to GET /roi/id\n @result = ImageServer.get('/roi/'+params[:id]);\n render :json => @result\n end",
"def show\r\n\r\n url = URI(\"https://spoonacular-recipe-food-nutrition-v1.p.rapidapi.com/recipes/#{params[:id]}/information\")\r\n\r\n http = Net::HTTP.new(url.host, url.port)\r\n http.use_ssl = true\r\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\r\n\r\n request = Net::HTTP::Get.new(url)\r\n request[\"x-rapidapi-key\"] = ENV[\"SPOONACULAR_API_KEY\"] # hidden API key\r\n request[\"x-rapidapi-host\"] = 'spoonacular-recipe-food-nutrition-v1.p.rapidapi.com'\r\n\r\n response = http.request(request)\r\n @recipe = JSON.parse response.read_body # gets the recipe\r\n\r\n p url_ingredients = URI(\"https://spoonacular-recipe-food-nutrition-v1.p.rapidapi.com/recipes/#{params[:id]}/ingredientWidget.json\")\r\n\r\n http_ingredients = Net::HTTP.new(url_ingredients.host, url_ingredients.port)\r\n http_ingredients.use_ssl = true\r\n http_ingredients.verify_mode = OpenSSL::SSL::VERIFY_NONE\r\n\r\n request_ingredients = Net::HTTP::Get.new(url_ingredients)\r\n request_ingredients[\"x-rapidapi-key\"] = ENV[\"SPOONACULAR_API_KEY\"]\r\n request[\"x-rapidapi-host\"] = 'spoonacular-recipe-food-nutrition-v1.p.rapidapi.com'\r\n\r\n response_ingredients = http.request(request_ingredients)\r\n # puts response_ingredients.read_body\r\n @ingredients = JSON.parse # data is a string (which looks like a hash -> convert to hash) response_ingredients.read_body\r\n p \"RECIPES\"\r\n # p @recipe\r\n p \"INGREDIENTS\"\r\n p @ingredients\r\n\r\n end",
"def show\n @livro = Livro.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @livro }\n end\n end",
"def index\n \treclamos = Reclamo.all\n \trender json: reclamos.to_json(include: [:tipo_reclamo, :ubicacion, :user], methods: [:valoracion])\n end",
"def show\n @rrold = Rrold.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @rrold }\n end\n end",
"def show\n @recruiter = Recruiter.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @recruiter }\n end\n end",
"def show\n @apprentice = Apprentice.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @apprentice }\n end\n end",
"def show\n @rinit = Rinit.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @rinit }\n end\n end",
"def show\n @prepagada = Prepagada.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @prepagada }\n end\n end",
"def show\n @remainder = Remainder.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @remainder }\n end\n end",
"def show\n @recinto = Recinto.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @recinto }\n end\n end",
"def show\n @portion = Portion.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @portion }\n end\n end",
"def index\r\n @respuesta = Respuestum.all\r\n end",
"def index\n @one_reg_institutions = OneRegInstitution.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @one_reg_institutions }\n end\n end",
"def show\n\n @recibo = Recibo.find(params[:recibo_id])\n @renglon_recdetalle = @recibo.renglon_recdetalles.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @renglon_recdetalle }\n end\n end",
"def show\n @data = @recipe.read(params[:id])\n render json: @data\n end",
"def show\n\n recipe = Recipe.find(params[:id])\n render :json => recipe.to_json\n\n end",
"def show\n @rum = Rum.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @rum }\n end\n end",
"def show\n @promocion = Promocion.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n #format.json { render json: @promocion }\n end\n end",
"def index\n @ores = Ore.all\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ores }\n end\n end",
"def index\n @notadedebito = Notadedebito.find(params[:notadecredito_id])\n @renglon_notadebitos = @notadedebito.renglon_notadebitos\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @renglon_notadebitos }\n end\n end",
"def index\n render json: reservations\n end",
"def find_client\n cliente = get_cliente(params[:id])\n\n respond_to do |format|\n format.json {render json: {client: cliente}}\n end\n end",
"def index\n @pictures = Picture.where(foodscape_id: params[:foodscape_id])\n render json: @pictures\n end",
"def show\n @odontologia1 = Odontologia1.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @odontologia1 }\n end\n end",
"def index\n @repuestos = Repuesto.all\n end",
"def show\n @nominee = Nominee.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @nominee }\n end\n end",
"def show\n @mouvement_recurrent = MouvementRecurrent.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @mouvement_recurrent }\n end\n end",
"def index\n if params[:single]\n\t url = \"#{API_BASE_URL}/photos/#{params[:id]}.json?token=#{ENV['API_KEY']}\"\n\t response = RestClient.get(url)\n\t @photo = JSON.parse(response.body)\n\telse\n\t url = \"#{API_BASE_URL}/photos.json?token=#{ENV['API_KEY']}\"\n response = RestClient.get(url)\n @photos = JSON.parse(response.body)\t\t \n\tend\n end",
"def findreg\n @detalles = Detalle.find(params[:id])\n render json: @detalles\n end",
"def show\n @retroalimentacion = Retroalimentacion.find(params[:id])\n @current_cliente=obtener_cliente(current_user)\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @retroalimentacion }\n end\n end",
"def show\n @drip = Drip.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @drip }\n end\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 @uchronist = Uchronist.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @uchronist }\n end\n end",
"def index\n @requisitions = Requisition.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @requisitions }\n end\n end",
"def index\n @disponibles = Disponible.take(50)\n\n render json: @disponibles, include: '**'\n end",
"def new\n @relogio = Relogio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @relogio }\n end\n end",
"def index\n @recipes = Recipe.all\n render json: @recipes\n end",
"def show\n @restroom = Restroom.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @restroom }\n end\n end",
"def show\n @parlamentarian = Parlamentarian.find_by_id(params[:rdf_uri])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @parlamentarian }\n end\n end",
"def show\n @dependencia = Dependencia.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @dependencia }\n end\n end",
"def show\n @notadedebito = Notadedebito.find(params[:notadecredito_id])\n @renglon_notadebito = @notadedebito.renglon_notadebitos.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @renglon_notadebito }\n end\n end",
"def index\n @factura = Factura.find(params[:factura_id])\n @renglon_facturas = @factura.renglon_facturas\n\n respond_to do |format|\n format.html # index.html.erb\n #format.json { render json: @renglon_facturas }\n end\n end"
] |
[
"0.68548715",
"0.6804808",
"0.67578286",
"0.6684862",
"0.6663994",
"0.66192037",
"0.6594375",
"0.6590454",
"0.6587788",
"0.6497196",
"0.6417393",
"0.63467866",
"0.6332764",
"0.6326117",
"0.6312485",
"0.6307782",
"0.62773067",
"0.62745696",
"0.6259949",
"0.62594545",
"0.625527",
"0.6235039",
"0.61626256",
"0.6129817",
"0.6120105",
"0.61136645",
"0.61070174",
"0.61067677",
"0.60850525",
"0.6053878",
"0.6049071",
"0.60279936",
"0.60094094",
"0.6004446",
"0.59995496",
"0.59693074",
"0.5965463",
"0.5960913",
"0.59507054",
"0.5944462",
"0.5929816",
"0.5927678",
"0.59168375",
"0.59148127",
"0.59104455",
"0.5906705",
"0.5906471",
"0.5898076",
"0.5893622",
"0.58892816",
"0.5888517",
"0.5885032",
"0.5883122",
"0.5881112",
"0.58794546",
"0.58794546",
"0.58793753",
"0.58780056",
"0.5877337",
"0.5873662",
"0.586376",
"0.5862638",
"0.5859465",
"0.58556277",
"0.58518595",
"0.584777",
"0.5843199",
"0.5836536",
"0.58294404",
"0.5825604",
"0.5825527",
"0.58216107",
"0.58214766",
"0.58119905",
"0.581025",
"0.5808449",
"0.5800663",
"0.5800616",
"0.580042",
"0.5796595",
"0.5795153",
"0.5792113",
"0.5789432",
"0.57878244",
"0.578418",
"0.578123",
"0.5779117",
"0.57781065",
"0.57775366",
"0.57774574",
"0.5775502",
"0.57739425",
"0.5773808",
"0.57701564",
"0.5767954",
"0.57673776",
"0.5766754",
"0.5765878",
"0.5764016",
"0.5752544",
"0.57448995"
] |
0.0
|
-1
|
POST /repondres POST /repondres.json
|
def create
@repondre = Repondre.new(repondre_params)
respond_to do |format|
if @repondre.save
format.html { redirect_to @repondre, notice: 'Repondre was successfully created.' }
format.json { render :show, status: :created, location: @repondre }
else
format.html { render :new }
format.json { render json: @repondre.errors, status: :unprocessable_entity }
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def create\n @respuesta = Respuesta.new(params[:respuesta])\n\n if @respuesta.save\n render json: @respuesta, status: :created, location: @respuesta\n else\n render json: @respuesta.errors, status: :unprocessable_entity\n end\n end",
"def create\n @repuesto = Repuesto.new(repuesto_params)\n\n respond_to do |format|\n if @repuesto.save\n format.html { redirect_to @repuesto, notice: 'Repuesto was successfully created.' }\n format.json { render :show, status: :created, location: @repuesto }\n else\n format.html { render :new }\n format.json { render json: @repuesto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @repuesto = Repuesto.new(repuesto_params)\n\n respond_to do |format|\n if @repuesto.save\n format.html { redirect_to @repuesto, notice: 'Repuesto creado exitosamente' }\n format.json { render :show, status: :created, location: @repuesto }\n else\n format.html { render :new }\n format.json { render json: @repuesto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @respuesta = Respuesta.new(params[:respuesta])\n\n respond_to do |format|\n if @respuesta.save\n format.html { redirect_to @respuesta, notice: 'Respuesta was successfully created.' }\n format.json { render json: @respuesta, status: :created, location: @respuesta }\n else\n format.html { render action: \"new\" }\n format.json { render json: @respuesta.errors, status: :unprocessable_entity }\n end\n end\n end",
"def repondre_params\n params.require(:repondre).permit(:user_id, :question_id)\n end",
"def create\n @respuesta = Respuesta.new(respuesta_params)\n\n respond_to do |format|\n if @respuesta.save\n format.html { redirect_to @respuesta, notice: 'Respuesta was successfully created.' }\n format.json { render :show, status: :created, location: api_v1_respuesta_url(@respuesta) }\n else\n format.html { render :new }\n format.json { render json: @respuesta.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @repuestum = Repuestum.new(params[:repuestum])\n\n respond_to do |format|\n if @repuestum.save\n format.html { redirect_to @repuestum, notice: 'Repuestum was successfully created.' }\n format.json { render json: @repuestum, status: :created, location: @repuestum }\n else\n format.html { render action: \"new\" }\n format.json { render json: @repuestum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @repertoire = Repertoire.new(repertoire_params)\n\n if @repertoire.save\n render :show, status: :created, location: @repertoire\n else\n render json: @repertoire.errors, status: :unprocessable_entity\n end\n end",
"def create\n @frais_repa = FraisRepa.new(params[:frais_repa])\n\n respond_to do |format|\n if @frais_repa.save\n format.html { redirect_to @frais_repa, :notice => 'Le frais de repas a bien été créé' }\n format.json { render :json => @frais_repa, :status => :created, :location => @frais_repa }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @frais_repa.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @regraponto = Regraponto.new(regraponto_params)\n\n respond_to do |format|\n if @regraponto.save\n format.html { redirect_to @regraponto, notice: 'Regraponto was successfully created.' }\n format.json { render :show, status: :created, location: @regraponto }\n else\n format.html { render :new }\n format.json { render json: @regraponto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @repa = Repa.new(params[:repa])\n\n respond_to do |format|\n if @repa.save\n format.html { redirect_to repas_url, notice: 'Repa was successfully created.' }\n format.json { render json: @repa, status: :created, location: @repa }\n else\n format.html { render action: \"new\" }\n format.json { render json: @repa.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @reconocimiento = Reconocimiento.new(params[:reconocimiento])\n\n respond_to do |format|\n if @reconocimiento.save\n format.html { redirect_to @reconocimiento, :notice => 'Reconocimiento was successfully created.' }\n format.json { render :json => @reconocimiento, :status => :created, :location => @reconocimiento }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @reconocimiento.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def post_spoonacular\n # %encode ingredients to url\n encoded_ingr = URI.escape(@translated_recipe[:ingredients_list])\n # post call block :\n url = URI(\"https://spoonacular-recipe-food-nutrition-v1.p.rapidapi.com/recipes/parseIngredients?includeNutrition=true\")\n http = Net::HTTP.new(url.host, url.port)\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n request = Net::HTTP::Post.new(url)\n request[\"content-type\"] = \"application/x-www-form-urlencoded\"\n request[\"x-rapidapi-key\"] = ENV[\"X_RAPIDAPI_KEY\"]\n request[\"x-rapidapi-host\"] = \"spoonacular-recipe-food-nutrition-v1.p.rapidapi.com\"\n # body of the call with ingredients and servings\n request.body = \"ingredientList=#{encoded_ingr}&#{@recipe_hash[:servings]}\"\n # response\n response = http.request(request)\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 @restaurantes_proximo = RestaurantesProximo.new(restaurantes_proximo_params)\n\n respond_to do |format|\n if @restaurantes_proximo.save\n format.html { redirect_to @restaurantes_proximo, notice: 'Restaurantes proximo was successfully created.' }\n format.json { render :show, status: :created, location: @restaurantes_proximo }\n else\n format.html { render :new }\n format.json { render json: @restaurantes_proximo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\n @respuestum = Respuestum.new(respuestum_params)\n # @comentario = Comentario.find(params[:id])\n #nombre = params[:nombre]\n #correo = params[:correo]\n #comentario = params[:comentario]\n\n #@respuestum = Respuestum.create(:nombre => string, :correo => string, :descripcion => text,:comentario_id => @comentario.id)\n\n respond_to do |format|\n if @respuestum.save\n format.html { redirect_to comentarios_url}\n format.json { render :show, status: :created, location: @respuestum }\n else\n format.html { render :new }\n format.json { render json: @respuestum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @resi = Resi.new(resi_params)\n\n respond_to do |format|\n if @resi.save\n format.html { redirect_to @resi, notice: 'Resi was successfully created.' }\n format.json { render :show, status: :created, location: @resi }\n else\n format.html { render :new }\n format.json { render json: @resi.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @relogio = Relogio.new(params[:relogio])\n\n respond_to do |format|\n if @relogio.save\n format.html { redirect_to @relogio, notice: 'Relogio was successfully created.' }\n format.json { render json: @relogio, status: :created, location: @relogio }\n else\n format.html { render action: \"new\" }\n format.json { render json: @relogio.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @repondres = Repondre.all\n end",
"def create\n @resto = Resto.new(resto_params)\n\n respond_to do |format|\n if @resto.save\n format.html { redirect_to @resto, notice: 'Entry was successfully created.' }\n format.json { render :show, status: :created, location: @resto }\n else\n format.html { render :new }\n format.json { render json: @resto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @recepe = Recepe.new(recepe_params)\n\n respond_to do |format|\n if @recepe.save\n format.html { redirect_to @recepe, notice: 'Recepe was successfully created.' }\n format.json { render :show, status: :created, location: @recepe }\n else\n format.html { render :new }\n format.json { render json: @recepe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\n @prepagada = Prepagada.new({ :prepagada => params[:prepagada], :odontologo_id => params[:odontologo_id] })\n\n respond_to do |format|\n if @prepagada.save\n format.html { redirect_to @prepagada, notice: 'Prepagada was successfully created.' }\n format.json { render json: @prepagada, status: :created, location: @prepagada }\n else\n format.html { render action: \"new\" }\n format.json { render json: @prepagada.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\r\n @respuestum = Respuestum.new(respuestum_params)\r\n\r\n respond_to do |format|\r\n if @respuestum.save\r\n format.html { redirect_to @respuestum, notice: 'Respuestum was successfully created.' }\r\n format.json { render :show, status: :created, location: @respuestum }\r\n else\r\n format.html { render :new }\r\n format.json { render json: @respuestum.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def create\n @reparacion = Reparacion.new(params[:reparacion])\n\n respond_to do |format|\n if @reparacion.save\n format.html { redirect_to @reparacion, notice: 'Reparacion se ha creado con éxito.' }\n format.json { render json: @reparacion, status: :created, location: @reparacion }\n else\n format.html { render action: \"new\" }\n format.json { render json: @reparacion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n # services / get_nutrients.rb\n fetched_params = GetNutrients.new(params[:marmiton_url]).perform\n puts fetched_params\n @recipe = Recipe.new(fetched_params)\n respond_to do |format|\n if @recipe.save\n format.html { redirect_to root_path, notice: 'La recette a été crée.' }\n else\n format.html { redirect_to root_path, notice: \"La recette n'a pas pu être ajoutée.\" }\n end\n end\n end",
"def create\n @relatorio = Relatorio.new(relatorio_params)\n\n respond_to do |format|\n if @relatorio.save\n format.html { redirect_to @relatorio, notice: 'Relatorio was successfully created.' }\n format.json { render :show, status: :created, location: @relatorio }\n else\n format.html { render :new }\n format.json { render json: @relatorio.errors, status: :unprocessable_entity }\n end\n end\n end",
"def repuesto_params\n params.require(:repuesto).permit(:articulo, :precio, :id_interna, :descripcion)\n end",
"def create\n @remito = Remito.new(params[:remito])\n\n respond_to do |format|\n if @remito.save\n format.html { redirect_to @remito, notice: 'Remito was successfully created.' }\n format.json { render json: @remito, status: :created, location: @remito }\n else\n format.html { render action: \"new\" }\n format.json { render json: @remito.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_repondre\n @repondre = Repondre.find(params[:id])\n end",
"def create\n @recepcion = Recepcion.new(recepcion_params)\n\n respond_to do |format|\n if @recepcion.save\n format.html { redirect_to @recepcion, notice: 'Recepcion was successfully created.' }\n format.json { render :show, status: :created, location: @recepcion }\n else\n format.html { render :new }\n format.json { render json: @recepcion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @rego = Rego.new(rego_params)\n\n respond_to do |format|\n if @rego.save\n format.html { redirect_to @rego, notice: 'Rego was successfully created.' }\n format.json { render :show, status: :created, location: @rego }\n else\n format.html { render :new }\n format.json { render json: @rego.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @respuesta = Respuesta.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @respuesta }\n end\n end",
"def create\r\n @relatorio = Relatorio.new(relatorio_params)\r\n\r\n respond_to do |format|\r\n if @relatorio.save\r\n format.html { redirect_to @relatorio, notice: 'Relatório criado com sucesso.' }\r\n format.json { render :show, status: :created, location: @relatorio }\r\n else\r\n format.html { render :new }\r\n format.json { render json: @relatorio.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def new\n @repa = Repa.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @repa }\n end\n end",
"def create\n params.permit(:intitule, :estObligatoire, :nombreDeCaractere, :ordre, :sondage_id)\n ajout = QuestionOuverteService.instance.creerQuestionOuverte(params[:intitule], params[:estObligatoire], params[:nombreDeCaractere], params[:ordre], params[:sondage_id])\n (ajout != nil) ? (render json: ajout, status: :ok) : (render json: nil, status: :not_found)\n end",
"def create\n @recurso_servidor = RecursoServidor.new(recurso_servidor_params)\n\n respond_to do |format|\n if @recurso_servidor.save\n format.html { redirect_to @recurso_servidor, notice: 'Recurso solicitado com sucesso.' }\n format.json { render :show, status: :created, location: @recurso_servidor }\n else\n format.html { render :new }\n format.json { render json: @recurso_servidor.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @retroalimentacion = Retroalimentacion.new(params[:retro])\n\n respond_to do |format|\n if @retroalimentacion.save\n format.html { redirect_to @retroalimentacion, notice: 'Retroalimentacion was successfully created.' }\n format.json { render json: @retroalimentacion, status: :created, location: @retroalimentacion }\n else\n format.html { render action: \"new\" }\n format.json { render json: @retroalimentacion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @repa = Repa.new(params[:repa])\n @repa.user_id = current_user.id\n respond_to do |format|\n if @repa.save\n format.html { redirect_to @repa, notice: 'Repa was successfully created.' }\n format.json { render json: @repa, status: :created, location: @repa }\n else\n format.html { render action: \"new\" }\n format.json { render json: @repa.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @resist = Resist.new(resist_params)\n\n respond_to do |format|\n if @resist.save\n format.html { redirect_to @resist, notice: 'Resist was successfully created.' }\n format.json { render :show, status: :created, location: @resist }\n else\n format.html { render :new }\n format.json { render json: @resist.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n puts 'AQQQQQUUUUUUUIIIIII'\n json = ActiveSupport::JSON.decode(params[:pessoa])\n puts json\n @pessoa = Pessoa.new(json)\n # @address = Address.new(params[:address])\n\n # @client.addresses = @address\n\n respond_to do |format|\n if @pessoa.save\n format.html { redirect_to @pessoa, notice: 'Pessoa was successfully created.' }\n format.json { render json: @pessoa, status: :created, location: @pessoa }\n else\n format.html { render action: \"new\" }\n format.json { render json: @pessoa.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @remuneracao = Remuneracao.new(remuneracao_params)\n\n respond_to do |format|\n if @remuneracao.save\n format.html { redirect_to @remuneracao, notice: 'Remuneracao was successfully created.' }\n format.json { render :show, status: :created, location: @remuneracao }\n else\n format.html { render :new }\n format.json { render json: @remuneracao.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @ponderacion = Ponderacion.new(ponderacion_params)\n\n respond_to do |format|\n if @ponderacion.save\n format.html { redirect_to @ponderacion, notice: 'Ponderacion was successfully created.' }\n format.json { render :show, status: :created, location: @ponderacion }\n else\n format.html { render :new }\n format.json { render json: @ponderacion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @nota_reparacion = NotaReparacion.new(nota_reparacion_params)\n\n respond_to do |format|\n if @nota_reparacion.save\n format.html { redirect_to @nota_reparacion, notice: 'Nota reparacion was successfully created.' }\n format.json { render :show, status: :created, location: @nota_reparacion }\n else\n format.html { render :new }\n format.json { render json: @nota_reparacion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @reel = Reel.new(params[:reel])\n\n respond_to do |format|\n if @reel.save\n format.html { redirect_to @reel, notice: 'Reel was successfully created.' }\n format.json { render json: @reel, status: :created, location: @reel }\n else\n format.html { render action: \"new\" }\n format.json { render json: @reel.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @siren = Siren.new(siren_params)\n\n respond_to do |format|\n if @siren.save\n format.html { redirect_to @siren, notice: 'Siren was successfully created.' }\n format.json { render :show, status: :created, location: @siren }\n else\n format.html { render :new }\n format.json { render json: @siren.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @restora = Restora.new(restora_params)\n\n respond_to do |format|\n if @restora.save\n format.html { redirect_to @restora, notice: 'Restora was successfully created.' }\n format.json { render :show, status: :created, location: @restora }\n else\n format.html { render :new }\n format.json { render json: @restora.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @restricao = Restricao.new(restricao_params)\n\n respond_to do |format|\n if @restricao.save\n format.html { redirect_to restricaos_path, notice: 'Restrição foi Criada com Sucesso!' }\n # format.json { render :show, status: :created, location: @restricao }\n else\n format.html { render :new }\n format.json { render json: @restricao.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @recurso = Recurso.new(params[:recurso])\n\n respond_to do |format|\n if @recurso.save\n format.html { redirect_to @recurso, notice: 'O recurso de auto de infração foi criado com sucesso.' }\n format.json { render json: @recurso, status: :created, location: @recurso }\n else\n format.html { render action: \"new\" }\n format.json { render json: @recurso.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @renseignement = Renseignement.new(renseignement_params)\n \n\n respond_to do |format|\n if @renseignement.save\n format.html { redirect_to @renseignement, notice: \"Renseignement was successfully created.\" }\n format.json { render :show, status: :created, location: @renseignement }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @renseignement.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post(resource, params)\n case resource\n when \"pedidos\", \"place_order\", \"new_order\" then url = \"/pedidos\"\n when \"envios\", \"shipping\" then url = \"/envios\"\n else url = \"/#{resource}\"\n end\n\n post_request(url, params)\n end",
"def new\n @repuestum = Repuestum.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @repuestum }\n end\n end",
"def create\n @donjon = Donjon.new(donjon_params)\n\n respond_to do |format|\n if @donjon.save\n format.html { redirect_to @donjon, notice: 'Donjon was successfully created.' }\n format.json { render :show, status: :created, location: @donjon }\n else\n format.html { render :new }\n format.json { render json: @donjon.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @relacao_produto = RelacaoProduto.new(relacao_produto_params)\n\n respond_to do |format|\n if @relacao_produto.save\n format.html { redirect_to @relacao_produto, notice: 'Relacao produto was successfully created.' }\n format.json { render :show, status: :created, location: @relacao_produto }\n else\n format.html { render :new }\n format.json { render json: @relacao_produto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @rodada = Rodada.new(rodada_params)\n\n respond_to do |format|\n if @rodada.save\n format.html { redirect_to @rodada, notice: 'A Rodada foi criada com sucesso.' }\n format.json { render :show, status: :created, location: @rodada }\n\n log = File.new(\"LOG SISFILA.txt\", \"a+\")\n log.puts \"#{Time.new.day}/#{Time.new.month}/#{Time.new.year} #{Time.new.hour}:#{Time.new.min}:#{Time.new.sec} - A rodada #{@rodada.descricao} foi criada.\"\n log.puts \"ID DA RODADA: #{@rodada.id}, DESCRICAO: #{@rodada.descricao}, POSICAO ATUAL: #{@rodada.posicao_atual}, INSCRICAO GUEST: #{@rodada.inscricao_guest}. \\n\\n\"\n log.close\n\n else\n format.html { render :new }\n format.json { render json: @rodada.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @restaurante = Restaurante.new(restaurante_params)\n #@restaurante = Restaurante.new params.require(:restaurante).permit(:nome, :endereco,:especialidade)\n #@restaurante = Restaurante.new(params[:restaurante])\n respond_to do |format|\n if @restaurante.save\n format.html { redirect_to @restaurante, notice: 'Restaurante criado com sucesso!.' }\n format.json { render :show, status: :created, location: @restaurante }\n else\n format.html { render :new }\n format.json { render json: @restaurante.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @recibo = Recibo.find(params[:recibo_id])\n @renglon_recdetalle = @recibo.renglon_recdetalles.create(params[:renglon_recdetalle])\n\n respond_to do |format|\n if @renglon_recdetalle.save\n format.html { redirect_to @recibo, notice: 'Renglon recdetalle was successfully created.' }\n format.json { render json: @renglon_recdetalle }\n else\n format.html { render action: \"new\" }\n format.json { render json: @renglon_recdetalle.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @relcliruta = Relcliruta.new(relcliruta_params)\n\n respond_to do |format|\n if @relcliruta.save\n format.html { redirect_to @relcliruta, notice: 'Relcliruta was successfully created.' }\n format.json { render :show, status: :created, location: @relcliruta }\n format.js {flash.now[:notice] = 'El cliente se ha agregado de forma exitosa.'} #ajax\n else\n format.html { render :new }\n format.json { render json: @relcliruta.errors, status: :unprocessable_entity }\n format.js {flash.now[:alert] = 'Error al agregar el cliente.'} #ajax\n end\n end\n end",
"def create\n @reentrada = Reentrada.new(reentrada_params)\n\n @reentrada.cadastro_1_id = user.cadastro.id\n\n respond_to do |format|\n if @reentrada.save\n format.html { redirect_to reentradas_path, notice: 'Reentrada was successfully created.' }\n format.json { render :show, status: :created, location: @reentrada }\n else\n format.html { render :new }\n format.json { render json: @reentrada.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @pessoa_receber = PessoaReceber.new(params[:pessoa_receber])\n @pessoa_receber.user_id = current_user.id\n respond_to do |format|\n if @pessoa_receber.save\n format.html { redirect_to @pessoa_receber, :notice => 'Pessoa receber was successfully created.' }\n format.json { render :json => @pessoa_receber, :status => :created, :location => @pessoa_receber }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @pessoa_receber.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @presenza = Presenza.new(params[:presenza])\n\n respond_to do |format|\n if @presenza.save\n format.html { redirect_to @presenza, notice: 'Presenza was successfully created.' }\n format.json { render json: @presenza, status: :created, location: @presenza }\n else\n format.html { render action: \"new\" }\n format.json { render json: @presenza.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n recipeIngredient = rRcipeIngredient.create(recipeIngredient_params)\n render json: recipeIngredient\n end",
"def create\n @recipe = current_user.recipes.new(recipe_params)\n\n respond_to do |format|\n if @recipe.save\n if params[:lista].present?\n params[:lista].each do |(c,ingrediente)|\n Ingredient.create(name: ingrediente, recipe_id:@recipe.id) if ingrediente != \"\"\n end\n end\n format.html { redirect_to @recipe, notice: 'Recipe was successfully created.' }\n format.json { render :show, status: :created, location: @recipe }\n format.js {flash.now[:notice] = 'La receta se ha creado de forma exitosa.'} #ajax\n else\n format.html { render :new }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n format.js {flash.now[:alert] = 'Error al crear la receta.'} #ajax\n end\n end\n end",
"def create\n @reparacion = Reparacion.new(reparacion_params)\n @reparacion.rep_estado = 'Espera'\n @reparacion.rep_fecha_in=Time.new\n @reparacion.rep_fecha_term=\"0000/00/00\"\n respond_to do |format|\n if @reparacion.save\n format.html { redirect_to @reparacion, notice: 'Reparacion was successfully created.' }\n format.json { render :show, status: :created, location: @reparacion }\n else\n format.html { render :new }\n format.json { render json: @reparacion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @premio = Premio.new(params[:premio])\n\n respond_to do |format|\n if @premio.save\n format.html { redirect_to @premio, :notice => 'Premio was successfully created.' }\n format.json { render :json => @premio, :status => :created, :location => @premio }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @premio.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @repuesto_bolet = RepuestoBolet.new(repuesto_bolet_params)\n\n respond_to do |format|\n if @repuesto_bolet.save\n format.html { redirect_to @repuesto_bolet, notice: 'Repuesto bolet was successfully created.' }\n format.json { render :show, status: :created, location: @repuesto_bolet }\n else\n format.html { render :new }\n format.json { render json: @repuesto_bolet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @notadedebito = Notadedebito.find(params[:notadedebito_id])\n @renglon_notadebito = @notadedebito.renglon_notadebitos.create(params[:renglon_notadebito])\n\n respond_to do |format|\n if @renglon_notadebito.save\n format.html { redirect_to @notadebito, notice: 'Renglon notadebito was successfully created.' }\n format.json { render json: @renglon_notadebito}\n else\n format.html { render action: \"new\" }\n format.json { render json: @renglon_notadebito.errors}\n end\n end\n end",
"def create\n authorize! :create, :repost\n @fun.repost_by current_user\n Stat.recount @fun.user, :reposts\n render json: { success: true }\n end",
"def create\n @donatur = Donatur.new(donatur_params)\n\n respond_to do |format|\n if @donatur.save\n format.html { redirect_to donaturs_path, notice: 'Donatur was successfully created.' }\n format.json { render :show, status: :created, location: @donatur }\n else\n format.html { render :new }\n format.json { render json: @donatur.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @presenza = Presenza.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @presenza }\n end\n end",
"def new\n @puntaje = Puntaje.new\n atributos\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @puntaje }\n end\n end",
"def new\n @puntaje = Puntaje.new\n atributos\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @puntaje }\n end\n end",
"def new\n @reparacion = Reparacion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @reparacion }\n end\n end",
"def create\n @prodingrediant = Prodingrediant.new(prodingrediant_params)\n\n respond_to do |format|\n if @prodingrediant.save\n format.html { redirect_to @prodingrediant, notice: 'Prodingrediant was successfully created.' }\n format.json { render :show, status: :created, location: @prodingrediant }\n else\n format.html { render :new }\n format.json { render json: @prodingrediant.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @resveration = Resveration.new(resveration_params)\n\n respond_to do |format|\n if @resveration.save\n format.html { redirect_to @resveration, notice: 'Resveration was successfully created.' }\n format.json { render :show, status: :created, location: @resveration }\n else\n format.html { render :new }\n format.json { render json: @resveration.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @reeldatum = Reeldatum.new(reeldatum_params)\n\n respond_to do |format|\n if @reeldatum.save\n format.html { redirect_to @reeldatum, notice: 'Reeldatum was successfully created.' }\n format.json { render :show, status: :created, location: @reeldatum }\n else\n format.html { render :new }\n format.json { render json: @reeldatum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @addre = Addre.new(params[:addre])\n\n respond_to do |format|\n if @addre.save\n format.html { redirect_to @addre, notice: 'Addre was successfully created.' }\n format.json { render json: @addre, status: :created, location: @addre }\n else\n format.html { render action: \"new\" }\n format.json { render json: @addre.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @disponible = Disponible.new(disponible_params)\n\n if @disponible.save\n render json: @disponible, status: :created, location: @disponible\n else\n render json: @disponible.errors, status: :unprocessable_entity\n end\n end",
"def create\n @pigeon = current_user.pigeons.new(pigeon_params)\n\n respond_to do |format|\n if @pigeon.save\n format.html { redirect_to @pigeon, notice: 'Pigeon was successfully created.' }\n format.json { render :show, status: :created, location: @pigeon }\n else\n format.html { render :new }\n format.json { render json: @pigeon.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @resourcer = Resourcer.new(resourcer_params)\n\n respond_to do |format|\n if @resourcer.save\n format.html { redirect_to @resourcer, notice: 'Resourcer was successfully created.' }\n format.json { render :show, status: :created, location: @resourcer }\n else\n format.html { render :new }\n format.json { render json: @resourcer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @restaturant = Restaturant.new(restaturant_params)\n\n respond_to do |format|\n if @restaturant.save\n format.html { redirect_to @restaturant, notice: \"Restaturant was successfully created.\" }\n format.json { render :show, status: :created, location: @restaturant }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @restaturant.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @rfid = RFID.new(rfid_params)\n @rfid.pessoa = @pessoa\n respond_to do |format|\n if @rfid.save\n format.html { redirect_to @pessoa, success: 'RFID cadastrado com sucesso!' }\n format.json { render :show, status: :created, location: @rfid }\n else\n format.html {\n flash.now[:error] = @rfid.errors\n render :new\n }\n format.json { render json: @rfid.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @ingrediente = Ingrediente.new(ingrediente_params)\n\n respond_to do |format|\n if @ingrediente.save\n format.html { redirect_to @ingrediente, notice: 'Ingrediente was successfully created.' }\n format.json { render :show, status: :created, location: @ingrediente }\n else\n format.html { render :new }\n format.json { render json: @ingrediente.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @recoleccion = Recoleccion.new(recoleccion_params)\n\n respond_to do |format|\n if @recoleccion.save\n format.html { redirect_to @recoleccion, notice: 'Recoleccion was successfully created.' }\n format.json { render :show, status: :created, location: @recoleccion }\n else\n format.html { render :new }\n format.json { render json: @recoleccion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @rep = Rep.new(rep_params)\n @reps.user = current_user\n\n respond_to do |format|\n if @rep.save\n format.html { redirect_to @rep, notice: 'Rep was successfully created.' }\n format.json { render action: 'show', status: :created, location: @rep }\n else\n format.html { render action: 'new' }\n format.json { render json: @rep.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @rep = Rep.new(params[:rep])\n\n respond_to do |format|\n if @rep.save\n format.html { redirect_to(@rep, :notice => 'Rep was successfully created.') }\n format.xml { render :xml => @rep, :status => :created, :location => @rep }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @rep.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def moip_post\n @nasp_rail = NaspRail.new(params[:nasp_rail])\n\n format.html { redirect_to @nasp_rail, :notice => 'Nova entrada criada com sucesso.' }\n format.json { render :json => @nasp_rail, :status => :created, :location => @nasp_rail }\n end",
"def new\n @frais_repa = FraisRepa.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @frais_repa }\n end\n end",
"def create\n @relatorio_pedagogicos = RelatorioPedagogico.all\n authorize @relatorio_pedagogicos\n\n @relatorio_pedagogico = RelatorioPedagogico.new(relatorio_pedagogico_params)\n\n respond_to do |format|\n if @relatorio_pedagogico.save\n format.html { redirect_to @relatorio_pedagogico, notice: 'Relatório pedagógico criado com sucesso!' }\n format.json { render :show, status: :created, location: @relatorio_pedagogico }\n else\n format.html { render :new }\n format.json { render json: @relatorio_pedagogico.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @regra_negocio = RegraNegocio.new(regra_negocio_params)\n\n respond_to do |format|\n if @regra_negocio.save\n format.html { redirect_to @regra_negocio, notice: 'Regra negocio was successfully created.' }\n format.json { render :show, status: :created, location: @regra_negocio }\n else\n format.html { render :new }\n format.json { render json: @regra_negocio.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @prueba_json = PruebaJson.new(prueba_json_params)\n\n respond_to do |format|\n if @prueba_json.save\n format.html { redirect_to @prueba_json, notice: 'Prueba json was successfully created.' }\n format.json { render action: 'show', status: :created, location: @prueba_json }\n else\n format.html { render action: 'new' }\n format.json { render json: @prueba_json.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @administracao_relatorios_diario = Administracao::RelatoriosDiario.new(administracao_relatorios_diario_params)\n\n respond_to do |format|\n if @administracao_relatorios_diario.save\n format.html { redirect_to @administracao_relatorios_diario, notice: 'Relatorios diario was successfully created.' }\n format.json { render :show, status: :created, location: @administracao_relatorios_diario }\n else\n format.html { render :new }\n format.json { render json: @administracao_relatorios_diario.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @prepagada = Prepagada.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @prepagada }\n end\n end",
"def create\n @reprodutor = Reprodutor.new(reprodutor_params)\n\n respond_to do |format|\n if @reprodutor.save\n format.html { redirect_to @reprodutor, notice: 'Reprodutor was successfully created.' }\n format.json { render action: 'show', status: :created, location: @reprodutor }\n else\n format.html { render action: 'new' }\n format.json { render json: @reprodutor.errors, status: :unprocessable_entity }\n end\n end\n end",
"def repa_params\n params.require(:repa).permit(:titre, :descritpion, :date, :prix, :menu ,:entree, :places ,:plat, :dessert,:image)\n end",
"def create\n @persosn = Persosn.new(persosn_params)\n\n respond_to do |format|\n if @persosn.save\n format.html { redirect_to @persosn, notice: 'Persosn was successfully created.' }\n format.json { render :show, status: :created, location: @persosn }\n else\n format.html { render :new }\n format.json { render json: @persosn.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @plate = @restaurante.plates.create(plate_params)\n @plate.ratings ||= []\n @plate.clients_ratings ||= []\n\n respond_to do |format|\n if @plate.save\n format.html { redirect_to restaurante_plate_path(@restaurante, @plate),\n notice: 'Plato creado exitosamente.' }\n format.json { render :show, status: :created, location: @plate }\n else\n format.html { render :new }\n format.json { render json: @plate.errors,\n status: :unprocessable_entity }\n end\n end\n end",
"def create\n @sub_rep = SubRep.new(sub_rep_params)\n\n respond_to do |format|\n if @sub_rep.save\n format.html { redirect_to @sub_rep, notice: 'Sub rep was successfully created.' }\n format.json { render :show, status: :created, location: @sub_rep }\n else\n format.html { render :new }\n format.json { render json: @sub_rep.errors, status: :unprocessable_entity }\n end\n end\n end",
"def destroy\n @repondre.destroy\n respond_to do |format|\n format.html { redirect_to repondres_url, notice: 'Repondre was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def create\n @resturant = Resturant.new(resturant_params)\n\n respond_to do |format|\n if @resturant.save\n format.html { redirect_to root_url, notice: 'Resturant was successfully created.' }\n format.json { render :show, status: :created, location: @resturant }\n else\n format.html { render :new }\n format.json { render json: @resturant.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @requerimiento = Requerimiento.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @requerimiento }\n end\n end"
] |
[
"0.67486906",
"0.64910513",
"0.6474885",
"0.63194746",
"0.63150126",
"0.6292258",
"0.6246537",
"0.62076414",
"0.6195743",
"0.61589086",
"0.6140582",
"0.60337466",
"0.5992653",
"0.5990383",
"0.5952739",
"0.59474397",
"0.58888096",
"0.58568925",
"0.58505213",
"0.58457494",
"0.5821061",
"0.5802418",
"0.5792672",
"0.57746357",
"0.5749578",
"0.5745301",
"0.57440746",
"0.573258",
"0.5719937",
"0.57136923",
"0.57129055",
"0.570807",
"0.56901264",
"0.5683567",
"0.56766444",
"0.56666005",
"0.56584126",
"0.5657288",
"0.5643658",
"0.5631436",
"0.5630649",
"0.5623416",
"0.561582",
"0.5612241",
"0.5607656",
"0.5605066",
"0.5598319",
"0.55955374",
"0.5594478",
"0.5592548",
"0.55878663",
"0.5584177",
"0.5574496",
"0.55701464",
"0.55646956",
"0.5545401",
"0.55377686",
"0.5535656",
"0.55338216",
"0.5533395",
"0.5532183",
"0.5523072",
"0.551785",
"0.5512568",
"0.5511266",
"0.55107373",
"0.55097884",
"0.5507702",
"0.5505594",
"0.5498776",
"0.5498776",
"0.54933125",
"0.5493125",
"0.5492538",
"0.5491956",
"0.5489897",
"0.54882133",
"0.5486172",
"0.5486101",
"0.54844964",
"0.5482886",
"0.54820454",
"0.5479792",
"0.54763687",
"0.547602",
"0.54760087",
"0.5464815",
"0.5464359",
"0.5462849",
"0.5462806",
"0.5461453",
"0.545602",
"0.5455792",
"0.5455228",
"0.54544365",
"0.54532754",
"0.54518527",
"0.54511094",
"0.54450303",
"0.5442412"
] |
0.7267646
|
0
|
PATCH/PUT /repondres/1 PATCH/PUT /repondres/1.json
|
def update
respond_to do |format|
if @repondre.update(repondre_params)
format.html { redirect_to @repondre, notice: 'Repondre was successfully updated.' }
format.json { render :show, status: :ok, location: @repondre }
else
format.html { render :edit }
format.json { render json: @repondre.errors, status: :unprocessable_entity }
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def patch!\n request! :patch\n end",
"def api_patch(path, data = {})\n api_request(:patch, path, :data => data)\n end",
"def patch\n headers = {\"If-Match\" => @version}\n response = @context.request :patch, \"#{@path}/#{@id}\", @data.to_json, headers\n @version += 1\n response\n # 'X-HTTP-Method-Override' => 'PATCH'\n end",
"def patch options\n rest_request({ method: :patch }.merge(options))\n end",
"def patch options\n rest_request({ method: :patch }.merge(options))\n end",
"def update\n respond_to do |format|\n if @resto.update(resto_params)\n format.html { redirect_to @resto, notice: 'Entry was successfully updated.' }\n format.json { render :show, status: :ok, location: @resto }\n else\n format.html { render :edit }\n format.json { render json: @resto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @repuesto.update(repuesto_params)\n format.html { redirect_to @repuesto, notice: 'Repuesto was successfully updated.' }\n format.json { render :show, status: :ok, location: @repuesto }\n else\n format.html { render :edit }\n format.json { render json: @repuesto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @respuesta = Respuesta.find(params[:id])\n\n if @respuesta.update(params[:respuesta])\n head :no_content\n else\n render json: @respuesta.errors, status: :unprocessable_entity\n end\n end",
"def update\n @respuesta = Respuesta.find(params[:id])\n\n respond_to do |format|\n if @respuesta.update_attributes(params[:respuesta])\n format.html { redirect_to @respuesta, notice: 'Respuesta was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @respuesta.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @rep.update(rep_params)\n format.html { redirect_to @rep, notice: 'Rep was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @rep.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @rest.update(rest_params)\n format.html { redirect_to @rest, notice: 'Rest was successfully updated.' }\n format.json { render :show, status: :ok, location: @rest }\n else\n format.html { render :edit }\n format.json { render json: @rest.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update(url, data)\n RestClient.put url, data, :content_type => :json\nend",
"def rest_edit(path, options={}, &blk)\n callback = Proc.new { |*args|\n @object = yield(*args) or pass\n rest_params.each { |k, v| @object.send :\"#{k}=\", v unless k == 'id' }\n\n return 400, @object.errors.to_json unless @object.valid?\n\n @object.save\n rest_respond @object\n }\n\n # Make it work with `Backbone.emulateHTTP` on.\n put path, &callback\n post path, &callback\n end",
"def rest_edit(path, options={}, &blk)\n callback = Proc.new { |*args|\n @object = yield(*args) or pass\n rest_params.each { |k, v| @object.send :\"#{k}=\", v unless k == 'id' }\n\n return 400, @object.errors.to_json unless @object.valid?\n\n @object.save\n rest_respond @object\n }\n\n # Make it work with `Backbone.emulateHTTP` on.\n put path, &callback\n post path, &callback\n end",
"def update\n respond_to do |format|\n if @repa.update(repa_params)\n format.html { redirect_to @repa, notice: 'Votre repas a bien été mis à jour' }\n format.json { render :show, status: :ok, location: @repa }\n else\n format.html { render :edit }\n format.json { render json: @repa.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @repa = Repa.find(params[:id])\n\n respond_to do |format|\n if @repa.update_attributes(params[:repa])\n format.html { redirect_to @repa, notice: 'Repa was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @repa.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @resi.update(resi_params)\n format.html { redirect_to @resi, notice: 'Resi was successfully updated.' }\n format.json { render :show, status: :ok, location: @resi }\n else\n format.html { render :edit }\n format.json { render json: @resi.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @repuesto_servicio.update(repuesto_servicio_params)\n format.html { redirect_to @repuesto_servicio, notice: 'Repuesto o servicio fue actualizado con éxito.' }\n format.json { render :show, status: :ok, location: @repuesto_servicio }\n else\n format.html { render :edit }\n format.json { render json: @repuesto_servicio.errors, status: :unprocessable_entity }\n end\n end\n end",
"def rest_patch(base_uri,json_payload,params)\n begin\n @response = RestClient.patch(base_uri,json_payload,params)\n rescue => e\n puts @response.code\n end\n return @response\n end",
"def update\n @frais_repa = FraisRepa.find(params[:id])\n\n respond_to do |format|\n if @frais_repa.update_attributes(params[:frais_repa])\n format.html { redirect_to @frais_repa, :notice => 'Le frais de repas a bien été modifé' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @frais_repa.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def patch(type, info)\n path, info = type_info(type, :path), force_case(info)\n ida = type == :client ? 'client_id' : 'id'\n raise ArgumentError, \"info must include #{ida}\" unless id = info[ida]\n hdrs = headers\n if info && info['meta'] && (etag = info['meta']['version'])\n hdrs.merge!('if-match' => etag)\n end\n reply = json_parse_reply(@key_style,\n *json_patch(@target, \"#{path}/#{Addressable::URI.encode(id)}\", info, hdrs))\n\n # hide client endpoints that are not quite scim compatible\n type == :client && !reply ? get(type, info['client_id']): reply\n end",
"def patch(path, data)\n request 'PATCH', path, body: data.to_json\n end",
"def update\n respond_to do |format|\n if @recepe.update(recepe_params)\n format.html { redirect_to @recepe, notice: 'Recepe was successfully updated.' }\n format.json { render :show, status: :ok, location: @recepe }\n else\n format.html { render :edit }\n format.json { render json: @recepe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @resist.update(resist_params)\n format.html { redirect_to @resist, notice: 'Resist was successfully updated.' }\n format.json { render :show, status: :ok, location: @resist }\n else\n format.html { render :edit }\n format.json { render json: @resist.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_with []\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 update\n @repuestum = Repuestum.find(params[:id])\n\n respond_to do |format|\n if @repuestum.update_attributes(params[:repuestum])\n format.html { redirect_to @repuestum, notice: 'Repuestum was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @repuestum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @restroom.update(restroom_params)\n format.html { redirect_to @restroom, notice: 'Restroom was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @restroom.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update(&block)\n validate_request()\n\n # Params includes all of the PATCH data at the top level along with other\n # other Rails-injected params like 'id', 'action', 'controller'. These\n # are harmless given no namespace collision and we're only interested in\n # the 'Operations' key for the actual patch data.\n #\n render(json: yield(self.safe_params()[:id], self.safe_params().to_hash()))\n end",
"def update\n respond_to do |format|\n if @restora.update(restora_params)\n format.html { redirect_to @restora, notice: 'Restora was successfully updated.' }\n format.json { render :show, status: :ok, location: @restora }\n else\n format.html { render :edit }\n format.json { render json: @restora.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update # PATCH\n raise NotImplementedError\n end",
"def update!(params)\n res = @client.put(path, nil, params, \"Content-Type\" => \"application/json\")\n @attributes = res.json if res.status == 201\n res\n end",
"def update\n recipe.update(recipe_params)\n render json: recipe\n end",
"def partial_update(klass, id, patchset, options = {}, format = nil)\n headers = {}\n headers[:accept] = \"#{format}\" if format\n format ||= @default_format\n options = { resource: klass, id: id, format: format}.merge options\n if [FHIR::Formats::ResourceFormat::RESOURCE_XML, FHIR::Formats::ResourceFormat::RESOURCE_XML_DSTU2].include?(format)\n options[:format] = FHIR::Formats::PatchFormat::PATCH_XML\n headers[:content_type] = \"#{FHIR::Formats::PatchFormat::PATCH_XML}\"\n elsif [FHIR::Formats::ResourceFormat::RESOURCE_JSON, FHIR::Formats::ResourceFormat::RESOURCE_JSON_DSTU2].include?(format)\n options[:format] = FHIR::Formats::PatchFormat::PATCH_JSON\n headers[:content_type] = \"#{FHIR::Formats::PatchFormat::PATCH_JSON}\"\n end\n headers[:prefer] = @return_preference if @use_return_preference\n reply = patch resource_url(options), patchset, fhir_headers(headers)\n reply.resource = parse_reply(klass, format, reply)\n reply.resource_class = klass\n reply\n end",
"def update\n @recurso = Recurso.find(params[:id])\n\n respond_to do |format|\n if @recurso.update_attributes(params[:recurso])\n format.html { redirect_to @recurso, notice: 'O recurso de auto de infração foi atualizado com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @recurso.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @repertoire.update(repertoire_params)\n render :show, status: :ok, location: @repertoire\n else\n render json: @repertoire.errors, status: :unprocessable_entity\n end\n end",
"def update\n @data = @recipe.update(params[:id], recipe_params)\n render json: @data\n end",
"def update\n respond_to do |format|\n if @tipoapreensao.update(tipoapreensao_params)\n format.html { redirect_to @tipoapreensao, notice: 'Tipoapreensao was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @tipoapreensao.errors, status: :unprocessable_entity }\n end\n end\n end",
"def rm_update path, data, msg\n\n re = rm_request path, data, 'PUT'\n puts re.body\n chk (re.code!='200'), msg + \"\\n#{re.code} #{re.msg}\\n\\n\"\n return true\n\nend",
"def update\n respond_to do |format|\n format.xml { head :method_not_allowed }\n format.json { head :method_not_allowed }\n end\n end",
"def update\n respond_to do |format|\n if @sivic_discipulo.update(sivic_discipulo_params_netested)\n format.html { redirect_to @sivic_discipulo, notice: 'Registro alterado com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @sivic_discipulo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @remito = Remito.find(params[:id])\n\n respond_to do |format|\n if @remito.update_attributes(params[:remito])\n format.html { redirect_to @remito, notice: 'Remito was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @remito.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @relogio = Relogio.find(params[:id])\n\n respond_to do |format|\n if @relogio.update_attributes(params[:relogio])\n format.html { redirect_to @relogio, notice: 'Relogio was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @relogio.errors, status: :unprocessable_entity }\n end\n end\n end",
"def patch(path, params = {})\n request(:patch, path, params)\n end",
"def patch(path, params = {})\n request(:patch, path, params)\n end",
"def update\n respond_to do |format|\n if @remixer.update(remixer_params)\n format.html { redirect_to @remixer, notice: 'Remixer was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @remixer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def patch\n end",
"def patch(url, payload, headers={})\n RestClient.patch url, payload, headers\n end",
"def activo_update\n respond_to do |format|\n activo = params[:laboratorio][:activo]\n id = params[:id]\n Laboratorio.where(id: id).update_all(activo: activo )\n msg = { :status => \"ok\", :message => \"Actualizado!\" }\n format.json { render :json => msg }\n end\n end",
"def update\n @reconocimiento = Reconocimiento.find(params[:id])\n\n respond_to do |format|\n if @reconocimiento.update_attributes(params[:reconocimiento])\n format.html { redirect_to @reconocimiento, :notice => 'Reconocimiento was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @reconocimiento.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n\n respond_to do |format|\n if @respuestum.update_attributes(params[:respuestum])\n @redireccion = Comment.find(@respuestum.comment_id)\n format.html { redirect_to(@redireccion, :notice => 'Respuesta actualizada correctamente.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @respuestum.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @clientes_servico.update(clientes_servico_params)\n format.html { redirect_to @clientes_servico, notice: 'Clientes servico was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @clientes_servico.errors, status: :unprocessable_entity }\n end\n end\n end",
"def edit\n respond_with(reagent)\n end",
"def update\n respond_to do |format|\n if @recurso_servidor.update(recurso_servidor_params)\n format.html { redirect_to @recurso_servidor, notice: 'Recurso servidor was successfully updated.' }\n format.json { render :show, status: :ok, location: @recurso_servidor }\n else\n format.html { render :edit }\n format.json { render json: @recurso_servidor.errors, status: :unprocessable_entity }\n end\n end\n end",
"def patch(path, **args); end",
"def update\n respond_to do |format|\n if @api_v1_resource.update(api_v1_resource_params)\n format.html { redirect_to @api_v1_resource, notice: 'Resource was successfully updated.' }\n format.json { render :show, status: :ok, location: @api_v1_resource }\n else\n format.html { render :edit }\n format.json { render json: @api_v1_resource.errors, status: :unprocessable_entity }\n end\n end\n end",
"def patch(operation, path, value = nil)\n ensure_client && ensure_uri\n body = {\n 'op' => operation,\n 'path' => path,\n 'value' => value\n }\n response = @client.rest_patch(@data['uri'], { 'Content-Type' => 'application/json-patch+json', 'body' => [body] }, @api_version)\n @client.response_handler(response)\n end",
"def update\n @ore = Ore.find(params[:id])\n \n respond_to do |format|\n if @ore.update_attributes(params[:ore])\n format.html { redirect_to @ore, notice: 'Ore was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @ore.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @reel = Reel.find(params[:id])\n\n respond_to do |format|\n if @reel.update_attributes(params[:reel])\n format.html { redirect_to @reel, notice: 'Reel was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @reel.errors, status: :unprocessable_entity }\n end\n end\n end",
"def patch(path, opts = {})\n request(:patch, path, opts).body\n end",
"def update\n respond_to do |format|\n if @rest_api.update(rest_api_params)\n format.html { redirect_to @rest_api, notice: 'Rest api was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @rest_api.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @pessoa_receber = PessoaReceber.find(params[:id])\n\n respond_to do |format|\n if @pessoa_receber.update_attributes(params[:pessoa_receber])\n format.html { redirect_to @pessoa_receber, :notice => 'Pessoa receber was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @pessoa_receber.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @first_rip.update(first_rip_params)\n format.html { redirect_to @first_rip, notice: 'First rip was successfully updated.' }\n format.json { render :show, status: :ok, location: @first_rip }\n else\n format.html { render :edit }\n format.json { render json: @first_rip.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @solicitacao_repass.update(solicitacao_repasse_params)\n format.html { redirect_to @solicitacao_repass, notice: \"Solicitacao repasse was successfully updated.\" }\n format.json { render :show, status: :ok, location: @solicitacao_repass }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @solicitacao_repass.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @reparacion = Reparacion.find(params[:id])\n\n respond_to do |format|\n if @reparacion.update_attributes(params[:reparacion])\n format.html { redirect_to @reparacion, notice: 'Reparacion se ha actualizado correctamente.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @reparacion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @api_v1_todo.update(api_v1_todo_params)\n format.json { render json: @api_v1_todo, status: :ok }\n else\n format.json { render json: @api_v1_todo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @telefon = Telefon.find(params[:id])\n @telefon.update_attributes(params[:telefon])\n respond_with(@telefon)\n end",
"def update\n respond_to do |format|\n if @restricao.update(restricao_params)\n format.html { redirect_to @restricao, notice: 'Restrição foi Editada com Sucesso!' }\n format.json { render :show, status: :ok, location: @restricao }\n else\n format.html { render :edit }\n format.json { render json: @restricao.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n# respond_to do |format|\n# if @req.update(req_params)\n format.json { render :json => {:status => 'success'}}\n# format.html { redirect_to @req, notice: 'Req was successfully updated.' }\n# format.json { render :show, status: :ok, location: @req }\n# else\n format.json { render :json => {:status => 'failed'}}\n# format.html { render :edit }\n# format.json { render json: @req.errors, status: :unprocessable_entity }\n# end\n# end\n end",
"def update\n respond_to do |format|\n if @remind.update(remind_params)\n format.html { redirect_to @remind, notice: 'Reminder was successfully updated.' }\n format.json { render :show, status: :ok, location: @remind }\n else\n format.html { render :edit }\n format.json { render json: @remind.errors, status: :unprocessable_entity }\n end\n end\n end",
"def UpdateView params = {}\n \n APICall(path: 'views.json',method: 'PUT',payload: params.to_json)\n \n end",
"def update\r\n respond_to do |format|\r\n if @sivic_rede.update(sivic_rede_params)\r\n format.html { redirect_to @sivic_rede, notice: 'Rede foi alterada com sucesso.' }\r\n format.json { head :no_content }\r\n else\r\n format.html { render action: 'edit' }\r\n format.json { render json: @sivic_rede.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def update\n respond_to do |format|\n if @resturant.update(resturant_params)\n format.html { redirect_to @resturant, notice: 'Resturant was successfully updated.' }\n format.json { render :show, status: :ok, location: @resturant }\n else\n format.html { render :edit }\n format.json { render json: @resturant.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @requerimiento = Requerimiento.find(params[:id])\n\n respond_to do |format|\n if @requerimiento.update_attributes(params[:requerimiento])\n format.html { redirect_to \"#{requerimientos_path}/#{@requerimiento.numero}\", notice: 'Requerimiento was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @requerimiento.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @productos = Car.where(:pedidoID => params[:id])\n respond_to do |format| \n if @pedido.update(pedido_params)\n \n format.html { redirect_to \"/\", notice: 'Pedido was successfully updated.' }\n format.json { render :show, status: :ok, location: @pedido }\n RestClient.post \"https://api:key-e7d79c66e74391fdf48b657624f23ddc\"\\\n \"@api.mailgun.net/v3/sandboxb9c2dadab0ea49f6b7130d1091646c59.mailgun.org/messages\",\n :from => \"Sistema de Pedidos <mailgun@sandboxb9c2dadab0ea49f6b7130d1091646c59.mailgun.org>\",\n #:to => \"proteina@sinergroup.com.mx\",\n :to => \"proteina@sinergroup.com.mx\",\n :subject => \"Solicitud de Pedido\",\n :html => (render_to_string(template: \"../views/pedidos/email\")).to_str\n else\n format.html { render :edit }\n format.json { render json: @pedido.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n #Finding the specific chore where the id matches the one we pass in with the body\n @v1_chore = Chore.where(id: params[:id]).first\n #Here we're checking if we have user_id in our body, and if we do, we'll change the selected chore's properties\n #with the parameters of the body, we go through the specific group to our specific chore with the path\n if v1_chore_params[:user_id]\n @v1_chore.user_id = params[:user_id]\n @v1_chore.assigned = true\n if @v1_chore.save\n render :show, status: :ok\n end\n else\n render json: @v1_chore.errors, status: :unprocessable_entity\n end\n end",
"def update\n @one = One.find(params[:id])\n\n respond_to do |format|\n if @one.update_attributes(params[:one])\n format.html { redirect_to @one, notice: 'One was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @one.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @regraponto.update(regraponto_params)\n format.html { redirect_to @regraponto, notice: 'Regraponto was successfully updated.' }\n format.json { render :show, status: :ok, location: @regraponto }\n else\n format.html { render :edit }\n format.json { render json: @regraponto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @premio = Premio.find(params[:id])\n\n respond_to do |format|\n if @premio.update_attributes(params[:premio])\n format.html { redirect_to @premio, :notice => 'Premio was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @premio.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @contas_receber.update(contas_receber_params)\n format.html { redirect_to @contas_receber, notice: 'Contas a receber alterado com sucesso.' }\n format.json { render :show, status: :ok, location: @contas_receber }\n else\n format.html { render :edit }\n format.json { render json: @contas_receber.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @objeto.update(cliente_params)\n set_redireccion\n format.html { redirect_to @redireccion, notice: 'Cliente was successfully updated.' }\n format.json { render :show, status: :ok, location: @objeto }\n else\n format.html { render :edit }\n format.json { render json: @objeto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @residencia.update(residencia_params)\n format.html { redirect_to [@programa, @residencia], notice: 'residencia was successfully updated.' }\n format.json { render :show, status: :ok, location: [@programa, @residencia] }\n else\n format.html { render :edit }\n format.json { render json: @residencia.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update options={}\n client.put(\"/#{id}\", options)\n end",
"def update\n @restroom = Restroom.find(params[:id])\n authorize! :update, @restroom\n\n respond_to do |format|\n if @restroom.update_attributes(params[:restroom])\n format.html { redirect_to @restroom, notice: 'Restroom was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @restroom.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @restroom = Restroom.find(params[:id])\n authorize! :update, @restroom\n\n respond_to do |format|\n if @restroom.update_attributes(params[:restroom])\n format.html { redirect_to @restroom, notice: 'Restroom was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @restroom.errors, status: :unprocessable_entity }\n end\n end\n end",
"def patch(path, data, params = {}, request_options = {})\n request(:patch, path, data, params)\n end",
"def update\n respond_to do |format|\n if @objeto.update(requisito_params)\n format.html { redirect_to @objeto, notice: \"Requisito was successfully updated.\" }\n format.json { render :show, status: :ok, location: @objeto }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @objeto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @resa.update(resa_params)\n format.html { redirect_to edit_resa_path(@resa), notice: 'Resa was successfully updated.' }\n format.json { render json: @resa, status: :accepted }\n\n else\n format.html { render action: 'edit' }\n format.json { render json: @resa.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @smp_referenz.update(smp_referenz_params)\n format.html { redirect_to @smp_referenz, notice: 'Smp referenz was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @smp_referenz.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @rep = Rep.find(params[:id])\n\n respond_to do |format|\n if @rep.update_attributes(params[:rep])\n format.html { redirect_to(@rep, :notice => 'Rep was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @rep.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n save_relations\n if @recipe.update(recipe_params)\n format.html { redirect_to @recipe, notice: 'Recipe was successfully updated.' }\n format.json { render :show, status: :ok, location: @recipe }\n else\n format.html { render :edit }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @repa = Repa.find(params[:id])\n\n if params[:destroy]\n @result = @repa.destroy\n @notice = 'Ce repas a été supprimée avec succés.'\n else\n @result = @repa.update_attributes(params[:repa])\n @notice = 'Cette pesée a été modifiée avec succés.'\n end\n\n\n respond_to do |format|\n if @result\n format.html { redirect_to repas_url, notice: @notice }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @repa.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @restroom = Restroom.find(params[:id])\n authorize @restroom\n\n respond_to do |format|\n if @restroom.update_attributes(params[:restroom])\n format.html { redirect_to @restroom, notice: 'Restroom was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @restroom.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @objeto.update(imagen_params)\n set_redireccion\n format.html { redirect_to @redireccion, notice: 'Imagen was successfully updated.' }\n format.json { render :show, status: :ok, location: @objeto }\n else\n format.html { render :edit }\n format.json { render json: @objeto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @json.update(json_params)\n format.html { redirect_to @json, notice: 'Json was successfully updated.' }\n format.json { render :show, status: :ok, location: @json }\n else\n format.html { render :edit }\n format.json { render json: @json.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @json.update(json_params)\n format.html { redirect_to @json, notice: 'Json was successfully updated.' }\n format.json { render :show, status: :ok, location: @json }\n else\n format.html { render :edit }\n format.json { render json: @json.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @recepcion.update(recepcion_params)\n format.html { redirect_to @recepcion, notice: 'Recepcion was successfully updated.' }\n format.json { render :show, status: :ok, location: @recepcion }\n else\n format.html { render :edit }\n format.json { render json: @recepcion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @recoleccion = Recoleccion.find(params[:id])\n\n respond_to do |format|\n if @recoleccion.update_attributes(params[:recoleccion])\n format.html { redirect_to @recoleccion, notice: 'Recoleccion was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @recoleccion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @docs_ponto.update(docs_ponto_params)\n format.html { redirect_to :back }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @docs_ponto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if request.content_type == \"application/json\"\n # .update is like a \"update people set ...\" in sql\n if @person.update(person_params)\n render json: @person\n else\n render json: @person.errors, status: :not_found\n end\n else\n render status: :bad_request\n end\n end"
] |
[
"0.6501582",
"0.6449516",
"0.64425606",
"0.64194584",
"0.64194584",
"0.6331684",
"0.63238007",
"0.6316814",
"0.6294377",
"0.6283186",
"0.62355757",
"0.6211169",
"0.6210132",
"0.6210132",
"0.6201105",
"0.61946887",
"0.6174476",
"0.6165434",
"0.61550134",
"0.6143365",
"0.61415476",
"0.61414933",
"0.6121565",
"0.61151093",
"0.61043215",
"0.60927",
"0.6083108",
"0.6081639",
"0.6077845",
"0.60753244",
"0.6069682",
"0.6012198",
"0.6003714",
"0.5997376",
"0.598859",
"0.5983054",
"0.5967352",
"0.5932568",
"0.5917049",
"0.59169555",
"0.5913043",
"0.5904907",
"0.58980083",
"0.58945805",
"0.58945805",
"0.58907795",
"0.5885838",
"0.58702725",
"0.5842269",
"0.5829468",
"0.5828891",
"0.5828646",
"0.5828134",
"0.58272076",
"0.582346",
"0.582111",
"0.5816163",
"0.580729",
"0.58033764",
"0.5801999",
"0.5800247",
"0.58002436",
"0.5798315",
"0.57960534",
"0.57918227",
"0.5789976",
"0.57848597",
"0.57833236",
"0.57810175",
"0.57784885",
"0.5777494",
"0.57739496",
"0.57699096",
"0.57696",
"0.5767863",
"0.57671905",
"0.5764819",
"0.5763898",
"0.5755474",
"0.57524514",
"0.5751095",
"0.574878",
"0.57434225",
"0.57384",
"0.57384",
"0.5736068",
"0.57352024",
"0.5734595",
"0.57326555",
"0.5730402",
"0.5730328",
"0.57299155",
"0.5728667",
"0.5727403",
"0.5721049",
"0.5721049",
"0.572081",
"0.57150704",
"0.5714812",
"0.5709897"
] |
0.6540675
|
0
|
DELETE /repondres/1 DELETE /repondres/1.json
|
def destroy
@repondre.destroy
respond_to do |format|
format.html { redirect_to repondres_url, notice: 'Repondre was successfully destroyed.' }
format.json { head :no_content }
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def delete\n client.delete(\"/#{id}\")\n end",
"def destroy\n @relogio = Relogio.find(params[:id])\n @relogio.destroy\n\n respond_to do |format|\n format.html { redirect_to relogios_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @repuestum = Repuestum.find(params[:id])\n @repuestum.destroy\n\n respond_to do |format|\n format.html { redirect_to repuesta_url }\n format.json { head :no_content }\n end\n end",
"def delete(path)\n RestClient.delete request_base+path\n end",
"def destroy\n @respuesta = Respuesta.find(params[:id])\n @respuesta.destroy\n\n respond_to do |format|\n format.html { redirect_to respuestas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @repa = Repa.find(params[:id])\n @repa.destroy\n\n respond_to do |format|\n format.html { redirect_to repas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @repa = Repa.find(params[:id])\n @repa.destroy\n\n respond_to do |format|\n format.html { redirect_to repas_url }\n format.json { head :no_content }\n end\n end",
"def delete!\n Recliner.delete(uri)\n end",
"def destroy\n @rep.destroy\n respond_to do |format|\n format.html { redirect_to reps_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @respuesta = Respuesta.find(params[:id])\n @respuesta.destroy\n\n head :no_content\n end",
"def destroy\n @remito = Remito.find(params[:id])\n @remito.destroy\n\n respond_to do |format|\n format.html { redirect_to remitos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @rescate.destroy\n respond_to do |format|\n format.html { redirect_to rescates_url, notice: 'Rescate fue eleminado' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @reconocimiento = Reconocimiento.find(params[:id])\n @reconocimiento.destroy\n\n respond_to do |format|\n format.html { redirect_to reconocimientos_url }\n format.json { head :no_content }\n end\n end",
"def delete\n url = prefix + \"delete\"\n return response(url)\n end",
"def delete\n url = prefix + \"delete\"\n return response(url)\n end",
"def delete\n res = HTTParty.get URL, headers: HEADERS\n message = JSON.parse res.body, symbolize_names: true\n if res.code == 200\n numSubs = message[:data].count\n if numSubs > 0\n message[:data].each do |sub|\n id = sub[:id]\n delRes = HTTParty.delete \"#{URL}/#{id}\", headers: HEADERS\n #TODO handle status codes\n end\n end\n end\n end",
"def delete_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 @red.destroy\n respond_to do |format|\n format.html { redirect_to reds_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n RestClient.delete \"#{REST_API_URI}/contents/#{id}.xml\" \n self\n end",
"def destroy\n @requerimiento = Requerimiento.find(params[:id])\n @requerimiento.destroy\n\n respond_to do |format|\n format.html { redirect_to requerimientos_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @receipe = Receipe.find(params[:id])\n @receipe.destroy\n\n respond_to do |format|\n format.html { redirect_to receipes_url }\n format.json { head :no_content }\n end\n end",
"def delete\n url = prefix + \"delete\" + id_param\n return response(url)\n end",
"def destroy\n @addre = Addre.find(params[:id])\n @addre.destroy\n\n respond_to do |format|\n format.html { redirect_to addres_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @resi.destroy\n respond_to do |format|\n format.html { redirect_to resis_url, notice: 'Resi was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @respuestum.destroy\n respond_to do |format|\n format.html { redirect_to comentarios_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @restaurantes_proximo.destroy\n respond_to do |format|\n format.html { redirect_to restaurantes_proximos_url, notice: 'Restaurantes proximo was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete\n supprimer = SondageService.instance.supprimerSondage(params[:id])\n (supprimer) ? (render json: true, status: :ok) : (render json: false, status: :not_found)\nend",
"def destroy\n @repuesto.destroy\n respond_to do |format|\n format.html { redirect_to repuestos_url, notice: 'Repuesto was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @repuesto.destroy\n respond_to do |format|\n format.html { redirect_to repuestos_url, notice: 'Repuesto was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @frais_repa = FraisRepa.find(params[:id])\n @frais_repa.destroy\n\n respond_to do |format|\n format.html { redirect_to frais_repas_url }\n format.json { head :no_content }\n end\n end",
"def delete path\n make_request(path, \"delete\", {})\n end",
"def destroy\n @resa.destroy\n respond_to do |format|\n format.html { redirect_to resas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @autore = Autore.find(params[:id])\n @autore.destroy\n\n respond_to do |format|\n format.html { redirect_to autores_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @resto.destroy\n respond_to do |format|\n format.html { redirect_to restos_url, notice: 'Entry was deleted.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @regraponto.destroy\n respond_to do |format|\n format.html { redirect_to regrapontos_url, notice: 'Regraponto was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @recurso = Recurso.find(params[:id])\n @recurso.destroy\n\n respond_to do |format|\n format.html { redirect_to recursos_url }\n format.json { head :no_content }\n end\n end",
"def delete\n RestClient.delete(url, @header) do |rso, req, res|\n setup(rso, req, res)\n end\n end",
"def destroy\n @retroalimentacion = Retroalimentacion.find(params[:id])\n @retroalimentacion.destroy\n\n respond_to do |format|\n format.html { redirect_to retroalimentacions_url }\n format.json { head :no_content }\n end\n end",
"def do_delete(uri = \"\")\n @connection.delete do |req|\n req.url uri\n req.headers['Content-Type'] = 'application/json'\n end\n end",
"def destroy\n @one = One.find(params[:id])\n @one.destroy\n\n respond_to do |format|\n format.html { redirect_to ones_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @rep = Rep.find(params[:id])\n @rep.destroy\n\n respond_to do |format|\n format.html { redirect_to(reps_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @reel = Reel.find(params[:id])\n @reel.destroy\n\n respond_to do |format|\n format.html { redirect_to reels_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @drip = Drip.find(params[:id])\n @drip.destroy\n\n respond_to do |format|\n format.html { redirect_to drips_url }\n format.json { head :no_content }\n end\n end",
"def delete\n client.delete(url)\n @deleted = true\nend",
"def destroy\n @first_rip.destroy\n respond_to do |format|\n format.html { redirect_to first_rips_url, notice: 'First rip was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @prueba_json.destroy\n respond_to do |format|\n format.html { redirect_to prueba_jsons_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @resist.destroy\n respond_to do |format|\n format.html { redirect_to resists_url, notice: 'Resist was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @remedio = Remedio.find(params[:id])\n @remedio.destroy\n\n respond_to do |format|\n format.html { redirect_to remedios_url }\n format.json { head :no_content }\n end\n end",
"def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end",
"def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end",
"def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end",
"def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end",
"def delete(*rest) end",
"def destroy\n @recinto = Recinto.find(params[:id])\n @recinto.destroy\n\n respond_to do |format|\n format.html { redirect_to recintos_url }\n format.json { head :no_content }\n end\n end",
"def delete\n start { |connection| connection.request http :Delete }\n end",
"def delete(path)\n repository = path.split(/\\//)[2]\n objectid = path.split(/\\//)[3]\n if storage_fetch(repository, objectid) && storage_delete(repository, objectid)\n ['200', {}, []]\n else\n ['404', {}, [\"Repository #{repository} or ObjectID #{objectid} not found: #{path}\"]]\n end\n end",
"def destroy\n @retro = Retro.find(params[:id])\n @retro.destroy\n\n respond_to do |format|\n format.html { redirect_to retros_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @recoleccion = Recoleccion.find(params[:id])\n @recoleccion.destroy\n\n respond_to do |format|\n format.html { redirect_to recoleccions_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @recla.destroy\n respond_to do |format|\n format.html { redirect_to reclas_url, notice: 'Recla was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @uchronia = Uchronia.find(params[:id])\n @uchronia.destroy\n\n respond_to do |format|\n format.html { redirect_to uchronias_url }\n format.json { head :no_content }\n end\n end",
"def delete\n delete_from_server single_url\n end",
"def delete\n request(:delete)\n end",
"def destroy\n @lore = Lore.find(params[:id])\n @lore.destroy\n\n respond_to do |format|\n format.html { redirect_to lores_url }\n format.json { head :no_content }\n end\n end",
"def delete\n url = prefix + \"delete\"\n return response(url)\n end",
"def delete\n url = prefix + \"delete\"\n return response(url)\n end",
"def destroy\r\n @sivic_rede.destroy\r\n respond_to do |format|\r\n format.html { redirect_to sivic_redes_url }\r\n format.json { head :no_content }\r\n end\r\n end",
"def destroy\n @presenza = Presenza.find(params[:id])\n @presenza.destroy\n\n respond_to do |format|\n format.html { redirect_to presenze_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @recipy = Recipy.find(params[:id])\n @recipy.destroy\n\n respond_to do |format|\n format.html { redirect_to recipies_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @relatorios = Relatorio.find(params[:id])\n @relatorios.destroy\n\n respond_to do |format|\n format.html { redirect_to(homes_path) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @rameur.reservations.each { |resa| resa.destroy if resa.rameurs.size == 1 }\n Reservation.where(responsable_id: @rameur.id).each { |resa| resa.destroy(responsable_id: nil) }\n @rameur.destroy\n respond_to do |format|\n format.html { redirect_to rameurs_url, notice: \"Rameur supprimé\" }\n format.json { head :no_content, status: :success }\n end\n end",
"def destroy\n @donante.destroy\n respond_to do |format|\n format.html { redirect_to donantes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @referee = Referee.find(params[:id])\n @referee.destroy\n\n respond_to do |format|\n format.html { redirect_to referees_url }\n format.json { head :no_content }\n end\n end",
"def destroy\r\n @respuestum.destroy\r\n respond_to do |format|\r\n format.html { redirect_to respuesta_url, notice: 'Respuestum was successfully destroyed.' }\r\n format.json { head :no_content }\r\n end\r\n end",
"def destroy\n client=Client.find_by_id(params[:id])\n if client != nil\n if client.destroy\n head 204\n end\n else\n head 404\n end\n end",
"def delete(url, headers={})\n RestClient.delete url, headers\n end",
"def delete(splat)\n bad_request if splat.empty?\n _delete resolve_uri(splat[0])\n end",
"def destroy\n @asignatura.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n set_redireccion\n @objeto.destroy\n respond_to do |format|\n format.html { redirect_to @redireccion, notice: 'Imagen was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete(path)\n request 'DELETE', path\n end",
"def destroy\n \n respond_to do |format|\n RestClient.delete 'localhost:3001/colores/'+@color.id.to_s, {:Authorization => 'admin irizREhyoG6Ejwr4AcjsQME9'}\n format.html { redirect_to colors_url, notice: \"Color was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @recurso = Recurso.find(params[:id])\n @recurso.destroy\n\n respond_to do |format|\n format.html { redirect_to(recursos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @jedi = Jedi.find(params[:id])\n @jedi.destroy\n\n respond_to do |format|\n format.html { redirect_to jedis_url }\n format.json { head :no_content }\n end\n end",
"def delete\n render json: Alien.delete(params[\"id\"])\n end",
"def destroy\n @reprogramacion = Reprogramacion.find(params[:id])\n @reprogramacion.destroy\n\n respond_to do |format|\n format.html { redirect_to reprogramaciones_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @redacao.destroy\n respond_to do |format|\n format.html { redirect_to redacaos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @repay.destroy\n respond_to do |format|\n format.html { redirect_to repays_path, notice: 'Import order was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @quiebre.destroy\n respond_to do |format|\n format.html { redirect_to quiebres_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @rebate = Rebate.find(params[:id])\n @rebate.destroy\n\n respond_to do |format|\n format.html { redirect_to rebates_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @recurso_servidor.destroy\n respond_to do |format|\n format.html { redirect_to recurso_servidors_url, notice: 'Recurso servidor was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @recommand = Recommand.find(params[:id])\n @recommand.destroy\n\n respond_to do |format|\n format.html { redirect_to(recommands_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @server1 = Server1.find(params[:id])\n @server1.destroy\n\n respond_to do |format|\n format.html { redirect_to server1s_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @solicitacao_repass.destroy\n respond_to do |format|\n format.html { redirect_to solicitacao_repasses_url, notice: \"Solicitacao repasse was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @odontologia1 = Odontologia1.find(params[:id])\n @odontologia1.destroy\n\n respond_to do |format|\n format.html { redirect_to odontologia1s_url }\n format.json { head :no_content }\n end\n end",
"def delete(path)\n request(:delete, path)\n end",
"def destroy\n @diapo = current_church.diapos.find(params[:id])\n @diapo.destroy\n\n respond_to do |format|\n format.html { redirect_to diapos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @third_rip.destroy\n respond_to do |format|\n format.html { redirect_to third_rips_url, notice: 'Third rip was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @datos_insumos_reactivo.destroy\n respond_to do |format|\n format.html { redirect_to datos_insumos_reactivos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @reprodutor.destroy\n respond_to do |format|\n format.html { redirect_to reprodutores_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @restora.destroy\n respond_to do |format|\n format.html { redirect_to restoras_url, notice: 'Restora was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @retroaspecto = Retroaspecto.find(params[:id])\n @retroaspecto.destroy\n\n respond_to do |format|\n format.html { redirect_to retroaspectos_url }\n format.json { head :no_content }\n end\n end"
] |
[
"0.71015644",
"0.69831276",
"0.69712216",
"0.6917839",
"0.6917161",
"0.68178993",
"0.68178993",
"0.6794902",
"0.6757411",
"0.6756695",
"0.6751125",
"0.67044115",
"0.67030483",
"0.66971534",
"0.66971534",
"0.668791",
"0.6687842",
"0.6682473",
"0.6671442",
"0.6653417",
"0.66471964",
"0.66460824",
"0.66453636",
"0.6638287",
"0.66337425",
"0.6632536",
"0.66252404",
"0.66192824",
"0.66192824",
"0.6610275",
"0.6603091",
"0.6594995",
"0.6594586",
"0.6579368",
"0.6572977",
"0.6571498",
"0.6566303",
"0.65627736",
"0.65559006",
"0.65529525",
"0.6541691",
"0.6534997",
"0.65300506",
"0.6522685",
"0.6520394",
"0.65195906",
"0.6515441",
"0.65057874",
"0.65026253",
"0.65026253",
"0.65026253",
"0.65026253",
"0.6496951",
"0.64942324",
"0.648926",
"0.64815575",
"0.64811575",
"0.6478712",
"0.6473257",
"0.646974",
"0.64685285",
"0.6467877",
"0.6467679",
"0.64638853",
"0.64638853",
"0.64564085",
"0.6455163",
"0.6447661",
"0.6445601",
"0.64352876",
"0.6429735",
"0.6427793",
"0.6426622",
"0.6421817",
"0.64207864",
"0.6420065",
"0.6419818",
"0.6417983",
"0.64151406",
"0.6414994",
"0.6414138",
"0.6410551",
"0.6409057",
"0.6406739",
"0.6406562",
"0.6405889",
"0.6405018",
"0.6403058",
"0.6402989",
"0.6401357",
"0.63976985",
"0.63969934",
"0.63968265",
"0.63960725",
"0.6392477",
"0.6389849",
"0.638936",
"0.63872397",
"0.6386501",
"0.6385684"
] |
0.7078386
|
1
|
Use callbacks to share common setup or constraints between actions.
|
def set_repondre
@repondre = Repondre.find(params[:id])
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end",
"def add_actions; end",
"def callbacks; end",
"def callbacks; end",
"def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end",
"def define_action_helpers; end",
"def post_setup\n end",
"def action_methods; end",
"def action_methods; end",
"def action_methods; end",
"def before_setup; end",
"def action_run\n end",
"def execute(setup)\n @action.call(setup)\n end",
"def define_action_helpers?; end",
"def set_actions\n actions :all\n end",
"def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end",
"def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end",
"def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end",
"def before_actions(*logic)\n self.before_actions = logic\n end",
"def setup_handler\n end",
"def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end",
"def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def workflow\n end",
"def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end",
"def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end",
"def before(action)\n invoke_callbacks *self.class.send(action).before\n end",
"def process_action(...)\n send_action(...)\n end",
"def before_dispatch(env); end",
"def after_actions(*logic)\n self.after_actions = logic\n end",
"def setup\n # override and do something appropriate\n end",
"def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end",
"def setup(_context)\n end",
"def setup(resources) ; end",
"def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end",
"def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end",
"def determine_valid_action\n\n end",
"def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end",
"def startcompany(action)\n @done = true\n action.setup\n end",
"def init_actions\n am = action_manager()\n am.add_action(Action.new(\"&Disable selection\") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } )\n am.add_action(Action.new(\"&Edit Toggle\") { @edit_toggle = !@edit_toggle; $status_message.value = \"Edit toggle is #{@edit_toggle}\" })\n end",
"def event_callbacks(event, metadata={})\n case event\n when :reset, :review\n if confirmed\n update_attributes(confirmed: false)\n end\n when :confirm\n confirm\n # trigger :order for all applicable items\n # NOTE: :order event is common to both physical and digital items\n items.each do |i|\n if i.event_permitted(:order)\n user_id = last_transition.user_id\n i.trigger!(:order, { order_id: id, user_id: user_id })\n end\n end\n when :complete_work\n request = metadata[:request]\n work_complete_notification(request)\n when :close\n close\n end\n if event != :close && !open\n reopen\n end\n end",
"def setup_action\n return unless PONY::ERRNO::check_sequence(current_act)\n new_sequence = @action_sequence[@sequence_index+1...@action_sequence.size]\n @sequence_index = 0\n new_sequence = DND::SkillSequence::ACTS[@acts[1]] + new_sequence\n execute_sequence\n end",
"def define_tasks\n define_weave_task\n connect_common_tasks\n end",
"def setup(&block)\n define_method(:setup, &block)\n end",
"def setup\n transition_to(:setup)\n end",
"def setup\n transition_to(:setup)\n end",
"def action\n end",
"def setup( *args )\n\t\t\tself.class.setupBlocks.each {|sblock|\n\t\t\t\tdebugMsg \"Calling setup block method #{sblock}\"\n\t\t\t\tself.send( sblock )\n\t\t\t}\n\t\t\tsuper( *args )\n\t\tend",
"def config(action, *args); end",
"def setup\n @setup_proc.call(self) if @setup_proc\n end",
"def before_action \n end",
"def setup_callbacks\n defined_callbacks.each do |meth|\n unless respond_to?(\"call_#{meth}_callbacks\".to_sym)\n self.class.module_eval <<-EOE\n def call_#{meth}_callbacks(*args)\n plugin_store.each {|a| a.call_#{meth}_callbacks(*args) } if respond_to?(:plugin_store) && plugin_store\n self.send :#{meth}, *args if respond_to?(:#{meth})\n end\n EOE\n end\n end\n end",
"def action\n end",
"def matt_custom_action_begin(label); end",
"def setup\n # override this if needed\n end",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def action(options,&callback)\n new_action = Action===options ? options : Action.new(options,&callback)\n # replace any with (shared name/alias or both default) + same arity\n @actions.delete_if do |existing_action|\n ((existing_action.names & new_action.names).size > 0 ||\n existing_action.default? && new_action.default?) &&\n existing_action.required.size == new_action.required.size &&\n existing_action.optional.size <= new_action.optional.size\n end\n @actions = (@actions + [new_action]).sort\n new_action\n end",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action\n end",
"def after(action)\n invoke_callbacks *options_for(action).after\n end",
"def pre_task\n end",
"def setup(server)\n server.on('beforeMethod', method(:before_method), 10)\n end",
"def add_actions\n attribute = machine.attribute\n name = self.name\n \n owner_class.class_eval do\n define_method(name) {self.class.state_machines[attribute].events[name].fire(self)}\n define_method(\"#{name}!\") {self.class.state_machines[attribute].events[name].fire!(self)}\n define_method(\"can_#{name}?\") {self.class.state_machines[attribute].events[name].can_fire?(self)}\n end\n end",
"def init_actions\n @select_action = SelectAction.new\n @endpoint_mouse_action = EndpointMouseAction.new\n @move_action = MoveAction.new\n end",
"def setup_signals; end",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action.respond_to?('weak!') ? action.weak! : action\n end",
"def initialize(*args)\n super\n @action = :set\nend",
"def after_set_callback; end",
"def setup\n #implement in subclass;\n end",
"def lookup_action; end",
"def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end",
"def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end",
"def release_actions; end",
"def around_hooks; end",
"def save_action; end",
"def setup(easy)\n super\n easy.customrequest = @verb\n end",
"def action_target()\n \n end",
"def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end",
"def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end",
"def before_setup\n # do nothing by default\n end",
"def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end",
"def default_action; end",
"def setup(&blk)\n @setup_block = blk\n end",
"def callback_phase\n super\n end",
"def advice\n end",
"def _handle_action_missing(*args); end",
"def duas1(action)\n action.call\n action.call\nend",
"def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end",
"def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end",
"def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend"
] |
[
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576",
"0.53124547",
"0.529654",
"0.5296262",
"0.52952296",
"0.52600986",
"0.52442724",
"0.52385926",
"0.52385926",
"0.52385926",
"0.52385926",
"0.52385926",
"0.5232394",
"0.523231",
"0.5227454",
"0.52226824",
"0.52201617",
"0.5212327",
"0.52079266",
"0.52050185",
"0.51754695",
"0.51726824",
"0.51710224",
"0.5166172",
"0.5159343",
"0.51578903",
"0.51522785",
"0.5152022",
"0.51518047",
"0.51456624",
"0.51398855",
"0.5133759",
"0.5112076",
"0.5111866",
"0.5111866",
"0.5110294",
"0.5106169",
"0.509231",
"0.50873137",
"0.5081088",
"0.508059",
"0.50677156",
"0.50562143",
"0.5050554",
"0.50474834",
"0.50474834",
"0.5036181",
"0.5026331",
"0.5022976",
"0.5015441",
"0.50121695",
"0.5000944",
"0.5000019",
"0.4996878",
"0.4989888",
"0.4989888",
"0.49864885",
"0.49797225",
"0.49785787",
"0.4976161",
"0.49683493",
"0.4965126",
"0.4958034",
"0.49559742",
"0.4954353",
"0.49535993",
"0.4952725",
"0.49467874",
"0.49423352",
"0.49325448",
"0.49282882",
"0.49269363",
"0.49269104",
"0.49252945",
"0.4923091",
"0.49194667",
"0.49174926",
"0.49173003",
"0.49171105",
"0.4915879",
"0.49155936"
] |
0.0
|
-1
|
Never trust parameters from the scary internet, only allow the white list through.
|
def repondre_params
params.require(:repondre).permit(:user_id, :question_id)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def param_whitelist\n [:role, :title]\n end",
"def expected_permitted_parameter_names; end",
"def safe_params\n params.except(:host, :port, :protocol).permit!\n end",
"def strong_params\n params.require(:team_member).permit(param_whitelist)\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def strong_params\n params.require(:community).permit(param_whitelist)\n end",
"def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end",
"def strong_params\n params.require(:education).permit(param_whitelist)\n end",
"def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end",
"def allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\n end",
"def param_whitelist\n [:rating, :review]\n end",
"def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end",
"def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end",
"def user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end",
"def user_params\n params.permit(:name, :phoneNumber, :address, :postalCode, :local, :link, :counter, :latitude, :longitude) \n end",
"def valid_params_request?; end",
"def strong_params\n params.require(:experience).permit(param_whitelist)\n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def whitelist_url_params\n params.require(:whitelist_url).permit(:domain)\n end",
"def allowed_params\n params.require(:allowed).permit(:email)\n end",
"def permitted_params\n []\n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\n end",
"def query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend",
"def strong_params\n params.require(:success_metric).permit(param_whitelist)\n end",
"def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end",
"def whitelisted_user_params\n params.require(:user).\n permit( :first_name, :last_name, :email,:password,:password_confirmation,:birthday,:gender)\n end",
"def user_params\n ActionController::Parameters.permit_all_parameters = true\n params.require(:user) #.permit(:name, :surname, :phone, :password, :email, :time_zone)\n end",
"def strong_params\n params.require(:metric_change).permit(param_whitelist)\n end",
"def safe_params\n params.require(:user).permit(:name)\n end",
"def get_params\n\t\treturn ActionController::Parameters.new(self.attributes).permit(\"account_id\", \"title\", \"category\", \"introduction\", \"tags\", \"segment_type\", \"visible\", \"status\", \"main_image\")\n\tend",
"def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end",
"def check_params; true; end",
"def param_whitelist\n whitelist = [\n :description,\n :progress,\n :kpi_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:kpi_id)\n end\n \n whitelist\n end",
"def quote_params\n params.permit!\n end",
"def valid_params?; end",
"def paramunold_params\n params.require(:paramunold).permit!\n end",
"def user_params\n\t\tparams.permit(:nickname, :avatar, :description, :password, :gender, :birthday, :email, :phone, :qq_id, :wechat_id)\n\tend",
"def filtered_parameters; end",
"def user_params\n params.permit(\n \t:id,\n \t:email, \n \t:first_name, \n \t:last_name, \n \t:password, \n \t:confirm_token, \n \t:phone_number,\n \t:facebook_link,\n \t:car_model,\n \t:license_plate)\n end",
"def filtering_params\n params.permit(:email, :name)\n end",
"def check_params\n true\n end",
"def wx_public_params\n params.require(:wx_public).permit(:nickname, :manager, :alias)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def listing_params\n\t\tparams.permit(:address, :transit_info, :rules, :other_info, :lat, :lng)\n\tend",
"def social_account_params\n\t\t\tparams.require(:social_account).permit!\n\t\tend",
"def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end",
"def url_params\n params.require(:url).permit(:short_url, :original_url, :clicks, :ip_addresses)\n end",
"def user_params\n params.require(:user).permit(:uri, :username, :password, :realname, :email, :publicvisible)\n end",
"def model_params\n\t\tparams.require(:manager).permit(\n\t :user_name,\n :password,\n :email,\n \t\t\t)\n\tend",
"def article_params_whitelist\n params.require(:article).permit(:title, :description, category_ids: [])\n end",
"def college_whitelist_params\n params.require(:college_whitelist).permit(:status)\n end",
"def active_code_params\n params[:active_code].permit\n end",
"def filtering_params\n params.permit(:email)\n end",
"def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end",
"def ip_address_params\n\t\t\tparams.require(:ip_address).permit!\n end",
"def pull_request_params\n whitelist = [\n :url,\n :id,\n :html_url,\n :diff_url,\n :patch_url,\n :issue_url,\n :number,\n :state,\n :locked,\n :title\n ]\n params.require(:pull_request).permit(whitelist)\n end",
"def reserved_params\n params.require(:reserved).permit(:name, :email, :pax, :address, :KTP, :title)\n end",
"def post_params\n if current_user.admin? \n params.permit(:title, :body, :city, :country, :gps_location, :privacy, :visible, :latitude, :longitude, images: [], files: [])\n else \n params.permit(:title, :body, :city, :country, :gps_location, :privacy,:latitude, :longitude, images: [], files: [])\n end \n end",
"def list_params\n params.permit(:name)\n end",
"def filter_parameters; end",
"def filter_parameters; end",
"def vineyard_params\n params.permit(:vineyard_name, :email, :website_url, :phone, :address, :city, :region, :postcode, :country, :specialty, :description, :pet_friendly, :holiday, :tours, :events, :family_friendly, :cover_image, :image_one, :image_two, :image_three, :image_four, :user_id, :base64)\n end",
"def available_activity_params\n # params.require(:available_activity).permit(:type,:geometry,:properties)\n whitelisted = ActionController::Parameters.new({\n type: params.require(:available_activity)[:type],\n geometry: params.require(:available_activity)[:geometry].try(:permit!).to_h,\n properties: params.require(:available_activity)[:properties].try(:permit!).to_h\n }).try(:permit!)\n end",
"def user_params\n params.permit(:name, :username, :email, :password, :img_url, :bg_url, :coinbank)\n end",
"def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end",
"def user_params\n params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\n :user, :color, :solde)\n end",
"def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end",
"def param_whitelist\n [\n :title,\n :description,\n :organization,\n :team_id,\n :started_at,\n :finished_at,\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n end",
"def url_whitelist; end",
"def admin_social_network_params\n params.require(:social_network).permit!\n end",
"def filter_params\n params.require(:filters).permit(:letters)\n end",
"def origin_params\n params.permit(:country, :state, :city, :postal_code, :address, :description)\n end",
"def valid_params(params)\n params.permit(:login, :first_name, :last_name, \n :password, :password_confirmation)\n end",
"def sensitive_params=(params)\n @sensitive_params = params\n end",
"def permit_request_params\n params.permit(:address)\n end",
"def user_params\n # Ensure a user can't give themselves admin priveleges\n params.delete(:admin) if current_user.admin?\n params.require(:user).permit(:name, :email, :admin, :image)\n end",
"def secure_params\n params.require(:location).permit(:name)\n end",
"def strong_params\n params.require( :setting ).\n permit( :global_scan_limit, :per_user_scan_limit,\n :target_whitelist_patterns, :target_blacklist_patterns )\n end",
"def question_params\n params.require(:survey_question).permit(question_whitelist)\n end",
"def case_insensitive_params\n params.require(:case_insensitive).permit(:name)\n end",
"def empire_master_no_match_params\n params.require(:empire_master_no_match).permit(:uid, :last_name, :list, :search_date, :double, :source)\n end",
"def maintenance_request_params\n params[:maintenance_request].permit! #allow all parameters for now\n end",
"def unwanted_params\n params.require(:unwanted).permit(:title, :description, :image)\n end",
"def url_params\n params[:url].permit(:full)\n end",
"def backend_user_params\n params.permit!\n end",
"def filter_params\n\t\treturn params[:candidate].permit(:name_for_filter)\n\tend",
"def speed_measurement_params\n\n #fuckit, to lazy to deal with permit crap right now\n ActionController::Parameters.permit_all_parameters = true\n\n params[:speed_measurement]\n end",
"def user_params\n params.permit(:name, :age, :username, :display_photo, :password)\n end",
"def get_params\r\n #params.require(:article).permit(:title, :permalink, :content, :source_site, :introtext, :type_id, :order_by, :searchable, :created_by, :edited_by, :published_by, :published_on, :user_id)\r\n params.require(:article).permit!\r\n\r\n end",
"def pub_params\n params.require(:pub).permit(:name, :description, :phone, :email, :hidden, :city_id, :address)\n end",
"def pass_params\n params[:pass].permit(:name, :price, :description, :colour, :events)\n end",
"def droptraining_params\n params.permit(:training_id,:user_id, :utf8, :authenticity_token, :commit)\n end",
"def person_params\n # params whitelist does *not* include admin, sub, remember_token\n # TBD: share this whitelist with the list used by configuration_permitted_parameters\n # TBD: should current_password be on this list? -- for now, leaving off, since it seems to work without\n # NOTE: do not include 'admin' in this list!\n params.require(:person).permit(\n :name, \n :email, \n :description,\n :password, \n :password_confirmation\n )\n end",
"def parameter_params\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\n end"
] |
[
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",
"0.62894756",
"0.6283177",
"0.6242471",
"0.62382483",
"0.6217549",
"0.6214457",
"0.6209053",
"0.6193042",
"0.6177802",
"0.6174604",
"0.61714715",
"0.6161512",
"0.6151757",
"0.6150663",
"0.61461",
"0.61213595",
"0.611406",
"0.6106206",
"0.6105114",
"0.6089039",
"0.6081015",
"0.6071004",
"0.60620916",
"0.6019971",
"0.601788",
"0.6011056",
"0.6010898",
"0.6005122",
"0.6005122",
"0.6001556",
"0.6001049",
"0.59943926",
"0.5992201",
"0.59909594",
"0.5990628",
"0.5980841",
"0.59669393",
"0.59589154",
"0.5958826",
"0.5957911",
"0.5957385",
"0.5953072",
"0.59526145",
"0.5943361",
"0.59386164",
"0.59375334",
"0.59375334",
"0.5933856",
"0.59292704",
"0.59254247",
"0.5924164",
"0.59167904",
"0.59088355",
"0.5907542",
"0.59064597",
"0.5906243",
"0.5898226",
"0.589687",
"0.5896091",
"0.5894501",
"0.5894289",
"0.5891739",
"0.58860534",
"0.5882406",
"0.587974",
"0.58738774",
"0.5869024",
"0.58679986",
"0.5867561",
"0.5865932",
"0.5864461",
"0.58639693",
"0.58617616",
"0.5861436",
"0.5860451",
"0.58602303",
"0.5854586",
"0.58537364",
"0.5850427",
"0.5850199"
] |
0.0
|
-1
|
The prepare method prepares training data.
|
def prepare(options = {})
raise "prepare not implemented"
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def prepare\r\n\t\t@machine \t||= @machineClass.new @trainTestStruct.trainingData, @target, @parameters\r\n\t\t@machine.train\r\n\tend",
"def prepare\n prepare_prerequisites\n @prepared = true\n end",
"def prepare\n end",
"def prepare\n end",
"def prepare\n end",
"def prepare\n end",
"def prepare\n end",
"def prepare\n end",
"def prepare\n end",
"def prepare\n end",
"def prepare\n end",
"def prepare!\n prepare_in_parallel!\n end",
"def prepare \n # initialize start values, prepare first generation\n begin\n self.start_values = IterativeLearning.build_condition(condition.start_values[\"each_chain\"], self)\n first_generation.prepare(self.start_values)\n rescue StandardError => e\n first_generation.prepare(condition.start_values)\n self.start_values = []\n end\n # initialize target values, if present\n begin\n self.target_values = IterativeLearning.build_condition(condition.target_values[\"each_chain\"], self)\n rescue StandardError\n self.target_values = []\n end\n self.save!\n end",
"def prepare\n end",
"def prepare_data\n initial_data_eval \n initial_sorting if self.data_grid.sorting?\n filter\n global_summary_array\n pagination\n summary_array\n self.data_grid.row_styler\n prepare_data_for_filters\n end",
"def prepare\n raise NotImplementedError\n end",
"def prepare; end",
"def prepare; end",
"def prepare; end",
"def prepare_data\n\t\t\tsuper\n\t\t\t@data[:tuneable_data] = @tuneable_data\n\t\t\t@data[:@lowest_old] = @lowest_old\n\t\tend",
"def prepare()\n end",
"def prepare\n model.tap do |p|\n p.identifier = set_identifiers\n p.meta = set_meta\n p.text = set_text\n p.status = COMPLETED_STATUS\n p.authored = set_date\n p.author = set_author\n p.subject = set_subject\n p.questionnaire = set_questionnaire\n p.group = set_group\n end\n end",
"def prepare\n model.tap do |p|\n p.name = name\n p.identifier = set_identifiers\n p.meta = set_meta\n end\n end",
"def prepare\n model.tap do |p|\n p.name = name\n p.identifier = set_identifiers\n p.meta = set_meta\n end\n end",
"def prepare!; end",
"def prepare!; end",
"def prepare\n set_title\n set_name\n end",
"def prepare_data\n # This method is just a stub.\n end",
"def prepare(preparers)\n preparers.each do |prepaper|\n prepaper.prepape_trip(self)\n end\n end",
"def prepare\n @prepare ||= default_prepare\n end",
"def prepare_batch\n batchid = parse(config[\"BATCH\"][\"batchid\"])\n batch = Batch.find(:first, :conditions => {:batchid => batchid, :facility_id => facility.id})\n @batch_condition = batch.nil? and @batchid != batchid\n if @batch_condition\n @batch = Batch.new\n @job_index = 0\n puts \"Preparing batch #{batchid}\"\n puts type\n InputBatch.log.debug \"Preparing batch #{batchid}\"\n parse_values(\"BATCH\", @batch)\n @batch = update_batch @batch\n @batch.batchid = batchid\n @batch.file_meta_hash = file_meta_hash\n else\n if @batchid != batchid\n puts \"Batch #{batchid} already loaded\"\n @batch = nil\n end\n end\n @batchid = batchid\n end",
"def prepare!\n Cleaner.prepare(self)\n end",
"def prepare\n super\n end",
"def prepare_batch\n if $IS_PARTNER_BAC\n prepare_bank_batch\n else\n index_batchid = parse(config['BATCH']['index_batch_number']).to_s\n if @current_batchid != index_batchid\n @current_batchid = index_batchid\n @new_batch_flag = 1\n end\n batchid = find_batchid\n batch = Batch.find(:first, :conditions => {:batchid => batchid, :facility_id =>\\\n facility.id})\n @batch_condition = batch.nil? and @batchid != batchid\n if @batch_condition && @corresp_flag\n @corresp_flag = false if (@version == 'BANK_OF_AMERICA' && type == 'CORRESP')\n @bat = Batch.new\n @job_index = 0\n InputBatch::Log.write_log \"Preparing batch #{batchid}\"\n InputBatch::Log.write_log type\n parse_values(\"BATCH\", @bat)\n @@batch_date = @bat.date if !@bat.date.blank?\n @bat = update_batch @bat\n @bat.batchid = batchid\n @bat.file_meta_hash = file_meta_hash\n else\n if @batchid != batchid && @corresp_flag\n InputBatch::Log.write_log \"Batch #{batchid} already loaded\"\n @bat = nil\n end\n end\n @batchid = batchid\n end\n end",
"def prepare\n FileUtils.mkdir_p(@base_dir)\n end",
"def prep\n\tend",
"def prepare(preparers)\n preparers.each do |prepaper|\n case prepaper\n when Mechanic\n prepaper.prepare_bicycles(bicycles)\n when TripCoordinator\n prepaper.buy_food(customers)\n when Driver\n prepaper.gas_up(vehicle)\n preparer.fill_water_tank(vehicle)\n end\n end\n end",
"def prepare\n # We get NotImplementedError by Tilt when we don't have this method\n end",
"def prepare\n #this is the fate thing, its included with the Rules module\n @toggle = fate\n @prepared = true\n end",
"def prepare\n started_at = DateTime.now.to_s\n prepare_deploy\n prepare_common_installation\n puppet_installation\n create_prepare_checkpoint(started_at)\n end",
"def prepare(&block)\n @prepare = block\n end",
"def prepare; self; end",
"def prepare_data(params)\n build_ingest_form\n build_uploader(params[:upload], params[:upload_cache])\n build_asset(params[:id], params[:template_id])\n assign_form_attributes(params)\n find_unmapped_rdf\n end",
"def prepare\n []\n end",
"def prepare(&block)\n @prepares << block\n end",
"def prepare\n insert_recording_reporter\n link_example_groups\n end",
"def set_training\n @training = student.trainings.build\n end",
"def prepare(preparers)\n preparers.each {|preparer|\n preparer.prepare_trip(self) }\n end",
"def prepare_data\n @data = {\n :banned_points => @banned_points,\n :cost => @current_cost,\n :path => @path\n }\n if @current_cost > @epsilon\n @data[:failed] = true\n end\n end",
"def prepare\n super\n\n @test_list = @builder.tests\n\n @test_list.each do |item|\n if @options[\"#{item}_RATIO\"].to_i >= 1\n 1.upto(@options[\"#{item}_RATIO\"].to_i) do\n @tests.push item\n end\n end\n end\n end",
"def prepare\n self.capture_uninvoiced_ledger_entries!\n self.create_freshbooks_invoice!\n self.apply_freshbooks_credit!\n end",
"def prepare\n true\n end",
"def prepare\n true\n end",
"def prepare\n FileUtils.rm_rf(output_dir)\n FileUtils.mkdir_p(output_dir)\n end",
"def prepare\n FileUtils.rm_rf(output_dir)\n FileUtils.mkdir_p(output_dir)\n end",
"def prepare(preparers)\n preparers.each { |preparer| preparer.prepare_trip(self) }\n end",
"def prepare\n prepare_sources\n prepare_rubygems\n prepare_gems\n end",
"def prepare!\n self.prepared_object = resolve_object\n end",
"def setup\n # suppress ActiveRecord logging\n ActiveRecord::Base.logger.level = Logger::WARN\n\n @importer_run = ImporterRun.new\n @transformer = Transformer.new(context: context, transformations: transformations, options: transformation_options)\n @thread_pool = ETL::ThreadPool.new(options.pool)\n @data_scrubber = ETL::DataScrubber.new(options.destination_model)\n invoke_callback(:before_run)\n end",
"def prepare_for_processing\r\n\t\tbegin\r\n\t\t\t@rate_tree = YAML.load(File.read(@options['rate_tree_yaml'])) #if File.exist?(@options['rate_tree_yaml'])\r\n\t\trescue\r\n\t\t\traise \"Error loading rate file.\\nPlease ensure you load rates before processing transactions\"\r\n\t\t\t\r\n\t\tend\r\n\t\t\r\n\t\tbegin\r\n\t\t\t@bin_tree = YAML.load(File.read(@options['bin_tree_yaml'])) #if File.exist?(@options['bin_tree_yaml'])\r\n\t\trescue\r\n\t\t\traise \"Error loading BIN file.\\nPlease ensure you load the BINs before processing transactions\"\r\n\t\tend\r\n\t\t\r\n\t\tget_client_folder #must come before load_profile\r\n\t\tload_profile\r\n\t\tset_reset_instance_variables\r\n\tend",
"def set_training\n @training = Training.find(1)\n end",
"def prepare_dataset\n @working_dataset.dataset.each { |tuple| @clustered_dataset[tuple] = -1 }\n end",
"def prepare\n puts \"Populating #{@collection} with #{@options.documents} documents\"\n @mq.populate_collection(@options.documents)\n end",
"def train\n classifiers_initializer = ClassifiersInitializer.load_or_create\n classifiers_initializer.run\n @classifiers = classifiers_initializer.classifiers.map do |name, classifier|\n Classifier.new(classifier, self.class.config, name).train\n end.to_h\n end",
"def prepare(prepareers)\n\t\tprepareers.each { |prepare| prepare.prepare_trip(self)}\n\tend",
"def prepare_for_caching\n @predictor.instance_variable_set(:@data_set, nil)\n end",
"def train_data\n ::RubyFann::TrainData.new(\n :inputs => inputs, \n :desired_outputs=> desired_outputs)\n end",
"def train(dataset)\n raise 'Override me!'\n end",
"def prepare(params)\n check_like_value(:keywords, params)\n check_array_value(:subjects, params)\n check_array_value(:media_types, params)\n check_array_value(:durations, params)\n check_single_value(:account_id, params)\n check_numeric_value(:per_page, params, 20)\n check_numeric_value(:page, params, 1)\n check_single_value(:workflow_state, params, \"active\")\n end",
"def setup\n @dataset = $dataset\n @dataset_2 = $dataset_2\n\n refute_nil @dataset, \"You do not have an active dataset to run the tests.\"\n\n super\n end",
"def make_training_set training_set_size\n sample = $ou.to_a.sample(training_set_size).shuffle\n data_to_csv 'train.csv', sample\nend",
"def prepare(config)\n @config_helper.parse_config!(config)\n end",
"def prepare admr\n \n end",
"def prepare_sources\n SOURCES.each_pair do |suite, url|\n prepare_source_for(url, @freshen)\n end\n end",
"def load_data\n\t\tFile.open(\"#{@path_to_training}\", \"r\").each_line do |line|\n\t\t\ta = line.split\n\t\t\tadd_movie(a[1].to_i, a[0].to_i, a[2].to_i)\n\t\t\tadd_user(a[0].to_i, a[1].to_i, a[2].to_i)\n\t\tend\n\t\tif File.file?(\"#{@path_to_test}\") then\n\t\t\tFile.open(\"#{@path_to_test}\", \"r\").each_line do |line|\n\t\t\t\ta = line.split\n\t\t\t\t@list_of_test_set << Rating.new(a[0].to_i, a[1].to_i, a[2].to_i)\n\t\t\tend\n\t\tend\n\tend",
"def set_train(train)\r\n @train = train\r\n end",
"def prepare!\n prepare_once\n @total_rows_number = postgres.execute(\"SELECT COUNT('id') FROM #{data_table_name} WHERE #{data_where_scope}\")[0][0].to_i\n @iteration_number = 0\n @finished = false\n @prepared = true\n end",
"def train\n raise NotImplementedError\n end",
"def setup(params)\n\n\t\tself.log << \"Starting setup\"\n\n\t\t@sdt_filter = SeriesDescriptionType.where(:series_description_type => ['T1 Volumetic','T1 Volumetric','T1+Volumetric','T1_Volumetric','T1','T2','T2 Flair','T2_Flair','T2+Flair','DTI'])\n\t\t@sdm_filter = SeriesDescriptionMap.where(:series_description_type_id => sdt_filter.map(&:id))\n\t\t@selected = []\n\t\t@driver = []\n\n\t if !File.directory?(params[:target_dir])\n\t Dir.mkdir(params[:target_dir])\n\t end\n\n\t self.log << \"Setup complete\"\n\n\tend",
"def prepare\n FileUtils.rm_rf(@tempdirs, secure: true) if @tempdirs\n @tempdirs = []\n @base_options = nil\n @mode_options = nil\n @user_recipients = nil\n @user_keys = nil\n @system_identifiers = nil\n end",
"def prepare_data(num_rows)\n app_train = read_dataset_from_csv('./input/application_train', num_rows)\n data = app_train[\"data\"]\n set_categorical_labels(data)\n numeric_features, _categorical_features = get_numeric_cateforical_features_from_the_raw_dataset(app_train[\"data\"])\n categorical_features_one_hot_encode = get_one_hot_feature_map_from_the_origin_dataset(data)\n one_hot_encoding_using_feature_map(data, categorical_features_one_hot_encode)\n\n # NaN values for DAYS_EMPLOYED: 365243 -> nan\n data.each do |r|\n r_features = r[\"features\"]\n if r_features[\"days_empoyed\"] == 365243\n r_features[\"days_employed\"] = \"\"\n r_features[\"days_employed_anom\"] = 1\n else\n r_features[\"days_employed_anom\"] = 0 \n end \n \n add_ratio_feature(\"payment_rate\", \"amt_annuity\", \"amt_credit\", r)\n add_ratio_feature(\"annuity_income_ratio\", \"amt_annuity\", \"amt_income_total\", r)\n add_ratio_feature(\"credit_goods_ratio\", \"amt_credit\", \"amt_goods_price\", r)\n # add_ratio_feature(\"income_person_ratio\", \"amt_income_total\", \"cnt_fam_members\", r)\n add_ratio_feature(\"employed_birth_ratio\", \"days_employed\", \"days_birth\", r)\n end\n # categorical_features << \"days_employed_anom\"\n\n bureau = read_dataset_from_csv('./input/bureau', 1000, $bureau_numeric_features)\n # bureau[\"data\"].each do |r|\n # puts r[\"features\"][\"days_enddate_fact\"]\n # end\n # return\n grouped = group_data(bureau[\"data\"])\n agged = agg_group_data(grouped, $bureau_numeric_features, \"bureau\")\n merge_to_dataset(app_train, agged, $bureau_numeric_features)\n\n app_train[\"features\"] = app_train[\"data\"][0][\"features\"].keys\n\n puts \"begin to normalize the dataset......\"\n nomalizer = Normalizer.new\n nomalizer.normalize(app_train, numeric_features)\n\n puts \"begin to impute missing value......\"\n imputer = SimpleImputer.new\n imputer.fit(app_train)\n \n puts \"finish preparing the dataset!\"\n return app_train\nend",
"def load_training_data\n\t\tCSV.foreach(@data_file_path+'/'+@training_file_name, {col_sep: \"\\t\", encoding: 'windows-1251:utf-8'}) do |row|\n\t\t\tuser_id, movie_id, rating, timestamp = row\n\t\t\trating = rating.to_f\n\t\t\tuser = get_obj(User, @all_users, user_id)\n\t\t\tuser.ratings[movie_id] = rating\n\n\t\t\tmovie = get_obj(Movie, @all_movies, movie_id)\n\t\t\tmovie.ratings[user_id] = rating\n\t\tend\n\tend",
"def get_data\n\t\tdata_hash = {path: @data_file_path, training: @training_file_name, testing: @testing_file_name}\n\t\tDataLoader.new(data_hash)\n\tend",
"def prepare_cart\n\n\t\tfind_cart_items\n\t\t\n\t\tset_cart_price\n\t\t\n\t\tset_cart_payments\n\t\t\n\t\tset_cart_paid_amount\n\t\t\n\t\tset_cart_pending_balance\n\n\t\tset_cart_minimum_payable_amount\n\n\t\tset_discount\n\n\tend",
"def prepare_pre_import\n end",
"def prepare\n projects.each(&:prepare)\n end",
"def set_preparation\n @preparation = Preparation.find(params[:id])\n end",
"def prepare_for_new_batch\n invoke_callback(:before_each_batch)\n\n new_rows.clear\n update_attrs.clear\n records.clear\n Thread.current[:existing_ids] = nil\n end",
"def prepare_attributes(data_set, meta_data, options)\n # create meta data and data set for the scaled output\n sc = DatasetScaling.new(meta_data, data_set)\n @meta_data = sc.scaled_meta\n @scaled_dataset = sc.scaled_data_set\n set_attributes(@scaled_dataset, options[:extreme_values])\n end",
"def prep_variables\n end",
"def load_training_data\n File.open(@training_file) {|file|\n @training_set = Nimbus::TrainingSet.new({}, {})\n file.each do |line|\n next if line.strip == ''\n data_feno, data_id, *snp_list = line.strip.split\n raise Nimbus::InputFileError, \"Individual ##{data_id} from training set has no value for all #{@tree_SNP_total_count} SNPs\" unless snp_list.size == @tree_SNP_total_count\n raise Nimbus::InputFileError, \"There are individuals with no ID, please check data in training file.\" unless (!data_id.nil? && data_id.strip != '')\n raise Nimbus::InputFileError, \"Individual ##{data_id} has no fenotype value, please check data in training file.\" unless (!data_feno.nil? && data_feno.strip != '')\n raise Nimbus::InputFileError, \"Individual ##{data_id} has invalid class (not in [#{classes*', '}]), please check data in training file.\" unless (@classes.nil? || @classes.include?(data_feno))\n\n data_feno = (@classes ? data_feno.to_s : data_feno.to_f)\n @training_set.individuals[data_id.to_i] = Nimbus::Individual.new(data_id.to_i, data_feno, snp_list.map{|snp| snp.to_i})\n @training_set.ids_fenotypes[data_id.to_i] = data_feno\n end\n }\n end",
"def configure_training_request\n available_ledgers :training_request\n set_training_request\n end",
"def _pre_process\n @pre_processor = @league.pre_processor.new(@data_feed_file).start\n\n if @pre_processor.errored?\n _output_errors(@pre_processor, 'preprocessing')\n else\n _output_success(@pre_processor, 'preprocessing')\n end\n end",
"def setup(params)\n\n\t\t@selected = []\n\t\t@driver = []\n\t\t@errors = []\n\t\t# @output_tmp = Dir.mktmpdir\n\n\tend",
"def initialize_attributes\n @training_model = Hash.new { |h, k| h[k] = Hash.new(0) }\n @classes = Set.new\n @total_words_counter = 0\n @negative_population = 0\n @neutral_population = 0\n @positive_population = 0\n @training_negatives = 0\n @training_neutrals = 0\n @training_positives = 0\n end",
"def prepare_for_configuration \n # clear_base_directory\n make_base_directory\n copy_misc_templates\n copy_custom_monitors\n store_keys_in_file\n Script.save!(self)\n # not my favorite...\n copy_ssh_key\n before_configuration_tasks\n end",
"def process_training_params\n params.fetch(:process_training, {})\n end",
"def training_params\n params.fetch(:training, {})\n end",
"def training_params\n params.fetch(:training, {})\n end",
"def setup()\n setupParamListTable(getConf(:paramList)) ;\n super() ;\n end"
] |
[
"0.73330617",
"0.68806666",
"0.6878072",
"0.6878072",
"0.6719182",
"0.6719182",
"0.6719182",
"0.6719182",
"0.6719182",
"0.6719182",
"0.6719182",
"0.67147785",
"0.66166973",
"0.6616436",
"0.64895463",
"0.63574576",
"0.6310802",
"0.6310802",
"0.6310802",
"0.63080657",
"0.62984604",
"0.61678535",
"0.6153009",
"0.6153009",
"0.6092311",
"0.6092311",
"0.60647583",
"0.60606205",
"0.6023128",
"0.6014076",
"0.60063195",
"0.5939162",
"0.59379196",
"0.591983",
"0.59176683",
"0.591389",
"0.5889678",
"0.5884176",
"0.58718693",
"0.57836646",
"0.5766534",
"0.57512516",
"0.56979513",
"0.5658889",
"0.5657083",
"0.5653355",
"0.5651745",
"0.56331325",
"0.56213677",
"0.5615295",
"0.56052274",
"0.5577638",
"0.5577638",
"0.5541074",
"0.5539698",
"0.55249864",
"0.5493188",
"0.54918903",
"0.54356337",
"0.5416755",
"0.5411991",
"0.5409908",
"0.5385408",
"0.5381943",
"0.53789264",
"0.53726447",
"0.53610075",
"0.53552777",
"0.53389704",
"0.5335711",
"0.53333366",
"0.5329634",
"0.53283876",
"0.5326794",
"0.5319833",
"0.5310253",
"0.530759",
"0.53072095",
"0.5302209",
"0.5289141",
"0.5288193",
"0.52858216",
"0.52432305",
"0.51943916",
"0.51884687",
"0.5167659",
"0.51653725",
"0.5156834",
"0.51458496",
"0.51446414",
"0.51427937",
"0.5135575",
"0.5126946",
"0.5114401",
"0.511093",
"0.51023835",
"0.50809944",
"0.50796205",
"0.50796205",
"0.50749123"
] |
0.545315
|
58
|
Trains the ANN with the training data (Don't forget to call prepare first) The desired error is divided by the normalizaion factor to respect data normalization.
|
def train(options = {})
options.reverse_merge!({ :max_epochs => 100000, :epochs_between_reports => 500, :desired_error => 0.0001 })
#fann.train_on_data(train_data, 10000, 100, 0.00001)
fann.train_on_data(train_data, options[:max_epochs], options[:epochs_between_reports], options[:desired_error] * normalization_factor)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def train(iterations=1)\n all_errors = []\n\n 1.upto(iterations) do |iteration|\n arguments = input_proc.call\n target_outputs = target_proc.call(*arguments)\n inputs = inputs_with_bias(arguments)\n actual_outputs = compute(*inputs)\n errors = actual_outputs.zip(target_outputs).map { |actual, target| target - actual }\n\n number_of_outputs.times do |i|\n number_of_medial_neurons.times do |j|\n @syntwo[j][i] += (learning_rate * @medout[j] * errors[i])\n end\n end\n\n sigma = []\n sigmoid = []\n\n number_of_medial_neurons.times do |i|\n sigma[i] = 0\n number_of_outputs.times do |j|\n sigma[i] = sigma[i] + errors[j] * @syntwo[i][j]\n end\n sigmoid[i] = 1 - @medout[i]**2\n end\n\n number_of_inputs.times do |i|\n number_of_medial_neurons.times do |j|\n delta = learning_rate * sigmoid[j] * sigma[j] * inputs[i]\n @synone[i][j] += delta\n end\n end\n\n overall_error = Math.sqrt(errors.map { |e| e**2 }.inject(:+))\n print \"\\r[#{iteration}] error: #{overall_error}\"\n\n all_errors << overall_error\n @training_iterations += 1\n end\n\n new_average_error = all_errors.inject(:+) / all_errors.length\n if @average_error.nil?\n puts \"\\rAverage error is now #{new_average_error}\"\n else\n better_or_worse = (@average_error - new_average_error) > 0 ? 'BETTER' : 'WORSE'\n puts \"\\rAverage error is #{better_or_worse} (#{@average_error} => #{new_average_error})\"\n end\n @average_error = new_average_error\n end",
"def doTraining\n\t\t# Ruby fan uses its own special data structure. 2D Array for both X and Y data\n\t\ttrain\t\t= RubyFann::TrainData.new(inputs: @xData[:train], desired_outputs: @yData[:train])\n\t\t# Train\n\t\tmachine\t= RubyFann::Standard.new(num_inputs: @nInputs, hidden_neurons:[2], num_outputs: 1)\n\t\tmachine.train_on_data(train, @iterations, @reportSteps, @maxError) \n\t\t# Remember to send the machine back to the caller\n\t\tmachine\n\tend",
"def train\n puts '>>> 1'\n train = RubyFann::TrainData.new(filename: './train.data')\n\n puts '>>> 2'\n @fann = RubyFann::Standard.new(num_inputs: @number_of_inputs, hidden_neurons: [@number_of_inputs/20, @number_of_inputs/40], num_outputs: @number_of_outputs)\n\n puts '>>> 3'\n @fann.train_on_data(train, 1000, 10, 0.1) # 1000 max_epochs, 10 errors between reports and 0.1 desired MSE (mean-squared-error)\n @fann.save('./headlines.net')\n\n puts '>>> 4'\n test\n end",
"def train(inputs, outputs)\n eval(inputs)\n backpropagate(outputs)\n calculate_error(outputs)\n end",
"def train filename=\"data/x_train.txt\"\n\n # Read from the file if we haven't already\n if @x.empty? && @y.empty? && @output.empty?\n read filename\n end\n\n i = 0 # Keep track of the iterations\n learning_rate = 0.1\n global_error = 0\n local_error = 0\n theta = 0\n\n begin\n sum = ActivationFunction.weighted_sum @weights, @x[i], @y[i]\n out = 0\n if sum >= theta\n out = 1\n end\n puts \"Sum: #{sum}\"\n\n local_error = @output[i] - out\n if local_error == 0\n local_error == 0.0001\n end\n\n puts \"Local Error: #{local_error}\"\n\n @weights[0] += learning_rate * local_error * @x[i]\n @weights[1] += learning_rate * local_error * @y[i]\n @weights[2] += learning_rate * local_error\n i = i + 1\n\n global_error += local_error * local_error\n puts \"Global Error : #{global_error}\"\n\n end while (global_error != 0 && i < @output.size)\n\n puts \"Decision Boundary Equation: #{@weights[0]}x + #{@weights[1]} +- #{@weights[2]}\"\n @weights\n end",
"def train(input, expected_output)\n # binding.pry\n output = calculate_output(input)\n backpropogate(expected_output)\n update_weights_from_error\n calculate_error(output, expected_output)\n end",
"def train(inputs, desired)\n # Guess the result\n guess = feedforward(inputs)\n # Compute the factor for changing the weight based on the error\n # Error = desired output - guessed output\n # Note this can only be 0, -2, or 2\n # Multiply by learning constant\n error = desired - guess\n # Adjust weights based on weightChange * input\n @weights.collect!.with_index { |w, i| w + error * inputs[i] }\n end",
"def train\n @weights.each_index do |i| \n # alter weight and apply momentum\n @weights[i] = @weights[i] + (@rate * inputs[i] * @gradient)\n @weights[i] = @weights[i] + @momentum * @lastchange\n \n @lastchange = @rate * inputs[i] * @gradient\n end\n @weights\n end",
"def train_neural_network\n # Prepare the inputs and outputs that will be used.\n # For every input that we create, we will need a matching output, as\n # each output represents the *expected* output of the neural network during\n # training and without which back-propagation is impossible. Therefore,\n # inputs and outputs are both lists of lists (lists of vectors).\n inputs = []\n outputs = []\n\n # Loop for each language with this outer loop. It means that the inside will\n # run as many times as we have different languages to train on.\n SEED.each do |lang, articles|\n # Prepare an array containing as many 0.0 values as we have languages.\n output = Array.new LANGUAGES.length, 0.0\n # Set the output that matches the current language to 1.0.\n output[LANGUAGES.index lang] = 1.0\n # At this point, the `ouput` variable contains something like [0.0, 0.0, 0.0]\n # and points the neural network to the expected output language we want.\n\n # Now we need an inner loop that will process each article.\n puts \"Processing language #{lang}...\"\n articles.each do |article|\n # Download the article text for the current language.\n text = wikipedia_page_text lang, article\n # Build the per-letter frequency dictionary.\n frequencies = letter_frequencies text\n # Transform the frequencies dictionary into our single input vector.\n input = build_inputs ALPHABET, frequencies\n inputs << input\n outputs << output\n puts \" Crawled page #{article}, length: #{text.length}\"\n end\n end\n\n # Here we initialize a new neural network and store it in the variable named\n # `net`. Later, any operation we need to perform over the neural network could\n # be invoked using `net.something`. The neural network is initialized using\n # the various sizes of our training dataset and expected output length.\n net = RubyFann::Standard.new num_inputs: ALPHABET.length,\n num_outputs: LANGUAGES.length,\n hidden_neurons: [ALPHABET.length]\n # Our neural network being from a library, it expects a very specific training\n # dataset format, so we will create one here to train on. The training object\n # will be the most simple one containing our inputs and outputs, and will be\n # stored in a variable named `train`.\n train = RubyFann::TrainData.new inputs: inputs, desired_outputs: outputs\n\n # Now we're going to train the neural network. The parameters that the library\n # expects are: the training dataset, the maximum number of iteration before\n # aborting, the visual reporting of the state of the training and the desired\n # target error rate (accuracy) of the resulting network.\n net.train_on_data train, 1000, 10, 0.01\n\n # As we might want to re-use the same network later if it proves itself to be\n # good enough, let's save it to the hard disk in a file.\n net.save 'frequencies.train'\n\n # As we want anyone calling this function to be able to use the trained network,\n # we make sure to return it here in the end.\n net\nend",
"def train_data\n ::RubyFann::TrainData.new(\n :inputs => inputs, \n :desired_outputs=> desired_outputs)\n end",
"def train_pattern!(training_set)\n # First have the network evaluate the training set input\n evaluate! training_set[:input]\n\n # BACKPROPAGATE ERRORS\n # 6. Calculate error terms for the output units\n errors = {}\n output.each.with_index do |neuron, j|\n errors[neuron] = (training_set[:output][j] - neuron.output)*neuron.gradient\n end\n\n # 7. Calculate the error terms for the hidden layer neurons\n hidden.reverse.inject(output) do |prev_layer, hidden_layer|\n hidden_layer.each do |neuron|\n err_sum = prev_layer.inject(0) do |sum, succ|\n sum += errors[succ]*(neuron.edge(succ))\n end\n errors[neuron] = neuron.gradient*err_sum\n end\n end\n\n # 8, 9. Update weights on output layer\n # Update weights on hidden layers\n (hidden + [output]).reverse.each do |layer|\n layer.each do |neuron|\n neuron.predecessors.each do |pred|\n neuron.update_edge! pred, (neuron.edge(pred) + (learning_rate_param)*(errors[neuron])*(pred.output))\n end\n end\n end\n\n # 10. Calculate the error term; this is the metric for how well the network is learning\n err_sum = output.inject(0) do |sum, neuron|\n sum + (errors[neuron] ** 2)\n end\n @last_error_term = (err_sum/2)\n end",
"def train(data)\n @olayer.each_index do |o|\n # Compute output gradient.\n @olayer[o].error = {value: data[o], exact: false}\n # Train the output layer.\n @olayer[o].train \n end\n\n # Train hidden layer.\n @hlayer.each_index do |h|\n wsum = 0\n @olayer.each{ |o| wsum = wsum + (o.weights[h] * o.gradient) }\n @hlayer[h].error = wsum\n @hlayer[h].train\n end\n end",
"def train_perceptron()\n @model = Perceptron.new()\n @model.train(@training_set)\n end",
"def prepare_network\n @neural_net = RubyFann::Standard.new(num_inputs: @nuerons_number,\n hidden_neurons: [(2 * @nuerons_number) / 3],\n num_outputs: @nuerons_number)\n end",
"def epoch\n sqerror = 0\n @range.each do |row|\n self.feed(@predictors[row])\n self.train(@predicted[row])\n rowerror = 0\n @olayer.each{ |o| rowerror = rowerror + o.error**2 }\n sqerror = sqerror + rowerror\n end\n \n @mse.push(sqerror / @range.count)\n @mse.last\n end",
"def evaluate\n @output_value = Math.tanh(@input_value - @bias)\n #p \"output value #{@output_value}\"\n @forward_nodes.each do |node, weight|\n #p \"weight #{weight} old input #{node.input_value}\"\n node.input_value += @output_value * weight\n #p \"new input #{node.input_value}\"\n end\n @input_value = 0\n end",
"def adaBoostTrainDS(dataArr,classLabels,numIt=40)\n weakClassArr = []\n m = shape(dataArr)[0]\n d = Array.new(m, 1.0/m) # init D to all equal\n aggClassEst = zeros(m,0)\n numIt.times do |i|\n bestStump,error,classEst = buildStump(dataArr,classLabels,d) # build Stump\n #printf(\"\\t[Test] classEst=%s\\n\", classEst)\n alpha = float(0.5*Math.log((1.0-error)/[error,1e-16].max)) #calc alpha, throw in max(error,eps) to account for error=0\n #printf(\"\\t[Test] alpha=#{alpha}\\n\")\n bestStump['alpha'] = alpha\n weakClassArr << bestStump #store Stump Params in Array\n # expon = multiply(-1*alpha*mat(classLabels).T,classEst)\n expon = (classLabels.multi(classEst)).multi(-1*alpha)\n #printf(\"\\t[Test] d=#{d} (expon=#{expon})\\n\")\n d = d.to_enum(:each_with_index).collect{|v,i| v*Math.exp(expon[i])}\n #d = d.multi(Math.exp(expon))\n #printf(\"\\t[Test] d=#{d} (d.sum=#{d.sum})\\n\") \n d = d/(d.sum)\n printf(\"\\t[Test] d=#{d}\\n\")\n #calc training error of all classifiers, if this is 0 quit for loop early (use break) \n #aggClassEst += alpha*classEst\n aggClassEst.plus!(classEst.multi(alpha))\n #printf(\"\\t[Test] aggClassEst=%s\\n\", aggClassEst)\n aggErrors = []\n aggClassEst.each_with_index do |v,i|\n #printf(\"\\t[Test] sign(%s)=%s <-> %s\\n\", v, sign(v), int(classLabels[i]))\n if Float(sign(v))!=classLabels[i]\n aggErrors << 1\n else\n aggErrors << 0\n end\n end\n errorRate = aggErrors.sum/Float(m) \n printf(\"\\t[Loop#{i+1}] total error: #{errorRate}...\\n\") \n break if errorRate == 0.0 \n end \n return weakClassArr\n end",
"def trainAsStandardRegressor\r\n\t\treturn if @trained && @gradientModel == false\r\n\t\t#Train standard regressor\r\n\t\t#FIRE!\r\n\t\t@lr.train_normal_equation\r\n\t\t#Train flags update\r\n\t\t@train\t\t\t\t= true\r\n\t\t@gradientModel\t\t= false\r\n\tend",
"def train(original_features, outputs)\n features = add_zero_feature polynomialize_features(original_features)\n @iterations = 0\n @old_thetas = Array.new features.first.size, 0\n @thetas = batch_descend @old_thetas, features, outputs\n while continue? @thetas, @old_thetas, features, outputs\n @old_thetas = @thetas\n @thetas = batch_descend @thetas, features, outputs\n end\n @iterations\n end",
"def train\n run_thresholds\n run_values_to_ranges\n run_reverse\n\n @classifiers\n end",
"def run(inputs, normalize_outputs = true)\n outputs = fann.run(inputs)\n if normalize_outputs\n return outputs.map { |value| value / normalization_factor }\n else\n return outputs\n end \n end",
"def train(forces, error)\n trained = @weights.zip(forces.map(&:to_a)\n .map { |a, b| (a * error.x + b * error.y) * @c })\n .map { |w, c| constrain(w + c, 0, 1.0) }\n @weights = trained\n end",
"def train\n raise NotImplementedError\n end",
"def feedback(eta, delta)\n @grad = delta * (B / A) * (A - @sigmoid) * (A + @sigmoid);\n eta_grad = eta * @grad;\n @wn.each_index {|i|\n @wn[i] += eta_grad * @xn[i];\n }\n end",
"def train trainset, ngens=@ngens, report_interval: 1000, desired_error: 1e-10\n # it makes sense to temporarily disable the `report_interval` with `false` or `nil`\n report_interval ||= 0\n # special case: not implemented in FANN\n if algo == :rwg\n return train_rwg(trainset, ngens,\n report_interval: report_interval, desired_error: desired_error)\n end\n # TODO: optimize maybe?\n times, inputs, targets = trainset.values\n tset = RubyFann::TrainData.new inputs: inputs, desired_outputs: targets\n # fann.init_weights tset # test this weights initialization\n\n # params: train_data, max_epochs, report_interval, desired_error\n fann.train_on_data(tset, ngens, report_interval, desired_error)\n end",
"def fit(x, y)\n x = ::Rumale::Validation.check_convert_sample_array(x)\n y = ::Rumale::Validation.check_convert_target_value_array(y)\n ::Rumale::Validation.check_sample_size(x, y)\n\n y = y.expand_dims(1) if y.ndim == 1\n n_targets = y.shape[1]\n n_features = x.shape[1]\n sub_rng = @rng.dup\n\n loss = ::Rumale::NeuralNetwork::Loss::MeanSquaredError.new\n @network = buld_network(n_features, n_targets, sub_rng)\n @network = train(x, y, @network, loss, sub_rng)\n @network.delete_dropout\n\n self\n end",
"def learn\n @mini_batches.each do |mini_batch|\n @X = Matrix.columns( mini_batch.map { |data| data[:x] } ) # (Dim, N)\n @D = Matrix.columns( mini_batch.map { |data| data[:d] } ) # (Dim, N)\n\n propagate_forward(@X)\n propagate_backward\n update\n end\n end",
"def train(features, y, learning_rate, iterations)\n m = features.length # Number of training examples\n n = features[0].length # Number of features\n initial_theta = [0.0] * (n + 1) # Initialize theta's\n\n features.each { |i| i.unshift(1) } # Append a column of 1's to features\n\n features = self.class.scale_features(features, m, n)\n\n # Run gradient descent to get our guessed theta\n self.class.gradient_descent_logistic(initial_theta, features, y, m, n, learning_rate, iterations)\n\n # Evaluate our hypothesis accuracy\n # puts \"Final theta: #{final_theta}\"\n # puts \"Initial cost: #{self.class.cost_logistic_regression(initial_theta, features, y, m, n)}\" if $debug\n # puts \"Final cost: #{self.class.cost_logistic_regression(final_theta, features, y, m, n)}\" if $debug\n # puts \"Example: #{self.class.cost_logistic_regression([0,0,1], features, y, m, n)}\" if $debug\n end",
"def reset\n @fann = RubyFann::Standard.new fann_opts\n if algo && algo != :rwg\n fann.set_training_algorithm(algo)\n end\n if actfn\n fann.set_activation_function_hidden(actfn)\n fann.set_activation_function_output(actfn)\n end\n if init_weights_range\n fann.randomize_weights(*init_weights_range.map(&method(:Float)))\n end\n end",
"def perceptron\n @feature_count = data.first.first.length\n iterations = 0\n weights = @feature_count.times.map { |x| 0.0001 }\n\n while iterations != @iterations\n data.each do |entry|\n feature_vector = entry.first\n activation = activation_output(weights, feature_vector)\n error = entry.last - activation\n error = (error == 0) ? 0.0001 : error\n @bias += @m*error\n weights = vector_add(weights, scalarXvector(error*@m, feature_vector))\n end\n iterations += 1\n end\n weights\nend",
"def initialize(inputNodes, hiddenNodes, outputNodes, learningRate=0.3, momentum=0.2)\n # Make sure we add the bias node to the input\n @inputNodes = inputNodes + 1\n @hiddenNodes = hiddenNodes\n @outputNodes = outputNodes\n\n @learningRate = learningRate\n @momentum = momentum\n\n @w_1 = NeuralNetwork::create_matrix(@inputNodes, @hiddenNodes, 0.0)\n @w_2 = NeuralNetwork::create_matrix(@hiddenNodes, @outputNodes, 0.0)\n \n # Randomize the values of Nthe nodes [-0.5, 0.5]\n @w_1.map! { |arr| arr.map { |v| rand(-0.5..0.5) } }\n @w_2.map! { |arr| arr.map { |v| rand(-0.5..0.5) } }\n\n # It helps to store the current state of node activations\n @activation_input = [1.0] * @inputNodes\n @activation_hidden = [1.0] * @hiddenNodes\n @activation_output = [1.0] * @outputNodes\n\n @din = NeuralNetwork::create_matrix(@inputNodes, @hiddenNodes, 0.0)\n @dout = NeuralNetwork::create_matrix(@hiddenNodes, @outputNodes, 0.0)\n\n puts \"\\n================================================================================================\\n[+]Weights from input to hidden nodes [#{@inputNodes}x#{@hiddenNodes}] has been initialized with small random values\"\n puts \"[+]Weights from hidden to output nodes [#{@hiddenNodes}x#{@outputNodes}] has been nitialized to small random values\\n================================================================================================\\n\"\n\n puts \"Neural network initialized with values \\n \\t Input Nodes:[{#{@inputNodes}]\\t Hidden Nodes: [#{@hiddenNodes}]\\t Output Nodes: [#{@outputNodes}]} \\n--------------------------------------------------------------------------------\\n\"\n puts \"\"\n\n end",
"def train(dataset)\n raise 'Override me!'\n end",
"def learn(inputs_set, outputs_set, max_training_count=50, tolerance=0.0, monitoring_channels=[])\n raise RubyBrain::Exception::TrainingDataError if inputs_set.size != outputs_set.size\n # raise \"inputs_set and outputs_set has different size!!!!\" if inputs_set.size != outputs_set.size\n\n best_error = Float::INFINITY\n best_weights_array = []\n max_training_count.times do |i_training|\n accumulated_errors = 0.0 # for rms\n inputs_set.zip(outputs_set).each do |t_input, t_output|\n forward_outputs = get_forward_outputs(t_input)\n # for rms start\n total_error_of_output_nodes = forward_outputs.zip(t_output).reduce(0.0) do |a, output_pair|\n a + ((output_pair[0] - output_pair[1])**2 / 2.0)\n end\n # end\n accumulated_errors += total_error_of_output_nodes / forward_outputs.size\n # accumulated_errors += forward_outputs.zip(t_output).reduce(0.0) { |a, output_pair| a + ((output_pair[0] - output_pair[1])**2 / 2.0) } / forward_outputs.size\n # for rms end\n backward_inputs = forward_outputs.zip(t_output).map { |o, t| o - t }\n run_backpropagate(backward_inputs)\n update_weights\n end\n\n rms_error = Math.sqrt(2.0 * accumulated_errors / inputs_set.size) # for rms\n # rms_error = calculate_rms_error(inputs_set, outputs_set)\n puts \"--> #{rms_error} (#{i_training}/#{max_training_count})\"\n \n if rms_error < best_error\n puts \"update best!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\"\n best_error = rms_error\n best_weights_array = @weights_set.get_weights_as_array\n end\n puts \"best: #{best_error}\"\n\n\n break if rms_error <= tolerance\n end\n if monitoring_channels.include? :best_params_training\n File.open \"best_weights_#{Time.now.to_i}.yml\", 'w+' do |f|\n YAML.dump(best_weights_array, f)\n end\n end\n end",
"def normalize\n puts \"[debug] [normalize] node weight: #{@weight.class}\"\n if @is_leaf == 1\n @@validations.each do |validation|\n puts \"[debug] [normalize] current validation: |#{validation[0].class}|#{validation[1]}|#{validation[2]}|\"\n if (validation[0]...validation[1]) === @weight\n puts \"Bang!\"\n @weight=validation[2]\n break\n end\n end\n 1\n else\n 0\n end\n end",
"def feed_forward\n # light up the input nodes corresponding to the\n # words in our query\n word_ids.size.times do |i|\n all_in[i] = 1.0\n end\n \n # hidden activations\n hidden_ids.size.times do |j|\n sum = 0.0\n word_ids.size.times do |i|\n sum += all_in[i] * weights_in[i][j]\n end\n all_hidden[j] = Math.tanh(sum)\n end\n\n #output activations\n url_ids.size.times do |k|\n sum = 0.0\n hidden_ids.size.times do |j|\n sum += all_hidden[j] * weights_out[j][k]\n end\n all_out[k] = Math.tanh(sum)\n end\n\n all_out\n end",
"def process(array)\n # \"Analysis for ...\"\n begin\n words = array.shift.split(\" \")\n rescue NoMethodError\n raise \"Invalid input for Regress\"\n end\n @num_cases = words[2].to_i\n @num_variables = words[5].to_i\n # headers\n array.shift\n # Basic stats\n @min = array.shift.split(\" \")[1].to_f\n @max = array.shift.split(\" \")[1].to_f\n @sum = array.shift.split(\" \")[1].to_f\n @mean= array.shift.split(\" \")[1].to_f\n @stddev = array.shift.split(\" \")[1].to_f\n # Ignore correlation matrix (for now)\n 6.times { array.shift }\n # Regression equation\n array.shift #header\n eq = array.shift.split(\" \")\n @slope = eq[2].to_f\n @intercept = eq[5].to_f\n array.shift # blank line\n # \"Significance test...\"\n array.shift #header\n array.shift #colheader\n vars = array.shift.split(\" \")\n @r = vars[0].to_f\n @r_squared = vars[1].to_f\n @se_est = vars[2].to_f\n @f = vars[3].to_f\n @prob = vars[4].to_f\n end",
"def train(combos, rewards)\n RubyFann::TrainData.new(\n inputs: combos,\n desired_outputs: rewards\n )\n end",
"def activate\n @output = (1.0 / (1.0 + Math.exp(-1 * self.weightedsum - @bias)))\n @output\n end",
"def train\n run_aggregation\n run_syntetics\n run_values_to_ranges\n run_reverse\n\n [name, classifier]\n end",
"def activation(dendrites, nueron_number)\n\tweights=Array.new\n\ttotal_value=0\n\tfor i in 0...dendrites.size\n\t\tvalue=dendrites[i].print_value \n\t\tweights=dendrites[i].print_weight\n\t\ttotal_value=total_value + (weights[nueron_number-1]*value)\n\tend\n\treturn total_value\nend",
"def predict(input)\n l_size = input.shape[0]\n az = Numo::DFloat.zeros(l_size,@nhidden)\n ar = Numo::DFloat.zeros(l_size,@nhidden)\n ahhat = Numo::DFloat.zeros(l_size,@nhidden)\n\tah = Numo::DFloat.zeros(l_size,@nhidden)\n\t\t\n a1 = tanh((input.dot @w1) + @b1)\n pp \"a1 is ============\"\n pp a1\n pp a1[1,0...a1.shape[1]]\n\t \n # (array slice view) http://ruby-numo.github.io/narray/narray/Numo/DFloat.html#[]-instance_method\t \n x = (Numo::DFloat.zeros(@nhidden)).concatenate(a1[1,0...a1.shape[1]])\n az[1,0...az.shape[1]] = sigm((x.dot @wz) + @bz)\n ar[1,0...ar.shape[1]] = sigm((x.dot @wr) + @br)\n ahhat[1,0...ahhat.shape[1]] = tanh((x.dot @wh) + @bh)\n\tah[1,0...ah.shape[1]] = az[1,0...az.shape[1]]*ahhat[1,0...ahhat.shape[1]]\n\n # for i in range(1,l_size):\n (1...l_size).each do |i|\n x = ah[i-1,0...ah.shape[1]].concatenate(a1[i,0...a1.shape[1]])\n az[i,0...az.shape[1]] = sigm((x.dot @wz) + @bz)\n ar[i,0...ar.shape[1]] = sigm((x.dot @wr) + @br)\n x = (ar[i,0...ar.shape[1]]*ah[i-1,0...ah.shape[1]]).concatenate(a1[i,0...a1.shape[1]])\n ahhat[i,0...ahhat.shape[1]] = tanh((x.dot @wh) + @bh)\n ah[i,0...ah.shape[1]] = (1-az[i,0...az.shape[1]])*ah[i-1,0...az.shape[1]] + az[i,0...az.shape[1]]*ahhat[i,0...ahhat.shape[1]]\n end\n \n a2 = tanh((ah.dot @w2) + @b2)\n\treturn a1,az,ar,ahhat,ah,a2\n end",
"def train(example, category_index, probability = 1)\n example.each do |token|\n @token_counts[category_index][token] += probability\n @total_token_counts[category_index] += probability\n end\n @category_counts[category_index] += probability\n end",
"def initialize(target_proc: nil, input_proc: nil, bias_neuron: 2.0,\n number_of_medial_neurons: 40, learning_rate: 0.01)\n @input_proc = input_proc || -> { [rand, rand * 2 * Math::PI] }\n @target_proc = target_proc || -> (r, a) { Complex.polar(r, a).rectangular }\n\n @number_of_inputs = input_proc.call.length\n @number_of_inputs += 1 if bias_neuron != nil\n\n @number_of_outputs = target_proc.call(*input_proc.call).length\n\n @number_of_medial_neurons = number_of_medial_neurons\n\n @learning_rate = learning_rate\n @bias_neuron = bias_neuron\n @average_error = nil\n @training_iterations = 0\n\n # Initialize the synapse weightings using random numbers\n # `@synone` contains the synapse weights between every input neuron and every\n # medial neuron.\n # `@syntwo` contais the synapse weights between every medial neuron and every\n # output neuron.\n @synone = @number_of_inputs.times.map { @number_of_medial_neurons.times.map { 0.1 * rand } }\n @syntwo = @number_of_medial_neurons.times.map { @number_of_outputs.times.map { 0.1 * rand } }\n end",
"def train(image, target_char)\n # quantize to two-color\n image = quantize_image(image)\n #image.write(filename_for_quantized_image(target_char, 'gif'))\n\n # the binary string we expect to see from the output nodes\n @target_binary_string = char_to_binary_string(target_char)\n\n # feed the image data forward through the network to obtain a result\n #\n assign_inputs image\n calculate_hidden_outputs\n calculate_final_outputs\n\n # propagate the error correction backward through the net\n #\n calculate_output_errors\n calculate_hidden_errors\n adjust_output_weights\n adjust_input_weights\n end",
"def train(sgd, obj, w, train_set, num_epoch = 50, batch_size = 2000)\n iters = []\n losses = []\n iters << 0\n losses << obj.func(train_set[\"data\"], sgd.weights)\n\n num_epoch.times do |t|\n if t % 10 == 0 \n puts \"# epoch: #{t}\"\n end\n train_set[\"data\"].each_slice(batch_size) do |batch| \n sgd.update(batch)\n # iters << i\n # losses << obj.func(batch, sgd.weights)\n # i += 1\n end\n iters << t + 1\n losses << obj.func(train_set[\"data\"], sgd.weights)\n end\n scores = score_binary_classification_model(train_set[\"data\"], w, obj)\n train_auc_1 = calc_auc_only_1(scores)\n puts train_auc_1\n return [sgd, iters, losses]\nend",
"def perceptron_training (x1, y1, x2, y2, training_size)\n\ttarget_slope = (y2 -y1)/(x2-x1)\n\ttarget_c = y1 - (target_slope*x1)\n\txt,yt,ot = generate_training_set(target_slope, target_c, training_size)\n\t# weights[0] is wx and weights[1] is wy\n\tweights = [my_rand(-1,1), my_rand(-1,1)]\n\tlearning_rate = 0.1\n\titeration = 1\n\tloop do\n\t\tglobal_error=0\n\t\tfor i in 0..training_size-1 do\n\t\t\t#for the weight calculate the output\n\t\t\tactual_output = output(xt[i],yt[i],weights)\n\t\t\tlocal_error = ot[i] - actual_output\n\t\t\tif local_error != 0\n\t\t\t\t#update weights to adjust\n\t\t\t\tweights[0] = weights[0] + learning_rate * local_error * xt[i]\n\t\t\t\tweights[1] = weights[1] + learning_rate * local_error * yt[i]\n\t\t\tend\n\t\t\tglobal_error = global_error + local_error.abs\n\t\tend\n\t\tif global_error == 0\n\t\t\tbreak\n\t\tend\n\t\titeration += 1\n\tend\n\tdisagreement = calculate_disagreement(-target_slope,1,weights[0],weights[1])\n\treturn iteration, disagreement\nend",
"def train_model( instances )\n instances = [ instances ] unless instances.class == Array\n # First randomize data **TODO** Use GSL for ranomization\n instances.sort!{ |xx,yy| rand(3) + 1 }\n # Step through each instance.\n instances.each do |inst|\n # First, predict based on current weights\n sum = score( inst )\n # Now, if we predict incorrectly, then we need to adjust weights\n if sum > @threshold\n # Fix weights for false positives\n demote!( inst ) if !inst.is_class\n else\n # Fix weights for false negatives\n promote!( inst ) if inst.is_class\n end\n end\n instances.push( *instances )\n end",
"def train_pixel\n\t\tif CartesianClassifier.train(params[:classname],params[:bands],params[:author])\n\t\t\trender :text => \"trained as '\"+params[:classname]+\"', you happy now?\", :layout => false\n\t\telse\n\t\t\trender :text => \"failed to train\", :layout => false\n\t\tend\n\tend",
"def compute(*inputs)\n if inputs.length != number_of_inputs\n raise WrongNumberOfInputsError, \"Expected #{number_of_inputs} inputs, got #{inputs.length}\"\n end\n\n # Stash these in instance variables so we can use them for training later\n @medin = []\n @medout = []\n\n outputs = []\n\n number_of_medial_neurons.times do |i|\n @medin[i] = 0\n number_of_inputs.times do |j|\n @medin[i] += @synone[j][i] * inputs[j]\n end\n @medout[i] = Math.tanh(@medin[i])\n end\n\n number_of_outputs.times do |i|\n outputs[i] = 0\n number_of_medial_neurons.times do |j|\n outputs[i] += @syntwo[j][i] * @medout[j]\n end\n end\n\n outputs\n end",
"def update_base_predictors(user,film,error,learn_rate,f_regulator)\r\n mu=SVD_param.find_by_name(@global_predictor_str)\r\n mu.value=mu.value + error*learn_rate\r\n user.base_predictor=user.base_predictor+(error*learn_rate - f_regulator*user.base_predictor)\r\n film.base_predictor=film.base_predictor+(error*learn_rate - f_regulator*film.base_predictor)\r\n mu.save\r\n user.save\r\n film.save\r\n end",
"def train_set\n data_input = data_output = @data_input\n data_input.delete_at(data_input.index(data_input.last))\n data_output.delete_at(data_output.index(data_output.first))\n RubyFann::TrainData.new(inputs: data_input,\n desired_outputs: data_output)\n end",
"def learn!\n parse_ngrams!\n parse_lexicon!\n compute_interpolations! if interpolations.nil?\n end",
"def predict(input)\n # Perform forward propagation to predict output\n \n # Activation on input nodes should simply be the input\n @activation_input[-1] = 1 # set bias node's activation to 1\n @activation_input[0..-2] = input\n \n # Compute the weighted sum into each hidden node\n @hiddenNodes.times do |x|\n s = 0.0\n @inputNodes.times do |i|\n s = s + (@activation_input[i] * @w_1[i][x])\n end\n # update activation for the hidden layer\n @activation_hidden[x] = NeuralNetwork::activation(s)\n end\n \n # Now compute the weighted sum into each output node\n @outputNodes.times do |x|\n s = 0.0\n @hiddenNodes.times do |h|\n s = s + (@activation_hidden[h] * @w_2[h][x])\n end\n # update activations for the output layer\n @activation_output[x] = NeuralNetwork::activation(s)\n end\n\n @activation_output\n\n end",
"def predictor\n w = perceptron\n\n train_data = normalize_data(\"votes-test.csv\")\n actual_values = train_data.map { |x| x.last }\n predictions = train_data.map { |x| activation_output(x.first, w) }\n\n wrong = (0..actual_values.length-1).select { |i| actual_values[i] != predictions[i] }.count\n correct = actual_values.length - wrong\n\n p \"CORRECT: #{correct}\"\n p \"WRONG: #{wrong}\"\nend",
"def prepare\r\n\t\t@machine \t||= @machineClass.new @trainTestStruct.trainingData, @target, @parameters\r\n\t\t@machine.train\r\n\tend",
"def trainAsGradientDescent\r\n\t\tlRate \t\t\t\t= @parameters[:lRate] || @@defaultGDLearnRate \r\n\t\titerations\t\t\t= @parameters[:iterations] || @@defaultGDIterations\r\n\t\t#Skip identical train\r\n\t\treturn if @trained && @gradientModel && @learningRate == lRate && @iterations == iterations\r\n\t\t#Set hyperparameters\r\n\t\t@learningRate \t\t= lRate\r\n\t\t@iterations\t\t\t= iterations\r\n\t\t#Train Gradient Descent\r\n\t\t@lr.train_gradient_descent @learningRate, @iterations, @silentMode\r\n\t\t#Train flags update\r\n\t\t@trained \t\t\t= true\r\n\t\t@gradientModel\t\t= true\r\n\tend",
"def train_and_print! s, input_sets, n=10000\n # Train it to recognize all of our inputs\n n.times do |n|\n input_sets.each do |set|\n s.train_pattern! input: set, output: set\n end\n\n print \"\\rFor iteration \\##{n}, error term is #{s.last_error_term}.\" if n != 0 && (n % 2000 == 0)\n end\n\n puts ''\n # Print out the result of the autoencoder for each\n input_sets.each do |set|\n puts \"For input: #{set},\\tOutput: #{s.evaluate!(set).map { |obj| obj.round }}\"\n end\nend",
"def feedforward(a)\n @biases.zip(@weights).each do |b, w|\n a = NeuralNets::Math.sigmoid_vec(w.dot(a) + b)\n end\n a\n end",
"def fit(x, y)\n x = Rumale::Validation.check_convert_sample_array(x)\n y = Rumale::Validation.check_convert_target_value_array(y)\n Rumale::Validation.check_sample_size(x, y)\n xx = fit_bias? ? expand_feature(x) : x\n @model = Numo::Liblinear.train(xx, y, liblinear_params)\n @weight_vec, @bias_term = weight_and_bias(@model[:w])\n self\n end",
"def first_full_learning()\r\n destoy_old_factors\r\n init_params\r\n\r\n global_av=get_global_av_rating\r\n set_default_users_factors(global_av)\r\n set_default_films_factors(global_av)\r\n\r\n #getting learning process params\r\n max_iter=SVD_param.find_by_name(@max_iterations_str).value.to_i\r\n learn_rate=SVD_param.find_by_name(@learning_rate_str).value\r\n ratings_count=Rating.all.count\r\n f_regulator=SVD_param.find_by_name(@f_regulator_str).value\r\n\r\n rmse=1\r\n rmse_old=0\r\n threshold=0.01\r\n iter_count=0\r\n while (rmse-rmse_old).abs>0.0001\r\n iter_count+=1\r\n rmse_old=rmse\r\n rmse=0\r\n\r\n log_write_iter_count(iter_count)\r\n\r\n Rating.all.each do |rating|\r\n user=User.find(rating.user_id)\r\n film=Film.find(rating.film_id)\r\n\r\n #get prediction and calculate error\r\n predicted=predict_rating(user=user,film=film)\r\n error=rating.value-predicted\r\n rmse+=error*error\r\n\r\n log_write_rating_and_error(rating,error,learn_rate,predicted)\r\n\r\n #update factors and predictors\r\n update_base_predictors(user,film,error,learn_rate,f_regulator)\r\n update_factors(user.id,film.id,learn_rate,error,f_regulator)\r\n end\r\n\r\n #calculate rmse\r\n rmse=rmse/ratings_count\r\n\r\n log_write_rmse(rmse,rmse_old)\r\n\r\n #if rmse changes by small amout - slow down learning rate\r\n if (rmse - rmse_old).abs < threshold\r\n learn_rate*=0.66\r\n threshold=threshold*0.5\r\n end\r\n #if iterations count is too big - stop learning\r\n if iter_count > max_iter\r\n break\r\n end\r\n end\r\n\r\n l_r=SVD_param.find_by_name(@learning_rate_str)\r\n l_r.value=learn_rate\r\n l_r.save\r\n\r\n end",
"def init_activation_nodes\n @activation_nodes = Array.new(@structure.length) do |n|\n Array.new(@structure[n], 1.0)\n end\n if not disable_bias\n @activation_nodes[0...-1].each {|layer| layer << 1.0 }\n end\n end",
"def predict new_data_set=nil\n if new_data_set.nil? then\n @fitted_mean_values\n else\n new_data_matrix = new_data_set.to_matrix\n # this if statement is done because Statsample::GLM::MLE::Normal#measurement expects that\n # the coefficient vector has a redundant last element (which is discarded by #measurement\n # in further computation)\n b = if self.is_a?(Statsample::GLM::MLE::Normal) then\n Matrix.column_vector(@coefficients.to_a + [nil])\n else\n @coefficients.to_matrix(axis=:vertical)\n end\n create_vector measurement(new_data_matrix, b).to_a.flatten\n end\n end",
"def backpropagate\n\t\t# calculate output errors\n\t\toutput_error = []\n\t\t@layers[2].neurons.each_with_index do |neuron, index|\n\t\t\terror = @expected_output[index] - neuron.value\n\t\t\toutput_error[index] = dtanh(neuron.value) * error\n\t\tend\n\n\t\t# calculate hidden errors\n\t\thidden_error = []\n\t\t@layers[1].neurons.each_with_index do |neuron, index|\n\t\t\terror = 0.0\n\t\t\tindex_helper = 0\n\t\t\tneuron.arrows.each do |arrow|\n\t\t\t\terror = error + output_error[index_helper] * arrow.weight\n\t\t\t\tindex_helper += 1\n\t\t\tend\n\t\t\thidden_error[index] = dtanh(neuron.value) * error\n\t\tend\n\n\t\t#update arrow weights going to outputs\n\t\t@layers[1].neurons.each do |neuron|\n\t\t\tneuron.arrows.each_with_index do |arrow, i|\n\t\t\t\tchange = output_error[i] * neuron.value\n\t\t\t\tarrow.weight = arrow.weight + change\n\t\t\tend\n\t\tend\n\t\t\n\t\t#update arrow weights going to hidden layer\n\t\t@layers[0].neurons.each do |neuron|\n\t\t\tneuron.arrows.each_with_index do |arrow, i|\n\t\t\t\tchange = hidden_error[i] * neuron.value\n\t\t\t\tarrow.weight = arrow.weight + change\n\t\t\tend\n\t\tend\n\tend",
"def learn(_d)\n # average\n u = @u\n @u = 0\n _d.each do |d|\n if d == \"?\"\n @u += u\n else\n @u += d\n end\n end\n @u /= _d.size\n\n # variance\n @s = 0\n _d.each do |d|\n if d == \"?\"\n # nothing\n else\n @s += (@u - d)**2\n end\n end\n @s /= _d.size\n end",
"def initialize data, target, parameters\r\n\t\tsuper(data, target, parameters)\r\n\t\t@silentMode\t\t\t= !(parameters[:silentMode] || false)\r\n\t\t@gradientModel\t\t= parameters[:gradientDescent] || false\r\n\t\tnewRegressor\r\n\tend",
"def read_training_corpus(training_corpus)\n @training_set = read_corpus_file(training_corpus)\n log \"Creating and training Perceptron Model\"\n train_perceptron()\n log \"Successfully trained Perceptron Model\" \n end",
"def set_train(train)\r\n @train = train\r\n end",
"def value(dendrites_array,num)\n\t\t\tx=activation(dendrites_array,num)\n\t\t\t@value=sigmoidal(x)\n\t\tend",
"def value(dendrites_array,num)\n\t\t\tx=activation(dendrites_array,num)\n\t\t\t@value=sigmoidal(x)\n\t\tend",
"def update\n ones = Matrix.columns( [Array.new(@N) { 1.0 }] )\n (1..@L).each do |l|\n delta_W = ( MU*@delta_W_prev[l] ) -\n @learning_rate*( (@Delta[l] * @Z[l-1].t / @N) + LAMBDA*@layers[l].W )\n delta_b = ( MU*@delta_b_prev[l] ) -\n @learning_rate*( @Delta[l] * ones )\n\n @delta_W_prev[l] = Marshal.load(Marshal.dump(delta_W))\n @delta_b_prev[l] = Marshal.load(Marshal.dump(delta_b))\n\n @layers[l].W = @layers[l].W + delta_W\n @layers[l].b = @layers[l].b + delta_b\n end\n end",
"def train(query:)\n Trainer.train(query: query)\n end",
"def activate x\n\t\tcase @type\n\n\t\t#perceptron types\n\t\twhen :sigmoid\n\t\t\tsigmoid(x)\n\t\twhen :threshold\n\t\t\tthreshold(x)\n\t\twhen :tanh\n\t\t\ttanh(x)\n\t\twhen :none\n\t\t\tnone(x)\n\t\twhen :rectified_liniar_unit\n\t\t\trectified_liniar_unit(x)\n\t\twhen :leaky_rectified_liniar_unit\n\t\t\tleaky_rectified_liniar_unit(x)\n\t\twhen :radial_basis\n\t\t\tradial_basis(x)\n\n\t\t#I/O\n\t\twhen :input #no params\n\t\t\tnone(x)\n\t\twhen :output #no params\t\t\t\n\t\t\tnone(x)\n\t\telse\n\t\t\traise \"unknown node type: #{@type}\"\n\t\tend\n\tend",
"def initialize\n @x = Array.new\n @y = Array.new\n @output = Array.new\n @weights = [0.0001,0.0001,0.0001]\n end",
"def train\n training = @prediction.trainedmodels.insert.request_schema.new\n training.id = 'emotion_prediction_id'\n training.storage_data_location = DATA_OBJECT\n result = @client.execute(\n :api_method => @prediction.trainedmodels.insert,\n :headers => {'Content-Type' => 'application/json'},\n :body_object => training\n )\n\n assemble_json_body(result)\n end",
"def mean\n\t\tsummation = predictions.inject(0.0) {|sum, pred| sum + pred.error }\n\t\tsummation / predictions.size\t\n\tend",
"def initialize(dataset = [], options = {})\r\n @dataset = dataset\r\n @dataset_normalized = []\r\n\r\n @normalization = options[:normalization] || :none # linear or standard_deviation\r\n\r\n normalize()\r\n end",
"def create\n @neural_strategy = NeuralStrategy.new(params[:neural_strategy])\n @quote_targets = QuoteTarget.find(:all)\n @neural_strategy.quote_target_id = params[:quote_target_id]\n @neural_strategy.last_neural_processing_time = 0\n @neural_strategy.last_prediction_processing_time = 0\n respond_to do |format|\n if @neural_strategy.save\n flash[:notice] = 'NeuralStrategy was successfully created.'\n format.html { redirect_to(@neural_strategy) }\n format.xml { render :xml => @neural_strategy, :status => :created, :location => @neural_strategy }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @neural_strategy.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def test_evaluate2\r\n model = DNN::Models::Sequential.new\r\n model << DNN::Layers::InputLayer.new(3)\r\n model.setup(DNN::Optimizers::SGD.new, DNN::Losses::MeanSquaredError.new)\r\n x = Xumo::SFloat[[0, 0.5, 1], [0.5, 1, 0]]\r\n y = Xumo::SFloat[[0, 1, 0.5], [0, 1, 0.5]]\r\n evaluator = DNN::Evaluator.new(model)\r\n assert_equal 0.5, evaluator.evaluate(x, y).first\r\n end",
"def train\n\n funny_joke_votes = Vote.all( :fields => [:joke_id], :username => @username, :percent.gt => 50 )\n unfunny_joke_votes = Vote.all( :fields => [:joke_id], :username => @username, :percent.lt => 50 )\n funny_joke_ids = []\n unfunny_joke_ids = []\n\n funny_joke_votes.each { |j| funny_joke_ids << j.joke_id.to_i }\n unfunny_joke_votes.each { |j| unfunny_joke_ids << j.joke_id.to_i }\n\n funny = []\n unfunny = []\n\n funny_joke_ids.each do |jid|\n funny << Joke.all( :id => jid )\n end\n\n unfunny_joke_ids.each do |jid|\n unfunny << Joke.all( :id => jid )\n end\n\n\n funny.flatten!\n unfunny.flatten! \n\n b = Classifier::Bayes.new 'funny', 'unfunny'\n\n @log.message :info, \"Training funny jokes (amount: #{funny.length.to_s})\"\n funny.each do |joke|\n content = joke.title.to_s + joke.content.to_s\n b.train_funny content\n end\n\n @log.message :info, \"Training unfunny jokes (amount: #{unfunny.length.to_s})\"\n unfunny.each do |joke|\n content = joke.title.to_s + joke.content.to_s\n b.train_unfunny content\n end\n\n result = []\n \n Joke.all.each do |joke|\n content = joke.title.to_s + joke.content.to_s\n type = b.classify content\n\n if( type.downcase == \"funny\" )\n result << joke \n end\n end\n \n result\n end",
"def linearAccuracy\n wrong = 0\n correct = 0\n tp = 0\n tn = 0\n fp = 0\n fn = 0\n\n @label = Array.new(@total_line) {0.00}\n @evaluate = Array.new(@total_line) {0.00}\n @bayes_part = Array.new(@total_line) {0.00}\n\n t_file = File.open(\"./true_label.txt\", \"r\").to_enum\n e_file = File.open(\"./p_zh.txt\", \"r\").to_enum\n b_file = File.open(\"./decision_label.txt\", \"r\").to_enum\n\n array_count = 0\n loop do\n #access next line in each file with .next\n line_t = t_file.next.to_f\n line_e = e_file.next.to_f\n line_b = b_file.next.to_f\n\n if line_e != 0.0\n if line_t == 1.0\n if line_e == 1.0\n tp += 1\n elsif line_e == -1.0\n fp += 1\n else\n puts \"what?\"\n end\n elsif line_t == -1.0\n if line_e == 1.0\n fn += 1\n elsif line_e == -1.0\n tn += 1\n else\n puts \"what??\"\n end\n else\n puts \"what???\"\n end \n\n @evaluate[array_count] = line_e\n @label[array_count] = line_t\n @bayes_part[array_count] = line_b\n array_count += 1\n end\n end\n\n # write best results in simple linear to file\n File.open('true_label_linear.txt', 'w') do |f1| \n # use \"\\n\" for two lines of text \n @label.each do |line|\n f1.puts line\n end\n end\n\n File.open('decision_label_linear.txt', 'w') do |f2| \n # use \"\\n\" for two lines of text \n @evaluate.each do |line|\n f2.puts line\n end\n end\n\n File.open('decision_label_bayes_part.txt', 'w') do |f3| \n # use \"\\n\" for two lines of text \n @bayes_part.each do |line|\n f3.puts line\n end\n end\n\n puts (\"#{@label.size} lines\")\n correct = tp + tn\n wrong = fp + fn\n @Accuracy = 0.0\n @Accuracy = correct.to_f * 100 / (correct + wrong)\n puts \"Simple Accuracy #{@Accuracy}%\"\n tpr = tp.to_f / (tp + fn)\n fpr = fp.to_f / (fp + tn)\n puts \"fp: #{fp} fn: #{fn} tp: #{tp} tn: #{tn}\"\n puts \"tpr #{tpr} fpr: #{fpr}\"\n\n print \"linear \"\n system('./calc_auc ./true_label_linear.txt ./decision_label_linear.txt')\n\n print \"bayes part accordingly \"\n system('./calc_auc ./true_label_linear.txt ./decision_label_bayes_part.txt')\nend",
"def evaluate(test_corpus)\n log \"Evaluating model against #{test_corpus}\"\n num_right = 0\n num_possible = 0\n outfile_name = \"data/output-perceptron.txt\"\n # Read file\n File.open(test_corpus) do |file|\n File.open(outfile_name, \"w+\") do |outfile|\n log \"Writing results to file #{outfile_name}.\"\n # Read lines.\n file.readlines.each do |line|\n # Extract tagged words.\n tagged_words = line.scan(TAGGED_WORD_RE)\n # Now just the words.\n just_the_words = tagged_words.map do |tag,word|\n word\n end\n states_guess = @model.states_of_events(just_the_words)\n outfile.print_in_corpus_format(states_guess.zip(just_the_words))\n states_guess.each_with_index do |state,index|\n num_right += 1 if state == tagged_words[index][0]\n num_possible += 1\n end\n end\n end\n end\n log \"Tagged #{num_right} correctly out of a possible #{num_possible}.\"\n return Float(num_right) / num_possible\n end",
"def prepare_data(num_rows)\n app_train = read_dataset_from_csv('./input/application_train', num_rows)\n data = app_train[\"data\"]\n set_categorical_labels(data)\n numeric_features, _categorical_features = get_numeric_cateforical_features_from_the_raw_dataset(app_train[\"data\"])\n categorical_features_one_hot_encode = get_one_hot_feature_map_from_the_origin_dataset(data)\n one_hot_encoding_using_feature_map(data, categorical_features_one_hot_encode)\n\n # NaN values for DAYS_EMPLOYED: 365243 -> nan\n data.each do |r|\n r_features = r[\"features\"]\n if r_features[\"days_empoyed\"] == 365243\n r_features[\"days_employed\"] = \"\"\n r_features[\"days_employed_anom\"] = 1\n else\n r_features[\"days_employed_anom\"] = 0 \n end \n \n add_ratio_feature(\"payment_rate\", \"amt_annuity\", \"amt_credit\", r)\n add_ratio_feature(\"annuity_income_ratio\", \"amt_annuity\", \"amt_income_total\", r)\n add_ratio_feature(\"credit_goods_ratio\", \"amt_credit\", \"amt_goods_price\", r)\n # add_ratio_feature(\"income_person_ratio\", \"amt_income_total\", \"cnt_fam_members\", r)\n add_ratio_feature(\"employed_birth_ratio\", \"days_employed\", \"days_birth\", r)\n end\n # categorical_features << \"days_employed_anom\"\n\n bureau = read_dataset_from_csv('./input/bureau', 1000, $bureau_numeric_features)\n # bureau[\"data\"].each do |r|\n # puts r[\"features\"][\"days_enddate_fact\"]\n # end\n # return\n grouped = group_data(bureau[\"data\"])\n agged = agg_group_data(grouped, $bureau_numeric_features, \"bureau\")\n merge_to_dataset(app_train, agged, $bureau_numeric_features)\n\n app_train[\"features\"] = app_train[\"data\"][0][\"features\"].keys\n\n puts \"begin to normalize the dataset......\"\n nomalizer = Normalizer.new\n nomalizer.normalize(app_train, numeric_features)\n\n puts \"begin to impute missing value......\"\n imputer = SimpleImputer.new\n imputer.fit(app_train)\n \n puts \"finish preparing the dataset!\"\n return app_train\nend",
"def run_ant(ant)\n begin\n before_run(ant)\n rescue => e\n logger.error \"Error during run ant_started method: #{e} \\n #{e.backtrace}\"\n end\n begin\n out = run(ant)\n ant.output = out\n rescue => e\n logger.error \"Error during processing run method: #{e} \\n #{e.backtrace}\"\n ensure\n begin\n after_run(ant)\n rescue => e\n logger.error \"Error in ant_finished method: #{e} \\n #{e.backtrace}\"\n end\n end\n end",
"def regress(x,y)\n weights = Array.new(x.length)\n for f in 0..(x.length - 1)\n weights[f] = WeightedFeature.new(x[f].name,0.0)\n end\n w0 = 0.0\n weight_magnitude = 0\n old_gradient = 0\n gradient = 0\n begin\n weight_magnitude = 0\n old_gradient = gradient\n gradient = 0\n old_weights = weights.clone\n h_ary = Array.new\n w0sum = 0\n for j in 0..(x[0].length - 1) #loop over training examples\n z = w0\n for k in 0..(x.length - 1) #calculate weightsT * X\n z += old_weights[k].weight*x[k][j]\n end\n h_ary[j] = 1 / (1 + Math.exp(-z)) #calculate and store hypotheses\n w0sum += (y[j] - h_ary[j])\n end\n for i in 0..(x.length - 1) #update features\n wisum = 0\n for j in 0..(x[0].length - 1) #loop over training examples\n wisum += x[i][j]*(y[j] - h_ary[j]) #recall precomputed hypotheses\n end\n wisum = wisum - (old_weights[i].weight / SIGMA**2)\n weights[i].weight = old_weights[i].weight + ETA*wisum\n weight_magnitude += weights[i].weight**2\n gradient += wisum**2\n end\n w0sum = w0sum - (w0 / SIGMA**2)\n w0 = w0 + ETA*w0sum\n gradient += w0sum**2\n gradient = gradient**(1.0/2)\n weight_magnitude = weight_magnitude**(1.0/2)\n end while((old_gradient - gradient).abs > EPSILON)\n weights.w0 = w0\n return weights\nend",
"def propagate(rate = 0.1, target = nil)\n error = 0.0\n\n # Is neuron in output layer\n if !target.nil?\n # Eq. 10.\n @error.responsibility = @error.projected = target - @activation\n else\n # The rest of the neuron compute their error responsibilities by back-\n # propagation\n connections.projected.each_value do |connection|\n neuron = connection.to\n\n # Eq. 21.\n error +=\n neuron.error.responsibility * connection.gain * connection.weight\n end\n\n # Projected error responsibility\n @error.projected = @derivative * error\n\n error = 0.0\n # Error responsibilities from all the connections gated by this neuron\n trace.extended.each do |id, _|\n neuron = @neighbors[id] # gated neuron\n # If gated neuron's selfconnection is gated by this neuron\n influence = neuron.selfconnection.gater == self ? neuron.old : 0.0\n\n # Index runs over all th econnections to the gated neuron that are\n # gated by this neuron\n trace.influences[id].each do |input, infl|\n # Captures the effect that the input connection of this neuron have,\n # on a neuron which its input/s is/are gated by this neuron\n influence +=\n infl.weight *\n trace.influences[neuron.id][input].from.activation\n end\n\n # Eq. 22.\n error += neuron.error.responsibility * influence\n end\n\n # Gated error responsibility\n @error.gated = @derivative * error\n\n # Error responsibility - Eq. 23.\n @error.responsibility = @error.projected + @error.gated\n end\n\n connections.inputs.each_value do |input_neuron|\n # Eq. 24\n gradient = @error.projected * trace.elegibility[input_neuron.id]\n trace.extended.each do |id, _|\n neuron = neighbors[id]\n gradient +=\n neuron.error.responsibility *\n trace.extended[neuron.id][input_neuron.id]\n end\n\n # Adjust weights - aka. learn\n input_neuron.weight += rate * gradient\n end\n\n # Adjust bias\n @bias += rate * @error.responsibility\n end",
"def train\n classifiers_initializer = ClassifiersInitializer.load_or_create\n classifiers_initializer.run\n @classifiers = classifiers_initializer.classifiers.map do |name, classifier|\n Classifier.new(classifier, self.class.config, name).train\n end.to_h\n end",
"def newRegressor\r\n\t\t@trained\t\t= false\r\n\t\t@lr \t\t\t= RubyLinearRegression.new\r\n\t\tputs trainingData.getDataStructure(useHash).first\r\n\t\t@lr.load_training_data trainingData.getDataStructure(useHash), trainingDataAsArray\r\n\tend",
"def mean\n\t\tsum = 0\n\t\tpred_list.each do |pred|\n\t\t\tsum += pred[:error]\n\t\tend\n\t\treturn sum / size\n\tend",
"def fit(x, y)\n x = Rumale::Validation.check_convert_sample_array(x)\n y = Rumale::Validation.check_convert_label_array(y)\n Rumale::Validation.check_sample_size(x, y)\n xx = fit_bias? ? expand_feature(x) : x\n @model = Numo::Liblinear.train(xx, y, liblinear_params)\n @weight_vec, @bias_term = weight_and_bias(@model[:w])\n @prob_param = proba_model(decision_function(x), y)\n self\n end",
"def feedforward(input_values)\n input_values.each_index do |input_index|\n @activation_nodes.first[input_index] = input_values[input_index]\n end\n @weights.each_index do |n|\n @structure[n+1].times do |j|\n sum = 0.0\n @activation_nodes[n].each_index do |i|\n sum += (@activation_nodes[n][i] * @weights[n][i][j])\n end\n @activation_nodes[n+1][j] = @propagation_function.call(sum)\n end\n end\n end",
"def train\n @badasspoints += 1\n end",
"def initialize()\n @predictions = []\n @difference = []\n @mean = -1\n end",
"def fit_transform(x, _y = nil)\n x = ::Rumale::Validation.check_convert_sample_array(x)\n\n fit(x)\n x / @norm_vec.expand_dims(1)\n end",
"def fit_transform(x, _y = nil)\n x = ::Rumale::Validation.check_convert_sample_array(x)\n\n fit(x)\n x / @norm_vec.expand_dims(1)\n end",
"def _pre_process\n @pre_processor = @league.pre_processor.new(@data_feed_file).start\n\n if @pre_processor.errored?\n _output_errors(@pre_processor, 'preprocessing')\n else\n _output_success(@pre_processor, 'preprocessing')\n end\n end",
"def transform(x)\n x = ::Rumale::Validation.check_convert_sample_array(x)\n\n cx = @params[:whiten] ? (x - @mean) : x\n cx.dot(@components.transpose)\n end",
"def predict new_data_set=nil\n if new_data_set.nil? then\n @fitted_mean_values\n else\n new_data_matrix = new_data_set.to_matrix\n b = @coefficients.to_matrix axis=:vertical\n create_vector measurement(new_data_matrix, b).to_a.flatten\n end\n end",
"def initialize\n @do_training = false\n @do_testing = false\n @do_importances = true\n\n @forest_size = DEFAULTS[:forest_size]\n @tree_SNP_sample_size = DEFAULTS[:tree_SNP_sample_size]\n @tree_SNP_total_count = DEFAULTS[:tree_SNP_total_count]\n @tree_node_min_size = DEFAULTS[:tree_node_min_size]\n @loss_function_discrete = DEFAULTS[:loss_function_discrete]\n @loss_function_continuous = DEFAULTS[:loss_function_continuous]\n\n @output_forest_file = File.expand_path(DEFAULTS[:output_forest_file], Dir.pwd)\n @output_training_file = File.expand_path(DEFAULTS[:output_training_file], Dir.pwd)\n @output_testing_file = File.expand_path(DEFAULTS[:output_testing_file], Dir.pwd)\n @output_tree_errors_file = File.expand_path(DEFAULTS[:output_tree_errors_file], Dir.pwd)\n @output_snp_importances_file = File.expand_path(DEFAULTS[:output_snp_importances_file], Dir.pwd)\n\n @silent = ENV['nimbus_test'] == 'running_nimbus_tests' ? true : DEFAULTS[:silent]\n end",
"def getTotalledResult\r\n\t\treturn @totalResult if @totalResult\r\n\t\tdataSet = RegressionDataSet.new nil, @trainTestStruct.trainingData.features\r\n\t\ti \t\t= 0\r\n\t\twhile i < @trainTestStruct.testSetCount\r\n\t\t\tdataSet << @trainTestStruct.testSets(i)\r\n\t\t\ti \t\t+= 1\r\n\t\tend\r\n\t\tinputAndTargets\t= getTargets dataSet\r\n\t\t@totalResult \t= @trainTestStruct.setTotalResult(@machine.validateSet inputAndTargets.first, inputAndTargets.last, @predictionType)\r\n\tend",
"def predict(x)\n raise \"#{self.class.name}##{__method__} expects to be called after training the model with the fit method.\" unless trained?\n x = Rumale::Validation.check_convert_sample_array(x)\n xx = fit_bias? ? expand_feature(x) : x\n Numo::Liblinear.predict(xx, liblinear_params, @model)\n end"
] |
[
"0.62786293",
"0.5942058",
"0.59141207",
"0.58798444",
"0.5814036",
"0.58032566",
"0.5654799",
"0.55475736",
"0.55252194",
"0.5481473",
"0.5470412",
"0.5452019",
"0.5338243",
"0.5287792",
"0.52805334",
"0.5244875",
"0.52251166",
"0.52147555",
"0.5177056",
"0.5149112",
"0.5120812",
"0.51109964",
"0.5106872",
"0.50987935",
"0.5001452",
"0.49947676",
"0.4977942",
"0.4947635",
"0.49295828",
"0.48973435",
"0.48823994",
"0.48779038",
"0.48695096",
"0.48256636",
"0.48231408",
"0.4813199",
"0.4812169",
"0.47634664",
"0.47423536",
"0.4738242",
"0.47170863",
"0.46999824",
"0.46942607",
"0.46840027",
"0.46504566",
"0.46300068",
"0.46234196",
"0.46027938",
"0.4578855",
"0.45739985",
"0.4569978",
"0.45638084",
"0.45534268",
"0.45384976",
"0.45280907",
"0.4527048",
"0.4517119",
"0.4501688",
"0.4453449",
"0.44472232",
"0.44405633",
"0.44369134",
"0.44346237",
"0.44246247",
"0.44197655",
"0.44135314",
"0.43983862",
"0.43895075",
"0.43895075",
"0.43796933",
"0.43782744",
"0.43748057",
"0.43564892",
"0.43344975",
"0.43281603",
"0.4323563",
"0.4304473",
"0.42856476",
"0.42852607",
"0.42715603",
"0.42629635",
"0.42548788",
"0.42448825",
"0.42434373",
"0.42409018",
"0.42392567",
"0.42390543",
"0.42377344",
"0.42367274",
"0.4230116",
"0.42257458",
"0.42250776",
"0.42221043",
"0.42221043",
"0.42187813",
"0.42175356",
"0.42139247",
"0.42113426",
"0.421091",
"0.42101374"
] |
0.6087506
|
1
|
Reinits the ANN and forgets learned stuff
|
def reset
init_fann
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def reset\n @fann = RubyFann::Standard.new fann_opts\n if algo && algo != :rwg\n fann.set_training_algorithm(algo)\n end\n if actfn\n fann.set_activation_function_hidden(actfn)\n fann.set_activation_function_output(actfn)\n end\n if init_weights_range\n fann.randomize_weights(*init_weights_range.map(&method(:Float)))\n end\n end",
"def reset\n if config.isRecurrent\n @nn.resetRecurrentStates\n else\n puts \"Warning not a recurrent network. This does nothing\"\n end\n end",
"def reset\n clear\n CONNECTION_TYPES.map { |ct| connections.send(ct) }.each do |conn_group|\n conn_group.each_value { |conn| conn.weight = rand * 0.2 - 0.1 }\n end\n\n @bias = rand * 0.2 - 0.1\n @old = @state = @activation = 0\n end",
"def reset\n initialize\n @log = nil\n @default_model = nil\n end",
"def reset!\n initialize\n end",
"def reset\n $iptr = 0\n $program = []\n $labels = {}\n $binding = binding\nend",
"def reset\n initialize\n setup\n end",
"def reset\n\t\tself.rs \t= 0\n\t\tself.ps \t= 0\n\t\tself.ss \t= 0\n\t\tself.gen\t= Random.new(SEED)\n\tend",
"def reset!\n @cached_descriptions = nil\n @nodes = nil\n @cloud_nodes = nil\n end",
"def reset\n @equations = nil\n @results = nil\n end",
"def reset\n setup\n end",
"def reset\n @targets_run = [ ]\n end",
"def initialize(inputNodes, hiddenNodes, outputNodes, learningRate=0.3, momentum=0.2)\n # Make sure we add the bias node to the input\n @inputNodes = inputNodes + 1\n @hiddenNodes = hiddenNodes\n @outputNodes = outputNodes\n\n @learningRate = learningRate\n @momentum = momentum\n\n @w_1 = NeuralNetwork::create_matrix(@inputNodes, @hiddenNodes, 0.0)\n @w_2 = NeuralNetwork::create_matrix(@hiddenNodes, @outputNodes, 0.0)\n \n # Randomize the values of Nthe nodes [-0.5, 0.5]\n @w_1.map! { |arr| arr.map { |v| rand(-0.5..0.5) } }\n @w_2.map! { |arr| arr.map { |v| rand(-0.5..0.5) } }\n\n # It helps to store the current state of node activations\n @activation_input = [1.0] * @inputNodes\n @activation_hidden = [1.0] * @hiddenNodes\n @activation_output = [1.0] * @outputNodes\n\n @din = NeuralNetwork::create_matrix(@inputNodes, @hiddenNodes, 0.0)\n @dout = NeuralNetwork::create_matrix(@hiddenNodes, @outputNodes, 0.0)\n\n puts \"\\n================================================================================================\\n[+]Weights from input to hidden nodes [#{@inputNodes}x#{@hiddenNodes}] has been initialized with small random values\"\n puts \"[+]Weights from hidden to output nodes [#{@hiddenNodes}x#{@outputNodes}] has been nitialized to small random values\\n================================================================================================\\n\"\n\n puts \"Neural network initialized with values \\n \\t Input Nodes:[{#{@inputNodes}]\\t Hidden Nodes: [#{@hiddenNodes}]\\t Output Nodes: [#{@outputNodes}]} \\n--------------------------------------------------------------------------------\\n\"\n puts \"\"\n\n end",
"def reset\n clear_cache\n @class_hierarchy = nil\n @ontology = nil\n @known_classes = nil\n end",
"def prepare_network\n @neural_net = RubyFann::Standard.new(num_inputs: @nuerons_number,\n hidden_neurons: [(2 * @nuerons_number) / 3],\n num_outputs: @nuerons_number)\n end",
"def reset()\n \n end",
"def reset\n @exemptions = ExemptionList.from_module(CoreExemptions)\n @global = false\n @trusted_filters = []\n end",
"def reset() end",
"def reset_loop\r\n @loop_start_ln = 0\r\n @loop_template = nil\r\n @loop_examples = Array.new\r\n end",
"def reset_loop\r\n @loop_start_ln = 0\r\n @loop_template = nil\r\n @loop_examples = Array.new\r\n end",
"def reset\n @loaded = false\n @target = nil\n @stale_state = nil\n end",
"def reset\n @loaded = false\n @target = nil\n @stale_state = nil\n end",
"def reset!\n end",
"def reset!\n end",
"def reset!\n @root = Node::Root.new(self, request_methods)\n @named_routes = {}\n @routes = []\n @grapher = Grapher.new(self)\n @priority_lookups = false\n end",
"def reset\n @res_features = FEATURES.dup\n @res_feature_types = FEATURE_TYPES.dup\n @res_segments = SEGMENTS.dup\n end",
"def reset ; end",
"def reset\n end",
"def reset\n end",
"def reset\n end",
"def reset\n end",
"def initialize\r\n reset\r\n end",
"def reset\n end",
"def reset\n end",
"def initialize\n self.reset!\n end",
"def reset_all_nodes\n nodes.where(net_id: id).each do |node|\n node.output = 0\n node.total_input = 0\n node.save\n end\n end",
"def initialize\n # reset\n end",
"def reset\n @parsers = nil\n @transformer = nil\n @cache = nil\n end",
"def initialize\n reset\n end",
"def initialize\n reset\n end",
"def initialize\n reset\n end",
"def initialize\n reset\n end",
"def do_reset\n\t\t\n\t\t\t# Mark state as reset\n\t\t\t@reset = true\n\t\t\t\n\t\t\t# Revert text and palette\n\t\t\tself.text = nil \n\t\t\tself.palette = @palette_normal\t\t\t\n\t\tend",
"def reset!\n self.words_for_last = []\n self.corpus_dfs = {}\n self.block_list = []\n self.single_block = []\n end",
"def reset()\n #This is a stub, used for indexing\n end",
"def reset()\n #This is a stub, used for indexing\n end",
"def initialize\n reset\n \tend",
"def reset()\n end",
"def reset; end",
"def reset; end",
"def reset; end",
"def reset; end",
"def reset; end",
"def reset; end",
"def reset; end",
"def reset; end",
"def reset; end",
"def reset; end",
"def reset; end",
"def reset; end",
"def reset; end",
"def reset; end",
"def reset; end",
"def reset; end",
"def reset; end",
"def reset; end",
"def reset!; end",
"def reset!; end",
"def reset!; end",
"def reset!; end",
"def reset()\r\n\t\t@time.reset\r\n\t\t@penalty.reset\r\n\t\t@usedHelp = 0\r\n\t\t@numberOfStars = 0\r\n\t\t@isFinished = false\r\n\t\t@nbClick = 0\r\n\t\treturn self\r\n\tend",
"def reset\n # TODO\n end",
"def reset\n\n end",
"def reset\r\n interpreter_reset\r\n compiler_reset\r\n end",
"def reset\n end",
"def reset\n end",
"def initialize\n reset\n end",
"def initialize\n reset\n end",
"def interpreter_reset\r\n @data_stack = Array.new\r\n @ctrl_stack = Array.new\r\n @start_time = Time.now\r\n end",
"def initialize()\n reset!\n end",
"def reset\n \n end",
"def reset\n @perms = []\n @depends = []\n @next_blocks = []\n @clobbers = []\n @offset = nil\n @state = nil\n @once = false\n @references = 0\n @used_references = 0\n @generated = false\n end",
"def reset\n @agent.reset\n end",
"def reset\n @gold, @metal, @stone, @wood = [5, 1, 1, 1]\n @dwarves, @elves, @gnomes = [3, 3, 0]\n @properties, @score = [12, 0]\n\n self\n end",
"def reset\n\t\tend",
"def init_activation_nodes\n @activation_nodes = Array.new(@structure.length) do |n|\n Array.new(@structure[n], 1.0)\n end\n if not disable_bias\n @activation_nodes[0...-1].each {|layer| layer << 1.0 }\n end\n end",
"def reset\n self.instance_variables.each do |var|\n instance_variable_set(var, nil)\n end\n initialize\n end",
"def reset\n @enabled = proc { |_env| Rails.env.development? || Rails.env.test? }\n @flamegraph_enabled = true\n @flamegraph_sample_rate = 0.5\n @logger = RailsMiniProfiler::Logger.new(Rails.logger)\n @skip_paths = []\n @storage = Storage.new\n @ui = UserInterface.new\n @user_provider = proc { |env| Rack::Request.new(env).ip }\n end",
"def initialize\n reset!\n end",
"def initialize\n reset!\n end",
"def initialize\n reset!\n end",
"def initialize\n reset!\n end",
"def initialize\n reset!\n end",
"def reset\n @params = initial_params\n self\n end",
"def reset\n @config = nil\n end",
"def reset()\n @result = false\n @tests = 0\n end",
"def reset\n @dependencies_are_ready = nil\n @dependencies_have_failed = nil\n reset_forward\n end",
"def reset\n cleanup(true)\n end",
"def reset!\n @rewrites = []\n @any_tests = false\n @needs_tests = false\n end",
"def reset\n\t\tself.gen = Random.new(SEED)\n\tend"
] |
[
"0.7521403",
"0.6686727",
"0.65604556",
"0.6288221",
"0.6282612",
"0.6225561",
"0.6075317",
"0.5897425",
"0.5828759",
"0.58217466",
"0.5800422",
"0.579044",
"0.57703185",
"0.57560396",
"0.5717115",
"0.57141227",
"0.57123655",
"0.57012695",
"0.5661192",
"0.5656705",
"0.56398517",
"0.56398517",
"0.5628319",
"0.5628319",
"0.56235176",
"0.5600458",
"0.56000227",
"0.5593315",
"0.5593315",
"0.5593315",
"0.5593315",
"0.5591968",
"0.55904335",
"0.55904335",
"0.5584367",
"0.5581519",
"0.5575471",
"0.5574981",
"0.5569666",
"0.5569666",
"0.5569666",
"0.5569666",
"0.55637556",
"0.5557683",
"0.5556545",
"0.5556545",
"0.5553383",
"0.5545229",
"0.553952",
"0.553952",
"0.553952",
"0.553952",
"0.553952",
"0.553952",
"0.553952",
"0.553952",
"0.553952",
"0.553952",
"0.553952",
"0.553952",
"0.553952",
"0.553952",
"0.553952",
"0.553952",
"0.553952",
"0.553952",
"0.55358034",
"0.55358034",
"0.55358034",
"0.55358034",
"0.55314434",
"0.5523181",
"0.55169004",
"0.5512191",
"0.5500083",
"0.5500083",
"0.5483375",
"0.5483375",
"0.54820883",
"0.5480101",
"0.54792714",
"0.54721725",
"0.546916",
"0.5464799",
"0.54624075",
"0.5452153",
"0.5448155",
"0.5447326",
"0.5440109",
"0.5440109",
"0.5440109",
"0.5440109",
"0.5440109",
"0.54365724",
"0.5433555",
"0.54282707",
"0.5426245",
"0.54196805",
"0.5406924",
"0.5404675"
] |
0.703791
|
1
|
Runs fann on real inputs
|
def run(inputs, normalize_outputs = true)
outputs = fann.run(inputs)
if normalize_outputs
return outputs.map { |value| value / normalization_factor }
else
return outputs
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def train(options = {})\n options.reverse_merge!({ :max_epochs => 100000, :epochs_between_reports => 500, :desired_error => 0.0001 })\n #fann.train_on_data(train_data, 10000, 100, 0.00001)\n fann.train_on_data(train_data, options[:max_epochs], options[:epochs_between_reports], options[:desired_error] * normalization_factor)\n end",
"def train\n puts '>>> 1'\n train = RubyFann::TrainData.new(filename: './train.data')\n\n puts '>>> 2'\n @fann = RubyFann::Standard.new(num_inputs: @number_of_inputs, hidden_neurons: [@number_of_inputs/20, @number_of_inputs/40], num_outputs: @number_of_outputs)\n\n puts '>>> 3'\n @fann.train_on_data(train, 1000, 10, 0.1) # 1000 max_epochs, 10 errors between reports and 0.1 desired MSE (mean-squared-error)\n @fann.save('./headlines.net')\n\n puts '>>> 4'\n test\n end",
"def test inputs\n inputs.collect &fann.method(:run)\n end",
"def reset \n init_fann\n end",
"def doTraining\n\t\t# Ruby fan uses its own special data structure. 2D Array for both X and Y data\n\t\ttrain\t\t= RubyFann::TrainData.new(inputs: @xData[:train], desired_outputs: @yData[:train])\n\t\t# Train\n\t\tmachine\t= RubyFann::Standard.new(num_inputs: @nInputs, hidden_neurons:[2], num_outputs: 1)\n\t\tmachine.train_on_data(train, @iterations, @reportSteps, @maxError) \n\t\t# Remember to send the machine back to the caller\n\t\tmachine\n\tend",
"def reset\n @fann = RubyFann::Standard.new fann_opts\n if algo && algo != :rwg\n fann.set_training_algorithm(algo)\n end\n if actfn\n fann.set_activation_function_hidden(actfn)\n fann.set_activation_function_output(actfn)\n end\n if init_weights_range\n fann.randomize_weights(*init_weights_range.map(&method(:Float)))\n end\n end",
"def train_data\n ::RubyFann::TrainData.new(\n :inputs => inputs, \n :desired_outputs=> desired_outputs)\n end",
"def convertf args\n if SHOW_FFI \n MemoryPointer.new(:float, 4).put_array_of_float(0,args ) \n else\n args\n end\nend",
"def calculate(nn)\n val = lambda do |curr, net, x, y|\n curr * 0.95 + 0.05 * (net.feed_forward([x, y]) * 280.0 - 140.0)\n end\n @z = (0...cols).map do |i|\n (0...rows).map do |j|\n val.call(z[i][j], nn, i * 1.0 / cols, j * 1.0 / cols)\n end\n end\n end",
"def h(n); ackermann(2, n); end",
"def ntype\n 'ruby-fann'\n end",
"def ret_f\n result = 0.0\n func = get_func(Fiddle::TYPE_FLOAT)\n if func\n result = func.call(*@args).to_f\n end\n result\n end",
"def prepare_network\n @neural_net = RubyFann::Standard.new(num_inputs: @nuerons_number,\n hidden_neurons: [(2 * @nuerons_number) / 3],\n num_outputs: @nuerons_number)\n end",
"def evaluate\n @output_value = Math.tanh(@input_value - @bias)\n #p \"output value #{@output_value}\"\n @forward_nodes.each do |node, weight|\n #p \"weight #{weight} old input #{node.input_value}\"\n node.input_value += @output_value * weight\n #p \"new input #{node.input_value}\"\n end\n @input_value = 0\n end",
"def predict(input)\n l_size = input.shape[0]\n az = Numo::DFloat.zeros(l_size,@nhidden)\n ar = Numo::DFloat.zeros(l_size,@nhidden)\n ahhat = Numo::DFloat.zeros(l_size,@nhidden)\n\tah = Numo::DFloat.zeros(l_size,@nhidden)\n\t\t\n a1 = tanh((input.dot @w1) + @b1)\n pp \"a1 is ============\"\n pp a1\n pp a1[1,0...a1.shape[1]]\n\t \n # (array slice view) http://ruby-numo.github.io/narray/narray/Numo/DFloat.html#[]-instance_method\t \n x = (Numo::DFloat.zeros(@nhidden)).concatenate(a1[1,0...a1.shape[1]])\n az[1,0...az.shape[1]] = sigm((x.dot @wz) + @bz)\n ar[1,0...ar.shape[1]] = sigm((x.dot @wr) + @br)\n ahhat[1,0...ahhat.shape[1]] = tanh((x.dot @wh) + @bh)\n\tah[1,0...ah.shape[1]] = az[1,0...az.shape[1]]*ahhat[1,0...ahhat.shape[1]]\n\n # for i in range(1,l_size):\n (1...l_size).each do |i|\n x = ah[i-1,0...ah.shape[1]].concatenate(a1[i,0...a1.shape[1]])\n az[i,0...az.shape[1]] = sigm((x.dot @wz) + @bz)\n ar[i,0...ar.shape[1]] = sigm((x.dot @wr) + @br)\n x = (ar[i,0...ar.shape[1]]*ah[i-1,0...ah.shape[1]]).concatenate(a1[i,0...a1.shape[1]])\n ahhat[i,0...ahhat.shape[1]] = tanh((x.dot @wh) + @bh)\n ah[i,0...ah.shape[1]] = (1-az[i,0...az.shape[1]])*ah[i-1,0...az.shape[1]] + az[i,0...az.shape[1]]*ahhat[i,0...ahhat.shape[1]]\n end\n \n a2 = tanh((ah.dot @w2) + @b2)\n\treturn a1,az,ar,ahhat,ah,a2\n end",
"def feedforward(inputs)\n # Sum all values\n sum = @weights.zip(inputs).map { |a, b| a * b }.inject(0, :+)\n # Result is sign of the sum, -1 or 1\n activate(sum)\n end",
"def infla(y=40,f=2)\n self.to_f*(f.to_q**y)\n end",
"def forward\n new_x, new_y = forward_prediction\n reset(x: new_x, y: new_y, f: @f)\n end",
"def f_x(n1, n2, x); 1.0 - fdist(n1, n2, x); end",
"def _naive_forecast(components, horizon)\n #\n # Computing the forecast for the naive model\n #\n return _trivial_forecast(components, horizon)\n\nend",
"def train_neural_network\n # Prepare the inputs and outputs that will be used.\n # For every input that we create, we will need a matching output, as\n # each output represents the *expected* output of the neural network during\n # training and without which back-propagation is impossible. Therefore,\n # inputs and outputs are both lists of lists (lists of vectors).\n inputs = []\n outputs = []\n\n # Loop for each language with this outer loop. It means that the inside will\n # run as many times as we have different languages to train on.\n SEED.each do |lang, articles|\n # Prepare an array containing as many 0.0 values as we have languages.\n output = Array.new LANGUAGES.length, 0.0\n # Set the output that matches the current language to 1.0.\n output[LANGUAGES.index lang] = 1.0\n # At this point, the `ouput` variable contains something like [0.0, 0.0, 0.0]\n # and points the neural network to the expected output language we want.\n\n # Now we need an inner loop that will process each article.\n puts \"Processing language #{lang}...\"\n articles.each do |article|\n # Download the article text for the current language.\n text = wikipedia_page_text lang, article\n # Build the per-letter frequency dictionary.\n frequencies = letter_frequencies text\n # Transform the frequencies dictionary into our single input vector.\n input = build_inputs ALPHABET, frequencies\n inputs << input\n outputs << output\n puts \" Crawled page #{article}, length: #{text.length}\"\n end\n end\n\n # Here we initialize a new neural network and store it in the variable named\n # `net`. Later, any operation we need to perform over the neural network could\n # be invoked using `net.something`. The neural network is initialized using\n # the various sizes of our training dataset and expected output length.\n net = RubyFann::Standard.new num_inputs: ALPHABET.length,\n num_outputs: LANGUAGES.length,\n hidden_neurons: [ALPHABET.length]\n # Our neural network being from a library, it expects a very specific training\n # dataset format, so we will create one here to train on. The training object\n # will be the most simple one containing our inputs and outputs, and will be\n # stored in a variable named `train`.\n train = RubyFann::TrainData.new inputs: inputs, desired_outputs: outputs\n\n # Now we're going to train the neural network. The parameters that the library\n # expects are: the training dataset, the maximum number of iteration before\n # aborting, the visual reporting of the state of the training and the desired\n # target error rate (accuracy) of the resulting network.\n net.train_on_data train, 1000, 10, 0.01\n\n # As we might want to re-use the same network later if it proves itself to be\n # good enough, let's save it to the hard disk in a file.\n net.save 'frequencies.train'\n\n # As we want anyone calling this function to be able to use the trained network,\n # we make sure to return it here in the end.\n net\nend",
"def feedforward(val)\n @output = val * weight # Compute output\n @sender = a.origin # Start animation at originating neuron\n @sending = true # Turn on sending\n end",
"def feedforward(input1, input2)\n n1 = neurons[0]\n n1.feedforward(input1)\n n2 = neurons[1]\n n2.feedforward(input2)\n end",
"def f(x0, y0)\n @f.call(x0, y0)\n end",
"def feedforward(input_values)\n input_values.each_index do |input_index|\n @activation_nodes.first[input_index] = input_values[input_index]\n end\n @weights.each_index do |n|\n @structure[n+1].times do |j|\n sum = 0.0\n @activation_nodes[n].each_index do |i|\n sum += (@activation_nodes[n][i] * @weights[n][i][j])\n end\n @activation_nodes[n+1][j] = @propagation_function.call(sum)\n end\n end\n end",
"def train trainset, ngens=@ngens, report_interval: 1000, desired_error: 1e-10\n # it makes sense to temporarily disable the `report_interval` with `false` or `nil`\n report_interval ||= 0\n # special case: not implemented in FANN\n if algo == :rwg\n return train_rwg(trainset, ngens,\n report_interval: report_interval, desired_error: desired_error)\n end\n # TODO: optimize maybe?\n times, inputs, targets = trainset.values\n tset = RubyFann::TrainData.new inputs: inputs, desired_outputs: targets\n # fann.init_weights tset # test this weights initialization\n\n # params: train_data, max_epochs, report_interval, desired_error\n fann.train_on_data(tset, ngens, report_interval, desired_error)\n end",
"def future_given_annuity(annuity, interest, term)\n (annuity * (((1 + interest.to_f) ** term) -1) / interest.to_f ).round(4)\n end",
"def to_f(aNum)\r\n# - - - - - - - - - - - - - - - - - -\r\n return 0.0 + aNum\r\nend",
"def pfdist(n1, n2, y); pf(1.0 - y, n1, n2); end",
"def fvan(i, n, pmt)\n return pmt * (((1 + i) ** n) - 1) / i \n end",
"def integ(f, a, b, n=1000)\n\tdx = (b - a).to_f / n\n\ts = 0.0\n\tn.times do |i|\n\t\tx = a + i * dx\n\t\ty = f.call(x)\n\t\ts += y * dx\n\tend\n\treturn s\nend",
"def fexp(wi_or_fei=nil)\n\n flow_expression(wi_or_fei || fei)\n end",
"def act_f()\n (y() >= 0) ? 1.0 : -1.0;\n end",
"def reciprocal\nFraccionario.new(@den, @num)\nend",
"def fourier_analysis_reverse(ns,as,bs,c, t0, t1)\n proc{|x|\n 0.5*c + ns.map{|n| as[n-1]*sin(2*PI*n*(x-t0)/(t1-t0)) +\n bs[n-1]*cos(2*PI*n*(x-t0)/(t1-t0))\n }.sum\n }\nend",
"def inverse_f\n return 0 if f_x.zero?\n temp_value = i = 0\n while temp_value <= f_x && i < n\n temp_value = gsl_cdf.binomial_P(i, p, n)\n next if temp_value >= f_x\n i += 1\n end\n i.zero? ? 0 : i - 1\n end",
"def call(f)\n CAS::Help.assert(f, Hash)\n Math::tan(@x.call(f))\n end",
"def test_to_f\n x = Torch.tensor([1.5])\n assert_equal 1.5, x.to_f\n end",
"def fit=(_arg0); end",
"def map_float (arr)\n flo = arr.map(& :to_f)\n puts \"El array como flotantes #{flo}\" \nend",
"def run_fib(args={})\n num = args.fetch(:num, generate_sm_num)\n fib = fibonacci_iter(num)\n # convert_results(fibonacci_iter(num))\n end",
"def processSamples(samples, f, fs)\r\n processSamplesKoef(samples, calc_koef(f, fs))\r\n end",
"def fit; end",
"def mle_via_newton(logLikelihood,initial_parameter_value,tolerance=0.001)\n # Your code goes here.\nend",
"def ifft\r\n inverse_strategy.new(data).calculate\r\n end",
"def run_fe_tests\n end",
"def pf_x(n1, n2, x); pfdist(n1, n2, 1.0 - x); end",
"def mrf; xparam(5); end",
"def feed_forward\n # light up the input nodes corresponding to the\n # words in our query\n word_ids.size.times do |i|\n all_in[i] = 1.0\n end\n \n # hidden activations\n hidden_ids.size.times do |j|\n sum = 0.0\n word_ids.size.times do |i|\n sum += all_in[i] * weights_in[i][j]\n end\n all_hidden[j] = Math.tanh(sum)\n end\n\n #output activations\n url_ids.size.times do |k|\n sum = 0.0\n hidden_ids.size.times do |j|\n sum += all_hidden[j] * weights_out[j][k]\n end\n all_out[k] = Math.tanh(sum)\n end\n\n all_out\n end",
"def feedforward(a)\n @biases.zip(@weights).each do |b, w|\n a = NeuralNets::Math.sigmoid_vec(w.dot(a) + b)\n end\n a\n end",
"def compute(*inputs)\n if inputs.length != number_of_inputs\n raise WrongNumberOfInputsError, \"Expected #{number_of_inputs} inputs, got #{inputs.length}\"\n end\n\n # Stash these in instance variables so we can use them for training later\n @medin = []\n @medout = []\n\n outputs = []\n\n number_of_medial_neurons.times do |i|\n @medin[i] = 0\n number_of_inputs.times do |j|\n @medin[i] += @synone[j][i] * inputs[j]\n end\n @medout[i] = Math.tanh(@medin[i])\n end\n\n number_of_outputs.times do |i|\n outputs[i] = 0\n number_of_medial_neurons.times do |j|\n outputs[i] += @syntwo[j][i] * @medout[j]\n end\n end\n\n outputs\n end",
"def frexp\n\t\tresult = Math.frexp(@input)\n\n\t render json: result, status: 200\n\trescue\n\t\trender json: {\"message\": 'Use the format: {\"input\": num}'}, status: 400\n\tend",
"def value(dendrites_array,num)\n\t\t\tx=activation(dendrites_array,num)\n\t\t\t@value=sigmoidal(x)\n\t\tend",
"def value(dendrites_array,num)\n\t\t\tx=activation(dendrites_array,num)\n\t\t\t@value=sigmoidal(x)\n\t\tend",
"def feedforward(forces)\n # Sum all values\n forces.zip(@weights).map { |a, b| a * b }.inject(Vec2D.new, :+)\n end",
"def pv(fv, n, r)\n fv*(1.0/((1+r)**n))\nend",
"def float!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 34 )\n\n \n # - - - - main rule block - - - -\n # at line 344:5: ( ( '0' .. '9' )+ '.' ( '0' .. '9' )* ( EXPONENT )? | '.' ( '0' .. '9' )+ ( EXPONENT )? | ( '0' .. '9' )+ EXPONENT )\n alt_12 = 3\n alt_12 = @dfa12.predict( @input )\n case alt_12\n when 1\n # at line 344:9: ( '0' .. '9' )+ '.' ( '0' .. '9' )* ( EXPONENT )?\n # at file 344:9: ( '0' .. '9' )+\n match_count_6 = 0\n while true\n alt_6 = 2\n look_6_0 = @input.peek( 1 )\n\n if ( look_6_0.between?( 0x30, 0x39 ) )\n alt_6 = 1\n\n end\n case alt_6\n when 1\n # at line 344:10: '0' .. '9'\n match_range( 0x30, 0x39 )\n\n else\n match_count_6 > 0 and break\n eee = EarlyExit(6)\n\n\n raise eee\n end\n match_count_6 += 1\n end\n\n match( 0x2e )\n # at line 344:25: ( '0' .. '9' )*\n while true # decision 7\n alt_7 = 2\n look_7_0 = @input.peek( 1 )\n\n if ( look_7_0.between?( 0x30, 0x39 ) )\n alt_7 = 1\n\n end\n case alt_7\n when 1\n # at line 344:26: '0' .. '9'\n match_range( 0x30, 0x39 )\n\n else\n break # out of loop for decision 7\n end\n end # loop for decision 7\n # at line 344:37: ( EXPONENT )?\n alt_8 = 2\n look_8_0 = @input.peek( 1 )\n\n if ( look_8_0 == 0x45 || look_8_0 == 0x65 )\n alt_8 = 1\n end\n case alt_8\n when 1\n # at line 344:37: EXPONENT\n exponent!\n\n end\n\n when 2\n # at line 345:9: '.' ( '0' .. '9' )+ ( EXPONENT )?\n match( 0x2e )\n # at file 345:13: ( '0' .. '9' )+\n match_count_9 = 0\n while true\n alt_9 = 2\n look_9_0 = @input.peek( 1 )\n\n if ( look_9_0.between?( 0x30, 0x39 ) )\n alt_9 = 1\n\n end\n case alt_9\n when 1\n # at line 345:14: '0' .. '9'\n match_range( 0x30, 0x39 )\n\n else\n match_count_9 > 0 and break\n eee = EarlyExit(9)\n\n\n raise eee\n end\n match_count_9 += 1\n end\n\n # at line 345:25: ( EXPONENT )?\n alt_10 = 2\n look_10_0 = @input.peek( 1 )\n\n if ( look_10_0 == 0x45 || look_10_0 == 0x65 )\n alt_10 = 1\n end\n case alt_10\n when 1\n # at line 345:25: EXPONENT\n exponent!\n\n end\n\n when 3\n # at line 346:9: ( '0' .. '9' )+ EXPONENT\n # at file 346:9: ( '0' .. '9' )+\n match_count_11 = 0\n while true\n alt_11 = 2\n look_11_0 = @input.peek( 1 )\n\n if ( look_11_0.between?( 0x30, 0x39 ) )\n alt_11 = 1\n\n end\n case alt_11\n when 1\n # at line 346:10: '0' .. '9'\n match_range( 0x30, 0x39 )\n\n else\n match_count_11 > 0 and break\n eee = EarlyExit(11)\n\n\n raise eee\n end\n match_count_11 += 1\n end\n\n exponent!\n\n end\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 34 )\n\n end",
"def propagation_fn(x) 1/(1+Math.exp(-x)) end",
"def fdist(n1, n2, f); 1.0 - q_f(n1, n2, f); end",
"def in_fahrenheit\n if @type == :f\n @temp\n else\n ((@temp.to_f * 9.0)/5.0) + 32.0\n end\n end",
"def calculate_acf\n denominator = 0.0\n acf = Array.new\n for i in 0..@signal.size-@windowlength-1 do\n acf[i] = 0\n denominator = 0.0\n for k in 0..@windowlength do\n acf[i] += @signal[k] * @signal[k+i]\n denominator += @signal[k+i]*@signal[k+i]\n end\n acf[i] = acf[i]/denominator\n end\n return acf\n end",
"def Float(p0) end",
"def present_given_annuity(annuity, interest, term)\n (annuity.to_f * (((1 + interest.to_f) ** term) -1) / (interest.to_f * (1 + interest.to_f) ** term )).round(4)\n end",
"def compute_result(f, t, n)\n\twynik = Array.new(n)\n\n\tfor i in Range.new(0, n-1)\n\t\tif i > 0\n\t\t\tprint \" + \" if @debug == true\n\t\tend\n\t\tprint \"x^#{i}(\" if @debug == true\n\t\twynik[i] = 0\n\t\tfor j in Range.new(i, n-1)\n\t\t\tx = newton(j, j-i, t)\n\t\t\tif x.count > 0\n\t\t\t\tfor a in x\n\t\t\t\t\ttmp = f[j]\n\t\t\t\t\tif j != i\n\t\t\t\t\t\tif (((j-i) % 2) == 0)\n\t\t\t\t\t\t\ttmp = f[j]\n\t\t\t\t\t\t\tprint \" + \" if @debug == true\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\ttmp = -tmp\n\t\t\t\t\t\t\tprint \" - \" if @debug == true\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\t\tprint \"f[#{j}]\" if @debug == true\n\t\t\t\t\tfor b in a\n\t\t\t\t\t\tprint \"*\" if @debug == true\n\t\t\t\t\t\tprint b if @debug == true\n\t\t\t\t\t\ttmp *= b\n\t\t\t\t\tend\n\t\t\t\t\twynik[i] += tmp\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\tprint \")\" if @debug == true\n\tend\n\treturn wynik\nend",
"def simpson(t1, t2, n, &f)\n n += 1 unless n % 2 == 0\n d=(t2-t1) / n.to_f \n out= (d / 3.0)*(f[t1.to_f].to_f+\n ((1..(n-1)).inject(0) {|ac,i|\n ac+((i%2==0) ? 2 : 4)*f[t1+d*i] \n })+f[t2.to_f].to_f)\n out\n end",
"def activation_function(value)\n Math.tanh(value)\n end",
"def f0\n fr(0)\n end",
"def call(weight, gradient)\n @moment ||= Xumo::DFloat.zeros(weight.shape[0])\n @moment += gradient**2\n weight - (@params[:learning_rate] / (@moment**0.5 + 1.0e-8)) * gradient\n end",
"def calc_koef(f, fs)\r\n 2 * Math.cos(2 * Math::PI * f / fs)\r\n end",
"def transform(x)\n x = ::Rumale::Validation.check_convert_sample_array(x)\n\n # initialize transformed features\n n_samples, n_features = x.shape\n z = Numo::DFloat.zeros(n_samples, n_output_features)\n # bias\n z[true, 0] = 1\n curr_col = 1\n # itself\n z[true, 1..n_features] = x\n curr_col += n_features\n # high degree features\n curr_feat_ids = Array.new(n_features + 1) { |n| n + 1 }\n (1...@params[:degree]).each do\n next_feat_ids = []\n n_features.times do |d|\n f_range = curr_feat_ids[d]...curr_feat_ids.last\n next_col = curr_col + f_range.size\n z[true, curr_col...next_col] = z[true, f_range] * x[true, d..d]\n next_feat_ids.push(curr_col)\n curr_col = next_col\n end\n next_feat_ids.push(curr_col)\n curr_feat_ids = next_feat_ids\n end\n z\n end",
"def f1(x, x); end",
"def logf(f)\n typedecl f: Float, foreign: Float\n Math.log(f)\n end",
"def pfX_(n1, n2, x); pfdist(n1, n2, x); end",
"def fX_(n1, n2, x); fdist(n1, n2, x); end",
"def forecast(temp, img)\n\n @image = img\n\n def image\n @image\n end\n @degrees = temp\n def results\n if @degrees.to_i < 70 && @degrees.to_i >= 40\n \"you better bring a jacket, it is going to be #{@degrees} degrees today.\"\n elsif @degrees.to_i < 40\n \"dude, its freezing. #{@degrees} degrees and not getting any hotter\"\n else\n \"grab your sunscreen, it's going to be #{@degrees} degrees today.\"\n end\n end\n save_forecast(results, image)\n end",
"def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n\n #use the built-in error checking\n if not runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n\n #assign the user inputs to variables\n fan_choice = runner.getOptionalWorkspaceObjectChoiceValue(\"fan_choice\",user_arguments,model) #model is passed in because of argument type\n coeff_choice = runner.getOptionalStringArgumentValue(\"coeff_choice\", user_arguments)\n \n #check the fan for reasonableness\n apply_to_all_fans = false\n fan = nil\n if fan_choice.empty?\n handle = runner.getStringArgumentValue(\"fan_choice\",user_arguments)\n if handle == OpenStudio::toUUID(\"\").to_s\n #all fans\n apply_to_all_fans = true\n fan = nil\n runner.registerInfo(\"Apply new coefficients to all variable volume fans.\")\n else\n runner.registerError(\"The selected fan with handle '#{handle}' was not found in the model. It may have been removed by another measure.\")\n return false\n end\n else\n if not fan_choice.get.to_FanVariableVolume.empty?\n fan = fan_choice.get.to_FanVariableVolume.get\n else\n runner.registerError(\"Script Error - argument not showing up as a Fan Variable Volume.\")\n return false\n end\n end #end of if fan.empty?\n\n #get fans for measure\n if apply_to_all_fans\n fans = model.getFanVariableVolumes\n else\n fans = []\n fans << fan\n end\n \n if fans.size == 0\n runner.registerError(\"Measure not applicable because there are no variable volume fans in the model.\")\n end\n \n #loop through fans and set new coefficients\n num_fans = 0\n fans.each do |fan|\n if coeff_choice.to_s == \"Multi Zone VAV with Airfoil or Backward Incline riding the curve\"\n runner.registerInfo(\"Setting #{fan.name.to_s} coefficients to Multi Zone VAV with Airfoil or Backward Incline riding the curve\")\n fan.setFanPowerCoefficient1(0.1631)\n fan.setFanPowerCoefficient2(1.5901)\n fan.setFanPowerCoefficient3(-0.8817)\n fan.setFanPowerCoefficient4(0.1281)\n fan.setFanPowerMinimumFlowFraction(0.70)\n elsif coeff_choice.to_s == \"Multi Zone VAV with Airfoil or Backward Incline with inlet vanes\"\n runner.registerInfo(\"Setting #{fan.name.to_s} coefficients to Multi Zone VAV with Airfoil or Backward Incline with inlet vanes\")\n fan.setFanPowerCoefficient1(0.9977)\n fan.setFanPowerCoefficient2(-0.659)\n fan.setFanPowerCoefficient3(0.9547)\n fan.setFanPowerCoefficient4(-0.2936)\n fan.setFanPowerMinimumFlowFraction(0.50)\n elsif coeff_choice.to_s == \"Multi Zone VAV with Forward Curved fans riding the curve\"\n runner.registerInfo(\"Setting #{fan.name.to_s} coefficients to Multi Zone VAV with Forward Curved fans riding the curve\")\n fan.setFanPowerCoefficient1(0.1224)\n fan.setFanPowerCoefficient2(0.612)\n fan.setFanPowerCoefficient3(0.5983)\n fan.setFanPowerCoefficient4(-0.3334)\n fan.setFanPowerMinimumFlowFraction(0.30)\n elsif coeff_choice.to_s == \"Multi Zone VAV with Forward Curved with inlet vanes\"\n runner.registerInfo(\"Setting #{fan.name.to_s} coefficients to Multi Zone VAV with Forward Curved with inlet vanes\")\n fan.setFanPowerCoefficient1(0.3038)\n fan.setFanPowerCoefficient2(-0.7608)\n fan.setFanPowerCoefficient3(2.2729)\n fan.setFanPowerCoefficient4(-0.8169)\n fan.setFanPowerMinimumFlowFraction(0.30)\n elsif coeff_choice.to_s == \"Multi Zone VAV with vane-axial with variable pitch blades\"\n runner.registerInfo(\"Setting #{fan.name.to_s} coefficients to Multi Zone VAV with vane-axial with variable pitch blades\")\n fan.setFanPowerCoefficient1(0.1639)\n fan.setFanPowerCoefficient2(-0.4016)\n fan.setFanPowerCoefficient3(1.9909)\n fan.setFanPowerCoefficient4(-0.7541)\n fan.setFanPowerMinimumFlowFraction(0.20) \n elsif coeff_choice.to_s == \"Multi Zone VAV with VSD and fixed SP setpoint\"\n runner.registerInfo(\"Setting #{fan.name.to_s} coefficients to Multi Zone VAV with VSD and fixed SP setpoint\")\n fan.setFanPowerCoefficient1(0.0013)\n fan.setFanPowerCoefficient2(0.1470)\n fan.setFanPowerCoefficient3(0.9506)\n fan.setFanPowerCoefficient4(-0.0998)\n fan.setFanPowerMinimumFlowFraction(0.20)\n elsif coeff_choice.to_s == \"Multi zone VAV with static pressure reset\"\n runner.registerInfo(\"setting #{fan.name.to_s} coefficients to Multi zone VAV with static pressure reset\")\n fan.setFanPowerCoefficient1(0.040759894)\n fan.setFanPowerCoefficient2(0.088044970)\n fan.setFanPowerCoefficient3(-0.072926120)\n fan.setFanPowerCoefficient4(0.943739823)\n fan.setFanPowerMinimumFlowFraction(0.10)\n elsif coeff_choice.to_s == \"Single zone VAV fan\"\n runner.registerInfo(\"Setting #{fan.name.to_s} coefficients to Single zone VAV fan\")\n fan.setFanPowerCoefficient1(0.027827882)\n fan.setFanPowerCoefficient2(0.026583195)\n fan.setFanPowerCoefficient3(-0.0870687)\n fan.setFanPowerCoefficient4(1.03091975)\n fan.setFanPowerMinimumFlowFraction(0.10)\n elsif coeff_choice.to_s == \"Typical VSD Fan\"\n runner.registerInfo(\"Setting #{fan.name.to_s} coefficients to Typical VSD Fan\")\n fan.setFanPowerCoefficient1(0.047182815)\n fan.setFanPowerCoefficient2(0.130541742)\n fan.setFanPowerCoefficient3(-0.117286942)\n fan.setFanPowerCoefficient4(0.940313747)\n fan.setFanPowerMinimumFlowFraction(0.10)\n elsif coeff_choice.to_s == \"No SP Reset VSD Fan\"\n runner.registerInfo(\"Setting #{fan.name.to_s} coefficients to No SP Reset VSD Fan\")\n fan.setFanPowerCoefficient1(0.070428852)\n fan.setFanPowerCoefficient2(0.385330201)\n fan.setFanPowerCoefficient3(-0.460864118)\n fan.setFanPowerCoefficient4(1.00920344)\n fan.setFanPowerMinimumFlowFraction(0.10)\n end\n num_fans += 1 \n\t end\n \n runner.registerFinalCondition(\"Changed fan coefficients for #{num_fans} fan object(s) to #{coeff_choice}\")\t\n return true\n\n end",
"def perform_processing_run(faids)\n perform_analysis(faids)\n perform_processing!\n end",
"def do_rff(fv, sv)\n hf = get_marginal_entropy(fv)\n hs = get_marginal_entropy(sv)\n hfs = get_conditional_entropy(fv, sv)\n \n # symmetrical uncertainty\n 2*(hf-hfs)/(hf+hs)\n end",
"def first_derivative(x,y,b)\n raise \"x.rows!=y.rows\" if x.row_size!=y.row_size\n raise \"x.columns!=p.rows\" if x.column_size!=b.row_size \n n = x.row_size\n k = x.column_size\n fd = Array.new(k)\n k.times {|i| fd[i] = [0.0]}\n n.times do |i|\n xi = Matrix.rows([x.row(i).to_a])\n fbx=f(b,xi)\n value1 = (y[i,0]-fbx)/ ( fbx*(1-fbx))*ff(b,xi) \n k.times do |j|\n fd[j][0] += value1*xi[0,j]\n end\n end\n Matrix.rows(fd, true)\n end",
"def call(f)\n CAS::Help.assert(f, Hash)\n Math::sin(@x.call(f))\n end",
"def in_fahrenheit\n \t@f ? @f : @c * 9.0 / 5.0 + 32\n end",
"def nfa_to_dfa\n\n partition_edges\n minimize\n\n @start_state.generate_pdf(\"_SKIP_prefilter.pdf\") if @generate_pdf\n\n if @with_filter\n filter = Filter.new(@start_state)\n filter.verbose = @generate_pdf\n filter.apply\n if filter.modified\n # Re-minimize the dfa, since it's been modified by the filter\n minimize\n @start_state.generate_pdf(\"_SKIP_postfilter.pdf\") if @generate_pdf\n end\n end\n\n @start_state\n end",
"def tanh(input, name: nil)\n check_allowed_types(input, FLOATING_POINT_TYPES)\n _op(:tanh, input, nil, name: name)\n end",
"def *(float)\n\t\treturn FuzzyVariable.new(@value*float.to_f, @domain)\n\tend",
"def solved(ans)\n\n end",
"def reciprocal\n Fraccion.new(@d,@n)\n end",
"def findBestIn(x, n, h, step, loops)\n #set initial\n best = trainAndValidate(x, n, h, step)\n for i in 2..loops\n trained = trainAndValidate(x, n, h, step)\n if trained.ann < best.ann\n best = trained\n end\n end\n best\nend",
"def calculate\r\n strategy.data = conjugate(data)\r\n fft_out = strategy.calculate\r\n n = fft_out.length.to_f\r\n conjugate(fft_out){ |real, imag| OpenStruct.new(real: (real / n), imaginary: (imag / n) ) }\r\n end",
"def kalman_filter motion, measurements, motion_sig, measurement_sig, mu, sig \n\tmeasurements.each_with_index do | x, i |\n\t\tmu, sig = update(mu, sig, measurements[i], measurement_sig ) \n\t\tputss 'update: '+[mu, sig].inspect\n\t\tmu, sig = predict(mu, sig, motion[i], motion_sig ) \n\t\tputss 'predict: '+[mu, sig].inspect\n\tend\nend",
"def analyze\n return unless @cur_fft or @next_fft\n if !@cur_fft_count or @cur_fft_count > @tries\n @cur_fft = @next_fft\n @cur_fft_count = 0\n fft = @cur_fft.dup\n adjust! fft, @phase, @gain\n @cur_fft_best = detect_energies FFTW3::fft(fft)\n else\n @cur_fft_count += 1\n phaseIncrement = @iq_rate * rand_direction\n gainIncrement = @iq_rate * rand_direction\n fft = @cur_fft.dup\n adjust! fft, @phase + phaseIncrement, @gain + gainIncrement\n det = detect_energies FFTW3::fft(fft)\n if det > @cur_fft_best\n @cur_fft_best = det\n @gain += gainIncrement\n @phase += phaseIncrement\n end\n end\n end",
"def fit(x, _y = nil)\n return self unless @params[:use_idf]\n\n x = check_convert_sample_array(x)\n\n n_samples = x.shape[0]\n df = x.class.cast(x.gt(0.0).count(0))\n\n if @params[:smooth_idf]\n df += 1\n n_samples += 1\n end\n\n @idf = Numo::NMath.log(n_samples / df) + 1\n\n self\n end",
"def fee_analysis(fee_analysis_request, opts = {})\n data, _status_code, _headers = fee_analysis_with_http_info(fee_analysis_request, opts)\n data\n end",
"def decision_function(x)\n raise \"#{self.class.name}##{__method__} expects to be called after training the model with the fit method.\" unless trained?\n x = Rumale::Validation.check_convert_sample_array(x)\n xx = fit_bias? ? expand_feature(x) : x\n Numo::Liblinear.decision_function(xx, liblinear_params, @model)\n end",
"def f(a)\n return lsin(a) + calcpi() / 2\nend",
"def initialize(n, ang_moment)\n @n = n\n @ang_moment = ang_moment\n @basis_functions = []\n end",
"def runFrOneOrMoreFiles(filenames)\n\t\t# ---- Multiple curves in a single diagram from a single file\n\t\t# ---- or repeated across multiple files\n\t\tif @oc[\"MulFrSin\"]\n\t\t\tfilenames.each { |fn| runMulFrSin(fn) }\n\n\t\telse\n\t\t\t# ---- Multiple curves in a single diagram from different files\n\t\t\tif @oc[\"MulFrMul\"]\n\t\t\t\trunMulFrMul(filenames)\n\n\t\t\telse\n\t\t\t\tif @oc[\"MulFrSeq\"]\n\t\t\t\t\tfilenames.each { |fn| runMulFrSeq(fn) }\n\n\t\t\t\t# ---- Default: a separate curve for each file\n\t\t\t\telse\n\t\t\t\t\tfilenames.each { |fn| runSinFrSin(fn) }\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend",
"def to_f(pattern)\n get_numeric_value(pattern){ |value| value.to_f(pattern) }\n end",
"def fv(i, n, amt)\n return ((1 + i) ** n) * amt\n end",
"def calculate_fee(transaction, params = {})\n amount = transaction.base_amount\n\n if @interchange\n use_payment_source = params[:use_payment_source].to_s == 'true' #todo: better pattern here?\n if use_payment_source\n payment_source = transaction.payor.payment_source_for_type(@payment_service.payment_type)\n bin = payment_source&.get_data_field(:bin)\n else\n card = params[:card_number]\n bin = card ? card[0..5] : nil\n end\n\n if bin.present?\n data = estimate_fee(amount, bin)\n fee = data[:estimated_fee]\n else\n # returns a range when card prefix not provided\n fee_range(amount) # note, returns an array with low/high range when params are missing\n end\n else\n apply_rate(amount)\n end\n end",
"def test_evaluate2\r\n model = DNN::Models::Sequential.new\r\n model << DNN::Layers::InputLayer.new(3)\r\n model.setup(DNN::Optimizers::SGD.new, DNN::Losses::MeanSquaredError.new)\r\n x = Xumo::SFloat[[0, 0.5, 1], [0.5, 1, 0]]\r\n y = Xumo::SFloat[[0, 1, 0.5], [0, 1, 0.5]]\r\n evaluator = DNN::Evaluator.new(model)\r\n assert_equal 0.5, evaluator.evaluate(x, y).first\r\n end"
] |
[
"0.61476433",
"0.5915051",
"0.58816946",
"0.5364278",
"0.5209733",
"0.5180717",
"0.517215",
"0.51483524",
"0.50332147",
"0.5018713",
"0.49074113",
"0.4829197",
"0.47957715",
"0.47709677",
"0.46796986",
"0.4667795",
"0.46353972",
"0.46081483",
"0.45909443",
"0.45753038",
"0.4570953",
"0.45645887",
"0.45496312",
"0.4533812",
"0.45201695",
"0.45096314",
"0.4498172",
"0.4496716",
"0.44819704",
"0.44654804",
"0.44632953",
"0.44590765",
"0.44478816",
"0.4439072",
"0.44315472",
"0.44124943",
"0.44013363",
"0.43926543",
"0.4378107",
"0.43645906",
"0.43210337",
"0.4319217",
"0.43028483",
"0.42906058",
"0.4290312",
"0.42873403",
"0.42860043",
"0.42749268",
"0.42406628",
"0.4240047",
"0.42395166",
"0.41918513",
"0.4183241",
"0.4183241",
"0.4166397",
"0.415652",
"0.41548645",
"0.4151506",
"0.4150437",
"0.4130622",
"0.4129236",
"0.41259536",
"0.40942088",
"0.4088988",
"0.408267",
"0.40678394",
"0.40662402",
"0.4061946",
"0.40522647",
"0.4044766",
"0.4041511",
"0.40291822",
"0.40286997",
"0.40283996",
"0.40256283",
"0.40182245",
"0.40083304",
"0.40077254",
"0.40025586",
"0.40019524",
"0.39978883",
"0.39972892",
"0.39913929",
"0.39893988",
"0.39884648",
"0.3988342",
"0.3988096",
"0.3987122",
"0.39853236",
"0.39727795",
"0.39703855",
"0.39647308",
"0.39632037",
"0.39623567",
"0.39517796",
"0.39490727",
"0.39469004",
"0.39463073",
"0.3938536",
"0.3934363"
] |
0.66603
|
0
|
Saves the fann config to a file
|
def save
fann.save("#{Rails.root}/data/#{self.class.to_s.tableize.singularize}.conf")
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def save()\n File.open(CONFIG_FILE, 'w'){ |f| f.write config.to_yaml } # Store\n end",
"def save\n File.open(file_name, 'w') { |f| f.write config.to_yaml }\n end",
"def save_configuration\n File.open(config_file, \"w\") do |file|\n file.write(YAML.dump(@config))\n end\n end",
"def save\n open @config_path, 'w' do |io|\n io.write({'files' => @files.collect(&:to_hash)}.to_yaml)\n end\n end",
"def write_config\n File.open(@config_file, \"w\"){|f| YAML.dump(config, f)}\n end",
"def save(file = nil)\n @file = file if file\n raise Error.new(Error::FileError) unless @file\n File.open(@file, 'w') do |f|\n f.puts(@prefix) if @prefix\n YAML.dump(@cfg, f)\n f.puts ''\n f.puts(@suffix) if @suffix\n end\n end",
"def save(fn)\n begin\n File.open(fn,\"w\") do |file|\n output = \"\"\n self.each do |key, value|\n output << key.to_s + \"=\" + value.to_s + \"\\r\\n\"\n end\n\n file.print output\n file.close\n end\n rescue\n raise \"Error: trouble saving configuration file: #{fn}.\\nDetails: #{$!}\"\n end\n end",
"def save\n unless File.exist?(config_dir)\n FileUtils.mkdir_p(config_dir, :mode => 0700)\n end\n\n tmpfile = File.join(config_dir, \"tmpconfig_#{rand 999999}\")\n File.open(tmpfile, \"w\") do |f|\n YAML.dump(conf, f )\n end\n\n FileUtils.mv(tmpfile, config_file)\n end",
"def config_write\n # Putting it in a format that zfm can also read and write\n f1 = File.expand_path(CONFIG_FILE)\n hash = {}\n hash['DIRS'] = @used_dirs.select { |dir| File.exist? dir }\n hash['FILES'] = @visited_files.select { |file| File.exist? file }\n # NOTE bookmarks is a hash and contains FILE:cursor_pos\n hash['BOOKMARKS'] = @bookmarks # .select {|file| File.exist? file}\n writeYML hash, f1\n @writing = @modified = false\n message \"Saved #{f1}\"\nend",
"def save\n if !Dir.exists? @config_directory\n FileUtils.mkdir_p @config_directory\n end\n\n open(@file, 'w').write @main.to_yaml\n end",
"def save_settings\n File.open(@path, \"w\") do |file|\n file.write @settings.to_yaml\n end\n end",
"def save( file = @hobix_yaml )\n unless file\n raise ArgumentError, \"Missing argument: path to save configuration (0 of 1)\"\n end\n File::open( file, 'w' ) do |f|\n YAML::dump( self, f )\n end\n self\n end",
"def saveConfig(configFile, config)\n #For Shoes compatability change to a known directory\n Dir.chdir(ENV['HOME'])\n #Test if exists\n if !(File.exist?(\".photoflow\"))\n FileUtils.mkdir_p (\".photoflow\")\n end\n open(configFile, 'w') {|f| YAML.dump(config, f)}\nend",
"def write\n require 'yaml'\n open config_file_name, 'w' do |io|\n io.write to_yaml\n end\n end",
"def save_file\r\n @saved = true\r\n saving\r\n Dir.mkdir(\"saves\") unless Dir.exists? \"saves\"\r\n File.open(\"my_save.yaml\", \"w\") {|f| f.puts YAML::dump(self) }\r\n end",
"def sauvegarder()\n begin\n File.open(CONSTANT_FICHIER_DATA_CONFIG, \"w\") do |f|\n \tf.puts Marshal.dump(self)\n end\n rescue Errno::ENOENT\n puts \"ERREUR: Configuration: sauvegarder(): le fichier #{CONSTANT_FICHIER_DATA_CONFIG} n'est pas accessible.\"\n end\n end",
"def save_config\n config = $bot[:config].clone\n config.delete :client\n File.open \"./#{Twittbot::CONFIG_FILE_NAME}\", 'w' do |f|\n f.write config.to_yaml\n end\n end",
"def to_config_file lanes = [1,2,3,4,5,6,7,8]\n view = ConfigFileView.new(self, lanes)\n view.write\n end",
"def saveFile(saveTag)\n aFile = File.new(\"config.version\", \"w+\")\n if aFile\n aFile.syswrite(\"version=#{saveTag}\")\n aFile.close\n else\n puts \"Unable to write a config.version file!\"\n end\n end",
"def store\n File.open(@config_file, 'w') do |f|\n f.chmod(0600)\n f.write(@config.to_json)\n end\n end",
"def save_settings\n open(@@FN_CREDENTIALS, \"wb\") { |fd| fd.write(YAML::dump(@credentials)) }\n open(@@FN_CONFIG, \"wb\") { |fd| fd.write(YAML::dump(@configuration)) }\n open(@@FN_SETTINGS, \"wb\") { |fd| fd.write(YAML::dump(@settings)) }\n end",
"def save_config\n plist = CFPropertyList::List.new\n plist.value = CFPropertyList.guess(@config)\n plist.save(@file, CFPropertyList::List::FORMAT_XML)\n end",
"def save_settings\n File.open( @settings_filename, 'w' ) do |out|\n YAML.dump( @app_settings, out )\n end\n @log.debug \"Settings saved into #{@settings_filename}\"\n end",
"def write_configure(config = nil)\n config ||= $configure\n File.open($configure_file, \"w\"){|f| YAML.dump(config, f)}\nend",
"def config_write\n return\n # Putting it in a format that zfm can also read and write\n #f1 = File.expand_path(\"~/.zfminfo\")\n f1 = File.expand_path(CONFIG_FILE)\n d = $used_dirs.join \":\"\n f = $visited_files.join \":\"\n File.open(f1, 'w+') do |f2| \n # use \"\\n\" for two lines of text \n f2.puts \"DIRS=\\\"#{d}\\\"\"\n f2.puts \"FILES=\\\"#{f}\\\"\"\n $bookmarks.each_pair { |k, val| \n f2.puts \"BM_#{k}=\\\"#{val}\\\"\"\n #f2.puts \"BOOKMARKS[\\\"#{k}\\\"]=\\\"#{val}\\\"\"\n }\n end\n $writing = $modified = false\nend",
"def save(name = @name)\n raise OneCfg::Config::Exception::NoContent if @content.nil?\n\n file_operation(name, 'w') {|file| file.write(to_s) }\n end",
"def save_to(path)\n File.write(path, to_fdf)\n end",
"def write_config_file(doc)\n if @pretend\n info \"In pretend mode, so not writing to #{@config_file}\"\n debug { \"I would have written: \\n#{doc}\" }\n @pretend_output = doc\n else\n File.open(@config_file, 'w') {|f| f.write(doc)}\n end\n end",
"def save_settings settings\n File.open(@settings_file, 'w') {|file| file << YAML::dump(settings)}\n end",
"def save_configuration\n create_config_dir_if_needed\n\n if configuration_writable?\n File.write(configuration_path, configuration_data.deep_stringify_keys!.to_yaml)\n configuration_data = read_configuration\n else\n throw StandardError.new \"Configuration cannot be saved at '#{configuration_path}'\"\n end\n end",
"def save\n File.open(SETTING_FILE, 'w') do |file|\n file.write @values.to_yaml\n end\n end",
"def save(discovery)\n return unless @file_path && discovery\n File.open(@file_path, 'wb') do |file|\n Marshal.dump(discovery, file)\n end\n end",
"def write_config\n info(\"writing config.yml\")\n AIPP.config.write! config_file\n end",
"def save_configuration\n if File.exist? determine_config_path\n bytes_required = File.size(determine_config_path)\n # Overwrite the current .config file with random bytes to eliminate\n # unencrypted credentials.\n # This won't account for COW filesystems or SSD wear-levelling but\n # is a best effort protection.\n random_bytes = SecureRandom.random_bytes(bytes_required)\n File.write(determine_config_path, random_bytes)\n else\n FileUtils.mkdir_p(Pathname.new(determine_config_path).dirname)\n end\n configuration.save\n end",
"def save\n File.open(file_path, 'w') do |file|\n YAML.dump(data, file)\n end\n end",
"def write_config()\nafile = File.open(\"cp3nodes.conf\", \"w\")\nafile.puts \"1 127.0.0.1 25500 25501 25502\\n\"\nafile.puts \"2 127.0.0.1 25503 25504 25505\\n\"\nafile.puts \"3 127.0.0.1 25506 25507 25508\\n\"\nafile.close\nend",
"def save\n File.open(@base_file, \"w\") do |f|\n f.puts(JSON.pretty_generate(@config))\n end\n File.open(@completions_file, \"w\") do |f|\n f.puts(JSON.pretty_generate(@completions.to_a))\n end\n end",
"def config_write\n # Putting it in a format that zfm can also read and write\n f1 = File.expand_path(\"~/.cygnusinfo\")\n #f1 = File.expand_path(CONFIG_FILE)\n d = $used_dirs.join \":\"\n f = $visited_files.join \":\"\n File.open(f1, 'w+') do |f2| \n # use \"\\n\" for two lines of text \n f2.puts \"DIRS=\\\"#{d}\\\"\"\n f2.puts \"FILES=\\\"#{f}\\\"\"\n $bookmarks.each_pair { |k, val| \n f2.puts \"BM_#{k}=\\\"#{val}\\\"\"\n #f2.puts \"BOOKMARKS[\\\"#{k}\\\"]=\\\"#{val}\\\"\"\n }\n end\n $writing = $modified = false\nend",
"def save\n file = File.new(@file,\"w+\")\n @properties.each {|key,value| file.puts \"#{key}=#{value}\\n\" }\n file.close\n end",
"def save_settings!\n File.open(settings_path, \"w\") { |f| f << settings.to_nested_hash.to_yaml }\n settings.create_accessors!\n end",
"def save_token(token)\n File.write(config_file, token)\n end",
"def save\n file = File.new(@file, 'w+')\n @properties.each { |key, value| file.puts \"#{key}=#{value}\\n\" }\n end",
"def save\n ::File.open(@file, \"w\") { |file| file << self.to_hash.to_yaml }\n end",
"def save!(file_path)\n File.open(file_path, \"w\") do |f|\n f.write(YAML.dump(@log))\n end\n end",
"def save_config\n botpart_config = Hash[@config.to_a - $bot[:config].to_a]\n\n unless botpart_config.empty?\n File.open @botpart_config_path, 'w' do |f|\n f.write botpart_config.to_yaml\n end\n end\n end",
"def config_write\n # Putting it in a format that zfm can also read and write\n #f1 = File.expand_path(\"~/.zfminfo\")\n f1 = File.expand_path(CONFIG_FILE)\n d = $used_dirs.join \":\"\n f = $visited_files.join \":\"\n File.open(f1, 'w+') do |f2| \n # use \"\\n\" for two lines of text \n f2.puts \"DIRS=\\\"#{d}\\\"\"\n f2.puts \"FILES=\\\"#{f}\\\"\"\n $bookmarks.each_pair { |k, val| \n f2.puts \"BM_#{k}=\\\"#{val}\\\"\"\n #f2.puts \"BOOKMARKS[\\\"#{k}\\\"]=\\\"#{val}\\\"\"\n }\n end\n $writing = $modified = false\nend",
"def cmd_notify_save\n\t\t\t\tprint_status(\"Saving paramters to config file\")\n\t\t\t\tif @user_name and @webhook_url\n\t\t\t\t\tconfig = {'user_name' => @user_name, 'webhook_url' => @webhook_url}\n\t\t\t\t\tFile.open(Notify_yaml, 'w') do |out|\n\t\t\t\t\t\tYAML.dump(config, out)\n\t\t\t\t\tend\n\t\t\t\t\tprint_good(\"All parameters saved to #{Notify_yaml}\")\n\t\t\t\telse\n\t\t\t\t\tprint_error(\"You have not provided all the parameters!\")\n\t\t\t\tend\n\t\t\tend",
"def cmd_notify_save\n\t\t\t\tprint_status(\"Saving options to config file\")\n\t\t\t\tif @user_name and @webhook_url and $source\n\t\t\t\t\tconfig = {'user_name' => @user_name, 'webhook_url' => @webhook_url, 'source' => $source}\n\t\t\t\t\tFile.open(Notify_yaml, 'w') do |out|\n\t\t\t\t\t\tYAML.dump(config, out)\n\t\t\t\t\tend\n\t\t\t\t\tprint_good(\"All settings saved to #{Notify_yaml}\")\n\t\t\t\telse\n\t\t\t\t\tprint_error(\"You have not provided all the parameters!\")\n\t\t\t\tend\n\t\t\tend",
"def write_config\n # Allow disabling the local settings.\n return unless new_resource.local_settings_path\n file new_resource.local_settings_path do\n content new_resource.local_settings_content\n mode '640'\n owner new_resource.parent.owner\n group new_resource.parent.group\n end\n end",
"def save!\n filepath.dirname.mkpath\n filepath.open( \"w\" ) do |f|\n f << YAML.dump( @entries )\n end\n clear_modified\n true\n end",
"def save\n File.open(\"#{@config_dir}/#{REPOSITORY_FILE}\", 'w') { |f| @repository_xml.write(f, 2) }\n end",
"def save\n # Nothing in base class. This should be used to persist settings in\n # subclasses that use files.\n end",
"def save\n File.write(yfile, to_yaml)\n end",
"def save_settings(filename, settings)\n require 'yaml'\n\n File.open(filename, 'w') do |file|\n file.write(settings.to_yaml)\n Log.instance.info(\"Settings written to [ #{filename} ]\")\n end\n end",
"def save( file )\n begin\n File.open( file, 'w' ) { |f| f.write( YAML.dump( self ) ) }\n rescue\n File.open( file, 'wb' ) { |f| f.write( Marshal.dump( self ) ) }\n end\n end",
"def save_config_signature\n Origen.app.session.origen_sim[\"#{id}_config\"] = config\n end",
"def save fname, options={}\n File.open(fname,\"wb\"){ |f| f << export(options) }\n end",
"def save\n File.open(path, 'w') do |out|\n YAML.dump(data, out)\n end\n end",
"def save\n File.open(file, 'w') do |f|\n self.attributes.each {|key, value| f.write \"#{key}: '#{value}'\\n\" }\n end\n end",
"def persist\n settings = {\n area: @focus[:key]\n }\n File.open(@path, 'w') do |file|\n file.write settings.to_yaml\n end\n end",
"def save filename\n File.open(filename, 'w') { |file| @properties.each {|key,value| file.write(\"#{key}:#{value},\\n\") } } \n end",
"def save\r\n SystemConfig.set name, to_h(false), true\r\n end",
"def generateConfigurationToFile(configuration,filePath)\n conf=generateConfigData(configuration)\n file=File.new(filePath,\"w\")\n file.write(conf)\n file.close\n end",
"def save\n File.open(file, \"w\") {|f| f.write(to_hash.to_yaml) }\n end",
"def save\n File.open(\"#{@config_dir}/#{REPOSITORY_FILE}\", 'w') { |f| @repository_xml.write_xml_to(f) }\n end",
"def save_config\n self.data = JSON.dump(self.config)\n end",
"def save_config\n self.data = JSON.dump(self.config)\n end",
"def save_configuration(path = nil)\n # If no path provided, see if we can find one in the dir tree.\n if path.nil?\n path = find_config_path\n end\n\n # Still no path? Use the current working dir.\n if path.nil?\n path = Pathname.pwd\n end\n\n unless path.to_s.end_with?('/' + config_filename)\n path = Pathname(path) + config_filename\n end\n\n path = Pathname(path).expand_path\n File.write(path, YAML.dump(configuration))\n $stdout << \"configuration saved to #{path}\\n\" if $debug\n\n path\n end",
"def save_config(scope = :user)\n case scope\n when :global\n if RUBY_PLATFORM.downcase =~ /mswin(?!ce)|mingw|bccwin/\n path = ENV['ALLUSERSPROFILE']\n else\n path = '/etc'\n end\n when :local\n path = File.expand_path '.'\n when :user\n path = File.expand_path '~'\n else\n path = scope\n end\n\n @config_factory.save_config @config,\n File.join(path, @settings[:config_file])\n end",
"def save_opf!\n file.write(opf_path, opf_xml.to_s)\n\n opf_xml\n end",
"def create_config_file(config_file)\n File.open(Rails.root.join('tmp', 'config'), 'wb') do |file|\n file.write(config_file)\n end\n end",
"def output_config_for_locale(locale)\n save_config_file(locale, \"config\")\n save_config_file(locale, \"faq\")\n save_config_file(locale, \"form\")\nend",
"def save # :nodoc:\n if @file\n File.open(SAVE_FILE, 'w') do |f|\n Marshal.dump(file, f)\n end\n else\n forget\n end\n end",
"def save # :nodoc:\n if @file\n File.open(SAVE_FILE, 'w') do |f|\n Marshal.dump(file, f)\n end\n else\n forget\n end\n end",
"def create_config_file\n f = File.open(\"#{repo_dir}/.ram_config\", \"w+\")\n f.write \"url: #{@url}\"\n f.close\n end",
"def save\n file = File.new(@file,\"w+\")\n @properties.each {|key,value| file.puts \"#{key}=#{value}\\n\" }\nend",
"def write()\n open(CurrentFilename, 'w'){|fp|\n Marshal.dump(@current_setting, fp)\n }\n end",
"def save_config_file(locale, key)\n locale_config = {}\n locale_config[locale] = {}\n unless @config[key].nil?\n locale_config[locale][key] = @config[key]\n path = \"config/locales/org/#{key}/#{locale}.yml\"\n File.delete(path) if File.exist?(path)\n TTY::File.create_file(path, locale_config.to_yaml)\n end\nend",
"def save\n File.open(file, \"w\") {|f| f.write(to_hash.to_yaml) }\n end",
"def flush filename = Filename\r\n #puts self.to_s\r\n File.open(filename,\"w\"){|file|\r\n file.print self.to_s\r\n }\r\n rescue\r\n @logger.fatal \"Cannot save settings to file '#{filename}'\"\r\n raise\r\n end",
"def save\n return unless dirty? && config.respond_to?(:write)\n\n config.write\n clean_up\n end",
"def write_config\n File.open(CONFIG_OUT, 'w') do |f|\n f.write(ssh_config + \"\\n\")\n end\nend",
"def save_cache!(config_file = File.expand_path(Assh::CONFIG_CACHE),\n timestamp_file = File.expand_path(Assh::CONFIG_CACHE_AT))\n cache = {\n hosts: @hosts,\n groups: @groups\n }\n File.open(config_file, 'w') { |f| f << cache.to_yaml }\n File.open(timestamp_file, 'w') { |f| f << current_time }\n\n end",
"def save\n @filename = @filename || gen_filename\n file = File.open(File.join(@dir, @filename), 'w') { |f|\n f.puts @issue.to_yaml\n }\n end",
"def save_configuration_files(server)\n puts \"Saving config files\"\n object_behavior(server, :spot_check_command, 'mkdir -p /root/start_stop_backup')\n object_behavior(server, :spot_check_command, 'cp /etc/postfix/main.cf /root/start_stop_backup/.')\n object_behavior(server, :spot_check_command, 'cp /etc/syslog-ng/syslog-ng.conf /root/start_stop_backup/.')\n end",
"def save\n File.open(@file, 'w') do |file|\n file.write(Psych.dump(@params))\n end\n @saved = true\n end",
"def write_config(file, text)\n File.open(file, 'w') do |file|\n file.puts text\n file.close\n end\n end",
"def save_to(path); end",
"def save\n if self.valid?\n # encrypt_password\n file = File.new(FILE_PATH, \"w+\")\n YAML::dump(self.attributes, file)\n file.close\n end\n end",
"def save\n # Get the currently set path\n \tconfig_file = File.expand_path('../../config/bookhero.conf',File.dirname(__FILE__))\n settings = YAML::load(File.open(config_file))\n \t@configured_library_path = settings['library_path']\n \t@configured_google_api_key = settings['google_api_key']\n\n \n # Get data from form\n library_path = params[:library_path]\n if library_path.blank?\n library_path = @configured_library_path\n end\n\n google_api_key = params[:google_api_key]\n # if google_api_key.blank?\n # google_api_key = @configured_google_api_key \n # end\n\n # Write the data to yaml config file.\n \tdata = {\"library_path\" => \"#{library_path}\",\n \"google_api_key\" => \"#{google_api_key}\"}\n \tFile.open(File.expand_path('../../config/bookhero.conf',File.dirname(__FILE__)),\"w\") {|f| f.write(data.to_yaml)}\n\n # Read settings again\n redirect_to :action => \"settings\"\n\n end",
"def save\n File.open(yaml_file, 'w') {|f| f.write(to_yaml) }\n end",
"def save\n return if !self.valid?\n\n File.open(@file, \"w\") do |f|\n NWN::Gff.write(f, :gff, @obj)\n end\n end",
"def save_to_file(path)\n variables_to_save = instance_variables.reject { |v| v =~ /_proc$/ || v =~ /^@med/ }\n File.open(path, 'w') { |f| f.puts(\n variables_to_save.inject({}) { |h,n| h[n] = instance_variable_get(n); h }.to_yaml\n ) }\n end",
"def save(dir = \".\")\n File.open(File.join(dir, \"#{name}.yaml\"), 'w') do |f|\n f.print YAML.dump(self)\n end\n end",
"def save!\n File.open(connections_file, 'w') {|f| f.write(@connections.to_yaml) }\n end",
"def save\n File.write @path, @index.to_yaml, encoding: \"UTF-8\"\n end",
"def create_save\n @save_data = {:turns => @turns,:guesses => @guesses,:secret_word => @secret_word, :hidden_word => @hidden_word}\n save = File.new(\"./lib/save.txt\", \"w+\")\n save.puts JSON::dump(save_data)\n save.close\n end",
"def save_config_signature\n Origen.app.session.origen_sim[\"#{id}_config\"] = config.except(*NON_DATA_CONFIG_ATTRIBUTES)\n end",
"def save file='GOL.sav'\n File.open(file,'w') do |f|\n Marshal.dump(state,f)\n end\n end",
"def save(overwrite=true)\n write_file(overwrite, @filename)\n end"
] |
[
"0.7859885",
"0.7826591",
"0.7706767",
"0.7404447",
"0.74038047",
"0.7197372",
"0.71766025",
"0.7032632",
"0.69455636",
"0.6920137",
"0.6918178",
"0.6889352",
"0.6831635",
"0.6809291",
"0.6793825",
"0.6720782",
"0.67181635",
"0.6687445",
"0.6678079",
"0.66646945",
"0.6653411",
"0.6616426",
"0.65994674",
"0.65410155",
"0.6504255",
"0.6503454",
"0.6478539",
"0.6450278",
"0.6446622",
"0.6410501",
"0.6403847",
"0.63904285",
"0.6382163",
"0.6364802",
"0.6342296",
"0.6322185",
"0.6318664",
"0.63139975",
"0.6311593",
"0.63012904",
"0.62976956",
"0.62972844",
"0.62944555",
"0.6287513",
"0.62734264",
"0.6268282",
"0.6260386",
"0.6256087",
"0.62474865",
"0.6237746",
"0.61934614",
"0.6181715",
"0.6170176",
"0.6165114",
"0.6163572",
"0.6160848",
"0.61451006",
"0.61429834",
"0.61377513",
"0.6134953",
"0.6125461",
"0.61213005",
"0.6114293",
"0.6112555",
"0.61114734",
"0.61087614",
"0.61087614",
"0.6105988",
"0.6103898",
"0.6099809",
"0.6091942",
"0.60866696",
"0.60851294",
"0.60851294",
"0.6083761",
"0.6071697",
"0.6060255",
"0.5995842",
"0.5985628",
"0.5985328",
"0.59683704",
"0.59663975",
"0.5966347",
"0.59596",
"0.59540117",
"0.59533405",
"0.59506977",
"0.59502965",
"0.59420675",
"0.5939248",
"0.5931362",
"0.5915535",
"0.59102374",
"0.5900514",
"0.58967817",
"0.5892471",
"0.5884054",
"0.5879693",
"0.587934",
"0.587865"
] |
0.70767057
|
7
|
Creates a train data object
|
def train_data
::RubyFann::TrainData.new(
:inputs => inputs,
:desired_outputs=> desired_outputs)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def create_train(train_type)\n Train.new(\n @train_types.find do |type|\n type.to_s.eql? \"#{train_type.fetch('type')}T\"\n end\n )\n end",
"def get_data\n\t\tdata_hash = {path: @data_file_path, training: @training_file_name, testing: @testing_file_name}\n\t\tDataLoader.new(data_hash)\n\tend",
"def set_train(train)\r\n @train = train\r\n end",
"def create_train(title = '[CREATE] Please choose Train type:')\n train_type = ask_choose_train_type(title)\n\n user_input_number = ask_enter('Train number')\n\n train = train_type.new(user_input_number)\n @trains << train\n puts \"\\n[SUCCESS] #{train} created!\"\n rescue StandardError => e\n show_error_message(e)\n retry\n end",
"def initialize (folder, u=nil)\n\t\t@train_data = Hash.new\n\t\t@test_data = Hash.new\n\t\tif u == nil \n\t\t\t@train_file = File.open(folder + \"/u.data\")\n\t\telse \n\t\t\t@train_file = File.open(folder+\"/\"+u+\".base\")\n\t\t\t@test_file = File.open(folder+\"/\"+u+\".test\")\n\t\tend\n\n\t\tload_data(@train_file, @train_data)\n\tend",
"def make_training_set training_set_size\n sample = $ou.to_a.sample(training_set_size).shuffle\n data_to_csv 'train.csv', sample\nend",
"def train\n raise NotImplementedError\n end",
"def train(dataset)\n raise 'Override me!'\n end",
"def train_set\n data_input = data_output = @data_input\n data_input.delete_at(data_input.index(data_input.last))\n data_output.delete_at(data_output.index(data_output.first))\n RubyFann::TrainData.new(inputs: data_input,\n desired_outputs: data_output)\n end",
"def train\n run_aggregation\n run_syntetics\n run_values_to_ranges\n run_reverse\n\n [name, classifier]\n end",
"def initialize\n\t\t@training_list=Array.new\n\t\t@w = Array.new(FEATURE_SIZE,0)\n\tend",
"def newRegressor\r\n\t\t@trained\t\t= false\r\n\t\t@lr \t\t\t= RubyLinearRegression.new\r\n\t\tputs trainingData.getDataStructure(useHash).first\r\n\t\t@lr.load_training_data trainingData.getDataStructure(useHash), trainingDataAsArray\r\n\tend",
"def train\n classifiers_initializer = ClassifiersInitializer.load_or_create\n classifiers_initializer.run\n @classifiers = classifiers_initializer.classifiers.map do |name, classifier|\n Classifier.new(classifier, self.class.config, name).train\n end.to_h\n end",
"def prepare\r\n\t\t@machine \t||= @machineClass.new @trainTestStruct.trainingData, @target, @parameters\r\n\t\t@machine.train\r\n\tend",
"def add_train(train)\n trains << train\n end",
"def train(combos, rewards)\n RubyFann::TrainData.new(\n inputs: combos,\n desired_outputs: rewards\n )\n end",
"def initialize(params = {})\n if params[:training_file_name]\n @attributes = []\n @attribute_types = {}\n default_value = \"\"\n training_data = [] # each data instance represented by an array with attribute values and class value last\n \n File.open(\"#{Training_Data_Folder}/#{params[:training_file_name]}\") do |f|\n header_array = f.gets.chomp.split(',')\n header_array.each do |attribute_with_type|\n attribute_type_pair = attribute_with_type.split(':')\n @attributes << attribute_type_pair.first\n @attribute_types[attribute_type_pair.first.to_sym] = attribute_type_pair.last.to_sym\n end\n \n default_value = f.gets.chomp\n \n f.each_line do |line|\n training_data << extract_data_instance(line)\n end\n end\n \n @tree = DecisionTree::ID3Tree.new(@attributes, training_data, default_value, @attribute_types)\n elsif params[:config_file_name]\n @tree = DecisionTree::ID3Tree.load_from_file(\"#{Config_Folder}/#{params[:config_file_name]}\")\n else\n puts \"Unrecognized parameters\"\n end\n end",
"def set_training\n @training = student.trainings.build\n end",
"def create data_object_class, opts={}\n data_object = make data_object_class, opts\n data_object.create\n data_object\n end",
"def train\n training = @prediction.trainedmodels.insert.request_schema.new\n training.id = 'emotion_prediction_id'\n training.storage_data_location = DATA_OBJECT\n result = @client.execute(\n :api_method => @prediction.trainedmodels.insert,\n :headers => {'Content-Type' => 'application/json'},\n :body_object => training\n )\n\n assemble_json_body(result)\n end",
"def initialize(dataset)\n @dataset = dataset\n end",
"def train_for(user)\n dataset = Predictors::StopRequestDataset.for(user)\n train(dataset)\n end",
"def initialize(data, start, constant_pool)\r\n creator = AttributesCreator.new(data, start, constant_pool)\r\n creator.create!\r\n @attributes = creator.attributes\r\n @size = creator.size\r\n end",
"def train\n puts '>>> 1'\n train = RubyFann::TrainData.new(filename: './train.data')\n\n puts '>>> 2'\n @fann = RubyFann::Standard.new(num_inputs: @number_of_inputs, hidden_neurons: [@number_of_inputs/20, @number_of_inputs/40], num_outputs: @number_of_outputs)\n\n puts '>>> 3'\n @fann.train_on_data(train, 1000, 10, 0.1) # 1000 max_epochs, 10 errors between reports and 0.1 desired MSE (mean-squared-error)\n @fann.save('./headlines.net')\n\n puts '>>> 4'\n test\n end",
"def set_train_datum\n @train_datum = TrainDatum.find(params[:id])\n end",
"def train\r\n return @train\r\n end",
"def set_train\n @train = Train.find(params[:id])\n end",
"def create\n @train = Train.new(train_params)\n\n respond_to do |format|\n if @train.save\n format.html { redirect_to @train, notice: 'Train was successfully created.' }\n format.json { render action: 'show', status: :created, location: @train }\n else\n format.html { render action: 'new' }\n format.json { render json: @train.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create(data={})\n object = self.new(data)\n object.save\n end",
"def create\n @train_datum = TrainDatum.new(train_datum_params)\n\n respond_to do |format|\n if @train_datum.save\n format.html { redirect_to @train_datum, notice: 'Train datum was successfully created.' }\n format.json { render :show, status: :created, location: @train_datum }\n else\n format.html { render :new }\n format.json { render json: @train_datum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def load_data\n\t\tFile.open(\"#{@path_to_training}\", \"r\").each_line do |line|\n\t\t\ta = line.split\n\t\t\tadd_movie(a[1].to_i, a[0].to_i, a[2].to_i)\n\t\t\tadd_user(a[0].to_i, a[1].to_i, a[2].to_i)\n\t\tend\n\t\tif File.file?(\"#{@path_to_test}\") then\n\t\t\tFile.open(\"#{@path_to_test}\", \"r\").each_line do |line|\n\t\t\t\ta = line.split\n\t\t\t\t@list_of_test_set << Rating.new(a[0].to_i, a[1].to_i, a[2].to_i)\n\t\t\tend\n\t\tend\n\tend",
"def new\n @prediction = Prediction.new\n end",
"def add_train(train)\n @trains << train\n end",
"def initialize (start_num, train_direction, line, speed = 1)\r\n @start_num = start_num #station start number integer\r\n @start_point = line.stations[@start_num].station_name #start station name string\r\n @train_direction = train_direction #direction string\r\n @station_arr = line.stations_names #list of line names array of string\r\n @distances = line.distances #list of distances of line array of integer\r\n @station_index = @start_num #current station index integer\r\n @line_name = line.line_name #line name string\r\n @timetable = {} #timetable for this train hash of array of interger\r\n @speed = speed\r\n \r\n @@all_trains.push(self) #array of train objects array of obj\r\n\r\n #if first station - change direction\r\n if(@station_index == 0)\r\n case line.direction #check line direction\r\n when 'NS'\r\n @train_direction = 'S'\r\n when 'EW'\r\n @train_direction = 'E'\r\n end\r\n end\r\n \r\n #if last station - change direction\r\n if(@station_index == (@station_arr.length - 1))\r\n case line.direction #check line direction\r\n when 'NS'\r\n @train_direction = 'N'\r\n when 'EW'\r\n @train_direction = 'W'\r\n end\r\n end\r\n \r\n # print \"Train created - #{@start_point} - #{@train_direction}\\n\"\r\n end",
"def load_training_data\n File.open(@training_file) {|file|\n @training_set = Nimbus::TrainingSet.new({}, {})\n file.each do |line|\n next if line.strip == ''\n data_feno, data_id, *snp_list = line.strip.split\n raise Nimbus::InputFileError, \"Individual ##{data_id} from training set has no value for all #{@tree_SNP_total_count} SNPs\" unless snp_list.size == @tree_SNP_total_count\n raise Nimbus::InputFileError, \"There are individuals with no ID, please check data in training file.\" unless (!data_id.nil? && data_id.strip != '')\n raise Nimbus::InputFileError, \"Individual ##{data_id} has no fenotype value, please check data in training file.\" unless (!data_feno.nil? && data_feno.strip != '')\n raise Nimbus::InputFileError, \"Individual ##{data_id} has invalid class (not in [#{classes*', '}]), please check data in training file.\" unless (@classes.nil? || @classes.include?(data_feno))\n\n data_feno = (@classes ? data_feno.to_s : data_feno.to_f)\n @training_set.individuals[data_id.to_i] = Nimbus::Individual.new(data_id.to_i, data_feno, snp_list.map{|snp| snp.to_i})\n @training_set.ids_fenotypes[data_id.to_i] = data_feno\n end\n }\n end",
"def create(data = {})\n object = self.new(data)\n object.save\n object\n end",
"def initialize dataset\n @clustered_dataset = Hash.new\n @array_of_k_means = Array.new\n @working_dataset = dataset\n prepare_dataset\n end",
"def initialize(training_data, testing_data)\n @training_data = training_data\n @testing_data = testing_data\n @range_file = File.join 'out', 'analysis',\n \"#{File.basename training_data}.range\"\n end",
"def initialize\n \tself.seed_data\n end",
"def initialize_trains\r\n @trains = Array.new\r\n\r\n @lines.each {|line, stations|\r\n @trains.push(Train.new(line))\r\n }\r\n \r\n return @trains\r\n end",
"def initialize(data_set)\n\t\t@user_info = Hash.new() # user to array of movies they have seen and what they rated them\n\t\t@movie_viewers = Hash.new() # user to array of movies they have seen\n\t\t@movie_ratings = Hash.new() # movies to an array of their ratings\n\t\t@test_set = [] # this holds all relevant information in .test files\n\t\t@predictions = []\n\t\tload_data(data_set)\n\tend",
"def create_data\n @entities_total.times do |i|\n @data << entity_class.new(i, self)\n end\n end",
"def train_perceptron()\n @model = Perceptron.new()\n @model.train(@training_set)\n end",
"def index\n @train_data = TrainDatum.all\n end",
"def initialize_attributes\n @training_model = Hash.new { |h, k| h[k] = Hash.new(0) }\n @classes = Set.new\n @total_words_counter = 0\n @negative_population = 0\n @neutral_population = 0\n @positive_population = 0\n @training_negatives = 0\n @training_neutrals = 0\n @training_positives = 0\n end",
"def doTraining\n\t\t# Ruby fan uses its own special data structure. 2D Array for both X and Y data\n\t\ttrain\t\t= RubyFann::TrainData.new(inputs: @xData[:train], desired_outputs: @yData[:train])\n\t\t# Train\n\t\tmachine\t= RubyFann::Standard.new(num_inputs: @nInputs, hidden_neurons:[2], num_outputs: 1)\n\t\tmachine.train_on_data(train, @iterations, @reportSteps, @maxError) \n\t\t# Remember to send the machine back to the caller\n\t\tmachine\n\tend",
"def create\n @trainmodel = Trainmodel.new(trainmodel_params)\n\n respond_to do |format|\n if @trainmodel.save\n format.html { redirect_to @trainmodel, notice: 'Trainmodel was successfully created.' }\n format.json { render :show, status: :created, location: @trainmodel }\n else\n format.html { render :new }\n format.json { render json: @trainmodel.errors, status: :unprocessable_entity }\n end\n end\n end",
"def test\n rows = Util.get_rows(:file => 'data/vehicles.csv', :n => 3000, :pre_process => true)\n classes = rows.transpose.last\n rows = rows.transpose[0..-2].transpose\n train(rows.first(2000), classes.first(2000))\n \"#{classes.last} classified as #{classify(rows.last)}\"\n end",
"def load_data\n\t\tload_using_arr(train_file,train_hash,0,1)\n\t\tload_using_arr(train_file,movie_hash,1,0)\n\tend",
"def create\n @spltrain = Spltrain.new(spltrain_params)\n\n respond_to do |format|\n if @spltrain.save\n format.html { redirect_to @spltrain, notice: 'Spltrain was successfully created.' }\n format.json { render :show, status: :created, location: @spltrain }\n else\n format.html { render :new }\n format.json { render json: @spltrain.errors, status: :unprocessable_entity }\n end\n end\n end",
"def init_trains\n init_train_types\n @config.fetch('trains').flat_map do |train_type|\n Array.new(train_type.fetch('count')) do\n create_train(train_type)\n end\n end\n end",
"def create\n @training = training_class.new(params[training_param])\n @training.user = current_user\n\n respond_to do |format|\n if @training.save\n format.html { redirect_to @training, notice: 'Debate training was successfully created.' }\n format.json { render json: @training, status: :created, location: @training }\n else\n format.html { render action: \"new\" }\n format.json { render json: @training.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_training\n @training = Training.find(1)\n end",
"def initialize(data=[], shape:nil, dtype: nil, device:Device.new(:numo)) # TODO: Refactor this method.\n shape ||= Shape.new()\n if data\n if data.is_a?(Array)\n data_arr = Numo::NArray[*data]\n predicted_type = DataTypes::Float64\n if data.flatten[0].is_a?(Integer)\n predicted_type = DataTypes::Int64\n elsif data.flatten[0].is_a?(Float)\n predicted_type = DataTypes::Float64\n elsif data.flatten[0].is_a?(Complex)\n predicted_type = DataTypes::Complex128\n else\n predicted_type = DataTypes::RObject\n end\n @dtype ||= predicted_type\n data = @dtype.get_dtype_on_device(device).cast(data_arr)\n @shape = shape || Shape.new(*data.shape)\n elsif data.is_a?(Numeric)\n predicted_type = DataTypes::RObject\n if data.is_a?(Integer)\n predicted_type = DataTypes::Int64\n elsif data.is_a?(Float)\n predicted_type = DataTypes::Float64\n elsif data.is_a?(Complex)\n predicted_type = DataTypes::Complex128\n end\n xmo_type = predicted_type.get_dtype_on_device(device)\n data = xmo_type[data]\n device = device\n elsif data.is_a?(Numo::NArray)\n @dtype ||= DataTypes::from_numo_dtype(data.class)\n elsif data.is_a?(Tensor)\n data = data.data\n else\n raise TypeError, \"#{data.class} is cannot convert to tensor. data must be Array or Numo::NArray.\"\n end\n @device = device\n @data = data\n @shape ||= Shape.new(*data.shape.to_a)\n @dtype ||= DataTypes::from_numo_dtype(data.class)\n else\n @device = device\n @shape = shape\n @dtype ||= DataTypes::RObject\n @data = @dtype.get_dtype_on_device(@device).zeros(*@shape.to_a)\n end\n @grad_function = nil\n @grad_tensor = nil\n @requires_grad = false\n return Functions::Constant.new.call(self)\n end",
"def initialize \n\t\t@predictions = []\n\tend",
"def dataset\n @dataset ||= data_maker.dataset\n end",
"def index\n @trainings = @runner.trainings #.limit(16).order(date: :desc) #esto no funciona si son del mismo dia\n @training = Training.new\n end",
"def create(entity)\n @dataset.create(\n _serialize(entity)\n )\n end",
"def create(entity)\n @dataset.create(\n _serialize(entity)\n )\n end",
"def initialize(data)\n @data = data\n @parameters = {}\n\n @data[@data.keys.sample].each_key do |ts|\n build_hash(ts)\n end\n end",
"def initialize(data)\n @checkpoints = []\n load_attributes(data)\n end",
"def load_data(folder,dataset=nil)\n train = dataset == nil ? \"#{folder}/u.data\" : \"#{folder}/#{dataset.to_s}.base\" \n test = dataset == nil ? \"\" : \"#{folder}/#{dataset.to_s}.test\"\n @trainset=read_file train\n @testset=read_file test\n #build user and movie index using hashes\n @user_index=@trainset.group_by { |item| item.u_id }\n @movie_index=@trainset.group_by { |item| item.m_id }\n @rating_index={}\n @trainset.each {|item| @rating_index[[item.u_id,item.m_id]]=item.rating }\n end",
"def build!(data_set_name)\n interface(data_set_name).create_empty_data_set\n library[data_set_name] = DataSet.new(data_set_name, interface(data_set_name))\n end",
"def initialize(data_location_hash)\n\t\t@data_file_path = data_location_hash[:path]\n\t\t@training_file_name = data_location_hash[:training]\n\t\t@testing_file_name = data_location_hash[:testing]\n\n\t\t@all_movies = Hash.new\n\t\t@all_users = Hash.new\n\n\t\tload_movie_data\n\t\tload_training_data\n\tend",
"def load_data (training_set, test_set = :NIL)\n base = training_set + \"/u.data\" if test_set == :NIL\n\t\tbase = training_set + \"/\" + test_set.to_s + \".base\" if test_set != :NIL\n\t\tfile = File.open (base)\n\n\t\ti=0\n\t\tfile.each_line do |line|\n\t\t\t@movieStore[i] = line.split(/\\s/)\n\t\t\ti += 1\n\t\tend\n\t\tif test_set != :NIL then\n\t\t\ttest_set = training_set + \"/\" + test_set.to_s + \".test\"\n\t\t\tfile2 = File.open(test_set)\n\t\t file2.each_line do |line|\n\t\t\t @test_set << line.split(/\\s/)\n\t\t end\n else\n @test_set = @movieStore\n end\n \n\t\tuser_movie_index()\n\tend",
"def initialize\n @data = Data.instance\n end",
"def initialize(kernel_type='RBF')\n @training_data_set = Diabetic.pick(538)\n @training = @training_data_set.collect {|d| [d.pregnant,\n d.oral_glucose_tolerance,\n d.blood_pressure,\n d.skin_fold_thickness,\n d.serum_insulin,\n d.body_mass_index,\n d.pedigree_function,\n d.age,\n d.positive]}\n\n\n @problem = Libsvm::Problem.new\n @parameter = Libsvm::SvmParameter.new\n @parameter.kernel_type = \"Libsvm::KernelType::#{kernel_type}\".constantize\n @parameter.cache_size = 100 # in megabytes\n @parameter.eps = 0.001\n @parameter.c = 10\n\n\n @labels = @training.collect {|t| t.pop}\n @examples = @training.map {|ary| Libsvm::Node.features(ary)}\n\n\n @problem.set_examples(@labels, @examples)\n\n @svm = Libsvm::Model.train(@problem, @parameter)\n end",
"def initialize(input_data)\n @data = input_data\n end",
"def train\n run_thresholds\n run_values_to_ranges\n run_reverse\n\n @classifiers\n end",
"def initialize(name, opts={})\n @version = StuffClassifier::VERSION\n\n @name = name\n\n # This values are nil or are loaded from storage\n @word_list = {}\n @category_list = {}\n @training_count=0\n\n # storage\n purge_state = opts[:purge_state]\n @storage = opts[:storage] || StuffClassifier::Base.storage\n unless purge_state\n @storage.load_state(self)\n else\n @storage.purge_state(self)\n end\n\n # This value can be set during initialization or overrided after load_state\n @thresholds = opts[:thresholds] || {}\n @min_prob = opts[:min_prob] || 0.0\n\n\n @ignore_words = nil\n @tokenizer = StuffClassifier::Tokenizer.new(opts)\n\n end",
"def initialize data\n self.data = data\n end",
"def initialize data\n self.data = data\n end",
"def initialize data\n self.data = data\n end",
"def initialize data\n self.data = data\n end",
"def initialize data\n self.data = data\n end",
"def initialize data\n self.data = data\n end",
"def initialize data\n self.data = data\n end",
"def initialize data\n self.data = data\n end",
"def build(data_list)\n @models = []\n\n data_list.each do |data|\n @models << @klass.new(data)\n end\n end",
"def generate_raw_data\n self.raw_data = Estimation::RawData.factory(cols: parameter_space.size, rows: project_setting.accuracy)\n end",
"def create_train\n puts 'What type of train do you want to create: 1 - passenger or 2 - cargo:'\n type = gets.chomp.to_i\n puts 'Enter the number of train: '\n number = gets.chomp\n\n case type\n when 1\n self.trains << PassengerTrain.new(number)\n puts \"Passenger train was created with number: #{number}\"\n when 2\n self.trains << CargoTrain.new(number)\n puts \"Cargo train was created with number: #{number}\"\n else\n puts 'Something goes wrong..'\n end\n end",
"def initialize\n self.features = {}\n end",
"def initialize(date = nil, batch_size = nil)\n @date = date\n @batch_size = batch_size\n end",
"def initialize(data)\n\n end",
"def initialize(text_file_name)\n @dictionary = Hash.new(0)\n contents = IO.read(text_file_name)\n wordsInFile = words(contents)\n train!(wordsInFile)\n end",
"def train_one_classifier(dataset)\n model = LogisticRegressionModelL2.new(0.000)\n lr = 1\n w = Hash.new {|h,k| h[k] = (rand * 0.1) - 0.05}\n sgd = StochasticGradientDescent.new(model, w, lr)\n sgd, iter, losses = train(sgd, model, w, dataset, num_epoch = 18, batch_size = 20)\n df = Daru::DataFrame.new({x: iter, y: losses})\n df.plot(type: :line, x: :x, y: :y) do |plot, diagram|\n plot.x_label \"Batches\"\n plot.y_label \"Cumulative Loss\"\n end.export_html\n return sgd\nend",
"def create\n @training = Training.new(training_params)\n\n respond_to do |format|\n if @training.save\n format.html { redirect_to '/training', notice: 'Обучение создано.' }\n format.json { render :show, status: :created, location: @training }\n else\n format.html { render :new }\n format.json { render json: @training.errors, status: :unprocessable_entity }\n end\n end\n end",
"def initialize(data)\n\t\t@data = data\n\tend",
"def initialize(k, test_set, database)\n @test_set = test_set\n @database = database\n @count = k\n @predictions = []\n run_test\n @mean = mean_calc\n end",
"def initialize(filename, frozen_model=false)\n log \"Method in use: #{method2str}\"\n if frozen_model\n rehydrate_model_from(filename)\n else\n read_training_corpus(filename)\n end\n end",
"def initialize(data)\n @data = data\n end",
"def initialize(data)\n @data = data\n end",
"def initialize(data)\n @data = data\n end",
"def initialize(data)\n @data = data\n end",
"def initialize\n load_data\n end",
"def create\n @trainclass = Trainclass.new(trainclass_params)\n\n respond_to do |format|\n if @trainclass.save\n format.html { redirect_to @trainclass, notice: 'Trainclass was successfully created.' }\n format.json { render :show, status: :created, location: @trainclass }\n else\n format.html { render :new }\n format.json { render json: @trainclass.errors, status: :unprocessable_entity }\n end\n end\n end",
"def initialize(data)\n @data = data\n end",
"def dataset\n @dataset_class.new(self)\n end",
"def dataset\n @dataset ||= generate_dataset\n end",
"def make_test_table path\n testdata = MovieData.new(path)\n users = testdata.userdata.keys\n test_table = []\n users.each do |key|\n testdata.userdata[key.to_s.to_sym].each do |id, actualrating|\n test_table.push([key, id, actualrating, predict(key, id)])\n end\n end\n return test_table\n end"
] |
[
"0.6902376",
"0.6741095",
"0.66243464",
"0.6612536",
"0.66034895",
"0.6421533",
"0.63924855",
"0.6388731",
"0.6362683",
"0.63475466",
"0.633105",
"0.6317757",
"0.6254829",
"0.62411696",
"0.62387985",
"0.6237182",
"0.62371397",
"0.6182625",
"0.61688024",
"0.6128827",
"0.6112821",
"0.61091435",
"0.60895824",
"0.60668355",
"0.6032433",
"0.6020709",
"0.6013786",
"0.6008003",
"0.6006918",
"0.6004279",
"0.59947234",
"0.5948853",
"0.5936961",
"0.5927905",
"0.5916666",
"0.58918697",
"0.58262527",
"0.5825772",
"0.58063304",
"0.5802592",
"0.57900876",
"0.5760827",
"0.5757618",
"0.57448983",
"0.5743063",
"0.57253194",
"0.5699273",
"0.569748",
"0.56837434",
"0.5680805",
"0.5678758",
"0.566562",
"0.56561595",
"0.5653209",
"0.5648944",
"0.56426644",
"0.5637412",
"0.5636983",
"0.5636983",
"0.56352675",
"0.5633619",
"0.5629976",
"0.5628579",
"0.5627634",
"0.56264365",
"0.5621803",
"0.5618289",
"0.5612541",
"0.56112224",
"0.5604585",
"0.5603454",
"0.5603454",
"0.5603454",
"0.5603454",
"0.5603454",
"0.5603454",
"0.5603454",
"0.5603454",
"0.5596088",
"0.557903",
"0.55642796",
"0.5562373",
"0.55620766",
"0.555628",
"0.5551674",
"0.55417264",
"0.5536464",
"0.5521488",
"0.5514438",
"0.55084354",
"0.55011517",
"0.55011517",
"0.55011517",
"0.55011517",
"0.5500739",
"0.54968655",
"0.5494626",
"0.54931676",
"0.5492923",
"0.54814893"
] |
0.7517891
|
0
|
==================== Generate Dummy Data ====================
|
def gen_dummy_users
num = (1..5).to_a
users = num.map {|n| "user" + n.to_s}
emails = users.map {|e| e + "@mailforspam.com" }
num.each{ |n| User.create(email: emails[n - 1], password: "12312312", password_confirmation: "12312312", username: users[n - 1]) }
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def create_dummy_values\n\t\tstock_rec = @@val\n\t\t@stock = Stock.find_by_ticker_symbol(stock_rec[\"ticker_symbol\"])\n\t\t@in_val = stock_rec[\"initial_stock_value\"].to_f\n\t\t@first_val = (@in_val - 100) <= 0 ? 0 : @in_val-100\n\t\tcolumns = [:stock_value, :stock_id]\n\t\t@all_dummy =[]\n\t\t(1..20).each do\n\t\t\tstock_value = rand(@first_val..@in_val+100)\n\t\t\t@all_dummy << @stock.stock_values.new({:stock_value => stock_value})\n\t\tend\n\t\tStockValue.import columns, @all_dummy\n\tend",
"def gen_data(parameters, x)\n mu = parameters[:mu]\n sig2 = parameters[:sig2]\n gamma = parameters[:gamma]\n size_i = x.shape[0]\n size_n = x.shape[1]\n\n sim_data_out = N.zeros_like(x)\n\n size_i.times do |i|\n size_n.times do |n|\n next if MLRatioSolve.skip_indices.include?([i,n])\n sim_data_out[i,n] = randnorm(mu[i]/gamma[n], sig2[i]/gamma[n]**2)\n end\n end\n\n sim_data_out\n end",
"def sampling_data(fun, v1=vv1, v2=vv2, repeat1=30, plan=NULL)\n len = v1.length\n data1 = Array.new(len, 0)\n len.times {|factor1|\n data1[factor1] = make_data_set(fun, v1, v2, factor1, repeat1, plan)\n }\n\n print \"sampling_data data is \\n\"\n p data1\n\n data1\nend",
"def _fake_data\n name = (\"a\"..\"z\").to_a.sample(4).join\n age = 18+((rand+rand+rand)/3*20).floor\n glutenfree = rand(2) == 1\n [name, age, glutenfree]\nend",
"def create_empty_data_set\n BasicInterfaceRegister[@data_lib][@data_set_name] = true\n end",
"def test_0_dummy\n\t\tend",
"def sample_data\n %w(A,B,1 A,C,2 B,C,3 B,D,3 C,D,1 B,E,2 D,F,3 D,E,3 E,G,3 F,G,1)\n end",
"def reset_dummy(options = {})\r\n options[:with_processed] = true unless options.key?(:with_processed)\r\n build_dummy_table(options[:with_processed])\r\n reset_class(\"Dummy\", options)\r\nend",
"def new_dummy_label\n @dummy_label_index ||= 0\n @dummy_labels ||= (\"a\"..\"aaaaaa\").to_a\n dummy_label = @dummy_labels[@dummy_label_index]\n @dummy_label_index += 1\n dummy_label\n end",
"def generate_test_data\n headerrow = ['foo', 'bar', 'baz', 'qux', 'quy', 'quz'] # contents inconsequential\n merchant_name = \"foo bar\" # use for occassional repetition\n item_description = \"baz qux\"\n item_price = 100\n # proc to generate a row of data with occassional repetition as per values above\n rowgen = Proc.new { [Faker::Name.name, [Faker::Commerce.product_name, item_description].sample, [Faker::Number.number(3), item_price].sample, (1..100).to_a.sample, Faker::Address.street_address, [Faker::Company.name, merchant_name].sample] }\n data = [ headerrow ]\n (0..(rand(100)+20)).each{ data << rowgen.call } # generate random number of rows\n data\nend",
"def generate_test_data()\n CSV.open(\"testdata.csv\", \"w\") do |csv|\n (1..1_000_000).each do |i|\n csv << [rand(100), rand(10_000), rand(100_000)]\n end\n end\nend",
"def create_empty\n EadGenerator.generate_empty\n end",
"def generate_test_data\n 50_000.times.map do |i|\n name = [\"John\", \"Peter\", \"Sylvia\"][rand(3)] + \" \" +\n [\"McTest\", \"McGregor\", \"McIntosh\"][rand(3)]\n [i, name, Time.at(rand * Time.now.to_i).strftime(\"%Y-%m-%d\") ].join(',')\n end.join(\"\\n\")\nend",
"def set_up_test(input_plates)\n input_plates.each do |plate|\n sample = plate.parts.first.sample\n plate.add_samples(Array.new(plate.get_empty.length, sample))\n end\n end",
"def make_training_set training_set_size\n sample = $ou.to_a.sample(training_set_size).shuffle\n data_to_csv 'train.csv', sample\nend",
"def randGenerator(dimension)\n\t\tr = Random.new\n\t\tfullTab = []\n\t\ttmpTab = []\n\t\tdimension.times do\n\t\t\tdimension.times do\n\t\t\t\tnb = r.rand(0..1)\n\t\t\t\tif nb == 0 then tmpTab << false else tmpTab << true end\n\t\t\tend\n\t\t\tfullTab << tmpTab\n\t\t\ttmpTab = []\n\t\tend\n\t\treturn fullTab\n\tend",
"def initialize\n \tself.seed_data\n end",
"def generate_fake_binary_sequence\n s = \"\"\n 1500.times{|i| s << kernel.rand(1) }\n s\n end",
"def samples; end",
"def samples; end",
"def generate_data\n\t\tgenerate_stations\n\t\tgenerate_demands\n\tend",
"def create_empty_data_set\n open_for_write\n close\n end",
"def __dummy_test__\n end",
"def generate_data_values\n data_array = Array.new()\n @data.repository.each { |dataset|\n data_array << create_data_hash(dataset)\n }\n return data_array\n end",
"def generate_raw_data\n self.raw_data = Estimation::RawData.factory(cols: parameter_space.size, rows: project_setting.accuracy)\n end",
"def sample\n @data.keys.sample\n end",
"def get_dummy(klass)\n type = get_type(klass)\n is_analyzer = type == \"Analyzer\"\n is_analyzer ? klass.new(\"dummy\") : klass.new(artifacts: [], rule: nil)\n end",
"def seed; end",
"def generate_alltestc\n\n end",
"def generate_alltest\n\n end",
"def isDummyNode?(node) \n return node.name == Tag_Dummy ;\n end",
"def initialize( real_domains = false, skip_mx_test = false )\n @use_real_domains = real_domains\n @skip_mx_test = skip_mx_test\n @random_sld_patterns = DefaultWeightedRandomSldPatterns\n @random_sld_letters = DefaultRandomSldLetters\n @random_sld_consonants = DefaultRandomSldConsonants\n @random_sld_vowels = DefaultRandomSldVowels\n end",
"def run_experiment(r,seed,max,step)\n r.del('hll')\n i = 0\n samples = []\n step = 1000 if step > 1000\n while i < max do\n elements = []\n step.times {\n ele = Digest::SHA1.hexdigest(i.to_s+seed.to_s)\n elements << ele\n i += 1\n }\n r.pfadd('hll',elements)\n approx = r.pfcount('hll')\n err = approx-i\n rel_err = 100.to_f*err/i\n samples << [i,rel_err]\n end\n samples\nend",
"def generate_dummy_data_for_presentation(pt1,user)\n\n#generate the exercises:\n# For the legs session type\n legs1 = Exercise.new(\"Full Squat\", \"Legs\", true, 10, 5, 1.2,4,3) \n legs2 = Exercise.new(\"Barbell Lunge\", \"Legs\", false, 15, 5, 1.1,4,2) \n legs3 = Exercise.new(\"Deadlift\", \"Legs\", true, 15, 5, 1.3,2,4) \n legs4 = Exercise.new(\"Leg Press\", \"Legs\", false, 20, 5, 1.25,6,5) \n legs5 = Exercise.new(\"Ham String Curl\", \"Legs\", true, 12, 5, 1.15,4,4) \n # For the Biceps, Triceps, Forearms and Abs (aka BTFA) session type \n btfa1 = Exercise.new(\"Bicep Curls\", \"BTFA\",true, 10, 5, 1.2,4,3) \n btfa2 = Exercise.new(\"Shoulder Press\", \"BTFA\", false, 10, 5, 1.2,4,3) \n btfa3 = Exercise.new(\"Bench Press\", \"BTFA\", true, 10, 5, 1.2,4,3) \n btfa4 = Exercise.new(\"Triceps Extension\", \"BTFA\", false, 10, 5, 1.2,4,3) \n btfa5 = Exercise.new(\"Sit Up\", \"BTFA\", true, 10, 5, 1.2,4,3) \n # For the Shoulders and Traps session type\n shoulders_traps1 = Exercise.new(\"Dumbell Shoulder Press\", \"Shoulders and Traps\",true, 10, 5, 1.2,4,3) \n shoulders_traps2 = Exercise.new(\"Upright Barbell Row\", \"Shoulders and Traps\", false, 10, 5, 1.2,4,3) \n shoulders_traps3 = Exercise.new(\"Seated Bent-over Rear Delt Raise\", \"Shoulders and Traps\", true, 10, 5, 1.2,4,3) \n shoulders_traps4 = Exercise.new(\"Side Lateral Raise\", \"Shoulders and Traps\", false, 10, 5, 1.2,4,3) \n shoulders_traps5 = Exercise.new(\"Barbell Shrug\", \"Shoulders and Traps\", true, 10, 5, 1.2,4,3) \n # For the Back session type\n back1 = Exercise.new(\"Barbell Deadlift\", \"Back\", true, 10, 5, 1.2,4,3) \n back2 = Exercise.new(\"Wide-Grip Pull Up\", \"Back\", false, 10, 5, 1.2,4,3) \n back3 = Exercise.new(\"Bent-Over Barbell Deadlift\", \"Back\", true, 10, 5, 1.2,4,3) \n back4 = Exercise.new(\"Standing T-Bar Row\", \"Back\", false, 10, 5, 1.2,4,3) \n # For the Chest session type\n chest1 = Exercise.new(\"Barbell Bench Press\", \"Chest\", true, 10, 5, 1.2,4,3) \n chest2 = Exercise.new(\"Flat Bench Dumbbell Press\", \"Chest\", false, 10, 5, 1.2,4,3) \n chest3 = Exercise.new(\"Seated Machine Chest Press\", \"Chest\", true, 10, 5, 1.2,4,3) \n chest4 = Exercise.new(\"Incline Dumbbell Press\", \"Chest\", false, 10, 5, 1.2,4,3) \n chest5 = Exercise.new(\"Machine Decline Press\", \"Chest\", true, 10, 5, 1.2,4,3) \n\n# add exercises to the PT object so that it's aware of them\n pt1.add_exercises(legs1)\n pt1.add_exercises(legs2)\n pt1.add_exercises(legs3)\n pt1.add_exercises(legs4)\n pt1.add_exercises(legs5)\n pt1.add_exercises(btfa1)\n pt1.add_exercises(btfa2)\n pt1.add_exercises(btfa3)\n pt1.add_exercises(btfa4)\n pt1.add_exercises(btfa5)\n pt1.add_exercises(shoulders_traps1)\n pt1.add_exercises(shoulders_traps2)\n pt1.add_exercises(shoulders_traps3)\n pt1.add_exercises(shoulders_traps4)\n pt1.add_exercises(shoulders_traps5)\n pt1.add_exercises(back1)\n pt1.add_exercises(back2)\n pt1.add_exercises(back3)\n pt1.add_exercises(back4)\n pt1.add_exercises(chest1)\n pt1.add_exercises(chest2)\n pt1.add_exercises(chest3)\n pt1.add_exercises(chest4)\n pt1.add_exercises(chest5)\n\n\n # establish id for user\n user.username = \"jim\"\n user.password = \"password\"\n user.first_name = \"Jimmy\"\n user.last_name = \"Coder\"\n user.gender = \"Male\"\n user.body_type = \"Mesomorph\"\n user.goal = \"musclebuild\"\n user.disclaimer = \"accept\"\n user.date_of_birth = Date.new(1990,9,9)\n # binding.pry\n user.weight = 56\n user.goal_weight = 75\n\n#establish some dummy workout history for our user:\n # (weight, completed_reps, exercise_performed, duration, date, session_number, session_type)\n workout_history_for_user = ExerciseInput.new(10, 8, chest1.name, 10, Date.new(2017,8,1), 1, chest1.session_type)\n user.add_completed_session(workout_history_for_user)\n #\n workout_history_for_user = ExerciseInput.new(10, 9, chest1.name, 10, Date.new(2017,8,1), 1, chest1.session_type)\n user.add_completed_session(workout_history_for_user)\n #\n workout_history_for_user = ExerciseInput.new(10, 10, chest1.name, 10, Date.new(2017,8,1), 1, chest1.session_type)\n user.add_completed_session(workout_history_for_user)\n #\n workout_history_for_user = ExerciseInput.new(10, 11, chest1.name, 10, Date.new(2017,8,2), 1, chest1.session_type)\n user.add_completed_session(workout_history_for_user)\n #\n workout_history_for_user = ExerciseInput.new(15, 8, chest1.name, 10, Date.new(2017,8,2), 1, chest1.session_type)\n user.add_completed_session(workout_history_for_user)\n #\n workout_history_for_user = ExerciseInput.new(15, 9, chest1.name, 10, Date.new(2017,8,2), 1, chest1.session_type)\n user.add_completed_session(workout_history_for_user)\n #\n workout_history_for_user = ExerciseInput.new(15, 9, chest1.name, 10, Date.new(2017,8,2), 1, chest1.session_type)\n user.add_completed_session(workout_history_for_user)\n #\n workout_history_for_user = ExerciseInput.new(15, 8, chest1.name, 10, Date.new(2017,8,3), 1, chest1.session_type)\n user.add_completed_session(workout_history_for_user)\n #\n workout_history_for_user = ExerciseInput.new(15, 8, chest1.name, 10, Date.new(2017,8,3), 1, chest1.session_type)\n user.add_completed_session(workout_history_for_user)\n #\n workout_history_for_user = ExerciseInput.new(15, 8, chest1.name, 10, Date.new(2017,8,3), 1, chest1.session_type)\n user.add_completed_session(workout_history_for_user)\n #\n workout_history_for_user = ExerciseInput.new(15, 8, chest1.name, 10, Date.new(2017,8,3), 1, chest1.session_type)\n user.add_completed_session(workout_history_for_user)\n #\n workout_history_for_user = ExerciseInput.new(15, 8, chest1.name, 10, Date.new(2017,8,4), 1, chest1.session_type)\n user.add_completed_session(workout_history_for_user)\n #\n workout_history_for_user = ExerciseInput.new(15, 8, chest1.name, 10, Date.new(2017,8,4), 1, chest1.session_type)\n user.add_completed_session(workout_history_for_user)\n #\n workout_history_for_user = ExerciseInput.new(15, 8, chest1.name, 10, Date.new(2017,8,4), 1, chest1.session_type)\n user.add_completed_session(workout_history_for_user)\n #\n workout_history_for_user = ExerciseInput.new(15, 8, chest1.name, 10, Date.new(2017,8,4), 1, chest1.session_type)\n user.add_completed_session(workout_history_for_user)\n #\n workout_history_for_user = ExerciseInput.new(15, 5, chest1.name, 10, Date.new(2017,8,5), 1, chest1.session_type)\n user.add_completed_session(workout_history_for_user)\n #\n workout_history_for_user = ExerciseInput.new(15, 8, chest1.name, 10, Date.new(2017,8,6), 1, chest1.session_type)\n user.add_completed_session(workout_history_for_user)\n #\n workout_history_for_user = ExerciseInput.new(20, 8, chest1.name, 10, Date.new(2017,8,7), 1, chest1.session_type)\n user.add_completed_session(workout_history_for_user)\n #\n workout_history_for_user = ExerciseInput.new(20, 10, chest1.name, 10, Date.new(2017,8,8), 1, chest1.session_type)\n user.add_completed_session(workout_history_for_user)\n #\n workout_history_for_user = ExerciseInput.new(25, 7, chest1.name, 10, Date.new(2017,8,9), 1, chest1.session_type)\n user.add_completed_session(workout_history_for_user)\n #\n workout_history_for_user = ExerciseInput.new(25, 8, chest1.name, 10, Date.new(2017,8,10), 1, chest1.session_type)\n user.add_completed_session(workout_history_for_user)\n #\n workout_history_for_user = ExerciseInput.new(25, 9, chest1.name, 10, Date.new(2017,8,11), 1, chest1.session_type)\n user.add_completed_session(workout_history_for_user)\n #\n workout_history_for_user = ExerciseInput.new(25, 10, chest1.name, 10, Date.new(2017,8,12), 1, chest1.session_type)\n user.add_completed_session(workout_history_for_user)\n #\n\n\nend",
"def sample n=1\n @rng.fill(n)\n end",
"def random_parts_1\n parts = []\n (1..8).each do |id|\n parts.push(Part.new(part_type_id: id, defect: ([false]*19 << true).sample))\n end\n parts\n end",
"def get_zero_tuple\n zero_tuple = Array.new(@working_dataset.dataset[0].size)\n for attribute_index in 0..zero_tuple.size - 1\n #if @workind_dataset.name_of_nominal_type == @working_dataset.get_type_of_attribute_by_index_of_attribute_of_tuple(attribute_index)\n if \"Nominal\" == @working_dataset.get_type_of_attribute_by_index_of_attribute_of_tuple(attribute_index)\n zero_tuple[attribute_index] = Hash.new\n else\n zero_tuple[attribute_index] = 0\n end\n end\n return zero_tuple\n end",
"def process_dummy exp\n result = @expected.new(:dummy) rescue @expected.new\n result << self.process(exp.shift) until exp.empty?\n result\n end",
"def basic_test_data\n sf = FactoryGirl.create(:city, name: \"San Francisco\")\n ch = FactoryGirl.create(:city, name: \"Chicago\")\n FactoryGirl.create(:business_type)\n\n # Admin user\n FactoryGirl.create(:user, admin: true, city_id: sf.id)\n\n # Need some businesses in each city\n 3.times do\n FactoryGirl.create(:business, city: sf.name, state: \"CA\")\n FactoryGirl.create(:business, city: ch.name, state: \"IL\")\n end\n\n %w(a b c d e f g h i j k).each do |tag|\n FactoryGirl.create(:tag, name: tag)\n end\n end",
"def dummy_reg(size = 16)\n Reg.new(self, 0, size, :dummy, init_as_writable: true)\n end",
"def create_sample_array\n sample_array = []\n\n\n # add songs to sample-array in correct ratios\n @spins_per_week.each do |k,v|\n v.times { sample_array.push(PL::db.get_song(k)) }\n end\n\n sample_array\n end",
"def generate_data(type, length)\n length = length.to_i\n if type == \"array\"\n data = []\n length.times do\n data << rand(1..length)\n end\n else\n data = \"\"\n length.times do\n data << rand(1..length).to_s\n end\n end\n data\nend",
"def generate_initial_population\n @population = []\n @population_size.times do\n population << Chromosome.seed(study_times, subjects)\n end\n end",
"def dummy_generator(result)\n Object.new.tap { |o| o.define_singleton_method(:generate) { |*args| result } }\n end",
"def test_double_create\n generator = nil\n assert_nothing_raised do\n generator = Markov::Generator.new [[1.0, \"bob\"], [0.8, \"sam\", :sam]]\n results = (0..50).map {|n| generator.one}\n assert results.include?(\"bob\")\n assert results.include?(\"sam\")\n end\n end",
"def process_dummy(exp)\n result = @expected.new(:dummy) rescue @expected.new\n\n until exp.empty? do\n result << self.process(exp.shift)\n end\n\n result\n end",
"def dataset\n @dataset ||= generate_dataset\n end",
"def make_valid_incomplete seed=2\n pattern = Array.new(size){|i| i+1}.shuffle\n size.times do |y|\n size.times do |x|\n set x, y, pattern[x] if rand(seed) == seed-1\n end\n base.times{|i| pattern.push pattern.shift}\n pattern.push pattern.shift if base - (y%base) == 1\n end\n self\n end",
"def make_valid_incomplete seed=2\n pattern = Array.new(size){|i| i+1}.shuffle\n size.times do |y|\n size.times do |x|\n set x, y, pattern[x] if rand(seed) == seed-1\n end\n base.times{|i| pattern.push pattern.shift}\n pattern.push pattern.shift if base - (y%base) == 1\n end\n self\n end",
"def deploy_lots_of_dummys(number = 10)\n (1..number.to_i).each { |x| deploy_dummy(x) }\n end",
"def create_dummy_test_files(*path)\n templates << TemplateExampleSpecBertha.new(project_name, module_name, test_directory: File.join(path))\n end",
"def predict_weather\n sunshine = [true, false].sample\n if sunshine\n puts \"Today's weather will be sunny!\"\n else\n puts \"Today's weather will be cloudy!\"\n end\nend",
"def make_data\n Array.new(2**15) { |i| (i / 16 % 256) }\n end",
"def generate_income\n income = []\n i = 1\n 100000.times do \n income << {i => number_generator}\n i += 1\n end\n FileReader.write(\"income_100k\", income)\n end",
"def build_dummy_table(with_processed)\r\n ActiveRecord::Base.connection.create_table :dummies, :force => true do |t|\r\n t.string :name\r\n t.string :image_file_name\r\n t.string :image_content_type\r\n t.integer :image_file_size\r\n t.datetime :image_updated_at\r\n t.boolean(:image_processing, :default => false) if with_processed\r\n end\r\nend",
"def initial_generate\n \n end",
"def sample_question\n get_all_from_database.sample\n end",
"def predict_weather\n sunshine = [true, false].sample\n\n if sunshine\n puts \"Today's weather will be sunny!\"\n else\n puts \"Today's weather will be cloudy!\"\n end\nend",
"def predict_weather\n sunshine = [true, false].sample\n\n if sunshine\n puts \"Today's weather will be sunny!\"\n else\n puts \"Today's weather will be cloudy!\"\n end\nend",
"def predict_weather\n sunshine = [true, false].sample\n\n if sunshine\n puts \"Today's weather will be sunny!\"\n else\n puts \"Today's weather will be cloudy!\"\n end\nend",
"def test_create_from_data\n data = @test_record.all_text\n \n creation_test do |record|\n record.create_from_data('', data)\n end\n end",
"def predict_weather\n sunshine = ['true', false].sample\n\n if sunshine\n puts \"Today's weather will be sunny!\"\n else\n puts \"Today's weather will be cloudy!\"\n end\nend",
"def build_sample\n sample = Array.new(8) {Array.new(8)}\n sample[0][0] = King.new(0, 0, 0)\n sample[7][7] = King.new(7, 7, 1)\n sample[0][4] = Rook.new(0, 4, 1)\n sample[4][0] = Rook.new(4, 0, 1)\n sample[4][4] = Bishop.new(4, 4, 1)\n sample\nend",
"def create_some_data\n\t\tSunspot.remove_all!\t\t\t\t\t#\tisn't always necessary\n\t\tStudySubject.solr_reindex\n\t\tassert StudySubject.search.hits.empty?\n\t\tsubject1 = FactoryBot.create(:complete_case_study_subject)\n\t\tFactoryBot.create(:sample, :study_subject => subject1,\n\t\t\t:sample_type => SampleType['marrowdiag'])\n\t\tsubject2 = FactoryBot.create(:complete_case_study_subject)\n\t\tFactoryBot.create(:sample, :study_subject => subject2,\n\t\t\t:sample_type => SampleType['periph'])\n\t\tStudySubject.solr_reindex\n\t\tassert !StudySubject.search.hits.empty?\n\tend",
"def skip_sample_layout\n lyt = []\n make_skip_start_array(@group_size).each do |j|\n cols = Array.new(@columns) { |c| c }\n cols.each { |c| @group_size.times { |i| lyt << [i*2 + j, c] } }\n end\n lyt\n end",
"def db_seed\n # Your code goes here!\n\n brands = []\n product_names = []\n prices = []\n 10.times do\n brands.push(Faker::Company.name)\n product_names.push(Faker::Commerce.product_name)\n prices.push(Faker::Commerce.price(10..50))\n end\n\n 10.times do\n Product.create(brand: brands.sample, name: product_names.sample, price: prices.sample )\n end\n\nend",
"def generate_population\n Array.new.tap do |population|\n Data::POPULATION_LENGTH.times do\n population.push(generate_random_member)\n end\n end\nend",
"def generate(*)\n to_a.sample\n end",
"def db_seed\n data_path = File.dirname(__FILE__) + \"/data.csv\"\n CSV.open(data_path, \"ab\") do |csv|\n 0.upto(9).each do |index|\n csv << [index, Faker::Company.name, Faker::Commerce.product_name, Faker::Commerce.price]\n end\n end\nend",
"def generate_starting_live_cells\n\t\tcells = []\n\t\tcell_count.times do\n\t\t\tstart_x = rand(size) # [0..4]\n\t\t\tstart_y = rand(size) # [0..4]\n\t\t\tcell = Cell.new(start_x, start_y)\n\n\t\t\tcells << cell\n\t\t\tupdate_board(cell)\n\t\tend\n\t\tcells\n\tend",
"def fill_data\n add_dog('walt')\n add_dog('foggy')\n add_dog('lister')\n end",
"def initialize(x, y)\n\t\t@neurons = Array.new\n\t\tx.times do\n\t\t\tneuron = Array.new(y)\n\t\t\t\n\t\t\t#create random weights\n\t\t\tneuron.each_index do |weight|\n\t\t\t\tneuron[weight] = rand * 2.0 - 1.0\n\t\t\tend\n\t\t\t@neurons << neuron\n\t\tend\n\tend",
"def create_missouri_data\n missouri_data = MissouriDatum.create(file_small: @file_names[1], file_large: @file_names[0])\n puts \"Instance saved!\"\n end",
"def data\n return @empty_data if @empty_data\n\n @empty_data = {}\n interval.each do |day|\n @empty_data[day.to_s(:short)] = 0\n end\n @empty_data\n end",
"def init_data\n end",
"def la\n %w[Birmingham Leeds].sample\n end",
"def create_random_array(size=5)\n Array.new(size) { Array.new(size) { [\"Yes\", \"No\", \"Maybe\"].sample } }\n end",
"def db_seed\n\tbrand = []\n\tproducts_names = []\n\tprices = []\n\tarray = []\n\t10.times do |i|\n\t\tbrand.push(Faker::Commerce.department)\n\t\tproducts_names.push(Faker::Commerce.product_name)\n\t\tprices.push(Faker::Commerce.price)\n\t\tProduct.create(id:i,brand:brand[i],name:products_names[i],price:prices[i])\n\tend\t\nend",
"def generate(size_x, size_y)\n @size_x = size_x\n @data = Array.new(size_x * size_y, 0)\n first_iteration = true\n\n number_of_passes.times do\n drops = create_drops\n\n # initial drop position is at the center of the map\n drop_point_x, drop_point_y = size_x / 2, size_y / 2\n\n drops.each do |drop|\n # drop particles\n drop.each { |particle| particle.drop(@data, drop_point_x, drop_point_y, size_x) }\n\n # move drop point for next drop\n if first_iteration\n drop_point_x = rand(size_x - 8) + 4 # make sure that particles\n drop_point_y = rand(size_y - 8) + 4 # aren't created near the edges\n else\n drop_point_x = rand(size_x / 2) + size_x / 4\n drop_point_y = rand(size_y / 2) + size_y / 4\n end\n end\n\n first_iteration = false\n change_variables_for_next_pass\n end\n\n @data\n end",
"def seed_data\n # for my own testing purposes\n puts \"Providing some seed data here\"\n today = Date.today\n range1 = DateRange.new(start_date_obj: today, end_date_obj: today + 3)\n hotel.make_reservation(date_range: range1, customer: \"Butters\", new_nightly_rate: 50)\n hotel.make_reservation(date_range: range1, customer: \"Me\")\n hotel.make_block(date_range: range1, room_ids:[11,12,13,14,15], new_nightly_rate:100)\n hotel.make_reservation_from_block(room_id:11, customer:\"Oski\")\n hotel.make_reservation_from_block(room_id:12, customer: \"Jesse\")\n hotel.make_block(date_range: range1, room_ids:[19,20], new_nightly_rate:125)\nend",
"def generate; end",
"def generate; end",
"def initialize(_input_data)\n super(_input_data)\n @prng = Random.new(module_data.data[\"_input_data\"][\"seed\"])\n end",
"def prepare_data(num_rows)\n app_train = read_dataset_from_csv('./input/application_train', num_rows)\n data = app_train[\"data\"]\n set_categorical_labels(data)\n numeric_features, _categorical_features = get_numeric_cateforical_features_from_the_raw_dataset(app_train[\"data\"])\n categorical_features_one_hot_encode = get_one_hot_feature_map_from_the_origin_dataset(data)\n one_hot_encoding_using_feature_map(data, categorical_features_one_hot_encode)\n\n # NaN values for DAYS_EMPLOYED: 365243 -> nan\n data.each do |r|\n r_features = r[\"features\"]\n if r_features[\"days_empoyed\"] == 365243\n r_features[\"days_employed\"] = \"\"\n r_features[\"days_employed_anom\"] = 1\n else\n r_features[\"days_employed_anom\"] = 0 \n end \n \n add_ratio_feature(\"payment_rate\", \"amt_annuity\", \"amt_credit\", r)\n add_ratio_feature(\"annuity_income_ratio\", \"amt_annuity\", \"amt_income_total\", r)\n add_ratio_feature(\"credit_goods_ratio\", \"amt_credit\", \"amt_goods_price\", r)\n # add_ratio_feature(\"income_person_ratio\", \"amt_income_total\", \"cnt_fam_members\", r)\n add_ratio_feature(\"employed_birth_ratio\", \"days_employed\", \"days_birth\", r)\n end\n # categorical_features << \"days_employed_anom\"\n\n bureau = read_dataset_from_csv('./input/bureau', 1000, $bureau_numeric_features)\n # bureau[\"data\"].each do |r|\n # puts r[\"features\"][\"days_enddate_fact\"]\n # end\n # return\n grouped = group_data(bureau[\"data\"])\n agged = agg_group_data(grouped, $bureau_numeric_features, \"bureau\")\n merge_to_dataset(app_train, agged, $bureau_numeric_features)\n\n app_train[\"features\"] = app_train[\"data\"][0][\"features\"].keys\n\n puts \"begin to normalize the dataset......\"\n nomalizer = Normalizer.new\n nomalizer.normalize(app_train, numeric_features)\n\n puts \"begin to impute missing value......\"\n imputer = SimpleImputer.new\n imputer.fit(app_train)\n \n puts \"finish preparing the dataset!\"\n return app_train\nend",
"def name\n \"dummy\"\n end",
"def e1334_random_bag (values)\n end",
"def initialize number\n self.number = number\n self.samples = []\n end",
"def initialize_data\n end",
"def gen_boolean\n [true, false].sample\n end",
"def predict_weather\n sunshine = ['true', 'false'].sample\n\n if sunshine\n puts \"Today's weather will be sunny!\"\n else\n puts \"Today's weather will be cloudy!\"\n end\nend",
"def predict_weather\n sunshine = ['true', 'false'].sample\n\n if sunshine\n puts \"Today's weather will be sunny!\"\n else\n puts \"Today's weather will be cloudy!\"\n end\nend",
"def GenerateWhiteNoise(width, height, seed)\n\n\tr = Random.new(seed)\n\tnoise = Array.new(width) { Array.new(height)}\n\n\ti = 0\n\twhile i < width do\n\t\tj = 0\n\t\twhile j < height do\n\t\t\tnoise[i][j] = (r.rand(2000)-1000)/1000.0\n\t\t\tj=j+1\n\t\tend\n\t\ti=i+1\n\tend\n\treturn noise\nend",
"def split_population_training_test( percentage, training )\n n = (training.length*percentage).round\n test = []\n\n n.times do\n i = rand(training.length - 1)\n test << training.delete_at(i)\n end\n\n test\nend",
"def sample_without_replacement(sample=1)\n if @data.respond_to? :sample_without_replacement\n @data.sample_without_replacement sample\n else\n raw_sample_without_replacement(sample)\n end\n end",
"def create_all_data_bags\n DATA_BAGS_CONF.keys.each do |bag|\n next if list_data_bags.include? bag\n puts \"TRACE: creating missing data bag #{bag}\" if verbose\n create_data_bag(bag)\n end\nend",
"def create_samples(n)\n n.times do |i|\n Post.create(title: \"New Post #{i}\", body: \"Body of post #{i}\", created_at: Time.now)\n end\nend",
"def setup_process_in_batches_tests\n @array = %W[one two three four five six seven eight nine ten]\n @empty = Array.new\n end",
"def generate_sample_data(waveform, num_samples, frequency, amplitude)\n position_in_period = 0.0\n position_in_period_delta = frequency / SAMPLE_RATE\n\n # Initialize an array of samples set to 0.0. Each sample will be replaced with\n # an actual value below.\n samples = [].fill(0.0, 0, num_samples)\n\n num_samples.times do |i|\n # Add next sample to sample list. The sample value is determined by\n # plugging position_in_period into the appropriate wave function.\n if waveform == :sine\n samples[i] = Math::sin(position_in_period * TWO_PI) * amplitude\n elsif waveform == :square\n samples[i] = (position_in_period >= 0.5) ? amplitude : -amplitude\n elsif waveform == :saw\n samples[i] = ((position_in_period * 2.0) - 1.0) * amplitude\n elsif waveform == :triangle\n samples[i] = amplitude - (((position_in_period * 2.0) - 1.0) * amplitude * 2.0).abs\n elsif waveform == :noise\n samples[i] = RANDOM_GENERATOR.rand(-amplitude..amplitude)\n end\n\n position_in_period += position_in_period_delta\n\n # Constrain the period between 0.0 and 1.0.\n # That is, keep looping and re-looping over the same period.\n if position_in_period >= 1.0\n position_in_period -= 1.0\n end\n end\n\n samples\nend",
"def initialize(bits_per_symbol: , p_0: 0.5, p_1: 0.5 )\r\n raise ArgumentError.new(\"Probabilities of bits must add up to 1\") if p_0 + p_1 != 1\r\n @bits_per_symbol, @p_0, @p_1, @random_generator = bits_per_symbol, p_0, p_1, Random.new\r\n end",
"def prepare_data\n # This method is just a stub.\n end"
] |
[
"0.68380237",
"0.5990347",
"0.5918289",
"0.5883012",
"0.5880438",
"0.5876096",
"0.5621978",
"0.5573727",
"0.5563637",
"0.5506718",
"0.54268116",
"0.5391417",
"0.5389615",
"0.5376903",
"0.5346934",
"0.5346644",
"0.5332797",
"0.53145105",
"0.5280209",
"0.5280209",
"0.52691686",
"0.5263666",
"0.52492374",
"0.52265036",
"0.5221963",
"0.5184896",
"0.51731837",
"0.510833",
"0.50754386",
"0.50567615",
"0.5045941",
"0.50401735",
"0.4998352",
"0.499332",
"0.49915147",
"0.49734646",
"0.49712622",
"0.49705997",
"0.49584815",
"0.49575725",
"0.49463013",
"0.49315244",
"0.49271265",
"0.49135724",
"0.490641",
"0.4895894",
"0.48892385",
"0.4881854",
"0.4881854",
"0.48742908",
"0.48679614",
"0.48567227",
"0.48527315",
"0.48416853",
"0.4840419",
"0.4835304",
"0.48251534",
"0.482228",
"0.482228",
"0.482228",
"0.48205116",
"0.4814975",
"0.48077917",
"0.480642",
"0.48017874",
"0.4801363",
"0.47999948",
"0.479122",
"0.47846082",
"0.47836414",
"0.47820917",
"0.47812426",
"0.47754744",
"0.47750282",
"0.47676134",
"0.4766685",
"0.47613797",
"0.47573444",
"0.47501904",
"0.47495192",
"0.47486478",
"0.47486478",
"0.4746366",
"0.47374162",
"0.47330943",
"0.47231495",
"0.4715741",
"0.47139874",
"0.47059423",
"0.47057024",
"0.47057024",
"0.47009772",
"0.46995324",
"0.46975228",
"0.46909168",
"0.46903175",
"0.46875116",
"0.46863285",
"0.4681159",
"0.46759287"
] |
0.54397416
|
10
|
Grab file read opts in the context
|
def file_read_opts(context)
context.registers[:site].file_read_opts
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def file_read_opts(context); end",
"def file_read_opts(context)\n context.registers[:site].file_read_opts\n end",
"def file_read_opts; end",
"def file_read_opts=(_arg0); end",
"def merged_file_read_opts(site, opts); end",
"def read_file(file, context); end",
"def command_options(opts)\n opts[:read] ? opts : opts.merge(:read => @read)\n end",
"def add_std_file_opt(inkey)\n @oparse.on(\"-f\", \"--file FILENAME\", \"Input from FILENAME\") do |f|\n @opts[inkey] = do_file_read(f)\n end\n return @oparse\n end",
"def read_file(file, context)\n File.read(file, file_read_opts(context))\n end",
"def file_handler_opts; end",
"def file_options; end",
"def read(*args)\n file.try(:read, *args)\n end",
"def read(opts = T.unsafe(nil)); end",
"def parse_file_argument(key)\n if @opts[key].nil? and f=@argv.shift\n @opts[key] = do_file_read(f)\n end\n end",
"def read(*args)\n IO.read(@path, *args)\n end",
"def read_file(file, context)\n File.read(file)\n end",
"def read\n @read ||= File.read(path)\n end",
"def read(*args, **kwd); end",
"def default_read(read = nil)\n @opts[:read] || @collection.read\n end",
"def yardopts_options(opts)\n opts.on('--[no-]yardopts [FILE]',\n \"If arguments should be read from FILE\",\n \" (defaults to yes, FILE defaults to .yardopts)\") do |use_yardopts|\n if use_yardopts.is_a?(String)\n self.options_file = use_yardopts\n self.use_yardopts_file = true\n else\n self.use_yardopts_file = (use_yardopts != false)\n end\n end\n\n opts.on('--[no-]document', \"If arguments should be read from .document file. \",\n \" (defaults to yes)\") do |use_document|\n self.use_document_file = use_document\n end\n end",
"def read(read = nil)\n return default_read if read.nil?\n set_option(:read, read)\n end",
"def read_file\n @read_file ||= File.open(self.file)\n end",
"def read(*args) IO.read(path, *args) end",
"def read_file path, options = {}\n File.read resolve_path(path, options)\n end",
"def read(file)\n if @options[:input_file]\n file = File.join(File.dirname(@options[:input_file]), file)\n end\n File.read(file)\n end",
"def read(*args)\n io.read(*args)\n end",
"def read(*args)\n #This is a stub, used for indexing\n end",
"def yardopts\n IO.read(options_file).shell_split\n rescue Errno::ENOENT\n []\n end",
"def inline\n return read_file if options.empty?\n inline_with_options\n end",
"def process_options\n \n if @options.attach or @options.detach\n @options.files = @arguments\n end\n \n end",
"def read_options(files)\n ret = {}\n files.each do |file|\n data = read_file(file)\n next if data.nil? || data.empty?\n ret = merge_hashes(ret, data)\n end\n ret\n end",
"def read\n open(fullpath, 'r') do |io|\n if block_given?\n yield io\n else\n io.read\n end\n end\n end",
"def read(path); end",
"def read\n IO.read(full_path)\n end",
"def read_config_file; end",
"def call(options = {})\n options.tap do |opts|\n opts[:contents] = File.open(opts[:file]).read\n end\n end",
"def read_options_from_file\n Shellwords.shellwords File.read(\".rspec_n\").to_s.gsub(/\\n|\\r\\n/, \" \")\n end",
"def read\n file\n end",
"def read_file(filename); end",
"def do_file_read(f)\n File.read(f) rescue(bail \"File Read Error: #{$!}\")\n end",
"def set_check_file(opts)\n opts = check_params(opts,[:file_info])\n super(opts)\n end",
"def read options = {}, &block\n object.read(options.merge(:version_id => @version_id), &block)\n end",
"def get_file(filename, options={})\n end",
"def read(opts = {})\n filename = opts.fetch(:filename, @filename)\n encoding = opts.fetch(:encoding, @encoding)\n return unless File.file? filename\n\n mode = encoding ? \"r:#{encoding}\" : 'r'\n File.open(filename, mode) { |fd| parse fd }\n self\n end",
"def read(*args)\r\n\t\t\tfh=@fh or return\r\n\t\t\tif args[1]!=nil\r\n\t\t\t\tfh.seek(args[1],IO::SEEK_CUR)\r\n\t\t\tend\r\n\t\t\tresult=fh.read(args[0])\r\n\t\t\tif result!=nil and @tell!=nil\r\n\t\t\t\t@tell+=result\r\n\t\t\tend\r\n\t\t\tresult\r\n\t\tend",
"def read_file_level_settings\n cdjf = corresponding_data_json_file\n return {} if cdjf.nil?\n cdjf.read_settings\n end",
"def yardopts(file = T.unsafe(nil)); end",
"def read(_ = nil)\n as_hash(read_lines)[base_name]\n end",
"def raw_read(context)\n raw(context)\n end",
"def read(opts = {})\n Jekyll.logger.debug \"Reading:\", relative_path\n\n if yaml_file?\n @data = SafeYAML.load_file(path)\n else\n begin\n merge_defaults\n read_content(**opts)\n read_post_data\n rescue StandardError => e\n handle_read_error(e)\n end\n end\n end",
"def read( *args ) IO.read( expand_tilde, *args ) end",
"def source(file, context)\n File.read(file, file_read_opts(context))\n end",
"def read\n clean content.send(@opts[:read])\n end",
"def read_opts(file_path=nil)\n begin\n default_opts.merge!(\n deep_symbolize(YAML.load_file(file_path || config_file_path))[environment.to_sym])\n rescue Errno::ENOENT => e\n p \"[warning] config file not read, using default options\"\n default_opts\n end\n end",
"def initialize(file)\n @file = file\n @options = {}\n @original_options = {}\n read\n end",
"def try_file(opt=\"\")\n File.read(File.expand_path(opt)) rescue opt\n end",
"def read(options={})\n self.open(options) {|f|\n str = f.read\n Meta.init str, f\n str\n }\n end",
"def read_config_file(file); end",
"def read_options args={}, update_options={}\n args = {:environment => nil,\n :config_file => nil,\n :verbose => 'silent'\n }.update(args)\n\n options = {}\n\n if File.exists? @cfg_file\n vputs \"Loading '#{@cfg_file}'\", args[:verbose]\n options = load_file @cfg_file\n end\n\n if args[:config_file]\n if !File.exists? args[:config_file]\n vputs \"ERROR: Config file '#{args[:config_file]}' not found!\", args[:verbose]\n exit\n end\n vputs \"Loading '#{args[:config_file]}'\", args[:verbose]\n update_options(args[:config_file], options)\n elsif @persistent_local_cfg_file && File.exists?(@persistent_local_cfg_file)\n vputs \"Loading '#{@persistent_local_cfg_file}'\", args[:verbose]\n update_options(@persistent_local_cfg_file, options)\n elsif @local_cfg_file && File.exists?(@local_cfg_file)\n vputs \"Loading '#{@local_cfg_file}'\", args[:verbose]\n update_options(@local_cfg_file, options)\n end\n\n if args[:environment]\n vputs \"Using environment '#{args[:environment]}'\", args[:verbose]\n options = (options['default']||{}).deep_merge!(options[args[:environment]]||{})\n end\n\n options.update(update_options)\n options['environment'] = 'development' if options['environment'].nil?\n options['verbose'] = false if options['verbose'].nil?\n\n if args[:verbose] == true\n len = options.keys.map { |k| k.size }.sort.last\n vputs \"Loaded options:\", args[:verbose]\n options.each { |k, v| puts \" #{k.ljust(len)} => #{v}\" }\n end\n\n options\n end",
"def read!(read = nil)\n mutate(:read, read)\n end",
"def sysread(*rest) end",
"def sysread(*rest) end",
"def read_file_with_http_info(file_name, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: NsxComponentAdministrationApi.read_file ...\"\n end\n # verify the required parameter 'file_name' is set\n if @api_client.config.client_side_validation && file_name.nil?\n fail ArgumentError, \"Missing the required parameter 'file_name' when calling NsxComponentAdministrationApi.read_file\"\n end\n # resource path\n local_var_path = \"/node/file-store/{file-name}/data\".sub('{' + 'file-name' + '}', file_name.to_s)\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/octet-stream'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['BasicAuth']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: NsxComponentAdministrationApi#read_file\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def ext_read(opts = {})\n ext_api = ActiveExtAPI::StoreRead.new self\n ext_api.read opts\n end",
"def gather_options\n @_options\n end",
"def read\n if RubyFileReader::Reader.debug?\n puts \"[DEBUG] - #{self}##{__method__}----------------------------------------\"\n end\n\n # Determine the inode number of the file we want to read.\n @inode = `ls -i #{@pathname.to_s}`.split[0].to_i\n\n # Read the meta info file for the file we want to read.\n meta_info = read_meta_info\n\n if meta_info[:inode] != @inode\n # The inode has changed for this file since we last read it, so\n # we need to read it from the beginning.\n\n offset = 0\n\n if RubyFileReader::Reader.debug?\n puts \"[DEBUG] - #{self}##{__method__}: inode has changed!\"\n puts \"[DEBUG] - #{self}##{__method__}: offset: #{offset}\"\n end\n\n @read_string = IO.read(@pathname, nil, offset, mode: 'r')\n @read_bytes = @read_string.bytesize\n elsif @pathname.size < meta_info[:bytes_read]\n # The inode has not changed, but the file size is smaller, which means\n # the file may have been truncated at some point, so we will read the\n # while file.\n\n offset = 0\n\n if RubyFileReader::Reader.debug?\n puts \"[DEBUG] - #{self}##{__method__}: inode match. possible truncated file.\"\n puts \"[DEBUG] - #{self}##{__method__}: offset: #{offset}\"\n end\n\n @read_string = IO.read(@pathname, nil, 0, mode: 'r')\n @read_bytes = @read_string.bytesize\n else\n # The inode is the same as the last time we read it and the file size\n # is >= than last time, so we can read from where we left off.\n\n offset = meta_info[:bytes_read]\n\n if RubyFileReader::Reader.debug?\n puts \"[DEBUG] - #{self}##{__method__}: inode match\"\n puts \"[DEBUG] - #{self}##{__method__}: offset: #{offset}\"\n end\n\n @read_string = IO.read(@pathname, nil, offset, mode: 'r')\n @read_bytes = meta_info[:bytes_read] + @read_string.bytesize\n end\n\n @data_read = true\n\n if RubyFileReader::Reader.debug?\n puts \"[DEBUG] - #{self}##{__method__}: inode: #{@inode}\"\n puts \"[DEBUG] - #{self}##{__method__}: read_string: #{@read_string}\"\n puts \"[DEBUG] - #{self}##{__method__}: read_bytes #{@read_bytes}\"\n puts \"[DEBUG] - #{self}##{__method__}: data_read: #{@data_read}\"\n end\n end",
"def get\n uploaded_file(read) if read\n end",
"def open_for_read\n end",
"def read_options\n if ( request.format.csv? )\n @is_task_type = params[ :user_report ].nil?\n type = @is_task_type ? 'task' : 'user'\n @exclude_title = ! ( params[ \"include_title_#{ type }\" ] == '1' )\n end\n end",
"def fetch_options\n options = {}\n opts = GetoptLong.new(\n ['--radar-scan-path', GetoptLong::REQUIRED_ARGUMENT],\n ['--known-items-dir-path', GetoptLong::REQUIRED_ARGUMENT],\n ['--help', GetoptLong::NO_ARGUMENT]\n )\n opts.each do |opt, arg|\n options[opt] = arg\n end\n\n if options['--help']\n puts 'Usage: bin/space-radar [--radar-scan-path FILE] [--known-items-dir-path FOLDER]'\n puts 'The data files need to have the \\'txt\\' extension.'\n puts 'The default data will be used if no paths given.'\n exit 0\n end\n\n options\n end",
"def read(_file)\n fail \"Fetcher #{self} does not implement `read(...)`. This is required.\"\n end",
"def cleanup_read_params!(options)\n options = options.symbolize_keys\n ensure_read_url!(options) unless read_url_provided?(options)\n Tumblr4Rails::ReadOptions::ReadHandler.new(options).process!\n end",
"def load(reqOpts = [], &block)\n optParse(&block)\n loadFile\n requiredOptions?(reqOpts)\n end",
"def read(files); end",
"def read(files); end",
"def get_file_data(options={})\n options={ file_type: :testflow \n }.merge(options)\n fp = FileParser.new\n fp.open(filename: @filename)\n if options[:file_type] == :testflow\n @testflow_lines = fp.readlines\n elsif options[:file_type] == :limits\n @limits_lines = fp.readlines\n else\n fail \"Invalid type '#{options[:type]}' passed to 'get_file_data'!\"\n end\n fp.close()\nend",
"def read_file(file)\n File.read(file)\nend",
"def read file\n File.open file\n end",
"def read ( file, trace_dir )\n extension = File.extname(file)\n case extension\n when '.csv' then read_csv(file)\n when '.bag' then read_bag(file,trace_dir)\n else abort(\"file extension #{extension} not supported\")\n end\nend",
"def opts\n load_defaults unless @opts\n @opts\n end",
"def initialize(file, opts = {})\n load_specifics(file)\n @file = file\n @info = @raw = read\n @opts = opts\n post_initialize if respond_to?(:post_initialize)\n end",
"def opts\n @opts\n end",
"def get_file()\n puts(\"Please enter a file path: \")\n for arg in ARGV\n \tname = arg\n end\n print meta_data(name)\n name\nend",
"def set_read_file\n @read_file = ReadFile.find(params[:id])\n end",
"def read(*args)\n sync\n io.read *args\n end",
"def options(path, **args); end",
"def read_file_properties_with_http_info(file_name, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: NsxComponentAdministrationApi.read_file_properties ...\"\n end\n # verify the required parameter 'file_name' is set\n if @api_client.config.client_side_validation && file_name.nil?\n fail ArgumentError, \"Missing the required parameter 'file_name' when calling NsxComponentAdministrationApi.read_file_properties\"\n end\n # resource path\n local_var_path = \"/node/file-store/{file-name}\".sub('{' + 'file-name' + '}', file_name.to_s)\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['BasicAuth']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'FileProperties')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: NsxComponentAdministrationApi#read_file_properties\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def read(*args)\n if @content\n if args.empty?\n @content\n else\n length, outbuf = args\n raise ArgumentError, \"outbuf argument not supported since the content is already loaded\" if outbuf\n @content[0, length]\n end\n elsif is_path?\n File.open(@file, \"rb\") {|file| file.read(*args)}\n else\n @file.try(:rewind)\n @content = @file.read(*args)\n @file.try(:close) unless @file.class.ancestors.include?(::StringIO) || @file.try(:closed?)\n @content\n end\n end",
"def read\n file.read\n end",
"def read(method, path, body = {}, opts = {})\n request(READ, method, path, body, opts)\n end",
"def working_read(filename)\n data = @file_opener.open(filename, \"r\") {|f| f.read }\n data = @filters[\"encode\"].call(filename, data) if @filters[\"encode\"]\n data\n end",
"def options; @opts end",
"def ReadOpt(image, types, directions, tbr_code)\n\t\tif ($bShowDiag) then\n\t\t\tputs (\"\\n================= PROCESSING: \" + WAUtils.signature(image))\n\t\tend\n\t\t\n\t\tnames = image.split('|')\n\t\turls = Array.new()\n\t\tfiles = Array.new()\n\t\timages = Array.new()\n\t\tnames.each do |name1| \n\t\t\tname = name1.strip\n\t\t\ts = name.downcase\n\t\t\tif s.start_with?(\"http://\", \"https://\", \"ftp://\", \"file://\") then\n\t\t\t\turls.push(name)\n\t\t\telsif File.file?(name) then\n\t\t\t\tfiles.push(name)\n\t\t\telsif name.start_with?(\"data:\") or WAUtils.isBase64(name) then\n\t\t\t\timages.push(name)\n\t\t\telse\n\t\t\t\traise Exception.new(\"Invalid image source: \" + WAUtils::signature(name))\n\t\t\tend\n\t\tend\n\t\treturn self.ReadLocal(urls, files, images, types, directions, tbr_code)\n\tend",
"def readlines(*args)\n IO.readlines(@path, *args)\n end",
"def read_file(absolute_path); end",
"def yardopts(file = options_file)\n return [] unless use_yardopts_file\n File.read_binary(file).shell_split\n rescue Errno::ENOENT\n []\n end",
"def process_options\n \n end",
"def process_options\n \n end",
"def process_options\n \n end",
"def file_started(file, options); end"
] |
[
"0.9021648",
"0.8383723",
"0.82770896",
"0.8101842",
"0.7288544",
"0.7150626",
"0.6790383",
"0.6417459",
"0.63896096",
"0.63300806",
"0.6267239",
"0.6236957",
"0.62325937",
"0.6200525",
"0.61569834",
"0.60986346",
"0.6097233",
"0.6050391",
"0.6044381",
"0.5990629",
"0.59762764",
"0.59677744",
"0.59485847",
"0.5866218",
"0.58414274",
"0.5785544",
"0.57317805",
"0.5703951",
"0.56997687",
"0.56525046",
"0.56490284",
"0.5626306",
"0.56248206",
"0.56026936",
"0.55934167",
"0.5577898",
"0.5571778",
"0.5562152",
"0.55583483",
"0.5553454",
"0.5546338",
"0.55423677",
"0.5538437",
"0.5534582",
"0.5527735",
"0.5517608",
"0.55129844",
"0.55075794",
"0.54992145",
"0.5497457",
"0.54824495",
"0.54713947",
"0.5461635",
"0.54414403",
"0.5437687",
"0.5392782",
"0.5389142",
"0.5375309",
"0.5371239",
"0.5370538",
"0.5367724",
"0.5367724",
"0.53643626",
"0.5353978",
"0.53392434",
"0.5335495",
"0.5307327",
"0.5300398",
"0.52961284",
"0.529295",
"0.5290485",
"0.52802265",
"0.5276176",
"0.5274127",
"0.5274127",
"0.5271585",
"0.5269382",
"0.52574956",
"0.5249498",
"0.5243915",
"0.52316153",
"0.5210225",
"0.519814",
"0.51967514",
"0.5192272",
"0.51860666",
"0.5185815",
"0.5181849",
"0.5176449",
"0.5171413",
"0.5169463",
"0.5169122",
"0.5168001",
"0.5161415",
"0.5157659",
"0.5152604",
"0.5133023",
"0.5133023",
"0.5133023",
"0.5119282"
] |
0.83096886
|
2
|
This method allows to modify the file content by inheriting from the class.
|
def source(file, context)
File.read(file, file_read_opts(context))
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def content= content\n @file = content\n @content = content.dup\n @content &&= @content.read if @content.respond_to? :read\n @content &&= @content.to_s if @content.respond_to? :read\n end",
"def render\n File.open(@file.output_path, \"w\") { |file| file.write(super) }\n end",
"def update(params = {})\n file = params.delete(:file)\n if file\n self.filename = sanitize_filename(file.original_filename)\n self.content_type = file.content_type\n self.file_contents = file.read\n end\n super\n end",
"def initialize(input_file)\n\t\tsuper(input_file)\n\t\t\n\tend",
"def modify\n super\n end",
"def initialize(params = {})\n @file = params.delete(:filecontents)\n super\n if @file\n self.filename = sanitize_filename(@file.original_filename)\n self.filetype = @file.content_type\n self.filecontents = @file.read\n end\n end",
"def file=(_); end",
"def parse file_contents\n raise NRSER::AbstractMethodError.new self, __method__ \n end",
"def file; end",
"def file; end",
"def file; end",
"def file; end",
"def file; end",
"def file; end",
"def file; end",
"def file; end",
"def file; end",
"def file; end",
"def file; end",
"def reopen_file!\n @file_contents = FileContents.new(file_path, @file_metadata)\n end",
"def output\n super(@file_format => @file_path)\n end",
"def update_file_content(new_content)\n return false if new_content.nil?\n self.file_content = new_content\n self.save\n end",
"def update_file_content(new_content)\n return false if new_content.nil?\n self.file_content = new_content\n self.save\n end",
"def guess(file)\n super(file)\n end",
"def edit_file(filename, content, options={})\n end",
"def edit_with_rexml\n require 'rexml/document'\n doc = REXML::Document.new(read)\n yield doc if block_given?\n self.content = doc.to_s\n save\n end",
"def modify_file\n file_path = \"./app/views/hocr_files/_p#{self.filename}_hocr.html\"\n file = File.open(file_path, \"r\")\n data = file.read\n data = self.replace_bbox(data)\n data = self.add_image(data)\n File.open(file_path, 'w') {|f| f.write(data) }\n end",
"def process(orig_file)\n end",
"def content_file=(file_path)\n if File.exist?(file_path)\n s = File.size(file_path)\n if s > 0\n self.size = s\n self.content_type = %x[ file -ib \"#{file_path}\" ].strip\n self.filename = File.basename(file_path)\n self.content = File.read(file_path)\n true\n else\n false\n end\n else\n false\n end\n end",
"def update_file_content(new_content)\n return false if new_content.nil?\n self.file_content = new_content\n return self.save\n end",
"def file\n end",
"def file\n end",
"def initialize(filename)\n super(filename);\n @@this = self;\n end",
"def doManipulation(contents); raise \"Abstract Exception: doManipulation must be extended\"; end",
"def read(path)\n return super unless password_file\n\n #@content = wrapped_class.new(::File.read(path), password)\n @content = wrapped_class.new(::File.read(path), password)\n end",
"def initialize(params = {})\n @file = params.delete(:file)\n super\n if @file\n self.filename = sanitize_filename(@file.original_filename)\n self.content_type = @file.content_type\n self.file_contents = @file.read\n end\n end",
"def inherited(subclass)\n super\n\n subclass.serialization.replace serialization\n subclass.fields.replace fields\n end",
"def extension(file)\n super\n end",
"def file=(filename)\n File.open(filename) do |f|\n self.text = f.read\n end\n self.text\n end",
"def content=(value)\n self.temp_files = [value].flatten.select do |f|\n FILE_CLASSES.member?(f.class.name)\n end\n # correctly triggering dirty\n if temp_files.present?\n write_attribute(:content, nil)\n content_will_change!\n else\n write_attribute(:content, value)\n end\n end",
"def update!\n parse\n return true if skipped?\n attributes = Attributes.new klass, @blocks[:attributes]\n attributes.update!\n @blocks[:attributes] = attributes.lines\n update_file\n end",
"def uploaded_file=(file_field)\n self.filename = base_part_of(file_field.original_filename)\n\n f_str = Iconv.conv('utf-8', self.encoding, file_field.read)\n\n f = StringIO.new(f_str)\n\n if self.format == 'OBT'\n it = OBNOTextIterator.new(f, self.sentence_delimiter == 'delimiter')\n elsif self.format == 'VRT'\n it = VRTReader.new(f)\n else\n raise RuntimeError\n end\n\n it.each_sentence {|s| sentences << s}\n f.close()\n\n # add postamble stored in iterator after parsing last sentence\n # TODO add support for arbitrary data for OBT format\n if self.format = 'VRT'\n self.postamble = it.postamble\n end\n end",
"def filename\n super\n end",
"def data\n raise NotImplementedError.new(\"data() must be implemented by subclasses of AbstractVersionedFile.\")\n end",
"def internal_file_attributes=(_arg0); end",
"def contents=(new_contents)\n debug(\"#{self.class.name}#contents= called, going to update containing model's #{attr_name}\")\n @contents = new_contents\n write\n end",
"def internal_file_attributes; end",
"def content\n @content = File.read(path)\n end",
"def write!(_)\n raise NotImplementedError, 'Implement #write! in child class'\n end",
"def initialize(file_content)\n # Set TXT file\n self.fichero = file_content\n # Initialize attribute default values\n self.lista_cobros = []\n end",
"def initialize(content)\n @content = content\n super()\n end",
"def file=(file)\n self.data = file\n dis_set :content_type, file.content_type\n dis_set :filename, file.original_filename\n end",
"def initialize(params = {})\n file = params.delete(:file)\n super\n if file\n self.filename = sanitize_filename(file.original_filename)\n self.content_type = file.content_type\n self.file_contents = file.read\n self.file_size = file.size\n end\n end",
"def value\n super || file\n end",
"def update_file\n output = (@blocks[:before] + @blocks[:attributes] + @blocks[:after]).join(\"\\n\").strip + \"\\n\"\n File.open(@filename,'w') { |f| f.write(output) } if output != @file\n end",
"def file_content\n self.lines.join\n end",
"def va_file\n super\n end",
"def set_content\n unless compare_content\n description = []\n description << \"update content in file #{@new_resource.path} from #{short_cksum(@current_resource.checksum)} to #{short_cksum(new_resource_content_checksum)}\"\n description << diff_current_from_content(@new_resource.content) \n converge_by(description) do\n backup @new_resource.path if ::File.exists?(@new_resource.path)\n ::File.open(@new_resource.path, \"w\") {|f| f.write @new_resource.content }\n Chef::Log.info(\"#{@new_resource} contents updated\")\n end\n end\n end",
"def content\n return IO.read(@file)\n end",
"def genFileContent(cls, bld)\r\n end",
"def initialize(filename)\n super(filename, EXT)\n end",
"def initialize(filename)\n super(filename, EXT)\n end",
"def initialize(top_level, file_name, content, options, stats)\n super\n\n preprocess = RDoc::Markup::PreProcess.new @file_name, @options.rdoc_include\n\n @content = preprocess.handle @content, @top_level\n end",
"def initialize\n @contents = []\n @open = true\n end",
"def initialize\n\t\t@contents = []\n\t\t@open = true\n\tend",
"def initialize\n\t\t@contents = []\n\t\t@open = true\n\tend",
"def initialize\n\t\t@contents = []\n\t\t@open = true\n\tend",
"def initialize\n\t\t@contents = []\n\t\t@open = true\n\tend",
"def initialize\n\t\t@contents = []\n\t\t@open = true\n\tend",
"def initialize\n\t\t@contents = []\n\t\t@open = true\n\tend",
"def initialize\n\t\t@contents = []\n\t\t@open = true\n\tend",
"def initialize\n\t\t@contents = []\n\t\t@open = true\n\tend",
"def initialize\n\t\t@contents = []\n\t\t@open = true\n\tend",
"def initialize\n\t\t@contents = []\n\t\t@open = true\n\tend",
"def initialize\n\t\t@contents = []\n\t\t@open = true\n\tend",
"def initialize\n\t\t@contents = []\n\t\t@open = true\n\tend",
"def initialize\n\t\t@contents = []\n\t\t@open = true\n\tend",
"def initialize\n\t\t@contents = []\n\t\t@open = true\n\tend",
"def initialize\n\t\t@contents = []\n\t\t@open = true\n\tend",
"def file_content(action)\n options = {\n source: @base_file,\n language: @language,\n file_type: @file_type\n }\n if action == \"update\"\n options[:target] = get_file\n @new_file = FileContent.new(options).update_file \n else\n @new_file = FileContent.new(options).generate_file\n end\n end",
"def set(file)\n self.file = file\n end",
"def extract_each_from(file_contents)\n raise NotImplementedError,\n \"#{__method__} must be implemented by derived classes.\"\n end",
"def file\n add FileCursor.new\n end",
"def changeset\n raise NotImplementedError.new(\"changeset() must be implemented by subclasses of AbstractVersionedFile.\")\n end",
"def parse\n parse_file\n self\n end",
"def contents\n # give the string contents of the file\n @file.seek 0\n @file.read @filesize\n end",
"def accept(visitor)\n visitor.visit_file(self)\n end",
"def initialize(file)\n super\n @io = IRB::MagicFile.open(file)\n @external_encoding = @io.external_encoding\n end",
"def initialize\n\t\t\t@contents = []\n\t\t\t@is_open = true\n\t\tend",
"def initialize(path)\n @path = path\n @content = File.read(path)\n end",
"def content!\n @raw = nil # force to reload it\n self.content\n end",
"def get_content()\n return super()\n end",
"def customize_file(user_id, filename)\n\t handle = File.open(filename, 'r')\n\t content = handle.read\n\t \n\tend",
"def initialize(object, file)\n super(object, file)\n @name = object.name\n @parent_class = object.parent_class\n end",
"def update_content(file, relation = :original_file)\n IngestJob.perform_later(wrapper!(file: file, relation: relation), notification: true)\n end",
"def initialize(file_name, file_contents, log_lines = false, parse_signatures = false)\n\n # set up basic options and defaults\n self.file_name = file_name\n self.file_contents = file_contents\n self.file_ext = File.extname(file_name)\n self.parts = []\n self.lines = 0\n @@log_lines = log_lines\n @@parse_signatures = parse_signatures\n\n # set the doc type based on extension\n case self.file_ext\n when '.rb'\n self.type = :RUBY\n when '.md', '.txt', '.markdown', '.mdown'\n self.type = :MARKDOWN\n end\n\n # set parser with file type\n self.parser = Rain::Parser.new(self.type)\n\n # set the default title to the proper-case file name\n # without the extension and underscores/dashes\n self.title = self.file_name.sub(self.file_ext, '')\n self.title.gsub!(/_|-/, ' ')\n\n # very simple proper-caser\n self.title.gsub!(/\\w+/) { |word| word.capitalize }\n end",
"def set_file_from_raw_data\n self.status = 'archived'\n self.file = ActionDispatch::Http::UploadedFile.new(filename: filename, tempfile: tempfile_for_filedata)\n end",
"def initialize(object, file)\n super(object, file)\n @name = object.name\n end",
"def initialize(object, file)\n super(object, file)\n @name = object.name\n end",
"def file=(file_data)\n return nil if file_data.nil? || file_data.size == 0 \n self.assign_type file_data.content_type\n self.location = file_data.original_filename if respond_to?(:location)\n if file_data.is_a?(StringIO)\n file_data.rewind\n self.temp_data = file_data.read\n else\n self.temp_path = file_data.path\n end\n @save_attachment = true\n end",
"def file=(f)\n @file = f\n @internal = nil # force reload\n @file\n end"
] |
[
"0.68086666",
"0.65491617",
"0.63522345",
"0.62686956",
"0.616935",
"0.61292666",
"0.60146105",
"0.6005256",
"0.6002504",
"0.6002504",
"0.6002504",
"0.6002504",
"0.6002504",
"0.6002504",
"0.6002504",
"0.6002504",
"0.6002504",
"0.6002504",
"0.6002504",
"0.59984416",
"0.5993044",
"0.5985594",
"0.5985594",
"0.59848624",
"0.5981277",
"0.5965913",
"0.59527636",
"0.59422827",
"0.59125066",
"0.5885935",
"0.5884658",
"0.5884658",
"0.5873545",
"0.5870129",
"0.584088",
"0.58400756",
"0.5839155",
"0.5837447",
"0.58269435",
"0.5821372",
"0.5803832",
"0.58005697",
"0.5798238",
"0.5788131",
"0.5771595",
"0.57613236",
"0.57470566",
"0.5743331",
"0.57388",
"0.57314813",
"0.57303065",
"0.5707937",
"0.5689932",
"0.5681604",
"0.56788635",
"0.56763375",
"0.56742406",
"0.5667512",
"0.5666011",
"0.5652076",
"0.56519395",
"0.56519395",
"0.56467503",
"0.5645852",
"0.563905",
"0.563905",
"0.563905",
"0.563905",
"0.563905",
"0.563905",
"0.563905",
"0.563905",
"0.563905",
"0.563905",
"0.563905",
"0.563905",
"0.563905",
"0.563905",
"0.5638465",
"0.5635777",
"0.5633814",
"0.56303406",
"0.562792",
"0.5623155",
"0.56119543",
"0.56068486",
"0.5604484",
"0.5604332",
"0.55742913",
"0.5572333",
"0.55721176",
"0.5572048",
"0.5561227",
"0.55601364",
"0.55599123",
"0.5559844",
"0.555725",
"0.55555624",
"0.55555624",
"0.55438167",
"0.554366"
] |
0.0
|
-1
|
GET /post_parts GET /post_parts.json
|
def index
@post_parts = PostPart.all
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def parts\n body.parts\n end",
"def parts\n @audio_file = AudioFile.find(params[:id])\n @parts = @audio_file.parts\n\n respond_to do |format|\n format.html # parts.html.erb\n format.xml { render :xml => @parts }\n format.json { render :json => @parts }\n end\n end",
"def show\n @part = @product.parts.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @part }\n end\n end",
"def parts\n @parts\n end",
"def show\n @job = Job.find(params[:job_id])\n @part = @job.parts.find(params[:id])\n\n respond_to do |format|\n format.html\n format.json {render json: @part}\n end\n end",
"def create\n @post_part = PostPart.new(post_part_params)\n\n respond_to do |format|\n if @post_part.save\n format.html { redirect_to @post_part, notice: 'Post part was successfully created.' }\n format.json { render :show, status: :created, location: @post_part }\n else\n format.html { render :new }\n format.json { render json: @post_part.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n @part = Part.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @part }\n end\n end",
"def index\n @parts = @chaper.parts\n end",
"def __endpoint_parts\n parts = @spec['url']['paths'].select do |a|\n a.keys.include?('parts')\n end.map do |path|\n path&.[]('parts')\n end\n (parts.inject(&:merge) || [])\n end",
"def parts; end",
"def parts; end",
"def parts; end",
"def index\n story_parts_words = {}\n story_parts = StoryPart.where(params[:story_id])\n # iterate through story parts to find word. Create story_part/word association to be passed into json data\n story_parts.each do |story_part|\n story_word_array = []\n story_word_array.push(story_part)\n story_word_array.push(story_part.word)\n story_parts_words[story_part.id] = story_word_array\n end\n \n render :json => story_parts_words\n end",
"def list_parts(options = {})\n result = client.bucket_list_parts(upload_id, key, options)\n .parsed_response\n\n parts_keys = %w(ListPartsResult Part)\n Utils.wrap(Utils.dig_value(result, *parts_keys)).map do |part|\n Struct::Part.new(part)\n end\n end",
"def get_mmsparts()\n return @api.do_request(\"GET\", get_base_api_path() + \"/mms_parts\")\n end",
"def get_mmsparts()\n return @api.do_request(\"GET\", get_base_api_path() + \"/mms_parts\")\n end",
"def render\n parts.map(&:content)\n end",
"def index\n #@parts = Part.find(:all, :order => 'part_number')\n\t@used_parts = UsedPart.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @used_parts }\n end\n end",
"def get_part_by_company_part\n @parts = PartsController::PartService.get_part_by_company_part(params[:param_part])\n if !@parts.nil?\n respond_to do |format|\n format.json{ render json: @parts}\n end \n else\n #não foi encontrado as informacoes\n end\n\tend",
"def get_part_by_category\n @categorys = PartsController::PartService.get_part_by_category(params[:param]);\n respond_to do |format|\n format.json { render json: @categorys }\n end \n end",
"def path_part(part)\n @_path_parts ||= app.blog.drafts.path_matcher.match(path).captures\n\n @_path_parts[app.blog.drafts.matcher_indexes[part]]\n end",
"def show\n @medium_body_part = MediumBodyPart.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @medium_body_part }\n end\n end",
"def post_part_params\n params.require(:post_part).permit(:heading, :body, :price, :neighborhood, :external_url, :timestamp)\n end",
"def set_post_part\n @post_part = PostPart.find(params[:id])\n end",
"def parts\n product.parts\n end",
"def parts\n product.parts\n end",
"def new\n @part = Part.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @part }\n end\n end",
"def new\n @part = Part.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @part }\n end\n end",
"def show\n @part_name = PartName.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @part_name }\n end\n end",
"def show\n @used_part = UsedPart.find(params[:id])\n prepFormVariables\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @used_part}\n end\n end",
"def index\n @parts = Part.preload(:job)\n end",
"def index\n #@part_names = PartName.find(:all, :order => 'name')\n\t@part_names = PartName.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @part_names }\n end\n end",
"def parts(url, path_based_params=false)\n return {} unless url\n\n # Parse out the URL parts\n parts = parse_url url\n\n return {} if not parts\n\n params = {}\n # Parse out the param-based parts\n if parts['query']\n pairs = parts['query'].split '&'\n pairs.each do |pair|\n key,value = pair.split '='\n value = CGI::unescape value.to_s\n params[key] = value\n end\n end\n # Parse bath-based URL params\n if path_based_params\n if parts['path']\n pairs = parts['path'].split '/'\n pairs.each do |pair|\n if pair.include? '='\n key,value = pair.split '='\n value = CGI::unescape value\n params[key] = value\n end\n end\n end\n end\n parts['params'] = params\n\n return parts\n end",
"def get_part(args)\n return send(args[:page]).send(args[:part][:locate])[args[:part][:num]] if part_plural?(args)\n\n send(args[:page]).send(args[:part])\n end",
"def part_params\n params.require(:part).permit(:name, :body, :user_id)\n end",
"def feed_parts\n\t\t[\n\t\t\t{:en_name => 'answers', :ru_name => 'Ответы', :description => 'Ответы на сообщения и комментарии', :path => '/feed?part=answers'},\n\t\t\t{:en_name => 'comments', :ru_name => 'Комментарии', :description => 'Комментарии к фото и видео', :path => '/feed?part=comments'},\n\t\t\t{:en_name => 'themes', :ru_name => 'Темы', :description => 'Новые темы, сообщения в ослеживаемых темах', :path => '/feed?part=themes'},\n\t\t\t{:en_name => 'articles', :ru_name => 'Материалы', :description => 'Новые статьи', :path => '/feed?part=articles'},\n\t\t\t{:en_name => 'videos', :ru_name => 'Видео', :description => 'Новые видео', :path => '/feed?part=videos'},\n\t\t\t{:en_name => 'albums', :ru_name => 'Фотоальбомы', :description => 'Новые альбомы и обновления в альбомах', :path => '/feed?part=albums'}\n\t\t]\n\tend",
"def fetch_page_part(name, part, options = {})\n fetch('/page/%s/%s' % [name, part], options)\n end",
"def index\n @post = find_post\n @post_sections = @post.sections\n end",
"def get_part\n @part\n end",
"def parts\n @body.xpath('./a:part', a: NS)\n end",
"def show\n if can?(:>=, \"3\")\n @part = Kitting::Part.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @part }\n end\n else\n redirect_to main_app.unauthorized_url\n end\n end",
"def part_params\n params[:part].permit(\"part_id\", \"name\")\n end",
"def show\r\n @theoretical_part = TheoreticalPart.find(params[:id])\r\n\r\n respond_to do |format|\r\n format.html # show.html.erb\r\n format.json { render json: @theoretical_part }\r\n end\r\n end",
"def create\n @part = Part.new(params[:part])\n\n respond_to do |format|\n if @part.save\n format.html { redirect_to @part, :notice => 'Part was successfully created.' }\n format.json { render :json => @part, :status => :created, :location => @part }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @part.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def index\n @parts = Part.where(job_id: params[:job_id])\n @job_id = params[:job_id]\n end",
"def all_page_part_content\n parts.map(&:body).join \" \"\n end",
"def show\n\t\t@part = Part.find(params[:id])\n# \t\t@product = Product.find(@part.product_id)\n\t\t@supplier = Supplier.find(@part.supplier_id)\n\t\t\n\t\trespond_to do |format|\n\t\tformat.html # show.html.erb\n\t\tformat.json { render json: @part }\n\t\tend\n\tend",
"def index\n @parts = Part.search(params[:search]).paginate(:page => params[:page], :per_page => 30)\n end",
"def feed_parts\n\t\t[\n\t\t#\t{:en_name => 'answers', :ru_name => 'Ответы', :description => 'Ответы на сообщения и комментарии', :path => '/feed?part=answers'},\n {:en_name => 'themes', :ru_name => 'Темы', :description => 'Новые темы в интересующих разделах', :path => '/feed?part=themes'},\n {:en_name => 'messages', :ru_name => 'Сообщения', :description => 'Новые сообщения в отслеживаемых разделах', :path => '/feed?part=messages'},\n\t\t\t{:en_name => 'comments', :ru_name => 'Комментарии', :description => 'Комментарии к фото и видео', :path => '/feed?part=comments'},\n\t\t\t{:en_name => 'videos', :ru_name => 'Видео', :description => 'Новые видео', :path => '/feed?part=videos'},\n\t\t\t{:en_name => 'albums', :ru_name => 'Фотоальбомы', :description => 'Новые альбомы и обновления в альбомах', :path => '/feed?part=albums'},\n\t\t\t{:en_name => 'articles', :ru_name => 'Материалы', :description => 'Новые статьи', :path => '/feed?part=articles'}\t\n\t\t]\n\tend",
"def update\n respond_to do |format|\n if @post_part.update(post_part_params)\n format.html { redirect_to @post_part, notice: 'Post part was successfully updated.' }\n format.json { render :show, status: :ok, location: @post_part }\n else\n format.html { render :edit }\n format.json { render json: @post_part.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @part = @product.parts.new(params[:part])\n\n respond_to do |format|\n if @part.save\n format.html { redirect_to [@product,@part], notice: 'Part was successfully created.' }\n format.json { render json: [@product,@part], status: :created, location: [@product,@part] }\n else\n format.html { render action: \"new\" }\n format.json { render json: @part.errors, status: :unprocessable_entity }\n end\n end\n end",
"def path_part(part)\n @_path_parts ||= Blog::UriTemplates.extract_params(blog_data.source_template, path)\n @_path_parts[part.to_s]\n end",
"def show\n @toyota_epc_part_number_list_child = ToyotaEpc::PartNumberListChild.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @toyota_epc_part_number_list_child }\n end\n end",
"def index\n @part_details = PartDetail.all\n end",
"def show\n @vendor_part = VendorPart.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @vendor_part }\n end\n end",
"def index\n @parts_for_proposal = PartsForProposal.all\n end",
"def index\n if params[:part_id]\n @materials = Material.find(:all, :conditions => [\"part_id = ?\", params[:part_id]])\n else\n @materials = Material.all\n end\n respond_to do |format|\n format.html\n format.json { render :json => @materials }\n end\n end",
"def getParts (boundary, body)\n parts = [ ]\n valid = false\n\n while 1\n position = body.index(\"--\" + boundary)\n\n break if position != 0 or position == nil\n\n follow = body.slice(position + boundary.length + 2, 2)\n\n break if follow != \"\\r\\n\" and follow != \"--\"\n\n if follow == \"--\"\n valid = true\n break\n end if\n\n # strip boundary start from body\n body = body.slice(position + boundary.length + 4, body.length)\n \n # look for boundary end\n final = body.index(\"--\" + boundary)\n\n break if final == nil\n\n # extract the part\n partTotal = body.slice(0, final)\n\n # look for envelope bounds\n position = partTotal.index(\"\\r\\n\\r\\n\");\n break if position == nil\n\n\n r = Regexp.new('content-id: ([^\\s]+)', Regexp::IGNORECASE)\n \n if r.match(partTotal.slice(0, position))\n contentId = Regexp.last_match(1)\n else\n contentId = \"\"\n end\n\n\n # strip envelope\n partTotal = partTotal.slice(position + 4, partTotal.length)\n\n # look for actual header & body\n partHeader, partBody = \"\", \"\"\n position = partTotal.index(\"\\r\\n\\r\\n\");\n\n break if position == nil\n \n partHeader = partTotal.slice(0, position)\n partBody = partTotal.slice(position + 4, partTotal.length)\n\n partHeaders = { }\n status = 500\n lineNumber = 0\n\n # parse headers and status code\n\n partHeader.each_line(\"\\r\\n\") do |line|\n if lineNumber == 0\n position = line.index(\"HTTP/1.1 \")\n break if position == nil\n status = line.slice(9, 3).to_i\n else\n key, void, value = line.partition(\":\")\n partHeaders[key.strip] = value.strip\n end\n lineNumber = lineNumber + 1\n end\n\n part = { :headers => partHeaders, :body => partBody, :status => status, :contentId => contentId }\n parts.push(part)\n\n body = body.slice(final, body.length)\n end\n\n if not valid\n raise \"invalid multipart response received\"\n end\n\n parts\n end",
"def create\n @part = Part.new(params[:part])\n\n respond_to do |format|\n if @part.save\n format.html { redirect_to @part, notice: 'Part was successfully created.' }\n format.json { render json: @part, status: :created, location: @part }\n else\n format.html { render action: \"new\" }\n format.json { render json: @part.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @part = Part.new(part_params)\n\n respond_to do |format|\n if @part.save\n format.html { redirect_to \"/parts?search=#{@part.part_number}\", notice: 'Part was successfully created.' }\n format.json { render :show, status: :created, location: @part }\n else\n format.html { render :new }\n format.json { render json: @part.errors, status: :unprocessable_entity }\n end\n end\n end",
"def parts\n @descriptive_detail.parts\n end",
"def content_for(part_slug)\n part_with_slug(part_slug).try(:body)\n end",
"def index\n @job_parts = JobPart.all\n end",
"def index\n @subparts = Subpart.all\n end",
"def index\n @image_to_parts = ImageToPart.all\n end",
"def index\n @order_parts = OrderPart.all\n end",
"def parts\n prefix, parts = split_names(@path)\n prefix.empty? ? parts : [prefix] + parts\n end",
"def show\n @medium_body_part_inv = MediumBodyPartInv.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @medium_body_part_inv }\n end\n end",
"def show\n #@parts = Part.find_by(id: @technique.part_id)\n @parts = Part.find(@technique.part_id)\n end",
"def new\n @medium_body_part = MediumBodyPart.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @medium_body_part }\n end\n end",
"def index\n if current_user.luna?\n respond_to do |format|\n format.html do\n @parts = Part.order(\"#{lowered_column} #{sort_direction}, id DESC\").page(params[:page]).per_page(Constants::PER_PAGE)\n end\n format.json do\n render json: Part.all_as_json\n end\n end\n else\n redirect_to(logout_path)\n end\n end",
"def show\n @reports_part = ReportsPart.find(params[:id])\n\n render json: @reports_part\n end",
"def index\n @part_attributes = PartAttribute.all\n end",
"def parts( format )\n @parts[format.to_s] ||= file ? @storage.find_page_parts( file, @lang, format.to_s ) : {}\n end",
"def index\n @partners = Partner.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @partners }\n end\n end",
"def index\n if params[:fulldoc].nil? then\n @singleparts = Singlepart.all\n else\n @singleparts = Singlepart.where(['fulldoc_id = ?', params[:fulldoc]])\n end\n end",
"def index\n @art_posts = ArtPost.all\n\n render json: @art_posts\n end",
"def index\n @post_ingredients = @post.post_ingredients\n end",
"def index\n @inventory_parts = InventoryPart.all\n prepFormVariables\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @inventory_parts }\n end\n end",
"def bodypart_params\n params.require(:bodypart).permit(:name, :img)\n end",
"def index\n @parties = Party.order(:name).all\n\n respond_to do |format|\n format.html\n format.json { render json: @parties }\n format.xml { render xml: @parties }\n end\n end",
"def list_parts(bucket_name, key, upload_id, options={})\n params = { uploadId: upload_id }\n params.merge! options\n send_request(GET, bucket_name, params, key)\n end",
"def show\n @foobar = Foobar.find(params[:id])\n \n @paragraphbuilder = @foobar.content.split(\"\\r\\n\")\n \n @paragraphbuilder.each do |paragraph|\n puts paragraph\n end \n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @foobar }\n \n \n end\n end",
"def show\n @voice_part = VoicePart.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @voice_part }\n end\n end",
"def get_available_multipart_form_parts(form_name, last_completed_part)\n add_parts = true\n parts = []\n # loop over the parts\n self.multipart_forms[form_name][:parts].each do |part|\n if( add_parts && !part.match(/_update$/) )\n parts << { :name => part, :number => parts.length + 1 }\n end\n if !ActsAsMultipartForm.config.show_incomplete_parts && part.to_s == last_completed_part.to_s\n add_parts = false \n end\n end\n return parts\n end",
"def index\n @parts = Part.order(:created_at)\n end",
"def show\n @page = Page.find(params[:id], include: [:attachments, :business])\n @posts = @page.posts.select('id, title, slug, price, photo, created_at')\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @page }\n end\n end",
"def part\n \"#{path.chomp('.part')}.part\"\n end",
"def show\n @partextras = Partextra.all\n end",
"def new\r\n @theoretical_part = TheoreticalPart.new\r\n\r\n respond_to do |format|\r\n format.html # new.html.erb\r\n format.json { render json: @theoretical_part }\r\n end\r\n end",
"def destroy\n @post_part.destroy\n respond_to do |format|\n format.html { redirect_to post_parts_url, notice: 'Post part was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def show\n @part = Part.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @part }\n end\n end",
"def show\n respond_to do |format|\n par = []\n @blogger.paragraphs.each do |para|\n para_details = {\n id: para.id,\n data: para.data,\n comments: para.comments.collect{ |dat| dat.body } \n }\n par << para_details\n end\n blog_json = {\n id: @blogger[:id],\n title: @blogger[:title],\n author: @blogger[:author],\n paragraph_details: par\n }\n \n format.json { render json: blog_json, status: :ok, location: @blogger }\n \n end\n end",
"def index\n @post_prod_dpts = PostProdDpt.all\n\n render json: @post_prod_dpts\n end",
"def part_params\n params.require(:part).permit(:description, :image_url, :pdf_url, :manufacturer, :part_number, :part_type, :quantity_in_stock, :specs)\n end",
"def parts\n @doc.content_types.parts Slide::CONTENT_TYPE\n end",
"def list_parts\n # if @@parts == nil\n # @@parts = ZAutoParts::Deal.today\n # #this is a little trick by putting the (1) we don't have to put -1, it starts the index at 1.\n # # @@parts.each.with_index(1) do |part, i|\n # # puts \"#{i}. #{part.name.colorize(:blue)} - #{part.price}\"\n # tp @@parts, :number, {:name => {:width => 50}}, :price\n # # binding.pry\n # # end\n # else\n tp self.parts, :number, {:name => {:width => 50}}, :price\n # @@parts.each.with_index(1) do |part, i|\n # puts \"#{i}. #{part.name.colorize(:blue)} - #{part.price}\"\n # end\n # end\n end",
"def get(path_part, additional_headers = {}, &block)\n api_request { @rest.get('/REST/' + path_part, nil, additional_headers, &block) }\n end",
"def index\n @tool_parts = ToolPart.includes{tool_part_items}.accessible_by(current_ability).search(params[:search]).page(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tool_parts }\n format.xml { render xml: @tool_parts }\n end\n end",
"def all_page_part_content\n\t content = \"\"\n\t \n\t self.parts.each do |part|\n\t content << \" #{part.body}\"\n\t end\n\t \n\t content\n\tend"
] |
[
"0.64217854",
"0.6355506",
"0.6234015",
"0.61558855",
"0.61489296",
"0.61131287",
"0.6068686",
"0.6002622",
"0.598498",
"0.59259564",
"0.59259564",
"0.59259564",
"0.5896",
"0.58364743",
"0.5834151",
"0.5834151",
"0.5785025",
"0.57775843",
"0.5747439",
"0.57305986",
"0.5730596",
"0.571725",
"0.571342",
"0.5617548",
"0.5595707",
"0.5595707",
"0.5595242",
"0.5591653",
"0.5564891",
"0.55584246",
"0.5553817",
"0.5531579",
"0.5469665",
"0.5467179",
"0.54644656",
"0.5464266",
"0.5461271",
"0.5452753",
"0.5444511",
"0.5433448",
"0.54286367",
"0.5419403",
"0.54155993",
"0.5383172",
"0.53721714",
"0.5357376",
"0.5339659",
"0.5332562",
"0.53272027",
"0.5320427",
"0.5318686",
"0.53159505",
"0.52881926",
"0.5285614",
"0.52595115",
"0.5253353",
"0.525094",
"0.5242943",
"0.524054",
"0.523741",
"0.5235015",
"0.522927",
"0.5220167",
"0.521095",
"0.5204322",
"0.5187433",
"0.5176427",
"0.51685363",
"0.5166172",
"0.5153369",
"0.5136943",
"0.51339954",
"0.5127391",
"0.51252043",
"0.5124062",
"0.51231444",
"0.51223445",
"0.5117196",
"0.5116961",
"0.5112469",
"0.5100042",
"0.5092483",
"0.50869",
"0.5069286",
"0.50636905",
"0.5061213",
"0.5061053",
"0.5058382",
"0.50537115",
"0.5048668",
"0.50462425",
"0.5041937",
"0.5016766",
"0.5013769",
"0.50058234",
"0.5005328",
"0.5001449",
"0.49963313",
"0.49904513",
"0.4982121"
] |
0.6966223
|
0
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.