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
== Metodo suma Dispersa
def +(other) #if ((other.class.to_s == "Dispersa") && (other.fil == @fil) && (other.col == @col)) matrizSuma = Array.new(@fil) {Array.new(@col) {0}} 0.upto(@numElementos - 1) do |i| matrizSuma[@filM[i]][@colM[i]] = @eleM[i] end 0.upto(other.numElementos - 1) do |i| matrizSuma[other.filM[i]][other.colM[i]] += other.eleM[i] end #puts "suma = #{matrizSuma}" return matrizSuma #else #raise ArgumentError, "Matrices de distinto tamanio" #end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def posti_disponibili\n self.vehicle.posti - self.n_passeggeri\n end", "def total\n # Calculo el total sin descuentos\n self.total_prize = @products.map {|p| p.prize }.inject :+\n\n # Aplico todos los descuentos dinamicamente\n @discounts.each do |discount|\n discount.call self\n end\n\n self.total_prize # Retorno el precio final\n end", "def totalSimplificado\n @biblioteca.livrosComoLista.map(&:preco).inject(0){|total, preco| total += preco}\n end", "def suma\n importe = 0\n if params[:depositocaucion_ids].blank? \n else \n params[:depositocaucion_ids].each { |item_id|\n item = Depositocaucion.find(item_id.to_i)\n params[:idcheque] = item.chequetercero_id\n @buscaimportes = Depositocaucion.buscaimporte(params[:idcheque])\n imp = 0\n @buscaimportes.each {|i| imp = imp + i.importe.to_d }\n importe = importe + imp\n }\n end \n params[:importe] = importe \n render :partial => \"suma\"\n end", "def apport_calorique(repas)\n @calrep = 0\n #on fait la somme des calories acquises ce jour\n repas.each do |r|\n @calrep += r.calories\n end\n @calrep.round\n end", "def sum_produits_assoc\n # TODO URGENT facture 46 la valeur renvoyee est fausse\n sum = 0\n # logger.error \"facture : #{self.id}\"\n self.protofactures.each do |p| \n # logger.error \"produit #{p.produit.name}\"\n # logger.error \"\\tquantite: #{p.quantite}\"\n # logger.error \"\\tused: #{p.get_used}\"\n # logger.error \"\\tstock: #{p.quantite - p.get_used}\"\n sum += p.prix_unit * p.quantite\n end\n # logger.error \"\\tsum_produits_assoc : #{sum}\"\n sum\n end", "def sumar_insumo(nombreInsumo, cantidad)\n\t\tcase nombreInsumo\n\t\t\twhen \"cebada\" then (@cebada += cantidad)\n\t\t\twhen \"arroz_maiz\" then (@arroz_maiz += cantidad)\n\t\t\twhen \"levadura\" then (@levadura += cantidad)\n\t\t\twhen \"lupulo\" then (@lupulo += cantidad)\n\t\t\twhen \"producto_silos_cebada\" then \n\t\t\t\t(@producto_silos_cebada += cantidad)\n\t\t\twhen \"producto_molino\" then \n\t\t\t\t(@producto_molino += cantidad)\n\t\t\twhen \"producto_paila_mezcla\" then \n\t\t\t\t(@producto_paila_mezcla += cantidad)\n\t\t\twhen \"producto_cuba_filtracion\" then \n\t\t\t\t(@producto_cuba_filtracion += cantidad)\n\t\t\twhen \"producto_paila_coccion\" then \n\t\t\t\t(@producto_paila_coccion += cantidad)\n\t\t\twhen \"producto_tanque_preclarificador\" then \n\t\t\t\t(@producto_tanque_preclarificador += cantidad)\n\t\t\twhen \"producto_enfriador\" then \n\t\t\t\t(@producto_enfriador += cantidad)\n\t\t\twhen \"producto_tcc\" then (@producto_tcc += cantidad)\n\t\t\twhen \"producto_filtro_cerveza\" then \n\t\t\t\t(@producto_filtro_cerveza += cantidad)\n\t\t\twhen \"producto_tanque_cerveza\" then \n\t\t\t\t(@producto_tanque_cerveza += cantidad)\n\t\t\twhen \"cerveza\" then (@cerveza += cantidad)\n\t\tend\n\tend", "def opcion4(inventario)\n sum = 0\n inventario.each do |llave,valor|\n sum += valor\n end\n \n puts \"El stock total de la tienda es: #{sum}\"\nend", "def precio_total_compras\n compras.sum(:precio_total)\n #p = 0\n #compras.each do |compra|\n #p += (compra.precio_total || 0)\n #end\n #return p\n end", "def index\n\n @puestos = Puesto.all\n\n \n @sumar = 0\n if params[:id]\n @sumar = @puesto.producto.cantidad - @puesto.cantidad \n else\n end\n\n end", "def total; end", "def receita_mes(data)\n\t\t@valor = 0\n\t\tself.categories.each do |c|\n\t\t\t@valor += c.valor_receita_mes(data)\n\t\tend\n\t\t@valor\n\tend", "def informacoes\n empregado = Empregado.find(params[:empregado_id])\n solicitacoes = Solicitacao.where(empregado_id: parametros[:empregado_id], mes_ano: parametros[:mes_ano])\n valor_ja_solicitado = solicitacoes.sum(&:valor)\n salario_disponivel = (empregado.salario || 0) - valor_ja_solicitado - solicitacoes.sum(&:taxa) # FIXME Romuloset - taxas\n\n render json: {\n valor_ja_solicitado: valor_ja_solicitado,\n salario_disponivel: salario_disponivel\n }\n end", "def sum_totals\n @total = Lote.where(:programacion_id => @programacion.first).sum(:precio_t)\n @total = Money.new(\"#{@total}00\", \"USD\").format\n @cantidades = Lote.where(:programacion_id => @programacion.first).sum(:cantidad)\n end", "def items_cesta()\n @total_cesta_cables = 0\n @items_cesta = 0\n CestaCable.all.each{|c| t=TipoMaterial.find_by_id(c.tipo_material_id);c.cantidad =1 unless !c.cantidad.blank?; suma= t.costo * c.cantidad unless t.nil?; @total_cesta_cables += suma unless t.nil?; @items_cesta += 1 unless t.nil?}\n\n return @items_cesta\nend", "def informa(pippo)\n # 1. Calcolo i valori di c14_idaliquotaiva e la loro frequenza in lbooks\n ivaInLbooks = Lbook.gruppiIVA\n risultL = \"1. Segue hash ivaInLbooks: #{ivaInLbooks.inspect}\"\n pippo.scriviRiga(risultL)\n\n # 2. Calcolo i valori di idaliquotaiva e la loro frequenza in books\n ivaInBbooks = Book.gruppiIVA\n risultB = \"2. Segue hash ivaInBbooks: #{ivaInBbooks.inspect}\"\n pippo.scriviRiga(risultB) \nend", "def schumann; end", "def valor_total_gasto\n\t\tself.qualificacoes.sum(:valor_gasto)\n\tend", "def set_importe_total\n self.importe_total = 0\n self.detalles.each do |detalle|\n self.importe_total += detalle.precio_unitario * detalle.cantidad unless detalle.marked_for_destruction?\n end\n end", "def despesa_mes(data)\n\t\t@valor = 0\n\t\tself.categories.each do |c|\n\t\t\t@valor += c.valor_despesa_mes(data)\n\t\tend\n\t\t@valor\n\tend", "def informacion_cuenta\n puts \"---------------------------------\"\n puts \"N° cuenta: #{@id}\"\n puts \"Saldo total: #{@s_corriente + @s_ahorro}\"\n puts \"Saldo cuenta de ahorro: #{@s_ahorro}\"\n puts \"Saldo cuenta corriente: #{@s_corriente}\"\n puts \"Tasa de interes: #{@tasa}\"\n puts \"---------------------------------\"\n self\n end", "def totals\n t=['Totaux']\n # bottoms est un arrau de totaux des différents mois de l'exercice\n bottoms = 1.upto(@period.list_months.size).collect do |i| # i va de 1 à 12 par ex\n lines.sum {|l| l[i]} # l[i] car l[0] est nature.name\n end\n t + bottoms + [bottoms.sum {|i| i}]\n end", "def totals\n t=['Totaux']\n # bottoms est un arrau de totaux des différents mois de l'exercice\n bottoms = 1.upto(@period.list_months.size).collect do |i| # i va de 1 à 12 par ex\n lines.sum {|l| l[i]} # l[i] car l[0] est nature.name\n end\n t + bottoms + [bottoms.sum {|i| i}]\n end", "def valor\n\t\t@valor = 0\n\t\tself.parts.each do |p|\n\t\t\t@valor += p.valor\n\t\tend\n\t\t@valor\n\tend", "def valor_total(estado)\n\t\t@valor = 0\n\t\tself.parts.each do |p|\n\t\t\tif(p.confirmacao == estado)\n\t\t\t\t@valor += p.valor\n\t\t\tend\n\t\tend\n\t\t@valor\n\tend", "def preco_total\n produto.preco * quantidade\n end", "def terreno\n grtotal = 0\n sum = 0\n\t\t#recorre las dos listas a la vez para sacar el terreno\n #usado de cada ingrediente segun el peso de este\n @lista.zip(@listagr).each do |normal, gr|\n cant = gr/1000.0\n sum += normal.terreno*cant\n end\n @terreno = sum\n\n end", "def getorden\n @id = params['id']\n @orden = Orden.find(@id)\n @factura = Factura.where(:ordens_id => @id).first\n @monto= @factura.iva + @factura.costoTotal\n\n @historico = Orden.rutas(@id)\n\n respond_to do |format|\n # format.html # show.html.erb\n format.xml\n end\n end", "def +(other)\n\t if (other.is_a? Matriz_Dispersa)\n\t\tif(@alt==other.alt && @anc=other.anc)\n\t\t\tsuma=Matriz_Dispersa.new(@alt+1,@anc+1, [],[],[], (@n_elem+other.n_elem))\n\t\t\tm = 0\n\t\t\t0.upto(suma.n_elem-1) do |i|\n\t\t\t if(other.elem[i].is_a? Fixnum)\n\t\t\t suma.elem[i]=0\n\t\t\t end\n\t\t\t if(other.elem[i].is_a? Fraccion)\n\t\t\t suma.elem[i]=Fraccion.new(0,1)\n\t\t\t end\n\t\t\tend\n\t\t\t0.upto(@alt) do |i|\n\t\t\t 0.upto(@anc) do |j|\n\t\t\t 0.upto(@n_elem-1) do |h|\n\t\t\t if(i==@alto[h])\n\t\t\t\t0.upto(@n_elem-1) do |t|\n\t\t\t\t if(j == @alto[t] && h==t)\n\t\t\t\t suma.elem[m]=@elem[t]\n\t\t\t\t suma.alto[m]=@alto[t]\n\t\t\t\t suma.ancho[m]=@ancho[t]\n\t\t\t\t m = m+1\n\t\t\t\t end\n\t\t\t\tend\n\t\t\t end\n\t\t\t end\n\t\t\t 0.upto(other.n_elem-1) do |l|\n\t\t\t\tif(i==other.alto[l])\n\t\t\t\t 0.upto(other.n_elem-1) do |t|\n\t\t\t\t if(j==other.alto[t] && l==t)\n\t\t\t\t suma.elem[m]=(suma.elem[m]+other.elem[t])\n\t\t\t\t suma.alto[m]=other.alto[t]\n\t\t\t\t suma.ancho[m]=other.ancho[t]\n\t\t\t\t m = m+1\n\t\t\t\t end\n\t\t\t\t end\n\t\t\t\tend\n\t\t\t end\n\t\t\t end\n\t\t\tend\n\t\t\tsuma\n\t\telse\n\t\t puts \"no se puede realizar la suma\"\n\t\tend\n\t else\n\t if(other.is_a? Matriz_Densa)\n\t if(@alt==other.alt && @anc=other.anc)\n\t\tother.+(self.to_densa)\n\t else\n\t\tputs \"no se puede realizar la suma\"\n\t end\n\t end\n\t end\n\tend", "def calcula_pago_total\n \t \tmonto = self.monto\n \t\ttipo_cliente = self.tipo\n \t\tif tipo_cliente == \"colocadora\"\n \t\t\tmonto = ((monto* 0.00)+monto).to_i\n \t\telse\n \t\t\tmonto = ((monto* 0.50)+monto).to_i\n \t\tend\n \tend", "def get_usoterreno\n aux = 0.0\n @contenido.each do |alimento|\n aux += alimento.ground\n end\n @usoterreno = aux\n end", "def show\n @departamento = @factura.departamento\n @consorcio = @factura.departamento.consorcio\n @gasto_ordinario_periodo = Gasto.para_consorcio(@consorcio.id).para_fecha(@factura.periodo.month, @factura.periodo.year).ordinario.sum(&:importe)\n @gasto_extraordinario_periodo = Gasto.para_consorcio(@consorcio.id).para_fecha(@factura.periodo.month, @factura.periodo.year).extraordinario.sum(&:importe)\n @gasto_ordinario_periodo_departamento = @gasto_ordinario_periodo * @departamento.coeficiente / 100\n @gasto_extraordinario_periodo_departamento = @gasto_extraordinario_periodo * @departamento.coeficiente / 100\n @gasto_mensual_departamento = @gasto_ordinario_periodo_departamento + @gasto_extraordinario_periodo_departamento\n @factura.importe_abonado = @gasto_mensual_departamento + @factura.saldo_anterior + @factura.intereses if @factura.importe_abonado.nil?\n @factura.save\n end", "def getNbRecompense\n return 0\n end", "def vct\n grtotal = 0\n sum = 0\n\t\t#recorre las dos listas a la vez para sacar el valor\n\t\t#nutricional de cada ingrediente segun el peso de este\n @lista.zip(@listagr).each do |normal, gr|\n cant = gr/1000.0\n sum += normal.val_en*cant\n end\n sum\n end", "def multiples_facturas_confirmar_parciales\n @width_layout=1180\n @form_title = I18n.t('Sistema.Body.Modelos.OrdenDespachoDetalle.Mensajes.orden_despacho_insumos') \n @form_title_record = I18n.t('Sistema.Body.Modelos.OrdenDespachoDetalle.Mensajes.orden_despacho_insumo') \n end", "def index\n @dispersions = Dispersion.select(\"usuario_id, sum(cantidad) as cantidad\").group(\"usuario_id\")\n end", "def suma_valores\n resultados = {}\n self.totales = {}\n self.totales_por_comprobante = {}\n\n # revisa todas las monedas\n EmpCuentab.monedas.each do |moneda, id_moneda|\n resultados[moneda] = {\n valor: 0.0,\n descuento: 0.0,\n desc_general: 0.0,\n subtotal: 0.0,\n iva: 0.0,\n ieps: 0.0,\n total: 0.0,\n }\n \n com_det_compra.where(moneda: moneda).each do |cdc|\n valor = cdc.precio * cdc.cantidad\n desc_cdc = valor * (cdc.descuento / 100)\n subtotal_temp = valor - desc_cdc\n desc_gral = subtotal_temp * (descuento / 100)\n subtotal = valor - desc_cdc - desc_gral\n iva = subtotal * (cdc.iva / 100)\n ieps = subtotal * (cdc.ieps / 100)\n total = subtotal + iva + ieps\n\n resultados[moneda][:valor] += valor\n resultados[moneda][:descuento] += desc_cdc\n resultados[moneda][:desc_general] += desc_gral\n resultados[moneda][:subtotal] += subtotal\n resultados[moneda][:iva] += iva\n resultados[moneda][:ieps] += ieps\n resultados[moneda][:total] += total\n\n # actualiza totales\n totales[moneda] = 0.0 unless totales[moneda]\n totales[moneda] += total\n\n # actualiza totales por comprobante\n comprobante = cdc.comprobante ? cdc.comprobante : \"Sin comprobante\"\n tipo_comp = cdc.tipo_comprobante ? cdc.tipo_comprobante : nil\n # total, moneda, nombre del departamento, id del departamento, comprobante, tipo de comprobante\n totales_por_comprobante[comprobante] = [0.0, nil, nil, nil, nil] unless totales_por_comprobante[comprobante]\n totales_por_comprobante[comprobante][0] += total\n totales_por_comprobante[comprobante][1] = cdc.moneda\n totales_por_comprobante[comprobante][2] = cdc.emp_locacion.nombre\n totales_por_comprobante[comprobante][3] = cdc.emp_locacion.id\n totales_por_comprobante[comprobante][4] = comprobante\n totales_por_comprobante[comprobante][5] = tipo_comp\n end\n end\n\n resultados\n end", "def valor_pendente\n\t\tself.valor_total(0)\n\tend", "def offre_demande\n\t\t@table = StatisticsTable.new\n\t\t@table.title = \"Offre et demande\"\n\t\t@table.axis_title = \"Nombre d utilisateurs\"\n\t\t\t\t\n\t\t@table.add_header('string','')\n\t\t@table.add_header('number','Offre')\n\t\t@table.add_header('number','Demande')\n\n\t\t@offre = 0\n\t\t@trips = Trip.find(:all, :conditions => ['on_demand = FALSE'])\n\t\t@trips.each do |trip|\n\t\t\t@offre += trip.seat \n\t\tend\n\t\t\n\t\t@demande = Trip.find(:all, :conditions => ['on_demand = TRUE']).size\n\t\t@trips.each do |trip|\n\t\t\t@demande += trip.users.size\n\t\tend \n\t\t@table.add_line([\"Nombre d utilisateurs\", @offre, @demande])\n\tend", "def sum (tableau)\n chiffre = 0\n tableau.each do |element|\n chiffre = chiffre + element\n end\n return chiffre\nend", "def sum; end", "def uno_mas\n\t\t@edad += 1\n\t\tif @edad < EDAD_MAXIMA\n\t\t\t@altura += @inc_alt\n\t\t\t@contador += prod_nar if @edad >= @ini_fru\n\t\telse\n\t\t\tmuere\n\t\tend\n\t\t@edad\n\tend", "def carbo \n grtotal = 0\n sum = 0\n\t\t#itera en las dos listas a la vez para poder calcular las \n #cabrohidratos dependiendo de la cantidad y tambien suma\n #todas las cantidades para poder calcular el porcentaje\n #despues\n @lista.zip(@listagr).each do |normal, gr|\n grtotal += gr\n cant = gr/1000.0\n sum += normal.carbo*cant\n end\n (sum*100)/grtotal\n end", "def subtotal\n precio * cantidad\n end", "def adeudos\n sumas = suma_valores\n resp = {cuentas_con_deuda: 0} # cuenta si alguna cuenta cuenta con deuda\n EmpCuentab.monedas.each do |moneda, id_moneda|\n total_compra = sumas[moneda][:total]\n total_deuda = total_compra - com_pagos.joins(:emp_cuentab).where('emp_cuentabs.moneda = ?', id_moneda).sum(:monto)\n resp[moneda] = {\n total: total_compra,\n deuda: total_deuda}\n if total_deuda > 0\n resp[:cuentas_con_deuda] += 1\n end\n end\n\n resp\n end", "def ValorRetirado(billetes_retiro,valor_solicitado , tipo_cuenta)\n \tsalida = []\n \tsum = 0\n billetes_retiro.each { |a| sum+=a }\n \n\t puts \"total de esta\"\n\t puts sum == valor_solicitado.to_i\n retiro = Atm.new\n retiro.fecha_retiro = Time.now.strftime(\"%Y-%m-%d %H:%M:%S %Z\")\n retiro.valor_retiro = sum\n retiro.save\n if sum == valor_solicitado.to_i\n \tsalida = sum # Si el valor es exacto lo retorna\n else\t\n #Buscamos la diferencia de la cantidad\t\n valor_sobra = sum - valor_solicitado.to_i\n puts valor_sobra\n #Buscamos si un solo billete esta dando la diferencia\n if billetes_retiro.include?(valor_sobra)\n nuevo_array = billetes_retiro.delete(20)\n nuevo_array.each { |a| sum+=a } #relizamos la suma de nuevo\n salida = [nuevo_array, sum] # retornamos array con nuevos valores\n \t else\n \t \tsalida = sum\n end \n end \t\n\n end", "def total_price\n puts \"O PRECO TOTAL DE ORDER FOI CHAMADO\"\n self.line_items.to_a.sum{ |item| item.total_price}\n end", "def totalHidratos\n\t\thidr = 0\n\t\ttotal = 0\n\t\t@platos.each do |alimento|\n\t\t\thidr += alimento.carbohidratos\n\t\tend\n\t\treturn hidr.round(2)\n\tend", "def suma_gramos\n\t\t\t@proteinas + @carbohidratos + @lipidos\n\t\tend", "def show\n\t@numero_parcelas = 1 +(@matricula.data_fim_contrato.year * 12 + @matricula.data_fim_contrato.month) - \n\t(@matricula.data_inicio_contrato.year * 12 + @matricula.data_inicio_contrato.month)\n\t\n\tif !@matricula.turma.nil?\n\t\t@calcular_valor_total = @matricula.turma.curso.valor.to_f * @numero_parcelas\n\t\t@calcular_valor_total = @matricula.turma.curso.valor.to_f * @numero_parcelas\n\t\t@valor_total = Money.new(@calcular_valor_total*100, \"BRL\").format\n\t\t@valor_parcela = Money.new(@matricula.turma.curso.valor.to_f*100, \"BRL\").format\n\t\t@responsavel = (@matricula.aluno.responsavel == nil) ? (@matricula.aluno) : (@matricula.aluno.responsavel)\n\tend\n\n\t\n end", "def disponibles\n total = []\n heros.each do |h|\n next unless h.tesoro\n next unless h.tesoro[item + 's']\n h.tesoro[item + 's'].each do |e|\n (total << h.id) if e == id\n end\n end\n total\n end", "def totalPrazo(cp,quant)\n\t\treg = cp.size - 1\n\t\tret = 0\n\t\tfor ct in (0..reg)\n\t\t\tret = ret + (desconto(Produt.find(cp[ct]).prazo, Produt.find(cp[ct]).id) * quant[ct])\n\t\tend\n\t\treturn ret\n\tend", "def show\n @ventum.Costo=List.where( ventum_id: params[:id]).sum(:costo)\n @ventum.save\n @list = List.new\n end", "def imprimir_sector\n #aqui guardo todos los datos que necesito para imprimirlos en las variable\n @form_title=''\n # @seguimientos = SeguimientoVisita.find(:all,:conditions => ['id = ?', params[:id]])\n @es_no=1\n @solicitudes = Solicitud.find(params[:id])\n\n @prestamos=Prestamo.find(:all,:conditions => ['solicitud_id = ? ', @solicitudes.id])\n @seguimientos = SeguimientoVisita.find(:all,:conditions => ['solicitud_id = ?', @solicitudes.id]) \n @unidad_produccion=UnidadProduccion.find(@solicitudes.unidad_produccion_id) \n\n #ojo esto solo se usa para calcular montos en la seccion de financiamiento caso animal\n @desembolso_totales_segun_nro_tramite=Desembolso.find(:all,:conditions=>\"solicitud_id = #{@solicitudes.id}\",:order=>:id)\n\n @sumado_montos_desembolso=0.0\n unless @desembolso_totales_segun_nro_tramite.empty? \n @desembolso_totales_segun_nro_tramite.each{ |des|\n\n @seguimientos.each { |segui|\n if des.seguimiento_visita_id == segui.id \n @sumado_montos_desembolso+=des.monto\n\n end \n } \n }\n end \n @orden_despacho_totales_segun_nro_tramite=OrdenDespacho.find(:all,:conditions=>\"solicitud_id = #{@solicitudes.id}\",:order=>:id)\n\n @sumado_montos_orden=0.0\n unless @orden_despacho_totales_segun_nro_tramite.empty?\n @orden_despacho_totales_segun_nro_tramite.each{ |ord|\n\n @seguimientos.each { |segui|\n if ord.seguimiento_visita_id == segui.id \n @sumado_montos_orden+=ord.monto\n\n end \n } \n\n }\n end\n \n if !@solicitudes.cliente.persona_id.nil?\n @es_no=1 \n @datos_cliente=Persona.find(@solicitudes.cliente.persona_id) \n\n else\n @es_no=2 \n @datos_cliente=Empresa.find(@solicitudes.cliente.empresa_id)\n @empresa_integrante = EmpresaIntegrante.find(:all, :conditions=> \"empresa_id = #{@datos_cliente.id}\")\n @empresa_unidad_produccion = Empresa.find(@unidad_produccion.cliente.empresa_id) \n unless @empresa_integrante.empty?\n condi=\"(\"\n @empresa_integrante.each{ |empresa|\n\n condi+=empresa.id.to_s << \",\" \n }\n condi=condi[0,condi.length-1] \n condi+=\")\" \n @empresa_integrante_tipo = EmpresaIntegranteTipo.find(:first, :conditions=> \"empresa_integrante_id in #{condi} and tipo = 'R'\")\n @datos_empresa=EmpresaIntegrante.find(@empresa_integrante_tipo.empresa_integrante_id).persona \n @conppa=UnidadProduccion.find(:first,:conditions=>\"cliente_id = #{@empresa_unidad_produccion.cliente_empresa.id}\")\n else\n @empresa_integrante=[]\n @datos_empresa=[]\n end \n end\n\n \n @sect=Sector.find(@solicitudes.sector_id)\n\n case params[:tipo]\n when \"VE\"\n @vista = 'view_planilla_vegetal_forestal' \n when \"AN\"\n @vista = 'view_planilla_animal' \n when \"AC\"\n @vista = 'view_planilla_acuicola' \n when \"PE\"\n @vista = 'view_planilla_pesca' \n else \n @maquinarias=UnidadProduccionMaquinaria.find_all_by_seguimiento_visita_id(@seguimientos[0].id)\n @tipo_maquinaria = TipoMaquinaria.find(:all, :order=>'nombre')\n @vista = 'view_planilla_maquinaria'\n end \n end", "def por_lip\n\t\t\t(@lipidos/suma_gramos)*100\n\t\tend", "def valorazucaresp\n\t\tvag=(azucares * 70) / 100\n vag.round(2)\n\tend", "def index\n fechas()\n @depositocaucionpendis = Depositocaucion.busqueda(params[:fechadesde], params[:fechahasta], params[:nrocheq])\n @depositocaucions = Depositocaucion.busquedatodo(params[:fechadesde], params[:fechahasta], params[:nrocheq])\n\n #para sacar los subtotales\n agrup = []\n @depositocaucions.each do |v|\n agrup << v.dcau_nroboletadeposito.to_i\n end\n @agrups = agrup.uniq\n\n @totalvens = Depositocaucion.totalven(params[:fechadesde], params[:fechahasta])\n @acreditados = Depositocaucion.acreditado(params[:fechadesde], params[:fechahasta])\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @depositocaucions }\n end\n end", "def numarulTotalDePersoane()\n @@instantePersoana += 1\n puts \"Numarul total de persoane: #@@instantePersoana\"\n end", "def excede_control_de_pago_global()\n @sumatoria_posible_pago_todos_tickets_de_hoy_todos_parlay_global = 0 # inicializacionn de variable sumatoria en cero ok\n #La idea aqui es verificar si la sumatoria de posible pago de todas las jugadas de todos los tipos de tickets activos de hoy no excede el limite globar de riesgo del sistema ok\n \n #limite GLOBAL = 1 ADMINISTRATIVO OK Y TIPOJUGADA TAMBIEN MANUAL = GLOBAL OK TED. POPULATE IT IN DATABASE PRODUCTION OK:\n control_monto_max_pago_global = Controldepagogt.where(:tipojugada => \"global\" ).first.limiteglobal.to_i || 1 # setear un valor default ok \n\n t_ids = Ticket.today.where(:activo => \"si\").ids # todos los ticket actio de hoy con ese parlay ok\n \n @listado_sumatoria_posible_pago = Jugadalot.where(:ticket_id => t_ids)# postrges casting erro string ok .sum(:posiblepago).to_i\n \n if not @listado_sumatoria_posible_pago.nil?\n @listado_sumatoria_posible_pago.each do |jugada|\n @sumatoria_posible_pago_todos_tickets_de_hoy_todos_parlay_global += jugada.posiblepago.to_i\n end\n \n end\n \n \n #Sumar posible pago de esas jugadas de cada ticket parlay ok.\n# @sumatoria_posible_pago_todos_tickets_de_hoy_todos_parlay_global = 0\n# t.each do |ticket|\n# @sumatoria_posible_pago_todos_tickets_de_hoy_todos_parlay_global += Jugadalot.where(:ticket_id => ticket.id).last.posiblepago.to_i\n# end\n\n if @sumatoria_posible_pago_todos_tickets_de_hoy_todos_parlay_global.to_i <= control_monto_max_pago_global.to_i\n # si es menor todo ok\n false # no excede\n else\n true #si excede \n end\n\n\n end", "def summary; end", "def summary; end", "def summary; end", "def summary; end", "def karte_drucken()\n # TODO ÄNDERN\n if !tarif_gewaehlt?\n puts \"Kein Tarif wurde gewählt.\"\n else\n if @eingeworfen <= @tarif.betrag\n puts \"Der offener Betrag: #{@tarif.betrag - @eingeworfen }\"\n else\n puts(\"------------------\")\n puts(\"- Cinema Magico -\")\n puts(\"- Phantastische Tierwesen\")\n # TODO diese Zeile ändern\n puts(\"- Preis \" + @tarif.betrag().to_s + \" Euro\") # vordefiniert to_s , von Integer zum String wandeln\n puts(\"- Bezahlt \" + @eingeworfen.to_s + \" Euro\") # vordefiniert to_s , von Integer zum String wandeln\n puts(\"------------------\")\n # die Gesamtsumme, mit dem der Automat nach der letzten Leerung\n # gefuettert wurde\n @eingeworfen -= @tarif.betrag\n @summe_automat = @summe_automat + @tarif.betrag\n @tarif = nil\n return\n end\n end\n\n end", "def verTodasVentasCarrito(ventas)\n \n totalVentas=0\n for i in(0..ventas.size-1)\n totalVentas+=ventas[i][3]\n print \"ID: #{ventas[i][0]} Cantidad: #{ventas[i][1]} Valor: #{ventas[i][2]}, Valor Total: #{ventas[i][3]} \\n\"\n end\n print \"Total de ventas: #{totalVentas} \\n\"\nend", "def buscar_cruces_pendientes\n cruces = Marca.all(:select => \"id\", :conditions => [\n \"marcas.importacion_id = ? AND marcas.propia = ? AND marcas.tipo_signo_id NOT IN (?)\", \n self.id, false, TipoSigno.descartadas_cruce\n ]).size\n\n cruces - self.consultas.size\n end", "def totalLipidos\n\t\tlip = 0\n\t\ttotal = 0\n\t\t@platos.each do |alimento|\n\t\t\tlip += alimento.lipidos\n\t\tend\n\t\treturn lip.round(2)\n\t\n\tend", "def sumar()\n\t\tnumeroUno = 1\n\t\tnumeroDos = 3\n\t\tputs \"-------------------\"\n\t\tputs numeroUno + numeroDos\n\tend", "def karte_drucken()\n if !tarif_gewaehlt?()\n puts (\"Es wurde noch kein Tarif gewählt. Bitte wählen Sie zuerst einen Tarif aus.\")\n elsif @tarif - @eingeworfen > 0\n offener_betrag = @tarif - @eingeworfen\n puts (\"Sie müssen noch \" + offener_betrag.to_s() + \" Euro einzahlen.\")\n else\n kartenpreis = @tarif\n\n puts(\"------------------\")\n puts(\"- Cinema Magico -\")\n puts(\"- Phantastische Tierwesen\")\n # TODO diese Zeile ändern\n puts(\"- Preis \" + @tarif.to_s + \" Euro\")\n puts(\"- Bezahlt \" + @eingeworfen.to_s + \" Euro\")\n puts(\"------------------\")\n # die Gesamtsumme, mit dem der Automat nach der letzten Leerung\n # gefuettert wurde\n wechsel_geld()\n @summe_automat += kartenpreis\n @tarif = nil\n return\n end\n end", "def suivre; end", "def index\n @cliente = Cliente.find(params[:cliente_id])\n @pagos = @cliente.pagos\n @imp_debe = 0\n @imp_haber = 0\n @pagos.each do |f| \n @imp_debe += f.pg_debe.to_f\n @imp_haber += f.pg_haber.to_f\n end\n @total = @imp_debe - @imp_haber\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: [@pagos, @imp_debe, @imp_haber, @total] }\n end\n end", "def summary\n \n end", "def calcular()\n lista_nombres=@individuos[0].get_lista_nombres\n lista_nombres.each do |nombre|\n cont=0\n igind=0\n #puts nombre\n for j in 0..@individuos.length-1\n\tglucosa=@individuos[j].get_glucosa.to_f\n #puts glucosa\n aibc=@individuos[j].get_aibc(nombre)\n #puts aibc\n aux=aibc/glucosa*100\n #puts aux\n igind=igind+aux\n\tcont=cont+1\n end\n igind=igind/cont\n #puts igind\n @resultados << nombre + \" \" + igind.round(2).to_s + \"\\n\"\n end\n end", "def valorizacao\n \t\tif self.tipo_de_operacao.compra?\n ((self.atual - self.entrada) / self.entrada) * 100.0\n else\n ((self.entrada - self.atual) / self.atual ) * 100.0\n end\n \tend", "def devolver_azucar \n\t\treturn @azucares\n\tend", "def promedio(restaurant_menu)\n contar=0\n suma=0\n restaurant_menu.each { |k,valor|\n contar += 1\n suma += valor\n}\n\nputs suma/contar\nend", "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 calorie_count\n @sugar_amount * CALORIES_PER_SUGAR_GRAM +\n @flour_amount * CALORIES_PER_FLOUR_GRAM\n end", "def fin\n empl = Employeur.instance\n return @debut + 7 * empl.semaines_par_paie\n end", "def amount; end", "def terrenoTotal\n\t\t@terrenoSuma = 0\n\t\t@platos.each do |alimento|\n\t\t\t@terrenoSuma += alimento.terreno\n\t\tend\n\t\treturn @terrenoSuma.round(2)\n\tend", "def ventas_comprobantecredito_subtotal(*args)\n entry,referencia = args\n \n entry.details.build do |dt|\n dt.account_id = referencia.account_id \n dt.description = __method__.to_s.humanize + ' rc' + self.numero.to_s\n\n dt.credit = referencia.debita? ? 0 : self.importe\n dt.debit = referencia.debita? ? self.importe : 0 \n end\n end", "def total_amount\n \t amount = 0\n \t operation_items.each do | oi |\n \t\tamount = amount + oi.amount\n end\n amount\n end", "def item_total\n tot = 0\n self.line_items.each do |li|\n tot += li.total\n end\n self.item_total = tot\n end", "def hidratos \n\t\t@hidratos = @azucares + @polialcoles + @almidon\n\t\treturn @hidratos\n\tend", "def status_da_divulgacao(topico)\n end", "def total_discount(items)\n 0\n end", "def total\n total = 0\n if self.showlines \n self.showlines.each do |showline|\n total += showline.tvshow.price\n end \n end \n return total\n end", "def show\n @total = Mitfahrer.where(:fahrt_id => @fahrt.id, :istBestatigt => true).select(\"COUNT(*) AS total\").first.total\n # @anfragen = Mitfahrer.where(:fahrt_id => @fahrt.id, :istBestatigt => false)\n @anfragen = Mitfahrer.where(\"fahrt_id = #{@fahrt.id}\")\n end", "def calc\n @adm_pedido = Adm::Pedido.find(params[:id])\n\n # verifica se o pedido já tem parcelas geradas\n #pedidoProcessado(@adm_pedido)\n\n if calculoTotal(@adm_pedido)\n redirect_to(show_adm_painel_path(@adm_pedido), :notice => 'Pedido recalculado')\n else\n redirect_to(show_adm_painel_path(@adm_pedido), :notice => 'Erro no recalculo')\n end\n end", "def promedio(restaurant_menu)\n suma_total = 0\n restaurant_menu.each { |k,v| suma_total += v }\n suma_total / restaurant_menu.length.to_f\nend", "def show\n add_breadcrumb \"Detalles\", @centro_costos\n end", "def totalkcal\n\t\t\tkcalproteinas + kcallipidos + kcalglucidos\n\t\tend", "def offense_counts; end", "def offense_counts; end", "def hidratos_carbono\r\n hc = 0\r\n @lista_alimentos.each do |i|\r\n hc += i.carbohidratos\r\n end\r\n return hc\r\n end", "def print_suma_lyginiu\n res = suma_lyginiu(@array)\n puts \"Suma visu lyginiu skaiciu masyvo: #{res}\"\n res\n end", "def index\n @hoje = Date.current\n @ano = params[:ano_param]\n if @ano == nil then @ano = @hoje.year.to_s end\n #@todoscontratos = Contrato.all.order(\"numero ASC\")\n @contratos = Contrato.all.where('ano = ?', @ano).order(\"numero ASC\")\n #@contratos = @todoscontratos.where('ano = ?', @ano)\n #@todos = @todoscontratos.size\n #@ativos = @todoscontratos.where('(? < data_venc)', @hoje).count\n #@finalizados = @todoscontratos.where('? > data_venc', @hoje).count\n @vigencia_rest\n end", "def index\n # On récupère la liste des utilisateurs avec une requête sur la base, de sorte à ce qu'il\n # n'y ait rien d'affiché au chargement. Cela permet un chargement très rapide de la page.\n @utilisateurs = Utilisateur.requete_id(params[:requete]) + Utilisateur.requete_nom(params[:requete]) + Utilisateur.requete_prenom(params[:requete])\n end", "def total\n @total\n end", "def aumentar(array, aumento, desde, hasta)\n arr_filtro = array[desde..hasta] #rango de los datos filtrados\n arr_filtro.map!{|venta_mensual| venta_mensual * aumento}.sum #valor total por el porcentaje de aumento\nend" ]
[ "0.6191417", "0.6145878", "0.61335695", "0.61130834", "0.610881", "0.59997654", "0.5980322", "0.59518814", "0.5925779", "0.5893532", "0.5893091", "0.5877957", "0.58752376", "0.5770682", "0.5745549", "0.5689198", "0.5688272", "0.56882524", "0.5685207", "0.56724936", "0.56696445", "0.565352", "0.565352", "0.56425184", "0.56308585", "0.56258726", "0.56235194", "0.5607274", "0.5605636", "0.56050014", "0.55979997", "0.55941236", "0.5588172", "0.5585257", "0.557318", "0.55668974", "0.55562305", "0.5555845", "0.5554064", "0.5550036", "0.5543802", "0.55349493", "0.5532144", "0.5518023", "0.5515781", "0.54987395", "0.5498503", "0.5487581", "0.5480104", "0.5468451", "0.5467776", "0.54568386", "0.5455703", "0.5455065", "0.5450733", "0.54504466", "0.5448699", "0.54424375", "0.54408604", "0.54389477", "0.54389477", "0.54389477", "0.54389477", "0.54346144", "0.5422493", "0.54189795", "0.5416752", "0.5413987", "0.5412447", "0.5408867", "0.54084545", "0.5406709", "0.5403652", "0.5399055", "0.53980905", "0.5397636", "0.539078", "0.5374527", "0.5359531", "0.5358094", "0.5356705", "0.53557986", "0.5352372", "0.5351409", "0.53462505", "0.53423196", "0.53394485", "0.53282964", "0.5327245", "0.53265995", "0.5322148", "0.53207624", "0.53184533", "0.53110075", "0.53110075", "0.5306778", "0.53065693", "0.53050435", "0.53047776", "0.5304408", "0.53036034" ]
0.0
-1
== Metodo resta Dispersa
def -(other) #if ((other.class.to_s == "Dispersa") && (other.fil == @fil) && (other.col == @col)) matrizResta = Array.new(@fil) {Array.new(@col) {0}} i = 0 (other.numElementos - 1).times { matrizResta[other.filM[i]][other.colM[i]] = 0 - other.eleM[i] i += 1 } i = 0 (@numElementos - 1).times { matrizResta[@filM[i]][@colM[i]] += @eleM[i] i += 1 } #puts "resta = #{matrizResta}" return matrizResta #else #raise ArgumentError, "Matrices de distinto tamanio" #end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def suivre; end", "def mi_carrera\n\n\tend", "def show\n add_breadcrumb \"Detalles\", @reqcargos\n end", "def zuruecksetzen()\n end", "def sigla; @nome; end", "def show\n #calculo de presupuesto\n \n end", "def unsichtbar_machen()\n end", "def display_details()\n puts \"Numele persoanei: #@nume\"\n puts \"Prenumele persoanei: #@prenume\"\n end", "def display_details()\n puts \"Numele persoanei: #@nume\"\n puts \"Prenumele persoanei: #@prenume\"\n end", "def show\n @operacao = 'Visualização'\n end", "def show\n @titulo = \"Ver Pedido\"\n @clase = \"Pedidos\"\n end", "def notificaciones\n end", "def desplegarProceso\n\t\tputs \"id=#{@id} cantBytes=#{@cantBytes} cantPaginas=#{@cantPaginas}\"\n\t\tputs \"marcosRealAsig=#{@marcosRealAsig} marcosSwapAsig=#{@marcosSwapAsig}\"\n\tend", "def schubert; end", "def refutal()\n end", "def posti_disponibili\n self.vehicle.posti - self.n_passeggeri\n end", "def procesarOc(ordenCompra)\n\trespuesta = ProveedorRecibirOcFtp.new.responderOc(ordenCompra)\n\tputs ':) Procesando OC: '<< ordenCompra._id.to_s\n\tif(respuesta) #Si la aceptamos, debemos ir a generar Factura\n\t\tputs ':) Aceptamos OC'\n\t\tif(ProveedorEnviarFacturaFtp.new.enviarFactura(ordenCompra._id)) #Si se genera la Factura, debemos despachar producto\n\t\t\tputs ':) Enviamos Factura'\n\t\t\tProveedorDespacharProductos.new.despacharProductos(ordenCompra, true)\n\t\t\tputs ':) Despachamos productos'\n\t\t\treturn respuesta\n\t\tend\n\tend\n\n\treturn respuesta\nend", "def respuesta_externa\n @comentario_root = @comentario.root\n @comentario_root.completa_info(@comentario_root.usuario_id)\n @especie_id = params[:especie_id] || 0 # Si es cero, es porque era un comentario general y lo cambiaron de tipo de comentario\n @ficha = (params[:ficha].present? && params[:ficha] == '1')\n\n # Si es una respuesta de usuario o es para mostrar en la ficha\n if (params[:created_at].present? && @comentario_root.created_at.strftime('%d-%m-%y_%H-%M-%S') != params[:created_at])\n render :file => '/public/404.html', :status => 404, :layout => false\n else\n\n @comentario_resp = @comentario\n cuantos = @comentario_root.descendant_ids.count\n categoriaContenido = @comentario.categorias_contenido_id\n\n #Esto es para que en el show se muestre el primer comentario ALWAYS (el seguro está en preguntar si resp.present?)\n @comentario_root.completa_info(@comentario_root.usuario_id)\n resp = [@comentario_root]\n\n if cuantos > 0\n resp = resp + @comentario.descendants.map{ |c|\n c.completa_info(@comentario_root.usuario_id)\n c\n }\n end\n\n # Como resp ya esta seteado desde arriba, ya no es necesario mandar uno distinto si cuantos == 0\n @comentarios = {estatus:1, cuantos: cuantos, resp: resp}\n\n # Para crear el comentario si NO es el render de la ficha\n if @ficha\n render 'show', layout: false\n else\n\n if Comentario::RESUELTOS.include?(@comentario_root.estatus) #Marcado como resuleto\n @sin_caja = true\n elsif Comentario::OCULTAR == @comentario_root.estatus # Marcado como eliminado\n @eliminado = true\n elsif Comentario::MODERADOR == @comentario_root.estatus # Marcado como eliminado\n @moderador = true\n else\n # Para saber el id del ultimo comentario, antes de sobreescribir a @comentario\n ultimo_comentario = @comentario_resp.subtree.order('ancestry ASC').map(&:id).reverse.first\n\n # Crea el nuevo comentario con las clases de la gema ancestry\n @comentario = Comentario.children_of(ultimo_comentario).new\n\n # Datos del usuario\n @comentario.usuario_id = @comentario_resp.usuario_id\n @comentario.nombre = @comentario_resp.nombre\n @comentario.correo = @comentario_resp.correo\n @comentario.institucion = @comentario.institucion\n\n # Estatus 6 quiere decir que es parte del historial de un comentario\n @comentario.estatus = Comentario::RESPUESTA\n\n # Categoria comentario ID\n @comentario.categorias_contenido_id = categoriaContenido\n\n # Caseta de verificacion\n @comentario.con_verificacion = true\n\n # Proviene de un administrador\n @comentario.es_admin = false\n\n # Si es una respuesta de un usuario\n @comentario.es_respuesta = true\n\n # Asigna la especie\n @comentario.especie_id = @comentario_resp.especie_id\n end # end si no es un comenatrio resuelto\n\n render 'show'\n\n end\n\n end\n end", "def sichtbar_machen()\n # TODO\n end", "def ligar #Metodo/função da classe Carro\n puts 'O carro está pronto para iniciar o trajeto.'\n end", "def sichtbar_machen()\n end", "def verdi; end", "def revisa_deuda\n if com_compra.adeudos[:cuentas_con_deuda] == 0\n com_compra.pagado!\n else\n com_compra.pendiente!\n end\n end", "def relatorios\n end", "def Com6 # Recuperation Info\n \n end", "def realizar_cuestionario_demora\n @paciente = Paciente.find(params[:id])\n @accionPerfilamiento = \"Cuestionario por Demora\"\n end", "def sichtbar_machen\n @sichtbar = true\n zeichnen()\n puts(self) \n end", "def completarReferencia(referencia)\n # Se aguarda que cargue correctamente la pantalla de Producir documento\n claseCampoTexto = 'z-bandbox-inp'\n #self.getBrowser().text_field(:class => claseCampoTexto).wait_while_present # ORIGINAL\n self.getElementosHTMLFactory().getElemento('input').esperarMientrasExistaComponente(claseCampoTexto)\n # Se completa la referencia\n # Obtener todos los inputs text y filtar los que no son visible\n # Completa todos los campos que existen\n indice = 0\n claseCampoTextoZ = 'z-textbox'\n #campos = self.getBrowser().text_fields(:class => claseCampoTextoZ)\n campos = self.getElementosHTMLFactory().getElemento('input').obtenerInputsPorClase(claseCampoTextoZ)\n campos.each do |i|\n indice = indice + 1\n if i.visible?\n if indice == POSICIONREFERENCIA \n i.set referencia\n #else\n #if indice > POSICIONREFERENCIA\n # i.set TEXTOCAMPOSFC\n #end \n end\n i.fire_event :blur\n end\n end\n end", "def show\n @ficha = (params[:ficha].present? && params[:ficha] == '1')\n\n cuantos = @comentario.descendants.count\n categoriaContenido = @comentario.categorias_contenido_id\n\n if cuantos > 0\n resp = @comentario.descendants.map{ |c|\n c.completa_info(@comentario.usuario_id)\n c\n }\n\n @comentarios = {estatus:1, cuantos: cuantos, resp: resp}\n\n else\n @comentarios = {estatus:1, cuantos: cuantos}\n end\n\n # Para saber el id del ultimo comentario, antes de sobreescribir a @comentario\n ultimo_comentario = @comentario.subtree.order('ancestry ASC').map(&:id).reverse.first\n\n # Especie\n especie_id = @comentario.especie_id\n\n # Crea el nuevo comentario con las clases de la gema ancestry\n @comentario = Comentario.children_of(ultimo_comentario).new\n\n # El ID del administrador\n @comentario.usuario_id = current_usuario.id unless @ficha\n\n # Estatus 6 quiere decir que es parte del historial de un comentario\n @comentario.estatus = Comentario::RESPUESTA\n\n # Categoria comentario ID\n @comentario.categorias_contenido_id = categoriaContenido\n\n # Para no poner la caseta de verificacion\n @comentario.con_verificacion = false\n\n # Proviene de un administrador\n @comentario.es_admin = true\n\n # Asigna la especie\n @comentario.especie_id = especie_id\n end", "def multiples_facturas_confirmar_parciales\n @width_layout=1180\n @form_title = I18n.t('Sistema.Body.Modelos.OrdenDespachoDetalle.Mensajes.orden_despacho_insumos') \n @form_title_record = I18n.t('Sistema.Body.Modelos.OrdenDespachoDetalle.Mensajes.orden_despacho_insumo') \n end", "def acces_nome\r\n @nome\r\n end", "def asunto\n @name = 'foro'\n @page = Page.find(params[:id])\n end", "def refresh\n flash[:warning] ||= []\n flash[:notice] ||= []\n\n created, updated, errors = Rapport.fetch\n\n errors.each do |error|\n flash[:warning] << error\n end\n\n msg = \"<strong>Actualisation Terminée</strong><br />\"\n msg+= \"#{created.size} nouveau(x) fichier(s)<br />\"\n if created.any?\n msg+= \"<ul>\"\n msg+= created.map {|r| \"<li>#{view_context.link_to(r.xml_file_name, r)}</li>\" }.join\n msg+= \"</ul><br />\"\n end\n msg+= \"#{updated.size} fichier(s) mis à jour\"\n if updated.any?\n msg+= \"<ul>\"\n msg+= updated.map {|r| \"<li>#{view_context.link_to(r.xml_file_name, r)}</li>\" }.join\n msg+= \"</ul>\"\n end\n flash[:notice] << msg.html_safe\n\n end", "def marcarubro \n @marcarubro = Listaprecio.agrupamiento\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @marcarubro }\n format.pdf { render :layout => false }\n end\n end", "def agregar_docente\n\t\t@seccion = \"Docentes\"\n @titulo = \"Agregar docente\"\n\tend", "def solicitudes_atrasadas\n end", "def nombre_completo\n\tprimer_nombre+\" \"+primer_apellido\n#fin del metodo\nend", "def recuperationEtape()\n\t\tstring=@techniqueObjet.etape(@etapeEnCours)\n\t\t@texteContenu.set_text(string)\n\tend", "def recuperationEtape()\n\t\tstring=@techniqueObjet.etape(@etapeEnCours)\n\t\t@texteContenu.set_text(string)\n\tend", "def transmission; end", "def partido\n localidad.partido\n end", "def realizar_cuestionario\n @paciente = Paciente.find(params[:id])\n @accionPerfilamiento = \"Cuestionario Tipo Frustraciones\"\n end", "def status_da_divulgacao(topico)\n end", "def get_titulo\n \"#{@titulo}\" \n end", "def presentacion\n \"La marca del Ventilador es #{@marca}\"\n end", "def discursarnolocal(pessoa, lugar)\n \"#{pessoa} discursou no #{lugar}\"\nend", "def renglones\n\t\t@renglones_reporte\n\tend", "def camino_retorno(menuname, pmenu_item, ptipo)\n sql = \" \"\n resstr = \" \"\n mdescr = \" \"\n if ptipo == 'I' #si recibe el menu_item\n sql = \" AND opc_item = '#{pmenu_item}'\"\n else #si recibe menu_controller \n sql = \" AND opc_controller = '#{pmenu_item}'\"\n end\n menutblcaminos = Vgemenuroute.where(\"menu_cod = '#{menuname}' \"+sql)\n menutblcaminos.each do |camino|\n mcontroller = camino.menu_controller\n\t vdescr = I18n.t('menu.'+mcontroller)\n\t if vdescr.empty? \n\t mdescr = camino.menu_descr\n\t else \n\t if vdescr['missing'] == 'missing' \n\t mdescr = camino.menu_descr\n\t\telse\n\t\t\tmdescr = vdescr\n\t\tend\n\t end\n case camino.item_type \n\t when 'R'\n\t resstr += link_to(mdescr, root_path)\n\t when 'N'\n\t\t vurl = url_for({:controller => 'home', :action => 'index', :itemnode=>camino.menu_item})\n\t\t resstr += \" >> \"+link_to(mdescr, vurl, :class => 'quick')\n\t else\n resstr += \" >> \"+link_to(mdescr, url_for( {:controller => camino.menu_controller }))\t \n\t end\n end\n return resstr\n end", "def del\n\t\t#methode ruft show auf ==> !?! ==> err aber funktioniert\n\tend", "def asignar_titulo_propiedad()\n \n end", "def informacoes_da_conta(local)\n\t\t\t\t\traise NotImplementedError.new('Sobreescreva este método na classe referente ao banco que você esta criando')\n\t\t\t\tend", "def afficher()\n print \"|\" + @etat.to_s\n end", "def lista\n @receitas = Receita.all\n\n respond_to do |format|\n format.html # lista.html.erb\n format.xml { render :xml => @receitas }\n end\n end", "def noticias\n @vocalia = Vocalium.find(params[:id])\n @actual = \"Vocalia\"\n @noticias = Seccion.find(@vocalia.seccion_id).posts\n end", "def titulo_guia\n titulo = []\n\n t = Especie.find(params[:especie_id])\n a = t.adicional\n\n tipo_region = params[:tipo_region] == \"anp\" ? \"ANP \" : \"Municipio de \"\n \n if a.nombre_comun_principal.present?\n titulo[0] = \"Guía de #{a.nombre_comun_principal}\"\n else\n titulo[0] = \"Guía de #{t.nombre_cientifico}\"\n end\n\n titulo[1] = tipo_region + params[:nombre_region]\n titulo\n end", "def show\n @diagnosticos = Diagnostico.all\n @stock_medicas = StockMedica.where(diagnostico_id == ficha_doc.diagnostico_id) \n end", "def comisiones_asignadas\n asunto.comisiones if asunto\n end", "def nome_perfil\n \tself.descricao\n end", "def actionNom\n\t\treturn \"Je sais rien faire :C\"\n\tend", "def retourAvant()#TOTEST\n if(@indiceCoup < tabCoup.size) #vérification normalement inutile puisque le bouton devrait être disable\n #On annule en passant au coup suivant\n coupSuivant = tabCoup.at(@indiceCoup)\n @grilleEnCours.tabCases[coupSuivant.case.positionY][coupSuivant.case.positionX].couleur = coupSuivant.couleur\n @grilleRaz = nil\n\n @indiceCoup += 1 #On passe au coup suivant\n\n socket = Fenetre1v1.getSocket\n if(socket != nil)\n socket.puts (\"av\" + @grilleEnCours.getPourcentage(@grilleBase, nil).to_s )\n end\n end\n\n return [peutRetourAvant?, coupSuivant.case] #Pour dire aux fonctions appelantes si on peut encore aller en avant\n end", "def retornoBusqueda()\nreturn @busqueda\nend", "def show\n @admin_coleccion = Admin::Coleccion.find(params[:id])\n @page_title = ['Datos de la Colección \\'', @admin_coleccion.nombre,'\\'']\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @admin_coleccion }\n end\n end", "def full_descripcion \n \"#{asunto.nombre} - \"+\"#{nombre}\" \n end", "def show\n add_breadcrumb \"Detalles\", @prospectos\n end", "def info_conta\n # CAMPO TAMANHO\n # agencia 3\n # conta corrente 7\n \"#{agencia}#{conta_corrente}\"\n end", "def modificare_carte\n\t\tputs \">>>MODIFICARE CARTE<<<\"\n\t\tputs \"Introduceti noul titlu: \"\n\t\t@titlu = gets\n\t\tputs \"Modificati numele autorului: \"\n\t\t@autor = gets\n\t\tputs \"Modificarea s-a executat cu succes!\"\n\tend", "def index\n # On récupère la liste des utilisateurs avec une requête sur la base, de sorte à ce qu'il\n # n'y ait rien d'affiché au chargement. Cela permet un chargement très rapide de la page.\n @utilisateurs = Utilisateur.requete_id(params[:requete]) + Utilisateur.requete_nom(params[:requete]) + Utilisateur.requete_prenom(params[:requete])\n end", "def devolver_azucar \n\t\treturn @azucares\n\tend", "def show\r\n checar_super_agencia\r\n end", "def imprime_ficha\n \n prawnto :prawn => {\n :left_margin => 20,\n :right_margin => 20,\n :top_margin => 400,\n :bottom_margin => 20 }\n \n @paciente = Paciente.find(params[:id]) \n @razon = \"\"\n @razon = @paciente.razon unless @paciente.razon.nil?\n @rfc = \"\"\n @rfc = @paciente.rfc unless @paciente.rfc.nil?\n @consulta = Consulta.find(params[:consulta_id])\n \n if !@consulta.cita.nil?\n @ref_estudio = @consulta.cita.operation.ref_estudio unless @consulta.cita.operation.ref_estudio.nil?\n @fecha_hora = @consulta.cita.fecha_hora unless @consulta.cita.fecha_hora.nil?\n else\n @ref_estudio = \"\"\n @fecha_hora = \"\"\n end\n \n \n \n respond_to do |format|\n #format.html # show.html.erb\n #format.xml { render :xml => @pago }\n format.pdf {render :layout => false }\n end\n end", "def changerEnRouge\n\t\t@couleur=1\n\tend", "def show \n authorize! :show_almacen,Sigesp::Solicitud \n respond_to do |format|\n format.html {\n @grupo = SolicitudGrupo.grupoSolicitud(@sigesp_solicitud.numsol)\n if @grupo.nil?\n @grupo = SolicitudGrupo.new \n @grupo.solicitudes.append @sigesp_solicitud\n end \n }\n format.pdf do\n @solicitud = Sigesp::Solicitud.find(params[:id])\n end\n end\n end", "def show\n #Llamada al metodo ip que se encuetra dentro de application_controller.rb y lo asignamos a la variable.\n @remote_ip = ip\n @factura = Factura.find(params[:id])\n @orden = Orden.where(:id => @factura.ordens_id).first\n @paquete = Paquete.where(:ordens_id => @factura.ordens_id)\n @compania = Companium.find(@factura.companias_id)\n @cliente = Persona.find(@orden.personas_id)\n @total = @factura.costoTotal + @factura.iva\n @dirQR = \"https://chart.googleapis.com/chart?cht=qr&chs=250x250&chl=http://\" + @remote_ip.to_s + \":3000/tracking/\" + @orden.id.to_s\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @factura }\n format.pdf { render :format=>false, :attachment=>false}\n #format.pdf {render :pdf => \"filename\", :stylesheets => \"factura\"} \n end\n end", "def show\n @produtos = @fornecedor.produtos\n @telefones = @fornecedor.telefones\n @emails = @fornecedor.emails\n end", "def nombre\n @nombre\n end", "def pray\n\n\tend", "def nombre()\n\t\tputs \"#{@nombre}\"\t\n\tend", "def retirar\n\t\tvt = params[:id]\n\t\t$CarrinhoCompras[vt.to_i] = \"\"\n\t\t$CarrinhoComprasQuant[vt.to_i] = 0\n\t\t\t$CarrinhoCompras.delete(\"\")\t\t\t# APAGANDO ITENS DO CARRINHO\n\t\t\t$CarrinhoComprasQuant.delete(0)\t\t# APAGANDO Quantidade referente a item\n\t\tredirect_to \"/compras?pd=\" + Admloja.first.mcab.to_s\n\tend", "def set_disponibilite\n @disponibilite = Disponibilite.find(params[:id])\n end", "def actionOK(viewListe, champRecherche, docs)\r\n\t\tselection = viewListe.selection()\r\n\t\t#si l'user a selectionne un doc dans le treeview\r\n\t\tif iter=selection.selected\r\n\t\t\ttitre = iter[1]\r\n\t\t\tnum = docs[titre].keys\r\n\t\t\t@idDocument = num\r\n\t\t\t@fenetreOuvrirDoc.destroy()\r\n\t\t#sinon, s'il a selectionne un doc via le champ de recherche\r\n\t\telsif titre = champRecherche.text()\r\n\t\t\t#si le titre entré ne figure pas dans la table de hash (dcs)\r\n\t\t\tif(!docs.has_key?(titre))\r\n\t\t\t\tchampRecherche.text=\"\"\r\n\t\t\t\tquickMessage(\"Ce document n'existe pas.\")\r\n\t\t\telse\r\n\t\t\t\tnum = docs[titre].keys\n\t\t\t\t@idDocument = num\r\n\t\t\t\t@fenetreOuvrirDoc.destroy()\r\n\t\t\tend\r\n\t\telse\r\n\t\t\t#si aucun document selectionné : message d'alerte\r\n\t\t\tquickMessage(\"Aucun document selectionne.\")\r\n\t\tend\r\n\tend", "def show\n if @input.devolucion\n @es_devolucion = \"Devolución\"\n else\n @es_devolucion = [\"Remito: \",@input.remito].join\n end\n end", "def specie; end", "def specie; end", "def specie; end", "def specie; end", "def informacion_cuenta\n puts \"---------------------------------\"\n puts \"N° cuenta: #{@id}\"\n puts \"Saldo total: #{@s_corriente + @s_ahorro}\"\n puts \"Saldo cuenta de ahorro: #{@s_ahorro}\"\n puts \"Saldo cuenta corriente: #{@s_corriente}\"\n puts \"Tasa de interes: #{@tasa}\"\n puts \"---------------------------------\"\n self\n end", "def sauvegarder(unNom)\n\t\tif nbSaves() >= 8\n\t\t\tdialog = Gtk::Dialog.new(\"Alerte\",\n \t $main_application_window,\n \t :destroy_with_parent,\n \t [ Gtk::Stock::OK, :none ])\n \t\t\tdialog.set_window_position(:center_always)\n\n \t # Ensure that the dialog box is destroyed when the user responds.\n \t dialog.signal_connect('response') { dialog.destroy }\n\n \t # Add the message in a label, and show everything we've added to the dialog.\n \t dialog.child.add(Gtk::Label.new( \"\\nImpossible:nombre maximum de sauvegardes atteint (8/8)!\\n\" ))\n \t dialog.show_all\n\t\telse\n\t\t\t# Serialisation des différentes classes\n\t\t\thypo = @hypo.to_yaml()\n\n\t\t\t# Ecriture dans le fichier\n\t\t\tmonFichier = File.open(\"../sauvegardes/\"+unNom, \"w\")\n\t\t\tmonFichier.write(hypo)\n\t\t\tmonFichier.write(\"***\\n\")\n\t\t\tmonFichier.write(@pseudo)\n\t\t\tmonFichier.write(\"\\n***\\n\")\n\t\t\tmonFichier.write(@inc)\n\t\t\tmonFichier.write(\"\\n***\\n\")\n\t\t\tmonFichier.write(@time)\n\t\t\tmonFichier.write(\"\\n***\\n\")\n\t\t\tmonFichier.write(@cheminMap)\n\t\t\tmonFichier.write(\"\\n***\\n\")\n\t\t\tmonFichier.write(@nbHypo)\n\t\t\tmonFichier.write(\"\\n***\\n\")\n\n\t\t\t# Fermeture du fichier\n\t\t\tmonFichier.close\n\t\tend\n\tend", "def devolver_nombre \n return @nombre\n end", "def formation; end", "def nombre\n\t\t@nombre\n\tend", "def recu\n if request.post? && params[:parent] && params[:courriel] then\n annee = (Date.today.month > 6 ? Date.today.year : Date.today.year - 1)\n parent = params[:parent]\n to = params[:courriel]\n unless @famille.recus.nil? || @famille.recus.empty?\n FamilleMailer.recu(@famille, @famille.recus, to, parent).deliver\n flash[:notice] = t(:public_recu_sent, to: to)\n else\n flash[:notice] = t(:public_recu_na)\n end\n redirect_to public_home_path\n return;\n end\n \n # On doit avoir une adresse courriel\n if @famille.courriels.empty?\n flash[:notice] = t(:public_recu_email_needed)\n redirect_to :action => 'edit'\n return\n end\n \n # Si on parvient jusqu'ici, on affiche le formulaire\n end", "def anulacion \n @solicitud=Solicitud.find(params[:id])\n @causal_select=CausalesAnulacionRevocatoria.find(:all,:conditions=>\"anulacion=true\",:order=>\"causa asc\")\n @width_layout = '660'\n end", "def show\n #Hicbir sey yazmasa da olur!!!\n setComment\n end", "def show\r\n @error=false\r\n begin\r\n @cargo=Rcargo::Cargo.find( BSON::ObjectId(params[:id])) #WHY need add BSON::Object, I \r\n # raise if @cargo.nil?\r\n rescue\r\n puts $@\r\n end\r\n # if not @error\r\n #for jubao purpose\r\n #@user=User.find(session[:user_id]) if session[:user_id]\r\n #update site statistic here\r\n #Sitedatum.first.inc(:cargoshow,1)\r\n \r\n #@jubao=Jubao.new\r\n #@jubaotype=\"cargo\"\r\n #@fromip=request.remote_ip\r\n #@belongid=params[:id]\r\n #@username=@user.name if @user \r\n #@wmail=Wmail.new\r\n \r\n #@wmail.subject=\"物流零距离货源信息-#{@cargo.fcity_name}-#{@cargo.tcity_name}-#{@cargo.created_at.to_s.slice(0,19)}\"\r\n # @wmail.mailtype=\"cargo_myself\"\r\n \r\n respond_to do |format|\r\n format.html # show.html.erb\r\n format.xml { render :xml => @cargo }\r\n end\r\n # else\r\n # respond_to do |format|\r\n # format.html { render \"cargos/showerror\"} # show.html.erb\r\n # format.xml { render :xml => @cargo }\r\n # end\r\n # end\r\n end", "def mostrar(marca)\n puts \"Marca: #{marca} - Modelo: #{nome}\"\n end", "def changerEnVide\n\t\t@couleur=-1\n\tend", "def index\n @detalle_orden_trabajos = DetalleOrdenTrabajo.all\n @detalle_orden_trabajos.repuesto_servicio = RepuestoServicio.first\n end", "def informa(pippo)\n # 1. Calcolo i valori di c14_idaliquotaiva e la loro frequenza in lbooks\n ivaInLbooks = Lbook.gruppiIVA\n risultL = \"1. Segue hash ivaInLbooks: #{ivaInLbooks.inspect}\"\n pippo.scriviRiga(risultL)\n\n # 2. Calcolo i valori di idaliquotaiva e la loro frequenza in books\n ivaInBbooks = Book.gruppiIVA\n risultB = \"2. Segue hash ivaInBbooks: #{ivaInBbooks.inspect}\"\n pippo.scriviRiga(risultB) \nend", "def show\n @mia_tabella = Search.mia_tabella(@search.tabella)\n @mio_campo = Search.mio_campo(@search.campo)\n @mio_tipo = Search.mio_tipo(@search.tipo)\n #\n @descrizione = @search.descrivi()\n end", "def show\n @competencia = Competencia.find(params[:id])\n #Resuelve el nombre del Cliente \n c = Cliente.where(:id => @competencia.razonsocial)\n c[0].razonsocial\n @competencia.razonsocial = c[0].razonsocial\n \n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @competencia }\n end\n end", "def troca\n @remetente = Sobrevivente.where(id: params[:de]).first\n @destinatario = Sobrevivente.where(id: params[:para]).first\n\n enviar = {agua: 1, comida: 2, medicamento: 3, municao: 4}\n receber = {agua: 0, comida: 2, medicamento: 3, municao: 8}\n\n trocou = @remetente.troca(@destinatario, enviar, receber)\n\n render json: { status: trocou }\n end" ]
[ "0.6417766", "0.6188226", "0.60239285", "0.6008295", "0.6005342", "0.5946158", "0.5909313", "0.58419067", "0.58419067", "0.5831526", "0.58143795", "0.5789364", "0.57860494", "0.5778818", "0.5727165", "0.57262605", "0.57159233", "0.5681059", "0.56730354", "0.5669841", "0.5668934", "0.56668997", "0.5655061", "0.56451744", "0.5627195", "0.5616963", "0.5615482", "0.560957", "0.5608172", "0.55849755", "0.55700463", "0.5550789", "0.55426425", "0.5542291", "0.55333626", "0.5532163", "0.5525059", "0.5521519", "0.5521519", "0.55193466", "0.55178386", "0.55073196", "0.5504315", "0.5502666", "0.5500049", "0.54998016", "0.5497503", "0.5483898", "0.5479924", "0.5472325", "0.54633605", "0.5453389", "0.5452167", "0.545099", "0.5445626", "0.54440355", "0.5442172", "0.54418224", "0.54407954", "0.5440301", "0.54402274", "0.5439777", "0.5434416", "0.54328847", "0.54139996", "0.54134965", "0.54057956", "0.5405752", "0.5403333", "0.5402945", "0.5401208", "0.5400725", "0.540014", "0.5396366", "0.5396085", "0.5394934", "0.5376066", "0.5374433", "0.5374042", "0.5361647", "0.53588676", "0.5347423", "0.5347423", "0.5347423", "0.5347423", "0.53391737", "0.5333948", "0.5332255", "0.53321654", "0.53308517", "0.5328802", "0.53284705", "0.53251916", "0.53245485", "0.5319371", "0.53193545", "0.53172165", "0.5316004", "0.5311648", "0.53110105", "0.53104436" ]
0.0
-1
== Metodo producto Dispersa
def *(other) #if ((other.class.to_s == "Dispersa") && (other.fil == @fil) && (other.col == @col)) matrizProd = Array.new(@fil) {Array.new(@col) {0}} 0.upto(other.numElementos - 1) do |i| if (other.filM[i] = @colM[i]) matrizProd[@filM[i]][@colM[i]] += @eleM[i] * other.eleM[i] end end #puts "prod = #{matrizProd}" return matrizProd #else #raise ArgumentError, "Matrices de distinto tamanio" #end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def products\n end", "def show\r\n @productos = Producto.where(\"producto_padre_id = ?\",@producto_padre.id);\r\n end", "def product\n nic_view.product\n end", "def retorna_nome_produto\n titulo_produto.greenify\n titulo_produto.text\n end", "def show\n combo_producto\n combo_platillo\n end", "def show\n add_breadcrumb \"Detalles\", @reqcargos\n end", "def show\n add_breadcrumb \"Detalles\", @centro_costos\n end", "def llenar_productos\n self.productos = self.clase.descripcion unless self.clase.nil?\n end", "def show\n @produtos = @fornecedor.produtos\n @telefones = @fornecedor.telefones\n @emails = @fornecedor.emails\n end", "def show\n add_breadcrumb \"Detalles\", @prospectos\n end", "def show\n@productos = @vendedor.producto.all\n end", "def tipoproductopf_de_productopf\n if params[:id] && params[:id].to_i>0 &&\n Productopf.where(id: params[:id].to_i).count == 1\n pr = Productopf.find(params[:id].to_i)\n respond_to do |format|\n format.js { render text: pr.tipoproductopf_id }\n format.json { render json: pr.tipoproductopf_id, status: :created }\n format.html { render inline: 'No implementado', \n status: :unprocessable_entity }\n end\n else\n render inline: 'Falta paŕametro', status: :unprocessable_entity \n end\n end", "def index\n @productos_detalles = ProductoDetalle.all\n end", "def description_bonita\n \t\"#{description} #{product.name}\"\n end", "def get_products_dato(id)\n products = Product.find_by(company_id: self.id,id: id) \n \n if products.unidad == nil\n return products.name + \" - \" \n else \n return products.name + \" - \"+products.unidad \n end \n end", "def show\n @ven_pros = @sale.sale_products.order(:quantity)\n @products = Product.all\n @sale_item = @sale.sale_products.new\n\n\n\n\n @sar = SaleProduct.where sale_id: @sale.id\n\n respond_to do |format|\n format.html\n format.pdf {render pdf: \"sale\",\n template: \"sales/sale.pdf.erb\",\n locals: {:sale => @sale}}\n end\n\n\n\n end", "def showBusqueda\n id = session[:farmacia_id]\n laboratorio = params[:laboratorio]\n nombre = params[:producto_id]\n @lab = Laboratorio.find_by_sql(\"select nombre, id from laboratorios where id = #{laboratorio} \").first \n sql = \"Select * from productos where not exists (select * from pro_fars where pro_fars.producto_id = productos.id and pro_fars.farmacium_id = #{id}) and laboratorio_id = #{laboratorio} and LOWER(nombre) like LOWER('%#{nombre}%') order by nombre\"\n @productos = Producto.paginate_by_sql(sql, :page => params[:page], :per_page => 8)\n\n @pro_far = ProFar.new\n render :template => \"pro_fars/index\"\n end", "def get_products_dato(id)\n products = Product.find_by(company_id: self.id,id: id) \n if products.unidad == nil\n return products.name + \" - \" \n else \n return products.name + \" - \"+products.unidad \n end \n end", "def get_products_dato(id)\n products = Product.find_by(company_id: self.id,id: id) \n if products.unidad == nil\n return products.name + \" - \" \n else \n return products.name + \" - \"+products.unidad \n end \n end", "def pro_farmBusqueda\n id = session[:farmacia_id]\n laboratorio = params[:laboratorio]\n nombre = params[:producto_id]\n @lab = Laboratorio.find_by_sql(\"select id, nombre from laboratorios where id = #{laboratorio} \").first\n sql = \"select * from pro_fars, productos, disponibilidads where pro_fars.producto_id = productos.id and disponibilidads.id =pro_fars.disponibilidad_id and productos.laboratorio_id = #{laboratorio} and pro_fars.farmacium_id = #{id} and LOWER(productos.nombre) like LOWER('%#{nombre}%') order by productos.nombre\"\n @productos = ProFar.paginate_by_sql(sql, :page => params[:page], :per_page => 7)\n render :template => \"pro_fars/productosfarmacia\"\n end", "def show\n \n @product = []\n @order.product_id.each do |z|\n a = Product.find(z[0])\n @product << a\n end\n @product\n @order\n end", "def show\n @lista_precio = ListaPrecio.find(params[:id])\n @producto_listas = @lista_precio.producto_lista_precios.paginate(:page => params[:page],:per_page => 30)\n @cant_productos = @lista_precio.producto_lista_precios.count \n\n respond_to do |format|\n format.html \n format.xml { render :xml => @lista_precio}\n end\n end", "def show\n @productos = Producto.all\n @cta_cte = CtaCte.where(matriculacion_id: @matriculacion.id).first\n @movimientos = Movimiento.where(cta_cte_id: @cta_cte.id)\n end", "def display_product\n STDOUT.puts \"--\"*50\n STDOUT.puts \"title: \\t\\t#{$title}\"\n STDOUT.puts \"seller: \\t#{$seller}\"\n STDOUT.puts \"price: \\t\\t#{$price}\"\n STDOUT.puts \"stars: \\t\\t#{$stars}\"\n STDOUT.puts \"reviews: \\t#{$reviews}\"\n STDOUT.puts \"image url: \\t#{$image_href}\"\n STDOUT.puts \"product url: \\t#{$url}\"\n end", "def display_resource(product)\n \"#{product.english_title}\"\n end", "def print_products\n linking(\"EpublicationBasedOnPrintProduct\") + self.alternative_format_products.select{|rp| rp.form && rp.form.code=~/^B/}\n end", "def to_s\n\t\t\"Por 100g o 100ml de producto\\tIr del producto\\tPor porcion de X gramos\\tIR por porcion\\n\"+\n\t\t\" Valor energetico: #{valorenergeticoKJ}/#{valorenergeticoKcal}\\t#{irenergeticoKJ}/#{irenergeticoKcal}\\t#{valorenergeticoKJp}/#{valorenergeticoKcalp}\\t#{irenergeticoKJp}/#{irenergeticoKcalp}\\n\"+\n\t\t\" Grasas: #{cgrasas}\\t#{irgrasas}\\t#{valorgrasasp}\\t#{irgrasasp}\\n\"+\n\t\t\" Grasas monosaturadas: #{grasasmono}\\t#{irmonograsas}\\t#{valormonograsasp}\\t#{irmonograsaslp}\\n\"+\n\t\t\" Grasas poliinsaturadas: #{grasaspoli}\\t#{irpoliinsaturadas}\\t#{valorgrasasp}\\t#{irpoliinsaturadas}\\n\"+\n\t\t\" Hidratos de carbono: #{hcarbono}\\t#{irhidratos}\\t#{valorhidratosp}\\t#{irhidratosp}\\n\"+\n\t\t\" Azucares: #{azucares}\\t#{irazucares}\\t#{valorazucaresp}\\t#{irazucaresp}\\n\"+\n\t\t\" Polialcoholes: #{polialcoholes}\\t#{irpolialcoholes}\\t#{valorpolialcoholesp}\\t#{irpolialcoholesp}\\n\"+\n\t\t\" Almidon: #{almidon}\\t#{iralmidon}\\t#{valoralmidonp}\\t#{iralmidonp}\\n\"+\n\t\t\" Fibra alimentaria: #{fibra}\\t#{irfibra}\\t#{valorfibrap}\\t#{irfibrap}\\n\"+\n\t\t\" Sal: #{sal}\\t#{irsal}\\t#{valorsalp}\\t#{irsalp}\\n\"+\n\t\t\" Vitamina/mineral: #{vitymin}\\t#{irvitaminas}\\t#{valorvityminp}\\t#{irvitaminasp}\\n\"\n\tend", "def show\n @titulo = \"Ver Pedido\"\n @clase = \"Pedidos\"\n end", "def consulta_prod\n @product = Product.select('codigo_ncm,cest').where(name: params[:name]).first\n respond_to do |format|\n format.html\n format.json { render :json => @product }\n end\n #------------DEU CERTO GLORIA Á DEUS!!!-----------------------------------------------\n end", "def partido\n localidad.partido\n end", "def product_name; end", "def index\n @quimicos_serigrafia_productos = QuimicosSerigrafiaProducto.all\n end", "def product_information\n super\n end", "def title\n \"line item for #{product.name}\"\n end", "def show\n\t\t@cart = current_cart\n\t\t\n\t\t# para mostrar a listagem de produtos na barra lateral (partial)\n\t\t@products = Product.all\n\tend", "def index\n @pedido_produtos = PedidoProduto.where(pedido_id: @pedido.id)\n end", "def show\n #calculo de presupuesto\n \n end", "def show\n\n @client = Client.find(@invoice.client_id)\n @total_items = Item.where(invoice_id: @invoice.id).sum(:total_value_sale)\n @lucro_total = Item.where(invoice_id: @invoice.id).sum(:profit_sale)\n @products = Product.order(:name)\n\n end", "def print_products\n\treturn \"\n ____ _ _ \n | _ \\\\ _ __ ___ __| |_ _ ___| |_ ___ \n | |_) | '__/ _ \\\\ / _` | | | |/ __| __/ __|\n | __/| | | (_) | (_| | |_| | (__| |_\\\\__ \\\\\n |_| |_| \\\\___/ \\\\__,_|\\\\__,_|\\\\___|\\\\__|___/\\n\\n\"\n\nend", "def show\n @productonegocio = Productonegocio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @productonegocio }\n end\n end", "def show\n @pedido=@item.pedido\n end", "def show\n @product = Product.all\n# respond_to do |format|\n# format.html # show.html.erb\n# format.xml { render :xml => @product }\n# end\n\tprawnto :filename => 'Report-Products.pdf', :inline => false\n\n end", "def index\r\n @producto_padres = ProductoPadre.all\r\n end", "def show\n @stock_negativo = @compra.check_detalles_negativos(true)\n end", "def produkt_bestilling(order)\n @fornavn = order.company_detail.first_name\n @etternavn = order.company_detail.last_name\n @fullt_navn = \"#{order.company_detail.first_name} #{order.company_detail.last_name}\"\n @epost = order.company_detail.email\n @produkt = order.product.name\n @pris = order.total\n\n\n mail(to: @epost, subject: 'Ordrebekreftelse - Logo Maker\\'n')\n end", "def index\n \n @producto_ofertados = ProductoOfertado.all\n end", "def name\n @product.name\n end", "def show\n @pcs = Pc.all\n @gjuhas = Gjuha.all\n @qytetets = Qytetet.all\n @pozi = Pozi.all\n @formularis= Formulari.find(params[:id])\n @status = Status.all\n respond_to do |format|\n format.html\n format.pdf do\n pdf=OrderPdf.new(@formularis)\n send_data pdf.render,\n filename: \"\", type: \"application/pdf\", desposition: \"inline\"\n end\n end\n end", "def multiples_facturas_confirmar_parciales\n @width_layout=1180\n @form_title = I18n.t('Sistema.Body.Modelos.OrdenDespachoDetalle.Mensajes.orden_despacho_insumos') \n @form_title_record = I18n.t('Sistema.Body.Modelos.OrdenDespachoDetalle.Mensajes.orden_despacho_insumo') \n end", "def mostrar_partidos\n \n puts \" \"\n puts \"Quantidade de votos por partido\"\n \n for partido in @partido\n partido.mostrar_dados \n end\n end", "def index\n @orden_products = OrdenProduct.all\n end", "def index\n @productos = Producto.all\n end", "def index\n @productos = Producto.all\n end", "def show\n @product = Product.where([\"id = ?\", params[:id].to_i]).first\n raise NoProductError if @product.blank?\n\n @providers = @product.providers\n @product_contents = @product.contents\n\n @shop = @product.shop\n raise NoShopError if @shop.blank?\n \n @reviews = @product.reviews\n @review_images = @product.review_images\n \n @main_review = @reviews.first\n @main_image = @product.images.try(:first)\n @countries = Country.all\n\n add_breadcrumb \"#{@shop.name} - #{@product.name} 商品詳細\", product_path\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n @title = \" #{@product.try(:color).try(:name)}-#{@products.try(:name)}-#{@product.try(:sort).try(:name)} \"\n @keywords =\"#{@product.try(:name)} #{@product.try(:sort).try(:name)} #{@product.try(:color).try(:name)}\"\n @description =\"#{@product.try(:name)}#{@product.try(:sort).try(:name)}#{@product.try(:color).try(:name)}#{@product.try(:introduction)}\"\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @product }\n end\n end", "def index\n @papel_sublimacion_productos = PapelSublimacionProducto.all\n end", "def index\n @lista_produtos = ListaProduto.all\n end", "def desplegarProceso\n\t\tputs \"id=#{@id} cantBytes=#{@cantBytes} cantPaginas=#{@cantPaginas}\"\n\t\tputs \"marcosRealAsig=#{@marcosRealAsig} marcosSwapAsig=#{@marcosSwapAsig}\"\n\tend", "def index\n @relacao_produtos = RelacaoProduto.all\n end", "def show\n @products = CatalogMebeli.find(params[:id]).products\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @product }\n end\n end", "def procesarOc(ordenCompra)\n\trespuesta = ProveedorRecibirOcFtp.new.responderOc(ordenCompra)\n\tputs ':) Procesando OC: '<< ordenCompra._id.to_s\n\tif(respuesta) #Si la aceptamos, debemos ir a generar Factura\n\t\tputs ':) Aceptamos OC'\n\t\tif(ProveedorEnviarFacturaFtp.new.enviarFactura(ordenCompra._id)) #Si se genera la Factura, debemos despachar producto\n\t\t\tputs ':) Enviamos Factura'\n\t\t\tProveedorDespacharProductos.new.despacharProductos(ordenCompra, true)\n\t\t\tputs ':) Despachamos productos'\n\t\t\treturn respuesta\n\t\tend\n\tend\n\n\treturn respuesta\nend", "def show\n # config de layout \n @layout = Array.new \n @layout[0] = \"produto\" \n @layout[1] = \"Ficha do Produto\" \n @layout[2] = \"slogan\" \n @layout[3] = \"COD: \" + \"%07d\" % params[:id] \n @layout[4] = \"\"\n @layout[5] = \"/adm/produtos/search\" \n \n @adm_produto = Adm::Produto.find(params[:id])\n \n # LEMBRETE\n # Para a edicao dos modelos produto_extra funcione, eh preciso \n # criar uma funcao do application_helper que possibilita ativar ou\n # não o java script que abre o form de edicao.\n # Inclusive eh tb por isso que o DIV que faz o efeito light box fica\n # criado na pagina e não dinamicamente como o de costume.\n \n # obtendo registros\n @arquivos_full = Arquivo.where(['fl_sistema = 1 AND produto_id = ?', @adm_produto.id]).all\n @adm_produto_extras_full = Adm::ProdutoExtra.where(['produto_id = ?', @adm_produto.id]).all\n \n # filtrando pela permissao do usuário os registros que ele pode ver\n if session[:usuario].status.area.codigo == '0'\n @arquivos = @arquivos_full\n @adm_produto_extras = @adm_produto_extras_full\n else\n @arquivos = @arquivos_full.find_all {|a| a.status.codigo == '0' }\n @adm_produto_extras = @adm_produto_extras_full.find_all {|p| p.status.codigo == '0' }\n end\n\n # verificando se é uma edição de Produto Extra\n if params[:id_produto_extras]\n @adm_produto_extra = Adm::ProdutoExtra.find(params[:id_produto_extras])\n else\n @adm_produto_extra = Adm::ProdutoExtra.new\n end\n \n # obtendo dados extras\n @historico = LogProduto.order(\"created_at DESC\").limit(10).where([\"produto_id = ?\", @adm_produto.id]).all\n \n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @adm_produto }\n end\n end", "def verProductos()\n for i in (0..$productos.size-1) #filas (i)\n for j in (0..$productos[i].size-1) #columnas (j)\n print \"{$productos[i][j]} \\s\"\n end\n print \"\\n\"\n end\nend", "def index\n @reprodutores = Reprodutor.all\n end", "def sample_products_list(facturama)\n puts \"===== Obtener los productos - Inicio =====\"\n\n lst_products = facturama.products.list # Se obtiene una lista con todos los productos\n lst_products_count = lst_products.count # Cantidad inicial de productos\n\n puts \"Cantidad inicial de productos: \" + lst_products_count.to_s\n\n puts \"===== Obtener los productos - Fin =====\"\n end", "def show\n set_meta_tags title: \"#{@item.name} | #{@place.is_restaurant? ? \"Categorías\" : \"Departamentos\"} #{@place.name}\",\n description: \"#{@item.name} | #{@place.is_restaurant? ? \"Categorías\" : \"Departamentos\"} #{@place.name}\"\n @products = @place.products.where(:item_ids.in => [@item.id]).paginate(page: params[:page], per_page: 30)\n end", "def index\n @entrada_produtos = EntradaProduto.all\n end", "def index\n @troca_produtos = TrocaProduto.all\n end", "def create_product\n\t\tproduct_attributes = @view.creando_producto\n\t\t@store.add_product(product_attributes[0], product_attributes[1])\n\t\toption = @view.second_view(@current_user, @current_user.actions)\n\t\tlist(option)\n\tend", "def index\n @titulo = \"Todos los proveedores\"\n unless params[:filtro].nil?\n proveedores = []\n if FiltroListaProveedores::FILTROS.include?(params[:filtro]) and not params[:valor].nil?\n case params[:filtro]\n when \"categoria\"\n @categoria = Categoria.find(params[:valor])\n proveedores = @categoria.nil? ? [] : @categoria.proveedores\n @cant_resultados = proveedores.size\n @titulo = @categoria.nombre\n when \"tipo\"\n existe_tipo = Proveedor::TIPO_EMPRESA.include?(params[:valor])\n @tipo = existe_tipo ? params[:valor].to_s.humanize : nil\n proveedores = existe_tipo ? Proveedor.where(:tipo_proveedor => params[:valor]) : []\n @cant_resultados = proveedores.size\n @titulo = existe_tipo ? @tipo : \"Por tipo\"\n when \"ubicacion\"\n @ubicacion = UbicacionGeografica.find(params[:valor])\n unless @ubicacion.nil? or @ubicacion.tipo != 'estado'\n #case @ubicacion.tipo\n #when 'pais'\n # proveedores = @ubicacion.proveedores_de_pais\n #when 'estado'\n proveedores = @ubicacion.proveedores\n #when 'municipio'\n # proveedores = @ubicacion.proveedores_de_municipio\n #when 'localidad'\n # proveedores = @ubicacion.proveedores_de_localidad\n #end\n end\n @cant_resultados = proveedores.size\n @titulo = @ubicacion.tipo.humanize+\" \"+@ubicacion.nombre\n end\n end\n else\n proveedores = Proveedor.order('created_at DESC')\n end\n @cant_resultados = proveedores.size\n @proveedores = proveedores.includes(:localidad,:municipio,:estado).order('created_at DESC').page(params[:p])\n @titulo += \" (\"+@cant_resultados.to_s+\")\"\n add_breadcrumb :index, :proveedores_path\n @categorias = Categoria.con_proveedores\n @categorias_meta = \"\"\n for c in @categorias\n @categorias_meta += c.nombre+\", \"\n end\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @proveedores }\n end\n end", "def list_products\n @products.map { |p| \"#{p.name} costs £#{p.price / 100.round(2)}\" }\n end", "def index\n @product_intros = ProductIntro.all\n end", "def index\n @produto_pedidos = ProdutoPedido.all\n end", "def index\n @produto_pedidos = ProdutoPedido.all\n end", "def show\n @operacao = 'Visualização'\n end", "def show\n @produto = Produto.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @produto }\n end\n end", "def show\n @produto = Produto.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @produto }\n end\n end", "def show\n @produto = Produto.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @produto }\n end\n end", "def index\n\n @productos = Producto.where(estado: \"Disponible\").order(\"horaaprobacion DESC\").page(params[:page]).per(15)\n if params[:term]\n palabra= \"%#{params[:term]}%\"\n @productos = Producto.where(estado: \"Disponible\").where(\"titulo LIKE ?\",palabra).order(\"horaaprobacion DESC\").page(params[:page]).per(15)\n end\n end", "def informa(pippo)\n # 1. Calcolo i valori di c14_idaliquotaiva e la loro frequenza in lbooks\n ivaInLbooks = Lbook.gruppiIVA\n risultL = \"1. Segue hash ivaInLbooks: #{ivaInLbooks.inspect}\"\n pippo.scriviRiga(risultL)\n\n # 2. Calcolo i valori di idaliquotaiva e la loro frequenza in books\n ivaInBbooks = Book.gruppiIVA\n risultB = \"2. Segue hash ivaInBbooks: #{ivaInBbooks.inspect}\"\n pippo.scriviRiga(risultB) \nend", "def show\n @diagnosticos = Diagnostico.all\n @stock_medicas = StockMedica.where(diagnostico_id == ficha_doc.diagnostico_id) \n end", "def show\n @hasProduct = HasProduct.new\n @has_used_supply = HasUsedSupply.new\n @order_detail = OrderDetail.new\n\n if @order.paid == 'No pagado'\n # Quotations\n real = HTTParty.get('https://api.cambio.today/v1/quotes/BRL/PYG/json?quantity=1&key=2291|UcRBwxvE*C~uzgnYu6~ESYN5VbugBB6A')\n peso = HTTParty.get('https://api.cambio.today/v1/quotes/ARS/PYG/json?quantity=1&key=2291|UcRBwxvE*C~uzgnYu6~ESYN5VbugBB6A')\n dolar = HTTParty.get('https://api.cambio.today/v1/quotes/USD/PYG/json?quantity=1&key=2291|UcRBwxvE*C~uzgnYu6~ESYN5VbugBB6A')\n @dolar = JSON.parse(dolar.body)\n @peso = JSON.parse(peso.body)\n @real = JSON.parse(real.body)\n end\n end", "def show\n @sistemas = Sistema.all\n @defeitos = Defeito.where(release_note_id: @release_note.id)\n @observacoes = Observacao.where(release_note_id: @release_note.id)\n @integracoes = Integracao.where(release_note_id: @release_note.id)\n @caracteristica_releases = CaracteristicaRelease.where(release_note_id: @release_note.id)\n end", "def limpar\n\t\tfor ct in (0..($CarrinhoCompras.size - 1))\n\t\t\t$CarrinhoCompras[ct] = \"\"\n\t\tend\n\t\tfor ct in (0..($CarrinhoComprasQuant.size - 1))\n\t\t\t$CarrinhoComprasQuant[ct] = 0\n\t\tend\n\t\t\n\t\t\t$CarrinhoCompras.delete(\"\")\t\t# APAGANDO ITENS DO CARRINHO\n\t\t\t$CarrinhoComprasQuant.delete(0)\t\t# APAGANDO Quantidade referente a item\n\t\tredirect_to \"/compras?pd=\" + Admloja.first.mcab.to_s\n\tend", "def naturalista_observaciones_service(proveedor)\n puts \"\\t\\tGenerando las observaicones de NaturaLista\"\n # Para las nuevas observaciones\n proveedor.kml_naturalista\n return unless proveedor.naturalista_kml.present?\n proveedor.kmz_naturalista\n puts \"\\t\\tCon KMZ naturalista\"\n end", "def destroy\n \n @company = Company.find(1)\n \n title =@orden_product.avisodetail.descrip \n \n if @orden_product.destroy\n flash[:notice]= \"Item fue eliminado satisfactoriamente \"\n redirect_to @orden \n else\n flash[:error]= \"Item ha tenido un error y no fue eliminado\"\n render :show \n end \n \n end", "def index\n @productos_por_clientes = ProductosPorCliente.all\n end", "def display_products\n\n puts \"Welcome to our store! We have following products in our store:\"\n @products.each do |product|\n puts \"Reference Number: #{product[:reference_number]}, Product: #{product[:name]}, Price: #{product[:price]}\"\n end\nend", "def show\n @empresa = Empresa.find(params[:empresa_id]) \n @producto = @empresa.productos.find(params[:producto_id])\n @item_producto = @producto.item_productos.find(params[:item_producto_id])\n @opinion = @item_producto.opinions.find(params[:id])\n end", "def index\n @producto_seccions = ProductoSeccion.all\n end", "def index\r\n authorize! :read, Product\r\n @page_title = \"بيانات الأصناف\"\r\n @products = Product.sorted\r\n end", "def retorna_nome_primeiro_produto\n nome_primeiro_produto.greenify\n nome_primeiro_produto.text\n end", "def new\n @producto = Producto.new\n @producto.alimento = true #Para que aparezca un default en el select\n usuarios = Usuario.where(:admin => 0) #Para coleccion del dueño del producto\n prod = Producto.all\n @marcas = get_marcas(prod)\n @fabricantes = get_fabricantes(prod)\n @companias = []\n for elem in usuarios do\n @companias.push([elem.compania, elem.id])\n end\n flash[:accion] = \"Crear Producto\"\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @producto }\n end\n end", "def index\n @foto_produtos = FotoProduto.all\n end", "def InfoProducto\n \tid = params[:id]\n @productos = Producto.find_by_sql(\"select distinct productos.nombre as nombreProducto, productos.id as idProducto, productos.oferta, productos.compra, laboratorios.nombre as nombreLaboratorio, presentacions.descripcion, plan_pacientes.id, \n\t\tplan_pacientes.nombre as nombrePlanPaciente, plan_pacientes.id as idPlanPaciente,\n\t\tsustancia.descripcion as descripcionSustancia\n\t\t from productos, presentacions, plan_pacientes, laboratorios, sustancia where \n\t\tproductos.presentacion_id = presentacions.id and\n\t\tproductos.laboratorio_id = laboratorios.id and\n\t\tproductos.sustancium_id = sustancia.id and\n\t\tproductos.id = #{id} LIMIT 1\")\n render json: @productos\n end", "def show\r\n checar_super_agencia\r\n end", "def description\n\t\tif params[:preview]\n session[:preview] = true\n end\n \n @object = find_product_or_service(params[:slug])\n \n if @object.nil?\n redirect_to bazar_path\n else \n @description = @object.description\n @supplier = @object.supplier_account.supplier\n \t\t@schedule = @object.schedule if @object.is_a? Service\n @title_content = @supplier.supplier_account.fantasy_name+': '+@object.name+' | Descripción'\n \t@meta_description_content = @supplier.supplier_account.fantasy_name+' | '+@object.name+': '+@object.description\n products_and_services_breadcrumbds(@object)\n end\n if numeric? params[:slug]\n redirect_to products_and_services_catalog_description_path(:slug => @object.slug)\n end\n end", "def index\n @caracteristica_propiedads = CaracteristicaPropiedad.all\n end", "def discount_title(scan)\n if scan.product.is_a? BuyXGetXProduct\n \"Buy #{scan.product.num_to_buy} #{scan.product.title.pluralize} Get #{scan.product.num_will_get}\"\n else\n \"#{scan.product.title} Bulk Purchase\"\n end\n end", "def labAddProduct\n @productos = Producto.all\n render :template => \"lab_fars/productoadd\"\n end", "def show\n begin\n @product = Product.published.find(params[:id])\n rescue\n return render_not_found\n end\n @title = \"КАТАЛОГ // #{@product.name}\"\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @product }\n end\n end" ]
[ "0.6475011", "0.639226", "0.63387185", "0.6226604", "0.61944246", "0.6190762", "0.6188815", "0.61596507", "0.6116307", "0.6112368", "0.6110953", "0.6102688", "0.60977286", "0.6095239", "0.6083448", "0.60633254", "0.60617805", "0.6054588", "0.6054588", "0.60425776", "0.60290504", "0.6028202", "0.60278696", "0.59904075", "0.5988008", "0.5975627", "0.5967414", "0.5958971", "0.59228975", "0.5919333", "0.5912924", "0.5898434", "0.5897241", "0.58469415", "0.58462995", "0.5845506", "0.58443373", "0.5842585", "0.5841668", "0.5832442", "0.58267015", "0.5814639", "0.57938826", "0.5786769", "0.57860684", "0.5779903", "0.5779001", "0.5776435", "0.5766903", "0.5760077", "0.5759351", "0.575838", "0.575838", "0.574227", "0.57422113", "0.574059", "0.57354116", "0.5733622", "0.5732752", "0.5731332", "0.5726309", "0.5720653", "0.5716608", "0.57132727", "0.570375", "0.56989753", "0.5697363", "0.5691671", "0.56881297", "0.568361", "0.5682815", "0.56824005", "0.5679726", "0.5679726", "0.5676865", "0.5676193", "0.5676193", "0.5676193", "0.567296", "0.56710017", "0.56649536", "0.56615025", "0.5650086", "0.56316054", "0.5623283", "0.56171787", "0.5616554", "0.5604309", "0.56028396", "0.5601711", "0.5601518", "0.56004596", "0.55969596", "0.55897486", "0.55838245", "0.557725", "0.5576712", "0.55764353", "0.557579", "0.5571897", "0.55657995" ]
0.0
-1
GET /field_definitions GET /field_definitions.json
def index if params[:step_definition_id] step_definition = StepDefinition.find(params[:step_definition_id]) if step_definition != nil @field_definitions = step_definition.field_definitions else @field_definitions = [] end else @field_definitions = FieldDefinition.all end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def definitions(key, field=nil)\n begin\n defs = self.definition_schema[key]\n if field.present?\n defs[field]\n else\n defs\n end\n rescue NoMethodError => e\n field_key = field.present? ? \"#{key}/#{field}\" : key\n ErrorTracker.report_exception(e, self.study.user, { missing_key: field_key, analysis_metadatum: self.attributes.to_h})\n Rails.logger.error \"Error accessing remote HCA Analysis metadata field definitions for #{field_key}: #{e.message}\"\n nil\n end\n end", "def create\n @field_definition = FieldDefinition.new(field_definition_params)\n\n respond_to do |format|\n if @field_definition.save\n format.html { redirect_to @field_definition, notice: 'Field definition was successfully created.' }\n format.json { render :show, status: :created, location: @field_definition }\n else\n format.html { render :new }\n format.json { render json: @field_definition.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_field_definition\n @field_definition = FieldDefinition.find(params[:id])\n end", "def definitions() return @definitions end", "def definitions\n @definitions ||= { responses: {} }\n end", "def get_field_list\n return make_request(\"#{self.endpoint}/list/fields\")\n end", "def get_object_definition(object_type)\n result = {}\n definition = @client.get_business_object_definition(object_type)\n selector = 'BusinessObjectDef > FieldList > Field'\n Nokogiri::XML(definition).css(selector).map do |field|\n result[field['Name']] = field.css('Description').inner_html\n end\n return result\n end", "def definitions\n definitions_repository.all\n end", "def get_fields()\n return @api.do_request(\"GET\", get_base_api_path() + \"/fields\")\n end", "def attribute_definition_of(field)\n @attribute_definitions.find_field(field)\n end", "def index\n @custom_definitions = CustomDefinition.all\n end", "def definitions\n @definitions ||= g_definitions\n end", "def definitions\n # Some httparty work to fetch definitions from Websters\n end", "def definitions(word)\n MinWords::DB[:defines].where(word_id: word[:id]).all\n end", "def definitions\n return @definitions\n end", "def fields\n @fields ||= {}\n end", "def fields\n @fields ||= {}\n end", "def fields\n @fields ||= {}\n end", "def fields\n @fields ||= {}\n end", "def fields\n @fields ||= {}\n end", "def to_h\n hash = {}\n self.class.field_definitions.each do |k, v|\n hash[k] = field_value k\n end\n hash\n end", "def types\n FIELD_TYPES\n end", "def index\n @definitions = Definition.all\n end", "def definitions; end", "def definitions; end", "def get_fields\n FIELD_DESCS\n end", "def definitions=(value)\n @definitions = value\n end", "def get_config_var_definitions(variable_id)\n path = \"/d2l/api/lp/#{$lp_ver}/configVariables/(#{variable_id}/definition\"\n _get(path)\n # returns Definition JSON data block\nend", "def generate_definitions_list\n definitions = YARD::Registry.all(:definition).uniq.sort_by{|define| define.name.to_s}\n generate_full_list(definitions, 'Definition', 'definitions')\nend", "def fields\n @fields ||= FieldList.new\n end", "def list_service_definitions_with_http_info(opts = {})\n\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ServiceDefinitionAPI.list_service_definitions ...'\n end\n allowable_values = ['v1', 'v2', 'v2.1']\n if @api_client.config.client_side_validation && opts[:'schema_version'] && !allowable_values.include?(opts[:'schema_version'])\n fail ArgumentError, \"invalid value for \\\"schema_version\\\", must be one of #{allowable_values}\"\n end\n # resource path\n local_var_path = '/api/v2/services/definitions'\n\n # query parameters\n query_params = opts[:query_params] || {}\n query_params[:'page[size]'] = opts[:'page_size'] if !opts[:'page_size'].nil?\n query_params[:'page[number]'] = opts[:'page_number'] if !opts[:'page_number'].nil?\n query_params[:'schema_version'] = opts[:'schema_version'] if !opts[:'schema_version'].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(['application/json'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:debug_body]\n\n # return_type\n return_type = opts[:debug_return_type] || 'ServiceDefinitionsListResponse'\n\n # auth_names\n auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth, :AuthZ]\n\n new_options = opts.merge(\n :operation => :list_service_definitions,\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 :api_version => \"V2\"\n )\n\n data, status_code, headers = @api_client.call_api(Net::HTTP::Get, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ServiceDefinitionAPI#list_service_definitions\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def find_datastore_form_attribute_definitions(params={}, headers=default_headers)\n @logger.info(\"Finding Datastore Form Attribute Definitions\")\n get(\"#{@api_url}/datastoreFormAttributeDefinitions\", params, headers)\n end", "def field_definition_params\n params.permit(:field_definition,:name, :field_type, :validationRegex, :required, :step_definition_id, :errorMessage, :order)\n end", "def get_field_deserializers()\n return super.merge({\n \"definitions\" => lambda {|n| @definitions = n.get_collection_of_object_values(lambda {|pn| MicrosoftGraph::Models::AccessReviewScheduleDefinition.create_from_discriminator_value(pn) }) },\n \"historyDefinitions\" => lambda {|n| @history_definitions = n.get_collection_of_object_values(lambda {|pn| MicrosoftGraph::Models::AccessReviewHistoryDefinition.create_from_discriminator_value(pn) }) },\n })\n end", "def print_definition()\n puts \"Definition\"\n puts \"----------------------------------------\"\n puts @word_info[:title], \" \"\n @word_info[:types_definitions].each do |type|\n puts \"\\t\" + type[:type]\n type[:definitions].each_with_index do |defintion, i|\n puts \"\\t #{i+1}. #{defintion}\"\n end\n print \"\\n\"\n end\n end", "def create\n\n step_definition_attributes = step_definition_params\n field_definitions_attributes = step_definition_attributes.delete(\"field_definitions\")\n\n @step_definition = StepDefinition.new(step_definition_attributes)\n @step_definition.field_definitions = FieldDefinition.createFieldDefinitions(field_definitions_attributes)\n\n respond_to do |format|\n if @step_definition.save\n format.html { redirect_to @step_definition, notice: 'Step definition was successfully created.' }\n format.json { render :show, status: :created, location: @step_definition }\n else\n format.html { render :new }\n format.json { render json: @step_definition.errors, status: :unprocessable_entity }\n end\n end\n end", "def property_definitions\n set_attributes_for(PropertyDefinition)\n PropertyDefinition.find(:all)\n end", "def get_fields\n _fields = @config['form']['fields']\n _fields.map{|k,v| Field.new(k=>v)}\n end", "def flights_fields\n render json: Search.getFlightsFieldInfo()\n end", "def fields\n FIELDS\n end", "def get_definitions\n Dictionary.find_by_word(word_id)\n end", "def get_definition\n\n end", "def get_field_spec(field_name,field_spec)\n fspec = field_spec[field_name]\n fspec ||= field_name\n case\n when fspec.is_a?(String)\n fspec = {'type' => fspec}\n when fspec.is_a?(Array)\n fspec = {'values_enum' => fspec}\n end\n fspec['description'] ||= field_name.gsub(/_/,' ').capitalize\n fspec\n end", "def get_field_deserializers()\n return {\n \"includeContent\" => lambda {|n| @include_content = n.get_enum_value(MicrosoftGraph::Models::SearchContent) },\n \"@odata.type\" => lambda {|n| @odata_type = n.get_string_value() },\n }\n end", "def getAllFieldsMap\n @customFieldMap = self.class.get(\"/rest/api/2/field\", :verify => false)\n end", "def definitions\n definitions = []\n while (code, parameters = response) and code != 250\n definitions << Definition.new(split(parameters), lines(false).join(\"\\n\"))\n end\n definitions\n end", "def fields\n preview_json['fields']\n end", "def dynamic_field_factories_hash\n @dynamic_field_factories_hash ||=\n begin\n dynamic_field_factories_hash = @types.inject({}) do |hash, type|\n Setup.for(type).dynamic_field_factories.each do |field_factory|\n (hash[field_factory.name.to_sym] ||= {})[type.name] = field_factory\n end\n hash\n end\n dynamic_field_factories_hash.each_pair do |field_name, field_configurations_hash|\n if @types.any? { |type| field_configurations_hash[type.name].nil? }\n dynamic_field_factories_hash.delete(field_name)\n else\n dynamic_field_factories_hash[field_name] = field_configurations_hash.values.first\n end\n end\n end\n end", "def search_keys \n return search_field_definitions.keys\n end", "def update\n respond_to do |format|\n if @field_definition.update(field_definition_params)\n format.html { redirect_to @field_definition, notice: 'Field definition was successfully updated.' }\n format.json { render :show, status: :ok, location: @field_definition }\n else\n format.html { render :edit }\n format.json { render json: @field_definition.errors, status: :unprocessable_entity }\n end\n end\n end", "def list_definitions(resource, filter = nil)\n resource_id = resource.respond_to?(:id) ? resource.id : resource\n version = configuration.provider_default_api_version(provider, 'metricDefinitions')\n\n url = File.join(\n configuration.environment.resource_url,\n resource_id,\n 'providers/microsoft.insights/metricdefinitions'\n )\n\n url << \"?api-version=#{version}\"\n url << \"&$filter=#{filter}\" if filter\n\n response = rest_get(url)\n\n Azure::Armrest::ArmrestCollection.create_from_response(\n response,\n Azure::Armrest::Insights::MetricDefinition\n )\n end", "def schema_definition\n of.schema_definition \n end", "def places_fields\n render json: Search.getPlacesFieldInfo()\n end", "def get_field_deserializers()\n return {\n \"hitsContainers\" => lambda {|n| @hits_containers = n.get_collection_of_object_values(lambda {|pn| MicrosoftGraph::Models::SearchHitsContainer.create_from_discriminator_value(pn) }) },\n \"@odata.type\" => lambda {|n| @odata_type = n.get_string_value() },\n \"queryAlterationResponse\" => lambda {|n| @query_alteration_response = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::AlterationResponse.create_from_discriminator_value(pn) }) },\n \"resultTemplates\" => lambda {|n| @result_templates = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::ResultTemplateDictionary.create_from_discriminator_value(pn) }) },\n \"searchTerms\" => lambda {|n| @search_terms = n.get_collection_of_primitive_values(String) },\n }\n end", "def step_definition_params\n params.permit(:id, :order, :workflow_id, \n field_definitions: [:id, :name, :field_type, :validationRegex, :required, :errorMessage, :order]\n )\n end", "def factory_definitions\n @factory_definitions ||= {}\n end", "def index\n @definitions = Definition.order('created_at desc')\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @definitions }\n end\n end", "def field_types\r\n return @field_types\r\n end", "def definition\n @definition ||= []\n end", "def destroy\n @field_definition.destroy\n respond_to do |format|\n format.html { redirect_to field_definitions_url, notice: 'Field definition was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def test_get_fields\n local_file_name = 'GetField.docx'\n remote_file_name = 'TestGetFields.docx'\n\n upload_file File.join(local_test_folder, field_folder + '/' + local_file_name), remote_data_folder + '/' + remote_file_name\n\n request = GetFieldsRequest.new(name: remote_file_name, node_path: 'sections/0', folder: remote_data_folder)\n\n result = @words_api.get_fields(request)\n assert_equal false, result.nil?\n end", "def get_field_deserializers()\n return {\n \"allowMultipleLines\" => lambda {|n| @allow_multiple_lines = n.get_boolean_value() },\n \"appendChangesToExistingText\" => lambda {|n| @append_changes_to_existing_text = n.get_boolean_value() },\n \"linesForEditing\" => lambda {|n| @lines_for_editing = n.get_number_value() },\n \"maxLength\" => lambda {|n| @max_length = n.get_number_value() },\n \"@odata.type\" => lambda {|n| @odata_type = n.get_string_value() },\n \"textType\" => lambda {|n| @text_type = n.get_string_value() },\n }\n end", "def get_definitions(word, *args)\n http_method = :get\n path = '/word/{word}/definitions'\n path.sub!('{word}', word.to_s)\n\n # Ruby turns all key-value arguments at the end into a single hash\n # e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')\n # becomes {:limit => 10, :part_of_speech => 'verb'}\n last_arg = args.pop if args.last.is_a?(Hash)\n last_arg = args.pop if args.last.is_a?(Array)\n last_arg ||= {}\n\n # Look for a kwarg called :request_only, whose presence indicates\n # that we want the request itself back, not the response body\n if last_arg.is_a?(Hash) && last_arg[:request_only].present?\n request_only = true\n last_arg.delete(:request_only)\n end\n\n params = last_arg\n body ||= {}\n request = Wordnik::Request.new(http_method, path, :params => params, :body => body)\n request_only ? request : request.response.body\n end", "def fields\n @fields ||= []\n end", "def update\n\n step_definition_attributes = step_definition_params\n field_definitions_attributes = step_definition_attributes.delete(\"field_definitions\")\n\n FieldDefinition.updateFieldDefinitions(field_definitions_attributes)\n\n respond_to do |format|\n if @step_definition.update(step_definition_attributes)\n format.html { redirect_to @step_definition, notice: 'Step definition was successfully updated.' }\n format.json { render :show, status: :ok, location: @step_definition }\n else\n format.html { render :edit }\n format.json { render json: @step_definition.errors, status: :unprocessable_entity }\n end\n end\n end", "def fields\n @fields ||= []\n end", "def fields\n return @fields if defined?(@fields)\n\n @fields = array_of_items_for(Fields, :fields)\n end", "def fields\n FIELDS\n end", "def definition_list(options = {}, &block)\n definition_list_for(resource, options, &block)\n end", "def find_form_attribute_definitions(kapp_slug, params={}, headers=default_headers)\n @logger.info(\"Finding Form attribute definitions in the \\\"#{kapp_slug}\\\" kapp.\")\n get(\"#{@api_url}/kapps/#{kapp_slug}/formAttributeDefinitions\", params, headers)\n end", "def fields\n schema.fields\n end", "def fields\n schema.fields\n end", "def fields\n schema.fields\n end", "def get_definition(cls, bld, fun)\r\n bld.add(\"///\")\r\n bld.add(\"/// Web API get single \" + cls.getUName())\r\n bld.add(\"///\")\r\n\r\n get_body(cls, bld, fun)\r\n\r\n bld.endFunction\r\n end", "def size\n @definitions.size\n end", "def fields\n schema.fields\n end", "def filter_fields\n i = -1\n render json: AppConfig['api_field_mappings'].map { |f| [f, i += 1] }.to_h\n end", "def contact_field_options(contact_field)\n contact_field_definitions[contact_field]\n end", "def fields\n @_fields ||= {}\n end", "def all\n @definitions ||= []\n end", "def fields\n FIELDS\n end", "def definitions\n run_context.definitions\n end", "def get_field_deserializers()\n return {\n \"expirationDateTime\" => lambda {|n| @expiration_date_time = n.get_date_time_value() },\n \"nextExpectedRanges\" => lambda {|n| @next_expected_ranges = n.get_collection_of_primitive_values(String) },\n \"@odata.type\" => lambda {|n| @odata_type = n.get_string_value() },\n \"uploadUrl\" => lambda {|n| @upload_url = n.get_string_value() },\n }\n end", "def index\n\n @definitions = Definition.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @definitions.to_xml(:request => request) }\n format.json { render :json => @definitions.to_json(:request => request) }\n end\n end", "def get_field_deserializers()\n return {\n \"@odata.type\" => lambda {|n| @odata_type = n.get_string_value() },\n \"resourceId\" => lambda {|n| @resource_id = n.get_string_value() },\n \"uri\" => lambda {|n| @uri = n.get_string_value() },\n }\n end", "def get_field_deserializers()\n return {\n \"isEnabled\" => lambda {|n| @is_enabled = n.get_boolean_value() },\n \"maxImageSize\" => lambda {|n| @max_image_size = n.get_number_value() },\n \"@odata.type\" => lambda {|n| @odata_type = n.get_string_value() },\n \"timeout\" => lambda {|n| @timeout = n.get_duration_value() },\n }\n end", "def definitions(input)\n list = 1\n input.body.each do |definition|\n current_definition = definition['text']\n puts \"#{list}. #{current_definition}\"\n list += 1\n end\n end", "def get_document_schema\n filePath = Rails.root.join(\"lib\", \"base_truevault_doc.json\")\n file = File.read(filePath)\n schema = JSON.parse(file).with_indifferent_access\n end", "def get_field_deserializers()\n return {\n \"@odata.type\" => lambda {|n| @odata_type = n.get_string_value() },\n \"recurrence\" => lambda {|n| @recurrence = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::PatternedRecurrence.create_from_discriminator_value(pn) }) },\n \"reportRange\" => lambda {|n| @report_range = n.get_string_value() },\n }\n end", "def get_field_deserializers()\n return {\n \"default\" => lambda {|n| @default = n.get_boolean_value() },\n \"@odata.type\" => lambda {|n| @odata_type = n.get_string_value() },\n \"position\" => lambda {|n| @position = n.get_number_value() },\n }\n end", "def fields\n @fields ||= begin\n default_fields\n end\n end", "def get_field_deserializers()\n return {\n \"excludeLocations\" => lambda {|n| @exclude_locations = n.get_collection_of_primitive_values(String) },\n \"includeLocations\" => lambda {|n| @include_locations = n.get_collection_of_primitive_values(String) },\n \"@odata.type\" => lambda {|n| @odata_type = n.get_string_value() },\n }\n end", "def test_get_form_fields\n filename = 'FormFilled.docx'\n remote_name = 'TestGetFormFields.docx'\n\n st_request = PutCreateRequest.new remote_test_folder + test_folder + '/' + remote_name, File.open(local_test_folder + test_folder + '/' + filename, \"r\").read \n @storage_api.put_create st_request\n\n request = GetFormFieldsRequest.new remote_name, remote_test_folder + test_folder, :node_path => 'sections/0'\n result = @words_api.get_form_fields request\n assert_equal 200, result.code\n end", "def get_field_deserializers()\n return {\n \"allowedDeviceCount\" => lambda {|n| @allowed_device_count = n.get_number_value() },\n \"blockedDeviceCount\" => lambda {|n| @blocked_device_count = n.get_number_value() },\n \"@odata.type\" => lambda {|n| @odata_type = n.get_string_value() },\n \"quarantinedDeviceCount\" => lambda {|n| @quarantined_device_count = n.get_number_value() },\n \"unavailableDeviceCount\" => lambda {|n| @unavailable_device_count = n.get_number_value() },\n \"unknownDeviceCount\" => lambda {|n| @unknown_device_count = n.get_number_value() },\n }\n end", "def get_field_deserializers()\n return {\n \"detectionType\" => lambda {|n| @detection_type = n.get_string_value() },\n \"method\" => lambda {|n| @method = n.get_string_value() },\n \"name\" => lambda {|n| @name = n.get_string_value() },\n \"@odata.type\" => lambda {|n| @odata_type = n.get_string_value() },\n }\n end", "def get_fields(payload)\n payload['fields']\n end", "def get_field_deserializers()\n return {\n \"isRequired\" => lambda {|n| @is_required = n.get_boolean_value() },\n \"locations\" => lambda {|n| @locations = n.get_collection_of_object_values(lambda {|pn| MicrosoftGraph::Models::LocationConstraintItem.create_from_discriminator_value(pn) }) },\n \"@odata.type\" => lambda {|n| @odata_type = n.get_string_value() },\n \"suggestLocation\" => lambda {|n| @suggest_location = n.get_boolean_value() },\n }\n end", "def document_show_fields\n Blacklight.config[:show_fields][:field_names]\n end", "def get_field_deserializers()\n return {\n \"contentSource\" => lambda {|n| @content_source = n.get_string_value() },\n \"hitId\" => lambda {|n| @hit_id = n.get_string_value() },\n \"isCollapsed\" => lambda {|n| @is_collapsed = n.get_boolean_value() },\n \"@odata.type\" => lambda {|n| @odata_type = n.get_string_value() },\n \"rank\" => lambda {|n| @rank = n.get_number_value() },\n \"resource\" => lambda {|n| @resource = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::Entity.create_from_discriminator_value(pn) }) },\n \"resultTemplateId\" => lambda {|n| @result_template_id = n.get_string_value() },\n \"summary\" => lambda {|n| @summary = n.get_string_value() },\n }\n end", "def fields\n DatasetService.get_fields dataset_id, api_table_name\n end" ]
[ "0.70758086", "0.6337163", "0.6179126", "0.61459696", "0.6027708", "0.5972366", "0.59629065", "0.5953797", "0.59530354", "0.5900668", "0.5883962", "0.5828771", "0.57892615", "0.5778741", "0.5736973", "0.5733617", "0.5733617", "0.5733617", "0.5733617", "0.5733617", "0.572039", "0.57031107", "0.5679087", "0.5670722", "0.5670722", "0.56678706", "0.5655142", "0.5640918", "0.5617653", "0.5611786", "0.5603227", "0.5593264", "0.5590995", "0.5583165", "0.55827206", "0.55406785", "0.5539313", "0.55304253", "0.5509966", "0.548382", "0.54780334", "0.5455217", "0.545117", "0.5433818", "0.5422385", "0.5416285", "0.5416017", "0.54068553", "0.54041874", "0.5401511", "0.53980905", "0.53945005", "0.5392316", "0.53922206", "0.5386577", "0.537898", "0.5376018", "0.5370008", "0.5359829", "0.5359123", "0.53579456", "0.5357666", "0.5352699", "0.53464776", "0.5346299", "0.53381366", "0.53322005", "0.5318113", "0.531482", "0.5305239", "0.529852", "0.529852", "0.529852", "0.5293971", "0.52939403", "0.52902985", "0.5288655", "0.5285375", "0.5274821", "0.52734256", "0.52682376", "0.5262711", "0.52564263", "0.52532667", "0.5240849", "0.5236863", "0.5234851", "0.5233025", "0.52318424", "0.5228472", "0.5224925", "0.52211356", "0.52196115", "0.5215298", "0.5205296", "0.52039695", "0.5198998", "0.51886636", "0.5185983", "0.51841456" ]
0.6603736
1
GET /field_definitions/1 GET /field_definitions/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def definitions(key, field=nil)\n begin\n defs = self.definition_schema[key]\n if field.present?\n defs[field]\n else\n defs\n end\n rescue NoMethodError => e\n field_key = field.present? ? \"#{key}/#{field}\" : key\n ErrorTracker.report_exception(e, self.study.user, { missing_key: field_key, analysis_metadatum: self.attributes.to_h})\n Rails.logger.error \"Error accessing remote HCA Analysis metadata field definitions for #{field_key}: #{e.message}\"\n nil\n end\n end", "def index\n if params[:step_definition_id] \n step_definition = StepDefinition.find(params[:step_definition_id])\n if step_definition != nil\n @field_definitions = step_definition.field_definitions\n else\n @field_definitions = []\n end\n else \n @field_definitions = FieldDefinition.all\n end\n end", "def set_field_definition\n @field_definition = FieldDefinition.find(params[:id])\n end", "def create\n @field_definition = FieldDefinition.new(field_definition_params)\n\n respond_to do |format|\n if @field_definition.save\n format.html { redirect_to @field_definition, notice: 'Field definition was successfully created.' }\n format.json { render :show, status: :created, location: @field_definition }\n else\n format.html { render :new }\n format.json { render json: @field_definition.errors, status: :unprocessable_entity }\n end\n end\n end", "def get_fields()\n return @api.do_request(\"GET\", get_base_api_path() + \"/fields\")\n end", "def get_field_list\n return make_request(\"#{self.endpoint}/list/fields\")\n end", "def GetField id\n\n APICall(path: \"ticket_fields/#{id}.json\")\n\n end", "def attribute_definition_of(field)\n @attribute_definitions.find_field(field)\n end", "def get_object_definition(object_type)\n result = {}\n definition = @client.get_business_object_definition(object_type)\n selector = 'BusinessObjectDef > FieldList > Field'\n Nokogiri::XML(definition).css(selector).map do |field|\n result[field['Name']] = field.css('Description').inner_html\n end\n return result\n end", "def flights_fields\n render json: Search.getFlightsFieldInfo()\n end", "def index\n @custom_definitions = CustomDefinition.all\n end", "def get_definition(cls, bld, fun)\r\n bld.add(\"///\")\r\n bld.add(\"/// Web API get single \" + cls.getUName())\r\n bld.add(\"///\")\r\n\r\n get_body(cls, bld, fun)\r\n\r\n bld.endFunction\r\n end", "def get_fields\n cached_response = REDIS.get(FIELDS_CACHE_KEY)\n\n # return the cached response if it's already in redis\n if cached_response != nil\n return JSON.parse(cached_response)\n end\n\n # otherwise, fetch and cache it\n resp = HTTParty.get(FORM_URL_BASE + \"fields.json\", basic_auth: WUFOO_AUTH)\n\n # make sure we got a good response\n throw \"Wufoo response error: #{resp.code}\" if resp.code != 200\n\n # cache the response value and set a long-ish TTL for it\n REDIS.multi do\n REDIS.set(FIELDS_CACHE_KEY, JSON.generate(resp))\n REDIS.expire(FIELDS_CACHE_KEY, 60 * 60 * 3)\n end\n\n resp[\"Fields\"] || []\nend", "def fields\n preview_json['fields']\n end", "def update\n respond_to do |format|\n if @field_definition.update(field_definition_params)\n format.html { redirect_to @field_definition, notice: 'Field definition was successfully updated.' }\n format.json { render :show, status: :ok, location: @field_definition }\n else\n format.html { render :edit }\n format.json { render json: @field_definition.errors, status: :unprocessable_entity }\n end\n end\n end", "def test_get_fields\n local_file_name = 'GetField.docx'\n remote_file_name = 'TestGetFields.docx'\n\n upload_file File.join(local_test_folder, field_folder + '/' + local_file_name), remote_data_folder + '/' + remote_file_name\n\n request = GetFieldsRequest.new(name: remote_file_name, node_path: 'sections/0', folder: remote_data_folder)\n\n result = @words_api.get_fields(request)\n assert_equal false, result.nil?\n end", "def destroy\n @field_definition.destroy\n respond_to do |format|\n format.html { redirect_to field_definitions_url, notice: 'Field definition was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def show\n @schema_field = SchemaField.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @schema_field }\n end\n end", "def get_field_spec(field_name,field_spec)\n fspec = field_spec[field_name]\n fspec ||= field_name\n case\n when fspec.is_a?(String)\n fspec = {'type' => fspec}\n when fspec.is_a?(Array)\n fspec = {'values_enum' => fspec}\n end\n fspec['description'] ||= field_name.gsub(/_/,' ').capitalize\n fspec\n end", "def index\n @definitions = Definition.all\n end", "def show\n api = Apikey.find_by(api_key: params[:api_key])\n api['count'] += 1\n if api.save\n word = params[:word_id]\n\n word_id = Word.where(word_name: word)\n @definitions = Definition.where(word_id: word_id.ids)\n render json:{\n id: @definitions\n }\n else\n flash[:notice] = 'Invalid'\n redirect_to apikeys_path\n end\n end", "def test_get_form_fields\n filename = 'FormFilled.docx'\n remote_name = 'TestGetFormFields.docx'\n\n st_request = PutCreateRequest.new remote_test_folder + test_folder + '/' + remote_name, File.open(local_test_folder + test_folder + '/' + filename, \"r\").read \n @storage_api.put_create st_request\n\n request = GetFormFieldsRequest.new remote_name, remote_test_folder + test_folder, :node_path => 'sections/0'\n result = @words_api.get_form_fields request\n assert_equal 200, result.code\n end", "def index_field(list_name, field_name, site_path = '')\n url = computed_web_api_url(site_path)\n easy = ethon_easy_json_requester\n easy.url = uri_escape \"#{url}Lists/GetByTitle('#{odata_escape_single_quote(list_name)}')/Fields/getByTitle('#{field_name}')\"\n easy.perform\n\n parsed_response_body = JSON.parse(easy.response_body)\n return 304 if parsed_response_body['d']['Indexed']\n\n update_object_metadata parsed_response_body['d']['__metadata'], { 'Indexed' => true }, site_path\n end", "def filter_fields\n i = -1\n render json: AppConfig['api_field_mappings'].map { |f| [f, i += 1] }.to_h\n end", "def test_get_field\n local_file_name = 'GetField.docx'\n remote_file_name = 'TestGetField.docx'\n\n upload_file File.join(local_test_folder, field_folder + '/' + local_file_name), remote_data_folder + '/' + remote_file_name\n\n request = GetFieldRequest.new(name: remote_file_name, index: 0, node_path: 'sections/0/paragraphs/0', folder: remote_data_folder)\n\n result = @words_api.get_field(request)\n assert_equal false, result.nil?\n end", "def print_definition()\n puts \"Definition\"\n puts \"----------------------------------------\"\n puts @word_info[:title], \" \"\n @word_info[:types_definitions].each do |type|\n puts \"\\t\" + type[:type]\n type[:definitions].each_with_index do |defintion, i|\n puts \"\\t #{i+1}. #{defintion}\"\n end\n print \"\\n\"\n end\n end", "def fields\n @fields ||= {}\n end", "def fields\n @fields ||= {}\n end", "def fields\n @fields ||= {}\n end", "def fields\n @fields ||= {}\n end", "def fields\n @fields ||= {}\n end", "def definitions() return @definitions end", "def index\n @definitions = Definition.order('created_at desc')\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @definitions }\n end\n end", "def get_fields\n FIELD_DESCS\n end", "def create\n\n step_definition_attributes = step_definition_params\n field_definitions_attributes = step_definition_attributes.delete(\"field_definitions\")\n\n @step_definition = StepDefinition.new(step_definition_attributes)\n @step_definition.field_definitions = FieldDefinition.createFieldDefinitions(field_definitions_attributes)\n\n respond_to do |format|\n if @step_definition.save\n format.html { redirect_to @step_definition, notice: 'Step definition was successfully created.' }\n format.json { render :show, status: :created, location: @step_definition }\n else\n format.html { render :new }\n format.json { render json: @step_definition.errors, status: :unprocessable_entity }\n end\n end\n end", "def test_get_form_field\n filename = 'FormFilled.docx'\n remote_name = 'TestGetFormField.docx'\n index = 0\n\n st_request = PutCreateRequest.new remote_test_folder + test_folder + '/' + remote_name, File.open(local_test_folder + test_folder + '/' + filename, \"r\").read \n @storage_api.put_create st_request\n\n request = GetFormFieldRequest.new remote_name, index, remote_test_folder + test_folder, :node_path => 'sections/0'\n result = @words_api.get_form_field request\n assert_equal 200, result.code\n end", "def definitions\n @definitions ||= { responses: {} }\n end", "def get_config_var_definitions(variable_id)\n path = \"/d2l/api/lp/#{$lp_ver}/configVariables/(#{variable_id}/definition\"\n _get(path)\n # returns Definition JSON data block\nend", "def new\n @definition = Definition.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @definition }\n end\n end", "def new\n @definition = Definition.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @definition }\n end\n end", "def update\n\n step_definition_attributes = step_definition_params\n field_definitions_attributes = step_definition_attributes.delete(\"field_definitions\")\n\n FieldDefinition.updateFieldDefinitions(field_definitions_attributes)\n\n respond_to do |format|\n if @step_definition.update(step_definition_attributes)\n format.html { redirect_to @step_definition, notice: 'Step definition was successfully updated.' }\n format.json { render :show, status: :ok, location: @step_definition }\n else\n format.html { render :edit }\n format.json { render json: @step_definition.errors, status: :unprocessable_entity }\n end\n end\n end", "def get_definition\n\n end", "def test_get_form_fields\n remote_file_name = 'TestGetFormFields.docx'\n\n upload_file File.join(local_test_folder, field_folder + '/FormFilled.docx'), remote_data_folder + '/' + remote_file_name\n\n request = GetFormFieldsRequest.new(name: remote_file_name, node_path: 'sections/0', folder: remote_data_folder)\n\n result = @words_api.get_form_fields(request)\n assert_equal false, result.nil?\n end", "def fields\n @fields ||= FieldList.new\n end", "def show\n @definition = Definition.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @definition }\n end\n end", "def show\n @definition = Definition.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @definition }\n end\n end", "def GetFields params = {}\n\n params = params.merge(path: 'ticket_fields.json')\n APICall(params)\n\n end", "def places_fields\n render json: Search.getPlacesFieldInfo()\n end", "def list_service_definitions_with_http_info(opts = {})\n\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ServiceDefinitionAPI.list_service_definitions ...'\n end\n allowable_values = ['v1', 'v2', 'v2.1']\n if @api_client.config.client_side_validation && opts[:'schema_version'] && !allowable_values.include?(opts[:'schema_version'])\n fail ArgumentError, \"invalid value for \\\"schema_version\\\", must be one of #{allowable_values}\"\n end\n # resource path\n local_var_path = '/api/v2/services/definitions'\n\n # query parameters\n query_params = opts[:query_params] || {}\n query_params[:'page[size]'] = opts[:'page_size'] if !opts[:'page_size'].nil?\n query_params[:'page[number]'] = opts[:'page_number'] if !opts[:'page_number'].nil?\n query_params[:'schema_version'] = opts[:'schema_version'] if !opts[:'schema_version'].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(['application/json'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:debug_body]\n\n # return_type\n return_type = opts[:debug_return_type] || 'ServiceDefinitionsListResponse'\n\n # auth_names\n auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth, :AuthZ]\n\n new_options = opts.merge(\n :operation => :list_service_definitions,\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 :api_version => \"V2\"\n )\n\n data, status_code, headers = @api_client.call_api(Net::HTTP::Get, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ServiceDefinitionAPI#list_service_definitions\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def get_response_field(field, target)\n return unless @response\n return @response[field] if target == 'header'\n return @response.body if field.nil? || field.empty?\n json = JSON.load(@response.body) rescue nil\n res = nil\n if json\n res = json_field(json, field)\n else\n doc = REXML::Document.new(@response.body)\n elem = doc.elements[field]\n res = elem.get_text.to_s if elem\n end\n res\n end", "def new\n @schema_field = SchemaField.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @schema_field }\n end\n end", "def definition_by_name(name)\n definitions_repository.get(name)\n end", "def types\n FIELD_TYPES\n end", "def get_field_with_http_info(name, field_name, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: PdfApi.get_field ...\"\n end\n # verify the required parameter 'name' is set\n if @api_client.config.client_side_validation && name.nil?\n fail ArgumentError, \"Missing the required parameter 'name' when calling PdfApi.get_field\"\n end\n # verify the required parameter 'field_name' is set\n if @api_client.config.client_side_validation && field_name.nil?\n fail ArgumentError, \"Missing the required parameter 'field_name' when calling PdfApi.get_field\"\n end\n # resource path\n local_var_path = \"/pdf/{name}/fields/{fieldName}\".sub('{' + 'name' + '}', name.to_s).sub('{' + 'fieldName' + '}', field_name.to_s)\n\n # query parameters\n query_params = {}\n query_params[:'storage'] = opts[:'storage'] if !opts[:'storage'].nil?\n query_params[:'folder'] = opts[:'folder'] if !opts[:'folder'].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 # Fix header in file\n post_body = nil\n\n # http body (model)\n # Fix header in file\n # post_body = nil\n auth_names = ['JWT']\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 => 'FieldResponse')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: PdfApi#get_field\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def show\n @field = FormulaField.find(params[:id])\n @owner = Project.find(@field.project_id).user_id\n\n recur = params.key?(:recur) ? params[:recur] : false\n\n respond_to do |format|\n format.html { render text: @field.to_json }\n format.json { render json: @field.to_hash(recur) }\n end\n end", "def get_definitions\n Dictionary.find_by_word(word_id)\n end", "def get_fields(payload)\n payload['fields']\n end", "def show\n @resource = Resource.find(params[:id])\n @resource_type = ResourceType.find(@resource.resource_type_id)\n @values = ResourceValue.where(resource_id: params[:id])\n @field_types=[]\n @values.each do |value|\n @field_types << value.Field\n end\n \n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @resource }\n end\n end", "def show\n @fieldtype = Fieldtype.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @fieldtype }\n end\n end", "def show\n @all_field_type = AllFieldType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @all_field_type }\n end\n end", "def fields\n FIELDS\n end", "def getAllFieldsMap\n @customFieldMap = self.class.get(\"/rest/api/2/field\", :verify => false)\n end", "def to_h\n hash = {}\n self.class.field_definitions.each do |k, v|\n hash[k] = field_value k\n end\n hash\n end", "def index\n @api_v1_initiative_fields = Api::V1::InitiativeField.all\n end", "def get_definitions(word, *args)\n http_method = :get\n path = '/word/{word}/definitions'\n path.sub!('{word}', word.to_s)\n\n # Ruby turns all key-value arguments at the end into a single hash\n # e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')\n # becomes {:limit => 10, :part_of_speech => 'verb'}\n last_arg = args.pop if args.last.is_a?(Hash)\n last_arg = args.pop if args.last.is_a?(Array)\n last_arg ||= {}\n\n # Look for a kwarg called :request_only, whose presence indicates\n # that we want the request itself back, not the response body\n if last_arg.is_a?(Hash) && last_arg[:request_only].present?\n request_only = true\n last_arg.delete(:request_only)\n end\n\n params = last_arg\n body ||= {}\n request = Wordnik::Request.new(http_method, path, :params => params, :body => body)\n request_only ? request : request.response.body\n end", "def fields; h.fields; end", "def definitions\n definitions_repository.all\n end", "def get_field_by_id(id, params = {})\n get(\"/fields/#{id}\", params)\n end", "def get_document_schema\n filePath = Rails.root.join(\"lib\", \"base_truevault_doc.json\")\n file = File.read(filePath)\n schema = JSON.parse(file).with_indifferent_access\n end", "def test_get_form_field\n remote_file_name = 'TestGetFormField.docx'\n\n upload_file File.join(local_test_folder, field_folder + '/FormFilled.docx'), remote_data_folder + '/' + remote_file_name\n\n request = GetFormFieldRequest.new(name: remote_file_name, index: 0, node_path: 'sections/0', folder: remote_data_folder)\n\n result = @words_api.get_form_field(request)\n assert_equal false, result.nil?\n end", "def get_fields(template); end", "def field_definition_params\n params.permit(:field_definition,:name, :field_type, :validationRegex, :required, :step_definition_id, :errorMessage, :order)\n end", "def definitions\n # Some httparty work to fetch definitions from Websters\n end", "def field_def(name)\n @@known_fields_lookup[name] || # the fast way\n @@known_fields.find{|hfd| hfd === name} || # the slow way\n FieldDesc.new(name.to_s.downcase.gsub(/^.|[-_\\s]./) { |x| x.upcase }.gsub('_', '-'), :repeatable => true) # make up as we go\n end", "def fields\n return @fields if defined?(@fields)\n\n @fields = array_of_items_for(Fields, :fields)\n end", "def definitions(word)\n MinWords::DB[:defines].where(word_id: word[:id]).all\n end", "def show_field(id)\n get(\"fields/#{id}\")\n end", "def get_field_deserializers()\n return super.merge({\n \"definitions\" => lambda {|n| @definitions = n.get_collection_of_object_values(lambda {|pn| MicrosoftGraph::Models::AccessReviewScheduleDefinition.create_from_discriminator_value(pn) }) },\n \"historyDefinitions\" => lambda {|n| @history_definitions = n.get_collection_of_object_values(lambda {|pn| MicrosoftGraph::Models::AccessReviewHistoryDefinition.create_from_discriminator_value(pn) }) },\n })\n end", "def schema_definition\n of.schema_definition \n end", "def get_field(field_name)\n\t\tend", "def get_field_config\n fields = @screen.get_screen_config['fields'].select do |field|\n field['name'] == @name\n end\n\n unless fields.size == 1\n raise \"Invalid results when looking for field '#{@name}'\"\n end\n\n fields[0]\n end", "def fields; end", "def fields; end", "def fields; end", "def get_field(field_name)\n fields = @data_source['fields']\n \n fields.each do | f |\n if f['name'] == filed_name\n return f\n end\n end \n return nil\n end", "def show\n @definitions = @word.definitions.order(cached_votes_up: :desc, created_at: :desc)\n end", "def fields\n DatasetService.get_fields dataset_id, api_table_name\n end", "def query_def; @hit.mrna.definition; end", "def generate_definitions_list\n definitions = YARD::Registry.all(:definition).uniq.sort_by{|define| define.name.to_s}\n generate_full_list(definitions, 'Definition', 'definitions')\nend", "def index\n\n @definitions = Definition.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @definitions.to_xml(:request => request) }\n format.json { render :json => @definitions.to_json(:request => request) }\n end\n end", "def step_definition_params\n params.permit(:id, :order, :workflow_id, \n field_definitions: [:id, :name, :field_type, :validationRegex, :required, :errorMessage, :order]\n )\n end", "def create\n @schema_field = SchemaField.new(params[:schema_field])\n\n respond_to do |format|\n if @schema_field.save\n format.html { redirect_to @schema_field, :notice => 'Schema field was successfully created.' }\n format.json { render :json => @schema_field, :status => :created, :location => @schema_field }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @schema_field.errors, :status => :unprocessable_entity }\n end\n end\n end", "def get_fields\n _fields = @config['form']['fields']\n _fields.map{|k,v| Field.new(k=>v)}\n end", "def fields\n FIELDS\n end", "def get_fieldconfig_with_http_info(type, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: GroupsApi.get_fieldconfig ...\"\n end\n \n \n # verify the required parameter 'type' is set\n fail ArgumentError, \"Missing the required parameter 'type' when calling GroupsApi.get_fieldconfig\" if type.nil?\n \n # verify enum value\n unless ['person', 'group', 'org', 'externalContact'].include?(type)\n fail ArgumentError, \"invalid value for 'type', must be one of person, group, org, externalContact\"\n end\n \n \n \n \n \n # resource path\n local_var_path = \"/api/v2/fieldconfig\".sub('{format}','json')\n\n # query parameters\n query_params = {}\n query_params[:'type'] = type\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 => 'FieldConfig')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: GroupsApi#get_fieldconfig\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def describe_index_fields(index_name, type)\n response = send_request(:get, path: \"#{index_name}/_mapping/#{type}\")\n if response.success?\n body = ActiveSupport::JSON.decode(response.body) if response.body.present?\n return if body.blank?\n fields = body[index_name.to_s][\"mappings\"][type.to_s][\"properties\"]\n\n fields.map do |field_name, properties|\n properties = Hash[ properties.map{|k,v| [k.to_sym, v]} ]\n type = properties.delete(:type)\n AgnosticBackend::Elasticsearch::RemoteIndexField.new field_name, type, **properties\n end\n end\n end", "def reflect_fields\n send_and_receive('admin/luke', params: { fl: '*', 'json.nl' => 'map' })['fields']\n end", "def fields\n @fields ||= []\n end", "def get_field(key,field)\n request :get, \"#{path_prefix}records/#{ue key}?field=#{ue field}\", :accept_404=>true, :force_encoding => \"ASCII-8BIT\", :raw_response => true\n end", "def json_fields\n\n mappings = {}\n\n json = self.record.json\n if !json\n return mappings\n end\n\n mappings['language'] = json['language']\n\n if json['notes']\n json['notes'].each do |note|\n if note['type'] == 'physloc' and !note['content'].blank?\n mappings['physical_location_note'] = note['content'].map { |cont| \"#{cont}\" }.join(\"; \")\n end\n end\n end\n\n if json['dates']\n json['dates']\n .select { |date| date['expression'].present? }\n .group_by { |date| date['label'] }\n .each { |label, dates|\n mappings[\"#{label}_date\"] = dates\n .map { |date| date['expression'] }\n .join(\"; \")\n }\n end\n\n mappings['restrictions_apply'] = json['restrictions_apply']\n mappings['display_string'] = json['display_string']\n\n instances = json.fetch('instances', false)\n if !instances\n return mappings\n end\n\n mappings['requests'] = instances\n .select{ |instance| !instance['digital_object'] }\n .each_with_index\n .map { |instance, i|\n request = {}\n\n instance_count = i + 1\n\n request['Request'] = \"#{instance_count}\"\n\n request[\"instance_is_representative_#{instance_count}\"] = instance['is_representative']\n request[\"instance_last_modified_by_#{instance_count}\"] = instance['last_modified_by']\n request[\"instance_instance_type_#{instance_count}\"] = instance['instance_type']\n request[\"instance_created_by_#{instance_count}\"] = instance['created_by']\n\n container = instance['sub_container']\n if container\n request[\"instance_container_grandchild_indicator_#{instance_count}\"] = container['indicator_3']\n request[\"instance_container_child_indicator_#{instance_count}\"] = container['indicator_2']\n request[\"instance_container_grandchild_type_#{instance_count}\"] = container['type_3']\n request[\"instance_container_child_type_#{instance_count}\"] = container['type_2']\n\n request[\"instance_container_last_modified_by_#{instance_count}\"] = container['last_modified_by']\n request[\"instance_container_created_by_#{instance_count}\"] = container['created_by']\n\n top_container = container['top_container']\n if top_container\n request[\"instance_top_container_ref_#{instance_count}\"] = top_container['ref']\n\n top_container_resolved = top_container['_resolved']\n if top_container_resolved\n request[\"instance_top_container_long_display_string_#{instance_count}\"] = top_container_resolved['long_display_string']\n request[\"instance_top_container_last_modified_by_#{instance_count}\"] = top_container_resolved['last_modified_by']\n request[\"instance_top_container_display_string_#{instance_count}\"] = top_container_resolved['display_string']\n request[\"instance_top_container_restricted_#{instance_count}\"] = top_container_resolved['restricted']\n request[\"instance_top_container_created_by_#{instance_count}\"] = top_container_resolved['created_by']\n request[\"instance_top_container_indicator_#{instance_count}\"] = top_container_resolved['indicator']\n request[\"instance_top_container_barcode_#{instance_count}\"] = top_container_resolved['barcode']\n request[\"instance_top_container_type_#{instance_count}\"] = top_container_resolved['type']\n request[\"instance_top_container_uri_#{instance_count}\"] = top_container_resolved['uri']\n\n collection = top_container_resolved['collection']\n if collection\n request[\"instance_top_container_collection_identifier_#{instance_count}\"] = collection\n .select { |c| c['identifier'].present? }\n .map { |c| c['identifier'] }\n .join(\"; \")\n\n request[\"instance_top_container_collection_display_string_#{instance_count}\"] = collection\n .select { |c| c['display_string'].present? }\n .map { |c| c['display_string'] }\n .join(\"; \")\n end\n\n series = top_container_resolved['series']\n if series\n request[\"instance_top_container_series_identifier_#{instance_count}\"] = series\n .select { |s| s['identifier'].present? }\n .map { |s| s['identifier'] }\n .join(\"; \")\n\n request[\"instance_top_container_series_display_string_#{instance_count}\"] = series\n .select { |s| s['display_string'].present? }\n .map { |s| s['display_string'] }\n .join(\"; \")\n end\n\n end\n end\n end\n\n request\n }\n\n return mappings\n end", "def get_field_deserializers()\n return {\n \"includeContent\" => lambda {|n| @include_content = n.get_enum_value(MicrosoftGraph::Models::SearchContent) },\n \"@odata.type\" => lambda {|n| @odata_type = n.get_string_value() },\n }\n end" ]
[ "0.6568905", "0.6402544", "0.6175839", "0.6164917", "0.61279273", "0.59294397", "0.5729203", "0.56470335", "0.5594209", "0.5581703", "0.5569659", "0.5538788", "0.5516743", "0.54836804", "0.54660326", "0.545755", "0.5430624", "0.5420847", "0.5420162", "0.541188", "0.54072845", "0.5402873", "0.5399308", "0.53943783", "0.5383579", "0.53811127", "0.5379201", "0.5379201", "0.5379201", "0.5379201", "0.5379201", "0.536847", "0.53507215", "0.53474414", "0.53367865", "0.53296775", "0.5310456", "0.5301934", "0.5300585", "0.5300585", "0.52968234", "0.52936876", "0.52727926", "0.52720726", "0.52717286", "0.52717286", "0.5259054", "0.5254918", "0.52523845", "0.52273566", "0.5223519", "0.52213675", "0.5219", "0.5214936", "0.5211313", "0.52107686", "0.5209184", "0.52051187", "0.5189997", "0.5174544", "0.5173887", "0.51556116", "0.51553226", "0.5154398", "0.51391155", "0.51376456", "0.5132547", "0.5125185", "0.51231825", "0.5121488", "0.511176", "0.5106655", "0.5104379", "0.5101152", "0.51005536", "0.5089863", "0.50666416", "0.5057987", "0.50567627", "0.5055118", "0.50550437", "0.5054539", "0.5054539", "0.5054539", "0.50541806", "0.505281", "0.50379467", "0.5030921", "0.50235283", "0.50123525", "0.5007421", "0.5004026", "0.5000655", "0.50002235", "0.49927965", "0.49900088", "0.49842238", "0.4983621", "0.49830112", "0.4978455", "0.49755773" ]
0.0
-1
POST /field_definitions POST /field_definitions.json
def create @field_definition = FieldDefinition.new(field_definition_params) respond_to do |format| if @field_definition.save format.html { redirect_to @field_definition, notice: 'Field definition was successfully created.' } format.json { render :show, status: :created, location: @field_definition } else format.html { render :new } format.json { render json: @field_definition.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n\n step_definition_attributes = step_definition_params\n field_definitions_attributes = step_definition_attributes.delete(\"field_definitions\")\n\n @step_definition = StepDefinition.new(step_definition_attributes)\n @step_definition.field_definitions = FieldDefinition.createFieldDefinitions(field_definitions_attributes)\n\n respond_to do |format|\n if @step_definition.save\n format.html { redirect_to @step_definition, notice: 'Step definition was successfully created.' }\n format.json { render :show, status: :created, location: @step_definition }\n else\n format.html { render :new }\n format.json { render json: @step_definition.errors, status: :unprocessable_entity }\n end\n end\n end", "def step_definition_params\n params.permit(:id, :order, :workflow_id, \n field_definitions: [:id, :name, :field_type, :validationRegex, :required, :errorMessage, :order]\n )\n end", "def field_definition_params\n params.permit(:field_definition,:name, :field_type, :validationRegex, :required, :step_definition_id, :errorMessage, :order)\n end", "def CreateField params = {}\n \n APICall(path: 'ticket_fields.json',method: 'POST',payload: params.to_json)\n \n end", "def custom_definition_params\n params.require(:custom_definition).permit(:name, :report_type_id)\n end", "def definition_params\n params.require(:definition).permit(:feature_id, :is_public, :is_primary, :ancestor_ids, :position, :content, :author_id, :language_id, :numerology, :tense)\n end", "def definition_params\n params.require(:definition).permit(:content, :is_fr, :is_li, :word_id, :contributor_id, :source, :is_validated)\n end", "def create\n @schema_field = SchemaField.new(params[:schema_field])\n\n respond_to do |format|\n if @schema_field.save\n format.html { redirect_to @schema_field, :notice => 'Schema field was successfully created.' }\n format.json { render :json => @schema_field, :status => :created, :location => @schema_field }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @schema_field.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @definition = Definition.new(params[:definition])\n\n respond_to do |format|\n if @definition.save\n format.html { redirect_to @definition, notice: 'Definition was successfully created.' }\n format.json { render json: @definition, status: :created, location: @definition }\n else\n format.html { render action: \"new\" }\n format.json { render json: @definition.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @definition = Definition.new(definition_params)\n\n respond_to do |format|\n if @definition.save\n format.html { redirect_to @definition, notice: \"Definition was successfully created.\" }\n format.json { render :show, status: :created, location: @definition }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @definition.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @definition = Definition.new(definition_params)\n\n respond_to do |format|\n if @definition.save\n format.html { redirect_to @definition.dictionary, notice: 'Definition was successfully created.' }\n format.json { render :show, status: :created, location: @definition }\n else\n format.html { render :new }\n format.json { render json: @definition.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_field_definition\n @field_definition = FieldDefinition.find(params[:id])\n end", "def update\n\n step_definition_attributes = step_definition_params\n field_definitions_attributes = step_definition_attributes.delete(\"field_definitions\")\n\n FieldDefinition.updateFieldDefinitions(field_definitions_attributes)\n\n respond_to do |format|\n if @step_definition.update(step_definition_attributes)\n format.html { redirect_to @step_definition, notice: 'Step definition was successfully updated.' }\n format.json { render :show, status: :ok, location: @step_definition }\n else\n format.html { render :edit }\n format.json { render json: @step_definition.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @custom_definition = @site.custom_definitions.new(custom_definition_params)\n\n if @custom_definition.save\n redirect_to @site\n else\n render 'new'\n end\n end", "def create\n @definition = Definition.new(definition_params)\n\n respond_to do |format|\n if @definition.save\n format.html { redirect_to word_path(@definition.word), notice: 'Definition was successfully created.' }\n format.json { render :show, status: :created, location: @definition }\n else\n format.html { render :new }\n format.json { render json: @definition.errors, status: :unprocessable_entity }\n end\n end\n end", "def definition_params\n params.require(:definition).permit(:dictionary_id, :initialism, :meaning)\n end", "def destroy\n @field_definition.destroy\n respond_to do |format|\n format.html { redirect_to field_definitions_url, notice: 'Field definition was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def definition_params\n params.require(:definition).permit(:sentence, :word_id)\n end", "def index\n if params[:step_definition_id] \n step_definition = StepDefinition.find(params[:step_definition_id])\n if step_definition != nil\n @field_definitions = step_definition.field_definitions\n else\n @field_definitions = []\n end\n else \n @field_definitions = FieldDefinition.all\n end\n end", "def create_tag_definition_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: TagDefinitionsApi.create_tag_definition ...\"\n end\n # resource path\n local_var_path = \"/1.0/kb/tagDefinitions\"\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 header_params[:'X-Killbill-CreatedBy'] = opts[:'x_killbill_created_by'] if !opts[:'x_killbill_created_by'].nil?\n header_params[:'X-Killbill-Reason'] = opts[:'x_killbill_reason'] if !opts[:'x_killbill_reason'].nil?\n header_params[:'X-Killbill-Comment'] = opts[:'x_killbill_comment'] if !opts[:'x_killbill_comment'].nil?\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = @api_client.object_to_http_body(opts[:'body'])\n auth_names = []\n data, status_code, headers = @api_client.call_api(:POST, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: TagDefinitionsApi#create_tag_definition\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def definitions(key, field=nil)\n begin\n defs = self.definition_schema[key]\n if field.present?\n defs[field]\n else\n defs\n end\n rescue NoMethodError => e\n field_key = field.present? ? \"#{key}/#{field}\" : key\n ErrorTracker.report_exception(e, self.study.user, { missing_key: field_key, analysis_metadatum: self.attributes.to_h})\n Rails.logger.error \"Error accessing remote HCA Analysis metadata field definitions for #{field_key}: #{e.message}\"\n nil\n end\n end", "def definitions=(value)\n @definitions = value\n end", "def save_definition(word_id, definition)\n MinWords::DB[:defines].insert definition_text: definition, word_id: word_id\n end", "def create_deal_field(**args)\n params = parameters(args) do\n required_params :name, :field_type\n optional_params :name, :field_type, :options\n end\n request(:post, 'dealFields', params)\n end", "def setup_form\n form = {\n schema: {\n type: 'object',\n properties: {\n array: {\n title: 'You have not configured your schema form',\n type: 'array',\n items: {\n type: 'string',\n enum: [\n \"Ok I'll do it right away\",\n \"I'll let someone else do it for me\"\n ]\n }\n }\n }\n }\n }\n render json: form.to_json\n end", "def postprocess(json_schema); json_schema; end", "def create\n @field = FormulaField.new(field_params)\n unless @field.valid?\n respond_to do |format|\n errs = @field.errors.full_messages.join ', '\n format.json { render json: { msg: errs }, status: :unprocessable_entity }\n end\n return\n end\n\n @project = Project.find(params[:field][:project_id])\n\n unless params[:field].key?(:name)\n @field.name = FormulaField.get_next_name(@project, @field.field_type)\n end\n\n respond_to do |format|\n if @field.save\n format.json { render json: @field.to_hash(false), status: :created, location: @field }\n else\n format.json { render json: @field.errors, status: :unprocessable_entity }\n end\n end\n end", "def definitions\n @definitions ||= { responses: {} }\n end", "def create\n @resource_type = ResourceType.new(params[:resource_type])\n respond_to do |format|\n if @resource_type.save\n if params[:fields]\n params[:fields].each do |param|\n @field = Field.new(\n :name => param[:name], \n :field_type_id => param[:field_type_id],\n :resource_type_id => @resource_type.id, \n :resource_type_reference_id => param[:resource_type_reference_id]\n )\n param[:validator_ids].each do |index|\n @field.field_validations.build(validator_id: index)\n end\n @field.save\n end\n end\n format.html { redirect_to @resource_type, notice: 'Resource type was successfully created.' }\n format.json { render json: @resource_type, status: :created, location: @resource_type }\n else\n format.html { render action: \"new\" }\n format.json { render json: @resource_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_or_update_service_definitions_with_http_info(body, opts = {})\n\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ServiceDefinitionAPI.create_or_update_service_definitions ...'\n end\n # verify the required parameter 'body' is set\n if @api_client.config.client_side_validation && body.nil?\n fail ArgumentError, \"Missing the required parameter 'body' when calling ServiceDefinitionAPI.create_or_update_service_definitions\"\n end\n # resource path\n local_var_path = '/api/v2/services/definitions'\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:debug_body] || @api_client.object_to_http_body(body)\n\n # return_type\n return_type = opts[:debug_return_type] || 'ServiceDefinitionCreateResponse'\n\n # auth_names\n auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth, :AuthZ]\n\n new_options = opts.merge(\n :operation => :create_or_update_service_definitions,\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 :api_version => \"V2\"\n )\n\n data, status_code, headers = @api_client.call_api(Net::HTTP::Post, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ServiceDefinitionAPI#create_or_update_service_definitions\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def table_def_params\n params.require(:table_def).permit(:name, fields_attributes: [:id, :name, :field_type, :required, :order, :_destroy])\n end", "def add_field(params = {})\n post(\"/fields\", params)\n end", "def definition_builder; end", "def definition_builder; end", "def test_post_form_field\n filename = 'FormFilled.docx'\n remote_name = 'TestPostFormField.docx'\n dest_name = remote_test_out + remote_name\n index = 0\n body = FormFieldTextInput.new({:Name => 'FullName', :Enabled => true, :CalculateOnExit => true,\n :StatusText => '', :TextInputType => 'Regular', :TextInputDefault => ''})\n\n st_request = PutCreateRequest.new remote_test_folder + test_folder + '/' + remote_name, File.open(local_test_folder + test_folder + '/' + filename, \"r\").read \n @storage_api.put_create st_request\n\n request = PostFormFieldRequest.new remote_name, body, index, remote_test_folder + test_folder, :dest_file_name => dest_name, :node_path => 'sections/0'\n result = @words_api.post_form_field request\n assert_equal 200, result.code\n end", "def update\n respond_to do |format|\n if @field_definition.update(field_definition_params)\n format.html { redirect_to @field_definition, notice: 'Field definition was successfully updated.' }\n format.json { render :show, status: :ok, location: @field_definition }\n else\n format.html { render :edit }\n format.json { render json: @field_definition.errors, status: :unprocessable_entity }\n end\n end\n end", "def r_property_definition_params\n params.require(:r_property_definition).permit(:property, :symbol, :table, :definition, :properties)\n end", "def create\n\n @definition = Definition.new(params[:definition])\n\n respond_to do |format|\n\n if @definition.save\n\n flash[:notice] = 'Definition was successfully created.'\n\n format.html {\n redirect_to(@definition)\n }\n format.xml {\n render(\n :xml => @definition.to_xml(:request => request),\n :status => :created,\n :location => @definition)\n }\n format.json {\n render(\n :json => @definition.to_json(:request => request),\n :status => :created,\n :location => @definition)\n }\n\n else\n\n format.html {\n render(:action => 'new')\n }\n format.xml {\n render(:xml => @definition.errors, :status => :unprocessable_entity)\n }\n format.json {\n render(:json => @definition.errors, :status => :unprocessable_entity)\n }\n end\n end\n end", "def definitions; end", "def definitions; end", "def create_break_type(body:)\n new_api_call_builder\n .request(new_request_builder(HttpMethodEnum::POST,\n '/v2/labor/break-types',\n 'default')\n .header_param(new_parameter('application/json', key: 'Content-Type'))\n .body_param(new_parameter(body))\n .header_param(new_parameter('application/json', key: 'accept'))\n .body_serializer(proc do |param| param.to_json unless param.nil? end)\n .auth(Single.new('global')))\n .response(new_response_handler\n .deserializer(APIHelper.method(:json_deserialize))\n .is_api_response(true)\n .convertor(ApiResponse.method(:create)))\n .execute\n end", "def create(client, workspace: required(\"workspace\"), resource_subtype: nil, type: nil, name: required(\"name\"), description: nil, precision: nil, enum_options: nil, options: {}, **data)\n with_params = data.merge(workspace: workspace, resource_subtype: resource_subtype || type, name: name, description: description, precision: precision, enum_options: enum_options).reject { |_,v| v.nil? || Array(v).empty? }\n Resource.new(parse(client.post(\"/custom_fields\", body: with_params, options: options)).first, client: client)\n end", "def create\n @task_definition = TaskDefinition.new(params[:task_definition])\n\n respond_to do |format|\n if @task_definition.save\n format.html { redirect_to @task_definition, notice: 'Task definition was successfully created.' }\n format.json { render json: @task_definition, status: :created, location: @task_definition }\n else\n format.html { render action: \"new\" }\n format.json { render json: @task_definition.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @r_property_definition = RPropertyDefinition.new(r_property_definition_params)\n\n respond_to do |format|\n if @r_property_definition.save\n format.html { redirect_to @r_property_definition, notice: 'R property definition was successfully created.' }\n format.json { render action: 'show', status: :created, location: @r_property_definition }\n else\n format.html { render action: 'new' }\n format.json { render json: @r_property_definition.errors, status: :unprocessable_entity }\n end\n end\n end", "def test_allow_dynamic_form_fields()\n # Parameters for the API call\n name = 'farhan'\n\n # dictionary for optional form parameters\n optional_form_parameters = {}\n optional_form_parameters['field'] = 'QA'\n\n # Perform the API call through the SDK function\n result = @controller.allow_dynamic_form_fields(name, _field_parameters: optional_form_parameters)\n\n # Test response code\n assert_equal(200, @response_catcher.response.status_code)\n\n # Test whether the captured response is as we expected\n refute_nil(result)\n expected_body = JSON.parse(\n '{\"passed\":true}'\n )\n received_body = JSON.parse(@response_catcher.response.raw_body)\n assert(TestHelper.match_body(expected_body, received_body, check_values: true))\n end", "def create\n @field = Field.new(field_params)\n\n respond_to do |format|\n if @field.save\n format.html { redirect_to @field, notice: 'Field was successfully created.' }\n format.json { render json: @field, status: :created, location: @field }\n else\n format.html { render action: \"new\" }\n format.json { render json: @field.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @field = Field.new(params[:field])\n\n respond_to do |format|\n if @field.save\n format.html { redirect_to @field, notice: 'Field was successfully created.' }\n format.json { render json: @field, status: :created, location: @field }\n else\n format.html { render action: \"new\" }\n format.json { render json: @field.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_process_def(process_def)\n doValidation(process_def)\n #@jtodoIMP handle when pass with ot without /\n post(process_def, self.create_process_uri)\n end", "def add_custom_field(field_name, options_array)\n \n validation_errors = []\n \n validation_errors.push('invalid_field_name') unless Util::CommonValidator.is_string?(field_name)\n validation_errors.push('invalid_options_array') unless Util::CommonValidator.is_array?(options_array)\n \n return validation_error(\n 'l_t_pd_d_2',\n 'something_went_wrong',\n validation_errors,\n GlobalConstant::ErrorAction.default\n ) if validation_errors.present?\n \n url_path = create_request_path(@deal_fields_endpoint)\n \n custom_params = {\n name: field_name,\n field_type: \"enum\",\n options: options_array\n }\n r = send_request_of_type('post', url_path, custom_params)\n return r unless r.success?\n \n success_with_data(\n {\n name: r[:data]['name'],\n key: r[:data]['key']\n })\n end", "def get_field_deserializers()\n return super.merge({\n \"definitions\" => lambda {|n| @definitions = n.get_collection_of_object_values(lambda {|pn| MicrosoftGraph::Models::AccessReviewScheduleDefinition.create_from_discriminator_value(pn) }) },\n \"historyDefinitions\" => lambda {|n| @history_definitions = n.get_collection_of_object_values(lambda {|pn| MicrosoftGraph::Models::AccessReviewHistoryDefinition.create_from_discriminator_value(pn) }) },\n })\n end", "def create\n @fieldtype = Fieldtype.new(params[:fieldtype])\n\n respond_to do |format|\n if @fieldtype.save\n format.html { redirect_to @fieldtype, notice: 'Fieldtype was successfully created.' }\n format.json { render json: @fieldtype, status: :created, location: @fieldtype }\n else\n format.html { render action: \"new\" }\n format.json { render json: @fieldtype.errors, status: :unprocessable_entity }\n end\n end\n end", "def trackingfield_create_with_http_info(body, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: TrackingFieldApi.trackingfield_create ...'\n end\n # verify the required parameter 'body' is set\n if @api_client.config.client_side_validation && body.nil?\n fail ArgumentError, \"Missing the required parameter 'body' when calling TrackingFieldApi.trackingfield_create\"\n end\n # resource path\n local_var_path = '/tracking_fields'\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', 'application/xml'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json', 'multipart/form-data'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = @api_client.object_to_http_body(body)\n auth_names = ['OAuth']\n data, status_code, headers = @api_client.call_api(:POST, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'InlineResponse2018')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: TrackingFieldApi#trackingfield_create\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def workflow_params\n params[:workflow].permit(:workflow, :id, :name, :type, :description, :_destroy,\n step_definitions: [ :id, :order, :workflow_id, \n field_definitions: \n [:id, :name, :field_type, :validationRegex, :required, :errorMessage, :order, :options]\n ],\n step_definitions_attributes: [ :id, :order, :workflow_id, :_destroy, \n field_definitions_attributes: \n [:id, :name, :field_type, :validationRegex, :required, :errorMessage, :order, :_destroy, :step_definition_id, :options]\n ])\n end", "def to_h\n hash = {}\n self.class.field_definitions.each do |k, v|\n hash[k] = field_value k\n end\n hash\n end", "def detect_define(d)\n if d[:body] =~ /\\A\\#\\s*define\\s+((\\w+)\\([^\\)]+\\))/\n d[:type] = :macro\n d[:decl] = $1.strip\n d[:name] = $2\n d[:tdef] = nil\n elsif d[:body] =~ /\\A\\#\\s*define\\s+(\\w+)/\n names = []\n d[:body].scan(/\\#\\s*define\\s+(\\w+)/) { |m| names << m[0].to_s }\n d[:tdef] = nil\n names.uniq!\n if names.length == 1\n d[:type] = :define\n d[:decl] = names[0]\n d[:name] = names[0]\n elsif names.length > 1\n d[:type] = :enum\n d[:decl] = names\n d[:name] = shortest_common_prefix(names)\n d[:name].sub!(/_*$/, '')\n end\n end\n end", "def create\n @defect_type = DefectType.new(defect_type_params)\n\n respond_to do |format|\n if @defect_type.save\n format.html { redirect_to @defect_type, notice: 'Defect type was successfully created.' }\n format.json { render :show, status: :created, location: @defect_type }\n else\n format.html { render :new }\n format.json { render json: @defect_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def create(definition)\n raise \"Index definition must be a Hash.\" unless definition.is_a? Hash\n definition[:name] = self.index_name unless !definition[:name]\n definition[:fields] = definition[:fields].map(&:to_hash)\n resp = create_request().post(build_index_list_url(), :json => definition)\n raise_on_http_error(resp)\n return JSON.parse(resp.to_s)\n end", "def to_schema\n { general: self.general_fields.map{ |field| {field.key => field.value} unless field.value.blank? }.compact.reduce(:merge) || {},\n input: self.input_parameters.map{ |input_parameter| { input_parameter.input_type => input_parameter.to_schema } } || [],\n method: {file: self.zip_url}.merge!(self.method_fields.map{ |field| {field.key => field.value} unless field.value.blank? }.compact.reduce(:merge) || {})\n }.to_json\n end", "def index\n @custom_definitions = CustomDefinition.all\n end", "def field_params\n params.require(:field).permit(:name, :title, :hint, :data_type, :default_value, validation_options: [])\n end", "def create_field_options(params)\n post('fieldOption/bulk', fieldOptions: params)\n end", "def create\n @definition = Definition.new(params[:definition])\n @definition.user_id = current_user.id\n current_user.definitions << @definition\n\n respond_to do |wants|\n if @definition.save\n flash[:notice] = 'Definition was successfully created.'\n wants.html { redirect_to(@definition) }\n wants.xml { render :xml => @definition, :status => :created, :location => @definition }\n else\n \tflash[:notice] = 'Definition was successfully created.'\n wants.html { render :action => \"new\" }\n wants.xml { render :xml => @definition.errors, :status => :unprocessable_entity }\n end\n end\n end", "def post #:doc:\n end", "def field_params\n params.require(:field).permit(:field_area, :field_average_slope, :field_name, :field_type, :location_id)\n end", "def create(field, options = {})\n body = options.has_key?(:body) ? options[:body] : {}\n body[:field] = field\n\n response = @client.post \"/api/topics/#{@topic_id}/fields\", body, options\n\n return response\n end", "def create(opts, org, metric, field_schemas)\n schema_dir = setup_dir(\"schema\")\n\n request = create_request(org, metric)\n schema_run(opts, schema_dir, \"createOrg\", request)\n\n request = create_request(org, metric, true)\n schema_run(opts, schema_dir, \"createMetric\", request)\n\n field_schemas.each{|key, value|\n create_field_internal(opts, request.merge({}), key, value)\n }\n end", "def create_fields\n create_fields_of(DivaServicesApi::Algorithm.general_information, :general)\n create_fields_of(DivaServicesApi::Algorithm.method_information, :method)\n end", "def create\n @all_field_type = AllFieldType.new(params[:all_field_type])\n\n respond_to do |format|\n if @all_field_type.save\n format.html { redirect_to @all_field_type, notice: 'All field type was successfully created.' }\n format.json { render json: @all_field_type, status: :created, location: @all_field_type }\n else\n format.html { render action: \"new\" }\n format.json { render json: @all_field_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @field_office = FieldOffice.new(field_office_params)\n\n respond_to do |format|\n if @field_office.save\n format.html { redirect_to @field_office, notice: 'Field office was successfully created.' }\n format.json { render :show, status: :created, location: @field_office }\n else\n format.html { render :new }\n format.json { render json: @field_office.errors, status: :unprocessable_entity }\n end\n end\n end", "def dfield_params\n params.require(:dfield).permit(:field_name, :field_type, :is_required, :is_show_in_list, :is_editable, :api, :brick_id, )\n end", "def create\n @field = Field.create(params[:field])\n respond_with :admin, @field\n end", "def create\n @farm_field = FarmField.new(farm_field_params)\n\n if @farm_field.save\n render :show, status: :created, location: api_farm_field_url(@farm_field)\n else\n render json: @farm_field.errors, status: :unprocessable_entity\n end\n end", "def create\n @defset = Defset.new(defset_params)\n\n respond_to do |format|\n if @defset.save\n format.html { redirect_to @defset, notice: 'Defset was successfully created.' }\n format.json { render action: 'show', status: :created, location: @defset }\n else\n format.html { render action: 'new' }\n format.json { render json: @defset.errors, status: :unprocessable_entity }\n end\n end\n end", "def word_params\n params.require(:word).permit(:word, :tag_list, definitions_attributes: [:definition, :URL])\n end", "def set_HasDefinition(value)\n set_input(\"HasDefinition\", value)\n end", "def set_HasDefinition(value)\n set_input(\"HasDefinition\", value)\n end", "def apply_schema(definition)\n schema = MultiJson.load(File.read(SCHEMA_PATH))\n JSON::Validator.fully_validate(schema, definition)\n end", "def print_definition()\n puts \"Definition\"\n puts \"----------------------------------------\"\n puts @word_info[:title], \" \"\n @word_info[:types_definitions].each do |type|\n puts \"\\t\" + type[:type]\n type[:definitions].each_with_index do |defintion, i|\n puts \"\\t #{i+1}. #{defintion}\"\n end\n print \"\\n\"\n end\n end", "def create_or_update_service_definitions(body, opts = {})\n data, _status_code, _headers = create_or_update_service_definitions_with_http_info(body, opts)\n data\n end", "def parse_define(d)\n if d[:body] =~ /define\\s+#{Regexp.quote(d[:name])}[ \\t]*(.*)/\n d[:value] = join_define($1)\n end\n d[:comments] = d[:rawComments].strip\n end", "def definitions(input)\n list = 1\n input.body.each do |definition|\n current_definition = definition['text']\n puts \"#{list}. #{current_definition}\"\n list += 1\n end\n end", "def definitions=(defs)\n @definitions = Hash[defs.collect do |key,value|\n [key.to_sym, Hash[value.collect do |key, val|\n [key.to_i, Hash[val.collect{|k,v| [k.to_i, v]}]]\n end]]\n end]\n end", "def generate_definitions_list\n definitions = YARD::Registry.all(:definition).uniq.sort_by{|define| define.name.to_s}\n generate_full_list(definitions, 'Definition', 'definitions')\nend", "def initialize\n @definitions = {}\n end", "def new\n @definition = Definition.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @definition }\n end\n end", "def new\n @definition = Definition.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @definition }\n end\n end", "def factory_definitions\n @factory_definitions ||= {}\n end", "def write_error_definitions!\n self.output[:definitions].merge!(\n 'Error' => {\n type: 'object',\n properties: {\n type: type_and_format('string'),\n message: type_and_format('string')\n }\n },\n 'Errors' => {\n type: 'object',\n properties: {\n errors: {\n type: 'array',\n items: { '$ref' => '#/definitions/Error' }\n }\n }\n }\n )\n end", "def export\n {\n ftype: type,\n role: role,\n name: name,\n sample_types: allowable_field_types.collect { |aft| aft.sample_type ? aft.sample_type.name : nil },\n object_types: allowable_field_types.collect { |aft| aft.object_type ? aft.object_type.name : nil },\n part: part ? true : false,\n array: array ? true : false,\n routing: routing,\n preferred_operation_type_id: preferred_operation_type_id,\n preferred_field_type_id: preferred_field_type_id,\n choices: choices\n }\n end", "def create_person_field(**args)\n params = parameters(args) do\n required_params :name, :field_type\n optional_params :name, :field_type, :options\n end\n request(:post, 'personFields', params)\n end", "def definition_translation_params\n params.require(:definition_translation).permit(:definition_id, :word_id,\n :contributor_id)\n end", "def create\n @import_def = ImportDef.new(params[:import_def])\n\n respond_to do |format|\n if @import_def.save\n format.html { redirect_to @import_def, notice: 'Import def was successfully created.' }\n format.json { render json: @import_def, status: :created, location: @import_def }\n else\n format.html { render action: \"new\" }\n format.json { render json: @import_def.errors, status: :unprocessable_entity }\n end\n end\n end", "def field_params\n params.require(:field).permit(:title, :height, :width, :price, :magazine_id, :status)\n end", "def define(arg)\n if arg\n arg = arg.chomp.rstrip.lstrip\n name = arg.split(\" \").first\n value = arg.gsub!(\"#{name} \",\"\")\n # negative\n if value =~ /^-(\\d|x)*$/ \n type = \"long\"\n # negative float\n elsif value =~ /^-(\\d|\\.|x)*$/ \n type = \"float\" \n elsif value =~ /[a-zA-Z]/\n type = \"str\"\n value = \"\\\"#{value}\\\"\"\n elsif value !~ /(\\.|x)/\n type = \"long\"\n elsif value =~ /(\\d*\\.\\d*)/ # and no \n type = \"float\"\n elsif value =~ /0x\\d\\d/\n type = \"byte\"\n else \n raise ArgumentError, \"opps, could not determine the define type, got #{value}\"\n end\n $define_types[name] = type\n arg = \"#define #{name} #{value}\"\n $defines << arg\n dummy_for_testing = arg, type\n end\n end", "def create_user_defined_field(params)\n update_user_defined_field(@id, 0, params)\n end", "def get_field_spec(field_name,field_spec)\n fspec = field_spec[field_name]\n fspec ||= field_name\n case\n when fspec.is_a?(String)\n fspec = {'type' => fspec}\n when fspec.is_a?(Array)\n fspec = {'values_enum' => fspec}\n end\n fspec['description'] ||= field_name.gsub(/_/,' ').capitalize\n fspec\n end", "def to_swagger\n result = {\n :name => @name,\n :in => @how_to_pass,\n :required => @required\n }\n\n if @type\n if @type == TYPE_ARRAY\n result[:type] = TYPE_ARRAY\n if @items\n if PRIMITIVE_TYPES.include? @items\n result[:items] = {:type => @items}\n else\n result[:schema] = ref_to_type(@items)\n end\n end\n else\n if PRIMITIVE_TYPES.include? @type\n result[:type] = @type\n else\n result[:schema] = ref_to_type(@type)\n end\n end\n end\n\n if @description\n result[:description] = @description\n end\n unless @params.empty?\n result.merge!(@params)\n end\n\n result\n end", "def define_index_field options = {}\n @params = {}\n\n @action = 'define_index_field'\n locals = Locals.fetch(action)\n options = check_required_fields(options, locals)\n\n build_params(locals, options)\n send_auth_request\n end", "def parse_definition_list; end", "def add_datastore_form_attribute_definition(name, description, allows_multiple, headers=default_headers)\n body = {\n \"allowsMultiple\" => allows_multiple,\n \"description\" => description,\n \"name\" => name\n }\n info(\"Adding Datastore Form attribute definition \\\"#{name}\\\" to the \\\"#{space_slug}\\\" space.\")\n # Create the attribute definition\n post(\"#{@api_url}/datastoreFormAttributeDefinitions\", body, headers)\n end" ]
[ "0.6650409", "0.6428674", "0.63167727", "0.5891492", "0.5798324", "0.57660174", "0.5747204", "0.5697241", "0.5676426", "0.56692153", "0.56343377", "0.56055397", "0.55115455", "0.5498918", "0.544877", "0.5438454", "0.5410673", "0.5372006", "0.53685665", "0.5311249", "0.52953166", "0.5273035", "0.52718747", "0.52558875", "0.52432144", "0.5232098", "0.5222984", "0.5214036", "0.5206842", "0.52064764", "0.51785696", "0.5161648", "0.51452225", "0.51452225", "0.5132312", "0.51067", "0.5102442", "0.50973034", "0.50811815", "0.50811815", "0.50561947", "0.5053126", "0.5050979", "0.50370985", "0.5033926", "0.50056493", "0.5001719", "0.49947125", "0.49868527", "0.49828944", "0.49744225", "0.4963548", "0.49629864", "0.49563932", "0.49434483", "0.49409202", "0.49389234", "0.49364015", "0.4935916", "0.49313435", "0.4923793", "0.4910663", "0.4908385", "0.49056497", "0.4905641", "0.4905303", "0.49030545", "0.49019155", "0.4899757", "0.48955968", "0.4885124", "0.4879895", "0.48634833", "0.48616388", "0.48570454", "0.48570454", "0.4853979", "0.48454663", "0.4830971", "0.48286054", "0.48135802", "0.48119545", "0.4800537", "0.47992966", "0.47808564", "0.47808564", "0.47793397", "0.47780252", "0.47760487", "0.47726825", "0.4769819", "0.47606704", "0.47605467", "0.47552586", "0.4754338", "0.47518054", "0.47491363", "0.47410378", "0.47392982", "0.4736124" ]
0.6931197
0
PATCH/PUT /field_definitions/1 PATCH/PUT /field_definitions/1.json
def update respond_to do |format| if @field_definition.update(field_definition_params) format.html { redirect_to @field_definition, notice: 'Field definition was successfully updated.' } format.json { render :show, status: :ok, location: @field_definition } else format.html { render :edit } format.json { render json: @field_definition.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n\n step_definition_attributes = step_definition_params\n field_definitions_attributes = step_definition_attributes.delete(\"field_definitions\")\n\n FieldDefinition.updateFieldDefinitions(field_definitions_attributes)\n\n respond_to do |format|\n if @step_definition.update(step_definition_attributes)\n format.html { redirect_to @step_definition, notice: 'Step definition was successfully updated.' }\n format.json { render :show, status: :ok, location: @step_definition }\n else\n format.html { render :edit }\n format.json { render json: @step_definition.errors, status: :unprocessable_entity }\n end\n end\n end", "def UpdateField params = {}\n \n APICall(path: 'ticket_fields.json',method: 'PUT',payload: params.to_json)\n \n end", "def update!(**args)\n @object_definitions = args[:object_definitions] if args.key?(:object_definitions)\n @operation_ids = args[:operation_ids] if args.key?(:operation_ids)\n end", "def update!(**args)\n @object_definitions = args[:object_definitions] if args.key?(:object_definitions)\n @operation_ids = args[:operation_ids] if args.key?(:operation_ids)\n end", "def update!(**args)\n @field_configs = args[:field_configs] if args.key?(:field_configs)\n @json_schema = args[:json_schema] if args.key?(:json_schema)\n @name = args[:name] if args.key?(:name)\n @struct_schema = args[:struct_schema] if args.key?(:struct_schema)\n end", "def update\n @schema_field = SchemaField.find(params[:id])\n\n respond_to do |format|\n if @schema_field.update_attributes(params[:schema_field])\n format.html { redirect_to @schema_field, :notice => 'Schema field was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @schema_field.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update_api_fields\n service_response = ClientManagement::UpdateApiFields.new(params).perform\n render_api_response(service_response)\n end", "def update!(**args)\n @json_schema = args[:json_schema] if args.key?(:json_schema)\n @name = args[:name] if args.key?(:name)\n @struct_schema = args[:struct_schema] if args.key?(:struct_schema)\n end", "def update!(**args)\n @json_schema = args[:json_schema] if args.key?(:json_schema)\n @name = args[:name] if args.key?(:name)\n @struct_schema = args[:struct_schema] if args.key?(:struct_schema)\n end", "def update_defect fields\n defect = @rally_api.find(:defect) { equal :formatted_i_d,\n fields[:formatted_i_d] }.first\n fields.delete_if { |name, val| val == defect.send(name) }\n defect.update(fields)\n end", "def update!(**args)\n @json_schemas = args[:json_schemas] if args.key?(:json_schemas)\n @schema = args[:schema] if args.key?(:schema)\n end", "def update_fields\n raise_if_no_document\n @doc.Fields.Update\n end", "def update\n respond_to do |format|\n if @resource_type.update_attributes(params[:resource_type])\n if params[:fields]\n params[:fields].each do |param|\n if param[:id]\n @field = Field.find(param[:id])\n @field.update_attributes(\n :name => param[:name], \n :field_type_id => param[:field_type_id],\n :resource_type_id => params[:id],\n :resource_type_reference_id => param[:resource_type_reference_id]\n )\n else\n @field = Field.create(\n :name => param[:name],\n :field_type_id => param[:field_type_id],\n :resource_type_id => params[:id],\n :resource_type_reference_id => param[:resource_type_reference_id]\n )\n end\n if @field.field_validations.any?\n @field.field_validations.each { |v| v.destroy }\n end\n if param[:validator_ids]\n param[:validator_ids].each do |index|\n next if index == \"multiselect-all\"\n @field.field_validations.build(validator_id: index.to_i)\n end\n end \n @field.save\n end\n end \n format.html { redirect_to @resource_type, notice: 'Resource type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @resource_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @custom_definition.update(custom_definition_params)\n format.html { redirect_to @custom_definition, notice: 'Custom definition was successfully updated.' }\n format.json { render :show, status: :ok, location: @custom_definition }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @custom_definition.errors, status: :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @additional_items = args[:additional_items] if args.key?(:additional_items)\n @additional_properties = args[:additional_properties] if args.key?(:additional_properties)\n @all_of = args[:all_of] if args.key?(:all_of)\n @any_of = args[:any_of] if args.key?(:any_of)\n @default = args[:default] if args.key?(:default)\n @definitions = args[:definitions] if args.key?(:definitions)\n @dependencies = args[:dependencies] if args.key?(:dependencies)\n @description = args[:description] if args.key?(:description)\n @enum = args[:enum] if args.key?(:enum)\n @example = args[:example] if args.key?(:example)\n @exclusive_maximum = args[:exclusive_maximum] if args.key?(:exclusive_maximum)\n @exclusive_minimum = args[:exclusive_minimum] if args.key?(:exclusive_minimum)\n @external_docs = args[:external_docs] if args.key?(:external_docs)\n @format = args[:format] if args.key?(:format)\n @id = args[:id] if args.key?(:id)\n @items = args[:items] if args.key?(:items)\n @max_items = args[:max_items] if args.key?(:max_items)\n @max_length = args[:max_length] if args.key?(:max_length)\n @max_properties = args[:max_properties] if args.key?(:max_properties)\n @maximum = args[:maximum] if args.key?(:maximum)\n @min_items = args[:min_items] if args.key?(:min_items)\n @min_length = args[:min_length] if args.key?(:min_length)\n @min_properties = args[:min_properties] if args.key?(:min_properties)\n @minimum = args[:minimum] if args.key?(:minimum)\n @multiple_of = args[:multiple_of] if args.key?(:multiple_of)\n @not = args[:not] if args.key?(:not)\n @one_of = args[:one_of] if args.key?(:one_of)\n @pattern = args[:pattern] if args.key?(:pattern)\n @pattern_properties = args[:pattern_properties] if args.key?(:pattern_properties)\n @properties = args[:properties] if args.key?(:properties)\n @ref = args[:ref] if args.key?(:ref)\n @required = args[:required] if args.key?(:required)\n @schema = args[:schema] if args.key?(:schema)\n @title = args[:title] if args.key?(:title)\n @type = args[:type] if args.key?(:type)\n @unique_items = args[:unique_items] if args.key?(:unique_items)\n end", "def update_field\n res = {\n :success => false,\n :msg => '',\n :data => {}\n }\n\n if (params[\"model\"] == nil)\n res[:msg] = 'order/update_field -- no model specified'\n else\n peer = nil\n case params[\"model\"]\n when \"entity\"\n peer = OrderEntity\n when \"company\"\n peer = Company\n when \"order\"\n peer = Order\n when \"order_revenu\"\n peer = OrderRevenu\n else\n res[:msg] = 'Could not locate that model'\n end\n if (peer != nil)\n obj = peer.new # <-- create a dummy instance of peer to check if method exists.\n if (!obj.respond_to?(params[\"field\"].to_a[0][0])) #<-- check the first key of hash only.\n res[:msg] = 'Error: Invalid field'\n else\n model = peer.update(params[:id], params[\"field\"])\n if (!model.errors.empty?)\n res = self.process_error(model.errors, res)\n else\n field = params[\"field\"].to_a\n res[:msg] = 'Updated field'\n res[:data][:field] = field[0][0]\n res[:data][:value] = field[0][1]\n res[:success] = true\n end\n end\n end\n end\n render :json => res, :layout => false\n end", "def update!(**args)\n @field_display_name = args[:field_display_name] if args.key?(:field_display_name)\n @field_id = args[:field_id] if args.key?(:field_id)\n @field_type = args[:field_type] if args.key?(:field_type)\n @formatted_type = args[:formatted_type] if args.key?(:formatted_type)\n @metadata = args[:metadata] if args.key?(:metadata)\n @multi_valued = args[:multi_valued] if args.key?(:multi_valued)\n @schema_display_name = args[:schema_display_name] if args.key?(:schema_display_name)\n @schema_id = args[:schema_id] if args.key?(:schema_id)\n @type = args[:type] if args.key?(:type)\n @value = args[:value] if args.key?(:value)\n end", "def update\n @definition = Definition.find(params[:id])\n @definition.update_attributes(params[:definition])\n respond_with @definition\n end", "def set_field_definition\n @field_definition = FieldDefinition.find(params[:id])\n end", "def update_metadata_field(field_name, value)\n @client.put(\"#{metadata_path}/#{field_name}\", nil, { value: value }, \"Content-Type\" => \"application/json\")\n end", "def test_update_field\n local_file_name = 'GetField.docx'\n remote_file_name = 'TestUpdateField.docx'\n\n upload_file File.join(local_test_folder, field_folder + '/' + local_file_name), remote_data_folder + '/' + remote_file_name\n\n request_field = FieldUpdate.new({:FieldCode => '{ NUMPAGES }'})\n request = UpdateFieldRequest.new(name: remote_file_name, index: 0, field: request_field, node_path: 'sections/0/paragraphs/0', folder: remote_data_folder)\n\n result = @words_api.update_field(request)\n assert_equal false, result.nil?\n end", "def update!(**args)\n @property_definitions = args[:property_definitions] if args.key?(:property_definitions)\n end", "def update_field(id, params = {})\n put(\"/fields/#{id}\", params)\n end", "def test_update_document_fields\n local_file_name = 'test_multi_pages.docx'\n remote_file_name = 'TestUpdateDocumentFields.docx'\n\n upload_file File.join(local_test_folder, 'Common/' + local_file_name), remote_data_folder + '/' + remote_file_name\n\n request = UpdateFieldsRequest.new(name: remote_file_name, folder: remote_data_folder)\n\n result = @words_api.update_fields(request)\n assert_equal false, result.nil?\n end", "def update\n @definition = Definition.find(params[:id])\n\n respond_to do |format|\n if @definition.update_attributes(params[:definition])\n format.html { redirect_to @definition, notice: 'Definition was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @definition.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @definition = Definition.find(params[:id])\n\n respond_to do |format|\n if @definition.update_attributes(params[:definition])\n format.html { redirect_to @definition, notice: 'Definition was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @definition.errors, status: :unprocessable_entity }\n end\n end\n end", "def update # PATCH\n raise NotImplementedError\n end", "def update_field(key,field,value)\n request :put, \"#{path_prefix}records/#{ue key}?field=#{ue field}\",\n :body => value,\n :content_type => \"application/octet-stream\"\n end", "def update\n if field_params[:as] =~ /pair/\n @field = CustomFieldPair.update_pair(params).first\n else\n @field = Field.find(params[:id])\n @field.update_attributes(field_params)\n end\n\n respond_with(@field)\n end", "def create_or_update_service_definitions_with_http_info(body, opts = {})\n\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ServiceDefinitionAPI.create_or_update_service_definitions ...'\n end\n # verify the required parameter 'body' is set\n if @api_client.config.client_side_validation && body.nil?\n fail ArgumentError, \"Missing the required parameter 'body' when calling ServiceDefinitionAPI.create_or_update_service_definitions\"\n end\n # resource path\n local_var_path = '/api/v2/services/definitions'\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:debug_body] || @api_client.object_to_http_body(body)\n\n # return_type\n return_type = opts[:debug_return_type] || 'ServiceDefinitionCreateResponse'\n\n # auth_names\n auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth, :AuthZ]\n\n new_options = opts.merge(\n :operation => :create_or_update_service_definitions,\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 :api_version => \"V2\"\n )\n\n data, status_code, headers = @api_client.call_api(Net::HTTP::Post, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ServiceDefinitionAPI#create_or_update_service_definitions\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def update_break_type(id:,\n body:)\n new_api_call_builder\n .request(new_request_builder(HttpMethodEnum::PUT,\n '/v2/labor/break-types/{id}',\n 'default')\n .template_param(new_parameter(id, key: 'id')\n .should_encode(true))\n .header_param(new_parameter('application/json', key: 'Content-Type'))\n .body_param(new_parameter(body))\n .header_param(new_parameter('application/json', key: 'accept'))\n .body_serializer(proc do |param| param.to_json unless param.nil? end)\n .auth(Single.new('global')))\n .response(new_response_handler\n .deserializer(APIHelper.method(:json_deserialize))\n .is_api_response(true)\n .convertor(ApiResponse.method(:create)))\n .execute\n end", "def update\n respond_to do |format|\n if @definition.update(definition_params)\n format.html { redirect_to @definition, notice: 'Definition was successfully updated.' }\n format.json { render :show, status: :ok, location: @definition }\n else\n format.html { render :edit }\n format.json { render json: @definition.errors, status: :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @fields = args[:fields] if args.key?(:fields)\n end", "def update!(**args)\n @fields = args[:fields] if args.key?(:fields)\n end", "def update!(**args)\n @fields = args[:fields] if args.key?(:fields)\n end", "def update!(**args)\n @fields = args[:fields] if args.key?(:fields)\n end", "def update!(**args)\n @fields = args[:fields] if args.key?(:fields)\n end", "def update\n respond_to do |format|\n if @definition.update(definition_params)\n format.html { redirect_to @definition, notice: \"Definition was successfully updated.\" }\n format.json { render :show, status: :ok, location: @definition }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @definition.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n puts field_params\n respond_to do |format|\n if @field.update(field_params)\n format.html { redirect_to fields_path, notice: 'Field was successfully updated.' }\n format.json { render :show, status: :ok, location: @field }\n else\n format.html { render :edit }\n format.json { render json: @field.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @field = Field.find(params[:id])\n\n respond_to do |format|\n if @field.update_attributes(params[:field])\n format.html { redirect_to @field, notice: 'Field was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @field.errors, status: :unprocessable_entity }\n end\n end\n end", "def update!\n @previously_changed = changes\n # extract only new values to build payload\n payload = Hash[changes.map { |key, values| [SYMBOL_TO_STRING[key.to_sym].to_sym, values[1]] }]\n @changed_attributes.try(:clear)\n changes_applied if respond_to?(:changes_applied)\n\n client.put(\"/customFields/#{id}\", payload)\n end", "def api_patch(path, data = {})\n api_request(:patch, path, :data => data)\n end", "def update!(**args)\n @cardinality = args[:cardinality] if args.key?(:cardinality)\n @default_value = args[:default_value] if args.key?(:default_value)\n @json_name = args[:json_name] if args.key?(:json_name)\n @kind = args[:kind] if args.key?(:kind)\n @name = args[:name] if args.key?(:name)\n @number = args[:number] if args.key?(:number)\n @oneof_index = args[:oneof_index] if args.key?(:oneof_index)\n @options = args[:options] if args.key?(:options)\n @packed = args[:packed] if args.key?(:packed)\n @type_url = args[:type_url] if args.key?(:type_url)\n end", "def update\n @field = Field.find(params[:id])\n @field.update_attributes(params[:field])\n respond_with :admin, @field\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 test_client_from_schema_with_url_prefix\n uuid = '1ab1c589-df46-40aa-b786-60e83b1efb10'\n body = {'Hello' => 'World!'}\n result = {'Goodbye' => 'Universe!'}\n Excon.stub(method: :patch) do |request|\n assert_equal(\"/api/resource/#{uuid}\", request[:path])\n assert_equal('application/json', request[:headers]['Content-Type'])\n assert_equal(body, MultiJson.load(request[:body]))\n Excon.stubs.pop\n {status: 200, headers: {'Content-Type' => 'application/json'},\n body: MultiJson.dump(result)}\n end\n\n schema = Heroics::Schema.new(SAMPLE_SCHEMA)\n output = StringIO.new\n cli = Heroics.cli_from_schema('cli', output, schema,\n 'https://example.com/api')\n cli.run('resource:update', uuid, body)\n assert_equal(MultiJson.dump(result, pretty: true) + \"\\n\", output.string)\n end", "def update(context)\n context.request.body.rewind # in case someone already read it\n\n begin\n data = JSON.parse(context.request.body.read)\n rescue JSON::ParserError\n context.halt(406, { status: 'error', message: 'Not acceptable JSON payload' }.to_json)\n end\n\n set_resource(context)\n\n begin\n permitted_params = resource_fields.map { |k| k[:name] }\n permitted_params = data.select { |k, _| permitted_params.include?(k) }\n\n if instance_variable_get(:\"@#{resource_name}\").update_attributes(permitted_params)\n instance_variable_get(:\"@#{resource_name}\").reload\n instance_variable_get(:\"@#{resource_name}\").to_json\n else\n errors = instance_variable_get(:\"@#{resource_name}\").errors.map { |k, v| \"#{k}: #{v}\" }.join('; ')\n context.halt(406, { status: 'error', message: errors }.to_json)\n end\n rescue StandardError => e\n context.halt(500, { status: 'error', message: e.message }.to_json)\n end\n end", "def update\n\n # workflow_attributes = workflow_params\n # step_definitions_attributes = workflow_attributes.delete(\"step_definitions\")\n\n # StepDefinition.updateStepDefinitions(step_definitions_attributes)\n\n respond_to do |format|\n if @workflow.update(workflow_params)\n format.html { redirect_to @workflow, notice: 'Workflow was successfully updated.' }\n format.json { render :show, status: :ok, location: @workflow }\n else\n format.html { render :edit }\n format.json { render json: @workflow.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @field = FormulaField.find(params[:id])\n\n respond_to do |format|\n if can_edit?(@field) && @field.update_attributes(field_params)\n format.html { redirect_to @field.project, notice: 'Field was successfully updated.' }\n format.json { render json: {}, status: :ok }\n else\n @field.errors[:base] << ('Permission denied') unless can_edit?(@field)\n logger.error \"Errors: #{@field.errors.inspect}\"\n format.html { redirect_to FormulaField.find(params[:id]), alert: 'Field was not updated.' }\n format.json { render json: @field.errors.full_messages, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @filed.update(field_params)\n format.html { redirect_to @field, notice: 'Successfully updated.' }\n format.json { render :show, status: :ok, location: @field }\n else\n format.html { render :edit }\n format.json { render json: @field.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_fields(fields)\n @id = fields['id']\n @name = fields['name']\n @type = fields['type']\n self\n end", "def update\n respond_to do |format|\n if @definition.update(definition_params)\n format.html { redirect_to @definition.dictionary || @definition, notice: 'Definition was successfully updated.' }\n format.json { render :show, status: :ok, location: @definition }\n else\n format.html { render :edit }\n format.json { render json: @definition.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @all_field_type = AllFieldType.find(params[:id])\n\n respond_to do |format|\n if @all_field_type.update_attributes(params[:all_field_type])\n format.html { redirect_to @all_field_type, notice: 'All field type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @all_field_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @description = args[:description] if args.key?(:description)\n @format = args[:format] if args.key?(:format)\n @json_path = args[:json_path] if args.key?(:json_path)\n @name = args[:name] if args.key?(:name)\n @priority = args[:priority] if args.key?(:priority)\n @type = args[:type] if args.key?(:type)\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 patch!\n request! :patch\n end", "def update!(**args)\n @schema_validation = args[:schema_validation] if args.key?(:schema_validation)\n @undeclared_properties = args[:undeclared_properties] if args.key?(:undeclared_properties)\n end", "def update!(**args)\n @field_path = args[:field_path] if args.key?(:field_path)\n end", "def update_definition(definition) update_attribute(:descriptor, definition) end", "def update!(**args)\n @fields = args[:fields] if args.key?(:fields)\n @name = args[:name] if args.key?(:name)\n @oneofs = args[:oneofs] if args.key?(:oneofs)\n @options = args[:options] if args.key?(:options)\n @source_context = args[:source_context] if args.key?(:source_context)\n @syntax = args[:syntax] if args.key?(:syntax)\n end", "def update_field(id, params)\n put(\"fields/#{id}\", field: params)\n end", "def update\n set_field\n # byebug\n if @field.update(fields_params)\n render :json => {}\n else\n render :json => @subject.errors, status: :unprocessable_entity\n end\n end", "def test_update_form_field\n remote_file_name = 'TestUpdateFormField.docx'\n\n upload_file File.join(local_test_folder, field_folder + '/FormFilled.docx'), remote_data_folder + '/' + remote_file_name\n\n request_form_field = FormFieldTextInput.new({:Name => 'FullName', :Enabled => true, :CalculateOnExit => true, :StatusText => '', :TextInputType => 'Regular', :TextInputDefault => 'No name'})\n request = UpdateFormFieldRequest.new(name: remote_file_name, index: 0, form_field: request_form_field, node_path: 'sections/0', folder: remote_data_folder, dest_file_name: remote_test_out + '/' + remote_file_name)\n\n result = @words_api.update_form_field(request)\n assert_equal false, result.nil?\n end", "def update\n respond_to do |format|\n if @defset.update(defset_params)\n format.html { redirect_to @defset, notice: 'Defset was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @defset.errors, status: :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @fields = args[:fields] if args.key?(:fields)\n @id = args[:id] if args.key?(:id)\n end", "def update!(**args)\n @completable_option = args[:completable_option] if args.key?(:completable_option)\n @dynamic_facetable_option = args[:dynamic_facetable_option] if args.key?(:dynamic_facetable_option)\n @field_path = args[:field_path] if args.key?(:field_path)\n @field_type = args[:field_type] if args.key?(:field_type)\n @indexable_option = args[:indexable_option] if args.key?(:indexable_option)\n @key_property_type = args[:key_property_type] if args.key?(:key_property_type)\n @recs_filterable_option = args[:recs_filterable_option] if args.key?(:recs_filterable_option)\n @retrievable_option = args[:retrievable_option] if args.key?(:retrievable_option)\n @searchable_option = args[:searchable_option] if args.key?(:searchable_option)\n end", "def update(field, options = {})\n body = options.has_key?(:body) ? options[:body] : {}\n body[:field] = field\n\n response = @client.put \"/api/topics/#{@topic_id}/fields/#{@id}\", body, options\n\n return response\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!(**args)\n @created = args[:created] if args.key?(:created)\n @definition = args[:definition] if args.key?(:definition)\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 @segment_id = args[:segment_id] if args.key?(:segment_id)\n @self_link = args[:self_link] if args.key?(:self_link)\n @type = args[:type] if args.key?(:type)\n @updated = args[:updated] if args.key?(:updated)\n end", "def update_fields(fields)\n @id = fields['id']\n @name = fields['name']\n @description = fields['desc']\n @closed = fields['closed']\n @url = fields['url']\n @organization_id = fields['idOrganization']\n self\n end", "def apply_schema(definition)\n schema = MultiJson.load(File.read(SCHEMA_PATH))\n JSON::Validator.fully_validate(schema, definition)\n end", "def update\n @import_def = ImportDef.find(params[:id])\n\n respond_to do |format|\n if @import_def.update_attributes(params[:import_def])\n format.html { redirect_to @import_def, notice: 'Import def was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @import_def.errors, status: :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @document_schema = args[:document_schema] if args.key?(:document_schema)\n end", "def update\n respond_to do |format|\n if @r_property_definition.update(r_property_definition_params)\n format.html { redirect_to @r_property_definition, notice: 'R property definition was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @r_property_definition.errors, status: :unprocessable_entity }\n end\n end\n end", "def test_update_model_with_body()\n # Parameters for the API call\n model = Employee.from_hash(APIHelper.json_deserialize(\n '{\"name\":\"Shahid Khaliq\",\"age\":5147483645,\"address\":\"H # 531, S # 20\",\"u'\\\n 'id\":\"123321\",\"birthday\":\"1994-02-13\",\"birthtime\":\"1994-02-13T14:01:54.9'\\\n '571247Z\",\"salary\":20000,\"department\":\"Software Development\",\"joiningDay'\\\n '\":\"Saturday\",\"workingDays\":[\"Monday\",\"Tuesday\",\"Friday\"],\"boss\":{\"perso'\\\n 'nType\":\"Boss\",\"name\":\"Zeeshan Ejaz\",\"age\":5147483645,\"address\":\"H # 531'\\\n ', S # 20\",\"uid\":\"123321\",\"birthday\":\"1994-02-13\",\"birthtime\":\"1994-02-1'\\\n '3T14:01:54.9571247Z\",\"salary\":20000,\"department\":\"Software Development\"'\\\n ',\"joiningDay\":\"Saturday\",\"workingDays\":[\"Monday\",\"Tuesday\",\"Friday\"],\"d'\\\n 'ependents\":[{\"name\":\"Future Wife\",\"age\":5147483649,\"address\":\"H # 531, '\\\n 'S # 20\",\"uid\":\"123412\",\"birthday\":\"1994-02-13\",\"birthtime\":\"1994-02-13T'\\\n '14:01:54.9571247Z\"},{\"name\":\"Future Kid\",\"age\":5147483648,\"address\":\"H '\\\n '# 531, S # 20\",\"uid\":\"312341\",\"birthday\":\"1994-02-13\",\"birthtime\":\"1994'\\\n '-02-13T14:01:54.9571247Z\"}],\"hiredAt\":\"Sun, 06 Nov 1994 08:49:37 GMT\",\"'\\\n 'promotedAt\":1484719381},\"dependents\":[{\"name\":\"Future Wife\",\"age\":51474'\\\n '83649,\"address\":\"H # 531, S # 20\",\"uid\":\"123412\",\"birthday\":\"1994-02-13'\\\n '\",\"birthtime\":\"1994-02-13T14:01:54.9571247Z\"},{\"name\":\"Future Kid\",\"age'\\\n '\":5147483648,\"address\":\"H # 531, S # 20\",\"uid\":\"312341\",\"birthday\":\"199'\\\n '4-02-13\",\"birthtime\":\"1994-02-13T14:01:54.9571247Z\"}],\"hiredAt\":\"Sun, 0'\\\n '6 Nov 1994 08:49:37 GMT\"}'\n ))\n\n # Perform the API call through the SDK function\n result = @controller.update_model(model)\n\n # Test response code\n assert_equal(200, @response_catcher.response.status_code)\n\n # Test whether the captured response is as we expected\n refute_nil(result)\n expected_body = JSON.parse(\n '{\"passed\":true}'\n )\n received_body = JSON.parse(@response_catcher.response.raw_body)\n assert(TestHelper.match_body(expected_body, received_body, check_values: true))\n end", "def update!(**args)\n @excluded_fields = args[:excluded_fields] if args.key?(:excluded_fields)\n @included_fields = args[:included_fields] if args.key?(:included_fields)\n @instance_type = args[:instance_type] if args.key?(:instance_type)\n @key_field = args[:key_field] if args.key?(:key_field)\n end", "def update_custom_field_with_http_info(id, api_custom_field, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: ProjectsApi#update_custom_field ...\"\n end\n \n # verify the required parameter 'id' is set\n fail \"Missing the required parameter 'id' when calling update_custom_field\" if id.nil?\n \n # verify the required parameter 'api_custom_field' is set\n fail \"Missing the required parameter 'api_custom_field' when calling update_custom_field\" if api_custom_field.nil?\n \n # resource path\n path = \"/Projects/{id}/CustomFields\".sub('{format}','json').sub('{' + 'id' + '}', id.to_s)\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n _header_accept = ['application/json', 'text/json']\n _header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result\n\n # HTTP header 'Content-Type'\n _header_content_type = ['application/json']\n header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = @api_client.object_to_http_body(api_custom_field)\n \n\n auth_names = []\n data, status_code, headers = @api_client.call_api(:PUT, path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'APICustomField')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ProjectsApi#update_custom_field\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def test_cli_from_schema\n uuid = '1ab1c589-df46-40aa-b786-60e83b1efb10'\n body = {'Hello' => 'World!'}\n result = {'Goodbye' => 'Universe!'}\n Excon.stub(method: :patch) do |request|\n assert_equal(\"/resource/#{uuid}\", request[:path])\n assert_equal('application/json', request[:headers]['Content-Type'])\n assert_equal(body, MultiJson.load(request[:body]))\n Excon.stubs.pop\n {status: 200, headers: {'Content-Type' => 'application/json'},\n body: MultiJson.dump(result)}\n end\n\n schema = Heroics::Schema.new(SAMPLE_SCHEMA)\n output = StringIO.new\n cli = Heroics.cli_from_schema('cli', output, schema, 'https://example.com')\n cli.run('resource:update', uuid, body)\n assert_equal(MultiJson.dump(result, pretty: true) + \"\\n\", output.string)\n end", "def update_api_definition_file\n if @research_tool.update(research_tool_params)\n redirect_to [:api_definition, :admin, @research_tool], notice: 'Research Tool was successfully updated.'\n else\n render :api_definition\n end\n end", "def update\n @fieldtype = Fieldtype.find(params[:id])\n\n respond_to do |format|\n if @fieldtype.update_attributes(params[:fieldtype])\n format.html { redirect_to @fieldtype, notice: 'Fieldtype was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @fieldtype.errors, status: :unprocessable_entity }\n end\n end\n end", "def update!(params)\n res = @client.put(path, nil, params, \"Content-Type\" => \"application/json\")\n @attributes = res.json if res.status == 201\n res\n end", "def update\n @field = Field.find(params[:id])\n\n respond_to do |format|\n if @field.update_attributes(params[:field])\n format.html { redirect_to([@kind, @field], :notice => t(:field_updated)) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @field.errors, :status => :unprocessable_entity }\n end\n end\n end", "def set_fields(object, json_object, *field_specs)\n field_specs.each do |field_spec|\n field_spec = field_spec.zip(field_spec).to_h if field_spec.is_a?(Array)\n field_spec.each do |json_field, hq_field|\n object.send(\"#{hq_field}=\", json_object[json_field.to_s])\n end\n end\n end", "def update_definition(id, new_def)\n MinWords::DB[:defines]\n .where(id: id)\n .update(:definition_text => new_def)\n end", "def update_field\n begin\n load_resource\n\n param_permits.each do |k,v|\n @grid.get_column(k).set(@resource, v)\n end\n\n if @resource.save\n render :json => @grid.get_hash(prepare_collection_query.where(id: @resource.id).first)\n else\n render :json => {status: \"ERROR\", errors: @resource.errors.messages }, status: :unprocessable_entity\n end\n rescue ActiveRecord::RecordNotSaved, ActiveRecord::RecordInvalid\n #This case can occurs when one field is a compound field and call \"save!\" method for example.\n render :json => {status: \"ERRORS\", errors: @resource.errors.messages }, status: :unprocessable_entity\n end\n end", "def update!(**args)\n @allowed_values = args[:allowed_values] if args.key?(:allowed_values)\n @deprecated = args[:deprecated] if args.key?(:deprecated)\n @description = args[:description] if args.key?(:description)\n @display_name = args[:display_name] if args.key?(:display_name)\n @fields = args[:fields] if args.key?(:fields)\n @immutable = args[:immutable] if args.key?(:immutable)\n @max_value = args[:max_value] if args.key?(:max_value)\n @min_value = args[:min_value] if args.key?(:min_value)\n @param_id = args[:param_id] if args.key?(:param_id)\n @recurse = args[:recurse] if args.key?(:recurse)\n @repeated = args[:repeated] if args.key?(:repeated)\n @required = args[:required] if args.key?(:required)\n @type = args[:type] if args.key?(:type)\n @validation_description = args[:validation_description] if args.key?(:validation_description)\n @validation_help_url = args[:validation_help_url] if args.key?(:validation_help_url)\n @validation_regex = args[:validation_regex] if args.key?(:validation_regex)\n end", "def update!(**args)\n @debug_options = args[:debug_options] if args.key?(:debug_options)\n @schema = args[:schema] if args.key?(:schema)\n @validate_only = args[:validate_only] if args.key?(:validate_only)\n end", "def update!(**args)\n @debug_options = args[:debug_options] if args.key?(:debug_options)\n @schema = args[:schema] if args.key?(:schema)\n @validate_only = args[:validate_only] if args.key?(:validate_only)\n end", "def postprocess(json_schema); json_schema; end", "def step_definition_params\n params.permit(:id, :order, :workflow_id, \n field_definitions: [:id, :name, :field_type, :validationRegex, :required, :errorMessage, :order]\n )\n end", "def update_fields(fields)\n attributes[:name] = fields['name']\n attributes[:id] = fields['id']\n self\n end", "def update!(**args)\n @name = args[:name] if args.key?(:name)\n @options = args[:options] if args.key?(:options)\n @property_definitions = args[:property_definitions] if args.key?(:property_definitions)\n end", "def update!(**args)\n @name = args[:name] if args.key?(:name)\n @options = args[:options] if args.key?(:options)\n @property_definitions = args[:property_definitions] if args.key?(:property_definitions)\n end", "def update_form_attribute_definition(kapp_slug, name, body, headers=default_headers)\n @logger.info(\"Updating the \\\"#{name}\\\" Form attribute definition in the \\\"#{kapp_slug}\\\" kapp.\")\n put(\"#{@api_url}/kapps/#{kapp_slug}/formAttributeDefinitions/#{encode(name)}\",body, headers)\n end", "def update(options: {}, **data)\n\n refresh_with(parse(client.put(\"/custom_fields/#{gid}\", body: data, options: options)).first)\n end", "def apply_ammendments(api_schema)\n api_schema.fetch(:apis).each do |endpoint|\n endpoint.fetch(:operations).each do |method|\n method[:nickname] = method[:nickname].sub('Api::V1::', '') unless method[:nickname].nil?\n method[:consumes] = ['application/x-www-form-urlencoded'] if ['post', 'patch', 'put', 'delete'].include? method[:method].downcase\n\n method[:parameters].each do |p|\n p[:required] = true if p[:required] == 'required'\n\n case p[:type]\n when 'date'\n p[:type] = 'string'\n p[:format] = 'date'\n when 'datetime'\n p[:type] = 'string'\n p[:format] = 'date-time'\n end\n\n p[:name] = :payload if p[:paramType] == 'body' && p[:name] == ''\n p[:'allowMultiple'] = true if p[:name] == 'state' # actually API allows multiple states in query\n end\n\n method[:responseMessages].each do |response_message|\n next unless response_message[:message].match?(/pdf/i)\n\n response_message[:responseModel] ||= 'File'\n method[:produces] ||= ['application/pdf', 'application/json']\n end\n end\n end\n\n\n api_schema.fetch(:models).values.each do |model|\n if model.fetch(:id) == 'Order'\n model.fetch(:properties)['updated_at'] ||= {:type=>\"date-time\", :description=>nil}\n end\n\n model.fetch(:properties).each do |name, property|\n case property[:type]\n when 'complex'\n property[:type] = [:items, :purchase_items].include?(name) ? 'array' : property[:items][:'$ref']\n when 'date'\n property[:type] = 'date-time'\n end\n end\n end\nend", "def update!(**args)\n @open_apiv3_schema = args[:open_apiv3_schema] if args.key?(:open_apiv3_schema)\n end", "def update!(**args)\n @recursive_structure_depth = args[:recursive_structure_depth] if args.key?(:recursive_structure_depth)\n @schema_type = args[:schema_type] if args.key?(:schema_type)\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 respond_to do |format|\n if @schema.update(schema_params)\n format.html { redirect_to @schema, notice: 'Schema was successfully updated.' }\n format.json { render :show, status: :ok, location: @schema }\n else\n format.html { render :edit }\n format.json { render json: @schema.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.6562135", "0.6268004", "0.6123477", "0.6123477", "0.60710317", "0.59882385", "0.597456", "0.5937513", "0.5937513", "0.5863146", "0.5801755", "0.57935566", "0.57839036", "0.57632226", "0.5755195", "0.57141423", "0.5708985", "0.5672161", "0.5616817", "0.5612955", "0.55771303", "0.55692136", "0.5542782", "0.5541977", "0.5525384", "0.5525384", "0.5503672", "0.5492557", "0.5480284", "0.5477684", "0.5469038", "0.54615855", "0.5455789", "0.5455789", "0.5455789", "0.5455789", "0.5455789", "0.5454446", "0.5452467", "0.5431709", "0.5429756", "0.5429476", "0.542132", "0.54137206", "0.5411511", "0.5404733", "0.5402886", "0.540071", "0.53979784", "0.53847814", "0.53638965", "0.5358105", "0.5343511", "0.534286", "0.53422046", "0.53235567", "0.5313915", "0.53023916", "0.52998954", "0.529511", "0.5293746", "0.52796245", "0.5279192", "0.5262343", "0.5260396", "0.5257075", "0.52553725", "0.5254486", "0.52512115", "0.5247855", "0.52470815", "0.52436906", "0.5240657", "0.5237831", "0.5225275", "0.52165914", "0.5215436", "0.52144635", "0.52135247", "0.5213379", "0.5211591", "0.5208897", "0.5206017", "0.5201929", "0.5199169", "0.51947224", "0.51942056", "0.51942056", "0.5192773", "0.5179228", "0.517808", "0.51761717", "0.51761717", "0.5159611", "0.51584834", "0.5156301", "0.51532286", "0.51506215", "0.5139983", "0.51356846" ]
0.65656084
0
DELETE /field_definitions/1 DELETE /field_definitions/1.json
def destroy @field_definition.destroy respond_to do |format| format.html { redirect_to field_definitions_url, notice: 'Field definition was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete_field!(field_name); end", "def DeleteField id\n \n APICall(path: \"ticket_fields/#{id}.json\",method: 'DELETE')\n \n end", "def delete_field(id)\n delete(\"fields/#{id}\")\n end", "def test_delete_field\n local_file_name = 'GetField.docx'\n remote_file_name = 'TestDeleteField.docx'\n\n upload_file File.join(local_test_folder, field_folder + '/' + local_file_name), remote_data_folder + '/' + remote_file_name\n\n request = DeleteFieldRequest.new(name: remote_file_name, index: 0, node_path: 'sections/0/paragraphs/0', folder: remote_data_folder)\n\n @words_api.delete_field(request)\n end", "def destroy\n @schema_field = SchemaField.find(params[:id])\n @schema_field.destroy\n\n respond_to do |format|\n format.html { redirect_to schema_fields_url }\n format.json { head :ok }\n end\n end", "def destroy\n @field = Field.find(params[:id])\n @field.destroy\n\n respond_to do |format|\n format.html { redirect_to fields_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @field = Field.find(params[:id])\n @field.destroy\n\n respond_to do |format|\n format.html { redirect_to fields_url }\n format.json { head :no_content }\n end\n end", "def delete\n client.delete(\"/customFields/#{id}\")\n end", "def delete_custom_field(custom_field_id)\n url = \"#{@goseg_base_url}/custom_fields/#{custom_field_id}\"\n puts url\n return RestClient.delete(url){|response, request, result| response }\n end", "def destroy\n\n @definition = Definition.find(params[:id])\n @definition.destroy\n\n respond_to do |format|\n format.html { redirect_to(definitions_url) }\n format.xml { head :ok }\n format.json { head :ok }\n end\n end", "def destroy\n @all_field_type = AllFieldType.find(params[:id])\n @all_field_type.destroy\n\n respond_to do |format|\n format.html { redirect_to all_field_types_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @fieldtype = Fieldtype.find(params[:id])\n @fieldtype.destroy\n\n respond_to do |format|\n format.html { redirect_to fieldtypes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @definition = Definition.find(params[:id])\n @definition.destroy\n\n respond_to do |format|\n format.html { redirect_to definitions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @definition = Definition.find(params[:id])\n @definition.destroy\n\n respond_to do |format|\n format.html { redirect_to definitions_url }\n format.json { head :no_content }\n end\n end", "def delete_field(*fields)\n fields.each {|f|\n f = check_field(f)\n raise ArgumentError, \"can not delete reserved field: #{f.inspect}\" if f.start_with?(\"_\") \n @tbl.delete(f)\n @field_list.delete(f)\n }\n nil\n end", "def test_delete_form_field\n filename = 'FormFilled.docx'\n remote_name = 'TestDeleteFormField.docx'\n index = 0\n\n st_request = PutCreateRequest.new remote_test_folder + test_folder + '/' + remote_name, File.open(local_test_folder + test_folder + '/' + filename, \"r\").read \n @storage_api.put_create st_request\n\n request = DeleteFormFieldRequest.new remote_name, index, remote_test_folder + test_folder, :node_path => 'sections/0'\n result = @words_api.delete_form_field request\n assert_equal 200, result.code\n end", "def destroy\n @field = Field.find(params[:id])\n @field.destroy\n\n respond_with(@field)\n end", "def destroy\n @api_v1_initiative_field.destroy\n respond_to do |format|\n format.html { redirect_to api_v1_initiative_fields_url, notice: 'Initiative field was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @definition.destroy\n respond_to do |format|\n format.html { redirect_to definitions_url, notice: 'Definition was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete(name)\n fields.delete(name.to_sym)\n end", "def destroy\n @definition.destroy\n respond_to do |format|\n format.html { redirect_to definitions_url, notice: \"Definition was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @field_rule.destroy\n respond_to do |format|\n format.html { redirect_to object_rule_field_rules_url, notice: ' field rule was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete()\n\n client.delete(\"/custom_fields/#{gid}\") && true\n end", "def destroy\n @field.destroy\n respond_to do |format|\n format.html { redirect_to fields_url, notice: 'Field was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def test_delete_field_without_node_path\n local_file_name = 'GetField.docx'\n remote_file_name = 'TestDeleteFieldWithoutNodePath.docx'\n\n upload_file File.join(local_test_folder, field_folder + '/' + local_file_name), remote_data_folder + '/' + remote_file_name\n\n request = DeleteFieldRequest.new(name: remote_file_name, index: 0, folder: remote_data_folder)\n\n @words_api.delete_field(request)\n end", "def delete_deal_field(id:, **args)\n params = parameters(args) do\n optional_params\n end\n request(:delete, \"dealFields/#{id}\", params)\n end", "def destroy\n @field = Field.find(params[:id])\n @field.destroy\n\n respond_to do |format|\n format.html { redirect_to(kind_fields_url(@kind)) }\n format.xml { head :ok }\n end\n end", "def test_delete_document_fields\n local_file_name = 'test_multi_pages.docx'\n remote_file_name = 'TestDeleteSectionParagraphFields.docx'\n\n upload_file File.join(local_test_folder, 'Common/' + local_file_name), remote_data_folder + '/' + remote_file_name\n\n request = DeleteFieldsRequest.new(name: remote_file_name, node_path: '', folder: remote_data_folder)\n\n @words_api.delete_fields(request)\n end", "def destroy\n @import_def = ImportDef.find(params[:id])\n @import_def.destroy\n\n respond_to do |format|\n format.html { redirect_to import_defs_url }\n format.json { head :ok }\n end\n end", "def test_delete_form_field\n remote_file_name = 'TestDeleteFormField.docx'\n\n upload_file File.join(local_test_folder, field_folder + '/FormFilled.docx'), remote_data_folder + '/' + remote_file_name\n\n request = DeleteFormFieldRequest.new(name: remote_file_name, index: 0, node_path: 'sections/0', folder: remote_data_folder, dest_file_name: remote_test_out + '/' + remote_file_name)\n\n @words_api.delete_form_field(request)\n end", "def destroy\n @invoicefield = Invoicefield.find(params[:id])\n @invoicefield.destroy\n\n respond_to do |format|\n format.html { redirect_to invoicefields_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @field = Field.find(params[:id])\n @field.destroy\n respond_with :admin, @field\n end", "def destroy\n @field = FormulaField.find(params[:id])\n @project = Project.find(@field.project_id)\n if can_delete?(@field) && (@project.data_sets.count == 0)\n @field.destroy\n respond_to do |format|\n format.json { render json: {}, status: :ok }\n format.html { redirect_to @field.project, notice: 'Field was successfuly deleted.' }\n end\n else\n @errors = []\n if @project.data_sets.count > 0\n @errors.push 'Project Not Empty.'\n end\n if (can_delete?(@field) == false)\n @errors.push 'User Not Authorized.'\n end\n respond_to do |format|\n format.json { render json: { errors: @errors }, status: :forbidden }\n format.html { redirect_to @field.project, alert: 'Field could not be destroyed' }\n end\n end\n end", "def destroy\n @field.update_attribute(:status, 'N')\n respond_to do |format|\n format.html { redirect_to magazine_issue_fields_path , notice: 'Field was successfully deleted.'}\n format.json { head :no_content }\n end\n end", "def delete_field_value(id)\n delete(\"fieldValues/#{id}\")\n end", "def delete_deal_fields(**args)\n params = parameters(args) do\n required_params :ids\n optional_params :ids\n end\n request(:delete, 'dealFields', params)\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 field_id = params[:id].to_s.split(/_/).last.to_i\n @field = Field.find(field_id)\n\n ActiveRecord::Base.transaction do\n @field.destroy\n end\n\n respond_to do |format|\n format.html # destroy.html.erb\n format.xml { render :xml => @field }\n end\n end", "def test_send_delete_body_with_blank_name_and_field()\n # Parameters for the API call\n body = DeleteBody.from_hash(APIHelper.json_deserialize(\n '{\"name\":\" \",\"field\":\" \"}'\n ))\n\n # Perform the API call through the SDK function\n result = @controller.send_delete_body(body)\n\n # Test response code\n assert_equal(200, @response_catcher.response.status_code)\n\n # Test whether the captured response is as we expected\n refute_nil(result)\n expected_body = JSON.parse(\n '{\"passed\":true}'\n )\n received_body = JSON.parse(@response_catcher.response.raw_body)\n assert(TestHelper.match_body(expected_body, received_body, check_values: true))\n end", "def test_send_delete_body_with_blank_field()\n # Parameters for the API call\n body = DeleteBody.from_hash(APIHelper.json_deserialize(\n '{\"name\":\"farhan\",\"field\":\" \"}'\n ))\n\n # Perform the API call through the SDK function\n result = @controller.send_delete_body(body)\n\n # Test response code\n assert_equal(200, @response_catcher.response.status_code)\n\n # Test whether the captured response is as we expected\n refute_nil(result)\n expected_body = JSON.parse(\n '{\"passed\":true}'\n )\n received_body = JSON.parse(@response_catcher.response.raw_body)\n assert(TestHelper.match_body(expected_body, received_body, check_values: true))\n end", "def destroy\n @r_property_definition.destroy\n respond_to do |format|\n format.html { redirect_to r_property_definitions_url }\n format.json { head :no_content }\n end\n end", "def delete_field(name, field_name, opts = {})\n @api_client.request_token_if_needed\n data, _status_code, _headers = delete_field_with_http_info(name, field_name, opts)\n rescue ApiError => error\n if error.code == 401\n @api_client.request_token_if_needed\n data, _status_code, _headers = delete_field_with_http_info(name, field_name, opts)\n else\n raise\n end\n return data\n end", "def test_delete_form_test_with_blank_field()\n # Parameters for the API call\n body = DeleteBody.from_hash(APIHelper.json_deserialize(\n '{\"name\":\"farhan\",\"field\":\" \"}'\n ))\n\n # Perform the API call through the SDK function\n result = @controller.send_delete_form(body)\n\n # Test response code\n assert_equal(200, @response_catcher.response.status_code)\n\n # Test whether the captured response is as we expected\n refute_nil(result)\n expected_body = JSON.parse(\n '{\"passed\":true}'\n )\n received_body = JSON.parse(@response_catcher.response.raw_body)\n assert(TestHelper.match_body(expected_body, received_body, check_values: true))\n end", "def delete_field_rel(id)\n delete(\"fieldRels/#{id}\")\n end", "def test_delete_paragraph_fields\n local_file_name = 'test_multi_pages.docx'\n remote_file_name = 'TestDeleteParagraphFields.docx'\n\n upload_file File.join(local_test_folder, 'Common/' + local_file_name), remote_data_folder + '/' + remote_file_name\n\n request = DeleteFieldsRequest.new(name: remote_file_name, node_path: 'paragraphs/0', folder: remote_data_folder)\n\n @words_api.delete_fields(request)\n end", "def destroy\n @company_dei_field.destroy\n respond_to do |format|\n format.html { redirect_to company_dei_fields_url, notice: \"Company dei field was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def delete(field)\n redis.hdel @key, field\n end", "def destroy\n @custom_definition.destroy\n redirect_to @site\n end", "def test_send_delete_body_with_special_field_name()\n # Parameters for the API call\n body = DeleteBody.from_hash(APIHelper.json_deserialize(\n '{\"name\":\"farhan\",\"field\":\"&&&\"}'\n ))\n\n # Perform the API call through the SDK function\n result = @controller.send_delete_body(body)\n\n # Test response code\n assert_equal(200, @response_catcher.response.status_code)\n\n # Test whether the captured response is as we expected\n refute_nil(result)\n expected_body = JSON.parse(\n '{\"passed\":true}'\n )\n received_body = JSON.parse(@response_catcher.response.raw_body)\n assert(TestHelper.match_body(expected_body, received_body, check_values: true))\n end", "def test_delete_section_fields\n local_file_name = 'test_multi_pages.docx'\n remote_file_name = 'TestDeleteSectionFields.docx'\n\n upload_file File.join(local_test_folder, 'Common/' + local_file_name), remote_data_folder + '/' + remote_file_name\n\n request = DeleteFieldsRequest.new(name: remote_file_name, node_path: 'sections/0', folder: remote_data_folder)\n\n @words_api.delete_fields(request)\n end", "def destroy\n Kernel.const_get(params[:model_name]).remove_dynamo_field(params[:field_name])\n redirect_to :controller => \"admin/fields\", :action => \"edit\", :model_name=>params[:model_name]\n end", "def destroy\n @sobject_field = SobjectField.find(params[:id])\n @sobject_field.destroy\n \n respond_to do |format|\n format.html { redirect_to sobject_fields_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @tbl_form_field.destroy\n respond_to do |format|\n format.html { redirect_to tbl_form_fields_url, notice: 'Tbl form field was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete_datastore_form_attribute_definition(name, headers=default_headers)\n @logger.info(\"Deleting the \\\"#{name}\\\" Datastore Form Attribute Definition\")\n delete(\"#{@api_url}/datastoreFormAttributeDefinitions/#{encode(name)}\", headers)\n end", "def destroy\n @valuefield = Valuefield.find(params[:id])\n @valuefield.destroy\n\n respond_to do |format|\n format.html { redirect_to '/admin' }\n format.json { head :ok }\n end\n end", "def destroy\n dictionary = @definition.dictionary\n @definition.destroy\n respond_to do |format|\n format.html { redirect_to dictionary_url(dictionary.id), notice: 'Definition was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @form_field.destroy\n respond_to do |format|\n format.html { redirect_to form_fields_url, notice: 'Form field was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @step_definition.destroy\n respond_to do |format|\n format.html { redirect_to step_definitions_url, notice: 'Step definition was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @table_def.destroy\n respond_to do |format|\n format.html { redirect_to table_defs_url, status: 303 }\n format.json { head :no_content }\n end\n end", "def destroy\n @field = Field.find(params[:id])\n begin\n @field.destroy \n rescue ActiveRecord::DeleteRestrictionError => e\n @field.errors.add(:base, e)\n end \n respond_to do |format|\n\n if e.nil?\n \n format.html { redirect_to(\"/fieldview\", :notice => 'field was successfully deleted.') }\n format.xml { head :ok }\n else \n format.html { render :action => \"edit\" }\n end\n \n \n end\n end", "def destroy\n @question_field = QuestionField.find(params[:id])\n @question_field.destroy\n\n respond_to do |format|\n format.html { redirect_to question_fields_url }\n format.json { head :no_content }\n end\n end", "def delete(path)\n RestClient.delete request_base+path\n end", "def delete_field_option(id)\n delete(\"fieldOptions/#{id}\")\n end", "def hdel(key, *fields); end", "def destroy\n @custom_field.destroy\n respond_to do |format|\n format.html { redirect_to custom_fields_url, notice: 'Custom field was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @field.destroy\n respond_to do |format|\n format.html { redirect_to company_form_group_fields_url(@company, @form, @group), notice: 'Form field was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def deletef\n url = prefix + \"deletef\" + id_param\n return response(url)\n end", "def delete(table_name, field)\nmongo_client = Mongo::Client.new($mongo_connect_string)\n if table_name == \"channel_reach\" && field == \"age\"\n result=mongo_client[:\"#{table_name}\"].delete_one({ \"#{field}\": '100' })\n elsif table_name == \"country_state_mappings\" && field == \"state\"\n result = mongo_client[:\"#{table_name}\"].delete_one({ country: \"India\", \"#{field}\": \"TestState\" })\n elsif table_name == \"regions\" && field == \"region\"\n result = mongo_client[:regions].delete_one({ region: \"Test Region\", type: \"Metro\", location: \"East\", contained_in: \"N/A\" })\n else\n result=mongo_client[:\"#{table_name}\"].delete_one({ \"#{field}\": 'Test New' })\n end\nend", "def test_delete_paragraph_fields_without_node_path\n local_file_name = 'test_multi_pages.docx'\n remote_file_name = 'TestDeleteParagraphFieldsWithoutNodePath.docx'\n\n upload_file File.join(local_test_folder, 'Common/' + local_file_name), remote_data_folder + '/' + remote_file_name\n\n request = DeleteFieldsRequest.new(name: remote_file_name, folder: remote_data_folder)\n\n @words_api.delete_fields(request)\n end", "def delete\n api(\"Delete\")\n end", "def destroy\n @company_field.destroy\n respond_to do |format|\n format.html { redirect_to company_fields_url, notice: 'Company field was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete(field)\n canonical = downcased(field)\n @headers.delete(canonical) if @headers.key?(canonical)\n end", "def destroy\n @dynabute_field.destroy\n respond_to do |format|\n format.html { redirect_to dynabute_fields_path(@dynabute_field.target_model), notice: 'Dynabute was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def hdel(key, *fields)\n fields.flatten!(1)\n send_command([:hdel, key].concat(fields))\n end", "def hdel(key, *fields)\n fields.flatten!(1)\n node_for(key).hdel(key, fields)\n end", "def deleteRequest\n\n end", "def delete(name = nil)\n if name\n redis.del field_key(name.to_s)\n else\n self.class.fields.each do |field|\n redis.del field_key(field[:name])\n end\n redis.srem \"sequence:#{prefix}:all\", self.id\n end\n end", "def delete_person_field(id:, **args)\n params = parameters(args) do\n optional_params\n end\n request(:delete, \"personFields/#{id}\", params)\n end", "def test_delete_section_paragraph_fields\n local_file_name = 'test_multi_pages.docx'\n remote_file_name = 'TestDeleteSectionParagraphFields.docx'\n\n upload_file File.join(local_test_folder, 'Common/' + local_file_name), remote_data_folder + '/' + remote_file_name\n\n request = DeleteFieldsRequest.new(name: remote_file_name, node_path: 'sections/0/paragraphs/0', folder: remote_data_folder)\n\n @words_api.delete_fields(request)\n end", "def destroy\n @processdef = Processdef.find(params[:id])\n @processdef.destroy\n\n respond_to do |format|\n format.html { redirect_to processdefs_url }\n format.json { head :no_content }\n end\n end", "def delete(*rest) end", "def test_delete_section_fields_without_node_path\n local_file_name = 'test_multi_pages.docx'\n remote_file_name = 'TestDeleteSectionFieldsWithoutNodePath.docx'\n\n upload_file File.join(local_test_folder, 'Common/' + local_file_name), remote_data_folder + '/' + remote_file_name\n\n request = DeleteFieldsRequest.new(name: remote_file_name, folder: remote_data_folder)\n\n @words_api.delete_fields(request)\n end", "def destroy\n @task_definition = TaskDefinition.find(params[:id])\n @task_definition.destroy\n\n respond_to do |format|\n format.html { redirect_to task_definitions_url }\n format.json { head :no_content }\n end\n end", "def op_destroy!(field)\n operate_field! field, { __op: :Delete }.freeze\n end", "def delete path\n make_request(path, \"delete\", {})\n end", "def delete_field_with_http_info(name, field_name, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: PdfApi.delete_field ...\"\n end\n # verify the required parameter 'name' is set\n if @api_client.config.client_side_validation && name.nil?\n fail ArgumentError, \"Missing the required parameter 'name' when calling PdfApi.delete_field\"\n end\n # verify the required parameter 'field_name' is set\n if @api_client.config.client_side_validation && field_name.nil?\n fail ArgumentError, \"Missing the required parameter 'field_name' when calling PdfApi.delete_field\"\n end\n # resource path\n local_var_path = \"/pdf/{name}/fields/{fieldName}\".sub('{' + 'name' + '}', name.to_s).sub('{' + 'fieldName' + '}', field_name.to_s)\n\n # query parameters\n query_params = {}\n query_params[:'storage'] = opts[:'storage'] if !opts[:'storage'].nil?\n query_params[:'folder'] = opts[:'folder'] if !opts[:'folder'].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 # Fix header in file\n post_body = nil\n\n # http body (model)\n # Fix header in file\n # post_body = nil\n auth_names = ['JWT']\n data, status_code, headers = @api_client.call_api(:DELETE, 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 => 'AsposeResponse')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: PdfApi#delete_field\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def destroy\n persister.delete(resource: delete_change_set)\n respond_to do |format|\n format.html { redirect_to data_dictionary_fields_url, notice: 'Metadata field was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @reflection.destroy\n head :no_content\n end", "def api_delete(path, data = {})\n api_request(:delete, path, :data => data)\n end", "def delete_property field\n orientdb.delete_property self, field\n end", "def destroy\n @api_v1_text_field.destroy\n respond_to do |format|\n format.html { redirect_to api_v1_text_fields_url, notice: 'Text field was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete_schema request_pb, options = nil\n raise ::ArgumentError, \"request must be provided\" if request_pb.nil?\n\n verb, uri, query_string_params, body = ServiceStub.transcode_delete_schema_request request_pb\n query_string_params = if query_string_params.any?\n query_string_params.to_h { |p| p.split \"=\", 2 }\n else\n {}\n end\n\n response = @client_stub.make_http_request(\n verb,\n uri: uri,\n body: body || \"\",\n params: query_string_params,\n options: options\n )\n operation = ::Gapic::Rest::TransportOperation.new response\n result = ::Google::Longrunning::Operation.decode_json response.body, ignore_unknown_fields: true\n\n yield result, operation if block_given?\n result\n end", "def delete\n request(:delete)\n end", "def delete(payload = {})\n request! do\n options = {payload: to_payload(payload)}\n api(options)[url.path].delete(API_HEADERS)\n end\n end", "def delete! key = nil\n if key.nil?\n @schema.delete!\n @values.clear\n else\n key = ::Kernel.String(key).to_sym\n @schema.delete! key\n @values.delete key\n end\n self\n end", "def delete_field(var_name)\n @fields.delete(var_name)\n end", "def test_delete_form_field_without_node_path\n remote_file_name = 'TestDeleteFormFieldWithoutNodePath.docx'\n\n upload_file File.join(local_test_folder, field_folder + '/FormFilled.docx'), remote_data_folder + '/' + remote_file_name\n\n request = DeleteFormFieldRequest.new(name: remote_file_name, index: 0, folder: remote_data_folder, dest_file_name: remote_test_out + '/' + remote_file_name)\n\n @words_api.delete_form_field(request)\n end", "def delete_person_fields(**args)\n params = parameters(args) do\n required_params :ids\n optional_params :ids\n end\n request(:delete, 'personFields', params)\n end", "def test_del\n header 'Content-Type', 'application/json'\n\n data = File.read 'sample-traces/0.json'\n post('/traces', data, 'CONTENT_TYPE': 'application/json')\n\n id = last_response.body\n\n delete \"/traces/#{id}\"\n assert last_response.ok?\n\n get \"/traces/#{id}\"\n\n contents = JSON.parse last_response.body\n assert_kind_of(Hash, contents, 'Response contents is not a hash')\n assert contents.key? 'description'\n assert(!last_response.ok?)\n end", "def destroy\n \n @report_field = @report_setup.report_fields.find(params[:id])\n @report_setup.remove_field(@report_field)\n\n return HESResponder(@report_field)\n end" ]
[ "0.6994925", "0.67600447", "0.6716103", "0.6662268", "0.66504896", "0.6497389", "0.6497389", "0.6495189", "0.6476443", "0.6375809", "0.63211066", "0.63173664", "0.63096696", "0.63096696", "0.6283502", "0.6262463", "0.6253855", "0.62296414", "0.62217116", "0.62123173", "0.62030375", "0.61981666", "0.61954045", "0.61886114", "0.6186761", "0.6168044", "0.61612356", "0.6157296", "0.6156064", "0.6155348", "0.61525404", "0.6146717", "0.6145534", "0.6125973", "0.6101041", "0.60812706", "0.60784096", "0.60612434", "0.60196173", "0.60152465", "0.59997386", "0.596775", "0.59616345", "0.5961345", "0.59594464", "0.5949774", "0.5945281", "0.59418464", "0.5936361", "0.5936077", "0.5929816", "0.59254116", "0.5921351", "0.59199446", "0.5913819", "0.5908077", "0.5907938", "0.589624", "0.58864886", "0.58833927", "0.5879809", "0.58773583", "0.58530754", "0.5851744", "0.5849785", "0.5849457", "0.58439213", "0.58425564", "0.5840108", "0.58385974", "0.5830574", "0.58259815", "0.5823761", "0.58201873", "0.58201855", "0.581536", "0.58151674", "0.58150744", "0.58020467", "0.57993364", "0.5799033", "0.5797675", "0.5793338", "0.5782808", "0.577547", "0.576879", "0.57598525", "0.5758964", "0.5754196", "0.57447016", "0.57395667", "0.57349104", "0.5724756", "0.5724054", "0.57225007", "0.5721265", "0.57116807", "0.57112825", "0.5709631", "0.57059175" ]
0.74825364
0
Use callbacks to share common setup or constraints between actions.
def set_field_definition @field_definition = FieldDefinition.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 field_definition_params params.permit(:field_definition,:name, :field_type, :validationRegex, :required, :step_definition_id, :errorMessage, :order) 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
2Given an array, find the int that appears an odd number of times. There will always be only one integer that appears an odd number of times.
def find_it(seq) uniqueInts=seq.uniq uniqueInts.each do |value| k=0 seq.each do |mainSeq| k+=1 if mainSeq==value end return value if k%2==1 end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def odd_occurances_in_array(a)\n res = 0\n a.each { |el| res ^= el }\n res\nend", "def oddities(array)\n result = []\n count = 0\n array.each do |element|\n result << element if count.even?\n count += 1\n end\n result\nend", "def find_odd(arr)\n arr.find { |i| arr.count(i).odd? }\nend", "def oddities_1(array)\n array.select { |element| array.index(element) % 2 == 0 }\nend", "def oddities(arry)\n arry.select { |n| n if arry.index(n).even? }\nend", "def odd(array) \n result = {}\n array.each do |number| \n counted = array.count(number)\n result[number] = counted\n if (result[number] % 2 != 0)\n return number\n end\n end\nend", "def find_it(seq)\n seq.detect{|num| seq.count(num).odd?}\nend", "def find_it(seq)\n integer_occurences = seq.each_with_object(Hash.new(0)) do | int, hash |\n hash[int] += 1\n end\n integer_occurences.select {| int, occured | occured.odd? }.keys[0]\nend", "def find_it(seq)\n seq.find { |n| seq.count(n).odd? }\nend", "def oddities(arr)\n index = 0\n arr.select do |e|\n index += 1\n index.odd?\n end\nend", "def find_it(seq)\n seq.each do |e|\n a = seq.count(e)\n e if (a % 2).odd?\n end\nend", "def find_it(seq)\n seq.each { |nb| return nb if seq.count(nb).odd? }\nend", "def find_it(seq)\n hash = Hash.new(0)\n seq.each do |num|\n hash[num] += 1\n end\n\n hash.each do |num, no_of_occurence|\n return num if no_of_occurence.odd?\n end\nend", "def find_it(seq)\n seq.find {|e| seq.count(e).odd?}\nend", "def oddities(array)\n array.select.with_index { |e, i| (i + 1).odd? }\nend", "def oddities(arr)\n arr.select{ |a| arr.index(a).even? }\nend", "def oddities(array)\n array.select { |element| array.index(element).even? }\nend", "def solution(a)\r\n a.each do |num|\r\n if (a.count(num) % 2) != 0\r\n return num\r\n end\r\n end\r\nend", "def oddities(array)\r\n array.select.with_index { |_, i| i.even? }\r\n end", "def oddities(arr)\n\tarr.select.with_index { |num, index| num if index.even? }\nend", "def odd_integers(array)\nend", "def oddities(array)\n odd_elements = []\n array.each do |element|\n odd_elements << element if array.index(element).even?\n end\n odd_elements\nend", "def oddities(array)\n array.select {|element| array.index(element).even?}\nend", "def oddities(array)\n odd_array = []\n array.each_with_index { |e, idx| odd_array << e if idx.even? }\n odd_array\nend", "def find_even_index(array)\n array.length.times do |middle_idx|\n part1 = [0] \n part2 = [0]\n array.each_with_index do |num, idx|\n part1 << num if idx < middle_idx\n part2 << num if idx > middle_idx\n end\n return middle_idx if part1.reduce(:+) == part2.reduce(:+)\n end\n -1\nend", "def find_it(seq)\n #your code here\n seq = seq.sort\n ans = []\n seq.each do |num|\n if seq.count(num) % 2 != 0\n return num\n end\n\n end\nend", "def odd_index_nums(array)\n array.select do |num|\n current_index = array.index(num)\n \n if current_index % 2 == 1\n num\n end\n end\nend", "def find_dup(array_of_integers)\n array_of_integers.each do |integer|\n return integer if array_of_integers.count(integer) == 2\n end\nend", "def oddities(array)\n new_array = []\n array.each_with_index { |num, idx| new_array << num if idx.even? }\n new_array\nend", "def oddities(arr)\n arr.select.with_index do |_,index|\n (index + 1).odd?\n end\nend", "def oddities(array)\n odd_array = []\n array.each_with_index do |e, idx|\n odd_array << e if idx.even?\n end\n odd_array\nend", "def oddities(array)\n array.select {|item| array.index(item).even?}\nend", "def find_dup(arr)\n arr.select { |num| arr.count(num) == 2 }.uniq.join.to_i\nend", "def find_it(seq)\n counts = Hash.new 0\n\n seq.each do |num|\n counts[num] += 1\n end\n\n counts.each {|item|\n return item[0] if item[1].odd?\n }\nend", "def evenies(array)\n array.select.with_index { |e, idx| e if idx.odd? }\nend", "def oddball(arr)\n oddcount = evencount = 0\n arr.each do |num|\n if num % 2 == 0\n evencount +=1\n else\n oddcount +=1\n end\n if oddcount > 1 || evencount > 1\n break\n end\n end\n if oddcount > 1\n arr.each do |num| return num if num % 2 == 0 end\n elsif evencount > 1\n arr.each do |num| return num if num % 2 != 0 end\n end\nend", "def oddities(int_array)\n index = 0\n odds = []\n\n while index < int_array.size\n odds.push(int_array[index])\n index += 2\n end\n odds\nend", "def oddities(arr)\r\n arr2 = arr.select do |x|\r\n arr.index(x).even?\r\n end\r\n arr2\r\nend", "def odd_indexed_integers(array)\n\nend", "def oddities(array)\n odd_element_array = []\n index = 0\n loop do\n break if index >= array.size\n odd_element_array << array[index] if index.even?\n index += 1\n end\n odd_element_array\nend", "def oddities(array)\nresult = []\narray.each_with_index do |value, idx|\n result << value if (idx + 1).odd?\nend\nresult\nend", "def solution(a)\n # write your code in Ruby 2.2\n pairs = {}\n for num in a\n if !pairs[num].nil?\n pairs[num] += 1\n else\n pairs[num] = 1\n end\n end\n\n for num, count in pairs\n return num if count.odd?\n end\nend", "def oddities(array)\n array.select.with_index { |e, idx| e if idx.even? }\nend", "def odd_integers\n odds_array = []\n group_by_appeareance.map do |k,v|\n if v.length.odd?\n odds_array << k\n end\n end\n odds_array\n end", "def evenies(array)\n even_array = []\n array.each_with_index { |e, idx| even_array << e if idx.odd? }\n even_array\nend", "def oddNum arr\n puts (1..255).select {|i| i%2 != 0}\nend", "def oddities(array)\n result = []\n array.select do |element|\n result << element if array.index(element).even?\n end\n result\nend", "def oddball(arr)\n a, b, c = arr\n if a %2 == b %2\n expected = a %2\n arr.drop(2).each{|n| return n if n != a}\n elsif a%2 == c %2\n return b\n else\n return a\n end\nend", "def oddOne(arr)\n\tif arr.all? { |i| i.even? }\n\t\treturn -1\n\telsif arr.all? { |i| i.odd? }\n\t\treturn -1\n\telse\n\t\tx = arr.count { |i| i.even? }\n\t\ty = arr.count { |i| i.odd? }\n\t\todd_one_out = arr.find { |i| i.odd? } if x > 1\n\t\todd_one_out = arr.find { |i| i.even? } if y > 1\n\t\tarr.index(odd_one_out)\n\tend\nend", "def oddities(array)\n result = []\n index = 0\n\n loop do\n result << array[index]\n index += 2\n break if index >= array.size\n end\n\n result\nend", "def oddball(arr)\n\tnew_arr = arr.map { |n| n % 2}\n\tnew_arr.count(0) == 1 ? arr[new_arr.index(0)] : arr[new_arr.index(1)]\nend", "def oddities(array)\n count = 0\n new_array = []\n loop do\n break if array.size == 0\n new_array << array[count]\n count += 2\n break if count >= array.size\n end\n new_array\nend", "def oddNum arr\r\n puts (1..255).select {|i| i%2 != 0}\r\nend", "def oddities(array)\n array.partition {|element| array.index(element).even?}\nend", "def oddities(arr)\n counter = 0\n return_array = []\n loop do\n return_array << arr[counter]\n counter += 2\n break if counter >= arr.size\n end\n return_array.compact\nend", "def find_it(seq)\n set_num = 0\n seq.each do |num|\n if seq.count(num) % 2 != 0\n set_num = num\n end\n end\n\n set_num\nend", "def oddities(arr)\n arr.select.with_index do |_, idx|\n idx.even?\n end\nend", "def find_it(seq)\n seq.find { |num| num if seq.count(num) % 2 != 0 }\nend", "def find_even_index(arr)\n arr.length.times do |i|\n if arr[0...i].reduce(0, :+) == arr[i+1..-1].reduce(0, :+)\n return i\n end\n end\n -1\nend", "def oddities(array)\n new_array = []\n array.each_with_index { |val, idx| new_array << val if idx.even? }\n new_array\nend", "def solution(a)\n return a.group_by{|n| n}.each_value{|v| return v.first if v.count.odd?}\nend", "def find_it(seq)\r\n counts = seq.each_with_object({}) { |n, hash| hash[n] = seq.count(n) }\r\n counts.key(counts.values.find(&:odd?))\r\nend", "def oddities(array)\n new_array = []\n array.each_with_index do |num, index|\n new_array << num if index.odd?\n end\n new_array\nend", "def oddities(array)\n odd_values = []\n index = 0\n \n while index < array.size\n odd_values << array[index]\n index += 2\n end\n odd_values\nend", "def oddities(array)\n odd_elements = []\n index = 0\n while index < array.size\n odd_elements << array[index]\n index += 2\n end\n odd_elements\nend", "def oddities(array)\n odd_elements = []\n index = 0\n while index < array.size\n odd_elements << array[index]\n index += 2\n end\n odd_elements\nend", "def iq_test(numbers)\n numbers = numbers.split(\" \")\n even_array = []\n odd_array = []\n numbers.each do |num|\n \tif num.to_i.even?\n \t\teven_array.push(num)\n \telse\n \t\todd_array.push(num)\n \tend\n end \n if even_array.size > odd_array.size\n \tnumbers.index(odd_array[0]) + 1\n else\n \tnumbers.index(even_array[0]) + 1\n end \nend", "def find_dup(arr)\n arr.select { |i| arr.count(i) == 2 }.uniq.join.to_i\nend", "def oddities(array)\nselected_index = []\nindex = 0\n\n\tloop do \n\tcurrent_array = array[index]\n\t\tif index.even?\n\t\t\tselected_index << current_array\n\t\tend\n\tindex += 1\n\tbreak if index == array.size\n\tend\nselected_index\n\nend", "def oddities(array)\n new_array = []\n index_range = (1..array.size-1)\n for n in index_range do \n new_array << array[n] if n.odd?\n end\n new_array\nend", "def find_even(array)\n array.select { |number| number.even? } #http://www.ruby-doc.org/core-2.2.0/Array.html#method-i-select\nend", "def find_even(array)\nend", "def odd_numbers(array)\n end", "def oddities(arr)\n arr2 = []\n arr.each_with_index { |elem, ndx| arr2 << elem if ndx.even? }\n arr2\nend", "def available_spots(arr, num)\n count = 0\n arr.each_with_index do |item, index|\n next if index == arr.count - 1\n if item.odd? == arr[index + 1].odd? \n if item.odd? != num.odd?\n next\n else\n count += 1\n end\n else\n count += 1\n end\n end\n count\nend", "def solution(a)\n # write your code in Ruby 2.2\n\n # sort a\n a = a.sort\n odd = 0\n\n # loop over the array\n (0..(a.length-1)).step(2) do |i|\n if((i+1 >= a.length) || ((i+1 < a.length) && (a[i] != a[i+1])))\n odd = a[i]\n break\n end\n end\n\n odd\nend", "def non_oddities(arr)\n arr_length = arr.size\n index = 0\n even_elements = []\n\n loop do\n even_elements << arr[index] if index.odd?\n\n index += 1\n break if index > arr_length\n end\n even_elements.compact\nend", "def oddities(init_array)\n odd_bods = []\n init_array.each_with_index do |element, index|\n odd_bods << element if index.odd?\n end\n odd_bods\nend", "def find_it(seq)\n h = {}\n seq.each { |i| h[i] ? h[i] = h[i] + 1 : h[i] = 1 }\n h.select { |k, v| v.odd? }.keys.first\nend", "def odd_out(a)\n return nil if a.length == 0\n\n d = {}\n a.each do |el|\n d[el] ||= 0\n d[el] += 1\n end\n ind = d.values.index{ |el| el % 2 == 1 }\n return d.keys[ind]\nend", "def find_even_index(array)\n array.size.times do |i|\n left_array = array[0...i]\n right_array = array[(i+1)..-1]\n return i if left_array.sum == right_array.sum\n end\n -1\nend", "def iq_test(numbers)\n arr = numbers.split(' ').map{|e| e.to_i}\n evenCount = arr.select {|e| e.even?}.count\n oddCount = arr.select {|e| e.odd?}.count\n\n arr.each_with_index do |e,i|\n if evenCount > oddCount\n return i + 1 if e.odd?\n else\n return i + 1 if e.even?\n end\n end\nend", "def oddball(arr)\r\n # your code goes here\r\n evens = []\r\n odds = []\r\n\r\n arr.each do |int|\r\n\r\n if int % 2 == 0\r\n evens << int\r\n else\r\n odds << int\r\n end\r\n\r\n end\r\n if evens.length == 1\r\n return evens[0]\r\n else\r\n return odds[0]\r\n end\r\n\r\nend", "def evens(arr)\n even_places = []\n arr.each_with_index do |el, idx|\n even_places << el if idx.odd?\n end\n even_places\nend", "def oddOrEven(arr)\n even = false\n evenCnt = 0\n for i in 0..2 do\n if arr[i] % 2 == 0 then\n evenCnt += 1\n end\n end\n\n if evenCnt > 1 then\n even = true\n for x in arr do\n if x % 2 != 0 then\n return x\n end\n end\n else\n for x in arr do\n if x % 2 == 0 then\n return x\n end\n end\n end\n\nend", "def oddities(arr)\n new_arr = []\n arr.each_with_index { |v, idx| new_arr << v if idx.even? }\n new_arr\nend", "def oddball(arr)\n is_even = []\n is_odd = []\n i = 0\n while i < arr.length\n if arr[i] % 2 = 0\n is_even += arr[i]\n else\n is_odd += arr[i]\n end\n i += 1\n end\n if is_even.length == 1\n return is_even[0]\n else\n return is_odd[0]\n end\nend", "def find_it(seq)\n num_occur = {}\n \n seq.each do |num|\n num_occur.has_key?(num) ? num_occur[num] += 1 : num_occur[num] = 1\n end\n\n num_occur.each do |key, value|\n return key if value.odd?\n end\nend", "def oddities(array)\n new_array = []\n\n index = 0\n while index < array.size\n new_array << array[index] if index.even?\n index += 1\n end\n new_array\nend", "def odd_numb array\n new_arr= array.select! do |value|\n value.class == Integer\n end\n new_arr.select { |value| value % 2 != 0 }.sort\nend", "def oddities1(arr)\n (arr.map.with_index { |element,i| element if i.even? }).compact\nend", "def select_every_odd arr\n ans = []\n arr.each_with_index do |item, i|\n if i%2 == 1 \n ans.push item\n end\n end\n ans\nend", "def OddNumbers()\n\tputs (1..255).find_all {|i| i % 2 != 0 }\nend", "def find_even_index(arr)\n i = 0\n a = 0\n b = 1\n for i in 0...arr.length\n a = arr.slice(0, i).sum\n b = arr.slice(i + 1, arr.length - 1).sum\n if a != b && i == arr.length - 1\n return -1\n elsif a != b\n i += 1\n else\n return i\n end\n end\nend", "def oddities(array)\n new_array = []\n array.each_with_index do |element, index|\n new_array.push(element) if (index + 1).odd?\n end\n new_array\nend", "def odd_index_nums(array)\n odd_index_array = []\n \n array.each_with_index do |element, index|\n if index.odd?\n odd_index_array << element\n end\n end\n odd_index_array\nend", "def oddies(numerals, odd = true)\n odd ? numerals.select { |item| numerals.index(item).even? } : arr.select { |item| numerals.index(item).odd? } \nend", "def oddities(array)\n result = []\n index = 0\n\n while index < array.size\n result << array[index]\n index += 2\n end\n\n result\nend", "def find_it(seq)\n hash = {}\n seq.each do |element|\n hash[element] ? hash[element] += 1 : hash[element] = 1\n end\n hash.find do |key, value|\n return key if value.odd?\n end \nend", "def oddities(array)\n ret_array = []\n array.each_with_index do |value, index|\n if index.even?\n ret_array << value\n end\n end\n ret_array\nend", "def oddities(ary)\n new_array = []\n counter = 0\n loop do\n break if counter == ary.size\n new_array << ary[counter] if counter.even?\n counter += 1\n end\n new_array\nend" ]
[ "0.78197885", "0.7638051", "0.7525708", "0.74908644", "0.7486596", "0.7483844", "0.74471146", "0.737544", "0.7351387", "0.73412836", "0.73292327", "0.72991675", "0.7288738", "0.72786164", "0.72373706", "0.7227842", "0.7197603", "0.7197414", "0.7189893", "0.7150033", "0.7131184", "0.7129633", "0.71289647", "0.7123269", "0.7109388", "0.7103601", "0.70979434", "0.7083717", "0.7078647", "0.70677334", "0.7066614", "0.70593977", "0.7051501", "0.7050224", "0.7041354", "0.7035986", "0.7033423", "0.70239705", "0.70216405", "0.7021193", "0.7018525", "0.7007965", "0.69864625", "0.69831926", "0.69692695", "0.6936381", "0.6935701", "0.69242865", "0.69223726", "0.6918318", "0.69093007", "0.6908175", "0.69022495", "0.68973845", "0.6897034", "0.6896128", "0.6892591", "0.68833363", "0.6883307", "0.6879476", "0.6863393", "0.6860112", "0.68571115", "0.6853711", "0.68510085", "0.6850841", "0.6830573", "0.68302345", "0.68188214", "0.6815879", "0.6797904", "0.67977834", "0.67973876", "0.67796737", "0.6779126", "0.67782", "0.6776058", "0.6772951", "0.6761198", "0.67586255", "0.6746839", "0.6745501", "0.6725366", "0.6724961", "0.6721232", "0.67149234", "0.67142457", "0.6707149", "0.6706419", "0.6704297", "0.67000735", "0.669751", "0.66938347", "0.6693682", "0.6686453", "0.6680448", "0.6676551", "0.6674193", "0.6672812", "0.66725665", "0.6671329" ]
0.0
-1
Use callbacks to share common setup or constraints between actions.
def set_purchase @purchase = Purchase.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_handler\n end", "def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end", "def before_actions(*logic)\n self.before_actions = logic\n end", "def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end", "def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end", "def 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 action; end", "def action; end", "def action; end", "def action; end", "def action; end", "def workflow\n end", "def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end", "def before(action)\n invoke_callbacks *self.class.send(action).before\n end", "def before_dispatch(env); end", "def process_action(...)\n send_action(...)\n end", "def setup\n # override and do something appropriate\n end", "def after_actions(*logic)\n self.after_actions = logic\n end", "def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end", "def setup(_context)\n end", "def setup(resources) ; end", "def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end", "def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end", "def determine_valid_action\n\n end", "def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end", "def 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 setup( *args )\n\t\t\tself.class.setupBlocks.each {|sblock|\n\t\t\t\tdebugMsg \"Calling setup block method #{sblock}\"\n\t\t\t\tself.send( sblock )\n\t\t\t}\n\t\t\tsuper( *args )\n\t\tend", "def action\n end", "def setup\n @setup_proc.call(self) if @setup_proc\n end", "def config(action, *args); 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 before_action \n end", "def action\n end", "def setup\n # override this if needed\n end", "def matt_custom_action_begin(label); 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 setup_signals; 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 after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend", "def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend", "def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action.respond_to?('weak!') ? action.weak! : action\n end", "def after_set_callback; end", "def setup\n #implement in subclass;\n end", "def initialize(*args)\n super\n @action = :set\nend", "def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end", "def lookup_action; end", "def around_hooks; end", "def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end", "def release_actions; end", "def setup(easy)\n super\n easy.customrequest = @verb\n end", "def save_action; end", "def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end", "def action_target()\n \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 setup(&blk)\n @setup_block = blk\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 callback_phase\n super\n end", "def advice\n end", "def call\n setup_context\n super\n end", "def _handle_action_missing(*args); end", "def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end", "def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend", "def duas1(action)\n action.call\n action.call\nend" ]
[ "0.6162554", "0.60452986", "0.5945278", "0.59169763", "0.58877826", "0.5834763", "0.5775349", "0.5704972", "0.5704972", "0.56543803", "0.5621491", "0.5427202", "0.54093206", "0.54093206", "0.54093206", "0.53975695", "0.53776276", "0.53562194", "0.5340594", "0.5337824", "0.5328757", "0.5310255", "0.5300339", "0.5298796", "0.5295774", "0.5256034", "0.5243039", "0.5236007", "0.5235239", "0.5235239", "0.5235239", "0.5235239", "0.5235239", "0.52321917", "0.5227032", "0.52216744", "0.5216349", "0.52161187", "0.5210265", "0.5207244", "0.5177388", "0.5177142", "0.51747334", "0.516293", "0.51629275", "0.5155534", "0.51540613", "0.515197", "0.5151636", "0.5145279", "0.51380795", "0.5135777", "0.5117378", "0.5115066", "0.5115066", "0.5110235", "0.5106418", "0.50917816", "0.50909185", "0.50855017", "0.5082105", "0.506359", "0.5055345", "0.50546116", "0.50523037", "0.50523037", "0.50327307", "0.5024364", "0.5021113", "0.50174654", "0.50163317", "0.5000553", "0.50002855", "0.49991882", "0.49905527", "0.49905527", "0.49849054", "0.4982546", "0.4980941", "0.4979153", "0.49693102", "0.4967172", "0.49594432", "0.49564302", "0.49552485", "0.49533385", "0.49506924", "0.49452737", "0.49442786", "0.49347955", "0.49341312", "0.49295264", "0.49261844", "0.4925649", "0.49251428", "0.4920729", "0.49177617", "0.4916373", "0.49158472", "0.4915794", "0.49156648" ]
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def purchase_param params.require(:purchase).permit(:item_id, :quantity, :date) 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 /organizations GET /organizations.json
def index @organizations = Organization.order_by_most_recent @json = gmap4rails_with_popup_partial(@organizations,'popup') @category_options = Category.html_drop_down_options end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_organizations\n params = {\n 'method' => :get,\n 'command' => '/org'\n }\n\n response, headers = send_request(params)\n orgs = response.css('OrgList Org')\n\n results = {}\n orgs.each do |org|\n results[org['name']] = org['href'].gsub(\"#{@api_url}/org/\", \"\")\n end\n results\n end", "def get_organizations\n begin\n github_api_setup.organizations.list\n rescue Exception => e\n logger.error \"Github #get_organizations error #{e}\"\n end\n end", "def GetOrgs params = {}\n\n params = params.merge(path: 'organizations.json')\n APICall(params)\n\n end", "def find_all_organizations\n get_url(\"https://api.github.com/users/#{current_user.username}/orgs\")\n end", "def organization\n _get(\"/account/organization\") { |json| json }\n end", "def GetOrg id\n\n APICall(path: \"organizations/#{id}.json\")\n\n end", "def orgs\n client.organizations\n end", "def index\n @organizations = Organization.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @organizations }\n end\n end", "def index\n @organizations = Organization.where(:id => current_user.organization_id)\n \n respond_with(@organizations)\n end", "def show\n organization = current_user.organizations.find(params[:id])\n if organization\n render json: organization, status: 200\n else\n head 404\n end\n end", "def index\n @organizations = Organization.all\n respond_with(@organizations)\n end", "def index\n @organizations = Organization.all\n respond_with @organizations\n end", "def index\n @organizations = Organization.all\n end", "def index\n @organizations = Organization.all\n end", "def index\n @organizations = Organization.all\n end", "def index\n @organizations = Organization.all\n end", "def index\n @organizations = Organization.all\n end", "def index\n @organizations = Organization.all\n end", "def index\n @organizations = Organization.all\n end", "def index\n @organizations = Organization.all\n end", "def index\n @organizations = Organization.all\n end", "def index\n @organizations = Organization.all\n end", "def organizations\n\t@organizations = Organization.all\n\t@organization_names = []\n\t@organizations.each do |o|\n\t\t@organization_names << o.name\n\tend\n\t\n\trespond_to do |format|\n\t\tformat.html { render :json => @organization_names }\n\tend\n end", "def index\r\n @orgs = Org.all\r\n\r\n respond_to do |format|\r\n format.html # index.html.erb\r\n format.json { render json: @orgs }\r\n end\r\n end", "def query_organizations(options = nil)\n require_relative 'telerivet/organization'\n self.cursor(Organization, get_base_api_path() + \"/organizations\", options)\n end", "def list \n @organizations = Organization.all\n \n render \"list\"\n end", "def organization(name, params = {})\n http.get \"/organization/#{name}\", params\n end", "def organization(name, params = {})\n http.get \"/organization/#{name}\", params\n end", "def list_organizations\r\n Organization.organizations_by_user(self)\r\n end", "def find_organizations_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: OrganizationsApi#find_organizations ...\"\n end\n \n # resource path\n path = \"/organizations\".sub('{format}','json')\n\n # query parameters\n query_params = {}\n query_params[:'attribute'] = opts[:'attribute'] if opts[:'attribute']\n query_params[:'value'] = opts[:'value'] if opts[:'value']\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n _header_accept = ['application/json']\n _header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result\n\n # HTTP header 'Content-Type'\n _header_content_type = []\n header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n \n\n auth_names = []\n data, status_code, headers = @api_client.call_api(:GET, path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'Array<OrganizationComposite>')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: OrganizationsApi#find_organizations\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def index\n render json: Organization.all\n end", "def account_organization\n get('account/organization')\n end", "def index\n @organizations = Organization.page(params[:page]).per_page(9).order(\"name DESC\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @organizations }\n end\n end", "def find_organizations\n Organization.all\n end", "def current_user_oganizations\n endpoint = '/api/user/orgs'\n @logger.debug(\"Getting current user organizations (GET #{endpoint})\") if @debug\n get(endpoint)\n end", "def index\n @orgs = Org.all\n end", "def index\n\t\t@organizations = Organization.all\n\n\t\trespond_to do |format|\n\t\t\tformat.html # index.html.erb\n\t\t\tformat.xml { render :xml => @organizations }\n\t\tend\n\tend", "def organizations\r\n OrganizationsController.instance\r\n end", "def index\n @organizations = Spree::Organization.all\n end", "def get_organisations_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: BlueOceanApi.get_organisations ...'\n end\n # resource path\n local_var_path = '/blue/rest/organizations/'\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\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['jenkins_auth']\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 => 'Organisations')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: BlueOceanApi#get_organisations\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def index\n @user_organizations = UserOrganization.all\n end", "def index\n redirect_to :root unless current_user.is_admin?\n @organizations = Organization.all\n end", "def orgs\n @orgs = Organization.find(:all, :order => 'name ASC')\n\n respond_to do |format|\n format.html # orgs.html.erb\n format.xml { render :xml => @orgs }\n end\n end", "def index\n @organizations = Organization.by_query(params[:q])\n end", "def get_organization_info\n path = \"/d2l/api/lp/#{$lp_ver}/organization/info\"\n _get(path)\n # return: Organization JSON block\nend", "def orgs(params = {})\n params.merge!(key: 'orgs')\n objects_from_response(Code42::Org, :get, 'org', params)\n end", "def organizations\n if Interface.first.nil?\n redirect_to root_url and return\n end\n\n respond_to do |format|\n format.html {\n render partial: 'organization'\n }\n end\n end", "def own_organizations\n api.org_memberships.select { |org| org[:role] == \"admin\"}\n end", "def show\n @organization = Organization.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @organization }\n end\n end", "def show\n @organization = Organization.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @organization }\n end\n end", "def show\n cf_get(path: \"/organizations/#{org_id}\")\n end", "def index\n if current_user.super_admin?\n @organisations = Organisation.all.order(:id)\n render json: @organisations.to_json\n else\n head :no_content\n end\n end", "def index\n @organization_accounts = OrganizationAccount.all.sort_by(&:organization_name).reverse\n \n if user_signed_in? && current_user.admin?\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @organization_accounts }\n end\n else\n redirect_to root_path\n end\n end", "def orgs\n @orgs ||= begin\n client.organizations.map(&:login)\n rescue Octokit::Unauthorized, Faraday::ConnectionFailed\n []\n end\n end", "def index\n @clients_organizations = ClientsOrganization.all\n end", "def list\n @connection.get('/user/orgs').map do |org_data|\n GitHubApi::Org.new(self, org_data)\n end\n end", "def index\n @admins_organizations = Organization.all\n end", "def get(*args)\n arguments(args, required: [:org_name])\n\n get_request(\"/orgs/#{arguments.org_name}\", arguments.params)\n end", "def org_dashboard\n respond_to do |format|\n format.html { @organization = Organization.first }\n format.json { render json: Organization.first }\n end\n end", "def get_organizations\n org_references =\n locations.each_with_object({}) do |loc, acc|\n reference = loc.resource.managingOrganization.reference\n org_id = reference.match(ID_MATCHER)[1]\n\n acc[org_id] ||= []\n acc[org_id] << loc\n end\n\n facility_identifiers = org_references&.keys&.join(',')\n org_response = organization_service.search(_id: facility_identifiers, _count: '100')\n\n org_response&.resource&.entry\n end", "def index\n @organization = Organization.find_by_id(params[:organization_id])\n if @organization\n @users = @organization.users\n else\n @status = :fail\n @data = {organization: \"Organization #{params[:organization_id]} not found.\"}\n render status: :not_found, json: json_response(:fail, data: @data)\n end\n end", "def index\n @organizations = Organization.find(:all, :order => 'name ASC')\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @organizations }\n end\n end", "def index\n organizations = if params[:q]\n CclaSignature.search(params[:q])\n else\n Organization.includes(:ccla_signatures)\n end\n\n respond_to do |format|\n format.json do\n render json: organizations.to_json(only: [:id], methods: [:company])\n end\n end\n end", "def get_user_organizations(user_id)\n raise Auth0::MissingUserId, 'Must supply a valid user_id' if user_id.to_s.empty?\n\n get \"#{users_path}/#{user_id}/organizations\"\n end", "def organization_teams\n get(\"/organizations/#{@default_org_slug}/teams/\")\n end", "def get(incoming={})\n opts = HttpClient::Helper.symbolize_keys(incoming)\n query = {\n :guid => HttpClient::Preconditions.assert_class_or_nil('guid', HttpClient::Helper.to_uuid(opts.delete(:guid)), String),\n :user_guid => HttpClient::Preconditions.assert_class_or_nil('user_guid', HttpClient::Helper.to_uuid(opts.delete(:user_guid)), String),\n :key => HttpClient::Preconditions.assert_class_or_nil('key', opts.delete(:key), String),\n :name => HttpClient::Preconditions.assert_class_or_nil('name', opts.delete(:name), String),\n :limit => HttpClient::Preconditions.assert_class_or_nil('limit', opts.delete(:limit), Integer),\n :offset => HttpClient::Preconditions.assert_class_or_nil('offset', opts.delete(:offset), Integer)\n }.delete_if { |k, v| v.nil? }\n @client.request(\"/organizations\").with_query(query).get.map { |hash| Apidoc::Models::Organization.new(hash) }\n end", "def index\n @orgs ||= Github::Org.orgs(\n current_user_github_access_token,\n current_github_username\n )\n end", "def find_organizations(opts = {})\n data, status_code, headers = find_organizations_with_http_info(opts)\n return data\n end", "def get_user_github_organizations(github_orgs_url)\n uri = URI.parse(github_orgs_url)\n\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = uri.scheme == 'https'\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n response = http.request(Net::HTTP::Get.new(uri.request_uri))\n\n user_organizations = JSON.parse(response.body)\n user_organizations.map { |o| o['login'] }\n end", "def index\n authorize @organization\n render :json => @organization.tags\n end", "def orgs(enterprise = 'default')\n @api.orgs enterprise\n end", "def org_show_data\n org = Organization.find(params[:org])\n\n @data = {\n name: org.name,\n website: org.website,\n logo_link: org.logo_link,\n users: user_names_and_emails_from_org(org)\n }\n\n render json: @data\n end", "def index\n @people = current_organization.people.all\n end", "def list_org\n @users = User.where(organization: true)\n\n render \"list_org\"\n end", "def index\n @organizations = Organization.order(sort_column + \" \" + sort_direction).page(params[:page])\n\n respond_to do |format|\n format.html\n format.json { render json: @organizations }\n end\n end", "def show\n authorize @organization_membership\n render json: @organization_membership\n end", "def index\n # Get page number\n page = params[:page].nil? ? 1 : params[:page]\n\n if current_user.admin?\n @organizations = Organization.all.paginate(page: page, per_page: PAGE_COUNT)\n else\n if current_user.organization\n redirect_to current_user.organization\n else\n redirect_to new_organization_path\n end\n end\n end", "def get_orgs_list(grafana_options)\n grafana_options[:method] = 'Get'\n grafana_options[:success_msg] = 'The list of organizations has been successfully retrieved.'\n grafana_options[:unknown_code_msg] = 'OrganizationApi::get_orgs_list unchecked response code: %{code}'\n grafana_options[:endpoint] = '/api/orgs/'\n\n _do_request(grafana_options)\n rescue BackendError\n nil\n end", "def show\n @organization_profile = OrganizationProfile.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @organization_profile }\n end\n end", "def show\n @organization = Organization.find(params[:id])\n end", "def index\n @search = params[:search] || Hash.new\n @search[:name_contains] = params[:term] if params[:term]\n @search.each do |k,v|\n if !v.blank? && Organization::SEARCHABLE.include?( k.to_sym )\n @organizations = @organizations.send k, v\n end\n end\n @organizations = @organizations.page(params[:page])\n\n\n respond_to do |format|\n format.html { render action: 'index' } # index.html.erb\n format.json { render json: @organizations.map { |o| { id: o.id, label: o.name, value: o.name(:last_first) } } }\n format.xml { render :xml => @organizations }\n end\n end", "def show\n @organization = Organization.find(params[:id])\n respond_with @organization\n end", "def index\n @group_organizations = GroupOrganization.all\n end", "def retrieve_organization(name = nil)\n name ||= organization_name\n org = Organization.find_by(name: name)\n halt_with_json_response(404, INVALID_ORG, 'organization does not exist') \\\n if org.nil?\n return org\n end", "def get_by_key(key)\n HttpClient::Preconditions.assert_class('key', key, String)\n @client.request(\"/organizations/#{CGI.escape(key)}\").get { |hash| Apidoc::Models::Organization.new(hash) }\n end", "def all_organizations\n admin? ? Organization.all : organizations.map(&organization_mapper(false)).flatten\n end", "def org_members\n @members = @github.orgs.members.list APP_CONF['org']\n render json: @members\n end", "def index\n @organization_memberships = OrganizationMembership.where(user_id: params['user_id'])\n authorize @organization_memberships\n\n render json: @organization_memberships\n end", "def index\n render json: current_org.users\n end", "def active_organizations\n admin? ? Organization.all : organizations.map(&organization_mapper).flatten\n end", "def org\n client.org(org_id)\n end", "def org\n client.org(org_id)\n end", "def index\n if search_params \n logger.debug \"Got params: #{search_params}\"\n @organization = Organization.find(search_params)\n else\n logger.debug \"No params!\"\n end\n # @organizations = Organization.all\n end", "def org(id = \"my\", params = {})\n object_from_response(Code42::Org, :get, \"org/#{id}\", params)\n end", "def show\n case current_user.role.name\n when \"Viewer\", \"User\"\n head :no_content\n return\n when \"Manager\", \"Admin\", \"SuperAdmin\"\n else\n raise \"User with email = \\\"#{current_user.email}\\\" has an invalid role!\"\n end\n render json: @organisation.as_json(\n only: [:id, :name],\n include: {\n organisation_units: {\n only: [:id, :name],\n include: {\n users: {\n only: [:id, :name],\n include: {\n role: { only: [:name] }\n }\n }\n }\n },\n }\n )\n end", "def get_organization_by_id(id)\n require_relative 'telerivet/organization'\n Organization.new(self, self.do_request(\"GET\", get_base_api_path() + \"/organizations/#{id}\"))\n end", "def index\n @sourcing_orgs = SourcingOrg.all\n end", "def organizations \n puts \"List of organizations:\"\nend", "def get_information_all_companies()\n\t\tpage = 275\n\t\tbegin\n\t\t\turl = create_url(\"organizations\",\"\",page)\n\t\t\tputs \"Reading #{url}\"\n\t\t\tresult = read_url(url)\n\t\t\t#save_json(result, [\"organizations\"])\n\n\t\t\tadd_organization_info(result,\"name\")\n\t\t\tadd_organization_info(result,\"path\")\n\t\t\t\n\t\t\tnext_url = result['data']['paging']['next_page_url']\n\t\t\tpage = page + 1\n\t\tend while next_url != nil\n\t\tcreate_permalink(@paths)\n\t\tsave_json(\"\", [\"names\", \"paths\", \"permalinks\"])\n\tend", "def show\n @external_organization = ExternalOrganization.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @external_organization }\n end\n end", "def index\n @organization = current_user.organization\n @merits = @organization.merits\n end" ]
[ "0.80765116", "0.80071", "0.78597564", "0.78338337", "0.78312206", "0.7745588", "0.7691283", "0.7672265", "0.76290935", "0.7590858", "0.7536119", "0.7533662", "0.7521284", "0.75053763", "0.75053763", "0.75053763", "0.75053763", "0.75053763", "0.75053763", "0.75053763", "0.75053763", "0.75053763", "0.75003576", "0.7459552", "0.74238825", "0.7423191", "0.74064505", "0.74064505", "0.7357264", "0.7353553", "0.7341248", "0.73080254", "0.73058045", "0.72576714", "0.72547036", "0.7234301", "0.7142644", "0.71310985", "0.71163946", "0.7108704", "0.7107696", "0.70913565", "0.70783454", "0.707133", "0.7065519", "0.70442355", "0.7034759", "0.7028269", "0.70132995", "0.70132995", "0.7013245", "0.6974229", "0.69214576", "0.68938667", "0.6885557", "0.68472105", "0.68455255", "0.68368435", "0.6836245", "0.6833144", "0.68022317", "0.6798124", "0.6792869", "0.6792308", "0.6789671", "0.6787703", "0.6787543", "0.6781702", "0.67770505", "0.6767805", "0.6752179", "0.67115045", "0.6705219", "0.6704132", "0.66987795", "0.66933274", "0.6674487", "0.6657487", "0.66493815", "0.66468114", "0.6620185", "0.661743", "0.6609138", "0.65819615", "0.65304035", "0.6525404", "0.6518936", "0.6513303", "0.65101445", "0.6500153", "0.64931446", "0.64931446", "0.6490563", "0.64766717", "0.64659196", "0.6454719", "0.64336836", "0.6418678", "0.6411601", "0.6403693", "0.6392693" ]
0.0
-1
GET /organizations/1 GET /organizations/1.json
def show @organization = Organization.find(params[:id]) @editable = current_user.can_edit?(@organization) if current_user @grabbable = current_user ? current_user.can_request_org_admin?(@organization) : true # @next_path = current_user ? organization_user_path(@organization.id, current_user.id) : new_user_session_path @json = gmap4rails_with_popup_partial(@organization,'popup') end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def GetOrg id\n\n APICall(path: \"organizations/#{id}.json\")\n\n end", "def show\n organization = current_user.organizations.find(params[:id])\n if organization\n render json: organization, status: 200\n else\n head 404\n end\n end", "def index\n @organizations = Organization.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @organizations }\n end\n end", "def get_organizations\n begin\n github_api_setup.organizations.list\n rescue Exception => e\n logger.error \"Github #get_organizations error #{e}\"\n end\n end", "def organization(name, params = {})\n http.get \"/organization/#{name}\", params\n end", "def organization(name, params = {})\n http.get \"/organization/#{name}\", params\n end", "def get_organizations\n params = {\n 'method' => :get,\n 'command' => '/org'\n }\n\n response, headers = send_request(params)\n orgs = response.css('OrgList Org')\n\n results = {}\n orgs.each do |org|\n results[org['name']] = org['href'].gsub(\"#{@api_url}/org/\", \"\")\n end\n results\n end", "def organization\n _get(\"/account/organization\") { |json| json }\n end", "def index\n @organizations = Organization.where(:id => current_user.organization_id)\n \n respond_with(@organizations)\n end", "def index\r\n @orgs = Org.all\r\n\r\n respond_to do |format|\r\n format.html # index.html.erb\r\n format.json { render json: @orgs }\r\n end\r\n end", "def GetOrgs params = {}\n\n params = params.merge(path: 'organizations.json')\n APICall(params)\n\n end", "def index\n @organizations = Organization.all\n respond_with(@organizations)\n end", "def index\n @organizations = Organization.all\n end", "def index\n @organizations = Organization.all\n end", "def index\n @organizations = Organization.all\n end", "def index\n @organizations = Organization.all\n end", "def index\n @organizations = Organization.all\n end", "def index\n @organizations = Organization.all\n end", "def index\n @organizations = Organization.all\n end", "def index\n @organizations = Organization.all\n end", "def index\n @organizations = Organization.all\n end", "def index\n @organizations = Organization.all\n respond_with @organizations\n end", "def find_all_organizations\n get_url(\"https://api.github.com/users/#{current_user.username}/orgs\")\n end", "def index\n @organizations = Organization.all\n end", "def show\n @organization = Organization.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @organization }\n end\n end", "def show\n @organization = Organization.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @organization }\n end\n end", "def index\n render json: Organization.all\n end", "def index\n @organizations = Organization.page(params[:page]).per_page(9).order(\"name DESC\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @organizations }\n end\n end", "def get_organization_info\n path = \"/d2l/api/lp/#{$lp_ver}/organization/info\"\n _get(path)\n # return: Organization JSON block\nend", "def list \n @organizations = Organization.all\n \n render \"list\"\n end", "def find_organizations_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: OrganizationsApi#find_organizations ...\"\n end\n \n # resource path\n path = \"/organizations\".sub('{format}','json')\n\n # query parameters\n query_params = {}\n query_params[:'attribute'] = opts[:'attribute'] if opts[:'attribute']\n query_params[:'value'] = opts[:'value'] if opts[:'value']\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n _header_accept = ['application/json']\n _header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result\n\n # HTTP header 'Content-Type'\n _header_content_type = []\n header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n \n\n auth_names = []\n data, status_code, headers = @api_client.call_api(:GET, path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'Array<OrganizationComposite>')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: OrganizationsApi#find_organizations\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def show\n cf_get(path: \"/organizations/#{org_id}\")\n end", "def orgs\n client.organizations\n end", "def index\n @orgs = Org.all\n end", "def organizations\n\t@organizations = Organization.all\n\t@organization_names = []\n\t@organizations.each do |o|\n\t\t@organization_names << o.name\n\tend\n\t\n\trespond_to do |format|\n\t\tformat.html { render :json => @organization_names }\n\tend\n end", "def org_dashboard\n respond_to do |format|\n format.html { @organization = Organization.first }\n format.json { render json: Organization.first }\n end\n end", "def account_organization\n get('account/organization')\n end", "def show\n @organization = Organization.find(params[:id])\n end", "def organizations\r\n OrganizationsController.instance\r\n end", "def index\n\t\t@organizations = Organization.all\n\n\t\trespond_to do |format|\n\t\t\tformat.html # index.html.erb\n\t\t\tformat.xml { render :xml => @organizations }\n\t\tend\n\tend", "def index\n @organizations = Organization.by_query(params[:q])\n end", "def query_organizations(options = nil)\n require_relative 'telerivet/organization'\n self.cursor(Organization, get_base_api_path() + \"/organizations\", options)\n end", "def show\n @organization_profile = OrganizationProfile.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @organization_profile }\n end\n end", "def show\n @organization = Organization.find(params[:id])\n respond_with @organization\n end", "def retrieve_organization(name = nil)\n name ||= organization_name\n org = Organization.find_by(name: name)\n halt_with_json_response(404, INVALID_ORG, 'organization does not exist') \\\n if org.nil?\n return org\n end", "def index\n @organizations = Spree::Organization.all\n end", "def index\n redirect_to :root unless current_user.is_admin?\n @organizations = Organization.all\n end", "def find_organizations\n Organization.all\n end", "def index\n @user_organizations = UserOrganization.all\n end", "def index\n @organization = Organization.find_by_id(params[:organization_id])\n if @organization\n @users = @organization.users\n else\n @status = :fail\n @data = {organization: \"Organization #{params[:organization_id]} not found.\"}\n render status: :not_found, json: json_response(:fail, data: @data)\n end\n end", "def index\n @organizations = Organization.find(:all, :order => 'name ASC')\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @organizations }\n end\n end", "def orgs\n @orgs = Organization.find(:all, :order => 'name ASC')\n\n respond_to do |format|\n format.html # orgs.html.erb\n format.xml { render :xml => @orgs }\n end\n end", "def organizations\n if Interface.first.nil?\n redirect_to root_url and return\n end\n\n respond_to do |format|\n format.html {\n render partial: 'organization'\n }\n end\n end", "def get(*args)\n arguments(args, required: [:org_name])\n\n get_request(\"/orgs/#{arguments.org_name}\", arguments.params)\n end", "def org(id = \"my\", params = {})\n object_from_response(Code42::Org, :get, \"org/#{id}\", params)\n end", "def get(incoming={})\n opts = HttpClient::Helper.symbolize_keys(incoming)\n query = {\n :guid => HttpClient::Preconditions.assert_class_or_nil('guid', HttpClient::Helper.to_uuid(opts.delete(:guid)), String),\n :user_guid => HttpClient::Preconditions.assert_class_or_nil('user_guid', HttpClient::Helper.to_uuid(opts.delete(:user_guid)), String),\n :key => HttpClient::Preconditions.assert_class_or_nil('key', opts.delete(:key), String),\n :name => HttpClient::Preconditions.assert_class_or_nil('name', opts.delete(:name), String),\n :limit => HttpClient::Preconditions.assert_class_or_nil('limit', opts.delete(:limit), Integer),\n :offset => HttpClient::Preconditions.assert_class_or_nil('offset', opts.delete(:offset), Integer)\n }.delete_if { |k, v| v.nil? }\n @client.request(\"/organizations\").with_query(query).get.map { |hash| Apidoc::Models::Organization.new(hash) }\n end", "def current_user_oganizations\n endpoint = '/api/user/orgs'\n @logger.debug(\"Getting current user organizations (GET #{endpoint})\") if @debug\n get(endpoint)\n end", "def index\n if current_user.super_admin?\n @organisations = Organisation.all.order(:id)\n render json: @organisations.to_json\n else\n head :no_content\n end\n end", "def get_organization_by_id(id)\n require_relative 'telerivet/organization'\n Organization.new(self, self.do_request(\"GET\", get_base_api_path() + \"/organizations/#{id}\"))\n end", "def show\n @external_organization = ExternalOrganization.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @external_organization }\n end\n end", "def list_organizations\r\n Organization.organizations_by_user(self)\r\n end", "def get_by_key(key)\n HttpClient::Preconditions.assert_class('key', key, String)\n @client.request(\"/organizations/#{CGI.escape(key)}\").get { |hash| Apidoc::Models::Organization.new(hash) }\n end", "def get_organisations_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: BlueOceanApi.get_organisations ...'\n end\n # resource path\n local_var_path = '/blue/rest/organizations/'\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\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['jenkins_auth']\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 => 'Organisations')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: BlueOceanApi#get_organisations\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def index\n @clients_organizations = ClientsOrganization.all\n end", "def show\n @environment = current_user.organization.environments.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @environment }\n end\n end", "def index\n @organization_accounts = OrganizationAccount.all.sort_by(&:organization_name).reverse\n \n if user_signed_in? && current_user.admin?\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @organization_accounts }\n end\n else\n redirect_to root_path\n end\n end", "def show\n authorize @organization_membership\n render json: @organization_membership\n end", "def index\n @admins_organizations = Organization.all\n end", "def own_organizations\n api.org_memberships.select { |org| org[:role] == \"admin\"}\n end", "def index\n organizations = if params[:q]\n CclaSignature.search(params[:q])\n else\n Organization.includes(:ccla_signatures)\n end\n\n respond_to do |format|\n format.json do\n render json: organizations.to_json(only: [:id], methods: [:company])\n end\n end\n end", "def org_show_data\n org = Organization.find(params[:org])\n\n @data = {\n name: org.name,\n website: org.website,\n logo_link: org.logo_link,\n users: user_names_and_emails_from_org(org)\n }\n\n render json: @data\n end", "def index\n @organizations = Organization.order(sort_column + \" \" + sort_direction).page(params[:page])\n\n respond_to do |format|\n format.html\n format.json { render json: @organizations }\n end\n end", "def index\n @orgs ||= Github::Org.orgs(\n current_user_github_access_token,\n current_github_username\n )\n end", "def index\n @people = current_organization.people.all\n end", "def orgs(params = {})\n params.merge!(key: 'orgs')\n objects_from_response(Code42::Org, :get, 'org', params)\n end", "def organization organization_id, cached_token=token\n uri = URI.parse(\"https://anypoint.mulesoft.com/accounts/api/organizations/#{organization_id}\")\n client = Net::HTTP.new(uri.host, uri.port)\n client.use_ssl = true\n\n request = Net::HTTP::Get.new(uri.request_uri)\n request.add_field(\"Authorization\", \"Bearer #{cached_token}\")\n\n response = client.request(request)\n\n return JSON.parse(response.body)\n end", "def org\n client.org(org_id)\n end", "def org\n client.org(org_id)\n end", "def show\r\n @org = Org.from_param(params[:abbr])\r\n # @jobs = Job.find(Curation.where(:org_id => @org.id).pluck(:job_id))\r\n @jobs = @org.jobs\r\n respond_to do |format|\r\n format.html # show.html.erb\r\n format.json { render json: @org }\r\n end\r\n end", "def index\n # Get page number\n page = params[:page].nil? ? 1 : params[:page]\n\n if current_user.admin?\n @organizations = Organization.all.paginate(page: page, per_page: PAGE_COUNT)\n else\n if current_user.organization\n redirect_to current_user.organization\n else\n redirect_to new_organization_path\n end\n end\n end", "def get_user_github_organizations(github_orgs_url)\n uri = URI.parse(github_orgs_url)\n\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = uri.scheme == 'https'\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n response = http.request(Net::HTTP::Get.new(uri.request_uri))\n\n user_organizations = JSON.parse(response.body)\n user_organizations.map { |o| o['login'] }\n end", "def get_user_organizations(user_id)\n raise Auth0::MissingUserId, 'Must supply a valid user_id' if user_id.to_s.empty?\n\n get \"#{users_path}/#{user_id}/organizations\"\n end", "def get_organizations\n org_references =\n locations.each_with_object({}) do |loc, acc|\n reference = loc.resource.managingOrganization.reference\n org_id = reference.match(ID_MATCHER)[1]\n\n acc[org_id] ||= []\n acc[org_id] << loc\n end\n\n facility_identifiers = org_references&.keys&.join(',')\n org_response = organization_service.search(_id: facility_identifiers, _count: '100')\n\n org_response&.resource&.entry\n end", "def show\n @organ = Organ.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @organ }\n end\n end", "def index\n authorize @organization\n render :json => @organization.tags\n end", "def index\n render json: current_org.users\n end", "def show\n case current_user.role.name\n when \"Viewer\", \"User\"\n head :no_content\n return\n when \"Manager\", \"Admin\", \"SuperAdmin\"\n else\n raise \"User with email = \\\"#{current_user.email}\\\" has an invalid role!\"\n end\n render json: @organisation.as_json(\n only: [:id, :name],\n include: {\n organisation_units: {\n only: [:id, :name],\n include: {\n users: {\n only: [:id, :name],\n include: {\n role: { only: [:name] }\n }\n }\n }\n },\n }\n )\n end", "def index\n @group_organizations = GroupOrganization.all\n end", "def find_organization\n @organization = Organization.find(params[:organization_id])\n end", "def index\n @search = params[:search] || Hash.new\n @search[:name_contains] = params[:term] if params[:term]\n @search.each do |k,v|\n if !v.blank? && Organization::SEARCHABLE.include?( k.to_sym )\n @organizations = @organizations.send k, v\n end\n end\n @organizations = @organizations.page(params[:page])\n\n\n respond_to do |format|\n format.html { render action: 'index' } # index.html.erb\n format.json { render json: @organizations.map { |o| { id: o.id, label: o.name, value: o.name(:last_first) } } }\n format.xml { render :xml => @organizations }\n end\n end", "def show\n @organization = Organization.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @organization }\n end\n end", "def index\n @organization_memberships = OrganizationMembership.where(user_id: params['user_id'])\n authorize @organization_memberships\n\n render json: @organization_memberships\n end", "def index\n if search_params \n logger.debug \"Got params: #{search_params}\"\n @organization = Organization.find(search_params)\n else\n logger.debug \"No params!\"\n end\n # @organizations = Organization.all\n end", "def list_org\n @users = User.where(organization: true)\n\n render \"list_org\"\n end", "def show\n @organization = Organization.find(params[:id])\n @address = @organization.address\n @member = Member.new\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @organization }\n end\n end", "def new\n @organization = Organization.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @organization }\n end\n end", "def new\n @organization = Organization.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @organization }\n end\n end", "def organization_teams\n get(\"/organizations/#{@default_org_slug}/teams/\")\n end", "def org_members\n @members = @github.orgs.members.list APP_CONF['org']\n render json: @members\n end", "def list\n @connection.get('/user/orgs').map do |org_data|\n GitHubApi::Org.new(self, org_data)\n end\n end", "def show\n @organization = current_user.organization\n end" ]
[ "0.7965355", "0.7789723", "0.7624976", "0.76014984", "0.75791377", "0.75791377", "0.75518954", "0.7519814", "0.74602246", "0.74229765", "0.7412952", "0.7383728", "0.7383559", "0.7383559", "0.7383559", "0.7383559", "0.7383559", "0.7383559", "0.7383559", "0.7383559", "0.7383559", "0.73825437", "0.73576486", "0.73490685", "0.7316738", "0.7316738", "0.72754604", "0.72455674", "0.7211236", "0.7186702", "0.7161037", "0.7154822", "0.7125796", "0.7124134", "0.70706636", "0.70245826", "0.7014641", "0.7011128", "0.69999534", "0.69630075", "0.6957113", "0.69350725", "0.69199747", "0.68781155", "0.68747586", "0.68743825", "0.6853471", "0.6851181", "0.68506324", "0.68443793", "0.68412125", "0.6808725", "0.67993337", "0.67981666", "0.6772103", "0.67623574", "0.6758727", "0.67547286", "0.67540437", "0.6732849", "0.6729809", "0.67246115", "0.6689021", "0.66730356", "0.6672913", "0.6647419", "0.66281456", "0.66230065", "0.6617488", "0.6606483", "0.6603194", "0.65953904", "0.6561981", "0.65604", "0.6555643", "0.65367585", "0.65364915", "0.65364915", "0.65260214", "0.6500989", "0.64982224", "0.649001", "0.64874667", "0.6487327", "0.6475932", "0.6464521", "0.6452377", "0.64430994", "0.6432239", "0.64304185", "0.6414206", "0.63979995", "0.6393904", "0.6387008", "0.6369483", "0.6352581", "0.6352581", "0.6348649", "0.6348477", "0.6331517", "0.6318389" ]
0.0
-1
GET /organizations/new GET /organizations/new.json
def new @organization = Organization.new end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @organization = Organization.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @organization }\n end\n end", "def new\n @organization = Organization.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @organization }\n end\n end", "def new\r\n @org = Org.new\r\n\r\n respond_to do |format|\r\n format.html # new.html.erb\r\n format.json { render json: @org }\r\n end\r\n end", "def new\n @organization = Organization.new\n @organization.name = params[:name]\n @organization.url = params[:url]\n @organization.homepage_url = params[:homepage_url]\n @organization.address = params[:address]\n\n authorize! :new, @organization\n\n @title = new_action_title\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @organization }\n end\n end", "def new\n @organizations = Organization.find(:all)\n @organization_user = OrganizationUser.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @organization_user }\n end\n end", "def new\n @user = User.new(:organization_id => current_org.id)\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end", "def new\n @organ = Organ.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @organ }\n end\n end", "def new\n @organization = Organization.new\n respond_with(@organization)\n end", "def new\n @organization_profile = OrganizationProfile.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @organization_profile }\n end\n end", "def new\n @organism = Organism.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @organism }\n end\n end", "def new\n @organization_account = OrganizationAccount.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @organization_account }\n end\n end", "def new\n @organization = Organization.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @organization }\n end\n end", "def new\n @organization = Organization.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @organization }\n end\n end", "def new\n @organization = Organization.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @organization }\n end\n end", "def new\n @external_organization = ExternalOrganization.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @external_organization }\n end\n end", "def new\n\t@user = User.new\n\t@organizations = Organization.all\n end", "def create\r\n @org = Org.new(params[:org])\r\n\r\n respond_to do |format|\r\n if @org.save\r\n format.html { redirect_to @org, notice: 'Org was successfully created.' }\r\n format.json { render json: @org, status: :created, location: @org }\r\n else\r\n format.html { render action: \"new\" }\r\n format.json { render json: @org.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end", "def create\n @organization = Organization.new(params[:organization])\n\n respond_to do |format|\n if @organization.save\n format.html { redirect_to admin_organizations_path, notice: \"Organization #{@organization.name} was successfully created.\" }\n format.json { render json: @organization, status: :created, location: @organization }\n else\n format.html { render action: \"new\" }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @organisation = Organisation.new\n end", "def new\n @organisation = Organisation.new\n end", "def new\n @organization = Organization.new\n session[:breadcrumbs].add \"New\"\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @organization }\n end\n end", "def new\n\t\t@organization = Organization.new\n\n\t\trespond_to do |format|\n\t\t\tformat.html # new.html.erb\n\t\t\tformat.xml { render :xml => @organization }\n\t\tend\n\tend", "def create\n @organization = Organization.new(organization_params)\n\n if @organization.save\n render :show, status: :created, location: @organization\n else\n render json: @organization.errors, status: :unprocessable_entity\n end\n end", "def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @organization }\n end\n end", "def new\n @organization = Organization.new\n respond_with @organization\n end", "def new\n @location = @organization.locations.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @location }\n end\n end", "def new\n @organization = Organization.new\n @organization.user_id = session[:user_id]\n\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @organization }\n end\n end", "def create\n @organization = Organization.new(organization_params)\n\n respond_to do |format|\n if @organization.save\n format.html { redirect_to @organization, notice: 'Organization was successfully created.' }\n format.json { render :show, status: :created, location: @organization }\n else\n format.html { render :new }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @organization = Organization.new(organization_params)\n\n respond_to do |format|\n if @organization.save\n format.html { redirect_to @organization, notice: 'Organization was successfully created.' }\n format.json { render :show, status: :created, location: @organization }\n else\n format.html { render :new }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @organization = Organization.new(organization_params)\n\n respond_to do |format|\n if @organization.save\n format.html { redirect_to @organization, notice: 'Organization was successfully created.' }\n format.json { render :show, status: :created, location: @organization }\n else\n format.html { render :new }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @organization = Organization.new(organization_params)\n\n respond_to do |format|\n if @organization.save\n format.html { redirect_to @organization, notice: 'Organization was successfully created.' }\n format.json { render :show, status: :created, location: @organization }\n else\n format.html { render :new }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @organization = Organization.new(organization_params)\n respond_to do |format|\n if @organization.save\n format.html { redirect_to organization_path(@organization), notice: 'Organization was successfully created.' }\n format.json { render :show, status: :created, location: @organization }\n else\n format.html { render :new }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @org = authed_user.orgs.build(org_params)\n\n respond_to do |format|\n if @org.save\n format.html { redirect_to @org, notice: 'Org was successfully created.' }\n format.json { render :show, status: :created, location: @org }\n else\n format.html { render :new }\n format.json { render json: @org.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @owner = Owner.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @owner }\n end\n end", "def new\n @serviceorg = Serviceorg.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @serviceorg }\n end\n end", "def create\n authorize! :create, Organization\n @organization = Organization.new(organization_params)\n respond_to do |format|\n if @organization.save\n format.js\n format.json { render :show, status: :created, location: @organization }\n else\n format.js { render :new }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @person = Person.new\n @companies = Company.pluck(:name)\n\n authorize! :create, Person\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @person }\n end\n end", "def new\n @participating_organization = ParticipatingOrganization.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @participating_organization }\n end\n end", "def new\n @orgao = Orgao.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @orgao }\n end\n end", "def create\n @organization = Organization.new(params[:organization])\n if @organization.save\n flash[:notice] = VALIDATION_MESSAGE[\"ORGANIZATION\"][\"CREATE\"]\n redirect_to admin_organization_path(@organization.id)\n else\n flash[:error] = @organization.errors.full_messages.join(\", \")\n render('new')\n end\n end", "def new\n @person = people_type.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @person }\n end\n end", "def new\n authorize! :create, Project\n \n @project = Project.new\n puts @project\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @project }\n end\n end", "def new\n @organism = Organism.new\n end", "def new\n @company = Company.new(:name => 'default')\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @company }\n end\n end", "def new\n @projects_person = ProjectsPerson.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @projects_person }\n end\n end", "def create\n @organization = Organization.new(organization_params)\n\n respond_to do |format|\n if @organization.save\n # create an associated Org_user\n @org_user = OrgUser.new\n @org_user.organization_id = @organization.id\n @org_user.user_id = current_user.id\n @org_user.save\n\n # On default create a membership to the OrgUser/Admin/person_that_created_the_org\n @membership = Membership.new\n @membership.individual_id = current_user.individual.id\n @membership.organization_id = @organization.id\n @membership.save\n\n format.html { redirect_to @organization, notice: 'Organization was successfully created.' }\n format.json { render action: 'show', status: :created, location: @organization }\n else\n format.html { render action: 'new' }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @people_organization = PeopleOrganization.new(people_organization_params)\n\n respond_to do |format|\n if @people_organization.save\n format.html { redirect_to @people_organization, notice: 'People organization was successfully created.' }\n format.json { render :show, status: :created, location: @people_organization }\n else\n format.html { render :new }\n format.json { render json: @people_organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @repository = Repository.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @repository }\n end\n end", "def new\n @repository = Repository.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @repository }\n end\n end", "def new\n @environment = @project.environments.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @environment }\n end\n end", "def new\n @organization_detail = OrganizationDetail.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @organization_detail }\n end\n end", "def new\n @project = Project.new :company_id => params[:company_id]\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @project }\n end\n end", "def create\n @organization = Organization.new(permitted_params)\n\n authorize! :create, @organization\n\n respond_to do |format|\n if @organization.save\n format.html { redirect_to @organization, notice: 'Organization was successfully created.' }\n format.json { render json: @organization, status: :created, location: @organization }\n else\n format.html {\n existing_organization = Organization.with_url(@organization.url)\n if existing_organization.nil?\n @title = new_action_title; render action: \"new\"\n else\n redirect_to existing_organization, :notice => \"Organization has already been submitted.\"\n end\n }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @panel_organization_invitation = Panel::OrganizationInvitation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @panel_organization_invitation }\n end\n end", "def new\n @organ = Organ.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @organ }\n end\n end", "def new\n @breadcrumb = 'create'\n @entity = Entity.new\n @towns = towns_dropdown\n @provinces = provinces_dropdown\n @zipcodes = zipcodes_dropdown\n @regions = Region.order(:name)\n @countries = Country.order(:name)\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @entity }\n end\n end", "def create\n @orgn = Orgn.new(orgn_params)\n\n respond_to do |format|\n if @orgn.save\n format.html { redirect_to @orgn, notice: 'Orgn was successfully created.' }\n format.json { render :show, status: :created, location: @orgn }\n else\n format.html { render :new }\n format.json { render json: @orgn.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @person = Person.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @person }\n end\n end", "def new\n @territory = Territory.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @territory }\n end\n end", "def new\n @person = Person.new\n @person.org = Org.find(params[:org]) if params[:org]\n @person.needs_office_space = true\n @person.from_date = Date.today\n @person.to_date = nil\n authorize! :create, @person\n\n respond_to do |format|\n format.html # new.html.erb\n format.js\n format.json { render json: @person }\n end\n end", "def new\n @company = Company.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @company }\n end\n end", "def new\n @company = Company.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @company }\n end\n end", "def new\n @company = Company.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @company }\n end\n end", "def new\n @company = Company.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @company }\n end\n end", "def new\n @company = Company.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @company }\n end\n end", "def new\n @company = Company.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @company }\n end\n end", "def new\n @company = Company.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @company }\n end\n end", "def new\n @company = Company.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @company }\n end\n end", "def new\n @company = Company.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @company }\n end\n end", "def new\n @company = Company.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @company }\n end\n end", "def new\n @organization_status = OrganizationStatus.new(organization: @organization)\n respond_with @organization_status\n end", "def create\n @organization = current_user.build_organization(organization_params)\n respond_to do |format|\n if @organization.save\n format.html { redirect_to root_path, notice: 'Organization was successfully created.' }\n format.json { render :show, status: :created, location: @organization }\n else\n format.html { render :new }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @organisation = Organisation.new(organisation_params)\n\n respond_to do |format|\n if @organisation.save\n format.html { redirect_to @organisation, notice: 'Organisation was successfully created.' }\n format.json { render :show, status: :created, location: @organisation }\n else\n format.html { render :new }\n format.json { render json: @organisation.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @person = @organisation.people.build\n authorize! :create, @person\n respond_to do |format|\n format.html\n format.js\n end\n end", "def new\n @gitto = Gitto.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @gitto }\n end\n end", "def create\n @organization = Organization.new(organization_params)\n\n respond_to do |format|\n if @organization.save\n format.html { redirect_to @organization, notice: 'Place was successfully created.' }\n format.json { render :show, status: :created, location: @organization }\n else\n format.html { render :new }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @organization = Organization.new(params[:organization])\n\n respond_to do |format|\n if @organization.save\n flash[:notice] = 'Organization was successfully created.'\n format.html { redirect_to(@organization) }\n format.xml { render :xml => @organization, :status => :created, :location => @organization }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @organization.errors, :status => :unprocessable_entity }\n end\n end\n end", "def new\r\n @company = Company.new\r\n\r\n respond_to do |format|\r\n format.html # new.html.erb\r\n format.json { render json: @company }\r\n end\r\n end", "def new\n @client_org_orderable = ClientOrgOrderable.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @client_org_orderable }\n end\n end", "def new\n @entity = Entity.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @entity }\n end\n end", "def new\n @organization_member = OrganizationMember.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @organization_member }\n end\n end", "def new\n @project = current_user.projects.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @project }\n end\n end", "def new\n @organization_user = @organization.organization_users.new\n end", "def new\n @person = Person.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @person }\n end\n end", "def new\n @person = Person.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @person }\n end\n end", "def new\n @person = Person.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @person }\n end\n end", "def new\n @person = Person.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @person }\n end\n end", "def new\n @person = Person.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @person }\n end\n end", "def new\n @person = Person.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @person }\n end\n end", "def new\n @person = Person.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @person }\n end\n end", "def create\n @organization_membership = OrganizationMembership.new(organization_membership_create_params)\n # authorize @organization_membership\n\n if @organization_membership.save\n render json: @organization_membership, status: :created, location: nil\n else\n render json: @organization_membership.errors, status: :unprocessable_entity\n end\n end", "def new\n @distro = Distro.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @distro }\n end\n end", "def new\n @distro = Distro.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @distro }\n end\n end", "def new\n @environment = Environment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @environment }\n end\n end", "def create\n @organization_profile = OrganizationProfile.new(params[:organization_profile])\n\n respond_to do |format|\n if @organization_profile.save\n format.html { redirect_to @organization_profile, notice: 'Organization profile was successfully created.' }\n format.json { render json: @organization_profile, status: :created, location: @organization_profile }\n else\n format.html { render action: \"new\" }\n format.json { render json: @organization_profile.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @corp_location = CorpLocation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @corp_location }\n end\n end" ]
[ "0.80002916", "0.80002916", "0.79110706", "0.7769764", "0.74969125", "0.74499846", "0.7448206", "0.7431489", "0.7401061", "0.7384301", "0.73354286", "0.73137957", "0.7312422", "0.7312422", "0.7299635", "0.7295927", "0.72741574", "0.7259706", "0.7255205", "0.7255205", "0.72195643", "0.7211597", "0.7079275", "0.70639724", "0.70164716", "0.6991808", "0.6977392", "0.6920034", "0.6920034", "0.6920034", "0.6920034", "0.6911976", "0.68763185", "0.68471557", "0.68430716", "0.68269634", "0.6821844", "0.6800542", "0.67991483", "0.67890555", "0.67750335", "0.677212", "0.6766512", "0.6766152", "0.6766145", "0.6748429", "0.6748051", "0.6745811", "0.6745811", "0.67414737", "0.6739125", "0.6738126", "0.6734612", "0.6724808", "0.6715736", "0.6714379", "0.6706905", "0.6700001", "0.66959167", "0.6693069", "0.668828", "0.668828", "0.668828", "0.668828", "0.668828", "0.668828", "0.668828", "0.668828", "0.668828", "0.668828", "0.6685327", "0.66850114", "0.6684378", "0.6677995", "0.66554344", "0.6650883", "0.66308016", "0.66260415", "0.6612926", "0.6610075", "0.6605693", "0.66055274", "0.660184", "0.659424", "0.659424", "0.659424", "0.659424", "0.659424", "0.659424", "0.659424", "0.659124", "0.65894455", "0.65894455", "0.65692085", "0.6569121", "0.65686065" ]
0.7459801
9
POST /organizations POST /organizations.json
def create # model filters for logged in users, but we check here if that user is an admin # TODO refactor that to model responsibility? unless current_user.try(:admin?) flash[:notice] = PERMISSION_DENIED redirect_to organizations_path and return false end @organization = Organization.new(params[:organization]) if @organization.save redirect_to @organization, notice: 'Organization was successfully created.' else render action: "new" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def CreateOrganization params = {}\n \n APICall(path: 'organizations.json',method: 'POST',payload: params.to_json)\n \n end", "def create\n @organization = Organization.new(params[:organization])\n\n respond_to do |format|\n if @organization.save\n format.html { redirect_to admin_organizations_path, notice: \"Organization #{@organization.name} was successfully created.\" }\n format.json { render json: @organization, status: :created, location: @organization }\n else\n format.html { render action: \"new\" }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @organization = Organization.new(organization_params)\n\n if @organization.save\n render :show, status: :created, location: @organization\n else\n render json: @organization.errors, status: :unprocessable_entity\n end\n end", "def create\n @org = authed_user.orgs.build(org_params)\n\n respond_to do |format|\n if @org.save\n format.html { redirect_to @org, notice: 'Org was successfully created.' }\n format.json { render :show, status: :created, location: @org }\n else\n format.html { render :new }\n format.json { render json: @org.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @organization = Organization.new(organization_params)\n @organization.access_token = ('a'..'z').to_a.shuffle[0,32].join\n\n respond_to do |format|\n if @organization.save\n OrganizationMembership.create(user_id: current_user.id, organization_id: @organization.id, admin: true)\n params[:departments].each do |d_id|\n DepartmentEntry.create(context: @organization, department_id: d_id)\n end\n format.html { redirect_to :dashboard, notice: 'Organization was successfully created.' }\n format.json { render :show, status: :created, location: @organization }\n else\n format.html { render :new }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @organization = current_user.build_organization(organization_params)\n respond_to do |format|\n if @organization.save\n format.html { redirect_to root_path, notice: 'Organization was successfully created.' }\n format.json { render :show, status: :created, location: @organization }\n else\n format.html { render :new }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @organization = Organization.new(organization_params)\n respond_to do |format|\n if @organization.save\n format.html { redirect_to organization_path(@organization), notice: 'Organization was successfully created.' }\n format.json { render :show, status: :created, location: @organization }\n else\n format.html { render :new }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @organization = Organization.new(organization_params)\n\n respond_to do |format|\n if @organization.save\n format.html { redirect_to @organization, notice: 'Organization was successfully created.' }\n format.json { render :show, status: :created, location: @organization }\n else\n format.html { render :new }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @organization = Organization.new(organization_params)\n\n respond_to do |format|\n if @organization.save\n format.html { redirect_to @organization, notice: 'Organization was successfully created.' }\n format.json { render :show, status: :created, location: @organization }\n else\n format.html { render :new }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @organization = Organization.new(organization_params)\n\n respond_to do |format|\n if @organization.save\n format.html { redirect_to @organization, notice: 'Organization was successfully created.' }\n format.json { render :show, status: :created, location: @organization }\n else\n format.html { render :new }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @organization = Organization.new(organization_params)\n\n respond_to do |format|\n if @organization.save\n format.html { redirect_to @organization, notice: 'Organization was successfully created.' }\n format.json { render :show, status: :created, location: @organization }\n else\n format.html { render :new }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @admins_organization = Organization.new(admins_organization_params)\n\n respond_to do |format|\n if @admins_organization.save\n format.html { redirect_to @admins_organization, notice: 'Organization was successfully created.' }\n format.json { render :show, status: :created, location: @admins_organization }\n else\n format.html { render :new }\n format.json { render json: @admins_organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @organization = Organization.new(organization_params)\n\n respond_to do |format|\n if @organization.save\n # create an associated Org_user\n @org_user = OrgUser.new\n @org_user.organization_id = @organization.id\n @org_user.user_id = current_user.id\n @org_user.save\n\n # On default create a membership to the OrgUser/Admin/person_that_created_the_org\n @membership = Membership.new\n @membership.individual_id = current_user.individual.id\n @membership.organization_id = @organization.id\n @membership.save\n\n format.html { redirect_to @organization, notice: 'Organization was successfully created.' }\n format.json { render action: 'show', status: :created, location: @organization }\n else\n format.html { render action: 'new' }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @people_organization = PeopleOrganization.new(people_organization_params)\n\n respond_to do |format|\n if @people_organization.save\n format.html { redirect_to @people_organization, notice: 'People organization was successfully created.' }\n format.json { render :show, status: :created, location: @people_organization }\n else\n format.html { render :new }\n format.json { render json: @people_organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @organization.save\n respond_with(@organization)\n end", "def create\n @organization = Organization.new(organization_params)\n @organization.assignments << Assignment.new({user: current_user, organization: @organization, is_admin: true, is_active: true})\n\n respond_to do |format|\n if @organization.save\n format.html { redirect_to @organization, notice: 'Organization was successfully created.' }\n format.json { render :show, status: :created, location: @organization }\n else\n format.html { render :new }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @user_organization = UserOrganization.new(user_organization_params)\n\n respond_to do |format|\n if @user_organization.save\n format.html { redirect_to @user_organization, notice: 'User organization was successfully created.' }\n format.json { render :show, status: :created, location: @user_organization }\n else\n format.html { render :new }\n format.json { render json: @user_organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @organization = Organization.new(name: params[:name], owner: params[:username]) #owner: params[:username]\n if @organization.save\n #binding.pry\n @owner = @organization.employees.new(username: params[:username], \n password: params[:password], \n organization_id: @organization.id,\n email: params[:email],\n admin: true)\n if @owner.save\n render \"create.json.jbuilder\", status: :created\n else\n render json: { errors: @owner.errors.full_messages }, status: :unprocessable_entity\n end\n\n else\n render json: { errors: @organization.errors.full_messages }, status: :unprocessable_entity\n end\n end", "def create\n @organization = current_user.organizations.build(params[:organization])\n if @organization.save\n redirect_to @organization, :flash => { :success => \"Profile created!\" }\n else\n render 'pages/home'\n end\n end", "def create\r\n @org = Org.new(params[:org])\r\n\r\n respond_to do |format|\r\n if @org.save\r\n format.html { redirect_to @org, notice: 'Org was successfully created.' }\r\n format.json { render json: @org, status: :created, location: @org }\r\n else\r\n format.html { render action: \"new\" }\r\n format.json { render json: @org.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end", "def post(organization_form)\n HttpClient::Preconditions.assert_class('organization_form', organization_form, Apidoc::Models::OrganizationForm)\n @client.request(\"/organizations\").with_json(organization_form.to_json).post { |hash| Apidoc::Models::Organization.new(hash) }\n end", "def create\n @organization = Organization.new(organization_params)\n\n respond_to do |format|\n if @organization.save\n format.html { redirect_to @organization, notice: 'Place was successfully created.' }\n format.json { render :show, status: :created, location: @organization }\n else\n format.html { render :new }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @organization_membership = OrganizationMembership.new(organization_membership_create_params)\n # authorize @organization_membership\n\n if @organization_membership.save\n render json: @organization_membership, status: :created, location: nil\n else\n render json: @organization_membership.errors, status: :unprocessable_entity\n end\n end", "def create\n current_user.organization_users.build(organization_user_params)\n @organization = Organization.find(organization_user_params[:organization_id])\n respond_to do |format|\n if current_user.save\n format.html { redirect_to @organization, notice: 'Organization was successfully created.' }\n format.json { render json: @organization, status: :created, location: @organization }\n else\n format.html { redirect_to @organization, error: 'Organization creation failed.' }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @organization = Organization.new(organization_params)\n respond_to do |format|\n if @organization.save\n current_user.add_role :editor, @organization\n format.html { redirect_to organizations_path, notice: 'Thank you for your submission. It will be published once it is reviewed by the staff.' }\n format.json { render action: 'show', status: :created, location: @organization }\n else\n format.html { render action: 'new' }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @organization = Spree::Organization.new(organization_params)\n\n respond_to do |format|\n if @organization.save\n format.html { redirect_to @organization, notice: 'Spree::Organization was successfully created.' }\n format.json { render action: 'show', status: :created, location: @organization }\n else\n format.html { render action: 'new' }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n authorize! :create, Organization\n @organization = Organization.new(organization_params)\n respond_to do |format|\n if @organization.save\n format.js\n format.json { render :show, status: :created, location: @organization }\n else\n format.js { render :new }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @organisation = Organisation.new(organisation_params)\n\n respond_to do |format|\n if @organisation.save\n format.html { redirect_to @organisation, notice: 'Organisation was successfully created.' }\n format.json { render :show, status: :created, location: @organisation }\n else\n format.html { render :new }\n format.json { render json: @organisation.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n if params[\"organization\"][\"org_type\"] == \"Other\"\n params[\"organization\"][\"org_type\"] = params[\"org_type_text\"]\n end\n @organization = Organization.new(organization_params)\n\n if params[\"organization\"][\"org_type\"] == \"Shelter\" && params[:availability_status] == \"Available\"\n @organization.availability = true\n else\n @organization.availability = false\n end \n\n respond_to do |format|\n if @organization.save\n session[:organization_id] = @organization.id\n format.html { redirect_to @organization, notice: 'Organization was successfully created.' }\n format.json { render :show, status: :created, location: @organization }\n else\n format.html { redirect_to new_organization_path, flash: {errors: @organization.errors} }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @organization = Organization.new(organization_params)\n\n respond_to do |format|\n if @organization.save\n format.html { redirect_to new_project_path, notice: 'Organization was successfully created.' }\n format.json { render :show, status: :created, location: @organization }\n @organization.memberships.create(user_id: current_user.id)\n organization_info = {\n pretext: \"A new organization has been created.\",\n fallback: \"#{@organization.name}: #{@organization.description}\",\n title: \"#{@organization.name}\",\n title_link: \"#{organization_url(@organization)}\",\n text: \"#{@organization.description}\",\n color: \"#BDD6DD\",\n }\n PROJECT501_NOTIFIER.ping(attachments: [organization_info])\n else\n format.html { render :new }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @organization = Organization.new(organization_params)\n respond_to do |format|\n if @organization.save && @organization.associate_user(current_user, ['admin'])\n User.add_user_to_group(@organization, ['admin'], params[:admin1_email], params[:admin1_first_name], params[:admin1_last_name], params[:admin1_phone] ) if (params[:admin1_email].present?)\n User.add_user_to_group(@organization, ['admin'], params[:admin2_email], params[:admin2_first_name], params[:admin2_last_name], params[:admin2_phone] ) if (params[:admin2_email].present?)\n \n format.html { redirect_to organization_path(@organization), notice: 'Organization was successfully created.' }\n format.json { render action: 'show', status: :created, location: @organization }\n else\n format.html { render action: 'new' }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n authorize @organization\n if @organization.update_attributes(tag_list: @tags)\n render :json => @organization.reload.tags, :status => :created\n else\n error!(:invalid_resource, @organization.errors, \"Tags have not been saved\")\n end\n end", "def create\n @organ = Organ.new(params[:organ])\n\n respond_to do |format|\n if @organ.save\n format.html { redirect_to @organ, notice: 'Organ was successfully created.' }\n format.json { render json: @organ, status: :created, location: @organ }\n else\n format.html { render action: \"new\" }\n format.json { render json: @organ.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @address = Address.create!(params[:address])\n @organization = Organization.new(params[:organization])\n @organization.address = @address\n \n respond_to do |format|\n if @organization.save\n format.html { redirect_to @organization, notice: 'Organization was successfully created.' }\n format.json { render json: @organization, status: :created, location: @organization }\n else\n format.html { render action: \"new\" }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @organization = Organization.new(params[:organization])\n if @organization.save\n flash[:notice] = VALIDATION_MESSAGE[\"ORGANIZATION\"][\"CREATE\"]\n redirect_to admin_organization_path(@organization.id)\n else\n flash[:error] = @organization.errors.full_messages.join(\", \")\n render('new')\n end\n end", "def create\n\t\t@organization = Organization.new(params[:organization])\n\n\t\trespond_to do |format|\n\t\t\tif @organization.save\n\t\t\t\tformat.html { redirect_to(@organization, :notice => 'Organization was successfully created.') }\n\t\t\t\tformat.xml { render :xml => @organization, :status => :created, :location => @organization }\n\t\t\telse\n\t\t\t\tformat.html { render :action => \"new\" }\n\t\t\t\tformat.xml { render :xml => @organization.errors, :status => :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend", "def index\n @organizations = Organization.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @organizations }\n end\n end", "def create\n @organization = Organization.new(params[:organization])\n \n \n respond_to do |format|\n if @organization.save\n User.updateOrg(current_user.id,@organization.id)\n \n @album = Album.new\n @album.name = @organization.name\n @album.save\n @organization.album_id = @album.id\n Organization.updateAlbum(@organization.id,@album.id)\n \n current_user.has_role!('owner', @organization)\n flash[:notice] = 'Organization was successfully created.'\n format.html { redirect_to(@organization) }\n format.xml { render :xml => @organization, :status => :created, :location => @organization }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @organization.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @clients_organization = ClientsOrganization.new(clients_organization_params)\n\n respond_to do |format|\n if @clients_organization.save\n format.json { render :show, status: :created, location: @clients_organization }\n else\n format.json { render json: @clients_organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @group_organization = GroupOrganization.new(group_organization_params)\n\n respond_to do |format|\n if @group_organization.save\n format.html { redirect_to @group_organization, notice: 'Group organization was successfully created.' }\n format.json { render :show, status: :created, location: @group_organization }\n else\n format.html { render :new }\n format.json { render json: @group_organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @organizer = Organizer.new(organizer_params)\n\n respond_to do |format|\n if @organizer.save\n format.html { redirect_to @organizer, notice: 'Organizer was successfully created.' }\n format.json { render :show, status: :created, location: @organizer }\n else\n format.html { render :new }\n format.json { render json: @organizer.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @organization_profile = OrganizationProfile.new(params[:organization_profile])\n\n respond_to do |format|\n if @organization_profile.save\n format.html { redirect_to @organization_profile, notice: 'Organization profile was successfully created.' }\n format.json { render json: @organization_profile, status: :created, location: @organization_profile }\n else\n format.html { render action: \"new\" }\n format.json { render json: @organization_profile.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n params[:organization][:tag_ids] ||= []\n @organization = Organization.new(params[:organization])\n\n respond_to do |format|\n if @organization.save\n flash[:notice] = t(\"organization.success_created\")\n format.html { redirect_to(@organization) }\n else\n @tag = Tag.new\n format.html { render :action => \"new\" }\n end\n end\n end", "def create\n @organization = Organization.new(params[:organization])\n\n respond_to do |format|\n if @organization.save\n flash[:notice] = 'Organization was successfully created.'\n format.html { redirect_to(@organization) }\n format.xml { render :xml => @organization, :status => :created, :location => @organization }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @organization.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create(organization_name)\n organization = client.organization\n organization.name = organization_name\n organization.create!\n\n organization\n end", "def create_organisation_items\n create_organisation\n end", "def create\n @organization_profile = OrganizationProfile.new(organization_profile_params)\n current_user.organization_account.organization_profiles << @organization_profile \n authorize @organization_profile\n respond_to do |format|\n if @organization_profile.save\n format.html { redirect_to @organization_profile, notice: 'Organization profile was successfully created.' }\n format.json { render :show, status: :created, location: @organization_profile }\n else\n format.html { render :new }\n format.json { render json: @organization_profile.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @organizations = Organization.all\n end", "def index\n @organizations = Organization.all\n end", "def index\n @organizations = Organization.all\n end", "def index\n @organizations = Organization.all\n end", "def index\n @organizations = Organization.all\n end", "def index\n @organizations = Organization.all\n end", "def index\n @organizations = Organization.all\n end", "def index\n @organizations = Organization.all\n end", "def index\n @organizations = Organization.all\n end", "def org_params\n params.require(:organization).permit(:name, :variety, {:user_ids =>[]})\n end", "def create\n @organization = Organization.new(permitted_params)\n\n authorize! :create, @organization\n\n respond_to do |format|\n if @organization.save\n format.html { redirect_to @organization, notice: 'Organization was successfully created.' }\n format.json { render json: @organization, status: :created, location: @organization }\n else\n format.html {\n existing_organization = Organization.with_url(@organization.url)\n if existing_organization.nil?\n @title = new_action_title; render action: \"new\"\n else\n redirect_to existing_organization, :notice => \"Organization has already been submitted.\"\n end\n }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @external_organization = ExternalOrganization.new(params[:external_organization])\n\n respond_to do |format|\n if @external_organization.save\n format.html { redirect_to @external_organization, notice: 'External organization was successfully created.' }\n format.json { render json: @external_organization, status: :created, location: @external_organization }\n else\n format.html { render action: \"new\" }\n format.json { render json: @external_organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def organizations\r\n OrganizationsController.instance\r\n end", "def organizations\n\t@organizations = Organization.all\n\t@organization_names = []\n\t@organizations.each do |o|\n\t\t@organization_names << o.name\n\tend\n\t\n\trespond_to do |format|\n\t\tformat.html { render :json => @organization_names }\n\tend\n end", "def create\n @organism = Organism.new(organism_params)\n\n respond_to do |format|\n if @organism.save\n format.html { redirect_to @organism, notice: 'Organism was successfully created.' }\n format.json { render json: @organism, status: :created, location: @organism }\n else\n format.html { render action: \"new\" }\n format.json { render json: @organism.errors, status: :unprocessable_entity }\n end\n end\n end", "def organization_params\n params.require(:organization).permit(:name, :abbreviation, :term_id)\n end", "def create\n authorize Org\n\n # Let the OrgSelectable concern determine which org was selected\n org = process_org_params\n\n if org.present?\n if org.new_record?\n org.language = Language.default\n org.managed = org_params[:managed] == '1'\n org.logo = params[:logo] if params[:logo]\n org.links = if org_params[:org_links].present?\n ActiveSupport::JSON.decode(org_params[:org_links])\n else\n { org: [] }\n end\n end\n\n begin\n # TODO: The org_types here are working but would be better served as\n # strong params. Consider converting over to follow the pattern\n # for handling Roles in the ContributorsController. This will allow\n # the use of all org_types instead of just these 3 hard-coded ones\n org.funder = org_params[:funder] == 'true'\n org.institution = org_params[:institution] == 'true'\n org.organisation = org_params[:organisation] == 'true'\n\n if org.save\n msg = success_message(org, _('created'))\n redirect_to admin_edit_org_path(org.id), notice: msg\n else\n flash.now[:alert] = failure_message(org, _('create'))\n @org = org\n @org.links = { org: [] } if org.links.blank?\n render 'super_admin/orgs/new'\n end\n rescue Dragonfly::Job::Fetch::NotFound\n failure = _('There seems to be a problem with your logo. Please upload it again.')\n redirect_to admin_edit_org_path(org), alert: failure\n render 'orgs/admin_edit', locals: {\n org: org,\n languages: Language.all.order('name'),\n method: 'POST',\n url: super_admin_orgs_path\n }\n end\n else\n flash.now[:alert] = _('Unable to create the organisation. Name can\\'t be blank')\n render 'super_admin/orgs/new'\n end\n end", "def create\n @organization = Organization.new(org_params)\n if @organization.save\n redirect_to :root, notice: 'You have signed up successfully but your account has not been approved.'\n else\n render action: 'new'\n end\n end", "def organization_invite\n params['host'] = Ind.http_api\n params['api_key'] = Accounts.new.find_by_email(params['email']).api_key\n\n org_res = Organizations.new.list(params).orgs\n\n org_res[0][:related_orgs] << params['org_id']\n org_res[0][:api_key] = params['api_key']\n org_res[0][:email] = params['email']\n org_res[0][:host] = Ind.http_api\n\n res = Organizations.new.update(org_res[0])\n redirect_to root_url\n end", "def create\n @organism = Organism.new(params[:organism])\n\n respond_to do |format|\n if @organism.save\n format.html { redirect_to @organism, notice: 'Organism was successfully created.' }\n format.json { render json: @organism, status: :created, location: @organism }\n else\n format.html { render action: \"new\" }\n format.json { render json: @organism.errors, status: :unprocessable_entity }\n end\n end\n end", "def UpdateOrganization params = {}\n \n APICall(path: 'organizations.json',method: 'PUT',payload: params.to_json)\n \n end", "def new\n @organization = Organization.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @organization }\n end\n end", "def new\n @organization = Organization.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @organization }\n end\n end", "def index\n @organizations = Organization.all\n end", "def create_member\n # Member.create!..\n\n respond_to do |format|\n format.html { redirect_to organization_path(params[:orgaid])}\n format.json { head :no_content }\n end\n end", "def create_organizations_api\n InfluxDB2::API::OrganizationsApi.new(@api_client)\n end", "def create\n @organization_catagory = OrganizationCatagory.new(organization_catagory_params)\n\n respond_to do |format|\n if @organization_catagory.save\n format.html { redirect_to @organization_catagory, notice: 'Organization catagory was successfully created.' }\n format.json { render :show, status: :created, location: @organization_catagory }\n else\n format.html { render :new }\n format.json { render json: @organization_catagory.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @organization_status = OrganizationStatus.new(create_organization_status_params)\n @organization_status.participant = Current.user\n @organization_status.save\n respond_with @organization_status, location: -> { @organization_status.organization }\n end", "def create\n @person = Person.new(params[:person])\n current_organization.people << @person\n if @person.save\n redirect_to people_path, notice: @person.name.to_s + ' was successfully created.'\n else\n render action: \"new\"\n end\n end", "def create\n @ngo = current_user.ngos.build(ngo_params)\n \n respond_to do |format|\n if @ngo.save\n @ngo.reindex\n format.html { redirect_to @ngo, notice: 'The organization was successfully created.' }\n format.json { render :show, status: :created, location: @ngo }\n else\n format.html { render :new }\n format.json { render json: @ngo.errors, status: :unprocessable_entity }\n end\n end\n end", "def organization_params\n params.permit(:id, :organization_id, :name)\n end", "def organization\n _get(\"/account/organization\") { |json| json }\n end", "def create\n @o_rganization = ORganization.new(o_rganization_params)\n\n respond_to do |format|\n if @o_rganization.save\n format.html { redirect_to @o_rganization, notice: 'O rganization was successfully created.' }\n format.json { render :show, status: :created, location: @o_rganization }\n else\n format.html { render :new }\n format.json { render json: @o_rganization.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @sourcing_org = SourcingOrg.new(sourcing_org_params)\n\n respond_to do |format|\n if @sourcing_org.save\n format.html { redirect_to @sourcing_org, notice: 'Sourcing org was successfully created.' }\n format.json { render :show, status: :created, location: @sourcing_org }\n else\n format.html { render :new }\n format.json { render json: @sourcing_org.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @partnering_organization = PartneringOrganization.new(partnering_organization_params)\n\n respond_to do |format|\n if @partnering_organization.save\n format.html { redirect_to @partnering_organization, notice: 'Partnering organization was successfully created.' }\n format.json { render :show, status: :created, location: @partnering_organization }\n else\n format.html { render :new }\n format.json { render json: @partnering_organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @organization = Organization.new(organization_params)\n if @organization.save\n session[:organization_id] = @organization.id\n if params[:organization][:dialog] == \"true\"\n if !params[:organization][:alias].blank?\n render json: {id: @organization.id, name: @organization.name, alias: params[:organization][:alias]}\n else\n @workday = session[:workday_id]\n render partial: \"dialog_add_workday_organization_fields\"\n end\n else\n flash[:success] = \"Organization created\"\n if !params[:to_donations].blank?\n redirect_to donations_organization_path(@organization)\n else\n if params[:stay].blank?\n redirect_to search_organizations_path\n else\n redirect_to edit_organization_path(@organization)\n end\n end\n end\n else # Save not successful\n if params[:organization][:dialog] == \"true\"\n @alias = params[:alias].blank? ? \"\" : params[:alias]\n render partial: \"dialog_form\"\n else\n @num_workdays = []\n @allow_stay = true\n render :new\n end\n end\n end", "def create\n @partnering_organization = PartneringOrganization.new(partnering_organization_params)\n respond_to do |format|\n if @partnering_organization.save\n format.html { redirect_to @partnering_organization, notice: 'Partnering organization was successfully created.' }\n format.json { render :show, status: :created, location: @partnering_organization }\n else\n format.html { render :new }\n format.json { render json: @partnering_organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def organisation_params\n params[:organisation].permit(:name, :contact_information, org_user_ids: [])\n end", "def create_organisation(user)\n\n user.organisations.create\n\n logger.info \"Successfully created organisation ID: #{user.organisations.first.id}\"\n\n end", "def create\n @orging = Orging.new(orging_params)\n\n respond_to do |format|\n if @orging.save\n format.html { redirect_to @orging, notice: 'Orging was successfully created.' }\n format.json { render :show, status: :created, location: @orging }\n else\n format.html { render :new }\n format.json { render json: @orging.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @participating_organization = ParticipatingOrganization.new(params[:participating_organization])\n\n respond_to do |format|\n if @participating_organization.save\n format.html { redirect_to(participating_organizations_path, :notice => 'Participating Organization was successfully created.') }\n format.xml { render :xml => @participating_organization, :status => :created, :location => @participating_organization }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @participating_organization.errors, :status => :unprocessable_entity }\n end\n end\n end", "def index\n @organizations = Organization.all\n respond_with @organizations\n end", "def new\n @organization = Organization.new\n respond_with(@organization)\n end", "def index\n @organizations = Organization.all\n respond_with(@organizations)\n end", "def people_organization_params\n params.require(:people_organization).permit(:PersonalID, :OrganizationName)\n end", "def create\n respond_to do |format|\n if @organization.save\n @organization.registrations << @registration if @registration\n flash[:notice] = 'Organization was successfully created.'\n format.html { redirect_to(@organization) }\n format.xml { render :xml => @organization, :status => :created, :location => @organization }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @organization.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n contestorganization = Contestorganization.create(params.require(:contestorganization).permit(:contest_id, :user_id))\n redirect_to contest_path(contestorganization.contest)\n end", "def create\n @organization = Organization.new(organization_params)\n if organization_params[:manual_fee_entry] == \"0\" || organization_params[:manual_fee_entry].nil?\n @organization.amount_owe = @organization.tournament.price*@organization.clubs.size\n end\n respond_to do |format|\n if @organization.save\n EventMailer.tournament_registration(@organization).deliver\n format.html { redirect_to @organization, notice: 'Organization was successfully created.' }\n format.json { render action: 'show', status: :created, location: @organization }\n else\n @tournaments = Tournament.active_tournaments\n @organization.clubs.build if @organization.clubs.empty?\n format.html { render action: 'new' }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n\t@user = User.new\n\t@organizations = Organization.all\n end", "def orgs\n client.organizations\n end", "def create\n @organization = Organization.new(params[:organization])\n\n respond_to do |format|\n if @organization.save\n OrganizationQuarter.create :organization_id => @organization.id, :quarter_id => @quarter.id, :unit_id => @unit.id\n flash[:notice] = 'Organization was successfully created.'\n format.html { redirect_to(service_learning_organization_path(@unit, @quarter, @organization)) }\n format.xml { render :xml => @organization, :status => :created, :location => @organization }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @organization.errors, :status => :unprocessable_entity }\n end\n end\n end", "def index\n @organizations = Organization.where(:id => current_user.organization_id)\n \n respond_with(@organizations)\n end", "def index\n @organizations = Organization.page(params[:page]).per_page(9).order(\"name DESC\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @organizations }\n end\n end", "def organisation_params\n params.require(:organisation).permit(:name, :abbreviation, :people_count, :other, :order)\n end" ]
[ "0.7546241", "0.71868527", "0.703545", "0.70268863", "0.7016771", "0.6988308", "0.6930564", "0.69226116", "0.69226116", "0.69226116", "0.69226116", "0.6916983", "0.6892586", "0.68546283", "0.685141", "0.67094165", "0.670208", "0.6676121", "0.6673902", "0.6667356", "0.661678", "0.6606358", "0.65989137", "0.65920204", "0.6576153", "0.6521847", "0.6511296", "0.6482782", "0.640478", "0.63843775", "0.6384338", "0.63596475", "0.6326186", "0.63151497", "0.63103044", "0.6306872", "0.62964654", "0.6295117", "0.628761", "0.6258914", "0.62503666", "0.62382954", "0.6235161", "0.62307596", "0.6229324", "0.6229037", "0.6227364", "0.6224935", "0.6224935", "0.6224935", "0.6224935", "0.6224935", "0.6224935", "0.6224935", "0.6224935", "0.6224935", "0.62167937", "0.6210213", "0.62032807", "0.6191011", "0.61832935", "0.61745024", "0.6167605", "0.6155596", "0.61482435", "0.6146451", "0.6145141", "0.61335015", "0.61284405", "0.61284405", "0.61250895", "0.61244977", "0.6122394", "0.612111", "0.6113998", "0.60993814", "0.6095899", "0.6077696", "0.6071919", "0.6071832", "0.60713065", "0.6065354", "0.60527307", "0.60492986", "0.6044099", "0.6038256", "0.60272247", "0.6013011", "0.6011849", "0.60022265", "0.60020775", "0.6001953", "0.59976673", "0.59904414", "0.5988663", "0.59828705", "0.5968018", "0.5965894", "0.5964181", "0.5963653", "0.5950892" ]
0.0
-1
PUT /organizations/1 PUT /organizations/1.json
def update @organization = Organization.find(params[:id]) params[:organization][:admin_email_to_add] = params[:organization_admin_email_to_add] if params[:organization] return false unless user_can_edit? @organization if @organization.update_attributes_with_admin(params[:organization]) redirect_to @organization, notice: 'Organization was successfully updated.' else render action: "edit" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def UpdateOrganization params = {}\n \n APICall(path: 'organizations.json',method: 'PUT',payload: params.to_json)\n \n end", "def update\n @organization = Organization.find(params[:id])\n @organization.update_attributes(organization_params)\n \n respond_with(@organization, :location => admin_organizations_path)\n end", "def update\n @organization = Organization.find(params[:id])\n\n respond_to do |format|\n if @organization.update_attributes(params[:organization])\n format.html { redirect_to admin_organizations_path, notice: \"Organization #{@organization.name} was successfully updated.\" }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @organization = Organization.find(params[:id])\n @organization.update_attributes(params[:organization])\n respond_with @organization\n end", "def update\n @organization.update(organization_params)\n if @organization.save\n render json: { success: \"organization updated successfully\"}, status: :ok\n else\n render json: { errors: @orgnanization.errors.full_messages }, status: :unprocessable_entity\n end\n end", "def update\n @organization = Organization.find(params[:id])\n\n respond_to do |format|\n if @organization.update_attributes(params[:organization])\n format.html { redirect_to @organization, notice: 'Organization was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @organization.update(organization_params)\n render :show, status: :ok, location: @organization\n else\n render json: @organization.errors, status: :unprocessable_entity\n end\n end", "def update\n @organization.update(organization_params)\n respond_with(@organization)\n end", "def update\n @organization_person = OrganizationPerson.find(params[:id])\n\n if @organization_person.update(organization_person_params)\n render json: @organization_person\n else\n render json: @organization_person.errors, status: :unprocessable_entity\n end\n end", "def update(name: nil)\n data = name.nil? ? {} : {name: name}\n cf_patch(path: \"/organizations/#{org_id}\", data: data)\n end", "def update\n if @organization.update(organization_params)\n render :show, status: :ok, location: @organization\n else\n render json: @organization.errors, status: :unprocessable_entity\n end\n end", "def update\r\n @org = Org.from_param(params[:abbr])\r\n\r\n respond_to do |format|\r\n if @org.update_attributes(params[:org])\r\n format.html { redirect_to @org, notice: 'Org 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: @org.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end", "def update\n respond_to do |format|\n if @organization.update(organization_params)\n format.html { redirect_to @organization, notice: 'Organization was successfully updated.' }\n format.json { render :show, status: :ok, location: @organization }\n else\n format.html { render :edit }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @organization.update(organization_params)\n format.html { redirect_to @organization, notice: 'Organization was successfully updated.' }\n format.json { render :show, status: :ok, location: @organization }\n else\n format.html { render :edit }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @organization.update(organization_params)\n format.html { redirect_to @organization, notice: 'Organization was successfully updated.' }\n format.json { render :show, status: :ok, location: @organization }\n else\n format.html { render :edit }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @organization.update(organization_params)\n format.html { redirect_to @organization, notice: 'Organization was successfully updated.' }\n format.json { render :show, status: :ok, location: @organization }\n else\n format.html { render :edit }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @organization.update(organization_params)\n format.html { redirect_to @organization, notice: 'Organization was successfully updated.' }\n format.json { render :show, status: :ok, location: @organization }\n else\n format.html { render :edit }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @organization.update(organization_params)\n format.html { redirect_to @organization, notice: 'Organization was successfully updated.' }\n format.json { render :show, status: :ok, location: @organization }\n else\n format.html { render :edit }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @organization.update(organization_params)\n format.html { redirect_to @organization, notice: 'Organization was successfully updated.' }\n format.json { render :show, status: :ok, location: @organization }\n else\n format.html { render :edit }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @org.update(org_params)\n format.html do\n redirect_to @org, notice: 'Org was successfully updated.'\n end\n format.json { render :show, status: :ok, location: @org }\n else\n format.html { render :edit }\n format.json { render json: @org.errors, status: :unprocessable_entity }\n end\n end\n end", "def edit_organization(org, options={})\n patch \"/orgs/#{org}\", :body => options\n end", "def update\n respond_to do |format|\n if @organization.update(organization_params)\n format.html { redirect_to @organization, notice: 'Organization was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @organization.update(organization_params)\n format.html { redirect_to @organization, notice: 'Organization was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @organization = Organization.find(params[:id])\n\n if @organization.update_attributes(params[:organization])\n redirect_to admin_organizations_url, :notice => t('organization.messages.update.success')\n else\n render action: \"edit\"\n end\n end", "def update_organization( params )\n\n raise ArgumentError.new(format('wrong type. \\'params\\' must be an Hash, given \\'%s\\'', params.class.to_s)) unless( params.is_a?(Hash) )\n raise ArgumentError.new('missing \\'params\\'') if( params.size.zero? )\n\n organization = validate( params, required: true, var: 'organization', type: String )\n name = validate( params, required: true, var: 'name', type: String )\n org = organization( organization )\n\n return { 'status' => 404, 'message' => format('Organization \\'%s\\' not found', organization) } if( org.nil? || org.dig('status').to_i != 200 )\n\n organization_id = org.dig('id')\n\n endpoint = format( '/api/orgs/%s', organization_id )\n payload = { name: name }\n\n @logger.debug(\"Update Organisation id #{organization_id} (PUT #{endpoint})\") if @debug\n\n put( endpoint, payload.to_json )\n end", "def update\n respond_to do |format|\n if @organization.update(organization_params)\n format.html { redirect_to edit_admin_organization_path(@organization), notice: 'Organization was successfully updated.' }\n format.json { head :no_content }\n else\n flash[:error] = \"#{@organization.errors.full_messages.first}\"\n format.html { redirect_to edit_admin_organization_path(@organization) }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @people_organization.update(people_organization_params)\n format.html { redirect_to @people_organization, notice: 'People organization was successfully updated.' }\n format.json { render :show, status: :ok, location: @people_organization }\n else\n format.html { render :edit }\n format.json { render json: @people_organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @organization.update(organization_params)\n format.html { redirect_to edit_organization_path(@organization), notice: 'Organization was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @organization.update_attributes(params[:organization])\n format.html { redirect_to admin_organization_path, notice: 'Organization was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { redirect_to admin_organization_path, notice: 'Organization could not be updated.' }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @organization.update(organization_params)\n format.html { redirect_to @organization, notice: 'Place was successfully updated.' }\n format.json { render :show, status: :ok, location: @organization }\n else\n format.html { render :edit }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @organization = Organization.find(params[:id])\n\n authorize! :update, @organization\n\n respond_to do |format|\n if @organization.update_attributes(permitted_params)\n format.html { redirect_to @organization, notice: 'Organization was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { @title = edit_action_title; render action: \"edit\" }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if !current_user.admin?\n head :forbidden\n else\n if @organisation.update(organisation_params)\n render json: @organisation.to_json, status: :ok\n else\n render json: @organisation.errors, status: :unprocessable_entity\n end\n end\n end", "def update\n\t\trespond_to do |format|\n\t\t\tif @organization.update_attributes(params[:organization])\n\t\t\t\tformat.html { redirect_to(@organization, :notice => 'Organization was successfully updated.') }\n\t\t\t\tformat.xml { head :ok }\n\t\t\telse\n\t\t\t\tformat.html { render :action => \"edit\" }\n\t\t\t\tformat.xml { render :xml => @organization.errors, :status => :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend", "def update\n respond_to do |format|\n if @clients_organization.update(clients_organization_params)\n format.json { render :show, status: :ok, location: @clients_organization }\n else\n format.json { render json: @clients_organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n authorize! :update, Organization\n respond_to do |format|\n if @organization.update(organization_params)\n format.js\n else\n format.js { render :edit }\n end\n end\n end", "def update\n respond_to do |format|\n if @user_organization.update(user_organization_params)\n format.html { redirect_to @user_organization, notice: 'User organization was successfully updated.' }\n format.json { render :show, status: :ok, location: @user_organization }\n else\n format.html { render :edit }\n format.json { render json: @user_organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @org.update(org_params)\n redirect_to @org, notice: \"#{@org.name} was successfully updated.\"\n else\n render :edit\n end\n end", "def update\n standard_update(OrganizationType, params[:id], organization_type_params)\n end", "def update\n respond_to do |format|\n if @organization.update_attributes(params[:organization])\n flash[:notice] = 'Organization was successfully updated.'\n format.html { redirect_to @organization }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @organization.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @organization.update_attributes( params[:organization],\n :as => ( permitted_to?( :admin, @organization ) ? :admin : :default ) )\n flash[:notice] = 'Organization was successfully updated.'\n format.html { redirect_to(@organization) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @organization.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @organization = Organization.find(params[:id])\n\n respond_to do |format|\n if @organization.update_attributes(params[:organization])\n flash[:notice] = 'Organization was successfully updated.'\n #format.html { redirect_to(@organization) }\n format.html { redirect_to :controller => 'organizations', :action => 'show' , :organization=> @organization.site_name }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @organization.errors, :status => :unprocessable_entity }\n end\n end\n end", "def set_org\n @org = Organization.find(params[:id])\n end", "def update\n respond_to do |format|\n if @casa_org.update(casa_org_params)\n format.html { redirect_to @casa_org, notice: 'CASA org was successfully updated.' }\n format.json { render :show, status: :ok, location: @casa_org }\n else\n format.html { render :edit }\n format.json { render json: @casa_org.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @organization.update(organization_params)\n format.html { redirect_to organization_path(@organization), notice: 'Организация успешно обновлена.' }\n format.json { render :show, status: :ok, location: @organization }\n else\n format.html { render :edit }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @admins_organization.update(admins_organization_params)\n format.html { redirect_to @admins_organization, notice: 'Organization was successfully updated.' }\n format.json { render :show, status: :ok, location: @admins_organization }\n else\n format.html { render :edit }\n format.json { render json: @admins_organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @external_organization = ExternalOrganization.find(params[:id])\n\n respond_to do |format|\n if @external_organization.update_attributes(params[:external_organization])\n format.html { redirect_to @external_organization, notice: 'External organization was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @external_organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @organ = Organ.find(params[:id])\n\n respond_to do |format|\n if @organ.update_attributes(params[:organ])\n format.html { redirect_to @organ, notice: 'Organ was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @organ.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @sourcing_org.update(sourcing_org_params)\n format.html { redirect_to @sourcing_org, notice: 'Sourcing org was successfully updated.' }\n format.json { render :show, status: :ok, location: @sourcing_org }\n else\n format.html { render :edit }\n format.json { render json: @sourcing_org.errors, status: :unprocessable_entity }\n end\n end\n end", "def edit\n @organization = Organization.find(params[:id])\n end", "def update(name, org_guid)\n org = @client.organization(org_guid)\n org.name = name\n org.update!\n end", "def set_organization\n @organization = Organization.find(params[:id])\n end", "def set_organization\n @organization = Organization.find(params[:id])\n end", "def set_organization\n @organization = Organization.find(params[:id])\n end", "def set_organization\n @organization = Organization.find(params[:id])\n end", "def it_update_from_organization\n organization = params[:org]\n if organization != '0'\n @organization = Organization.find(organization)\n @stores = @organization.blank? ? stores_dropdown : @organization.stores.order(:name)\n @products = @organization.blank? ? products_dropdown : @organization.products.order(:product_code)\n else\n @stores = stores_dropdown\n @products = products_dropdown\n end\n # Products array\n @products_dropdown = products_array(@products)\n # Setup JSON\n @json_data = { \"store\" => @stores, \"product\" => @products_dropdown }\n render json: @json_data\n end", "def update\n respond_to do |format|\n if update_organisation\n format.html { redirect_to @organisation, notice: 'Organisation was successfully updated.' }\n format.json { render :show, status: :ok, location: @organisation }\n else\n format.html { render :edit }\n format.json { render json: @organisation.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_organization\n begin\n @organization = Organization.find(params[:id])\n rescue ActiveRecord::RecordNotFound\n render json: { status: 'error', errors: [\"Organization not found\"] },\n status: :not_found\n end\n end", "def update\n authorize @organization_membership\n\n if @organization_membership.update(organization_membership_update_params)\n head :no_content\n else\n render json: @organization_membership.errors, status: :unprocessable_entity\n end\n end", "def set_organization\n # @org = Organization.find(params[:id])\n end", "def update\n @organization_profile = OrganizationProfile.find(params[:id])\n\n respond_to do |format|\n if @organization_profile.update_attributes(params[:organization_profile])\n format.html { redirect_to @organization_profile, notice: 'Organization profile was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @organization_profile.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_organization\n @organization = Organization.find(params[:name])\n end", "def update\n @organization = Organization.find(params[:id])\n\n if current_user.has_role?('admin')\n @organization.is_pending = false\n end\n respond_to do |format|\n if @organization.update_attributes(params[:organization])\n flash[:notice] = 'Organization was successfully updated.'\n format.html { redirect_to(@organization) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @organization.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @organization_detail = OrganizationDetail.find(params[:id])\n\n respond_to do |format|\n if @organization_detail.update_attributes(params[:organization_detail])\n format.html { redirect_to(@organization_detail, :notice => 'OrganizationDetail was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @organization_detail.errors, :status => :unprocessable_entity }\n end\n end\n end", "def co_update_from_organization\n organization = params[:company]\n if organization != '0'\n @organization = Organization.find(organization)\n @users = @organization.blank? ? users_dropdown : users_dropdown\n #@users = @organization.blank? ? users_dropdown : @organization.users.order(:email)\n else\n @users = users_dropdown\n end\n @json_data = { \"users\" => @users }\n render json: @json_data\n end", "def update\n @participating_organization = ParticipatingOrganization.find(params[:id])\n\n respond_to do |format|\n if @participating_organization.update_attributes(params[:participating_organization])\n format.html { redirect_to(participating_organizations_path, :notice => 'Participating Organization was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @participating_organization.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n if @organization.update(organization_params)\n redirect_to [:settings, @organization], notice: \"Organization was successfully updated.\"\n else\n render :edit\n end\n end", "def set_organization\n @organization = Organization.find(params[:id])\n end", "def set_organization\n @organization = Organization.find(params[:id])\n end", "def set_organization\n @organization = Organization.find(params[:id])\n end", "def set_organization\n @organization = Organization.find(params[:id])\n end", "def set_organization\n @organization = Organization.find(params[:id])\n end", "def set_organization\n @organization = Organization.find(params[:id])\n end", "def set_organization\n @organization = Organization.find(params[:id])\n end", "def set_organization\n @organization = Organization.find(params[:id])\n end", "def set_organization\n @organization = Organization.find(params[:id])\n end", "def set_organization\n @organization = Organization.find(params[:id])\n end", "def set_organization\n @organization = Organization.find(params[:id])\n end", "def set_organization\n @organization = Organization.find(params[:id])\n end", "def set_organization\n @organization = Organization.find(params[:id])\n end", "def set_organization\n @organization = Organization.find(params[:id])\n end", "def set_organization\n @organization = Organization.find(params[:id])\n end", "def set_organization\n @organization = Organization.find(params[:id])\n end", "def set_organization\n @organization = Organization.find(params[:id])\n end", "def set_organization\n @organization = Organization.find(params[:id])\n end", "def set_organization\n @organization = Organization.find(params[:id])\n end", "def set_organization\n @organization = Organization.find(params[:id])\n end", "def update\n result = Organization::Editor.perform(organization: current_organization, options: update_organization_params.to_h)\n\n respond_to do |format|\n format.html do\n if result.success?\n flash[:success] = \"Successfully updated \\\"#{current_organization.title}\\\"!\"\n redirect_to current_organization\n else\n current_organization.reload\n render :edit\n end\n end\n format.js do\n set_filter_options\n set_filtered_organizations\n render \"organizations/archive.js.erb\", format: :js\n end\n end\n end", "def set_organization\n @organization = current_user.organizations.where(id: params[:id]).first\n end", "def update!(**args)\n @organization_id = args[:organization_id] if args.key?(:organization_id)\n @organization_name = args[:organization_name] if args.key?(:organization_name)\n end", "def set_organization\n\t @organization = Organization.find(params[:id])\n\tend", "def update\n @organization_status.update(update_organization_status_params)\n respond_with @organization_status, location: lambda {\n organization_organization_statuses_path(@organization_status.organization)\n }\n end", "def update\n @organisation = Organisation.find(params[:id])\n\n respond_to do |format|\n if @organisation.update_attributes(params[:organisation])\n format.html { redirect_to(locations_url, :notice => \"#{@organisation.to_s} was successfully updated.\") }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @organisation.errors, :status => :unprocessable_entity }\n end\n end\n end", "def edit(org_name, params={})\n _validate_presence_of org_name\n normalize! params\n filter! VALID_ORG_PARAM_NAMES, params\n\n patch_request(\"/orgs/#{org_name}\", params)\n end", "def update\n @organ = Organ.find(params[:id])\n\n respond_to do |format|\n if @organ.update_attributes(params[:organ])\n format.html { redirect_to(@organ, :notice => 'Organ was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @organ.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @organization_account = OrganizationAccount.find(params[:id])\n\n respond_to do |format|\n if @organization_account.update_attributes(params[:organization_account])\n format.html { redirect_to @organization_account, notice: 'Organization account was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @organization_account.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @organization.update_attributes(params[:organization])\n flash[:notice] = VALIDATION_MESSAGE[\"ORGANIZATION\"][\"UPDATE\"] rescue nil\n format.html { redirect_to admin_organization_path(@organization.id) }\n else\n flash[:error] = @organization.errors.full_messages.join(\", \")\n format.html { render :action => \"edit\",:id => @organization.id }\n end\n end\n end", "def update\n @organization.user_updated_id = current_user.id\n respond_to do |format|\n if @organization.update(organization_params)\n format.html { redirect_to @organization, notice: 'Información actualizada satisfactoriamente.' }\n format.json { render :show, status: :ok, location: @organization }\n else\n format.html { render :edit }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def GetOrg id\n\n APICall(path: \"organizations/#{id}.json\")\n\n end", "def update_tenant_circle(args = {}) \n put(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend", "def set_organization\n @organization = Organization.friendly.find(params[:id])\n end", "def set_organization\n @organization = Organization.friendly.find(params[:id])\n end" ]
[ "0.78295016", "0.7434708", "0.7253623", "0.7247928", "0.7240768", "0.7187564", "0.7173343", "0.71293944", "0.71054447", "0.70963454", "0.70263505", "0.6951313", "0.6945305", "0.6945305", "0.6945305", "0.6945305", "0.6945305", "0.6945305", "0.6945305", "0.69379544", "0.6911741", "0.6906686", "0.6906686", "0.6874064", "0.6866124", "0.6851786", "0.68257964", "0.6825172", "0.6817825", "0.68084365", "0.6807733", "0.68032545", "0.67244667", "0.6711768", "0.668489", "0.66743207", "0.66698605", "0.6653635", "0.66099143", "0.660866", "0.65779406", "0.6577848", "0.657128", "0.65699774", "0.65657026", "0.6536534", "0.65126604", "0.6494768", "0.648594", "0.64733297", "0.6468194", "0.6468194", "0.6468194", "0.6468194", "0.6428561", "0.64274645", "0.64257985", "0.6422472", "0.6415664", "0.6392162", "0.63602877", "0.63543195", "0.6343582", "0.6326525", "0.6320336", "0.63197505", "0.63137686", "0.63137686", "0.63137686", "0.63137686", "0.63137686", "0.63137686", "0.63137686", "0.63137686", "0.63137686", "0.63137686", "0.63137686", "0.63137686", "0.63137686", "0.63137686", "0.63137686", "0.63137686", "0.63137686", "0.63137686", "0.63137686", "0.63137686", "0.62912583", "0.62722176", "0.62656796", "0.62626505", "0.62559086", "0.6238496", "0.6238106", "0.6235311", "0.62265193", "0.6220996", "0.62146163", "0.62117165", "0.62000173", "0.6172005", "0.6172005" ]
0.0
-1
DELETE /organizations/1 DELETE /organizations/1.json
def destroy unless current_user.try(:admin?) flash[:notice] = PERMISSION_DENIED redirect_to organization_path(params[:id]) and return false end @organization = Organization.find(params[:id]) @organization.destroy redirect_to organizations_url end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def DeleteOrganization id\n \n APICall(path: \"organizations/#{id}.json\",method: 'DELETE')\n \n end", "def destroy\n @organization = Organization.find(params[:id])\n @organization.destroy\n\n respond_to do |format|\n format.html { redirect_to organizations_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @organization = Organization.find(params[:id])\n @organization.destroy\n\n respond_to do |format|\n format.html { redirect_to organizations_url }\n format.json { head :no_content }\n end\n end", "def destroy\r\n @org = Org.from_param(params[:abbr])\r\n @org.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_to orgs_url }\r\n format.json { head :no_content }\r\n end\r\n end", "def destroy\n @organization.destroy\n respond_to do |format|\n format.html { redirect_to organizations_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @organization.destroy\n respond_to do |format|\n format.html { redirect_to organizations_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @organization.destroy\n respond_to do |format|\n format.html { redirect_to organizations_url }\n format.json { head :no_content }\n end\n end", "def delete(id:)\n id_check(:id, id)\n\n cf_delete(path: \"/organizations/#{org_id}/railguns/#{id}\")\n end", "def destroy\n @organization = Organization.find(params[:id])\n @organization.delete\n end", "def destroy\n @org = Organisation.find_by( id: params[\"id\"]).delete\n redirect_to root_url\n end", "def destroy\n @people_organization.destroy\n respond_to do |format|\n format.html { redirect_to people_organizations_url, notice: 'People organization was successfully removed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @organization = Organization.find(params[:id])\n\n authorize! :destroy, @organization\n\n @organization.destroy\n\n respond_to do |format|\n format.html { redirect_to organizations_url }\n format.json { head :no_content }\n end\n end", "def destroy\n the_org = @person.org_id\n the_name = @person.name\n @person.destroy\n\n respond_to do |format|\n format.html { redirect_to org_path(the_org), status: 303, notice: t('.delete_ok', item: the_name) }\n format.json { head :no_content }\n end\n end", "def destroy\n @organization.destroy\n\n respond_to do |format|\n format.html { redirect_to(organizations_url) }\n end\n end", "def destroy\n @organization.destroy\n respond_to do |format|\n format.html { redirect_to current_user }\n format.json { head :no_content }\n end\n end", "def destroy\n @organization.destroy\n render json: { success: \"Organization deleted successfully\" }, status: :ok\n end", "def destroy\n @organization = Organization.find(params[:id])\n begin\n @organization.destroy\n rescue Exception => e\n flash[:alert] = e.message\n end\n\n respond_to do |format|\n format.html { redirect_to admin_organizations_path }\n format.json { head :no_content }\n end\n end", "def destroy\n # @organization.destroy\n respond_to do |format|\n format.html { redirect_to organizations_url, notice: 'Organization was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @external_organization = ExternalOrganization.find(params[:id])\n @external_organization.destroy\n\n respond_to do |format|\n format.html { redirect_to external_organizations_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @organization = Organization.find(params[:id])\n @organization.destroy\n\n respond_to do |format|\n format.html { redirect_to(organizations_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @organization.destroy\n\n respond_to do |format|\n format.html { redirect_to(organizations_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @organization.destroy\n respond_to do |format|\n format.html { redirect_to organizations_url, notice: 'Организация успешно удалена.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @organization.destroy\n respond_to do |format|\n format.html { redirect_to organizations_url, notice: 'Organization was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @organization.destroy\n respond_to do |format|\n format.html { redirect_to organizations_url, notice: 'Organization was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @organization.destroy\n respond_to do |format|\n format.html { redirect_to organizations_url, notice: 'Organization was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @organization.destroy\n respond_to do |format|\n format.html { redirect_to organizations_url, notice: 'Organization was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @organization.destroy\n respond_to do |format|\n format.html { redirect_to organizations_url, notice: 'Organization was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @organization.destroy\n respond_to do |format|\n format.html { redirect_to organizations_url, notice: 'Organization was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @organization.destroy\n respond_to do |format|\n format.html { redirect_to organizations_url, notice: 'Organization was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @sourcing_org.destroy\n respond_to do |format|\n format.html { redirect_to sourcing_orgs_url, notice: 'Sourcing org was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @organization.destroy\n respond_to do |format|\n format.html { redirect_to organizations_url, notice: \"Organization was destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @organisation.destroy\n respond_to do |format|\n format.html { redirect_to organisations_url, notice: 'Organisation was successfully deleted.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @user.destroy\n respond_to do |format|\n format.html { redirect_to current_org }\n format.json { render json: @organization }\n end\n end", "def destroy\n @organization.destroy\n respond_with(:organizations)\n # respond_to do |format|\n # format.html { redirect_to organizations_url }\n # format.json { head :no_content }\n # end\n end", "def destroy\n standard_destroy(OrganizationType, params[:id])\n end", "def destroy\n Organization.find(params[:id]).destroy\n flash[:success] = \"Organization deleted\"\n redirect_to search_organizations_path\n end", "def destroy\n @clients_organization.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n @organization = Organization.find(params[:id])\n @organization.destroy\n respond_with(@organization)\n end", "def destroy\n @admins_organization.destroy\n respond_to do |format|\n format.html { redirect_to admins_organizations_url, notice: 'Organization was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @organization = Organization.find(params[:id])\n @organization.destroy\n respond_with @organization\n end", "def destroy\n \n @organization.destroy\n \n respond_to do |format|\n format.html { redirect_to organizations_url, notice: 'Place was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @serviceorg = Serviceorg.find(params[:id])\n @serviceorg.destroy\n\n respond_to do |format|\n format.html { redirect_to serviceorgs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @organism = Organism.find(params[:id])\n @organism.destroy\n\n respond_to do |format|\n format.html { redirect_to organisms_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @organization.destroy\n respond_to do |format|\n format.html { redirect_to organization_url, notice: 'Organization was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n authorize! @organization\n @organization.destroy\n\n redirect_to root_path\n end", "def destroy\n @organ = Organ.find(params[:id])\n @organ.destroy\n\n respond_to do |format|\n format.html { redirect_to organs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @organization = Organization.find(params[:id])\n @organization.destroy\n \n redirect_to admin_organizations_url, notice: t('organization.messages.delete.success')\n end", "def destroy\n \n @organism.destroy\n\n respond_to do |format|\n format.html { redirect_to organisms_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @casa_org.destroy\n respond_to do |format|\n format.html { redirect_to casa_orgs_url, notice: 'CASA org 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 @user_organization.destroy\n respond_to do |format|\n format.html { redirect_to user_organizations_url, notice: 'User organization was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @client_org_orderable = ClientOrgOrderable.find(params[:id])\n @client_org_orderable.destroy\n\n respond_to do |format|\n format.html { redirect_to client_org_orderables_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @organization.destroy\n respond_with(@organization)\n end", "def destroy\n @organization_account = OrganizationAccount.find(params[:id])\n @organization_account.destroy\n\n respond_to do |format|\n format.html { redirect_to organization_accounts_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @host_org.destroy\n respond_to do |format|\n format.html { redirect_to host_orgs_url, notice: 'Host org was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @org.destroy\n redirect_to orgs_url, notice: \"#{@org.name} was successfully deleted.\"\n end", "def destroy\n @environment = current_user.organization.environments.find(params[:id])\n @environment.destroy\n\n respond_to do |format|\n format.html { redirect_to environments_url }\n format.json { head :no_content }\n end\n end", "def delete_by_key(key)\n HttpClient::Preconditions.assert_class('key', key, String)\n @client.request(\"/organizations/#{CGI.escape(key)}\").delete\n nil\n end", "def delete\n render json: Company.delete(params[\"id\"])\n end", "def destroy\n @organization.destroy\n end", "def destroy\n @orging.destroy\n respond_to do |format|\n format.html { redirect_to orgings_url, notice: 'Orging was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @organization_detail = OrganizationDetail.find(params[:id])\n @organization_detail.destroy\n\n respond_to do |format|\n format.html { redirect_to(organization_details_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @organization_profile = OrganizationProfile.find(params[:id])\n @organization_profile.destroy\n\n respond_to do |format|\n format.html { redirect_to organization_profiles_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @organization.destroy\n flash[:notice] = 'Organization was successfully removed.'\n\n respond_to do |format|\n format.html { redirect_to(organizations_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @o_rganization.destroy\n respond_to do |format|\n format.html { redirect_to o_rganizations_url, notice: 'O rganization was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n\t\t@organization = Organization.find(params[:id])\n\t\t@organization.destroy\n\n\t\trespond_to do |format|\n\t\t\tformat.html { redirect_to(organizations_url) }\n\t\t\tformat.xml { head :ok }\n\t\tend\n\tend", "def destroy\n @organization_catagory.destroy\n respond_to do |format|\n format.html { redirect_to organization_catagories_url, notice: 'Organization catagory was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @employe.destroy\n respond_to do |format|\n format.html { redirect_to employes_path(api_id: @employe.organisme_id), notice: 'Employe was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @participating_organization = ParticipatingOrganization.find(params[:id])\n @participating_organization.destroy\n\n respond_to do |format|\n format.html { redirect_to(participating_organizations_url) }\n format.xml { head :ok }\n end\n end", "def delete\n render json: Alien.delete(params[\"id\"])\n end", "def destroy\n @person = Person.find(params[:id])\n @person.destroy\n respond_to do |format|\n format.json { render json: {}, status: :ok }\n end\n end", "def destroy\n official = Official.find(params[:id])\n official.destroy\n head 204\n end", "def destroy\n @alumno.destroy\n respond_to do |format|\n format.html { redirect_to grupos_path }\n format.json { head :no_content }\n end\n end", "def destroy\n @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 check_privileges(:superadmin?, organisation_path(params[:id])); return if performed?\n @organisation = Organisation.friendly.find(params[:id])\n @organisation.destroy\n flash[:success] = \"Deleted #{@organisation.name}\"\n redirect_to organisations_path\n end", "def delete\n client.delete(\"/#{id}\")\n end", "def destroy\n @orgn.destroy\n track_activity @orgn\n respond_to do |format|\n format.html { redirect_to orgns_url, notice: 'Orgn was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @person.destroy\n respond_to do |format|\n format.html { redirect_to admin_people_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @admin_agency = Admin::Agency.find(params[:id])\n @admin_agency.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_agencies_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @person = Person.find(params[:id])\n @person.destroy\n\n respond_to do |format|\n format.html { redirect_to root_path }\n format.json { head :no_content }\n end\n end", "def destroy\n @org_unit.destroy\n respond_to do |format|\n format.html { redirect_to org_units_url, notice: 'Org unit was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @group_organization.destroy\n respond_to do |format|\n format.html { redirect_to group_organizations_url, notice: 'Group organization was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @organisme.destroy\n respond_to do |format|\n format.html { redirect_to organismes_url, notice: 'Organisme was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @organizer.destroy\n respond_to do |format|\n format.html { redirect_to organizers_url, notice: 'Organizer was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @organizer.destroy\n respond_to do |format|\n format.html { redirect_to organizers_url, notice: 'Organizer was successfully destroyed.' }\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 \n keystone.delete_tenant(keystone.get_tenant(params[:id])[:id])\n\n respond_to do |format|\n format.html { redirect_to tenants_url }\n format.json { head :ok }\n end\n end", "def destroy\n # @person = Person.find(params[:id])\n @person.destroy\n\n respond_to do |format|\n format.html { redirect_to people_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @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 @organ = Organ.find(params[:id])\n @organ.destroy\n\n respond_to do |format|\n format.html { redirect_to(organs_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n authorize! :destroy, @individual\n @individual.destroy\n respond_to do |format|\n format.html { redirect_to individuals_url }\n format.json { head :no_content }\n end\n end", "def destroy\n unless current_user.try(:superadmin?)\n flash[:notice] = PERMISSION_DENIED\n redirect_to organisation_path(params[:id]) and return false\n end\n @organisation = Organisation.friendly.find(params[:id])\n @organisation.destroy\n flash[:success] = \"Deleted #{@organisation.name}\"\n\n redirect_to organisations_path\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 @person = Person.find(params[:id])\n @person.destroy\n\n respond_to do |format|\n format.html { redirect_to people_url }\n format.json { head :ok }\n end\n end", "def destroy\n @person = Person.find(params[:id])\n @person.destroy\n\n respond_to do |format|\n format.html { redirect_to people_url }\n format.json { head :ok }\n end\n end", "def destroy\n @person = Person.find(params[:id])\n @person.destroy\n\n respond_to do |format|\n format.html { redirect_to people_url }\n format.json { head :ok }\n end\n end", "def destroy\n @occupant = Occupant.find(params[:id])\n @occupant.destroy\n\n respond_to do |format|\n format.html { redirect_to occupants_url }\n format.json { head :no_content }\n end\n end", "def destroy_by_body\n @person = Person.find(person_delete_param[:id])\n id = @person.id\n\n if @person.destroy\n render json: { status: 'DELETE Success' }, status: :ok\n else\n render json: { status: 'Error', message:'Error deleting person', person: @person.errors }, status: :unprocessable_entity\n end\n end", "def destroy\n ## note use of method chaining to combine find & destroy into one line\n Person.find(params[:id]).destroy\n respond_to do |format|\n format.html { redirect_to people_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @person.destroy\n respond_to do |format|\n format.html { redirect_to people_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @person.destroy\n respond_to do |format|\n format.html { redirect_to people_url }\n format.json { head :no_content }\n end\n end" ]
[ "0.7767288", "0.75106853", "0.75106853", "0.7457346", "0.7439525", "0.7439525", "0.7439525", "0.7331174", "0.73253006", "0.73227197", "0.7295465", "0.7285924", "0.7278945", "0.7270234", "0.726735", "0.72643864", "0.72632885", "0.723405", "0.7200872", "0.7193817", "0.71657467", "0.71488714", "0.71204734", "0.71204734", "0.71204734", "0.71204734", "0.71204734", "0.71204734", "0.71204734", "0.7115395", "0.7101233", "0.7098312", "0.708705", "0.7085407", "0.7084386", "0.7071004", "0.706313", "0.7062378", "0.7061485", "0.7059044", "0.704055", "0.7036474", "0.70297706", "0.702916", "0.70251834", "0.70162535", "0.70135725", "0.7001765", "0.6998686", "0.6978198", "0.696906", "0.6968368", "0.69501054", "0.6925744", "0.69044435", "0.6895838", "0.68868506", "0.68823034", "0.6874819", "0.68583053", "0.68555754", "0.6850577", "0.6850006", "0.6835527", "0.6809422", "0.6804169", "0.67862296", "0.6782862", "0.6779343", "0.67624056", "0.6749459", "0.67456675", "0.67302835", "0.6723526", "0.67176485", "0.670722", "0.6705247", "0.6701616", "0.66924155", "0.6691064", "0.66808456", "0.668001", "0.6679329", "0.666764", "0.666764", "0.66624546", "0.6654458", "0.6648173", "0.6645709", "0.66453046", "0.664137", "0.66357213", "0.66341585", "0.6625787", "0.6625787", "0.6625787", "0.6622431", "0.66215783", "0.66163236", "0.6612257", "0.6612257" ]
0.0
-1
=begin Make a API call to convert file/url/hash based on parameters and return xml response.
def convert(target_type_method, source_type, source, source_name=nil, source_options=nil, notification_url=nil) if !@@_target_type_options.has_key?(target_type_method) raise "Invalid Target Type." end @@_target_type =@@_target_type_options[target_type_method] if !@@_source_type_options.has_key?(source_type) raise "Invalid Source Type." end @@_source_type = source_type if @@_source_type == SOURCE_TYPE_FILE_BASE64 or @@_source_type == SOURCE_TYPE_FILE_PATH if source_name === nil || source_name.length < 1 raise "Invalid Source Name." end end if @@_source_type == SOURCE_TYPE_FILE_PATH if !File.exist?(source) raise "File not found:"+source end require 'base64' source = Base64.encode64(open(source) { |io| io.read }); end data={"apiKey"=>@@_api_key, "targetType"=>@@_target_type_options[target_type_method], "targetMethod" => target_type_method, "testMode" =>@@_test_mode, "notificationUrl" => notification_url } if @@_source_type == SOURCE_TYPE_URL data['sourceUrl'] = source else file={"file"=>{ "fileName"=>source_name, "fileData"=>source }} data=data.merge(file) end if source_options != nil data['format'] = source_options end response = api_call('queue-insert',data) response_array = xml_to_array(response) if response_array['queue_answer']['status']['code'] == '0' @@hash = response_array['queue_answer']['params']['hash']; @@download_url = response_array['queue_answer']['params']['downloadUrl']; end @@_url =URL; return response; end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_xml(params = {:format => :xml, :action => :query})#TODO put these in so that they're default and not lost when we pass stuff in...\n url = _form_url(params)\n \n #TODO wonder if I should make a generic library for external url requests, to standardize the header/etc?\n #requests without user-agents are refused. See:\n #http://www.mooduino.co.uk/2010/04/wikipedia-api-user-agent-string-in-php.html\n retries = 2\n begin\n http = Net::HTTP.new(WIKI_API_SERVER) #en.wikipedia.org\n resp = http.request_get(WIKI_API_PATH + url, 'User-Agent' => 'WikipediaAntiSpamBot/0.1 (+hincapie.cis.upenn.edu)')\n \n raise \"POST FAILED:\" + resp.inspect unless resp.is_a? Net::HTTPOK or resp.is_a? Net::HTTPFound\n #retry if resp.body.to_s.empty?\n resp.body\n rescue Net::HTTPBadResponse, Errno::ECONNRESET, Errno::ETIMEDOUT, Errno::ECONNREFUSED, SocketError, \n Timeout::Error, Errno::EINVAL, EOFError, Net::HTTPHeaderSyntaxError, Net::ProtocolError => e\n if retries > 0\n retries -= 1\n retry\n else\n raise Exception.new(\"Connection timed out after more than 3 retries: #{e}\")\n end\n end\nend", "def do_request(params)\n # Convert the uri to a URI if it's a string.\n if params[:uri].is_a?(String)\n params[:uri] = URI.parse(params[:uri])\n end\n host_url = \"#{params[:uri].scheme}://#{params[:uri].host}#{params[:uri].port ? \":#{params[:uri].port}\" : ''}\"\n\n # Hash connections on the host_url ... There's nothing to say we won't get URI's that go to\n # different hosts.\n @connections[host_url] ||= Fog::XML::Connection.new(host_url, @persistent, @connection_options)\n\n # Set headers to an empty hash if none are set.\n headers = params[:headers] || {}\n headers['Accept'] = 'application/*+xml;version=1.5' if version == '1.5'\n\n # Add our auth cookie to the headers\n if @cookie\n headers.merge!('Cookie' => @cookie)\n end\n\n # Make the request\n response = @connections[host_url].request({\n :body => params[:body] || '',\n :expects => params[:expects] || 200,\n :headers => headers,\n :method => params[:method] || 'GET',\n :path => params[:uri].path\n })\n\n # Parse the response body into a hash\n unless response.body.empty?\n if params[:parse]\n document = Fog::ToHashDocument.new\n parser = Nokogiri::XML::SAX::PushParser.new(document)\n parser << response.body\n parser.finish\n response.body = document.body\n end\n end\n\n response\n end", "def make_url(params) #:nodoc:\n params[:key] = @key\n params[:output] = 'xml'\n\n super params\n end", "def _api_call(method, args)\r\n uri = _uri(method, args)\r\n response = XmlSimple.xml_in(_http_get(uri))\r\n end", "def make_url(method, params)\n params[:key] = @key\n params[:output] = 'xml'\n\n super method, params\n end", "def call\n request = http_request_class.new(uri.request_uri, headers)\n request.body = body if body\n http = http_setup\n # http.set_debug_output($stdout)\n response = wait_for_completion(HttpResponse.new(http.request(request)))\n Nokogiri::XML response.body unless response.nil?\n end", "def rest_get(uri)\n \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 return doc\n \n end\n \nend", "def make_url(params) #:nodoc:\n params[:appid] = @appid\n params[:output] = 'xml'\n\n super params\n end", "def make_url(params) #:nodoc:\n params[:appid] = @appid\n params[:output] = 'xml'\n\n super params\n end", "def process_return url, format\n data = Net::HTTP.get_response(URI.parse(url)).body\n\n # header...\n header = Hash.new \n header[:url] = url \n\n if (format == \"xml\") then\n doc = REXML::Document.new(data)\n \n header[:status] = doc.root.elements[\"status\"].text\n header[:copyright] = doc.root.elements[\"copyright\"].text\n header[:num_results] = doc.root.elements[\"results/totalCommentsReturned\"].text if (doc.root.elements[\"results/totalCommentsReturned\"] != nil)\n \n # data...\n records = Array.new\n doc.root.each_element('//result_set/results/comments/comment') do |review| \n record = Hash.new \n review.each_element do |ele|\n record.merge!({ele.name => ele.text})\n end\n records << record\n end \n \n return records, header\n \n else\n return data, header\n end\n \n end", "def request_conversion( doc_id:, version:CURRENT, filename:, action:, callback_url:nil )\n params = {}\n params[:callback_url] = callback_url if callback_url\n params[:backtrace] = @backtrace if @backtrace\n\n send_request :post, \"#{path_for(doc_id, filename, version)}/#{action}\", params, :json\n end", "def make_url(params) #:nodoc:\n super params.merge(:output => \"xml\", :oe => 'utf8', :ll => @ll, :spn => @spn, :sensor => false)\n end", "def make_xml_request( opts={} )\n\t\topts = TEST_XML_REQUEST_OPTS.merge( opts )\n\t\theaders = normalize_headers( opts, TEST_XML_HEADERS )\n\t\theaders.delete( 'URI' ) # XML requests don't have one\n\n\t\tMongrel2.log.debug \"XML request, headers = %p, opts = %p\" % [ headers, opts ]\n\n\t\theaderstring = TNetstring.dump( Yajl::Encoder.encode(headers) )\n\t\tbodystring = TNetstring.dump( opts[:body] || \"#{TEST_XML_PATH} />\" )\n\n\t\t# UUID ID PATH SIZE:HEADERS,SIZE:BODY,\n\t\tdata = \"%s %d %s %s%s\" % [\n\t\t\topts[:uuid],\n\t\t\topts[:id],\n\t\t\topts[:path],\n\t\t\theaderstring,\n\t\t\tbodystring,\n\t\t]\n\t\treturn data.encode( 'binary' )\n\tend", "def make_xml_request( opts={} )\n\t\topts = TEST_XML_REQUEST_OPTS.merge( opts )\n\t\theaders = normalize_headers( opts, TEST_XML_HEADERS )\n\t\theaders.delete( 'URI' ) # XML requests don't have one\n\n\t\tMongrel2.log.debug \"XML request, headers = %p, opts = %p\" % [ headers, opts ]\n\n\t\theaderstring = TNetstring.dump( Yajl::Encoder.encode(headers) )\n\t\tbodystring = TNetstring.dump( opts[:body] || \"#{TEST_XML_PATH} />\" )\n\n\t\t# UUID ID PATH SIZE:HEADERS,SIZE:BODY,\n\t\tdata = \"%s %d %s %s%s\" % [\n\t\t\topts[:uuid],\n\t\t\topts[:id],\n\t\t\topts[:path],\n\t\t\theaderstring,\n\t\t\tbodystring,\n\t\t]\n\t\treturn data.encode( 'binary' )\n\tend", "def call\n uri = URI(full_url)\n\n request = Net::HTTP::Post.new(uri)\n default_headers.each { |k, v| request[k] = v }\n request.body = to_xml\n\n https = Net::HTTP.new(uri.hostname, uri.port)\n https.use_ssl = true\n https.ssl_version = :TLSv1_2_client\n if Nuncium.configuration.cert_file\n https.verify_mode = OpenSSL::SSL::VERIFY_PEER\n https.cert = Nuncium.configuration.cert_file\n https.key = Nuncium.configuration.private_key\n https.verify_depth = 5\n request.basic_auth(Nuncium.configuration.data_box, '')\n else\n request.basic_auth(\n Nuncium.configuration.username,\n Nuncium.configuration.password\n )\n end\n response = https.request(request)\n call_reponse_wrapper(response)\n end", "def do_request(params)\n # Convert the uri to a URI if it's a string.\n if params[:uri].is_a?(String)\n params[:uri] = URI.parse(params[:uri])\n end\n host_url = \"#{params[:uri].scheme}://#{params[:uri].host}#{params[:uri].port ? \":#{params[:uri].port}\" : ''}\"\n\n # Hash connections on the host_url ... There's nothing to say we won't get URI's that go to\n # different hosts.\n @connections[host_url] ||= Fog::Connection.new(host_url, @persistent, @connection_options)\n\n # Set headers to an empty hash if none are set.\n headers = params[:headers] || {}\n\n # Add our auth cookie to the headers\n if @cookie\n headers.merge!('Cookie' => @cookie)\n end\n\n # Make the request\n response = @connections[host_url].request({\n :body => params[:body] || '',\n :expects => params[:expects] || 200,\n :headers => headers,\n :method => params[:method] || 'GET',\n :path => params[:uri].path\n })\n\n # Parse the response body into a hash\n #puts response.body\n unless response.body.empty?\n if params[:parse]\n document = Fog::ToHashDocument.new\n parser = Nokogiri::XML::SAX::PushParser.new(document)\n parser << response.body\n parser.finish\n\n response.body = document.body\n end\n end\n\n response\n end", "def convert()\n @helper.post(@fields, @files, @raw_data)\n end", "def execute(xml)\n\t\tAPIRequest.execute(url,xml.to_s)\n\tend", "def makeOutput(hash, format, xmlRoot)\n if format == 'json'\n content_type 'application/json'\n output = hash.to_json\n elsif format == 'xml'\n content_type 'text/xml'\n output = hash.to_xml(:root => \"#{xmlRoot}\")\n else\n # default to json for now\n content_type 'application/json'\n output = hash.to_json\n end\n \n # close DB connection\n if @db\n @db.close\n end\n \n return output\nend", "def api_xml(path,method=:get,options={})\n xml_message(amee,\"/data\"+path,method,options)\n end", "def compare_document_docx_with_http_info(input_file1, input_file2, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: CompareDocumentApi.compare_document_docx ...'\n end\n # verify the required parameter 'input_file1' is set\n if @api_client.config.client_side_validation && input_file1.nil?\n fail ArgumentError, \"Missing the required parameter 'input_file1' when calling CompareDocumentApi.compare_document_docx\"\n end\n # verify the required parameter 'input_file2' is set\n if @api_client.config.client_side_validation && input_file2.nil?\n fail ArgumentError, \"Missing the required parameter 'input_file2' when calling CompareDocumentApi.compare_document_docx\"\n end\n # resource path\n local_var_path = '/convert/compare/docx'\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(['multipart/form-data'])\n\n # form parameters\n form_params = {}\n form_params['inputFile1'] = input_file1\n form_params['inputFile2'] = input_file2\n\n # http body (model)\n post_body = nil\n auth_names = ['Apikey']\n data, status_code, headers = @api_client.call_api(:POST, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'String')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: CompareDocumentApi#compare_document_docx\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def convert_document_xls_to_xlsx_with_http_info(input_file, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ConvertDocumentApi.convert_document_xls_to_xlsx ...'\n end\n # verify the required parameter 'input_file' is set\n if @api_client.config.client_side_validation && input_file.nil?\n fail ArgumentError, \"Missing the required parameter 'input_file' when calling ConvertDocumentApi.convert_document_xls_to_xlsx\"\n end\n # resource path\n local_var_path = '/convert/xls/to/xlsx'\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(['multipart/form-data'])\n\n # form parameters\n form_params = {}\n form_params['inputFile'] = input_file\n\n # http body (model)\n post_body = nil\n auth_names = ['Apikey']\n data, status_code, headers = @api_client.call_api(:POST, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'String')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ConvertDocumentApi#convert_document_xls_to_xlsx\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def XML(thing, url = T.unsafe(nil), encoding = T.unsafe(nil), options = T.unsafe(nil), &block); end", "def XML(thing, url = T.unsafe(nil), encoding = T.unsafe(nil), options = T.unsafe(nil), &block); end", "def get_xml\n response = @api.request(:get, @location, type: 'xml')\n response.body if response.status == 200\n end", "def convert_document_csv_multi_to_xlsx_with_http_info(input_file1, input_file2, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ConvertDocumentApi.convert_document_csv_multi_to_xlsx ...'\n end\n # verify the required parameter 'input_file1' is set\n if @api_client.config.client_side_validation && input_file1.nil?\n fail ArgumentError, \"Missing the required parameter 'input_file1' when calling ConvertDocumentApi.convert_document_csv_multi_to_xlsx\"\n end\n # verify the required parameter 'input_file2' is set\n if @api_client.config.client_side_validation && input_file2.nil?\n fail ArgumentError, \"Missing the required parameter 'input_file2' when calling ConvertDocumentApi.convert_document_csv_multi_to_xlsx\"\n end\n # resource path\n local_var_path = '/convert/csv/multi/to/xlsx'\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(['multipart/form-data'])\n header_params[:'worksheetNames'] = opts[:'worksheet_names'] if !opts[:'worksheet_names'].nil?\n\n # form parameters\n form_params = {}\n form_params['inputFile1'] = input_file1\n form_params['inputFile2'] = input_file2\n form_params['inputFile3'] = opts[:'input_file3'] if !opts[:'input_file3'].nil?\n form_params['inputFile4'] = opts[:'input_file4'] if !opts[:'input_file4'].nil?\n form_params['inputFile5'] = opts[:'input_file5'] if !opts[:'input_file5'].nil?\n form_params['inputFile6'] = opts[:'input_file6'] if !opts[:'input_file6'].nil?\n form_params['inputFile7'] = opts[:'input_file7'] if !opts[:'input_file7'].nil?\n form_params['inputFile8'] = opts[:'input_file8'] if !opts[:'input_file8'].nil?\n form_params['inputFile9'] = opts[:'input_file9'] if !opts[:'input_file9'].nil?\n form_params['inputFile10'] = opts[:'input_file10'] if !opts[:'input_file10'].nil?\n\n # http body (model)\n post_body = nil\n auth_names = ['Apikey']\n data, status_code, headers = @api_client.call_api(:POST, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'String')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ConvertDocumentApi#convert_document_csv_multi_to_xlsx\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def request(uris_data)\r\n\r\n #Setup output array\r\n xmlNodes = Array.new\r\n responses = request_raw(uris_data)\r\n \r\n responses.each do |response|\r\n if (response.code == \"200\")\r\n response.body.empty? ? (xmlNodes << XmlNode.new(\"Empty\")) : xmlNodes << XmlNode.parse(response.body)\r\n else\r\n xmlnode = XmlNode.new(\"error\")\r\n xmlnode.put_node('code', response.code) #put status code as xmlnode\r\n xmlnode.put_node('msg', response.body)\r\n xmlNodes << xmlnode\r\n end\r\n end\r\n return xmlNodes\r\n end", "def send_xml(out_xml)\n uri = URI.parse(@url)\n http = Net::HTTP.new(uri.host, uri.port)\n request = Net::HTTP::Post.new(uri.request_uri)\n\n @logger.error \"#$%$ #{@user}\"\n request.basic_auth @user, @password\n request.body = out_xml\n\n log(\"Sending request: #{request.inspect}\")\n response = http.request(request)\n\n log(\"Response: #{response}\")\n return response.body\n end", "def convert_document_xlsx_to_html_with_http_info(input_file, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ConvertDocumentApi.convert_document_xlsx_to_html ...'\n end\n # verify the required parameter 'input_file' is set\n if @api_client.config.client_side_validation && input_file.nil?\n fail ArgumentError, \"Missing the required parameter 'input_file' when calling ConvertDocumentApi.convert_document_xlsx_to_html\"\n end\n # resource path\n local_var_path = '/convert/xlsx/to/html'\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(['multipart/form-data'])\n\n # form parameters\n form_params = {}\n form_params['inputFile'] = input_file\n\n # http body (model)\n post_body = nil\n auth_names = ['Apikey']\n data, status_code, headers = @api_client.call_api(:POST, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'String')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ConvertDocumentApi#convert_document_xlsx_to_html\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def convert_document_xlsx_to_png_with_http_info(input_file, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ConvertDocumentApi.convert_document_xlsx_to_png ...'\n end\n # verify the required parameter 'input_file' is set\n if @api_client.config.client_side_validation && input_file.nil?\n fail ArgumentError, \"Missing the required parameter 'input_file' when calling ConvertDocumentApi.convert_document_xlsx_to_png\"\n end\n # resource path\n local_var_path = '/convert/xlsx/to/png'\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', 'text/json', 'application/xml', 'text/xml'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['multipart/form-data'])\n\n # form parameters\n form_params = {}\n form_params['inputFile'] = input_file\n\n # http body (model)\n post_body = nil\n auth_names = ['Apikey']\n data, status_code, headers = @api_client.call_api(:POST, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'XlsxToPngResult')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ConvertDocumentApi#convert_document_xlsx_to_png\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def process_request\n api_response = self.class.post(api_url, :body => build_xml)\n puts api_response if @debug\n response = parse_response(api_response)\n if success?(response)\n success_response(api_response, response)\n else\n failure_response(api_response, response)\n end\n end", "def make_get_xml(who, api_key)\n return lambda {|method, extra|\n begin\n io = open(\"http://ws.audioscrobbler.com/2.0/?method=#{method}&user=#{who}&api_key=#{api_key}&#{extra}\")\n if io.status[0].to_i != 200 then\n puts \"? \" + io.status[0]\n end\n return Nokogiri::XML(io.read)\n rescue OpenURI::HTTPError => e\n nd = Nokogiri::XML(e.io.read)\n puts \"! \" + nd.at('//lfm/error').inner_text\n exit\n end\n\n return nd\n }\nend", "def convert_document_xlsx_to_xls_with_http_info(input_file, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ConvertDocumentApi.convert_document_xlsx_to_xls ...'\n end\n # verify the required parameter 'input_file' is set\n if @api_client.config.client_side_validation && input_file.nil?\n fail ArgumentError, \"Missing the required parameter 'input_file' when calling ConvertDocumentApi.convert_document_xlsx_to_xls\"\n end\n # resource path\n local_var_path = '/convert/xlsx/to/xls'\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(['multipart/form-data'])\n\n # form parameters\n form_params = {}\n form_params['inputFile'] = input_file\n\n # http body (model)\n post_body = nil\n auth_names = ['Apikey']\n data, status_code, headers = @api_client.call_api(:POST, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'String')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ConvertDocumentApi#convert_document_xlsx_to_xls\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def sendfile\n @tmxfile = Tmxfile.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => Hash.from_tmx(@tmxfile.source_data).to_json }\n# format.tmx { render :tmx => @tmxfile.source_data }\n format.tmx {\n @sendfile = \"\"\n doc = XML::Document.string(Tmxfile.first.source_data) \n phrases = doc.find('/language/phrasetype/phrase')\n targetdoc = XML::Document.string(Tmxfile.first.target_data) \n tphrases = targetdoc.find('/language/phrasetype/phrase')\n sourcehash = createsourcehash(phrases) # a private function\n targethash = createtargethash(tphrases) # a private function\n @sendfile = createTMX(sourcehash, targethash)\n render :sendfile\n }\n end\n end", "def request(path, parameters = {})\n response = Basecamp.connection.post(path, convert_body(parameters), \"Content-Type\" => content_type)\n\n if response.code.to_i / 100 == 2\n result = XmlSimple.xml_in(response.body, 'keeproot' => true, 'contentkey' => '__content__', 'forcecontent' => true)\n typecast_value(result)\n else\n raise \"#{response.message} (#{response.code})\"\n end\n end", "def _convertXML() \n\n require 'rexml/document'\n return REXML::Document.new(self.response)\n\n raise \"Unimplemented.\"\n \n\t#\t\t\tfrom xml.dom.ext.reader import PyExpat\n#\t\t\tParser = PyExpat.Reader\n#\t\texcept ImportError :\n#\t\t\tfrom xml.dom.ext.reader import Sax2\n#\t\t\tParser = Sax2.Reader\n#\t\t\t#import warnings\n#\t\t\t#warnings.warn(\"Expat parser could not be loaded, using Sax2. Might slow down things...\")\n#\t\treader = Parser()\n#\t\treturn reader.fromStream(self.response)\n\n end", "def request(resource, method = \"get\", args = nil)\n \t \n \t @now_playing_url = 'http://62.216.251.203:80/nowplaying'\n \t @submission_url = 'http://62.216.251.205:80/protocol_1.2'\n \t @session_id = '17E61E13454CDD8B68E8D7DEEEDF6170'\n \t \n \t if @base_url == Scrobbler::API_URL\n \t pieces = resource.split('/')\n pieces.shift\n \t api_version = pieces.shift\n if api_version == \"1.0\"\n folder = pieces.shift\n file = pieces.last[0, pieces.last.index('.xml')]\n base_pieces = pieces.last.split('?')\n\n file = if base_pieces.size > 1\n # if query string params are in resource they are underscore separated for filenames\n base_pieces.last.split('&').inject(\"#{file}_\") { |str, pair| str << pair.split('=').join('_') + '_'; str }.chop!\n else\n file\n end\n\n File.read(File.dirname(__FILE__) + \"/../fixtures/xml/#{folder}/#{file}.xml\")\n elsif api_version == \"2.0\"\n method_pieces = pieces.last.split('&')\n api_method = method_pieces.shift\n if api_method == '?method=artist.search'\n return File.read(File.dirname(__FILE__) + \"/../fixtures/xml/search/artist.xml\")\n elsif api_method == '?method=album.search'\n return File.read(File.dirname(__FILE__) + \"/../fixtures/xml/search/album.xml\")\n elsif api_method == '?method=track.search'\n return File.read(File.dirname(__FILE__) + \"/../fixtures/xml/search/track.xml\")\n elsif pieces.last =~ /[?&]method=album\\.getinfo/\n return File.read(File.dirname(__FILE__) + \"/../fixtures/xml/album/info.xml\")\n elsif pieces.last =~ /[?&]method=artist\\.gettoptags/\n return File.read(File.dirname(__FILE__) + \"/../fixtures/xml/artist/toptags.xml\")\n elsif pieces.last =~ /[?&]method=artist\\.search/\n return File.read(File.dirname(__FILE__) + \"/../fixtures/xml/artist/search.xml\")\n elsif pieces.last =~ /[?&]method=artist\\.gettopfans/\n return File.read(File.dirname(__FILE__) + \"/../fixtures/xml/artist/fans.xml\")\n elsif pieces.last =~ /[?&]method=artist\\.gettoptracks/\n return File.read(File.dirname(__FILE__) + \"/../fixtures/xml/artist/toptracks.xml\")\n elsif pieces.last =~ /[?&]method=artist\\.gettopalbums/\n return File.read(File.dirname(__FILE__) + \"/../fixtures/xml/artist/topalbums.xml\")\n elsif pieces.last =~ /[?&]method=artist\\.getsimilar/\n return File.read(File.dirname(__FILE__) + \"/../fixtures/xml/artist/similar.xml\")\n elsif pieces.last =~ /[?&]method=album\\.search/\n return File.read(File.dirname(__FILE__) + \"/../fixtures/xml/album/search.xml\")\n elsif pieces.last =~ /[?&]method=tag\\.gettoptracks/\n return File.read(File.dirname(__FILE__) + \"/../fixtures/xml/tag/toptracks.xml\")\n elsif pieces.last =~ /[?&]method=tag\\.gettopartists/\n return File.read(File.dirname(__FILE__) + \"/../fixtures/xml/tag/topartists.xml\")\n elsif pieces.last =~ /[?&]method=tag\\.gettopalbums/\n return File.read(File.dirname(__FILE__) + \"/../fixtures/xml/tag/topalbums.xml\")\n elsif pieces.last =~ /[?&]method=track\\.gettoptags/\n return File.read(File.dirname(__FILE__) + \"/../fixtures/xml/track/toptags.xml\")\n elsif pieces.last =~ /[?&]method=track\\.gettopfans/\n return File.read(File.dirname(__FILE__) + \"/../fixtures/xml/track/fans.xml\")\n elsif pieces.last =~ /[?&]method=track\\.search/\n return File.read(File.dirname(__FILE__) + \"/../fixtures/xml/track/search.xml\")\n elsif pieces.last =~ /[?&]method=user\\.getlovedtracks/\n return File.read(File.dirname(__FILE__) + \"/../fixtures/xml/user/lovedtracks.xml\")\n elsif pieces.last =~ /[?&]method=user\\.gettopartists/\n return File.read(File.dirname(__FILE__) + \"/../fixtures/xml/user/topartists.xml\")\n elsif pieces.last =~ /[?&]method=user\\.gettopalbums/\n return File.read(File.dirname(__FILE__) + \"/../fixtures/xml/user/topalbums.xml\")\n elsif pieces.last =~ /[?&]method=user\\.gettoptracks/\n return File.read(File.dirname(__FILE__) + \"/../fixtures/xml/user/toptracks.xml\")\n elsif pieces.last =~ /[?&]method=user\\.getfriends/\n return File.read(File.dirname(__FILE__) + \"/../fixtures/xml/user/friends.xml\")\n elsif pieces.last =~ /[?&]method=user\\.gettoptags/\n return File.read(File.dirname(__FILE__) + \"/../fixtures/xml/user/toptags.xml\")\n elsif pieces.last =~ /[?&]method=user\\.getneighbours/\n return File.read(File.dirname(__FILE__) + \"/../fixtures/xml/user/neighbours.xml\")\n elsif pieces.last =~ /[?&]method=user\\.getrecenttracks/\n return File.read(File.dirname(__FILE__) + \"/../fixtures/xml/user/recenttracks.xml\")\n elsif pieces.last =~ /[?&]method=user\\.playlists/\n return File.read(File.dirname(__FILE__) + \"/../fixtures/xml/user/playlists.xml\")\n elsif pieces.last =~ /[?&]method=event\\.getinfo/\n return File.read(File.dirname(__FILE__) + \"/../fixtures/xml/event/event.xml\")\n elsif pieces.last =~ /[?&]method=event\\.getshouts/\n return File.read(File.dirname(__FILE__) + \"/../fixtures/xml/event/shouts.xml\")\n elsif pieces.last =~ /[?&]method=user\\.getweeklyalbumchart/\n return File.read(File.dirname(__FILE__) + \"/../fixtures/xml/user/weeklyalbumchart.xml\")\n elsif pieces.last =~ /[?&]method=user\\.getweeklyartistchart/\n return File.read(File.dirname(__FILE__) + \"/../fixtures/xml/user/weeklyartistchart.xml\")\n elsif pieces.last =~ /[?&]method=user\\.getweeklytrackchart/\n return File.read(File.dirname(__FILE__) + \"/../fixtures/xml/user/weeklytrackchart.xml\")\n elsif pieces.last =~ /[?&]method=user\\.getevents/\n return File.read(File.dirname(__FILE__) + \"/../fixtures/xml/user/events.xml\")\n else\n old_request(resource, method, args)\n end\n end\n \t elsif @base_url == Scrobbler::AUTH_URL\n if args[:hs] == \"true\" && args[:p] == Scrobbler::AUTH_VER.to_s && args[:c] == 'rbs' &&\n args[:v] == '0.2.13' && args[:u] == 'chunky' && !args[:t].blank? &&\n args[:a] == Digest::MD5.hexdigest('7813258ef8c6b632dde8cc80f6bda62f' + args[:t])\n \n \"OK\\n#{@session_id}\\n#{@now_playing_url}\\n#{@submission_url}\"\n end\n elsif @base_url == @now_playing_url\n if args[:s] == @session_id && ![args[:a], args[:t], args[:b], args[:n]].any?(&:blank?)\n 'OK'\n end \n elsif @base_url == @submission_url\n if args[:s] == @session_id && \n ![args['a[0]'], args['t[0]'], args['i[0]'], args['o[0]'], args['l[0]'], args['b[0]']].any?(&:blank?)\n 'OK'\n end\n\t end\n\t end", "def xml(path, params = {}, env = {}, &block)\n params = {:api_key => '5c87948ac1979401'}.merge params\n xml = LibXML::XML::Parser.string(get(path + '.xml', params, env).body).parse\n if error = xml.find('/error').first\n message = error.find_first('message')\n puts\n puts \"Server Error: #{message.content}\"\n backtrace = error.find_first('backtrace')\n puts backtrace.content\n exit!\n end\n if block_given?\n yield xml\n else\n xml\n end\n end", "def request_xml(scope, name, opts, cache_only = false)\n opts = EAAL.additional_request_parameters.merge(opts)\n xml = EAAL.cache.load(self.keyid, self.vcode, scope, name,opts)\n\n if (not xml) && (not cache_only)\n \n conn = Faraday.new(:url => \"#{EAAL.api_base}\") do |faraday|\n faraday.request :url_encoded\n faraday.adapter Faraday.default_adapter\n end\n\n response = conn.get(\n request_path(name), \n opts.merge({\n :keyid => self.keyid,\n :vcode => self.vcode}))\n \n case response.status\n when 200\n # Nothing\n when 404\n raise EAAL::Exception::APINotFoundError.new(\"The requested API (#{scope} / #{name}) could not be found.\")\n else\n if response.body\n doc = Hpricot.XML(response.body)\n result = EAAL::Result.new(scope.capitalize + name, doc)\n else\n raise EAAL::Exception::HTTPError.new(response.status), \"An HTTP Error occurred, body: #{response.body}\"\n end\n end\n\n EAAL.cache.save(self.keyid, self.vcode, scope,name,opts, response.body)\n xml = response.body\n end\n\n if xml\n doc = Hpricot.XML(xml)\n result = EAAL::Result.new(scope.capitalize + name, doc)\n else \n result = nil\n end\n end", "def do_request(command, params)\n url = request_url(command, params)\n @xml_getter.fetch url\n end", "def process_request\n @build_xml = build_xml\n pickup_serv_log('Final XML Request : ' + @build_xml.to_s)\n api_url_srv = api_url + \"/pickup\"\n pickup_serv_log('URL for API : ' + api_url_srv.to_s)\n api_response = self.class.post(api_url_srv, :body => build_xml)\n pickup_serv_log('API Response : ' + api_response.to_s)\n puts api_response if @debug\n response = parse_response(api_response)\n if success?(response)\n pickup_serv_log('Successfully Done : ' + response.to_s)\n success_response(api_response, response)\n else\n failure_response(api_response, response)\n end\n end", "def request_body(xml); xml; end", "def send_api_request(method, params={}, data=nil)\n url = get_url(method, params)\n\n @http_response = send_request(url, data)\n return { } if @http_response.body.empty?\n\n # 'Hashify' the XML\n @xml_response = @http_response.body\n hash = Hash.from_xml(@xml_response)\n\n # simple validation of the xml body\n unless hash.has_key?(:returncode)\n raise BigBlueButtonException.new(\"Invalid response body. Is the API URL correct? \\\"#{@url}\\\", version #{@version}\")\n end\n\n # default cleanup in the response\n hash = BigBlueButtonFormatter.new(hash).default_formatting\n\n # if the return code is an error generates an exception\n unless hash[:returncode]\n exception = BigBlueButtonException.new(hash[:message])\n exception.key = hash.has_key?(:messageKey) ? hash[:messageKey] : \"\"\n raise exception\n end\n\n hash\n end", "def http_request(url, parameters = {})\n params = params_to_string(parameters)\n url << '?'+params unless params !~ /\\S/\n \n return Net::HTTP.get_response(::URI.parse(url)).body\n \n fname = \"#{MD5.md5(params)}.mql\"\n open(fname,\"w\") do |f|\n f << response\n end\n Ken.logger.info(\"Wrote response to #{fname}\")\n end", "def send_xml_api_request(markup)\n result =\n if login_type == \"legacy\"\n send_request(markup, \"#{self.api_url}/XMLAPI#{@session_id}\", 'api')\n else\n send_oauth_request(markup, \"#{self.api_url}/XMLAPI\", 'api')\n end\n\n doc = Hash.from_xml(REXML::Document.new(result).to_s)\n\n return doc if silverpop_successful?(doc)\n\n raise_error(doc)\n end", "def get_xml(url, options = {})\n\t\t\t\n\t\t\t# better way of doing this?\n\t\t\t# Map custom keys to the HTTP request values\n\t\t\treqs = {\n\t\t\t\t:character_name => 'n',\n\t\t\t\t:realm => 'r',\n\t\t\t\t:search => 'searchQuery',\n\t\t\t\t:type => 'searchType',\n\t\t\t\t:guild_name => 'n',\n\t\t\t\t:item_id => 'i',\n\t\t\t\t:team_size => 'ts',\n\t\t\t\t:team_name => 't',\n\t\t\t\t:group => 'group'\n\t\t\t}\n\t\t\t\n\t\t\t\n\t\t\tparams = []\n\t\t\toptions.each do |key, value|\n\t\t\t\tparams << \"#{reqs[key]}=#{u(value)}\" if reqs[key]\n\t\t\tend\n\t\t\t\n\t\t\tquery = '?' + params.join('&') if params.size > 0\n\t\t\t\n\t\t\tbase = self.base_url(options[:locale], options)\n\t\t\tfull_query = base + url + query\n\t\t\t\n\t\t\tputs full_query if options[:debug]\n\t\t\t\n\t\t\tif options[:caching]\n\t\t\t\tresponse = get_cache(full_query, options)\n\t\t\telse\n\t\t\t\tresponse = http_request(full_query, options)\n\t\t\tend\n\t\t\t\t\t\t\n\t\t\tdoc = Hpricot.XML(response)\n\t\t\terrors = doc.search(\"*[@errCode]\")\n\t\t\tif errors.size > 0\nbegin\n\t\t\t\terrors.each do |error|\n\t\t\t\t\traise Wowr::Exceptions::raise_me(error[:errCode], options)\n\t\t\t\tend\nrescue\nend\n\t\t\telsif (doc%'page').nil?\n\t\t\t\traise Wowr::Exceptions::EmptyPage\n\t\t\telse\n\t\t\t\treturn (doc%'page')\n\t\t\tend\n\t\tend", "def convert_document_csv_to_xlsx_with_http_info(input_file, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ConvertDocumentApi.convert_document_csv_to_xlsx ...'\n end\n # verify the required parameter 'input_file' is set\n if @api_client.config.client_side_validation && input_file.nil?\n fail ArgumentError, \"Missing the required parameter 'input_file' when calling ConvertDocumentApi.convert_document_csv_to_xlsx\"\n end\n # resource path\n local_var_path = '/convert/csv/to/xlsx'\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(['multipart/form-data'])\n\n # form parameters\n form_params = {}\n form_params['inputFile'] = input_file\n\n # http body (model)\n post_body = nil\n auth_names = ['Apikey']\n data, status_code, headers = @api_client.call_api(:POST, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'String')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ConvertDocumentApi#convert_document_csv_to_xlsx\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def post_xml(url, ls_data)\n uri = URI.parse(url)\n request = Net::HTTP::Post.new(uri.request_uri, HEADER_XML)\n request.body = ls_data\n request.basic_auth(@nsx_user, @nsx_password)\n response = Net::HTTP.start(uri.host, uri.port, :use_ssl => true,\n :verify_mode => OpenSSL::SSL::VERIFY_NONE) do |https|\n https.request(request)\n end\n return response.body if check_response(response, 201)\n end", "def convert_image_image_format_convert_with_http_info(format1, format2, input_file, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ConvertImageApi.convert_image_image_format_convert ...'\n end\n # verify the required parameter 'format1' is set\n if @api_client.config.client_side_validation && format1.nil?\n fail ArgumentError, \"Missing the required parameter 'format1' when calling ConvertImageApi.convert_image_image_format_convert\"\n end\n # verify the required parameter 'format2' is set\n if @api_client.config.client_side_validation && format2.nil?\n fail ArgumentError, \"Missing the required parameter 'format2' when calling ConvertImageApi.convert_image_image_format_convert\"\n end\n # verify the required parameter 'input_file' is set\n if @api_client.config.client_side_validation && input_file.nil?\n fail ArgumentError, \"Missing the required parameter 'input_file' when calling ConvertImageApi.convert_image_image_format_convert\"\n end\n # resource path\n local_var_path = '/convert/image/{format1}/to/{format2}'.sub('{' + 'format1' + '}', format1.to_s).sub('{' + 'format2' + '}', format2.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(['multipart/form-data'])\n\n # form parameters\n form_params = {}\n form_params['inputFile'] = input_file\n\n # http body (model)\n post_body = nil\n auth_names = ['Apikey']\n data, status_code, headers = @api_client.call_api(:POST, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'String')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ConvertImageApi#convert_image_image_format_convert\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def request(params = {})\n params.merge!(default_params)\n\n uri = URI.parse(base_uri)\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = true\n\n encoded = URI.encode_www_form(params)\n path = [uri.path, encoded].join(\"?\")\n\n request = Net::HTTP::Get.new(path)\n\n STDERR.puts path if debug?\n\n response = http.request(request) \n\n case response.code.to_i\n when 200\n STDERR.puts response.body if debug?\n\n response = MultiXml.parse(response.body)\n if response[\"interface_response\"][\"ErrCount\"].to_i == 0\n return response\n else\n raise InterfaceError, response[\"interface_response\"][\"errors\"].values.join(\", \")\n end\n end\n end", "def convert_document_autodetect_get_info_with_http_info(input_file, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ConvertDocumentApi.convert_document_autodetect_get_info ...'\n end\n # verify the required parameter 'input_file' is set\n if @api_client.config.client_side_validation && input_file.nil?\n fail ArgumentError, \"Missing the required parameter 'input_file' when calling ConvertDocumentApi.convert_document_autodetect_get_info\"\n end\n # resource path\n local_var_path = '/convert/autodetect/get-info'\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', 'text/json', 'application/xml', 'text/xml'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['multipart/form-data'])\n\n # form parameters\n form_params = {}\n form_params['inputFile'] = input_file\n\n # http body (model)\n post_body = nil\n auth_names = ['Apikey']\n data, status_code, headers = @api_client.call_api(:POST, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'AutodetectGetInfoResult')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ConvertDocumentApi#convert_document_autodetect_get_info\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def make_xml_request( opts={} )\n\t\topts = TEST_XML_REQUEST_OPTS.merge( opts )\n\t\theaders = normalize_headers( opts, TEST_XML_HEADERS )\n\t\theaders.delete( 'URI' ) # XML requests don't have one\n\n\t\tMongrel2.log.debug \"XML request, headers = %p, opts = %p\" % [ headers, opts ]\n\n\t\theaderstring = TNetstring.dump( Yajl::Encoder.encode(headers) )\n\t\tbodystring = TNetstring.dump( opts[:body] || \"#{TEST_XML_PATH} />\" )\n\n\t\t# UUID ID PATH SIZE:HEADERS,SIZE:BODY,\n\t\treturn \"%s %d %s %s%s\" % [\n\t\t\topts[:uuid],\n\t\t\topts[:id],\n\t\t\topts[:path],\n\t\t\theaderstring,\n\t\t\tbodystring,\n\t\t]\n\tend", "def xml_http_request?; end", "def download\n # headers for streaming suggested by:\n # https://coderwall.com/p/kad56a/streaming-large-data-responses-with-rails\n # and\n # https://github.com/felixbuenemann/xlsxtream/issues/14\n response.headers.delete(\"Content-Length\") # See one line above\n response.headers['X-Accel-Buffering'] = 'no' # Stop NGINX from buffering\n response.headers['Cache-Control'] = 'no-cache'\n \n # Headers for browser-handling\n response.headers['Content-Type'] = 'application/marcxml+xml'\n response.headers['Content-Disposition'] = \"attachment; filename=#{download_filename('xml')}\" \n \n # Setup Blacklight / Solr params\n params['page'] = 1\n params['rows'] = 100\n # params['fl'] = 'id,marc_display'\n params['source'] = active_source\n\n extra_params = {\n 'fl' => 'id,marc_display',\n 'sort' => 'id asc',\n 'stats' => false,\n 'facet' => false,\n }\n \n # Stream response\n stream = response.stream\n\n begin\n # XML Header - MARC XML collection open tag\n stream.write marcxml_header\n\n total = 0\n hits = params['rows']\n while hits >= params['rows'] && total < 10_000\n # # CLIO-level query\n # # search_engine = blacklight_search(params.to_unsafe_h)\n # # hits = search_engine.documents.count\n # # search_engine = blacklight_search(params.to_unsafe_h)\n # # hits = search_engine.documents.count\n # # total += hits\n # \n # # Blacklight-level query\n # # - doesn't include marc_display\n # # - doesn't allow over-riding 'fl' param\n # # search, documents = search_results(params)\n # # hits = documents.count\n # \n # # unapproved lower-level querying..\n # # builder = search_builder.with(params)\n # # builder.page = 1\n # # builder.rows = 1000\n # # response = repository.search(builder)\n \n # Need to use lower-level \"search_builder\", so that we \n # can override 'fl' param, to include marc_display\n query = search_builder.with(params).merge(extra_params)\n solr_response = repository.search(query)\n \n hits = solr_response.documents.count\n total += hits\n\n solr_response.documents.each do |solr_doc|\n # stream.write solr_doc['marc_display']\n # pretty-print - does this make reporting too slow?\n stream.write solr_doc['marc_display'].\n gsub(/<leader/, \"\\n <leader\").\n gsub(/<controlfield/, \"\\n <controlfield\").\n gsub(/<datafield/, \"\\n <datafield\").\n gsub(/<\\/datafield/, \"\\n </datafield\").\n gsub(/<subfield/, \"\\n <subfield\").\n gsub(/<\\/record/, \"\\n</record\")\n stream.write \"\\n\"\n end\n\n # increment page\n # extra_params['page'] = (extra_params['page'].to_i + 1).to_s\n params['page'] = (params['page'].to_i + 1).to_s\n end\n\n # close collection tag\n stream.write marcxml_footer\n\n ensure\n stream.close\n end\n \n end", "def hash_xml(xml, params)\n params.each do |key, value|\n xml = xml_key_value(key, value, xml)\n end\n xml\n end", "def build_file(params)\n # proto (required): protocol on connect back\n # hostname (required): hostname to connect to\n # file_type (required): file extension -- e.g. docx\n # hostname (required): connect back host -- this is confusing as it's not used by every combination\n\n oxmls = oxml_file_defaults()\n pl = read_payloads()\n\n if params[\"proto\"] == \"none\"\n ip = params[\"hostname\"]\n else\n # TODO is this correct for all protocols?\n ip = params[\"proto\"]+\"://\"+params[\"hostname\"]\n end\n\n # This takes in a file type and picks the file from the samples.\n input_file = oxmls[params[\"file_type\"]][0]\n if input_file == \"\"\n raise StandardError, \"Error: File could not be found based on file_type\"\n end\n\n nname = \"temp_#{Time.now.to_i}_\"\n ext = params[\"file_type\"]\n rand_file = \"./output/#{nname}_z.#{ext}\"\n # Make a copy of the sample and place it into the rand_file\n FileUtils::copy_file(input_file,rand_file)\n\n if oxmls.include?(params[\"file_type\"])\n fn = string_replace(pl[params[\"payload\"]][0],rand_file,ip,params[\"exfil_file\"])\n elsif params[\"file_type\"] == \"svg\"\n fn = insert_payload_svg(\"./samples/sample.svg\",pl[params[\"payload\"]][0],ip,params[\"exfil_file\"])\n elsif params[\"file_type\"] == \"xml\"\n fn = insert_payload_xml(\"./samples/sample.xml\",pl[params[\"payload\"]][0],ip,params[\"exfil_file\"])\n end\n\n return fn\nend", "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 create\n\n # load file and parameter from POST\n fileObj = params[:file]\n readerName = params[:reader]\n writerName = params[:writer]\n validation = params[:validate]\n showAllTags = false\n showAllTags = true if params[:showAllTags] == 'true'\n forceValid = true\n forceValid = false if params[:forceValid] == 'false'\n requestFormat = 'auto'\n requestFormat = params[:format] if params[:format]\n\n # call the ADIwg metadata translator\n @mdReturn = ADIWG::Mdtranslator.translate(\n file: fileObj, reader: readerName, validate: validation,\n writer: writerName, showAllTags: showAllTags, forceValid: forceValid)\n\n # return content based on:\n # ... response type 'auto' w/o errors - return output in native format\n # ... response type 'auto' w/ errors - return full object in native format\n # ... response type 'xml' - always return full object in XML format\n # ... response type 'json' - always return full object in JSON format\n\n # construct a hash to collect response content\n @responseInfo = {}\n @responseInfo[:success] = true\n @responseInfo[:readerStructureStatus] = 'OK'\n @responseInfo[:readerStructureMessages] = @mdReturn[:readerStructureMessages]\n @responseInfo[:readerValidationStatus] = 'OK'\n @responseInfo[:readerValidationMessages] = @mdReturn[:readerValidationMessages]\n @responseInfo[:readerExecutionStatus] = 'OK'\n @responseInfo[:readerExecutionMessages] = @mdReturn[:readerExecutionMessages]\n @responseInfo[:writerStatus] = 'OK'\n @responseInfo[:writerMessages] = @mdReturn[:writerMessages]\n @responseInfo[:readerRequested] = @mdReturn[:readerRequested]\n @responseInfo[:readerVersionRequested] = @mdReturn[:readerVersionRequested]\n @responseInfo[:readerVersionUsed] = @mdReturn[:readerVersionUsed]\n @responseInfo[:writerRequested] = @mdReturn[:writerRequested]\n @responseInfo[:writerVersion] = @mdReturn[:writerVersion]\n @responseInfo[:writerOutputFormat] = @mdReturn[:writerOutputFormat]\n @responseInfo[:writerForceValid] = @mdReturn[:writerForceValid]\n @responseInfo[:writerShowTags] = @mdReturn[:writerShowTags]\n @responseInfo[:writerCSSlink] = @mdReturn[:writerCSSlink]\n @responseInfo[:writerMissingIdCount] = @mdReturn[:writerMissingIdCount]\n @responseInfo[:translatorVersion] = @mdReturn[:translatorVersion]\n @responseInfo[:writerOutput] = @mdReturn[:writerOutput]\n\n # set messages Status (ERROR, WARNING, NOTICE, none)\n aSMess = @responseInfo[:readerStructureMessages]\n aVMess = @responseInfo[:readerValidationMessages]\n aEMess = @responseInfo[:readerExecutionMessages]\n aWMess = @responseInfo[:writerMessages]\n\n status = 'OK'\n status = 'NOTICE' if aSMess.any? {|s| s.include?('NOTICE')}\n status = 'WARNING' if aSMess.any? {|s| s.include?('WARNING')}\n status = 'ERROR' if aSMess.any? {|s| s.include?('ERROR')}\n @responseInfo[:readerStructureStatus] = status\n\n status = 'OK'\n status = 'NOTICE' if aVMess.any? {|s| s.include?('NOTICE')}\n status = 'WARNING' if aVMess.any? {|s| s.include?('WARNING')}\n status = 'ERROR' if aVMess.any? {|s| s.include?('ERROR')}\n @responseInfo[:readerValidationStatus] = status\n\n status = 'OK'\n status = 'NOTICE' if aEMess.any? {|s| s.include?('NOTICE')}\n status = 'WARNING' if aEMess.any? {|s| s.include?('WARNING')}\n status = 'ERROR' if aEMess.any? {|s| s.include?('ERROR')}\n @responseInfo[:readerExecutionStatus] = status\n\n status = 'OK'\n status = 'NOTICE' if aWMess.any? {|s| s.include?('NOTICE')}\n status = 'WARNING' if aWMess.any? {|s| s.include?('WARNING')}\n status = 'ERROR' if aWMess.any? {|s| s.include?('ERROR')}\n @responseInfo[:writerStatus] = status\n\n # check for errors returned by parser, validator, reader, and writer\n @responseInfo[:success] = false unless @mdReturn[:readerStructurePass]\n @responseInfo[:success] = false unless @mdReturn[:readerValidationPass]\n @responseInfo[:success] = false unless @mdReturn[:readerExecutionPass]\n @responseInfo[:success] = false unless @mdReturn[:writerPass]\n\n # the json schema validator returns expanded folder/file path names to gem\n # these path names may pose a security risk and are removed from the messages\n # find gem path and removed it from messages\n unless @responseInfo[:readerValidationStatus] == 'OK'\n each_recur(@responseInfo[:readerValidationMessages]) do |elem, idx, arr|\n arr[idx]=sanitize(elem)\n end\n end\n\n\n # NOTE: to format for expected v2 response\n responseV2 = {\n success: @responseInfo[:success],\n messages: {\n :readerRequested => @responseInfo[:readerRequested],\n :readerVersionRequested => @responseInfo[:readerVersionRequested],\n :readerVersionUsed =>@responseInfo[:readerVersionUsed],\n :readerStructurePass =>@responseInfo[:readerStructureStatus] != 'ERROR',\n :readerStructureMessages =>@responseInfo[:readerStructureMessages],\n :readerValidationLevel =>@responseInfo[:readerValidationLevel],\n :readerValidationPass =>@responseInfo[:readerValidationStatus] != 'ERROR',\n :readerValidationMessages =>@responseInfo[:readerValidationMessages],\n readerExecutionPass: @responseInfo[:readerExecutionStatus] != 'ERROR',\n readerExecutionMessages: @responseInfo[:readerExecutionMessages],\n writerRequested: @responseInfo[:writerRequested],\n writerVersion: @responseInfo[:writerVersion],\n writerPass: @responseInfo[:writerStatus] != 'ERROR',\n writerMessages: @responseInfo[:writerMessages],\n writerOutputFormat: @responseInfo[:writerOutputFormat],\n writerOutput: @responseInfo[:writerOutput],\n writerForceValid: @responseInfo[:writerForceValid],\n writerShowTags: @responseInfo[:writerShowTags],\n writerCSSlink: @responseInfo[:writerCSSlink],\n writerMissingIdCount: @responseInfo[:writerMissingIdCount],\n translatorVersion: @responseInfo[:translatorVersion] },\n data: @responseInfo[:writerOutput] }\n\n\n # build lightly formatted string for 'plain' text rendering\n sPlain = format_plain(responseV2).sub(\"messages:\\n\",'')\n\n #leave messages but don't replicate writerOutput\n responseV2[:messages].delete(:writerOutput)\n\n if requestFormat == 'auto'\n if @responseInfo[:success]\n render xml: @responseInfo[:writerOutput] if @responseInfo[:writerOutputFormat] == 'xml'\n render json: @responseInfo[:writerOutput] if @responseInfo[:writerOutputFormat] == 'json'\n render inline: @responseInfo[:writerOutput] if @responseInfo[:writerOutputFormat] == 'html'\n unless %w(xml json html).include?(@responseInfo[:writerOutputFormat])\n if writerName == ''\n render plain: sPlain\n else\n render plain: 'Requested format ' + @responseInfo[:writerOutputFormat] + ' not handled.'\n end\n end\n else\n render plain: sPlain\n end\n end\n\n render plain: sPlain if requestFormat == 'plain'\n render json: responseV2 if requestFormat == 'json'\n render xml: responseV2 if requestFormat == 'xml'\n end", "def convert_document_xlsx_to_csv_with_http_info(input_file, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ConvertDocumentApi.convert_document_xlsx_to_csv ...'\n end\n # verify the required parameter 'input_file' is set\n if @api_client.config.client_side_validation && input_file.nil?\n fail ArgumentError, \"Missing the required parameter 'input_file' when calling ConvertDocumentApi.convert_document_xlsx_to_csv\"\n end\n # resource path\n local_var_path = '/convert/xlsx/to/csv'\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(['multipart/form-data'])\n header_params[:'outputEncoding'] = opts[:'output_encoding'] if !opts[:'output_encoding'].nil?\n\n # form parameters\n form_params = {}\n form_params['inputFile'] = input_file\n\n # http body (model)\n post_body = nil\n auth_names = ['Apikey']\n data, status_code, headers = @api_client.call_api(:POST, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'String')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ConvertDocumentApi#convert_document_xlsx_to_csv\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def process_request(legacy_xml_or_hash)\n c.soap(:ProcessRequest, { \n :ProcessRequest => { \n :_attributes => { :xmlns => 'http://wildwestdomains.com/webservices/' },\n :sRequestXML => \n c.class.escape_html(\n \"<wapi clTRID='#{GoDaddyReseller::API.next_uid[0..50]}'\" + \n \" account='#{user_id}' pwd='#{password}'>\" +\n \"#{legacy_xml_or_hash.is_a?(Hash) ? c.class.xml_encode_hash(legacy_xml_or_hash) : legacy_xml_or_hash.to_s}\" +\n \"</wapi>\"\n )\n }\n }\n )\n end", "def query(action, hash = {})\n # uri = URI.parse(\"https://130.59.10.31\")\n # http = Net::HTTP.new(uri.host, uri.port)\n # http.use_ssl = true\n # http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n #\n # request = Net::HTTP::Get.new(uri.request_uri)\n #\n # response = http.request(request)\n # response.body\n # response.status\n # response[\"header-here\"] # All headers are lowercase\n uri = URI.parse(@url + \"/api/xml?action=#{action}\")\n hash.each_pair do |key, val|\n if val\n if key == \"filter\" or key == \"sort\"\n uri.query += val.query\n else\n uri.query += \"&\" + key + \"=\" + CGI::escape(\"#{val}\")\n end\n end\n end\n http = Net::HTTP.new(uri.host, uri.port)\n if uri.scheme == \"https\"\n http.use_ssl=true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n end\n request = Net::HTTP::Get.new(uri.request_uri)\n # logger = Logger.new('log/development.log')\n # logger.info(url.path + \"?\" + url.query)\n if @sessionid\n request.add_field(\"Cookie\", \"BREEZESESSION=\"+@sessionid)\n end\n puts \"ACS query - request: \" + request.path\n response = http.request(request)\n puts \"ACS query - response: \" + response.body.inspect\n return response\n end", "def getXMLTicket(path)\n resp2 = @@conn.get do |req|\n req.url path\n req.headers['Authorization'] = 'Basic aHIuc2VsbGVydEBnbWFpbC5jb206c2VzMTEy' #@TODO make this a param\n req.headers['Content-Type'] = 'application/xml'\n end\n # puts \"Responce : \" + resp2['body'].inspect\n # puts \"Responce2 : \" + resp2.body.to_s()\n \n return resp2.body.to_s()\n end", "def parse_to_xml\n raise_if_error\n response_xml\n end", "def convert_local_file input_file,output_filename,output_format\n begin\n \n if input_file == \"\"\n raise(\"input file not specified\")\n end \n \n if output_filename == \"\"\n raise(\"output file not specified\")\n end\n \n if output_format == \"\"\n raise(\"output format not specified\")\n end\n \n str_uri = $productURI + \"/words/convert?format=\" + output_format\n str_signed_uri = Common::Utils.sign(str_uri)\n \n response_stream = Common::Utils.uploadFileBinary(input_file, str_signed_uri) \n \n valid_output = Common::Utils.validate_output(response_stream)\n \n if valid_output == \"\"\n \n if output_format == \"html\"\n saveformat = \"zip\"\n else\n saveformat = output_format\n end\n \n if output_filename == \"\"\n output_filename = Utils::get_filename(input_file) + \".\" + saveformat\n end\n \n output_path = $OutPutLocation + output_filename\n Common::Utils.saveFile(response_stream,output_path)\n return \"\"\n else\n return valid_output\n end\n \n rescue Exception=>e\n print e \n end \n end", "def send_get_request endpoint, params={}, api_key=nil, ssl=false #https://api.vpsmatrix.net/uploads/get_file_list\n uri = URI.parse(endpoint)\n uri.query = URI.encode_www_form(params)\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = true if ssl\n req = Net::HTTP::Get.new(uri.path)\n req['authorization'] = \"Token token=#{api_key}\" if api_key\n http.request(req)\n end", "def request(method, path, parameters = {}, second_try = false)\n puts convert_body(parameters)\n response = send(method, path, convert_body(parameters), \"Content-Type\" => content_type) \n\n if response.code.to_i / 100 == 2\n result = Hash.from_xml(response.body)\n elsif response.code == \"302\" && !second_try\n connect!(@url, !@use_ssl)\n request(path, parameters, true)\n else\n raise \"#{response.message} (#{response.code})\"\n end\n end", "def send_request( xml )\n write( xml )\n read\n end", "def convert_document_docx_to_html_with_http_info(input_file, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ConvertDocumentApi.convert_document_docx_to_html ...'\n end\n # verify the required parameter 'input_file' is set\n if @api_client.config.client_side_validation && input_file.nil?\n fail ArgumentError, \"Missing the required parameter 'input_file' when calling ConvertDocumentApi.convert_document_docx_to_html\"\n end\n # resource path\n local_var_path = '/convert/docx/to/html'\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(['multipart/form-data'])\n\n # form parameters\n form_params = {}\n form_params['inputFile'] = input_file\n\n # http body (model)\n post_body = nil\n auth_names = ['Apikey']\n data, status_code, headers = @api_client.call_api(:POST, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'String')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ConvertDocumentApi#convert_document_docx_to_html\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def hex2_bin()\n return MicrosoftGraph::Drives::Item::Items::Item::Workbook::Functions::Hex2Bin::Hex2BinRequestBuilder.new(@path_parameters, @request_adapter)\n end", "def convert_document_xlsx_to_txt_with_http_info(input_file, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ConvertDocumentApi.convert_document_xlsx_to_txt ...'\n end\n # verify the required parameter 'input_file' is set\n if @api_client.config.client_side_validation && input_file.nil?\n fail ArgumentError, \"Missing the required parameter 'input_file' when calling ConvertDocumentApi.convert_document_xlsx_to_txt\"\n end\n # resource path\n local_var_path = '/convert/xlsx/to/txt'\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', 'text/json', 'application/xml', 'text/xml'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['multipart/form-data'])\n\n # form parameters\n form_params = {}\n form_params['inputFile'] = input_file\n\n # http body (model)\n post_body = nil\n auth_names = ['Apikey']\n data, status_code, headers = @api_client.call_api(:POST, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'TextConversionResult')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ConvertDocumentApi#convert_document_xlsx_to_txt\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def convert_document_autodetect_to_jpg_with_http_info(input_file, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ConvertDocumentApi.convert_document_autodetect_to_jpg ...'\n end\n # verify the required parameter 'input_file' is set\n if @api_client.config.client_side_validation && input_file.nil?\n fail ArgumentError, \"Missing the required parameter 'input_file' when calling ConvertDocumentApi.convert_document_autodetect_to_jpg\"\n end\n # resource path\n local_var_path = '/convert/autodetect/to/jpg'\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', 'text/json', 'application/xml', 'text/xml'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['multipart/form-data'])\n header_params[:'quality'] = opts[:'quality'] if !opts[:'quality'].nil?\n\n # form parameters\n form_params = {}\n form_params['inputFile'] = input_file\n\n # http body (model)\n post_body = nil\n auth_names = ['Apikey']\n data, status_code, headers = @api_client.call_api(:POST, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'AutodetectToJpgResult')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ConvertDocumentApi#convert_document_autodetect_to_jpg\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def parseXML()\n @transform = PoortegoTransform.new('ParsedResponse')\n result_href = XmlSimple.xml_in(@xml_response.to_s)\n \n unless (result_href.has_key?('ResponseData'))\n return\n end\n \n (result_href['ResponseData'])[0].each do |response_key, response_val|\n if (response_key == 'Entities')\n parse_entities_hash(response_val)\n elsif (response_key == 'Links')\n parse_links_hash(response_val)\n else\n puts \"Invalid ResponseData key\"\n end\n end\n \n (result_href['ResponseMessages'])[0].each do |message_key, message_val|\n if (message_key == 'Message')\n parse_message_hash(message_val)\n else\n puts \"Invalid ResponseMessages key\"\n end\n end\n \n end", "def initialize(params)\n @result = params[:result]\n @user_id = params[:userid]\n @post = build_xml( params[:result] )\n end", "def convert_document_eml_to_jpg_with_http_info(input_file, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ConvertDocumentApi.convert_document_eml_to_jpg ...'\n end\n # verify the required parameter 'input_file' is set\n if @api_client.config.client_side_validation && input_file.nil?\n fail ArgumentError, \"Missing the required parameter 'input_file' when calling ConvertDocumentApi.convert_document_eml_to_jpg\"\n end\n # resource path\n local_var_path = '/convert/eml/to/jpg'\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', 'text/json', 'application/xml', 'text/xml'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['multipart/form-data'])\n header_params[:'quality'] = opts[:'quality'] if !opts[:'quality'].nil?\n\n # form parameters\n form_params = {}\n form_params['inputFile'] = input_file\n\n # http body (model)\n post_body = nil\n auth_names = ['Apikey']\n data, status_code, headers = @api_client.call_api(:POST, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'EmlToJpgResult')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ConvertDocumentApi#convert_document_eml_to_jpg\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def create\n respond_to do |format|\n format.html do\n @xml_sample = XmlSample.new(params[:xml_sample])\n if @xml_sample.save\n redirect_to @xml_sample, notice: 'Xml sample was successfully created.'\n else\n render action: \"new\"\n end\n end\n format.xml do\n rexml = REXML::Document.new(params[\"xml\"])\n attr = Hash.from_xml(rexml.to_s)\n @xml_sample = XmlSample.new(attr[\"xmlsample\"])\n if @xml_sample.save\n xml = {msg: \"complete\", status: \"OK\"}.to_xml\n else\n xml = {msg: \"failed\", status: \"NG\"}.to_xml\n end\n return render xml: xml\n end\n end\n end", "def convert_document_docx_to_jpg_with_http_info(input_file, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ConvertDocumentApi.convert_document_docx_to_jpg ...'\n end\n # verify the required parameter 'input_file' is set\n if @api_client.config.client_side_validation && input_file.nil?\n fail ArgumentError, \"Missing the required parameter 'input_file' when calling ConvertDocumentApi.convert_document_docx_to_jpg\"\n end\n # resource path\n local_var_path = '/convert/docx/to/jpg'\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', 'text/json', 'application/xml', 'text/xml'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['multipart/form-data'])\n header_params[:'quality'] = opts[:'quality'] if !opts[:'quality'].nil?\n\n # form parameters\n form_params = {}\n form_params['inputFile'] = input_file\n\n # http body (model)\n post_body = nil\n auth_names = ['Apikey']\n data, status_code, headers = @api_client.call_api(:POST, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'DocxToJpgResult')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ConvertDocumentApi#convert_document_docx_to_jpg\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def execute_call_xml(url)\n parse_xml_response(execute_call_plain(url), url)\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 convert( content:, action:, language:'en' )\n params = {}\n response = nil\n with_tempfile(content) do |io|\n params[:file] = io\n params[:action] = action\n params[:language] = language if language\n params[:backtrace] = @backtrace if @backtrace\n response = send_request :post, \"convert\", params, :binary\n end\n response\n end", "def convert_document_with_http_info(name, file, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: DiagramApi.convert_document ...\"\n end\n # verify the required parameter 'name' is set\n if @api_client.config.client_side_validation && name.nil?\n fail ArgumentError, \"Missing the required parameter 'name' when calling DiagramApi.convert_document\"\n end\n # verify the required parameter 'file' is set\n if @api_client.config.client_side_validation && file.nil?\n fail ArgumentError, \"Missing the required parameter 'file' when calling DiagramApi.convert_document\"\n end\n # resource path\n local_var_path = \"/diagram/{name}/convert\".sub('{' + 'name' + '}', name.to_s)\n\n # query parameters\n query_params = {}\n query_params[:'sourceFilename'] = opts[:'source_filename'] if !opts[:'source_filename'].nil?\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['multipart/form-data'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['multipart/form-data'])\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/octet-stream'])\n\n # form parameters\n form_params = {}\n #form_params[\"File\"] = file\n\n # http body (model)\n post_body = file\n auth_names = ['JWT']\n data, status_code, headers = @api_client.call_api(:PUT, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'File')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: DiagramApi#convert_document\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def get_page_convert_to_tiff_with_http_info(name, page_number, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: PdfApi.get_page_convert_to_tiff ...\"\n end\n # verify the required parameter 'name' is set\n if @api_client.config.client_side_validation && name.nil?\n fail ArgumentError, \"Missing the required parameter 'name' when calling PdfApi.get_page_convert_to_tiff\"\n end\n # verify the required parameter 'page_number' is set\n if @api_client.config.client_side_validation && page_number.nil?\n fail ArgumentError, \"Missing the required parameter 'page_number' when calling PdfApi.get_page_convert_to_tiff\"\n end\n # resource path\n local_var_path = \"/pdf/{name}/pages/{pageNumber}/convert/tiff\".sub('{' + 'name' + '}', name.to_s).sub('{' + 'pageNumber' + '}', page_number.to_s)\n\n # query parameters\n query_params = {}\n query_params[:'width'] = opts[:'width'] if !opts[:'width'].nil?\n query_params[:'height'] = opts[:'height'] if !opts[:'height'].nil?\n query_params[:'folder'] = opts[:'folder'] if !opts[:'folder'].nil?\n query_params[:'storage'] = opts[:'storage'] if !opts[:'storage'].nil?\n query_params[:'password'] = opts[:'password'] if !opts[:'password'].nil?\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['multipart/form-data'])\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 # Fix header in file\n post_body = nil\n\n # http body (model)\n # Fix header in file\n # post_body = nil\n auth_names = ['JWT']\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 => 'File')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: PdfApi#get_page_convert_to_tiff\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def send_request(method, options = {}, http_method = :get, endpoint = REST_ENDPOINT)\n options.merge!(:api_key => @api_key, :method => method)\n sign_request(options)\n \n rsp = request_over_http(options, http_method, endpoint)\n \n rsp = '<rsp stat=\"ok\"></rsp>' if rsp == \"\"\n xm = XmlMagic.new(rsp)\n \n if xm[:stat] == 'ok'\n xm\n else\n raise Flickr::Errors.error_for(xm.err[:code].to_i, xm.err[:msg])\n end\n end", "def convert_document_docx_to_png_with_http_info(input_file, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ConvertDocumentApi.convert_document_docx_to_png ...'\n end\n # verify the required parameter 'input_file' is set\n if @api_client.config.client_side_validation && input_file.nil?\n fail ArgumentError, \"Missing the required parameter 'input_file' when calling ConvertDocumentApi.convert_document_docx_to_png\"\n end\n # resource path\n local_var_path = '/convert/docx/to/png'\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', 'text/json', 'application/xml', 'text/xml'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['multipart/form-data'])\n\n # form parameters\n form_params = {}\n form_params['inputFile'] = input_file\n\n # http body (model)\n post_body = nil\n auth_names = ['Apikey']\n data, status_code, headers = @api_client.call_api(:POST, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'DocxToPngResult')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ConvertDocumentApi#convert_document_docx_to_png\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def response\n connection.send(request_method) do |req|\n req.url path\n req.headers['LicenseID'] = client.license_id\n req.headers['Host'] = client.host\n req.headers['Connection'] = 'Keep-Alive'\n req.headers['Expect'] = '100-continue'\n req.headers['Content-Type'] = 'text/xml'\n req.body = body\n end\n end", "def convert_document_doc_to_docx_with_http_info(input_file, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ConvertDocumentApi.convert_document_doc_to_docx ...'\n end\n # verify the required parameter 'input_file' is set\n if @api_client.config.client_side_validation && input_file.nil?\n fail ArgumentError, \"Missing the required parameter 'input_file' when calling ConvertDocumentApi.convert_document_doc_to_docx\"\n end\n # resource path\n local_var_path = '/convert/doc/to/docx'\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(['multipart/form-data'])\n\n # form parameters\n form_params = {}\n form_params['inputFile'] = input_file\n\n # http body (model)\n post_body = nil\n auth_names = ['Apikey']\n data, status_code, headers = @api_client.call_api(:POST, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'String')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ConvertDocumentApi#convert_document_doc_to_docx\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def get_page_convert_to_bmp_with_http_info(name, page_number, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: PdfApi.get_page_convert_to_bmp ...\"\n end\n # verify the required parameter 'name' is set\n if @api_client.config.client_side_validation && name.nil?\n fail ArgumentError, \"Missing the required parameter 'name' when calling PdfApi.get_page_convert_to_bmp\"\n end\n # verify the required parameter 'page_number' is set\n if @api_client.config.client_side_validation && page_number.nil?\n fail ArgumentError, \"Missing the required parameter 'page_number' when calling PdfApi.get_page_convert_to_bmp\"\n end\n # resource path\n local_var_path = \"/pdf/{name}/pages/{pageNumber}/convert/bmp\".sub('{' + 'name' + '}', name.to_s).sub('{' + 'pageNumber' + '}', page_number.to_s)\n\n # query parameters\n query_params = {}\n query_params[:'width'] = opts[:'width'] if !opts[:'width'].nil?\n query_params[:'height'] = opts[:'height'] if !opts[:'height'].nil?\n query_params[:'folder'] = opts[:'folder'] if !opts[:'folder'].nil?\n query_params[:'storage'] = opts[:'storage'] if !opts[:'storage'].nil?\n query_params[:'password'] = opts[:'password'] if !opts[:'password'].nil?\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['multipart/form-data'])\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 # Fix header in file\n post_body = nil\n\n # http body (model)\n # Fix header in file\n # post_body = nil\n auth_names = ['JWT']\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 => 'File')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: PdfApi#get_page_convert_to_bmp\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def hex2_dec()\n return MicrosoftGraph::Drives::Item::Items::Item::Workbook::Functions::Hex2Dec::Hex2DecRequestBuilder.new(@path_parameters, @request_adapter)\n end", "def AxeDownload(download)\n uri = URI('https://axeweb.intel.com/axe/api/testlist/295/latest/combined')\n puts uri\n req = Net::HTTP::Get.new(uri)\n req.basic_auth 'autoclient', 'gr@ph1c$'\n \n if download\n print \"#{Time.now.strftime(\"%l:%M:%S %p\")} - Start download\\n\"\n res = Net::HTTP.start(uri.hostname, uri.port, :use_ssl => true, :verify_mode => OpenSSL::SSL::VERIFY_NONE) {|http|\n http.request(req)\n }\n #puts res.body\n \n unless res.kind_of? Net::HTTPSuccess\n puts \"Error downloading results from Axe\"\n exit(9)\n end\n open('result.json', 'wb') do |fileAXE|\n fileAXE << res.body\n end\n print \"#{Time.now.strftime(\"%l:%M:%S %p\")} - End download\\n\"\n end\nend", "def fetch(xml, options = {})\n options = {\n type: String,\n downcase: false,\n symbolize: false,\n strip: false,\n squeeze: false,\n squeeze_lines: false,\n rm_specials: false,\n whitespace: false,\n get_text: false,\n to_i: false,\n to_html: false,\n to_bool: false,\n children: false,\n to_dec: false,\n to_f: false,\n underscore: false\n }.update(options)\n options[:symbolize] = options[:to_sym] if options[:to_sym]\n # Check for incompatible options\n xml_orig = xml\n numeric_methods = [:to_i, :to_f, :to_dec]\n if options[:get_text] == true && options[:to_html] == true\n fail 'Cannot use :get_text and :to_html options at the same time, exiting...'\n end\n if options[:symbolize] == true\n fail 'Cannot convert to a number of any type and symbolize at the same time' if numeric_methods.reject { |arg| options[arg] == true }.size < 3\n end\n fail 'Cannot select multiple numeric conversion args at the same time' if numeric_methods.reject { |arg| options[arg] == true }.size < 2\n if xml.nil?\n Origen.log.debug 'XML data is nil!'\n return nil\n end\n xml = xml.text if options[:get_text] == true\n # Sometimes XML snippets get sent as nodes or as Strings\n # Must skip this code if a String as it is designed to change\n # the XML node into a string\n unless xml.is_a? String\n if options[:to_html] == true\n if xml.children\n # If there are children to this XMl node then grab the content there\n if xml.children.empty? || options[:children] == false\n xml = xml.to_html\n else\n xml = xml.children.to_html\n end\n end\n end\n end\n unless xml.is_a? options[:type]\n Origen.log.debug \"XML data is not of correct type '#{options[:type]}'\"\n Origen.log.debug \"xml is \\n#{xml}\"\n return nil\n end\n if options[:type] == String\n if xml.match(/\\s+/) && options[:whitespace] == false\n Origen.log.debug \"XML data '#{xml}' cannot have white space\"\n return nil\n end\n xml.downcase! if options[:downcase] == true\n xml = xml.underscore if options[:underscore] == true\n xml.strip! if options[:strip] == true\n xml.squeeze!(' ') if options[:squeeze] == true\n xml = xml.squeeze_lines if options[:squeeze_lines] == true\n xml.gsub!(/[^0-9A-Za-z]/, '_') if options[:rm_specials] == true\n if options[:symbolize] == true\n return xml.to_sym\n elsif options[:to_i] == true\n return xml.to_i\n elsif options[:to_dec] == true\n return xml.to_dec\n elsif options[:to_f] == true\n return xml.to_f\n elsif [true, false].include?(xml.to_bool) && options[:to_bool] == true\n # If the string can convert to Boolean then return TrueClass or FalseClass\n return xml.to_bool\n else\n return xml\n end\n else\n # No real examples yet of non-string content\n return xml\n end\n end", "def parse(uri, response, body); end", "def request(method, path, params = nil)\n requestParam = params.nil? ? '' : '&' + params\n response = self.client.send_request(method, path, self.common_param + requestParam)\n REXML::Document.new(response.body)\n end", "def request(path, parameters = {}, second_try = false)\n response = post(path, convert_body(parameters), \"Content-Type\" => content_type)\n \n if DEBUG\n puts \"Reponse:\"\n puts response.body\n end\n \n if response.code.to_i / 100 == 2\n result = XmlSimple.xml_in(response.body, 'keeproot' => true,\n 'contentkey' => '__content__', 'forcecontent' => true)\n typecast_value(result)\n elsif response.code == \"302\" && !second_try\n connect!(@url, !@use_ssl)\n request(path, parameters, true)\n else\n raise \"#{response.message} (#{response.code})\"\n end\n end", "def bin2_hex()\n return MicrosoftGraph::Drives::Item::Items::Item::Workbook::Functions::Bin2Hex::Bin2HexRequestBuilder.new(@path_parameters, @request_adapter)\n end", "def run(host, key, user, port)\n xml = build_command(@action, @object, @params, @cookie)\n\n md5_signature = Digest::MD5.hexdigest(\n Digest::MD5.hexdigest(\n xml + key\n ) + key\n )\n\n headers = {\n 'Content-Type' => 'text/xml',\n 'X-Username' => user,\n 'X-Signature' => md5_signature,\n 'Content-Length' => xml.size.to_s\n }\n\n http = Net::HTTP.new(URI.encode(host), port)\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n #http.ca_file = File.join(File.dirname(__FILE__), \"../..\", \"cacert.pem\")\n res = http.post(URI.encode(\"/\"), xml, headers)\n\n @returned_parameters = parse_response(res.body)\n end", "def prepare(variables, config)\n @format ||= 'xml'\n @failures = []\n @send_count = 0\n @config_delay = config.delay\n @config_use_ssl = config.use_ssl\n\n # 1. Normalize call fields\n @headers ||= []\n @params ||= []\n # Clone config values so we don't mess with them when expanding variables\n config.headers.each do |h|\n value = @headers.detect { |header| header['name'] == h['name'] }\n @headers << { 'name' => h['name'].dup, 'value' => h['value'].dup } unless value\n end if config.headers\n config.params.each do |p|\n value = @params.detect { |header| header['name'] == h['name'] }\n @params << { 'name' => h['name'].dup, 'value' => h['value'].dup } unless value\n end if config.params && request_class.REQUEST_HAS_BODY\n variables.substitute!(@params)\n variables.substitute!(@headers)\n\n # 2. Build URI\n variables.substitute!(@id) if @id\n uri_class = (@use_ssl || @use_ssl.nil? && config.use_ssl) ? URI::HTTPS : URI::HTTP\n port = @port || config.port || uri_class::DEFAULT_PORT\n variables.substitute!(port)\n host = @host || config.host\n variables.substitute!(host)\n @uri = uri_class.build( :host => host, :port => port )\n base_url = \"/#{@base_url || config.base_url}/\".squeeze('/')\n variables.substitute!(base_url)\n path = @path\n unless path\n path = \"#{base_url}#{@resource}\"\n path = \"#{path}/#{@id}\" if @id\n path = \"#{path}.#{@format}\" if @format && !@format.empty? && !@custom\n path = \"#{path}#{@custom.separator}#{@custom.name}\" if @custom\n end\n variables.substitute!(path)\n @uri.merge!(path)\n\n # 3. Build request\n case @operation\n when 'index', 'show' then request_class = Net::HTTP::Get\n when 'create' then request_class = Net::HTTP::Post\n when 'update' then request_class = Net::HTTP::Put\n when 'destroy' then request_class = Net::HTTP::Delete\n else\n if type = (@type || @custom && @custom.type)\n case type\n when 'get' then request_class = Net::HTTP::Get\n when 'post' then request_class = Net::HTTP::Post\n when 'put' then request_class = Net::HTTP::Put\n when 'delete' then request_class = Net::HTTP::Delete\n end\n else\n @failures << \"Missing request type for request on '#{@resource}'.\"\n return\n end\n end\n @request = request_class.new(@uri.to_s)\n username = @username || config.username\n variables.substitute!(username) if username\n password = @password || config.password\n variables.substitute!(password) if password\n if username && password\n @request.basic_auth(username, password)\n end\n form_data = Hash.new\n @headers.each { |header| @request[header['name']] = header['value'] }\n @params.each { |param| form_data[param['name']] = param['value'] }\n @request.set_form_data(form_data) unless form_data.empty?\n Log.request(@request)\n\n # 4. Send request and check response code\n @oks = @valid_codes.map { |r| r.to_s } if @valid_codes\n @oks ||= %w{200 201 202 203 204 205 206}\n end", "def request_url(command, params)\n url = \"http://www.openaustralia.org/api/#{command}?key=#{@key}&output=xml\"\n params.each do |k,v|\n key = CGI::escape(k.to_s)\n value = CGI::escape(v.to_s)\n url += \"&#{key}=#{value}\"\n end\n url\n end", "def process(xml)\n timeout(TIMEOUT) do\n url = URI.parse(webservices_url)\n http = Net::HTTP.new(url.host, url.port)\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n http.start {\n request = Net::HTTP::Post.new(url.to_s)\n request.body = xml\n response = http.request(request)\n response.body\n }\n end\n end", "def convert_document_autodetect_to_thumbnails_advanced_with_http_info(input_file, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ConvertDocumentApi.convert_document_autodetect_to_thumbnails_advanced ...'\n end\n # verify the required parameter 'input_file' is set\n if @api_client.config.client_side_validation && input_file.nil?\n fail ArgumentError, \"Missing the required parameter 'input_file' when calling ConvertDocumentApi.convert_document_autodetect_to_thumbnails_advanced\"\n end\n # resource path\n local_var_path = '/convert/autodetect/to/thumbnail/advanced'\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', 'text/json', 'application/xml', 'text/xml'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['multipart/form-data'])\n header_params[:'pages'] = opts[:'pages'] if !opts[:'pages'].nil?\n header_params[:'maxWidth'] = opts[:'max_width'] if !opts[:'max_width'].nil?\n header_params[:'maxHeight'] = opts[:'max_height'] if !opts[:'max_height'].nil?\n header_params[:'extension'] = opts[:'extension'] if !opts[:'extension'].nil?\n\n # form parameters\n form_params = {}\n form_params['inputFile'] = input_file\n\n # http body (model)\n post_body = nil\n auth_names = ['Apikey']\n data, status_code, headers = @api_client.call_api(:POST, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'AutodetectToThumbnailsResult')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ConvertDocumentApi#convert_document_autodetect_to_thumbnails_advanced\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def convert_document_docx_to_doc_with_http_info(input_file, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ConvertDocumentApi.convert_document_docx_to_doc ...'\n end\n # verify the required parameter 'input_file' is set\n if @api_client.config.client_side_validation && input_file.nil?\n fail ArgumentError, \"Missing the required parameter 'input_file' when calling ConvertDocumentApi.convert_document_docx_to_doc\"\n end\n # resource path\n local_var_path = '/convert/docx/to/doc'\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(['multipart/form-data'])\n\n # form parameters\n form_params = {}\n form_params['inputFile'] = input_file\n\n # http body (model)\n post_body = nil\n auth_names = ['Apikey']\n data, status_code, headers = @api_client.call_api(:POST, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'String')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ConvertDocumentApi#convert_document_docx_to_doc\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def get_binary\n # the base uri for api requests\n _query_builder = Configuration.base_uri.dup\n\n # prepare query string for API call\n _query_builder << '/response/binary'\n\n # validate and preprocess url\n _query_url = APIHelper.clean_url _query_builder\n\n # prepare headers\n _headers = {\n 'user-agent' => 'Stamplay SDK'\n }\n\n # Create the HttpRequest object for the call\n _http_request = @http_client.get _query_url, headers: _headers\n \n # Call the on_before_request callback\n @http_call_back.on_before_request(_http_request) if @http_call_back\n\n # Invoke the API call and get the binary response\n _response = @http_client.execute_as_binary(_http_request)\n\n # Call the on_after_response callback\n @http_call_back.on_after_response(_response) if @http_call_back\n\n # Endpoint error handling using HTTP status codes.\n if _response.status_code == 404\n return nil\n end\n\n # Global error handling using HTTP status codes.\n validate_response(_response)\n\n # Return appropriate response type\n return _response.raw_body\n end", "def execute(xml)\n\t\tmessage = {\n\t\t\ttoken: Afasgem.get_token,\n\t\t\tconnectorType: @connectorname,\n\t\t\tconnectorVersion: 1,\n\t\t\tdataXml: xml\n\t\t}\n\t\tresp = @client.call(:execute, message: message)\n\t\treturn resp\n\tend" ]
[ "0.62352574", "0.5829825", "0.5788444", "0.5745369", "0.57185555", "0.56870383", "0.5615419", "0.55938756", "0.55938756", "0.55931884", "0.55706173", "0.5545379", "0.5537766", "0.55376756", "0.5528486", "0.55256814", "0.55100614", "0.54819185", "0.5456925", "0.54431677", "0.5423308", "0.54024965", "0.5399416", "0.5399416", "0.53831255", "0.53775644", "0.5364375", "0.53517675", "0.5346775", "0.53426576", "0.53259903", "0.53246844", "0.5320759", "0.53110236", "0.5307938", "0.53001523", "0.5295296", "0.52942", "0.52855897", "0.5272796", "0.5269151", "0.52629966", "0.5261076", "0.5259242", "0.5254207", "0.5243513", "0.5237067", "0.5236875", "0.5218549", "0.521738", "0.5217067", "0.5216752", "0.5215609", "0.52145797", "0.5203963", "0.5201801", "0.52007294", "0.5187497", "0.51857424", "0.5181619", "0.5178342", "0.51681817", "0.51575506", "0.51530063", "0.51504827", "0.5148848", "0.5134601", "0.512945", "0.51213956", "0.5113415", "0.5110852", "0.51100045", "0.51087683", "0.5103836", "0.5087692", "0.5085505", "0.50761443", "0.5075055", "0.5071828", "0.5071308", "0.50695604", "0.5057116", "0.5051862", "0.50406736", "0.5036991", "0.50199425", "0.5017609", "0.5015793", "0.50137085", "0.5009581", "0.50041425", "0.4993308", "0.49915767", "0.4991199", "0.498021", "0.49799743", "0.4978063", "0.49778655", "0.4972663", "0.4971667", "0.49673352" ]
0.0
-1
=begin Make an API call to server based on action and parameters.
def api_call(action, xml_data) require 'net/http' require 'uri' current_url = URL; if action != 'get-queue' get_server(@@_target_type_options[@@_target_type]); end uri = URI.parse(current_url+"/"+action) http = Net::HTTP.new(uri.host,uri.port) request=Net::HTTP::Post.new(uri.request_uri); request.set_form_data({ "queue"=> array_to_xml(xml_data,"")}) return http.request(request).body end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def call_api (action, argument = \"\")\n\t\turi_str = BASE_URL + action + @api_key + argument\n\t\turi = URI.parse(uri_str)\n\t\tresponse = Net::HTTP.get_response(uri)\n\t\t#check response\n\t\tresponse_body = JSON.parse(response.body)\n\tend", "def request(action, params = {})\n # Merge the default params with any custom ones\n params = @defaults.merge(params) unless !@defaults\n \n # Exception checks\n if !params[:apikey] || (params[:apikey].is_a?(Array) && params[:apikey].size < 1)\n raise MissingAPIKey\n end\n \n if params[:priority] && !PRIORITY_RANGE.include?(params[:priority])\n raise PriorityOutOfRange\n end\n \n # Raise an exception if we're trying to use more API keys than allowed for this action\n if params[:apikey].is_a?(Array) && ((action == 'verify' && params[:apikey].size > 1) || params[:apikey].size > MAX_API_KEYS)\n raise TooManyAPIKeys\n end\n \n # If there are multiple API Keys in an array, merge them into a comma-delimited string\n if params[:apikey].is_a?(Array)\n params[:apikey] = params[:apikey].collect{|v| v + ',' }.to_s.chop\n end\n \n # Delete any empty key/value sets\n params.delete_if {|key, value| value.nil? }\n \n # Make the request\n req = Typhoeus::Request.new(API_URL + action,\n :user_agent => @user_agent,\n :method => (action == 'add') ? :post : :get,\n :params => (action == 'add') ? params : {:apikey => params[:apikey]}\n )\n \n # Typhoeus request on_complete method adds the HTTP code to an array\n req.on_complete do |response|\n @responses << response.code\n end\n \n # Return the request\n req\n end", "def api action, path, params={}, body=nil\n body ||= params.delete(:BODY)\n\n remote_params = URI.encode_www_form params\n remote_path = debug_path = path.sub('%o', Flow.organization).sub(':organization', Flow.organization)\n remote_path += '?%s' % remote_params unless remote_params.blank?\n\n curl = ['curl -s']\n curl.push '-X %s' % action.to_s.upcase\n curl.push '-u %s:' % api_key\n\n if body\n body = body.to_json unless body.is_a?(Array)\n curl.push '-H \"Content-Type: application/json\"'\n curl.push \"-d '%s'\" % body.gsub(%['], %['\"'\"']) if body\n end\n\n curl.push '\"https://api.flow.io%s\"' % remote_path\n command = curl.join(' ')\n\n puts command if defined?(Rails::Console)\n\n dir = Rails.root.join('log/api')\n Dir.mkdir(dir) unless Dir.exist?(dir)\n debug_file = '%s/%s.bash' % [dir, debug_path.gsub(/[^\\w]+/, '_')]\n File.write debug_file, command + \"\\n\"\n\n data = JSON.load `#{command}`\n\n if data.kind_of?(Hash) && data['code'] == 'generic_error'\n data\n else\n data\n end\n end", "def request(action, params = T.unsafe(nil), header = T.unsafe(nil), query = T.unsafe(nil)); end", "def hit\n action = params[:req]\n name = params[:name] || params[:id]\n render api_not_supported action, name\n end", "def request\n http_segments = @segments.clone\n @params.each do |key,value|\n http_segments[key] = value\n end\n \n # avoid using URI.encode\n query = ''\n http_segments.each do |key, value|\n query += \"&#{key}=#{value}\"\n end\n query = query[1..-1]\n \n uri = URI::HTTP.build(\n :host => HOST,\n :path => @action_path,\n :query => query\n ).to_s\n result = JSON.parse(HTTParty.get(uri).parsed_response)\n Baidumap::Response.new(result,self)\n end", "def do_request(action,parameters)\n request_parameters = { :action => action, :login => @username}.merge(parameters)\n signature = Digest::MD5.hexdigest( to_signature( request_parameters.merge({:password => @password}) ) )\n request_parameters[\"signature\"] = signature\n result = JSON.parse(http_get(\"www.smsforall.ru\",@api,request_parameters.merge(parameters) ))\n end", "def rpc(action, args={})\n company = @company\n username = @user\n password = @password\n url = \"https://#{company}.logicmonitor.com/santaba/rpc/#{action}?\"\n args.each_pair do |key, value|\n url << \"#{key}=#{value}&\"\n end\n url << \"c=#{company}&u=#{username}&p=#{password}\"\n uri = URI(url)\n begin\n http = Net::HTTP.new(uri.host, 443)\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n req = Net::HTTP::Get.new(uri.request_uri)\n response = http.request(req)\n return response.body\n rescue SocketError => se\n puts \"There was an issue communicating with #{url}. Please make sure everything is correct and try again. Exiting\"\n puts se.message\n exit 3\n rescue Error => e\n puts \"There was an issue.\"\n puts e.message\n puts \"Exiting\"\n exit 4\n end\n return nil\nend", "def request(action, value=nil, message=nil, header=nil, parse_response=true)\n #param value : value to be concatenated to action path ex: GET host/path/value\n check_token\n hd = header || @headers\n method = action[:method]\n value = '' if !value\n path = action[:path]+value\n begin\n response = perform(method, path, message, hd)\n return parse_response(response) if parse_response\n return response\n rescue GDataError => e\n STDERR.puts \"Error occurred \", e\n return nil\n rescue Exception => e\n STDERR.puts \"Exception occurred \", e\n return nil\n end\n end", "def send_action(action, params={})\n set_params Hash[action: action].merge params\n @response = http_send_action\n end", "def call_rest(action, url, headers, ref, body = nil)\n begin\n # change url based on if we have a ref or not\n if ref.nil?\n url = url\n else\n url = url + \"/\" + ref\n end\n\n # set params for api call\n params = {\n :method => action,\n :url => url,\n :verify_ssl => false,\n :headers => headers\n }\n\n # generate payload data\n params[:payload] = body if body\n log(:info, \"call_rest: Request URL: #{url}\")\n log(:info, \"call_rest: Request Action: #{action}\")\n log(:info, \"call_rest: Request Headers: #{headers.inspect}\")\n log(:info, \"call_rest: Request Payload: #{params[:payload]}\")\n\n # execute the request\n RestClient::Request.new(params).execute\n rescue => err\n # log and backtrace the error\n log(:error, \"[#{err}]\\n#{err.backtrace.join(\"\\n\")}\")\n log(:error, \"call_rest: #{err}. Returning nil.\")\n return nil\n end\nend", "def api_get(action, data)\n api_request(action, data, 'GET')\n end", "def api_get(action, data)\n api_request(action, data, 'GET')\n end", "def call_api\n @client.build_url\n @client.get\n assign_data\n end", "def exec_api(agent, operation, params)\n begin\n uri = agent.uri\n post = JsonRequest.new(operation, params)\n debug { \"uri: \" + uri }\n debug { post.to_s }\n\n if crypto_enabled? then\n ret = http_post(uri, encrypt_for_agent(agent, post.to_json))\n res = decrypt_from_agent(agent, ret)\n else\n res = http_post_json(uri, post.to_json)\n end\n\n ret = JsonResponse.from_json(res)\n debug { ret.to_s }\n return ret\n\n rescue Curl::Err::CurlError => ex\n ret = JsonResponse.new(\"fail\", ex.message, ex.backtrace)\n debug { ret.to_s }\n return ret\n end\n end", "def call_satellite(action, url, user, password, ref, content_type, body = nil)\n begin\n # change url based on if we have a ref or not\n if ref.nil?\n url = url\n else\n url = url + \"/\" + ref\n end\n\n # set params for api call\n params = {\n :method => action,\n :url => url,\n :user => user,\n :password => password,\n :verify_ssl => false,\n :headers => { :content_type => content_type, :accept => content_type }\n }\n\n # generate payload data\n content_type == :json ? (params[:payload] = JSON.generate(body) if body) : (params[:payload] = body if body)\n log(:info, \"Satellite6 Request: #{url} action: #{action} payload: #{params[:payload]}\")\n\n # execute the request\n RestClient::Request.new(params).execute\n rescue => err\n # log and backtrace the error\n log(:error, \"[#{err}]\\n#{err.backtrace.join(\"\\n\")}\")\n log(:error, \"call_satellite: #{err}. Returning nil.\")\n return nil\n end\nend", "def request(action, data = nil)\n session.request(\n Endpoint.new.soap_action_name(entity_class, action),\n data\n )\n end", "def call(url:, action: :get, **options)\n response = client.send(action, url, options[:body], 'Content-Type': 'application/json')\n\n unless response.success?\n Rails.logger.info(\"#API response fail: #{response.inspect}\")\n raise ::Errors::BadRequest\n end\n\n return JSON.parse response.body if response.status == 200\n end", "def make_request action, params\r\n hash = to_wsdl(params)\r\n tries = 0\r\n\r\n begin\r\n tries += 1\r\n header = authentication_header unless action == 'AuthenticateUser'\r\n response = client.send(\"#{action}!\") do |soap|\r\n soap.namespace = LL_NAMESPACE + '/'\r\n soap.action = LL_NAMESPACE + '/' + action\r\n soap.input = action\r\n soap.header = header\r\n soap.body = hash\r\n end\r\n if response.http.code != '200'\r\n raise \"SYWR: SOAP #{action} failed\"\r\n else\r\n response\r\n end\r\n rescue => e\r\n if tries < 3\r\n reset_token if e == '(detail) Authenticated token has expired or is invalid'\r\n logger.debug \"SYWR: SOAP #{action} failed - #{e}\"\r\n retry\r\n else\r\n logger.warn \"SYWR: SOAP #{action} completely failed - #{e}\"\r\n @errors << 'failed'\r\n nil\r\n end\r\n end\r\n end", "def request(action, data = nil)\n session.request(\n Endpoint.new.soap_action_name(self.class, action),\n data\n )\n end", "def request(params)\n\n # Add auth header\n headers = params[:headers] || {}\n headers['x-vcloud-authorization'] = @auth_key if !@auth_key.nil? || !@auth_key.equal?('')\n\n # set connection options\n options = {:url => params[:url],\n :body => params[:body] || '',\n :expects => params[:expects] || 200,\n :headers => headers || {},\n :method => params[:method] || 'GET'\n }\n\n # connect\n res = RestClient::Request.execute options\n\n raise res if (res.code!=params[:expects] && res.code!=200)\n\n res\n\n\n end", "def hit_api_direct\n # CollegiateLink API needs some data to be hashed and sent for auth purposes\n time = (Time.now.to_f * 1000).to_i.to_s\n ipaddress = ENV['cl_ipaddress']\n apikey = ENV['cl_apikey']\n privatekey = ENV['cl_privatekey']\n random = SecureRandom.hex\n hash = Digest::SHA256.hexdigest(apikey + ipaddress + time + random + privatekey)\n\n url = ENV['cl_apiurl'] + @resource + \"?time=\" + time + \"&apikey=\" + apikey + \"&random=\" + random + \"&hash=\" + hash + @url_options\n return send_request(url, nil)\n end", "def call_rest(action, url, auth_cert, auth_key, ref, content_type, body = nil)\n begin\n # change url based on if we have a ref or not\n if ref.nil?\n url = url\n else\n url = url + \"/\" + ref\n end\n\n # set params for api call\n params = {\n :method => action,\n :url => url,\n :ssl_client_cert => OpenSSL::X509::Certificate.new(auth_cert),\n :ssl_client_key => OpenSSL::PKey::RSA.new(auth_key),\n :verify_ssl => false,\n :headers => { :content_type => content_type, :accept => content_type }\n }\n\n # generate payload data\n content_type == :json ? (params[:payload] = JSON.generate(body) if body) : (params[:payload] = body if body)\n log(:info, \"call_rest: Request: #{url} action: #{action} payload: #{params[:payload]}\")\n\n # execute the request\n RestClient::Request.new(params).execute\n rescue => err\n # log and backtrace the error\n log(:error, \"[#{err}]\\n#{err.backtrace.join(\"\\n\")}\")\n log(:error, \"call_rest: #{err}. Returning nil.\")\n return nil\n end\nend", "def get(action, params)\n \n request = query_string(action, params)\n logger.debug(\"request: #{request}\")\n \n url = URI.parse(@endpoint)\n response = Net::HTTP.start(url.host, url.port) { |http|\n http.get(request)\n }\n \n status = success?(response.body)\n gateway_response = GatewayResponse.new(@endpoint, request, response.body, status) \n end", "def send_request(api_method, opts = {}, action = :get, endpoint = self.endpoint)\n\n opts.merge! method: api_method, api_key: key\n\n case action\n when :get\n url_string = endpoint + \"?\" + opts.collect{|k,v| \"#{k}=#{CGI.escape(v.to_s)}\"}.join('&')\n url = URI.parse(url_string)\n req = Net::HTTP::Get.new url.request_uri\n\n Net::HTTP.start(url.host, url.port, use_ssl: url.scheme == 'https') do |http|\n http.request req\n end\n when :post\n Net::HTTP.post_form URI.parse(endpoint), opts\n end\n end", "def run\n\n action Colors.grey(\"REQUEST \") + Colors.light_blue(\"#{options[:method].upcase} #{url}\")\n Console.instance.indent\n # run the request\n options[:ssl_verifypeer] = false\n options[:followlocation] = true\n\n Injector.decorate(options)\n\n # convert all headers keys to strings to avoid having symbols like :\"header\" when\n # declaring headers with colons instead of arrows\n if options.key?(:headers)\n new_opts = {}\n options[:headers].map do |k, v|\n new_opts[k.to_s] = v\n end\n options[:headers] = new_opts\n end\n\n if options.key?(:headers) and options[:headers].key?('Content-Type')\n ctype = options[:headers]['Content-Type']\n if ctype.include?('application/json')\n # automatically encode json content\n options[:body] = JSON.generate(options[:body], quirks_mode: true)\n end\n end\n\n\n\n self.response = Typhoeus::Request.new(url, options).run\n\n self.req_response = RequestResponse.new.tap { |r|\n r.raw_body = response.body\n r.headers = response.headers\n r.code = response.code\n r.total_time = response.total_time\n\n if !r.headers.nil? && r.headers.key?('Content-Type') && r.headers['Content-Type'].include?('application/json')\n r.body = JSON.parse(response.body)\n else\n r.body = response.body\n end\n }\n\n # reset assertion counter\n self.assert_no = 1\n\n # evaluate response against expectations\n begin\n instance_eval(&expectations)\n rescue AssertionException\n error error_msg + \" at #{expectations.source_location}\"\n raise RequestException\n rescue StandardError => e\n error 'Exception ' + e.message\n info e.backtrace.inspect\n _debug_info\n error error_msg\n raise RequestException\n ensure\n Console.instance.unindent\n end\n\n req_response\n\n end", "def call_infoblox(action, ref, content_type, return_type, body = nil, return_fields = nil)\n # set url\n if return_fields.nil?\n url = \"#{@base_url}\" + \"#{ref}\"\n else\n url = \"#{@base_url}\" + \"#{ref}\" + \"\\?_return_fields\"\n end\n \n # set params for api call\n params = {\n :method => action,\n :url => url,\n :verify_ssl => false,\n :headers => {\n :content_type => content_type,\n :accept => return_type,\n :authorization => \"Basic #{Base64.strict_encode64(\"#{@username}:#{@password}\")}\"\n }\n }\n \n # generate payload data\n content_type == :json ? (params[:payload] = JSON.generate(body) if body) : (params[:payload] = body if body)\n log(:info, \"Calling -> Infoblox: #{url} action: #{action} payload: #{params[:payload]}\")\n response = RestClient::Request.new(params).execute\n raise \"Failure <- Infoblox Response: #{response.code}\" unless response.code == 200 || response.code == 201\n return response\n end", "def request(*args); end", "def call_infoblox(action, ref, content_type, return_type, body = nil, return_fields = nil)\n # set url\n if return_fields.nil?\n url = \"#{@base_url}\" + \"#{ref}\"\n else\n url = \"#{@base_url}\" + \"#{ref}\" + '?_return_fields='\n end\n\n # set params for api call\n params = {\n :method => action,\n :url => url,\n :verify_ssl => false,\n :headers => {\n :content_type => content_type,\n :accept => return_type,\n :authorization => \"Basic #{Base64.strict_encode64(\"#{@username}:#{@password}\")}\"\n }\n }\n\n # generate payload data\n content_type == :json ? (params[:payload] = JSON.generate(body) if body) : (params[:payload] = body if body)\n log(:info, \"Calling -> Infoblox: #{url} action: #{action} payload: #{params[:payload]}\")\n response = RestClient::Request.new(params).execute\n raise \"Failure <- Infoblox Response: #{response.code}\" unless response.code == 200 || response.code == 201\n return response\n end", "def perform(arguments = {})\n case type.to_sym\n when :post, :get\n api.public_send(type, path, @arguments.merge(arguments))\n else\n raise ArgumentError, \"Unregistered request type #{request_type}\"\n end\n end", "def call(method, params={})\n # Build path\n params[:apikey] = @api_key\n params = params.map { |p| p.join('=') }.join('&').gsub(/\\s/, '%20')\n path = [@uri.path, API_VERSION, method].compact.join('/') << '?' << params\n # Send request\n get = Net::HTTP::Get.new(path)\n response = @http.request(get)\n handleResult response.body\n end", "def api_call(payload); end", "def _make_api_call(json_params=nil)\n\n puts \"Crossbar::HTTP - Request: POST #{url}\" if self.verbose\n\n encoded_params = nil\n if json_params != nil\n if self.pre_serialize != nil and self.pre_serialize.is_a? Proc\n json_params = self._parse_params json_params\n end\n encoded_params = JSON.generate(json_params)\n end\n\n puts \"Crossbar::HTTP - Params: #{encoded_params}\" if encoded_params != nil and self.verbose\n\n uri = URI(self.url)\n\n if self.key != nil and self.secret != nil and encoded_params != nil\n signature, nonce, timestamp = self._compute_signature(encoded_params)\n params = {\n timestamp: timestamp,\n seq: self.sequence.to_s,\n nonce: nonce,\n signature: signature,\n key: self.key\n }\n uri.query = URI.encode_www_form(params)\n\n puts \"Crossbar::HTTP - Signature Params: #{params}\" if self.verbose\n end\n\n # TODO: Not sure what this is supposed to be but this works\n self.sequence += 1\n\n self._api_call uri, encoded_params\n end", "def perform_get_request\n # Validate preventing request error\n\n # setup params, like API Key if needed\n\n # Perform the request\n get_request\n end", "def requestAction(controller,action,params={})\n controller.class_eval{\n def params=(params); @params = params end\n def params; @params end\n }\n c = controller.new\n c.request = @_request\n c.response = @_response\n c.params = params\n c.send(action)\n c.response.body\n end", "def call(_method, _path, params = {})\n puts \"Aici?\"\n begin\n #path = \"https://login-test03.cloud.xirrus.com/api/v2#{_path}\"\n\n path = \"#{@xms_url}/api/v2#{_path}\"\n puts \"PATH = #{path}\"\n if (_method == :get || _method == :get_string || _method == :get_csv || _method == :get_csv_all_radios || _method == :put_with_query_params || _method == :post_with_query_params)\n query = build_query(params)\n path += \"?#{query}\"\n # Escape if anu spaces in url\n path = URI.escape(path)\n end\n success = false\n case _method\n\n when :get\n puts \"#{token}\"\n response_json_string = RestClient.get( path, :authorization => \"Bearer #{token}\",\n\n :format => :json,\n\n :content_type => :json,\n\n :accept => :json\n ) # RestClient get\n\n when :post\n\n response_json_string = RestClient.post( path , params.to_json , :authorization => \"Bearer #{token}\",\n\n :format => :json,\n\n :content_type => :json,\n\n :accept => :json\n ) # RestClient Post\n when :post_file\n\n response_json_string = RestClient.post( path , params , :authorization => \"Bearer #{token}\",\n\n :format => :json,\n\n :content_type => :text,\n\n :accept => :json\n ) # RestClient Post file\n\n\n\n when :put\n puts params.to_json\n response_json_string = RestClient.put( path , params.to_json , :authorization => \"Bearer #{token}\",\n\n :format => :json,\n\n :content_type => :json,\n\n :accept => :json\n ) # RestClient Post\n\n when :delete\n response_json_string = RestClient.delete( path , :authorization => \"Bearer #{token}\",\n\n :format => :json,\n\n :content_type => :json,\n\n :accept => :json\n ) # RestClient Post\n when :delete_with_args\n response_json_string = RestClient.delete( path ,params, :authorization => \"Bearer #{token}\",\n\n :format => :json,\n\n :content_type => :json,\n\n :accept => :json\n ) # RestClient Post\n else nil\n\n end\n\n puts \" ---------- \"\n pp response_json_string\n puts \" ---------- \"\n response = API::ApiClient::Response.new(response_json_string, path)\n # update_history(response)\n if response.cookie\n @all_cookies = response.cookie\n puts \"new cookie...\"\n end\n @history << [path,response.body]\n\n response\n\n rescue => e\n puts \" ---------- \"\n puts e.message\n puts \" ---------- \"\n #puts \"rescuing ng api client call - #{e.message}\"\n\n #puts \"NG::ApiClient.call rescued - path: #{_path}\"\n #puts \"e.message: #{e.message}\"\n #response = XMS::NG::ApiClient::Response.new(e.message, path)\n e.message\n end\n\n end", "def query(action, hash = {})\n # uri = URI.parse(\"https://130.59.10.31\")\n # http = Net::HTTP.new(uri.host, uri.port)\n # http.use_ssl = true\n # http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n #\n # request = Net::HTTP::Get.new(uri.request_uri)\n #\n # response = http.request(request)\n # response.body\n # response.status\n # response[\"header-here\"] # All headers are lowercase\n uri = URI.parse(@url + \"/api/xml?action=#{action}\")\n hash.each_pair do |key, val|\n if val\n if key == \"filter\" or key == \"sort\"\n uri.query += val.query\n else\n uri.query += \"&\" + key + \"=\" + CGI::escape(\"#{val}\")\n end\n end\n end\n http = Net::HTTP.new(uri.host, uri.port)\n if uri.scheme == \"https\"\n http.use_ssl=true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n end\n request = Net::HTTP::Get.new(uri.request_uri)\n # logger = Logger.new('log/development.log')\n # logger.info(url.path + \"?\" + url.query)\n if @sessionid\n request.add_field(\"Cookie\", \"BREEZESESSION=\"+@sessionid)\n end\n puts \"ACS query - request: \" + request.path\n response = http.request(request)\n puts \"ACS query - response: \" + response.body.inspect\n return response\n end", "def call_action action=nil\n action ||= @action\n invoke{ dispatch action }\n invoke{ handle_status(@response.status) }\n content_type self.class.content_type unless @response[CNT_TYPE]\n @response.finish\n end", "def instance_run(action)\n @response = {}\n @message = nil\n @error = nil\n\n res = nil\n\n # load default object\n if @@params[:_id]\n eval \"@object = @#{@@class_name.underscore} = #{@@class_name}.unscoped.find(@@params[:_id].to_i)\"\n @response[:path] = @object.path\n end\n\n if @@actions[action] && @@actions[action][:params]\n for key, values in @@actions[action][:params]\n next if @error\n value = @@params[key]\n eval \"@_#{key} = value\" if value.present?\n for type in values\n case type\n when :req\n @error = \"[#{key}] is required\" unless value\n when :email\n begin\n Validate.email value\n rescue\n @error ||= \"[#{key}] #{$!.message}\"\n end\n end\n end\n end\n end\n\n unless @error\n begin\n if @@actions[action]\n res = instance_exec &@@actions[action][:proc]\n elsif respond_to?(action)\n res = send(action)\n else\n @error ||= \"Action #{action} not found in #{self.class.name.sub('Cell','')} API, available #{self.class.actions.to_sentence}\"\n end\n rescue\n if $!\n @error ||= $!.message.split(' for #').first\n root = __FILE__.sub('lux/lux/modules/lux_api.rb','')\n @response[:backtrace] = $!.backtrace.reject{ |el| el.index('/gems/') }.map{ |el| el.sub(root, '') }\n end\n end\n end\n\n if res\n res = instance_eval(&res) if res.kind_of?(Proc)\n res = res.all.map{ |el| el.attributes } if res.class.name == 'ActiveRecord::Relation'\n\n # object given\n if res.respond_to?(:attributes)\n @response[:path] = res.path if res.respond_to?(:path)\n res = res.attributes.reject{ |f| ['updated_by', 'updated_at', 'created_by', 'created_at'].index(f) }\n end\n\n @response[:data] = res\n @response[:message] = @message unless @message.nil?\n # @response[:message] = res if !@message && res.kind_of?(String)\n @error ||= \"Wrong type for @error\" if @error && !@error.kind_of?(String)\n @error ||= \"Wrong type for @message\" if @message && !@message.kind_of?(String)\n end\n\n # if we define _redirect then we will be redirected to exact page\n # useful for file uploads\n if @@params[:_redirect]\n if @error\n Page.flash :error, @error\n elsif @response[:message]\n Page.flash :info, @response[:message]\n end\n\n Page.redirect(@@params[:_redirect])\n end\n\n @response[:error] = @error if @error\n @response[:ip] = '127.0.0.1'\n ap @response if Page.dev?\n @response\n end", "def http_call(payload); end", "def make_api_call(url, api_params)\n RestClient.post(url, api_params, content_type: :json)\n end", "def APICall params = {}\n \n path = params[:path]\n method = params[:method] || 'GET'\n payload = params[:payload] || nil\n \n params.delete(:method)\n params.delete(:path)\n params.delete(:payload)\n \n a = Time.now.to_f\n \n http = Net::HTTP.new(@infra[:domain]+'.zendesk.com',443)\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n http.use_ssl = true\n \n uri = %{#{@infra[:path]}#{path}}\n uri << '?'+params.map{ |key,val| \"#{key}=#{val}\" }.join('&') if params && params.count > 0\n uri = URI.escape uri\n \n reqs = {\n 'GET' => Net::HTTP::Get.new(uri),\n 'POST' => Net::HTTP::Post.new(uri),\n 'PUT' => Net::HTTP::Put.new(uri),\n 'DELETE' => Net::HTTP::Delete.new(uri)\n }\n req = reqs[method]\n \n content_type = 'application/json'\n content_type = 'application/binary' if path.include? 'uploads'\n req.content_type = content_type\n \n req.basic_auth @username,@infra[:authentication]\n \n req.body = payload if method == 'POST' || method == 'PUT'\n \n response = http.request req\n \n code = response.code.to_f.round\n body = response.body\n \n b = Time.now.to_f\n c = ((b-a)*100).round.to_f/100\n \n final = {code: code.to_i,body: nil}\n final = final.merge(body: JSON.parse(body)) if method != 'DELETE' && code != 500\n final = final.merge(time: c)\n \n @api += 1\n \n final\n \n end", "def api_request method, params = nil\n\t\t\tconnection = ZenfolioAPI::HTTP.new()\n\t\t\t@response = connection.POST(method, params, @auth.token)\n\t\tend", "def raw_api(method,params=nil)\n debug(6,:var=>method,:msg=>\"method\")\n debug(6,:var=>params,:msg=>\"Parameters\")\n\n checkauth\n checkversion(1,1)\n params={} if params==nil\n obj=do_request(json_obj(method,params))\n return obj['result']\n end", "def api_request(action, data, request_type)\n data[:api_key] = @api_key\n data[:format] ||= 'json'\n data[:sig] = Sailthru::TriggermailClient.get_signature_hash(data, @secret)\n _result = self.http_request(\"#{@api_uri}/#{action}\", data, request_type)\n\n\n # NOTE: don't do the unserialize here\n unserialized = JSON.parse(_result)\n return unserialized ? unserialized : _result\n end", "def api_post(action, data)\n api_request(action, data, 'POST')\n end", "def post(action, **args); end", "def http_send_action\n http = http_inst\n req = http_post\n Response.new http.request req\n end", "def api_execute(path, method, options = {})\n params = options[:params]\n case method\n when :get\n req = build_http_request(Net::HTTP::Get, path, params)\n when :post\n req = build_http_request(Net::HTTP::Post, path, nil, params)\n when :put\n req = build_http_request(Net::HTTP::Put, path, nil, params)\n when :delete\n req = build_http_request(Net::HTTP::Delete, path, params)\n else\n fail \"Unknown http action: #{method}\"\n end\n timeout = options[:timeout] || @read_timeout\n http = Net::HTTP.new(host, port)\n http.read_timeout = timeout\n setup_https(http)\n req.basic_auth(user_name, password) if [user_name, password].all?\n Log.debug(\"Invoking: '#{req.class}' against '#{path}\")\n res = http.request(req)\n Log.debug(\"Response code: #{res.code}\")\n process_http_request(res, req, params)\n end", "def send_request method, params = nil\n if params.nil?\n raise ArgumentError, \"Invalid request params\"\n else\n required = { 'api_key' => @api_key }\n params = required.merge(params)\n params = URI.escape(params.collect{ |k,v| \"#{k}=#{v}\"}.join('&'))\n end\n url = @api_url + method + '/?' + params\n raise ArgumentError, \"Can't send request to the server\" if not url.is_a? String\n uri = URI.parse(url)\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n req = Net::HTTP::Get.new(uri.request_uri)\n res = http.request(req)\n data = res.body\n if not data.is_a? String or not data.is_json?\n raise RuntimeError, \"Server returned incorrect format data.\"\n end\n result = JSON.parse(data)\n end", "def send_request(method, params, &block); end", "def send_request method, params = {}\n uri = URI.parse(@api_url)\n if Time.now.to_i > @exp + 3600\n get_acces_token\n @exp = Time.now.to_i\n end\n required = { 'access_token' => @access_token, 'method' => method }\n params = required.merge(params)\n params = URI.escape(params.collect{ |k,v| \"#{k}=#{v}\"}.join('&'))\n http = Net::HTTP.new(uri.host, uri.port)\n req = Net::HTTP::Post.new(uri.request_uri)\n req['User-Agent'] = \"zhzhussupovkz pleer.com-ruby-api\"\n req.body = params\n res = http.request(req)\n if res.code == \"200\"\n data = res.body\n result = JSON.parse(data)\n else\n puts \"Invalid getting data from server\"\n exit\n end\n end", "def execute_soap_request(action, args, extra_namespaces)\n original_action_name =\n get_service_registry.get_method_signature(action)[:original_name]\n original_action_name = action if original_action_name.nil?\n response = @client.request(original_action_name) do |soap|\n set_headers(soap, args, extra_namespaces)\n end\n return response\n end", "def call_api method, arguments = {}, &block\n # Ensures only a valid DataContext is used\n unless @context.is_a? DataContext\n block.call nil, 'A context object was not provided.'\n return\n end\n \n unless @context.valid?\n block.call nil, 'A valid context object was not provided.'\n return\n end\n \n # Ensures only valid arguments are used\n query = []\n arguments.each_pair do |key, value|\n if API_VALID_ARGUMENTS.member? key.to_s\n query << \"$#{key}=#{URI.escape value.to_s}\"\n else\n query << \"#{key}=#{URI.escape value.to_s}\"\n end\n end\n \n # Generates timestamp and url\n timestamp = DOL.timestamp\n url = URI.parse [\"#{@context.host}/#{@context.url}/#{method}\", query.join('&')].join '?'\n \n # Creates a new thread, creates an authenticaed request, and requests data from the host\n @mutex.synchronize do\n @active_requests << Thread.new do\n request = Net::HTTP::Get.new [url.path, url.query].join '?'\n request.add_field 'Authorization', \"Timestamp=#{timestamp}&ApiKey=#{@context.key}&Signature=#{signature timestamp, url}\"\n request.add_field 'Accept', 'application/json'\n result = Net::HTTP.start url.host, url.port do |http|\n http.request request\n end\n \n if result.is_a? Net::HTTPSuccess\n \n #Cleanup jsonresult.\n result = result.body.gsub(/\\\\+\"/, '\"')\n result = result.gsub /\\\\+n/, \"\"\n result = result.gsub /\\\"\\\"\\{/, \"{\"\n result = result.gsub /}\\\"\\\"/, \"}\"\n\n result = JSON.parse(result)['d']\n \n if (result.include?'results')\n result = result['results'] if result.is_a? Hash\n end\n\n block.call result, nil\n \n else\n block.call nil, \"Error: #{result.message}\"\n end\n \n @mutex.synchronize do\n @active_requests.delete Thread.current\n end\n end\n end\n end", "def perform(action, method = :get, payload = {})\n payload.merge!(username: self.username, password: self.password)\n\n headers = { 'User-Agent' => DeathByCaptcha::API_VERSION }\n\n if method == :post\n uri = URI(\"http://#{self.hostname}/api/#{action}\")\n req = Net::HTTP::Post.new(uri.request_uri, headers)\n req.set_form_data(payload)\n\n elsif method == :post_multipart\n uri = URI(\"http://#{self.hostname}/api/#{action}\")\n req = Net::HTTP::Post.new(uri.request_uri, headers)\n boundary, body = prepare_multipart_data(payload)\n req.content_type = \"multipart/form-data; boundary=#{boundary}\"\n req.body = body\n\n else\n uri = URI(\"http://#{self.hostname}/api/#{action}?#{URI.encode_www_form(payload)}\")\n req = Net::HTTP::Get.new(uri.request_uri, headers)\n end\n\n res = Net::HTTP.start(uri.hostname, uri.port) do |http|\n http.request(req)\n end\n\n case res\n when Net::HTTPSuccess, Net::HTTPSeeOther\n Hash[URI.decode_www_form(res.body)]\n when Net::HTTPForbidden\n raise DeathByCaptcha::APIForbidden\n when Net::HTTPBadRequest\n raise DeathByCaptcha::APIBadRequest\n when Net::HTTPRequestEntityTooLarge\n raise DeathByCaptcha::APICaptchaTooLarge\n when Net::HTTPServiceUnavailable\n raise DeathByCaptcha::APIServiceUnavailable\n else\n raise DeathByCaptcha::APIResponseError.new(res.body)\n end\n end", "def exec(op, params)\n exec_api(JsonRequest.new(op, params))\n end", "def api_request(action, data, request_type, binary_key = nil)\n if !binary_key.nil?\n binary_key_data = data[binary_key]\n data.delete(binary_key)\n end\n\n if data[:format].nil? || data[:format] == 'json'\n data = prepare_json_payload(data)\n else\n data[:api_key] = @api_key\n data[:format] ||= 'json'\n end\n\n if !binary_key.nil?\n data[binary_key] = binary_key_data\n end\n _result = http_request(action, data, request_type, binary_key)\n\n # NOTE: don't do the unserialize here\n if data[:format] == 'json'\n begin\n unserialized = JSON.parse(_result)\n return unserialized ? unserialized : _result\n rescue JSON::JSONError => e\n return {'error' => e}\n end\n end\n _result\n end", "def actions()\n\t(\n\t\tcall_src_sip_username = _arg( 'Caller-Username' )\n\t\tcall_src_cid_userinfo = _arg( 'Caller-Caller-ID-Number' )\n\t\tcall_src_cid_displayname = _arg( 'Caller-Caller-ID-Name' )\n\t\tcall_dst_sip_userinfo = _arg( 'Caller-Destination-Number' )\n\t\tcall_dst_sip_domain = _arg( 'var_sip_to_host' )\n\t\t\n\t\t# Strip \"-kambridge-\" prefix added in kamailio.cfg:\n\t\tcall_dst_sip_userinfo = call_dst_sip_userinfo.gsub( /^-kambridge-/, '' )\n\t\t\n\t\tlogger.info(_bold( \"[FS] Call-proc. request, acct. #{call_src_sip_username.inspect} as #{call_src_cid_userinfo.inspect} (#{call_src_cid_displayname.inspect}) -> #{call_dst_sip_userinfo.inspect} ...\" ))\n\t\t_args.each { |k,v|\n\t\t\tcase v\n\t\t\t\twhen String\n\t\t\t\t\t#logger.debug( \" #{k.ljust(36)} = #{v.inspect}\" )\n\t\t\t\t#when Hash\n\t\t\t\t#\tv.each { |k1,v1|\n\t\t\t\t#\t\tlogger.debug( \" #{k}[ #{k1.ljust(30)} ] = #{v1.inspect}\" )\n\t\t\t\t#\t}\n\t\t\tend\n\t\t}\n\t\t\n\t\t# For FreeSwitch dialplan applications see\n\t\t# http://wiki.freeswitch.org/wiki/Mod_dptools\n\t\t# http://wiki.freeswitch.org/wiki/Category:Dptools\n\t\t\n\t\t# Note: If you want to do multiple iterations (requests) you\n\t\t# have to set channel variables to keep track of \"where you\n\t\t# are\" i.e. what you have done already.\n\t\t# And you have to explicitly send \"_continue\" as the last\n\t\t# application.\n\t\t\t\t\n\t\tif call_dst_sip_userinfo.blank?\n\t\t\tcase _arg( 'Answer-State' )\n\t\t\t\twhen 'ringing'\n\t\t\t\t\taction :respond , '404 Not Found' # or '400 Bad Request'? or '484 Address Incomplete'?\n\t\t\t\telse\n\t\t\t\t\taction :hangup , ''\n\t\t\tend\n\t\telse\n\t\t\t\n\t\t\tcall_dst_real_sip_username = call_dst_sip_userinfo # un-alias\n\t\t\t# (Alias lookup has already been done in kamailio.cfg.)\n\t\t\t\n\t\t\t# Here's an example: {\n\t\t\t#action :set , 'effective_caller_id_number=1234567'\n\t\t\t#action :bridge , \"sofia/internal/#{call_dst_real_sip_username}\"\n\t\t\t#action :answer\n\t\t\t#action :sleep , 1000\n\t\t\t#action :playback , 'tone_stream://%(500, 0, 640)'\n\t\t\t#action :set , 'voicemail_authorized=${sip_authorized}'\n\t\t\t#action :voicemail , \"default $${domain} #{call_dst_real_sip_username}\"\n\t\t\t#action :hangup\n\t\t\t#action :_continue\n\t\t\t# end of example }\n\t\t\t\n\t\t\t\n\t\t\t# http://kb.asipto.com/freeswitch:kamailio-3.1.x-freeswitch-1.0.6d-sbc#dialplan\n\t\t\t\n\t\t\t#OPTIMIZE Implement call-forwardings here ...\n\t\t\t\n\t\t\t# Ring the SIP user via Kamailio for 30 seconds:\n\t\t\taction_log( FS_LOG_INFO, \"Calling #{call_dst_real_sip_username} ...\" )\n\t\t\taction :set , \"call_timeout=5\"\n\t\t\taction :export , \"sip_contact_user=ufs\"\n\t\t\taction :bridge , \"sofia/internal/#{call_dst_real_sip_username}@127.0.0.1\"\n\t\t\t\n\t\t\t#OPTIMIZE Implement call-forward on busy/unavailable here ...\n\t\t\t\n\t\t\t# Go to voicemail:\n\t\t\taction_log( FS_LOG_INFO, \"Going to voicemail ...\" )\n\t\t\taction :answer\n\t\t\taction :voicemail , \"default #{call_dst_sip_domain} #{call_dst_real_sip_username}\"\n\t\t\taction :hangup\n\t\t\t\n\t\t\t\n\t\tend\n\t\t\n\t\t\n\t\trespond_to { |format|\n\t\t\tformat.xml {\n\t\t\t\trender :actions, :layout => false\n\t\t\t}\n\t\t\tformat.all {\n\t\t\t\trender :status => '406 Not Acceptable',\n\t\t\t\t\t:layout => false, :content_type => 'text/plain',\n\t\t\t\t\t:text => \"<!-- Only XML format is supported. -->\"\n\t\t\t}\n\t\t}\n\t\treturn\n\t)end", "def commit(action, params = {})\n unless VALID_ACTIONS.include? action.to_sym\n raise \"Invalid action\"\n end\n @action = action\n @params = params\n \n conn = Faraday.new(:url => API_URL) do |c|\n c.request :soap\n c.response :soap, \"item\"\n c.adapter :net_http\n end\n \n request = conn.post do |r|\n r.body = format_params_for_fantastico\n r.headers = {'Content-Type' => 'text/xml; charset=utf-8'}\n end\n \n response = request.body\n \n @success = !(response.is_a?(Hash) && response.has_key?(\"faultcode\"))\n \n response\n end", "def iod_request (api, params)\r\n uri = URI(\"http://api.idolondemand.com/1/api/async/#{api}/v1\")\r\n uri.query = URI.encode_www_form(params)\r\n res = Net::HTTP.get_response(uri, p_addr = $proxy_host, p_port = $proxy_port)\r\n jobid = JSON.parse(res.body)['jobID']\r\n puts \"Post request jobid [#{jobid}]\"\r\n return job_results(jobid)\r\nend", "def execute\n space_slug = @parameters[\"space_slug\"].empty? ? @info_values[\"space_slug\"] : @parameters[\"space_slug\"]\n if @info_values['api_server'].include?(\"${space}\")\n server = @info_values['api_server'].gsub(\"${space}\", space_slug)\n elsif !space_slug.to_s.empty?\n server = @info_values['api_server']+\"/\"+space_slug\n else\n server = @info_values['api_server']\n end\n\n username = URI.encode(@info_values[\"api_username\"])\n password = @info_values[\"api_password\"]\n error_handling = @parameters[\"error_handling\"]\n\n route_base = \"#{server}/app/api/v1/teams\"\n\n puts \"API ROUTE: #{route_base}\" if @debug_logging_enabled\n\n resource = RestClient::Resource.new(route_base, { :user => username, :password => password })\n\n # Building the object that will be sent to Kinetic Core\n dataHash = {}\n\tdataHash[\"name\"] = @parameters[\"team_name\"]\n\tif !@parameters[\"members\"].empty?\n\t\tmembers = JSON.parse(@parameters[\"members\"])\n\t\tmembership = []\n\t\tmembers.each do |member|\n\t\t username = {}\n\t\t username[\"username\"] = member\n\t\t user = {}\n\t\t user[\"user\"] = username\n\t\t membership.push(user)\n\t\tend\n\t\tdataHash[\"memberships\"] = membership\n\tend\n\n\tputs \"DATA: #{dataHash.to_json}\" if @debug_logging_enabled\n\tbegin\n\t#create\n response = resource.post(dataHash.to_json, { accept: :json, content_type: :json })\n\n\n # Build the results to be returned by this handler\n <<-RESULTS\n <results>\n <result name=\"Handler Error Message\"></result>\n </results>\n RESULTS\n\n rescue RestClient::Exception => error\n error_message = JSON.parse(error.response)[\"error\"]\n if error_handling == \"Raise Error\"\n raise error_message\n else\n <<-RESULTS\n <results>\n <result name=\"Handler Error Message\">#{error.http_code}: #{escape(error_message)}</result>\n </results>\n RESULTS\n end\n end\n end", "def send_action(service, action, param)\r\n param_str = \"\"\r\n param.each do |key, value|\r\n param_str << '<%{key}>%{value}</%{key}>'.%(key: key, value: value)\r\n end\r\n xmldata = ActionXML.%(type: service.type, action: action, arguments: param_str)\r\n req = Net::HTTP::Post.new(uri = URI(@igd_location + service.control_url))\r\n req.content_type = 'text/xml; charset=\"utf-8\"'\r\n req['SOAPAction'] = '\"%{type}#%{action}\"'.%(type: service.type, action: action)\r\n res = Net::HTTP.start(uri.hostname, uri.port) do |http|\r\n http.request(req, xmldata)\r\n end\r\n #res = Net::HTTP.request(req, xmldata)\r\n xml = REXML::Document.new(res.body).root\r\n if(res.is_a?(Net::HTTPSuccess))\r\n xml.each_element('s:Body/u:*') do |element|\r\n return {is_error: false, has_xml: true, xml: element}\r\n end\r\n else\r\n return {is_error: true, \r\n faultcode: xml.get_text('s:Body/s:Fault/faultcode').to_s,\r\n faultstring: xml.get_text('s:Body/s:Fault/faultstring').to_s,\r\n code: xml.get_text('s:Body/s:Fault/detail/UPnPError/errorCode').to_s.to_i,\r\n descr: xml.get_text('s:Body/s:Fault/detail/UPnPError/errorDescription').to_s\r\n }\r\n end\r\n return {is_error: false, has_xml: false}\r\n end", "def remote_call(url_params: {}, params: {})\n endpoint = sprintf(\"#{VERSION}/#{path}\", url_params)\n\n endpoint += authentication.to_query(endpoint)\n if method == :get\n response = client.get(endpoint, params, HEADERS)\n elsif method == :post\n response = client.post(endpoint, json_encode(params), {'Content-Type' => 'application/json'}.merge!(HEADERS))\n end\n\n if response.success?\n Result.new(response.value.body)\n else\n response\n end\n end", "def request(verb, params)\n params = build_url(params)\n\n if access_token\n params.merge!(:access_token => access_token)\n end\n\n Connection.new(verb, params).fetch\n end", "def http_request(action, data, method_type = 'POST', binary_key = nil)\n\n uri = \"#{@api_uri}/#{action}\"\n if method_type != \"POST\" && (!method_type.is_a? String)\n uri += \"?\" + data.map{ |key, value| \"#{CGI::escape(key.to_s)}=#{CGI::escape(value.to_s)}\" }.join(\"&\")\n end\n\n req = nil\n\n _uri = URI.parse(uri)\n\n headers = {\n \"Content-Type\": \"text/json\",\n \"Api-Key\":\"#{@api_key}\"\n }\n\n if method_type == 'POST'\n req = set_up_post_request(\n _uri, data, headers, binary_key\n )\n\n else\n request_uri = \"#{_uri.path}?#{_uri.query}\"\n if method_type == 'DELETE'\n req = Net::HTTP::Delete.new(request_uri, headers)\n else\n req = Net::HTTP::Get.new(request_uri, headers)\n end\n end\n\n begin\n http = Net::HTTP::Proxy(@proxy_host, @proxy_port).new(_uri.host, _uri.port)\n\n if _uri.scheme == 'https'\n http.ssl_version = :TLSv1\n http.use_ssl = true\n http.set_debug_output $stderr\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE if @verify_ssl != true # some openSSL client doesn't work without doing this\n http.ssl_timeout = @opts[:http_ssl_timeout] || 5\n end\n http.open_timeout = @opts[:http_open_timeout] || 5\n http.read_timeout = @opts[:http_read_timeout] || 10\n http.close_on_empty_response = @opts[:http_close_on_empty_response] || true\n\n\n response = http.start do\n http.request(req)\n end\n\n rescue Timeout::Error, Errno::ETIMEDOUT => e\n raise UnavailableError, \"Timed out: #{_uri}\"\n rescue => e\n raise ClientError, \"Unable to open stream to #{_uri}: #{e.message}\"\n end\n\n response.body || raise(ClientError, \"No response received from stream: #{_uri}\")\n end", "def process\n send_request @action\n end", "def json_api_request(request_method, action, parameters = {}, session = nil, flash = nil)\n @request.headers['ACCEPT'] = 'application/vnd.api+json'\n @request.headers['CONTENT_TYPE'] = 'application/vnd.api+json'\n extra_headers = parameters[:headers] || {}\n extra_headers.each do |key, value|\n @request.headers[key] = value\n end\n parameters.delete :headers\n parameters[:format] = :json_api unless parameters&.key? :format\n __send__(request_method, action, params: parameters, session: session, flash: flash)\nend", "def api_request(method, uri, token, payload, options={})\n params = options.fetch('params', {})\n headers = options.fetch('headers', {})\n req_headers = headers.merge({params: params}).merge({'X-Auth-Token': token})\n RestClient::Request.execute(method: method.to_sym,\n url: uri,\n headers: req_headers,\n timeout: @timeout,\n payload: payload)\n end", "def make_call(action, endpoint, job)\n response = HTTParty.post(\n \"http://localhost:3000/#{endpoint}\",\n :body => {\n \"#{action}\" => \"#{job}\",\n \"client\" => \"client_cert.pem\",\n }\n )\n puts response\n menu\n end", "def magic_action(action, user_id=self.user, patient_id = \"\", param_1=nil, param_2=nil, param_3=nil, param_4=nil, param_5=nil, param_6=nil, data=nil)\n begin\n response = self.client.request(\"Magic\", xmlns: \"http://www.allscripts.com/Unity\") do\n http.headers = {\"Accept-Encoding\" => \"gzip, deflate\", \"SOAPAction\" => \"http://www.allscripts.com/Unity/IUnityService/Magic\", \"Content-Type\" => \"text/xml; charset=UTF-8\"}\n soap.body = {\n \"Action\" => action,\n \"UserID\" => user_id,\n \"Appname\" => self.app,\n \"PatientID\" => patient_id,\n \"Token\" => self.security_token,\n \"Parameter1\" => param_1,\n \"Parameter2\" => param_2,\n \"Parameter3\" => param_3,\n \"Parameter4\" => param_4,\n \"Parameter5\" => param_5,\n \"Parameter6\" => param_6,\n \"data\" => data,\n :attributes! => {\"data\" =>{\"xsi:nil\" => true}}\n }\n end\n rescue Timeout::Error\n puts \"Timeout was rescued\"\n 30.times do |i|\n sleep 1\n puts \"#{30 - i} seconds to next retry\"\n end\n puts \"retrying\"\n retry\n end\n return response\n end", "def request(*args)\n end", "def post(action, params = T.unsafe(nil), header = T.unsafe(nil), query = T.unsafe(nil)); end", "def call_API\n case @input[:type]\n when :text\n @input = @input[:value]\n call_text_API\n when :url\n @input = @input[:value]\n call_URL_API\n else\n \"Invalid input\"\n end\n end", "def perform(action, payload = {})\n payload.merge!(\n cmd: action,\n version: DeathByCaptcha::API_VERSION,\n username: self.username,\n password: self.password,\n vendor_id: 5,\n )\n\n socket = create_socket()\n socket.puts(payload.to_json)\n response = socket.read()\n socket.close()\n\n begin\n response = JSON.parse(response)\n rescue\n raise DeathByCaptcha::APIResponseError.new(\"invalid JSON: #{response}\")\n end\n\n if !(error = response['error'].to_s).empty?\n case error\n when 'not-logged-in', 'invalid-credentials', 'banned', 'insufficient-funds'\n raise DeathByCaptcha::APIForbidden\n when 'invalid-captcha'\n raise DeathByCaptcha::APIBadRequest\n when 'service-overload'\n raise DeathByCaptcha::APIServiceUnavailable\n else\n raise DeathByCaptcha::APIResponseError.new(error)\n end\n end\n\n response\n end", "def invoke_action(action, args = {})\n raise ArgumentError, \"Browser.invoke_action expects an ActionController::Action as first parameter\"\\\n unless ::Waw::ActionController::Action===action\n location, response = fetch(relative_uri(action.uri), :post, args)\n apply_action_routing(action, JSON.parse(response.body))\n self.response\n end", "def request(type, id=\"\", params=\"\")\n id = id.to_s\n params = params.to_s\n api_path = case type\n when \"orders\"\n \"/api/v2/orders?\"\n when \"order_metadata\"\n raise \"ID required\" if id.empty?\n \"/api/v2/orders/#{id}?\"\n when \"shop_metadata\"\n raise \"ID required\" if id.empty?\n \"/api/v2/shop/#{id}?\"\n end\n api_path.chop! if params.empty?\n\n response = HTTParty.get(\n @domain + api_path + params, \n basic_auth: @auth\n )\n response_valid?(response)\n response\nend", "def perform_request(method, path, params, body)\n CONNECTION.run_request \\\n method.downcase.to_sym,\n path,\n ( body ? MultiJson.dump(body): nil ),\n {'Content-Type' => 'application/json'}\n end", "def call\n uri = URI.parse(ovh_domain)\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = true\n\n request = build_request\n add_headers(request)\n\n response = http.request(request)\n stdout_warn_log \"Made call to API: #{response.body}\"\n stdout_error_log 'Error: Call to API failed' && context.fail! unless response.is_a? Net::HTTPSuccess\n response\n end", "def update\n unless @action.nil?\n log_action( action.name, @environment[:api_key] )\n\n @success.call( action ) if @success && @action\n @action = nil;\n end\n end", "def post(action, params={}, options={})\n request(:post, action, params, options)\n end", "def execute_action(action_name, args, &block)\n validator = ParametersValidator.new(get_service_registry())\n args = validator.validate_args(action_name, args)\n response = execute_soap_request(\n action_name.to_sym, args, validator.extra_namespaces)\n log_headers(response.http.headers)\n handle_errors(response)\n return extract_result(response, action_name, &block)\n end", "def send_request(options)\n\n # construct our RESTful request URI\n uri = \"#{Base.base_uri}/api/#{options[:target]}\"\n uri += \"/#{options[:id]}\" if options.has_key?(:id)\n uri += \"/#{options[:what]}\" if options.has_key?(:what)\n uri += \".#{options[:how]}\" if options[:method] == \"get\"\n puts \"|--------------------- SEND_REQUEST ---------------------|\"\n puts \"| URI\"\n puts \"| #{uri}\"\n puts \"| Params\"\n puts \"| id => #{options[:id]}\"\n puts \"| what => #{options[:what]}\"\n puts \"| how => #{options[:how]}\"\n puts \"|--------------------- ------------ ---------------------|\"\n \n if @access_token.nil? \n return self.class.send(options[:method] || \"get\", uri, options)\n else\n return @access_token.send(options[:method] || \"get\", uri, options).body\n end\n \n end", "def make_request url, parameters={}, method=:get, settings={}\n raise 'not implemented'\n end", "def call_api\n url = \"#{@base_uri}/stock\"\n params = {symbol: @symbol, api_token: @api_key}\n\n if @exchange\n params[:stock_exchange] = @exchange\n end\n\n Lita.logger.debug \"call_api: #{url} #{params.inspect}\"\n\n @response = RestClient.get url, {params: params}\n\n Lita.logger.debug \"response: #{@response}\"\n end", "def request(action, force_reload: nil, request_options: nil)\n res = nil\n ClientRequest.transaction do\n cc = cache_key(action, request_options)\n clear_cache(cc) if force_reload\n retrieved_from = 'cache'\n res = Rails.cache.fetch(cc, expires_in: CacheExpiresIn) do\n retrieved_from = 'api'\n post_action action, request_options\n end\n\n project_admin.record_job_request action, result: { retrieved_from: retrieved_from }\n end\n res\n end", "def execute\n space_slug = @parameters[\"space_slug\"].empty? ? @info_values[\"space_slug\"] : @parameters[\"space_slug\"]\n if @info_values['api_server'].include?(\"${space}\")\n server = @info_values['api_server'].gsub(\"${space}\", space_slug)\n elsif !space_slug.to_s.empty?\n server = @info_values['api_server']+\"/\"+space_slug\n else\n server = @info_values['api_server']\n end\n\n api_username = URI.encode(@info_values[\"api_username\"])\n api_password = @info_values[\"api_password\"]\n api_server = @info_values[\"api_server\"]\n kapp_slug = @parameters[\"kapp_slug\"]\n form_slug = @parameters[\"form_slug\"]\n query = @parameters[\"query\"]\n error_handling = @parameters[\"error_handling\"]\n\n api_route = \"#{server}/app/api/v1/kapps/#{kapp_slug}/forms/#{form_slug}/submissions\" +\n \"?include=details,origin,parent,form,type&limit=1&q=#{URI.escape(query)}\"\n\n puts \"API ROUTE: #{api_route}\" if @enable_debug_logging\n\n resource = RestClient::Resource.new(api_route, { :user => api_username, :password => api_password })\n\n response = resource.get\n\n # if the user record did not exist\n if response.nil?\n <<-RESULTS\n <results>\n <result name=\"ID\"></result>\n <result name=\"Label\"></result>\n <result name=\"Origin\"></result>\n <result name=\"Parent\"></result>\n <result name=\"Submitted At\"></result>\n <result name=\"Type\"></result>\n <result name=\"Updated At\"></result>\n <result name=\"Updated By\"></result>\n <result name=\"Closed At\"></result>\n <result name=\"Core State\"></result>\n <result name=\"Created At\"></result>\n <result name=\"Created By\"></result>\n <result name=\"Form Description\"></result>\n <result name=\"Form Name\"></result>\n <result name=\"Form Notes\"></result>\n <result name=\"Form Slug\"></result>\n <result name=\"Form Status\"></result>\n </results>\n RESULTS\n else\n\n allresults = JSON.parse(response)[\"submissions\"]\n puts \"Full RESULTS: #{allresults.inspect}\" if @enable_debug_logging\n results = allresults[0]\n\n puts \"RESULTS: #{results.inspect}\" if @enable_debug_logging\n\n if results.nil?\n <<-RESULTS\n <results>\n <result name=\"Handler Error Message\"></result>\n <result name=\"ID\"></result>\n <result name=\"Label\"></result>\n <result name=\"Origin\"></result>\n <result name=\"Parent\"></result>\n <result name=\"Submitted At\"></result>\n <result name=\"Type\"></result>\n <result name=\"Updated At\"></result>\n <result name=\"Updated By\"></result>\n <result name=\"Closed At\"></result>\n <result name=\"Core State\"></result>\n <result name=\"Created At\"></result>\n <result name=\"Created By\"></result>\n <result name=\"Form Description\"></result>\n <result name=\"Form Name\"></result>\n <result name=\"Form Notes\"></result>\n <result name=\"Form Slug\"></result>\n <result name=\"Form Status\"></result>\n </results>\n RESULTS\n else\n <<-RESULTS\n <results>\n <result name=\"Handler Error Message\"></result>\n <result name=\"ID\">#{escape(results[\"id\"])}</result>\n <result name=\"Label\">#{escape(results[\"label\"])}</result>\n <result name=\"Origin\">#{escape(results[\"origin\"])}</result>\n <result name=\"Parent\">#{escape(results[\"parent\"])}</result>\n <result name=\"Submitted At\">#{escape(results[\"submittedAt\"])}</result>\n <result name=\"Type\">#{escape(results[\"type\"])}</result>\n <result name=\"Updated At\">#{escape(results[\"updatedAt\"])}</result>\n <result name=\"Updated By\">#{escape(results[\"updatedBy\"])}</result>\n <result name=\"Closed At\">#{escape(results[\"closedAt\"])}</result>\n <result name=\"Core State\">#{escape(results[\"coreState\"])}</result>\n <result name=\"Created At\">#{escape(results[\"createdAt\"])}</result>\n <result name=\"Created By\">#{escape(results[\"createdBy\"])}</result>\n <result name=\"Form Description\">#{escape(results[\"form\"][\"description\"])}</result>\n <result name=\"Form Name\">#{escape(results[\"form\"][\"name\"])}</result>\n <result name=\"Form Notes\">#{escape(results[\"form\"][\"notes\"])}</result>\n <result name=\"Form Slug\">#{escape(results[\"form\"][\"slug\"])}</result>\n <result name=\"Form Status\">#{escape(results[\"form\"][\"status\"])}</result>\n </results>\n RESULTS\n end\n end\n\n rescue RestClient::Exception => error\n error_message = JSON.parse(error.response)[\"error\"]\n if error_handling == \"Raise Error\"\n raise error_message\n else\n <<-RESULTS\n <results>\n <result name=\"Handler Error Message\">#{error.http_code}: #{escape(error_message)}</result>\n </results>\n RESULTS\n end\n end", "def do_request(verb, entity=nil, url_args=nil, post_args=nil)\n should_parse_xml = true\n url = URI(@api_url)\n if ['/oauth/request_token', '/oauth/access_token'].include?(verb)\n should_parse_xml = false\n url.path = verb\n else\n if not entity.nil?\n url.path = ['', API_VERSION, verb, entity].join('/')\n else\n url.path = ['', API_VERSION, verb].join('/')\n end\n end\n\n args = nil\n if not url_args.nil?\n args = url_args\n url.query = TripIt.urlencode_args(url_args)\n end\n\n request = nil\n if not post_args.nil?\n args = post_args\n request = Net::HTTP::Post.new(url.path)\n request.set_form_data(post_args)\n else\n request = Net::HTTP::Get.new(url.request_uri)\n end\n\n @credential.authorize(request, url, args)\n\n http = Net::HTTP.new(url.host, url.port)\n http.use_ssl = true\n if @verify_ssl\n http.verify_mode = OpenSSL::SSL::VERIFY_PEER\n end\n response = http.start do\n http.request(request)\n end\n\n if response.code == '200'\n if should_parse_xml\n parse_xml(response.body)\n else\n response.body\n end\n else\n response.error!\n end\n end", "def send\n uri = URI(@api_url)\n http = Net::HTTP.new(uri.host, uri.port)\n if uri.scheme == \"https\"\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_PEER\n end\n http.read_timeout = GlobalConstant::CompanyApi.read_timeout\n http.open_timeout = GlobalConstant::CompanyApi.open_timeout\n req_obj = get_request_obj(uri.request_uri)\n\n http_response, e = nil, nil\n begin\n http_response = http.request(req_obj)\n set_api_response_cookie(http_response)\n parse_api_response(http_response)\n rescue Net::ReadTimeout, Net::OpenTimeout => e\n # Timeouts\n exception_with_internal_code(\n e,\n 'company_api_timeout',\n 'company api timeout',\n GlobalConstant::ErrorCode.internal_server_error,\n debug_data\n )\n rescue Exception => e\n # Exceptions\n exception_with_internal_code(e, 'company_api_exception', 'company api exception', GlobalConstant::ErrorCode.internal_server_error, debug_data)\n end\n\n end", "def perform_request(method, path, params={}, body=nil, headers=nil)\n client.perform_request method, path, params, body, headers\n end", "def request method, *params, **options\n json = {method: method, params: params, id: 1, version: '1.0'}.merge!(options).to_json\n ret = JSON.parse(@http.request_post(@uri.path, json).body)\n if ret['error']\n error_code, error_message = ret['error']\n raise Sonycam::Error.make(error_code), error_message\n else\n ret['result']\n end\n end", "def hit_api_local\n # Authentication info\n pass = ENV['stugov_api_user']\n priv = ENV['stugov_api_pass']\n # Our base URL hosted on stugov's server\n base_url = ENV['stugov_api_base_url']\n\n # We make a sha256 hash of this in binary format, then base64 encode that\n digest = Base64.encode64(OpenSSL::HMAC.digest(OpenSSL::Digest.new(\"sha256\"), priv, pass)).chomp\n\n url = base_url + \"?resource=\" + @resource + @url_options\n return send_request(url, digest)\n end", "def make_request(request)\n puts \"\\n\\n\"\n puts \"==> Request, action='#{request.path}', params = #{request.query}...\"\n\n action = request.path.to_s.split(\"/\")[-1]\n\n if action && @app.valid?(action) then\n response = @app.send(action.to_sym, request.query)\n\n return response\n end\n\n return \"Error: Unrecognised action: #{action}\"\n rescue Exception => e\n $stderr.puts \"*** [E]: #{e}\\n#{e.backtrace.join(\"\\n\")}\"\n return \"Error: #{e}\"\n end", "def perform(api_method, *args)\n client.send(api_method, *args)\n end", "def execute_manual_request\n http_method = params[:http_method]\n path = params[:path]\n headers = params[:headers]\n body = params[:body]\n params.each do |key, value|\n if key.start_with?(\"replace_\") && !key.end_with?(\"_by\")\n path.gsub!(\"XXX#{value}XXX\",params[key + \"_by\"]) if params[key + \"_by\"] != \"\"\n headers.gsub!(\"XXX#{value}XXX\",params[key + \"_by\"]) if params[key + \"_by\"] != \"\"\n body.gsub!(\"XXX#{value}XXX\",params[key + \"_by\"]) if params[key + \"_by\"] != \"\"\n end\n end\n if params[:task_id]\n @task = Task.find(params[:task_id])\n @regexpressions = @task.regexpressions\n end\n begin\n if @cloud\n if @cloud.api == \"Atmos\"\n @response, @headers, @url = atmos_request(http_method, path, headers, body)\n elsif @cloud.api == \"Amazon\"\n @response, @headers, @url = amazon_request(http_method, path, headers, body)\n elsif @cloud.api == \"Swift\"\n @response, @headers, @url = swift_request(http_method, path, headers, body)\n end\n else\n url = path\n uri = URI.parse(url)\n headers_to_send = Hash.new\n headers.split(\"\\n\").each do |row|\n hash = eval(row)\n headers_to_send[hash.keys.first.downcase] = hash.values.first.to_s\n end\n if params[:user] != \"\" && params[:password] != \"\"\n login = Base64.urlsafe_encode64(\"#{params[:user]}:#{params[:password]}\")\n headers_to_send[\"Authorization\"] = \"Basic #{login}\"\n end\n @response = http_request(url, uri.port, http_method, headers_to_send, body)\n @headers = headers_to_send\n end\n rescue Exception => e\n @exception = e\n end\n respond_to do |format|\n format.js { render 'shared/execute_manual_request' }\n end\n end", "def api_request(input_args)\n addr = URI(api_url)\n parms = input_args.clone\n parms = api_defaults.merge(parms)\n addr.query = URI.encode_www_form(parms)\n JSON.parse(Net::HTTP.get(addr))\n end", "def execute\n\n case @template[:payload][:method]\n when 'get'\n begin\n out = RestClient.get @template[:payload][:uri]\n response = {:status => 200, :message => \"[i2] GET request on #{@template[:payload][:uri]} executed.\", :id => @template[:payload][:uri], :response => out.to_str}\n rescue Exception => e\n response = {:status => 400, :message => \"Unable to perform GET request, #{e}\"}\n Services::Slog.exception e\n end\n when 'post'\n begin\n\n case @template[:payload][:message]\n when 'form'\n out = RestClient.post @template[:payload][:uri], @template[:payload]\n when 'text/plain'\n out = RestClient.post @template[:payload][:uri], @template[:payload][:content], :content_type => 'text/plain'\n when 'application/javascript'\n if @template[:payload][:content].nil?\n out = RestClient.post @template[:payload][:uri], @template[:payload].to_json, :content_type => 'application/javascript'\n else\n out = RestClient.post @template[:payload][:uri], @template[:payload][:content], :content_type => 'application/javascript'\n end\n when \"application/json\"\n if @template[:payload][:content].nil?\n out = RestClient.post @template[:payload][:uri], @template[:payload].to_json, :content_type => 'application/json'\n else\n out = RestClient.post @template[:payload][:uri], @template[:payload][:content], :content_type => 'application/json'\n end\n when 'application/xml'\n if @template[:payload][:content].nil?\n out = RestClient.post @template[:payload][:uri], @template[:payload].to_xml, :content_type => 'application/xml'\n else\n out = RestClient.post @template[:payload][:uri], @template[:payload][:content], :content_type => 'application/xml'\n end\n when 'text/xml'\n if @template[:payload][:content].nil?\n out = RestClient.post @template[:payload][:uri], @template[:payload].to_xml, :content_type => 'text/xml'\n else\n out = RestClient.post @template[:payload][:uri], @template[:payload][:content], :content_type => 'text/xml'\n end\n when 'text/html'\n out = RestClient.post @template[:payload][:uri], @template[:payload][:content], :content_type => 'text/html'\n end\n\n response = {:status => 200, :message => \"[i2] POST request on #{@template[:payload][:uri]} executed.\", :id => @template[:payload][:uri], :response => out.to_str}\n rescue Exception => e\n response = {:status => 400, :message => \"Unable to perform POST request, #{e}\"}\n end\n when 'put'\n begin\n\n rescue Exception => e\n response = {:status => 440, :message => \"Unable to perform PUT request (not implemented), #{e}\"}\n end\n when 'delete'\n begin\n\n rescue Exception => e\n response = {:status => 440, :message => \"Unable to perform DELETE request (not implemented), #{e}\"}\n end\n end\n response\n end", "def execute_request(request:, payload:, api_config:)\n http_request = HTTPI::Request.new(request.url.try(:to_s))\n http_request.body = payload\n\n if api_config[:http_basic_username] && api_config[:http_basic_password]\n http_request.auth.basic(api_config[:http_basic_username], api_config[:http_basic_password])\n end\n\n http_request.auth.ssl.verify_mode = api_config[:ssl_verify_mode] || :peer\n http_request.open_timeout = api_config[:timeout] || 30\n http_request.read_timeout = api_config[:timeout] || 30\n\n if block_given?\n http_request = yield http_request\n end\n\n request.http_request = http_request\n\n begin\n response = HTTPI.request(request.action.http_method, http_request)\n request.http_response = response\n rescue => e\n raise RequestError.new(e, request)\n end\n\n if response.error?\n raise RequestError.new(\"#{request.action.http_method} #{request.url} returned #{response.code}\", request)\n end\n\n request\n end", "def perform_action(method, action)\n @client.send(method, \"/api/mod/conversations/#{id}/#{action}\")\n end", "def send_request; end", "def invoke_method\n unless check_preconditions\n return send_response(status: :precondition_failed)\n end\n\n method = request.request_method.downcase\n status, body = make_request method\n\n send_response status: status, body: body\n end" ]
[ "0.77791095", "0.7266592", "0.705587", "0.6855841", "0.6766559", "0.67496413", "0.67155707", "0.66886926", "0.6679214", "0.6666716", "0.6639777", "0.66321707", "0.66321707", "0.6547145", "0.65405256", "0.6539476", "0.6513818", "0.65135354", "0.6489488", "0.6482179", "0.64701986", "0.64664847", "0.64273626", "0.64182377", "0.6410505", "0.6403949", "0.6403272", "0.6397383", "0.63886404", "0.63826203", "0.6381962", "0.63774604", "0.63618994", "0.63527954", "0.6322993", "0.63163644", "0.63129765", "0.6305898", "0.62878937", "0.62842613", "0.6281802", "0.62698877", "0.62652993", "0.62622046", "0.62534034", "0.6247919", "0.62429315", "0.62425494", "0.6230412", "0.62248755", "0.6224039", "0.6205175", "0.6202046", "0.6201495", "0.6194166", "0.6192267", "0.61811996", "0.61646545", "0.6153078", "0.6147429", "0.6145011", "0.6137503", "0.6129032", "0.6123613", "0.61225307", "0.6118109", "0.61167794", "0.6106719", "0.6091802", "0.608913", "0.60801333", "0.60800874", "0.60661775", "0.60629624", "0.6062475", "0.606186", "0.60600823", "0.60542953", "0.6048982", "0.60432506", "0.6040248", "0.60359967", "0.6030113", "0.60241497", "0.60237026", "0.6023469", "0.6018318", "0.60176164", "0.6014016", "0.6011457", "0.60113734", "0.5994516", "0.59777117", "0.59742224", "0.59726167", "0.5963481", "0.5960924", "0.5958238", "0.5955748", "0.594508" ]
0.663921
11
=begin getProgress Provide process status for created instance or you can manually check status for specific hash.
def get_progress(hash=nil) if @@hash.length < 1 and hash == nil raise "Get Progress: Hash not found." end return api_call('queue-status',{"apiKey"=>@@_api_key,"hash"=>(hash!=nil)?hash:@@hash }) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_status\n response = @api.get(@cloud.url(:status, @process_id), no_callbacks: true, token: @cloud.access_token.token)\n @progress = response['ProgressPercents'].to_i\n @progress\n end", "def check_progress\n self.increment_count\n begin\n self.send(\"check_progress_#{self.type}\")\n rescue\n self.update_attributes(:status =>'not yet available')\n end\n end", "def get_progress\n listing_params = ActiveListing.get_validation_params(self)\n\n ActiveListing.new(listing_params).progress\n end", "def progress; state == 'running' ? @doc['progress'] : nil; end", "def progress\n data.progress\n end", "def progress\n return @progress\n end", "def progress\n return 100 unless @history.first\n completed_size = @history.first.jobs.select(&:completed?).size\n completed_size * 100 / @history.first.jobs.size\n end", "def progress; end", "def progress; end", "def progress; end", "def progress; end", "def progress; end", "def progress_info\n\n color=\"#AAAAAA\"\n progress=0\n message=\"Log not available.\"\n\n if self.cluster_stdout\n\n color=\"blue\"\n progress=0\n message=\"Execution not started.\"\n\n self.cluster_stdout.each_line do |line| \n if /\\([0-9]* run \\/ [0-9]* fail \\/ [0-9]* done \\/ [0-9]* left\\)/.match(line)\n run = /[0-9]* run/.match(line)[0].to_s.split[0].to_f \n done = /\\/ [0-9]* done/.match(line)[0].to_s.split[1].to_f\n failed = /\\/ [0-9]* fail/.match(line)[0].to_s.split[1].to_f\n left = /\\/ [0-9]* left/.match(line)[0].to_s.split[1].to_f\n progress=100*(run+done+failed)/(run+done+failed+left)\n # set toolbar color \n red=255*(failed)/(failed+done+run)\n blue=255*(run).to_f/(failed+done+run).to_f\n green=128*(done).to_f/(failed+done+run).to_f\n color=\"rgb(#{red.to_i},#{green.to_i},#{blue.to_i})\"\n if progress!= 100 && (\n\t CbrainTask::COMPLETED_STATUS.include?(self.status) ||\n\t CbrainTask::FAILED_STATUS.include?(self.status) ||\n\t self.status == \"Post Processing\" ||\n\t self.status == \"Data Ready\")\n color=\"red\"\n end\n if progress==100\n\t color=\"green\"\n end\n message=\"PSOM tasks: #{run.to_i} run / #{failed.to_i} fail / #{done.to_i} done / #{left.to_i} left\"\n end\n end\n end \n return {:color => color,:percentage => progress, :message => message, :show_percentage => true}\n end", "def log_progress_info(dobj, status)\n {\n status:,\n discovery_finished: true,\n pid: dobj.druid.id,\n timestamp: Time.now.utc.strftime('%Y-%m-%d %H:%M:%S')\n }\n end", "def progress\n if processed\n return 100.0\n end\n\n response = Zencoder::Job.progress(zencoder_job_id)\n \n if response.body[\"state\"] == \"finished\"\n processed!\n return 100.0\n end\n\n return response.body[\"progress\"] if response.body[\"progress\"]\n\n return 0.0\n end", "def create\n @progress = Progress.new(params[:progress])\n\n respond_to do |format|\n if @progress.save\n format.json { render json: @progress, status: :created, location: @progress }\n else\n format.json { render json: @progress.errors, status: :unprocessable_entity }\n end\n end\n end", "def progress=(value)\n @progress = value\n end", "def process_status\n @wait_thr.value\n end", "def print_progress\n @data[\"print_progress\"]\n end", "def progress(run)\n return unless run.started?\n\n progress = Progress.new(run)\n\n progress_bar = tag.progress(\n value: progress.value,\n max: progress.max,\n class: [\"progress\"] + STATUS_COLOURS.fetch(run.status)\n )\n progress_text = tag.p(tag.i(progress.text))\n tag.div(progress_bar + progress_text, class: \"block\")\n end", "def calculate_progress\n result = self.progress_status\n (100 * result.values.count(true) / result.values.compact.count).to_s\n end", "def indicate_progress\n end", "def progressValue\n return @progressValue\n end", "def check_progress\n #if (Time.zone.now - analysis_job.overall_progress_modified_at) > OVERALL_PROGRESS_REFRESH_SECONDS\n\n # https://github.com/ActsAsParanoid/acts_as_paranoid/issues/45\n was_deleted = deleted?\n if was_deleted\n old_paranoid_value = paranoid_value\n self.paranoid_value = nil\n end\n\n # skip validations and callbacks, and do not set updated_at, save value to database\n update_columns(update_job_progress)\n\n # finally, after each update, check if we can finally finish the job!\n complete! if may_complete?\n\n self.paranoid_value = old_paranoid_value if was_deleted\n end", "def create\n @progress = Progress.new(progress_params)\n\n respond_to do |format|\n if @progress.save\n format.html { redirect_to user_path(@progress.user_id), notice: 'Progress was successfully created.' }\n format.json { render :show, status: :created, location: @progress }\n else\n format.html { render :new }\n format.json { render json: @progress.errors, status: :unprocessable_entity }\n end\n end\n end", "def progress\n total_steps_count = self.steps.count\n\n if total_steps_count.zero?\n 0.0\n else\n approved_steps_count = self.steps.where(state: 'approved').count\n (approved_steps_count * 100.0 / total_steps_count).round(2)\n end\n end", "def set_progress\n @progress = Progress.find(params[:id])\n end", "def set_progress\n @progress = Progress.find(params[:id])\n end", "def progress( opts = {}, &block )\n opts = opts.symbolize_keys\n\n include_stats = opts[:stats].nil? ? true : opts[:stats]\n include_messages = opts[:messages].nil? ? true : opts[:messages]\n include_slaves = opts[:slaves].nil? ? true : opts[:slaves]\n include_issues = opts[:issues].nil? ? true : opts[:issues]\n include_errors = opts.include?( :errors ) ? (opts[:errors] || 0) : false\n\n as_hash = opts[:as_hash] ? true : opts[:as_hash]\n\n data = {\n 'stats' => {},\n 'status' => status,\n 'busy' => running?\n }\n\n data['messages'] = flush_buffer if include_messages\n\n if include_errors\n data['errors'] = errors( include_errors.is_a?( Integer ) ? include_errors : 0 )\n end\n\n if include_issues\n data['issues'] = as_hash ? issues_as_hash : issues\n end\n\n data['instances'] = {} if include_slaves\n\n stats = []\n stat_hash = {}\n stats( true, true ).each { |k, v| stat_hash[k.to_s] = v } if include_stats\n\n if master? && include_slaves\n data['instances'][self_url] = stat_hash.dup\n data['instances'][self_url]['url'] = self_url\n data['instances'][self_url]['status'] = status\n end\n\n stats << stat_hash\n\n if !has_slaves? || !include_slaves\n if include_stats\n data['stats'] = merge_stats( stats )\n else\n data.delete( 'stats' )\n end\n data['instances'] = data['instances'].values if include_slaves\n block.call( data )\n return\n end\n\n foreach = proc do |instance, iter|\n instance.framework.progress_data( opts ) do |tmp|\n if !tmp.rpc_exception?\n tmp['url'] = instance.url\n iter.return( tmp )\n else\n iter.return( nil )\n end\n end\n end\n\n after = proc do |slave_data|\n slave_data.compact!\n slave_data.each do |slave|\n data['messages'] |= slave['messages'] if include_messages\n\n if include_errors && slave['errors']\n data['errors'] ||= []\n data['errors'] |= slave['errors']\n end\n\n if include_slaves\n url = slave['url']\n data['instances'][url] = slave['stats'] || {}\n data['instances'][url]['url'] = url\n data['instances'][url]['status'] = slave['status']\n end\n\n stats << slave['stats']\n end\n\n if include_slaves\n sorted_data_instances = {}\n data['instances'].keys.sort.each do |url|\n sorted_data_instances[url] = data['instances'][url]\n end\n data['instances'] = sorted_data_instances.values\n end\n\n if include_stats\n data['stats'] = merge_stats( stats )\n else\n data.delete( 'stats' )\n end\n\n data['busy'] = slave_data.map { |d| d['busy'] }.include?( true )\n\n block.call( data )\n end\n\n map_slaves( foreach, after )\n end", "def create\n @api_v1_progress = Api::V1::Progress.new(api_v1_progress_params)\n\n respond_to do |format|\n if @api_v1_progress.save\n format.html { redirect_to @api_v1_progress, notice: 'Progress was successfully created.' }\n format.json { render :show, status: :created, location: @api_v1_progress }\n else\n format.html { render :new }\n format.json { render json: @api_v1_progress.errors, status: :unprocessable_entity }\n end\n end\n end", "def progress\n summary = exec_summary\n summary.progress.num_completed_scan_ranges.to_f / summary.progress.total_scan_ranges.to_f\n end", "def progress_ratio\n return [0, 7] if self.status_id < RegistrationNotStarted::ID\n voting_absentee? ? statuses = Status.voting_absentee_statuses : statuses = Status.voting_in_person_statuses\n progress = statuses.index(self.status) + 1 # otherwise they start at 0\n total = statuses.length\n [progress, total]\n end", "def progress=(_arg0); end", "def progress=(_arg0); end", "def progress=(_arg0); end", "def progress=(_arg0); end", "def progress(progress)\n progress = [progress] unless progress.respond_to?(:[])\n publishProgress(progress)\n end", "def create\n\n @user_repo_progress = UserRepoProgress.find_or_initialize_by(user_id: @current_user.id, reposoitory_id: params[:reposoitory_id])\n @user_repo_progress.update_attribute(:progress, '0.00')\n @user_repo_progress.save\n\n head(:created)\n\n end", "def status\n :process #default\n end", "def progress\n return @procs_queue.size / @initial_size.to_f\n end", "def progress()\n percent = (($ops / $total_ops) * 100).floor\n if (percent <= 99)\n $progress.progress = percent\n $ops += 1\n else\n $progress.finish\n end\nend", "def create\n @task_progress = TaskProgress.new(task_progress_params)\n\n respond_to do |format|\n if @task_progress.save\n format.html { redirect_to @task_progress, notice: 'Task progress was successfully created.' }\n format.json { render :show, status: :created, location: @task_progress }\n else\n format.html { render :new }\n format.json { render json: @task_progress.errors, status: :unprocessable_entity }\n end\n end\n end", "def sync_progress\n response = rpc(:block_count, _coerce: Hash)\n\n count = response[:count]\n unchecked = response[:unchecked]\n total = count + unchecked\n\n count.to_f * 100 / total.to_f\n end", "def get_progress()\n @result_tfile.rewind\n progress = @result_tfile.each_line.collect do |line|\n group = line.scan(/Completed (\\d+) requests/)\n group = group.empty? ? 0 : group[0][0]\n end\n progress.reject{|x| x == 0}.length * 10\n end", "def status\n status_async.value!\n end", "def progress(status)\n #For each SUT\n $sut.each do |ip, sut|\n #We check the status that we determined earlier,\n #depending on it we call the progress functions\n if status[ip]['status'] == 'Autotest'\n autotestprogress(status, sut, ip)\n elsif status[ip]['status'] == 'Stability'\n stabilityprogress(status, sut, ip)\n elsif status[ip]['status'] == 'CanWakeupTest'\n status[ip]['progress'] == 'Not implemented'\n elsif status[ip]['status'] == 'Manual'\n #If the test is manual, we just say it is not implemented yet. Do not know if it ever will,\n #because it is kind of impossible to know where manual test results will be saved.\n status[ip]['progress'] = 'Not implemented'\n elsif status[ip]['status'] == \"Idle\"\n latest = `ls -td #{$autotestpath}#{sut[:name]}*/ | head -n 1`[0...-1]\n latest = `ls -td #{latest}2017*/ | head -n 1`[0...-1]\n failed = `find #{latest} -name *TestRun.txt`[0...-1]\n if failed == '' && latest != ''\n status[ip]['progress'] = \"Last test failed to proceed\"\n status[ip]['progresscolor'] = \"color:red;\"\n else\n #Idle will be shown as empty in progress tab\n status[ip]['progress'] = ' '\n status[ip]['progresscolor'] = \"color:white;\"\n end\n end\n end\nend", "def check_progress\n succeed(self) if finished?\n end", "def set_status\n @completed = @progress == @number\n end", "def status\n raise ProcessNotRunningError.new \"#@prefix called .status before .run.\" unless @pid\n waitpid unless @status\n @status\n end", "def processing_status\n return @processing_status\n end", "def progress_line; end", "def set_progress state\n Vips.vips_image_set_progress self, state\n end", "def show_progress=(_arg0); end", "def progress\n l = length\n l.zero? ? 0 : 100 * time / l\n end", "def progress\n l = length\n l.zero? ? 0 : 100 * time / l\n end", "def progress\n l = length\n l.zero? ? 0 : 100 * time / l\n end", "def progressable; end", "def update_progress\n p = Progress.find_or_initialize_by(team_id:self.team_id,user_id:self.user_id,question_id:self.question_id)\n x = self.calc_progress\n if x > p.value\n p.value = x\n end\n p.save!\n end", "def status\n if not(exist?)\n return :init\n end\n\n if @ppg_filename.nil?\n return :unset\n end\n\n if Global.job_queue.active?(@id)\n return :processing\n end\n\n return :processable\n end", "def status\n { history: @history.recent(5),\n uploading: @uploader.status,\n host: @uploader.host,\n pending: pending_status_to_hash,\n upload_at: 'See Cron' }\n end", "def in_progress\n list.select {|l| l[:status] == 40 }\n end", "def get_build_progress\n total = get_total_pages\n complete = get_page_count('success')\n progress = (complete.to_f / total.to_f) * 100\n\n progress.ceil\n end", "def percent_progress\n data[:percent_progress]\n end", "def percent_progress\n data[:percent_progress]\n end", "def get_progress()\n doc = get_vre_status()\n result = {\n \"updating\" => false,\n \"ready\" => false\n }\n if doc\n doc.each {|key, value|\n if key.to_s().start_with?(\"collection_count_\")\n outputkey = key[\"collection_count_\".length..-1]\n subkey = \"count\"\n elsif key.to_s().start_with?(\"collection_finished_\")\n outputkey = key[\"collection_finished_\".length..-1]\n subkey = \"finished\"\n end\n if outputkey\n if !result.key?(outputkey)\n result[outputkey] = {}\n end\n result[outputkey][subkey] = value[0] if value\n end\n }\n if doc[:updating]\n result[\"updating\"] = !!doc[:updating][0]\n else\n result[\"updating\"] = false\n end\n if doc[:ready]\n result[\"ready\"] = !!doc[:ready][0]\n else\n result[\"ready\"] = false\n end\n end\n result\n end", "def status\n @__status\n end", "def check_project_status\n submit_process(:status) if @project.started?\n render json: state_snapshot\n end", "def ticket_progress_bar(progress)\n\n completed_hours = ticket_estimate_in_hours(progress.closed_estimated_minutes)\n total_hours = ticket_estimate_in_hours(progress.total_estimated_minutes)\n completed_percentage = if progress.total_tickets == 0 || progress.closed_tickets == 0\n 0\n else\n ((progress.closed_tickets.to_f / progress.total_tickets.to_f) * 100).ceil\n end\n\n bar = content_tag(:div, nil, style: \"width: #{completed_percentage}%\")\n bar_label = content_tag(:span, \"#{completed_percentage}%\")\n bar_container = content_tag(:div, bar + bar_label, class: 'progress-bar')\n footer = content_tag(:small, \"#{completed_hours} of #{total_hours} hours completed\")\n\n bar_container + footer\n \n end", "def progress_percentage\n progress = $redis.hgetall(redis_key)\n\n if progress.present?\n return 100 if progress['total_items'] == '0'\n (progress['processed_items'].to_f / progress['total_items'].to_f) * 100\n else\n 100\n end\n end", "def progress_mark; end", "def get_status\n\n #Create status file if needed...\n begin\n status_hash = YAML::load_file(status_file)\n rescue\n save_status\n status_hash = YAML::load_file(status_file)\n end\n\n @job_uuid = status_hash[\"job_uuid\"]\n\n @files_total = status_hash[\"files_total\"]\n @files_local = status_hash[\"files_local\"]\n @file_size_mb = status_hash[\"files_size_mb\"]\n\n #Conversion stats.\n @activities_total = status_hash[\"activities_total\"]\n @activities_converted = status_hash[\"activities_converted\"]\n\n #Consolidation stats.\n @files_consolidated = status_hash[\"files_consolidated\"]\n\n @file_current = status_hash[\"file_current\"]\n @status = status_hash[\"status\"]\n @error = status_hash[\"error\"]\n\n #Process modes.\n @enabled = status_hash[\"enabled\"]\n @download = status_hash[\"download\"]\n @convert = status_hash[\"convert\"]\n @consolidate = status_hash[\"consolidate\"]\n end", "def user_progress\n url_params = params.except(*[:id, :controller, :action]).symbolize_keys\n url_params[:user_id] = params[:id]\n\n if !can?(current_user, :get_user_progress, User.where(id: params[:id]).first)\n render status: :forbidden, json: {}\n return\n end\n\n result = @progressService.get_user_progress(url_params)\n\n render status: result.status,\n json: Oj.dump({\n info: result.info,\n organization: result.object\n }, mode: :compat)\n end", "def status\n return @task_status if job_ended?\n\n current_task_status = puppet_to_task_status(puppet_status)\n\n self.task_status = case current_task_status\n when 'successful'\n processing_succeed_task\n when 'running'\n processing_running_task\n when 'failed'\n processing_error_task\n when 'undefined'\n processing_undefined_task\n end\n\n time_is_up! if should_stop?\n @task_status\n end", "def in_progress?\n self.status == 'active'\n end", "def in_progress?\n self.status == 'active'\n end", "def get_status\n\t\tEventMachine::get_subprocess_status @signature\n\tend", "def status\n if @pbsid.nil?\n OSC::Machete::Status.not_submitted\n else\n @torque.qstat @pbsid, host: @host\n end\n end", "def get_progress_bar\n return @builder['progressbar']\n end", "def status\n instance_get(:status)\n end", "def normalization_progress(node)\n if node['progress']\n node['progress'] = 100 if node['progress'] > 100 ||\n ['ready', 'error'].include?(node['status'])\n node['progress'] = 0 if node['progress'] < 0\n else\n node['progress'] = 100 if final_status?(node['status'])\n end\n end", "def real_progress_now(date = Date.today)\n get_last_progress(date) ? get_last_progress(date).progress : 0\n end", "def progress(msg, nontty_log = T.unsafe(nil)); end", "def status\n instance.status\n end", "def status\n @parcel.status\nend", "def status\n Command::Installer::Status.new(\n *command_params\n ).execute\n rescue => e\n catch_errors(e)\n end", "def progress(object)\n reporter.progress(object)\n end", "def progress\n total = asset.pieces.count\n downloaded = total - piece_downloads.incomplete.count\n [downloaded, total]\n end", "def progress(_object)\n self\n end", "def set_task_progress\n @task_progress = TaskProgress.find(params[:id])\n end", "def status_message\n (+'').tap do |ret|\n if task.progress\n ret << \"#{(task.progress * 100).to_i}%\"\n ret << ': ' if task.progress_message.present?\n end\n ret << task.progress_message if task.progress_message.present?\n end\n end", "def progress(url)\n @progress_url = url\n end", "def images_conversion_progress\n return (\"%.2f\" % (number_of_completed_images * 1.0 / self.number_of_images_entry)).to_f if self.is_pdf_convertible? \n return 1\n end", "def latest_progress\n progress[latest_key]\n end", "def describe_progress\n if @options[:num]\n \"#{@messages.size} of #{@options[:num]} message#{'s' if @messages.size!=1} collected\"\n else\n \"#{@messages.size} message#{'s' if @messages.size!=1} collected\"\n end \n end", "def resque_progress(object, worker)\r\n\t\tresult = []\r\n\t\tif object.has_attribute?('meta_id') and !(object.meta_id.nil?)\r\n\t\t\tmeta = worker.constantize.get_meta(\"#{object.meta_id}\")\r\n\t\t\tresult = meta.progress\r\n\t\tend\r\n\t\tresult\r\n\tend", "def progress()\n return 1.0 * @done_time_units / @total_time_units\n end", "def in_progress?\n return false unless status\n status.match(/^Generated on/).nil?\n end", "def progress_params\n params.require(:progress).permit(:user_id, :company_name, :business_category, :occupation_category, :status)\n end", "def progress(percentage, description = nil)\n reply({:progress => percentage, :description => description}, {:message_type => 'progress'})\n end", "def module_progress\n userId = params[:id]\n time_unit_id = params[:time_unit_id]\n mod = params[:module]\n\n result = @progressService.get_recalculated_module_progress(userId, time_unit_id, mod)\n\n render status: result.status,\n json: {\n info: result.info,\n module_progress: result.object\n }\n end" ]
[ "0.7091271", "0.67764544", "0.6535717", "0.64436024", "0.64172184", "0.63970846", "0.63940275", "0.6329501", "0.6329501", "0.6329501", "0.6329501", "0.6329501", "0.6308591", "0.62772566", "0.6162767", "0.611275", "0.6062739", "0.60513943", "0.60277295", "0.60080534", "0.6003791", "0.5945773", "0.5932747", "0.5887766", "0.58675975", "0.58657414", "0.58616924", "0.58616924", "0.58473235", "0.5841044", "0.58389753", "0.58346546", "0.58239764", "0.58239764", "0.58239764", "0.58239764", "0.57931334", "0.57852036", "0.57677794", "0.57573295", "0.5743968", "0.57394385", "0.5721116", "0.57084584", "0.5702035", "0.56994516", "0.5696902", "0.56886417", "0.5688448", "0.56823933", "0.56557626", "0.5618181", "0.56137073", "0.5611408", "0.5611408", "0.5611408", "0.5604835", "0.5589203", "0.5585591", "0.55854434", "0.55676633", "0.55640167", "0.5556949", "0.5556949", "0.55550396", "0.5514922", "0.55078393", "0.54883915", "0.54866797", "0.5467421", "0.54609746", "0.54513913", "0.5435209", "0.5428854", "0.5428854", "0.5427155", "0.5424048", "0.54159397", "0.5415599", "0.5402101", "0.53944683", "0.53928864", "0.5388759", "0.53871757", "0.53847456", "0.53807503", "0.5377785", "0.537548", "0.5374253", "0.53733003", "0.5372148", "0.53702927", "0.5360305", "0.5358546", "0.5353852", "0.53497493", "0.534803", "0.533829", "0.53377193", "0.53336066" ]
0.64988923
3
=begin deleteFile Delete file from server after process or you can manually delete for specific hash.
def delete_file(hash=nil) if @@hash.length < 1 && hash === nil raise "Delete File: Hash not found." end return api_call('queue-manager',{"apiKey"=>@@_api_key,"hash"=>(hash!=nil)?hash:@@hash, "method"=>"deleteFile" }); end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete(filename); end", "def delete_file\n File.unlink file\n end", "def delete_file\n File.unlink file\n end", "def destroy_file\n Qiniu::RS.delete(qiniu_config[:bucket_name], full_filename)\n end", "def destroy_file\n File.delete full_file_path\n rescue\n end", "def delete_file(file)\n delete_attachment(file)\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 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\n @file = nil\n # file.delete\n end", "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 del\n File.delete(@file)\n end", "def delete_file\n begin\n File.delete(stored_file_path)\n rescue => e\n logger.error(\"Could not delete #{stored_file_path}. Ignored.\")\n logger.error(e)\n end\n end", "def deleteFile(filePath, dryRun)\n #N Without this, the deletion command won't be run at all\n sshAndScp.deleteFile(filePath, dryRun)\n end", "def destroy\n file&.delete\n 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_file\n start_ssh do |ssh|\n ssh.exec!(\"rm #{e full_filename}\")\n dir = File.dirname(full_filename)\n ssh.exec!(\"find #{e dir} -maxdepth 0 -empty -exec rm -r {} \\\\;\")\n dir = File.dirname(dir)\n ssh.exec!(\"find #{e dir} -maxdepth 0 -empty -exec rm -r {} \\\\;\")\n end\n end", "def delete_file(filename,repo)\n curl_delete(\"#{self.host}/api2/repos/#{repo}/file/?p=#{filename}\").body_str\n end", "def delete!\n safe_close\n File.delete(@file_path)\n end", "def delete(bucket, file); end", "def deleteFile(filePath, dryRun)\n #N Without this, the required ssh command to delete a file won't be (optionally) executed.\n ssh(\"rm #{filePath}\", dryRun)\n end", "def destroy\n @file_version.destroy\n head :no_content\n end", "def b2_delete_file(file)\n\n if parse_files_json(file) == {}\n\n puts \"File not present\"\n\n else\n \n result_hash = convert_json(b2_delete_file_version(file))\n\n if result_hash[\"fileName\"] == file\n puts \"File deleted successfully\"\n else\n puts \"Error deleting file\"\n end\n\n end\n\nend", "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_file(uid, info = {})\n if info[\"multipart_id\"]\n multipart_upload = object(uid).multipart_upload(info[\"multipart_id\"])\n abort_multipart_upload(multipart_upload)\n\n delete [object(\"#{uid}.info\")]\n else\n delete [object(uid), object(\"#{uid}.info\")]\n end\n end", "def delete_file(filename)\r\n DeleteFile.new(filename)\r\n end", "def delete_file( path )\n # removes a file at path\n connection.delete( path )\n last_ftp_command_ok?\n end", "def _delete(uploaded_file, context)\n remove(uploaded_file, context)\n end", "def delete_file(filename)\n http.delete([204,404], luwak, escape(filename))\n true\n end", "def delete_file\n @file = []\n end", "def delete\n File.delete(file_name)\n rescue\n # ignore\n end", "def delete_file_from_db(file_id)\n $db.execute(\"DELETE FROM files WHERE file_id = ?\", file_id)\nend", "def delete\n unless FileDescriptor.exists?(filename: params[:fname])\n fpath = filePath params[:fname]\n begin\n File.delete fpath\n result = {status: 'ok'}\n status = 200\n rescue Exception => e\n result = {status: 'error', message: e.message}\n status = 500\n end\n else\n result = {status: 'error', message: 'File is open'}\n status = 403 # Forbidden\n end\n render json: result.to_json, status: status\n end", "def destroy_file\n db_file.destroy if db_file\n end", "def destroy_file\n object = self.class.bucket.objects.find(full_filename)\n object.destroy\n end", "def delete_file!(file_id)\n execute!(api_method: drive.files.delete, parameters: { fileId: file_id })\n end", "def destroy(file=@file)\n if self.legacy?\n return unless @password.send(:rm_file, self) \n end\n super\n end", "def delete(remote_filepath)\n @request = Net::HTTP::Delete.new(::File.join(@uri.path, remote_filepath))\n @request.basic_auth @username, @password\n\n @response = @http.request(@request)\n @response.body.presence || @response.code.to_i\n end", "def delete_file(uid, info = {})\n grid_info = files_collection.find(filename: uid).first\n bucket.delete(grid_info[:_id]) if grid_info\n end", "def delete_firmware_file(file)\n response = request(:delete, \"/devmgr/v2/firmware/upload/#{file}\")\n status(response, 204, 'Failed to delete firmware file')\n end", "def destroy\n pid = @generic_file.noid\n @generic_file.delete\n begin\n Resque.enqueue(ContentDeleteEventJob, pid, current_user.user_key)\n rescue Redis::CannotConnectError\n logger.error \"Redis is down!\"\n end\n redirect_to sufia.dashboard_path, :notice => render_to_string(:partial=>'generic_files/asset_deleted_flash', :locals => { :generic_file => @generic_file })\n end", "def delete\n Modeles::File.delete @fileInTable.id\n @errors = nil\n @fileInTable = nil\n @path = nil\n @user = nil\n @group = nil\n @userRights = nil\n @groupRights = nil\n @othersRights = nil\n end", "def destroy_file\n FileUtils.rm(full_filename) if File.exists?(full_filename)\n end", "def smb_file_rm(file)\n fd = smb_open(file, 'ro')\n fd.delete\nend", "def delete(command)\n pp @client.files.delete(clean_up(command[1]))\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 deleteEssence\n \n begin\n \n # Gets @filename and @path\n getPathAndFilename \n name = @filename \n filepath = @path\n puts \"filepath: \" + filepath \n puts \"filename: \" + name\n \n # Find the device \n device = User.find_by_username(params[:username]).devices.find_by_dev_name(params[:devicename])\n \n # Essence can't be deleted from a virtual container\n if device.dev_type == \"virtual_container\"\n render :text => \"Error: Essence can't be deleted from a virtual container'\", :status => 409\n return \n end\n \n file = nil\n if device != nil\n file = device.devfiles.find(:first, :conditions => [\"name = ? and path = ?\", name, filepath])\n if file == nil\n puts \"FILE NOT FOUND: \" + name\n render :text => \"Error. File's metadata can not be found.\", :status => 404\n return\n end\n \n if params[:blob_hash]\n blob = file.blobs.find(:first, :conditions => [\"blob_hash = ?\", params[:blob_hash]])\n else\n blob = file.blobs.find_by_follower_id(nil)\n end\n end\n \n # Checks that the file's and it's version's metadata can be found in database.\n if file == nil or blob == nil\n puts \"Blob not found for file: \" + name\n render :text => \"Error. File's metadata can not be found.\", :status => 404\n return\n end\n \n if blob.uploaded == false\n render :text => \"Error: Essence of the file was not on the server.\", :status => 409\n return\n end\n \n # Remove the fileupload entry\n fup = Fileupload.find_by_blob_id(blob.id)\n if fup != nil\n fup.destroy\n end\n \n # Update blob not to be uploaded and upload_requested to nil\n blob.update_attribute(:uploaded, false)\n blob.update_attribute(:upload_requested, nil)\n \n \n # Remove the actual essence\n deletepath = \"public/devfiles/\" + file.device_id.to_s + \"/\" + blob.blob_hash + \"_\" + file.name\n \n if File.exists?(deletepath)\n FileUtils.rm_f(deletepath)\n puts \"deleted the essence...\"\n else\n puts \"Essence not found and could not be deleted...\"\n end\n \n rescue => exp\n putsE(exp)\n render :text => \"There was an error when trying to delete the essence from the server\", :status => 409\n return\n end\n \n render :text => \"Essence of the file deleted from the server\", :status => 200\n return\n end", "def destroy\n \n @user_file = UserFile.find(params[:id])\n authorize! :destroy, @user_file\n name=@user_file.uploaded_file_file_name\n @user_file.destroy\n\n respond_to do |format|\n format.html { redirect_to :back,:notice=>\"Deleted file: \"+name }\n format.json { head :ok }\n end\n end", "def delete_file(no_raise: true)\n __debug_items(binding)\n return if destroyed? || attached_file.nil?\n file_attacher.destroy\n file_attacher.set(nil)\n rescue => error\n log_exception(error, __method__)\n re_raise_if_internal_exception(error)\n raise error unless no_raise\n end", "def delete_file storage_file_path\n @bucket.file(storage_file_path).delete if @bucket.file storage_file_path\n end", "def delete_file storage_file_path\n @bucket.file(storage_file_path).delete if @bucket.file storage_file_path\n end", "def remove(filename); end", "def delete uri\n @change_semaphore.synchronize do\n filename = uri_to_file(uri)\n library.delete filename\n # Remove diagnostics for deleted files\n send_notification \"textDocument/publishDiagnostics\", {\n uri: uri,\n diagnostics: []\n }\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_file_parts\n #TODO implementation\n end", "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_file(f)\n #return false if !f.kind_of?(Fog::Storage::AWS::File) || !storage_provider.eql?(:aws)\n log \"Deleting: #{f.key}\"\n return f.destroy\n end", "def destroy\n @upload = @upload = Upload.find_by(id: params[:id], user_id: current_or_guest_user.id)\n @file = ActiveStorage::Attachment.find(params[:file])\n @file&.purge\n @upload.destroy unless @upload.files.present?\n flash[:success] = 'File Deleted Successful!'\n redirect_to root_path\n rescue StandardError => error\n flash[:danger] = 'File Does Not Exist!'\n flash[:error] = error.message\n redirect_to root_path\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_file \n #pp \"deleting file_asset: path is\" + full_filepath\n File.delete(full_filepath) if File.exists?(full_filepath)\n end", "def delete(filename)\n File.delete File.join(@base_path, filename)\n end", "def destroy\n Rails.logger.debug {\"destroying gridfs file #{@id}\"}\n if persisted?\n Photo.mongo_client.database.fs.find(:_id=>BSON::ObjectId.from_string(@id)).delete_one\n end\n end", "def test_delete_file\n remote_file_name = 'TestDeleteFile.docx'\n\n upload_file File.join(local_test_folder, local_file), remote_data_folder + '/' + remote_file_name\n\n request = DeleteFileRequest.new(path: remote_data_folder + '/' + remote_file_name)\n\n @words_api.delete_file(request)\n end", "def delete(uploaded_file, context = {})\n _delete(uploaded_file, context)\n uploaded_file\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 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 delete_file(basepath = MP3_STORAGE_PATH)\n FileUtils.rm_rf(\"#{basepath}/#{id}\")\n end", "def delete_file\n\n #delete the file\n Chef::Log.debug \"DEBUG: Removing file #{ node[\"php_fpm\"][\"pools_path\"] }/#{ @new_resource.pool_name }.conf!\"\n ::File.delete(\"#{ node[\"php_fpm\"][\"pools_path\"] }/#{ @new_resource.pool_name }.conf\")\n\nend", "def delete_uploaded_file(new_file)\n if version_name.blank? && Refinery::PhotoGallery.delete_uploaded_file\n filename_to_delete = File.join(Rails.root.to_s,Refinery::PhotoGallery.photo_gallery_dir_relative_to_root, store_dir, filename )\n File.delete(filename_to_delete)\n end\n end", "def delete\n ::File.unlink(@path)\n end", "def delete!(uploaded_file, phase:)\n store.delete(uploaded_file, context.merge(phase: phase))\n end", "def delete\n @uppity_file = PostedFile.get(params[:id])\n @uppity_file.destroy\n redirect_to(posts_index_url)\n end", "def file_delete(file)\n\t\tputs \"Delete the local host repository entries from file: #{file}\"\n\t\traise \"File non-exist. Please check your file path and name again: #{file}\" unless File.exist?(file)\n\t\thosts=file_2_list(file)\n\t\tchanges=bulk_delete(hosts)\n\t\tputs \"Delete done.\"\n\t\treturn changes\n\trescue => ee\n\t\tputs \"Exception on method #{__method__}: #{ee}\"\n\tend", "def deleteFile(file_path)\n puts \"Delete file: \" + file_path.to_s\n File.delete(file_path) if File.exist?(file_path)\nend", "def destroy\n File.unlink(@resource[:path])\n Puppet.debug \"deleted file #{@resource[:path]}\"\n end", "def delete_file(filename)\n begin\n File.delete(filename)\n rescue Exception => e\n puts e.message\n end\n end", "def rm_file(file)\n @files.delete(file.path)\n end", "def destroy_file(project_id, file_id)\n params = { query: [project_id, file_id] }\n\n data = endpoint(name: 'Files', params: params).do_delete\n\n RubyLokaliseApi::Generics::DeletedResource.new data.content\n end", "def delete_file(file_name)\n dst_path = \"#{self.path}#{file_name}\"\n if self.class.curr_host == host\n begin\n File.delete(dst_path)\n rescue Errno::EISDIR\n FileUtils.rm_r(dst_path)\n rescue Errno::ENOENT\n end\n else\n cmd = \"ssh -q -oBatchMode=yes -oStrictHostKeyChecking=no #{self.host} \\\"rm -rf #{dst_path.shellescape}\\\"\"\n r = `#{cmd} 2>&1`\n raise r if $?.exitstatus != 0\n \n cmd = \"ssh -q -oBatchMode=yes -oStrictHostKeyChecking=no #{self.host} \\\"ls -la #{dst_path.shellescape}\\\"\"\n r = `#{cmd} 2>/dev/null`\n raise \"Path #{dst_path} not deleted\" unless r.empty?\n end\n end", "def delete_file(file_name)\n dst_path = \"#{self.path}#{file_name}\"\n if self.class.curr_host == host\n begin\n File.delete(dst_path)\n rescue Errno::EISDIR\n FileUtils.rm_r(dst_path)\n rescue Errno::ENOENT\n end\n else\n cmd = \"ssh -q -oBatchMode=yes -oStrictHostKeyChecking=no #{self.host} \\\"rm -rf #{dst_path.shellescape}\\\"\"\n r = `#{cmd} 2>&1`\n raise r if $?.exitstatus != 0\n \n cmd = \"ssh -q -oBatchMode=yes -oStrictHostKeyChecking=no #{self.host} \\\"ls -la #{dst_path.shellescape}\\\"\"\n r = `#{cmd} 2>/dev/null`\n raise \"Path #{dst_path} not deleted\" unless r.empty?\n end\n end", "def delete_session_file(file)\n File::delete(file[:filename]) if File::exist?(file[:filename])\n File::delete(file[:original_tmp_filename]) if file[:original_tmp_filename] && File::exists?(file[:original_tmp_filename])\n if session[:image_upload]\n for association_name in session[:image_upload].keys\n break if image_upload_session(association_name)[:uploaded_files].delete(file)\n end\n end\n end", "def gp_delete_file(aid)\n data = Asn1Ber.encode [{:class => :application, :primitive => true,\n :number => 0x0F, :value => aid}]\n response = iso_apdu! :cla => 0x80, :ins => 0xE4, :p1 => 0x00, :p2 => 0x80,\n :data => data\n delete_confirmation = response[1, response[0]]\n delete_confirmation\n end", "def delete (fei)\n\n fei_path = compute_file_path(fei)\n\n #ldebug { \"delete() for #{fei.to_debug_s} at #{fei_path}\" }\n\n File.delete(fei_path)\n end", "def remove!\n FileUtils.rm(File.join(remote_path, remote_file))\n end", "def delete(http_connection)\n success = true\n tries ||= 3\n display = []\n display.push file_path\n if File.exists?(self.file_path)\n begin\n request = Net::HTTP::Delete.new(api_url_for_delete)\n WebTranslateIt::Util.add_fields(request)\n display.push Util.handle_response(http_connection.request(request))\n puts ArrayUtil.to_columns(display)\n rescue Timeout::Error\n puts StringUtil.failure(\"Request timeout. Will retry in 5 seconds.\")\n if (tries -= 1) > 0\n sleep(5)\n retry\n else\n success = false\n end\n rescue\n display.push StringUtil.failure(\"An error occured: #{$!}\")\n success = false\n end\n else\n puts StringUtil.failure(\"\\nMaster file #{self.file_path} doesn't exist locally!\")\n end\n return success\n end", "def delete_from_disk; 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_remote\n policy = get_policy(\"remove\")\n signature = get_signature(policy)\n remote = url+\"?signature=\"+signature+\"&policy=\"+policy\n try = self.class.delete(remote)\n\n # If file not found in filepicker, destroy anyway, else only if success\n if try.not_found?\n true\n else\n try.success?\n end\n end", "def destroy\n authorize! :destroy, @master_file, message: \"You do not have sufficient privileges to delete files\"\n filename = File.basename(@master_file.file_location) if @master_file.file_location.present?\n filename ||= @master_file.id\n media_object = MediaObject.find(@master_file.media_object_id)\n media_object.ordered_master_files.delete(@master_file)\n media_object.master_files.delete(@master_file)\n media_object.save\n @master_file.destroy\n flash[:notice] = \"#{filename} has been deleted from the system\"\n redirect_to edit_media_object_path(media_object, step: \"file-upload\")\n end", "def super_delete(filepath)\n # Thanks, Windows. http://alx.github.io/2009/01/27/ruby-wundows-unlink.html\n 10.times do\n begin\n File.delete(filepath)\n break\n rescue\n @logger.warn(\"Unable to delete file #{filepath}\")\n sleep 0.05\n end\n end\n end", "def deleteFile(bucket, file, client)\n\tfilename = File.basename(file)\n\tbegin\n\t \tresp = client.client.delete_objects({\n\t \t\tbucket: bucket,\n\t\t\tdelete: { objects: [\n\t\t\t\t{ key: filename }\n\t\t\t],\n\t\t\tquiet: false }\n\t\t})\n\trescue Exception => e\n\t\tputs \"Wrong file name\"\n\t\tputs e\n\t\texit\n\tend\n\treturn resp\nend", "def rm_file(file)\n @files.delete(file.path)\n end", "def destroy\n @upload_file = UploadFile.find(params[:id])\n\t\tauthorize! :destroy, @upload_file\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 destroy\n @file = UserUpload.find(params[:id])\n if @file\n \t@file.destroy\n end\n # Render nothing to denote success\n render :text => \"\" and return\n end", "def b2_delete_file_version(file)\n\n auth_hash = convert_json(b2_authorize_account)\n api_url = auth_hash[\"apiUrl\"]\n account_authorization_token = auth_hash[\"authorizationToken\"]\n\n file_hash = parse_files_json(file)\n file_name = file\n file_id = file_hash[file]\n\n uri = URI(\"#{api_url}/b2api/v1/b2_delete_file_version\")\n req = Net::HTTP::Post.new(uri)\n req.add_field(\"Authorization\",\"#{account_authorization_token}\")\n req.body = \"{\\\"fileName\\\":\\\"#{file_name}\\\", \\\"fileId\\\":\\\"#{file_id}\\\"}\"\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 destroy_dirty_file!(file)\n system(\"trashtrash #{file}\")\n end", "def deleteUploadFile\n\n filepath = Rails.root.join(path, file_name)\n\n if File.exist? filepath \n File.delete filepath\n end\n\n end", "def delete\n @lock.synchronize do\n ::File.unlink(@tmpfile) if ::File.exist?(@tmpfile)\n end\n end", "def destroy\n @upload_file_to_server.destroy\n respond_to do |format|\n format.html { redirect_to upload_file_to_servers_url, notice: 'Upload file to server was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @attachment.file.purge\n @attachment.destroy\n respond_to do |format|\n format.html { redirect_to lines_url, notice: 'Attachment was successfully destroyed.' }\n end\n end" ]
[ "0.73422194", "0.7309502", "0.7309502", "0.7259103", "0.71199125", "0.7115461", "0.70857453", "0.7083061", "0.7082959", "0.7033079", "0.7033079", "0.6990905", "0.6967677", "0.6964429", "0.6955098", "0.6925234", "0.690997", "0.6902744", "0.6896549", "0.68585706", "0.68562996", "0.68422", "0.6838267", "0.68358916", "0.6825104", "0.682042", "0.6818054", "0.6814301", "0.67970055", "0.6789409", "0.6751504", "0.67217517", "0.67144036", "0.6695395", "0.66813916", "0.66725993", "0.66347444", "0.6633949", "0.6628158", "0.6626943", "0.6625865", "0.66235477", "0.6622126", "0.65829164", "0.6578219", "0.65736926", "0.65735674", "0.65705186", "0.65589875", "0.65537524", "0.65537524", "0.6552159", "0.65493906", "0.65445834", "0.65404016", "0.6540328", "0.65401936", "0.65271074", "0.65263015", "0.65204537", "0.6519464", "0.6495486", "0.64925283", "0.64912134", "0.648341", "0.6476346", "0.64739394", "0.6471344", "0.64693666", "0.6468864", "0.64549166", "0.6449123", "0.6441904", "0.6441124", "0.64387596", "0.6438253", "0.64104736", "0.64053047", "0.6380652", "0.6380652", "0.63749945", "0.6372356", "0.63705903", "0.63671327", "0.6361709", "0.636031", "0.6354891", "0.63527304", "0.6350058", "0.6347465", "0.63421446", "0.6340534", "0.6339988", "0.63363", "0.6335691", "0.6333632", "0.6332426", "0.6323554", "0.6320422", "0.6317704" ]
0.71981096
4
=begin Get free api server information.
def get_server(target_type) return api_call('get-queue',{'apiKey' => @@_api_key,'targetType' => target_type}); end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def server_info\n return @server_info if @server_info.present?\n response = request :get, SERVER_INFO_PATH\n @server_info = response.error? ? nil :\n response.result.with_indifferent_access\n end", "def server_info()\n #This is a stub, used for indexing\n end", "def server_info\n check_connection\n @protocol.server_info\n end", "def info\n get(\"/api-info\")\n end", "def servers_detailed()\n return get_request(address(\"/servers/detail\"), @token)\n end", "def getinfo\n @api.request 'getinfo'\n end", "def get_server\n get_general['server']\n end", "def info\n response = rpc.request Riakpb::Util::MessageCode::GET_SERVER_INFO_REQUEST\n\n @node = response.node\n @server_version = response.server_version\n\n {:node => @node, :server_version => @server_version}\n end", "def details\n data = servers_client.get(server_path, json_headers).body\n JSON.parse(data)['server']\n end", "def servers\n endpoint = 'https://pcs.baidu.com/rest/2.0/pcs/manage?method=listhost'\n @res = @api.request_json( endpoint )\n end", "def server_info\n db(\"admin\").command({:buildinfo => 1}, {:admin => true, :check_response => true})\n end", "def info\n response = from_server \"api/info.json\"\n response.data\n end", "def server_settings\n [\n {\n url: \"https://api.shipengine.com\",\n description: \"No description provided\",\n }\n ]\n end", "def api_info(req)\n client.request(req) do |response|\n json_response = ::RHC::Json.decode(response.content)\n [ json_response['supported_api_versions'], json_response['api_version'] || json_response['version'].to_f, json_response['data'] ]\n end\n end", "def servers\n response = get \"server\"\n data = JSON.parse response.body\n data[\"servers\"][\"server\"]\n end", "def servers\n response = get \"server\"\n data = JSON.parse response.body\n data[\"servers\"][\"server\"]\n end", "def info\n result = []\n Server.all.each do |server|\n result << server.short_result\n end\n\n status_key = makeStatusKey(result)\n render :json => {servers:result}.merge(status_key)\n\n end", "def server\n arrayCommand( \"show server\", DictArray, RESPONSE_SERVER_INFO_FOLLOWS )\n end", "def server\n arrayCommand( \"show server\", DictArray, RESPONSE_SERVER_INFO_FOLLOWS )\n end", "def server_info\n {:node => \"riak@#{node.host}\", :server_version => '2.0'}\n end", "def getinfo\n request :getinfo\n end", "def info\n connection.server_info\n end", "def server_info!\n @server_info = nil\n server_info\n end", "def get_sys_info(server)\n server_id = server['id']\n conn_path = @connection.call('system.get_connection_path', @sid, server_id)\n puts conn_path\n end", "def net_http_get_package_info\n thread = @thread\n timestamp = Time.now.utc.strftime(\"%Y-%m-%dT%H:%M:%S\\+0000\")\n\n uri = URI(\"#{@sendsafely_url}/#{API}/package/#{@thread}/\")\n\n req = Net::HTTP::Get.new(uri)\n req['Content-Type'] = 'application/json'\n req['ss-api-key'] = @sendsafely_key_id\n req['ss-request-timestamp'] = timestamp\n req['ss-request-signature'] = OpenSSL::HMAC.hexdigest(\"SHA256\", @sendsafely_key_secret, @sendsafely_key_id+\"/#{API}/package/#{thread}\"+timestamp)\n\n res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) {|http|\n http.request(req)\n }\n\n puts res.body\n end", "def server_status\n http_get(:uri=>\"/server/status\", :fields=>x_cookie)\n end", "def server_settings\n [\n {\n url: \"https://api.samsara.com/v1\",\n description: \"No descriptoin provided\",\n }\n ]\n end", "def overview\n request_uri = \"#{@api_endpoint}/#{@key}\"\n HTTParty.get(request_uri)\n end", "def overview\n request_uri = \"#{@api_endpoint}/#{@key}\"\n HTTParty.get(request_uri)\n end", "def servers # Only in Ruby API (1.3 compatible)\n\t\t@settings.servers\n\tend", "def api_server\n @api_server ||= NewRelic::Control::Server.new(Agent.config[:api_host], Agent.config[:api_port])\n end", "def server_settings\n [\n {\n url: \"https://api.cammio.me/api/v2\",\n description: \"No description provided\",\n }\n ]\n end", "def info\n request('getinfo')\n end", "def server_software; end", "def api_version\n self.class.get('/api')['api_ver']\n end", "def info\n IbmCloudRest.get \"#{@uri}/\"\n end", "def available_servers\n authenticate_user!\n @rackspace_servers = Server.rackspace_servers\n end", "def api_version\n request('getAPIVersion')\n end", "def read_host_info\n json { execute_prlctl('server', 'info', '--json') }\n end", "def run_cve_2021_26855\n # request for internal server name.\n response = send_http(datastore['METHOD'], \"localhost~#{random_ssrf_id}\")\n if response.code != 500 || !response.headers.to_s.include?('X-FEServer')\n fail_with(Failure::NotFound, 'No \\'X-FEServer\\' was found')\n end\n\n server_name = response.headers['X-FEServer']\n print_status(\"Internal server name (#{server_name})\")\n\n # get informations by autodiscover request.\n print_status(message('Sending autodiscover request'))\n server_id, legacy_dn = request_autodiscover(server_name)\n\n print_status(\"Server: #{server_id}\")\n print_status(\"LegacyDN: #{legacy_dn}\")\n\n # get the user UID using mapi request.\n print_status(message('Sending mapi request'))\n sid = request_mapi(server_name, legacy_dn, server_id)\n print_status(\"SID: #{sid} (#{datastore['EMAIL']})\")\n\n # search oab\n sid, session, canary, oab_id = search_oab(server_name, sid)\n\n [server_name, sid, session, canary, oab_id]\n end", "def api\n {\n 'host' => self['apiHost'],\n 'password' => self['apiPassword'],\n 'path' => self['apiPath'],\n 'port' => self['apiPort'],\n 'protocol' => self['apiProtocol'],\n 'username' => self['apiUsername']\n }\n end", "def api_version\n @api_version ||= begin\n pool = self.pool.get_all[0]\n host = self.pool.get_master(pool)\n major = self.host.get_API_version_major(host)\n minor = self.host.get_API_version_minor(host)\n \"#{major}.#{minor}\"\n end\n end", "def host\n conf['api']['host']\n end", "def server\r\n\t\t@usr_server\r\n\tend", "def info\n CouchRest.get \"#{@uri}/\"\n end", "def fetch_basic_info\n {\n server: Socket.gethostname,\n rails_root: defined?(Rails) ? Rails.root : nil,\n process: $PROCESS_ID,\n uname: Sys::Uname.uname,\n timestamp: @timestamp,\n pwd: File.expand_path($PROGRAM_NAME)\n }\n end", "def rest\n @rest ||= Chef::ServerAPI.new(server.root_url, {:api_version => \"0\"})\n end", "def show\n @server_info = ServerInfo.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @server_info }\n end\n end", "def api\n self.well_info.api\n end", "def api\n @api\n end", "def server\n platform.server\n end", "def api_object\n unless $api\n $api = FyberAPI.new(\n 'b07a12df7d52e6c118e5d47d3f9e60135b109a1f',\n {\n appid: 157,\n format: 'json',\n device_id: '2b6f0cc904d137be2e1730235f5664094b83',\n locale: 'de',\n ip: '109.235.143.113'\n }\n )\n end\n $api\n end", "def getwalletinfo\n @api.request 'getwalletinfo'\n end", "def get_devserver\n devserver = all_info[:devserver]\n if devserver!=nil\n return devserver.split(':').last\n end\n end", "def nameserver_info\n facts.fetch(\"Nameserver\", {})\n end", "def http_servers\r\n HTTPServersController.instance\r\n end", "def print_server_details\n @check_server_status_array = Array.new(@lpar_id_array)\n get_url('compute')\n @check_server_status_array.each do |lpar|\n @server_status_print = rest_get(\"#{@resource_url}/servers/#{lpar}\", @token_id)\n @server_status = JSON.parse(@server_status_print)['server']\n @server_name_print = @server_status['name']\n @server_addresses = JSON.parse(@server_status_print)['server']['addresses']\n begin\n @server_ip4address = @server_addresses.values[0][0]['addr']\n puts \"LPAR Name: #{@server_name_print}, IP Address: #{@server_ip4address}\"\n rescue\n puts \"Deploy of LPAR Name #{@server_name_print} has resulted in error. Please login to PowerVC GUI to check further.\"\n end\n end\n end", "def get_serv_config\n\t\taction = \"configuration\"\n\t\tresponse = call_api(action)\n\tend", "def apis; end", "def get_api_version\n response = send_api_request(:index)\n response[:returncode] ? response[:version].to_s : \"\"\n end", "def info() \n \treturn self.response.info()\n\tend", "def sysinfo\n\t\trequest = Packet.create_request('stdapi_sys_config_sysinfo')\n\t\tresponse = client.send_request(request)\n\n\t\t{\n\t\t\t'Computer' => response.get_tlv_value(TLV_TYPE_COMPUTER_NAME),\n\t\t\t'OS' => response.get_tlv_value(TLV_TYPE_OS_NAME),\n\t\t}\n\tend", "def api_host #:nodoc:\n API_URI\n end", "def host\n \"https://api.monzo.com/\"\n end", "def api\n return @api\n end", "def api_mode; end", "def server\n uri = \"#{options[:use_ssl] ? \"https\" : \"http\"}://#{Blupee.config.api_server}\"\n end", "def get url\n puts \"COMMUNICATING WITH TOGGL SERVER COMMUNICATING WITH TOGGL SERVER\"\n uri = URI.parse( url )\n http = Net::HTTP.new( uri.host, uri.port )\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n request = Net::HTTP::Get.new( uri.request_uri )\n request.basic_auth( @api_key, \"api_token\" )\n request[\"Content-Type\"] = \"application/json\"\n response = http.request( request )\n \n if response.code.to_i==200 # OK\n hash = JSON.parse( response.body )\n elsif response.code.to_i==403 # Authentication\n raise Exceptions::AuthenticationError\n else\n puts \"Error, code #{ response.code }.\"\n puts response.body\n end\n end", "def get_api_version\n response = send_api_request(:index)\n if response[:returncode]\n response[:version].to_s\n else\n \"\"\n end\n end", "def info(url)\n rest = RestClient::Request.execute(\n method: :get,\n url: url,\n user: ENV['USER'],\n password: ENV['KEY'],\n headers: {\"Content-Type\" => \"application/json\"}\n )\n JSON.parse(rest, :symbolize_names => true)\n rescue RestClient::Exception\n \"Sorry something went wrong with the API\"\n end", "def get_version\n prepare\n @api.get_api_version\n end", "def get_zapp_server\n return self.plant_attributes[self.plant.intern][self.env.intern][:host], self.plant_attributes[self.plant.intern][self.env.intern][:soap_port]\n end", "def servers\n Vultr::Resource::Server.new(@faraday)\n end", "def show\n @server = Server.find(params[:id])\n checkaccountobject(\"servers\",@server)\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @server }\n end\n end", "def cobbler_info(system_name,options)\n connection = XMLRPC::Client.new2(\"#{options[:cobbler_api]}\")\n system_data = connection.call(\"get_system_as_rendered\",\"#{system_name}\")\n return(system_data)\nend", "def show\n @licserver = Licserver.find(params[:id])\n\n\t\trespond_to do |format|\n\t\t\tformat.template\n\t\t\tformat.html\n\t\t\tformat.json {\n\t\t\t\trender json: {\n\t\t\t\t\t:name => @licserver.get_port_at_server,\n\t\t\t\t\t:type => @licserver.license_type_id,\n\t\t\t\t\t:tags => @licserver.tags.map{ |x| x.title }.join(\" \")\n\t\t\t\t}\n\t\t\t}\n\t\tend\n end", "def get_server_version\n server_info[:server_version]\n end", "def all_companies_information\n\t\tbegin\n\t url = URI.parse(Rails.application.secrets[:api_endpoints]['onething']['url_company_info'])\n\t\t url_params = {}\n\t\t path = \"#{url.path}?#{url_params.collect { |k,v| \"#{k}=#{CGI::escape(v.to_s)}\"}.join('&')}\"\n\t\t request = Net::HTTP::Get.new(path) \n\t\t response = Net::HTTP.start(url.host, url.port, :use_ssl => false, :verify_mode => OpenSSL::SSL::VERIFY_NONE) do |http| \n\t\t http.request(request)\n\t\t end \n\t\t json_data = JSON.parse(response.body) rescue nil\n\t\t if !json_data.present?\n\t\t \treturn {}\n\t\t else\n\t\t return json_data\n\t\t end\n\t rescue => e\n\t \treturn {:message => 'Error in fetchng API data. Please try again.'}\t\n\t end\n\tend", "def get_info\n end", "def get_info\n end", "def get_info\n end", "def api_version\n Gandi.call('version.info')['api_version']\n end", "def available_server\n @context.server.each do |server_name|\n begin\n return Rack::Handler.get(server_name.downcase)\n rescue LoadError\n rescue NameError\n end\n end\n raise \"servers #{@context.server.join(', ')} not found\"\n end", "def get_api endpoint\n\turi = URI.parse(\"http://#{@HOST}:#{@HTTP}#{endpoint}\")\n\trequest = Net::HTTP::Get.new(uri)\n\trequest[\"Accept\"] = \"application/json\"\n\toptions = { use_ssl: uri.scheme == \"https\" }\n\tresponse = Net::HTTP.start(uri.hostname, uri.port, options) do |http|\n\t\thttp.request(request)\n\tend\nend", "def get_servers\n\t\t\tbegin\n\t\t\t\tresp = @rs_conn.get('/servers')\n\n\t\t\t\t# 200 Success :: anything else is failure\n\t\t\t\tunless resp.code == \"200\"\n\t\t\t\t\traise \"Error requesting server list. Error code #{resp.code}\"\n\t\t\t\tend\n\t\t\t\t# Convert the output to json\n\t\t\t\tserver_list = JSON.parse(resp.body)\n\t\t\t\treturn server_list\n\t\t\trescue Exception => e\n\t\t\t\traise e\n\t\t\tend\n\t\tend", "def call_rest_getlbvstats\n print \"get lb vserver stats\\n\"\n @uri.path = \"/nitro/v1/config/lbvserver/\"\n @request = Net::HTTP::Get.new(@uri)\n @request.basic_auth \"#{@username}\", \"#{@password}\"\n @request.add_field('Content-Type', 'application/vnd.com.citrix.netscaler.lbvserver+json')\n\n Net::HTTP.start(@uri.host, @uri.port) { |http|\n response = http.request(@request)\n\n if response.code == \"200\"\n result = JSON.parse(response.body)\n File.open(\"lbvserver-stats.json\", \"w\") do |file|\n file.write(JSON.pretty_generate(result))\n end\n end\n }\n\n end", "def current_server\n @_current_server\n end", "def current_server\n @_current_server\n end", "def get(url = \"/api/system/info\")\n url = File.join(@client.url, url)\n request = Typhoeus::Request.new(url,\n method: :get,\n headers: headers,\n ssl_verifypeer: @client.ssl_verify_peer?,\n cookiefile: cookie_file_path, # read from\n cookiejar: cookie_file_path, # write to\n userpwd: [@client.user, @client.password].join(\":\"))\n request.run\n request.response\n end", "def url_api\n Guidebox\n end", "def getblockchaininfo\n @api.request 'getblockchaininfo'\n end", "def status_info\n current_path = '/api/v1/status'\n @conn.get(current_path)\n end", "def get_server_properties\n http_get(:uri=>\"/server/properties\", :fields=>x_cookie)\n end", "def info\n get '/'\n end", "def getserverurl\r\n return getvalue(@@SERVER_URL)\r\n end", "def info(**args)\n valid_params?(args)\n params = convert_params(args)\n client.get(\"#{ENDPOINT}/info\", options: params.compact).tap do |resp|\n resp.body = resp.body.map { |_k, data| data }\n end\n end", "def info(**args)\n valid_params?(args)\n params = convert_params(args)\n client.get(\"#{ENDPOINT}/info\", options: params.compact).tap do |resp|\n resp.body = resp.body.map { |_k, data| data }\n end\n end", "def fetchServerConfig()\n #Construct the URL for the request\n url = \"http://api.themoviedb.org/3/configuration?api_key=#{$apiKey}\"\n #Preform a restful reqeust for the data\n data = RestClient.get(url)\n #Parse the returned JSON and return it as a hash\n return JSON.parse(data)\nend", "def endpoint\n ENDPOINT[server]\n end", "def status\n service.get(\"\")\n end" ]
[ "0.71093667", "0.7016905", "0.6907714", "0.6830765", "0.67768633", "0.67594224", "0.67090803", "0.6695377", "0.66152024", "0.6554503", "0.6554107", "0.6536369", "0.65354407", "0.6467605", "0.64468616", "0.64468616", "0.6440169", "0.6367192", "0.6367192", "0.62701386", "0.6244495", "0.62421316", "0.6230247", "0.61522377", "0.614696", "0.61329633", "0.6127849", "0.6126081", "0.6126081", "0.6109561", "0.61058795", "0.6070794", "0.6055865", "0.6052117", "0.6035595", "0.60053104", "0.59870243", "0.59856707", "0.5982786", "0.5964106", "0.5962275", "0.59531915", "0.5929334", "0.5906875", "0.5900794", "0.5880899", "0.5866913", "0.58373773", "0.58310825", "0.5825157", "0.58146745", "0.5813356", "0.5802424", "0.5794278", "0.5788496", "0.5786697", "0.5777241", "0.5776663", "0.57356006", "0.5731929", "0.5706106", "0.5704978", "0.5699428", "0.5698114", "0.569615", "0.5693878", "0.5689223", "0.5685117", "0.5683304", "0.5683229", "0.5675263", "0.5668321", "0.56678426", "0.5666642", "0.5658359", "0.56499016", "0.5643249", "0.5628785", "0.561985", "0.561985", "0.561985", "0.56047547", "0.559923", "0.5593133", "0.55889434", "0.5583201", "0.55783945", "0.55783945", "0.5572748", "0.55499077", "0.55408865", "0.5540773", "0.5540271", "0.55389243", "0.55339944", "0.5531441", "0.5531441", "0.5530809", "0.5527164", "0.5521788" ]
0.5579157
86
=begin Create one time token to use API.
def create_token return api_call('request-token',{"apiKey"=> @@_api_key }); end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_one_time_token\n @one_time_token =\n JSON::JWT.new(iss: 'try-it-juku-test',\n exp: 5.minutes.since,\n nbf: Time.current,\n sub: { shin_cd: @current_chief.shin_cd })\n .sign(ACCESS_TOKEN_SIGNATURE, :HS256).to_s\n end", "def create_api_token\n begin\n ApiToken.create(api_consumer: self)\n end\n end", "def generate_token\n #Token.generate_token(self.id)\n end", "def make_token\r\n # From the restful-authentication plug-in\r\n args = [ Time.now, (1..10).map{ rand.to_s } ]\r\n Digest::SHA1.hexdigest(args.flatten.join('--'))\r\n end", "def generate_token\n self.token = UniqueToken.generate\n end", "def create_token\n @account_token = SecureRandom.urlsafe_base64(nil, false)\n @authentication_token = create_authentication_token\n key = account_token_key(@account_token)\n redis_token = Redis::HashKey.new(key)\n expire_time = DateTime.now + ACCOUNT_TOKEN_TTL\n redis_token.bulk_set({expire_at: expire_time.to_s, authentication_token: @authentication_token})\n redis_token.expireat(expire_time.to_i)\n update_app_info\n {account_token: @account_token, authentication_token: @authentication_token}\n end", "def refresh_token!\n create_token = Kickit::API::CreateToken.new\n resp = create_token.execute(:username => username,\n :developerKey => Kickit::Config.developerKey)\n @token = resp\n end", "def generate_single_access_token\n self.single_access_token ||= UUIDTools::UUID.random_create\n end", "def get_new_access_token\n now = Time.now\n params = {\n body: {\n grant_type: 'urn:ietf:params:oauth:grant-type:uma-ticket',\n ticket: retrieve_ticket,\n client_id: key_info['oxtrust_client_id'],\n client_assertion_type: 'urn:ietf:params:oauth:client-assertion-type:jwt-bearer',\n client_assertion: generate_json_web_token(now),\n scope: 'oxtrust-api-read oxtrust-api-write'\n }\n }\n req = HTTParty.post('https://localhost/oxauth/restv1/token', params)\n if req.code == 200\n token = req['access_token']\n save_access_token(token, now.to_i + 86_400)\n token\n else\n Puppet.err(\n \"Gluu API HTTP #{req.code}: #{req['error_description']}\",\n )\n end\n end", "def token_generate\n res = call('auth.token_generate')\n\n return unless res || res['token']\n\n res['token']\n end", "def create_request_token(params={})\n RequestToken.create :client_application => self, :callback_url=>self.token_callback_url\n end", "def create_request_token(params={})\n\t\tRequestToken.create :client_application => self, :callback_url=>self.token_callback_url\n\tend", "def generate_token\n self.status = STATUS[:present]\n self.access_token = SecureRandom.urlsafe_base64(45, true)\n self.expires = Time.zone.now.to_i + TOKEN_LIFE\n self.login_time = Time.zone.now\n self.user_events.build(event_name: 'Login', event_time: Time.zone.now)\n save\n self.access_token\n end", "def generate_token\n self.token = Digest::SHA1.hexdigest([self.workplace_id, self.institute.id, Time.now, rand].join)\n end", "def generate_authentication_token\n self.auth_token = User.new_token\n\t\t\tself.auth_expires_at = Time.now + 240.hours\n\tend", "def create_auth_token(key)\n\t\tself.auth_token = Digest::SHA1.hexdigest(\"#{random_string}--#{Time.now}---#{key}\")\n\tend", "def generate_api_token\n token = nil\n loop do\n token = Devise.friendly_token\n break token unless ApiToken.where(token: token).first\n end\n ApiToken.create({\n token: token,\n user_id: self.id\n })\n end", "def initialize\n setup_token\n end", "def create_set_and_add_token\n token = SecureRandom.urlsafe_base64\n @user.token = token\n response.headers['X-AUTH-TOKEN'] = token\n end", "def create_token\n if self.token.nil?\n self.token = loop do\n random_token = \"BON-#{SecureRandom.uuid.split('-').first}\"\n break random_token unless self.class.exists?(token: random_token)\n end\n end\n end", "def setup_token\n token = SecureRandom.hex(16)\n @token = token\n token\n end", "def generate_token\n token_hash = SecureRandom.hex\n token_hash.force_encoding('utf-8')\n access_tokens.create(token: token_hash, token_expire: Time.now + DEFAULT_TOKEN_EXPIRE)\n end", "def generate_token\n token_hash = SecureRandom.hex\n token_hash.force_encoding('utf-8')\n access_tokens.create(token: token_hash, token_expire: Time.now + DEFAULT_TOKEN_EXPIRE)\n end", "def generate_remote_token!\n remote_tokens.create.token\n end", "def make_auth_token\n Carto::Common::EncryptionService.make_token(length: 64)\n end", "def create_token_for(app_name)\n timestamp = Time.now.utc.strftime(\"%Y%m%d%H%M%S\")\n display = \"#{app_name}_#{timestamp}\"\n Vault.auth_token.create(name: app_name,\n ttl: '720h',\n display_name: display,\n policies: [app_name])\n end", "def generate_token\n self.perishable_token = Digest::MD5.hexdigest(\"#{Time.now}\")\n end", "def generate_auth_token\n token = AuthToken.new(user: self)\n token if token.save\n end", "def make_token\n secure_digest(Time.now, (1..10).map{ rand.to_s })\n end", "def generate_access_token\n begin\n self.access_token = User.new_token\n end while ApiKey.exists?(access_token: access_token)\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 generate_access_token\n self.access_token ||= self.create_access_token\n save && access_token\n end", "def new_jwt\n Knock::AuthToken.new(payload: { sub: current_user.id }).token\n end", "def generate_token\n @raw_token = Doorkeeper::OAuth::Helpers::UniqueToken.generate\n secret_strategy.store_secret(self, :token, @raw_token)\n end", "def generate_token\n self.apply_code = \"#{SecureRandom.hex(4)}\"\n self.act_status_type_id = 2\n end", "def generate_token\n self.update({:token => SecureRandom.hex})\n end", "def token\n validate_arguments!\n\n display Turbot::Auth.api_key\n end", "def create_api_token(params = {})\n ApiToken.create(self, params)\n end", "def generate_token\n begin\n token = Other::TokenGenerator.call(25).value_or('')\n end until !User.where(token: token).nil?\n self.bf_api_token = token\n end", "def create_access_token\n hash = nil\n Songkick::OAuth2.generate_id do |token|\n hash = Songkick::OAuth2.hashify(token) \n end\n return hash\n end", "def create_token\n @user = User.find(params[:id])\n @token = Token.generate(@user)\n\n respond_to do |format|\n if @token.save\n format.html { redirect_to action: 'index'}\n format.json { render :show, status: :created, location: @token }\n else\n format.html { render :new }\n format.json { render json: @token.errors, status: :unprocessable_entity }\n end\n end\n end", "def generate_token\n self.token = secure_digest(Time.now, candidate_id)\n end", "def generate_token\n new_token =\n SimpleTokenAuthentication::TokenGenerator.instance.generate_token\n update(authentication_token: new_token)\n self\n end", "def create\n @api_token = ApiToken.new(params[:api_token])\n\t@api_token.user = current_user\n respond_to do |format|\n if @api_token.save\n format.html { redirect_to('/dashboard#index', :notice => 'Eve api key was successfully created.') }\n format.xml { render :xml => @api_token, :status => :created, :location => '/dashboard#index' }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @api_token.errors, :status => :unprocessable_entity }\n end\n end\n end", "def generate_token(_user)\n JsonWebToken.encode(login_payload, 3.days.from_now)\n end", "def generate_token\n self.token ||= Base64.urlsafe_encode64(SecureRandom.random_bytes(12))\n end", "def generate_token\n\t\tself.token = SecureRandom.hex\n end", "def generate_token\n if self.token.blank?\n self.id = self.token = UniqueToken.generate\n end\n end", "def create_token\n Rails.logger.info(\"Enter Create Token\")\n \n # create token\n token = GenerateToken.unique_token\n access_token = self.create_access_token( token: token, role: {})\n raise et(\"account.create_token_failed\") if access_token.blank?\n\n true\n rescue => e \n Rails.logger.error(\"**** ERROR **** #{e.message}\")\n end", "def generate_token\n self.token = SecureRandom.urlsafe_base64\n end", "def generate_api_key!\n\t\t@api_key = Digest::SHA1.hexdigest((Time.now.to_f + rand(100) * rand()).to_s) \n\tend", "def token\n @token ||= \"%x-%s\" % [ Time.now.to_i, SecureRandom::hex(4) ]\n end", "def rest_generate_token(id)\n db = Mysql.new(config['mysql_server'], config['mysql_admin'], config['mysql_admin_password'], \"tatoc\")\n uuid = nil\n rows = db.query(\"select uuid from rest where id=#{id}\")\n rows.each do |row|\n uuid = row[0]\n end\n if uuid == nil\n response = Hash.new\n response['error']=\"Invalid Session ID\"\n return response\n end\n timestamp = Time.now.to_i\n private_key = Digest::MD5.hexdigest(\"#{uuid}#{timestamp}\")\n\n db.query(\"update rest set private_key=\\\"#{private_key}\\\", key_generated_at=#{timestamp} where id=#{id}\")\n response = Hash.new\n response['token']=private_key\n response['expires']=timestamp + 30\n response\n end", "def gen_tokens\n self.access_token = SecureRandom.hex(16)\n end", "def create(body = {})\n @client.token.create(body)\n end", "def generate_auth_token\n begin\n token = SecureRandom.hex\n end while AuthToken.exists?(auth_token: token)\n self.auth_tokens.create(auth_token: token)\n token\n end", "def generate_ccg_token(api_name = nil)\n client_id = prompt('Client ID', :modules_appeals_api, :token_generation, :ccg, :client_id)\n private_key_path = prompt('Path to private key', :modules_appeals_api, :token_generation, :ccg, :private_key_path)\n\n scopes = api_scopes(api_name)\n metadata = fetch_openid_metadata(ccg: true)\n token_uri = metadata[:token_endpoint]\n\n puts \"Fetching CCG token with scopes #{scopes.join(', ')} from '#{token_uri}'\"\n\n # Audience must match the okta endpoint used to request the token\n ccg_audience = \"#{metadata[:issuer]}/v1/token\"\n header_content = { 'typ' => 'JWT', 'alg' => 'RS256' }\n iat = Time.now.to_i\n payload_content = {\n 'aud' => ccg_audience,\n 'iss' => client_id,\n 'sub' => client_id,\n 'iat' => iat,\n 'exp' => iat + 300 # The maximum allowed lifetime is 300 seconds (5 minutes)\n }\n private_key = OpenSSL::PKey.read(File.read(private_key_path))\n client_assertion = JWT.encode(payload_content, private_key, 'RS256', header_content)\n client_assertion_type = 'urn:ietf:params:oauth:client-assertion-type:jwt-bearer'\n\n result = post_form_data(\n token_uri,\n {\n 'grant_type' => 'client_credentials',\n 'client_assertion' => client_assertion,\n 'client_assertion_type' => client_assertion_type,\n 'scope' => scopes.join(' ')\n }\n )\n\n raise \"Unsuccessful token request to #{token_uri}:\\n#{result.inspect} #{result.body}\" if result.code.to_i >= 400\n\n puts JSON.pretty_generate(JSON.parse(result.body))\n end", "def generate_token!\n new_token = User.unique_random(field_name: 'api_token')\n update_column(:api_token, new_token)\n end", "def generate_token\n token_gen = SecureRandom.hex\n self.token = token_gen\n token_gen\n end", "def create\n self.resource = warden.authenticate!(scope: :user)\n token = Tiddle.create_and_return_token(resource, request)\n render json: { authentication_token: token }\n end", "def create\n results = ->{\n if params[:token_key].present?\n token = ApiToken.where(token_key: params[:token_key], token_secret: params[:token_secret]).first rescue nil\n token.reset_token_and_key(true) if token.present?\n end\n\n # Attempt to set to the current user, even if current token key is bad\n token ||= current_user.api_token if current_user?\n token ||= ApiToken.create\n\n if token && !token.new_record?\n {success: true, authentication: token.to_api}\n else\n {error: true}\n end\n }\n\n respond_to do |format|\n format.json { render json: results.call, callback: params[:callback] }\n end\n end", "def token\n\t\t@token = ApiKey.find_by_user_id(self.id)\n\t\tif @token == nil\n\t\t\t\treturn ApiKey.create!(user: self)\n\t\telse\n\t\t\t\treturn @token\n\t\tend\n\tend", "def new\n gon.client_token = generate_client_token\n end", "def generate_keys\n\t\tself.token = OAuth::Helper.generate_key(20)[0,20]\n\t\tself.expires_at = 10.minutes.from_now\n\t\tself.authorized_at = Time.now\n\tend", "def generate_token\n self.token ||= SecureRandom.hex(16)\n end", "def set_internal_token!\n self.token ||= generate_token\n end", "def generate_token\n SecureRandom.urlsafe_base64.tap do |token|\n logger.debug \"Generated token #{token}\"\n end\n end", "def generate_access_token\n begin\n self.token = SecureRandom.hex\n end while self.class.exists?(token: token)\n end", "def generate_access_token\n begin\n self.token = SecureRandom.hex\n end while self.class.exists?(token: token)\n end", "def generate_token\n self.token = SecureRandom.base64(64)\n end", "def generate_token\n @token = SecureRandom.base58(10)\n self.update(token: @token)\n end", "def generate_token!\n self.token = SecureRandom.hex\n save!\n end", "def create_token(opts = {})\n self.token = Digest::SHA256.hexdigest(\n Time.now.to_s + Rails.application.secrets.salt + email\n )\n save if opts[:save] == true\n end", "def create_key\n self.key = loop do\n random_token = SecureRandom.urlsafe_base64(nil, false)\n break random_token unless Api.exists?(key: random_token)\n end\n end", "def generate_auth_token\n self.auth_token = SecureRandom.hex\n end", "def generate_auth_token\n \tbegin\n \t\tself.auth_token = User.new_token\n \tend while self.class.exists?(auth_token: auth_token)\n end", "def new_jwt_token\n payload = {\n iat: Time.now.to_i, # Issued at time.\n exp: (10 * 60) + Time.now.to_i, # JWT expiration time.\n iss: APP_ID # Integration's GitHub identifier.\n }\n JWT.encode(payload, PRIVATE_KEY, 'RS256')\n end", "def generate_api_token!\n loop do\n generated_api_token = Devise.method(:friendly_token).call\n raise ApiTokenLengthError if generated_api_token.empty?\n self.api_token = generated_api_token\n break unless self.class.exists?(api_token: api_token)\n end\n end", "def generate_access_token\n self.access_token = Digest::SHA1.hexdigest(\"#{random_salt}#{Time.now.to_i}\")\n end", "def generate_access_token\n self.access_token = Digest::SHA1.hexdigest(\"#{random_salt}#{Time.now.to_i}\")\n end", "def generate_access_token\n self.access_token = Digest::SHA1.hexdigest(\"#{random_salt}#{Time.now.to_i}\")\n end", "def generate_api_key\n digest = Digest::SHA2.new(512)\n # generate a unique token\n unique_seed = SecureRandom.hex(20)\n digest.update(\"#{unique_seed} SECRET! #{Time.current.to_f}\").to_s\n end", "def generate_api_key\n digest = Digest::SHA2.new(512)\n # generate a unique token\n unique_seed = SecureRandom.hex(20)\n digest.update(\"#{unique_seed} SECRET! #{Time.current.to_f}\").to_s\n end", "def generate_request\n token = @oauth.consumer.get_request_token\n begin\n @db.execute( \"INSERT INTO request_tokens VALUES (NULL,?,?,current_timestamp)\",\n token.token, token.secret)\n rescue\n puts \"Failed to insert request token #{$!}\"\n return false\n end\n token\n end", "def create_token(user_id, dev_id)\n token = SecureRandom.base64(384)\n DB[:Token].where(UserID: user_id).where(DeviceID: dev_id)\n .update(Token: token, Timestamp: Time.now.to_i + 600)\n token\n end", "def request_token\n self.token = Pivotal::Client.fetch_token(email, password)\n end", "def request_token\n @token=current_client_application.create_request_token\n if @token\n render :text=>@token.to_query\n else\n render :nothing => true, :status => 401\n end\n end", "def token\n @token ||= Token.new(config)\n end", "def create_token(id, username)\n JWT.encode(payload(id, username), ENV['JWT_SECRET'], 'HS256')\n end", "def create_token(id, username)\n JWT.encode(payload(id, username), ENV['JWT_SECRET'], 'HS256')\n end", "def generate_and_set_token(user=nil)\n user ||= create(:user_with_token)\n current_time = Time.now\n jwt_config = Rails.application.secrets.jwt\n token = JWT.encode({\"iat\" => current_time.to_i,\n \"iss\" => jwt_config['issuer'],\n \"exp\" => (current_time + 14.days).to_i,\n \"user_id\" => user.id},\n jwt_config['secret_key'],\n jwt_config['hmac_sha_algo'])\n request.headers['Authorization'] = \"Bearer #{token}\"\n end", "def create\n require 'digest/sha1'\n \n @access_token = AccessToken.new\n @access_token.user_id = current_user.id\n @access_token.last_access = Time.now\n @access_token.token = Digest::SHA1.hexdigest Time.now.to_s\n @access_token.active = true\n \n respond_to do |format|\n if @access_token.save\n format.html { redirect_to(@access_token, :notice => 'Access token was successfully created.') }\n format.xml { render :xml => @access_token, :status => :created, :location => @access_token }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @access_token.errors, :status => :unprocessable_entity }\n end\n end\n end", "def require_api_token\n end", "def generate_token\n self.token = SecureRandom.hex if new_record?\n end", "def request_token\n @token = current_client_application.create_request_token\n if @token\n render :text => @token.to_query\n else\n render :nothing => true, :status => 401\n end\n end", "def create\n puts \"MESSAGE 14 IN CREATE\"\n @auth = request.env['omniauth.auth']['credentials']\n # The following statement saves the tokens to the database\n Token.create(\n access_token: @auth['token'],\n refresh_token: @auth['refresh_token'],\n expires_at: Time.at(@auth['expires_at']).to_datetime)\n end", "def token_secret=(_arg0); end", "def token_secret=(_arg0); end", "def token_secret=(_arg0); end", "def generate_api_key\n @project.reset_token!\n render :settings_api\n end" ]
[ "0.8003303", "0.7740658", "0.73060983", "0.7283917", "0.72717005", "0.7226481", "0.72062707", "0.71999466", "0.71927714", "0.7190985", "0.719002", "0.7186691", "0.7161049", "0.714691", "0.71447974", "0.7141118", "0.7110375", "0.7105321", "0.70993626", "0.7097249", "0.7093375", "0.7075643", "0.7075643", "0.7066336", "0.7050278", "0.70481163", "0.70233554", "0.70188737", "0.70093894", "0.7001527", "0.6982293", "0.69710726", "0.69684875", "0.6954038", "0.69459635", "0.693573", "0.6921574", "0.6915638", "0.68920743", "0.6889628", "0.6873755", "0.6861155", "0.6832341", "0.6822852", "0.6813897", "0.68092", "0.68031293", "0.6802436", "0.6800682", "0.6790004", "0.6787252", "0.67787576", "0.67688996", "0.6767349", "0.67578554", "0.6754458", "0.6751867", "0.673992", "0.6733125", "0.67270017", "0.6725484", "0.6719514", "0.6713149", "0.6708795", "0.6706469", "0.6706074", "0.6701754", "0.67007756", "0.67007756", "0.6699946", "0.66954833", "0.66939425", "0.6692492", "0.6691831", "0.668934", "0.66862625", "0.668626", "0.6679455", "0.66679", "0.66679", "0.66679", "0.66587347", "0.66587347", "0.66493857", "0.6647942", "0.6638526", "0.6630787", "0.6620268", "0.6616186", "0.6616186", "0.6613988", "0.6609293", "0.66078", "0.6606793", "0.66050416", "0.6590629", "0.6585312", "0.6585312", "0.6585312", "0.6574408" ]
0.8550086
0
=begin Convert an array to xml string.
def array_to_xml(hash, xml) require "active_support/core_ext" return hash.to_xml(:root => 'queue') end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_xml(a)\n r = \"\"\n if ishash(@a[a])\n r = self.hash_to_xml(a,@a[a])\n elsif isarray(@a[a])\n r = self.array_to_xml(a,@a[a])\n else\n r = \"<#{a}>#{@a[a]}</#{a}>\"\n end\n r \n end", "def to_xml\n @node.flatten.map(&:to_s).join\n end", "def to_xml\n return to_s\n end", "def to_xml\n return to_s\n end", "def to_xml(options = T.unsafe(nil)); end", "def to_xml(options = T.unsafe(nil)); end", "def to_xml(*args); end", "def to_xml(*args); end", "def to_xml(*args); end", "def to_xml(*args); end", "def to_xml(*args); end", "def to_xml(*args); end", "def to_s\n @xml\n end", "def to_xml\n return self.to_s\n end", "def to_xml\n self.to_s\n end", "def to_xml\n self.to_s\n end", "def to_xml\n return @doc.to_s\n end", "def to_xml(options = T.unsafe(nil), &block); end", "def to_xml \n return @_xml unless @_xml.empty?\n @_xml << \"<wddxPacket version='1.0'>\"\n if @comment.nil?\n @_xml << \"<header/>\"\n else\n @_xml << \"<header><comment>#{@comment}</comment></header>\"\n end\n @_xml << \"<data>\" \n if @data.size.eql?(1)\n @_xml << @data \n else \n @_xml << \"<array length='#{@data.size}'>\"\n @_xml << @data\n @_xml << \"</array>\"\n end \n @_xml << \"</data></wddxPacket>\"\n @_xml = @_xml.join('')\n @_xml\n end", "def marshal( options={} )\n xml = options[:builder]\n\n @table.each_pair do |key, value|\n if value.is_a?( Array )\n if value.empty?\n do_xml!( xml, key, nil )\n else\n value.each { |each_value| do_xml!( xml, key, each_value ) }\n end\n elsif value.is_a?(REXML::Element)\n xml << value.to_s\n else\n do_xml!( xml, key, value )\n end\n end\n end", "def to_s\n \"<#{@name}\" + @attrs.sort.map{|k,v| \" #{k}='#{v.xml_attr_escape}'\"}.join +\n if @contents.size == 0\n \"/>\"\n else\n \">\" + @contents.map{|x| if x.is_a? String then x.xml_escape else x.to_s end}.join + \"</#{name}>\"\n end\n end", "def to_xml\n builder = Builder::XmlMarkup.new(:indent=>2)\n builder.instruct! :xml, version: '1.0', encoding: 'UTF-8'\n xml = builder.items{ self.each{|x| builder.item(x) } }\n xml\n end", "def encode_array(arr)\n arr.join ','\n end", "def toxml\n\t\tend", "def to_xml\n doc = Nokogiri::XML::Document.new\n element = to_nokogiri(doc)\n element.to_s\n end", "def to_xml\n doc = Nokogiri::XML::Document.new\n element = to_nokogiri(doc)\n element.to_s\n end", "def xml_from_array(builder, tags_and_values)\n tags_and_values.each do |tag, value|\n tag = javaize_key(tag)\n if value.is_a?(Array)\n builder.tag!(tag) { xml_from_array(builder, value) }\n else\n builder.tag!(tag, value)\n end\n end\n end", "def _to_xml(xml)\n end", "def to_xml\n\t\tend", "def to_xml\n\t\tend", "def stringify_array( array )\n\t\t\treturn array.collect do |item|\n\t\t\t\tcase item\n\t\t\t\twhen Symbol\n\t\t\t\t\titem.to_s\n\t\t\t\twhen Array\n\t\t\t\t\tstringify_array( item )\n\t\t\t\telse\n\t\t\t\t\titem\n\t\t\t\tend\n\t\t\tend\n\t\tend", "def stringify_array( array )\n\t\t\treturn array.collect do |item|\n\t\t\t\tcase item\n\t\t\t\twhen Symbol\n\t\t\t\t\titem.to_s\n\t\t\t\twhen Array\n\t\t\t\t\tstringify_array( item )\n\t\t\t\telse\n\t\t\t\t\titem\n\t\t\t\tend\n\t\t\tend\n\t\tend", "def stringify_array( array )\n\t\t\treturn array.collect do |item|\n\t\t\t\tcase item\n\t\t\t\twhen Symbol\n\t\t\t\t\titem.to_s\n\t\t\t\twhen Array\n\t\t\t\t\tstringify_array( item )\n\t\t\t\telse\n\t\t\t\t\titem\n\t\t\t\tend\n\t\t\tend\n\t\tend", "def to_xml\n Builder.new(self).to_s\n end", "def to_str\n str = \"\"\n REXML::Formatters::Pretty.new(1).write(@xml,str)\n\n return str \n end", "def xml_to_string(xml)\n return if xml.nil?\n output = $data.each.map do |key, value|\n \"#{key.to_str}:#{xml.elements[value].text.to_f}\"\n end\n output.join(' ')\nend", "def to_xml\r\n x = Builder::XmlMarkup.new(:target => (reply = ''))\r\n x.instruct!\r\n x.comment! \"#{@collection.size} entries\" \r\n x.strings(:each => @each) {\r\n @collection.each do |each|\r\n x.s(each)\r\n end\r\n }\r\n reply\r\n end", "def to_s\n\t w=0\n\t aux = \"[\"\n\t for i in(0..@alt)\n\t aux += \"[\"\n\t for j in(0..@anc)\n\t\tif (w < @n_elem && i==@alto[w])\n\t\t if(j==@ancho[w])\n\t\t if(j==@anc)\n\t\t\taux += \"#{@elem[w]}\"\n\t\t else\n\t\t\taux += \"#{@elem[w]},\"\n\t\t end\n\t\t w=w+1\n\t\t else\n\t\t if(j==@anc)\n\t\t\taux += \"0\"\n\t\t else\n\t\t\taux += \"0,\"\n\t\t end\n\t\t end\n\t\telse\n\t\t if(j==@anc)\n\t\t\taux += \"0\"\n\t\t else\n\t\t\taux += \"0,\"\n\t\t end\n\t\tend\n\t end\n\t aux += \"]\"\n\t end\n\t aux += \"]\"\n\t aux\n\tend", "def write_array(array)\n\t\twrite_byte(10)\n\t\twrite_word32_network(array.length)\n\t\tarray.each do |el| \n\t\t\twrite(el)\n\t\tend\n\tend", "def to_s\n return self.xml\n end", "def to_str\n str = \"\"\n REXML::Formatters::Pretty.new(1).write(@xml,str)\n \n return str \n end", "def array_to_string(arr)\n arr.map { |e| \"'#{sanitize(e)}'\" }.join(\",\")\n end", "def to_xml\n output=\"\"\n self.to_rexml.write output\n end", "def to_xml\n @xml.to_xml\n end", "def buildXML(label,array,xml)\r\n array.each do |hash|\r\n xml.send(label) do\r\n # Create an element named for the label\r\n hash.each do |key,value|\r\n if value.is_a?(Array)\r\n buildXML(key,value,xml)\r\n else\r\n # Create <key>value</key> (using variables)\r\n xml.send(key,value)\r\n end\r\n end\r\n end\r\n end\r\n end", "def to_xml\n\t\tmsg_xml = ''\n\t\t@hash.each do |info|\n\t\t\tmsg_xml += \"<#{info.key}>#{xml(info.value)}</#{info.key}>\\n\"\n\t\tend\n\t\tmsg_xml\n\tend", "def to_xml\n if @xml_header.nil?\n xml = ''\n else\n xml = @xml_header.to_xml + \"\\n\"\n end\n self.document.__types.each do |t|\n xml += self.document.send(t).to_xml\n end\n return xml\n end", "def to_xml\n\t\t\t\"<#{@name} #{attributes_string} />\"\n\t\tend", "def to_xml\n ret = \"<document documenttype=\\\"\" + @documenttype +\n \"\\\" documentid=\\\"\" + xmlQuote(@documentid, true) + \"\\\">\\n\"\n\n fields.sort.each { | key,value |\n if value.class == Array\n ret << \" <\" + key + \">\\n\"\n if value[0].class == Array\n\t value.sort.each { | v |\n ret << \" <item weight=\\\"\" + v[1].to_s + \"\\\">\" + xmlQuote(v[0].to_s) + \"</item>\\n\"\n }\n else\n\t value.each { | v |\n ret << \" <item>\" + xmlQuote(v.to_s) + \"</item>\\n\"\n }\n end\n ret << \" </\" + key + \">\\n\"\n elsif value.class == Hash\n ret << \" <\" + key + \">\\n\"\n value.sort.each { | k, v |\n ret << \" <item><key>#{k}</key><value>#{v}</value></item>\\n\"\n }\n ret << \" </\" + key + \">\\n\"\n elsif value.class == String or value.is_a? Numeric\n ret << \" <\" + key + \">\" + xmlQuote(value.to_s) + \"</\" + key + \">\\n\"\n elsif value # Struct\n ret << \" <\" + key + \">\\n\"\n value.each_pair { | name, val |\n ret << \" <#{name}>#{xmlQuote(val)}</#{name}>\\n\"\n }\n ret << \" </\" + key + \">\\n\"\n else # nil value, eg. <foo/>\n ret << \" <\" + key + \"/>\\n\"\n end\n }\n ret << \"</document>\"\n ret\n end", "def array_to_sentence_string(array, connector = T.unsafe(nil)); end", "def to_xml(options={})\n to_a.to_xml options.reverse_merge(:root => \"hints\", :skip_types => true)\n end", "def to_xml(ns=nil)\n x = super.chomp(\"/>\").chomp(\" \")\n x << %[>]\n #self.class.inherited_elements.each do |name, kind, opts|\n xml_schema_elements.each do |name, kind, opts|\n obj = send(name)\n next unless obj\n case obj\n when Array\n obj.each do |v|\n if v.is_a? Tag\n x << v.to_xml(xml_namespace)\n else\n x << %[<#{name}>#{xml_escape(v.to_s)}</#{name}>]\n end\n end\n else\n if obj.is_a? Tag\n x << obj.to_xml(xml_namespace)\n else\n x << %[<#{name}>#{xml_escape(obj.to_s)}</#{name}>]\n end\n end\n end\n x << %[</#{xml_tagname}>]\n x\n end", "def test_array_arg\n\tarray = Array.new\n\tw = NQXML::Writer.new(array)\n\n\tw.write('data')\n\tassert_equals(['data'], array)\n\n\tw.comment('foo')\n\tassert_equals(['data', '<!--foo-->'], array)\n end", "def serialize(root, array)\n if root == nil\n array.push('N')\n return\n else\n array.push(root.val)\n serialize(root.left, array)\n serialize(root.right, array)\n end\n array.join(\",\")\nend", "def xml_str # :nodoc:\n @writer.string\n end", "def to_xml\n RAGE::XMLCodec.new.encode(self)\n end", "def test_hash_with_array\n expected = <<EXPECTED\n<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<hash>\n <numbers type=\"array\">\n <number>1</number>\n <number>2</number>\n </numbers>\n</hash>\nEXPECTED\n assert_equal expected, {'numbers' => [1, 2]}.to_xml\n assert_equal expected, {'numbers' => ['1', '2']}.to_xml\n end", "def to_xml\n to_xml_builder.to_xml\n end", "def to_xml\n to_xml_builder.to_xml\n end", "def stringify(arr)\n arr.map { |s| s.to_s }.join(\"<br>\")\n end", "def to_s\n \"Vector[\" + @elements.join(\", \") + \"]\"\n end", "def to_xml\n @xml ||= get_xml\n end", "def to_xml(obj)\n obj.to_xml\n end", "def to_xml\n @builder.to_xml\n end", "def to_xml_string(str = +'')\n return if empty?\n\n str << '<cols>'\n each { |item| item.to_xml_string(str) }\n str << '</cols>'\n end", "def to_xml\n xml = String.new\n builder = Builder::XmlMarkup.new(:target => xml, :indent => 2)\n \n # Xml instructions (version and charset)\n builder.instruct!\n \n builder.source(:primary => primary_source) do\n builder.id(id, :type => \"integer\")\n builder.uri(uri.to_s)\n end\n \n xml\n end", "def to_xml\n\n prelude = \"<?xml version='1.0'?>\\n<Root xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:noNamespaceSchemaLocation='file:///order.xsd'>\\n<order>\"\n str= [ add_costs_xml,\n additional_text_xml,\n customer_id,\n delivery_country_code,\n delivery_date_xml,\n delivery_name_1,\n delivery_name_2,\n delivery_name_3,\n delivery_place,\n delivery_print_code_xml,\n delivery_street,\n delivery_codes,\n delivery_zipcode,\n discount_xml,\n gross_price_code,\n invoice_country_code,\n invoice_name_1,\n invoice_name_2,\n invoice_name_3,\n invoice_place,\n invoice_print_code_xml,\n invoice_street,\n invoice_zipcode,\n order_type,\n payment_codes,\n reference_1,\n reference_2,\n representative_1,\n short_name,\n urgent_code,\n tax_code,\n order_release_code\n ].compact\n str.each do |s|\n s = s.force_encoding('UTF-8')\n end\n all = str.join(\"\\n\")\n ending = \"<positionen AnzPos='#{positions.length}'>#{xml_for(positions)}</positionen>\\n</order>\\n</Root>\"\n prelude + all + ending\n end", "def to_xml\n xml = children.map(&:to_xml).join('')\n\n if doctype\n xml = doctype.to_xml + \"\\n\" + xml.strip\n end\n\n if xml_declaration\n xml = xml_declaration.to_xml + \"\\n\" + xml.strip\n end\n\n return xml\n end", "def to_s\n #create an array to hold the values\n array_values = []\n #loop through array\n @store.each do |element|\n #check if it's not empty, then add element to the array that was created\n if !element.nil?\n array_values.append(element)\n end\n end\n #return the array and make sure to do to_s to ensure string in case it mutated somewhere\n return array_values.to_s\n end", "def back_to_s(array)\n array.join(\"\")\nend", "def write(xml, object)\n if definition.array?\n object.each do |item|\n write_entity(xml, item)\n end\n else\n write_entity(xml, object)\n end\n end", "def to_xml(options = {})\n to_xml_opts = {:skip_types => true} # no type information, not such a great idea!\n to_xml_opts.merge!(options.slice(:builder, :skip_instruct))\n # a builder instance is provided when to_xml is called on a collection,\n # in which case you would not want to have <?xml ...?> added to each item\n to_xml_opts[:root] ||= \"retailer\"\n self.attributes.to_xml(to_xml_opts)\n end", "def to_s\n\t\treturn self.stringify_nodes( @output )\n\tend", "def to_s\n return self.xml_header + self.xml_docs.join + self.xml_footer\n end", "def to_xml()\r\n msg = REXML::Document.new\r\n msg << REXML::Element.new(\"#{@type.to_s}\")\r\n msg.root << REXML::Element.new(\"GROUP\").add_text(\"#{@group}\") if @group != nil\r\n msg.root << REXML::Element.new(\"ID\").add_text(\"#{@procID}\") if @procID != nil\r\n msg.root << REXML::Element.new(\"PATH\").add_text(\"#{@path}\") if @path != nil\r\n msg.root << REXML::Element.new(\"ARGSLINE\").add_text(\"#{@cmdLineArgs.join(\" \")}\") if @cmdLineArgs != nil\r\n # Build the <ENV> child element\r\n if !@env.empty? \r\n line = \"\"\r\n @env.each { |k,v|\r\n line << \"#{k.to_s}=#{v.to_s} \" \r\n }\r\n msg.root << REXML::Element.new(\"ENV\").add_text(\"#{line}\")\r\n end\r\n # Build the <OML_CONFIG> child element\r\n if @omlConfig != nil\r\n el = REXML::Element.new(\"OML_CONFIG\")\r\n el.add_element(@omlConfig)\r\n msg.root << el\r\n end\r\n return msg\r\n end", "def to_xml()\n builder = Nokogiri::XML::Builder.new(:encoding => ENCODING) do |xml|\n xml.Types(:xmlns => Axlsx::XML_NS_T) {\n each { |type| type.to_xml(xml) }\n }\n end\n builder.to_xml(:save_with => 0)\n end", "def to_xml(elem_name = nil)\n # The root element is the class name, downcased\n elem_name ||= self.class.to_s.split('::').last.downcase\n root = Element.new elem_name\n\n # Add each BaseObject member to the root elem\n self.members.each do |field_name|\n next if self.class::MUTABILITY[field_name.to_sym] == :read_only\n\n value = self.send(field_name)\n\n if value.is_a?(Array)\n node = root.add_element(field_name)\n value.each { |array_elem|\n array_elem_name = 'line' if field_name == 'lines'\n node.add_element(array_elem.to_xml(array_elem_name))\n }\n elsif !value.nil?\n root.add_element(field_name).text = value\n end\n end\n root\n end", "def to_xml_string(str = +'')\n str << '<filters '\n serialized_attributes(str)\n str << '>'\n filter_items.each { |filter| filter.to_xml_string(str) }\n date_group_items.each { |date_group_item| date_group_item.to_xml_string(str) }\n str << '</filters>'\n end", "def to_xml\n\t\t\ttext = \"\"\n\t\t\t@response.write(text, 1)\n\t\t\treturn text\n\t\tend", "def records_as_xml( quantity = 1 )\n addr_arr = self.records(quantity)\n XmlSimple.xml_out( { :address => addr_arr },\n { :NoAttr=>true, :RootName=>:emailing,\n :XmlDeclaration=>true } )\n end", "def to_xml(options = nil)\n all_attributes.to_xml(options || {})\n end", "def convert_array(arr)\n return '' if arr.nil?\n result = ''\n case arr\n when String, Fixnum then result << arr.to_s\n when NilClass then result << ''\n when Array\n case arr.first\n when String, Fixnum\n result << '<ul>'\n arr.each do |a|\n result << \"<li>#{convert_array(a)}</li>\" unless a.empty?\n end\n result << '</ul>'\n when NilClass then result << ''\n when Array\n result << '<ul>'\n arr.each do |a|\n result << convert_array(a)\n end\n result << '</ul>'\n when Hash\n # Change the formatting of sub-tables for easier viewing\n result << '<span class=\"ReportCSSChildTable ReportCSS\"><table><thead><tr>'\n arr.first.keys.each { |a| result << \"<td>#{convert_array(a)}</td>\" }\n result << '</tr></thead><tbody>'\n arr.each do|a|\n result << '<tr>'\n a.values.each { |b| result << \"<td>#{convert_array(b)}</td>\" }\n result << '</tr>'\n end\n result << '</tbody></table></span>'\n else\n result << 'Unknown value!!'\n end\n else\n result << 'Unknown value!'\n end\n end", "def array2str(type, arr)\n case type\n when :char, :int8\n arr.pack('c*')\n when :uchar, :uint8\n arr.pack('C*')\n when :short, :int16\n arr.pack('s*')\n when :ushort, :uint16\n arr.pack('S*')\n when :int32\n arr.pack('l*')\n when :uint32\n arr.pack('L*')\n when :int\n arr.pack('i!*')\n when :uint\n arr.pack('I!*')\n when :bool\n [arr ? 1 : 0].pack('i!*')\n when :long\n arr.pack('l!*')\n when :ulong\n arr.pack('L!*')\n when :long_long, :int64\n arr.pack('q*')\n when :ulong_long, :uint64\n arr.pack('Q*')\n when :size_t\n arr.pack(SIZET_FORMAT)\n when :float\n arr.pack('f*')\n when :double\n arr.pack('d*')\n when :string, :pointer\n arr.pack('p*')\n else\n raise \"unknown type #{type}\"\n end\n end", "def to_xml(*)\n self\n end", "def to_xml(*args)\n @doc.to_xml(*args)\n end", "def to_xml(options={})\n options = options.reverse_merge(:root => false)\n to_hash(options).to_xml(:root => data_name(@_data))\n end", "def strify_array( array )\n\t\tarray = [ array ] if !array.is_a?( Array )\n\t\tarray.map do |m|\n\t\t\tm = (Array === m) ? strify_array(m) : m\n\t\t\tm = (Hash === m) ? strify_hash(m) : m\n\t\t\tSymbol === m ? m.to_s : m\n\t\tend\n\tend", "def to_s\n r = []\n each do |e|\n r << e\n end\n '[' + r.join(', ') + ']'\n end", "def to_s\n\t\t\t\t'[' << map(&:to_s).join(', ') << ']'\n\t\t\tend", "def to_xml(builder, include_dims=true)\n builder.grid do |xml|\n xml.cube\n dims_to_xml(xml) if include_dims\n xml.slices do |xml|\n xml.slice :rows => @row_count, :cols => @col_count do |xml|\n xml.data do |xml|\n xml.range :start => 0, :end => @row_count * @col_count - 1 do\n xml.vals @vals.join('|')\n xml.types @types.join('|')\n end\n end\n end\n end\n end\n end", "def to_xml()\n XmlSimple.xml_out( { :address => self.to_hash() }, { :KeepRoot=>true, :NoAttr=>true } )\n end", "def to_xml\n ns = namespace ? \"#{namespace}:\" : ''\n body = children.map(&:to_xml).join('')\n attrs = ''\n\n attributes.each do |key, value|\n attrs << \"#{key}=#{value.inspect}\"\n end\n\n attrs = \" #{attrs}\" unless attrs.empty?\n\n return \"<#{ns}#{name}#{attrs}>#{body}</#{name}>\"\n end", "def to_s\n to_ary\n end", "def to_s\n element_string = '['\n @options.each { |option| element_string.concat(\"#{option.join(',')}|\") }\n element_string.chop.concat(']')\n end", "def normalize_array(array)\n array.map(&:to_s)\n end", "def normalize_array(array)\n array.map(&:to_s)\n end", "def to_s_with_c14nxl\n if instance_variable_defined?(:@c14nxl)\n to_a.map {|c| c.serialize(:save_with => ::Nokogiri::XML::Node::SaveOptions::NO_EMPTY_TAGS)}.join(\"\")\n else\n to_s_without_c14nxl\n end\n end", "def array_to_string(value)\n result = ''\n value.each { |value| result += to_cli_value(value) + ',' }\n result = '[' + result.chomp(',') + ']'\n end", "def xml; end", "def to_xml(ns=nil)\n x = super.chomp(\"/>\").chomp(\" \")\n x << \">\"\n x << xml_escape(xml_value.to_s)\n x << \"</#{xml_tagname}>\"\n x\n end" ]
[ "0.6696121", "0.669173", "0.65800935", "0.65800935", "0.64539003", "0.64539003", "0.64367825", "0.64367825", "0.64367825", "0.64367825", "0.64367825", "0.64367825", "0.643426", "0.639226", "0.6366356", "0.6366356", "0.63052046", "0.62652904", "0.62152576", "0.619897", "0.61959386", "0.6184962", "0.6168192", "0.61365473", "0.6129014", "0.6129014", "0.6125176", "0.6121686", "0.61178666", "0.61178666", "0.60748327", "0.60748327", "0.60748327", "0.60679734", "0.6060517", "0.60496986", "0.60445285", "0.60358053", "0.6030317", "0.6028667", "0.60179305", "0.5993001", "0.59894466", "0.59695566", "0.596653", "0.595265", "0.59513444", "0.5939023", "0.5922987", "0.59134984", "0.591096", "0.5894604", "0.58906394", "0.5871851", "0.58710295", "0.5854698", "0.5819063", "0.58147603", "0.58147603", "0.5806234", "0.5804241", "0.57943165", "0.5793958", "0.5791399", "0.57849854", "0.57838696", "0.5780489", "0.5773988", "0.5772661", "0.5762673", "0.5757838", "0.57471657", "0.574684", "0.5739582", "0.5737743", "0.57344466", "0.57238865", "0.5723081", "0.5718145", "0.5718104", "0.5699458", "0.5696665", "0.5681953", "0.56772596", "0.5644686", "0.563555", "0.5632341", "0.5630599", "0.5626797", "0.56259", "0.5617682", "0.5610287", "0.56088936", "0.5605612", "0.56000614", "0.56000614", "0.55893266", "0.55725366", "0.55710155", "0.55479634" ]
0.6912599
0
=begin Convert an xml string to array.
def xml_to_array(xml_string) return Hash.from_xml(xml_string) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def array_from_xml(xml, opts=OPTS)\n node = Nokogiri::XML(xml).children.first\n unless node \n raise Error, \"Malformed XML used\"\n end\n node.children.reject{|c| c.is_a?(Nokogiri::XML::Text)}.map{|c| from_xml_node(c, opts)}\n end", "def parse_to_array(line_as_string)\n as_array = line_as_string.split(\" \")\nend", "def subtag2array(str)\n sep = \"\\001\"\n str.gsub(/\\n(\\s{1,#{@tagsize-1}}\\S)/, \"\\n#{sep}\\\\1\").split(sep)\n end", "def node_to_ary(node)\n node.to_s.split(\"\\n\")\n end", "def parse_xml xml\n result = XmlSimple.xml_in(xml, {'ForceArray' => false})\n result = result['result'] if result['result']\n result\n end", "def getXMLData( xpathObj) \n @variantArr = Array.new\n @file.xpath(xpathObj).each do |node| \n recursive_child(node) \n if !node.next_sibling.nil? && !node.next_sibling.blank?\n recursive_child(node.next_sibling)\n end \n return @mainArr \n end\n end", "def document_to_array( xpath = DIF_XPATH, namespace = NAMESPACE)\n a = []\n document.xpath( xpath, namespace ).each do | node |\n dif = Gcmd::Dif.new\n dif.load_xml node.to_s\n a << dif.document_to_hash\n end\n a\n end", "def string_to_array\r\n @input.chars.map {|e| e.to_i}\r\n end", "def parse_xml(file)\n\t\tdata = []\n\t\t# Break open XML and go through nodes\n\t\tbegin\n\t\t\tfile = file_sanitizer(file)\n\t\t\tdata = XmlSimple.xml_in(file, {'ForceArray' => false })\n\t\trescue Exception => e\n\t\t\traise e\n\t\tend\n\t\tdata\n\tend", "def convert_to_array(attr)\n attr = attr.split(',')\n return attr\nend", "def put_in_array(elem)\n array = []\n elem.each {|e| array << e.text}\n return array\nend", "def string_to_array(string)\n string.split(\" \")\nend", "def string_to_array(string)\n string.split(\" \")\nend", "def split_string_to_array(str)\n @string_as_array = str.split('')\n return @string_as_array\nend", "def parse_record\n @data = NamespaceArray.new\n document.xpath('//xmlns:xmlData').each do |xdata|\n xdata.children.each do |child|\n if child.element?\n @data << child\n end\n end\n end\n end", "def oci_list_to_array(response,ele_name)\n response_array = Array.new\n parse_response = REXML::Document.new(response)\n parse_response.elements.each(\"//command/\"+ele_name) do |ele|\n parse_line = REXML::Document.new(\"#{ele}\")\n\n #If list is nested within elements pull values from the last element in ele_name\n if ele_name =~ /\\/(\\w+)$/\n sub_ele_name = $1\n response_array << parse_line.elements[\"//#{sub_ele_name}\"].text\n else\n response_array << parse_line.elements[\"//#{ele_name}\"].text\n end\n end\n\n return response_array\n end", "def convert_string_tags_to_array(_tags)\n (_tags).split(tags_separator).map(&:strip).reject(&:blank?)\n end", "def parse_xml_collection(xml_text)\n hash = Hash.from_xml(replace_nested_xml_tags(xml_text))\n if 1 == hash.size && hash.first.last.is_a?(Array)\n tag_name = hash.keys.first.singularize\n return get_hash_array_from_xml_object(hash, tag_name)\n else\n raise \"Bad object: Unexpected format: #{hash.inspect}\"\n end\n end", "def toptag2array(str)\n sep = \"\\001\"\n str.gsub(/\\n([A-Za-z\\/\\*])/, \"\\n#{sep}\\\\1\").split(sep)\n end", "def string_to_array(str)\n return [] if str.blank?\n return str.split(\",\").each{|t| t.strip!} if str.class == String\n return []\n end", "def string_to_nested_array(str)\n arr1 = str.split(',')\n arr2 = []\n for i in 0..arr1.size - 1\n arr2[i] = arr1[i].split(':')\n end\n return arr2\nend", "def to_array_form(external_ref_path)\n # TODO: use regexp disjunction\n external_ref_path.gsub(/^node\\[/, '').gsub(/^service\\[/, '').gsub(/\\]$/, '').split('][')\n end", "def csv_to_array(csv); end", "def decode(xml)\n if !xml.respond_to?(:read)\n xml = StringIO.new(xml)\n end\n ::XmlSimple.xml_in(xml, 'ForceArray'=>false)\n rescue\n case $!\n when parse_error\n raise $!\n else\n raise parse_error, \"Couldn't parse the given document.\"\n end \n end", "def resume_to_array(text)\n result = text\n result.gsub!(\",\",\"\")\n result.gsub!(\"(\",\"\")\n result.gsub!(\")\",\"\")\n result.gsub!(\"[\",\"\")\n result.gsub!(\"]\",\"\")\n result.downcase!\n return result.split\nend", "def _getarray\n if @document.nil?\n return @list\n else\n return @document.native_text\n end\n end", "def get_array(element, path='.')\n return unless element\n \n result = element/path\n if (result.is_a? Nokogiri::XML::NodeSet) || (result.is_a? Array)\n result.collect { |item| self.get(item) }\n else\n [self.get(result)]\n end\n end", "def to_array\n @word.split(\" \") #or @word.chars will work too.\n end", "def read_loaded_txt_file_to_array(file)\n\ttext_array = file.read.split(\",\")\nend", "def arrayify(str)\n str.split(\"\\n\")\n end", "def from_trusted_xml(xml)\n from_xml xml, []\n end", "def from_xml(xml)\n\t\tend", "def position_string_to_array(string)\n size = Math.sqrt(string.length).to_i\n array = chunk(string, size).map { |row| chunk(row, 1) }\n array\n end", "def position_string_to_array(string)\n size = Math.sqrt(string.length).to_i\n array = chunk(string, size).map { |row| chunk(row, 1) }\n array\n end", "def string_to_arr(str)\n arr = str.split(\" \")\n arr_f = []\n \n for a in arr\n if a != \"\"\n arr_f.push(a.strip)\n end\n end\n \n return arr_f\n end", "def ext_arr(ext)\n temp_arr = []\n ext.each{|e| temp_arr.push(e.text) }\n return temp_arr\n end", "def array_from_rows(str)\n str.split(\"\\n\").map { |x| x.split(' ').map { |y| y.to_i } }\n end", "def to_array\n self.word.split(\"\")\n end", "def get_array(path='.')\n Element.get_array(@element, path)\n end", "def get_artifact_array(document)\n artifacts = []\n REXML::XPath.each(document, \"//artifact\") { |matched_artifact| artifacts << matched_artifact.text }\n artifacts\n end", "def number_array\n @input_string.split(' ')\n end", "def get_array(path=\"\")\n Element.get_array(@element, path)\n end", "def content_as_array\n begin\n # '[\"a\",\"b\", \"c\"]' -> '\"a\",\"b\",\"c\"'\n no_brackets = content[1...-1]\n\n # '\"a\",\"b\",\"c\"' -> ['\"a\"', '\"b\"', '\"c\"']\n quoted_elements = no_brackets.split(\", \")\n\n # ['\"a\"', '\"b\"', '\"c\"'] -> ['a', 'b', 'c']\n quoted_elements.map { |quoted_elt| quoted_elt[1...-1] }\n rescue\n []\n end\n end", "def read_file_to_arr(path)\n ret = []\n File.open(path, \"r\") do |f|\n f.each_line do |line|\n ret << line.split(\" \").map { |s| s.to_i}\n end\n end\n return ret\nend", "def to_array str\n array = []\n str.split().each do |i|\n entry = i.split(\",\")\n\n width = entry[0].to_i\n height = entry[1].to_i\n\n if entry.length == 2\n array << [width, height]\n else\n ALL_MACROS[entry[2]].call(width, height, array)\n end\n end\n\n array\nend", "def read_XML_file(xfile)\n result_array = []\n if File.file?(xfile)\n puts \"\\n\\nOPENING #{xfile}\"\n f = File.open(xfile)\n doc = Nokogiri::XML(f)\n if is_squish?(doc)\n result_array = squish_parser(doc)\n else\n result_array = rspec_parser(doc)\n end\n else\n puts \"\\nNot a file: #{xfile} - verify options (-x for directory, -f for a specific file)\"\n end\n return result_array \n end", "def parse_xml (xml)\n\n xml = REXML::Document.new(xml) \\\n if xml.is_a?(String)\n\n xml = xml.root \\\n if xml.is_a?(REXML::Document)\n\n if xml.is_a?(REXML::Text)\n\n s = xml.to_s.strip\n\n return s if s.length > 0\n\n return nil\n end\n\n return nil if xml.is_a?(REXML::Comment)\n\n # then it's a REXML::Element\n\n rep = [\n xml.name,\n xml.attributes.inject({}) { |r, (k, v)| r[k] = v; r },\n [] ]\n\n xml.children.each do |c|\n\n r = parse_xml(c)\n\n rep.last << r if r\n end\n\n rep\n end", "def Array(p0) end", "def to_a\n return @array if @array\n decoded = decode_format ? string.unpack(decode_format)[0] : string\n if string.size == 0\n []\n else\n uncompressed = @compressed ? Zlib::Inflate.inflate(decoded) : decoded\n uncompressed.unpack(unpack_format)\n end\n end", "def to_a\n collect { |node| node.data }\n end", "def array_from_string string\n # takes the string found when params tries to return an array, and reconstruct the array.\n array = string.split(/[^Q1234567890]+/)\n array.delete(\"\")\n array\n end", "def to_a\n array\n end", "def to_a; [Array]; end", "def parse_xml(file)\n @data_pts = Array.new\n doc = REXML::Document.new File.new(file)\n doc.elements.each('data/pt'){|pt|\n value = nil\n error = nil\n vars = Hash.new\n pt.attributes.each{|tag,val|\n\tif(tag == 'value')\n\t value = val.to_f\n\telsif(tag == 'error')\n\t error = val.to_f\n\telse\n\t vars[tag] = val.to_f\n\tend\t\n }\n @data_pts.push(DataPt.new(value,error,vars))\n }\n end", "def q1_read_to_array(data_file_name)\r\n array2d = []\r\n \r\n read_file(\"data/\"+data_file_name).each{ |line|\r\n array1d = line.split(\",\").map(&:strip).map(&:to_s)\r\n array2d << array1d\r\n }\r\n return array2d\r\nend", "def get_content_array(xpath_query)\n scraped_array = Array.new\n pos = 0\n @current_page.search(xpath_query).each do |var|\n scraped_array[pos] = var.content.strip\n pos += 1\n end\n scraped_array\n end", "def parse(str)\n # defined in ext/rdo_postgres/arrays.c\n end", "def retrieve_xmlelements(xpath_str)\n collection = []\n if NOKOGIRI\n @xml.xpath(xpath_str).each { |pelem|\n collection << XMLElement.new(pelem)\n }\n else\n @xml.elements.each(xpath_str) { |pelem|\n collection << XMLElement.new(pelem)\n }\n end\n collection\n end", "def getMembersAsArray() \n ret = []\n it = self.getIterator() \n while(it.hasMoreResources())\n ret << it.nextResource().getContentAsREXML()\n end\n \n return ret\n end", "def string_to_array_method\n @card_array = @card_number_string.chars\n end", "def to_ary \n\t\t\treturn @elem.to_ary\n\t\tend", "def _from_xml(xml)\n return XmlSimple.xml_in(xml, {\n 'ForceArray'=>['accessGroup'],\n 'GroupTags'=>{\n 'services'=>'service',\n 'metros'=>'metro',\n 'networkIdentifiers'=>'ni'\n },\n 'KeyAttr'=>['id','name']\n })\n end", "def board_to_array(board_string)\n return board_string.split(\"\").map! { |value| value.to_i }\n\nend", "def parse(str)\n Ox.sax_parse(self, StringIO.new(str), symbolize: false, convert_special: true)\n end", "def getSizeAsArray\n rows = self.size.strip.split(\"\\r\\n\")\n @result = []\n rows.each do |row|\n @result << row.split('x')\n end\n\n return @result \n end", "def lisp_list_to_array(ast)\n\t\t\tarray = []\n\t\t\twhile ast.kind_of? LispPair\n\t\t\t\tarray << ast.first\n\t\t\t\tast = ast.rest\n\t\t\tend\n\t\t\treturn array\n\t\tend", "def tsv2array( data )\n return_data = [] \n data_by_line = data.split(\"\\n\")\n \n data_by_line.each do |d|\n intermediate = {}\n data_by_item = d.split(\"\\t\")\n for i in 0 .. ( data_by_item.size() - 1 )\n intermediate[ self.attributes[i] ] = data_by_item[i]\n end\n return_data.push( intermediate )\n end\n \n return return_data\n end", "def aryfy(arg)\n ast AST::ASTArray, :children => [arg]\n end", "def to_array\n\t@word.chars \nend", "def to_arr(value)\n if value.is_a?(Array)\n value\n else\n # Split by commas, but don't use commas inside double quotes\n # https://stackoverflow.com/questions/21105360/regex-find-comma-not-inside-quotes\n value.to_s.split(/(?!\\B\"[^\"]*),(?![^\"]*\"\\B)/)\n end\n end", "def array_tree\n return @array_tree if @array_tree\n @description.strip!\n #@description.gsub!(/[^\\s()]+/, '\"\\0\"')\n @description.gsub!(/[^\\s()]+/) {|w| '\"'+w.gsub('\"', '\\'')+'\"'}\n @description.gsub!('(', '[')\n @description.gsub!(')', ']')\n @description.gsub!(/\\s+/,\" \")\n @description.gsub!(' ', ', ')\n @description.gsub!('\\\\', '\\\\\\\\\\\\')\n begin\n @array_tree = eval(@description) # TODO safety level\n rescue Exception => ex\n puts \"Error while parsing:\\n#{@description}\"\n end\n @array_tree\n end", "def call(string)\n Sequel::Postgres::PGArray.new(Sequel::Postgres.parse_pg_array(string, @converter), @type)\n end", "def csv_to_array(csv)\n csv.split(\",\").map(&:strip)\n end", "def csv_to_array(csv)\n csv.split(\",\").map(&:strip)\n end", "def as_content_array\n as_array[1]\n end", "def to_ary\n\t\t\treturn @elements.to_ary\n\t\tend", "def to_array\n @word.chars\n end", "def each_to_a(s)\n a = []\n s.each { |i| a << i }\n a\n end", "def to_array\n array = []\n self.each { |x| array.push x }\n return array\n end", "def get_arrays(line)\n pairs = line.chomp.split(',')\n arrys = pairs.map do |range|\n indeces = range.split('-').map(&:to_i)\n (indeces.first..indeces.last).to_a\n end\nend", "def parse\n Ox.parse(@xml)\n end", "def java_tree_to_arrays(tree)\n # label just has to be unique. don't think we're using it for anything\n label = tree.label.value + '-' + tree.object_id.to_s\n root = Tree::TreeNode.new(label, tree.label.value)\n tree.children.each{|x|root << java_tree_to_arrays(x)}\n root\n end", "def to_ary\n\t\t@data.flatten\n\tend", "def converted_arrays; end", "def convert_to_ruby_array( java_array, to_string = false )\n java_array.to_a\n end", "def markup_to_parameter_array(str)\n str.downcase.slice(1,str.size-2).strip.gsub(/[\\s]+/, \" \").split(/:/).map {|s| s.strip}\n end", "def to_array(string)\n word_array=[]\n string.scan(/\\w+/)\nend", "def retrieve_elements(filter)\n elements_array = Array.new\n\n if NOKOGIRI\n @xml.xpath(filter.to_s).each { |pelem|\n elements_array << pelem.text if pelem.text\n }\n else\n @xml.elements.each(filter.to_s) { |pelem|\n elements_array << pelem.text if pelem.text\n }\n end\n\n if elements_array.size == 0\n return nil\n else\n return elements_array\n end\n\n end", "def str2array(type, str)\n case type\n when :char, :int8\n str.unpack('c*')\n when :uchar, :uint8\n str.unpack('C*')\n when :short, :int16\n str.unpack('s*')\n when :ushort, :uint16\n str.unpack('S*')\n when :int32\n str.unpack('l*')\n when :uint32\n str.unpack('L*')\n when :int\n str.unpack('i!*')\n when :uint\n str.unpack('I!*')\n when :bool\n str.unpack('i!*') != 0\n when :long\n str.unpack('l!*')\n when :ulong\n str.unpack('L!*')\n when :long_long, :int64\n str.unpack('q*')\n when :ulong_long, :uint64\n str.unpack('Q*')\n when :size_t\n str.unpack(SIZET_FORMAT)\n when :float\n str.unpack('f*')\n when :double\n str.unpack('d*')\n when :string, :pointer\n str.unpack('p*')\n else\n raise \"unknown type #{type}\"\n end\n end", "def extract_response(xml_data)\n doc = REXML::Document.new(xml_data)\n r = 0\n x = ''\n s = ''\n doc.root.each_element('//Result') { |elt| r = elt.text} \n doc.root.each_element('//XMLout') { |elt| x = pretty_xml(elt.text)} \n doc.root.each_element('//CapabilitiesOut') { |elt| x = pretty_xml(elt.text)} \n doc.root.each_element('//SuppMsgOut') { |elt| s = elt.text } \n return [r.to_i,s,x];\n end", "def normalize_attrs(attrs)\n attr_pairs = []\n case attrs.first\n when Array, NilClass\n attr_pairs = attrs\n when String\n attrs.each_index {|i|\n next if i % 2 == 0\n attr_pairs << [attrs[i-1],attrs[i]]\n }\n else # Wow, yet another format! It's either from the distant past or distant future.\n raise ::Msf::DBImportError.new(\"Unknown format for XML attributes. Please check your Nokogiri version.\")\n end\n return attr_pairs\n end", "def parse_xml\n\n raise \"parse_xml method has not been implemented in this class\"\n \n end", "def to_array(version)\n version.split(/[.-]/).map do |x|\n if x =~ /\\A.*([0-9]+).*\\Z/\n $1.to_i\n else\n 0\n end\n end\nend", "def sentence_to_array (string)\n string_split = string.split('.')\n string_split.map! do |words|\n words.split('!') \n end\n string_split.flatten!\n\n string_split.map! do |words|\n words.split('?') \n end\n string_split.flatten\nend", "def to_a\n\t\tarr = []\n\t\teach {|valor| arr << valor}\n\t\tarr\n\tend", "def to_plist\n node = XML::Node.new('array')\n values.each do |attribute|\n node << attribute.to_s.to_plist\n end\n node\n end", "def prediction_to_array(string)\n segments = []\n string.scan(/[io](\\d+)-(\\d+)/) do |m1, m2|\n segments << { :start => m1.to_i, :stop => m2.to_i }\n end\n segments\n end", "def to_a\n nodes.map(&:at)\n end", "def parse_string(xml_string)\n doc = Handsoap::XmlQueryFront.parse_string(xml_string, :nokogiri)\n on_response_document(doc)\n doc\n end", "def issn_array\n return nil unless issn.present?\n return issn if issn.is_a?(Array)\n return JSON.parse(issn) if issn.start_with?('[')\n\n [issn]\n end" ]
[ "0.76040816", "0.666295", "0.65903074", "0.63825923", "0.6306955", "0.61723995", "0.61355793", "0.6132945", "0.61137897", "0.61028665", "0.5969989", "0.5931572", "0.5931572", "0.5922456", "0.59220636", "0.59026235", "0.58812326", "0.5865497", "0.5809855", "0.5809386", "0.5790098", "0.57783026", "0.57682014", "0.57222414", "0.5682123", "0.5666496", "0.5631557", "0.56222486", "0.56214607", "0.5618174", "0.5585551", "0.55616003", "0.5553693", "0.5553693", "0.55435276", "0.5543103", "0.5517353", "0.55084926", "0.5490478", "0.54872996", "0.54862696", "0.5471591", "0.5462679", "0.54600865", "0.5441207", "0.5436382", "0.540447", "0.53983945", "0.53932214", "0.539027", "0.53667396", "0.53663445", "0.53582335", "0.5357711", "0.5350239", "0.53465265", "0.5336119", "0.53234124", "0.5322282", "0.53148735", "0.5303229", "0.5302885", "0.53015554", "0.53012365", "0.5296774", "0.529654", "0.52923816", "0.5286552", "0.5258308", "0.524812", "0.524631", "0.5245016", "0.52296513", "0.52296513", "0.52257776", "0.52096367", "0.52064717", "0.52000725", "0.5197334", "0.5193772", "0.51784116", "0.5171244", "0.51537186", "0.5153266", "0.51464665", "0.51453495", "0.5139349", "0.51315796", "0.5128074", "0.512551", "0.512137", "0.51213396", "0.5114823", "0.51010066", "0.50997764", "0.50891364", "0.50854874", "0.5085465", "0.5082869", "0.5076081" ]
0.8026987
0
=begin To get hash value of job
def get_hash() return @@hash; end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def job_hash\n [@image,@config].hash\n end", "def job_hash\n [@image,@config].hash\n end", "def job_key\n Digest::MD5.hexdigest(path)\n end", "def expected_digest\n hash = {\n 'class' => 'CourseDataUpdateWorker',\n 'queue' => queue_for(@course),\n 'unique_args' => [@course_id]\n }.to_json\n digest = OpenSSL::Digest::MD5.hexdigest hash\n \"uniquejobs:#{digest}\"\n end", "def block_hash\n\t\tdigest = Digest::SHA2.new\n\n\t\tdigest << '%d' % [ self.index ]\n\t\tdigest << self.timestamp.strftime( '%s%N' )\n\t\tdigest << self.payload\n\t\tdigest << self.payload_hash\n\t\tdigest << self.proof.to_s\n\t\tdigest << self.previous_hash\n\t\t\n\t\treturn digest.hexdigest\n\tend", "def sha\n result_hash['sha']\n end", "def job_key; Thread.current[:job_key]; end", "def hash\n shasum.hash\n end", "def hash\n shasum.hash\n end", "def hash\n shasum.hash\n end", "def hash\n id.hash + 32 * bs_request.hash\n end", "def hash\n 0\n end", "def hash() end", "def hash() end", "def hash() end", "def hash() end", "def hash() end", "def hash() end", "def hash() end", "def hash\n @hash || calculate_hash!\n end", "def calculate_hash!\n prefix = PREFIX_NAME_LOOKUP[self.type]\n # add special cases for refs\n self.hash_id = NodeId.sha1(\"#{prefix} #{self.size}\\0#{self.content}\")\n end", "def hash\n Digest::SHA256.hexdigest( \"#{nonce}#{time}#{difficulty}#{prev}#{data}\" )\n end", "def compute_hash( path )\n res = '0'\n autorelease_pool { res = NSData.sha1FromContentsOfFile(path) }\n res\n end", "def getJobId()\n return @helper.getJobId()\n end", "def getJobId()\n return @helper.getJobId()\n end", "def getJobId()\n return @helper.getJobId()\n end", "def getJobId()\n return @helper.getJobId()\n end", "def getJobId()\n return @helper.getJobId()\n end", "def getJobId()\n return @helper.getJobId()\n end", "def getJobId()\n return @helper.getJobId()\n end", "def sha\n id.sha\n end", "def hash\n if @_hash.nil?\n @_hash = {}\n run\n end\n @_hash\n end", "def hash(block)\n Digest::SHA256.hexdigest(block.to_s.encode)\n end", "def hash\n @hash\n end", "def hash=(_arg0); end", "def hash\n @hash || @hash = (value.hash * -1)\n end", "def hash\r\n id.hash\r\n end", "def hash\n guid.hash\n end", "def getHash element\n\tfile = File.new(element)\n\thash = Digest::SHA256.file file\n\tfile.close\n\treturn hash.hexdigest \n\tend", "def hash\n value_id.hash\n end", "def get_hash(input)\n return $hasher.reset.update(input).to_s\nend", "def job\n @job\n end", "def job\n @job\n end", "def job\n @job\n end", "def test_calc_hash\r\n\t\ts = \"SYSTEM>Gaozu(100)\"\r\n\t\ttb = Block.new(\"0\", \"0\", s, \"1518893687.329767000\", \"fd19\")\r\n\t\tstringVal = tb.get_calculated_hash\r\n\t\tval = stringVal.strip.eql? \"fd18\"\r\n\t\t\r\n\t\tassert_equal val, true\r\n\tend", "def calculate_block_hash(block)\n Digest::SHA256.hexdigest(block.block_index.to_s + block.previous_block_hash + block.timestamp + block.data)\n end", "def calculate_payload_hash\n\t\treturn Digest::SHA2.hexdigest( self.payload )\n\tend", "def hash_code; end", "def hash_from_payload(payload)\n Digest::SHA256.digest(Digest::SHA256.digest( payload )).reverse.unpack(\"H*\")[0]\n end", "def job_id\n async && async.job_id\n end", "def hash\n return @id.hash\n end", "def current_sha\n @current_sha ||= Digest::SHA512.hexdigest(File.read(hostsfile_path))\n end", "def hash(*) end", "def hash\n id.hash\n end", "def hash\n id.hash\n end", "def hash\n id.hash\n end", "def hash\n id.hash\n end", "def hash\n id.hash\n end", "def hash\n id.hash\n end", "def hash\n id.hash\n end", "def hash\n id.hash\n end", "def hash\n id.hash\n end", "def hash\n id.hash\n end", "def get_broadhash\n blocks = self.blocks_get_status\n if blocks[\"success\"]\n return blocks[\"broadhash\"]\n else\n return nil\n end\n end", "def get_job_id\n # check if the job ID has already been set (the job name will not change\n # during execution, so it is safe to assume that the job ID won't change)\n if not defined? @job_id or @job_id == '' or @job_id == nil\n result = veeamconfig('job', 'list').lines\n if result.length > 1\n result.each_with_index do |line, index|\n # skip the first line of output, since it is just the table setup\n next if index == 0\n\n # split line into array by space\n bits = line.split(' ')\n # pull out the repository name\n job_name = bits[0]\n\n # parse and return the job ID\n @job_id = bits[1].tr('{}', '') if job_name == @resource[:job_name]\n return @job_id\n end\n\n # return false if the job doesn't exist\n false\n else\n # return false if there are no jobs that exist\n false\n end\n else\n # return the job ID if it's already set\n @job_id\n end\n end", "def get_hash(key)\n (Zlib.crc32(key).abs % 100).to_s(36)\n end", "def hash\n id.hash\n end", "def hash\n id.hash\n end", "def hash\n if @sha512hash != nil\n return @sha512hash.to_i(16)\n else\n super\n end\n end", "def hash; end", "def hash; end", "def hash; end", "def hash; end", "def hash; end", "def hash; end", "def hash; end", "def hash; end", "def hash; end", "def hash; end", "def job_identity(args)\n Digest::SHA1.hexdigest([ Time.now.to_f, rand, self, args ].join)\n end", "def hash\n @hash.hash\n end", "def c_hash\n sha256 = Digest::SHA256.new\n token = @code.token.token\n hashed_token = sha256.digest(token)\n first_half = hashed_token[0...hashed_token.length / 2]\n Base64.urlsafe_encode64(first_half).tr('=', '')\n end", "def hash()\n #This is a stub, used for indexing\n end", "def hash\r\n # TODO what if file is empty?\r\n @hash ||= Digest::SHA1.file(File.join(@directory, @filename)).hexdigest\r\n end", "def hash\n @id.hash\n end", "def hash\n return (path + file_id.to_s).hash\n end", "def hash() #:nodoc:\n prime = 31;\n result = 1;\n result = prime * result + @amount.to_i\n result = prime * result + @new_balance.to_i\n result = prime * result + (@date.nil? ? 0 : Bankjob.date_time_to_ofx(@date).hash);\n result = prime * result + (@raw_description.nil? ? 0 : @raw_description.hash);\n result = prime * result + (@type.nil? ? 0 : @type.hash);\n # don't use value date\n return result;\n end", "def get_namecoin_hash\n return @chunks[-7].hth if is_name_new?\n if is_name_firstupdate?\n name = @chunks[-10].to_s.hth\n rand = @chunks[-9].to_s.hth\n return Bitcoin.hash160(rand + name)\n end\n rescue\n nil\n end", "def hash\n\n self.h.fei.hash\n end", "def hash\n id.hash\n end", "def hash_id\n @hid\n end", "def hash\n value.hash\n end", "def hash\n [id, task_id, name, workflow_type, workflow_action, source_type, destination_type, status, log_time, job_started, job_finished, to_process_size, processed_size, to_process_files, processed_files, finalized_files, estimation_time, bandwidth].hash\n end", "def hash\n return @revision.hash if @revision\n return object_id\n end", "def get_size(folder,hash)\n \n size_command = 'du -sh '+folder+' | cut -f 1'\n\n job_size = `#{size_command}`\n job_size = job_size.chomp\n\n hash['job_size']=job_size\n\n\nend", "def calc_hash(pass)\n salt_cost = SCrypt::Engine.autodetect_cost(self[:salt])\n SCrypt::Engine.scrypt(pass, self[:salt], salt_cost, 32).unpack('H*').first\n end", "def sha_hash (arg)\r\n Digest::SHA2.hexdigest(arg)\r\n end", "def hash\n bytes.hash\n end", "def hash99999\n return nil unless @parts\n\n k = construct\n return nil unless k\n\n Digest::SHA256.hexdigest(construct[0..-6] << '99999')[0..23]\n end", "def hash\n @jira.hash ^ @issue.key.hash\n end" ]
[ "0.7202386", "0.7202386", "0.71622455", "0.6925619", "0.6860948", "0.6721181", "0.66859925", "0.66045046", "0.66045046", "0.66045046", "0.65331626", "0.65301454", "0.6493129", "0.6493129", "0.6493129", "0.6493129", "0.6493129", "0.6493129", "0.6493129", "0.6459377", "0.6381081", "0.6272972", "0.6242662", "0.6194756", "0.6194756", "0.6194756", "0.6194756", "0.6194756", "0.6194756", "0.6194756", "0.6153841", "0.6136685", "0.61050093", "0.61045057", "0.60971206", "0.60946006", "0.6092862", "0.608825", "0.6075308", "0.6070838", "0.6052103", "0.6011219", "0.600956", "0.600956", "0.6001005", "0.59969884", "0.5996083", "0.59910727", "0.5988518", "0.59827733", "0.5973803", "0.5967069", "0.5964638", "0.59646225", "0.59635204", "0.59635204", "0.59635204", "0.59635204", "0.59635204", "0.59635204", "0.59635204", "0.59635204", "0.59635204", "0.5951384", "0.594078", "0.59369457", "0.5933757", "0.5933757", "0.59316766", "0.59220773", "0.59220773", "0.59220773", "0.59220773", "0.59220773", "0.59220773", "0.59220773", "0.59220773", "0.59220773", "0.59220773", "0.5917596", "0.59163445", "0.59130263", "0.58980024", "0.5895089", "0.5891565", "0.58845645", "0.5882537", "0.58774763", "0.5870346", "0.586692", "0.5847013", "0.58200276", "0.5819418", "0.5815994", "0.5813166", "0.5809148", "0.5800705", "0.5790597", "0.57739925", "0.57734257" ]
0.57810384
98
=begin To get download url of inserted job
def get_download_url() return @@download_url; end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def url\n \"#{ProcessingJob.endpoint}/#{cloud_crowd_id}\"\n end", "def url\n \"#{File.join(job.url, number.to_s)}/\"\n end", "def build_jobs_url\n \"http://#{host_name}:#{port}/jobs\"\n end", "def track_download\n connection.get(links.download_location)[\"url\"]\n end", "def get_queue_url(job)\n sqs.create_queue(queue_name: job.queue_name)[:queue_url]\n end", "def jobconf_url\n NAMENODE_URL + \":50030/jobconf.jsp?jobid=#{job_id}\"\n end", "def job\n @job\n end", "def job\n @job\n end", "def job\n @job\n end", "def get_download\n\tend", "def batch_job_status_url\n return if job_description.blank?\n\n job_hash = JSON.parse(job_description)\n if job_hash && job_hash['jobId']\n AwsUtil.get_batch_job_url(job_hash['jobQueue'], job_hash['jobId'])\n end\n end", "def job(url)\n server(url).job(URI(url).path)\n end", "def url\n @client.get_download_link(@path)\n end", "def jobdetails_url\n NAMENODE_URL + \":50030/jobdetails.jsp?jobid=#{job_id}\"\n end", "def job \n @job\n end", "def archive_download_url\n raise \"Not implemented yet!\"\n end", "def update_real_url_and_filesize\n ItemJob.perform_later id\n end", "def download_location\n self.remote_location.blank? ? File.join(self.id, self.upload_file_name) : self.remote_location\n end", "def filename\n File.join(%w{public finished-jobs},Digest::SHA1.hexdigest(url)+\".txt\")\n end", "def result\n result = job.results.find_by!(name: \"my-file\")\n\n if result.file.attached?\n Jobler::FileDownload.new(\n url: url_for_result(name: \"my-file\")\n )\n else\n Jobler::FileDownload.new(\n file_name: \"some-file.zip\",\n temp_file: temp_file_for_result(name: \"my-file\")\n )\n end\n end", "def url\n client = client_from_attachment( hpg_resolve(shift_argument) )\n id = shift_argument\n\n if id\n b = client.get_backup(id)\n else\n b = client.get_latest_backup\n end\n\n if $stdout.isatty\n display '\"'+b['public_url']+'\"'\n else\n display b['public_url']\n end\n end", "def download_blob\n uuid = SecureRandom.uuid\n path = File.join(Dir.tmpdir, \"template-#{uuid}\")\n\n @logger.debug(\"Downloading job '#{@name}' (#{blobstore_id})...\")\n t1 = Time.now\n\n File.open(path, \"w\") do |f|\n App.instance.blobstores.blobstore.get(blobstore_id, f, sha1: present_model.sha1)\n end\n\n @logger.debug(\"Job '#{@name}' downloaded to #{path} \" +\n \"(took #{Time.now - t1}s)\")\n\n path\n end", "def job # this is a getter\n @job\n end", "def get_downloaded_filename\n get_download_filename\n end", "def fetch_job\n JSON.parse(RestClient.get(url).body)\n end", "def download_url\n process_emulation 10\n clear_progress_bar\n self.downloaded_at = Time.now.utc\n save! && ready!\n end", "def create_resultfile_link(report, job)\n \"http://s3.amazonaws.com/#{report[:bucket_name]}/resultfiles/#{job.resultfile_name}.zip\"\n end", "def download_uri\n return @download_uri\n end", "def tracks_get_download_link params = { :track_id => nil, :reason => 'save' }\n json = send_request 'tracks_get_download_link', params\n if json['success'] == true\n json['url']\n else\n puts \"Error: \" + json['message']\n exit\n end\n end", "def download_job(uuid, out_fn, username, password)\n puts \"Downloading data from job #{uuid} to #{out_fn}\"\n fail \"Output file exists!\" if File.exist?(out_fn)\n\n job = get_job(uuid, username, password)\n puts \"Job info:\"\n puts summarise_job(job, 2)\n puts \"\"\n\n # Download stuff.\n puts \"Retrieving index...\"\n index = get_json(job['results']['dataURL'], username, password, '')\n\n num_files = index['urlCount']\n puts \"Retrieving #{num_files} files...\"\n \n i = 0\n File.open(out_fn, 'w') do |out|\n index['urlList'].each do |url|\n i += 1\n print \" #{i} / #{num_files} (#{((i.to_f / num_files.to_f) * 100.0).round(2)}%) \\r\"\n\n begin\n # RAW HTTP get request\n res = Net::HTTP.get(URI(url))\n zlibr = Zlib::GzipReader.new(StringIO.new(res.to_s))\n out.puts zlibr.read\n rescue StandardError => e\n print \"\\n*** ERR on file #{i}, URL: #{url}\\n\"\n end\n \n end # /url iteration\n end # /file handle\n\n print \"Done\\n\"\nend", "def job_id\n async && async.job_id\n end", "def get_single_job_sample(client)\n response = client[\"jobs/#{$job_id}\"].get\n\n p ''\n p 'Get single job'\n p response\nend", "def initialize_url(batch_job_url)\n headers = DEFAULT_HEADERS\n headers['Content-Length'] = 0\n headers['x-goog-resumable'] = 'start'\n\n response = AdsCommon::Http.post_response(\n batch_job_url, '', @api.config, headers)\n\n return response.headers['Location']\n end", "def jobPath\n @jobPath ||= File.join(Utils.getSpoolPath, Utils.getJobFilename(@id))\n end", "def download_url(format='original')\n @download_urls[format] ||= begin\n response = API.instance.send_request('docs.getDownloadUrl', :doc_id => self.id, :doc_type => format)\n response.elements['/rsp/download_link'].cdatas.first.to_s\n end\n end", "def download_url(format='original')\n @download_urls[format] ||= begin\n response = API.instance.send_request('docs.getDownloadUrl', :doc_id => self.id, :doc_type => format)\n response.elements['/rsp/download_link'].cdatas.first.to_s\n end\n end", "def queue_to_download\n self.save!\n end", "def download_link\n \"http://#{self.registered_download.brand.default_website.url}/#{self.registered_download.url}/get_it/#{self.download_code}\"\n end", "def uri_for_job(job)\n uri = @jenkins_url + JENKINS_URI % {:job_name => job}\n\n uri += \"?token=#{@jenkins_build_key}\" unless @jenkins_build_key.nil?\n \n uri\n end", "def job\n fetch('games.final_fantasy_xiv.jobs')\n end", "def location\n @gapi.job_reference.location\n end", "def q_url\n return @q_url if @q_url\n @q_url = @sqs_queue.url\n @q_url\n end", "def save_to_server!\n DownloadWorker.perform_async(self.id)\n end", "def download_uri\n @attributes[:download_uri]\n end", "def download_uri\n @attributes[:download_uri]\n end", "def external_download_url\n @file.external_bytestream_uri.to_s\n end", "def complete_job()\n puts \"Completing job id #{@job.id}\"\n connect()\n @server.puts(Command::COMPLETE_JOB)\n @server.puts(@job.id)\n # Send the encoded file\n FileTransfer.send(@server,@job.destination)\n disconnect()\n end", "def get_artifact(job_name,filename)\n @artifact = job.find_artifact(job_name)\n response = make_http_request(Net::HTTP::Get.new(@artifact))\n if response.code == \"200\"\n File.write(File.expand_path(filename), response.body)\n else\n raise \"Couldn't get the artifact\"\n end\n end", "def run_job\n end", "def job_id\n @gapi.job_reference.job_id\n end", "def getIngest_job( job_id)\n params = Hash.new\n params['job_id'] = job_id\n return doCurl(\"get\",\"/ingest_job\",params)\n end", "def fetch_conversion_job(job_id)\n uri = URI(@config[:biodbnet][:url] + @config[:biodbnet][:fetch_path])\n res = Net::HTTP.post_form(\n uri,\n 'dbResFile' => job_id\n )\n res.body\n end", "def submission_url(submission_id)\n self.google_bucket_url + \"/#{submission_id}\"\n end", "def queue_url(*_)\n if Settings.active_job_queue.url\n Settings.active_job_queue.url\n else\n super\n end\n end", "def getJobId()\n return @helper.getJobId()\n end", "def getJobId()\n return @helper.getJobId()\n end", "def getJobId()\n return @helper.getJobId()\n end", "def getJobId()\n return @helper.getJobId()\n end", "def getJobId()\n return @helper.getJobId()\n end", "def getJobId()\n return @helper.getJobId()\n end", "def getJobId()\n return @helper.getJobId()\n end", "def get_upload_url\n # raise 'Login first!' unless @customer_login_id\n\n response = @savon.call :get_upload_url, \n message: { 'wsdl:sessionID' => @session_id }\n \n @upload_url = response.body[:get_upload_url_response][:get_upload_url_result] \n end", "def post_job_content_sample(client)\n job_multipart = {\n :file => File.new($full_path),\n 'num copies' => 10\n }\n\n response = client['jobs'].post job_multipart\n\n p ''\n p 'Submit a new job'\n p response\nend", "def export_job\n return nil if completed?\n export_sie = Services::ExportSie.new(self)\n if export_sie.create_file(sie_type)\n logger.info \"** sie_export #{id} create_file returned ok, marking complete\"\n complete\n else\n logger.info \"** sie_export #{id} create_file did NOT return ok, not marking complete\"\n end\n end", "def find_job(job_id)\n response = HTTParty.get(\"#{@host}/api/jobs/#{job_id}\")\n\n return response['job']\n end", "def job\n OSC::Machete::Job.new(\n script: script,\n pbsid: pbsid,\n host: host || workflow.batch_host,\n torque_helper: ResourceMgrAdapter.new(workflow)\n )\n end", "def download\n res = @stash_identifier.last_submitted_resource\n if res&.download_uri\n res = @stash_identifier.last_submitted_resource\n StashEngine::CounterLogger.version_download_hit(request: request, resource: res) if res\n redirect_to res.merritt_producer_download_uri # latest version, friendly download because that's what we do in UI for object\n else\n render text: 'download for this dataset is unavailable', status: 404\n end\n end", "def pending_file_url(item = nil)\n get_file_data(item)[:url].presence\n end", "def download_url\n @item.xpath('./enclosure').first['url']\n end", "def request_job_to_process\n \n response = HTTParty.get(\"#{@host}/api/process/request_job/#{@process_code}.json\", query: {\n api_key: @api_key\n })\n\n job = response[\"job\"]\n #If there is no job waiting, end script\n if job.nil? || job[\"id\"].to_i == 0 \n @helper.terminate(\"No job to process at this time\")\n else\n @helper.log(\"Starting process #{@process_code} for job: #{job[\"id\"]} - #{job[\"author\"]} - #{job[\"title\"]} - #{job[\"created_at\"]}\")\n end\n return job\n end", "def download_path\n if self.upload_file_name.nil?\n self.human_fastq_url\n else\n if self.study.public?\n download_file_path(self.study.url_safe_name, filename: self.bucket_location)\n else\n download_private_file_path(self.study.url_safe_name, filename: self.bucket_location)\n end\n end\n end", "def print_job_sample(client)\n response = client[\"jobs/#{$job_id}/print\"].put nil\n\n p ''\n p 'Print a job'\n p response\nend", "def download\n Delayed::Job.enqueue(ExportJob.new(current_account))\n flash[:success] = _('Give us some time then check your email.')\n redirect_to export_pages_path\n end", "def queue_job; end", "def get_job_preview_sample(client)\n response = client[\"jobs/#{$job_id}/preview/1\"].get\n\n p ''\n p 'Get job preview'\n uri = \"data:image/jpeg;base64,#{Base64.strict_encode64 response}\"\n p uri\nend", "def getExecutionsForAJob(job_id)\n uri = URI(RUNDECKSERVER + ':' + RUNDECKPORT + '/api/1/job/' + job_id + '/executions')\n http = Net::HTTP.new(uri.host, uri.port)\n headers = {\n 'Content-Type'=> 'application/json',\n 'X-RunDeck-Auth-Token'=> API_KEY \n}\n r = http.get(uri.path, headers)\n return r.body.force_encoding(\"UTF-8\")\nend", "def jobinfo\n dir + JOBINFO_FILENAME\n end", "def getTaskURL\r\n\t\t\t\t\treturn @taskUrl\r\n\t\t\t\tend", "def job_results(jobid)\r\n wait_on_status(jobid)\r\n puts \"Retrieving results for job [#{jobid}]\"\r\n uri = URI(\"http://api.idolondemand.com/1/job/result/\" + jobid)\r\n uri.query = URI.encode_www_form(:apikey => $api_key)\r\n res = Net::HTTP.get_response(uri, p_addr = $proxy_host, p_port = $proxy_port)\r\n return JSON.parse(res.body)['actions']\r\nend", "def run_job(job)\r\n @log = Logger.new(File.expand_path(\"#{Rails.root}/log/scraper_job.log\", __FILE__))\r\n @log.info(\"Job started\")\r\n \r\n # initial job parameters\r\n region_list = JSON.parse(self.target_region_list)\r\n days_to_gather = self.days_to_gather\r\n size_of_a_day = 86400 # epoch time units (86400 is equal to 24 hours)\r\n size_of_a_time_slice = 10800 # epoch time units (10800 is equal to 3 hours)\r\n \r\n # start gathering from the beginning of the current day\r\n initial_start_time = Time.new(Time.now.year, Time.now.month, Time.now.day).to_i\r\n number_of_time_slices = ((days_to_gather * size_of_a_day) / size_of_a_time_slice).to_i\r\n \r\n job.log.concat(\"\\n#{Time.now.strftime(\"%F %T %Z\")}: > #{self.class} started (id:#{self.id})\")\r\n job.log.concat(\"\\n#{Time.now.strftime(\"%F %T %Z\")}: > The Epoch Start Time: #{initial_start_time}\")\r\n job.log.concat(\"\\n#{Time.now.strftime(\"%F %T %Z\")}: > The Formatted Start Time: #{Time.at(initial_start_time).strftime(\"%c\")}\")\r\n job.save\r\n \r\n # iterate each region\r\n region_list.each {|region_name,region_lookup| \r\n #validate a region exists\r\n region = Region.find_by name: region_name\r\n if region\r\n \r\n # run the channel scraper\r\n encoded_uri = URI.encode(\"https://www.foxtel.com.au/webepg/ws/foxtel/channels?regionId=\" + region_lookup)\r\n #job.log.concat(\"\\n#{Time.now.strftime(\"%F %T %Z\")}: > The encoded URI for #{region_name} is #{encoded_uri}\")\r\n #job.save\r\n raw_channels_created = 0\r\n raw_channels_skipped = 0\r\n\r\n # access the file and the data_hash\r\n file = URI.parse(encoded_uri)\r\n get_file_count = 0\r\n begin\r\n data_hash = JSON.parse(file.read)\r\n rescue Errno::ECONNRESET => e\r\n get_file_count += 1\r\n retry unless get_file_count > 10\r\n job.log.concat(\"\\n#{Time.now.strftime(\"%F %T %Z\")}: > Tried #{get_file_count} times and couldn't get #{file}: #{e}\")\r\n job.save\r\n @log.error(\"#{e.message}\")\r\n @log.error(\"#{e.backtrace}\")\r\n rescue OpenSSL::SSL::SSLError => e\r\n get_file_count += 1\r\n retry unless get_file_count > 10\r\n job.log.concat(\"\\n#{Time.now.strftime(\"%F %T %Z\")}: > Tried #{get_file_count} times and couldn't get #{file}: #{e}\")\r\n job.save\r\n @log.error(\"#{e.message}\")\r\n @log.error(\"#{e.backtrace}\")\r\n end\r\n\r\n # populate an array of times from the data hash\r\n #@log.debug(\"#{data_hash.inspect}\") \r\n data_hash[\"channels\"].each {|channel_hash|\r\n #@log.debug(\"#{channel_hash.inspect}\")\r\n raw_channel = RawChannel.create_from_channel_hash(region, channel_hash)\r\n if raw_channel.new_record?\r\n raw_channels_skipped += 1\r\n else\r\n raw_channels_created += 1\r\n end\r\n }\r\n job.log.concat(\"\\n#{Time.now.strftime(\"%F %T %Z\")}: > Raw Channels Created: #{raw_channels_created}, Skipped: #{raw_channels_skipped}, Total: #{raw_channels_skipped + raw_channels_created} for #{region_name}(#{region_lookup.to_s}).\")\r\n job.save\r\n \r\n # run the program scraper\r\n raw_programs_created = 0\r\n raw_programs_skipped = 0\r\n \r\n number_of_time_slices.times do |i|\r\n start_time = Time.at(initial_start_time + (i* size_of_a_time_slice))\r\n end_time = Time.at(start_time.to_i + size_of_a_time_slice)\r\n encoded_uri = URI.encode(\"https://www.foxtel.com.au/webepg/ws/foxtel/grid/events?startDate=\" + start_time.to_i.to_s + \"000&endDate=\" + end_time.to_i.to_s + \"000&regionId=\" + region_lookup)\r\n #job.log.concat(\"\\n#{Time.now.strftime(\"%F %T %Z\")}: > The encoded URI is #{encoded_uri}\")\r\n #job.save\r\n \r\n # access the file and the data_hash\r\n file = URI.parse(encoded_uri)\r\n get_file_count = 0\r\n begin\r\n data_hash = JSON.parse(file.read)\r\n rescue Errno::ECONNRESET => e\r\n get_file_count += 1\r\n retry unless get_file_count > 10\r\n job.log.concat(\"\\n#{Time.now.strftime(\"%F %T %Z\")}: > Tried #{get_file_count} times and couldn't get #{file}: #{e}\")\r\n job.save\r\n @log.error(\"#{e.message}\")\r\n @log.error(\"#{e.backtrace}\")\r\n rescue OpenSSL::SSL::SSLError => e\r\n get_file_count += 1\r\n retry unless get_file_count > 10\r\n job.log.concat(\"\\n#{Time.now.strftime(\"%F %T %Z\")}: > Tried #{get_file_count} times and couldn't get #{file}: #{e}\")\r\n job.save\r\n @log.error(\"#{e.message}\")\r\n @log.error(\"#{e.backtrace}\")\r\n end\r\n \r\n # populate an array of times from the data hash\r\n #@log.debug(\"#{data_hash.inspect}\")\r\n data_hash[\"channelEventsByTag\"].each {|channel_events|\r\n #@log.debug(\"#{program_array.inspect}\")\r\n channel_tag = channel_events[0]\r\n channel = Channel.find_by_tag(channel_tag)\r\n raw_channel = RawChannel.find_by_channel_tag_and_region_name(channel_tag,region_name)\r\n if channel.nil? and raw_channel.nil?\r\n # no channel or raw channel\r\n job.log.concat(\"\\n#{Time.now.strftime(\"%F %T %Z\")}: > The channel record and raw_channel record for #{channel_tag} in #{region_name} does not exist!\")\r\n job.save\r\n else\r\n # channel is ok\r\n array_of_channel_events = channel_events[1]\r\n #job.log.concat(\"\\n#{Time.now.strftime(\"%F %T %Z\")}: > Processing #{array_of_channel_events.length} channel events for channel #{channel.name} for #{region_name}.\")\r\n #job.save \r\n array_of_channel_events.each { |channel_event|\r\n raw_program = RawProgram.create_from_channel_event(region, channel_tag, channel_event)\r\n if raw_program.new_record?\r\n raw_programs_skipped += 1\r\n else\r\n raw_programs_created += 1\r\n end \r\n } \r\n end\r\n }\r\n end\r\n job.log.concat(\"\\n#{Time.now.strftime(\"%F %T %Z\")}: > Raw Programs Created #{raw_programs_created}, Skipped: #{raw_programs_skipped}, Total: #{raw_programs_created + raw_programs_skipped} for #{region_name}(#{region_lookup.to_s}).\")\r\n job.save\r\n else\r\n # no region\r\n job.log.concat(\"\\n#{Time.now.strftime(\"%F %T %Z\")}: > The region record for #{region_name} does not exist!\")\r\n job.save\r\n end\r\n }\r\n \r\n job.log.concat(\"\\n#{Time.now.strftime(\"%F %T %Z\")}: > #{self.class} completed (id:#{self.id})\")\r\n job.save\r\n \r\n @log.info(\"#{self.class} completed (id:#{self.id})\")\r\n return true\r\n end", "def after job=dj\n end", "def download_link\n download_params = { :sub => 'download', :fileid => @fileid, :filename => @remote_filename, :cookie => @api.cookie }\n DOWNLOAD_URL % [ @server_id, @short_host, download_params.to_query ]\n end", "def job_params\n params.require(:url)\n end", "def mturk_url\n MTurkUtils.get_task_url self\n end", "def download_slideshow\n Down.download bucket_url.url\n end", "def url\n Rails.application.routes.url_helpers.nfs_store_download_path(id)\n end", "def download_url\n ActiveStorage::Current.host = Rails.application.routes.default_url_options[:host] if ActiveStorage::Current.host.blank?\n file.attached? ? file.blob.url : ''\n end", "def download\n \n @tmpfile = fetch_remote(location)\n \n @fetched_at = Time.new\n \n return @tmpfile\n \n end", "def load_job_submit\n location = Location.find_by_location_barcode(self.pdt_screen_def.get_input_control_value(\"location\"))\n self.set_temp_record(:location, location)\n if !location\n result_screen = PDTTransaction.build_msg_screen_definition(\"location does not exist\",nil,nil,nil)\n return result_screen\n end\n\n if !location.current_job_reference_id\n result_screen = PDTTransaction.build_msg_screen_definition(\"job not created , create new job\",nil,nil,nil)\n return result_screen\n end\n job = Job.find_by_id(location.current_job_reference_id)\n \n if !job\n result_screen = PDTTransaction.build_msg_screen_definition(\"job not created , create new job\",nil,nil,nil)\n return result_screen\n end\n\n if job.job_type_code.upcase != \"RECOOLING\"\n result_screen = PDTTransaction.build_msg_screen_definition(\"this is not a recooling job\",nil,nil,nil)\n return result_screen\n end\n\n if job.current_job_status.upcase != \"JOB_CREATED\"\n result_screen = PDTTransaction.build_msg_screen_definition(\"job[\" + job.job_number + \"] status must be 'created'\",nil,nil,nil)\n return result_screen\n end\n\n pallet_probes = PalletProbe.find_all_by_job_id(job.id)\n if (pallet_probes.length() == 0)\n error = [\"NO PROBES ALLOCATED\"]\n result_screen = PDTTransaction.build_msg_screen_definition(nil, nil, nil, error)\n return result_screen\n end\n\n ActiveRecord::Base.transaction do\n job.update_attribute(:current_job_status, \"JOB_LOADED\")\n\n self.set_transaction_complete_flag\n end\n\n self.set_transaction_complete_flag\n result_screen = PDTTransaction.build_msg_screen_definition(\"job loaded succesfully\",nil,nil,nil)\n return result_screen\n end", "def completing_work\n self.completed_at = Time.now\n\n # Log to recent_activities on request completion.\n request_data = name.blank? ? number : name\n req_link = request_link(number)\n\n # BJB Script and REST dont have current user\n log_user = User.current_user.nil? ? self.backup_owner : User.current_user\n\n # TODO: RJ: Rails 3: Log Activity plugin not compatible with rails 3\n #log_user.log_activity(:context => \"#{req_link} has been #{aasm_state}\") do\n freeze_request!\n #end\n update_properties # Now commit properties on completed request\n\n # if there is a run for this request, let it know we are done\n self.run.try(:request_completed, self)\n self.push_msg\n\n end", "def download\n track = tracks.joins(:library).where(:libraries => {:online => true}).first\n if track\n DownloadWorker.enqueue(:url => track.url, :song_id => self.id)\n else\n dequeue!\n end\n end", "def job_tracker_url(tracker)\n url_for :controller => :job_trackers, :action => 'show', :id => tracker\n end", "def success(job)\n complete()\n end", "def set_job\n @job = Job.find(params[:id])\n if @job.processing? && S3Store.read(S3Store::OUTPUT_BUCKET, \"#{@job.model_path}.out\")\n @job.solution_path = \"#{@job.model_path}.out\"\n @job.finished!\n @job.save\n end\n @job\n end", "def file_url\n return nil if target_item.files.empty?\n target_item.files.last.uri.to_s\n end", "def export_url\n begin\n \"/instruments/#{self.id}/export/#{latest_export.try(:id)}\"\n rescue\n nil\n end\n end", "def generated_url; end", "def file_url\n end", "def get_job(id)\n conn = @client.get do |req|\n req.url \"/api/v2/job/#{id}\"\n req.headers[\"Authorization\"] = @token\n end\n conn.body\n end", "def job\n\t\tjid = @db.hget('sgt-unit:'+@id, 'job')\n\t\treturn nil if jid == nil\n\t\tgetJob(@db, jid)\n\tend" ]
[ "0.651653", "0.64707714", "0.63897383", "0.6312987", "0.62368554", "0.61887854", "0.6162872", "0.6162872", "0.6159142", "0.61589646", "0.6135914", "0.61326665", "0.6115116", "0.61142886", "0.61062783", "0.60814697", "0.6069027", "0.6066687", "0.60637474", "0.60447466", "0.60434294", "0.604071", "0.6008169", "0.5999468", "0.5951778", "0.59373975", "0.59281754", "0.59222466", "0.58996737", "0.5894688", "0.5884692", "0.5866972", "0.5860629", "0.5847818", "0.57670516", "0.57670516", "0.5765755", "0.5758483", "0.5754531", "0.57500875", "0.5724379", "0.57206476", "0.57201445", "0.57179093", "0.57179093", "0.57109356", "0.5710791", "0.57012135", "0.56874937", "0.56840444", "0.56708235", "0.566552", "0.5663567", "0.56596744", "0.56513554", "0.56513554", "0.56513554", "0.56513554", "0.56513554", "0.56513554", "0.56513554", "0.5644901", "0.56388324", "0.56385756", "0.5610522", "0.5601643", "0.5601211", "0.5594967", "0.55900127", "0.55893534", "0.55845845", "0.5582747", "0.5569209", "0.55611414", "0.5555447", "0.5546404", "0.5540879", "0.5523765", "0.55161065", "0.5510554", "0.550358", "0.55017096", "0.549919", "0.5495089", "0.54925025", "0.54915315", "0.5488262", "0.5480056", "0.5464799", "0.5459822", "0.54588205", "0.54550946", "0.5446681", "0.54460114", "0.5436438", "0.54317534", "0.5424291", "0.5421159", "0.5414255", "0.5413095" ]
0.64159566
2
Serializes the object, POSTs it to +url+ with +format+, deserializes the returned document and updates properties accordingly.
def post(options={}, &block) response = http.post_uri(options.merge(:body => serialize), &block) handle_response(response) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def post url, object = nil\n request url, HTTP::Post, object\n end", "def save document\n ensure_connection!\n resp = connection.create_doc index_id, document.to_hash\n if resp.success?\n raw = document.instance_variable_get \"@raw\"\n raw.merge! JSON.parse(resp.body)\n return document\n end\n fail ApiError.from_response(resp)\n rescue JSON::ParserError\n raise ApiError.from_response(resp)\n end", "def put\n conn = @client.authorized_connection(url: @client.object_api_url)\n res = conn.put do |req|\n req.headers['Content-Type'] = \"application/json\"\n req.url resource_uri\n req.body = raw.to_json\n end\n if res.success?\n data = JSON.parse(res.body)\n self.class.new(data, @client)\n else\n nil\n end\n end", "def create(object, path = nil)\n to_ostruct(post(sanitize!(path), object.to_json))\nend", "def perform_post_with_object(path, options, klass)\n perform_request_with_object(:post, path, options, klass)\n end", "def save\n method, path = id ? [:post, :update] : [:put, :create]\n self.attributes = Connection.send(method, create_route(path), attributes_without_blanks).body['data']\n self\n end", "def patch\n conn = @client.authorized_connection(url: @client.object_api_url)\n res = conn.patch do |req|\n req.headers['Content-Type'] = \"application/json\"\n req.url resource_uri\n req.body = raw.to_json\n end\n if res.success?\n data = JSON.parse(res.body)\n self.class.new(data, @client)\n else\n nil\n end\n end", "def request url, klass, object\n url = URI url\n\n request = klass.new url.path\n\n if object\n request.body = object.to_xml\n end\n\n dispatch request, to: url\n end", "def post(object, url, headers={})\n do_request(\"post\", url, object, headers)\n end", "def update\n self.publish_json\n end", "def save_object(object, objectID = nil, request_options = {})\n client.put(Protocol.object_uri(name, get_objectID(object, objectID)), object.to_json, :write, request_options)\n end", "def save\n if new_record?\n fields = create_fields\n validate_on_create(fields)\n result_type = self.class.collection_name\n response = self.class.connection.post([fields].to_json)\n else\n fields = update_fields\n validate_on_update(fields)\n result_type = self.class.resource_name\n response = connection.post(fields.to_json)\n end\n parsed = JSON.parse(response)\n if parsed[result_type].empty?\n @errors = parsed[\"warnings\"] || []\n false\n else\n @properties = (new_record? ? parsed[result_type].first : parsed[result_type])\n @new_record = false\n @errors = []\n true\n end \n rescue RestClient::RequestFailed => e\n response = e.response.body\n parsed = JSON.parse(response)\n @errors = parsed[\"errors\"] || [e.message]\n false\n end", "def save(options = {}, &block)\n if block.present?\n raise MotionResource::URLNotDefinedError.new \"URL is not defined for #{self.class.name}!\" unless self.class.respond_to?(:url)\n\n action = if new_record?\n \"create\"\n elsif self.id.present?\n \"update\"\n else\n raise MotionResource::ActionNotImplemented.new \"Action ist not implemented for #{self.class.name}!\"\n end\n\n model = self\n\n model.id = nil if model.id.present? && action == \"create\"\n\n hash = buildHashFromModel(self.class.name.downcase, self)\n hash.merge!(options[:params]) if options[:params].present?\n\n requestBlock = Proc.new do |response|\n if response.ok? && response.body.present?\n json = BW::JSON.parse(response.body.to_str)\n\n model.wrap(json)\n model.lastSyncAt = Time.now if model.respond_to?(:lastSyncAt)\n model.save\n else\n model = nil\n end\n\n block.call(model) if block.present? && block.respond_to?(:call)\n end\n\n case action\n when \"create\"\n BW::HTTP.post(self.class.url, {payload: hash}, &requestBlock)\n when \"update\"\n BW::HTTP.put(\"#{self.class.url}/#{model.id}\", {payload: hash}, &requestBlock)\n end\n else\n super\n end\n end", "def perform_post_with_object_from_collection(path, options, klass, collection_name)\n perform_request_with_object_from_collection(:post, path, options, klass, collection_name)\n end", "def save doc\n if doc['_attachments']\n doc['_attachments'] = encode_attachments(doc['_attachments'])\n end\n if doc['_id']\n slug = CGI.escape(doc['_id'])\n CouchRest.put \"#{@root}/#{slug}\", doc\n else\n CouchRest.post \"#{@root}\", doc\n end\n end", "def save\n if self.class.find(name, client: client)\n client.post(api_path, to_json, headers)\n else\n client.put(api_path, to_json, headers)\n end\n true\n end", "def create_representation_with(doc, options, format)\n propagated_options, private_options = normalize_options!(options)\n\n representable_mapper(format, propagated_options).serialize(represented, doc, propagated_options, private_options)\n end", "def submit\n obj = ActiveSupport::Inflector.constantize(self.class.to_s.gsub(/Builder/, ''))\n obj.new(Client.post_xml_request(to_s))\n end", "def post\n resource.post(request, response)\n end", "def create\n \n @doc = Doc.new(params[:doc])\n\n respond_to do |format|\n if @doc.save\n save_object_relationship\n format.html { redirect_to(@doc, :notice => 'Doc was successfully created.') }\n format.xml { render :xml => @doc, :status => :created, :location => @doc }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @doc.errors, :status => :unprocessable_entity }\n end\n end\n end", "def perform_post_with_objects(path, options, klass)\n perform_request_with_objects(:post, path, options, klass)\n end", "def put url, object = nil\n request url, HTTP::Put, object\n end", "def post\n RestClient.post(url, @body, @header) do |rso, req, res|\n setup(rso, req, res)\n end\n end", "def save\n self.client.api_post(\"/feed\", self.create_params)\n end", "def create_object(opts)\n ctn = opts[:container_name]\n obn = opts[:object_name]\n if opts[:content].is_a?(String)\n body = StringIO.new(opts[:content])\n else\n body = opts[:content]\n end\n\n headers = opts[:headers] || {}\n if opts[:content_type].nil?\n headers['X-Detect-Content-Type'] = 'true'\n else\n headers['Content-Type'] = opts[:content_type]\n end\n if !opts[:metadata].nil?\n opts[:metadata].each do |k,v|\n headers[\"X-Object-Meta-#{k}\"] = v\n end\n end\n resp = self.execute_request(\n path: \"/#{ctn}/#{obn}\",\n method: \"PUT\",\n headers: headers,\n data: body\n )\n parse_object(resp, {'name' => obn, 'container_name' => ctn})\n resp[:object].reload if resp[:object]\n return resp\n end", "def update_with_url(url, options = {}, &block)\n use_callback = block_given?\n filtered_attributes = filtered_updatable_attributes(options)\n\n attributes = attributes_to_post_data(model_name, filtered_attributes)\n\n post_data = options[:params_root] || {}\n post_data.merge!(attributes)\n\n method = options[:method] || (persisted? ? :put : :post)\n api_client.send(method, url, post_data, options) do |data, status_code|\n assign_response_data = options.fetch(:save_response, true)\n if assign_response_data && status_code.to_s =~ /20\\d/ && data.is_a?(Hash)\n set_attributes_from_response(data)\n save if options[:save_response]\n end\n block.call(data, status_code, data) if use_callback\n end\n end", "def create\n @document = Document.new(document_params)\n\n respond_to do |format|\n if @document.save\n format.html{\n flash[:success] = \"Document has saved successfully!\"\n redirect_to @document\n }\n format.json {\n url = url_for @document\n render json: {\n status_code: 0,\n response:{\n url: url\n }\n }\n }\n else\n format.html{ render 'new' }\n format.json {\n render json: {\n status_code: 1,\n errors: @document.errors\n }\n }\n end\n end\n end", "def post( doc, opts = {} )\n response = http_action :post, nil, opts.merge( :doc => doc )\n doc['_id'], doc['_rev'] = response['id'], response['rev'] if doc.kind_of? Hash\n response\n end", "def create_document_using_post_with_http_info(document_request, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: DocumentApi.create_document_using_post ...'\n end\n # verify the required parameter 'document_request' is set\n if @api_client.config.client_side_validation && document_request.nil?\n fail ArgumentError, \"Missing the required parameter 'document_request' when calling DocumentApi.create_document_using_post\"\n end\n # resource path\n local_var_path = '/nucleus/v1/document'\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(['*/*'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = @api_client.object_to_http_body(document_request)\n auth_names = ['oauth2']\n data, status_code, headers = @api_client.call_api(:POST, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'Document')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: DocumentApi#create_document_using_post\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def put(options={}, &block)\n response = http.put_uri(options.merge(:body => serialize), &block)\n handle_response(response)\n self\n end", "def save(object)\n full_name = extract_full_name object\n post 'api/save', :id => full_name\n end", "def create\n @document = Document.new(document_params)\n\n if @document.save\n render :show, status: :created, location: @document\n else\n render json: @document.errors, status: :unprocessable_entity\n end\n end", "def save\n @client.patch(@endpoint, :content=>@changed)\n return nil\n end", "def save\n self.attributes =\n if persisted?\n PROXY.patch(\"#{resources_name}/#{id}\", attributes)\n else\n @persisted = true\n PROXY.post(resources_name, attributes)\n end\n end", "def update_properties_from(doc, options, format)\n propagated_options, private_options = normalize_options!(options)\n\n representable_mapper(format, propagated_options).deserialize(represented, doc, propagated_options, private_options)\n end", "def create\n @document = Document.new(params[:document])\n\n respond_to do |format|\n if @document.save\n format.html { redirect_to @document, notice: 'Document was successfully created.' }\n format.json { render jbuilder: @document, status: :created, location: @document }\n else\n format.html { render action: \"new\" }\n format.json { render json: @document.errors, status: :unprocessable_entity }\n end\n end\n end", "def post(url_variables:, body:)\n ensure_service_document\n\n end", "def save(doc)\n doc = encode_attachments_of(doc)\n\n if doc['_id']\n server.put(\"#{name}/#{CGI.escape(doc['_id'])}\", doc)\n else\n server.post(\"#{name}\", doc)\n end\n end", "def post endpoint, body = {}\n body.merge!(api_key: api_key, namespace: namespace)\n\n response = connection.post do |req|\n req.url endpoint\n req.body = body.to_json\n end\n\n format_response_or_raise_error(response)\n end", "def object\n instance_variable_defined?(:@object) ? @object : @object = begin\n if media_type == 'application/json'\n JSON.parse(body) rescue nil\n elsif media_type == 'application/x-www-form-urlencoded'\n CGI.parse(body).map { |k, vs| {k => vs.last} }.inject({}, &:update)\n end\n end\n end", "def update obj, &block\n populate(obj, &block).save!\n json obj\n end", "def save\n doc = collection.find_one()\n collection.update({\"_id\" => doc[\"_id\"]}, {'boom' => to_json})\n end", "def put\n RestClient.put(url, @body, @header) do |rso, req, res|\n setup(rso, req, res)\n end\n end", "def create\n @squadron_document = SquadronDocument.new(params[:squadron_document])\n\n respond_to do |format|\n if @squadron_document.save\n format.html { redirect_to @squadron_document, :notice => 'Squadron document was successfully created.' }\n format.json { render :json => @squadron_document, :status => :created, :location => @squadron_document }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @squadron_document.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n #returning connection.post(collection_path, to_xml, self.class.headers) do |response|\n returning connection.post(collection_path, to_ssj, self.class.headers) do |response|\n self.id = id_from_response(response)\n load_attributes_from_response(response)\n end\n end", "def post_request(object)\n end", "def create(obj)\n do_request('create', nil, nil, {'xml' => obj_to_xml(obj)})\n end", "def with_serializer(object, serializer); end", "def update\n document = Document.find(params[:id])\n if document.update(params_document)\n render json: document, status: 200\n else\n render json: document.errors, status: 422\n end\n\n end", "def save_design_doc(data)\n attrs = case data\n when String\n MultiJson.load(data)\n when IO\n MultiJson.load(data.read)\n when Hash\n data\n else\n raise ArgumentError, \"Document should be Hash, String or IO instance\"\n end\n rv = nil\n id = attrs.delete('_id').to_s\n attrs['language'] ||= 'javascript'\n if id !~ /\\A_design\\//\n rv = Result.new(:operation => :http_request,\n :key => id,\n :error => ArgumentError.new(\"'_id' key must be set and start with '_design/'.\"))\n yield rv if block_given?\n raise rv.error unless async?\n end\n req = make_http_request(id, :body => MultiJson.dump(attrs),\n :method => :put, :extended => true)\n req.on_body do |res|\n rv = res\n val = MultiJson.load(res.value)\n if block_given?\n if res.success? && val['error']\n res.error = Error::View.new(\"save_design_doc\", val['error'])\n end\n yield(res)\n end\n end\n req.continue\n unless async?\n rv.success? or raise res.error\n end\n end", "def publish(object)\n write(object)\n uri = @uri.merge(object.url)\n if(object.is_a? StructuredArticle) then\n if(object.publishDate == nil)then\n time = Time.now.httpdate.to_s\n prop = '<v:publish-date xmlns:v=\"vrtx\">' + time + '</v:publish-date>'\n self.proppatch(uri, prop)\n end\n end\n return uri.to_s\n end", "def create_brokerage_document_using_post_with_http_info(document_co, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: BrokerageApi.create_brokerage_document_using_post ...'\n end\n # verify the required parameter 'document_co' is set\n if @api_client.config.client_side_validation && document_co.nil?\n fail ArgumentError, \"Missing the required parameter 'document_co' when calling BrokerageApi.create_brokerage_document_using_post\"\n end\n # resource path\n local_var_path = '/brokerage/document'\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(['*/*'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = @api_client.object_to_http_body(document_co)\n auth_names = ['oauth2']\n data, status_code, headers = @api_client.call_api(:POST, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'BrokerageDocumentVO')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: BrokerageApi#create_brokerage_document_using_post\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def create_resource object\n object.save\n end", "def create\n @document = Document.new(params[:document])\n\n respond_to do |format|\n if @document.save\n format.html { redirect_to @document, :notice => 'Document was successfully created.' }\n format.json { render :json => @document, :status => :created, :location => @document }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @document.errors, :status => :unprocessable_entity }\n end\n end\n end", "def post\n Rentlinx.client.post(self)\n end", "def create\n run_callbacks :create do\n connection.post(collection_path, encode, self.class.headers).tap do |response|\n self.id = id_from_response(response)\n load_attributes_from_response(response)\n end\n end\n end", "def save\n if @parse_object_id\n method = :put\n self.merge!(@op_fields) # use operations instead of our own view of the columns\n else\n method = :post\n end\n\n body = safe_hash.to_json\n data = Parse.client.request(self.uri, method, body)\n\n if data\n # array operations can return mutated view of array which needs to be parsed\n parse Parse.parse_json(class_name, data)\n end\n\n if @class_name == Parse::Protocol::CLASS_USER\n self.delete(\"password\")\n self.delete(:username)\n self.delete(:password)\n end\n\n self\n end", "def putObject(object, body, contentType)\n\t\t\turi = parseURI(object)\n\t\t\tresponse = do_put(uri, body, contentType)\n\t\t\treturn nil if response == nil\n\t\t\treturn response\n\t\tend", "def put_document index, id, document\n uri = URI(\"http://#{@host}:#{@port_s}/#{index}/_doc/#{id}\")\n req = Net::HTTP::Put.new(uri)\n req.body = document.to_json\n run(uri, req)\n end", "def save\n object.save\n end", "def save\n update_attributes(WebPay.client.post(path, @updated_attributes))\n @updated_attributes = {}\n self\n end", "def create\n @document = Document.new(document_params)\n\n if @document.save\n render json: {status: 'SUCCESS', message:'Document created', data:@document}, status: :ok\n else\n render json: {status: 'ERROR', message:'Document not created', data:@document.errors}, status: :unprocessable_entity\n end\n\n end", "def create_document!(model)\n document = model.new(params)\n unless document.valid?\n error 400, convert(body_for(:invalid_document, document))\n end\n unless document.save\n error 400, convert(body_for(:internal_server_error))\n end\n document\n end", "def put(id:, url_variables:, body:)\n ensure_service_document\n end", "def transmit_document!\n version_id = document_version_ref_id\n version_id.present? ? update_document(version_id) : upload_document\n end", "def post(header = {})\n url = \"#{ApiClient.config.path}#{self.class.resource_path}\"\n response = ApiClient::Dispatcher.post(url, self.to_hash, header)\n attributes = ApiClient::Parser.response(response, url)\n update_attributes(attributes)\n end", "def swagger_object(target_class, request, options)\n object = {\n info: info_object(options[:info].merge(version: options[:doc_version])),\n swagger: '2.0',\n produces: options[:produces] || content_types_for(target_class),\n consumes: options[:consumes],\n authorizations: options[:authorizations],\n securityDefinitions: options[:security_definitions],\n security: options[:security],\n host: GrapeSwagger::DocMethods::OptionalObject.build(:host, options, request),\n basePath: GrapeSwagger::DocMethods::OptionalObject.build(:base_path, options, request),\n schemes: options[:schemes].is_a?(String) ? [options[:schemes]] : options[:schemes]\n }\n\n GrapeSwagger::DocMethods::Extensions.add_extensions_to_root(options, object)\n object.delete_if { |_, value| value.blank? }\n end", "def show\n if request.put?\n logger.debug params.inspect\n else\n respond_to do |format|\n format.html\n format.json { render :json => @document.to_obj }\n end\n end\n end", "def post(endpoint, options)\n #Send request\n res = RestClient.post endpoint,\n options,\n content_type: :json\n\n #Process and return response\n return JSON.parse(res.body, object_class: OpenStruct)\nend", "def post(url, resource_name, options = {})\n build_response(resource_name) do\n connection.post do |req|\n req.url url\n req.body = options.to_json\n end\n end\n end", "def create_or_update(object_fields, identifier,\n object_name, endpoint, create_object = true)\n # Check that user has authenticated\n @local_auth_error = local_auth_error\n\n return Hash[@error => @local_auth_error] if @local_auth_error\n\n # Check that object contains required fields and no bad fields\n field_error = get_field_errors(object_fields, object_name, create_object)\n\n return Hash[@error => field_error] if field_error\n\n # Since this is a POST request, we need an auth and object objects\n values = Hash['auth' => token_auth, 'object' => object_fields].to_json\n\n # Reformat the identifier with the leading '/' so it can be added to\n # the url. Do this here instead of the url assignment below so we can\n # set it to ' if it wasn't passed.\n identifier = identifier ? format('/%s', identifier) : ''\n\n # Construct url to post to\n url = format('%s/%s%s', @baseurl, endpoint, identifier)\n\n # Test mode, remove leading '/' from identifier\n identifier.slice!(0)\n test_identifier = identifier\n if @test\n return test_handler(object_fields, test_identifier,\n object_name, create_object)\n end\n\n # Attempt to POST to TimeSync, then convert the response to a ruby\n # hash\n begin\n # Success!\n response = RestClient.post(url, values, content_type: :json,\n accept: :json)\n return response_to_ruby(response.body, response.code)\n rescue => e\n # Request error\n return Hash[@error => e]\n end\n end", "def post(uri, doc = nil, options = {})\n execute(uri, :post, options, doc)\n end", "def serialize_json(o)\n API_CLIENT.object_to_http_body(o)\nend", "def post(path, options={}, format=format)\n request(:post, path, options, format)\n end", "def create\n @document_format = DocumentFormat.new(params[:document_format])\n\n respond_to do |format|\n if @document_format.save\n format.html { redirect_to root_path, notice: 'Document format was successfully created.' }\n format.json { render json: @document_format, status: :created, location: @document_format }\n else\n format.html { render action: \"new\" }\n format.json { render json: @document_format.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_record(http)\n json = %|{\n \"kind\": \"Article\",\n \"title\": \"Sample\",\n \"text\": \"Just some random text.\"\n}|\n resp = http.send_request('PUT', '/v1/Article', json, { 'Content-Type' => 'application/json' })\n # Response should be an OK with a JSON body.\n assert_equal(Net::HTTPOK, resp.class, 'response not an OK')\n reply = Oj.strict_load(resp.body, symbol_keys: true)\n\n # Make sure the message has the correct fields and values.\n assert_equal(0, reply[:code], 'create reply.code should be 0 meaning no error')\n ref = reply[:ref]\n refute_equal(nil, ref, 'create reply record reference can not be nil')\n refute_equal(0, ref, 'create reply record reference can not be 0')\n ref\n end", "def update(url, data)\n RestClient.put url, data, :content_type => :json\nend", "def update\n document = @document.revision.versions.new(document_params(true))\n if document.save\n send_emails_helper(document)\n render json: document.attributes_for_edit\n else\n render json: document.errors, status: :unprocessable_entity\n end\n end", "def save(options = {})\n handle_errors { self.class.get('/add', :query => options) }\n end", "def post endpoint, data\n do_request :post, endpoint, data\n end", "def ingest\n json = self.result.deep_dup.with_indifferent_access\n JsonUtilities.strip_uri_type!(json)\n JsonUtilities.clean_uris!(json)\n client = HTTPClient.new\n # fire & forget\n client.put_async(\"#{INGEST_BASE_URL}?api_key=#{ENV['RC_API_KEY']}&doi=#{URI.encode_www_form_component(doi)}\",\n MultiJson.dump(json),\n 'Content-Type' => 'application/json',\n 'Accept' => 'application/json')\n end", "def create\n @modified_document = ModifiedDocument.new(modified_document_params)\n \n if @modified_document.save\n render json: @modified_document, status: :ok\n else\n render json: @modified_document.errors, status: :unprocessable_entity\n end\n end", "def create\n @document = Document.new(params[:document])\n\n respond_to do |format|\n if @document.save\n format.html { redirect_to @document, notice: 'Document was successfully created.' }\n format.json { render json: @document, status: :created, location: @document }\n else\n format.html { render action: \"new\" }\n format.json { render json: @document.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @document = Document.new(params[:document])\n\n respond_to do |format|\n if @document.save\n format.html { redirect_to @document, notice: 'Document was successfully created.' }\n format.json { render json: @document, status: :created, location: @document }\n else\n format.html { render action: \"new\" }\n format.json { render json: @document.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @article = Article.new(article_params)\n response = RestClient.get 'http://scraper:3000/api/get', { params: { url: @article.url } }\n scraped_article = JSON.parse(response.body)\n @article.update({\n :title => scraped_article['title'],\n :byline => scraped_article['byline'],\n :excerpt => scraped_article['excerpt'],\n :content_html => scraped_article['content'],\n :readerable => scraped_article['readerable'],\n :scraped_at => DateTime.now\n })\n\n respond_to do |format|\n if @article.save\n format.html { redirect_to @article, notice: 'Article was successfully created.' }\n format.json { render :show, status: :created, location: @article }\n else\n format.html { render :new }\n format.json { render json: @article.errors, status: :unprocessable_entity }\n end\n end\n end", "def save\n update\n rescue Net::HTTPClientException => e\n # If that fails, go ahead and try and update it\n if e.response.code == \"404\"\n create\n else\n raise e\n end\n end", "def add_document(birthdate:, first_name:, last_name:, street:, postal_code:, country_code:, document_type:, document_value:)\n data = {\n doc: {\n birth_day: birthdate.day,\n birth_month: birthdate.month,\n birth_year: birthdate.year,\n name_first: first_name,\n name_last: last_name,\n address_street1: street,\n address_postal_code: postal_code,\n address_country_code: country_code,\n document_type: document_type,\n document_value: document_value\n }\n }\n\n @client.patch(path: \"/users/#{@user_id}\", oauth_key: @oauth_key, fingerprint: @fingerprint, json: data)\n end", "def to_doc\n logger.debug \"creating doc for class: #{self.class.name}, id: #{self.id}\"\n # Churn through the complete Active Record and add it to the Ferret document\n doc = Ferret::Document.new\n # store the id of each item\n doc[:id] = self.id\n\n # store the class name if configured to do so\n if configuration[:store_class_name]\n doc[:class_name] = self.class.name\n end\n \n # iterate through the fields and add them to the document\n fields_for_ferret.each_pair do |field, config|\n doc[field] = self.send(\"#{field}_to_ferret\") unless config[:ignore]\n end\n return doc\n end", "def create\n if(@document = Document.new(params[:document])).save\n flash['notice'] = 'Document was successfully created.'\n respond_with @document, \n :location => site_document_url(@document.site.slug , @document.id.to_s)\n else\n\n if doc = Document.where(uri: params[:document][:uri]).first\n params[:id] = doc.id\n update\n else\n respond_with @document\n end\n end\n \n end", "def create\n create_document\n\n respond_to do |format|\n if @node.new_record?\n @node.skin_id ||= current_site.root_node.skin_id\n\n flash.now[:error] = _(\"Upload failed.\")\n unless @node.respond_to?('target_klass')\n # Could we find another way to fake the new object as acting like a template ?\n class << @node\n def target_klass; nil; end\n end\n end\n format.html { render :action => 'new'}\n else\n flash.now[:notice] = _(\"Upload succeeded.\")\n format.html { redirect_to document_url(@node[:zip]) }\n end\n end\n end", "def create\n @published_document = PublishedDocument.new(params[:published_document])\n\n respond_to do |format|\n if @published_document.save\n flash[:notice] = 'PublishedDocument was successfully created.'\n format.html { redirect_to(@published_document) }\n format.xml { render :xml => @published_document, :status => :created, :location => @published_document }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @published_document.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n document = Document.find(params[:id])\n document.update!(update_params)\n render json: {}\n end", "def perform_post_with_objects_from_collection(path, options, klass, collection_name)\n perform_request_with_objects_from_collection(:post, path, options, klass, collection_name)\n end", "def upload\n doc = DocumentService::Document.create!({\n original_filename: params[\"original_filename\"],\n content_type: params[\"file\"].content_type,\n document: params['file'].tempfile,\n public: true\n })\n render json: {id: doc.id}, status: :created\n end", "def update_record(http, ref)\n json = %|{\n \"kind\": \"Article\",\n \"title\": \"Sample\",\n \"text\": \"Updated text.\"\n}|\n resp = http.send_request('POST', \"/v1/Article/#{ref}\", json, { 'Content-Type' => 'application/json' })\n # Response should be an OK with a JSON body.\n assert_equal(Net::HTTPOK, resp.class, 'response not an OK')\n reply = Oj.strict_load(resp.body, symbol_keys: true)\n\n # Make sure the message has the correct fields and values.\n assert_equal(0, reply[:code], 'update reply.code should be 0 meaning no error')\n updated = reply[:updated]\n assert_equal(1, updated.length, 'update reply.updated should contain exactly one member')\n ref = updated[0]\n refute_equal(nil, ref, 'update reply record reference can not be nil')\n refute_equal(0, ref, 'update reply record reference can not be 0')\n ref\n end", "def save\n generate_archive(generate_content_types, generate_rels, generate_document)\n end", "def publish\n p = Page.find_by_id(params[:id])\n p.published_on = Time.now\n p.save!\n respond_with p, :location => nil\n end", "def save!\n Post.create!(to_h) if save?\n end", "def serialize(object) end", "def update(params = {})\n raise \"Can't update a resource without a REST Client\" unless @client\n set_up_properties_from(@client.post(@path, params))\n self\n end" ]
[ "0.5841951", "0.5771368", "0.5770921", "0.5748789", "0.56112456", "0.5555683", "0.5555321", "0.5524757", "0.54836804", "0.54252154", "0.54065543", "0.5390666", "0.5313991", "0.53101856", "0.52858627", "0.5282111", "0.5273313", "0.5271023", "0.52601826", "0.52429634", "0.5216243", "0.52123666", "0.52017814", "0.51669914", "0.51364505", "0.51270235", "0.5113856", "0.5097557", "0.5071042", "0.50684816", "0.50604784", "0.5031988", "0.5027739", "0.4985086", "0.4962214", "0.49575388", "0.49423102", "0.49413595", "0.49381232", "0.4935282", "0.49327916", "0.49263334", "0.49252138", "0.488993", "0.4889734", "0.4879425", "0.4878516", "0.48586503", "0.48560077", "0.48447812", "0.48417905", "0.48415658", "0.48414758", "0.48412564", "0.4831812", "0.48315686", "0.48237288", "0.48189533", "0.48167986", "0.48156098", "0.48128694", "0.48115823", "0.48085296", "0.4806731", "0.48044023", "0.48020056", "0.47899616", "0.47875875", "0.47867104", "0.47863403", "0.47803986", "0.4778573", "0.47757334", "0.47540843", "0.47539252", "0.4748354", "0.4733523", "0.472975", "0.47276306", "0.47259805", "0.47227556", "0.47149262", "0.4714509", "0.4714509", "0.47086006", "0.47085196", "0.47012228", "0.46990114", "0.46945602", "0.46880022", "0.4687911", "0.46850306", "0.46789682", "0.46785593", "0.46763963", "0.467472", "0.46746263", "0.4672649", "0.46667263", "0.46660995" ]
0.5166971
24
GETs +url+ with +format+, deserializes the returned document and updates properties accordingly.
def get(options={}, &block) response = http.get_uri(options, &block) handle_response(response) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get(url, query = {})\n query[:format] ||= @format\n OEmbed::Response.create_for(raw(url, query), self, url, query[:format].to_s)\n end", "def get(url, options={})\n resp = RestClient.get url, rest_client_options(options)\n Representation.new self, MultiJson.load(resp)\n end", "def call\n fail(WordpRSS::InvalidURLError.new(\"#{url} is not a valid URL\")) unless url =~ URI::regexp\n\n RestClient.get(url)\n end", "def get(resource_uri, format = \"text/turtle\")\n uri = build_uri_for_resource resource_uri \n log \"get #{uri}\"\n request = Net::HTTP::Get.new(uri)\n request[\"Accept\"] = format\n response = Net::HTTP.start(uri.hostname, uri.port) {|http|\n http.request(request)\n }\n doc = FedoraDoc.new(response)\n log \"resource body \\r\\n#{doc.body}\"\n doc\n end", "def get_document_with_format(request)\n data, _status_code, _headers = get_document_with_format_with_http_info(request)\n request_token if _status_code == 401\n data\n end", "def service_document\n response = get(@url.to_s)\n response.body\n end", "def http_get(path, query, format = :json)\n uri = URI.parse(\"http://#{Jamendo::API_SERVER}/v#{Jamendo::API_VERSION}/#{path}#{query}\")\n puts uri.request_uri\n http = Net::HTTP.new(uri.host, uri.port) \n request = Net::HTTP::Get.new(uri.request_uri)\n begin\n response = http.request(request)\n result = parse_response(response)\n assert_response(result[:headers])\n return result[:results]\n rescue JamendoError => e\n e.inspect\n end\n end", "def get_resource(url, resource_class, params={})\n resource_class.from_hash(get(url, params), client: self)\n end", "def get url, params={}, headers={}\n uri = URI.parse(url)\n path = uri.path + \"?\" + query_string(default_params.merge(params))\n response = http(uri.host, uri.port).get(path, default_headers.merge(headers))\n JSON.parse(response.body)\n end", "def get(url, params = {})\n client.get(url, params).body\n end", "def get_document_all_using_get_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: DocumentApi.get_document_all_using_get ...'\n end\n # resource path\n local_var_path = '/nucleus/v1/document'\n\n # query parameters\n query_params = {}\n query_params[:'ascending'] = opts[:'ascending'] if !opts[:'ascending'].nil?\n query_params[:'filter'] = opts[:'filter'] if !opts[:'filter'].nil?\n query_params[:'order_by'] = opts[:'order_by'] if !opts[:'order_by'].nil?\n query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?\n query_params[:'size'] = opts[:'size'] if !opts[:'size'].nil?\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['*/*'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['oauth2']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'PageDocument')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: DocumentApi#get_document_all_using_get\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def do_get\n Net::HTTP.get(URI.parse(api_url))\n end", "def json_get(url)\n get url, :parse=>true\n end", "def test_get_document_with_format\n filename = 'test_multi_pages.docx'\n remote_name = 'TestGetDocumentWithFormat.docx'\n format = 'text'\n\n st_request = PutCreateRequest.new remote_test_folder + test_folder + '/' + remote_name, File.open(local_common_folder + filename, \"r\").read\n @storage_api.put_create st_request\n\n request = GetDocumentWithFormatRequest.new remote_name, format, remote_test_folder + test_folder\n result = @words_api.get_document_with_format request\n assert result.length > 0, 'Error occurred while converting document'\n end", "def get_response url, format\r\n begin\r\n response = Net::HTTP.get_response(URI.parse(url))\r\n if format.to_sym == :json\r\n res = JSON.parse response.body\r\n else\r\n res = response.body\r\n end\r\n rescue Exception => e\r\n res = \"ERROR: There is a problem while fetching data, please check whether OpenTSDB is running or not.\"\r\n end\r\n res\r\n end", "def fetch\n options = {\n \"url\" => @location\n }\n\n @connector.apply(:get, self, options)\n end", "def get(url, version: nil, locale: nil)\n @client.get(url, headers: headers(version: version, locale: locale))\n end", "def get(url)\n self.class.get(url)\n end", "def get(url, options={})\n rest_connection.get do |req|\n req.url build_url(url)\n req.headers['Content-Type'] = 'application/json'\n req.headers['Accept'] = 'application/json'\n req.params = options[:params] if options.has_key?(:params) && !options[:params].empty?\n req.options.timeout = config.rest_timeout\n req.options.open_timeout = config.rest_open_timeout\n end\n end", "def get(url, options = {})\n options[\"apikey\"] = @api_key\n uri = generate_uri(url, @default_options.merge(options))\n\n response = Net::HTTP.get_response(uri)\n json? ? JSON.parse(response.body) : response.body\n end", "def rest_get(url)\n JSON.parse(RestClient.get(url))\n end", "def fetch_raw(format=nil)\n @format = RESPONSE_FORMATS[format] if format\n http_pull(build_url)\n end", "def get\n JSON.parse(self.class.get(url).response.body)\n end", "def show\n @document_format = DocumentFormat.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @document_format }\n end\n end", "def get(url)\n begin\n # Start by creating a new `RestCLient::Resource` authenticated with\n # the `@project` name and `@password`.\n resource = RestClient::Resource.new(url) \n # `GET` the resource\n resource.get {|response, request, result, &block|\n case response.code\n when 200\n JSON.parse(response.body)\n else\n response.return!(request, result, &block)\n end\n }\n rescue => e\n # Rescue and reraise with the current `@url` for debugging purposes \n raise \"Problem fetching #{@url} because #{e.message}\"\n end\n end", "def document\n json = Net::HTTP.get_response URI.parse(query_string(@query))\n json.body\n end", "def get\n res = connection.get url.to_s\n Response.const_get(class_basename).new res.body, res.status\n end", "def get(path, query = {})\n url = URI.join(@api_url, path)\n\n @response_class.new(self,\n { url: url, query: query },\n get_http(url, query))\n end", "def get(url, representer)\n response = begin\n RestClient.get(url).body\n rescue RestClient::Exception => e\n raise RequestError, e.message\n end\n\n representer.from_json(response)\n end", "def fetch_with_url(url, options = {}, &block)\n use_callback = block_given?\n api_client.get(url) do |data, status_code|\n if data.present?\n fetch_with_attributes(data, save_associations: options[:save], &block)\n end\n block.call(data, status_code, data) if use_callback\n end\n end", "def get_document_using_get_with_http_info(document_id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: DocumentApi.get_document_using_get ...'\n end\n # verify the required parameter 'document_id' is set\n if @api_client.config.client_side_validation && document_id.nil?\n fail ArgumentError, \"Missing the required parameter 'document_id' when calling DocumentApi.get_document_using_get\"\n end\n # resource path\n local_var_path = '/nucleus/v1/document/{document_id}'.sub('{' + 'document_id' + '}', document_id.to_s)\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['*/*'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['oauth2']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'Document')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: DocumentApi#get_document_using_get\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def search_document_get_with_http_info(type, id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: SearchApi.search_document_get ...\"\n end\n # verify the required parameter 'type' is set\n if @api_client.config.client_side_validation && type.nil?\n fail ArgumentError, \"Missing the required parameter 'type' when calling SearchApi.search_document_get\"\n end\n # verify the required parameter 'id' is set\n if @api_client.config.client_side_validation && id.nil?\n fail ArgumentError, \"Missing the required parameter 'id' when calling SearchApi.search_document_get\"\n end\n # resource path\n local_var_path = \"/search/documents/{type}/{id}\".sub('{' + 'type' + '}', type.to_s).sub('{' + 'id' + '}', id.to_s)\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['oauth2_client_credentials_grant', 'oauth2_password_grant']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'Object')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: SearchApi#search_document_get\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def get(options = {}, all = true)\n uri = URI.parse(request_path(options, all))\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n response = http.request(Net::HTTP::Get.new(uri.request_uri))\n (options[:format] && options[:format] == \"pdf\") ? response.body : response.body\n end", "def get\n\t\t\tself.make_request!({uri: self.to_uri, method: :get})\n\t\tend", "def fetch(options = {})\n url = build_url(options)\n puts \"Getting #{url}\"\n\n json = get_response(url)\n\n if self.is_json?\n data = JSON.parse(json)\n else\n data = XmlSimple.xml_in(json)\n end\n\n # TODO: Raise hell if there is a problem\n\n collection = OpenCongressApi::Collection.build(json_result(data))\n collection.map!{|result| format_result(result)}\n end", "def get(url, options = {}, &block)\n options = treat_params_as_query(options)\n request HttpGetWithEntity, url, options, &block\n end", "def get(url, headers={})\n RestClient.get url, headers\n end", "def get(endpoint, url, args, version = 'v1')\n qs = build_qs(args)\n req_url = \"#{url}/api/#{version}/#{endpoint}?#{qs}\"\n\n request(req_url, :GET)\n end", "def get(path, query={})\n request_json :get, path, query\n end", "def show\n if request.put?\n logger.debug params.inspect\n else\n respond_to do |format|\n format.html\n format.json { render :json => @document.to_obj }\n end\n end\n end", "def get(url, options = {})\n self.class.default_params.merge!(options)\n response = self.class.get(url)\n handle_response(response)\n end", "def get endpoint\n do_request :get, endpoint\n end", "def get(url); end", "def get(url, headers = {})\n http :get, \"#{url}.json\", headers\n end", "def load_from_url!(url)\n uri = URI(url)\n req = Net::HTTP::Get.new(uri)\n req['Accept'] = 'application/json'\n\n res = Net::HTTP.start(uri.hostname, uri.port) do |http|\n http.request(req)\n end\n\n # TODO: handle redirects\n raise IOError, \"Unable to load URL #{url}\" unless res.is_a?(Net::HTTPOK)\n\n load_from_json!(res.body)\n end", "def get(api, params={})\n url2json(:GET, \"#{@endpoint}#{api}\", params)\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 get(path, params={})\n params = merge_set_up_params(params)\n @token = \"b3688c52-9235-45ca-b01f-c5b2b83a4f4f\"\n @result = Typhoeus::Request.get(API_URL + path, :params => params,\n :headers => {\"Authorization\" => \"Basic#{@token}\"})\n puts @result.body\n # check if the url looks correct in the log\n puts @result.effective_url\n # parse the result to json\n return JSON.parse(@result.body)\n end", "def rest_get(api_url)\n RestClient::Request.execute(method: :get,\n url: api_url,\n verify_ssl: @verify_ssl).body\n end", "def lws_api_get(path)\n # See also catalog_controller for use of ENV['LWS_...']\n url ||= ENV['LWS_API_URL']\n url ||= \"#{ENV['LWS_CORE_URL']}/api\" if ENV['LWS_CORE_URL']\n \n # http://localhost:8888/api/collections\n resp = Net::HTTP.get_response(URI.parse(\"#{url || 'http://127.0.0.1:8888/api'}#{path}\"))\n result = JSON.parse(resp.body)\n end", "def do_get url\n\t\turi = URI.parse(url)\n\t\tNet::HTTP.get_response(uri)\n\tend", "def test_get_document_with_format_and_out_path\n filename = 'test_multi_pages.docx'\n remote_name = 'TestGetDocumentWithFormat.docx'\n format = 'text'\n out_path = 'Out/TestGetDocumentWithFormat.txt'\n\n st_request = PutCreateRequest.new remote_test_folder + test_folder + '/' + remote_name, File.open(local_common_folder + filename, \"r\").read\n @storage_api.put_create st_request\n\n request = GetDocumentWithFormatRequest.new remote_name, format, remote_test_folder + test_folder, :out_path => out_path\n result = @words_api.get_document_with_format request\n assert result.length > 0, 'Error occurred while converting document'\n end", "def api_fetch(url)\n JSON.parse(RestClient.get url)\nend", "def get url, options={}\n options.merge!({:v => Time.now.strftime(\"%Y%m%d\")}) unless options[:v]\n response = self.class.get(url, {:query => options}).parsed_response\n if response[\"meta\"][\"code\"] == 200\n return response\n else\n raise Foursquared::Error.new(response[\"meta\"])\n end\n end", "def query(options = {})\n options.each_pair do |key, value|\n self.send(\"#{key}=\", value)\n end\n \n raise 'No API base URL provided.' unless @@base_url\n raise 'No API key provided.' unless @@api_key\n raise 'No resource specified.' unless @resource\n raise 'No format specified.' unless @format\n \n return do_get\n end", "def get(url)\n request(:get, url, {}, nil)\n end", "def get\n @research_output = @service.get({type: params[:graph], detail: params[:detail], id: params[:id]},\n host: request.env[\"HTTP_HOST\"], limit: params[:num_results], offset: params[:start_offset], :per_project => params[:per_project], format: params[:format])\n\n respond_with @research_output\n end", "def get_api_resource ( url )\n\n if @cache.exists( url )\n return @cache.get( url )\n end\n\n uri = URI( url )\n request = Net::HTTP::Get.new( uri )\n request['X-TBA-App-Id'] = \"#{@organization}:#{@app_identifier}:#{@version}\"\n\n resource = Net::HTTP.start( uri.hostname, uri.port,\n :use_ssl => uri.scheme == 'https' ) { |http|\n http.request( request )\n }\n\n case resource\n when Net::HTTPSuccess, Net::HTTPRedirection\n data = JSON.parse( resource.body )\n @cache.set( url, data )\n return data\n else\n resource.value\n end\n end", "def retrieve \n if !check_auth()\n render text: { \"message\" => \"401 Unauthorized\" }.to_json(), status: :unauthorized\n else\n uri = params[:uri]\n type = params[:type]\n doc = Document.find_by_uri(uri)\n if doc.present?\n case type\n when 'gale'\n render :text => doc.get_corrected_gale_xml()\n when 'text'\n render :text => doc.get_corrected_text()\n when 'tei-a'\n render :text => doc.get_corrected_tei_a(false)\n when 'tei-a-words'\n render :text => doc.get_corrected_tei_a(true)\n when 'original-gale'\n render :text => doc.get_original_gale_xml()\n when 'original-text'\n render :text => doc.get_original_gale_text()\n end\n else\n render text: { \"message\" => \"Document #{uri} not found\" }.to_json(), status: :not_found\n end\n end\n end", "def get url, options={}\n response = self.class.get(url, {:query => options}).parsed_response\n raise Skydrive::Error.new(response[\"error\"]) if response[\"error\"]\n response[\"data\"] ? response[\"data\"] : response\n end", "def get(resource_url, params)\n headers = {'Authorization' => authorization('GET', resource_url, params)}\n url = resource_url + '?' + URI.encode_www_form(params)\n res = URI.open(url, headers)\n Response.new(res)\n end", "def new\n @document_format = DocumentFormat.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @document_format }\n end\n end", "def get(options = {})\n from_web(@uri, options)\n end", "def get(id)\n Gini::Api::Document.new(self, \"/documents/#{id}\")\n end", "def perform_get(rest_url, request)\n query_params = request.api_params.blank? ? '' : to_query_params(request.api_params)\n url = \"#{rest_url}&#{query_params}\"\n\n response = RestClient::Request.execute(\n method: request.http_method,\n url: url,\n headers: request.header_params,\n read_timeout: 30,\n open_timeout: 15\n )\n JSON.parse(response)\n end", "def get(*args)\n params = args.extract_options!\n @connection.get do |req|\n req.url versioned_path(args), params\n end\n end", "def api_fetch(url)\n JSON.parse(URI.open(url).read)\nend", "def get(path, params={}, options={})\n request(:get, api_path(path), params, options)\n end", "def consume(url, options = {}, with_status = false)\n base_uri, path = extract_base_uri_and_path(url)\n\n method = (options[:method] || 'GET').to_s.downcase\n\n _options = build_httpparty_options(options, method)\n _options[:base_uri] = base_uri\n\n if with_status\n verbose_perform_request_to(method, path, _options)\n else\n perform_request_to(method, path, _options)\n end\n end", "def get(url)\n result = JSON.parse self.class.get(url, @request_options).body\n status = result['status']\n fail StandardError, \"Returned status: #{status}\" unless status == 'OK'\n result['response']\n end", "def download_url(format='original')\n @download_urls[format] ||= begin\n response = API.instance.send_request('docs.getDownloadUrl', :doc_id => self.id, :doc_type => format)\n response.elements['/rsp/download_link'].cdatas.first.to_s\n end\n end", "def download_url(format='original')\n @download_urls[format] ||= begin\n response = API.instance.send_request('docs.getDownloadUrl', :doc_id => self.id, :doc_type => format)\n response.elements['/rsp/download_link'].cdatas.first.to_s\n end\n end", "def get(url, resource_name, options = {})\n build_response(resource_name) do\n connection.get do |req|\n req.url url\n req.params = options\n end\n end\n end", "def get\n subclass(:Response).new connection.get do |req|\n req.url uri\n end\n end", "def initialize(uri = nil, factory = nil, json: nil, ld: nil)\n uri = json ? json['uri'] : nil if uri.nil?\n super(uri, factory)\n if json\n has_part = json['hasPart']\n is_part_of = json['isPartOf']\n self.authors = get_property('authors', json, single: false)\n self.book_jacket_url = get_property('bookjacketURL', json)\n self.date = get_property('date', json)\n self.doi = get_property('doi', json)\n self.edition = get_property('edition', json)\n self.edition_data = get_property('editionData', json)\n self.eissn = get_property('eissn', json)\n self.has_part = has_part ? factory.get(uri, json: has_part) : nil\n self.is_part_of = is_part_of ? factory.get(uri, json: is_part_of) : nil\n self.isbn10 = get_property('isbn10', json)\n self.isbn13 = get_property('isbn13', json)\n self.isbns = get_property('isbns', json, single: false)\n self.issn = get_property('issn', json)\n self.issue = get_property('issue', json)\n self.issued = json ? json['issued'] : nil # TODO\n self.latest_edition = get_property('latestEdition', json)\n self.local_control_number = get_property('lcn', json)\n self.online_resource = get_property('onlineResource', json) ? true : false\n self.page = get_property('page', json)\n self.page_end = get_property('pageEnd', json)\n self.page_start = get_property('pageStart', json)\n self.place_of_publication = get_property('placeOfPublication', json)\n self.publisher = get_property('publisher', json)\n self.title = get_property('title', json)\n self.type = get_property('type', json)\n self.url = get_property('url', json, is_url: true)\n self.volume = get_property('volume', json)\n end\n end", "def get(uri, options = {})\n build_response(request.get(uri, build_request_options({:input => options.to_params})))\n end", "def get(url)\n p = URI.parse url\n case p.scheme\n when /https?/\n http_get p, @resource[:path]\n when \"file\"\n FileUtils.copy p.path, @resource[:path]\n end\n end", "def get\n if(resource.exist?)\n #print_range(request)\n res = resource.get(request, response)\n if(res == OK && !resource.collection?)\n response['Etag'] = resource.etag\n response['Content-Type'] = resource.content_type\n response['Content-Length'] = resource.content_length.to_s\n response['Last-Modified'] = resource.last_modified.httpdate\n end\n res\n else\n NotFound\n end\n end", "def get(path, timestamp=nil, options={}, authenticate=true)\n path = \"#{path}?#{URI.encode_www_form(options)}\" if !options.empty?\n http_request :get, path, timestamp, options, authenticate\n end", "def get_document index, id\n uri = URI(\"http://#{@host}:#{@port_s}/#{index}/_doc/#{id}\")\n req = Net::HTTP::Get.new(uri)\n run(uri, req)\n end", "def download_image_online_with_http_info(document, index, format, password = nil)\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: SlidesApi.download_image_online ...'\n end\n\n # verify the required parameter 'document' is set\n if @api_client.config.client_side_validation && document.nil?\n fail ArgumentError, \"Missing the required parameter 'document' when calling SlidesApi.download_image_online\"\n end\n # verify the required parameter 'index' is set\n if @api_client.config.client_side_validation && index.nil?\n fail ArgumentError, \"Missing the required parameter 'index' when calling SlidesApi.download_image_online\"\n end\n # verify the required parameter 'format' is set\n if @api_client.config.client_side_validation && format.nil?\n fail ArgumentError, \"Missing the required parameter 'format' when calling SlidesApi.download_image_online\"\n end\n # verify enum value\n if @api_client.config.client_side_validation && !['Jpeg', 'Png', 'Gif', 'Bmp', 'Tiff'].any?{ |s| s.casecmp(format)==0 }\n fail ArgumentError, \"Invalid value for parameter format: \" + format + \". Must be one of Jpeg, Png, Gif, Bmp, Tiff\"\n end\n # resource path\n local_var_path = '/slides/images/{index}/{format}'\n local_var_path = @api_client.replace_path_parameter(local_var_path, 'index', index)\n local_var_path = @api_client.replace_path_parameter(local_var_path, 'format', format)\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(['multipart/form-data'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n header_params[:'password'] = password unless password.nil?\n\n # http body (model)\n post_body = nil\n\n # form parameters\n post_files = []\n if document\n post_files = post_files.push(document)\n end\n\n auth_names = ['JWT']\n data, status_code, headers = @api_client.call_api(:POST, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :body => post_body,\n :files => post_files,\n :auth_names => auth_names,\n :return_type => 'File')\n return data, status_code, headers\n end", "def call(url, **options)\n self.class.get url, options\n end", "def get(url, opts = {})\n response = RestClient::Request.new(\n method: :get,\n url: \"#{ENDPOINT_URL}/#{url}\",\n verify_ssl: false,\n headers: {\n 'Content-Type' => 'application/json',\n 'Authorization' => \"Basic #{authorization_hash}\",\n 'client-id' => client_id,\n 'access-token' => access_token\n },\n payload: opts\n ).execute\n\n JSON.parse(response)\n end", "def httpget(url, corpNum, userID = '')\n headers = {\n \"x-pb-version\" => KAKAOCERT_APIVersion,\n \"Accept-Encoding\" => \"gzip,deflate\",\n }\n\n if corpNum.to_s != ''\n headers[\"Authorization\"] = \"Bearer \" + getSession_Token(corpNum)\n end\n\n if userID.to_s != ''\n headers[\"x-pb-userid\"] = userID\n end\n\n uri = URI(getServiceURL() + url)\n request = Net::HTTP.new(uri.host, 443)\n request.use_ssl = true\n\n Net::HTTP::Get.new(uri)\n\n res = request.get(uri.request_uri, headers)\n\n if res.code == \"200\"\n if res.header['Content-Encoding'].eql?('gzip')\n JSON.parse(gzip_parse(res.body))\n else\n JSON.parse(res.body)\n end\n else\n raise KakaocertException.new(JSON.parse(res.body)[\"code\"],\n JSON.parse(res.body)[\"message\"])\n end\n end", "def get\n conn = @client.authorized_connection(url: @client.object_api_url)\n res = conn.get do |req|\n req.url resource_uri\n resource_params.each { |key, value|\n req.params[key] = value\n }\n end\n if res.success?\n data = JSON.parse(res.body)\n self.class.new(data, @client)\n else\n nil\n end\n end", "def get(url, options)\n headers = options[:headers] || {}\n params = options[:params] || {}\n url = url_with_params(url, params)\n req = Net::HTTP::Get.new(url)\n request_with_headers(req, headers)\n end", "def get\n RestClient.get(url, @header) do |rso, req, res|\n setup(rso, req, res)\n end\n end", "def get\n @response = Net::HTTP.get_response(URI(@url))\n end", "def get(url)\n call(url: url)\n end", "def get url # {{{\n # Pre-condition\n raise ArgumentError, \"The function expects a string, but got a (#{url.class.to_s})\" unless( url.is_a?(String) )\n\n # Main\n content = OpenStruct.new\n request = open( url )\n\n content.url = url\n content.content = request.readlines\n content.content_type = request.content_type\n content.charset = request.charset\n content.content_encoding = request.content_encoding\n content.last_modified = request.last_modified\n content.date = DateTime.now\n\n # Post-condition\n raise ArgumentError, \"Result should be of type OpenStruct, but is (#{content.class.to_s})\" unless( content.is_a?(OpenStruct) )\n\n content\n end", "def get(uri, *args)\n response = Faraday.new(request_options(args)) do |faraday|\n faraday.headers['Content-Type'] = 'application/json-patch+json'\n faraday.adapter Faraday.default_adapter\n faraday.response :logger, ::Logger.new(STDOUT), bodies: true if debug_mode?\n end.get(uri)\n\n raise Error, response.body unless response.status == 200\n\n parse_api_response(response.body).merge('headers' => response.headers)\n end", "def get(url, params={}, options={})\n FreebaseAPI.logger.debug(\"GET #{url}\")\n params[:key] = @key if @key\n options = { format: options[:format], query: params }\n options.merge!(@proxy_options)\n response = self.class.get(url, options)\n handle_response(response)\n end", "def show\n\n active_doc = site_account.api_docs_services.published.find_by_id_or_system_name! params[:id]\n\n json = if active_doc.specification.swagger_2_0?\n active_doc.specification.as_json\n else\n ThreeScale::Swagger::Translator.translate! active_doc.body\n end\n\n respond_with json\n end", "def read_with_http_info(file_publication_href, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: PublicationsFileApi.read ...'\n end\n # verify the required parameter 'file_publication_href' is set\n if @api_client.config.client_side_validation && file_publication_href.nil?\n fail ArgumentError, \"Missing the required parameter 'file_publication_href' when calling PublicationsFileApi.read\"\n end\n # resource path\n local_var_path = '{file_publication_href}'.sub('{' + 'file_publication_href' + '}', file_publication_href.to_s)\n\n # query parameters\n query_params = {}\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 => 'FileFilePublication')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: PublicationsFileApi#read\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def fetch(remote_url, &fetcher)\n entry = entry_for(remote_url)\n if entry.valid?\n entry.document\n else\n entry.document = fetcher.call\n end\n end", "def show\n @document = Document.find(params[:id])\n\n respond_to do |format|\n format.html # _resource.html.erb\n format.json { render json: @document }\n end\n end", "def call(**params)\n url = construct_url(**full_params(params))\n\n @client.get(url).yield_self do |response|\n guard_errors!(response)\n self.class.parse(response.body)\n end\n rescue API::Error\n raise # Not catching in the next block\n rescue StandardError => e\n raise unless url\n raise API::Error, \"#{e.class} at #{url}: #{e.message}\"\n end", "def call\n response = client.mget options\n\n pairs = response[\"docs\"].map { |doc| [doc[\"_id\"], doc[\"_source\"]] }\n\n pairs.to_h\n end", "def get url\n RestClient::Request.execute(:method => :get, :url => url, :headers => lbaas_headers, :timeout => @timeout, :open_timeout => @open_timeout)\n end", "def get_doc(url)\n page = MetaInspector.new(url)\n doc = page.document\n\n raise page.errors[0] if !page.ok?\n\n doc\n end", "def get(url, options={}, &block)\n http_options = options.merge(@basic_options)\n if block_given?\n RestClient.get(url, http_options, &block)\n else\n RestClient.get(url, http_options)\n end\n end" ]
[ "0.63117754", "0.621188", "0.60270643", "0.5922283", "0.5872436", "0.5795031", "0.57926154", "0.57490164", "0.57336766", "0.5714641", "0.57051593", "0.570485", "0.56958234", "0.56830424", "0.5682117", "0.5676084", "0.5672516", "0.5664012", "0.56617785", "0.56219715", "0.56212115", "0.56096435", "0.5604679", "0.55953664", "0.55581826", "0.55562", "0.55180615", "0.55118674", "0.5503091", "0.5481432", "0.54796666", "0.5457957", "0.545253", "0.5449035", "0.5435686", "0.54281735", "0.54274213", "0.54273546", "0.5417388", "0.54152536", "0.5413476", "0.5408446", "0.54078984", "0.539371", "0.5341574", "0.5336219", "0.5330006", "0.5320888", "0.5310575", "0.5307382", "0.5306704", "0.5298321", "0.5286971", "0.528293", "0.5279144", "0.52769566", "0.52736837", "0.5269532", "0.52537125", "0.52521896", "0.5246037", "0.52433676", "0.5241294", "0.52340215", "0.5233102", "0.52312356", "0.5223861", "0.52200633", "0.5218889", "0.52156514", "0.521382", "0.521382", "0.52075946", "0.5202297", "0.51993936", "0.5191431", "0.51715714", "0.51623964", "0.51610905", "0.5155797", "0.51487017", "0.5145458", "0.5134315", "0.51319563", "0.5120008", "0.5116316", "0.51161224", "0.51127046", "0.5111004", "0.5110645", "0.51053536", "0.51041126", "0.50994813", "0.5098188", "0.50973773", "0.5096785", "0.50926155", "0.5091466", "0.5090918", "0.508969", "0.50844145" ]
0.0
-1
Serializes the object, PUTs it to +url+ with +format+, deserializes the returned document and updates properties accordingly.
def put(options={}, &block) response = http.put_uri(options.merge(:body => serialize), &block) handle_response(response) self end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def put\n conn = @client.authorized_connection(url: @client.object_api_url)\n res = conn.put do |req|\n req.headers['Content-Type'] = \"application/json\"\n req.url resource_uri\n req.body = raw.to_json\n end\n if res.success?\n data = JSON.parse(res.body)\n self.class.new(data, @client)\n else\n nil\n end\n end", "def put url, object = nil\n request url, HTTP::Put, object\n end", "def put(object, url, headers={})\n do_request(\"put\", url, object, headers)\n end", "def put\n RestClient.put(url, @body, @header) do |rso, req, res|\n setup(rso, req, res)\n end\n end", "def perform_put_with_object(path, options, klass)\n perform_request_with_object(:put, path, options, klass)\n end", "def put(url, resource_name, options = {})\n build_response(resource_name) do\n connection.put do |req|\n req.url url\n req.body = options.to_json\n end\n end\n end", "def update\n self.publish_json\n end", "def put(url, payload = {}, headers = {})\n http :put, \"#{url}.json\", payload.to_json, headers\n end", "def patch\n conn = @client.authorized_connection(url: @client.object_api_url)\n res = conn.patch do |req|\n req.headers['Content-Type'] = \"application/json\"\n req.url resource_uri\n req.body = raw.to_json\n end\n if res.success?\n data = JSON.parse(res.body)\n self.class.new(data, @client)\n else\n nil\n end\n end", "def update(url, data)\n RestClient.put url, data, :content_type => :json\nend", "def put(url, body = {})\n call(url: url, action: :put, body: body)\n end", "def put(url, payload, headers={})\n RestClient.put url, payload, headers\n end", "def put(path, options={}, format=format)\n request(:put, path, options, format)\n end", "def update_with_url(url, options = {}, &block)\n use_callback = block_given?\n filtered_attributes = filtered_updatable_attributes(options)\n\n attributes = attributes_to_post_data(model_name, filtered_attributes)\n\n post_data = options[:params_root] || {}\n post_data.merge!(attributes)\n\n method = options[:method] || (persisted? ? :put : :post)\n api_client.send(method, url, post_data, options) do |data, status_code|\n assign_response_data = options.fetch(:save_response, true)\n if assign_response_data && status_code.to_s =~ /20\\d/ && data.is_a?(Hash)\n set_attributes_from_response(data)\n save if options[:save_response]\n end\n block.call(data, status_code, data) if use_callback\n end\n end", "def putObject(object, body, contentType)\n\t\t\turi = parseURI(object)\n\t\t\tresponse = do_put(uri, body, contentType)\n\t\t\treturn nil if response == nil\n\t\t\treturn response\n\t\tend", "def update obj, &block\n populate(obj, &block).save!\n json obj\n end", "def put(id:, url_variables:, body:)\n ensure_service_document\n end", "def put(url, payload, headers={})\n payload = MultiJson.encode(payload)\n headers = headers.merge({:content_type => 'application/json'})\n request(:put, url, payload, headers)\n end", "def put(url, payload, headers: {}, options: {})\n request_with_payload(:put, url, payload, headers, options)\n end", "def save_object(object, objectID = nil, request_options = {})\n client.put(Protocol.object_uri(name, get_objectID(object, objectID)), object.to_json, :write, request_options)\n end", "def update_properties_from(doc, options, format)\n propagated_options, private_options = normalize_options!(options)\n\n representable_mapper(format, propagated_options).deserialize(represented, doc, propagated_options, private_options)\n end", "def put(url, options = {}, &block)\n run! Request.new(url, :put, options.slice(:headers, :params, :payload), &block)\n end", "def perform_put_with_object_from_collection(path, options, klass, collection_name)\n perform_request_with_object_from_collection(:put, path, options, klass, collection_name)\n end", "def orchio_put(jdoc)\n response = client.send_request :put, inst_args(json: jdoc)\n if cache.enabled?\n simple_cache.save(\n Document.new(\n response.body.to_hash,\n Metadata.new(\n :collection => ocollection,\n :key => @id,\n :ref => response.header.etag\n )))\n end\n set_ref_value response\n orchio_status response, 201\n end", "def put url, payload\n RestClient::Request.execute(:method => :put, :url => url, :payload => payload, :headers => lbaas_headers, :timeout => @timeout, :open_timeout => @open_timeout)\n end", "def put endpoint, data\n do_request :put, endpoint, data\n end", "def put( doc, opts = {} )\n response = http_action :put, doc, opts.merge( :doc => doc )\n doc['_id'], doc['_rev'] = response['id'], response['rev'] if doc.kind_of? Hash\n response\n end", "def put(uri, doc = nil, options = {})\n execute(uri, :put, options, doc)\n end", "def put_document index, id, document\n uri = URI(\"http://#{@host}:#{@port_s}/#{index}/_doc/#{id}\")\n req = Net::HTTP::Put.new(uri)\n req.body = document.to_json\n run(uri, req)\n end", "def put(url, payload, options={}, &block)\n http_options = options.merge(@basic_options)\n if block_given?\n RestClient.put(url, payload, http_options, &block)\n else\n RestClient.put(url, payload, http_options)\n end\n\n end", "def put(path, request_options = {}, resource_options = {})\n response(:put, resource(resource_options)[path], request_options)\n end", "def update options={}\n client.put(\"/#{id}\", options)\n end", "def perform_put_with_objects(path, options, klass)\n perform_request_with_objects(:put, path, options, klass)\n end", "def put(params)\n self.class.put(url, body: params)\n end", "def update\n\n respond_to do |format|\n if @uri.update(uri_params)\n format.json { render json: @uri, status: 200 }\n else\n format.json { render json: @uri.errors, status: :unprocessable_entity }\n end\n end\n end", "def put(id, json)\n with_endpoint do |endpoint|\n url = [endpoint, @resource_name, id].compact.join('/')\n url += \"/\" \n return HTTParty.put(url, :body => json, :timeout => 4, :headers => { 'Content-Type' => 'application/json' })\n end\n end", "def 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 put options={}, &block\n handle_exceptions do\n Chimps.log.info(\"PUT #{url}\")\n Response.new(super(encoded_body, options, &block))\n end\n end", "def update(attributes = {})\n set_all(attributes)\n ensure_client && ensure_uri\n response = @client.rest_put(@data['uri'], { 'Accept-Language' => 'en_US', 'body' => @data }, @api_version)\n @client.response_handler(response)\n self\n end", "def fire_put(url_or_path, entity, options = {}, &block)\n url = absolute_url(url_or_path)\n headers = {:Accept => MEDIA_TYPE_JSON, :'Content-type' => ENCODED_MEDIA_TYPE_JSON}.\n merge(options.fetch(:headers, {}))\n headers = merge_log_weasel_header(headers)\n timeout = options.fetch(:timeout, Ladon.default_request_timeout)\n body = encode_entity(entity)\n response = Typhoeus::Request.put(url, headers: headers, timeout: timeout, body: body)\n handle_response(response, method: :put, url: url, default_data: options[:default_data],\n raise_on_error: options[:raise_on_error], &block)\n end", "def put options\n rest_request({ method: :put }.merge(options))\n end", "def put options\n rest_request({ method: :put }.merge(options))\n end", "def update(attributes = {})\n set_all(attributes)\n ensure_client && ensure_uri\n response = @client.rest_put(@data['uri'], { 'Accept-Language' => 'en_US', 'body' => @data }, @api_version)\n @client.response_handler(response)\n self\n end", "def put(url, options = {}, &block)\n request HttpPut, url, options, &block\n end", "def put(header = {})\n url = \"#{ApiClient.config.path}#{self.class.resource_path}\"\n response = ApiClient::Dispatcher.put(url, self.to_hash, header)\n attributes = ApiClient::Parser.response(response, url)\n update_attributes(attributes)\n end", "def put url, body, headers = {}\n http_request(url, Net::HTTP::Put, body, headers)\n end", "def put(url, vars={})\n send_request url, vars, 'PUT'\n end", "def put(path, options = {}, signature = false, raw = false, unformatted = false, no_response_wrapper = self.no_response_wrapper, signed = sign_requests)\n request(:put, path, options, signature, raw, unformatted, no_response_wrapper, signed)\n end", "def update(params = {})\n raise \"Can't update a resource without a REST Client\" unless @client\n set_up_properties_from(@client.post(@path, params))\n self\n end", "def show\n if request.put?\n logger.debug params.inspect\n else\n respond_to do |format|\n format.html\n format.json { render :json => @document.to_obj }\n end\n end\n end", "def create_object(opts)\n ctn = opts[:container_name]\n obn = opts[:object_name]\n if opts[:content].is_a?(String)\n body = StringIO.new(opts[:content])\n else\n body = opts[:content]\n end\n\n headers = opts[:headers] || {}\n if opts[:content_type].nil?\n headers['X-Detect-Content-Type'] = 'true'\n else\n headers['Content-Type'] = opts[:content_type]\n end\n if !opts[:metadata].nil?\n opts[:metadata].each do |k,v|\n headers[\"X-Object-Meta-#{k}\"] = v\n end\n end\n resp = self.execute_request(\n path: \"/#{ctn}/#{obn}\",\n method: \"PUT\",\n headers: headers,\n data: body\n )\n parse_object(resp, {'name' => obn, 'container_name' => ctn})\n resp[:object].reload if resp[:object]\n return resp\n end", "def put!\n request! :put\n end", "def put(uri, params = {})\n send_request(uri, :put, params)\n end", "def put\n if(resource.collection?)\n Forbidden\n elsif(!resource.parent_exists? || !resource.parent_collection?)\n Conflict\n else\n resource.lock_check if resource.supports_locking?\n status = resource.put(request, response)\n response['Location'] = \"#{scheme}://#{host}:#{port}#{url_format(resource)}\" if status == Created\n response.body = response['Location']\n status\n end\n end", "def put(path, params={}, options={})\n request(:put, api_path(path), params, options)\n end", "def put(path, options={})\n response = request(path, :put, options)\n validate response\n responsed_response = parse response\n data = { headers: response.headers, body: parsed_response }\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(resource, id, format=@default_format)\n options = { resource: resource.class, id: id, format: format }\n reply = put resource_url(options), resource, fhir_headers(options)\n reply.resource = parse_reply(resource.class, format, reply)\n reply.resource_class = resource.class\n reply\n end", "def update_document_using_put_with_http_info(document, document_id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: DocumentApi.update_document_using_put ...'\n end\n # verify the required parameter 'document' is set\n if @api_client.config.client_side_validation && document.nil?\n fail ArgumentError, \"Missing the required parameter 'document' when calling DocumentApi.update_document_using_put\"\n end\n # verify the required parameter 'document_id' is set\n if @api_client.config.client_side_validation && document_id.nil?\n fail ArgumentError, \"Missing the required parameter 'document_id' when calling DocumentApi.update_document_using_put\"\n end\n # resource path\n local_var_path = '/nucleus/v1/document/{document_id}'.sub('{' + 'document_id' + '}', document_id.to_s)\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['*/*'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = @api_client.object_to_http_body(document)\n auth_names = ['oauth2']\n data, status_code, headers = @api_client.call_api(:PUT, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'Document')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: DocumentApi#update_document_using_put\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def put(endpoint)\n respond_with(\n connection(endpoint).put(prepare(endpoint.uri), custom_dump(endpoint.req_params)),\n endpoint\n )\n end", "def update(params)\n self.class.new reinit_endpoint(params).do_put\n end", "def save(options = {}, &block)\n if block.present?\n raise MotionResource::URLNotDefinedError.new \"URL is not defined for #{self.class.name}!\" unless self.class.respond_to?(:url)\n\n action = if new_record?\n \"create\"\n elsif self.id.present?\n \"update\"\n else\n raise MotionResource::ActionNotImplemented.new \"Action ist not implemented for #{self.class.name}!\"\n end\n\n model = self\n\n model.id = nil if model.id.present? && action == \"create\"\n\n hash = buildHashFromModel(self.class.name.downcase, self)\n hash.merge!(options[:params]) if options[:params].present?\n\n requestBlock = Proc.new do |response|\n if response.ok? && response.body.present?\n json = BW::JSON.parse(response.body.to_str)\n\n model.wrap(json)\n model.lastSyncAt = Time.now if model.respond_to?(:lastSyncAt)\n model.save\n else\n model = nil\n end\n\n block.call(model) if block.present? && block.respond_to?(:call)\n end\n\n case action\n when \"create\"\n BW::HTTP.post(self.class.url, {payload: hash}, &requestBlock)\n when \"update\"\n BW::HTTP.put(\"#{self.class.url}/#{model.id}\", {payload: hash}, &requestBlock)\n end\n else\n super\n end\n end", "def update(params = {})\n raise \"Can't update a resource without a REST Client\" unless @client\n yield params if block_given?\n set_up_properties_from(@client.put(@path, params))\n self\n end", "def put(path, options={})\n url = build_url path, options\n body, mime = build_payload options\n headers = (options[:headers] || {}).merge :content_type => mime\n Response.new(@client[url].put body, headers)\n rescue RestClient::Exception => e\n Response.new e.response\n end", "def put(params)\n bucket = params[:bucket]\n object = params[:object]\n value = params[:value]\n content_type = params[:content_type]\n cb = params[:cb]\n date = generate_date\n sign_string = generate_signed_string('PUT', 'private', bucket, object, content_type)\n signature = generate_signature(sign_string)\n auth = generate_auth(signature)\n headers = generate_put_headers(date, auth, 'private', content_type, value.size)\n path = \"/\" << object\n\n @req_options = {:method => :put, :head => headers, :path => path, :body => value}\n @cb = cb if cb\n @bucket = bucket\n try_request\n self\n end", "def put(payload = {})\n request! do\n api[url.path].put(to_payload(payload), API_HEADERS)\n end\n end", "def update\n document = Document.find(params[:id])\n if document.update(params_document)\n render json: document, status: 200\n else\n render json: document.errors, status: 422\n end\n\n end", "def update\n put :update\n end", "def save\n if self.class.find(name, client: client)\n client.post(api_path, to_json, headers)\n else\n client.put(api_path, to_json, headers)\n end\n true\n end", "def save(request)\n raise ArgumentError, \"PUT does not accept options\" unless request.options.empty?\n update(request) || create(request)\n end", "def put(path, body = nil, ctype = 'application/json')\n make_call(mk_conn(path, 'Content-Type': ctype,\n 'Accept': 'application/json'),\n :put, nil, body.to_json)\n end", "def update(options = {})\n @client.put(self.link(:edit), self.to_json, options)\n end", "def put(uri, params = {}, env = {}, &block)\n super(uri, params, env, &block).tap do |response|\n record_request_response_pair!('put')\n end\n end", "def perform_put(path, options = {})\n perform_request(:put, path, options)\n end", "def upsert_catalog_object_with_http_info(body, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: CatalogApi.upsert_catalog_object ...\"\n end\n # verify the required parameter 'body' is set\n fail ArgumentError, \"Missing the required parameter 'body' when calling CatalogApi.upsert_catalog_object\" if body.nil?\n # resource path\n local_var_path = \"/v2/catalog/object\".sub('{format}','json')\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n \n header_params['Square-Version'] = \"2018-07-12\"\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = @api_client.object_to_http_body(body)\n auth_names = ['oauth2']\n data, status_code, headers = @api_client.call_api(:POST, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'UpsertCatalogObjectResponse')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: CatalogApi#upsert_catalog_object\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def save\n validate\n\n if @id\n raise TwitterAds::NotFound.new(nil, 'Method PUT not allowed.', 404)\n else\n super\n end\n end", "def update(resource, id, format = nil)\n base_update(resource, id, nil, format)\n end", "def put(path, options={})\n request :put, path, options\n end", "def save\n method, path = id ? [:post, :update] : [:put, :create]\n self.attributes = Connection.send(method, create_route(path), attributes_without_blanks).body['data']\n self\n end", "def update\n if @formato.update(formato_params)\n render json: @formato\n else\n render json: @formato.errors, status: :unprocessable_entity \n end\n end", "def update\n document = Document.find(params[:id])\n document.update!(update_params)\n render json: {}\n end", "def put payload, path = \"\"\n make_request(path, \"put\", payload)\n end", "def update\n @doc = Doc.find(params[:id])\n \n respond_to do |format|\n if @doc.update_attributes(params[:doc])\n save_object_relationship\n format.html { redirect_to(@doc, :notice => 'Doc was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @doc.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update(uri, payload)\n url = \"#{@config[:base_url]}#{@config[:rest_path]}/#{extract_pid(uri)}\"\n request = Request.new(\n \"Put\", url, payload.to_s, {\n \"Accept\" => \"application/json\",\n \"Content-Type\" => \"application/json\",\n \"Content-Length\" => \"nnnn\",\n @auth_header => @token\n }\n )\n response = request.perform\n response\n end", "def put(api_version, resource, payload, query_parameters = nil,\n headers = nil)\n make_rest_call(:put, uri_builder(api_version, resource,\n query_parameters), payload, headers)\n end", "def put(request)\n _request(request) { |client, options| client.put options }\n end", "def create_method\n :http_put\n end", "def create_method\n :http_put\n end", "def update(options = {}, &block)\n object = get_resource_ivar || find_and_update_resource\n\n options[:location] = collection_path if object.errors.empty?\n\n respond_with_dual(object, options, &block)\n end", "def put(obj)\n end", "def put(path, options = {})\n request(:put, path, options)\n end", "def put(path, options = {})\n request(:put, path, options)\n end", "def on_put(resource_uri, opts)\n #resource = _get_resource(resource_uri, true, opts)\n \n #puts \"ON_PUT_OPTS: #{opts.inspect}\"\n body, format = parse_body(opts)\n case format\n # when :empty\n # # do nothing\n when :xml\n modifier_el = body.root\n resource = put_resource_xml(modifier_el, resource_uri, opts)\n else\n raise UnsupportedBodyFormatException.new(format)\n end\n show_resource(resource, opts)\n end", "def update\n @document_format = DocumentFormat.find(params[:id])\n\n respond_to do |format|\n if @document_format.update_attributes(params[:document_format])\n format.html { redirect_to document_formats_url, notice: 'Document format was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @document_format.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n # returning connection.put(element_path(prefix_options), to_xml, self.class.headers) do |response|\n returning connection.put(element_path(prefix_options), to_ssj, self.class.headers) do |response|\n load_attributes_from_response(response)\n end\n end", "def put(resource_path, body:, headers: {}, prefix: API_PREFIX)\n request(method: :put, resource_path: resource_path, headers: headers, body: body, prefix: prefix)\n end", "def update\n save_doc\n end", "def put(path, data = {})\n request 'PUT', path, body: data.to_json\n end", "def put(path, options={}, raw=false)\n request(:put, path, options, raw)\n end" ]
[ "0.66783696", "0.6592143", "0.611606", "0.6053623", "0.60305244", "0.5755128", "0.5714296", "0.57021576", "0.5689208", "0.56457937", "0.5645185", "0.5637551", "0.56319565", "0.5626417", "0.5618084", "0.5589152", "0.55726236", "0.5570112", "0.5565754", "0.5526729", "0.55235016", "0.55138236", "0.55022436", "0.54887646", "0.54817486", "0.54672503", "0.5440342", "0.5440103", "0.5433973", "0.5423197", "0.542028", "0.541791", "0.54021597", "0.5398976", "0.5397361", "0.5388605", "0.538088", "0.538088", "0.53464603", "0.53365374", "0.5334106", "0.5330803", "0.5330803", "0.53243655", "0.5302061", "0.529594", "0.52948296", "0.5293092", "0.5266256", "0.5259367", "0.52408016", "0.5233166", "0.5227033", "0.52243996", "0.52131337", "0.5208546", "0.520668", "0.5201818", "0.51997745", "0.5199113", "0.5194599", "0.51930356", "0.5187783", "0.5187285", "0.51869833", "0.5184012", "0.51769996", "0.51744187", "0.5161131", "0.51598465", "0.5159763", "0.5158427", "0.51464576", "0.51212853", "0.5120363", "0.51033485", "0.5102883", "0.5092873", "0.50785327", "0.50727445", "0.50680655", "0.5060081", "0.5057903", "0.5052628", "0.5044008", "0.5042268", "0.5040377", "0.50387526", "0.50387526", "0.5033775", "0.5031501", "0.50268805", "0.50268805", "0.5019117", "0.50093013", "0.5009008", "0.50073016", "0.5001369", "0.500005", "0.49998" ]
0.6161295
2
This smells of :reek:FeatureEnvy (refers to 'faraday' more than self)
def connection @connection ||= Faraday.new(Features::SegmentDeletionConfig.config.uri) do |faraday| faraday.use ResponseMiddleware faraday.use Faraday::Adapter::NetHttp end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def faraday_builder(builder)\n end", "def faraday_connection(url=nil)\n url ||= self.root\n key = \"faraday_connection_#{url}\"\n return Thread.current[key] if Thread.current[key]\n\n fc = Faraday.new(:url => url)\n fc.headers.merge!('User-Agent' => \"HyperResource #{HyperResource::VERSION}\")\n fc.headers.merge!(self.headers || {})\n if ba=self.auth[:basic]\n fc.basic_auth(*ba)\n end\n Thread.current[key] = fc\n end", "def faraday\n mutex.synchronize do\n @faraday ||= create_faraday\n end\n end", "def service_request(service); end", "def initialize(faraday_response)\n @faraday_env = faraday_response.env\n @status = faraday_env.status\n @body = faraday_env.body\n @headers = faraday_response.headers\n end", "def setup_connection\n Faraday.new(:url => @api_url) do |connection|\n #connection.request :url_encoded\n connection.request :json\n #connection.request :retry\n\n connection.response :logger if debug?\n connection.response :raise_error\n connection.response :json, :content_type => /\\bjson$/\n\n connection.use :instrumentation\n connection.adapter Faraday.default_adapter\n end\n end", "def connection(headers: {}, parse_json: true)\n super do |faraday|\n faraday.adapter(:test, stubs)\n end\n end", "def faraday\n @faraday ||= Faraday.new ssl: { verify: ssl_verify } do |faraday|\n authenticate!(faraday)\n\n faraday.request(:retry, max: retries) if retries\n faraday.options.timeout = read_timeout if read_timeout\n faraday.options.open_timeout = open_timeout if open_timeout\n\n faraday.request :url_encoded # Form-encode POST params\n faraday.response :raise_error\n faraday.use :http_cache, store: http_cache, serializer: Marshal\n faraday.use Faraday::CacheHeaders\n faraday.response :json, content_type: /\\bjson$/\n faraday.adapter :excon\n end\n end", "def service; raise NotImplementedError; end", "def initialize\n @use_ssl = false\n @http_adapter = Yummly::FaradayAdapter\n end", "def transport; end", "def transport; end", "def transport; end", "def patch_initialize\n ::Faraday::Connection.module_eval do\n alias_method :initialize_original, :initialize\n\n def initialize(url = nil, options = nil, &block)\n # initialize the connection as usual\n initialize_original(url, options, &block)\n\n # before we let go, add the Faraday tracer to the beginning of the stack\n @builder.insert(0, ::Faraday::Tracer)\n end\n end\n end", "def create_faraday\n faraday_options = options.slice(:headers, :params)\n if options[:insecure]\n faraday_options[:ssl] = { verify: false }\n end\n Faraday.new(nil, faraday_options) do\n # options\n if options[:url_prefix]\n _1.url_prefix = options[:url_prefix]\n end\n _1.options.timeout = options[:timeout]\n\n #\n # middleware that runs on both disk/network requests\n #\n\n # cookie middleware\n _1.use :cookie_jar\n\n # auto-encode form bodies\n _1.request :url_encoded\n\n # Before httpdisk so each redirect segment is cached\n # Keep track of redirect status for logger\n _1.response :follow_redirects, callback: ->(_old_env, new_env) { new_env[:redirect] = true }\n\n #\n # httpdisk\n #\n\n httpdisk_options = options.slice(:dir, :expires, :force, :force_errors, :ignore_params, :utf8)\n _1.use :httpdisk, httpdisk_options\n\n #\n # middleware below only used it httpdisk uses the network\n #\n\n # rate limit\n rate_limit = options[:rate_limit]\n _1.request :rate_limiter, interval: rate_limit\n\n # After httpdisk so that only non-cached requests are logged.\n # Before retry so that we don't log each retry attempt.\n _1.response :logger, nil, formatter: Middleware::LogFormatter if !options[:silent]\n\n retry_options = {\n max_interval: rate_limit, # very important, negates Retry-After: 86400\n max: options[:retries],\n methods: %w[delete get head options patch post put trace],\n retry_statuses: (500..600).to_a,\n retry_if: ->(_env, _err) { true },\n }\n _1.request :retry, retry_options\n end\n end", "def shopify_connection\n Faraday.new(url: SHOPIFY_BASE_URL, ssl: { verify: false }) do |faraday|\n faraday.request :url_encoded # form-encode POST params\n faraday.adapter Faraday.default_adapter # make requests with Net::https\n end\nend", "def shopify_connection\n Faraday.new(url: SHOPIFY_BASE_URL, ssl: { verify: false }) do |faraday|\n faraday.request :url_encoded # form-encode POST params\n faraday.adapter Faraday.default_adapter # make requests with Net::https\n end\nend", "def connection\n Faraday.new(base_path, headers: base_request_headers, request: request_options) do |faraday|\n faraday.use :breakers\n faraday.request :json\n\n faraday.response :raise_error, error_prefix: service_name\n faraday.response :caseflow_errors\n faraday.response :betamocks if mock_enabled?\n faraday.response :json\n faraday.adapter Faraday.default_adapter\n end\n end", "def wrap_feature(feature)\n Feature.new(feature)\n end", "def http11_close_workarounds_state\n super\n end", "def leeway; end", "def leeway; end", "def service; end", "def connection\n @connection ||= Faraday.new(api_endpoint) do |http|\n http.headers[:accept] = \"application/json, */*\"\n http.headers[:user_agent] = user_agent\n\n http.request :authorization, :Bearer, -> { token_store.get_token }\n http.request :json\n\n http.use Keap::REST::Response::RaiseError\n\n http.response :dates\n http.response :json, content_type: \"application/json\"\n # http.response :logger do |logger|\n # logger.filter(/(Bearer) (\\w+)/, '\\1 [FILTERED]')\n # end\n\n http.adapter adapter, @stubs\n end\n end", "def initialize(faraday_response)\n @response = faraday_response\n end", "def connection\n Faraday.new(url:, headers:) do |conn|\n conn.request :json\n conn.use :breakers\n conn.use Faraday::Response::RaiseError\n conn.response :raise_error, error_prefix: service_name\n conn.response :json\n conn.response :betamocks if mock_enabled?\n conn.adapter Faraday.default_adapter\n end\n end", "def request_and_handle http_method, path, options\n if http_method.is_a?(String) || http_method.is_a?(Symbol)\n http_method = HTTP_METHODS[http_method.to_s]\n raise \"Unknown http method: #{http_method}\" unless http_method\n end\n \n req_options = default_options.dup\n req_options = req_options.merge(options)\n \n raise ConfigurationError.new \"No endpoint defined\" if !path || path.empty?\n raise ConfigurationError.new \"No hostname defined\" if !req_options[:base_uri] || req_options[:base_uri].empty?\n \n # prepare request\n req = HTTParty::Request.new http_method, path, req_options\n\n # Sanitized request for logs\n safe_req_options = strip_unsafe_params(http_method, req_options)\n req_to_output = HTTParty::Request.new http_method, path, safe_req_options\n req_for_airbrake = { :method => http_method, :path => path, :options => safe_req_options }\n\n begin\n response = req.perform\n rescue => ex\n raise CityGridExceptions::RequestError.new req_for_airbrake, ex\n ensure\n if CityGrid.print_curls? \n if defined?(Rails.logger)\n Rails.logger.info req_to_output.to_curl\n else\n puts req_to_output.to_curl\n end\n end\n end\n\n \n begin \n # catch unparsable responses (html etc)\n if !response.parsed_response.is_a?(Hash)\n #pp \"[gem] the response was unparsable (response was not a hash)\"\n raise CityGridExceptions::ResponseParseError.new req_for_airbrake, response\n # catch responses not in new response format\n elsif response[\"errors\"]\n #pp \"[gem] An error in the old response format was caught. Raising a general response error...\"\n raise CityGridExceptions::ResponseError.new req_for_airbrake, response[\"errors\"], response\n\n # Parse and handle new response codes \n elsif (response[\"response\"] && response[\"response\"][\"code\"] != \"SUCCESS\") && \n (response[\"response\"] && response[\"response\"][\"code\"] != 200) && \n (response[\"response\"] && response[\"response\"][\"code\"] != 400) \n error_code = response[\"response\"][\"code\"]\n #pp \"[gem] The response was contained in the first level of the response hash. Below:\"\n #pp response\n #pp \"found error code: #{error_code}\"\n #pp \"****************************************************************************\"\n raise CityGridExceptions.appropriate_error(error_code).new req_for_airbrake, response, response[\"response\"][\"message\"].to_s #+ \" \" + CityGridExceptions.print_superclasses(error_code)\n # if the response is a nested hash/nested hash containing arrays\n elsif response[\"totalNumEntries\"] && response[\"response\"].nil?\n #pp \"[gem] now parsing a response with multiple entries: #{response}\"\n error_code = parse_multiple_responses(response)\n #pp \"the error code that came back is #{error_code}\"\n if error_code.nil? || error_code == []\n #pp \"[gem] passing over this for now\"\n return CityGrid::API::Response.new response # pass over for now\n elsif error_code[0] == \"SUCCESS\" || error_code[0] == 200 || error_code[0] == 400\n return CityGrid::API::Response.new response\n else \n #pp \"[gem] we found an error and it was #{error_code[1]}\"\n raise CityGridExceptions.appropriate_error(error_code[0]).new req_for_airbrake, response, error_code[1].to_s + \" \"# + CityGridExceptions.print_superclasses(error_code[0])\n end\n else\n return CityGrid::API::Response.new response\n end\n rescue => ex\n pp \"The gem threw an error: #{ex}\"\n raise ex if CityGrid.raise_errors?\n end\n end", "def connection\n Faraday.new(base_path, headers: base_request_headers, request: request_options) do |faraday|\n faraday.use :breakers\n faraday.request :json\n\n faraday.response :raise_error, error_prefix: service_name\n faraday.response :betamocks if mock_enabled?\n faraday.response :json\n faraday.adapter Faraday.default_adapter\n end\n end", "def build_transport_args(state) # rubocop:disable Lint/UnusedMethodArgument\n end", "def faraday_safe(faraday_method, url)\n around_request.call(faraday_method, url) do\n faraday.send(faraday_method, url)\n end\n rescue Faraday::ConnectionFailed => exception\n raise($!, exception.message)\n rescue Faraday::TimeoutError => exception\n timeout_error_with_message(exception, url)\n rescue Faraday::ClientError => exception\n client_error_with_message(exception, url)\n end", "def connection\n Faraday.new(base_path, headers: base_request_headers, request: request_options, ssl: ssl_options) do |conn|\n conn.use :breakers\n conn.request :soap_headers\n\n conn.response :soap_parser\n conn.response :betamocks if Settings.emis.mock\n conn.adapter Faraday.default_adapter\n end\n end", "def use(*features); end", "def meta_header_adapter\n if @transport_class == Transport::HTTP::Faraday\n version = '0'\n adapter_version = case @arguments[:adapter]\n when :patron\n version = Patron::VERSION if defined?(::Patron::VERSION)\n {pt: version}\n when :net_http\n version = if defined?(Net::HTTP::VERSION)\n Net::HTTP::VERSION\n elsif defined?(Net::HTTP::HTTPVersion)\n Net::HTTP::HTTPVersion\n end\n {nh: version}\n when :typhoeus\n version = Typhoeus::VERSION if defined?(::Typhoeus::VERSION)\n {ty: version}\n when :httpclient\n version = HTTPClient::VERSION if defined?(HTTPClient::VERSION)\n {hc: version}\n when :net_http_persistent\n version = Net::HTTP::Persistent::VERSION if defined?(Net::HTTP::Persistent::VERSION)\n {np: version}\n else\n {}\n end\n {fd: Faraday::VERSION}.merge(adapter_version)\n elsif defined?(Transport::HTTP::Curb) && @transport_class == Transport::HTTP::Curb\n {cl: Curl::CURB_VERSION}\n elsif defined?(Transport::HTTP::Manticore) && @transport_class == Transport::HTTP::Manticore\n {mc: Manticore::VERSION}\n end\n end", "def conn\n @conn ||= Faraday.new(base_url, headers: @headers, ssl: ssl_options, request: timeout) do |faraday|\n faraday.use :breakers\n faraday.use Faraday::Response::RaiseError\n faraday.use EVSS::ErrorMiddleware\n faraday.response :betamocks if @use_mock\n faraday.response :snakecase, symbolize: false\n faraday.response :json_parser\n faraday.use :remove_cookies\n faraday.adapter :httpclient\n end\n end", "def forex_symbols_with_http_info(exchange, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: DefaultApi.forex_symbols ...'\n end\n # verify the required parameter 'exchange' is set\n if @api_client.config.client_side_validation && exchange.nil?\n fail ArgumentError, \"Missing the required parameter 'exchange' when calling DefaultApi.forex_symbols\"\n end\n # resource path\n local_var_path = '/forex/symbol'\n\n # query parameters\n query_params = opts[:query_params] || {}\n query_params[:'exchange'] = exchange\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:body] \n\n # return_type\n return_type = opts[:return_type] || 'Array<ForexSymbol>' \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: DefaultApi#forex_symbols\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def extra_state; end", "def http; end", "def faraday_adapter\n Faraday.default_adapter\n end", "def across_service_state\n super\n end", "def fire_eagle_request!\n client = FireEagle::Client.new(fire_eagle_config)\n client.get_request_token\n attribute_set(:fe_request_token, client.request_token.token)\n attribute_set(:fe_request_token_secret, client.request_token.secret)\n save\n client\n end", "def build_connection\n Faraday.new(url) do |f|\n f.request :retry, max: 2, interval: 0.1, backoff_factor: 2\n\n f.headers['Content-Type'] = content_type\n f.headers['User-Agent'] = user_agent\n\n f.options.timeout = timeout\n f.options.open_timeout = open_timeout\n\n f.adapter :typhoeus\n end\n end", "def feature_setup\n raise NotImplementedError\n end", "def apply_request(request_env); end", "def weber; end", "def request_and_handle http_method, path, options\n if http_method.is_a?(String) || http_method.is_a?(Symbol)\n http_method = HTTP_METHODS[http_method.to_s]\n raise \"Unknown http method: #{http_method}\" unless http_method\n end\n \n req_options = default_options.dup\n req_options = req_options.merge(options)\n \n raise ConfigurationError.new \"No endpoint defined\" if !path || path.empty?\n raise ConfigurationError.new \"No hostname defined\" if !req_options[:base_uri] || req_options[:base_uri].empty?\n \n # prepare request\n req = HTTParty::Request.new http_method, path, req_options\n req.options[:timeout] = CityGrid.custom_timeout if req.options && CityGrid.custom_timeout_set?\n\n # Sanitized request for logs\n safe_req_options = strip_unsafe_params(http_method, req_options)\n req_to_output = HTTParty::Request.new http_method, path, safe_req_options\n req_for_airbrake = { :method => http_method, :path => path, :options => safe_req_options }\n\n begin\n response = req.perform\n rescue => ex \n if defined?(Rails.logger)\n Rails.logger.error safe_req_options\n Rails.logger.error req_to_output\n Rails.logger.error req_for_airbrake\n Rails.logger.error ex\n end\n raise CityGridExceptions::RequestError.new req_for_airbrake, nil, ex.message, req_to_output.to_curl\n ensure\n if CityGrid.print_curls? \n if defined?(Rails.logger)\n Rails.logger.info req_to_output.to_curl\n puts req_to_output.to_curl\n else\n puts req_to_output.to_curl\n end\n end\n end\n\n response_status = parse_response_status response\n \n begin \n # catch unparsable responses (html etc)\n if !response.parsed_response.is_a?(Hash)\n #pp \"[gem] the response was unparsable (response was not a hash)\"\n raise CityGridExceptions::ResponseParseError.new req_for_airbrake, response, \"the response was unparsable (response was not a hash)\", req_to_output.to_curl\n else\n # Parse and handle new response codes \n if !response_status.nil? && response_status[\"code\"] != \"SUCCESS\" && response_status[\"code\"] != 200\n raise CityGridExceptions.appropriate_error(response_status[\"code\"]).new req_for_airbrake, response, response_status[\"message\"].to_s, req_to_output.to_curl\n else\n return CityGrid::API::Response.new response\n end\n end\n rescue => ex\n pp \"API ERROR: #{ex}\"\n raise ex if CityGrid.raise_errors?\n end\n end", "def create_connection\n\t\t@connection = Faraday.new(:url => @base_url) do |faraday|\n\t\t\tfaraday.headers['Accept'] = 'application/json'\n\t\t\tfaraday.adapter Faraday.default_adapter\n\t\tend\n\tend", "def configure_faraday(&config)\n @configuration[:faraday_configuration] = config\n end", "def parse_faraday(response)\n JSON.parse(response)\n end", "def connection\n @conn ||= Faraday.new(base_path, headers: base_request_headers, request: request_options) do |faraday|\n faraday.use :breakers\n faraday.use Faraday::Response::RaiseError\n\n faraday.request :multipart\n faraday.request :json\n\n faraday.response :betamocks if mock_enabled?\n faraday.response :json\n faraday.adapter Faraday.default_adapter\n end\n end", "def connection\n @conn ||= Faraday.new(base_path, headers: base_request_headers, request: request_options) do |faraday|\n faraday.use :breakers\n faraday.use Faraday::Response::RaiseError\n\n faraday.request :multipart\n faraday.request :json\n\n faraday.response :betamocks if mock_enabled?\n faraday.response :json\n faraday.adapter Faraday.default_adapter\n end\n end", "def faraday_with_default_adapter(base, &block)\n Faraday.new(base) { | connection |\n yield connection\n\n # IMPORTANT Without this line, nothing will happen.\n connection.adapter Faraday.default_adapter\n }\n end", "def refork; end", "def connection\n @conn ||= Faraday.new(base_path, headers: base_request_headers, request: request_options) do |faraday|\n faraday.use :breakers\n faraday.use Faraday::Response::RaiseError\n faraday.request :json\n\n faraday.response :betamocks if use_mocks?\n faraday.response :snakecase, symbolize: false\n faraday.response :json, content_type: /\\bjson/\n\n faraday.adapter Faraday.default_adapter\n end\n end", "def service_endpoint; end", "def service_endpoint; end", "def from_api?; false end", "def forex_exchanges_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: DefaultApi.forex_exchanges ...'\n end\n # resource path\n local_var_path = '/forex/exchange'\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:body] \n\n # return_type\n return_type = opts[:return_type] || 'Array<String>' \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: DefaultApi#forex_exchanges\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def get_sax_feature(feature)\n \n end", "def example_pending; end", "def faraday_options(options)\n {\n url: options[:url] + options[:path],\n proxy: faraday_proxy(options),\n ssl: faraday_ssl(options),\n headers: faraday_headers(options),\n request: faraday_request(options),\n }\n end", "def faraday_options\n cfg_get(:faraday_options)\n end", "def connection(uri:, params:)\n Faraday.new(\n url: \"#{@endpoint}/#{@api_version}/#{uri}\",\n params: params,\n headers: {\n 'User-Agent' => \"RubyGem-zombie_battleground-api_#{VERSION}\",\n 'Content-Type' => 'application/json'\n }\n )\n end", "def refinement\n raise NotImplementedError\n end", "def initialize(trip, http_request_bundler)\n @trip = trip\n @lyft_api_service = LyftApiService.new(Config.lyft_client_token)\n @http_request_bundler = http_request_bundler\n\n # add http calls to bundler based on services\n request = prepare_http_requests\n @http_request_bundler.add(request[:label], request[:url], request[:action], request[:options])\n end", "def transport=(_arg0); end", "def connection\n @conn ||= Faraday.new(base_path, headers: base_request_headers, request: request_options) do |faraday|\n faraday.use :breakers\n faraday.use Faraday::Response::RaiseError\n\n faraday.response :betamocks if mock_enabled?\n faraday.response :json\n faraday.adapter Faraday.default_adapter\n end\n end", "def call(env)\n @app.call(env).on_complete do |response|\n Log.debug {\n \"#{self.class}: response status #{response.status.inspect}\"\n }\n end\n rescue Exception => e\n Log.info { \"#{self.class}: Faraday caught #{e.class}: #{e}\" }\n raise\n end", "def private; end", "def initialize(trip, http_request_bundler)\n @trip = trip\n @uber_api_service = UberApiService.new(Config.uber_token)\n @http_request_bundler = http_request_bundler\n\n # add http calls to bundler based on services\n request = prepare_http_requests\n @http_request_bundler.add(request[:label], request[:url], request[:action], request[:options])#'uber_estimates_fares', request[:url], :get, headers = {})\n end", "def faraday_options(options)\n {\n url: options[:url] + options[:path],\n proxy: faraday_proxy(options),\n ssl: faraday_ssl(options),\n headers: faraday_headers(options),\n request: faraday_request(options),\n }\n end", "def bi_service\n end", "def endpoint; end", "def endpoint; end", "def endpoint; end", "def endpoint; end", "def endpoint=(_arg0); end", "def create_connection(accept_type='application/json')\n @connection = Faraday.new(:url => @base_url, :ssl => { :verify => @ssl_verify }) do |faraday|\n faraday.headers['Accept'] = accept_type\n faraday.request :att_multipart\n faraday.adapter Faraday.default_adapter\n end\n end", "def _prepare_context; end", "def faraday_connection(url = nil)\n url ||= URI.join(root, href)\n\n Faraday.new(faraday_options.merge(url: url)) do |builder|\n builder.headers.merge!(headers || {})\n builder.headers['User-Agent'] = Aptible::Resource.configuration\n .user_agent\n\n if (ba = auth[:basic])\n builder.basic_auth(*ba)\n end\n\n builder.request :url_encoded\n builder.request :retry\n builder.adapter Faraday.default_adapter\n end\n end", "def api; end", "def api; end", "def isolated; end", "def isolated; end", "def set_request; end", "def connection(options={})\r\n Faraday.new(:url => 'http://www.femexfut.org.mx/portalv2/webservices/ws_portal_v2.aspx/', :proxy=>\"\") do |builder|\r\n builder.use Faraday::Response::Mashify\r\n builder.use Faraday::Response::ParseXml\r\n builder.use Faraday::Response::Logger \r\n builder.adapter Faraday.default_adapter\r\n end\r\n end", "def mock_feature_state(feature, state)\n allow(EnrollRegistry).to receive(:feature_enabled?).and_return(false)\n allow(EnrollRegistry).to receive(:feature_enabled?).with(feature).and_return(state)\n end", "def apis; end", "def legitimate_proxy?; end", "def conn\n Faraday.new(:url => @config.url) do |c|\n c.adapter Faraday.default_adapter\n c.headers['User-Agent'] = @config.usr_agent\n c.params = self.options\n end\n end", "def feature(name, &block); begin; yield; features << name; rescue Exception; end; end", "def spam?( env ); raise NotImplementedError; end", "def connection\n Faraday.new(:url => host) do |faraday|\n #faraday.response :logger # log requests to STDOUT\n faraday.response :xml, :content_type => /\\bxml$/\n faraday.adapter Faraday.default_adapter # make requests with Net::HTTP\n end\n end", "def api\n TaskMapper::Provider::Fogbugz.api\n end", "def api\n TaskMapper::Provider::Fogbugz.api\n end", "def resolve\n abstract\n end", "def faraday_adapter(adapter)\n @configuration[:faraday_adapter] = adapter\n end", "def initialize\n super\n require 'multi_json'\n require 'google/apis/bigquery_v2'\n require 'googleauth'\n require 'active_support/json'\n require 'active_support/core_ext/hash'\n require 'active_support/core_ext/object/json'\n\n # MEMO: signet-0.6.1 depend on Farady.default_connection\n Faraday.default_connection.options.timeout = 60\n end", "def receive_axfr(soa_resource)\n done\n end", "def transport(_protocol)\n Class.new do\n attr_reader :provided_features\n def initialize(features)\n @provided_features = features\n end\n end.new(transport_features)\n end", "def new_http(uri); end", "def faraday_configuration(config)\n config.configure_faraday do |conn|\n conn.request :url_encoded\n conn.use :instrumentation\n conn.response :logger\n conn.response :follow_redirects\n end\n end" ]
[ "0.6038544", "0.5699972", "0.55331606", "0.5529503", "0.53634346", "0.53439194", "0.5320443", "0.5310597", "0.53085977", "0.53005457", "0.5298104", "0.5298104", "0.5298104", "0.52591604", "0.5186078", "0.5181141", "0.5181141", "0.5125692", "0.5125199", "0.5110972", "0.51073337", "0.51073337", "0.5106117", "0.5063408", "0.5063348", "0.5059168", "0.5055136", "0.5031975", "0.5009594", "0.4982969", "0.4980672", "0.49702603", "0.49596608", "0.49322894", "0.49271613", "0.4918923", "0.49166393", "0.49111974", "0.49110696", "0.49012345", "0.48992112", "0.4895369", "0.4886288", "0.48756123", "0.486991", "0.48637307", "0.48595053", "0.4855635", "0.4835502", "0.4835502", "0.48338518", "0.48332477", "0.482874", "0.48190692", "0.48190692", "0.48172536", "0.48163033", "0.48120552", "0.480834", "0.4805372", "0.48035672", "0.48022863", "0.47952127", "0.47945625", "0.47916552", "0.4789106", "0.47812927", "0.47810245", "0.47804707", "0.47779575", "0.47663566", "0.47516274", "0.47516274", "0.47516274", "0.47516274", "0.4750604", "0.4746593", "0.4741086", "0.473827", "0.4737241", "0.4737241", "0.47365808", "0.47365808", "0.47362986", "0.4735162", "0.4733697", "0.4732929", "0.47141764", "0.47138363", "0.4709894", "0.46998063", "0.46993417", "0.469789", "0.469789", "0.46941447", "0.46917623", "0.4691526", "0.46886235", "0.4688202", "0.4684537", "0.4684286" ]
0.0
-1
If options[:previous] is true, returns the code for the immediately previous subqing (multilevel only).
def odk_code(options = {}) CodeMapper.instance.code_for_item(object, options) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def prev\n prev? ? @current - 1 : nil\n end", "def previous\n end", "def previous\n end", "def previous\n before.ascending.last\n end", "def previous(options = {})\n pages = self_and_siblings.where(\"lft < ?\", lft)\n select_page(pages, options.merge(order: :desc))\n end", "def prev\n prev_qtr_code = quarter_code_id == 1 ? 4 : quarter_code_id - 1\n prev_year = quarter_code_id == 1 ? year - 1 : year\n Quarter.find_easily(prev_qtr_code, prev_year)\n end", "def previous\n\t first? ? nil : locate - 1\n\tend", "def previous_step\n self.step_flow.previous_step if can_decrement_step\n end", "def previous\n validates_possibility_of :previous\n self.index -= 1\n self.current\n end", "def prev\n\t\tself - 1\n\tend", "def previous_question\n if @question.question_type == \"quiz\"\n @previous_question = @question.id - 10\n if @previous_question < 0\n @previous_question = @previous_question + 69\n end\n elsif @question.question_type == \"self-guided\"\n if @question.id > 71\n @previous_question = @question.id - 1\n end\n end\n end", "def previous!\n counter_rotate!.first\n end", "def previous?\n self.rel == \"previous\"\n end", "def previous\n first? ? nil : @collection[index - 1]\n end", "def intend_previous\n intend_with :last, :previous\n end", "def intend_previous\n intend_with :last, :previous\n end", "def prev\n\t\t@prev\n\tend", "def previous\n master_files_sorted = self.sorted_set\n if master_files_sorted.find_index(self) > 0\n return master_files_sorted[master_files_sorted.find_index(self)-1]\n else\n return nil\n end\n end", "def previous\n master_files_sorted = self.sorted_set\n if master_files_sorted.find_index(self) > 0\n return master_files_sorted[master_files_sorted.find_index(self)-1]\n else\n return nil\n end\n end", "def select_prev_question\n prev = find_prev_next_question[0]\n self.current_question = prev if prev\n end", "def previous?(other)\n return self.previous_rank == other \n end", "def previous_number(num)\n return num - 1\nend", "def previous_number(num)\n return num - 1\nend", "def previous_number(num)\n return num - 1\nend", "def previous_number(num)\n return num - 1\nend", "def get_Previous()\n \t return @outputs[\"Previous\"]\n \tend", "def get_Previous()\n \t return @outputs[\"Previous\"]\n \tend", "def get_Previous()\n \t return @outputs[\"Previous\"]\n \tend", "def get_Previous()\n \t return @outputs[\"Previous\"]\n \tend", "def get_Previous()\n \t return @outputs[\"Previous\"]\n \tend", "def previous\n self.offset(-1)\n end", "def previous_number(number)\n return number-1\nend", "def previous\n connection.write(\"prev\")\n end", "def prev?\n not prev.nil?\n end", "def get_prev()\n\t\t\treturn @prev\n\t\tend", "def calculate_prev\n p = @current_page - 1\n p <= 0 || p > @total_pages ? nil : p\n end", "def previous_element; end", "def previous_number(number)\n return number - 1 \nend", "def previous_number(number)\n return number - 1\nend", "def previous_number(number)\n return number - 1\nend", "def previous_queries\n self.form_field_value.queries.id_lt(self.id)\n end", "def previous(n=1)\n self - n\n end", "def previous_page\n return if page == 1\n page - 1\n end", "def previous?\n previous_id != '0'\n end", "def prevQuestion()\n return if $intQuestionOnScreen == 0 || $intQuestionOnScreen == 1\n $btnNext.state = 'enabled'\n $intQuestionOnScreen -= 1\n if $intQuestionOnScreen == 1\n $btnPrev.state = 'disabled'\n end\n destroyChoicesOnScreen()\n resetAnswerLabelColors()\n printQuestionOnScreen()\n printAnswersOnScreen()\n printChoicesOnScreen()\n printUsersChoiceOnScreen()\nend", "def prev?\n current_page > 1\n end", "def previous_page\n current_page == 1 ? nil : current_page - 1\n end", "def previous\n Expression.where('id < ? AND collection_id = ?', self.id, self.collection_id).order('id DESC').limit(1).first\n end", "def previous_page\n num = @collection.current_page > 1 && @collection.current_page - 1\n previous_or_next_page(num, @options[:previous_label], 'prev')\n end", "def previous\n tokens[@current - 1]\n end", "def previous\n at(position - 1)\n end", "def prev_number(number)\n return number -= 1\nend", "def previous_subsection(subsection)\n\n section = self.checklist.sections.detect { |s| s.id == subsection.section_id}\n i = section.subsections.index(subsection)\n if i > 0\n return section.subsections[i-1]\n else\n j = self.checklist.sections.index(section)\n if j > 0\n return self.checklist.sections[j-1].subsections.last\n else\n return nil\n end\n end\n end", "def prev_num(num1)\n return num1 + 1\nend", "def previous?\n return @page > 1\n end", "def previous\r\n\r\n SmartQuery.first(:order => 'smart_queries.id DESC', :conditions => [\"smart_queries.id < ?\", self.id])\r\n end", "def find_prev(*args)\n find(:prev, *args)\n end", "def find_prev(*args)\n find(:prev, *args)\n end", "def previous_page\n current_page > 1 ? (current_page - 1) : nil\n end", "def previous_page\n current_page > 1 ? (current_page - 1) : nil\n end", "def previous_page\n return nil if total_pages < 1\n return nil if page == 1\n return page - 1\n end", "def previous_page\n current_page > 1 ? (current_page - 1) : nil\n end", "def previous_page\n current_page > 1 ? (current_page - 1) : nil\n end", "def previous_page\n current_page > 1 ? (current_page - 1) : nil\n end", "def previous_page\n current_page > 1 ? (current_page - 1) : nil\n end", "def previous_page\n current_page > 1 ? (current_page - 1) : nil\n end", "def previous_page\n current_page == 1 ? nil : current_page - 1\n end", "def previous\t \n @music.off\n @song.kill\n @count -= 2\n end", "def prev_page\n page - 1 if pages.include?(page - 1)\n end", "def prev_page\n self.survey_version.pages.where(:page_number => (self.page_number - 1)).first\n end", "def previous_workshop\n course = self.chapter.course\n course.workshops.previous_than(self.place).where(:hidden => false).order(\"place desc\").first\n end", "def previous\r\n\r\n BgWorker.first(:order => 'bg_workers.id DESC', :conditions => [\"bg_workers.id < ?\", self.id])\r\n end", "def solr_retrieve_previous_next(options = {})\n\n rid = options['previous-next-index']\n\n # set defaults if missing\n if options['page'].nil?\n options['page'] = '1'\n end\n if options['per_page'].nil?\n options['per_page'] = '20'\n end\n\n rpp = options['per_page'].to_i\n\n # determine result page and update options\n goto_page = rid / rpp\n if (rid % rpp) > 0\n goto_page += 1\n end\n options['page'] = goto_page.to_s\n pnum = options['page'].to_i\n\n max = rpp * pnum\n min = max - rpp + 1\n result_index = rid - min\n cached_results = search(options, false, false)\n cached_results_found = cached_results.stat_total_hits\n\n # last result in set, get next result\n if rid == max\n options_next = options\n options_next['page'] = cached_results.page_number+1\n next_result_set = search(options_next, false, false)\n result_next = next_result_set.records.first\n else\n unless rid == cached_results_found\n result_next = cached_results.records[result_index+1]\n end\n end\n\n if result_index == 0\n # first result in set that's not the very first result, get previous result\n if rid != 1\n options_previous = options\n options_previous['page'] = cached_results.page_number-1\n previous_result_set = search(options_previous, false, false)\n result_prev = previous_result_set.records.last\n end\n else\n result_prev = cached_results.records[result_index-1]\n end\n\n # return json result set with just the previous and next records in it\n r = empty_results(cached_results.stat_total_hits)\n results = EBSCO::EDS::Results.new(r, @config)\n next_previous_records = []\n unless result_prev.nil?\n next_previous_records << result_prev\n end\n unless result_next.nil?\n next_previous_records << result_next\n end\n results.records = next_previous_records\n results.to_solr\n\n end", "def previous\n @pointer -= 1\n end", "def previous_page\n @current_page > 1 ? (@current_page - 1) : nil\n end", "def previous_segment\n return nil if sibling_segments.empty?\n index = sibling_segments.sort_by(&:index).index(self)\n if index && index >= 1\n sibling_segments[index - 1]\n else\n nil\n end\n end", "def previous\n raise NameError, \"Already at the start of the series\" if start?\n @count -= 1\n self\n end", "def previous\n return nil if self.position == self.sentence.segments.count - 1\n self.sentence.segments[self.position+1]\n end", "def previous\n if (r = @lastresult[\"queries\"][\"previousPage\"])\n return search_by_query_hash(r.first)\n else\n return nil\n end\n end", "def previous_page\n current_page > 1 ? (current_page - 1) : nil\n end", "def previous\n\t\t@result = nil\n\t\t@skip = (@skip || 0) - get_resultcount\n\t\t@skip = [0, @skip].max\n\t\treturn self\n\tend", "def previous_page\n current_page > 1 ? (current_page - 1) : nil\n end", "def previous_page\n current_page > 1 ? (current_page - 1) : nil\n end", "def previous_page\n @current_page - 1 if has_previous_page?\n end", "def previous(query)\n unless query.nil?\n index = query.find_index(self.id)\n if index\n prev_id = query[index-1] unless index.zero?\n self.class.find_by_id(prev_id)\n end\n end\n end", "def previous\n return @page - 1\n end", "def do_previous\n do_command('requests/status.json?command=pl_previous')\n return currently_playing\n end", "def prev\n goto(@current_page - 1)\n end", "def previous_page; end", "def previous\n self.new_record? ? nil : Slide.where(:lesson_id => self.lesson_id, :position => (self.position - 1)).first\n end", "def select_previous!\n pane.previous_row!\n end", "def succ\n @nxt || self\n end", "def prev_page\n go_to_page(@current_page-1)\n end", "def previous_page\n end", "def previous_version\n current_version - 1\n end", "def prev(name = nil)\n previous_or_next('<', name)\n end", "def get_previous_quote_version\n if !self.new_quote? && self.parent_quote.present?\n self.parent_quote.version_quotes.date_created_ordered.each_with_index do |quote, index|\n if self.id == quote.id\n if index == 0\n return self.parent_quote\n else\n return self.parent_quote.version_quotes.date_created_ordered[index - 1]\n end\n end\n end\n end\n\n return nil\n end", "def previous\r\n\r\n Customer.first(:order => 'customers.id DESC', :conditions => [\"customers.id < ?\", self.id])\r\n end", "def prev_page\n current_page > 1 ? (current_page - 1) : nil\n end", "def prev\n connection.write(\"prev\")\n end", "def previous_code_line(line_number); end" ]
[ "0.63352436", "0.6200611", "0.6200611", "0.6152846", "0.6146951", "0.6125282", "0.61186343", "0.6050739", "0.60451937", "0.5940888", "0.5930395", "0.5918392", "0.59064096", "0.5832325", "0.5829831", "0.5829831", "0.58231807", "0.58141625", "0.5795504", "0.57760155", "0.5726847", "0.57243526", "0.57243526", "0.57243526", "0.57243526", "0.5722621", "0.5722621", "0.5722621", "0.5722621", "0.5722621", "0.5708677", "0.5657205", "0.5653012", "0.564537", "0.564312", "0.5629818", "0.56236875", "0.5622947", "0.56143475", "0.56143475", "0.557803", "0.5573319", "0.5568346", "0.5548716", "0.5547099", "0.55431396", "0.5541472", "0.55306", "0.5520762", "0.5519675", "0.5518357", "0.5518067", "0.55154234", "0.5508069", "0.55032724", "0.54949814", "0.54909194", "0.54909194", "0.54850084", "0.54850084", "0.54840195", "0.547268", "0.547268", "0.547268", "0.547268", "0.547268", "0.5471661", "0.54695684", "0.54639447", "0.54638076", "0.5463701", "0.54613155", "0.54600245", "0.54598737", "0.5459863", "0.544696", "0.5444946", "0.5430684", "0.5430375", "0.5421428", "0.54205346", "0.54199255", "0.54199255", "0.54017806", "0.53940815", "0.53914106", "0.53896284", "0.5377707", "0.53751874", "0.5365555", "0.5363661", "0.53630686", "0.5359971", "0.53549033", "0.5354426", "0.5353638", "0.53517425", "0.53492755", "0.5333761", "0.5327735", "0.5321007" ]
0.0
-1
Yields a block where inside the block you have a different breadcrumb than outside.
def with_breadcrumb(key, *args, &block) original_renderer = @_gretel_renderer @_gretel_renderer = Gretel::Renderer.new(self, key, *args) yield @_gretel_renderer = original_renderer end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def breadcrumb(&block)\n config.breadcrumb = block\n end", "def parent_breadcrumb(options = {}, &block)\n if block_given?\n gretel_renderer.yield_parent_breadcrumb(options, &block)\n else\n gretel_renderer.parent_breadcrumb(options)\n end\n end", "def r_breadcrumbs(&block)\n content_tag(\"div\", &block)\n end", "def yield_parent_breadcrumb(options = {})\n if parent = parent_breadcrumb(options)\n yield parent\n end\n end", "def block_view(context, block_name)\n \n app = context[:app]\n \n result = case block_name\n \n when 'site_breadcrumb_public'\n\n preffixes = Plugins::Plugin.plugin_invoke_all('ignore_path_prefix_breadcrumb', {:app => self})\n\n if app.request.path_info.empty? or app.request.path_info.start_with?(*preffixes)\n bc = ''\n else\n path = app.request.path_info\n if path.match /\\/page\\/\\d+/\n path.sub!(/\\/page\\/\\d+/,'')\n end\n home_page_path = SystemConfiguration::Variable.get_value('site.anonymous_front_page', nil)\n bc = app.t.breadcrumb.home\n\n if home_page_path != path\n path_array = path.split('/')\n result = \"\"\n summary = \"\\\\\"\n bc = path_array.slice(0, path_array.size-1).inject(\"\") do |result, item| \n if item.empty?\n result << \"<a href=\\\"/\\\">#{app.t.breadcrumb.home}</a>\"\n result\n else \n result << \"<span class=\\\"breadcrumb_separator\\\"> &gt; </span> \" unless result.empty?\n result << \"<a href=\\\"#{summary}#{item}\\\">#{item.capitalize.gsub(/-/,' ')}</a>\"\n summary << \"#{item}\\\\\" \n result\n end\n end\n if path_array.size > 1\n bc << \" <span class=\\\"breadcrumb_separator\\\"> &gt; </span> <span class=\\\"breadcrumb_last\\\">#{path_array.last.capitalize.gsub(/-/,' ')}</span>\"\n end\n end\n end \n\n bc == app.t.breadcrumb.home ? '' : bc\n\n\n when 'site_breadcrumb'\n preffixes = Plugins::Plugin.plugin_invoke_all('ignore_path_prefix_breadcrumb', {:app => self})\n \n if app.request.path_info.empty? or app.request.path_info.start_with?(*preffixes)\n bc = ''\n else\n breadcrumb = Site::BreadcrumbBuilder.build(app.request.path_info, context) \n bc_render = SiteRenders::BreadcrumbRender.new(breadcrumb, context)\n bc = bc_render.render \n end \n\n bc\n\n\n when 'site_adminmenu'\n \n if app.user and app.user.is_superuser?\n \n # Retrieve the admin menu options\n admin_menu = {:name => 'admin_menu', :title => 'Admin menu', :description => 'Administration menu'}\n admin_menu_items = Plugins::Plugin.plugin_invoke_all('menu', context)\n \n menu = Site::Menu.build(admin_menu, admin_menu_items)\n menu.language_in_routes = false\n SiteRenders::MenuRender.new(menu, context).render\n \n end\n \n when /^menu_/\n \n menu_name = block_name.match(/^menu_(.+)/)[1]\n \n if menu = Site::Menu.get(menu_name)\n menu_render = SiteRenders::MenuRender.new(menu, context)\n menu_render.render\n else\n ''\n end\n \n when /^view_/ \n\n view_name = block_name.sub(/view_/,'')\n \n if view = ContentManagerSystem::View.get(view_name)\n arguments = \"\"\n if app.request.path_info and app.request.path_info.split('/').length > 2\n arguments = (x=app.request.path_info.split('/')).slice(2,x.length).join('/')\n end\n ::CMSRenders::ViewRender.new(view, app).render(1, arguments) \n else\n ''\n end\n \n when /^content_/\n \n content_id = block_name.sub(/content_/,'')\n if content = ContentManagerSystem::Content.get(content_id.to_i)\n CMSRenders::ContentRender.new(content, app).render\n else\n ''\n end \n\n\n end\n\n return result\n \n \n end", "def get_breadcrumb_as_block(context)\n \n blocks = [{:name => 'site_breadcrumb',\n :module_name => :cms,\n :theme => Themes::ThemeManager.instance.selected_theme.name}]\n\n return blocks\n \n end", "def get_public_breadcrumb_as_block(context)\n \n blocks = [{:name => 'site_breadcrumb_public',\n :module_name => :cms,\n :theme => Themes::ThemeManager.instance.selected_theme.name}]\n\n return blocks\n \n end", "def render_list(&block)\n view.capture_haml do\n view.haml_tag :ul, class: \"breadcrumb\" do\n yield\n end\n end\n end", "def extract_breadcrumb\n end", "def travNav(navBar, &block)\n navBar.each { |nav|\n block.yield(nav)\n if nav['type'] == 'folder'\n travNav(nav['sub_nav'], &block)\n end\n }\nend", "def breadcrumbs() [] end", "def r_breadcrumbs_nav(&block)\n content_tag(\"nav\", class: \"hidden sm:flex items-center text-sm leading-5 font-medium\", &block)\n end", "def parent_breadcrumb(options = {})\n render(options)[-2]\n end", "def breadcrumbs\n content_tag :ol, class: 'breadcrumb' do\n split_path = request.path.split('/').drop(1)\n concat content_tag :li, (link_to 'Home', '/')\n split_path.each_with_index do |p, i|\n concat content_tag :li, (link_to p.capitalize_each('-'), '/' + split_path.take(i+1).join('/'))\n end\n end\n end", "def then_i_see_home_and_parent_links\n within \".gem-c-contextual-breadcrumbs\" do\n expect(page).to have_link(\"Home\")\n expect(page).to have_link(@parent[\"title\"])\n end\n end", "def individual_breadcrumb\n add_breadcrumb \"Clients\", clients_path, :title => \"Clients\" \n add_breadcrumb \"Power Of Attorney\", '', :title => \"Power Of Attorney\" \n add_breadcrumb \"Principal Create\", '', :title => \"Principal Create\"\n end", "def manageable_breadcrumbs(options = {})\n items = Helpers::NavigationBuilder.new\n yield items if block_given?\n\n options[:class] ||= \"\"\n options[:class] << \" breadcrumb\"\n options[:class].strip!\n\n content_tag(\"div\", options) do\n content_tag(\"ul\") do\n items.collect { |item|\n content_tag(\"li\", :class => item[:class]) do\n if item[:active]\n item[:label]\n else\n link_to(item[:label], item[:href])\n end\n end\n }.join(\"\").html_safe\n end\n end\n end", "def link_breadcrumb_or_not(menu)\n # path for the breadcrumb menu item\n path_method = \"breadcrumb_#{menu}_path\"\n path = send(path_method) if respond_to?(path_method.to_sym, include_private=true)\n path = '#' if path and current_page?(path) # if the current request is this path then stub it out with #\n path ||= '#'\n link_breadcrumb(menu, path)\n end", "def ascend(&block)\n paths = ascendants\n paths.each(&block) if block\n paths\n end", "def acts_as_family_tree_breadcrumb(aaft_instance, sep=' &gt; ')\n if aaft_instance.parent.nil?\n grandparent = aaft_instance.all_parent_relations.collect(&:parent_node).detect(&:parent)\n trail = grandparent.nil? ? [aaft_instance] : grandparent.all_parents + [grandparent, aaft_instance]\n else\n trail = aaft_instance.all_parents + [aaft_instance]\n end\n trail.collect do |r|\n block_given? ? yield(r) : r.to_s\n end.join(sep)\n end", "def acts_as_family_tree_breadcrumb(aaft_instance, sep=' &gt; ')\n if aaft_instance.parent.nil?\n grandparent = aaft_instance.all_parent_relations.collect(&:parent_node).detect(&:parent)\n trail = grandparent.nil? ? [aaft_instance] : grandparent.all_parents + [grandparent, aaft_instance]\n else\n trail = aaft_instance.all_parents + [aaft_instance]\n end\n trail.collect do |r|\n block_given? ? yield(r) : r.to_s\n end.join(sep)\n end", "def breadcrumb\n add_breadcrumb \"Users\", persons_path if @rider.book\n add_breadcrumb \"Master book\", master_riders_path if @rider.is_master?\n\n add_breadcrumb @rider.book.person.first_name, person_path(@rider.book.person) if @rider.book\n add_breadcrumb @rider.book.number, person_book_path(@rider.book.person, @rider.book) if @rider.book\n if @rider.is_master?\n add_breadcrumb @rider.book.number, master_book_path(@rider.book) \n else\n add_breadcrumb @rider.book.number, book_rider_path(@rider.book, @rider)\n end\n add_breadcrumb @rider.name, book_rider_path(@rider.book, @rider) if @rider\n end", "def regular_compact_breadcrumbs(document)\n breadcrumb_links = []\n breadcrumb_links << add_campus_link(document) unless document.campus.nil?\n breadcrumb_links << add_parent_campus_link(document) unless document.parent_campus.nil? && !document.campus.nil?\n breadcrumb_links << build_repository_link(document)\n\n parents = document_parents(document)\n breadcrumb_links << parents[0, 1].map do |parent|\n link_to parent.label, solr_document_path(parent.global_id)\n end\n\n breadcrumb_links << '&hellip;'.html_safe if parents.length > 1\n\n safe_join(\n breadcrumb_links,\n aria_hidden_breadcrumb_separator\n )\n end", "def f_places_breadcrumb\n ancestor_list = @feature.nil? ? nil : @feature.closest_ancestors_by_perspective(current_perspective).drop(1)\n f_breadcrumb(ancestor_list)\n end", "def breadcrumb(object, level = 0)\n path = (\"../\" * level) + object.name + \".html\"\n link = link_to(object.name, path)\n\n if object.parent.kind_of?(RDoc::TopLevel)\n link\n else\n breadcrumb(object.parent, level+1) + \"&nbsp; > &nbsp;\" + link\n end\n end", "def render_breadcrumb ( menu , options )\n links = []\n item = current_item(menu)\n if item != nil\n links << render_breadcrumb_node(item, options)\n while item.parent != nil do\n if item.parent.is_a? Symbol\n links << link_to( 'Home', '/' , {:class=>options[:link_class]} ).html_safe + ' > '.html_safe\n break\n else\n links << render_breadcrumb_node(item.parent, options).html_safe + ' > '.html_safe\n item = item.parent\n end\n end\n end\n links = links.reverse\n links.empty? ? '' : content_tag('div', links.join(\"\\n\") , :class=>options[:div_class]).html_safe\n end", "def page_breadcrumbs(page)\n page.ancestors.reverse.map { |p| link_to(p.name, p.path) }\n end", "def crumb(key, &block)\n crumbs[key] = block\n end", "def the_breadcrumb(add_post_type = true)\n generate_breadcrumb(add_post_type)\n h.breadcrumb_draw\n end", "def add_resource_breadcrumb(resource)\n ancestor_nodes(resource).each do |node|\n @breadcrumbs << { name: node, url: url_for( action: :edit, id: node.id ) }\n end\n super\n end", "def goldberg_breadcrumbs\n render :file => \"#{RAILS_ROOT}/vendor/plugins/goldberg/app/views/goldberg/menu_items/_breadcrumbs.rhtml\", :use_full_path => false, :locals => {:crumbs => Goldberg.menu.crumbs}\n end", "def breadcrumb action = @action, acc = []\n begin\n (parent_actions ||= []) << action\n end while action.breadcrumb_parent && (action = action(*action.breadcrumb_parent))\n\n content_tag(:ul, :class => \"breadcrumb\", :id => \"breadcrumb\") do\n parent_actions.map do |a|\n am = a.send(:eval, 'bindings[:abstract_model]')\n o = a.send(:eval, 'bindings[:object]')\n content_tag(:li, :class => current_action?(a, am, o) && \"active\") do\n crumb = if a.http_methods.include?(:get)\n current_action?(a, am, o) ? aclass = 'pjax tip-bottom current' : aclass = 'pjax tip-bottom'\n if a.action_name == :dashboard\n adata = t('admin.menu.Gohome')\n else\n adata = t('admin.menu.Gosection')\n end\n link_to locale_url_for(:action => a.action_name, :controller => 'rails_admin/main', :model_name => am.try(:to_param), :id => (o.try(:persisted?) && o.try(:id) || nil)), \"data-original-title\" => adata, :class => aclass do\n if a.action_name == :dashboard\n icon = content_tag(:i, '', :class => 'icon-home')\n else\n icon = ''\n end\n icon + wording_for(:breadcrumb, a, am, o)\n end\n else\n content_tag(:span, wording_for(:breadcrumb, a, am, o))\n end\n #crumb+= content_tag(:span, '/', :class => 'divider') unless current_action?(a, am, o)\n crumb+= content_tag(:span, '') unless current_action?(a, am, o)\n crumb\n end\n end.reverse.join().html_safe\n end\n end", "def f_breadcrumb(feature)\n # content_tag :div, acts_as_family_tree_breadcrumb(feature, breadcrumb_separator) {|r| f_link(r, feature_path(r.fid), {}, {:s => true})}, :class => \"breadcrumbs\"\n content_tag :div, feature.closest_ancestors_by_perspective(current_perspective).collect{|r| f_link(r, feature_path(r.fid), {}, {:s => true})}.join(breadcrumb_separator).html_safe, :class => \"breadcrumbs\"\n end", "def each(&block)\n node = top\n\n while node\n if block\n block.yield(node)\n end\n\n if node.previous\n node = node.previous\n else\n break\n end\n end\n\n return node\n end", "def each_leaf#:yields: leaf\n leafs.compact!\n \n leafs.each do |leaf|\n yield leaf\n end\n end", "def breadcrumbs(separator=\" / \")\n crumbs = env[\"PATH_INFO\"].split(\"/\").map {|path| { :path => path, :name => path } }\n crumbs[0] = { :path => \"/\", :name => \"projects\" }\n crumbs = crumbs[0..-2].inject([]) do |crumbs_so_far, current|\n crumbs_so_far << %(<a href=\"#{current[:path]}\">#{current[:name]}</a>)\n end << crumbs.last[:name]\n crumbs.join(separator)\n end", "def breadcrumbs\n home = link_to(image_tag('home.png', :class => 'home'), '/', :title => t('app.home'))\n breadcrumbs = [home] + crumbs.split(Breadcrumb.instance.delimiter)\n content_tag(:ul, breadcrumbs.map { |trail| content_tag(:li, trail) }, :id => 'breadcrumb')\n end", "def each_hidden_leaf#:yields: leaf\n leafs.compact!\n \n leafs.each do |leaf|\n yield leaf unless leaf.visible\n end\n end", "def break_out_of_lists(block)\n b = block\n last_list = nil\n while (b) do\n last_list = b if b.type == 'List'\n b = b.parent;\n end\n\n if (last_list)\n while (block != last_list) do\n finalize(block, @line_number);\n block = block.parent;\n end\n finalize(last_list, @line_number);\n @tip = last_list.parent;\n end\n end", "def drop_breadcrumb(new_bc, onlyreplace = false)\n # if the breadcrumb is in the array, remove it and all below by counting how many to pop\n return if skip_breadcrumb?\n\n remove = 0\n @breadcrumbs.each do |bc|\n if remove.positive? # already found a match,\n remove += 1 # increment pop counter\n\n # Check for a name match BEFORE the first left paren \"(\" or a url match BEFORE the last slash \"/\"\n elsif bc[:name].to_s.gsub(/\\(.*/, \"\").rstrip == new_bc[:name].to_s.gsub(/\\(.*/, \"\").rstrip ||\n bc[:url].to_s.gsub(%r{\\/.?$}, \"\") == new_bc[:url].to_s.gsub(%r{\\/.?$}, \"\")\n remove = 1\n end\n end\n remove.times { @breadcrumbs.pop } # remove found element and any lower elements\n if onlyreplace\n @breadcrumbs.push(new_bc) if remove.positive? # only add it if something was removed\n else\n @breadcrumbs.push(new_bc)\n end\n @breadcrumbs.push(new_bc) if onlyreplace && @breadcrumbs.empty?\n @title = if (@lastaction == \"registry_items\" || @lastaction == \"filesystems\" || @lastaction == \"files\") && new_bc[:name].length > 50\n new_bc [:name].slice(0..50) + \"...\" # Set the title to be the new breadcrumb\n else\n new_bc [:name] # Set the title to be the new breadcrumb\n end\n\n # add @search_text to title for gtl screens only\n if @search_text.present? && @display.nil? && !@in_a_form\n @title += _(\" (Names with \\\"%{search_text}\\\")\") % {:search_text => @search_text}\n end\n end", "def parent_breadcrumbs_gallery(gallery)\n breadcrumbs = \"\"\n unless gallery.parent.nil?\n breadcrumbs += parent_breadcrumbs_gallery(gallery.parent)\n breadcrumbs += content_tag(:label, \" > \")\n end\n breadcrumbs += link_to(gallery.name, gallery_path(gallery),\n :class => (@breadcrumb == gallery ? 'end-breadcrumb' : 'middle-breadcrumb'))\n end", "def bb_unconditional_branch\n @file.puts \" @current_block.left = arg1.basic_block\"\n @file.puts \" @current_block.close\"\n @file.puts \" @current_block = new_basic_block\"\n end", "def breadcrumbs\n breadcrumbs = link_to this_webapp.webapp_name, root_path, :class => 'first-breadcrumb'\n unless @breadcrumb.nil?\n breadcrumbs += content_tag(:label, \" > \")\n if @breadcrumb.kind_of? Picture\n picture = @breadcrumb\n @breadcrumb = @breadcrumb.gallery\n end\n breadcrumbs += parent_breadcrumbs_gallery(@breadcrumb)\n\n unless picture.nil?\n breadcrumbs += content_tag(:label, \" > \")\n breadcrumbs += content_tag(:label, picture.title, :class => 'end-breadcrumb')\n end\n end\n if @finish_breadcrumb\n breadcrumbs + \" > \" + @finish_breadcrumb\n else\n breadcrumbs\n end\n end", "def each_child(&block)\n children.each do | child |\n yield(child)\n child.each_child &block unless child.leaf?\n end\n end", "def find_paths_backward(&block)\n find_paths do\n follow { |n| n.in }\n instance_eval(&block)\n end \n end", "def breadcrumbs(content)\n content_for(:breadcrumbs, content) if content\n end", "def descend(&block)\n paths = descendants\n paths.each(&block) if block\n paths\n end", "def MyBlockMethod()\n puts \"At the top of the method\"\n\tyield\n\tputs \"At the bottom of the method\"\nend", "def breadcrumb_with_autohier(*args)\n # This method only deals with wiki pages; send the rest to the old method.\n if not @page then\n return breadcrumb_without_autohier args \n end\n elements = args.flatten\n elements.any? ? content_tag('p', args.join('&gt;')+'&gt;'+@page.short_title, :class=>'breadcrumb') : nil\n end", "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 each_leaf!\n raise \"Method not yet written.\"\n\n self.each do |leaf|\n yield(leaf)\n end\n end", "def breadcrumbs_for_business_directory_theme \n breadcrumbs = \"\"\n if @text.present?\n breadcrumbs = \"You searched for #{truncate(@text, :length => 30)}\"\n breadcrumbs += \" in #{@postal_code}\" if @postal_code.present?\n elsif @postal_code.present? \n breadcrumbs = \"ZIP: #{@postal_code}\"\n end\n if @category\n if @text.present?\n breadcrumbs += \" in \"\n else\n options = {\n :category_id => nil,\n :iframe_width => params[:iframe_width],\n :iframe_height => params[:iframe_height],\n :layout => @layout,\n :page_size => params[:page_size]\n }\n breadcrumbs += link_to( \"Coupons: \", options )\n end\n if @category.parent \n breadcrumbs += \"#{link_to( h(@category.parent.name), pagination_link_params(@page).merge!( :category_id => @category.parent.to_param) )}: \"\n end\n breadcrumbs += link_to( h(@category.name), pagination_link_params(@page) )\n end\n breadcrumbs = \"&nbsp;\" if breadcrumbs.blank?\n content_tag( :div, breadcrumbs, :class => 'breadcrumbs' )\n end", "def recursively_fix_breadcrumbs!(cards = collection_cards)\n cards.each do |card|\n next unless card.primary?\n\n if card.item.present?\n # have to reload in order to pick up new parent relationship\n card.item.reload.recalculate_breadcrumb!\n elsif card.collection_id.present?\n # this will run recursively rather than using breadcrumb to find all children\n card.collection.reload.recalculate_breadcrumb!\n card.collection.recursively_fix_breadcrumbs!\n end\n end\n end", "def index\n @breadcrumbs = nil\n end", "def breadcrumb_trail\n ancestors + [self]\n end", "def hardcoded_breadcrumbs\n [\n {\n title: \"Home\",\n url: \"/\",\n },\n {\n title: subtopic.parent.title,\n url: subtopic.parent.base_path,\n },\n {\n title: subtopic.title,\n url: subtopic.base_path,\n },\n ]\n end", "def traverse(&block); end", "def traverse(&block); end", "def visit(node, &block)\n before = current.dup\n enter(node)\n yield node, current, before\n node.children.each do |child|\n if child.kind_of?(Parser::AST::Node)\n visit(child, &block)\n end\n end\n leave(node)\n end", "def breadcrumbs\n Set.new(parent? ? (parent.breadcrumbs + [self]) : [self])\n end", "def each_ancestor # :nodoc:\n end", "def crawl(&blk)\r\n while crawlNext(&blk)\r\n end\r\n end", "def breadcrumbs\n @crumbs ||= parent.nil? ? [] : (parent.breadcrumbs + [parent])\n end", "def breadcrumbs\n\t\trender :breadcrumbs\n\tend", "def test_headlines_nested\n\n # load page\n page = Wiki::Api::Page.new name: \"program\"\n assert page.is_a?(Wiki::Api::Page), \"expected Page object\"\n headline = page.root_headline\n assert headline.is_a?(Wiki::Api::PageHeadline), \"expected PageHeadline object\"\n assert headline.name == \"program\", \"expected developer headline\"\n\n # search nested headline: english\n english = headline.headline(\"english\").first\n assert english.is_a?(Wiki::Api::PageHeadline), \"expected PageHeadline object\"\n\n # search nested headline: noun\n noun = english.headline(\"noun\").first\n assert noun.is_a?(Wiki::Api::PageHeadline), \"expected PageHeadline object\"\n\n # get block\n block = noun.block\n assert block.is_a?(Wiki::Api::PageBlock), \"expected PageBlock object\"\n\n # list items\n block.list_items.each do |list_item|\n assert list_item.is_a?(Wiki::Api::PageListItem), \"expected PageListItem object\"\n # links\n list_item.links.each do |link|\n assert link.is_a?(Wiki::Api::PageLink), \"expected PageListItem object\"\n end\n end\n\n # links\n block.links.each do |link|\n assert link.is_a?(Wiki::Api::PageLink), \"expected PageListItem object\"\n end\n end", "def break_off_crumbs(uri)\n crumbs = []\n split_uri = uri.split('/')\n split_uri.each_with_index do |crumb, i|\n crumbs << make_crumb([split_uri[0..i].join('/')])\n end\n crumbs\n end", "def traverse(parent, &block)\n\n end", "def add_breadcrumbs\n breadcrumb_for \"index\" # base\n\n if action_name != \"index\"\n breadcrumb_for action_name\n end\n end", "def block_contents(node, context)\n block_given? ? yield : ss_comments(node)\n node << (child = block_child(context))\n while tok(/;/) || has_children?(child)\n block_given? ? yield : ss_comments(node)\n node << (child = block_child(context))\n end\n node\n end", "def sup_bro\n puts \"This is before a block!\"\n name = \"Katy\"\n yield(name)\n puts \"This is after a block!\"\nend", "def test_unbalanced_child_gets_returned_if_exists\n parent = @system.base\n assert_equal @system.get_by_name(\"ugml\"), @system.unbalanced_child(parent)\n end", "def render_parent_block(name, context, blocks = {})\n # ob_start();\n display_parent_block(name, context, blocks)\n # return ob_get_clean();\n end", "def inside_t1\n yield\n end", "def block_node; end", "def block_node; end", "def in_branch(name, &block)\n previous_branch = current_branch\n\n if name != previous_branch\n git \"branch\", name unless branches.include?(name)\n git \"checkout\", name\n end\n \n yield\n rescue StandardError\n STDERR.puts $!\n raise\n ensure\n unless current_branch == previous_branch\n git \"reset\", \"--hard\"\n git \"checkout\", previous_branch\n end\n end", "def traverse_down(&block)\n block.call(self)\n if(!children.nil?)\n children.each{ |child| child.traverse_down(&block) }\n end\n end", "def each_ancestor\n ancestors = [self]\n while not ancestors.last.parent.nil?\n ancestors << ancestors.last.parent\n end\n ancestors.reverse_each { |a| yield a }\n end", "def block_children(options = {})\n throw ArgumentError.new('Required arguments :block_id missing') if options[:block_id].nil?\n if block_given?\n Pagination::Cursor.new(self, :block_children, options).each do |page|\n yield page\n end\n else\n get(\"blocks/#{options[:block_id]}/children\", options.except(:block_id))\n end\n end", "def block\n (@blocks ||= Array.new) << Block.new\n @in_block = @blocks.last\n yield\n @in_block = nil\n end", "def breadcrumbs\n @breadcrumbs\n end", "def breadcrumbs\n @breadcrumbs\n end", "def pickup_breadcrumbs\n @bcname = request.path.inspect\n case\n when request.path == \"/\"\n @bcname = Bcrmb.find_by_bckey(\"home\").name\n when request.path =~ /(\\/as\\w\\w\\/)(\\w+)/\n token2in_path = $2\n if (mybc = Bcrmb.find_by_bckey(token2in_path))\n @bcname = mybc.send(:name)\n else\n @bcname = Bcrmb.find_by_bckey(\"allbc\").name\n end # if\n else\n @bcname = Bcrmb.find_by_bckey(\"allbc\").name\n end # case\n\n end", "def render_breadcrumb(options = {})\n options = {\n separator: \">\",\n page: @page,\n restricted_only: false,\n reverse: false,\n link_active_page: false\n }.merge(options)\n\n pages = options[:page]\n .self_and_ancestors.contentpages\n .published\n\n if options.delete(:restricted_only)\n pages = pages.restricted\n end\n\n if options.delete(:reverse)\n pages = pages.reorder(\"lft DESC\")\n end\n\n if options[:without].present?\n without = options.delete(:without)\n pages = pages.where.not(id: without.try(:collect, &:id) || without.id)\n end\n\n render \"alchemy/breadcrumb/wrapper\", pages: pages, options: options\n end", "def add_resource_breadcrumb(resource)\n ancestors = []\n if resource.new_record?\n if resource.parent_id\n ancestors = resource.parent.ancestors\n ancestors += [resource.parent]\n end\n else\n ancestors = resource.ancestors\n end\n\n ancestors.each do |ancestor|\n @breadcrumbs << { name: ancestor, url: url_for( action: :edit, id: ancestor.id ) }\n end\n\n super\n end", "def test_block\n\tputs \"You are in the method\"\n\tyield\n\tputs \"You are again back to the method\"\n\tyield\nend", "def getPageBreadcrumb(unit, pageName)\n (!pageName || pageName == \"home\" || pageName == \"campus_landing\") and return []\n pageName == \"search\" and return [{ name: \"Search\", id: unit.id + \":\" + pageName}]\n pageName == \"profile\" and return [{ name: \"Profile\", id: unit.id + \":\" + pageName}]\n pageName == \"sidebar\" and return [{ name: \"Sidebars\", id: unit.id + \":\" + pageName}]\n p = Page.where(unit_id: unit.id, slug: pageName).first\n p or halt(404, \"Unknown page #{pageName} in #{unit.id}\")\n return [{ name: p[:name], id: unit.id + \":\" + pageName, url: \"/#{unit.id}/#{pageName}\" }]\nend", "def each_leaf(&block)\n each_leaf_node([], @root, block)\n end", "def traverse_balanced(other, callbacks = nil, &block)\n traverse_balanced(self, other, callbacks ||\n Diff::LCS.YieldingCallbacks, &block)\n end", "def sidebar_menu(title, &block)\n content_tag :ul, class: 'sidebar-menu tree', data: { widget: 'tree' } do\n concat(content_tag(:li, title, class: 'header'))\n concat(yield(block))\n end\n end", "def block_method\n yield(\"Brandon\",\"CS\")\n yield(\"Katie\",\"Econ\")\nend", "def breadcrumbs(links)\n bcs = []\n\n position = 1\n links.each do |link|\n bcs << single(position: position, **symbolize_keys(link))\n position += 1\n end\n\n return %(<ol class=\"breadcrumbs\" vocab=\"http://schema.org/\" typeof=\"BreadcrumbList\">#{bcs.join(@divider)}</ol>)\n end", "def go_back_after(&block)\n @page_stack ? @page_stack.push(current_path) : @page_stack = [current_path]\n yield(block)\n visit(@page_stack.pop)\n end", "def optional_root_tag(root_name, b, &block)\n if root_name\n b.tag!(root_name) { |c| yield(c) }\n else\n yield(b)\n end\n end", "def iterating_block?(node); end", "def breadcrumbs\n configuration.breadcrumbs\n end", "def each_child\n childptr = CMark.node_first_child(@pointer)\n while not childptr.null? do\n nextptr = CMark.node_next(childptr)\n yield Node.new(nil, childptr)\n childptr = nextptr\n end\n end", "def less_rest\n add_breadcrumb \"Waktu Kerja dan Lembur\", \"#absences\"\n add_breadcrumb \"Istirahat Kurang\", \"#lest_rest\"\n render :layout => false\n end", "def traverse(&block)\n\t\ttraverse(@current_node, &block)\n\tend", "def each_visible_leaf#:yields: leaf\n leafs.compact!\n \n leafs.each do |leaf|\n yield leaf if leaf.visible\n end\n end" ]
[ "0.68129647", "0.67216146", "0.6717222", "0.6500311", "0.6433048", "0.6320943", "0.6131868", "0.6078897", "0.6028785", "0.59340864", "0.59029555", "0.58716357", "0.58684564", "0.5856284", "0.5838531", "0.58041793", "0.5773873", "0.57517636", "0.57260644", "0.57254916", "0.57254916", "0.57191086", "0.5694824", "0.56874675", "0.567043", "0.5669691", "0.5664998", "0.56321275", "0.56293774", "0.5626037", "0.5616037", "0.5562623", "0.55605954", "0.5548965", "0.5535782", "0.55251646", "0.5524135", "0.5521439", "0.5504701", "0.5501308", "0.549749", "0.5485376", "0.54762685", "0.54716116", "0.54421854", "0.54332167", "0.5419187", "0.5408446", "0.5388391", "0.53863597", "0.5383051", "0.5357758", "0.5349912", "0.53481734", "0.5346373", "0.5338189", "0.53359854", "0.53359854", "0.5329347", "0.5326847", "0.5325416", "0.53233933", "0.53101385", "0.5299156", "0.529395", "0.52878433", "0.52874476", "0.5286468", "0.52826345", "0.5282019", "0.5266008", "0.52642316", "0.5262367", "0.52591383", "0.52591383", "0.5257382", "0.52548206", "0.5250601", "0.523618", "0.5235175", "0.52338517", "0.52338517", "0.5223091", "0.5218622", "0.5217695", "0.52157795", "0.5206303", "0.5196448", "0.5190892", "0.51644933", "0.5163971", "0.5161632", "0.5155523", "0.515072", "0.51503295", "0.5141862", "0.5141577", "0.5135886", "0.51192194", "0.51190114" ]
0.6009178
9
Renders the breadcrumbs HTML, for example in your layout. See the readme for default options. If you supply a block, it will yield an array with the breadcrumb links so you can build the breadcrumbs HTML manually: You are here: ()
def breadcrumbs(options = {}) gretel_renderer.render(options) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def r_breadcrumbs(&block)\n content_tag(\"div\", &block)\n end", "def breadcrumb(&block)\n config.breadcrumb = block\n end", "def block_view(context, block_name)\n \n app = context[:app]\n \n result = case block_name\n \n when 'site_breadcrumb_public'\n\n preffixes = Plugins::Plugin.plugin_invoke_all('ignore_path_prefix_breadcrumb', {:app => self})\n\n if app.request.path_info.empty? or app.request.path_info.start_with?(*preffixes)\n bc = ''\n else\n path = app.request.path_info\n if path.match /\\/page\\/\\d+/\n path.sub!(/\\/page\\/\\d+/,'')\n end\n home_page_path = SystemConfiguration::Variable.get_value('site.anonymous_front_page', nil)\n bc = app.t.breadcrumb.home\n\n if home_page_path != path\n path_array = path.split('/')\n result = \"\"\n summary = \"\\\\\"\n bc = path_array.slice(0, path_array.size-1).inject(\"\") do |result, item| \n if item.empty?\n result << \"<a href=\\\"/\\\">#{app.t.breadcrumb.home}</a>\"\n result\n else \n result << \"<span class=\\\"breadcrumb_separator\\\"> &gt; </span> \" unless result.empty?\n result << \"<a href=\\\"#{summary}#{item}\\\">#{item.capitalize.gsub(/-/,' ')}</a>\"\n summary << \"#{item}\\\\\" \n result\n end\n end\n if path_array.size > 1\n bc << \" <span class=\\\"breadcrumb_separator\\\"> &gt; </span> <span class=\\\"breadcrumb_last\\\">#{path_array.last.capitalize.gsub(/-/,' ')}</span>\"\n end\n end\n end \n\n bc == app.t.breadcrumb.home ? '' : bc\n\n\n when 'site_breadcrumb'\n preffixes = Plugins::Plugin.plugin_invoke_all('ignore_path_prefix_breadcrumb', {:app => self})\n \n if app.request.path_info.empty? or app.request.path_info.start_with?(*preffixes)\n bc = ''\n else\n breadcrumb = Site::BreadcrumbBuilder.build(app.request.path_info, context) \n bc_render = SiteRenders::BreadcrumbRender.new(breadcrumb, context)\n bc = bc_render.render \n end \n\n bc\n\n\n when 'site_adminmenu'\n \n if app.user and app.user.is_superuser?\n \n # Retrieve the admin menu options\n admin_menu = {:name => 'admin_menu', :title => 'Admin menu', :description => 'Administration menu'}\n admin_menu_items = Plugins::Plugin.plugin_invoke_all('menu', context)\n \n menu = Site::Menu.build(admin_menu, admin_menu_items)\n menu.language_in_routes = false\n SiteRenders::MenuRender.new(menu, context).render\n \n end\n \n when /^menu_/\n \n menu_name = block_name.match(/^menu_(.+)/)[1]\n \n if menu = Site::Menu.get(menu_name)\n menu_render = SiteRenders::MenuRender.new(menu, context)\n menu_render.render\n else\n ''\n end\n \n when /^view_/ \n\n view_name = block_name.sub(/view_/,'')\n \n if view = ContentManagerSystem::View.get(view_name)\n arguments = \"\"\n if app.request.path_info and app.request.path_info.split('/').length > 2\n arguments = (x=app.request.path_info.split('/')).slice(2,x.length).join('/')\n end\n ::CMSRenders::ViewRender.new(view, app).render(1, arguments) \n else\n ''\n end\n \n when /^content_/\n \n content_id = block_name.sub(/content_/,'')\n if content = ContentManagerSystem::Content.get(content_id.to_i)\n CMSRenders::ContentRender.new(content, app).render\n else\n ''\n end \n\n\n end\n\n return result\n \n \n end", "def manageable_breadcrumbs(options = {})\n items = Helpers::NavigationBuilder.new\n yield items if block_given?\n\n options[:class] ||= \"\"\n options[:class] << \" breadcrumb\"\n options[:class].strip!\n\n content_tag(\"div\", options) do\n content_tag(\"ul\") do\n items.collect { |item|\n content_tag(\"li\", :class => item[:class]) do\n if item[:active]\n item[:label]\n else\n link_to(item[:label], item[:href])\n end\n end\n }.join(\"\").html_safe\n end\n end\n end", "def get_breadcrumb_as_block(context)\n \n blocks = [{:name => 'site_breadcrumb',\n :module_name => :cms,\n :theme => Themes::ThemeManager.instance.selected_theme.name}]\n\n return blocks\n \n end", "def render_breadcrumb ( menu , options )\n links = []\n item = current_item(menu)\n if item != nil\n links << render_breadcrumb_node(item, options)\n while item.parent != nil do\n if item.parent.is_a? Symbol\n links << link_to( 'Home', '/' , {:class=>options[:link_class]} ).html_safe + ' > '.html_safe\n break\n else\n links << render_breadcrumb_node(item.parent, options).html_safe + ' > '.html_safe\n item = item.parent\n end\n end\n end\n links = links.reverse\n links.empty? ? '' : content_tag('div', links.join(\"\\n\") , :class=>options[:div_class]).html_safe\n end", "def render_breadcrumb(options={})\n default_options = {\n :seperator => %(<span class=\"seperator\">></span>),\n :page => current_page,\n :without => nil\n }\n options = default_options.merge(options)\n bc = \"\"\n pages = breadcrumb(options[:page])\n pages.delete(Page.root)\n unless options[:without].nil?\n unless options[:without].class == Array\n pages.delete(options[:without])\n else\n pages = pages - options[:without]\n end\n end\n pages.each do |page|\n if page.name == current_page.name\n css_class = \"active\"\n elsif page == pages.last\n css_class = \"last\"\n elsif page == pages.first\n css_class = \"first\"\n end\n if (page == Page.language_root(session[:language]))\n if configuration(:redirect_index)\n url = show_page_url(:urlname => page.urlname)\n else\n url = index_url\n end\n else\n url = show_page_url(:urlname => page.urlname)\n end\n bc << link_to( h(page.name), url, :class => css_class, :title => page.title )\n unless page == pages.last\n bc << options[:seperator]\n end\n end\n bc\n end", "def render_list(&block)\n view.capture_haml do\n view.haml_tag :ul, class: \"breadcrumb\" do\n yield\n end\n end\n end", "def goldberg_breadcrumbs\n render :file => \"#{RAILS_ROOT}/vendor/plugins/goldberg/app/views/goldberg/menu_items/_breadcrumbs.rhtml\", :use_full_path => false, :locals => {:crumbs => Goldberg.menu.crumbs}\n end", "def breadcrumbs\n content_tag :ol, class: 'breadcrumb' do\n split_path = request.path.split('/').drop(1)\n concat content_tag :li, (link_to 'Home', '/')\n split_path.each_with_index do |p, i|\n concat content_tag :li, (link_to p.capitalize_each('-'), '/' + split_path.take(i+1).join('/'))\n end\n end\n end", "def r_breadcrumbs_nav(&block)\n content_tag(\"nav\", class: \"hidden sm:flex items-center text-sm leading-5 font-medium\", &block)\n end", "def breadcrumbs\n home = link_to(image_tag('home.png', :class => 'home'), '/', :title => t('app.home'))\n breadcrumbs = [home] + crumbs.split(Breadcrumb.instance.delimiter)\n content_tag(:ul, breadcrumbs.map { |trail| content_tag(:li, trail) }, :id => 'breadcrumb')\n end", "def parent_breadcrumb(options = {}, &block)\n if block_given?\n gretel_renderer.yield_parent_breadcrumb(options, &block)\n else\n gretel_renderer.parent_breadcrumb(options)\n end\n end", "def get_public_breadcrumb_as_block(context)\n \n blocks = [{:name => 'site_breadcrumb_public',\n :module_name => :cms,\n :theme => Themes::ThemeManager.instance.selected_theme.name}]\n\n return blocks\n \n end", "def breadcrumbs(content)\n content_for(:breadcrumbs, content) if content\n end", "def breadcrumbs\n breadcrumbs = link_to this_webapp.webapp_name, root_path, :class => 'first-breadcrumb'\n unless @breadcrumb.nil?\n breadcrumbs += content_tag(:label, \" > \")\n if @breadcrumb.kind_of? Picture\n picture = @breadcrumb\n @breadcrumb = @breadcrumb.gallery\n end\n breadcrumbs += parent_breadcrumbs_gallery(@breadcrumb)\n\n unless picture.nil?\n breadcrumbs += content_tag(:label, \" > \")\n breadcrumbs += content_tag(:label, picture.title, :class => 'end-breadcrumb')\n end\n end\n if @finish_breadcrumb\n breadcrumbs + \" > \" + @finish_breadcrumb\n else\n breadcrumbs\n end\n end", "def render_crumbs(options = {})\n options[:format] = :html if options[:format] == nil\n if options[:seperator] == nil\n options[:seperator] = \" &raquo; \" if options[:format] == :html\n options[:seperator] = \"crumb\" if options[:format] == :xml\n end\n options[:links] = true if options[:links] == nil\n case options[:format]\n when :html\n crumb_string = crumbs.collect do |crumb|\n crumb_to_html crumb, options[:links]\n end * options[:seperator]\n crumb_string = crumb_string.html_safe if crumb_string.respond_to?(:html_safe)\n crumb_string\n when :xml\n crumbs.collect do |crumb|\n crumb_to_xml crumb, options[:links], options[:seperator]\n end * ''\n else\n raise \"Unknown breadcrumb output format\"\n end\n end", "def render_breadcrumb(options = {})\n options = {\n separator: \">\",\n page: @page,\n restricted_only: false,\n reverse: false,\n link_active_page: false\n }.merge(options)\n\n pages = options[:page]\n .self_and_ancestors.contentpages\n .published\n\n if options.delete(:restricted_only)\n pages = pages.restricted\n end\n\n if options.delete(:reverse)\n pages = pages.reorder(\"lft DESC\")\n end\n\n if options[:without].present?\n without = options.delete(:without)\n pages = pages.where.not(id: without.try(:collect, &:id) || without.id)\n end\n\n render \"alchemy/breadcrumb/wrapper\", pages: pages, options: options\n end", "def breadcrumbs\n\t\trender :breadcrumbs\n\tend", "def documentation_breadcrumb_for(page, options = {})\n options[:root_link] = options[:root_link].nil? ? t('documentation.helpers.documentation_breadcrumb_for.default_root_link') : options[:root_link]\n options[:class] ||= 'breadcrumb'\n\n String.new.tap do |s|\n s << \"<nav class='#{options[:class]}'><ul>\"\n\n if options[:root_link]\n s << \"<li><a href='#{documentation_doc_root.blank? ? '/' : documentation_doc_root}'>#{options[:root_link]}</a></li>\"\n end\n\n if page.is_a?(::Documentation::Page)\n page.breadcrumb.each do |child|\n s << \"<li><a href='#{documentation_doc_root}/#{child.full_permalink}'>#{child.title}</a></li>\"\n end\n end\n\n s << \"</ul></nav>\"\n end.html_safe\n end", "def with_breadcrumb(key, *args, &block)\n original_renderer = @_gretel_renderer\n @_gretel_renderer = Gretel::Renderer.new(self, key, *args)\n yield\n @_gretel_renderer = original_renderer\n end", "def the_breadcrumb(add_post_type = true)\n generate_breadcrumb(add_post_type)\n h.breadcrumb_draw\n end", "def render_breadcrumb_node(node, options)\n caption, url, selected = extract_node_details(node)\n content_tag('span', render_single_breadcrumb_node(node, caption, url, selected, options), :class=>options[:span_class] ).html_safe\n end", "def regular_compact_breadcrumbs(document)\n breadcrumb_links = []\n breadcrumb_links << add_campus_link(document) unless document.campus.nil?\n breadcrumb_links << add_parent_campus_link(document) unless document.parent_campus.nil? && !document.campus.nil?\n breadcrumb_links << build_repository_link(document)\n\n parents = document_parents(document)\n breadcrumb_links << parents[0, 1].map do |parent|\n link_to parent.label, solr_document_path(parent.global_id)\n end\n\n breadcrumb_links << '&hellip;'.html_safe if parents.length > 1\n\n safe_join(\n breadcrumb_links,\n aria_hidden_breadcrumb_separator\n )\n end", "def breadcrumbs(links)\n bcs = []\n\n position = 1\n links.each do |link|\n bcs << single(position: position, **symbolize_keys(link))\n position += 1\n end\n\n return %(<ol class=\"breadcrumbs\" vocab=\"http://schema.org/\" typeof=\"BreadcrumbList\">#{bcs.join(@divider)}</ol>)\n end", "def breadcrumb_for(identifier, options={})\n options[:collection_tag] ||= 'ul'\n options[:collection_class] ||= 'breadcrumb'\n\n # Retreive the breadcrumbs trail and format them\n sections = find_breadcrumbs_trail(identifier)\n render_menu(sections, options)\n end", "def home_breadcrumbs(action=\"\")\n crumbs = []\n\n crumbs.push({ \"text\": t(\"defaults.home\"), \"link\": root_path })\n\n case action\n when \"api\"\n crumbs.push({ \"text\": \"API\" })\n\n when \"conferences\"\n crumbs.push({ \"text\": t(\"views.conference.list\") })\n end\n\n render \"partials/breadcrumbs\", crumbs: crumbs\n end", "def breadcrumbs_for_business_directory_theme \n breadcrumbs = \"\"\n if @text.present?\n breadcrumbs = \"You searched for #{truncate(@text, :length => 30)}\"\n breadcrumbs += \" in #{@postal_code}\" if @postal_code.present?\n elsif @postal_code.present? \n breadcrumbs = \"ZIP: #{@postal_code}\"\n end\n if @category\n if @text.present?\n breadcrumbs += \" in \"\n else\n options = {\n :category_id => nil,\n :iframe_width => params[:iframe_width],\n :iframe_height => params[:iframe_height],\n :layout => @layout,\n :page_size => params[:page_size]\n }\n breadcrumbs += link_to( \"Coupons: \", options )\n end\n if @category.parent \n breadcrumbs += \"#{link_to( h(@category.parent.name), pagination_link_params(@page).merge!( :category_id => @category.parent.to_param) )}: \"\n end\n breadcrumbs += link_to( h(@category.name), pagination_link_params(@page) )\n end\n breadcrumbs = \"&nbsp;\" if breadcrumbs.blank?\n content_tag( :div, breadcrumbs, :class => 'breadcrumbs' )\n end", "def breadcrumbs() [] end", "def breadcrumb_with_autohier(*args)\n # This method only deals with wiki pages; send the rest to the old method.\n if not @page then\n return breadcrumb_without_autohier args \n end\n elements = args.flatten\n elements.any? ? content_tag('p', args.join('&gt;')+'&gt;'+@page.short_title, :class=>'breadcrumb') : nil\n end", "def render(options = {})\n format = options.delete(:format) || :list\n klass = Breadcrumbs::Render.const_get(format.to_s.classify)\n html = klass.new(self, options).render\n\n html.respond_to?(:html_safe) ? html.html_safe : html\n end", "def render(options = {})\n options[:format] ||= :list\n\n klass_name = options.delete(:format).to_s.classify\n klass = Breadcrumbs::Render.const_get(klass_name)\n klass.new(self, options).render\n end", "def breadcrumbs(separator=\" / \")\n crumbs = env[\"PATH_INFO\"].split(\"/\").map {|path| { :path => path, :name => path } }\n crumbs[0] = { :path => \"/\", :name => \"projects\" }\n crumbs = crumbs[0..-2].inject([]) do |crumbs_so_far, current|\n crumbs_so_far << %(<a href=\"#{current[:path]}\">#{current[:name]}</a>)\n end << crumbs.last[:name]\n crumbs.join(separator)\n end", "def breadcrumb(*args)\n @breadcrumbs ||= []\n\n args.each_slice(2).map do |pair|\n crumb = Outpost::Breadcrumb.new\n crumb.title = pair[0]\n crumb.link = pair[1]\n\n @breadcrumbs.push crumb\n end\n end", "def parent_breadcrumb(options = {})\n render(options)[-2]\n end", "def breadcrumbs\n configuration.breadcrumbs\n end", "def breadcrumb action = @action, acc = []\n begin\n (parent_actions ||= []) << action\n end while action.breadcrumb_parent && (action = action(*action.breadcrumb_parent))\n\n content_tag(:ul, :class => \"breadcrumb\", :id => \"breadcrumb\") do\n parent_actions.map do |a|\n am = a.send(:eval, 'bindings[:abstract_model]')\n o = a.send(:eval, 'bindings[:object]')\n content_tag(:li, :class => current_action?(a, am, o) && \"active\") do\n crumb = if a.http_methods.include?(:get)\n current_action?(a, am, o) ? aclass = 'pjax tip-bottom current' : aclass = 'pjax tip-bottom'\n if a.action_name == :dashboard\n adata = t('admin.menu.Gohome')\n else\n adata = t('admin.menu.Gosection')\n end\n link_to locale_url_for(:action => a.action_name, :controller => 'rails_admin/main', :model_name => am.try(:to_param), :id => (o.try(:persisted?) && o.try(:id) || nil)), \"data-original-title\" => adata, :class => aclass do\n if a.action_name == :dashboard\n icon = content_tag(:i, '', :class => 'icon-home')\n else\n icon = ''\n end\n icon + wording_for(:breadcrumb, a, am, o)\n end\n else\n content_tag(:span, wording_for(:breadcrumb, a, am, o))\n end\n #crumb+= content_tag(:span, '/', :class => 'divider') unless current_action?(a, am, o)\n crumb+= content_tag(:span, '') unless current_action?(a, am, o)\n crumb\n end\n end.reverse.join().html_safe\n end\n end", "def render_navbar(&block)\n action_link = get_action_link\n if !action_link\n action_link = CONFIG[:title_short]\n end\n html = content_tag(:div, id: 'navbar') do\n content_tag(:div, class: 'navbar-inner') do\n if current_lines_user\n content_tag(:span, class: 'buttons', &block) + \"<div class='btn-menu'><div class='stripes'></div></div>\".html_safe +\n \"<div class='submenu'>\n <div class='submenu-inner'>\n <ul>\n <li>#{link_to(\"Dashboard\", admin_articles_path)}</li>\n <li>#{link_to(t('activerecord.models.lines/author', count: 1).html_safe, admin_authors_path)}</li>\n </ul>\n <ul>\n <li class='small'>#{t('lines.logged_in_as').html_safe} #{current_lines_user.email}</li>\n <li>#{link_to(t('lines.buttons.logout').html_safe, logout_path)}</li>\n </ul>\n <ul>\n <li>#{link_to(t('lines.buttons.formating_help').html_safe, \"#\", class: \"btn-cheatsheet\")}</li>\n <li>#{link_to(t('lines.buttons.about').html_safe, \"http://lines.opoloo.com\")}</li>\n </ul>\n </div>\n </div>\".html_safe\n else\n content_tag(:span, link_to('', root_path), class: 'backlink') + content_tag(:span, action_link, class: 'actionlink')\n end\n end\n end\n html\n end", "def individual_breadcrumb\n add_breadcrumb \"Clients\", clients_path, :title => \"Clients\" \n add_breadcrumb \"Power Of Attorney\", '', :title => \"Power Of Attorney\" \n add_breadcrumb \"Principal Create\", '', :title => \"Principal Create\"\n end", "def breadcrumb\n add_breadcrumb \"Users\", persons_path if @rider.book\n add_breadcrumb \"Master book\", master_riders_path if @rider.is_master?\n\n add_breadcrumb @rider.book.person.first_name, person_path(@rider.book.person) if @rider.book\n add_breadcrumb @rider.book.number, person_book_path(@rider.book.person, @rider.book) if @rider.book\n if @rider.is_master?\n add_breadcrumb @rider.book.number, master_book_path(@rider.book) \n else\n add_breadcrumb @rider.book.number, book_rider_path(@rider.book, @rider)\n end\n add_breadcrumb @rider.name, book_rider_path(@rider.book, @rider) if @rider\n end", "def build_breadcrumbs\n @breadcrumbs = [\n { :title => I18n.t(\"admin.sections.#{resource_collection_name}\"), :url => collection_path }\n ]\n @breadcrumbs << { :title => params[:action] } unless params[:action] == 'index'\n end", "def render_crumbs(crumbs, options = {})\n\n options[:skip_if_blank] ||= Crummy.configuration.skip_if_blank\n return '' if options[:skip_if_blank] && crumbs.count < 1\n options[:format] ||= Crummy.configuration.format\n options[:separator] ||= Crummy.configuration.send(:\"#{options[:format]}_separator\")\n options[:right_separator] ||= Crummy.configuration.send(:\"#{options[:format]}_right_separator\")\n options[:links] ||= Crummy.configuration.links\n options[:first_class] ||= Crummy.configuration.first_class\n options[:last_class] ||= Crummy.configuration.last_class\n options[:microdata] ||= Crummy.configuration.microdata if options[:microdata].nil?\n options[:truncate] ||= Crummy.configuration.truncate if options[:truncate]\n options[:last_crumb_linked] = Crummy.configuration.last_crumb_linked if options[:last_crumb_linked].nil?\n options[:right_side] ||= Crummy.configuration.right_side\n\n last_hash = lambda do |o|\n k = o.map{ |c| c.is_a?(Hash) ? (c.empty? ? nil: c) : nil }.compact\n k.empty? ? {} : k.last\n end\n local_global = lambda do |crumb, global_options, param_name|\n if last_hash.call(crumb).has_key?(param_name.to_sym)\n last_hash.call(crumb)[param_name.to_sym]\n else\n global_options[param_name.to_sym]\n end\n end\n\n case options[:format]\n when :html\n crumb_string = crumbs.map.with_index(1) do |crumb, index|\n next if local_global.call(crumb, options, :right_side)\n crumb_to_html(\n crumb,\n local_global.call(crumb, options, :links),\n local_global.call(crumb, options, :first_class),\n local_global.call(crumb, options, :last_class),\n (crumb == crumbs.first),\n (crumb == crumbs.last),\n local_global.call(crumb, options, :microdata),\n index,\n local_global.call(crumb, options, :last_crumb_linked),\n local_global.call(crumb, options, :truncate)\n )\n end.compact.join(options[:separator]).html_safe\n if options[:microdata]\n content_tag(:div, crumb_string, itemscope: true, itemtype: data_definition_url(\"BreadcrumbList\"))\n else\n crumb_string\n end\n when :html_list\n # Let's set values for special options of html_list format\n options[:li_class] ||= Crummy.configuration.li_class\n options[:ol_class] ||= Crummy.configuration.ol_class\n options[:ol_id] ||= Crummy.configuration.ol_id\n options[:ol_id] = nil if options[:ol_id].blank?\n crumb_string = crumbs.map do|crumb|\n next if local_global.call(crumb, options, :right_side)\n crumb_to_html_list(\n crumb,\n local_global.call(crumb, options, :links),\n local_global.call(crumb, options, :li_class),\n local_global.call(crumb, options, :first_class),\n local_global.call(crumb, options, :last_class),\n (crumb == crumbs.first),\n (crumb == crumbs.find_all{|crumbb| !last_hash.call(crumbb).fetch(:right_side,false)}.compact.last),\n local_global.call(crumb, options, :microdata),\n local_global.call(crumb, options, :last_crumb_linked),\n local_global.call(crumb, options, :truncate),\n local_global.call(crumb, options, :separator)\n )\n end.compact.join.html_safe\n crumb_right_string = crumbs.reverse.map do |crumb|\n next if !local_global.call(crumb, options, :right_side)\n crumb_to_html_list(\n crumb,\n local_global.call(crumb, options, :links),\n local_global.call(crumb, options, :li_right_class),\n local_global.call(crumb, options, :first_class),\n local_global.call(crumb, options, :last_class),\n (crumb == crumbs.first),\n (crumb == crumbs.find_all{|crumbb|!local_global.call(crumbb, options, :right_side)}.compact.last),\n local_global.call(crumb, options, :microdata),\n local_global.call(crumb, options, :last_crumb_linked),\n local_global.call(crumb, options, :truncate),\n local_global.call(crumb, options, :right_separator)\n )\n end.compact.join.html_safe\n content_tag(:ol, :class => options[:ol_class], :id => options[:ol_id]) do\n concat crumb_string\n concat crumb_right_string\n end\n when :xml\n crumbs.collect do |crumb|\n crumb_to_xml(\n crumb,\n local_global.call(crumb, options, :links),\n local_global.call(crumb, options, :separator),\n (crumb == crumbs.first),\n (crumb == crumbs.last)\n )\n end * ''\n else\n raise ArgumentError, \"Unknown breadcrumb output format\"\n end\n end", "def breadcrumb(object, level = 0)\n path = (\"../\" * level) + object.name + \".html\"\n link = link_to(object.name, path)\n\n if object.parent.kind_of?(RDoc::TopLevel)\n link\n else\n breadcrumb(object.parent, level+1) + \"&nbsp; > &nbsp;\" + link\n end\n end", "def add_breadcrumbs\n breadcrumb_for \"index\" # base\n\n if action_name != \"index\"\n breadcrumb_for action_name\n end\n end", "def get_breadcrumbs\n current = @product || @brand || @category || @page\n # BreadcrumbsMaker.build current, params\n make_breadcrumbs current\n end", "def set_breadcrumbs\n @breadcrumbs = []\n add_breadcrumb \"Home\", root_path\n end", "def set_breadcrumbs\n @breadcrumbs = []\n add_breadcrumb \"Home\", root_path\n end", "def member_breadcrumbs\n add_breadcrumb(@period.name, url_for(@period), true, 'Coaching Period')\n end", "def hardcoded_breadcrumbs\n [\n {\n title: \"Home\",\n url: \"/\",\n },\n {\n title: subtopic.parent.title,\n url: subtopic.parent.base_path,\n },\n {\n title: subtopic.title,\n url: subtopic.base_path,\n },\n ]\n end", "def breadcrumbs\n @crumbs ||= parent.nil? ? [] : (parent.breadcrumbs + [parent])\n end", "def bootstrap_nav(*args, &block)\n levels = { :primary => 1, :secondary => 2, :tertiary => 3 }\n options = args.extract_options!\n level = levels[options[:level]] || (options[:level] || 1).to_i\n\n\n # If there are no arguments, use the current page\n args.unshift page if args.empty? && !page.nil?\n \n current_page = page\n \n contents = \"\".tap do |str|\n\n page = current_page # TODO: Can't call page within tap, so we've passed it as a variable. Can we do this better?\n\n # Opening HTML for Twitter Bootstrap Navigation\n if level == 1\n str << '<ul class=\"nav\">'\n else\n str << '<ul class=\"dropdown-menu\">'\n end\n \n pages = args.map do |arg|\n if arg.root?\n arg.children.first\n else \n case arg\n when Breeze::Content::NavigationItem then arg\n else Breeze::Content::NavigationItem.where(:permalink => arg.to_s).first\n end\n end\n end.flatten.compact\n \n ancestry = pages.first ? pages.first.self_and_ancestors.to_a : [ page ]\n\n # If page is undefined, there's no active page\n # This is used for example on the Breeze Commerce Cart and Checkout pages\n # In the longer term, this should be removed, in favour of making the cart a proper page, with checkout as a view\n page ||= nil\n \n active = page ? (page.root? ? [page] : ancestry.dup) : []\n ancestry << ancestry.last.children.first if ancestry.last\n ancestry.compact!\n \n if level <= ancestry.length && ancestry[level].present?\n siblings = ancestry[level].self_and_siblings.to_a.select(&:show_in_navigation?) \n # siblings = page.self_and_siblings.to_a.select(&:show_in_navigation?) \n siblings.unshift ancestry[level - 1] if options[:home] || (level == 1 && options[:home] != false)\n siblings.each_with_index do |p, i|\n page_title = if (options[:home] && options[:home] != true) && (p.level < level || p.root?)\n options[:home]\n case options[:home]\n when true then p.title\n when Symbol then p.send options[:home]\n when Proc then options[:home].call(p)\n else options[:home].to_s\n end\n else\n p.title\n end\n page_title = p.title if page_title.blank?\n \n link_options = ({}).tap do |o|\n o[:class] = [ p.root? ? \"home\" : p.slug ].tap do |classes|\n classes << \"active\" if p == page || (active.index(p).to_i > 0 && p.level == level)\n classes << \"first\" if i == 0\n classes << \"last\" if i == siblings.length - 1\n end.join(\" \")\n end\n \n link = if block_given?\n capture p, link_options, &block\n else\n permalink = p.class.name == \"Breeze::Content::Placeholder\" ? 'javascript:void(0)' : p.permalink\n link_to content_tag(:span, \"#{page_title}\".html_safe), permalink, link_options\n end\n \n recurse = case options[:recurse]\n when true then 3\n when :active then ancestry.include?(p) ? 1 : 0\n when Numeric, /^\\d+$/ then options[:recurse].to_i\n else 0\n end\n \n if recurse > 0 && p.level == level && !p.root?\n unless (child = p.children.first).nil?\n link << bootstrap_nav(child, options.merge(:level => level + 1, :recurse => recurse - 1), &block)\n end\n end\n \n # if options[:full] && p.children\n # p.children.each do |child|\n # link << navigation_bootstrap(child, options.merge(:full => true), &block)\n # end\n # end\n\n li_options = ({}).tap do |o|\n o[:class] = [ p.root? ? \"home\" : p.slug ].tap do |classes|\n classes << \"active\" if p == page || (active.index(p).to_i > 0 && p.level == level)\n classes << \"first\" if i == 0\n classes << \"last\" if i == siblings.length - 1\n classes << \"dropdown\" if p.children.length > 0\n classes << 'level-' + level.to_s\n end.join(\" \")\n end\n \n str << content_tag(:li, link.html_safe, li_options)\n end\n end\n \n # Opening HTML for Twitter Bootstrap Navigation\n str << '</ul>'\n \n end\n # content_tag :div, contents.html_safe, options.except(:level, :recurse).reverse_merge(:class => \"#{levels.invert[level] || \"level-#{level}\"} navigation\")\n contents.html_safe\n \n end", "def breadcrumbs\n @breadcrumbs\n end", "def breadcrumbs\n @breadcrumbs\n end", "def add_breadcrumb title, link = nil\n if link.nil?\n @breadcrumbs << { :title => title }\n else\n @breadcrumbs << { :title => title, :link => link }\n end\n end", "def add_breadcrumb title, link = nil\n if link.nil?\n @breadcrumbs << { :title => title }\n else\n @breadcrumbs << { :title => title, :link => link }\n end\n end", "def add_resource_breadcrumb(resource)\n ancestor_nodes(resource).each do |node|\n @breadcrumbs << { name: node, url: url_for( action: :edit, id: node.id ) }\n end\n super\n end", "def f_breadcrumb(ancestors_list = nil)\n if ancestors_list.nil? && @feature.nil?\n content_tag :ol, \"<li>#{link_to(ts('home.this').html_safe, root_path)}</li>\".html_safe, class: 'breadcrumb'\n else\n ancestors_list ||= @feature.closest_ancestors_by_perspective(current_perspective)\n list = ancestors_list.collect do |r|\n name = r.prioritized_name(current_view)\n options = {}\n if name.nil?\n name_str = r.pid\n else\n name_str = name.name\n options[:class] = 'non-capitalizable' if !name.orthographic_system_code.blank?\n end\n link_to(name_str, feature_path(r.fid), options)\n end\n list = [link_to(\"#{ts('app.short')}:\".html_safe, root_path)] + list[0...list.size-1].collect{|e| \"#{e}#{breadcrumb_separator}\".html_safe} + [list.last]\n content_tag :ol, list.collect{|e| \"<li>#{e}</li>\"}.join.html_safe, class: 'breadcrumb'\n end\n # content_tag :div, acts_as_family_tree_breadcrumb(feature, breadcrumb_separator) {|r| f_link(r, feature_path(r.fid), {}, {:s => true})}, :class => \"breadcrumbs\"\n end", "def breadcrumb\n Array(@breadcrumb)\n\tend", "def member_breadcrumbs\n add_breadcrumb(@assignment.period.name, url_for(@assignment.period), @assignment.period.can_view?(current_user), 'Coaching Period')\n if @assignment.group \n add_breadcrumb(@assignment.group.display_name, url_for(@assignment.group), @assignment.group.can_view?(current_user), 'Coaching Group')\n elsif @assignment.team\n add_breadcrumb(@assignment.team.display_name, url_for(@assignment.team), @assignment.team.can_view?(current_user), 'Team')\n end\n add_breadcrumb(@assignment.user.display_name, url_for(@assignment), true, 'Assignment')\n end", "def index\n @breadcrumbs = nil\n end", "def yield_parent_breadcrumb(options = {})\n if parent = parent_breadcrumb(options)\n yield parent\n end\n end", "def page_block(title = nil, options = {}, &block)\n block_to_partial('shared/block', options.merge(:title => title), &block)\n end", "def show\n breadcrumb\n end", "def index\n @breadcrumbs = [[\"#{t(:accounting_plans)}\"]]\n init\n end", "def parent_breadcrumbs_gallery(gallery)\n breadcrumbs = \"\"\n unless gallery.parent.nil?\n breadcrumbs += parent_breadcrumbs_gallery(gallery.parent)\n breadcrumbs += content_tag(:label, \" > \")\n end\n breadcrumbs += link_to(gallery.name, gallery_path(gallery),\n :class => (@breadcrumb == gallery ? 'end-breadcrumb' : 'middle-breadcrumb'))\n end", "def extract_breadcrumb\n end", "def f_breadcrumb(feature)\n # content_tag :div, acts_as_family_tree_breadcrumb(feature, breadcrumb_separator) {|r| f_link(r, feature_path(r.fid), {}, {:s => true})}, :class => \"breadcrumbs\"\n content_tag :div, feature.closest_ancestors_by_perspective(current_perspective).collect{|r| f_link(r, feature_path(r.fid), {}, {:s => true})}.join(breadcrumb_separator).html_safe, :class => \"breadcrumbs\"\n end", "def add_breadcrumb name, url = ''\n @breadcrumbs ||= []\n url = eval(url) if url =~ /_path|_url|@/\n @breadcrumbs << [name, url]\n end", "def show\n add_breadcrumb :show, :show\n end", "def page_breadcrumbs(page)\n page.ancestors.reverse.map { |p| link_to(p.name, p.path) }\n end", "def breadcrumbs\n migajas_env[\"app.breadcrumbs\"] ||= Trail.new(migajas_env)\n end", "def render_menu_block(menu_block, *args, &link_func)\n if menu_block.is_a?(String)\n menu_block = Spree::MenuBlock.find_by_name(menu_block)\n end\n\n # TODO: log an error\n return if menu_block.nil?\n\n defaults = {\n depth: 0,\n wrapper_el: 'ul',\n submenu_wrapper_el: 'ul',\n item_wrapper_el: 'li',\n wrapper_class: \"cms-menu\",\n item_wrapper_class: nil,\n wrapper_id: nil,\n show_parent: false,\n cache: true,\n }\n options = defaults.merge(args.extract_options!)\n\n cache_if options.delete(:cache), [\n menu_block,\n menu_block.fragment_cache_options(request.fullpath, options)\n ] do\n path = Spree::CmsRoutes.remove_spree_mount_point(request.fullpath)\n\n mi = nil\n if menu_block.sets_active_tree? || menu_block.follows_current?\n # find_by_id to avoid ActiveRecord error\n mi = Spree::MenuItem.find_by_id(Spree::MenuItem.id_from_cached_slug(path))\n end\n\n if menu_block.follows_current?\n # attempt to find the current menu\n if mi\n # set the root id\n root_id = case menu_block.menu_block_type\n when MenuBlock::TYPES.assoc('Show children of \"current\" menu item').last\n mi.id # children\n when MenuBlock::TYPES.assoc('Show children or siblings of \"current\" menu item').last\n if mi.children.where(is_published: true, is_visible_in_menu: true).any?\n mi.id # children\n else\n mi.parent_id # siblings\n end\n else\n mi.parent_id # siblings\n end\n safe_concat(render_menu_tree(\n mi.menu,\n options.merge({\n only_visible: true,\n root_id: root_id,\n path_ids: mi.path_ids,\n }),\n &link_func\n ))\n end\n else\n safe_concat(\n render_menu_tree(\n menu_block.menu,\n options.merge({\n only_visible: true,\n root_id: menu_block.spree_menu_item_id,\n path_ids: (mi ? mi.path_ids : []),\n }),\n &link_func\n )\n )\n end\n end\n\n end", "def block_children(options = {})\n throw ArgumentError.new('Required arguments :block_id missing') if options[:block_id].nil?\n if block_given?\n Pagination::Cursor.new(self, :block_children, options).each do |page|\n yield page\n end\n else\n get(\"blocks/#{options[:block_id]}/children\", options.except(:block_id))\n end\n end", "def index\n @cp_blocks = Block.all\n @title = \"Блоки\"\n end", "def breadcrumbs(pages)\n klass = ->(total, index) {\n total == index ? 'is-active' : 'u-underline-on-hover is-hidden-mobile'\n }\n\n max_index = pages.length - 1\n\n pages.map.with_index do |(page, link), index|\n content_tag('li', class: klass.call(max_index, index)) do\n link_to(page, link)\n end\n end.join('').html_safe\n end", "def show\n breadcrumbs_for :show\n end", "def root_breadcrumb\n breadcrumb \"Outpost\", outpost_root_path\n end", "def index \n add_breadcrumb \"Administrar\", :sections_path\n add_breadcrumb \"Recursos\", :resources_path \n end", "def index\n block_pagination\n respond_to do |format|\n format.html {\n @action_nav = CW::ActionNav::Controller::Base.new.section('Change') {|s|\n s.link 'add show episode ordering', { :action => 'new', :type => 'HomePageBlockShowDl' }, { :title => 'Add a Show DL Episode ordered block to the home page' }\n s.link 'add show filtered ordering', { :action => 'new', :type => 'HomePageBlockFiltered' }, { :title => 'Add a block filtered by show id and order to the home page' }\n }\n render :action => 'index'\n }\n end\n end", "def show\n @breadcrumbs = [[\"Home\", root_url], [@bond.citizen,\"/citizens/#{@bond.citizen.id}?tab=finances\"], [@bond, \"/bonds/#{@bond.id}\"]]\n end", "def set_root_breadcrumb\n add_breadcrumb '<span class=\"fa fa-lg\">&#xf015</span><span class=\"sr-only\">Top</span>'.html_safe, root_path\n end", "def add_breadcrumb(name, *args)\n args_order_and_defaults = {\n url: nil,\n children: nil,\n store: true,\n i18n_scope: nil,\n separator: false,\n links: [],\n allow_humanize_name: true,\n custom_attributes: {}\n }\n options = args.extract_options!\n\n options_from_args = Hash[args.map.with_index do |arg, arg_index|\n key = args_order_and_defaults.keys[arg_index]\n [key, arg]\n end]\n\n options_for_call = args_order_and_defaults.merge(options_from_args).merge(options)\n _add_breadcrumb(name, options_for_call)\n end", "def link_breadcrumb_or_not(menu)\n # path for the breadcrumb menu item\n path_method = \"breadcrumb_#{menu}_path\"\n path = send(path_method) if respond_to?(path_method.to_sym, include_private=true)\n path = '#' if path and current_page?(path) # if the current request is this path then stub it out with #\n path ||= '#'\n link_breadcrumb(menu, path)\n end", "def breadcrumbs\r\n\t\t\tself.parent.nil? ? [] : self.parent.breadcrumbs + [self]\r\n\t\tend", "def show\n add_breadcrumb_for_show\n end", "def block_list(context={})\n \n blocks = []\n blocks.concat(get_menus_as_blocks(context))\n blocks.concat(get_breadcrumb_as_block(context))\n blocks.concat(get_public_breadcrumb_as_block(context))\n blocks.concat(get_views_as_blocks(context))\n blocks.concat(get_contents_as_blocks(context))\n \n return blocks\n \n end", "def get_bread_crumbs(url,sep)\n begin\n retVal = \"\"\n url.gsub!(/\\?.*$/,\"\")\n unless url.split(/\\//).length <= 3\n elements = url.split('/')\n project_id = \"\"\n project_title = \"\"\n study_id = \"\"\n study_title = \"\"\n no_match = false\n is_end_of_trail = false\n\n # the string to return\n retVal = image_tag(\"Computer-silk.png\", :style=> \"border: 0px; vertical-align: top\", :alt => \"computer\") + \" \"\n retVal = retVal + link_to(\"My Work\", \"/\") + \" \"\n\n # remove the https://www.srdr.com bit from the array\n elements = elements[3..elements.length-1]\n\n i = 0\n elements.each do |element|\n if i == elements.length - 1\n is_end_of_trail = true\n end\n\n retVal = retVal + image_tag(\"Silk_arrow_right_gray.png\", :style=>\"border: 0px; vertical-align:top;\", :alt => \"arrow\") + \" \"\n case element\n when \"extraction_forms\"\n if project_id.to_s.empty?\n efid = elements[i+1]\n ef = ExtractionForm.find(efid,:select=>[\"project_id\"])\n unless ef.nil?\n project_id = ef.project_id\n end\n session[:project_id] = project_id\n end\n extraction_form_uri=\"/projects/#{project_id.to_s}/extractionforms\"\n retVal = retVal + image_tag(\"Table-silk.png\", :style=> \"border: 0px; vertical-align: top;\", :alt => \"table\") + \" \" + create_crumb_link(extraction_form_uri,\" Extraction Forms\",is_end_of_trail)\n when \"projects\"\n project_uri\t= \"/projects/\"\n retVal = retVal + image_tag('Folder-silk.png', :style=> \"border: 0px; vertical-align: top;\", :alt => \"folder\") + \" \" + create_crumb_link(project_uri, \"My Projects\", is_end_of_trail)\n #print \"In the projects block and retVal is now #{retVal}...\\n\\n\"\n\n when \"studies\"\n study_uri = \"/projects/#{project_id.to_s}/studies\"\n retVal = retVal + image_tag(\"Book-silk.png\", :style=> \"border: 0px; vertical-align: top;\", :alt=>\"book\") + \" \" + create_crumb_link(study_uri,\"Studies\", is_end_of_trail)\n\n when \"home\"\n retVal.gsub!(/\\>\\s$/,\"\")\n\n when \"account\"\n retVal = retVal + image_tag(\"User.png\", :style=> \"border: 0px; vertical-align: top;\", :alt => \"user\") + \" \" + create_crumb_link('/account/','Account',true) + \" \"\n\n when \"search\"\n retVal = retVal + image_tag(\"Zoom.png\", :style=> \"border: 0px; vertical-align: top;\", :alt => \"search\") + \" \" + create_crumb_link('/search/','Search',true) + \" \"\n retVal.gsub!(/\\>$/,\"\")\n\n when \"demo1\"\n retVal = retVal + image_tag(\"film.png\", :style=> \"border: 0px; vertical-align: top;\") + \" \" + create_crumb_link('/home/demo1/','Demo 1: Viewing and Creating Projects',true) + \" \"\n retVal.gsub!(/\\>$/,\"\")\n\n when \"demo2\"\n retVal = retVal + image_tag(\"film.png\", :style=> \"border: 0px; vertical-align: top;\") + \" \" + create_crumb_link('/home/demo2/','Demo 2: Creating and Editing Extraction Form Templates',true) + \" \"\n retVal.gsub!(/\\>$/,\"\")\n\n when \"demo3\"\n retVal = retVal + image_tag(\"film.png\", :style=> \"border: 0px; vertical-align: top;\") + \" \" + create_crumb_link('/home/demo3/','Demo 3: Viewing, Editing and Creating Study Records ',true) + \" \"\n retVal.gsub!(/\\>$/,\"\")\n\n when /^\\d+/\n\n previous = elements[i-1]\n if previous == \"projects\"\n project_id = element.to_i\n project_title = Project.find(project_id,:select=>\"title\")\n unless project_title.nil?\n project_title = project_title.title\n else\n project_title = \"New Project\"\n end\n project_uri = \"/projects/#{project_id.to_s}/edit\"\n retVal = retVal + image_tag(\"Folder_edit.png\", :style=> \"border: 0px; vertical-align: top;\") + \" \" + create_crumb_link(project_uri, project_title, is_end_of_trail)\n\n elsif previous == \"studies\"\n study_id = element.to_i\n study_title = PrimaryPublication.find(:first,:conditions=>[\"study_id=?\",study_id],:select=>\"title\")\n unless study_title.nil?\n study_title = study_title.title\n else\n study_title=\"New Study\"\n end\n study_uri = \"/projects/#{project_id.to_s}/studies/#{study_id.to_s}\"\n retVal = retVal + image_tag(\"Book_edit.png\", :style=> \"border: 0px; vertical-align: top;\") + \" \" + create_crumb_link(study_uri, study_title, is_end_of_trail)\n\n elsif previous == \"extraction_forms\"\n extraction_form_id = element.to_i\n extraction_form_title = ExtractionForm.find(extraction_form_id)\n unless extraction_form_title.nil?\n extraction_form_title = extraction_form_title.title\n else\n extraction_form_title = \"Untitled\"\n end\n extraction_form_uri = \"/projects/#{project_id.to_s}/extraction_forms/#{extraction_form_id.to_s}/edit\"\n retVal = retVal + image_tag(\"Table_edit.png\", :style=> \"border: 0px; vertical-align: top;\") + \" \" + create_crumb_link(extraction_form_uri,extraction_form_title,is_end_of_trail)\n else\n # fill this in for other types of urls\n end\n when /^\\w+/\n text = case element\n # these should be consistent now\n when \"extractionforms\" then \"Manage Extraction Forms\"\n when \"questions\" then \"Key Questions\"\n when \"publications\" then \"Publications\"\n when \"arms\" then \"Arms\"\n when \"design\" then \"Design Details\"\n when \"baselines\" then \"Baseline Characteristics\"\n when \"outcomes\" then \"Outcomes\"\n when \"results\" then \"Outcome Data\"\n when \"adverse\" then \"Adverse Events\"\n when \"quality\" then \"Study Quality\"\n else element.to_s.capitalize\n end\n\n edits_arr = [\"Key Questions\", \"Publications\", \"Study Arms\", \"Study Design\", \"Baseline Characteristics\", \"Outcomes\", \"Results Entry\", \"Adverse Events\", \"Study Quality\"]\n\n #print \"Found #{element.to_s}\\n\\n\"\n if text == \"Edit\"\n retVal = retVal + image_tag(\"Pencil.png\", :style=> \"border: 0px; vertical-align: top\") + \" \"\n elsif edits_arr.include?(text)\n retVal = retVal + image_tag(\"Pencil.png\", :style=> \"border: 0px; vertical-align: top\") + \" \" + create_crumb_link(\"\",text,is_end_of_trail)\n else\n retVal = retVal + create_crumb_link(\"\",text,is_end_of_trail)\n end\n retVal.gsub!(/\\>\\s$/,\"\")\n else\n # get rid of the trailing characters\n # is doing two chops more efficient?\n retVal.gsub!(/\\>\\s$/,\"\")\n no_match = true\n end\n retVal = retVal + \" \"\n i = i+1\n end\n end #ending the unless statement at the top\n return retVal\n\n rescue\n return \"Error in breadcrumbs: \" + elements[elements.length-1]\n end\n end", "def add_breadcrumb(name, url = nil)\n @breadcrumbs ||= []\n url = send(url) if url.is_a?(Symbol)\n name = send(name).to_s.titleize if name.is_a?(Symbol)\n @breadcrumbs << [name, url]\n end", "def r_mobile_breadcrumbs_nav(url)\n content_tag(\"nav\", class: \"sm:hidden\") do\n link_to(url, class: \"flex items-center text-sm leading-5 font-medium text-gray-500 hover:text-gray-700 #{HOVER_ANIMATION}\") do\n concat(content_tag(\"svg\", class: \"flex-shrink-0 -ml-1 mr-1 h-5 w-5 text-gray-400\", \"viewBox\": \"0 0 20 20\", \"fill\": \"currentColor\") do\n tag(\"path\", \"fill-rule\": \"evenodd\", d: \"M12.707 5.293a1 1 0 010 1.414L9.414 10l3.293 3.293a1 1 0 01-1.414 1.414l-4-4a1 1 0 010-1.414l4-4a1 1 0 011.414 0z\", \"clip-rule\": \"evenodd\")\n end)\n concat \"Back\"\n end\n end\n end", "def crumbs\n [self]\n end", "def crumb(key, &block)\n crumbs[key] = block\n end", "def index\n add_breadcrumb \"Inicio\", :root_path\n add_breadcrumb \"#{@course_user.course.name} \", student_course_path(@course_user.course)\n end", "def legend_block(&block)\n concat content_tag(:div, capture(&block), :class => \"faux_legend\")\n end", "def show\n add_breadcrumb 'Blacklist'\n end", "def sidebar_menu(title, &block)\n content_tag :ul, class: 'sidebar-menu tree', data: { widget: 'tree' } do\n concat(content_tag(:li, title, class: 'header'))\n concat(yield(block))\n end\n end", "def add_breadcrumb name, url = ''\n\t\t@breadcrumbs ||= []\n\t\t url = eval(url) if url =~ /_path|_url|@/\n\t\t@breadcrumbs << [name, url]\n\tend", "def to_breadcrumb\n self.title\n end", "def set_breadcrumbs name\n case name \n when \"change_password\"\n add_breadcrumb \"Dashboard\", admin_root_path, :title => \"Dashboard\"\n add_breadcrumb \"Change Password\", admin_change_password_path, :title => \"Change Password\" \n else\n add_breadcrumb \"Dashboard\", admin_root_path, :title => \"Dashboard\"\n end\n end", "def links_for_render(options = {})\n out = links.dup\n\n # Handle autoroot\n if options[:autoroot] && out.map(&:key).exclude?(:root) && Gretel::Crumbs.crumb_defined?(:root)\n out.unshift *Gretel::Crumb.new(context, :root).links\n end\n\n # Set current link to actual path\n if options[:link_last_to_current_path] && out.any? && request\n out.last.url = request.fullpath\n end\n\n # Handle show root alone\n if out.size == 1 && !options[:display_single_fragment]\n out.shift\n end\n\n # Set last link to current\n out.last.try(:current!)\n\n out\n end", "def breadcrumb_add element_name\n @breadcrumb = @breadcrumb + @separator + element_name\n end" ]
[ "0.78619164", "0.7748351", "0.75749576", "0.744244", "0.7280234", "0.70840126", "0.7059596", "0.70563114", "0.69747335", "0.692678", "0.68995434", "0.68396497", "0.68174696", "0.68052185", "0.6779306", "0.67790353", "0.6575714", "0.6551005", "0.65180796", "0.6514634", "0.6490942", "0.64907295", "0.6458406", "0.64283633", "0.6365241", "0.62867504", "0.62787473", "0.6268318", "0.6246558", "0.6239506", "0.6237658", "0.6200975", "0.62006533", "0.6178797", "0.61716104", "0.6171266", "0.6162896", "0.61478823", "0.6139088", "0.60552734", "0.60495985", "0.5987727", "0.5974077", "0.5905238", "0.5901128", "0.58656454", "0.58656454", "0.5840601", "0.58387256", "0.5834147", "0.5814223", "0.57491964", "0.57491964", "0.5705889", "0.5705889", "0.5683776", "0.56784", "0.56613845", "0.5633112", "0.5596796", "0.558803", "0.55728376", "0.5552289", "0.5549048", "0.5538742", "0.55300957", "0.5524013", "0.5523328", "0.5509136", "0.54976594", "0.54952514", "0.5489767", "0.54728776", "0.54693574", "0.5458035", "0.5446226", "0.54432756", "0.5436227", "0.5420105", "0.5418436", "0.5413078", "0.54064804", "0.54005265", "0.53883606", "0.5371106", "0.53709716", "0.53583336", "0.53564477", "0.53563863", "0.5352989", "0.53465664", "0.5342498", "0.5335926", "0.5335192", "0.5334299", "0.533085", "0.53026414", "0.5301936", "0.5295595", "0.52955157" ]
0.73083365
4
Returns or yields parent breadcrumb (secondtolast in the trail) if it is present. ()
def parent_breadcrumb(options = {}, &block) if block_given? gretel_renderer.yield_parent_breadcrumb(options, &block) else gretel_renderer.parent_breadcrumb(options) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parent_breadcrumb(options = {})\n render(options)[-2]\n end", "def yield_parent_breadcrumb(options = {})\n if parent = parent_breadcrumb(options)\n yield parent\n end\n end", "def breadcrumb current\n return [] if current.nil?\n result = Array.new\n result << current\n while current = current.parent\n result << current\n end\n return result.reverse\n end", "def breadcrumb_trail\n ancestors + [self]\n end", "def ultimate_parent # note: ultimate parent is self, not nil, if self has no parent...\n if parent_id.blank?\n self\n else\n parent.ultimate_parent\n end\n end", "def breadcrumbs\r\n\t\t\tself.parent.nil? ? [] : self.parent.breadcrumbs + [self]\r\n\t\tend", "def breadcrumbs\n Set.new(parent? ? (parent.breadcrumbs + [self]) : [self])\n end", "def parent_breadcrumbs_gallery(gallery)\n breadcrumbs = \"\"\n unless gallery.parent.nil?\n breadcrumbs += parent_breadcrumbs_gallery(gallery.parent)\n breadcrumbs += content_tag(:label, \" > \")\n end\n breadcrumbs += link_to(gallery.name, gallery_path(gallery),\n :class => (@breadcrumb == gallery ? 'end-breadcrumb' : 'middle-breadcrumb'))\n end", "def breadcrumbs\n @crumbs ||= parent.nil? ? [] : (parent.breadcrumbs + [parent])\n end", "def breadcrumb_with_autohier(*args)\n # This method only deals with wiki pages; send the rest to the old method.\n if not @page then\n return breadcrumb_without_autohier args \n end\n elements = args.flatten\n elements.any? ? content_tag('p', args.join('&gt;')+'&gt;'+@page.short_title, :class=>'breadcrumb') : nil\n end", "def parent\n has_parent? and history.first\n end", "def acts_as_family_tree_breadcrumb(aaft_instance, sep=' &gt; ')\n if aaft_instance.parent.nil?\n grandparent = aaft_instance.all_parent_relations.collect(&:parent_node).detect(&:parent)\n trail = grandparent.nil? ? [aaft_instance] : grandparent.all_parents + [grandparent, aaft_instance]\n else\n trail = aaft_instance.all_parents + [aaft_instance]\n end\n trail.collect do |r|\n block_given? ? yield(r) : r.to_s\n end.join(sep)\n end", "def acts_as_family_tree_breadcrumb(aaft_instance, sep=' &gt; ')\n if aaft_instance.parent.nil?\n grandparent = aaft_instance.all_parent_relations.collect(&:parent_node).detect(&:parent)\n trail = grandparent.nil? ? [aaft_instance] : grandparent.all_parents + [grandparent, aaft_instance]\n else\n trail = aaft_instance.all_parents + [aaft_instance]\n end\n trail.collect do |r|\n block_given? ? yield(r) : r.to_s\n end.join(sep)\n end", "def end_of_chain\n parent_id ? self.class.first(:parent_id => parent_id, :order => [:start.desc]) : self\n end", "def return_to_parent\n @current_node = @current_node.parent.parent\n # @current_node.depth = @current_node.depth - 1\n end", "def get_parent\n return nil\n end", "def get_parent_tagname\n self.parent_tagname.present? ? self.parent_tagname : nil\n end", "def get_parent_tagname\n self.parent_tagname.present? ? self.parent_tagname : nil\n end", "def breadcrumb(object, level = 0)\n path = (\"../\" * level) + object.name + \".html\"\n link = link_to(object.name, path)\n\n if object.parent.kind_of?(RDoc::TopLevel)\n link\n else\n breadcrumb(object.parent, level+1) + \"&nbsp; > &nbsp;\" + link\n end\n end", "def get_parent(chapno)\n return nil if chapno == [0]\n if chapno.empty?\n # returns the root chapter\n Chapter.root\n else\n chapno = chapno[0 ... chapno.count-1] # cut one element on right\n c = Chapter.find_by(chapter_no: chapno.to_yaml)\n if c\n return c\n else\n get_parent(chapno) \n end\n end\n end", "def breadcrumbs\n breadcrumbs = link_to this_webapp.webapp_name, root_path, :class => 'first-breadcrumb'\n unless @breadcrumb.nil?\n breadcrumbs += content_tag(:label, \" > \")\n if @breadcrumb.kind_of? Picture\n picture = @breadcrumb\n @breadcrumb = @breadcrumb.gallery\n end\n breadcrumbs += parent_breadcrumbs_gallery(@breadcrumb)\n\n unless picture.nil?\n breadcrumbs += content_tag(:label, \" > \")\n breadcrumbs += content_tag(:label, picture.title, :class => 'end-breadcrumb')\n end\n end\n if @finish_breadcrumb\n breadcrumbs + \" > \" + @finish_breadcrumb\n else\n breadcrumbs\n end\n end", "def parent\n ancestors.last\n end", "def parent\n ltree_scope.find_by \"#{self.class.table_name}.#{ltree_path_column} = SUBPATH(?, 0, NLEVEL(?) - 1)\", ltree_path,\n ltree_path\n end", "def extract_breadcrumb\n end", "def last_parent\n @stack.reverse.find { | obj | obj.kind_of? Parent }\n end", "def breadcrumb\n add_breadcrumb \"Users\", persons_path if @rider.book\n add_breadcrumb \"Master book\", master_riders_path if @rider.is_master?\n\n add_breadcrumb @rider.book.person.first_name, person_path(@rider.book.person) if @rider.book\n add_breadcrumb @rider.book.number, person_book_path(@rider.book.person, @rider.book) if @rider.book\n if @rider.is_master?\n add_breadcrumb @rider.book.number, master_book_path(@rider.book) \n else\n add_breadcrumb @rider.book.number, book_rider_path(@rider.book, @rider)\n end\n add_breadcrumb @rider.name, book_rider_path(@rider.book, @rider) if @rider\n end", "def parent_links_for(crumb)\n links = []\n while crumb = crumb.parent\n links.unshift *crumb.links\n end\n links\n end", "def f_places_breadcrumb\n ancestor_list = @feature.nil? ? nil : @feature.closest_ancestors_by_perspective(current_perspective).drop(1)\n f_breadcrumb(ancestor_list)\n end", "def parent(*args)\n return call_ancestry_method(:parent) if use_ancestry?\n\n rels = parent_rels(*args).take(2)\n raise _(\"Multiple parents found.\") if rels.length > 1\n rels.first.try(:resource)\n end", "def previous_sibling\n return nil if parent.nil? # self is root\n return nil if 1 == parent.children.size # self is parent's only child\n if 0 == own_child_index\n return nil # self is first child\n else\n # return previous sibling\n parent.children[own_child_index - 1]\n end\n end", "def existing_parent(dir)\n dir.ascend do |ascendant|\n break ascendant if ascendant.directory?\n end\n end", "def link_breadcrumb_or_not(menu)\n # path for the breadcrumb menu item\n path_method = \"breadcrumb_#{menu}_path\"\n path = send(path_method) if respond_to?(path_method.to_sym, include_private=true)\n path = '#' if path and current_page?(path) # if the current request is this path then stub it out with #\n path ||= '#'\n link_breadcrumb(menu, path)\n end", "def parent\n return @links[:parent]\n end", "def parent\n return nil if @path == '/'\n unless @path.to_s.empty?\n new_for_path ::File.split(@path).first\n end\n end", "def node_heading_parent(node, level = 'h7')\n # If initially called on a heading, we only accept stronger headings\n level = node.name if level == 'h7' && node_heading?(node)\n\n previous = node.previous_element\n\n # No previous element, we go up to the parent\n unless previous\n parent = node.parent\n # No more parent, then no heading found\n return nil if parent.name == 'body'\n return node_heading_parent(parent, level)\n end\n\n # This is a heading, we return it\n return previous if node_heading?(previous) && previous.name < level\n\n node_heading_parent(previous, level)\n end", "def breadcrumbs\n @breadcrumbs\n end", "def breadcrumbs\n @breadcrumbs\n end", "def parent_of( page )\n dir = page.directory\n\n loop do\n if @db.has_key? dir\n parent = @db[dir].find {|p| p.filename == 'index'}\n return parent unless parent.nil? or parent == page\n end\n\n break if dir.empty?\n dir = ::File.dirname(dir)\n dir = '' if dir == '.'\n end\n\n return\n end", "def fetch_categories_crumb(category, link_last_one = true)\n return \"\" unless category\n ancestors = category.ancestors\n last = link_last_one ? \"#{link_to(category.name, category_path(category))}\" : \"#{category.name}\"\n return last if ancestors.empty?\n links = ancestors.inject(\"\") do |acc, elem|\n acc += \"#{link_to(elem.name, category_path(elem))} /\"\n end + last\n end", "def parent(path)\n return nil if (path.strip.empty?) or (path == '/')\n p_path = File.dirname(path)\n nodes = lookup(p_path, nil, false, false, true)\n pair = nodes.select{ |p| p[0] == :document }.first\n pair ||= nodes.first\n pair.last\n end", "def has_parent?\n not history.empty?\n end", "def parent\n self / '..'\n end", "def crumb_parents\n []\n end", "def fetch_parent(stack, node)\n stack_2 = []\n while !stack.empty?\n potential_parent = stack.pop\n potential_structure_marker = potential_parent.structure_marker.to_s.strip\n if is_parent?(potential_structure_marker, node.indentation, potential_parent.indentation)\n parent = potential_parent\n stack_2.push(parent)\n while !stack_2.empty?\n elem = stack_2.pop\n stack.push(elem)\n end\n return parent\n else\n stack_2.push(potential_parent)\n end\n end\n end", "def fetch_parent(stack, node)\n stack_2 = []\n while !stack.empty?\n potential_parent = stack.pop\n potential_structure_marker = potential_parent.structure_marker.to_s.strip\n if is_parent?(potential_structure_marker, node.indentation, potential_parent.indentation)\n parent = potential_parent\n stack_2.push(parent)\n while !stack_2.empty?\n elem = stack_2.pop\n stack.push(elem)\n end\n return parent\n else\n stack_2.push(potential_parent)\n end\n end\n end", "def search_for_ previous_element(_start_element, _style)\n unless _start_element.nil?\n # have we already found what we're looking for?\n if _start_element.name == _style\n return _start_element\n end\n # _start_element is a div.block and not the _start_element itself\n if _start_element[:class] == \"block\" && _start_element[:id] != @start_here[:id]\n # begin recursion with last child inside div.block\n from_child = search_for_ previous_element(_start_element.children.last, _style)\n if(from_child)\n return from_child\n end\n end\n # begin recursion with previous element\n from_child = search_for_ previous_element(_start_element.previous, _style) \n return from_child ? from_child : false\n else\n return false\n end\nend", "def regular_compact_breadcrumbs(document)\n breadcrumb_links = []\n breadcrumb_links << add_campus_link(document) unless document.campus.nil?\n breadcrumb_links << add_parent_campus_link(document) unless document.parent_campus.nil? && !document.campus.nil?\n breadcrumb_links << build_repository_link(document)\n\n parents = document_parents(document)\n breadcrumb_links << parents[0, 1].map do |parent|\n link_to parent.label, solr_document_path(parent.global_id)\n end\n\n breadcrumb_links << '&hellip;'.html_safe if parents.length > 1\n\n safe_join(\n breadcrumb_links,\n aria_hidden_breadcrumb_separator\n )\n end", "def parent\n parents.empty? ? nil : parents[0]\n end", "def TreeView_GetParent(hwnd, hitem) TreeView_GetNextItem(hwnd, hitem, TreeViewGetNextItem[:PARENT]) end", "def parent(of_node, level = 1)\n ancestor = of_node\n until level.zero?\n ancestor = ancestor.parent\n level -= 1\n end\n return ancestor\n end", "def pbt_top_parent\n record = self\n return nil unless record.pbt_parent\n no_repeat = PolyBelongsTo::SingletonSet.new\n while !no_repeat.include?(record.pbt_parent) && !record.pbt_parent.nil?\n no_repeat.add?(record)\n record = record.pbt_parent\n end\n record\n end", "def get_parent(path)\n parent = @root\n path[1..path.length-1].each do |path_item|\n if parent.child_exists?(path_item)\n parent = parent.get_child(path_item)\n end\n end\n\n return parent\n end", "def parent_tag\n return nil unless within_open_tag?\n\n @tags_list.last\n end", "def parent\n parent_path = @path.cotta_parent\n return nil unless parent_path\n candidate = CottaDir.new(factory, parent_path)\n if (block_given?)\n candidate = candidate.parent until candidate.nil? or yield candidate\n end\n candidate\n end", "def find_prev_in(parent, index)\n while index >= 0\n c = parent.blocks[index]\n if c.context == :section\n return c if c.level == @chunk_level\n\n parent = c\n index = c.blocks.length\n end\n index -= 1\n end\n # index was for the first section in the parent so the previous page\n # *is* the parent.\n parent\n end", "def breadcrumbs() [] end", "def previous_sibling\n return @links[:previous_sibling]\n end", "def ancestors_traverse(tree, item, &block)\n x = nil # sub-tree object containing node to be located\n parent = nil # sub-tree object - parent of x, or soon its successor\n found = false\n\n found, x, parent = bst_search(tree, item)\n\n return false if ! found # no point in going further\n\n locator = tree\n parent = nil\n found = false\n\n while( !found && locator)\n if item.data < locator.node.data\n # descend left\n block.call(locator)\n parent = locator\n locator = locator.left_child\n elsif item.data > locator.node.data\n # descend right\n block.call(locator)\n parent = locator\n locator = locator.right_child\n else\n found = true\n end\n end\n return found\n end", "def breadcrumb_name\n title\n end", "def get_breadcrumbs\n current = @product || @brand || @category || @page\n # BreadcrumbsMaker.build current, params\n make_breadcrumbs current\n end", "def individual_breadcrumb\n add_breadcrumb \"Clients\", clients_path, :title => \"Clients\" \n add_breadcrumb \"Power Of Attorney\", '', :title => \"Power Of Attorney\" \n add_breadcrumb \"Principal Create\", '', :title => \"Principal Create\"\n end", "def previous_node\n peer = nil\n if !parent.nil? and parent.respond_to?(:children)\n index = parent.children.index(self)\n peer = index > 0 ? parent.children[index - 1] : nil\n end\n peer\n end", "def parent\n self.parents.where('forestify_level = ?', self.forestify_level - 1).first\n end", "def parent\n root = path.sub(/^#{::Regexp.escape(traversal_root)}/, '')\n parts = root.split('/')\n\n tail = parts.pop\n is_index = (tail == @app.config[:index_file])\n\n if parts.empty?\n return is_index ? nil : @store.find_resource_by_path(@app.config[:index_file])\n end\n\n test_expr = parts.join('\\\\/')\n test_expr = %r{^#{test_expr}(?:\\.[a-zA-Z0-9]+|\\/)$}\n # eponymous reverse-lookup\n found = @store.resources.find do |candidate|\n candidate.path =~ test_expr\n end\n\n if found\n found\n else\n parts.pop if is_index\n @store.find_resource_by_destination_path(\"#{parts.join('/')}/#{@app.config[:index_file]}\")\n end\n end", "def page_breadcrumbs(page)\n page.ancestors.reverse.map { |p| link_to(p.name, p.path) }\n end", "def parent\n\t\treturn parent_of @current_node\n\tend", "def parent_rel(*args)\n rels = parent_rels(*args).take(2)\n raise _(\"Multiple parents found.\") if rels.length > 1\n rels.first\n end", "def parent\n @parent ||= new_or_create? ? find_parent_by_id : lookup_parent_from_child\n end", "def find_beeper()\n while not next_to_a_beeper?()\n move_toward_beeper()\n end\n end", "def path(reverse = true)\n unless self.parent.nil?\n if reverse\n \"#{self.title} - #{self.parent.path}\" \n else\n \"#{self.parent.path(false)} - #{self.title}\"\n end\n else\n self.title\n end\n end", "def find_current_child\n if adds_deep_link?\n child_id = local_value_for_path(param(:deep_link))\n else\n child_id = param(param_name)\n end\n \n find_child(child_id) || find_child(@current_child_id) || default_child\n end", "def depth\n @breadcrumb.scan( \"/\" ).size\n end", "def parent\n return nil unless catalog\n\n unless defined?(@parent)\n if parents = catalog.adjacent(self, :direction => :in)\n # We should never have more than one parent, so let's just ignore\n # it if we happen to.\n @parent = parents.shift\n else\n @parent = nil\n end\n end\n @parent\n end", "def parent_dn\n\t\treturn nil if self.dn == self.directory.base_dn\n\t\treturn '' if self.dn.index( ',' ).nil?\n\t\treturn self.split_dn( 2 ).last\n\tend", "def the_breadcrumb(add_post_type = true)\n generate_breadcrumb(add_post_type)\n h.breadcrumb_draw\n end", "def depth\n breadcrumbs.size\n end", "def parent\n object.try(:loaded)&.[](:parents)&.first || wayfinder.decorated_parent\n end", "def then_i_see_home_and_parent_links\n within \".gem-c-contextual-breadcrumbs\" do\n expect(page).to have_link(\"Home\")\n expect(page).to have_link(@parent[\"title\"])\n end\n end", "def parent\n self + '..'\n end", "def prev_sibling\n\t\treturn prev_sibling_of @current_node\n\tend", "def assign_breadcrumb\n if page.present?\n self.page.breadcrumb ||= page.title\n end\n end", "def assign_breadcrumb\n if page.present?\n self.page.breadcrumb ||= page.title\n end\n end", "def ascend(&block)\n paths = ascendants\n paths.each(&block) if block\n paths\n end", "def parent_node(node)\n node.find(:xpath, '..', wait: 0, visible: false)\n end", "def explore_upwards(node)\n node = node.parent until node.parent.nil? || node.parent.left == node\n node.parent.nil? ? nil : node.parent.data\nend", "def previous_sibling\n if siblings.where(project_id: project_id).any?\n sibs = self_and_siblings.order(:cached).pluck(:id)\n\n s = sibs.index(id)\n TaxonName.find(sibs[s - 1]) if s != 0\n else\n nil\n end\n end", "def else_branch\n node_parts[-1]\n end", "def else_branch\n node_parts[-1]\n end", "def get_parent(generation_level)\n return self if root? || generation_level <= 0\n parent.get_parent(generation_level-1)\n end", "def parent_name\n @parent ? @parent.full_name : '(unknown)'\n end", "def parent?(node, maybe_child = nil)\n if maybe_child.nil?\n !offsprings(node).empty?\n else\n offsprings(node).include? maybe_child\n end\n end", "def parent\n self.node && self.node.parent && self.node.parent.content\n end", "def parent_id(*args)\n return call_ancestry_method(:parent_id) if use_ancestry?\n\n rels = parent_ids(*args).take(2)\n raise _(\"Multiple parents found.\") if rels.length > 1\n rels.first\n end", "def breadcrumb_remove\n temp = @breadcrumb.split( @separator )\n temp.pop()\n @element_name = temp[-1]\n @breadcrumb = temp.join( @separator )\n end", "def trace_path_back(end_node)\n path = []\n\n current_node = end_node\n until current_node.nil?\n path << current_node\n current_node = current_node.parent\n end\n\n path\n end", "def name_path_to_parent\n path = []\n p = parent\n while p do\n path.unshift p\n p = p.parent\n end\n path\n end", "def parent()\n bag.get(bag.parent(path))\n end", "def render_breadcrumb ( menu , options )\n links = []\n item = current_item(menu)\n if item != nil\n links << render_breadcrumb_node(item, options)\n while item.parent != nil do\n if item.parent.is_a? Symbol\n links << link_to( 'Home', '/' , {:class=>options[:link_class]} ).html_safe + ' > '.html_safe\n break\n else\n links << render_breadcrumb_node(item.parent, options).html_safe + ' > '.html_safe\n item = item.parent\n end\n end\n end\n links = links.reverse\n links.empty? ? '' : content_tag('div', links.join(\"\\n\") , :class=>options[:div_class]).html_safe\n end", "def first_ancestors(method)\n return nil if root?\n if value = parent.send(method)\n return value\n end\n parent.first_ancestors(method) \n end", "def rest_parent_label\n defined?(@rest_parent_label) ? @rest_parent_label : default_rest_parent_label\n end" ]
[ "0.71094614", "0.7056014", "0.6413934", "0.63741654", "0.63702136", "0.6329462", "0.6316898", "0.6302244", "0.6295133", "0.6194351", "0.61781543", "0.6129419", "0.6129419", "0.59964657", "0.5981051", "0.59602785", "0.5919928", "0.5919928", "0.5898388", "0.5876841", "0.58744687", "0.5862703", "0.5843323", "0.58408684", "0.582217", "0.58134776", "0.58073556", "0.57880557", "0.57666415", "0.57519263", "0.57500106", "0.5721632", "0.5717595", "0.57076114", "0.5705028", "0.5704575", "0.5704575", "0.57014936", "0.56885505", "0.5675914", "0.5670379", "0.56608886", "0.56587493", "0.5654702", "0.5654702", "0.56535894", "0.564546", "0.5628946", "0.562637", "0.5622498", "0.56192964", "0.56113696", "0.5606947", "0.55917084", "0.55842835", "0.5577299", "0.55770695", "0.5574013", "0.55565214", "0.5552517", "0.55462915", "0.55430514", "0.5531926", "0.55169046", "0.5516502", "0.5511153", "0.55057037", "0.5495661", "0.54934347", "0.54824203", "0.548012", "0.5479802", "0.54725903", "0.5471178", "0.54685974", "0.5449182", "0.5448014", "0.5445204", "0.5444328", "0.54367167", "0.5429517", "0.5429517", "0.54212856", "0.54188824", "0.5413282", "0.54115856", "0.5409863", "0.5409863", "0.5409452", "0.5408524", "0.54063886", "0.5395585", "0.5391393", "0.53910196", "0.53772795", "0.53753006", "0.53752923", "0.53746665", "0.5367382", "0.5367136" ]
0.73721915
0
Reference to the Gretel breadcrumbs renderer.
def gretel_renderer @_gretel_renderer ||= Gretel::Renderer.new(self, nil) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def breadcrumbs(options = {})\n gretel_renderer.render(options)\n end", "def with_breadcrumb(key, *args, &block)\n original_renderer = @_gretel_renderer\n @_gretel_renderer = Gretel::Renderer.new(self, key, *args)\n yield\n @_gretel_renderer = original_renderer\n end", "def goldberg_breadcrumbs\n render :file => \"#{RAILS_ROOT}/vendor/plugins/goldberg/app/views/goldberg/menu_items/_breadcrumbs.rhtml\", :use_full_path => false, :locals => {:crumbs => Goldberg.menu.crumbs}\n end", "def the_breadcrumb(add_post_type = true)\n generate_breadcrumb(add_post_type)\n h.breadcrumb_draw\n end", "def render_breadcrumb(options={})\n default_options = {\n :seperator => %(<span class=\"seperator\">></span>),\n :page => current_page,\n :without => nil\n }\n options = default_options.merge(options)\n bc = \"\"\n pages = breadcrumb(options[:page])\n pages.delete(Page.root)\n unless options[:without].nil?\n unless options[:without].class == Array\n pages.delete(options[:without])\n else\n pages = pages - options[:without]\n end\n end\n pages.each do |page|\n if page.name == current_page.name\n css_class = \"active\"\n elsif page == pages.last\n css_class = \"last\"\n elsif page == pages.first\n css_class = \"first\"\n end\n if (page == Page.language_root(session[:language]))\n if configuration(:redirect_index)\n url = show_page_url(:urlname => page.urlname)\n else\n url = index_url\n end\n else\n url = show_page_url(:urlname => page.urlname)\n end\n bc << link_to( h(page.name), url, :class => css_class, :title => page.title )\n unless page == pages.last\n bc << options[:seperator]\n end\n end\n bc\n end", "def breadcrumbs\n\t\trender :breadcrumbs\n\tend", "def breadcrumbs\n configuration.breadcrumbs\n end", "def render(options = {})\n options[:format] ||= :list\n\n klass_name = options.delete(:format).to_s.classify\n klass = Breadcrumbs::Render.const_get(klass_name)\n klass.new(self, options).render\n end", "def render_crumbs(options = {})\n options[:format] = :html if options[:format] == nil\n if options[:seperator] == nil\n options[:seperator] = \" &raquo; \" if options[:format] == :html\n options[:seperator] = \"crumb\" if options[:format] == :xml\n end\n options[:links] = true if options[:links] == nil\n case options[:format]\n when :html\n crumb_string = crumbs.collect do |crumb|\n crumb_to_html crumb, options[:links]\n end * options[:seperator]\n crumb_string = crumb_string.html_safe if crumb_string.respond_to?(:html_safe)\n crumb_string\n when :xml\n crumbs.collect do |crumb|\n crumb_to_xml crumb, options[:links], options[:seperator]\n end * ''\n else\n raise \"Unknown breadcrumb output format\"\n end\n end", "def breadcrumbs\n @breadcrumbs\n end", "def breadcrumbs\n @breadcrumbs\n end", "def breadcrumbs\n home = link_to(image_tag('home.png', :class => 'home'), '/', :title => t('app.home'))\n breadcrumbs = [home] + crumbs.split(Breadcrumb.instance.delimiter)\n content_tag(:ul, breadcrumbs.map { |trail| content_tag(:li, trail) }, :id => 'breadcrumb')\n end", "def breadcrumbs\n migajas_env[\"app.breadcrumbs\"] ||= Trail.new(migajas_env)\n end", "def render_breadcrumb ( menu , options )\n links = []\n item = current_item(menu)\n if item != nil\n links << render_breadcrumb_node(item, options)\n while item.parent != nil do\n if item.parent.is_a? Symbol\n links << link_to( 'Home', '/' , {:class=>options[:link_class]} ).html_safe + ' > '.html_safe\n break\n else\n links << render_breadcrumb_node(item.parent, options).html_safe + ' > '.html_safe\n item = item.parent\n end\n end\n end\n links = links.reverse\n links.empty? ? '' : content_tag('div', links.join(\"\\n\") , :class=>options[:div_class]).html_safe\n end", "def r_breadcrumbs(&block)\n content_tag(\"div\", &block)\n end", "def breadcrumbs() [] end", "def manageable_breadcrumbs(options = {})\n items = Helpers::NavigationBuilder.new\n yield items if block_given?\n\n options[:class] ||= \"\"\n options[:class] << \" breadcrumb\"\n options[:class].strip!\n\n content_tag(\"div\", options) do\n content_tag(\"ul\") do\n items.collect { |item|\n content_tag(\"li\", :class => item[:class]) do\n if item[:active]\n item[:label]\n else\n link_to(item[:label], item[:href])\n end\n end\n }.join(\"\").html_safe\n end\n end\n end", "def render(options = {})\n format = options.delete(:format) || :list\n klass = Breadcrumbs::Render.const_get(format.to_s.classify)\n html = klass.new(self, options).render\n\n html.respond_to?(:html_safe) ? html.html_safe : html\n end", "def breadcrumbs\n breadcrumbs = link_to this_webapp.webapp_name, root_path, :class => 'first-breadcrumb'\n unless @breadcrumb.nil?\n breadcrumbs += content_tag(:label, \" > \")\n if @breadcrumb.kind_of? Picture\n picture = @breadcrumb\n @breadcrumb = @breadcrumb.gallery\n end\n breadcrumbs += parent_breadcrumbs_gallery(@breadcrumb)\n\n unless picture.nil?\n breadcrumbs += content_tag(:label, \" > \")\n breadcrumbs += content_tag(:label, picture.title, :class => 'end-breadcrumb')\n end\n end\n if @finish_breadcrumb\n breadcrumbs + \" > \" + @finish_breadcrumb\n else\n breadcrumbs\n end\n end", "def parent_breadcrumb(options = {}, &block)\n if block_given?\n gretel_renderer.yield_parent_breadcrumb(options, &block)\n else\n gretel_renderer.parent_breadcrumb(options)\n end\n end", "def renderer\n HtmlRenderer.new(self)\n end", "def renderer\n HtmlRenderer.new(self)\n end", "def renderer\n @renderer ||= HtmlRenderer.new(self)\n end", "def breadcrumb(&block)\n config.breadcrumb = block\n end", "def breadcrumbs\n content_tag :ol, class: 'breadcrumb' do\n split_path = request.path.split('/').drop(1)\n concat content_tag :li, (link_to 'Home', '/')\n split_path.each_with_index do |p, i|\n concat content_tag :li, (link_to p.capitalize_each('-'), '/' + split_path.take(i+1).join('/'))\n end\n end\n end", "def breadcrumbs(content)\n content_for(:breadcrumbs, content) if content\n end", "def set_breadcrumbs\n @breadcrumbs = []\n add_breadcrumb \"Home\", root_path\n end", "def set_breadcrumbs\n @breadcrumbs = []\n add_breadcrumb \"Home\", root_path\n end", "def renderer; end", "def breadcrumbs\r\n\t\t\tself.parent.nil? ? [] : self.parent.breadcrumbs + [self]\r\n\t\tend", "def breadcrumb\n add_breadcrumb \"Users\", persons_path if @rider.book\n add_breadcrumb \"Master book\", master_riders_path if @rider.is_master?\n\n add_breadcrumb @rider.book.person.first_name, person_path(@rider.book.person) if @rider.book\n add_breadcrumb @rider.book.number, person_book_path(@rider.book.person, @rider.book) if @rider.book\n if @rider.is_master?\n add_breadcrumb @rider.book.number, master_book_path(@rider.book) \n else\n add_breadcrumb @rider.book.number, book_rider_path(@rider.book, @rider)\n end\n add_breadcrumb @rider.name, book_rider_path(@rider.book, @rider) if @rider\n end", "def crumbs\n [self]\n end", "def to_breadcrumb\n self.title\n end", "def render_breadcrumb_node(node, options)\n caption, url, selected = extract_node_details(node)\n content_tag('span', render_single_breadcrumb_node(node, caption, url, selected, options), :class=>options[:span_class] ).html_safe\n end", "def breadcrumbs\n @crumbs ||= parent.nil? ? [] : (parent.breadcrumbs + [parent])\n end", "def render_breadcrumb(options = {})\n options = {\n separator: \">\",\n page: @page,\n restricted_only: false,\n reverse: false,\n link_active_page: false\n }.merge(options)\n\n pages = options[:page]\n .self_and_ancestors.contentpages\n .published\n\n if options.delete(:restricted_only)\n pages = pages.restricted\n end\n\n if options.delete(:reverse)\n pages = pages.reorder(\"lft DESC\")\n end\n\n if options[:without].present?\n without = options.delete(:without)\n pages = pages.where.not(id: without.try(:collect, &:id) || without.id)\n end\n\n render \"alchemy/breadcrumb/wrapper\", pages: pages, options: options\n end", "def documentation_breadcrumb_for(page, options = {})\n options[:root_link] = options[:root_link].nil? ? t('documentation.helpers.documentation_breadcrumb_for.default_root_link') : options[:root_link]\n options[:class] ||= 'breadcrumb'\n\n String.new.tap do |s|\n s << \"<nav class='#{options[:class]}'><ul>\"\n\n if options[:root_link]\n s << \"<li><a href='#{documentation_doc_root.blank? ? '/' : documentation_doc_root}'>#{options[:root_link]}</a></li>\"\n end\n\n if page.is_a?(::Documentation::Page)\n page.breadcrumb.each do |child|\n s << \"<li><a href='#{documentation_doc_root}/#{child.full_permalink}'>#{child.title}</a></li>\"\n end\n end\n\n s << \"</ul></nav>\"\n end.html_safe\n end", "def individual_breadcrumb\n add_breadcrumb \"Clients\", clients_path, :title => \"Clients\" \n add_breadcrumb \"Power Of Attorney\", '', :title => \"Power Of Attorney\" \n add_breadcrumb \"Principal Create\", '', :title => \"Principal Create\"\n end", "def breadcrumbs_label(text = nil)\n $tracer.trace(__method__)\n tag = div.className(\"/results_header/\")\n if(text.nil?)\n return ToolTag.new(tag.find.div, __method__)\n else\n return ToolTag.new(tag.find.div(text), __method__)\n end\n end", "def breadcrumbs_for_business_directory_theme \n breadcrumbs = \"\"\n if @text.present?\n breadcrumbs = \"You searched for #{truncate(@text, :length => 30)}\"\n breadcrumbs += \" in #{@postal_code}\" if @postal_code.present?\n elsif @postal_code.present? \n breadcrumbs = \"ZIP: #{@postal_code}\"\n end\n if @category\n if @text.present?\n breadcrumbs += \" in \"\n else\n options = {\n :category_id => nil,\n :iframe_width => params[:iframe_width],\n :iframe_height => params[:iframe_height],\n :layout => @layout,\n :page_size => params[:page_size]\n }\n breadcrumbs += link_to( \"Coupons: \", options )\n end\n if @category.parent \n breadcrumbs += \"#{link_to( h(@category.parent.name), pagination_link_params(@page).merge!( :category_id => @category.parent.to_param) )}: \"\n end\n breadcrumbs += link_to( h(@category.name), pagination_link_params(@page) )\n end\n breadcrumbs = \"&nbsp;\" if breadcrumbs.blank?\n content_tag( :div, breadcrumbs, :class => 'breadcrumbs' )\n end", "def breadcrumbs\n Set.new(parent? ? (parent.breadcrumbs + [self]) : [self])\n end", "def breadcrumb\n Array(@breadcrumb)\n\tend", "def view_renderer; end", "def view_renderer; end", "def get_breadcrumbs\n current = @product || @brand || @category || @page\n # BreadcrumbsMaker.build current, params\n make_breadcrumbs current\n end", "def parent_breadcrumb(options = {})\n render(options)[-2]\n end", "def parent_breadcrumbs_gallery(gallery)\n breadcrumbs = \"\"\n unless gallery.parent.nil?\n breadcrumbs += parent_breadcrumbs_gallery(gallery.parent)\n breadcrumbs += content_tag(:label, \" > \")\n end\n breadcrumbs += link_to(gallery.name, gallery_path(gallery),\n :class => (@breadcrumb == gallery ? 'end-breadcrumb' : 'middle-breadcrumb'))\n end", "def renderer r\n @renderer = r\n end", "def renderer r\n @renderer = r\n end", "def get_text_breadcrumb\r\n bread_crumb_text.text\r\n end", "def r_breadcrumbs_nav(&block)\n content_tag(\"nav\", class: \"hidden sm:flex items-center text-sm leading-5 font-medium\", &block)\n end", "def extract_breadcrumb\n end", "def render_crumbs(crumbs, options = {})\n\n options[:skip_if_blank] ||= Crummy.configuration.skip_if_blank\n return '' if options[:skip_if_blank] && crumbs.count < 1\n options[:format] ||= Crummy.configuration.format\n options[:separator] ||= Crummy.configuration.send(:\"#{options[:format]}_separator\")\n options[:right_separator] ||= Crummy.configuration.send(:\"#{options[:format]}_right_separator\")\n options[:links] ||= Crummy.configuration.links\n options[:first_class] ||= Crummy.configuration.first_class\n options[:last_class] ||= Crummy.configuration.last_class\n options[:microdata] ||= Crummy.configuration.microdata if options[:microdata].nil?\n options[:truncate] ||= Crummy.configuration.truncate if options[:truncate]\n options[:last_crumb_linked] = Crummy.configuration.last_crumb_linked if options[:last_crumb_linked].nil?\n options[:right_side] ||= Crummy.configuration.right_side\n\n last_hash = lambda do |o|\n k = o.map{ |c| c.is_a?(Hash) ? (c.empty? ? nil: c) : nil }.compact\n k.empty? ? {} : k.last\n end\n local_global = lambda do |crumb, global_options, param_name|\n if last_hash.call(crumb).has_key?(param_name.to_sym)\n last_hash.call(crumb)[param_name.to_sym]\n else\n global_options[param_name.to_sym]\n end\n end\n\n case options[:format]\n when :html\n crumb_string = crumbs.map.with_index(1) do |crumb, index|\n next if local_global.call(crumb, options, :right_side)\n crumb_to_html(\n crumb,\n local_global.call(crumb, options, :links),\n local_global.call(crumb, options, :first_class),\n local_global.call(crumb, options, :last_class),\n (crumb == crumbs.first),\n (crumb == crumbs.last),\n local_global.call(crumb, options, :microdata),\n index,\n local_global.call(crumb, options, :last_crumb_linked),\n local_global.call(crumb, options, :truncate)\n )\n end.compact.join(options[:separator]).html_safe\n if options[:microdata]\n content_tag(:div, crumb_string, itemscope: true, itemtype: data_definition_url(\"BreadcrumbList\"))\n else\n crumb_string\n end\n when :html_list\n # Let's set values for special options of html_list format\n options[:li_class] ||= Crummy.configuration.li_class\n options[:ol_class] ||= Crummy.configuration.ol_class\n options[:ol_id] ||= Crummy.configuration.ol_id\n options[:ol_id] = nil if options[:ol_id].blank?\n crumb_string = crumbs.map do|crumb|\n next if local_global.call(crumb, options, :right_side)\n crumb_to_html_list(\n crumb,\n local_global.call(crumb, options, :links),\n local_global.call(crumb, options, :li_class),\n local_global.call(crumb, options, :first_class),\n local_global.call(crumb, options, :last_class),\n (crumb == crumbs.first),\n (crumb == crumbs.find_all{|crumbb| !last_hash.call(crumbb).fetch(:right_side,false)}.compact.last),\n local_global.call(crumb, options, :microdata),\n local_global.call(crumb, options, :last_crumb_linked),\n local_global.call(crumb, options, :truncate),\n local_global.call(crumb, options, :separator)\n )\n end.compact.join.html_safe\n crumb_right_string = crumbs.reverse.map do |crumb|\n next if !local_global.call(crumb, options, :right_side)\n crumb_to_html_list(\n crumb,\n local_global.call(crumb, options, :links),\n local_global.call(crumb, options, :li_right_class),\n local_global.call(crumb, options, :first_class),\n local_global.call(crumb, options, :last_class),\n (crumb == crumbs.first),\n (crumb == crumbs.find_all{|crumbb|!local_global.call(crumbb, options, :right_side)}.compact.last),\n local_global.call(crumb, options, :microdata),\n local_global.call(crumb, options, :last_crumb_linked),\n local_global.call(crumb, options, :truncate),\n local_global.call(crumb, options, :right_separator)\n )\n end.compact.join.html_safe\n content_tag(:ol, :class => options[:ol_class], :id => options[:ol_id]) do\n concat crumb_string\n concat crumb_right_string\n end\n when :xml\n crumbs.collect do |crumb|\n crumb_to_xml(\n crumb,\n local_global.call(crumb, options, :links),\n local_global.call(crumb, options, :separator),\n (crumb == crumbs.first),\n (crumb == crumbs.last)\n )\n end * ''\n else\n raise ArgumentError, \"Unknown breadcrumb output format\"\n end\n end", "def add_breadcrumbs\n breadcrumb_for \"index\" # base\n\n if action_name != \"index\"\n breadcrumb_for action_name\n end\n end", "def new\n build_breadcrumbs\n end", "def new\n build_breadcrumbs\n end", "def breadcrumb_for(identifier, options={})\n options[:collection_tag] ||= 'ul'\n options[:collection_class] ||= 'breadcrumb'\n\n # Retreive the breadcrumbs trail and format them\n sections = find_breadcrumbs_trail(identifier)\n render_menu(sections, options)\n end", "def set_root_breadcrumb\n add_breadcrumb '<span class=\"fa fa-lg\">&#xf015</span><span class=\"sr-only\">Top</span>'.html_safe, root_path\n end", "def f_breadcrumb(ancestors_list = nil)\n if ancestors_list.nil? && @feature.nil?\n content_tag :ol, \"<li>#{link_to(ts('home.this').html_safe, root_path)}</li>\".html_safe, class: 'breadcrumb'\n else\n ancestors_list ||= @feature.closest_ancestors_by_perspective(current_perspective)\n list = ancestors_list.collect do |r|\n name = r.prioritized_name(current_view)\n options = {}\n if name.nil?\n name_str = r.pid\n else\n name_str = name.name\n options[:class] = 'non-capitalizable' if !name.orthographic_system_code.blank?\n end\n link_to(name_str, feature_path(r.fid), options)\n end\n list = [link_to(\"#{ts('app.short')}:\".html_safe, root_path)] + list[0...list.size-1].collect{|e| \"#{e}#{breadcrumb_separator}\".html_safe} + [list.last]\n content_tag :ol, list.collect{|e| \"<li>#{e}</li>\"}.join.html_safe, class: 'breadcrumb'\n end\n # content_tag :div, acts_as_family_tree_breadcrumb(feature, breadcrumb_separator) {|r| f_link(r, feature_path(r.fid), {}, {:s => true})}, :class => \"breadcrumbs\"\n end", "def breadcrumbs(separator=\" / \")\n crumbs = env[\"PATH_INFO\"].split(\"/\").map {|path| { :path => path, :name => path } }\n crumbs[0] = { :path => \"/\", :name => \"projects\" }\n crumbs = crumbs[0..-2].inject([]) do |crumbs_so_far, current|\n crumbs_so_far << %(<a href=\"#{current[:path]}\">#{current[:name]}</a>)\n end << crumbs.last[:name]\n crumbs.join(separator)\n end", "def f_breadcrumb(feature)\n # content_tag :div, acts_as_family_tree_breadcrumb(feature, breadcrumb_separator) {|r| f_link(r, feature_path(r.fid), {}, {:s => true})}, :class => \"breadcrumbs\"\n content_tag :div, feature.closest_ancestors_by_perspective(current_perspective).collect{|r| f_link(r, feature_path(r.fid), {}, {:s => true})}.join(breadcrumb_separator).html_safe, :class => \"breadcrumbs\"\n end", "def breadcrumb_master\n add_breadcrumb \"Master Rider\", master_riders_path\n add_breadcrumb @rider.name, master_rider_path(@rider) if @rider\n end", "def breadcrumbs(links)\n bcs = []\n\n position = 1\n links.each do |link|\n bcs << single(position: position, **symbolize_keys(link))\n position += 1\n end\n\n return %(<ol class=\"breadcrumbs\" vocab=\"http://schema.org/\" typeof=\"BreadcrumbList\">#{bcs.join(@divider)}</ol>)\n end", "def build_breadcrumbs\n @breadcrumbs = [\n { :title => I18n.t(\"admin.sections.#{resource_collection_name}\"), :url => collection_path }\n ]\n @breadcrumbs << { :title => params[:action] } unless params[:action] == 'index'\n end", "def home_breadcrumbs(action=\"\")\n crumbs = []\n\n crumbs.push({ \"text\": t(\"defaults.home\"), \"link\": root_path })\n\n case action\n when \"api\"\n crumbs.push({ \"text\": \"API\" })\n\n when \"conferences\"\n crumbs.push({ \"text\": t(\"views.conference.list\") })\n end\n\n render \"partials/breadcrumbs\", crumbs: crumbs\n end", "def hardcoded_breadcrumbs\n [\n {\n title: \"Home\",\n url: \"/\",\n },\n {\n title: subtopic.parent.title,\n url: subtopic.parent.base_path,\n },\n {\n title: subtopic.title,\n url: subtopic.base_path,\n },\n ]\n end", "def breadcrumb_name\n title\n end", "def links\n @links ||= if @breadcrumb_key.present?\n # Reload breadcrumbs configuration if needed\n Gretel::Crumbs.reload_if_needed\n\n # Get breadcrumb set by the `breadcrumb` method\n crumb = Gretel::Crumb.new(context, breadcrumb_key, *breadcrumb_args)\n\n # Links of first crumb\n links = crumb.links.dup\n \n # Get parent links\n links.unshift *parent_links_for(crumb)\n\n links\n else\n []\n end\n end", "def root_breadcrumb\n breadcrumb \"Outpost\", outpost_root_path\n end", "def breadcrumb(object, level = 0)\n path = (\"../\" * level) + object.name + \".html\"\n link = link_to(object.name, path)\n\n if object.parent.kind_of?(RDoc::TopLevel)\n link\n else\n breadcrumb(object.parent, level+1) + \"&nbsp; > &nbsp;\" + link\n end\n end", "def member_breadcrumbs\n add_breadcrumb(@period.name, url_for(@period), true, 'Coaching Period')\n end", "def breadcrumbs\n request_data[:breadcrumbs] ||= Bugsnag::Utility::CircularBuffer.new(@max_breadcrumbs)\n end", "def get_breadcrumb_as_block(context)\n \n blocks = [{:name => 'site_breadcrumb',\n :module_name => :cms,\n :theme => Themes::ThemeManager.instance.selected_theme.name}]\n\n return blocks\n \n end", "def add_resource_breadcrumb(resource)\n ancestor_nodes(resource).each do |node|\n @breadcrumbs << { name: node, url: url_for( action: :edit, id: node.id ) }\n end\n super\n end", "def renderer=(value)\n @renderer = value\n end", "def renderer_for(format)\n renderer_factory.renderer_for(format)\n end", "def add_breadcrumb name, url = ''\n @breadcrumbs ||= []\n url = eval(url) if url =~ /_path|_url|@/\n @breadcrumbs << [name, url]\n end", "def block_view(context, block_name)\n \n app = context[:app]\n \n result = case block_name\n \n when 'site_breadcrumb_public'\n\n preffixes = Plugins::Plugin.plugin_invoke_all('ignore_path_prefix_breadcrumb', {:app => self})\n\n if app.request.path_info.empty? or app.request.path_info.start_with?(*preffixes)\n bc = ''\n else\n path = app.request.path_info\n if path.match /\\/page\\/\\d+/\n path.sub!(/\\/page\\/\\d+/,'')\n end\n home_page_path = SystemConfiguration::Variable.get_value('site.anonymous_front_page', nil)\n bc = app.t.breadcrumb.home\n\n if home_page_path != path\n path_array = path.split('/')\n result = \"\"\n summary = \"\\\\\"\n bc = path_array.slice(0, path_array.size-1).inject(\"\") do |result, item| \n if item.empty?\n result << \"<a href=\\\"/\\\">#{app.t.breadcrumb.home}</a>\"\n result\n else \n result << \"<span class=\\\"breadcrumb_separator\\\"> &gt; </span> \" unless result.empty?\n result << \"<a href=\\\"#{summary}#{item}\\\">#{item.capitalize.gsub(/-/,' ')}</a>\"\n summary << \"#{item}\\\\\" \n result\n end\n end\n if path_array.size > 1\n bc << \" <span class=\\\"breadcrumb_separator\\\"> &gt; </span> <span class=\\\"breadcrumb_last\\\">#{path_array.last.capitalize.gsub(/-/,' ')}</span>\"\n end\n end\n end \n\n bc == app.t.breadcrumb.home ? '' : bc\n\n\n when 'site_breadcrumb'\n preffixes = Plugins::Plugin.plugin_invoke_all('ignore_path_prefix_breadcrumb', {:app => self})\n \n if app.request.path_info.empty? or app.request.path_info.start_with?(*preffixes)\n bc = ''\n else\n breadcrumb = Site::BreadcrumbBuilder.build(app.request.path_info, context) \n bc_render = SiteRenders::BreadcrumbRender.new(breadcrumb, context)\n bc = bc_render.render \n end \n\n bc\n\n\n when 'site_adminmenu'\n \n if app.user and app.user.is_superuser?\n \n # Retrieve the admin menu options\n admin_menu = {:name => 'admin_menu', :title => 'Admin menu', :description => 'Administration menu'}\n admin_menu_items = Plugins::Plugin.plugin_invoke_all('menu', context)\n \n menu = Site::Menu.build(admin_menu, admin_menu_items)\n menu.language_in_routes = false\n SiteRenders::MenuRender.new(menu, context).render\n \n end\n \n when /^menu_/\n \n menu_name = block_name.match(/^menu_(.+)/)[1]\n \n if menu = Site::Menu.get(menu_name)\n menu_render = SiteRenders::MenuRender.new(menu, context)\n menu_render.render\n else\n ''\n end\n \n when /^view_/ \n\n view_name = block_name.sub(/view_/,'')\n \n if view = ContentManagerSystem::View.get(view_name)\n arguments = \"\"\n if app.request.path_info and app.request.path_info.split('/').length > 2\n arguments = (x=app.request.path_info.split('/')).slice(2,x.length).join('/')\n end\n ::CMSRenders::ViewRender.new(view, app).render(1, arguments) \n else\n ''\n end\n \n when /^content_/\n \n content_id = block_name.sub(/content_/,'')\n if content = ContentManagerSystem::Content.get(content_id.to_i)\n CMSRenders::ContentRender.new(content, app).render\n else\n ''\n end \n\n\n end\n\n return result\n \n \n end", "def crumbs\n get_or_set_ivar \"@_crumbs\", []\n end", "def add_breadcrumb name, url = ''\n\t\t@breadcrumbs ||= []\n\t\t url = eval(url) if url =~ /_path|_url|@/\n\t\t@breadcrumbs << [name, url]\n\tend", "def r_mobile_breadcrumbs_nav(url)\n content_tag(\"nav\", class: \"sm:hidden\") do\n link_to(url, class: \"flex items-center text-sm leading-5 font-medium text-gray-500 hover:text-gray-700 #{HOVER_ANIMATION}\") do\n concat(content_tag(\"svg\", class: \"flex-shrink-0 -ml-1 mr-1 h-5 w-5 text-gray-400\", \"viewBox\": \"0 0 20 20\", \"fill\": \"currentColor\") do\n tag(\"path\", \"fill-rule\": \"evenodd\", d: \"M12.707 5.293a1 1 0 010 1.414L9.414 10l3.293 3.293a1 1 0 01-1.414 1.414l-4-4a1 1 0 010-1.414l4-4a1 1 0 011.414 0z\", \"clip-rule\": \"evenodd\")\n end)\n concat \"Back\"\n end\n end\n end", "def renderer_factory\n Renderable.renderer_factory\n end", "def renderer *val\n if val.empty?\n return @renderer\n end\n @renderer = val[0]\n end", "def crumbs\n @crumb_jar ||= CrumbJar.new(self)\n end", "def show\n breadcrumb\n end", "def links_for_render(options = {})\n out = links.dup\n\n # Handle autoroot\n if options[:autoroot] && out.map(&:key).exclude?(:root) && Gretel::Crumbs.crumb_defined?(:root)\n out.unshift *Gretel::Crumb.new(context, :root).links\n end\n\n # Set current link to actual path\n if options[:link_last_to_current_path] && out.any? && request\n out.last.url = request.fullpath\n end\n\n # Handle show root alone\n if out.size == 1 && !options[:display_single_fragment]\n out.shift\n end\n\n # Set last link to current\n out.last.try(:current!)\n\n out\n end", "def crumbs\n @crumbs ||= {}\n end", "def page_breadcrumbs(page)\n page.ancestors.reverse.map { |p| link_to(p.name, p.path) }\n end", "def renderer\r\n if @renderer.blank?\r\n if self.controller.present?\r\n @renderer = PageTag::PageRenderer::RailsRenderer.new(self.ehtml, self.ecss, self.ejs, self.context,self.controller)\r\n else\r\n @renderer = PageTag::PageRenderer::ErubisRenderer.new(self.ehtml, self.ecss, self.ejs, self.context)\r\n end\r\n end\r\n @renderer\r\n end", "def breadcrumbs\n add_breadcrumb(@problem.name, problem_path(@problem))\n add_breadcrumb \"Solutions\", problem_solutions_path(@problem)\n end", "def regular_compact_breadcrumbs(document)\n breadcrumb_links = []\n breadcrumb_links << add_campus_link(document) unless document.campus.nil?\n breadcrumb_links << add_parent_campus_link(document) unless document.parent_campus.nil? && !document.campus.nil?\n breadcrumb_links << build_repository_link(document)\n\n parents = document_parents(document)\n breadcrumb_links << parents[0, 1].map do |parent|\n link_to parent.label, solr_document_path(parent.global_id)\n end\n\n breadcrumb_links << '&hellip;'.html_safe if parents.length > 1\n\n safe_join(\n breadcrumb_links,\n aria_hidden_breadcrumb_separator\n )\n end", "def render(&block)\n self.renderer = block\n end", "def add_breadcrumb_modulo\n add_breadcrumb pluralize_model(TbAvaliacao), gerente_tb_avaliacoes_path\n end", "def add_breadcrumb(name, url = nil)\n breadcrumbs << Crumb.new(name, url)\n end", "def navigation\n @rendered_nav ||= @formatter.new(\n Octant.get(:test), @formatter_options).to_html\n end", "def add_breadcrumb(name, url = nil)\n @breadcrumbs ||= []\n url = send(url) if url.is_a?(Symbol)\n name = send(name).to_s.titleize if name.is_a?(Symbol)\n @breadcrumbs << [name, url]\n end", "def acts_as_family_tree_breadcrumb(aaft_instance, sep=' &gt; ')\n if aaft_instance.parent.nil?\n grandparent = aaft_instance.all_parent_relations.collect(&:parent_node).detect(&:parent)\n trail = grandparent.nil? ? [aaft_instance] : grandparent.all_parents + [grandparent, aaft_instance]\n else\n trail = aaft_instance.all_parents + [aaft_instance]\n end\n trail.collect do |r|\n block_given? ? yield(r) : r.to_s\n end.join(sep)\n end", "def acts_as_family_tree_breadcrumb(aaft_instance, sep=' &gt; ')\n if aaft_instance.parent.nil?\n grandparent = aaft_instance.all_parent_relations.collect(&:parent_node).detect(&:parent)\n trail = grandparent.nil? ? [aaft_instance] : grandparent.all_parents + [grandparent, aaft_instance]\n else\n trail = aaft_instance.all_parents + [aaft_instance]\n end\n trail.collect do |r|\n block_given? ? yield(r) : r.to_s\n end.join(sep)\n end", "def render_list(&block)\n view.capture_haml do\n view.haml_tag :ul, class: \"breadcrumb\" do\n yield\n end\n end\n end", "def add_resource_breadcrumb(resource)\n ancestors = []\n if resource.new_record?\n if resource.parent_id\n ancestors = resource.parent.ancestors\n ancestors += [resource.parent]\n end\n else\n ancestors = resource.ancestors\n end\n\n ancestors.each do |ancestor|\n @breadcrumbs << { name: ancestor, url: url_for( action: :edit, id: ancestor.id ) }\n end\n\n super\n end" ]
[ "0.8187783", "0.75630695", "0.7382717", "0.6954178", "0.6743278", "0.6724286", "0.67181635", "0.6576366", "0.6514266", "0.6514109", "0.6514109", "0.6496024", "0.6482023", "0.6463976", "0.64127415", "0.6392123", "0.6386978", "0.63468766", "0.6320909", "0.61905783", "0.61519027", "0.61519027", "0.6137583", "0.60968316", "0.60120654", "0.5995826", "0.59848356", "0.59848356", "0.5975485", "0.5952687", "0.593846", "0.59382385", "0.5933519", "0.59301955", "0.59255844", "0.59232754", "0.5905093", "0.5898929", "0.5887687", "0.58852005", "0.5845992", "0.58445305", "0.5817797", "0.5817797", "0.5805205", "0.57967955", "0.57960695", "0.57924604", "0.57924604", "0.578241", "0.5744511", "0.57360196", "0.57251304", "0.5718737", "0.56992495", "0.56992495", "0.569705", "0.5691173", "0.5676974", "0.56387883", "0.56341803", "0.56299347", "0.56289715", "0.56272984", "0.5612025", "0.5596968", "0.5585644", "0.55794847", "0.557601", "0.5524914", "0.55133003", "0.5509598", "0.5486174", "0.54805607", "0.5476366", "0.54708683", "0.54652303", "0.54605895", "0.54198664", "0.53988135", "0.53971946", "0.5384726", "0.5381087", "0.5374385", "0.53706497", "0.5360633", "0.53581035", "0.53210723", "0.53185034", "0.5303913", "0.5303154", "0.5294374", "0.52740604", "0.5273598", "0.5254444", "0.5245914", "0.52368903", "0.52368903", "0.5232298", "0.5208501" ]
0.63012195
19
helper method for delete:
def maximum(tree_node = @root) while tree_node.right tree_node = tree_node.right end return tree_node end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete\n \n end", "def delete\n \n end", "def delete\n end", "def delete\n\n end", "def delete\n end", "def delete\n end", "def delete\n end", "def delete\n end", "def delete\n end", "def delete\n end", "def delete\n end", "def delete\n\n\tend", "def delete\n end", "def delete\n end", "def delete(*rest) end", "def delete(name)\n\n end", "def deleted(item)\n end", "def delete\n # TODO: implement delete\n end", "def destroy; delete end", "def delete\n raise NotImplementedError\n end", "def delete\n raise NotImplementedError\n end", "def delete(name); end", "def delete(name); end", "def delete(obj) ; end", "def delete\n\t\tfalse\n\tend", "def delete(object); end", "def delete\n raise NotImplementedError\n end", "def delete_operations; end", "def delete\n raise NotImplementedError\n end", "def delete; raise ActiveRecord::ReadOnlyRecord; end", "def delete(action, **args); end", "def delete(value)\n end", "def delete(value)\n end", "def delete!(*rest) end", "def deleteRequest\n\n end", "def delete_item\n\nend", "def del\n delete\n end", "def destroy\r\n\r\n end", "def delete_post\n\t \n \tend", "def destroy; end", "def destroy; end", "def destroy; end", "def destroy; end", "def destroy; end", "def destroy; end", "def destroy; end", "def destroy; end", "def destroy; end", "def destroy; end", "def delete\n return false\n end", "def destroy \r\n\r\n end", "def destroy\n \n end", "def destroy\n \n end", "def destroy \n \n end", "def destroy\r\n end", "def destroy\r\n end", "def delete(oid)\n end", "def delete\n destroy\n end", "def delete\n destroy\n end", "def destroy\n \n end", "def destroy\n \n end", "def destroy\n \n end", "def destroy\n \n end", "def destroy\n \n end", "def destroy\n \n end", "def destroy\n \n end", "def delete!\n request! :delete\n end", "def delete(contactname)\n\n end", "def _destroy_delete\n delete\n end", "def _destroy_delete\n delete\n end", "def delete(table, ids) # abstract\n end", "def destroy\n \n end", "def delete\n ret_val = error_if_exists('delete')\n super if ret_val\n return ret_val\n end", "def destroy\n\n end", "def delete(key)\n\n end", "def destroy\n \n end", "def destroy\n \n end", "def destroy\n \n end", "def destroy\n \n end", "def destroy\n \n end", "def destroy\n \n end", "def destroy\r\n end", "def destroy\n\t\t\n\tend", "def delete\n return @delete\n end", "def destroy\n end", "def destroy\n end", "def destroy\n end", "def destroy\n end", "def destroy\n end", "def destroy\n end", "def destroy\n end", "def destroy\n end", "def destroy\n end", "def destroy\n end", "def destroy\n end", "def destroy\n end", "def destroy\n end", "def destroy\n end", "def destroy\n end", "def destroy\n end", "def destroy\n end" ]
[ "0.8373501", "0.80260485", "0.8013269", "0.80042505", "0.7956913", "0.7956913", "0.7956913", "0.7956913", "0.7956913", "0.7956913", "0.7956913", "0.79107374", "0.7799738", "0.77781236", "0.7493549", "0.7422571", "0.74152577", "0.7396308", "0.73679674", "0.7326224", "0.7326224", "0.7311375", "0.7311375", "0.7252753", "0.725267", "0.7244257", "0.7208222", "0.72013843", "0.71965003", "0.71889603", "0.7187095", "0.7183631", "0.7183631", "0.7167577", "0.7125145", "0.711353", "0.7107788", "0.7078295", "0.7065486", "0.705726", "0.705726", "0.705726", "0.705726", "0.705726", "0.705726", "0.705726", "0.705726", "0.705726", "0.705726", "0.70541155", "0.7052777", "0.7017235", "0.7017235", "0.70120704", "0.69652414", "0.69652414", "0.69552475", "0.69548935", "0.69548935", "0.6948128", "0.6948128", "0.6948128", "0.6948128", "0.6948128", "0.6948128", "0.6948128", "0.6945965", "0.6911031", "0.69078535", "0.69078535", "0.689664", "0.68946195", "0.68924433", "0.68908125", "0.68870634", "0.6877803", "0.6877803", "0.6877803", "0.6877803", "0.6877803", "0.6877803", "0.68777853", "0.68683136", "0.6865189", "0.6863397", "0.6863132", "0.6863132", "0.6863132", "0.6863132", "0.6863132", "0.6863132", "0.6863132", "0.6863132", "0.6863132", "0.6863132", "0.6863132", "0.6863132", "0.6863132", "0.6863132", "0.6863132", "0.6863132" ]
0.0
-1
optional helper methods go here:
def find_parent(value, tree_node = @root) return nil if @root.value == value # puts "tree_node.value", tree_node.value # puts "tree_node.left.value", tree_node.left.value # puts "tree_node.right.value", tree_node.right.value return tree_node if tree_node.left.value == value || tree_node.right.value == value if tree_node.value > value tree_node = tree_node.left find_parent(value, tree_node) else tree_node = tree_node.right find_parent(value,tree_node) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def optional; end", "def private; end", "def maybe; end", "def extra; end", "def missing?; end", "def optional_positionals; end", "def specie; end", "def specie; end", "def specie; end", "def specie; end", "def required_defaults; end", "def missing; end", "def fallbacks=(_arg0); end", "def fallbacks; end", "def fallbacks; end", "def custom; end", "def custom; end", "def probers; end", "def explicit?; end", "def missed?; end", "def ignores; end", "def helpers; end", "def helpers; end", "def helpers; end", "def conditionally(*) end", "def conditionally(*) end", "def possibly_include_hidden?; end", "def maybe so, maybe: self\n so\n end", "def required_positionals; end", "def informational?; end", "def required; end", "def required; end", "def required; end", "def extra_args; end", "def missing_option; end", "def missing_option; end", "def missing_option; end", "def missing_option; end", "def missing_option; end", "def missing_option; end", "def missing_option; end", "def missing_option; end", "def missing_option; end", "def who_we_are\r\n end", "def generic?; true; end", "def none?; end", "def none?; end", "def none?; end", "def missing?; false; end", "def maybe so, maybe: self\n maybe\n end", "def has_required?; end", "def placebo?; false end", "def ensure_others\n self.description ||= self.title\n self.url ||= \"http://www.google.com\"\n self.image_url ||= \"https://s33.postimg.cc/pjju7pp9b/shire.jpg\"\n end", "def multiple?; end", "def isolated?; end", "def isolated?; end", "def fallback_data; end", "def fallback_data; end", "def argument?; end", "def suivre; end", "def extra=(_arg0); end", "def requirements; end", "def requirements; end", "def requirements; end", "def requirements; end", "def required_by_default?; end", "def caveats; nil end", "def caveats; nil end", "def schubert; end", "def present?; end", "def internal?; end", "def common\n \n end", "def simple_present; end", "def alternatives; end", "def safe_by_default; end", "def extra; @extra; end", "def formation; end", "def defaults; end", "def defaults; end", "def defaults; end", "def defaults; end", "def defaults; end", "def defaults; end", "def defaults; end", "def defaults; end", "def defaults; end", "def defaults; end", "def specialty; end", "def returns_nil; end", "def usable?; end", "def dynamic?; end", "def user_options; end", "def null?; false end", "def missing_option=(_arg0); end", "def missing_option=(_arg0); end", "def missing_option=(_arg0); end", "def missing_option=(_arg0); end", "def missing_option=(_arg0); end", "def missing_option=(_arg0); end", "def requirements=(_arg0); end", "def requirements=(_arg0); end" ]
[ "0.69176954", "0.63765454", "0.63068986", "0.6306494", "0.6274195", "0.6185965", "0.61177635", "0.61177635", "0.61177635", "0.61177635", "0.6087291", "0.6078838", "0.6068349", "0.59986085", "0.59986085", "0.5961325", "0.5961325", "0.5928666", "0.5928561", "0.59222955", "0.59065574", "0.58851177", "0.58851177", "0.58851177", "0.58748436", "0.58748436", "0.5831661", "0.58219814", "0.5807916", "0.579686", "0.5790369", "0.5790369", "0.5790369", "0.5778636", "0.5775039", "0.5775039", "0.5775039", "0.5775039", "0.5775039", "0.5775039", "0.5775039", "0.5775039", "0.5775039", "0.57691306", "0.5750277", "0.5747054", "0.5747054", "0.5747054", "0.57444555", "0.57302725", "0.57285404", "0.57059926", "0.56977975", "0.5688177", "0.56796306", "0.56796306", "0.56737614", "0.56737614", "0.5657868", "0.564176", "0.56351733", "0.5630148", "0.5630148", "0.5630148", "0.5630148", "0.56216246", "0.5619652", "0.5619652", "0.5619203", "0.56173486", "0.56049603", "0.5587795", "0.55781704", "0.5564607", "0.5546612", "0.5546413", "0.5541797", "0.5533462", "0.5533462", "0.5533462", "0.5533462", "0.5533462", "0.5533462", "0.5533462", "0.5533462", "0.5533462", "0.5533462", "0.553323", "0.5532771", "0.551871", "0.5515256", "0.5513105", "0.55053437", "0.55006707", "0.55006707", "0.55006707", "0.55006707", "0.55006707", "0.55006707", "0.54947376", "0.54947376" ]
0.0
-1
Given a string of words, you need to find the highest scoring word Each letter of a word scores points according to its position in the alphabet: a = 1, b = 2, c = 3 etc. You need to return the highest scoring word as a string. If two words score the same, return the word that appears earliest in the original string. All letters will be lowercase and all inputs will be valid.
def high(x) x = ('abcdefghijklmnopqrstuvwxyz') letterScore = { 'a' => 1, 'b' => 2, 'c' => 3, 'd' => 4, 'e' => 5, 'f' => 6, 'g' => 7, 'h' => 8, 'i' => 9, 'j' => 10, 'k' => 11, 'l' => 12, 'm' => 13, 'n' => 14, 'o' => 15, 'p' => 16, 'q' => 17, 'r' => 18, 's' => 19, 't' => 20, 'u' => 21, 'v' => 22, 'w' => 23, 'x' => 24, 'y' => 25, 'z' => 26 } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def high(string)\n letter_scores = ('a'..'z').to_a\n words = string.split\n\n word_scores = words.map do |word|\n score = 0\n word.chars.each { |char| score += letter_scores.index(char}\n score \n end\n words[word_scores.index(word_scores.max)]\nend", "def high(string)\n letter_scores = ('a'..'z').zip(1..26).to_h\n words = string.split\n\n word_scores = words.map do |word|\n score = 0\n word.chars.each { |char| score += letter_scores[char]}\n score \n end\n words[word_scores.index(word_scores.max)]\nend", "def high(string)\n letter_array = (\"a\"..\"z\").to_a\n score_hash = Hash.new(0)\n\n word_array = string.split\n word_array.each do |word|\n word.chars.each do |letter|\n score_hash[word] += letter_array.index(letter) + 1\n end\n end\n max_word_value = score_hash.values.max\n score_hash.key(max_word_value)\nend", "def alphabet_score(string)\n alpha = ('a'..'z').to_a\n\n words_with_points = string.split(' ').map { |word| [word.chars.map { |char| alpha.index(char) + 1 }.sum, word] }\n words_with_points.max_by { |inner| inner[0] }.last\nend", "def alphabet_score(str)\n alpha_chars = ('a'..'z').to_a\n max_score = 0\n max_word = ''\n arr = str.split(' ')\n arr.each do |word|\n word_score = word.chars.map { |char| alpha_chars.index(char) + 1 }.sum\n if word_score > max_score\n max_score = word_score\n max_word = word\n end\n end\n max_word\nend", "def highest_scoring_word(words)\n sorted_words = words.sort_by { |word| word.length }\n\n possibles = sorted_words.group_by { |word| score(word) }.max[1]\n return possibles.find { |w| w.length == 7 } if possibles.any? { |word| word.length == 7}\n possibles.first\n end", "def high(sentence)\n alpha_score = (\"a\"..\"z\").zip(1..26).to_h\n arr_sentence = sentence.split\n \n score_array = []\n \n arr_sentence.each do |word|\n score = 0\n word.chars.each do |char|\n score += alpha_score[char]\n end\n score_array << score\n end\n score_of_words = arr_sentence.zip(score_array).to_h\n \n result = score_of_words.max_by {|k,v| v}\n result.first\nend", "def high x \n letters = ('a'..'z').to_a\n indexes = (1..26).to_a\n obj = letters.zip(indexes)\n highest_count = 0\n highest_word = ''\n\n word_arr = x.split(' ')\n word_arr.each do |word|\n current_count = 0\n letter_arr = word.split('')\n letter_arr.each do |l|\n obj.each do |o|\n if l == o[0]\n current_count += o[1]\n end\n end\n end\n if current_count > highest_count\n highest_count = current_count\n highest_word = word \n end\n end\n return highest_word\nend", "def most_frequent_letter(string)\n \n #get rid of spaces\n string.gsub!(\" \", \"\")\n \n hash = Hash.new(0)\n string.split(\"\").each {|char| hash[char] += 1}\n \n #create hash and get max by first index\n hash.max_by{|char, num| num}[0]\n \nend", "def high(x)\n arr = x.split(\" \")\n alphab = (\"a\"..\"z\").to_a\n scores = []\n \n arr.each do |word|\n score = 0\n word.split(\"\").each do |letter| \n score += (alphab.index(letter) + 1) \n end\n scores.push(score)\n end\n \n puts arr[scores.index(scores.max)]\nend", "def most_common_letter(string)\nletters = {}\nletters.default = 0\t\nstring.each_char do |letter| letters[\"#{letter}\"] += 1 unless letter == \" \" end\n\tletter_counts = letters.invert.sort.reverse\n\tarr = letter_counts[0]\n\treturn letter_counts[0].reverse\nend", "def highest_score_from(words)\n\n best_word = {\n word: [],\n score: 0\n }\n\n words.each do |word|\n\n score = score_word(word)\n\n if score > best_word[:score]\n best_word[:word].clear\n best_word[:word] << word\n best_word[:score] = score\n end\n\n if score == best_word[:score]\n best_word[:word] << word\n end\n\n end\n\n # applies rules for ties:\n # - shortest word wins unless there is a 10 letter word\n # - if multiple 10 letter words, the first word wins\n shortest_word = best_word[:word].min_by do |word|\n word.length\n end\n\n all_tiles_words = best_word[:word].select do |word|\n word.length == 10\n end\n\n if all_tiles_words.empty?\n best_word[:word] = shortest_word\n else\n best_word[:word] = all_tiles_words[0]\n end\n\n return best_word\n\nend", "def most_common_letter(string)\n\n\tletters = string.split('')\n\tfrequencies = Hash.new(0)\n\n\tletters.each do |letter|\n \tfrequencies[letter] += 1\n\tend\n\n\t#puts frequencies\n\n\t#frequencies = frequencies.sort_by do |letter, count|\n #\tcount\n\t#end\n\n\t#frequencies.reverse!\n\t#return frequencies\n\n\tmost_common_letter_value = frequencies.max_by do |key, value|\n\t\tvalue\n\tend\n\t\n\t#puts most_common_letter_value\n\treturn most_common_letter_value\n\t\nend", "def most_frequent_letter(string)\nend", "def best_letter string\n alphabet = ('a'..'z').to_a\n frequency_hash = Hash['a' => 1]\n alphabet.each do |x|\n frequency_hash[x] = alphabet_frequency(string, x)\n end\n #puts frequency_hash\n number_alphabet [(alphabet_number(frequency_hash.min_by{|k,v| v}.first.split(\"\")).first + 1) % 26]\nend", "def most_common_letter(str)\n counts = Hash.new(0)\n str.delete(\" \").gsub(/[^a-zA-Z0-9\\-]/,\"\").split(\"\").each do |char|\n counts[char] += 1\n end\n counts.max_by{ |key,value| value }\nend", "def most_common_letter(string)\n\thistogram = {}\n\tstring.split(\"\").each do |i|\n\t\tif !histogram.has_key?(i)\n\t\t\thistogram[i] = 0\n\t\tend\n\tend\n\thistogram.each_key do |key|\n\t\tstring.split(\"\").each do |i|\n\t\t\tif key == i\n\t\t\t\thistogram[key] += 1\n\t\t\tend\n\t\tend\n\tend\n\thighest_count_letter = [histogram.keys[0], histogram.values[0]]\n\thistogram.each_key do |key|\n\t\tif histogram[key] > highest_count_letter[1]\n\t\t\thighest_count_letter = [key, histogram[key]]\n\t\tend\n\tend\n\treturn highest_count_letter\nend", "def highestRemainLetterOf word\n word.gsub!('*','.').downcase!\n @incorrectWord = @missingWord - word.chars\n getHighestAbilityLetterFrom(Regexp.compile('^'+word+'$')).pop[0]\nend", "def get_the_shortest_word(str)\n words = str.split()\n return words.max\nend", "def LetterCount(str)\n words = str.split(' ')\n num_repeats = nil\n best_word = nil\n \n idx = 0\n while idx < words.length\n word = words[idx]\n count = 0\n \n word_freq = Hash.new(0)\n word.split('').map {|x| word_freq[x] += 1 }\n if word_freq.select {|x,y| y > 1 }.empty?\n idx += 1\n next\n else\n count += word_freq.select {|x,y| y > 1 }.size\n end\n \n if num_repeats == nil || count > num_repeats\n num_repeats = count\n best_word = word\n end\n \n idx += 1\n end\n \n if num_repeats == nil\n return -1\n else\n return best_word\n end\nend", "def most_common_letter(string)\r\nidx = 0\r\ncommon_letter = nil\r\nletter_counter = nil\r\n\r\n while idx < string.length\r\n letter = string[idx]\r\n count = 0\r\n idx2 = 0\r\n while idx2 < string.length\r\n if string[idx2] == letter\r\n count = count+1\r\n end\r\n idx2 = idx2 + 1\r\n end\r\n if(letter_counter == nil)||(count > letter_counter)\r\n common_letter = letter\r\n letter_counter = count\r\n end\r\n idx = idx + 1\r\n end\r\n return [common_letter,letter_counter].to_s\r\nend", "def LetterCountI(str)\n largest_count = 0\n words = str.split(\" \")\n i = 0\n while i < words.length\n if count(words[i]) > largest_count\n largest_count = count(words[i])\n largest_word = words[i]\n end\n i += 1\n end\n if largest_count == 0\n return -1\n else\n return largest_word\n end\nend", "def most_common(string)\n count = Hash.new(0)\n string.split(\"\").each { |letter| count[letter] += 1 }\n count.max_by{ |key,value| value }[0]\nend", "def most_common_letter(string)\n list = {}\n array = string.split('')\n\n array.each do |letter|\n list[letter] += 1 if list[letter]\n list[letter] = 1 if !list[letter]\n end\n\n highest_count = list.values.max\n\n [list.key(highest_count), highest_count]\nend", "def highest_score_from(words)\n highest_score = 0\n winning_words = []\n words.each do |word|\n if score_word(word) > highest_score\n highest_score = score_word(word)\n winning_words.clear << word\n elsif score_word(word) == highest_score\n winning_words << word\n end\n end\n\n # no tie scenario\n if winning_words.count == 1\n return {word: winning_words[0], score: highest_score}\n else \n\n # tie scenario\n winning_words.each do |word|\n # determines whether word is 10 letters long\n if word.length == 10\n return {word: word, score: highest_score}\n end\n end\n # if there is no 10 letter word, find shortest word\n winner = winning_words.min_by do |word|\n word.length\n end \n\n return {word: winner, score: highest_score}\n end \nend", "def most_common_letter(string)\n # letter : how many times\n letter_count = Hash.new(0)\n\n (0...string.length).each do |i|\n letter_count[string[i]] += 1\n end\n\n letter = string[0]\n count = letter_count[letter]\n\n (1...string.length).each do |i|\n if letter_count[string[i]] > count\n count = letter_count[string[i]]\n letter = string[i]\n end\n end\n\n [letter, count]\nend", "def LetterCountI(str)\n greatest = \"\"\n\n str.downcase.split(\" \").each do |i|\n if (i.chars.length - i.chars.uniq.length) > (greatest.chars.length - greatest.chars.uniq.length)\n greatest = i\n end\n end\n\n greatest.length > 0 ? greatest : -1\nend", "def highest_word_score\n word = highest_scoring_word\n highest_score = Scrabble::Scoring.score(word)\n return highest_score\n end", "def most_common_letter(string)\n most_common = \"\"\n highest_occurance = 0\n \n counter = {}\n i = 0\n \n while i < string.length \n counter[string[i]].nil? ? counter[string[i]] = 1 : counter[string[i]] += 1\n i += 1\n end\n \n counter.each do |char, count|\n if count > highest_occurance\n most_common = char\n highest_occurance = count\n end\n end\n \n return [most_common, highest_occurance]\nend", "def get_most_used_letter(word)\n\t\tletter_counts = Hash.new(0)\n\t\tword.each do |letter|\n\t\t\tletter_counts[letter] += 1\n\t\tend\n\n\t\tmax_letter = \"\"\n\t\tmax_letter_count = 0\n\t\tletter_counts.each do |letter, count| \n\t\t\tif(count > max_letter_count)\n\t\t\t\tmax_letter_count = count\n\t\t\t\tmax_letter = letter\n\t\t\tend\n\t\tend\n\n\t\tmax_letter\t\t\n\tend", "def most_common_letter(string)\n\n\tcount = Hash.new(0)\n\n\tstring.each_char do |x|\n\t\tcount[x] += 1\n\tend\n\n\tcount.sort[0]\nend", "def find_the_most_letter_a(array)\n most_as = 0\n most_as_string = \"\"\n array.each_with_index do |string,i|\n a = 0\n string.each_char do |char|\n if char.downcase == \"a\"\n a +=1\n end\n end\n if a > most_as\n most_as = a\n most_as_string = array[i]\n end\n\n end\n most_as_string\nend", "def LongestWord(str)\n words = str.split.map { |s| s.gsub(/\\W/, '') }\n longest = words [0]\n words.each { |word| longest = word if word.length > longest.length }\n longest\nend", "def most_common_letter(string)\n popular_letter = string[0]\n most_frequency = 1\n\n idx = 0\n while idx < string.length\n letter = string[idx]\n\n frequency = 0\n idx1 = 0\n while idx1 < string.length\n\t\t\n\n if string[idx] == string[idx1]\n frequency += 1\n end\n\n if most_frequency < frequency\n most_frequency = frequency\n popular_letter = string[idx1]\n end\n\n\n #take first letter, \n #find number of occurnces\n\n #store in most popular\n\n #check 2nd number\n #if == first number, skip\n\n #if not 2nd number\n #\tcount,\n\n #if more popular\n\n #store as most popular\n\n\n\n\n\n ## return [(string[idx]), idx]\n idx1 += 1\n end\n\n\n idx += 1 \n end\n \n return [popular_letter, most_frequency]\nend", "def highest_score_from(words)\n all_words_scores = []\n\n # Calculate scores of all words\n words.each do |word|\n each_word_score = {}\n each_word_score[:word] = word\n each_word_score[:score] = score_word(word)\n all_words_scores << each_word_score\n end\n\n word_rank = all_words_scores.each.sort_by {|hash| hash[:score]}.reverse\n\n puts \"word rank: #{word_rank}\"\n\n best_word = word_rank[0]\n\n word_rank.each_with_index do |hash, index|\n\n if word_rank[index][:score] > best_word[:score]\n best_word = word_rank[index]\n\n # Tie Handling\n elsif word_rank[index][:score] == best_word[:score]\n if best_word[:word].length != 10\n if word_rank[index][:word].length == 10\n best_word = word_rank[index]\n elsif word_rank[index][:word].length < best_word[:word].length\n best_word = word_rank[index]\n end\n end\n end\n index += 1\n end\n return best_word\nend", "def most_frequent_word(str)\n frqWrd = \"\"\n words = word_count(str)\n words.each do |key|\n frqWrd = key if words[key] >= words[frqWrd]\n end\n frqWrd[0]\nend", "def most_common_letter(string)\n most_common_letter = nil\n most_common_letter_count = nil\n \n index1 = 0\n while index1 < string.length\n letter = string[index1] \n count = 0 \n \n index2 = 0\n while index2 < string.length \n if string[index2] == letter \n count += 1 \n end\n index2 += 1\n end\n\n if (most_common_letter_count == nil) || (count > most_common_letter_count)\n most_common_letter = letter\n most_common_letter_count = count\n end\n\n index1 += 1\n end\n \n return [most_common_letter, most_common_letter_count]\n end", "def letterCountI(str)\n\t# count = 0\n\t# mostRepeatedLetters = ''\n\t# str = str.split('').each{|letter| \n\t# \tif(str.count(letter) > count)\n\t# \t\tcount = str.count(letter)\n\t# \t\tmostRepeatedLetters = str\n\t# \tend\n\t# }\n\t# return mostRepeatedLetters\n\n\tletterCount = 0\n\tletterMaxWord = ''\n\tstr = str.split(' ').each{|word| word.split('').each{|letter| \n\t\tif(word.downcase.count(letter) > letterCount)\n\t\t\tletterCount = word.downcase.count(letter)\n\t\t\tletterMaxWord = word\n\t\tend\n\t\t}}\n\tletterCount > 1 ? (return letterMaxWord) : (return -1)\n\t\nend", "def highest_score_from(words)\n maximum_score = words.map { |word| score_word(word) }.max\n highest = words.select { |word| score_word(word) == maximum_score }\n if highest.length == 1 \n winning_word = highest.first\n else\n highest_lengths = highest.map {|i| i.length}\n if highest_lengths.any? { |x| x == 10}\n index_of_length_10 = highest_lengths.find_index(10)\n winning_word = highest[index_of_length_10]\n else\n winning_word = highest[highest_lengths.find_index(highest_lengths.min)]\n end \n end\n\n results = Hash.new\n results[:score] = maximum_score\n results[:word] = winning_word \n\n return results\nend", "def highest_word_score\n return Scrabble::Scoring.score(highest_scoring_word)\n end", "def highest_scoring_word\n highest_scoring_word = Scrabble::Scoring.highest_score_from(@array_of_words)\n\n return highest_scoring_word\n end", "def highest_scoring_word\n word = Scrabble::Scoring.highest_score_from(plays)\n return word\n end", "def most_frequent_word(string)\n hash = {}\n splitstring = string.split(\" \")\n splitstring.each {|element| element.downcase!}\n p splitstring\n splitstring.each{|element| if hash[element].nil?\n hash[element]=1\n else\n hash[element]+=1\n end}\nmost_frequent_item = hash.max_by{ |i| hash.count( i ) }\nputs most_frequent_item\nend", "def highest_word_score\n return highest_scoring_value = Scrabble::Scoring.score(highest_scoring_word)\n end", "def solve(s)\n alphabet = ('a'..'z').to_a\n s.gsub(/[aeiou]/, ' ').split.map { |l| l.chars.map { |i| alphabet.index(i) + 1 }.sum }.max\nend", "def find_longest_word(input)\n array = input.split(\" \")\n array.sort! { |x, y| y.length <=> x.length }\n array[0]\nend", "def LongestWord(sen)\n arr = sen.split(\" \")\n arr.sort! { |a, b| b.length <=> a.length }\n arr[0]\n\nend", "def get_the_shortest_word(str)\n str.split(\" \").sort! {|s, l| s.length <=> l.length}[0]\nend", "def least_frequent_word(str)\n words = str.split\n frequency = words.length\n min_word = \"\"\n\n words.each_with_index do |word, idx|\n if words.count(word) < frequency\n frequency = words.count(word)\n min_word = words[idx]\n end\n end\n min_word\nend", "def get_the_longest_word(str)\n str.split(\" \").sort! {|s, l| l.length <=> s.length}[0]\nend", "def getHighestAbilityLetterFrom pattern\n remainWords = []\n @currentBucket.each {|bucketWord|\n remainWords += [bucketWord] if pattern.match(bucketWord)\n }\n remainWords.each{|word|\n remainWords.delete word if (word.chars - @incorrectWord) != word.chars\n }\n remainWords = checkNewWords {|word| pattern.match(word)} if remainWords == []\n @currentBucket = remainWords\n\n dict = statisticLetter remainWords\n @missingWord.each {|letter| dict.delete letter}\n getSortListFrom dict\nend", "def score(word=@word)\n before = 0\n alph = @alph.dup\n counts = @counts.dup\n\n # For each position in the word find the number of words that are\n # before word being ranked given the prior letters.\n for i in (0...word.size)\n ind = alph.index(word[i])\n prior = 0\n\n # Count possible words starting with earlier letters in the alphabet\n for j in (0...ind)\n # Possible words ignoring letter repeats\n possible = (word.size - i - 1).factorial\n # Remove number of ways to reorganize each letter\n for k in (0...counts.size)\n if j == k\n possible /= (counts[k] - 1).factorial\n else\n possible /= (counts[k]).factorial\n end\n end\n prior += possible\n end\n before += prior\n\n # Adjust the alphabet to remove the consumed letter\n counts[ind] -= 1\n if counts[ind] == 0\n counts.delete_at(ind)\n alph.delete_at(ind)\n end\n end\n\n # Add one to the number of prior words to get the rank\n return before + 1\n end", "def most_common_letter(string)\n\ti = 0\n\tcount2 = 0\n\tarr = []\n\twhile(i < string.length)\n\t\tj = 0\n\t\tcount1 = 0\n\t\twhile(j < string.length)\n\t\t\tif(string[i] == string[j] && !arr.include?(string[j]))\n\t\t\t\tcount1 += 1\n\t\t\tend\n\t\t\tj += 1\n\t\tend\n\t\tif(count1 > count2)\n\t\t count2 = count1\n\t\t arr << string[i]\n\t\t most_num = [string[i],count2]\n\t\tend\t\n\t\ti += 1\n\tend\n\treturn most_num\nend", "def most_probable_next_word(string)\n words = string.split(\" \")\n bigram_key = words.last\n trigram_key = words.last(2).join(\" \") if words.count >= 2\n most_probable_word = \"\"\n\n ## if we can find trigram and trigram exists\n if words.count >= 2 and @trigrams[trigram_key] != nil\n # get w3 from grams with highest P(w1,w2,w3) = P(w1)*P(w2|w1)*P(w3|w1,w2)\n highest_probability = 0.0\n\n @unigrams.each_key do |word|\n tempProb = probability_of_sequence(trigram_key + \" \" + word)\n # if P(w1)*P(w2|w1)*P(w3|w1,w2) > highest_probability\n if tempProb > highest_probability\n highest_probability = tempProb\n most_probable_word = word\n end\n end\n\n puts \"ERROR IN TRIGRAMS\" if highest_probability == 0.0\n puts \"Trigram, highest_probability: \" + highest_probability.to_s + \" Perplexity: \" + perplexity(highest_probability, 3).round(4).to_s\n return most_probable_word\n ## if we can find a bigram and bigram exists\n elsif words.count >= 1 and @bigrams[bigram_key] != nil\n # get w2 from grams with highest P(w2|w1)\n highest_probability = 0.0\n\n @unigrams.each_key do |word|\n tempProb = probability_of_sequence(bigram_key + \" \" + word)\n # if P(w1)*P(w2|w1) > highest_probability\n if tempProb > highest_probability\n highest_probability = tempProb\n most_probable_word = word\n end\n end\n puts \"ERROR IN BIGRAMS\" if highest_probability == 0.0\n puts \"Bigram, highest_probability: \" + highest_probability.to_s + \" Perplexity: \" + perplexity(highest_probability, 2).round(4).to_s\n return most_probable_word\n ## return random unigram?\n else\n highest_probability = 0.0\n @unigrams.each_key do |word|\n tempProb = probability_of_sequence(word)\n # if P(w1)*P(w2|w1) > highest_probability\n if tempProb > highest_probability\n highest_probability = tempProb\n most_probable_word = word\n end\n end\n puts \"Unigram, highest_probability: \" + highest_probability.to_s + \" Perplexity: \" + perplexity(highest_probability, 1).round(4).to_s\n return most_probable_word\n end\n end", "def most_common_letter(string)\n idx = jdx = ctr = 0\n most = [ string[idx], 1 ]\n\n while idx < string.length # Iterate through string\n\n while jdx < string.length # Iterate through remainder of string\n\n if string[jdx] == string[idx] # Count matches\n ctr += 1\n end\n\n jdx += 1\n end\n\n if ctr > most[1] # If more common, update\n most = [string[idx], ctr]\n end\n\n jdx = idx += 1\n ctr = 0\n end\n\n return most\nend", "def high(x)\r\n x.split.max_by{|x| score_word(w)} end", "def highest_scoring_word\n return Scrabble::Scoring.highest_score_from(@plays)\n end", "def highest_word_score\n Scrabble::Scoring.score(Scrabble::Scoring.highest_score_from(@plays_array))\n end", "def highest_score_from(words)\n contestants = words.map{ |word| [word, score_word(word)] }.to_h\n\n winning_word = {word: \"\", score: 0}\n\n contestants.each do |word, score|\n if score > winning_word[:score]\n winning_word = {word: word, score: score}\n elsif score == winning_word[:score] \n if winning_word[:word].length == 10\n next\n elsif word.length == 10\n winning_word = {word: word, score: score}\n elsif word.length < winning_word[:word].length\n winning_word = {word: word, score: score}\n end\n end \n end\n return winning_word\nend", "def highest_word_score\n Scoring.score(highest_scoring_word)\n end", "def find_longest_word(input_string)\n array = input_string.split(\" \")\n array.max_by {|word| word.length}\nend", "def LongestWord(sen)\n words = sen.split(' ').map do |i|\n /[a-zA-Z0-9]+/.match(i)\n end\n\n longest = words.max_by.each do |i|\n i.to_s.length\n end\n\n longest\n\nend", "def most_common(string)\n # binding.pry\n arr = string.downcase.gsub(/[^a-z0-9\\s]/i, '').split(\" \")\n arr = arr.map { |x| x.downcase }\n words_hash = arr.group_by { |x| x }\n final_arr = []\n words_hash.each do |k,v|\n #binding.pry\n if v.length > 1\n final_arr << k\n end\n end\n p final_arr\nend", "def mcw(word)\n\t\tmostCommonWord = ''\n\t\tvalue = 0\n\t\t#determines if a word in a hash happens the most\n\t\t#p $bigrams[word]\n\t\t$bigrams[word].each do |x|\n\t\t\tif x[1] > value\n\t\t\t\tmostCommonWord = x[0]\n\t\t\t\tvalue = x[1]\n\n\t\t\t#if two hashes have the same value, then randomly chooses between the two\n\t\t\telsif x[1] == value\n\t\t\t\tchoice = Random.rand(2)\n\t\t\t\tif choice == 1\n\t\t\t\t\tmostCommonWord = x[0]\n\t\t\t\t\tvalue = x[1]\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\treturn mostCommonWord\n\tend", "def highest_scoring_word\n Scrabble::Scoring.highest_score_from(@plays_array)\n end", "def most_frequent_bigram(str)\n adjacent_letter={}\n letter=\"\"\n (0...str.length-1).each do |i|\n letter=str[i]+str[i+1]\n if adjacent_letter.has_key?(letter)\n adjacent_letter[letter]+=1\n else\n adjacent_letter[letter]=1\n end\n end\n\n max=0\n max_aj=\"\"\n adjacent_letter.each do |k,v|\n if v>max\n max=v\n max_aj=k\n end\n end\n max_aj\n\n\nend", "def highest_scoring_word\n \tScoring.highest_score_from(@words_played)\n end", "def highest_score_from(words)\n winner = {\n word: \"\",\n score: 0,\n }\n\n words.each do |word|\n if score_word(word) > winner[:score]\n winner = { word: word, score: score_word(word) }\n elsif score_word(word) == winner[:score]\n if ((word.length < winner[:word].length) || (word.length == 10)) && (winner[:word].length != 10)\n winner = { word: word, score: score_word(word) }\n end\n end\n end\n return winner\nend", "def best_match(given_word)\n words = (@word_list.is_a? Array) ? @word_list : @word_list.keys\n\n word_bigrams = bigramate(given_word)\n word_hash = words.map do |key|\n [key, bigram_compare(word_bigrams, bigramate(key))]\n end\n word_hash = Hash[word_hash]\n\n # Weight by word usage, if logical\n word_hash = apply_usage_weights(word_hash) if @word_list.is_a? Hash\n\n word_hash.max_by { |_key, value| value }.first\n end", "def highest_scoring_word\n Scoring.highest_score_from(plays)\n end", "def most_common_letter(string)\n \n idx = 0 \n while idx < string.length\n letter = string[idx]\n count = 0\n \n idx1 = 0\n while idx1 < string.length\n \n if string[idx1] == letter\n count += 1\n end\n \n idx1 += 1\n end\n \n idx += 1\n end\n\n puts [letter, count] \n return [letter, count]\nend", "def most_vowels(str)\n words = str.split(\" \")\n hash = Hash.new(0)\n words.each do |word|\n hash[word] = vowel_count(word)\n end\n sorted_hash = hash.sort_by { |key, val| val} # [[\"a\", 1], [\"what\", 1], [\"life\", 2], [\"wonderful\", 3]]\n return sorted_hash[-1][0]\nend", "def LetterCount(str)\n mayor = 0 \n arr = []\n \n str.split(\" \").each do |word|\n if (CountMax(word) > mayor)\n mayor = CountMax(word)\n arr << word \n end\n end\n \n # code goes here\n return (CountMax(arr.last) <= 1)? -1 : arr.last\n \n \nend", "def most_common_vowel(string)\n\t\n\tvowels = Hash.new 0\n\tsplitted_string = string.split(\"\")\n\tvowels_hash = Hash.new\n\tsplitted_string.each do |letter|\n\t\tvowels[letter] += 1\n\tend\n\t\t\n\tvowels.each do |key,value| \n\t\t\n\t\tif key == \"a\" \n\t\t\tvowels_hash[key] = value\n\t\telsif key == \"e\" \n\t\t vowels_hash[key] = value\n\t\telsif key == \"i\" \n\t\t vowels_hash[key] = value\n\t\telsif key == \"o\" \n\t\t vowels_hash[key] = value\n\t\telsif key == \"u\" \n\t\t vowels_hash[key] = value\n\t\telsif key == \"y\"\n\t\t\tvowels_hash[key] = value\n\t\tend\n\t\t\n\t\t\n\tend\n\t top_letter = \"\"\n\t\tmax_letter = vowels_hash.max_by { |k, v| v}\n\t\tmax_letter.first\nend", "def most_frequent_bigram(str)\n bigrams_hash = biagram_hash(str)\n bigrams_hash.key(bigrams_hash.values.max)\nend", "def most_vowels(sentence)\n\tvowels = \"aeiou\"\n \tresult = Hash.new(0)\n \twords = sentence.split(\" \")\n\n \twords.each do |word|\n word.each_char do |c|\n if vowels.include?(c)\n result[word] += 1\n end\n end\n end\n\n \tlargest = 0\n \tthe_word = \"\"\n \tresult.each do |k, v|\n if v > largest\n largest = v\n the_word = k\n end\n end\n \treturn the_word\n\nend", "def most_frequent_bigram(str)\n pairs = Hash.new(0)\n str.each_char.with_index do |letter, indx|\n if indx != str.length-1\n pair = letter + str[indx+1]\n end\n pairs[pair] += 1\n end\n pairs.key(pairs.values.max)\nend", "def most_common_letter(string)\nletters = string.split(\"\")\n# Making a new hash \nfrequencies = Hash.new (0)\n# Add one to the key's value every time the key appears\nletters.each { |letter| frequencies|letter| += 1 }\n# Sorting frequencies by the value of letter \nfrequencies = frequencies.sort_by do |letters, letter| \n letter\nend\n \n puts letters + \" \" + letter \nend", "def most_frequent_bigram(str)\n hash = Hash.new(0)\n str.each_char.with_index do |char, idx|\n hash[str[idx..idx+1]] += 1\n end\n max = 0\n max_bigram = \"\"\n hash.each_pair do |key, value|\n if value > max\n max_bigram = key\n max = value\n end\n end\n return max_bigram\nend", "def letter_per_word(array,letter)\n array.max\nend", "def longest_string(list_of_words)\n list_of_word = list_of_words.sort_by { |x| x.length }\n return list_of_word[-1]\nend", "def longest_duplicated_letter(str)\n return if str.nil? || str.empty?\n max = 0\n k = 0\n sum = 1\n candidate = str[0]\n (1...str.size).each do |i|\n if str[i] == candidate \n sum += 1\n if max < sum\n k = i\n max = sum\n end\n else\n candidate = str[i]\n sum = 1\n end\n end\n [max,str[k]]\nend", "def good_word(wordlist)\n # letter frequency\n freqs = Hash.new { |h,k| h[k] = 0 }\n wordlist.each do |w|\n w.chars.each { |c| freqs[c] += 1 }\n end\n\n # score = number of unique chars X sum of letter frequencies\n wordlist.max_by do |w|\n chars = w.chars.to_a.uniq\n chars.length * chars.map{|c| freqs[c]}.inject{|sum,n| sum + n}\n end\nend", "def most_frequent_occurrence(str)\n lower_str = str.downcase\n letters = {}\n most_frequent = []\n\n for i in 0..lower_str.length - 1\n if letters[lower_str[i]]\n letters[lower_str[i]] += 1\n else\n letters[lower_str[i]] = 1\n end\n end\n\n letters.each do |key, value|\n if most_frequent.length == 0 || letters[key] > most_frequent[1]\n most_frequent = [key, value]\n end\n end\n\n return most_frequent[0]\nend", "def LetterCount(str)\n\n \n words = str.split(\" \")\n most = \"\"\n count = 0\n \n words.each do |word|\n hash = Hash.new(0)\n word.split(\"\").each {|letter| hash[letter] += 1} #must split word\n repeats = hash.select {|letter, count| count >= 2}.size\n if repeats > count\n count = repeats\n most = word\n end\n \n end\n \n return most\n \nend", "def most_common_letter(string)\n\t\n\t\n\tarr = string.split(\"\")\n\tletters = Hash.new\t\n\t\n\tarr.each do |x|\n\tletters[x] = arr.count[\"x\"]\n end\n\tputs letters\n\nend", "def LongestWord(sen)\n str = sen.split(\" \")\n longest_word = str[0]\n str.each do |word|\n word.sub(/[\\w\\s]/, '')\n if longest_word.length < word.length\n longest_word = word\n end\n end\n longest_word\nend", "def english(str)\n result = []\n arr = str.split(' ')\n result << arr.uniq.group_by { |v| arr.count(v) }.max.last.join\n result << arr.max_by{ |x| x.length } \nend", "def letter_count(string)\n\narray = string.split(' ')\nmax_word = \"\"\nmax_counter = 0\n\ni = 0\nwhile i < array.length #loop through sentence\n\tk = 0\n\tcounter = 0\n\trepeats = []\n\twhile k < array[i].length #loop through each letter in each word\n\t\tletter = array[i][k]\n\n\t\tj = k+1\n\t\t\twhile j < array[i].length #compare each letter to the rest\n\t\t\t\tif letter == array[i][j] && repeats.include?(letter) == false\n\t\t\t\n\t\t\t\t\trepeats.push(letter)\n\t\t\t\tend\n\n\t\t\t\tj += 1\n\t\t\tend\n\t\tk += 1\t\n\tend\n\t\n\tif repeats.length > max_counter \n\t\tmax_counter = repeats.length\n\t\tmax_word = array[i]\n\tend\n\n\ti += 1\nend\n\nif max_counter == 0\n\treturn -1\nend\n\nreturn max_word\nend", "def guess\n letters = @possible_letters.collect {|letter| [ score_for(letter),letter ]}\n letter = letters.min {|letter1,letter2| letter1 <=> letter2 }\n letter[1]\n end", "def score_word(word)\n word_letters = make_word_array(word)\n score = 0\n word_letters.each do |letter|\n score += LETTER_SCORES[letter]\n end\n score += 8 if word.length >= 7 && word.length <= 10\n return score\nend", "def LongestWord(sen)\n arr = sen.split(' ')\n longest = arr[0]\n arr.each do |word|\n if word.length > longest.length\n longest = word\n end\n end\n return longest\nend", "def longest_word(sen)\n words = sen.split\n words.map! { |word| word.delete('^A-Za-z1-9_\\'') }\n longest = words.first\n words.each_with_index do |word, idx|\n next if idx >= words.size - 1\n longest = longest.size < words[idx + 1].size ? words[idx + 1] : longest\n end\n longest\nend", "def most_frequent_bigram(str)\n\n new_hash = Hash.new(0)\n str.each_char.with_index do |ele, i|\n if i < (str.length - 1)\n new_hash[ele + str[i +1]] += 1\n end\n end\n # p new_hash.values.max\n new_hash.each do |k, v|\n if new_hash.values.max == v\n return k\n end\n end\n\nend", "def most_used_letter\n s1 = @text.gsub(/[^a-z]/, '')\n arr= s1.split('')\n arr1 = arr.uniq #rids chars array of duplicates\n arr2 = {}\n\n #makes an object with a count of all unique characters\n arr1.map do |c|\n arr2[c] = arr.count(c) #count searches an array and returns the number of occurrances of the specified element\n end\n\n #to start the following loop with the first key/value pair of arr2\n biggest = { arr2.keys.first => arr2.values.first }\n arr2.each do |key, value|\n if value > biggest.values.first\n biggest = {}\n biggest[key] = value\n end\n end\n\n biggest\nend", "def solve(words, letters)\n hash = Hash.new(0)\n hash2 = Hash.new(0)\n letters.each_char do |char|\n hash[char] += 1\n end\n \n longest = 0\n \n words.each_with_index do |word, idx|\n word.each_char.with_index do |char, idx|\n if !hash[char] || hash[char] <= 0\n next\n end\n if hash[char] > 0\n hash[char] -= 1\n end\n end\n \n end\n return longest\nend", "def most_common_letter(string)\n # #create array, letter and count to return \n # mostCommon = []\n # count = 0\n # #assign the first letter to a variable\n # i = 0\n # #loop through array\n # while i < string.length\n # count = string.count(string[i])\n # for j in string\n # #count how many times that first letter exists\n # if string.count(j) > count\n # #count how many times the second letter exists\n # mostCommonLetter = j\n # count = string.count(j)\n # #if first is greater, make it mostcommon\n # end \n # #if second is greater, make it most common\n # end \n # end\n \n #loop through array\n i = 0\n j = 0\n counter = 0\n greatestCount = 0\n #for every element, keep a tally counter\n while i < string.length\n j = 0\n #loop through the array and count how many times this char occurs\n while j < string.length\n if string[i] == string[j]\n counter += 1\n end \n j += 1\n end \n #if it is greater than the last count\n if counter > greatestCount \n #reassign it to the last count\n greatestCount = counter\n #put the char and the count in an array\n mostCounted = [string[i], greatestCount]\n end \n counter = 0\n i += 1\n end \n #return array\n return mostCounted\nend", "def max_letter_frequency_per_word(sentence)\n\tnumbers_larger_than(letter_per_word(words_longer_than(sentence, 3), \"e\"))\nend", "def most_common_vowel(string)\n hash = Hash.new(0)\n vowels = \"aeiou\".chars\n string.chars do |letter|\n if vowels.include?(letter)\n hash[letter] += 1\n end\n end\n #Sort based on key then find max based on value\n #It returns as array [key, value]. so we take the 1st index:\n hash.sort_by {|key, value| key}.max_by {|key, value| value}[0]\n # could also use .last method after sort to find max\nend", "def find_shortest_words(str)\n words = str.downcase.split(/[^a-z0-9]/)\n words = words.sort_by {|word| word.size}\n shortest = []\n\n words = words.select {|word| word.size > 0}\n\n size = words[0].size\n words.each do |word|\n break if word.size > size\n shortest << word\n end\n shortest.sort\nend", "def mcw(inWord)\n\tsubsequent_words = $bigrams[inWord]\n\tmost_common_word = subsequent_words.max_by{|k,v| v}\n\n\t# If the word pulled from the hash is not nil return the key from the key value pair\n\tif not most_common_word.nil?\n\t return most_common_word[0]\n\telse\n\t\treturn nil\n\tend\nend" ]
[ "0.82453847", "0.8169409", "0.8084587", "0.80545866", "0.8015876", "0.790732", "0.7879747", "0.7776403", "0.77014893", "0.76093554", "0.7572922", "0.7511308", "0.74876714", "0.74689996", "0.74571675", "0.745092", "0.74367625", "0.74190664", "0.7389264", "0.73663265", "0.7324809", "0.73176545", "0.7308551", "0.730764", "0.72661155", "0.72633636", "0.7256291", "0.72431386", "0.7229162", "0.72193646", "0.7136525", "0.71319604", "0.7130012", "0.7109947", "0.71074694", "0.7106478", "0.70813924", "0.7075112", "0.7055059", "0.7050168", "0.7046643", "0.703555", "0.7016223", "0.6976057", "0.6973711", "0.69721484", "0.69713145", "0.69297874", "0.6928296", "0.6925603", "0.6915494", "0.6904723", "0.690375", "0.6899725", "0.6897311", "0.6896706", "0.68790346", "0.6875869", "0.68701494", "0.68656665", "0.686155", "0.6850744", "0.6828534", "0.6817611", "0.6816993", "0.6814683", "0.6797645", "0.67829555", "0.67704743", "0.67644036", "0.6753181", "0.6746334", "0.6738723", "0.67212427", "0.67183834", "0.6711912", "0.6692441", "0.66886157", "0.6682656", "0.66824114", "0.6680021", "0.66789585", "0.667621", "0.6670605", "0.66578853", "0.66555554", "0.6629086", "0.66148394", "0.66114765", "0.66035795", "0.65919137", "0.6588448", "0.65857625", "0.6583613", "0.65763235", "0.65761244", "0.6555642", "0.65501696", "0.65461165", "0.65393996", "0.6536629" ]
0.0
-1
A palindrome is a word or sequence of words that reads the same backwards as forwards. Write a method that returns the length of the longest palindrome in a given string. If there is no palindrome longer than two letters, return false.
def longest_palindrome(string) longest_palindrome = false i = 0 while i < string.length - 1 j = i + 1 while j < string.length curr_string = string[i..j] len = curr_string.length if is_palindrome?(curr_string) longest_palindrome = len if !longest_palindrome || len > longest_palindrome end j += 1 end i += 1 end longest_palindrome end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def longest_palindrome(string)\n string.length.downto(3) do |length|\n string.chars.each_cons(length) do |substr_arr|\n return substr_arr.length if palindrome?(substr_arr.join)\n end\n end\n false\nend", "def longest_palindrome(string)\n\tcurrent_longest = \"\"\n\tif string.length < 3\n\t\treturn false\n\tend\n\t#This represents the overarching iteration through the string. \n\t#As a string must be at least length 3 to be a palindrome, no search is necessary\n\t#for the last 2 letters of the string\n\tfor x in 0...string.length-2 do\n\t\t#Note: Need to ensure that every matching letter is checked\n\t\t#First part of conditional removes spaces from consideration for palindrome-ness\n\t\tif string[x] != \" \" && string.slice(x+1...(string.length)).include?(string[x])\n\t\t\tsubstring = string.slice(x..(string.rindex(string[x])))\n\t\t\tif Palindrome?(substring) && substring.length > current_longest.length\n\t\t\t\tcurrent_longest = substring\n\t\t\t\t#If the longest palindrome is the entire string itself, return it\n\t\t\t\tif current_longest.length == string.length\n\t\t\t\t\treturn current_longest\n\t\t\t\tend\n\t\t\tend\n\t\t\t#Check the substring, without the last matched letter for palindrome\n\t\t\t#This is to account for second matched letters, but wastes runtime on\n\t\t\t#Some unnecessary operations\n\t\t\tsub_test = longest_palindrome(string.slice(x...(string.rindex(string[x]))))\n\t\t\tif sub_test && sub_test.length > current_longest.length\n\t\t\t\tcurrent_longest = sub_test\n\t\t\tend\n\t\tend\n\tend\n\treturn current_longest.length > 0 ? current_longest : false\nend", "def longest_palindrome(string)\n longest = ''\n i = 0\n while i < string.length\n j = 1\n while (i + j) <= string.length\n x = string.slice(i, j)\n if (x == x.reverse) && (x.length > longest.length)\n longest = x\n end\n j += 1\n end\n i += 1\n end\n if longest.length == 1\n return false\n end\n longest.length\n\nend", "def longest_palindrome(string)\n \nend", "def longest_palindrome(string)\n string_arr = string.split(\"\")\n longest = 0\n substring = \"\"\n\n while string_arr.length > 0\n string_arr.each do |char|\n substring << char\n palindrome?(substring) && substring.length > longest ? longest = substring.length : next\n end\n\n string_arr.shift\n substring = \"\"\n end\n \n longest\nend", "def longest_palindrome(string)\n pal_arr = get_palindromes(string)\n return false if pal_arr.empty?\n sorted_arr = pal_arr.sort_by {|el| el.length}\n \n sorted_arr[-1].length\n \n \nend", "def longest_palindrome(string)\n\ti = 0\n\tlongest = \"\"\n\twhile i < string.length\n\t\tcurrent_palindrome = \"\"\n\t\tj = 1\n\t\twhile j <= string.length\n\t\t\tif palindrome?(string.slice(i,j))\n\t\t\t\tcurrent_palindrome = string.slice(i,j)\n\t\t\tend\n\n\t\t\tif longest == \"\" || current_palindrome.length > longest.length\n\t\t\t\tlongest = current_palindrome\n\t\t\tend\t\n\t\t\tj += 1\n\t\tend\n\t\ti += 1\n\tend\n\tlongest\nend", "def longest_palindrome(string)\nend", "def longest_palindrome(str)\n \nend", "def longest_palindrome(str)\r\n pal = \"\"\r\n (0..str.size).each do |x|\r\n i = 1\r\n while (i < (str.size-x)) do\r\n\t if str[x,i].reverse == str[x,i]\r\n\t pal = str[x,i] if pal.size < str[x,i].size\r\n\t end\r\n\t i+= 1\r\n\tend\r\n end\r\n pal\r\nend", "def longest_palindrome(string)\n\nend", "def longest_palindrome(string)\n\nend", "def longest_palindrome(string)\n\nend", "def longest_palindrome(string)\n for substring_length in string.length...3\n for check in 0..(string.length - sub_string)\n possible_palindrome = string[check...check+substring_length]\n if palindrome(possible_palindrome)\n return possible_palindrome\n end\n end\n end\n return false \nend", "def longest_palindrome(s)\n result = ''\n \n for i in (0..s.length-1) do\n for j in (i..s.length-1) do \n result = s[i..j] if s[i..j].length > result.length && s[i..j] == s[i..j].reverse\n end\n end\n \n result\nend", "def longest_palindrome s\n return 0 if s.empty?\n (s.length).downto(1).each do | i |\n s.split(\"\").each_cons(i).map do |c|\n return c.count if c == c.reverse\n end\n end\nend", "def find_longest_palindrome(string)\n l = string.size\n l.downto(0) { |i|\n 0.upto(l) { |j|\n s = string.slice(j,i)\n return s if s == s.reverse && s.size > 1\n }\n }\nend", "def longest_palindrome(s)\n max = \"\"\n 0.upto(s.size - 1).each { |i|\n odd = palindrome(s, i, i)\n even = palindrome(s, i, i + 1)\n \n return s if odd.size == s.size || even.size == s.size\n max = odd if odd.size > max.size\n max = even if even.size > max.size\n }\n\n max \nend", "def longest_palindrome(str)\n\nend", "def longest_palindrome(string)\n longest = \"\"\n i = 0\n j = 0\n\n while i < string.length\n while j < string.length\n if is_palindrome?(string[i..j]) && string[i..j].length > longest.length\n longest = string[i..j]\n end\n j += 1\n end\n i += 1\n j = i + 1\n end\n\n longest\nend", "def longest_palindrome(string)\n best_palindrome_start = 0\n best_palindrome_len = 0\n\n 0.upto(string.length - 1).each do |start|\n # micro-optimization: don't look at substrings shorter than best\n # palindrome.\n len = best_palindrome_len + 1\n while start + len <= string.length\n if is_palindrome?(string, start, len)\n best_palindrome_start, best_palindrome_len = start, len\n end\n\n len += 1\n end\n end\n\n [best_palindrome_start, best_palindrome_start + best_palindrome_len - 1]\nend", "def longest_palindrome(string)\n if string.length <= 1\n return string\n end\n\n i = 0\n string.length.downto(1).each do |length|\n # .. is inclusive\n (0..i).each do |start_index|\n if palindrome?(string.slice(start_index, length))\n return string.slice(start_index, length)\n end\n end\n\n i += 1\n end\n\n string[0]\nend", "def largest_palindrome(string)\n palindromes(string).max {|a, b| a.size <=> b.size }\nend", "def naive_longest_palindrome(s)\n longest = s[0]\n s.each_char.with_index do |ch_i, i|\n s.each_char.with_index do |ch_j, j|\n next if j < i\n possible_pal = s[i..j]\n if is_palindrome?(possible_pal)\n longest = possible_pal.length > longest.length ? possible_pal : longest\n end\n end\n end\n longest\nend", "def longest_palindrome(s)\n return '' if s == ''\n arr = s.chars\n\n s.length.downto(1) do |char|\n palindrome = arr.each_cons(char).find { |tested| tested == tested.reverse }\n return palindrome.join if palindrome\n end\nend", "def longest_palindrome(string)\n # Create a variable to store our results to be returned\n best_palindrome = nil\n \n # Loop through our string\n i = 0\n while i < string.length # to go through each letter in the string\n # create local variable\n length = 1 # assign first length to 1\n \n # Create second loop\n while (i + length) <= string.length # to slice out out the substring 0 + 1 <= 5\n # local variable\n substring = string.slice(i, length) # to define the substring string.slice(0, 1) => ab\n \n if palindrome?(substring) && (best_palindrome == nil || substring.length > best_palindrome.length)\n best_palindrome = substring\n end\n # substring becomes new best_palindrome if it meets 2 requirements:\n # 1. it is a palindrome\n # 2. it's (nil = to the first substring as best_palindrome) OR new substring is longer than current logest substring.\n \n length += 1 # increment length of substring at each starting index. (i.e. a, ab, abc, abcd, etc...)\n end\n \n i += 1 # then increment i to set each letter as startign index. (i.e. abcd, bcbd, cbd, etc...)\n end\n \n return best_palindrome\n end", "def longest_palindrome(string)\n\n palindromes = []\n\n (0...string.length).each do |i|\n (i+1...string.length).each do |j|\n sub = string[i..j]\n palindromes << sub if sub == sub.reverse\n end\n end\n\n palindromes.sort_by(&:length).last \n\nend", "def longest_palindrome(string)\n largest = ''\n (0...string.length).each do |i|\n (i + 1...string.length).each do |j|\n sub_str = string[i..j]\n if sub_str == sub_str.reverse\n if sub_str.length > largest.length\n largest = sub_str\n end\n end\n end\n end \n largest\nend", "def longest_palindrome(string)\n longest = \"\"\n len = 2\n \n while len < string.length\n i = 0\n while i+len <= string.length\n if is_palindrome?(string[i...i+len])\n longest = [i, i+len-1]\n end\n i += 1\n end\n len += 1\n end\n\n longest\nend", "def longest_palindrome(str)\n return 0 if str.empty?\n\n arr = str.chars\n substrings = []\n length = 1\n loop do\n arr.each_cons(length) { |set| substrings << set }\n length += 1\n break if length > arr.length\n end\n substrings.select { |set| set == set.reverse }.max_by(&:length).length\n p substrings\nend", "def palindrome(string)\n (string.length <= 1) || ((string[0, 1] == string[-1, 1]) && palindrome(string[1..-2]))\nend", "def palindrome?(string)\n if string.size <= 1\n true\n else\n string[0] == string[-1] && palindrome?(string[1..-2])\n end\nend", "def palindrome?(string)\n return true if string.length == 1\n return true if string.length == 2 && string[0] == string[1]\n return true if string[0] == string[string.length-1] && palindrome?(string[1...-1])\n false\nend", "def is_palindrome(s)\n return is_palindrome(s, 0, s.length - 1 )\nend", "def longest_palindrom(str)\n return str if str.length <= 1\n\n result = ''\n (0...str.length - 1).each do |i|\n ((i + 1)...str.length).each do |j|\n substr = str[i, j]\n result = substr if is_palindrom?(substr) && (result.length < substr.length)\n end\n end\n result\nend", "def palindrome?(str)\n n = str.size / 2\n (0..n).all? do |i|\n str[i] == str[str.size-1-i]\n end\nend", "def palindrome?(str)\n matches = []\n str.size.times { |index| matches << (str[index] == str[-(index+1)]) }\n matches.all?(true) && matches.size > 1\nend", "def is_palindrome?(string)\n (0...((string.length) / 2)).each do |left|\n return false unless string[left] == string[-(left + 1)]\n end\n return true\nend", "def longest_palindrome(str)\n result = [0, \"\"]\n for i in (0..str.length - 1)\n p1 = expand(str, i, i) \n result = result[0] > p1.length ? result : [p1.length, p1]\n p2 = expand(str, i, i + 1) \n result = result[0] > p2.length ? result : [p2.length, p2]\n end\n result[1]\nend", "def palindrome?(word)\n array_of_letters = word.downcase.split(\"\")\n count_front = 0\n count_back = word.length - 1\n # Match the first letter with the last, if they are the same then step through the word\n while count_front < count_back\n if array_of_letters[count_front] == array_of_letters[count_back]\n count_front += 1\n count_back -= 1\n else\n return false\n end\n end\n return true\nend", "def longest_palindrome(string)\n length = string.length\n while true\n (0..(string.length - length)).each do |i|\n word = string[i...(i + length)]\n return [i, (i + length - 1)] if is_palindrome?(word)\n end\n length -= 1\n end\nend", "def check_palindrome(s)\n for i in 0...(s.length/2).floor\n if s[i] != s[s.length-i-1]\n return false\n end\n end\n return true\nend", "def palindrome (word)\n if word.length == 1 || word.length == 0 #baseline, where it ends\n true\n else\n if word[0] == word[-1]\n palindrome(word[1..-2])\n else\n false\n end\n end\nend", "def palindrome?(str)\n (str.length - 1).downto(0).map { |i| str[i] }.zip(str.chars).all? { |a, b| a == b }\nend", "def longest_palindrome(s)\n left = 0\n right = 0\n for i in 0...s.length do\n odd = length_from_center(s, i, i)\n even = length_from_center(s, i, i + 1)\n longest = [odd, even].max\n if longest > right - left\n left = i - (longest - 1) / 2\n right = i + longest / 2\n end\n end\n return s[left..right]\n end", "def is_palindrome(s)\n if s.length < 2\n return true\n elsif s[0] != s[-1]\n return false\n else\n return is_palindrome(s[1..-2])\n end\nend", "def palindrome (word)\n word.length.times do |n|\n if (word[n] != word[word.length - n - 1]) \n return false\n end\n end\n return true\nend", "def is_palindrome(s)\n return true if s.length <= 1\n return pal(s, 0, (s.length - 1))\nend", "def is_palindrome?(string)\n counter = 0\n \n if string.length == 0 || string.length == 1\n return counter\n elsif string[0]==string[-1]\n is_palindrome?(string[1..-2])\n counter += 1\n\n elsif string[0]!=string[-1]\n is_palindrome?(string[1..-1]) \n\n else\n false\n end \nend", "def valid_palindrome(str)\n l_ndx = 0\n r_ndx = str.size - 1\n while l_ndx < r_ndx\n unless str[l_ndx] == str[r_ndx]\n return palindromic?(str, l_ndx, r_ndx - 1) || palindromic?(str, l_ndx + 1, r_ndx)\n end\n\n l_ndx += 1\n r_ndx -= 1\n end\n\n true\nend", "def is_palindrome(s)\n if s.length <= 1\n return true\n end\n\n if s[0] != s[-1]\n return false\n end\n return is_palindrome(s[1...-1])\nend", "def is_palindrome?(string)\n if string.length == 1 || string.length == 0\n true\n else\n if string[0] == string[-1]\n is_palindrome?(string[1..-2])\n else\n false\n end\n end\nend", "def is_palindrome(s)\n if s.length < 2\n return true\n elsif s[0] != s[-1]\n return false\n else\n return is_palindrome(s[1..-2])\n end\nend", "def is_palindrome(word)\n forward = 0\n backword = word.length - 1\n while forward <= backword\n if word[forward] != word[backword]\n return false\n end\n forward += 1\n backword -= 1\n end\n return true\nend", "def almost_palindrome_checker(string)\n p1 = 0\n p2 = string.length - 1\n array = string.split('')\n\n while p1 < p2\n return palindrome_checker(array, p1, p2 - 1) || palindrome_checker(array, p1 + 1, p2) if array[p1] != array[p2]\n\n p1 += 1\n p2 -= 1\n end\n\n true\nend", "def palindrome? x\n # convert into string\n y = x.to_s\n look = y.length / 2\n y[0..(look-1)] == y[-look..-1].reverse\nend", "def palindrome?(str)\n length = str.length\n half1 = str.slice(0, length/2)\n if length.odd?\n half2 = str.slice(length/2 + 1, length)\n else\n half2 = str.slice(length/2, length)\n end\n half1 === half2.reverse\nend", "def palindrome_r(word)\n if word.length == 1 or word.length == 0\n true\n else\n if word[0] == word[-1]\n palindrome_r(word[1..-2])\n else\n false\n end\n end\nend", "def palidrome?(word)\n j = word.length - 1\n half_length = word.length / 2\n\n half_length.times do |i|\n if word[i] != word[j]\n return false\n end\n j -= 1\n end\n\n return true\nend", "def is_palindrome(str)\n return false if str.empty?\n 0.upto(str.size / 2) do |i|\n return false if str[i] != str[-i - 1]\n end\n return true\nend", "def is_palindrome(s)\n if s.length == 0 || s.length == 1\n return true\n else\n first_and_last_match = (s[0] == s[-1])\n s[0] = ''\n s[-1] = ''\n return first_and_last_match && is_palindrome(s)\n end\nend", "def is_palindrome(s)\n return true if s.length <= 1\n return s[0] == s[-1] && is_palindrome(s[1,s.length - 2])\nend", "def palyndrome?(str)\n (0..( (str.size - 1) / 2 )).each do |i|\n return false if str[i] != str[ str.size - 1 - i ]\n end\n true\n end", "def palindrome?(string)\n\n idx1 = 0\n idx2 = -1\n\n while idx1 < string.length\n if string[idx1] != string[idx2] \n return false\n end\n\n idx1 += 1\n idx2 -= 1\n end\n\n return true\nend", "def is_palindrome(s)\n return true if s.length <= 1\n return false if s[0] != s[-1]\n return is_palindrome(s[1...-1])\nend", "def is_palindrome(s)\n return true if s.length <= 1\n return false if s[0] != s[-1]\n return is_palindrome(s[1...-1])\nend", "def palindrome?(string)\n first = 0\n last = string.length - 1\n \n while first < last do\n return false if string[first] != string[last]\n first += 1\n last -= 1\n end\n true\nend", "def is_palindrome(s)\n return true if s.empty?\n return false if s[0] != s[-1]\n return is_palindrome(s[1...-1])\n \n # To do this without creating new strings, make a helper method\n # that accepts additional parameters for left_char and right_char and increments\n # them inward each time, like I did for reverse_in_place with helper_reverse\nend", "def is_palindrome(s)\n return true if s.length == 0\n return palindrome_helper(s, 0, s.length - 1)\nend", "def palindrome(string)\n if string.length == 1 || string.length == 0\n true\n elsif string[0] == string[-1]\n palindrome(string[1..-2])\n else\n false\n end\nend", "def is_palindrome(s) \n return true if s.length < 2\n return false if s[0] != s[-1]\n\n return is_palindrome(s[1..-2])\nend", "def palindrome?(str)\n i = 0\n while i < str.length/2\n if str[i] != str[str.length - i - 1]\n return false\n end\n i = i + 1\n end\n return true\nend", "def is_palindrome(s)\n if s.length < 2 \n return true \n elsif s[0] != s[-1]\n return false\n else \n return is_palindrome(s[1..-2])\n end\nend", "def longest_palindrome(s)\n return s if s.length == 1\n previous = s[0]\n\n all_same = true\n z = 0\n counter = 0\n while z < s.length\n if s[z] == previous\n counter += 1\n else\n tmp_longest = previous * counter\n longest = tmp_longest if tmp_longest.length > longest.length\n previous = s[z]\n counter = 1\n break if counter > s.length / 2\n end\n z += 1\n end\n return previous * counter if all_same || counter > s.length / 2\n\n longest = ''\n i = 0\n while i < s.length\n starting_letter = s[i]\n matching_hash = {}\n matching_hash[i] = starting_letter\n\n j = i + 1\n while j < s.length\n if s[j] == starting_letter\n matching_hash[j] = s[j]\n end\n j += 1\n end\n\n i += 1\n\n indices = matching_hash.keys\n next if indices.length == 1\n next if (indices[-1] - indices[0]) < longest.length\n\n first_index = matching_hash.first[0]\n\n k = 0\n valid_sequence = true\n while k < (indices.length / 2 - 1)\n first_dist = indices[k + 1] - indices[k]\n second_dist = indices[indices.length - 1 - k] - indices[indices.length - 2 - k]\n if first_dist != second_dist\n valid_sequence = false\n break\n end\n k += 1\n end\n\n next if !valid_sequence\n\n matching_hash.delete_if {|key,v| (key != first_index) && (key - first_index < longest.length)}\n indices = matching_hash.keys\n\n n = 1\n last_index = indices[-1]\n running_str = ''\n while first_index + n < ((last_index - first_index) / 2)\n matching_hash.each do |key, v|\n if key == first_index\n running_str = matching_hash[key] << s[key + n]\n else\n checking_str = matching_hash[key] << s[key - n]\n matching_hash.delete(key) if checking_str != running_str\n end\n end\n n +=1\n end\n\n matching_hash.values.each do |value|\n longest = value if value.length > longest.length\n end\n end\n puts \"longest: #{longest}\"\n return longest\nend", "def palindrome?\n str = self.to_s\n len = str.size\n\n if len.odd?\n str[0, len/2] == str[len/2 + 1, len/2].reverse\n else\n str[0, len/2] == str[len/2, len/2].reverse\n end\n end", "def is_palindrome(s)\n\tl = 0\n\tr = s.length - 1\n\treturn pal_helper(s, l, r)\nend", "def is_palindrome(s)\n if s.length == 0\n return true\n else \n if s[0] == s[-1]\n return is_palindrome(s[1..-2])\n else\n return false\n end\n end\nend", "def palindrome1?(str)\n if str.size <= 1\n true\n else\n str[0] == str[-1] ? palindrome1?(str[1..-2]) : false\n end\nend", "def palindrome(string)\n return true if string.length <= 1\n\n if string[0] == string[-1]\n palindrome(string[1..-2])\n else\n false\n end\nend", "def is_palindrome(string)\n joined_str = string.gsub(/[^0-9a-z]/i, '').downcase\n reverse_str = reverser(joined_str.clone)\n difference_count = 0\n joined_str.length.times do |i|\n difference_count += 1 if joined_str[i] != reverse_str[i]\n end\n\n if difference_count != 0\n return false\n else\n return true\n end\n\nend", "def palindrome?(pal_str)\n char_list = pal_str.split\n reverse_list = Array.new\n char_list.length.times do\n reverse_list.push(char_list.pop) unless char_list == []\n end\n reversed_string = reverse_list.join('')\n true if pal_str == reversed_string\nend", "def palindrome(str)\n if str.length == 1 || str.length.zero?\n true\n elsif str[0] == str[-1]\n palindrome(str[1..-2])\n else\n false\n end\nend", "def word_palindrome(word)\n\n index = 0\n end_point = -1\n\n while index < word.length/2\n return false if word[index] != word[end_point-index]\n index+=1\n end\n return true\n\nend", "def palindrome?(substr)\n substr == substr.reverse && substr.length > 1\nend", "def is_palindrome(s)\n if s == \"\"\n return true\n end\n if s[0] != s[-1]\n return false\n end\n return is_palindrome(s[1...-1])\nend", "def is_palindrome(s)\n if s.length <= 1\n return true\n elsif s[0] != s[-1] \n return false\n else \n return is_palindrome(s[1..-2])\n end \nend", "def palindrome(str)\n return true if str.size == 1 || str.size == 0 # base case\n if str[0] == str[-1]\n palindrome(str[1..-2]) # getting closer to base case\n else\n false\n end\nend", "def is_palindrome?(string)\n i = 0\n\n while i < string.length / 2\n if string[i] != string[string.length - 1 - i]\n return false\n end\n i += 1\n end\n\n return true\nend", "def is_palindrome(s)\n return true if s.length <= 1\n if s[0] == s[-1]\n return is_palindrome(s[1...-1])\n else\n return false\n end\n end", "def is_palindrome(s)\n return true if s.empty?\n\n if s[0] == s[-1]\n return is_palindrome(s[1..-2]) \n else \n return false\n end \nend", "def is_palindrome(s)\n return true if s.empty? || s.length == 1\n return is_palindrome(s[1..-2])if s[0] == s[-1]\n return false\nend", "def palindrome?(string)\n \n begin_index = 0\n end_index = string.length - 1\n \n if string.length == 1\n return true\n end\n \n while begin_index < end_index || begin_index != end_index\n if string[begin_index] == string[end_index]\n begin_index += 1\n end_index -= 1\n palindrome = true\n else\n begin_index = end_index\n palindrome = false\n end\n end\n return palindrome\n \nend", "def is_palindrome(string)\n return true if string.empty? || string.length == 1\n\n front = 0\n back = string.length - 1\n\n while back > front\n return false if string[front] != string[back]\n front += 1\n back -= 1 \n end\n return true\nend", "def longest_palindrome(s)\n string_hash = Hash.new(0)\n \n s.each_char do |char|\n string_hash[char] += 1\n end\n \n beginning_count = 0\n middle_count = 0\n \n string_hash.keys.each do |key|\n if string_hash[key] % 2 == 1\n middle_count = 1\n end\n \n beginning_count += string_hash[key] / 2\n end\n \n beginning_count * 2 + middle_count\nend", "def palindrome?(str)\n str = str.downcase\n\n if str.length == 0 || str.length == 1\n true\n elsif str[0] == str[-1]\n palindrome?(str[1..-2])\n true\n else\n false\n end\nend", "def is_palindrome(s)\n if s == \"\" || s.length == 1\n return true\n elsif s[0] != s[-1]\n return false\n else\n return is_palindrome(s[1..-2])\n end\nend", "def is_palindrome(string) # a b c d c b a, m u m s, e a a e\n left = 0\n right = string.length - 1\n\n while left <= right # 0 != 6, 1 != 5, 2 != 4, 3 != 3\n return false if string[left] != string[right]\n if string[left] == string[right]\n left += 1\n right -= 1\n end\n end\n\n return true if left > right\n false\nend", "def palindrome(string)\n word_array = string.split(\"\")\n\n word_array.each_with_index do |letter,index|\n if letter[index] == letter[-index]\n return true\n end\n end\n end", "def palindrome?(string)\n new_string = \"\"\n i = 1\n string.length.times do\n new_string << string[-i]\n i += 1\n end\n string == new_string\nend" ]
[ "0.87534237", "0.8531388", "0.8502772", "0.8411477", "0.83973724", "0.83963454", "0.83865374", "0.8368124", "0.8297867", "0.8293101", "0.82867646", "0.82867646", "0.82867646", "0.82502496", "0.823413", "0.82338357", "0.8229775", "0.8208013", "0.81769633", "0.8171867", "0.81680566", "0.81595284", "0.81307924", "0.81109333", "0.80109143", "0.7988723", "0.79663974", "0.789358", "0.7887602", "0.7843425", "0.7827252", "0.78015256", "0.7800851", "0.77984077", "0.7795066", "0.77828866", "0.7774298", "0.77741176", "0.7772142", "0.77675164", "0.77608263", "0.7760177", "0.77582055", "0.7748322", "0.7738668", "0.772147", "0.7709492", "0.77087295", "0.76947933", "0.76880777", "0.7685702", "0.7683465", "0.76783484", "0.7677421", "0.7675903", "0.76678914", "0.7666615", "0.76636106", "0.7656636", "0.76547784", "0.76514053", "0.76505417", "0.7637051", "0.7635052", "0.76336044", "0.76336044", "0.76304996", "0.7629113", "0.76271033", "0.7624348", "0.7623587", "0.7620727", "0.76173615", "0.76166964", "0.7606697", "0.7605242", "0.76012695", "0.7600894", "0.7586396", "0.75823075", "0.75797445", "0.75723356", "0.7556784", "0.7555282", "0.7550128", "0.7545687", "0.7545162", "0.75332123", "0.7520255", "0.7519231", "0.75065947", "0.7496111", "0.74954855", "0.74944085", "0.7489466", "0.7484758", "0.7483191", "0.74809456", "0.7478469" ]
0.8370956
8
Write a function `anagrams(str1, str2)` that takes in two words and returns a boolean indicating whether or not the words are anagrams. Anagrams are words that contain the same characters but not necessarily in the same order. Solve this without using `Arraysort` or `Arraysort_by`.
def anagrams(str1, str2) letters = Hash.new(0) str1.split('').each do |char| letters[char] += 1 end str2.split('').each do |char| letters[char] -= 1 end letters.all? { |_, v| v.zero? } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def anagrams?(str1, str2)\n return false unless str1.length == str2.length\n\n str1.each_char do |chr|\n return false unless str2.count(chr) == str1.count(chr)\n end\n\n true\nend", "def are_anagrams?(str1, str2)\n # if different length, then can't possibly match\n return false if str1.length != str2.length\n\n str1_arr = str1.split('').sort\n str2_arr = str2.split('').sort\n 0.upto(str1_arr.length-1) do |i|\n return false if str1_arr[i] != str2_arr[i]\n end\n true\nend", "def anagrams_maybe_better(string1, string2)\n return true if string1.chars.sort == string2.chars.sort\n false\nend", "def anagrams?(word1, word2)\n if word1.length != word2.length\n return false\n end\n word1.each_char do |ele|\n if !word2.include?(ele)\n return false\n end\n end\n return true\nend", "def anagrams?(s1, s2)\n return false if s1.downcase == s2.downcase\n \n a1 = s1.downcase.delete(' ').chars.sort\n a2 = s2.downcase.delete(' ').chars.sort\n\n a1 == a2\nend", "def anagrams?(str1, str2)\n make_tally(str1) == make_tally(str2)\nend", "def anagrams?(word1, word2)\n\tarr1 = word1.split(\"\")\n \tarr2 = word2.split(\"\")\n\n count = Hash.new(0)\n \tcount2 = Hash.new(0)\n\n \tarr1.each {|word| count[word] += 1}\n \tarr2.each {|word| count2[word] += 1}\n\n if count == count2\n return true\n else\n return false\n end\nend", "def anagrams?(word1, word2)\n w1 = Hash.new(0)\n word1.each_char do |char|\n w1[char] += 1\n end\n w2 = Hash.new(0)\n word2.each_char do |char|\n w2[char] += 1\n end\n return w1 == w2\nend", "def are_anagrams_v2?(str1, str2)\n return false if str1.length != str2.length\n str1_char_count = Array.new(256, 0)\n str2_char_count = Array.new(256, 0)\n str1.each_byte do |c|\n str1_char_count[c] += 1\n end\n\n str2.each_byte do |c|\n str2_char_count[c] += 1\n end\n\n 0.upto(str1_char_count.length-1) do |i|\n return false if str1_char_count[i] != str2_char_count[i]\n end\n true\nend", "def check_anagrams(s1, s2)\n return false if s1.length != s2.length\n s1.chars.sort == s2.chars.sort\nend", "def are_anagrams(firstword, secondword)\n firstword.downcase.split(\"\").sort.join == secondword.downcase.split(\"\").sort.join\nend", "def anagrams(word1, word2)\n length = word1.length\n if word1.length == word2.length\n array = []\n while length>=0\n array.push(word1[length-1])\n length -= 1\n end\n length2 = word2.length\n while length2 >= 0\n if array.include?(word2[length2 - 1])\n length2 -= 1\n else\n return false\n end\n end\n return true\n else\n return false\n end\nend", "def anagrams?(a_string, another_string)\n # TODO: implement the obvious method to test if two words are anagrams\n puts a_string_sorted = clean(a_string.downcase.chars.sort.join)\n puts another_string_sorted = clean(another_string.downcase.chars.sort.join)\n a_string_sorted == another_string_sorted\nend", "def anagrams?(word1, word2)\n return char_count(word1) == char_count(word2)\nend", "def anagrams?(word1, word2)\n return char_count(word1) == char_count(word2)\nend", "def anagrams?(word1, word2)\n\treturn hashLetters(word1) == hashLetters(word2)\nend", "def anagrams?(word1, word2)\r\n return charCount(word1) == charCount(word2)\r\nend", "def anagrams?(word1, word2)\n return char_count(word1) == char_count(word2)\nend", "def anagrams?(word1, word2)\n return char_count(word1) == char_count(word2)\nend", "def anagrams?(word1, word2)\n return char_count(word1) == char_count(word2)\nend", "def anagrams?(word1, word2)\n\n # let's use hash count \n counter1 = Hash.new(0)\n\n word1.each_char do |char|\n counter1[char] += 1\n end \n \n counter2 = Hash.new(0)\n word2.each_char do |char|\n counter2[char] += 1\n end \n\n if counter1 == counter2\n return true \n end \n\n return false\nend", "def are_anagrams?( s1, s2 )\r\n\ttransformS1 = s1.downcase.split('').sort.join('')\r\n\ttransformS2 = s2.downcase.split('').sort.join('')\r\n\treturn transformS1 == transformS2\r\nend", "def are_anagrams?(word1, word2)\n #si las palabras son anagramas regresa true de lo contrario regresa false\n if canonical(word1) == canonical(word2) then true else false end\nend", "def is_anagram(w1, w2)\n\tw1.downcase.split(\"\").sort.join == w2.downcase.split(\"\").sort.join\nend", "def str_anagram(str1, str2)\n if str1.chars.sort.join.downcase == str2.chars.sort.join.downcase\n puts true\n else\n puts false\n end\n end", "def check_anagrams(first_words, second_words)\n first_words.each_with_index do |word, index|\n if word.split('').sort == second_words[index].split('').sort\n puts true\n else\n puts false\n end\n end\nend", "def anagrams?(word1, word2)\n\treturn char_count(word1) == char_count(word2)\n \nend", "def is_anagram(w1, w2)\n\tif w1.split(//).sort == w2.split(//).sort\n\t\treturn true\n\tend\n\treturn false\nend", "def anagrams(stringA, stringB)\n compare_strA = stringA.downcase\n .gsub(/[^\\w]/, '')\n .split('')\n .sort { |a, b| a <=> b}\n .join('')\n \n compare_strB = stringB.downcase\n .gsub(/[^\\w]/, '')\n .split('')\n .sort { |a, b| a <=> b}\n .join('')\n \n compare_strA == compare_strB\nend", "def is_anagram(s1, s2)\n\ts1 = s1.downcase.split('').sort\n\ts2 = s2.downcase.split('').sort\n\ts1 == s2 ? true : false \t \nend", "def anagrams(str1, str2)\n hash_1 = Hash.new(0)\n hash_2 = Hash.new(0)\n str1.each_char { |char| hash_1[char] += 1 }\n str2.each_char { |char| hash_2[char] += 1 }\n hash_1 == hash_2\nend", "def string_anagrams(str1, str2)\n return false if str1 == nil || str2 == nil\n return false if str1.length != str2.length\n\n ascii_options = Array.new(256)\n 256.times do |i|\n ascii_options[i] = 0\n end\n\n str1.length.times do |i|\n ascii_options[str1[i].ord] += 1\n end\n\n str2.length.times do |i|\n ascii_options[str2[i].ord] -= 1\n return false if ascii_options[str2[i].ord] < 0\n end\n\n return true\nend", "def anagrams2(str1, str2)\n arr1 = str1.split(\"\")\n arr2 = str2.split(\"\")\n arr1.each do |el|\n i = arr2.index(el)\n return false if i.nil?\n arr2.delete_at(i)\n end\n arr2.empty?\nend", "def valid_anagram(str1, str2)\n str1 = str1.split('').sort\n str2 = str2.split('').sort\n if str1 == '' && str2 == ''\n true\n else\n str1 == str2\n end\nend", "def anagram str1, str2\n str1.downcase.chars.sort.join == str2.downcase.chars.sort.join\nend", "def is_anagram word1, word2\n \tpermute = permute_word(word1)\n \tpermute.each do |w|\n \t puts w.join\n \t if w.join.eql?(word2)\n \t \treturn true\n \t end\n \tend\n \treturn false\n end", "def anagrams?(str_sym_or_int_1, str_sym_or_int_2)\n str_sym_or_int_1.to_s.downcase.delete(' ').split('').sort.join == str_sym_or_int_2.to_s.downcase.delete(' ').split('').sort.join\nend", "def anagram?(s1,s2)\n\ts1.chars.sort == s2.chars.sort\nend", "def anagramI?(str1, str2)\n anagrams = str1.split(\"\").permutation.to_a.map { |anagram| anagram.join(\"\") }\n anagrams.include?(str2)\nend", "def anagrams_one_hash?(str1, str2)\n letter_count = Hash.new(0)\n str1.each_char { |char| letter_count[char] += 1 }\n str2.each_char { |char| letter_count[char] -= 1 }\n\n letter_count.each_value.all? { |val| val == 0 }\nend", "def first_anagrams_2(str_1, str_2)\n string_1 = str_1.split('')\n string_2 = str_2.split('')\n\n return false if str_1.length != str_2.length\n\n string_1.each do |char|\n idx = string_2.find_index(char)\n if idx == nil\n return false\n else\n string_2.delete_at(idx)\n end\n end\n\n return true if string_2.empty?\nend", "def anagrams_better(string1, string2)\n string2 = string2.chars\n return false if string1.length != string2.length\n string1.chars.each do |ch|\n idx = string2.index(ch)\n unless idx.nil?\n string2.delete_at(idx)\n end\n end\n return true if string2.empty?\n false\nend", "def anagram3(str1, str2)\n str1 = str1.downcase.chars.sort.join\n str2 = str2.downcase.chars.sort.join\n\n return str1 == str2\nend", "def anagrams(str1, str2)\n hash1 = Hash.new(0) \n hash2 = Hash.new(0) \n\n str1.each_char do |el|\n hash1[el] += 1\n end\n\n str2.each_char do |el|\n hash2[el] += 1\n end\n\n hash1 == hash2\nend", "def anagram(string1, string2)\n puts \"Are #{string1} and #{string2} anagrams?\"\n if string1.length != string2.length\n return false\n else\n string1.length.times do |i|\n if !string2.include? string1[i] \n return false\n end\n end\n return true\n end\nend", "def first_anagram?(str1, str2)\n all_anagrams1 = str1.split(\"\").permutation.to_a.map(&:join)\n # (n) + (n!) + (n!) + (n!*n) => reduces down to O(n *n!) \n # ^\n #bottleneck\n all_anagrams1.include?(str2) # O(n!*n) \nend", "def anagram?(s1, s2)\n\ts1_array = s1.split(\"\")\n\ts2_array = s2.split(\"\")\n\tif s1_array.sort == s2_array.sort\n\t\treturn true\n\telse\n\t\treturn false\n\tend\nend", "def anagram?(a, b)\n a.chars.sort == b.chars.sort\nend", "def anagram?(x, y)\n x.chars.sort == y.chars.sort\nend", "def second_anagram?(str1, str2)\n str1_chars = str1.chars\n str2_chars = str2.chars\n\n str1.chars.each do |ch1|\n str1_chars.delete_if { str2.include?(ch1) }\n end\n\n str2.chars.each do |ch1|\n str2_chars.delete_if { str1.include?(ch1) }\n end\n\n str1_chars == str2_chars\nend", "def first_anagram?(str1, str2)\n anagrams = str1.split(\"\").permutation.to_a \n anagrams.include?(str2.split(\"\"))\nend", "def anagram3(str1, str2) #O(nlogn)\n split1 = str1.split(\"\").sort #O(n) + O(nlogn) = O(nlogn)\n split2 = str2.split(\"\").sort #O(n) + O(nlogn) = O(nlogn)\n\n split1 == split2 #O(n)\nend", "def anagrams?(word1, word2)\n\nend", "def anagrams?(word1, word2)\n\nend", "def anagram3(string, string2)\n(string.chars.sort.join == string2.chars.sort.join) ? true : false\nend", "def anagram?(phrase_one, phrase_two)\n phrase_one.split('').sort == phrase_two.split('').sort\n end", "def anagrams(str1, str2)\n \nend", "def anagram (str1, str2)\n # to downcase and remove non alphanumeric characters \n str1_hash = str_to_hash(str1.downcase.gsub(/(\\W)/, \"\"))\n str2_hash = str_to_hash(str2.downcase.gsub(/(\\W)/, \"\"))\n\n if str1_hash == str2_hash\n return true\n else\n return false\n end\n\nend", "def first_anagram?(str1, str2)\n all_anagrams(str1).include?(str2)\nend", "def third_anagrams?(str1,str2)\n str1.split(\"\").sort.join(\"\") == str2.split(\"\").sort.join(\"\")\nend", "def anagram?(a, b)\n return false unless a.length == b.length\n a.chars.sort == b.chars.sort\nend", "def anagramIII?(str1, str2)\n str1_arr = str1.split(\"\")\n str2_arr = st2.split(\"\")\n str1_arr.sort == str2_arr.sort\nend", "def not_better_by_much_anagram(string1, string2)\n hsh1 = Hash.new(0)\n hsh2 = Hash.new(0)\n\n string1.chars.each do |ch|\n hsh1[ch] +=1\n end\n\n string2.chars.each do |ch|\n hsh2[ch] +=1\n end\n\n return true if hsh1 == hsh2\n false\nend", "def second_anagram?(string1, string2)\n s1char_arr = string1.chars\n s2char_arr = string2.chars\n return false if s1char_arr.length != s2char_arr.length\n s1char_arr.dup.each_with_index do |ch1, ind1|\n s2char_arr.dup.each_with_index do |ch2, ind2|\n if s1char_arr.include?(ch2)\n string1.delete!(ch2)\n string2.delete!(ch2)\n p string1\n p string2\n end\n end\n end\n\n string1.empty? && string2.empty?\nend", "def anagram_3?(str1,str2)\n str1.chars.sort == str2.chars.sort\nend", "def second_anagram?(str1, str2)\n str1.chars.each do |char1|\n str2.chars.each do |char2|\n if char1 == char2\n str1.delete!(char1)\n str2.delete!(char2)\n end\n end\n end\n return true if str1.empty?\n false\nend", "def anagram_3?(word1, word2)\n return false if word1.length != word2.length\n arr1, arr2 = word1.split(\"\").sort, word2.split(\"\").sort\n (0...word1.length).all? { |idx| arr1[idx] == arr2[idx] }\nend", "def anagram?\n chars1 = @input1.downcase.gsub(/[!@#$%^&*()-=_+|;':\",.<>?']/, '').split(\"\").sort\n chars2 = @input2.downcase.gsub(/[!@#$%^&*()-=_+|;':\",.<>?']/, '').split(\"\").sort\n if\n self.allwords?\n if\n chars1 == chars2\n return \"These words are anagrams!\"\n elsif\n self.antigrams?\n return \"These words are not anagrams but they are antigrams!\"\n elsif self.antigrams? == false\n return \"These words are neither anagrams nor antigrams!\"\n end\n else\n return \"You need to input actual words!\"\n end\n end", "def third_anagram?(str1, str2)\n letters1 = str1.chars\n letters1.sort!\n letters2 = str2.chars\n letters2.sort!\n \n letters1 == letters2\nend", "def anagram?(str1,str2)\r\n count = Hash.new(0)\r\n str1.each_char {|char| count[char] +=1}\r\n str2.each_char {|char| count[char] -=1}\r\n count.values.all?(0)\r\nend", "def fith_anagram?(str1, str2)\n hash = Hash.new(0)\n \n str1.each_char { |char| hash[char] += 1 }\n str2.each_char { |char| hash[char] += 1 }\n \n hash.values.all? { |v| v > 1 }\nend", "def second_anagram?(str1, str2)\n str1.chars.each do |el|\n if str2.include?(el)\n str1 = str1.sub(el, \"\")\n str2 = str2.sub(el, \"\")\n end\n end\n\n str1.empty? && str2.empty?\nend", "def second_anagram?(word1, word2)\n return false if word1.length != word2.length\n word1.chars.each do |char1|\n word2.chars.each do |char2|\n if char1 == char2\n word1 = delete_char(word1, char1)\n word2 = delete_char(word2, char1)\n end\n end\n end\n\n word1.empty? && word2.empty?\nend", "def third_anagram?(word1, word2)\n split1= word1.chars.sort\n split2 = word2.chars.sort\n split1 == split2\nend", "def bonus_anagram?(str1, str2)\n counts = Hash.new(0)\n\n str1.chars.each { |letter| counts[letter] += 1 }\n str2.chars.each { |letter| counts[letter] -= 1 }\n\n counts.values.all? { |value| value == 0 }\nend", "def second_anagram?(str_1, str_2)\n words = str_2.chars\n str.each_char.with_index do |char, i|\nend\n\n# def first_anagram?(str_1, str_2)\n# hash_1 = Hash.new(0)\n# hash_2 = Hash.new(0)\n\n# str_1.each_char { |char| hash_1[char] += 1}\n# str_2.each_char { |char| hash_2[char] += 1}\n\n# hash_1 == hash_2\n# end\n\n# p first_anagram?(\"gizmo\", \"sally\") #=> false\n# p first_anagram?(\"elvis\", \"lives\") #=> true", "def third_anagram?(first_word, second_word)\n first_word.chars.sort == second_word.chars.sort\nend", "def third_anagram?(word1, word2)\n first = word1.chars.sort.join(\"\")\n second = word2.chars.sort.join(\"\")\n\n p first == second \nend", "def second_anagram?(str1, str2)\n return false if str1.length != str2.length\n str1_copy = str1.dup\n str2_copy = str2.dup\n\n (0...str1.length).each do |i|\n if str2.include?(str1[i])\n str1_copy.delete!(str1[i])\n end\n end\n\n (0...str2.length).each do |i|\n if str1.include?(str2[i])\n str2_copy.delete!(str2[i])\n end\n end\n\n\n return true if str1_copy.empty? && str2_copy.empty?\n false\nend", "def third_anagram?(str1, str2)\n\n str1.chars.sort == str2.chars.sort\n #sort1 #sort2\nend", "def slightly_better_by_much_anagram(string1, string2)\n hsh1 = Hash.new(0)\n\n string1.chars.each do |ch|\n hsh1[ch] += 1\n end\n\n string2.chars.each do |ch|\n hsh1[ch] -= 1\n end\n\n return true if hsh1.values.all? {|el| el == 0}\n false\nend", "def anagram_bruteforce? (s1,s2)\n sp = StringPermutator.new\n return true if sp.permutations(s1).include? s2\n false\n end", "def third_anagram?(word_1, word_2)\n word_1.chars.sort == word_2.chars.sort\nend", "def second_anagram?(str1, str2)\n return false unless str1.length == str2.length\n str2_arr = str2.chars\n str1_copy = str1.dup.chars\n str1.chars.each_with_index do |letter, idx|\n return false unless str2_arr.include?(letter)\n str2_arr.delete_at(str2_arr.index(letter)) if str2_arr.include?(letter)\n end\n true\nend", "def third_anagram?(string1, string2)\n arr1 = string1.chars.sort\n arr2 = string2.chars.sort\n\n arr1 == arr2\nend", "def second_anagram?(str1, str2)\n first = str1.chars\n second = str2.chars\n\n first_dup = first.dup\n second_dup = second.dup\n\n first.each_with_index do |char, idx|\n second.each_with_index do |char2, idx2|\n if char == char2\n first_dup[idx] = \"\"\n second_dup[idx2] = \"\"\n end\n end\n end\n\n first_dup == second_dup\nend", "def second_anagram?(string1,string2)\n # byebug\n return false unless string1.length == string2.length\n\n chars1 = string1.chars\n chars2 = string2.chars\n\n chars1.each do |char|\n if chars2.include?(char)\n chars2.delete(char)\n end\n end\n\n return true if chars2.empty?\n\n false\nend", "def second_anagram?(word1, word2)\n split1, split2 = word1.chars, word2.chars\n\n idx = 0\n while idx < split1.length\n split2.each_with_index do |el2, idx2|\n if el2 == split1[idx]\n split1.delete_at(idx)\n split2.delete_at(idx2)\n idx = -1\n break\n end\n end\n idx += 1\n end\n return false unless split1.empty? && split2.empty?\n true\nend", "def second_anagram?(str_1, str_2)\n str_1.each_char do |char|\n return false unless str_1.include?(str_2[0])\n str_2.chars.delete_at(str_2.index(char))\n end\n true\nend", "def third_anagram?(str1, str2)\n s1 = str1.split('').sort\n s2 = str2.split('').sort\n\n s1 == s2\nend", "def third_anagram?(str_1, str_2)\n sorted_str_1 = str_1.chars.sort.join\n sorted_str_2 = str_2.chars.sort.join\n sorted_str_1 == sorted_str_2\nend", "def first_anagram?(string1, string2)\n all_anagrams(string1).include?(string2)\nend", "def third_anagram?(str1,str2) #O(nlogn)\n str1_a = str1.split('').sort\n str2_a = str2.split('').sort\n\n str1_a == str2_a \nend", "def third_anagram(str1, str2) \n sorted_str1 = str1.split(\"\").sort\n sorted_str2 = str2.split(\"\").sort\n\n sorted_str1 == sorted_str2\nend", "def second_anagram?(str1, str2)\n letters1 = str1.chars\n letters2 = str2.chars\n\n str1.chars.each do |c|\n match1 = letters1.index(c)\n match2 = letters2.index(c)\n\n return false unless match1 && match2\n\n letters1.delete_at(match1)\n letters2.delete_at(match2)\n end\n\n letters1.empty? && letters2.empty?\nend", "def third_anagram?(str1, str2)\n\n str1.split(\"\").sort == str2.split(\"\").sort\n\nend", "def third_anagram?(word1, word2)\n a, b = word1.split(''), word2.split('')\n\n a.sort == b.sort\nend", "def third_anagram?(first_str, second_str)\n first_sorted = first_str.chars.sort # n + nlogn\n second_sorted = second_str.chars.sort # m + mlogm\n first_sorted == second_sorted\nend", "def third_anagram?(string1, string2)\n chars1 = string1.chars.sort\n chars2 = string2.chars.sort\n\n chars1 == chars2\nend", "def third_anagram?(str1, str2)\n sorted1 = str1.split(\"\").sort.join #O(n + nlogn + n) => O(nlogn)\n sorted2 = str2.split(\"\").sort.join #O(n + nlogn + n) => O(nlogn)\n\n sorted1 == sorted2 #O(1)\nend" ]
[ "0.9069233", "0.9025581", "0.90137744", "0.89904934", "0.8972882", "0.8948267", "0.89023894", "0.8873611", "0.88331133", "0.8813541", "0.8813156", "0.88123095", "0.8796728", "0.8793009", "0.8793009", "0.8792254", "0.87823725", "0.8780502", "0.8780502", "0.8780502", "0.87670964", "0.87628627", "0.8745809", "0.87312293", "0.8677936", "0.86757886", "0.8674288", "0.8670894", "0.86657554", "0.86570156", "0.86554325", "0.8652416", "0.85819083", "0.85681885", "0.8566406", "0.85194105", "0.84923947", "0.84632057", "0.8459147", "0.84530514", "0.8433645", "0.8427093", "0.8398613", "0.8396831", "0.8389791", "0.83856016", "0.8370758", "0.8358011", "0.8356755", "0.83341175", "0.8330611", "0.83305514", "0.8310776", "0.8310776", "0.8298205", "0.8294909", "0.82760435", "0.8258583", "0.8254446", "0.8250728", "0.8247208", "0.8245716", "0.8224287", "0.82194924", "0.8189801", "0.81850904", "0.81756276", "0.81733435", "0.8165649", "0.81609464", "0.8150759", "0.8150269", "0.8126919", "0.81209147", "0.8110756", "0.8110591", "0.8102315", "0.80976194", "0.80870533", "0.8086384", "0.80831444", "0.8082441", "0.80805343", "0.8077604", "0.8075037", "0.8073688", "0.80721116", "0.8069133", "0.80637", "0.8052608", "0.8045572", "0.8045072", "0.8042505", "0.80337715", "0.8031999", "0.8028735", "0.8015841", "0.80135304", "0.8012129", "0.80071586" ]
0.8828899
9
Define a recursive method `permutations(array)` that returns all of the permutations of an array example => permutations([1,2,3]) should return => [ [1, 2, 3], [1, 3, 2], [2, 1, 3], [2, 3, 1], [3, 1, 2], [3, 2, 1] ] You CANNOT use call Ruby's builtin `Arraypermutation` method.
def permutations(array) return [array] if array.length <= 1 # Similar to the subsets problem, we observe that to get the permutations of # [1, 2, 3] we can look at the permutations of [1, 2] which are [1, 2] and # [2, 1] and add the last element to every possible index getting [3, 1, 2], # [1, 3, 2], [1, 2, 3], [3, 2, 1], [2, 3, 1], [2, 1, 3] # pop off the last element first = array.shift # make the recursive call perms = permutations(array) # we will need an array to store all our different permutations total_permutations = [] # Now we iterate over the result of our recusive call say [[1, 2], [2, 1]] # and for each permutation add first into every index. This new subarray # gets added to total_permutations. perms.each do |perm| (0..perm.length).to_a.each do |i| total_permutations << perm[0...i] + [first] + perm[i..-1] end end total_permutations end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def permutations(array)\n\treturn array.permutation\nend", "def permutations(array)\n return [array] if array.length == 1\n\n perms = []\n array.each do |el|\n dupped = array.dup\n dupped.delete(el)\n permutations(dupped).each { |perm| perms << [el] + perm }\n end\n\n perms\nend", "def permutations(array)\n debugger\n return [array] if array.length <= 1\n # pop off the last element\n first = array.shift\n # make the recursive call\n perms = permutations(array)\n # we will need an array to store all our different permutations\n total_permutations = []\n\n\n # Now we iterate over the result of our recusive call say [[1, 2], [2, 1]]\n # and for each permutation add first into every index. This new subarray\n # gets added to total_permutations.\n perms.each do |perm|\n (0..perm.length).each do |i|\n total_permutations << perm[0 ... i] + [first] + perm[i .. -1]\n end\n end\n total_permutations\nend", "def permutations(array)\n if array[0].is_a?(Array)\n permutation_num = factorial(array[0].length)\n return array if array.length == permutation_num\n current = array[-1]\n prev_array = [current[-1]] + current[0..-2]\n next_array = [current[-1]] + current[0..-2].reverse\n result = array + [next_array , prev_array]\n permutations(result)\n else\n permutation_num = factorial(array.length)\n return array if array.length == permutation_num\n next_array = [array[0]] + array[1..-1].reverse\n result = [array] + [next_array]\n permutations(result)\n end\n end", "def permutations(array)\n return [array] if array.length <= 1\n\n\n # Similar to the subsets problem, we observe that to get the permutations\n # of [1, 2, 3] we can look at the permutations of [1, 2] which are\n # [1, 2] and [2, 1] and add the last element to every possible index getting\n # [3, 1, 2], [1, 3, 2], [1, 2, 3], [3, 2, 1], [2, 3, 1]\n\n # pop off the last element\n first = array.shift\n # make the recursive call\n perms = permutations(array)\n # we will need an array to store all our different permutations\n total_permutations = []\n\n\n # Now we iterate over the result of our recusive call say [[1, 2], [2, 1]]\n # and for each permutation add first into every index. This new subarray\n # gets added to total_permutations.\n perms.each do |perm|\n (0..perm.length).each do |i|\n total_permutations << perm[0...i] + [first] + perm[i..-1]\n end\n end\n total_permutations\nend", "def permutations(array)\n\nend", "def permutations(array)\n\nend", "def permutations(array)\n\nend", "def permutations(array)\n\nend", "def permutations(array)\n \nend", "def permutations(array)\n results = []\n results[0] = [[array.first]]\n (1..array.length - 1).each do |i|\n new_perms = []\n old_perms = results[i-1].deep_dup\n old_perms.each do |perm|\n perm.each_with_index do |value, index|\n new_perms << perm.splice(index, i + 1)\n end\n new_perms << perm.push(i + 1)\n end\n results[i] = new_perms\n end\n results[array.length - 1]\nend", "def permutations(array)\n return [[]] if array.empty?\n return [array] if array.length == 1\n new_arr = []\n\n first_el = array.shift\n array_perms = permutations(array)\n array_perms.each do |perm|\n (0..perm.length).each do |idx|\n new_arr << perm[0...idx] + [first_el] + perm[idx..-1]\n end\n end\n return new_arr\nend", "def permutations(array)\n return [array] if array.length <= 1\n\n first = array.shift\n perms = permutations(array)\n total_permutations = []\n\n perms.each do |perm|\n (0..perm.length).each do |i|\n total_permutations << perm.take(i) + [first] + perm.drop(i)\n end\n end\n total_permutations\nend", "def permutations(array)\n return [array] if array.length <= 1\n\n first = array.shift\n perms = permutations(array)\n\n total_permutations = []\n\n perms.each do |perm|\n (0..perm.length).each do |i|\n total_permutations << perm[0...i] + [first] + perm[i..-1]\n end\n end\n\n total_permutations\nend", "def permutations(array)\n\n ret = []\n return [array] if array.length < 2\n sub = permutations(array[1..-1])\n sub.each do |sub_array|\n (0..sub_array.length).each do |idx|\n ret << sub_array[0...idx] + [array.first] + sub_array[idx..-1]\n end\n end\n ret\nend", "def permutations(array)\n return [array] if array.length == 1\n\n first = array.shift\n\n perms = permutations(array)\n total_permutations = []\n perms.each do |perm|\n (0..perm.length).each do |i|\n total_permutations << perm[0...i] + [first] + perm[i..-1]\n end\n\n end\n total_permutations\nend", "def permutations(array)\n return [array] if array.length <= 1\n total_permutations = []\n last = array[-1]\n perms = permutations(array[0...-1])\n\n perms.each do |perm|\n 0.upto(perm.length) do |index|\n total_permutations << perm[0...index] + [last] + perm[index..-1]\n end\n end\n\n total_permutations\nend", "def permutations(array)\n if array.empty?\n return [[]]\n end\n if array.count == 1\n return [array.clone]\n end\n arr = []\n array.each_with_index do |ele, idx|\n cpy = array.clone\n cpy.delete_at(idx)\n permutations(cpy).each do |perm|\n arr << [ele] + perm\n end\n end\n return arr\nend", "def permutations(array)\n return [array] if array.length <= 1\n start = array.shift\n perm = permutations(array)\n total_perms = []\n perm.each do |perms|\n (0..perm.length).each do |i|\n total_perms << perms[0...i] + [start] + perms[i..-1]\n end\n end\n total_perms\nend", "def permutations(array)\n return [array] if array.length <= 1\n \n \n # Similar to the subsets problem, we observe that to get the permutations\n # of [1, 2, 3] we can look at the permutations of [1, 2] which are\n # [1, 2] and [2, 1] and add the last element to every possible index getting\n # [3, 1, 2], [1, 3, 2], [1, 2, 3], [3, 2, 1], [2, 3, 1]\n \n # pop off the last element\n first = array.shift\n # make the recursive call\n perms = permutations(array)\n # we will need an array to store all our different permutations\n total_permutations = []\n \n \n # Now we iterate over the result of our recusive call say [[1, 2], [2, 1]]\n # and for each permutation add first into every index. This new subarray\n # gets added to total_permutations.\n perms.each do |perm|\n (0..perm.length).each do |i|\n total_permutations << perm[0...i] + [first] + perm[i..-1]\n end\n end\n total_permutations\nend", "def permute(arr)\n return [array] if array.length <= 1\n\n first = array.shift\n perms = permute(array)\n total_permutations = []\n \n \n # Now we iterate over the result of our recusive call say [[1, 2], [2, 1]]\n # and for each permutation add first into every index. This new subarray\n # gets added to total_permutations.\n perms.each do |perm|\n (0..perm.length).each do |i|\n total_permutations << perm[0...i] + [first] + perm[i..-1]\n end\n end\n total_permutations\nend", "def permute(arr)\n permutations = []\n for i in (0 .. arr.size - 1)\n for j in (i + 1 .. arr.size - 1)\n permutations.push([arr[i],arr[j]])\n end\n end\n permutations\n end", "def permutations(array)\n #base case\n return [[]] if array.empty?\n\n results = []\n prev_perm = permutations(array[0...-1]) # permutations([1,2]) == [[1, 2], [2, 1]]\n last_ele = array[-1] # 3\n prev_perm.each do |sub_arr|\n (0...array.length).each do |idx|\n # temp = Array.new(array.length) [nil, nil, nil]\n # temp = sub_arr[0...idx] + [last_ele] + sub_arr[idx..-1]\n results << temp\n end\n end\n results\nend", "def permutations(arr)\n return [arr] if arr.length == 1\n results = []\n arr.each_with_index do |num, idx|\n rest_of_arr = arr[0...idx] + arr[(idx + 1)..-1]\n permutations(rest_of_arr).each do |permutation|\n results << [num] + permutation\n end\n end\n results\nend", "def permutations(array)\n return [array] if array.length == 1\n\n results = []\n\n array.each_with_index do |item, i|\n permutations(array[0..i-1] + array[i+1..-1]).each do |perm|\n results << perm.unshift(item)\n end\n end\n\n results\nend", "def permutation(array)\n answer_arr = []\n return array if array.length == 1\n array.each_index do |i|\n perm = permutation(array - [array[i]])\n perm.each do |el|\n answer_arr << ([array[i]] + [el]).flatten\n end\n perm.each do |el|\n answer_arr << ([el] + [array[i]]).flatten\n end\n end\n answer_arr.uniq\nend", "def permutations(arr)\n # will have to iterate\n # will have logic similar to subsets\n\n # [1], hits base case and we're done\n\n return [arr] if arr.length <= 1\n\n result = []\n last_ele = arr.pop\n sub_perms = permutations(arr)\n\n sub_perms.each do |sub|\n (0..sub.length) do |i| # index will vary, we to include sub.length as an index, otherwise we will never be able to shove into the last/back spot\n result << sub[0...i] + [last_ele] + sub[i..-1]\n # since the i will vary as we iterate through, ^^ will shift the last_ele around\n end\n end", "def permutations(arr)\n arr = arr.dup\n return [arr] if arr.length == 1\n\n last_el = arr.pop\n base = permutations(arr) # [[1]]\n\n results = []\n base.each do |perm|\n (perm.length + 1).times do |i|\n result = perm[0...i] + [last_el] + perm[i..-1]\n results << result\n end\n end\n\n results\nend", "def permutations array\n if array.size < 2\n yield array\n else\n array.each do |element|\n permutations(array.select() {|n| n != element}) \\\n {|val| yield([element].concat val)}\n end\n end\nend", "def permutations(array)\n return array if array.length <= 1\n\n if array.length == 2\n return [array, array.reverse]\n end\n\n final_array = []\n\n array.length.times do\n set = array.take(array.length - 1)\n\n final_array += permutations(set).map do |item|\n item += [array.last]\n end\n\n next_item = array.shift\n array.push(next_item)\n end\n\n final_array\nend", "def array_permutation(array)\n return array[0] if array.size == 1\n first = array.shift\n return first.product( array_permutation(array) )\nend", "def permutations(array)\n return [array] if array.length < 2\n\n result = []\n prev = permutations(array[0..-2])\n prev.each do |perm|\n (0..perm.size).each do |idx|\n result << perm.dup.insert(idx, array.last)\n end\n end \n \n result\nend", "def permutations(arr)\n return [arr] if arr.length <= 1\n\n prev_perms = permutations(arr[0..-2])\n total_perms = []\n\n prev_perms.each do |sub_perm|\n (0..sub_perm.length).each do |idx|\n total_perms << sub_perm[0...idx] + [arr.last] + sub_perm[idx..-1]\n end\n end\n\n total_perms\nend", "def permutations(arr)\n return [arr] if arr.length <= 1\n\n first = arr.shift\n perms = permutations(arr)\n total_perms = []\n\n perms.each do |perm|\n (0..perm.length).each do |i|\n total_perms << perm[0...i] + [first] + perm[i..-1]\n end\n end\n\n total_perms.sort\nend", "def permutations(array)\n # debugger\n return [array] if array.length == 1\n perms = permutations(array[0..-2])\n other_perms = []\n perms.each do |perm|\n other_perms += (0..perm.length).map do |idx|\n temp = perm.dup\n temp.insert(idx, array[-1])\n end\n end \n other_perms\nend", "def permutations(arr)\n return [arr] if arr.length <= 1\n\n [arr.last] + permutations(arr[0...-1])\nend", "def permutations(arr)\n return arr if arr.length <= 1\n perm = [arr]\n sub_perm = permutations(arr[1..-1])\n curr_el = arr[0]\n p sub_perm\n p \" sub_perm #{sub_perm} \"\n if sub_perm.length > 1\n\n sub_perm.each do |subArr|\n temp = []\n (0...subArr.length).each do |i|\n temp = subArr[0..i] + [curr_el] + subArr[i + 1..-1]\n end\n perm << temp\n end\n end\n # puts \" sub_perm #{sub_perm} \"\n # sub_perm.each do |subArr|\n # subArr << curr_el\n # perm << subArr\n # end\n # sub_perm << curr_el\n # perm << sub_perm\nend", "def permutations(arr)\n # return nil if arr.empty?\n return [arr] if arr.length == 1\n # grab first element to append to all perms of smaller array\n first_el = arr.shift\n # get permutations of shrunken array\n subset_perms = permutations(arr)\n total_permutations = []\n # iterate through all smaller perms\n subset_perms.each do |sub|\n # add first element to all possible indices of perms array\n # and add to total_perms array\n (0..sub.length).each do |i|\n subset = sub[0...i] + [first_el] + sub[i..-1]\n total_permutations << subset\n end\n end\n total_permutations\nend", "def permutations(array)\n #[1,2]\nreturn [array] if array==[1]\n\n\n\n\nprevious=permutations(array[0...-1])\nlast = array.last\nresult=[]\nprevious.each do |ele|\n (0...array.length-1).each do |i|\n result << ele[0..i]+[last]+ele[i+1..-1]\n \n \n end\n result << [last]+ele\n\n end\n result\nend", "def permutations(arr)\n return arr if arr.length <= 1\n return [arr, arr.reverse] if arr.length == 2\n last_el = arr.pop\n old_arr = arr.deep_dup\n arr = []\n permutations(old_arr).each do |el|\n (0..el.length).each do |pos|\n base_el = el.deep_dup\n arr += [base_el.insert(pos, last_el)]\n end\n end\n arr\nend", "def perms(arr)\n result = []\n all_perms(arr, 0, result)\nend", "def print_permutations_of(array) \n array.permutation.to_a.each do |element|\n puts element.join(\", \")\n end\n end", "def permutations(elements)\n return [elements] if elements.size <= 1\n result = []\n elements.uniq.each do |p|\n _elements = elements.dup\n _elements.delete_at(elements.index(p))\n permutations(_elements).each do |perm|\n result << (perm << p)\n end\n end\n result\nend", "def get_permutations(arr)\n\t# byebug\n\treturn [arr] if arr.count <= 1\n\n\tarray_except_last = arr[0..arr.count - 2]\n\tlast_one = [arr.last]\n\n\tpermutations_of_array_except_last = get_permutations(array_except_last)\n\n\tpermutations = []\n\tpermutations_of_array_except_last.each do |permutation_of_array_except_last|\n\t\t(0..permutation_of_array_except_last.count).each do |position|\n\t\t\tif position == 0\n\t\t\t\tp = last_one + permutation_of_array_except_last\n\t\t\telsif position == array_except_last.count\n\t\t\t\tp = permutation_of_array_except_last + last_one\n\t\t\telse\n\t\t\t\tp = permutation_of_array_except_last[0...position] + last_one + permutation_of_array_except_last[position..permutation_of_array_except_last.count - 1]\n\t\t\tend\n\t\t\tpermutations << p\n\t\tend\n\tend\n\tpermutations\nend", "def array_permutations(arr)\n return [arr] if arr.length <= 1\n removed = arr.last\n sliced_arr = arr.slice(0...-1)\n new_arrays = array_permutations(sliced_arr)\n res = []\n new_arrays.each{|new_array|res += insert_num(new_array, removed)}\n res\nend", "def permutation (array)\n# yields permutation set WITH duplicates\nend", "def permutations(arr)\n return [[]] if arr.empty? \n \n #last element arr\n #putting before and after every index of a perm\n #permuatations(arr[0..-2])\n #last = arr[-1]\n \n last = arr[-1]\n perms = permutations(arr[0..-2])\n result = [] \n perms.each do |sub_arr| #[a,b]\n current_perms = []\n (0..sub_arr.length).each do |i|\n dup = sub_arr.dup \n current_perms << dup.insert(i,last) # dup = ['b','a']\n end \n result += current_perms\n end \n\n result \nend", "def permutation(array)\n return array if array.length == 1\n\n smaller = permutation(array[0...-1])\n combination_array = []\n (smaller.length + 1).times do |index|\n combination_array += smaller.dup.insert(index, array[-1])\n # debugger\n end\n combination_array\nend", "def permutations_of_array(a, k)\n a.permutation(k).to_a\nend", "def get_permutations(n)\r\n return (1..n).to_a.permutation.to_a\r\nend", "def permutations(input)\n return [] if input.empty?\n [permute(0,input)].flatten\n end", "def permutations_lazy_iter(arr)\n new_arr = [arr]\n num_perms = factorial(arr.length)\n\n until new_arr.length == num_perms\n new_arr << arr.shuffle\n new_arr = new_arr.uniq\n end\n\n new_arr\nend", "def permute(list)\n if (list.length <= 1)\n return [list]\n end\n permutations = []\n count = 1\n list.each do |item|\n sublist_permutations = permute(list - [item])\n sublist_permutations.each do |permutation|\n permutation.unshift(item)\n permutations << permutation\n #puts \"Permutations : #{permutations.join(', ')}\"\n #puts \"permutation lists: #{permutations.each {permutation.join(', ')}}\"\n end\n end\n return permutations\nend", "def permutations\n return [self] if length == 1\n\n orders = []\n positions = (0...length).to_a\n\n # Finding the permutations with a basic array of digits\n positions.each do |position|\n (positions - [position]).permutations.each do |permutation|\n orders << permutation.unshift(position)\n end\n end\n\n # We subsitute in our original elements. This prevents duplicate\n # elements from causing problems, and allows the [3,3] example to work.\n orders.map { |order| order.map { |index| self[index] } }\n end", "def all_permutations\n perms = permutations\n perms = perms.shuffle.take(1) if @single_perm || ENV['FAST_TESTS']\n\n perms.each do |p|\n yield(p)\n WebMock.reset!\n end\n end", "def permutations(array)\n results = []\n\n 1000.times do \n premutation = array.shuffle\n results << array << premutation\n end\n\n results.uniq.sort\nend", "def permutations(string)\n permute(string, 0, string.length)\nend", "def permutations(arrays, i)\n if i == arrays.length then return [[]] end\n\n res_next = permutations(arrays, i + 1)\n res = []\n arrays[i].each do |x|\n res_next.each do |y|\n res << ([x] + y)\n end\n end\n return res\nend", "def permute(items, perms=[], res=[])\n unless items.length > 0\n res << perms\n else\n for i in items\n newitems = items.dup\n newperms = perms.dup\n newperms.unshift(newitems.delete(i))\n permute(newitems, newperms,res)\n end\n end\n return res\nend", "def permutations(string)\n string.chars.permutation(string.length).to_a.map { |arr| arr.join }.uniq\nend", "def permutations(sequence)\n return sequence if sequence.empty?\n\n ch = sequence.delete_at(0)\n underlying = Set.new([ch])\n sequence.each do |ch|\n new_set = Set.new\n underlying.each do |permutation|\n (0..permutation.length).each do |idx|\n new_set.add(permutation.dup.insert(idx, ch))\n end\n end\n underlying = new_set\n end\n underlying.each\nend", "def permutations(string)\n string.chars.permutation(string.length).map(&:join).uniq\nend", "def permutations(sequence)\n return sequence if sequence.empty?\n ch = sequence.delete_at(0)\n underlying = Set.new([ch])\n sequence.each do |ch|\n new_set = Set.new\n underlying.each do |permutation|\n (0..permutation.length).each do |idx|\n new_set.add(permutation.dup.insert(idx, ch))\n end\n end\n underlying = new_set\n end\n underlying.each\n end", "def lexicographic_permutations\n a=Array.new\n (1..self.length.factorial).each { |i| a << self.lexicographic_permutation(i) }\n a\n end", "def perm(arr)\n return [arr] if arr.length <= 1\n result = []\n arr.each_index do |idx|\n temp = perm(arr[0...idx] + arr[idx+1..-1])\n subset = temp.map { |sub| [arr[idx]] + sub }\n result += subset\n end\n\n result\n\n\n\n\n # return [arr] if arr.length <= 1\n # result = []\n #\n # arr.each_index do |idx|\n #\n # other_perm = perm(arr[0...idx] + arr[idx+1..-1])\n # row = other_perm.map { |subarr| [arr[idx]] + subarr }\n # result += row\n # end\n #\n # result\nend", "def permutations(base, result = [])\n base = base.dup\n base.empty? ? [result] : base.shift.map { |value| permutations(base, result + [value]) }.flatten(1)\n end", "def permutations(string)\n perms = []\n combos = string.split('').permutation.to_a.map { |combo| combo.join('') }\n combos.each { |combo| perms << combo if !perms.include?(combo) }\n perms\nend", "def permutations(str)\n permutation(str.chars)\nend", "def permutations(string)\n string.chars.permutation.to_a.map(&:join).uniq\nend", "def permutations(string)\nend", "def permutations(str)\nend", "def permute(nums)\n result = []\n permute_helper(nums, [], result)\n result\nend", "def permutations(a, i)\n if i == a.size \n puts to_decimal(a)\n gets\n return\n end\n\n for j in i..a.size-1\n a[j], a[i] = a[i], a[j]\n permutations(a, i + 1)\n a[j], a[i] = a[i], a[j]\n end\nend", "def permute(level, input)\n return [input] if level == input.length - 1\n\n results = []\n for i in level..(input.length-1)\n foo = permute(level+1, swap(input, level, i))\n results << foo\n end\n results\n end", "def permutation(string)\n return [string] if string.size < 2\n char = string[0]\n total_perms = []\n perms = permutation(string[1..-1])\n\n perms.each do |perm|\n (0..perm.length).each do |i|\n total_perms << perm[0...i] + char + perm[i..-1]\n end\n end\n\n total_perms\nend", "def permute(nums)\n result = []\n permute_helper(nums, [], result)\n result\nend", "def permutations(p)\r\n p.to_s.scan(/\\d/).permutation.map{|e| e.join}.sort\r\nend", "def permutation(length = size, &block)\n return enum_for(:permutation, length) if not block_given?\n if length == 0\n yield EmptyList\n elsif length == 1\n each { |obj| yield Cons.new(obj, EmptyList) }\n elsif not empty?\n if length < size\n tail.permutation(length, &block)\n end\n\n tail.permutation(length-1) do |p|\n 0.upto(length-1) do |i|\n left,right = p.split_at(i)\n yield left.append(right.cons(head))\n end\n end\n end\n self\n end", "def q(a);a.permutation;end", "def permutation(string)\n return [string] if string.size < 2\n char = string[0]\n perms = permutation(string[1..-1])\n result = []\n perms.each do |perm|\n result << char + perm\n (1..perm.length-1).each do |i|\n result << perm[0..i-1] + char + perm[i..-1]\n end\n result << perm + char\n end\n result.uniq\nend", "def getPermutations3(s,perm=[])\n subresult = getPermutations2(s[1..3])\n subresult.each do |item|\n perm.push(item.insert(0,s[0]))\n end\n if perm.length >= factorial(s.length)\n return perm\n else\n s = rotateChar(s)\n getPermutations3(s,perm)\n end\nend", "def permutations(paths)\n permutations = paths.map(&:downcase).map(&:all_permutations)\n permutations = permutations.flatten.sort_by(&:length).reverse\n permutations\nend", "def permute(nums, solution = [], results = []\n return results << solution.clone if solution.size == nums.size\n\n nums.each do |num|\n next if solution.include?(num)\n\n solution << num\n permute(nums, solution, results)\n solution.pop\n end\n results\nend", "def string_permutations(str) \n return [] if !str || str.length == 0\n \n perms = []\n helper(rest: str, perms: perms)\n perms \nend", "def test_permutations\n find = Finder.new\n arr = [\"CAKE\", \"ANT\", \"TRY\"]\n word_list = [\"CAKE\", \"NAT\"]\n result = find.permutations(arr, word_list)\n expected = [\"CAKE\", \"NAT\"]\n assert_equal expected, result\n end", "def permutations(perms, digits)\n\tcounts = Array.new(digits.size, 0)\n\t\nend", "def number_permutations(number)\n permutations = []\n\n [3, 4, 5, 6, 7, 10].each do |pattern|\n permutations << split_in_two(number, pattern)\n end\n [[3, 3], [3, 4], [4, 3]].each do |pattern|\n permutations << split_in_three(number, pattern.first, pattern.last)\n end\n\n permutations\n end", "def nth_permutation(number_of_permutations)\n\t\tpermutation_array = []\n\t\tnumber_of_permutations -= 1 # assuming we start from the first permutation rather than the zeroth\n\t\twhile lexographic_array.length > 0\n\t\t\tindex = number_of_permutations / (lexographic_array.length - 1).factorial\n\t\t\tnumber_of_permutations %= (lexographic_array.length - 1).factorial\n\t\t\tpermutation_array.push(lexographic_array.delete_at(index))\n\t\tend\n\t\tpermutation_array\n\tend", "def permute(words)\n return nil if words.nil?\n return [] if words.empty?\n\n pwords = []\n words.each do |w|\n list = w.chars.to_a.permutation.map(&:join)\n pwords.concat list\n end\n pwords\n end", "def permutations(string)\n # base case\n if string.length == 0\n return string\n end\n\n results = []\n\n i = 0\n while i < string.length\n first_letter = string[i]\n rest = string[i+1..-1]\n permutes = permutations(rest)\n \n permutes.each do |permuties|\n results.push(first_letter += permuties)\n end\n end\n\n return results\n\nend", "def permutate(word)\n max_size = word.size\n perms_arr = word.chars.permutation.map(&:join)\n perms_arr.each do |perm|\n @perms << perm if perm.size == max_size\n end\n end", "def getPermutations(s)\n result = []\n for i in 0..2\n substring = s[1..2]\n result.push(s[0] + substring)\n result.push(s[0] + substring.reverse)\n s = rotateChar(s)\n end\n\n return result\nend", "def permute_string(perm_string)\n char_array = perm_string.chars\n permute_rec(char_array,0,char_array.size - 1, [])\nend", "def permute(&block)\n case size\n when 0 then yield []\n when 1 then yield self\n when 2\n yield self\n yield self.reverse\n else\n 0.upto(size-1) do |i|\n a = dup\n c = a.slice!(i)\n a.permute do |p|\n yield p.dup.unshift(c)\n end\n end\n end\n end", "def getPermutations2(s,perm=[])\n substring = s[1..2]\n perm.push(s[0] + substring)\n perm.push(s[0] + substring.reverse)\n if perm.length >= factorial(s.length)\n return perm\n else\n s = rotateChar(s)\n getPermutations2(s,perm)\n end\nend", "def permsol(str)\n str.chars.permutation.to_a.map(&:join).uniq \nend", "def mixup_shuffle arr\n recursive_shuffle(arr, [])\nend", "def perm(nums, i, result)\n return result << nums.dup if i == nums.size\n\n (i...nums.size).each do |j|\n nums[i], nums[j] = nums[j], nums[i]\n perm(nums, i + 1, result)\n nums[i], nums[j] = nums[j], nums[i]\n end\nend", "def shuffle(array)\n recursive_shuffle array, []\nend", "def pbEachCombination(array,num)\n return if array.length<num || num<=0\n if array.length==num\n yield array\n return\n elsif num==1\n for x in array\n yield [x]\n end\n return\n end\n currentComb=[]\n arr=[]\n for i in 0...num\n currentComb[i]=i\n end\n begin\n for i in 0...num\n arr[i]=array[currentComb[i]]\n end\n yield arr\n end while _pbNextComb(currentComb,array.length)\nend" ]
[ "0.8647357", "0.85897994", "0.84596074", "0.8430699", "0.8413507", "0.84101796", "0.84101796", "0.84101796", "0.84101796", "0.8404899", "0.8383136", "0.83517617", "0.83476245", "0.8343056", "0.8307858", "0.83060837", "0.8285539", "0.81761634", "0.8172498", "0.81558454", "0.81368214", "0.8059565", "0.8035909", "0.7976919", "0.7949265", "0.7914205", "0.7874327", "0.78568333", "0.7854627", "0.7782098", "0.7755913", "0.7750648", "0.7749005", "0.77448726", "0.77071697", "0.75698715", "0.756526", "0.7518183", "0.7515043", "0.7473445", "0.74550676", "0.7388606", "0.7366494", "0.7347615", "0.7257075", "0.72348964", "0.7226953", "0.71974605", "0.71941555", "0.71036667", "0.70997775", "0.70445013", "0.6935526", "0.69173265", "0.6913314", "0.6908529", "0.6862583", "0.6846484", "0.6819471", "0.6796244", "0.67570007", "0.6742575", "0.6737587", "0.6731799", "0.671894", "0.67105347", "0.6692822", "0.6654488", "0.6637665", "0.6636227", "0.65947026", "0.65510017", "0.65470594", "0.6546843", "0.6524166", "0.6522671", "0.6497414", "0.64268035", "0.64063334", "0.63921404", "0.6379803", "0.6352162", "0.6306195", "0.63013697", "0.6288872", "0.62724036", "0.6220773", "0.6173047", "0.6107301", "0.60823774", "0.6081823", "0.6039355", "0.60296434", "0.6003333", "0.5994763", "0.5915291", "0.5890225", "0.58871365", "0.5867454", "0.58171463" ]
0.8478517
2
Back in the good old days, you used to be able to write a darn near uncrackable code by simply taking each letter of a message and incrementing it by a fixed number, so "abc" by 2 would look like "cde", wrapping around back to "a" when you pass "z". Write a function, `caesar_cipher(str, shift)` which will take a message and an increment amount and outputs the encoded message. Assume lowercase and no punctuation. Preserve spaces. To get an array of letters "a" to "z", you may use `("a".."z").to_a`. To find the position of a letter in the array, you may use `Arrayfind_index`.
def caesar_cipher(str, shift) letters = ("a".."z").to_a encoded_str = "" str.split('').each do |char| if char == " " encoded_str << " " next end old_idx = letters.find_index(char) new_idx = (old_idx + shift) % letters.count encoded_str << letters[new_idx] end encoded_str end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def caesar_cipher(string, shift_factor)\n\n\n upc_alphabet_arr = ('A'..'Z').to_a\n downc_alphabet_arr = ('a'..'z').to_a\n\n\n string_chars_arr = string.chars\n\n new_chars_arr = []\n\n string_chars_arr.each do |char|\n if upc_alphabet_arr.include?(char)\n new_index = (upc_alphabet_arr.index(char) + shift_factor)%26\n new_char = upc_alphabet_arr[new_index]\n\n new_chars_arr << new_char\n\n elsif downc_alphabet_arr.include?(char)\n new_index = (downc_alphabet_arr.index(char) + shift_factor)%26\n new_char = downc_alphabet_arr[new_index]\n\n new_chars_arr << new_char\n\n else \n new_chars_arr << char\n end\n end\n\n new_string = new_chars_arr.join(\"\")\n puts new_string\nend", "def caesar_cipher(string, shift)\n shifted = \"\"\n letters = (\"a\"..\"z\").to_a\n string.each_char do |char|\n old_idx = letters.find_index(char)\n if old_idx\n shifted << letters[(old_idx + shift) % 26]\n else\n shifted << \" \"\n end\n end\n\n shifted\nend", "def caesar_cipher(str, shift)\n results = []\n #get all chars\n chars = str.split('')\n # if its a char included in alpha then get index num of low case\n alphabet = ('a'..'z').to_a\n chars.each do |char|\n if alphabet.include?(char.downcase)\n index = alphabet.index(char.downcase)\n results << alphabet[(index+shift)%26]\n else\n results << char\n end\n end\n # add the shift to index and get the modulo and get the letter indexd there\n # else pass the char to results because not a letter\n\n results.join('')\n\nend", "def caesar_cipher(str, shift)\n letters = (\"a\"..\"z\").to_a\n\n encoded_str = \"\"\n str.each_char do |char|\n if char == \" \"\n encoded_str < \" \"\n next\n end\n old_idx = letters.find_index(char)\n new_idx = (old_idx + shift) % letters.count\n encoded_str << letters[new_idx]\n end\n encoded_str\nend", "def caesar_cipher(string, shift)\n\n while shift > 26 #prevents users from accessing a value beyond the letters of ASCII table\n puts 'Sorry choose a number equal to or lower than 26'\n shift.gets.chomp.to_i\n end \n \nstring.chars.map {|char| #.chars seperates each symbol of the string (including spaces) into an array; .map 'maps' each element in the block with |char| representing the variable being targeted\n if char =~ (/\\w/) && char == char.upcase #the =~ is a 'match operator' used to match current char with \\w (any alphanumeric character) AND checks to see if char is uppercase\n char = char.ord + shift # .ord gives the ASCII value of the char + given shift num \n if char > 90 #if char is greater than 90, substract the total letters of alphabet to link char with appropriately shifted posotion \n char = (char - 26).chr #use chr to return it back to letter form \n else\n char.chr #if not greater than 90 (all char greater than 90 fall into lowercase category), simply return the .chr \n end\n elsif char =~ (/\\w/) && char == char.downcase #elsif char matches alphanumeric character AND downcase....\n char = char.ord + shift #.ord value +shift \n if char > 122 #if greater than lowercase z in ASCII table...\n char = (char - 26).chr \n else\n char.chr\n end\n else #if its not a letter just char it up some \n char\n \n end}.join #rejoin the .chars array as shifted string \n \nend", "def caesar_cipher(str, shift)\n letters = (\"a\"..\"z\").to_a\n\n encoded_str = \"\"\n str.each_char do |char|\n if char == \" \"\n encoded_str << \" \"\n next\n end\n\n old_idx = letters.find_index(char)\n new_idx = (old_idx + shift) % letters.count\n\n encoded_str << letters[new_idx]\n end\n\n encoded_str\nend", "def caesar_cipher(string, shift)\n lower = ('a'..'z')\n caesar_string = ''\n\n string.each_char do |char|\n shift.times { char = char.next } if lower.include?(char.downcase) # identify letters only\n caesar_string << char[-1]\n end\n caesar_string\nend", "def caesar_cipher(str, shift)\n letters = (\"a\"..\"z\").to_a\n new_string = \"\"\n str.chars.each do |char|\n if letters.include?(char)\n shift_position = (letters.index(char) + shift) % 26\n new_string += letters[shift_position]\n else\n new_string += char\n end\n end\n new_string\nend", "def caesar_cipher(string, shift_factor)\n alphabet = [\"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\", \"i\", \"j\", \"k\", \"l\", \"m\", \"n\", \"o\", \"p\", \"q\", \"r\", \"s\", \"t\", \"u\", \"v\", \"w\", \"x\", \"y\", \"z\", \"A\", \"B\", \"C\", \"D\", \"E\", \"F\", \"G\", \"H\", \"I\", \"J\", \"K\", \"L\", \"M\", \"N\", \"O\", \"P\", \"Q\", \"R\", \"S\", \"T\", \"U\", \"V\", \"W\", \"X\", \"Y\", \"Z\"]\n return string.split(//).map { |el|\n el.gsub(/\\w/, \"#{ind = alphabet.index(el).to_i + shift_factor\n until alphabet.index(el).to_i > 25 && ind < 52 || alphabet.index(el).to_i < 26 && ind < 26\n ind -= 26\n end\n alphabet[ind]}\")\n }.join\nend", "def caesar_cipher(str, shift)\n alpha = (\"a\"..\"z\").to_a\n new_str = \"\"\n \n str.each_char do |char|\n if alpha.index(char)\n old_idx = alpha.index(char)\n new_str += alpha[(old_idx + shift) % 26]\n else\n new_str += char\n end\n end\n\n new_str\nend", "def caesar_cipher(offset, string)\n\n result = \"\"\n\n array = string.split(\"\")\n\n i = 0\n\n while array.length > i\n\n ascii = array[i].ord\n p ascii\n\n if( array[i] != \" \") # keep space the same, do not add offset\n ascii += offset\n end\n\n if ascii >= 122 # IMPORTANT\n\n # look at note2self\n #\n back_round_from_a = ( ascii - \"a\".ord ) % 26\n #\n # look at note2self\n\n ascii = back_round_from_a + \"a\".ord\n # if x, i.e. x = 199 & offset = 3 so, total 122, then back_round_from_a = 0\n # Therefor, back_round_from_a + \"a\".ord === 0 + 97 => a\n\n end\n\n letter = ascii.chr\n p letter\n\n result += letter\n\n i += 1\n end # while\n\n p result\n\n return result\n\nend", "def caesar_cipher(input_string, shift_factor)\r\n positions = input_string.unpack('C*')\r\n shifted_positions = positions.map do |pos|\r\n case pos\r\n when (65..90), (97..122)\r\n shifted = pos + (shift_factor % 26) # use % 26 to account for shift factors over 26\r\n if (shifted > 90 && shifted < 97) || (shifted > 122) # loop around\r\n shifted = shifted - 26\r\n end\r\n pos = shifted\r\n else\r\n pos # ignore non-alphabet chars\r\n end\r\n end\r\n result_string = shifted_positions.pack('C*')\r\n puts result_string\r\nend", "def caesar_cipher(caesar_string, shift_factor) \n alphabet = (\"a\"..\"z\").to_a\n new_string = \"\"\n\n caesar_string.each_char do |input|\n if input == \" \"\n new_string += \" \"\n else \n old_index = alphabet.find_index(input)\n new_index = (old_index + shift_factor) % alphabet.count\n new_string += alphabet[new_index]\n end\n end\n\nputs new_string.chomp\n\nend", "def caesar_cipher(str, shift)\n alph = (\"a\"..\"z\").to_a\n\n decode = \"\"\n\n str.chars.each do |letter|\n if letter == \" \"\n decode << letter\n end\n\n num = alph.find_index(letter)\n decode << alph[(num + shift) % 26]\n end\n\n decode\nend", "def caesar_cipher(str, shift)\n\nend", "def caesar_cipher(str, shift)\n dictionary = (\"a\"..\"z\").to_a\n new_array = []\n str.split(\"\").each do |letter|\n index_letter = dictionary.find_index(letter)\n if index_letter.nil?\n new_array << letter\n else\n new_index = (index_letter + shift) % 26\n\n new_array << dictionary[new_index]\n end\n end\n new_array.join\nend", "def caesar_cipher(str, shift)\n alphabet ||= ('a'..'z').to_a\n res = \"\"\n str.chars.each do |letter|\n if letter == \" \"\n res += letter\n else\n old_idx = alphabet.index(letter)\n new_idx = old_idx*shift % 26\n res += alphabet[new_idx]\n end\n end\n res\nend", "def caesar_cipher(str, shift)\n letters = (\"a\"..\"z\").to_a\n\n encoded_str = \"\"\n str.chars.each do |char|\n if char == \" \"\n encoded_str += \" \"\n next\n end\n\n old_idx = letters.index(char)\n new_idx = (old_idx + shift) % letters.length\n encoded_str << letters[new_idx]\n end\n\n encoded_str\nend", "def caesar_cipher(str, shift)\n alpha = ('a'..'z').to_a\n\n str.split(' ').map do |word|\n word.chars.map { |x| alpha[(alpha.index(x) + shift) % 26] }.join\n end.join(' ')\nend", "def caesar_cipher(str, shift)\n alphabet = ('a'..'z').to_a\n arr = []\n words = str.split\n words.each do |word|\n newword = ''\n word.each_char do |chr|\n idx = alphabet.index(chr) + shift\n newword += alphabet[idx % alphabet.length]\n end\n arr << newword\nend\n arr.join(' ')\nend", "def caesar_cipher(string, shift)\n alphabet = (\"a\"..\"z\").to_a\n\n result = \"\"\n string.each_char do |char|\n if char == \" \"\n result += \" \"\n else\n result += alphabet[(alphabet.index(char) + shift) % 26]\n end\n end\n\n return result\nend", "def caesar_cipher(string, shift = DateTime.now.day) # I set shift to be the current day if I do not include a parameter for it\n string.tr Alphabet.join, Alphabet.map{ |array| array.rotate shift }.join # This looks at every single character in the string and uses .map to rotate the array to bascially let it shift how ever many times within the array to assign the new character to the string variable\nend", "def caesar_cipher(string, shift)\nend", "def caesar_cipher(str, shift)\n cipher = (\"a\"..\"z\").to_a\n\n result = \"\"\n str.chars.each do |char|\n if char == \" \"\n result << char\n else\n shifted_idx = cipher.index(char) * shift % cipher.length\n result << cipher[shifted_idx]\n end\n end\n result\nend", "def caesar_cipher(string, shift)\n begin\n shift = shift % 26\n new_string = \"\"\n letters = string.split('')\n letters.each do |i|\n if i >='a' && i <= 'z'\n encrypted = i.ord + shift\n if encrypted > 122 # ASCII for 'z'; wraps around to 'a'\n encrypted = encrypted - 26\n end\n elsif i >='A' && i <= 'Z'\n encrypted = i.ord + shift\n if encrypted > 90 # ASCII for 'Z'; wraps around to 'A'\n encrypted = encrypted - 26\n end\n else\n encrypted = i\n end\n new_string << encrypted.chr\n end\n return new_string\n rescue TypeError\n return \"Invalid shift factor. Please enter a number.\"\n end\nend", "def caesar(string, shift)\n letters = string.chars\n code_word = []\n letters.each do |letter|\n if /[a-zA-Z]/ !~ letter\n code_word << letter\n else\n new_ord = letter.ord + shift\n if letter.ord > 90\n first_letter = 97\n else\n first_letter = 65\n end\n code_word << (((new_ord % first_letter) % 26) + first_letter).chr\n end\n end\n code_word.join\nend", "def caesar(str, shift)\n\n alpha = ('a'..'z').to_a\n cipher = []\n\n str.split(\"\").map do |char|\n\n if alpha.include? char\n\n char_index = (alpha.index(char) + shift) % 26\n\n cipher << alpha[char_index]\n\n elsif alpha.include? char.downcase\n\n char_index = (alpha.index(char.downcase) + shift) % 26\n\n cipher << alpha[char_index].upcase\n\n\n else\n\n cipher << char\n\n end\n\n end\n\n cipher.join\n\nend", "def caesar_cipher(message, shift_key)\n result = \" \"\n message.each_char do |letter|\n if letter.ord.between?(65,90) || letter.ord.between?(97, 122)\n final_code = letter.ord + shift_key\n\n final_code -= 26 if (final_code > 91 && letter.ord < 91) || final_code > 122\n result += final_code.chr\n else\n result += letter\n end\n end\n return result\nend", "def Caesar_cipher(input_string,input_shift)\n\n alphabet = ('a'..'z').to_a\n alphabetUpCase = ('A'..'Z').to_a\n\n input_string.each_char {|letter| \n if letter =~ /[A-Z]/\n new_letter_index = alphabetUpCase.index(letter) + input_shift\n if new_letter_index > 25\n new_letter_index -= 26\n puts alphabetUpCase[new_letter_index]\n else\n puts alphabetUpCase[new_letter_index]\n end\n elsif letter =~ /[a-z]/\n new_letter_index = alphabet.index(letter) + input_shift\n if new_letter_index > 25\n new_letter_index -= 25\n puts alphabet[new_letter_index]\n else\n puts alphabet[new_letter_index]\n end\n else\n puts letter\n end\n }\nend", "def caesar_cipher(string, shift_factor)\n output = \"\"\n string.scan (/./) do |i|\n if (\"a\"..\"z\").include? (i.downcase)\n shift_factor.times {i = i.next}\n end\n output << i[-1]\n end\n return output\nend", "def caesar_cipher(string, shift)\n\tstring = string.to_s\n\tshift = shift.to_i\n\tnew_string = \"\"\n\n\tstring.each_byte do |i|\n\t\tif (i > 64 && i < 91) #A-Z\n\t\t\tif (i+shift) > 90\n\t\t\t\tnew_string << (i+shift - 26).chr \n\t\t\telse\n\t\t\t\tnew_string << (i+shift).chr\n\t\t\tend\n\t\telsif (i > 96 && i < 123) #a-z\n\t\t\tif (i+shift) > 122\n\t\t\t\tnew_string << (i+shift - 26).chr\n\t\t\telse\n\t\t\t\tnew_string << (i+shift).chr\n\t\t\tend\n\t\telse\n\t\t\tnew_string << i.chr\n\t\tend\n\tend\n\n\tputs new_string\nend", "def caesar_cipher(str, num)\n alphabet = 'abcdefghijklmnopqrstuvwxyz'\n\n str.each_char.with_index do |char, i|\n shift = alphabet.index(char) + num # shifting num chars in the alphabet\n if shift > 26 # restart at 0 after index 26\n shift -= 26\n end\n str[i] = alphabet[shift]\n end\n\n str\nend", "def caesar_cipher(word, shift)\n letters = ('a'..'z').to_a.concat(('A'..'Z').to_a)\n cipher = \"\"\n\n #only shift alpha characters\n word.each_char do |c|\n cipher += letters.include?(c) ? letters[(letters.index(c) + shift) % 52] : c\n end\n\n cipher\nend", "def caesars_cipher(str, shift = 1)\n encrypted = ''\n\n ascii_nums = str.bytes\n ascii_nums.each do |i|\n encrypted << case i\n when 65..90\n ((i + shift - 65) % 26 + 65).chr\n when 97..122\n ((i + shift - 97) % 26 + 97).chr\n else\n i.chr\n end\n end\n encrypted\nend", "def caesar_cipher(string, shift)\n alphabet = Array('a'..'z')\n encrypter = Hash[alphabet.zip(alphabet.rotate(shift))]\n string.chars.map { |c| encrypter.fetch(c, \" \") }\nend", "def caesar_cipher(string_to_cipher, shift)\n shifted_string = \"\"\n string_to_cipher.chars.map do |char|\n ascii = char.ord\n if ((65..90) === ascii || (97..122) === ascii) then \n ascii += shift \n if (ascii > 90 && ascii < 97) || (ascii > 122) then\n ascii -= 26\n end\n end\n shifted_string += ascii.chr\n\n end\n shifted_string\nend", "def caesar_cipher(string, shift_factor = 0)\n result = ''\n string.each_char do |char|\n # use cipher only if char is an uppercase or lowercase letter\n if char.ord.between?(65, 90) || char.ord.between?(97, 122)\n new_code = char.ord + shift_factor\n\n #ensure wrapping from Z to A or z to a\n new_code -= 26 if (new_code > 91 && char.ord < 91) || new_code > 122\n result += new_code.chr\n else\n result += char\n end\n end\n result\nend", "def caesar_cipher text, shift = 5 #shifts letters by 5 - by default\nletters = text.split(//)\nncrypted_string = \"\"\nletters.each do |x|\nif (x =~ /\\w/) && (x =~ /\\D/) && (x != \"_\") ##Checks with RegEx's whether the current array index' value is a word character + a non-digit character + not an underscore '_', so only a-z & A-Z letters pass the test and are affected by the following code.\nif x == x.upcase ##<-I do this so I can wrap back to A when Z's #ord index is exceeded. \"A\".ord == 65, \"Z\".ord == 90\nx = x.ord + shift\nif x > 90\nx -= 90\nx += 64\nend\nelsif x == x.downcase ##Same is done here for downcases as is done above for upcases. \"a\".ord == 97, \"z\".ord == 122\nx = x.ord + shift\nif x > 122\nx -= 122\nx += 96\nend\nend\nx.chr\nend\nncrypted_string << x\nend\nputs ncrypted_string\nend", "def caesar_cipher(offset, string)\n\talph = [\"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\", \"i\", \"j\", \"k\", \"l\", \"m\", \"n\", \"o\", \"p\", \"q\", \"r\", \"s\", \"t\", \"u\", \"v\", \"w\", \"x\", \"y\", \"z\"]\n\ti = 0\n\tnew_string = \"\"\n\tind = 0\n\n\tputs string.length \n\n\twhile i < string.length\n\t\t\n\t\t\n\t\t\n\t\tif string[i] == \" \"\n\t\t\tnew_string = new_string + \" \"\n\t\t\t\n\t\telse \n\t\t\tind = alph.index(string[i])\n\t\t\t\n\t\t\tif (ind + offset) > 25\n\t\t\t\tind = (ind + offset) - 26 \n\t\t\t\t\n\t\t\t\tnew_string = new_string + alph[(ind)]\n\t\t\t\t\n\t\t\telse \n\t\t\t\tnew_string = new_string + alph[(ind + offset)]\n\t\t\t\t\n\t\t\tend\n\t\tend\n\t\ti +=1\n\tend\n\n\treturn new_string\n\nend", "def ceasar_cipher(phrase, shift)\n phrase.downcase!\n words = phrase.split(\" \")\n words.each do |word| #for each word in the sentence\n word.split(\"\").each_with_index do |letter, index| #for each letter in the word\n asciiValue = letter.ord\n if(asciiValue >= 97 && asciiValue <= 122) #if the value is a letter and not a character or digit\n\n newValue = asciiValue + shift\n \n if newValue > 122 #if it goes beyond z, loop around back to a\n difference = newValue - 122\n offset = 96+difference\n letter = offset.chr\n word[index] = letter\n else\n letter = newValue.chr \n word[index] = letter\n end\n end \n end\n end\n puts words.join(\" \")\nend", "def caesar_cipher(str, shift)\n result = \"\"\n str.each_char do |char|\n if char == \" \"\n result += \" \"\n next\n else\n shift.times { char == \"z\" ? char = 'a' : char = char.next }\n result += (char)\n end\n end\n result\nend", "def caesar_cipher(word, shift) \n\n #Checks if 'word' is a String \n unless word.is_a? String\n return \"Input was not text\"\n end\n\n #Initializes a temp word\n new_word = \"\"\n\n #Creates an array of ascii numbers for each letter in 'word'\n word_array = word.codepoints.to_a\n\n #Loops over each letter in 'word' and manipulates\n for i in 0..word_array.length-1\n\n #Keeps track of the letter casing\n lowercase = false\n if word_array[i] >= 97 && word_array[i] <= 122\n lowercase = true\n else\n lowercase = false\n end\n\n #Adds the shift to the letter (checks if the character is a letter and not a symbol or space)\n if word_array[i] >= 65 && word_array[i] <= 122\n word_array[i] += shift\n end\n\n # Checks character ascii values\n if word_array[i] > 122 && lowercase == true\n word_array[i] -= 26\n elsif word_array[i] > 90 && lowercase == false\n word_array[i] -= 26\n end\n new_word += word_array[i].chr\n end\n return new_word\nend", "def caesar_cipher(phrase, shift)\n shifted_array = phrase.chars.map {|char| shift_letter(char, shift)}\n new_phrase = shifted_array.join\nend", "def caesar_cipher(text, shift)\n upper = ('A'..'Z').to_a\n lower = ('a'..'z').to_a\n shifted = text.split('').map do |character|\n case character\n when /[[:upper:]]/ then \n (upper.rotate(shift))[upper.index(character)]\n when /[[:lower:]]/ then \n (lower.rotate(shift))[lower.index(character)]\n else character\n end\n end\n shifted.join\nend", "def caesar_cipher(shift, string)\n alphabet = (\"a\"..\"z\").to_a\n blank = string.each_char.map do |letter| alphabet.include?(letter) ? alphabet[(alphabet.index(letter) + shift) % alphabet.length] : letter\n end\n return blank.join #must use return not puts, otherwise tests will not pass! Also no (\" \") needed because mapping adds a \" \"\n #in between every letter and a \"nil\" + \" \" in between every word, and join deletes the spaces in between the letters\n #and deletes the nil in between words, leaving one space in between words.\nend", "def caesar_cipher(word, shift)\n ascii_shift = 97\n word.each_codepoint.map do |num|\n num = num - ascii_shift + shift\n num = (num % 26) + ascii_shift\n end\n .inject('', :<<)\nend", "def caesar_cipher(offset, string)\n words = string.split(\" \")\n\n word_idx = 0\n while word_idx < words.length\n word = words[word_idx]\n\n letter_idx = 0\n while letter_idx < word.length\n char_i = word[letter_idx].ord - \"a\".ord\n\n new_char_i = (char_i + offset) % 26\n word[letter_idx] = (\"a\".ord + new_char_i).chr\n\n letter_idx += 1\n end\n\n word_idx += 1\n end\n\n return words.join(\" \")\nend", "def Caesar_Cypher(string, shift_factor)\n coded_array = []\n arr = string.split(\"\")\n\n arr.each do |letter|\n ascii_letter = letter.ord\n\n if ascii_letter.between?(65, 90)\n ascii_letter += shift_factor\n if ascii_letter > 90\n ascii_letter -= 26\n end\n elsif ascii_letter.between?(97, 122)\n ascii_letter += shift_factor\n if ascii_letter > 122\n ascii_letter -= 26\n end\n end\n\n coded_array.push(ascii_letter.chr)\n end\n\n cypher = coded_array.join(\"\")\n p cypher\nend", "def caesar_cipher phrase, shift\n\tphrase.split('').map { |char| \n\t\tif (char.match(/[a-z]/))\n\t\t\t((((char.ord - 97) + shift) % 26) + 97).chr\n\t\telsif (char.match(/[A-Z]/))\n\t\t\t((((char.ord - 65) + shift) % 26) + 65).chr\n\t\telse\n\t\t\tchar\n\t\tend\n\t}.join\nend", "def caesar_cipher(text, shift=0)\n return text if shift == 0 || text == \"\" || shift.nil? || text.nil?\n standard_key_caps = (\"A\"..\"Z\").to_a\n standard_key_lower = (\"a\"..\"z\").to_a\n\n while shift < 0 do\n shift += 26\n end\n\n i = shift % 26\n\n\n shift_key_caps = []\n range = ('A'..'Z').to_a\n range.each do |x|\n shift_key_caps[i] = x\n i+=1\n i=0 if i >= 26\n end\n\n i=shift\n shift_key_lower = []\n range = ('a'..'z').to_a\n range.each do |x|\n shift_key_lower[i] = x\n i+=1\n i=0 if i >= 26\n end\n\n text_mod = \"\"\n text.each_char do |x|\n character = x\n if standard_key_caps.include?(x)\n offset = shift_key_caps.index(x)\n character = standard_key_caps[offset]\n elsif standard_key_lower.include?(x)\n offset = shift_key_lower.index(x)\n character = standard_key_lower[offset]\n end\n text_mod = text_mod + character\n end\n text_mod\nend", "def caesar_cipher(str, shift)\n shifted = \"\"\n words = str.split(\" \")\n words.each do |word|\n word.each_char do |char|\n shifted += shift_char(char, shift)\n end\n shifted += \" \"\n end\n shifted[0...-1]\nend", "def caesar_cipher2(message, offset)\n\n\toffset %= 26\n\tcipher = ''\n\n\t# Direction is relevant\n\tincrement = true if offset > 0\n\n\tif increment\n\t\tmessage.each_char do |c|\n\t\t\toffset.times do\n\t\t\t\tif c.match(/[A-Ya-y]/)\n\t\t\t\t\tc.next! # No wrap required on these letters, increment\n\t\t\t\telse\n\t\t\t\t\tif c.match(/Z/) #Wrap required\n\t\t\t\t\t\tc = 'A'; end\n\t\t\t\t\tif c.match(/z/)\n\t\t\t\t\t\tc = 'a'; end; end; end\n\t\t\tcipher << c # Insert scrambled character to output string\n\t\tend\n\telse # decrement\n\t\tmessage.each_char do |c|\n\t\t\toffset.abs.times do # Use absolute value, can't do a loop negative times!\n\t\t\t\tif c.match(/[B-Zb-z]/)\n\t\t\t\t\tc = (c.ord - 1).chr # Quick shuffling using ASCII value\n\t\t\t\telse\n\t\t\t\t\tif c.match(/A/) # Reverse wrap required\n\t\t\t\t\t\tc = 'Z'; end\n\t\t\t\t\tif c.match(/a/) \n\t\t\t\t\t\tc = 'z'; end; end; end\n\t\t\tcipher << c # Insert scrambled character to output string\n\t\tend\n\tend\n\n\treturn cipher\nend", "def caesar_cipher(input, shift)\n\toutput = \"\"\n\t\n\tinput.each_byte do |ascii|\n\t\t# Take each character's ASCII code\n\t\tif ascii >= 65 && ascii <= 90\n\t\t\t# If character is uppercase letter:\n\t\t\tascii -= 65 \t\t\t\t\t# Subtract to A=0, Z=25\n\t\t\tascii = (ascii + shift) % 26 \t# Shift with wrapping Z-to-A\n\t\t\tascii += 65\t\t\t\t\t\t# Add back to new ASCII code\n\t\t\toutput += ascii.chr\t\t\t\t# Add ASCII character to output\n\t\telsif ascii >= 97 && ascii <= 122\n\t\t\t# If character is lowercase letter:\n\t\t\tascii -= 97 \t\t\t\t\t# Subtract to a=0, z=25\n\t\t\tascii = (ascii + shift) % 26 \t# Shift with wrapping z-to-a\n\t\t\tascii += 97\t\t\t\t\t\t# Add back to new ASCII code\n\t\t\toutput += ascii.chr\t\t\t\t# Add ASCII character to output\n\t\telse\n\t\t\toutput += ascii.chr\t\t\t\t# Else just add character to output\n\t\tend\n\tend\n\toutput\nend", "def caesar_cipher(str, num)\n new_str = \"\"\n str.each_char { |c| new_str += shift_char(c, num) }\n new_str\nend", "def solve_cipher (message, shift:-3)\n \n #Iterate over message\n message.each_char do |c|\n\n\n \t#Calculate the integer ordinal of the char\n \tindex = c.ord\n\n \t\n \t#If lower case\n \tif (97..122) === index\n\t \t#Positive shift\n\t \tif shift > 0\n\t \t\t#If it's a \"special\" letter apply the \"special\" cipher , if not apply the \"normal cipher\" \n\t \t\tif index+shift>122\n\t \t\t\tprint (97+(index+shift-123)).chr \t\t\n\t \t\telse \n\t \t\t\tprint (index+shift).chr\n\t \t\tend\n\t \t#Negative shift\n\t \telsif shift < 0 \n\t \t\t#If it's a \"special\" letter apply the \"special\" cipher , if not apply the \"normal cipher\" \n\t \t\tif index+shift<97\n\t \t\t\tprint (123-(97-index)+shift).chr \t\t\n\t \t\telse \n\t \t\t\tprint (index+shift).chr\n\t \t\tend\n\n\t \telse\n\t \t\tprint index.chr \t\t\n\t \tend\n\t#If upper case\n\telsif (65..90) === index\n\t \t#Positive shift\n\t \tif shift > 0 \n\t \t\t#If it's a \"special\" letter apply the \"special\" cipher , if not apply the \"normal cipher\"\n\t \t\tif index+shift>90\n\t \t\t\tprint (65+(index+shift-91)).chr \t\t\n\t \t\telse \n\t \t\t\tprint (index+shift).chr\n\t \t\tend\n\t \t#Negative shift\n\t \telsif shift < 0 \n\t \t\t#If it's a \"special\" letter apply the \"special\" cipher , if not apply the \"normal cipher\" \n\t \t\tif index+shift<65\n\t \t\t\tprint (91-(65-index)+shift).chr \t\t\n\t \t\telse \n\t \t\t\tprint (index+shift).chr\n\t \t\tend\n\n\t \telse\n\t \t\tprint index.chr \t\t\n\t \tend\n\t#If other character\n\telse\t\t\n\t \t\tprint index.chr \n\tend\n\t\t\n \t\t\n end\nend", "def caesar_cipher(userWord, userShift)\n userWordArray = userWord.split(\"\") #Makes an array of characters\n shift = userShift%26\n c = []\n userWordArray.each do |letter|\n if letter.ord == 32\n c.push(letter)\n elsif letter.ord < 122\n b = letter.ord + shift\n c.push(b.chr)\n else\n b = letter.ord \n diff= (b-122) + shift\n b = 96+diff\n c.push(b.chr)\n end\n end\n c = c.join\nend", "def caesar_cipher(string, shift)\n result = \"\"\n string.each_char do |ch|\n result += ch == \" \" ? ch : shift(ch, shift)\n end\n result\nend", "def vigenere_cipher(str, arr)\n alpha = ('a'..'z').to_a\n new_msg = ''\n\n str.each_char.with_index do |char,idx|\n old_pos = alpha.index(char)\n new_pos = old_pos + arr[idx % arr.length]\n new_msg += alpha[new_pos % 26]\n end\n new_msg\nend", "def cipher(string, shift)\n message = (string.chars.map do |char|\n shift.times { char.next! } if /[A-Za-z]/.match(char)\n char[0]\n end).join\n puts message\nend", "def caesar_cipher(word, shift)\n\tletters = ('a'..'z').to_a.concat(('A'..'Z').to_a) # create array of all possible chars\n\tdecoded = \"\"\n\n\tword.each_char do |c| \n\t\tif letters.include?(c)\t\n\t\t\tdecoded += letters[letters.index(c) - shift]\n\t\telse\n\t\t\tdecoded += c # adds non-alpha char to the decoded string\n\t\tend\n\tend\n\t decoded\nend", "def caesar_cipher(word, shift)\n\tletters = ('a'..'z').to_a.concat(('A'..'Z').to_a) # create array of all possible chars\n\tdecoded = \"\"\n\n\tword.each_char do |c| \n\t\tif letters.include?(c)\t\n\t\t\tdecoded += letters[letters.index(c) - shift]\n\t\telse\n\t\t\tdecoded += c # adds non-alpha char to the decoded string\n\t\tend\n\tend\n\t decoded\nend", "def vigenere_cipher(message, keys)\n alphabet = (\"a\"..\"z\").to_a\n indices = message.split(\"\").map {|char| alphabet.index(char)}\n \n ciphered_message = \"\"\n indices.each_with_index do |n, i|\n shift_amount = keys[i % keys.length]\n new_index = (n + shift_amount) % alphabet.length\n ciphered_message += alphabet[new_index]\n end\n\n ciphered_message\nend", "def caesar_cipher(string, shift = 1)\n alphabet = Array('a'..'z')\n non_caps = Hash[alphabet.zip(alphabet.rotate(shift))]\n \n alphabet = Array('A'..'Z')\n caps = Hash[alphabet.zip(alphabet.rotate(shift))]\n \n encrypter = non_caps.merge(caps)\n \n string.chars.map { |c| encrypter.fetch(c, c) }\nend", "def caesar_cypher(string, shift)\n string.split('').map do |char|\n if char == ' '\n char\n elsif char.ord + shift > 'z'.ord\n (char.ord + shift - 26).chr\n else\n (char.ord + shift).chr\n end\n end.join('')\nend", "def caesar_cipher(str, num)\n alphabet = \"abcdefghijklmnopqrstuvxyz\"\n new_str = \"\"\n \n str.each_char do |char|\n old_idx = alphabet.index(char) # each items index on the alphabet\n\tnew_idx = old_idx + num\n\tnew_char = alphabet[new_idx % 26] # to ensure that results is always less than 26 e.g. 'z' + 4 will fail without this, will now return to 'a' + 4 = 'd'.\n\tnew_str += new_char\n\tend\n \n return new_str\n\nend", "def solve_cipher(input, shift=nil)\n\n# Setting -3 as defautl shift\n\tif shift.nil? \n\t\tshift = -3\n\tend\n\n\n# Positive numbers shift right and negative numbers shift left \n\tif shift < 0\n\t\tshift = -shift\n\tend\n\n\toutput = \"\"\n\t(input.split\"\").each do |letra|\n\n\t\t# Spaces remain as spaces\n\t\tif letra == \" \"\n\t\t\toutput << \" \"\n\n\t\t# a will be z in case of shift = 1\n\t\telsif letra == 'a'\n\t\t\tindice = 122 + shift\n\n\t\telse\n\t\t\tindice = letra.ord - shift\n\n\t\toutput << indice.chr\n\t\tend\n\tend\n\tputs output\nend", "def caesar_cipher(string,num)\n alpha = (\"a\"..\"z\").to_a \n string_array = \"\"\n string.each_char do |char|\n if alpha.include?(char)\n old_index = alpha.index(char)\n new_index = old_index + num \n string_array += alpha[new_index % 26]\n else\n string_array += char \n end\n\n end\n return string_array\nend", "def caeser_cipher(message, inc)\n message.downcase!\n alphabet = (\"a\"..\"z\").to_a\n message_array = message.split(//)\n puts(message_array)\n\n message_index_array = message_array.map do |e|\n alphabet.index(e)\n end\n\n puts(message_index_array)\n rotated = alphabet.rotate(inc)\n puts(rotated)\n\n crypted_array = message_index_array.map do |e|\n if e == nil\n \" \"\n else\n rotated[e]\n end \n end\n\n crypted_array.join\n #it iterates through the message array, and finds the index of each character within the alphabet\n #the alphabet array shifts based on inc\n #each chacter in the message array is swapped out for it's indexed counterpart. \nend", "def caesar_cipher(str, num)\n new_str = \"\"\n alphabet = \"abcdefghijklmnopqrstuvwxyz\"\n str.each_char do |char|\n old_index = alphabet.index(char)\n new_index = old_index + num\n new_char = alphabet[new_index % 26] # MOST IMPORTANT STEP!!!!! THIS WILL ALSO TAKE CARE OF new_index > 26\n new_str += new_char\n end\n return new_str\nend", "def vigenere_cipher(msg, arr)\n alphabet = (\"a\"..\"z\").to_a\n new_msg = \"\"\n msg.each_char.with_index do |char, i|\n pos= alphabet.index(char)\n key = arr[i % arr.length]\n new_pos = (pos + key) % alphabet.length\n new_msg += alphabet[new_pos]\n end\n new_msg\nend", "def caesar_cipher(str, num)\n alphabet = \"abcdefghijklmnopqrstuvwxyz\"\n new_str = \"\"\n \n\tstr.each_char do |char|\n old_idx = alphabet.index(char)\n new_idx = old_idx + num\n new_char = alphabet[new_idx % 26]\n new_str += new_char\n\n end\n return new_str\n\nend", "def caesar(str,shift)\n str_split = str.split(\"\")\n str_shift = str_split.map{|char| char_shift(char, shift)}\n str_final = str_shift.join(\"\")\n end", "def caesar_cipher(str, shift)\n res = [] \n str.split(\" \").each do |word|\n res << encode_word(word, shift)\n end\n res.join(' ')\nend", "def caesar_cipher(str, num)\r\n alphabet = \"abcdefghijklmnopqrstuvwxyz\"\r\n new_str = \"\"\r\n\r\n str.each_char do |char|\r\n old_idx = alphabet.index(char)\r\n new_idx = old_idx + num\r\n new_char = alphabet[new_idx % 26]\r\n new_str += new_char\r\n end\r\n\r\n return new_str\r\nend", "def decrypt_caesar_cipher(string, shift = -@offset_value.to_i)\n alphabet = Array('a'..'z')\n encrypter = Hash[alphabet.zip(alphabet.rotate(shift))]\n string.chars.map { |c| encrypter.fetch(c, \" \") }\nend", "def caesar_cipher(string, shift = 1)\n alphabet = Array('a'..'z')\n non_caps = Hash[alphabet.zip(alphabet.rotate(shift))]\n \n alphabet = Array('A'..'Z')\n caps = Hash[alphabet.zip(alphabet.rotate(shift))]\n \n encrypter = non_caps.merge(caps)\n \n string.chars.map { |c| encrypter.fetch(c, c) }\n end", "def caesar_cipher(str, num)\n alphabet = \"abcdefghijklmnopqrstuvwxyz\"\n new_str = \"\"\n\n str.each_char do |char|\n old_idx = alphabet.index(char)\n new_idx = old_idx + num\n new_char = alphabet[new_idx % 26]\n new_str += new_char\n end\n\n return new_str\nend", "def caesar_cipher(str, num)\n alphabet = \"abcdefghijklmnopqrstuvwxyz\"\n new_str = \"\"\n\n str.each_char do |char|\n old_idx = alphabet.index(char)\n new_idx = old_idx + num\n new_char = alphabet[new_idx % 26]\n new_str += new_char\n end\n\n return new_str\nend", "def solve_cipher(input_array,shift)\n\toutput_array = []\n\tinput_array.each do |char|\n\t\tpos1 = char.ord\n\t\tpos2 = pos1 + shift\n\t\tif pos2 < 97\n\t\t\tpos3 = 123 - (97 - pos2) \n\t\t\toutput_array << pos3.chr\n\t\telsif pos2 > 122\n\t\t\tpos3 = 96 + (pos2 - 122) \n\t\t\toutput_array << pos3.chr\n\t\telse\n\t\t\toutput_array << pos2.chr\n\t\tend\n\tend\n\toutput_array\nend", "def caesar_cipher(str, shift)\n word = str.split(\" \")\n ans = \"\"\n word.each do |var|\n if var == word.last\n ans << caeser_helper(var, shift)\n else\n ans << caeser_helper(var, shift) + \" \"\n end\n end\n \n ans\nend", "def caesar_cypher (text, shift)\n\tupper = (\"A\"..\"Z\").to_a\n\tlower = (\"a\"..\"z\").to_a\n\ttext_a = text.chars\n\tfinished = \"\"\n\ttext_a.each do |char|\n\t\t# Check if the character is uppercase\n\t\tif upper.include?(char)\n\t\t\tindex = upper.index(char)\n\t\t\tindex += shift\n\t\t\twhile index >= upper.length\n\t\t\t\tindex -= upper.length\n\t\t\tend\n\t\t\tfinished << upper[index]\n\t\t# Check if it's lowercase\n\t\telsif lower.include?(char)\n\t\t\tindex = lower.index(char)\n\t\t\tindex += shift\n\t\t\twhile index >= lower.length\n\t\t\t\tindex -= lower.length\n\t\t\tend\n\t\t\tfinished << lower[index]\n\t\t# Append all miscellaneous characters that don't match\n\t\telse\n\t\t\tfinished << char\n\t\tend\n\tend\n\tfinished\nend", "def encipher(char, shift) \n if char >= 65 && char <= 90 \n index = char - 65\n shifted_char = (index + shift) % 26\n if shifted_char < 0 \n shifted_char += 26\n enciphered_char = shifted_char + 65\n else\n enciphered_char = shifted_char + 65\n end\n elsif char >= 97 && char <= 122\n index = char - 97\n shifted_char = (index + shift) % 26\n if shifted_char < 0\n shifted_char += 26\n enchiphered_char = shifted_char + 97\n else \n enciphered_char = shifted_char + 97\n end\n else\n char = char \n end\nend", "def caesar_cipher(sentence, raw_offset)\r\n offset = raw_offset % 26\r\n sentence.gsub(/([a-zA-Z])/){|char| shift_the_letter(char.ord, offset).chr}\r\nend", "def caesar_cipher(str, shift)\n new_str = []\n str = str.split('')\n str.each do |x| \n new_str << letter_cipher(x, shift) \n end\n new_str = new_str.join\n puts new_str\n return new_str\nend", "def caesar_cipher(str, num)\n \tnew_str = \"\"\n\n \tstr.each_char do |c|\n new_letter = c.ord + num\n if new_letter > 122\n shift = ((new_letter - 96) % 26) + 96\n new_str += shift.chr\n else\n new_str += new_letter.chr\n end\n end\n return new_str\nend", "def vigenere_cipher(str, arr)\n alphabet = \"abcdefghijklmnopqrstuvwxyz\"\n results = \"\"\n str.each_char.with_index do |char, i|\n ind = (alphabet.index(char) + arr[0]) % 26\n results += alphabet[ind]\n arr.rotate!\n end\n results\nend", "def caesar_cipher(str, num)\n alphabet = 'abcdefghijklmnopqrstuvwxyz'\n cipher = ''\n\n (0...str.length).each do |i|\n char = str[i]\n index = alphabet.index(char) + num\n cipher += alphabet[index % 26]\n end\n return cipher\nend", "def solve_cipher(input, shift)\n words = input.split(\"\")\n \n string_container = \"\" \n words.each do | letter|\n \tif letter == \" \"\n \t\tstring_container += \" \"\n\n \telse\n \tstring_container += (letter.ord + shift).chr\n\tend\n end\n\tstring_container\n\t#your code goes here\nend", "def caesar_cipher(text_to_cipher, key)\n # ensure key is a value between 0 and 25\n key = key % 26\n\n text_to_cipher.split(\"\").map do |character|\n if letter?(character)\n shift(character, key)\n else\n character\n end\n end.join(\"\")\n\nend", "def caesar_cipher(message, offset)\n\t\n\tchars\t= \t[]\n\tnums \t= \t[]\n\t\n\tif offset > -1\n\t\toffset = offset % 26\n\telse\n\t\toffset = -offset % 26\n\t\toffset = -offset; end\n\n\twords = message.split(\" \") # Make an array of words from the input, strip spaces\n\twords.each do |word| # From each word....\n\t\tchars.push(word.split(\"\")); end # Construct a sub-array of its characters\n\t\n\tchars.each do |char| # On each character....\n\t\tnums.push(char.map(&:ord)); end # Send the ASCII integer value to a new array\n\n\tfor i in 0...nums.length do # Step through each word\n\t\tfor j in 0...nums[i].length do # And each character\n\t\t\tnums[i][j] += offset # Alter the ASCII value by the offset\n\t\t\tnums[i][j] = nums[i][j].chr; end; end # Translate back, ASCII->String\n\n\treturn nums\nend", "def caesar_cipher(str, num)\n alphabet = \"abcdefghijklmnopqrstuvwxyz\"\n new_str = \"\"\n \n str.each_char do |char|\n old_idx = alphabet.index(char)\n new_idx = old_idx + num\n new_char = alphabet[new_idx % 26]\n new_str += new_char\n end\n\n return new_str\nend", "def caesar_cipher(str, num)\n alphabet = \"abcdefghijklmnopqrstuvwxyz\"\n new_str = \"\"\n \n str.each_char do |char|\n old_idx = alphabet.index(char)\n new_idx = old_idx + num\n new_char = alphabet[new_idx % 26]\n new_str += new_char\n end\n \n return new_str\nend", "def vigenere_cipher(message, keys)\n alphabet = (\"a\"..\"z\").to_a\n encrypted = \"\"\n\n message.each_char.with_index do |char, idx|\n shift = keys[idx % keys.length]\n encrypted += alphabet[(alphabet.index(char) + shift) % 26]\n end\n\n encrypted\nend", "def vigenere_cipher(message, keys)\n alpha = (\"a\"..\"z\").to_a\n count = 0\n message.each_char.with_index do |char, idx|\n pos = alpha.index(char)\n #rather than count we can do key alpha[(pos + key[idx % key.length] )% 26]\n message[idx] = alpha[(pos + keys[count]) % alpha.length]\n count += 1\n count = 0 if count == keys.length\n end\n message\nend", "def cipher(sentence, shift)\n # Funtion to cipher the word given a specific shift value to change the letter\n lowercase = 'abcdefghijklmnopqrstuvwxyz'\n uppercase = lowercase.upcase\n\n ciphered_word = []\n\n sentence.each_char.with_index do |char, idx|\n\n if lowercase.include?(char)\n index = lowercase.index(char)\n ciphered_word << lowercase[(index + shift) % 26]\n elsif uppercase.include?(char)\n index = uppercase.index(char)\n ciphered_word << uppercase[(index + shift) % 26]\n else\n ciphered_word << char\n end\n end\n\n return ciphered_word.join('')\n\nend", "def cipher(str, shift)\n alphabet = (\"a\"..\"z\").to_a\n \n i = 0\n while i < str.length \n if str[i] == \" \"\n i += 1\n next\n end \n char = str[i]\n prevIdx = alphabet.index(char)\n newIdx = (prevIdx + shift) % 26\n str[i] = alphabet[newIdx]\n i += 1\n end \n str\nend", "def caesar_cipher(str, num)\n \talphabet = \"abcdefghijklmnopqrstuvwxyz\"\n \tcipher = \"\"\n\n\tstr.each_char do |char|\n \tletterPos = alphabet.index(char)\n \tnewPos = letterPos + num\n \tcipher += alphabet[newPos % 26] # mod so wraps arround\n end\n \n \treturn cipher\nend", "def letter_cipher(letter, shift)\n if not letter?(letter)\n return letter\n end\n cap_start = 'A'.ord\n low_start = 'a'.ord\n if is_upper(letter)\n start = cap_start\n else\n start = low_start\n end\n mod_letter = (letter.ord + shift - start)\n if mod_letter >= 26\n if is_upper(letter)\n start = low_start\n else\n start = cap_start\n end\n end\n mod_letter = start + mod_letter % 26\n return mod_letter.chr\nend", "def vigenere_cipher(message, keys)\n alpha = (\"a\"..\"z\").to_a\n new_string = \"\"\n message.each_char.with_index do |char, i|\n old_i = alpha.index(char)\n new_i = (old_i + keys[i % keys.length]) % 26\n new_string += alpha[new_i]\n end\n new_string\nend", "def vigenere_cipher(message, keys)\n alphabet = (\"a\"..\"z\").to_a\n new_msg = \"\"\n\n message.each_char.with_index do |char|\n old_pos = alphabet.index(char)\n new_pos = old_pos + keys[idx % keys.length]\n new_msg += alphabet[new_pos % alphabet.length]\n end\n\n new_msg\nend" ]
[ "0.8599134", "0.8594511", "0.85886806", "0.856101", "0.8551369", "0.85338473", "0.85260546", "0.85254586", "0.85237694", "0.85232854", "0.85210884", "0.8505192", "0.8492382", "0.8481106", "0.8459711", "0.84583384", "0.8453188", "0.84526193", "0.84524393", "0.84277356", "0.84205496", "0.84076977", "0.840097", "0.8380515", "0.83795345", "0.8361592", "0.8338148", "0.83324057", "0.8330208", "0.83223045", "0.8298412", "0.82956916", "0.82921624", "0.8271665", "0.8257094", "0.8253757", "0.82530516", "0.82492554", "0.82315946", "0.82019246", "0.8197925", "0.8194209", "0.81918776", "0.8177468", "0.8151156", "0.81496835", "0.8123785", "0.81151927", "0.808733", "0.8081223", "0.807814", "0.8049239", "0.80396986", "0.8024585", "0.8022605", "0.8021422", "0.80162567", "0.8014931", "0.79732925", "0.7961071", "0.7961071", "0.7959046", "0.7959003", "0.7956293", "0.795229", "0.7931297", "0.79188937", "0.78956807", "0.7890587", "0.7866824", "0.7866051", "0.7840811", "0.78333557", "0.7826793", "0.78071284", "0.7797653", "0.7791424", "0.77826697", "0.77763665", "0.77759063", "0.7768814", "0.77685535", "0.7764233", "0.77627736", "0.77598125", "0.77526355", "0.77440894", "0.77338064", "0.7731096", "0.77266467", "0.77206874", "0.7713767", "0.7705032", "0.76834047", "0.7682327", "0.7666581", "0.7647607", "0.7647089", "0.7626238", "0.7615621" ]
0.8567948
3
Write a recursive method that takes in a base 10 number n and converts it to a base b number. Return the new number as a string E.g. base_converter(5, 2) == "101" base_converter(31, 16) == "1f"
def base_converter(num, b) return num.to_s if [0,1].include?(num) digits = %w(0 1 2 3 4 5 6 7 8 9 a b c d e f) base_converter(num/b, b) + digits[num % b] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def base_converter(num, b)\n\n return num.to_s if [0, 1].include?(num)\n\n digits = %w(0123456789abcdef)\n base_converter(num/b, b) + digits[num % b]\n\nend", "def base_converter(num, b)\n return \"\" if num == 0\n digits = %w(0 1 2 3 4 5 6 7 8 9 a b c d e f)\n\n base_converter(num/b, b) + digits[num%b]\n end", "def toBase(n, base)\n return n.to_s(base) if base > 0\n return '0' if n.zero?\n\n digits = []\n while n != 0\n n, remainder = n.divmod(base)\n if remainder < 0\n n += 1\n remainder -= base\n end\n digits << remainder\n end\n digits.join.reverse\nend", "def num_to_s(num, base)\n raise \"Please give a base greater than 1 and less than 16\" if base <= 1 || base > 16\n\n number_string_hash = {0 =>\"0\", 1 =>\"1\", 2 =>\"2\", 3 =>\"3\", 4 =>\"4\", 5 =>\"5\", 6 =>\"6\",\n 7 =>\"7\", 8 =>\"8\", 9 =>\"9\" }\n \n if base > 10\n num = num.to_i(base)\n base = 10\n end\n \n num_string = \"\"\n num_place = 0\n while num > 0\n current_digit = (num / base**num_place) % base\n num = num - (current_digit * (base**num_place))\n num_string.prepend(number_string_hash[current_digit])\n num_place += 1\n end\n num_string\nend", "def base_converter(num, b)\n\nend", "def convert( number, base )\n if(number < base)\n return @digits[number]\n else\n return convert( number / base, base ) + @digits[ number % base ]\n end\n end", "def binarify(base_ten_num)\n raise 'input must be an integer' if base_ten_num.is_a?(String)\n base_ten_num.to_s(2)\nend", "def convert_to_base_8(n)\n n.to_s(8).to_i # replace these two method calls\nend", "def convert_base(base, integer, target_base)\n x = 0\n result = ''\n\n start_pos = (integer[0] == '-') ? 1 : 0\n\n for i in start_pos..(integer.length - 1)\n x *= base\n x += (integer[i].ord - '0'.ord < 10) ? integer[i].ord - '0'.ord : integer[i].ord - 'A'.ord + 10\n end\n x\n\n\n while (x > 0)\n remainder = x % target_base\n result.prepend (remainder < 10) ? remainder.to_s : ((remainder - 10) + 'A'.ord).chr\n x /= target_base\n end\n\n\n if start_pos == 1\n result.prepend '-'\n end\n\n result\nend", "def convert(digits, from_base:, to_base:)\n if from_base > MAX || to_base > MAX || from_base < MIN || to_base < MIN\n raise InvalidRadix,\n \"cannot convert #{digits} from base #{from_base} to base #{to_base}\"\n end\n\n if from_base < 37 && to_base < 37\n return digits.to_s.to_i(from_base).to_s(to_base)\n end\n\n represent(value_of(digits.to_s, in_base: from_base), in_base: to_base)\n end", "def convert_to_base_8(n)\n n.to_s(8).to_i\nend", "def convert_to_base_8(n)\n n.to_s(8).to_i\nend", "def convert_to_base_8(n)\r\n #n.method_name.method_name # replace these two method calls\r\n n.to_s(8).to_i\r\nend", "def base10_to_base2(num)\n base2_ary = []\n\n MAX_POWER_OF_TWO.downto(0).each do |pow|\n if 2 ** pow <= num\n base2_ary << num / 2 ** pow\n num = num % 2 ** pow\n else\n base2_ary << 0\n end\n end\n\n base2_ary.join('').to_i\nend", "def to_s(base = 2)\n case base \n when 2\n inject(\"\") { |a, b| a + \"%0#{@bits}b \" % b }.strip\n when 10\n self.inject(\"\") { |a, b| a + \"%1d \" % b }.strip\n else\n raise(ArgumentError, \"unsupported base\")\n end\n end", "def decimal_base(n)\n 10**(n-1)\nend", "def binary_to_base_n(binaryarr, base)\n val = 0\n pow = 0\n while !binaryarr.empty?\n val += binaryarr.pop * 2**pow\n pow += 1\n end\n t = []\n num_to_digit_array(val, base).each do |dig|\n if dig > 9\n t << (('a'..'z').to_a[dig-10])\n else\n t << (dig)\n end\n end\n t.join\nend", "def represent(number, in_base:)\n digits = \"\"\n\n while number > 0\n digits = CHARS[number % in_base] + digits\n number = number / in_base\n end\n\n digits\n end", "def base2to10(binary)\n base_ten = 0\n binary.split(\"\").reverse.map {|digit| digit.to_i}.each_with_index {|digit, index| base_ten += digit * (2**index)}\n return base_ten\nend", "def from_base(base=10)\n n = 0\n chars.reverse_each.with_index do |c, power|\n value = BASE_DIGITS[c]\n n += (base**power) * value\n end\n n\n end", "def base_two(num)\n result = ''\n\n until num.zero?\n rem = num % 2\n num /= 2\n result += rem.to_s\n end\n\n result.reverse\nend", "def convertCodeGolf(inStr, inBase, outBase)\n number = inStr.chars.reverse.map.with_index{ |c,i|\n inBase**i*$digits.index(c) }.reduce &:+\n intToStr(number, outBase)\nend", "def base2to10(str_num)\n str = str_num.dup.reverse\n total = 0\n\n str.each_char.with_index do |char, idx|\n total += (char.to_i * (2 ** idx))\n end\n total\nend", "def to_s(base=2)\n n = Bits.power_of_two(base)\n if n\n digits = (size+n-1)/n\n #{ }\"%0#{digits}d\" % @v.to_s(base)\n Numerals::Format[:fix, base: base].set_leading_zeros(digits).write(@v)\n else\n @v.to_s(base)\n end\n end", "def to_bcd(n)\n n.to_s.gsub(/\\d/) {|d| \"%04b \" % d}.strip\nend", "def to_s(base=nil)\n base.nil? ? super() : super().to_i(Gibbler.default_base).to_s(base)\n end", "def integer_to_string(number)\n result = ''\n loop do\n number, remainder = number.divmod(10)\n # binding.pry\n result.prepend(DIGITS[remainder])\n break if number == 0\n end\n result\nend", "def base2to10(binary)\n\tresult = 0\n digits = binary.chars.reverse\n\n digits.each_with_index do |bit, idx|\n result += bit.to_i * (2**idx)\n end\n\n result\nend", "def integer_to_string(number)\n\n\tconversion = {0 => '0', 1 => '1', 2 => '2', 3 => '3', 4 => '4', 5 => '5',\n\t\t\t\t 6 => '6', 7 => '7', 8 => '8', 9 => '9' }\n\n\tnumber.digits.reverse.map do |num|\n\t\tconversion[num]\n\tend.join\n\nend", "def toBinary (x)\n if (x>1)\n toBinary(x/2) + (x%2).to_s\n elsif x==1\n return x.to_s\n end\nend", "def to_bits(base10_num)\n bits = @bit_vals.map do |b|\n if base10_num >= b\n base10_num -= b\n '1'\n else\n '0'\n end\n end\n bits.join\n end", "def reverse(number)\n return number if number.to_s.length == 1 #1 is the last number to go\n number_array = number.to_s.split(\"\")\n first_element = number_array.pop #ie 2 (from base)\n new_number = number_array.join(\"\").to_i\n recursive_call = first_element.to_s + reverse(new_number).to_s #take advantage of string concat\n\n output_string = \"\"\n number = output_string + recursive_call\n number.to_i\nend", "def super_digit(n)\n # base case\n return n if n/10 == 0\n \n # recursive case\n return super_digit(n/10 + n%10)\nend", "def stringy number, count = 1\n binary_string = ''\n\n if count == 1\n (number / 2).times {binary_string << '10'}\n binary_string << '1' if number % 2 == 1\n elsif count == 0\n (number / 2).times {binary_string << '01'}\n binary_string << '0' if number % 2 == 1\n end\n\n binary_string\n end", "def super_digit(n)\n s = n.to_s \n if s.length <= 1 # basecase here\n return n\n end\n \n sum = 0 \n s.split(\"\").each do |d|\n sum += d.to_i \n end\n \n return super_digit(sum)\nend", "def int_to_binary_string(number)\n number.to_s(2)\nend", "def decimal_to_binary(number)\n if number == 0\n 0\n else\n number % 2 + 10 * decimal_to_binary(number/2)\n end \nend", "def super_digit(n)\n new_num = 0\n numbers = n.to_s.split(\"\")\n if numbers.length <= 1\n return n\n end\n numbers.each do |i|\n new_num += i.to_i\n end\n return super_digit(new_num)\nend", "def to_s(base=nil, divider=nil)\n divider = divider.to_s if divider\n if base\n convert(base).to_s(nil, divider)\n else\n if code\n digits_encoded.join(divider)\n else\n if @base > 10\n digits.join(divider || DIVIDER)\n else\n digits.join(divider)\n end\n end\n end\n end", "def integer_to_string(num)\n\tlookup_table = {0 => '0', 1 => '1', 2 => '2', 3 => '3', 4 => '4', \n\t\t\t\t\t5 => '5', 6 =>'6', 7 => '7', 8 => '8', 9 => '9'}\n \n result = ''\n\n if num.is_a? Integer\n num.digits.reverse.each do |number|\n result += lookup_table[number]\n end\n result\n else\n puts \"Invalid entry!\"\n end\nend", "def super_digit(n)\n n < 10 ? n : super_digit(n / 10 + n % 10)\nend", "def number_to_english(n)\n\n numbers_to_name = {\n 1000 => \"thousand\",\n 100 => \"hundred\",\n 90 => \"ninety\",\n 80 => \"eighty\",\n 70 => \"seventy\",\n 60 => \"sixty\",\n 50 => \"fifty\",\n 40 => \"forty\",\n 30 => \"thirty\",\n 20 => \"twenty\",\n 19=>\"nineteen\",\n 18=>\"eighteen\",\n 17=>\"seventeen\",\n 16=>\"sixteen\",\n 15=>\"fifteen\",\n 14=>\"fourteen\",\n 13=>\"thirteen\",\n 12=>\"twelve\",\n 11 => \"eleven\",\n 10 => \"ten\",\n 9 => \"nine\",\n 8 => \"eight\",\n 7 => \"seven\",\n 6 => \"six\",\n 5 => \"five\",\n 4 => \"four\",\n 3 => \"three\",\n 2 => \"two\",\n 1 => \"one\",\n 0 => \"zero\"\n }\n\n\n str = \"\"\n numbers_to_name.each do |num, name|\n\n if n == 0\n return str\n\n elsif n > 99999\n return str\n\n elsif n.to_s.length == 1 && n/num > 0\n return \"#{name}\"\n\n elsif n < 100 && n/num > 0\n\n return \"#{name}\" if n%num == 0\n return \"#{name} \" + number_to_english(n%num)\n\n elsif n/num > 0\n return number_to_english(n/num) + \" #{name} \" + number_to_english(n%num)\n\n end\n\n end\nend", "def recursiveBaseExpansionOf(base, n, a)\n if n != 0\n q = (n/base).floor\n recursiveBaseExpansionOf(base, q, a << n - (q * base))\n else \n return a\n end\n end", "def refined_super_digit(n, k)\n refined = \"\"\n\n k.times do \n refined += n.to_s \n end \n refined = refined.to_i\n\n super_digit(refined)\n\nend", "def print_binary(n)\n puts \"print binary (#{n})\"\n if n < 0 \n print \"-\"\n print_binary(-n)\n \n elsif n < 2\n print n\n \n else\n last_digit = n % 2\n rest_of_digit = n / 2\n print_binary(rest_of_digit)\n print_binary(last_digit)\n end\nend", "def super_digit(n)\n if 10 > n\n return n\n end\n\n last_digit = n % 10\n sum = n / 10 + last_digit \n \n return super_digit(sum)\nend", "def super_digit(n)\n while n >= 10\n n = n % 10 + super_digit(n / 10)\n end\n return n\nend", "def integer_to_string(number)\n hash_of_integers = { 0 => '0', 1 => '1', 2 => '2', 3 => '3', 4 => '4', 5 => '5', 6 => '6', 7 => '7', 8 => '8', 9 => '9'}\n \n string =''\n loop do\n\n number, digit = number.divmod(10)\n \n string.prepend(hash_of_integers[digit])\n break if number == 0\n end\n string\nend", "def display_binary(n)\n if (n <= 0)\n return\n end\n display_string = binary_to_int(n).to_s\n display_string.tr!(\"[], \", \"\")\n display_string.reverse!\n puts \"#{n} in binary is: #{display_string}\"\n return display_string\nend", "def super_digit(n)\n string_n = n.to_s\n return n if string_n.size == 1\n\n i = 1\n sum = string_n[0].to_i\n while i < string_n.size\n sum += string_n[i].to_i\n i += 1\n end\n return super_digit(sum)\nend", "def super_digit(n)\n while n > 9\n n = n % 10 + super_digit(n / 10)\n end\n return n\nend", "def super_digit(n)\n string_n = n.to_s\n return n if string_n.size == 1\n\n i = 1\n sum = string_n[0].to_i\n while i < string_n.size\n sum += string_n[i].to_i\n i += 1\n end\n return super_digit(sum)\n end", "def super_digit(n)\n sum = 0\n while n >= 10 do\n sum += n % 10\n n /= 10\n end\n sum += n\n return sum < 10 ? sum : super_digit(sum)\nend", "def super_digit(n)\n return n if n < 10 \n return super_digit(n.to_s.chars.map(&:to_i).sum)\nend", "def integer_to_string(num)\n num.digits.map { |x| INT_CONVERT[x] }.reverse.join\nend", "def super_digit(n)\n sum = 0\n\n if n < 10\n return sum + n\n else\n until n < 10\n sum += (n % 10)\n n /= 10\n end\n\n sum += n\n end\n\n return super_digit(n = sum)\nend", "def super_digit(n)\n return n if n < 10\n sum = n.to_s.chars.map(&:to_i).sum\n return super_digit(sum)\nend", "def super_digit(n)\n return n if n / 10 == 0\n return super_digit(digit_helper(n))\nend", "def num_into_string(number)\n puts number.ordinalize\nend", "def super_digit(n)\n return n if n / 10 < 1\n \n string = n.to_s.split(\"\")\n sum = 0\n \n string.each do |num|\n sum += num.to_i\n end\n \n return super_digit(sum)\nend", "def num_to_string(number)\n case number\n when '1'\n \"one \"\n when '2'\n \"two \"\n when '3'\n \"three \"\n when '4'\n \"four \"\n when '5'\n \"five \"\n when '6'\n \"six \"\n when '7'\n \"seven \"\n when '8'\n \"eight \"\n when '9'\n \"nine \"\n when '10'\n \"ten \"\n when '11'\n \"eleven \"\n when '12'\n \"twelve \"\n when '13'\n \"thirteen \"\n when '14'\n \"fourteen \"\n when '15'\n \"fifteen \"\n when '16'\n \"sixteen \"\n when '17'\n \"seventeen \"\n when '18'\n \"eighteen \"\n when '19'\n 'nineteen '\n when '20'\n \"twenty \"\n when '30'\n \"thirty \"\n when '40'\n \"fourty \"\n when '50'\n \"fifty \"\n when '60'\n \"sixty \"\n when '70'\n \"seventy \"\n when '80'\n \"eighty \"\n when '90'\n \"ninty \"\n else\n \"\"\n end\nend", "def convert_base(number, base)\n \n exponents = []\n n = 0 # Exponent / number position\n\n # Find the appropriate exponent size larger than the number \n while number != 0\n # puts \"Current top number: #{number}\"\n # puts \"Current exponent value: #{n}\"\n running_total = 0\n if number < base ** n\n # puts \"Base ** n: #{base ** n}\" \n # puts \"If loop current number: #{number}\"\n running_total += base ** (n-1)\n # puts \"If loop running_total: #{running_total}\"\n number = number - running_total\n # puts \"If loop number after subtraction: #{number}\"\n if exponents[n-1].nil? then exponents[n-1] = 1 else exponents[n-1] += 1 end\n n = 0\n else\n n += 1\n end\n end\n\n exponents.inspect\n\nend", "def to_2digit(number)\n if number < 9\n number=\"0\"+number.to_s\n else\n number=number.to_s\n end\n return number\nend", "def convert(num)\n return num.to_s\nend", "def super_digit(n)\n return n if n < 10\n\n sum = 0 \n\n while n > 0\n digit = n % 10\n n /= 10\n sum += digit\n end\n\n super_digit(sum)\n\nend", "def super_digit(n)\n return n if n.to_s.length == 1 \n\n return super_digit(digit_helper(n))\nend", "def super_digit(n)\n return n if n < 10\n\n sum_digits = 0\n until n == 0\n sum_digits += n % 10\n n /= 10\n end\n\n super_digit(sum_digits)\nend", "def integer_to_string(int)\n int.digits.map { |num| NUMBERS[num] }.join.reverse\nend", "def integer_to_string(int)\n num_digits = 1\n loop do\n quotient = int / 10**num_digits\n break if quotient == 0\n num_digits += 1\n end\n \n digits_arr = []\n for i in (1..num_digits)\n digits_arr.unshift(int % 10**i/ 10**(i-1))\n end \n \n digits_arr.each_with_index do |digit, index| \n if digit == 0\n digits_arr[index] = '0'\n elsif digit == 1\n digits_arr[index] = '1'\n elsif digit == 2\n digits_arr[index] = '2'\n elsif digit == 3\n digits_arr[index] = '3' \n elsif digit == 4\n digits_arr[index] = '4' \n elsif digit == 5\n digits_arr[index] = '5'\n elsif digit == 6\n digits_arr[index] = '6'\n elsif digit == 7\n digits_arr[index] = '7'\n elsif digit == 8\n digits_arr[index] = '8'\n elsif digit == 9\n digits_arr[index] = '9'\n end\n end \n \n string_version = digits_arr.join('')\n # p string_version\nend", "def to_i(base=10) end", "def convertToTwoDigitString inInt\n if inInt < 10 \n return \"0\" + inInt.to_s;\n end\n inInt.to_s\n end", "def do_digit(chr, base)\n result = \"\"\n num = chr.to_i\n case num\n when (1..3)\n 1.upto(num) { result << ROMANS[base] }\n when 4 \n result << 'IV' if base == 1 #=> 4\n result << 'IL' if base == 10 #=> 40\n result << 'ID' if base == 100 #=> 400\n # no 4000+ in roman number, max roman number is 3000\n when 5\n result << 'V' if base == 1 #=> 5\n result << 'L' if base == 10 #=> 50\n result << 'D' if base == 100 #=> 500\n # no 5000 in roman number, max roman number is 3000\n when (6..8)\n result << 'V' if base == 1 #=> 6+\n result << 'L' if base == 10 #=> 60+\n result << 'D' if base == 100 #=> 600+\n 1.upto(num-5) { result << ROMANS[1] } # add extra 'III'\n # no 6000+ in roman number, max roman number is 3000\n when 9\n result << 'IX' if base == 1 #=> 9\n result << 'XC' if base == 10 #=> 90\n result << 'CM' if base == 100 #=> 900\n # no 9000 in roman number, max roman number is 3000\n end \n result\n end", "def base2to10(binary)\n #split to single digits\n digits = binary.split('').map{|str| str.to_i}.reverse\n #loop through multiply by 2 raised to index and add to result\n result = 0\n digits.each_with_index do |num, i|\n result += (num *(2**i))\n end\n result\nend", "def super_digit(n)\n return n if n/10 == 0\n \n sum = n % 10\n while n/10 != 0\n n = n/10\n sum += n % 10\n end\n return super_digit(sum)\nend", "def super_digit(n)\n return n if n < 10\n sum = super_digit_helper(n, 0)\n super_digit(sum)\nend", "def handle_hundred (num)\n num2str=''\n if (num%100==0)\n num2str+=NUM_MAP[num/100]+ ' '+ NUM_MAP[100]\n elsif (num%100>=10 && num%100 <= 99)\n num2str+=NUM_MAP[num/100]+ ' '+ NUM_MAP[100]+ ' ' +handle_ten(num%100)\n elsif (num%100>=1 && num%100 <= 9)\n num2str+=NUM_MAP[num/100]+ ' '+ NUM_MAP[100]+ ' ' +handle_bit(num%100)\n end\n return num2str\nend", "def dec_to_base7(decimal)\r\n result = []\r\n until decimal == 0\r\n result.push(decimal % 7)\r\n decimal = decimal / 7\r\n end\r\n return result.reverse.join.to_i\r\nend", "def base_conversion(value, base)\n #if value < 0\n # @negative, value = true, value.abs\n #end\n i = value.abs\n\n a = []\n while i > 0\n i, r = i.divmod(base)\n a << r\n end\n\n a << 0 if a.empty?\n\n a.reverse\n end", "def to_bin(number)\n number = Integer(number);\n if(number == 0)\n return 0;\n end\n ret_bin = \"\";\n ## Untill val is zero, convert it into binary format\n while(number != 0)\n ret_bin = String(number % 2) + ret_bin;\n number = number / 2;\n end\n return ret_bin;\n end", "def do_digit(chr, base)\n result = \"\"\n num = chr.to_i\n case num\n when (1..3)\n 1.upto(num) { result << ROMANS[base] }\n when 4 \n result << 'IV' if base == 1 #=> 4\n result << 'XL' if base == 10 #=> 40\n result << 'CD' if base == 100 #=> 400\n # no 4000+ in roman number, max roman number is 3000\n when 5\n result << 'V' if base == 1 #=> 5\n result << 'L' if base == 10 #=> 50\n result << 'D' if base == 100 #=> 500\n # no 5000 in roman number, max roman number is 3000\n when (6..8)\n result << 'VI' if base == 1 #=> 6+\n result << 'LX' if base == 10 #=> 60+\n result << 'DC' if base == 100 #=> 600+\n # add extra C, X or I\n 1.upto(num-6) { result << ROMANS[base] } \n # no 6000+ in roman number, max roman number is 3000\n when 9\n result << 'IX' if base == 1 #=> 9\n result << 'XC' if base == 10 #=> 90\n result << 'CM' if base == 100 #=> 900\n # no 9000 in roman number, max roman number is 3000\n end \n result\n end", "def handle_ten (num)\n num2str=''\n if (num%10==0)\n num2str+=NUM_MAP[num]\n elsif (num>10 && num<20)\n num2str+=NUM_MAP[num]\n else\n num2str+=NUM_MAP[num/10*10]+'-'+NUM_MAP[num%10]\n end\n return num2str\nend", "def number_to_string (num) \n p num.to_s\nend", "def integer_to_string(number)\n string = number.digits.reverse.join\nend", "def integer_to_string(number)\n string = number.digits.reverse.join\nend", "def integer_to_string(num)\n num.digits.reverse.join\nend", "def dec2bin(n)\n case n\n when 0 then '0000'\n when 1 then '0001'\n when 2 then '0010'\n when 3 then '0011'\n when 4 then '0100'\n when 5 then '0101'\n when 6 then '0110'\n when 7 then '0111'\n when 8 then '1000'\n when 9 then '1001'\n when 10 then '1010'\n when 11 then '1011'\n when 12 then '1100'\n when 13 then '1101'\n else nil\n end\n end", "def number_to_english(n)\n return \"\" unless n.integer? && n >= 0\n\n numbers_to_name = {\n 1000000 => \"million\",\n 1000 => \"thousand\",\n 100 => \"hundred\",\n 90 => \"ninety\",\n 80 => \"eighty\",\n 70 => \"seventy\",\n 60 => \"sixty\",\n 50 => \"fifty\",\n 40 => \"forty\",\n 30 => \"thirty\",\n 20 => \"twenty\",\n 19=>\"nineteen\",\n 18=>\"eighteen\",\n 17=>\"seventeen\",\n 16=>\"sixteen\",\n 15=>\"fifteen\",\n 14=>\"fourteen\",\n 13=>\"thirteen\",\n 12=>\"twelve\",\n 11 => \"eleven\",\n 10 => \"ten\",\n 9 => \"nine\",\n 8 => \"eight\",\n 7 => \"seven\",\n 6 => \"six\",\n 5 => \"five\",\n 4 => \"four\",\n 3 => \"three\",\n 2 => \"two\",\n 1 => \"one\",\n 0 => \"zero\"\n }\n\n if n < 10\n numbers_to_name[n]\n elsif n < 100\n if n % 10 == 0 || n < 20\n numbers_to_name[n]\n else\n numbers_to_name[(n / 10) * 10] + ' ' + numbers_to_name[(n % 10)]\n end\n elsif n < 1000\n if n % 100 == 0\n numbers_to_name[(n / 100)] + ' ' + numbers_to_name[100]\n else\n numbers_to_name[(n / 100)] + ' ' + numbers_to_name[100] + ' ' + number_to_english(n % 100)\n end\n elsif n <= 99999\n number_to_english(n / 1000) + ' ' + numbers_to_name[1000] + ' ' + number_to_english(n % 1000)\n else\n \"\"\n end\n\nend", "def integer_to_string(int)\n int_str = ''\n\n loop do\n int, remainder = int.divmod(10)\n int_str.prepend(DIGITS[remainder])\n\n break if int == 0\n end\n\n int_str\nend", "def do_digit(chr, base)\n # max roman number is 3000\n # 1 = base 1 char, 10 = base 2 chars, 100 = base 3 chars, 1000 = base 4 chars\n romans = { 1 => 'I', 5 => 'V', 10 => 'X', 50 => 'L', 100 => 'C', 500 => 'D', 1000 => 'M' }\n\n result = ''\n num = chr.to_i\n case num\n when (1..3)\n 1.upto(num) { result << romans[base] }\n when 4\n result << 'IV' if base == 1\n result << 'XL' if base == 10\n result << 'CD' if base == 100\n when 5\n result << 'V' if base == 1\n result << 'L' if base == 10\n result << 'D' if base == 100\n when (6..8)\n result << 'VI' if base == 1\n result << 'LX' if base == 10\n result << 'DC' if base == 100\n # add extra C, X or I\n 1.upto(num - 6) { result << romans[base] }\n when 9\n result << 'IX' if base == 1\n result << 'XC' if base == 10\n result << 'CM' if base == 100\n else\n # zero will go here, don't need to do anything about it\n end\n result\n end", "def integer_to_string(int)\n string_chars = {\n 0 => '0', 1 => '1', 2 => '2', 3 => '3', 4 => '4', 5 => '5',\n 6 => '6', 7 => '7', 8 => '8', 9 => '9'\n }\n\n string = ''\n int.digits.reverse.each {|digit| string << string_chars[digit]}\n string\nend", "def number_to_string(num)\n num.to_s\nend", "def refined_super_digit(n, k)\n s = \"\"\n k.times do\n s += n.to_s\n end\n return super_digit(s.to_i)\nend", "def to_string(number)\n str_array = []\n loop do\n str_array.unshift(number % 10)\n number /= 10\n break if number == 0\n end\n str_array.join\nend", "def super_digit(n)\n #has to be a single digit \n if n < 10 \n return n\n else \n return super_digit(n.digits.sum)\n end \n \n \nend", "def super_digit(n)\n return n.abs if n.abs < 10\n\n sum = recursive_digit_helper(n)\n\n return super_digit(sum)\nend", "def integer_to_string(int)\n convert = %w(0 1 2 3 4 5 6 7 8 9)\n string = ''\n int.digits.each { |digit| string += convert[digit] }\n string.reverse\nend", "def integer_to_string(int)\n convert = %w(0 1 2 3 4 5 6 7 8 9)\n string = ''\n int.digits.each { |digit| string += convert[digit] }\n string.reverse\nend", "def to_bin(num_string)\n digits = convert_to_base10(num_string)\n digits.map!{|char| to_bits(char)}\n digits.join\n end", "def super_digit(n)\n return n if n < 10\n count = add_digits(n)\n return super_digit(count)\n\nend", "def add_binary(a,b)\n #your code here\n binary = a + b\n binary.to_s(2) # Convert um inteiro para string na base 2(base binária)\nend" ]
[ "0.835826", "0.8239488", "0.79268646", "0.75288016", "0.7468854", "0.74058414", "0.7319654", "0.72496575", "0.7096845", "0.70771414", "0.700969", "0.700969", "0.6985824", "0.697721", "0.6976664", "0.6951264", "0.69168115", "0.67891693", "0.66726947", "0.66271615", "0.66150093", "0.6578291", "0.6560049", "0.6475586", "0.6405819", "0.6405397", "0.637515", "0.6367706", "0.63493603", "0.6348216", "0.634702", "0.6342384", "0.6329089", "0.632544", "0.631846", "0.6313175", "0.6309606", "0.6304937", "0.6300825", "0.6292641", "0.62846607", "0.62628186", "0.6258931", "0.62366605", "0.62261266", "0.62247634", "0.6216357", "0.6206125", "0.61967003", "0.61954457", "0.619526", "0.61895573", "0.618839", "0.61869454", "0.61827624", "0.6180207", "0.6175272", "0.61697364", "0.6165419", "0.6165393", "0.61636925", "0.61575735", "0.6153665", "0.6149569", "0.6135226", "0.6132551", "0.6121329", "0.6114997", "0.61124265", "0.60955125", "0.6088095", "0.60865706", "0.60842365", "0.60687387", "0.60660756", "0.6061622", "0.60528207", "0.60504204", "0.6050255", "0.60478514", "0.6035598", "0.6034779", "0.6025318", "0.6025318", "0.6023226", "0.60217285", "0.60185397", "0.601703", "0.60043377", "0.6000249", "0.599815", "0.5995238", "0.5991913", "0.5984898", "0.59814626", "0.59768176", "0.5976489", "0.5972274", "0.5964536", "0.5961226" ]
0.8167173
2
Write a recursive method `subsets(array)` that returns all of the subsets of an array example => subsets([1,2,3]) should return => [ [], [1], [2], [1, 2], [3], [1, 3], [2, 3], [1, 2, 3] ]
def subsets(array) return [[]] if array.empty? subs = subsets(array[0..-2]) subs.concat(subs.map{|el| el += [array.last]}) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def subsets(array)\n if array.length <= 1\n return array\n end\n subset_array = []\n (0..array.length - 1).each do |i|\n subset_array << subsets(array[0...i]) << subsets(array[0...i]).concat([array[-1]])\n end\n return subset_array\nend", "def subsets(arr)\n return [arr] if arr.empty?\nsubsets(arr[])\nend", "def subsets(array)\n return [[]] if array.empty?\n number = array.pop\n prev_subsets = subsets(array)\n new_subsets = []\n prev_subsets.each do |subset|\n new_subsets << ([number] + subset)\n end\n prev_subsets + new_subsets\nend", "def subsets(array)\n if array.empty?\n return [[]]\n end\n\n el = array.shift[0]\n old_subsets = subsets(array)\n new_subsets = old_subsets.map { |old_subset| [el] + old_subset }\n new_subsets + old_subsets\nend", "def subsets(arr)\n return [arr] unless arr.is_a?(Array)\n return [arr] if arr.empty?\n\n # return [arr] if arr.length == 1\n # first = arr.shift\n # all_subsets << subsets(first)\n # all_subsets << subsets(arr)\n\n # [[],[1]] << [2],[1,2] [each, last] << [last] [each,last]\n # subsets(arr-1) << subsets(arr)[-1]\n all_subsets = [[]]\n\n arr.each { |ele| all_subsets << [ele] }\n\n (0...(arr.length - 1)).each do |idx1|\n # all_subsets << [arr[idx1]] unless all_subsets.include?(arr[idx1])\n (1...arr.length).each do |idx2|\n if idx2 > idx1 && !all_subsets.include?(arr[idx2])\n # all_subsets << [arr[idx2]]\n all_subsets << arr[idx1..idx2]\n end\n end\n end\n\n all_subsets\nend", "def subsets(array)\n return [[]] if array.empty?\n\n dupped = array.dup\n last = dupped.pop\n sets = subsets(dupped)\n\n subsets(dupped).each do |set|\n sets << (set << last)\n end\n\n sets\nend", "def array_subsets(arr)\n return arr if arr.length == 0 || arr.length == 1\n new_arr = []\n new_arr << [arr[0]] + array_subsets(arr[1..-1])\n \n # length = 1\n # new_arr = [[]]\n # while length <= arr.length\n # arr.each do |el|\n # new_arr << Array.new(length) { el }\n # end\n # length += 1\n # end\nend", "def subsets(arr)\n return [arr] if arr.empty?\n # p arr\n # if arr.length == 1\n # return subsets(arr[0...0]) + [arr]\n # end\n\n arr.each {|ele| subsets(arr -[ele]) } + [arr]\nend", "def subsets(array)\n return [[]] if array.empty?\n subs = array[0...-1]\n smaller_subs = subsets(subs)\n bigger_subs = []\n smaller_subs.each do |sub|\n bigger_subs << sub + [array[-1]]\n end\n smaller_subs + bigger_subs\nend", "def subsets_of(array)\n 0.upto(array.length).flat_map { |n| array.combination(n).to_a }\n end", "def subsets(arr)\r\n comb = [] #set up return array\r\n\r\n for x in 0..arr.length do # gives a value from 0 to arr.length to pass below\r\n arr.combination(x) {|y| comb << y} # pushes to the return all of the possible combinations of the array\r\n end # the x insures that all possible lengths of combinations are returned.\r\n\r\n comb # returns all combinations\r\nend", "def subsets(array)\n return [[]] if array.empty?\n\n val = array[0]\n subs = subsets(array.drop(1))\n new_subs = subs.map { |sub| sub + [val] }\n\n subs + new_subs\nend", "def subsets(array) # [1, 2], [1]\n return [[]] if array.length == 0\n # return [[], array ] if array.length == 1\n\n except_last = subsets(array[0...-1]) #subsets([1]), subsets([])\n combination = except_last.map { |ele| ele += [array[-1]]} #map subsets([1]) + [2], \n\n except_last + combination\nend", "def subsets(arr)\n return [ [] ] if arr.empty?\n subs = subsets(arr.drop(1)) # [ [] ]\n return subs.concat(subs.map { |sub| [arr.first].concat(sub) })\nend", "def array_subsets(array)\n return [array] if array.empty?\n \nend", "def subsets (arr)\n return [[]] if arr.length == 0\n\n interim = subsets(arr[0...-1])\n interim + interim.map do |el|\n el + [arr[-1]]\n end\nend", "def subsets(array)\n\n return [[]] if array == []\n all_but_last = subsets(array[0...array.length - 1].dup)\n last = array.last\n all_but_last.map { |el| el.dup } + all_but_last.map { |el| el << last }\nend", "def subsets(array)\n return [[]] if array == []\n\n sets = subsets(array[0...-1])\n sets + sets.map { |el| el += [array.last] }\nend", "def subsets(arr)\n return [arr] if arr.empty?\n out = []\n subsets(arr[1..-1]).each do |s|\n out << s\n out << [arr[0]] + s\n end\n out\nend", "def subsets(array)\n\nend", "def subsets(array)\n\nend", "def subsets(array)\n\nend", "def subsets(arr)\n return [[]] if arr.empty?\n subsets_arr = []\n cur_el = arr[0]\n prior_subs = subsets(arr[1..-1])\n prior_subs.each do |subset|\n subsets_arr << subset.dup.push(cur_el)\n end\n subsets_arr + prior_subs\nend", "def subsets(arr)\n return [[]] if arr.empty?\n s = subsets(arr - [arr.last])\n s + s.map { |el| el + [arr.last] }\nend", "def subsets(array)\n return [[]] if array.empty?\n subs = subsets(array[0..-2])\n subs += subs.map { |el| el += [array.last] }\n end", "def powerset(array)\n subsets = [[]]\n\n array.each do |elem|\n (1..subsets.length - 1).each do |i|\n current_subset = subsets[i]\n subsets.append(current_subset + [elem])\n end\n end\n\n return subsets\nend", "def subsets(set)\n return [[]] if set == []\n \n res= [[]]\n \n 0.upto set.length-1 do |i|\n subsets(set[(i+1)..-1]).each do |subsubset|\n res << [set[i]] + subsubset\n end\n end\n \n res\nend", "def powerset(array)\n subsets = [[]]\n array.each { |element|\n for i in 0..subsets.length - 1\n current_subset = subsets[i]\n subsets << (current_subset + [element])\n end\n }\n return subsets\nend", "def find_subsets(nums)\n\tsorted_nums = nums.sort()\n\n\tsubsets = []\n\tsubsets.append([])\n\n\tstart_index, end_index = 0, 0\n\n\tfor i in 0..(nums.length - 1)\n\t\tstart_index = 0\n\t\t0\n\t\t0\n\t\tif i > 0 and nums[i] == nums[i - 1]\n\t\t\tstart_index = end_index + 1\n\t\tend\n\n\t\tend_index = subsets.length - 1\n\t\t0\n\t\t1\n\t\tfor j in start_index..end_index\n\t\t\tsubset1 = Array.new(subsets[j])\n\t\t\t[]\n\t\t\t[]\n\t\t\tsubset1.append(nums[i])\n\t\t\t[1]\n\t\t[3]\n\t\t\tsubsets.append(subset1)\n\t\t\t[[],[1],[3]]\n\t\tend\n\tend\n\n\treturn subsets\nend", "def subsets(arr)\n return [[]] if arr == [] \n\n new_arr = []\n last = arr[-1]\n subset = subsets(arr[0..-2])\n\n subset.each do |suba|\n new_arr << suba + [last]\n end\n \n subset + new_arr\n\nend", "def subsets(nums)\n result = []\n subsets_helper(nums, [], result, 0)\n result\nend", "def subsets(arr)\n return [arr] if arr.empty?\n prev = subsets(arr[0..-2]) \n next_one = []\n prev.each { |sub| next_one << sub + [arr[-1]] }\n return prev + next_one\nend", "def subsets(arr)\n subsets_helper(result = [], temp = [], arr, 0)\nend", "def subsets(arr)\n return [[]] if arr.length == 0\n #return [arr] if arr.length == 1\n\n prev_set = subsets(arr[0..-2])\n new_subset = prev_set.map { |subarr| subarr + [arr[-1]] }\n\n prev_set + new_subset\nend", "def subsets(arr)\n return [[]] if arr.empty?\n\n val = arr[0]\n subs = subsets(arr.drop(1))\n new_subs = subs.map{ |sub| sub + val }\n\n subs + new_subs\nend", "def subsets(arr)\n ans = [[]]\n arr.length.times do |id|\n id2 = id + 1\n ans << [arr[id]]\n while id2 < arr.length\n ans << arr[id..id2]\n id2 += 1\n end\n end\n ans\nend", "def subsets(arr)\n res = [] \n if arr.length == 1 \n res << [] \n res << [arr[0]]\n return res \n elsif arr.empty?\n return [[]]\n end\n \n last = arr.pop \n old_set = subsets(arr)\n res = old_set\n \n res += old_set.map{ |i| i + [last] }\nend", "def subsets(arr)\n #base case(s)\n p arr\n return [arr] if arr.empty?\n # return [[], arr] if arr.length == 1\n #inductive step\n remaining_arr = subsets(arr[0...-1])\n remaining_arr + remaining_arr.map { |ele| ele + [arr.last] }\n # subsets(arr) + subsets(arr[0...-1])\nend", "def subsets(arr)\n return [[]] if arr.empty?\n\n last_el = arr.last\n results = []\n\n\n subsets(arr[0..-2]).each do |el|\n sub_arr = el << last_el\n results << sub_arr\n end\n\n subsets(arr[0..-2]) + results\nend", "def recursive_subsets(arr)\n return [[]] if arr.empty?\n last_el = arr.pop\n p sub_arr = recursive_subsets(arr)\n p last_el\n sub_arr += sub_arr.map { |el| el + [last_el] }\nend", "def subsets(set)\n return [[]] if set.empty?\n smaller_set = set.take(set.count-1)\n smaller_subsets = subsets(smaller_set)\n bigger_subsets = []\n smaller_subsets.each do |smaller_subset|\n bigger_subsets << smaller_subset + [set.last]\n end\n\n smaller_subsets + bigger_subsets\nend", "def subsets(nums)\n return [[]] if nums.empty?\n return [[],[nums.first]] if nums.size == 1\n [[], (0...nums.size).map {|x|\n [[nums[x]], subsets(nums[x + 1..-1]).map { |y| [nums[x]] + y }]\n }.flatten]\nend", "def subsets(nums)\n return [[]] if nums.empty?\n first = nums[0]\n prev_subs = subsets(nums[1..-1])\n new_subs = prev_subs.map do |sub|\n sub + [first]\n end \n prev_subs + new_subs\nend", "def subsets(ary)\n # base case\n return [[]] if ary.empty?\n\n # create subsets without the last element (smaller array)\n subs = subsets(ary.take(ary.length - 1))\n\n # adds the subs with the last element that was omitted.\n subs.concat( subs.map { |sub| sub + [ary.last] })\n\nend", "def subsets(arr)\n # return an empty array (tech a subset of an empty array) - base case\n return [[]] if arr.empty?\n # take out the last el\n last = arr[-1]\n # take all the other els\n # find all subsets don't have the last element\n subsets_without_last = subsets(arr[0...-1])\n # create an array with a combo of s (the el) & the last ele in arr\n # find all subsets that have the last element\n subsets_with_last = subsets_without_last.map { |s| s.dup << last }\n # merge with prior subsets\n # all subsets of arr either have the last element, or they don't.\n subsets_without_last + subsets_with_last\nend", "def subsets(arr)\n return [self] if arr.length == 1\n\n subs + subsets()\nend", "def array_subsets(arr)\n return [[]] if arr.empty?\n partial_subset = array_subsets(arr[0..-2])\n addition = partial_subset.map {|ele| ele + [arr[-1]]}\n partial_subset + addition\nend", "def powerset(array, idx = nil)\n if (idx == nil)\n idx = array.length - 1\n end\n if (idx < 0)\n return [[]]\n end\n element = array[idx]\n subsets = powerset(array, idx - 1)\n for i in 0..subsets.length - 1\n current_subset = subsets[i]\n subsets << current_subset + ([element])\n end\n return subsets\nend", "def powerset(array, index = nil)\n if index.nil?\n index = array.length - 1\n elsif index < 0\n return [[]]\n end\n\n ele = array[index]\n subsets = power(array, index - 1)\n (0..subsets.length - 1).each do |i|\n current_subset = subsets[i]\n subsets.append(current_subset + [ele])\n end\n\n subsets\nend", "def subsets_iter(arr)\n new_arr = [[]]\n # byebug\n i = 0\n while i < arr.length\n# byebug\n ele1 = arr[i]\n new_arr << [ele1]\n\n if arr.length > 2\n sub_arr = [ele1]\n j = i + 1\n while j < arr.length\n # byebug\n ele2 = arr[j]\n sub_arr << ele2\n new_arr << sub_arr.dup\n sub_arr.pop\n j += 1\n end\n end\n i += 1\n end\n# byebug\n new_arr << arr unless arr.length < 2\n\n new_arr\nend", "def subsets(arr)\n return [[]] if arr.empty?\n # debugger\n # take - return first n elements\n\n subArr = arr.take(arr.count - 1)\n\n subs = subsets(subArr)\n\n # concat Appends the elements of other_ary to self.\n # tyle co +\n subArrays = subs.map { |sub| sub + [arr.last] }\n subs.concat(subArrays)\nend", "def subsets(arr)\n return [[]] if arr.empty?\n\n # new_series = subsets(arr[0..-2]).each do |subarr|\n # subarr << arr[-1]\n # end\n # subsets(arr[0..-2]) + new_series\n\n prev = subsets(arr[0..-2])\n prev.concat( prev.map { |subarr| subarr + [arr.last] } )\n\nend", "def subsets(arr)\n # byebug\n return [arr] if arr.empty?\n\n if arr.length.odd?\n mid_idx = arr.length / 2\n else\n mid_idx = arr.length / 2 - 1\n end\n# byebug\n with_last = subsets(arr[1..-1])\n # byebug\n without_last = subsets(arr[0...-1])\n # byebug\n combined1 = subsets(arr[0...mid_idx] + arr[mid_idx + 1..-1])\n # combined2 = subsets(arr[0..mid_idx] + arr[mid_idx + 2..-1]) # this didn't work. still missing [1, 2, 4] with [1, 2, 3, 4] original input\n# byebug\n output = without_last + combined1 + with_last + [arr] # combined2\n output.uniq\nend", "def subsets(arr)\n return [[]] if arr.empty?\n sub = subsets(arr[0...-1])\n newsub = sub.map { |ele| ele + [arr.last] } \n sub + newsub\n\n\n# sub + arr[-1]\nend", "def each_subset(array)\n subsets_of(array).each {|subset| yield(subset)}\n end", "def permutations(array)\n return [array] if array.length <= 1\n\n\n # Similar to the subsets problem, we observe that to get the permutations\n # of [1, 2, 3] we can look at the permutations of [1, 2] which are\n # [1, 2] and [2, 1] and add the last element to every possible index getting\n # [3, 1, 2], [1, 3, 2], [1, 2, 3], [3, 2, 1], [2, 3, 1]\n\n # pop off the last element\n first = array.shift\n # make the recursive call\n perms = permutations(array)\n # we will need an array to store all our different permutations\n total_permutations = []\n\n\n # Now we iterate over the result of our recusive call say [[1, 2], [2, 1]]\n # and for each permutation add first into every index. This new subarray\n # gets added to total_permutations.\n perms.each do |perm|\n (0..perm.length).each do |i|\n total_permutations << perm[0...i] + [first] + perm[i..-1]\n end\n end\n total_permutations\nend", "def permutations(array)\n return [array] if array.length <= 1\n\n # Similar to the subsets problem, we observe that to get the permutations of \n # [1, 2, 3] we can look at the permutations of [1, 2] which are [1, 2] and \n # [2, 1] and add the last element to every possible index getting [3, 1, 2], \n # [1, 3, 2], [1, 2, 3], [3, 2, 1], [2, 3, 1], [2, 1, 3]\n\n # pop off the last element\n first = array.shift\n\n # make the recursive call\n perms = permutations(array)\n\n # we will need an array to store all our different permutations\n total_permutations = []\n\n # Now we iterate over the result of our recusive call say [[1, 2], [2, 1]]\n # and for each permutation add first into every index. This new subarray\n # gets added to total_permutations.\n perms.each do |perm|\n (0..perm.length).to_a.each do |i|\n total_permutations << perm[0...i] + [first] + perm[i..-1]\n end\n end\n\n total_permutations\nend", "def find_subsets(arr, target_value)\n rec(arr, target_value, arr.length - 1)\nend", "def permutations(array)\n return [array] if array.length <= 1\n \n \n # Similar to the subsets problem, we observe that to get the permutations\n # of [1, 2, 3] we can look at the permutations of [1, 2] which are\n # [1, 2] and [2, 1] and add the last element to every possible index getting\n # [3, 1, 2], [1, 3, 2], [1, 2, 3], [3, 2, 1], [2, 3, 1]\n \n # pop off the last element\n first = array.shift\n # make the recursive call\n perms = permutations(array)\n # we will need an array to store all our different permutations\n total_permutations = []\n \n \n # Now we iterate over the result of our recusive call say [[1, 2], [2, 1]]\n # and for each permutation add first into every index. This new subarray\n # gets added to total_permutations.\n perms.each do |perm|\n (0..perm.length).each do |i|\n total_permutations << perm[0...i] + [first] + perm[i..-1]\n end\n end\n total_permutations\nend", "def subsets_2(nums, results = [], solution = [], current_idx = 0)\n results << solution.clone\n return if current_idx >= nums.length\n\n current_idx.upto(nums.length - 1) do |i|\n solution << nums[i]\n subsets(nums, results, solution, i + 1)\n solution.pop\n end\n\n results\nend", "def subsets_with_dup(nums)\n result = []\n nums.sort!\n subsets_helper(nums, [], result, 0, {})\n result\nend", "def subsets_3(nums, results = [], solution = [], current_idx = 0)\n results << solution.clone\n return if current_idx == nums.length\n\n nums[current_idx..-1].each_with_index do |num, i|\n solution << num\n subsets(nums, results, solution, current_idx + i + 1)\n solution.pop\n end\n\n results\nend", "def subsets(arr, n = arr.size-1)\n #Heaps permutations\n @sol = [] if n == arr.size - 1\n\n if n == 0\n p arr\n @sol << arr\n return arr\n else\n (n+1).times do |i|\n p i\n subsets(arr,n-1)\n if( (n - 1) % 2 == 1)\n arr[1],arr[n] = arr[n],arr[1]\n else\n arr[i],arr[n] = arr[n],arr[i]\n end\n end\n end\nend", "def generate_n_sets(array, number_of_sets)\n\nend", "def powerset(arr)\n arr.inject([Set.new].to_set) do |powerset, el|\n new_powerset = Set.new\n powerset.each do |subset|\n new_powerset << subset\n new_powerset << subset + [el]\n end\n new_powerset\n end\n end", "def common_subsets(array_one, array_two)\n\nend", "def recompute_recursive_subsets\n @recursive_subsets = subsets.inject(ValueSet.new) do |set, child|\n set.merge(child.recursive_subsets)\n end\n if parent\n parent.recompute_recursive_subsets\n end\n end", "def get_power_set_2(set)\n\treturn [[]] if set.empty?\n\n\tnum = set.pop\n\tprevious_subsets = get_power_set_2(set)\n\n\tprevious_subsets.map do |subset|\n\t\t[subset.dup.push(num), subset]\n\tend.flatten(1)\n\nend", "def subset_in_array?(array, value)\n result = 1.upto(array.length).flat_map do |n|\n array.combination(n).to_a\n end\n result.include?(value)\nend", "def common_subsets(arr1, arr2)\n subsets(intersection3(arr1, arr2))\nend", "def find_subsets_of_points(options={})\n puts \"Calculating subsets\"\n puts \"Set of #{@points_amount} points: 2^#{@points_amount} subsets = #{2**@points_amount} different subsets\"\n @points_subsets = Array.new(@points_amount) { Array.new }\n # amount of all subsets of a set 2^n-1 (-1, as we're excluding the empty set {})\n (1..2**@points.length-1).each { |i|\n p i if i%100000 == 0\n subset_size = subset_size(i)\n if (options[:with_first_point_only] != true) || (options[:with_first_point_only] == true and i % 2 == 1)\n @points_subsets[subset_size-1] << i\n end\n }\n\n (2..@points_amount).each do |subset_size|\n subsets = @points_subsets[subset_size-1]\n puts \"Subset size: \" + subset_size.to_s + \"; Subsets total: \" + subsets.size.to_s\n end\n\n puts \"Done calculating subsets\"\n end", "def permutations(array)\n\n ret = []\n return [array] if array.length < 2\n sub = permutations(array[1..-1])\n sub.each do |sub_array|\n (0..sub_array.length).each do |idx|\n ret << sub_array[0...idx] + [array.first] + sub_array[idx..-1]\n end\n end\n ret\nend", "def sub_arrays(arr)\n sub_arr = []\n i_arr = []\n arr.length.times do |x|\n arr.map do |ele1|\n i_arr += [ele1]\n sub_arr << i_arr\n end\n i_arr = []\n arr.shift\n end\n sub_arr\nend", "def common_subsets(array_one, array_two)\n common_array = fast_intersection(array_one, array_two)\n subsets(common_array)\nend", "def common_subsets(array_one, array_two)\n subsets(fast_intersection(array_one, array_two))\nend", "def get_power_set_1(set)\n\t(0..set.length).map {|i| set.combination(i).to_a}.flatten(1)\nend", "def permutations(array)\n debugger\n return [array] if array.length <= 1\n # pop off the last element\n first = array.shift\n # make the recursive call\n perms = permutations(array)\n # we will need an array to store all our different permutations\n total_permutations = []\n\n\n # Now we iterate over the result of our recusive call say [[1, 2], [2, 1]]\n # and for each permutation add first into every index. This new subarray\n # gets added to total_permutations.\n perms.each do |perm|\n (0..perm.length).each do |i|\n total_permutations << perm[0 ... i] + [first] + perm[i .. -1]\n end\n end\n total_permutations\nend", "def sub_arrays\n result = []\n self.each_index do |i|\n self.each_index do |j|\n result << self[i..j] if j >= i\n end\n end\n result\n end", "def permutations(array)\n if array.empty?\n return [[]]\n end\n if array.count == 1\n return [array.clone]\n end\n arr = []\n array.each_with_index do |ele, idx|\n cpy = array.clone\n cpy.delete_at(idx)\n permutations(cpy).each do |perm|\n arr << [ele] + perm\n end\n end\n return arr\nend", "def permute(arr)\n return [array] if array.length <= 1\n\n first = array.shift\n perms = permute(array)\n total_permutations = []\n \n \n # Now we iterate over the result of our recusive call say [[1, 2], [2, 1]]\n # and for each permutation add first into every index. This new subarray\n # gets added to total_permutations.\n perms.each do |perm|\n (0..perm.length).each do |i|\n total_permutations << perm[0...i] + [first] + perm[i..-1]\n end\n end\n total_permutations\nend", "def sub(array)\n arr = []\n array.each_index do |i|\n (i...array.length).each do |j|\n arr << array[i..j]\n end\n end\n arr \nend", "def select(array, path=[], solutions=[])\n if path.size == 5 #|| array.size == 0\n solutions << path\n return solutions \n end\n\n 0.upto(array.size-1).each do |num|\n arr = array[num]\n if arr[0].is_a?(Array)\n arr.each do |a|\n select(array[(num+1..-1)], path + [a],solutions)\n end\n else\n select(array[(num+1..-1)], path + [arr], solutions)\n end\n end\n\n return solutions\nend", "def permutations(arr)\n # return nil if arr.empty?\n return [arr] if arr.length == 1\n # grab first element to append to all perms of smaller array\n first_el = arr.shift\n # get permutations of shrunken array\n subset_perms = permutations(arr)\n total_permutations = []\n # iterate through all smaller perms\n subset_perms.each do |sub|\n # add first element to all possible indices of perms array\n # and add to total_perms array\n (0..sub.length).each do |i|\n subset = sub[0...i] + [first_el] + sub[i..-1]\n total_permutations << subset\n end\n end\n total_permutations\nend", "def permutations array\n if array.size < 2\n yield array\n else\n array.each do |element|\n permutations(array.select() {|n| n != element}) \\\n {|val| yield([element].concat val)}\n end\n end\nend", "def find_subarrays(nums_ary)\n subarrays = []\n last_index = nums_ary.size - 1\n 0.upto(last_index) do |start_index|\n start_index.upto(last_index) do |end_index|\n subarrays << nums_ary[start_index..end_index]\n end\n end\n subarrays.push([])\nend", "def permutation(array)\n answer_arr = []\n return array if array.length == 1\n array.each_index do |i|\n perm = permutation(array - [array[i]])\n perm.each do |el|\n answer_arr << ([array[i]] + [el]).flatten\n end\n perm.each do |el|\n answer_arr << ([el] + [array[i]]).flatten\n end\n end\n answer_arr.uniq\nend", "def permutation (array)\n# yields permutation set WITH duplicates\nend", "def largest_sub_sum(array)\n subsets = []\n i = 0\n while i < array.length\n j = i\n while j < array.length\n subsets << array[i..j]\n j += 1\n end\n i += 1\n end\n result = nil\n subsets.map {|subset| subset.inject(:+)}.each do |sum|\n result = sum if result.nil? || result < sum\n end\n result\nend", "def permutations(arr)\n # will have to iterate\n # will have logic similar to subsets\n\n # [1], hits base case and we're done\n\n return [arr] if arr.length <= 1\n\n result = []\n last_ele = arr.pop\n sub_perms = permutations(arr)\n\n sub_perms.each do |sub|\n (0..sub.length) do |i| # index will vary, we to include sub.length as an index, otherwise we will never be able to shove into the last/back spot\n result << sub[0...i] + [last_ele] + sub[i..-1]\n # since the i will vary as we iterate through, ^^ will shift the last_ele around\n end\n end", "def PowerSetCount(arr)\n combinations = []\n (0..arr.size).each { |combo| combinations += arr.combination(combo).to_a }\n combinations.size\nend", "def permutations(array)\n #base case\n return [[]] if array.empty?\n\n results = []\n prev_perm = permutations(array[0...-1]) # permutations([1,2]) == [[1, 2], [2, 1]]\n last_ele = array[-1] # 3\n prev_perm.each do |sub_arr|\n (0...array.length).each do |idx|\n # temp = Array.new(array.length) [nil, nil, nil]\n # temp = sub_arr[0...idx] + [last_ele] + sub_arr[idx..-1]\n results << temp\n end\n end\n results\nend", "def getLineSubset( arr, len )\n return [] if (arr.empty? || (x = arr[0]) > len)\n return [[x]] if x == len\n ar = arr.drop(1)\n getLineSubset( ar, len-x )\n .each{ |a| a.unshift x }\n .concat getLineSubset( ar, len )\nend", "def permutations(array)\n return [array] if array.length == 1\n\n perms = []\n array.each do |el|\n dupped = array.dup\n dupped.delete(el)\n permutations(dupped).each { |perm| perms << [el] + perm }\n end\n\n perms\nend", "def permutations(array)\n return [array] if array.length <= 1\n start = array.shift\n perm = permutations(array)\n total_perms = []\n perm.each do |perms|\n (0..perm.length).each do |i|\n total_perms << perms[0...i] + [start] + perms[i..-1]\n end\n end\n total_perms\nend", "def largest_contiguous_subsum(arr)\n subsets = []\n\n (0...arr.length).each do |idx1|\n (idx1...arr.length).each do |idx2|\n subsets << arr[idx1..idx2]\n end\n end \n\n largest_sum = subsets.first.sum\n\n subsets.each do |subset|\n if subset.sum > largest_sum\n largest_sum = subset.sum\n end\n end\n\n print subsets\nend", "def unique_combinations(array, aggregate, all=Set.new, current=[], start=0, &aggregator)\n return all if array.length == start\n (1..array.length-start).flat_map do |offset|\n index = start + offset\n element = array[index-1]\n nextaggregate, prune = aggregator.call(aggregate, element)\n break if prune\n combination = [*current, element]\n unless all.include? combination\n all << combination\n unique_combinations(array, nextaggregate, all, combination, index, &aggregator)\n end\n end\n all\nend", "def variations(a)\n if !a.empty?\n first = a.first \n if a.length==1 then\n first\n else\n rest = variations(a[1..-1])\n first.map{ |x| rest.map{ |y| \"#{x} #{y}\" } }.flatten\n end\n else\n # \"array is empty\"\n a\n end\n \nend", "def permutations(array)\n return [array] if array.length <= 1\n\n first = array.shift\n perms = permutations(array)\n total_permutations = []\n\n perms.each do |perm|\n (0..perm.length).each do |i|\n total_permutations << perm.take(i) + [first] + perm.drop(i)\n end\n end\n total_permutations\nend", "def permutations(array)\n return [[]] if array.empty?\n return [array] if array.length == 1\n new_arr = []\n\n first_el = array.shift\n array_perms = permutations(array)\n array_perms.each do |perm|\n (0..perm.length).each do |idx|\n new_arr << perm[0...idx] + [first_el] + perm[idx..-1]\n end\n end\n return new_arr\nend" ]
[ "0.87270164", "0.8645382", "0.8640923", "0.8629626", "0.85947233", "0.85543853", "0.84376246", "0.8425681", "0.8392608", "0.83855593", "0.83690864", "0.8278923", "0.82593596", "0.8256711", "0.82462156", "0.8226202", "0.82134324", "0.820435", "0.82006145", "0.8193629", "0.8193629", "0.8193629", "0.80997574", "0.8084394", "0.80835974", "0.8050187", "0.8016321", "0.7991656", "0.7920343", "0.7910591", "0.7907531", "0.79002655", "0.78828615", "0.78621346", "0.776214", "0.7743355", "0.7733981", "0.77325815", "0.77217776", "0.7702736", "0.7692966", "0.7685738", "0.764999", "0.76412797", "0.7631336", "0.7631121", "0.7574355", "0.7548287", "0.74768347", "0.7435078", "0.7433968", "0.7395495", "0.71584886", "0.7047044", "0.704287", "0.7038588", "0.70168316", "0.7013117", "0.6990567", "0.68350875", "0.6817546", "0.68153936", "0.6645729", "0.66030586", "0.65613186", "0.6385764", "0.6383925", "0.6152791", "0.6139066", "0.6136605", "0.60776407", "0.6056079", "0.60525656", "0.60025525", "0.5983333", "0.59394467", "0.59302974", "0.5908225", "0.5857136", "0.5775199", "0.5737122", "0.5718755", "0.5716194", "0.5711202", "0.5704944", "0.5701948", "0.5652572", "0.56295484", "0.5621745", "0.55852836", "0.5564136", "0.5563545", "0.5560823", "0.5545926", "0.554517", "0.55443335", "0.55355203", "0.55324954", "0.55250335" ]
0.8103324
22
See question here: Write a recursive method to solve `make_better_change`. HINT: To make_better_change, we only take one coin at a time and never rule out denominations that we've already used. This allows each coin to be available each time we get a new remainder. By iterating over the denominations and continuing to search for the best change, we assure that we test for 'nongreedy' uses of each denomination. `make_better_change(24, [10,7,1])` should return [10,7,7]
def make_better_change(value, coins) return nil if coins.empty? return [] if value == 0 change = [] coins = coins.sort.reverse.select{|coin| coin <= value} coins.each do |coin| remainder = value - coin if remainder > 0 best_remainder = make_better_change(remainder, coins) change << [coin] + best_remainder unless best_remainder.nil? else change << [coin] end end change.sort_by!{|arr| arr.size}.first end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def make_better_change(amount, coin_denoms)\n return [amount] if coin_denoms.include?(amount)\n return [] if amount <= 0\n\n coin_denoms.sort.reverse!\n all_possible_arr = []\n\n coin_denoms.each do |value|\n change_arr = []\n change_arr << value\n change_arr.concat(make_better_change(amount - value, coin_denoms))\n all_possible_arr << change_arr if change_arr.inject(:+) == amount\n end\n\n all_possible_arr.min_by { |arr| arr.length }\n\nend", "def make_better_change(change, coins)\n # base case would be if the change exactly matched one of the coins\n # it would simple return the coin and it would be the least amount of coins\n return [change] if coins.include?(change)\n\n # filter out any coins that are greater than the change\n # we also need an array to compare possible solutions\n usable_coins = coins.select { |coin| coin <= change }\n possible_solutions = []\n \n # loop through the usable coins and make possible combinations\n usable_coins.each do |coin|\n remainder_coins = usable_coins.select { |i| i <= coin }\n remainder_change = change - coin\n\n # rescuing exception\n begin\n # make_better_change will return nil if there is no possible solution\n # so it would be nil + [coin], which would result in NoMethodError\t\n possible_solution = make_better_change(remainder_change, remainder_coins) + [coin]\n rescue NoMethodError\n return nil\n end\n\n possible_solutions << possible_solution\n end\n\n possible_solutions.sort_by(&:length).first\nend", "def make_change(target, coins = [25, 10, 5, 1])\n # Don't need any coins to make 0 cents change\n return [] if target == 0\n # Can't make change if all the coins are too big. This is in case\n # the coins are so weird that there isn't a 1 cent piece.\n return nil if coins.none? { |coin| coin <= target }\n\n # Optimization: make sure coins are always sorted descending in\n # size. We'll see why later.\n coins = coins.sort.reverse\n\n best_change = nil\n coins.each_with_index do |coin, index|\n # can't use this coin, it's too big\n next if coin > target\n\n # use this coin\n remainder = target - coin\n\n # Find the best way to make change with the remainder (recursive\n # call). Why `coins.drop(index)`? This is an optimization. Because\n # we want to avoid double counting; imagine two ways to make\n # change for 6 cents:\n # (1) first use a nickel, then a penny\n # (2) first use a penny, then a nickel\n # To avoid double counting, we should require that we use *larger\n # coins first*. This is what `coins.drop(index)` enforces; if we\n # use a smaller coin, we can never go back to using larger coins\n # later.\n best_remainder = make_change(remainder, coins.drop(index))\n\n # We may not be able to make the remaining amount of change (e.g.,\n # if coins doesn't have a 1cent piece), in which case we shouldn't\n # use this coin.\n next if best_remainder.nil?\n\n # Otherwise, the best way to make the change **using this coin**,\n # is the best way to make the remainder, plus this one coin.\n this_change = [coin] + best_remainder\n\n # Is this better than anything we've seen so far?\n if (best_change.nil? || (this_change.count < best_change.count))\n best_change = this_change\n end\n end\n\n best_change\nend", "def make_change( amount, coins=[25,10,5,1], avoid_pennies=true, recursing=false )\n # Don't sort in place, in case the user wants to preserve the coin array\n coins = coins.sort_by{ |coin| -coin }\n owed = amount\n change = []\n coins.each{ |coin|\n while owed >= coin\n owed -= coin\n change << coin\n end\n }\n change = nil unless owed == 0\n\n if recursing\n change\n else\n answers = [ change ]\n while coins.shift\n answers << make_change( amount, coins, avoid_pennies, true )\n end\n answers.compact.sort_by{ |answer|\n [\n answer.length,\n -answer.send( avoid_pennies ? :last : :first )\n ]\n }.first\n end\nend", "def make_better_change(total, coins = [1,5,10,25])\n # base case once total reaches 0\n return [] if total == 0\n\n # array to hold current best change\n best_change = nil\n\n # sort high to low, unnecessary for this function\n coins.sort!{|a,b| b <=> a}\n\n # since best change method unknown, we cycle through coins, grabbing\n # one of current coin and making best change with remainder.\n coins.each do |coin|\n next if coin > total # coin is unusable\n rest_of_change = make_better_change(total - coin, coins)\n change = [coin] + rest_of_change\n # if best change array empty or current change uses less coins, replace\n if best_change.nil? || change.count < best_change.count\n best_change = change\n end\n end\n best_change\nend", "def make_change(amount, coins = [10, 7, 1])\n return [] if amount == 0\n return nil if coins.none? { |coin| coin <= amount }\n\n coins = coins.sort.reverse\n best_change = nil\n coins.each_with_index do |coin, index|\n next if coin > amount\n remainder = amount - coin\n \n best_remainder = make_change(remainder, coins.drop(index))\n \n next if best_remainder.nil?\n \n this_change = [coin] + best_remainder\n \n if best_change.nil? || (this_change.count < best_change.count)\n best_change = this_change\n end \n end\n \n best_change\nend", "def make_better_change(total, coin_values)\n return [] if total == 0\n return nil if coin_values.none? { |coin| coin <= total }\n\n coins = coin_values.sort.reverse\n\n change_possibilities = []\n coins.each_with_index do |coin, index|\n next if coin > total\n\n remainder = total - coin\n best_remainder = make_better_change(remainder, coins.drop(index))\n next if best_remainder.nil?\n\n change_possibilities << [coin] + best_remainder\n end\n\n change_possibilities.min_by(&:length)\nend", "def make_change(coins, target)\n return [] if target == 0\n coins.sort!{|a,b| b <=> a }\n best_change = []\n\n coins.each do |coin|\n solution = []\n (target / coin).times { solution << coin }\n\n solution += make_change(coins.drop(1), target % coin)\n\n if best_change.length > solution.length || best_change.empty?\n best_change = solution\n end\n end\n best_change\nend", "def make_change(change, coins)\n return [] if change == 0\n return nil if coins.count == 0 && change != 0\n\n current_coin = coins.first\n if change / current_coin >= 1\n results = [current_coin] + make_change(change - current_coin, coins)\n next_results = make_change(change - current_coin, coins.shift)\n greedy_results = [current_coin] + next_results unless next_results == nil\n results = greedy_results if greedy_results.length < results.length \n else\n coins.shift\n results = make_change(change, coins)\n end\nend", "def make_change(value,coins)\n return nil if value < coins.min\n best = nil\n coins.each do |coin|\n if value < coin\n next\n elsif value == coin\n return [coin]\n else\n # Try finding a combination of coins that will sum to value - coin.\n # Then you can get a combination of coins for value by adding the\n # current coin.\n candidate = [coin] + make_change(value - coin, coins)\n \n if candidate != nil && (best.nil? || candidate.size < best.size)\n best = [coin] + make_change(value - coin, coins)\n end\n end\n end\n best\nend", "def greedy_make_change(amount, coins = [25, 10, 5, 1])\n return [] if amount == 0\n change = []\n sorted_coins = coins.sort\n largest_coin = sorted_coins.pop\n\n large_coins = amount / largest_coin\n large_coins.times {change << largest_coin}\n\n new_amount = amount - change.sum\n \n change += greedy_make_change(new_amount, sorted_coins)\n\n change\nend", "def greedy_make_change(amount, coins = [25, 10, 5, 1])\n #debugger\n return [amount] if amount == 1\n return [] if coins.min > amount\n\n collected_coins = []\n\n coins.each do |coin|\n divided_amount = amount / coin\n\n if divided_amount > 0\n new_amount = amount - (coin * divided_amount)\n if new_amount == 0\n return collected_coins\n end\n\n divided_amount.times do\n collected_coins << coin\n end\n\n collected_coins += greedy_make_change(new_amount, coins)\n #elsif divided_amount ==\n\n end\n end\n\n collected_coins\nend", "def make_change(amount, coins = [25, 10 ,5, 1])\n biggest_fit_coin = coins.detect { |val| amount >= val }\n\n if biggest_fit_coin == amount\n [biggest_fit_coin]\n else\n [biggest_fit_coin] + make_change(amount - biggest_fit_coin)\n end\nend", "def make_greedy_change(amount, bank = [25,10,5,1])\n return [] if amount == 0\n\n bank.each_with_index do |coin, idx|\n next if coin > amount\n\n remainder = amount - coin\n return [coin] + make_greedy_change(remainder, bank)\n end\nend", "def make_change(target, coins = [25, 10, 5, 1])\n return [] if target == 0\n return nil if coins.none? { |coin| coin <= target }\n\n coins = coins.sort.reverse\n best_change = nil\n\n coins.each_with_index do |coin, index|\n next if coin > target\n remainder = target - coin\n best_remainder = make_change(remainder, coins.drop(index))\n next if best_remainder.nil?\n this_change = [coin] + best_remainder\n if (best_change.nil? || (this_change.count < best_change.count))\n best_change = this_change\n end\n end\n\n return best_change if best_change.nil?\n best_change.count\nend", "def greedy_make_change(total, coins)\n return [] if total == 0\n change = []\n # sort coins largest to smallest\n coins.sort!{|a,b| b <=> a}\n # remove first coin from array\n coin = coins.shift\n # calculate how many fit into total \n coin_count = total / coin\n # add coin to change as many times as calculated above\n coin_count.times { change << coin}\n # current coin change and recursive call to remaining total using remaining coins\n change + greedy_make_change(total-(coin * coin_count), coins)\nend", "def make_better_change(amount, coins)\n stack = [amount]\n until stack.empty?\n coins.each do |coin|\n break if amount - coin == 0\n stack << amount - coin if amount >= coin\n make_better_change(amount-coin, coins)\n end\n end\nend", "def recursive_greedy_make_change(amount, coins = [25, 10, 5, 1])\n return [] if amount == 0\n\n if amount >= coins.first\n new_amount = amount - coins.first\n return [coins.first] + recursive_greedy_make_change(new_amount, coins)\n else\n return recursive_greedy_make_change(amount, coins[1..-1])\n end\nend", "def make_better_change(amount, denoms)\n return greedy_make_change(amount, denoms) if greedy_make_change(amount, denoms).length < greedy_make_change(amount, denoms[1..-1]).length\n make_better_change(amount, denoms[1..-1])\nend", "def make_smart_change(change_amount, available_coins)\n possible_answers = []\n while available_coins.length > 1 do\n possible_answers << make_change(change_amount, available_coins)\n \n #compare best answer\n # this_answer = make_smart_change(x,y)\n # if best_ans.length > this_answer\n # best_ans = this_answer\n # end\n next if available_coins.length == 1\n available_coins = available_coins[1..-1]\n end\n \n #pick shortest length array within possible_answers\n possible_answers.sort_by(&:length)[0]\n \nend", "def make_change(n)\n\tdef change(amount, denoms, index)\n\t\treturn 0 if amount == 0\n\t\treturn 1 if index >= denoms.length\n\t\tcurrent_denom = denoms[index]\n\t\tways = 0\n\t\ti = 0\n\t\twhile i * current_denom <= amount\n\t\t\tamount_remaining = amount - i * current_denom\n\t\t\tways += change(amount_remaining, denoms, index + 1)\n\t\t\ti += 1\n\t\tend\n\t\tways\n\tend\n\tdenoms = [100, 20, 10, 5, 2, 1]\n\tchange(n, denoms, 0)\nend", "def greedy_make_change(value, coins)\n return [] if value == 0 || coins.empty?\n num_coin = value / coins.first\n remaining_value = value % coins.first\n [coins.first] * num_coin + greedy_make_change(remaining_value, coins.drop(1))\nend", "def make_better_change(value, coins)\n check_coins = coins.select { |el| el <= value }\n return nil if check_coins.empty?\n\n solutions = []\n check_coins.sort.reverse.each do |coin|\n remain = value - coin\n\n if remain > 0\n remain = make_better_change(remain, coins)\n solutions << [coin] + remain unless remain.nil?\n else\n solutions << [coin]\n end\n end\n solutions.sort_by! { |arr| arr.length }.first\n\n end", "def greedy_change(num, coins)\n return [] if num <= 0\n\n result = []\n new_coin = coins.select { |coin| num - coin >= 0 }.max\n #p new_coin\n result << new_coin\n #p result\n #p greedy_change(num - new_coin, coins)\n result + greedy_change(num - new_coin, coins)\nend", "def greedy_make_change(total, coin_values)\n return [] if total == 0\n\n coin = coin_values.find { |cn| cn <= total }\n\n [coin] + greedy_make_change(total - coin, coin_values)\nend", "def greedy_make_change(cents,coins = [25,10,5,1])\n return [cents] if coins.include?(cents)\n arr = Array.new\n coins.each do |coin|\n if coin < cents\n arr << coin\n break\n end\n end\n greedy_make_change(cents-arr.first,coins).each {|coin| arr << coin}\n return arr\nend", "def make_better_change(amount, coins = [25, 10, 5, 1])\n\treturn [] if amount < 1\n\tsmallest_change = nil\n\n\tcoins.sort.reverse.each.with_index do |coin, i|\n\t\tunless coin > amount\n\t\t\tchange = [coin] + make_better_change(amount - coin, coins.drop(i))\n\t\t\tif smallest_change == nil || change.count < smallest_change.count\n\t\t\t\tsmallest_change = change\n\t\t\tend\n\t\tend\n\tend\n\n\tsmallest_change\nend", "def greed_make_change(change, coin_arr)\n return [] if change <= coin_arr.min - 1\n changed = false\n i = 0\n change_arr = []\n until changed || i == coin_arr.length\n remainder = change - coin_arr[i]\n if remainder >= 0\n change_arr += [coin_arr[i]] + greed_make_change(remainder,coin_arr)\n change -= coin_arr[i]\n changed = true\n end\n i += 1\n end\n change_arr\nend", "def make_change_it(amount, coins = [25, 10, 5, 1])\n #iterative version to make sure can get it \n change = []\n i = 0\n while amount > 0\n #as long as money is greater than zero there's a coin that we can give back\n while amount >= coins[i]\n #compare money that you have to the biggest coin\n amount -= coins[i]\n change << coins[i]\n p change\n end\n i += 1\n end\nend", "def bestCoinsExchange(coins, change)\n\n #sums is in the format [[coin values], depth]\n #the coin values will be either a real coin\n #or the sum of other coins\n #depth is used to determine how deep in the calculation\n #loop we are. if we have a value for 757 that consists of\n #only 2 coins (depth 1), then we will favor that result\n #in our sums hash over some future result that may use more\n #than 2 coins to arrive at 757\n\n sums = {}\n for c in coins\n sums[c] = [[c],0]\n end\n\n depth = 1\n #keep looping till we have a combination of coins equaling\n #the total change\n while sums[change] == nil\n prod = coins.product(sums.keys)\n prod.each{|p|\n sum = p[0] + p[1]\n l = sums[sum]\n #when putting the combination of coins as the answer\n #for a collection of summed values, we will favor\n #the shallower depth (fewer coins) and the larger coin\n #if the depths are equal\n if l == nil || (p[0] > l[0][0] && l[1] >= depth)\n #dont bother storing the sum if it is larger\n #than what we are looking for\n sums[sum] = [p,depth] if sum <= change\n end\n }\n depth += 1\n end\n\n a = sums[change][0]\n counts = {}\n getCounts(coins, sums, a, counts)\n counts.collect{|k,v| [k,v]}.sort_by{|a| a[0]}.reverse\nend", "def make_change(change_needed, register)\n return [] if change_needed == 0\n\n biggest_coin = register.max\n if biggest_coin <= change_needed\n biggest_coin_amount = 1\n change = [biggest_coin]\n change_remaining = change_needed - biggest_coin\n new_register = register\n else\n new_register = register.dup.sort[0...-1]\n change = []\n change_remaining = change_needed\n end\n\n return change + make_change(change_remaining, new_register)\nend", "def change1(total, denominations)\n breakdowns = []\n\n denominations.each_with_index do |coin, index|\n next if total/coin == 0\n\n subtotal = total\n set = []\n count = subtotal / coin\n\n if count > 0\n count.times { set << coin }\n subtotal -= (coin * count)\n end\n\n if subtotal > 0\n set += change1(subtotal, denominations[index+1..-1])\n end\n breakdowns << set.flatten\n end\n breakdowns\nend", "def make_change(coins, money, index)\n return 1 if money == 0\n return 0 if index >= coins.size\n\n amount_with_coin = 0\n ways = 0\n\n while amount_with_coin <= money\n remaining = money - amount_with_coin\n ways += make_change(coins, remaining, index + 1)\n amount_with_coin += coins[index]\n end\n\n ways\nend", "def greedy_change(amount, coins)\n return {} if amount <= 0\n coins_count = {}\n coins_count[coins.max] = amount / coins.max\n remainder = amount % coins.max\n coins.delete(coins.max)\n coins_count.merge(greedy_change(remainder, coins))\nend", "def greedy_make_change(target, coins=[25,10,5,1])\nend", "def make_change(amt, coins, coin_cache = {0 => 0})\n ### THIS FAILS SPECS BECAUSE NIL.nan? IS NOT A METHOD ###\n return coin_cache[amt] if coin_cache.key?(amt)\n return nil if amt < coins.first\n\n best_change = amt\n coins.each do |coin|\n next if amt < coin\n prev_change = make_change(amt - coin, coins, coin_cache)\n if prev_change.nil?\n coin_cache[amt] = nil\n else\n best_change = [best_change, prev_change + 1].min\n coin_cache[amt] = best_change\n end\n end\n\n best_change == amt ? nil : best_change\n end", "def make_change(amt, coins, coin_cache = {0 => 0})\n return coin_cache[amt] if coin_cache[amt]\n return 0.0/0.0 if amt < coins[0]\n\n min_change = amt\n way_found = false\n idx = 0\n while idx < coins.length && coins[idx] <= amt\n num_change = 1 + make_change(amt - coins[idx], coins, coin_cache)\n if num_change.is_a?(Integer)\n way_found = true\n min_change = num_change if num_change < min_change\n end\n idx += 1\n end\n\n if way_found\n coin_cache[amt] = min_change\n else\n coin_cache[amt] = 0.0/0.0\n end\n end", "def make_change_iterative(amount, coins = [25, 10, 5, 1])\n change = []\n coins.each do |coin|\n count = amount / coin # how many of that coin I can use\n count.times { change << coin }\n amount -= count * coin\n end\n \n change\nend", "def calculate_change(candidate, bills, remaining)\n (0..4).each do |level|\n # Try giving out change at every bills level, skipping denominations that\n # don't have any bills or are bigger than the current change amount.\n next if bills[level] == 0\n next if VALUES[level] > remaining\n # If the denomination is equal to the change remaining, add this bill to\n # change and return the change amount.\n if remaining == VALUES[level]\n candidate[level] += 1\n return candidate\n else\n # Otherwise, recursively try adding the bill to the change amount. If\n # this branch is successful, it will be returned; otherwise, we'll skip\n # to the next denomination\n trial_candidate = candidate.dup\n trial_bills = bills.dup\n trial_remaining = remaining\n trial_candidate[level] += 1\n trial_bills[level] -= 1\n trial_remaining -= VALUES[level]\n trial = calculate_change(trial_candidate, trial_bills, trial_remaining)\n return trial if trial\n end\n end\n false\n end", "def make_change(coins, target_change)\n sorted_in_descending = coins.sort { |a, b| b <=> a }\n change = []\n i = 0\n while i < coins.length\n current_coin = sorted_in_descending[i]\n p current_coin\n if target_change >= current_coin\n target_change -= current_coin\n change << current_coin\n else\n i += 1\n end\n end\n change.length\nend", "def make_change(total, denominations)\n ways = {}\n start_point = 1\n while start_point <= total\n sub_answer = 0\n denominations.each do |coin|\n if coin == start_point\n sub_answer += 1\n elsif coin < start_point\n next if (denominations.include?(start_point - coin) && coin < (start_point - coin))\n sub_answer += ways[start_point - coin]\n end\n end\n ways[start_point] = sub_answer\n start_point += 1\n end\n puts ways\nend", "def change(amount, coins)\n return 0 if coins.empty?\n\n # TO make zero, there is one way. Dont give anything.\n ways = Array.new(amount + 1, 0)\n ways[0] = 1\n coins.each do |coin|\n (coin..amount).each do |amt|\n ways[amt] += ways[amt - coin]\n end\n end\n ways[-1]\nend", "def make_change(amt, coins, coin_cache = {0 => 0})\n return coin_cache[amt] if coin_cache[amt]\n return 0.0/0.0 if amt < coins[0]\n\n min = amt\n change_possible = false\n coins.each do |coin|\n next if coin > amt\n\n test_change = make_change(amt - coin, coins, coin_cache) + 1\n if test_change.integer? && test_change < min\n change_possible = true\n min = test_change\n end\n end\n\n min = 0.0/0.0 unless change_possible\n coin_cache[amt] = min\n\n min\n end", "def make_greedy_coin(remainder,arr=[50,25,10,5,1])\ni=0\nresult=[]\nwhile i < arr.length\nif remainder - arr[i]<0\ni+=1\nelse\n result << arr[i]\n return result+make_greedy_coin(remainder-arr[i])\nend\n\nend\nreturn result\nend", "def make_change(amt, coins, coin_cache = { 0 => 0 })\n return coin_cache[amt] if coin_cache[amt]\n return 0.0 / 0.0 if amt < coins[0]\n\n ans = 0.0 / 0.0\n coins.each do |coin|\n break if coin > amt\n num_coins = 1 + make_change(amt - coin, coins, coin_cache)\n ans = num_coins unless ans.is_a?(Integer) && num_coins > ans\n end\n\n coin_cache[amt] = ans.is_a?(Integer) ? ans : 0.0 / 0.0\n end", "def nonConstructibleChange(coins)\n min_change = 0\n coins.sort!\n\n coins.each do |coin|\n if coin > (min_change + 1)\n return (min_change + 1)\n else\n min_change += coin\n end\n end\n return (min_change + 1)\nend", "def given(array = [])\n i = cur_val = 0\n until array[i].nil?\n cur_val += array[i] * VALS[i]\n i += 1 \n end\n return [array] if cur_val == GOAL_VAL\n combos = []\n if VALS[i] > 1\n (0..((GOAL_VAL - cur_val) / VALS[i])).each do |num_coins|\n combos += given( array + [num_coins] )\n end\n return combos\n else\n return [array + [GOAL_VAL - cur_val] ]\n end\nend", "def coin_change2(coins, amount)\n coins_needed = Hash.new do |hash, key|\n coins_needed_after_one = coins.select {|coin_value| coin_value <= key}.map {|coin_value| hash[key-coin_value]}\n .reject {|coins_needed| coins_needed == -1}.min\n hash[key] = if coins_needed_after_one == nil then -1 else 1 + coins_needed_after_one end\n end.update(0 => 0)\n \n #This is just to prevent stack overflow. If you tried to directly calculate amount you might have too many calls down.\n (1..amount).each {|current| coins_needed[current]}\n \n coins_needed[amount]\nend", "def coin_change(coins, amount)\n coins = coins.sort\n\n return -1 if coins.empty?\n return -1 if coins[0] > amount\n\n current_coin = coins.pop\n change = []\n sum = 0\n\n loop_coins(coins, amount ,current_coin, change, sum)\nend", "def change2(amount, denominations)\n denomination_breakdown = Array.new(amount + 1, 0)\n denomination_breakdown[0] = 1\n\n denominations.each do |denomination|\n (denomination..amount).each do |higher_amount|\n remainder = higher_amount - denomination\n denomination_breakdown[higher_amount] += denomination_breakdown[remainder]\n end\n end\n\n denomination_breakdown[amount]\nend", "def make_change(amt, coins)\n return Float::INFINITY if amt < 0\n return @change_hash[amt] if @change_hash[amt]\n min_so_far = Float::INFINITY\n coins.each do |coin|\n num_coins = make_change(amt - coin, coins) + 1\n min_so_far = num_coins if num_coins < min_so_far\n end\n @change_hash[amt] = min_so_far\n min_so_far\n end", "def change(amount, arr)\n changes = [[]] + Array.new(amount, Array.new(amount))\n\n 1.upto(amount) do |i|\n arr.each do |coin|\n next if coin > i\n\n changes[i] = changes[i - coin] + [coin] if changes[i].size > (changes[i - coin] + [coin]).size\n end\n end\n\n changes[amount]\nend", "def change(amount, coins)\n dp = Array.new(amount + 1,0)\n dp[0] = 1\n (1..coins.size).each do |i|\n (1..amount).each do |j|\n if coins[i - 1] <= j\n dp[j] = dp[j] + dp[j - coins[i-1]]\n end\n end\n end\n dp[amount]\nend", "def change(amount, arr)\n arr.reverse.each_with_object([]) do |coin, change|\n until coin > amount\n amount -= coin\n change << coin\n end\n end\nend", "def make_change(a, list = [25, 10, 5, 1])\n return [] if a < 0\n return [] if a != a.floor\n\n parents = Array.new(a + 1)\n parents[0] = 0\n worklist = [[0, 0]]\n while parents[a].nil? && !worklist.empty? do\n base, starting_index = worklist.shift\n starting_index.upto(list.size - 1) do |index|\n denomination = list[index]\n tot = base + denomination\n if tot <= a && parents[tot].nil?\n parents[tot] = base\n worklist << [tot, index]\n end\n end\n end\n\n return [] if parents[a].nil?\n result = []\n while a > 0 do\n parent = parents[a]\n result << a - parent\n a = parent\n end\n result.sort!.reverse!\n end", "def make_largest_change(amount, coins)\n orig_amount, change = amount, []\n coins.size.times {|index| change[index], amount = amount / coins[index], amount % coins[index] }\n amount > 0 ? make_largest_change(orig_amount + 1, coins) : change # err in favor of larger amount returned\n end", "def make_change(amt, coins)\n return Float::INFINITY if amt < 0\n @cache[0] = 0\n\n return @cache[amt] if @cache[amt]\n minimum = Float::INFINITY\n\n coins.each do |coin|\n attempt = make_change(amt - coin, coins) + 1\n minimum = attempt unless minimum.is_a?(Integer)\n minimum = attempt if attempt < minimum\n end\n\n @cache[amt] = minimum\n end", "def make_change(money, change)\n return [] if money == 0\n if change.first > money\n make_change(money, change.drop(1))\n else\n make_change(money - change.first, change).unshift(change.first)\n end\nend", "def GetChangeCombos(n, c)\n ways = Array.new(n+1,0)\n ways[0] = 1\n c.select!{|c| c<n}\n return 0 if (c.empty?)\n for coin in c\n for amount in coin..n\n ways[amount] =ways[amount] + ways[amount - coin]\n end \n end\n ways[n]\nend", "def make_better_change(value, coins)\n\nend", "def make_better_change(value, coins)\n\nend", "def make_better_change(value, coins)\n\nend", "def changer(amount)\n\n coins = []\n\n [25, 10, 5, 1].each do |denomination|\n coins = amount / denomination\n returned_coins += [denomination] * coins\n amount -= coins * denomination\n end\n returned_coins\nend", "def make_change(amount, denominations = DENOMINATIONS)\n change = {} \n denominations.each{|coin, value|\n num, amount = amount.divmod(value)\n change[coin] = num if num > 0\n }\n # print \" \"\n change\nend", "def dp_change(money, coins) \n <<-DOC\n Input: An integer money and an array Coins = (coin1, ..., coind).\n Output: The minimum number of coins with denominations Coins that changes money.\n \n DPCHANGE(money, Coins)\n MinNumCoins(0) ← 0\n for m ← 1 to money\n MinNumCoins(m) ← ∞\n for i ← 1 to |Coins|\n if m ≥ coini\n if MinNumCoins(m - coini) + 1 < MinNumCoins(m)\n MinNumCoins(m) ← MinNumCoins(m - coini) + 1\n output MinNumCoins(money) \n \n DOC\n\n # Since we can't assign infinity, lets assign the max possible coins + 1 as inifinity\n # Get the least value coin and divide our money with that \n infinity = (money/coins[-1]) + 1\n min_num_coins = {}\n min_num_coins[0] = 0\n (1..money).each do |m|\n min_num_coins[m] = infinity\n coins.each do |coin|\n if (m >= coin)\n if (min_num_coins[m-coin] + 1) < min_num_coins[m]\n min_num_coins[m] = min_num_coins[m-coin] + 1\n end\n end\n end\n end\n return min_num_coins[money]\n end", "def change_possibilities(amount, array_length, target)\n # If the target is 0 there is only one solution\n return 1 if (target == 0)\n \n # If the target is less than 0 there are no solutions\n return 0 if (target < 0)\n \n # If there are no more integers i the array and\n # the target is greater than 0, then no\n # solution exist\n return 0 if (array_length <=0 and target >= 1)\n \n return change_possibilities(amount, array_length-1, target) + change_possibilities(amount, array_length, target-amount[array_length-1] )\nend", "def change(amount, coin_arr, index)\n\tif amount == 0\n\t\treturn 1\n\tend\n\tif index >= coin_arr.length\n\t\treturn 0\n\tend\n\n\tamount_with_coin = 0\n\tways = 0\n\n\twhile amount_with_coin <= amount\n\t\tremainder = amount - amount_with_coin\n\t\tways += change(remainder, coin_arr, index+1)\n\t\tamount_with_coin += coin_arr[index]\n\tend\n\tways\nend", "def change_possibilities_bottom_up(amount, denominations)\n ways_of_doing_n_cents = [0] * (amount + 1)\n ways_of_doing_n_cents[0] = 1\n\n denominations.each do |coin|\n (coin..amount).each do |higher_amount|\n higher_amount_remainder = higher_amount - coin \n ways_of_doing_n_cents[higher_amount] += ways_of_doing_n_cents[higher_amount_remainder]\n end\n end\n ways_of_doing_n_cents\nend", "def determine_minimal_coins(num)\n count = 0\n coins = [11, 9, 7, 5, 3, 1]\n change = num\n coins.each do |coin|\n while change >= coin\n count += 1\n # why in this line, the change always minus 11? but not other coins?????????????\n change -= coin\n end\n end\n count\nend", "def coin_combos(total)\n coins = [1, 5, 10, 25, 50, 100]\n counter ||= 0\n if total == 0\n counter += 1\n p \"#{counter} is counter\"\n return\n elsif total > 0\n coins.reverse.each do |integer|\n if integer < total\n coin_combos(total - integer)\n end\n end\n end\nend", "def change_possibilities_bottom_up(amount, denominations)\n ways_of_doing_n_cents = [1] + Array.new(amount, 0)\n\n denominations.each do |coin| # 1\n (coin..amount).each do |higher_amount|\n higher_amount_remainder = higher_amount - coin\n ways_of_doing_n_cents[higher_amount] += ways_of_doing_n_cents[higher_amount_remainder]\n end\n end\n\n ways_of_doing_n_cents[amount]\nend", "def make_change(amount)\n\tcoin_values = [25, 10, 5, 1]\n\tcoins = []\n\n\tcoin_values.each do |value|\n\t\twhile amount >= value\n\t\t\tcoins.push(value)\n\t\t\tamount -= value\n\t\tend\n\tend\n\n\t# while (amount - 25) >= 0\n\t# \tcoins.push(25)\n\t# \tamount -= 25\n\t# end\n\n\t# while (amount - 10) >= 0\n\t# \tcoins.push(10)\n\t# \tamount -= 10\n\t# end\n\n\n\t# while (amount - 5) >= 0\n\t# \tcoins.push(5)\n\t# \tamount -= 5\n\t# end\n\n\t# while (amount - 1) >= 0\n\t# \tcoins.push(1)\n\t# \tamount -= 1\n\t# end\n\tcoins\nend", "def return_coins(remaining_coins,target_amount)\n # 1. loop through coins, if any one of it is == target_amount, return it.\n # 2. if coins < target_amount, minus the coin from target_amount and save it in a variable.\n return [] if remaining_coins.sum < target_amount\n return [1] if target_amount == 1\n return [] if remaining_coins == []\nfor i in remaining_coins\n return i if i == target_amount\n\n if i == target_amount/3 && !(i < target_amount) \n testcase10 = remaining_coins.select{|x|x==(target_amount/3)}\n return testcase10\n elsif i < target_amount \n save = i\n temporary = target_amount - save\n end\nend \n# remaining_coins.delete_at(remaining_coins.index(remaining_coins[-1]))\nremaining_coins.delete_at(remaining_coins.find_index(save))\nfinal = [save] + [return_coins(remaining_coins,temporary)]\nreturn final.flatten.sort\nend", "def coin_change(coins, amount)\n make_change(coins, amount, 0, {})\nend", "def make_change_for_amount(amount, check = false)\n remaining_returns = amount\n\n change = []\n\n @coins.each do |coin, count|\n num_coins = count\n\n while num_coins > 0 && ((remaining_returns - @@coin_value_by_details[coin]) >= 0)\n # remove amount we need less\n remaining_returns -= @@coin_value_by_details[coin]\n change << @@coin_value_by_details[coin]\n\n num_coins -= 1\n end\n\n @coins[coin] = num_coins unless check\n\n break if remaining_returns == 0\n end\n\n change\n end", "def change_in_coins(change)\n return [] if change.zero?\n supported_nominals.reverse_each do |coin|\n next if (change - coin).negative? || !coin_available?(coin)\n remove_change_coin(coin)\n next unless (sum = change_in_coins(change - coin))\n return sum + [coin]\n end\n nil\n end", "def make_change(amount, denominations)\n\nend", "def calculate_change(amount, coin_array = nil)\n # ignore coins higher than the target amount\n @status = :no_change\n avail_coins = get_available_coins(coin_array, amount)\n return status unless avail_coins.any?\n required_quantity = amount / avail_coins[0].value\n return status unless coins_are_available(avail_coins, required_quantity)\n residual = amount % avail_coins[0].value\n return @status = :success if residual.zero?\n calculate_change(residual, avail_coins[1..-1])\n end", "def coin_denominaitons(money, denom)\n\tcount = 0\n\tresult = []\n\t#M = money\n\t#D = denom.reverse\n\tdef denominate (mm, dd)\n\t\tsubresult = []\n\t\t#while m > 0\n\t\t\tdd.each do |d|\n\t\t\t\twhile mm >= d\n\t\t\t\t\tsubresult << \"#{d}c\"\n\t\t\t\t\tmm - d\n\t\t\t\tend\n\t\t\tend\n\t\t#end\n\t\tputs subresult\n\t\tresult << subresult\n\t\tcount += 1\n\t\tdd.shift\n\t\tdenominate(mm, dd)\n\tend\t\n\tdenominate(money,denom)\n\tputs \"Number of ways to make #{M}: #{count}\"\n\tputs result\nend", "def change_for(total_change)\n raise NegativeTargetError if total_change < 0\n\n final_row = coins.reduce(\n [[]] + [nil] * total_change,\n &method(:apply_coin_to_row)\n )\n\n raise ImpossibleCombinationError if final_row[-1].nil?\n\n final_row[-1]\n end", "def possibilities (target, coins)\n return 1 if target == 0\n return 0 if target < 0 || coins . length == 0\n\n sum = 0\n for i in 0 .. (target / coins [0]) . to_i do\n sum += possibilities(target - i * coins [0], coins [1 .. -1])\n end\n\n return sum\nend", "def alternate_options(amount, coins)\n inner_options, high, head, tail = [], amount / coins[0], coins[0], coins[1..-1]\n high.times {|n| inner_options << make_largest_change((amount - ((high - n) * head)), tail).unshift(high - n)}\n inner_options\n end", "def make_change( amount )\n #REMOVED IN REFACTOR: coins = changer( pull_cents( f ), COINS )\n #REMOVED IN REFACTOR: bills = changer( pull_bills( f ), BILLS )\n coins = changer( pull_currency( amount ){ | s, idx | currency = s[ idx + 1..-1 ] }, COINS )\n bills = changer( pull_currency( amount ){ | s, idx | currency = s[ 0...idx ] }, BILLS )\n [ bills, coins ]\n end", "def make_change(num)\n\t\n\tarray = []\n\n\tamount = num\n\tquaters = amount/25\n\t# puts quaters \n\tamount_left= num - (quaters * 25 )\n\tdime = amount_left/10\n\t# puts dime\n\tamount_left2 = num - (quaters*25+dime*10)\n\tnickel = amount_left2/5\n\t# puts nickel\n\tamount_left3 = num - (quaters*25+dime*10+nickel*5)\n\tpenny = amount_left3/1\n\t# puts penny\n\tarray.push((quaters*25),(dime*10),(nickel*5),penny)\n\tarray\n\n\t# coins = []\n\n\t# while (amount-25) >= 0\n\t# \tcoins.push(25)\n\t# \tamount -=25\n\t# end\n\n\n\n\nend", "def change (cost, quantity) \n\t@total_change = @total - (cost.to_i * quantity.to_i) #subtract cost*quantity to the total money\n\t@new_total = @total_change \n\t#looking for number of bills per denomination\n\tif @total_change >= 1000\n \t\tthousands_change = @total_change / 1000\n \t\t@total_change = @total_change % 1000\n \tend\n \t\n \tif @total_change >= 500\n \t\tfive_hundreds_change = @total_change / 500\n \t\t@total_change = @total_change % 500\n \tend\n \t\n \tif @total_change >= 100\n \t\thundreds_change = @total_change / 100\n \t\t@total_change = @total_change % 100\n \tend\n \t\n \tif @total_change >= 50\n \t\tfifties_change = @total_change / 50\n \t\t@total_change = @total_change % 50\n \tend\n \t\n \tif @total_change >= 20\n \t\ttwenties_change = @total_change / 20\n \t\t@total_change = @total_change % 20\n \tend\n \t\n \tif @total_change >= 10\n \t\ttens_change = @total_change / 10\n \t\t@total_change = @total_change % 10\n \tend\n \t\n \tif @total_change >= 5\n \t\tfives_change = @total_change / 5\n \t\t@total_change = @total_change % 5\n \tend\n \t\n \tif @total_change >= 1\n \t\tones_change = @total_change / 1\n \t\t@total_change = @total_change % 1\n \tend\n \t\n \tchange = {\n \t\t:ones => ones_change.to_i,\n \t\t:fives => fives_change.to_i,\n \t\t:tens => tens_change.to_i,\n \t\t:twenties => twenties_change.to_i,\n \t\t:fifties => fifties_change.to_i,\n \t\t:hundreds => hundreds_change.to_i,\n \t\t:five_hundreds => five_hundreds_change.to_i,\n \t\t:thousands => thousands_change.to_i\n \t}\n \t\n \t\"<br /> #{change[:ones]} Php 1\" \"<br />#{change[:fives]} Php 5\" \"<br />#{change[:tens]} Php 10,\" \"<br />#{change[:twenties]} Php 20\" \"<br />#{change[:fifties]} Php 50\" \"<br />#{change[:hundreds]} Php 100\" \"<br />#{change[:five_hundreds]} Php 500\" \"<br />#{change[:thousands]} Php 1000\"\n end", "def min_change_sum(coins, total)\n totals = Array.new(total + 1, 1000000000000)\n totals[0] = 0\n\n (1..total).each do |i|\n coins.each do |coin|\n if coin <= i && (totals[i-coin] + 1 < totals[i])\n totals[i] = totals[i-coin] + 1\n end\n end\n end\n\n totals[total]\nend", "def coins(n, demoninations = [1, 5, 10, 25])\n change_table = []\n\n \n\nend", "def coin_combos(target_value, coin_values)\n coin_values.sort!\n _coin_combos(target_value, coin_values)\nend", "def lemonade_change(bills)\n hash = {\n 5 => 0,\n 10 => 0,\n 20 => 0\n }\n \n bills.each do |bill|\n hash[bill] += 1\n if bill != 5\n change = bill - 5\n \n until change == 0\n if change >= 20\n if hash[20] > 0\n hash[20] -=1\n change -= 20\n elsif hash[10] > 0\n hash[10] -=1\n change -= 10\n elsif hash[5] > 0\n hash[5] -=1\n change -= 5\n else\n return false\n end\n elsif change >= 10\n if hash[10] > 0\n hash[10] -=1\n change -=10\n elsif hash[5] > 0\n hash[5] -=1\n change -= 5\n else\n return false\n end\n elsif change >= 5\n if hash[5] > 0\n hash[5] -=1\n change -= 5\n else\n return false\n end\n end\n end\n \n end\n end\n true\nend", "def dispense_change(change_due, product)\n coins = @coins.map(&:value)\n change = coins.sort\n .reverse\n .map do |coin|\n number_of_coins = change_due / coin\n change_due %= coin\n Array.new(number_of_coins) { coin }\n end\n change.flatten.each do |ch|\n @coins.delete(@coins.find { |c| c.value == ch })\n end\n puts \"Here are the coins due to you: #{change.flatten} pennies\"\n dispense_product(product)\n change.flatten\n end", "def wonky_coins(n)\n return 1 if n == 0\n\n # call wonky_coins from inside itself. This is called *recursion*.\n return wonky_coins(n / 2) + wonky_coins(n / 3) + wonky_coins(n / 4)\nend", "def solution_proximity_heuristic(amount,comb,coins)\n (amount-comb.sum)*min_size_heuristic(amount,comb,coins)\nend", "def find_solutions_dp\n solutions = Array.new(@amount+1).map {|i| 0 }\n solutions[0] = 1\n\n @coins.each do |coin|\n for i in coin..@amount\n solutions[i] = solutions[i] + solutions[i-coin]\n end\n end\n\n solutions[@amount]\n end", "def arrange_coins(n)\n k = 0\n while (n -= k) > k\n k += 1\n end\n k\nend", "def puppy_golden_age_brute_forced(gains)\n \n # brute force solution\n \n if gains.empty?\n return nil\n end\n \n golden_age_so_far= [0, 0]\n value_so_far= sum(gains[0..0])\n \n 0.upto (gains.length-1) do |i|\n i.upto (gains.length-1) do |j|\n if sum(gains[i..j]) > value_so_far\n value_so_far= sum(gains[i..j])\n golden_age_so_far= [i, j]\n end\n end\n end\n \n golden_age_so_far\nend", "def recursive_solution\n\n end", "def getWays(n, c)\n # i = n or change needed\n # j = enabled coins\n # dp[i][j] = dp[i - j's coin value][j] + dp[i][j - 1]\n store = [[1] * c.length]\n\n (1..n).each do |i|\n c.length.times do |j|\n sum_one = i - c[j] >= 0 ? store[i - c[j]][j] : 0\n sum_two = j - 1 >= 0 ? store[i][j - 1] : 0\n store[i] = [] unless store[i]\n store[i][j] = sum_one + sum_two\n end\n end\n\n store.last.last\nend", "def 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 min_size_heuristic(amount,comb,coins)\n rem = amount-comb.sum\n return Infinity if rem < 0\n comb.size+rem.to_f/(coins.select{|c|c<=rem&&c<=comb.max}.max) rescue comb.size\nend" ]
[ "0.8316686", "0.83139235", "0.82586664", "0.82519823", "0.8250704", "0.82127", "0.8174465", "0.80130213", "0.79879445", "0.79535246", "0.79313856", "0.79106355", "0.78628373", "0.7860745", "0.78558904", "0.78454685", "0.78333384", "0.7801111", "0.7747187", "0.7690399", "0.7679756", "0.76529205", "0.7632515", "0.75849503", "0.7579093", "0.7513821", "0.7509126", "0.74878615", "0.74457157", "0.7235641", "0.7224194", "0.72124195", "0.7159455", "0.7123874", "0.7098299", "0.7016233", "0.6992644", "0.69797117", "0.6883463", "0.6809876", "0.6801026", "0.6790852", "0.6777901", "0.6753094", "0.67240715", "0.6712607", "0.6671843", "0.66630816", "0.6653909", "0.66297585", "0.6628757", "0.65988976", "0.65791297", "0.6564271", "0.65390944", "0.6530937", "0.6508771", "0.6493652", "0.64935803", "0.6489198", "0.6489198", "0.6489198", "0.64798987", "0.64669603", "0.6463408", "0.6445453", "0.6411947", "0.6371728", "0.6359614", "0.63170856", "0.63168836", "0.62725335", "0.6226022", "0.6136706", "0.6124161", "0.61116", "0.60999715", "0.60909766", "0.6066744", "0.60570747", "0.603281", "0.6007731", "0.5980535", "0.59759974", "0.5947251", "0.5938861", "0.5912709", "0.5888986", "0.5876049", "0.5841091", "0.5819523", "0.5766031", "0.5738232", "0.57373565", "0.5733808", "0.5719675", "0.5713292", "0.5697038", "0.56795484" ]
0.7930268
12
THIS PROBLEM WILL NOT SHOW UP ON A REAL ASSESSMENT If you are a nonnative English speaker and find it difficult to understand this problem, do not spend too much time on it. Focus on other problems instead. Define a method `pig_latinify(sentence)` that translates a sentence into pig latin. You may want a helper method. Rules In the English language, vowels are the following letters: ['a', 'e', 'i', 'o', 'u'] Consonants are all other letters. Pig latin translation uses the following rules: 1. If the word begins with a vowel, simply append `ay` onto the end. ex. 'apple' => 'appleay' 2. If the word begins with a consonant, move the starting consonants to the end of the word and then append `ay` ex1. 'pearl' => 'earlpay' ex2. `school` => `oolschay` 3. Treat `qu` at the start of a word as a singular consonant. ex1. `queen` => `eenquay` ex2. `square` => `aresquay`
def pig_latinify(sentence) translated_words = sentence.split(" ").map do |word| translate_word(word) end translated_words.join(" ") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def pig_latin_sentence(sentence)\n y = sentence\n x = sentence.split\n vowels = [\"a\", \"e\", \"i\", \"o\", \"u\"]\n t = \"t\"\n h = \"h\"\n qu = \"qu\"\n\n x.map do |word|\n first_letter = word[0]\n if vowels.include?(first_letter)\n word << \"way\"\n elsif word.include?(t && h)\n word << t\n word << h\n word.slice!(0..1)\n word << \"ay\"\n elsif word.include?(qu)\n word << qu\n word.slice!(0..1)\n word << \"ay\"\n else\n word << first_letter\n word.slice!(0)\n word << \"ay\"\n end\n x[0].capitalize!\n end\n\n x.join(\" \")\nend", "def convert_pig_latin(sent)\n vowels = \"aeiou\"\n latin = []\n\n sent = sent.split(\" \")\n sent.each_with_index do |word,idx|\n uppercase = false\n if word.length < 3\n latin << word\n elsif vowels.include?(word[0].downcase)\n latin << (word + \"yay\")\n else\n temp_str = \"\"\n i = 0\n while i < word.length\n uppercase = true if i == 0 && word[i] == word[i].upcase\n if !vowels.include?(word[i].downcase)\n temp_str += word[i]\n else \n new_word = (word[i..-1] + temp_str.downcase + \"ay\")\n uppercase ? ( latin << (new_word[0].upcase + new_word[1..-1]) ) : ( latin << new_word )\n break\n end\n i += 1\n end\n end\n end\n latin.join(\" \")\nend", "def piglatinize_word(word)\r\n # vowel at the start\r\n # 3 consonants\r\n # 2 consonants\r\n # 1 consonant\r\n # count consonants\r\n count = 0\r\n # check if word starts with a vowel\r\n if !consonant?(word[0])\r\n word += \"w\"\r\n else\r\n count += 1\r\n end\r\n \r\n # check if word starts with 3 consonants\r\n if count == 1 && consonant?(word[1]) && consonant?(word[2])\r\n count += 2\r\n word = word.slice(3..-1) + word.slice(0,3)\r\n # check if word starts with 2 consonants if it isn't 3\r\n elsif count == 1 && consonant?(word[1])\r\n word = word.slice(2..-1) + word.slice(0,2)\r\n # check if word starts with 1 consonant if it isn't 3 or 2\r\n elsif count == 1 \r\n word = word.slice(1..-1) + word.slice(0)\r\n end\r\n\r\n # finally add the \"ay\" using += or <<\r\n word+= \"ay\"\r\n end", "def pig_latin(word)\n vowels = ['a', 'e', 'i', 'o', 'u']\n suffix = 'ay'\n position = 0\n word = word.split(//)\n\n word.any? do |character|\n if vowels.include?(character)\n position = word.find_index(character)\n end\n end\n\n word = word.join.downcase\n punctuation = punctuation?(word) ? word.chars.last : ''\n word_start = punctuation?(word) ? word[position..-2] : word[position..-1]\n\n if position > 0\n word = word_start + word[0...position] + suffix + punctuation \n return word\n end\n\n word = word + suffix\nend", "def pig_latin_name(word)\n# and returns a new string (pig latinified)\n# need to define vowels (can be an array?)\n vowels_list = vowels\n# break word into letters\n letters = word.split(\"\")\n# iterate through each letter of the word\n# until we hit a vowel\n letters.each do |letter|\n\n # check if first letter is vowel or consonant\n if is_consonant?(letter)\n # move it to the end\n removed_consonant = letters.shift\n letters = letters + removed_consonant.split\n #\n else\n letters.push(\"ay\")\n return letters.join\n end\n\n # then add \"ay\" at the end and return\n end\n\nend", "def piglatinize(word)\n vowels = ['a','e','o','u','i','A','E','O','U','I']\n split_word = word.split('')\n\n if vowels.include?(split_word[0])\n split_word << \"way\"\n else\n until vowels.include?(split_word[0])\n split_word.rotate!(1)\n end\n split_word << \"ay\"\n end\n split_word.join\n end", "def piglatinize(words)\n \n # \"flat iron\"\n # change the words in to an arry of words\n # words = \"Flat iron\"\n # expecting \"atFlay ironway\"\n splited_words = words.split(\" \")\n # vowels = [\"a\", \"e\",\"i\",\"o\"]\n sentence = []\n splited_words.each do |word|\n # .map do |word|\n changed_word = []\n beginning =[]\n i = 0\n while i < word.length do\n if word[i].downcase != \"a\" && word[i].downcase != \"e\" && word[i].downcase != \"i\" && word[i].downcase != \"o\" && word[i].downcase != \"u\"\n \n changed_word << word[i] \n else\n break\n end\n i += 1\n end\n \n beginning << word[i, word.length]\n if word[0].downcase != \"a\" && word[0].downcase != \"e\" && word[0].downcase != \"i\" && word[0].downcase != \"o\" && word[0].downcase != \"u\"\n\n latinized = beginning.join + changed_word.join + \"ay\" \n sentence << latinized \n else\n latinized = beginning.join + changed_word.join + \"way\" \n sentence << latinized\n end\n end \n sentence.join(\" \")\n end", "def convert_sentence_to_pig_latin(sentence)\n\tpig_sentence = ''\n\twords = sentence.split(/\\W+/)\n\trubbish = sentence.split(/\\w+/)\n\tfor i in (0..words.length)\n\t\tpig_sentence += rubbish[i].to_s + convert_word_to_pig_latin(words[i]) \n\t\t#put rubbish at first because it has empty string\n\tend\n\treturn pig_sentence\nend", "def pig_latin word\n vowels = %w(a e i o u)\n if vowels.include? word[0]\n word + 'yay'\n else\n vw = nil\n word.chars.each_with_index do |x,xi|\n vw = xi and break if vowels.include? x\n end\n pre = word[0...vw]\n suf = word[vw..-1]\n suf + pre + 'ay'\n end\nend", "def pig_latin(word)\n # Encrypts words into pig latin\n # if/else: catches the \"qu\" phoneme to treat it as a group\n # until: builds the word section to be shifted to the end\n i = 0\n shift = ''\n vowels = ['a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U']\n if word.include?('qu') == true\n until \"u\".include? (word[i]) do\n shift += word[i]\n i += 1\n end\n shift += word[i]\n else \n until vowels.include? (word[i]) do \n shift += word[i]\n i += 1\n end\n end\n word.sub(shift, '') + shift.downcase + 'ay'\nend", "def pig_latin(word)\n\nif word[0..0] =~ /[A-Z]/\n is_cap = true\nelse\n is_cap = false\nend\n\n if word.slice(0) == \"a\" ||\n word.slice(0) == \"e\" ||\n word.slice(0) == \"i\" ||\n word.slice(0) == \"o\" ||\n word.slice(0) == \"u\"\n word += \"way\"\n\n elsif word.slice(0..1) == \"qu\"\n word = word.slice(2..word.length) + word.slice(0..1) + \"ay\"\n\n elsif word.slice(1) == \"a\" ||\n word.slice(1) == \"e\" ||\n word.slice(1) == \"i\" ||\n word.slice(1) == \"o\" ||\n word.slice(1) == \"u\"\n word = word.slice(1..word.length) + word.slice(0) + \"ay\"\n\n elsif word.slice(2) == \"a\" ||\n word.slice(2) == \"e\" ||\n word.slice(2) == \"i\" ||\n word.slice(2) == \"o\" ||\n word.slice(2) == \"u\"\n word = word.slice(2..word.length) + word.slice(0..1) + \"ay\"\n\n elsif word.slice(3) == \"a\" ||\n word.slice(3) == \"e\" ||\n word.slice(3) == \"i\" ||\n word.slice(3) == \"o\" ||\n word.slice(3) == \"u\"\n word = word.slice(3..word.length) + word.slice(0..2) + \"ay\"\n\n end\n if is_cap == true\n return word.capitalize\n else\n return word\n end\nend", "def convert_pig_latin(sentence)\n translated = []\n\n sentence.split(' ').each do |word|\n if word.length > 2\n translated << pig_latin(word)\n else\n translated << word\n end\n end\n translated.join(' ')\nend", "def piglatin(word)\n new_string = \"\"\n vowels = (\"aeiou\")\n word.split(\"\").each_with_index do |letter, index| \n if !vowels.include?(letter.downcase)\n next\n else\n if index == 0\n new_string += word + \"way\"\n return new_string\n else\n up_to_vowel = word.slice(0...index)\n after_vowel = word.slice(index..-1)\n new_string += after_vowel + up_to_vowel + \"ay\"\n return new_string\n end\n end\n end\n end", "def pig_latin_sentence(sentence)\r\n\tnew_sentence = \"\"\r\n\tsentence.split.each do |word|\r\n\t\tif word[0].downcase =~ /[aeiou]/\r\n\t\t\tword << \"way\" \r\n\t\telse\r\n\t\t\tn = /[aeiou]/.match word.downcase\r\n\t\t\tword = n.to_s + n.post_match + n.pre_match + \"ay\"\r\n\t\tend\r\n\t\tnew_sentence << word\r\n\tend\r\n\tnew_sentence\r\nend", "def pigatize\n # Declare the output string\n piglatin = ''\n # Split the input text into words and loop with .each,\n # and 'word' as the iterator variable.\n split(' ').each do |word|\n # Check to see if the first letter is a vowel, else it's a consonant.\n if starts_with_vowel(word[0])\n # Add onto the output string with += and add an extra space.\n piglatin += word + 'way'\n else\n piglatin += word[1..-1] + word[0] + 'ay' + ' '\n end\n end\n # Added a .chomp here to get rid of any trailing space.\n piglatin.chomp\n end", "def pig_latinify(sentence)\n\nend", "def sentence_to_pig_latin(sentence)\n sentence = sentence.split(' ')\n sentence.map! do |word|\n punctuation = get_punctuation(word)\n word = remove_punctuation(word.downcase)\n pig_latin(word) + punctuation\n end\n sentence.join(' ')\nend", "def pig_latinify(sentence)\nend", "def pig_latin(string)\n words_array = string.split(\" \")\n modified_words_array = \"\"\n words_array.map do |word|\n \n if word =~ /\\A[aeiou]/\n word += \"ay\"\n modified_words_array << word + \" \"\n \n # regex to grab three consonants took from http://stackoverflow.com/questions/18406509/using-regexp-to-check-whether-a-string-starts-with-a-consonant\n # word starts with three consonants or \"[const.]qu\" ie. \"square\", \"squat\"\n elsif ( word =~ /\\A(?i:(?![aeiou])[a-z]){3}/ ) || ( word =~ (/\\b[^aeiou]+qu/) ) # word =~ /\\A[^aeiou]+qu{3}/ )\n without_first_three = word[3..-1]\n without_first_three += word[0..2] + \"ay\"\n if word[0] == word[0].upcase\n without_first_three.capitalize!\n end\n modified_words_array << without_first_three + \" \"\n \n # word starts with two consonants or \"qu\" ie. \"quake\", \"quart\" \n elsif ( word =~ /\\A(?i:(?![aeiou])[a-z]){2}/ ) || ( word =~ /\\A[qu]{2}/ )\n without_first_two = word[2..-1]\n without_first_two += word[0..1] + \"ay\"\n if word[0] == word[0].upcase\n without_first_two.capitalize!\n end\n modified_words_array << without_first_two + \" \"\n \n # word starts with consonant \n elsif word =~ /\\A[^aeiou]/\n without_first = word[1..-1]\n without_first += word[0] + \"ay\"\n if word[0] == word[0].upcase\n without_first.capitalize!\n end\n modified_words_array << without_first + \" \"\n end\n \n end\n modified_words_array.chomp(\" \")\nend", "def piglatinizer(str)\n plstr = \"\"\n arr = str.split\n\n arr.each do |pig|\n if (pig.size <= 2) && (pig.slice(0) =~ /[aeiou]/)\n plstr << pig\n plstr << \"ay \"\n else\n l = pig.slice!(0)\n plstr << pig\n plstr << l\n plstr << \"ay \"\n end\n end\n plstr.downcase.capitalize\nend", "def pig_latin(word)\n vowels = [\"a\", \"e\", \"i\", \"o\", \"u\"]\n ind = word.index(/[aeiou]/)\n\n if vowels.include?(word[0])\n word.delete(\" \") << \"ay\"\n else\n if ind == nil\n word << \"ay\"\n else\n final_word = word.chars.drop(ind) << word.chars.slice(0..ind-1) << \"ay\"\n final_word.join\n end\n end\n end", "def pig_latin(word)\n if word.slice(0..1) == \"qu\"\n word = word.slice(1..word.length) + word.slice(0) + \"ay\" \n elsif word.slice(0) == \"a\" ||\n word.slice(0) == \"e\" ||\n word.slice(0) == \"i\" ||\n word.slice(0) == \"o\" ||\n word.slice(0) == \"u\"\n word += \"way\"\n elsif word.slice(1) == \"a\" ||\n word.slice(1) == \"e\" ||\n word.slice(1) == \"i\" ||\n word.slice(1) == \"o\" ||\n word.slice(1) == \"u\"\n word = word.slice(1..word.length) + word.slice(0) + \"ay\"\n elsif word.slice(2) == \"a\" ||\n word.slice(2) == \"e\" ||\n word.slice(2) == \"i\" ||\n word.slice(2) == \"o\" ||\n word.slice(2) == \"u\"\n word = word.slice(2..word.length) + word.slice(0..1) + \"ay\"\n else word.slice(3) == \"a\" ||\n word.slice(3) == \"e\" ||\n word.slice(3) == \"i\" ||\n word.slice(3) == \"o\" ||\n word.slice(3) == \"u\"\n word = word.slice(3..word.length) + word.slice(0..2) + \"ay\"\n end\n return word\nend", "def pig_latin_word(word)\n\tvowels = \"a,e,i,o,u\"\n \tif ( vowels.include?(word[0]) )\n return word + \"yay\"\n end\n \tfor i in (0...word.length)\n if (vowels.include?(word[i]))\n return word[i..-1] + word[0...i] + \"ay\"\n end\n end\nend", "def pig_latin(word)\n check_vowel = %w(a e i o u).include?(word[0])\n if check_vowel == true\n word + 'way'\n else\n word_array = word.chars.to_a\n until word_array[0].to_s == \"a\" || word_array[0].to_s == \"e\" || word_array[0].to_s == \"i\" || word_array[0].to_s == \"o\" || word_array[0].to_s == \"u\"\n word_array << word_array[0]\n word_array.shift\n end\n word_array.join + 'ay'\n end\nend", "def pig_latinify(sentence)\n sentence.split(\" \").map { |word| pig_process(word) }.join(\" \")\nend", "def pig_latin_word(word)\n vowels = \"aeiou\" # vowel string to reference to contain all vowels\n \n # abcdefghijklmnopqrstuvwxyz\n\n # check if the word starts with a vowel, then add yay\n if vowels.include?(word[0]) # word is a string and check if starts with first position if its a vowel - check this character\n return word + \"yay\" # return + add string yay\n end \n\n # iterate through every letter of each word\n word.each_char.with_index do |char, idx| # iterate and grab every character\n if vowels.include?(char) # we know the behavior of each char is to iterate from left to right\n before_vowel = word[0...idx] # up to but not including vowel -- gives you `tr`\n after_vowel = word[idx..-1] # very last position, inclusive -- gives you `ash`\n return after_vowel + before_vowel + \"ay\"\n end\n end\n\nend", "def pig_it text\n\n # split string into array of words\n text_array = text.split(\" \")\n \n #for each word take first character from index [0] and move to last character index [-1] + 'ay', remove first character\n latin_array = text_array.map do |word|\n new_word = word + word[0] + \"ay\" \n new_word[1..-1]\n end\n \n #join together to single string\n latin_string = latin_array.join(\" \")\n \n #delete 'ay' from endings of sentences with punctuation - kind of cheating \n latin_string.sub! '!ay', '!' \n latin_string.sub! '?ay', '?'\n\n latin_string\n\nend", "def pig_latin_word(word)\n vowels = \"aeiou\"\n pigArr = []\n wordArr = word.split(\"\")\n \n if vowels.include?(word[0]) == true\n return word << \"yay\"\n else\n\n word.each_char.with_index do |ele, idx|\n\n if vowels.include?(ele) == true\n wordArr << pigArr\n return wordArr.join(\"\") + \"ay\"\n else\n wordArr[idx] = \"\"\n pigArr << ele\n end\n \n end\n\n end\nend", "def pig_latinify(sentence)\n results = []\n sentence.split(' ').each do |word|\n results << pig_word(word)\n end\n results.join(' ')\nend", "def pig_latin(sentence)\n sentence.split.map { |word| latinify(word) }.join(\" \")\nend", "def pig_latin_word(word)\n vowels = ['a', 'e', 'i', 'o', 'u']\n new_word = \"\"\n if vowels.include?(word[0])\n return word + \"yay\"\n else\n word.each_char.with_index do |ch, i|\n if vowels.include?(ch)\n return word[i..-1] + word[0...i] + \"ay\"\n end\n end\n end\nend", "def pig_latin_word(word)\n pigLatin = \"\"\n str1 = \"\"\n str2 = \"\"\n\n if is_vowel(word[0])\n pigLatin = word + \"yay\"\n return pigLatin\n end\n\n word.each_char.with_index do |char, i|\n if is_vowel(char)\n return word[i..-1] + word[0...i] + \"ay\"\n end\n end\nend", "def piglatinize(string)\n string.split(\" \").each do |word|\n m = word.match(/^[^aeiou]+/i)\n if m\n word.delete_prefix!(m[0])\n word << m[0]\n word << \"ay\"\n else\n word << \"way\"\n end\n end.join(\" \")\n end", "def pig_latin_word(word)\n vowels = \"aeiou\"\n\n if vowels.include?(word[0])\n return word + \"yay\"\n end\n\n word.each_char.with_index do |char, i|\n if vowels.include?(char)\n return word[i..-1] + word[0...i] + \"ay\"\n end\n end\nend", "def pig_latin_word(word)\r\n latin = word\r\n word.each_char.with_index do |char,idx|\r\n if isVowel(char)\r\n if idx == 0\r\n return latin + 'yay'\r\n else\r\n return latin + 'ay'\r\n end\r\n else\r\n letter = latin[0]\r\n latin[0] = \"\"\r\n latin += letter\r\n end\r\n end\r\nend", "def pig_latin(word)\n if word.chr =~ /[aeiou]/\n word + \"way\"\n\n else while word =~ /\\A[^aeiou]/\n word = \"#{word[1..-1]}#{word[0..0]}\"\n if word.chr =~ /[aeiou]/\n end\n end\n word + \"ay\"\nend\nend", "def pig_latin_word(word)\n vowels = 'aeiou'\n\n if vowels.include?(word[0])\n return word + 'yay'\n end\n\n word.each_char.with_index do | char, i |\n if vowels.include?(char)\n return word[i..-1] + word[0...i] + 'ay'\n end\n end\nend", "def pig_latin_word(word)\n word_array = word.split('')\n vowels = 'aeiou'\n if vowels.include?(word_array.first)\n return \"#{word_array.join}yay\"\n end\n\n until vowels.include?(word_array.first)\n char = word_array.shift\n word_array.push(char)\n end\n\n \"#{word_array.join}ay\"\nend", "def piglatinize(phrase)\n return PigLatinizer.translate_text(phrase)\n end", "def pig_latin(sentence)\n \n\nend", "def pig_latin_sentence(sentence)\n words = sentence.split(\" \")\n new_words = []\n words.each do |word|\n new_words << pig_latin(word)\n end\n new_words.join(\" \")\nend", "def pig_latin(sentence)\n\nend", "def pig_latin(word)\n word_array = word.split(\"\")\n if word.start_with?(\"a\",\"e\",\"i\",\"o\",\"u\")\n return \"#{word}way\"\n else\n until word_array[0].start_with?(\"a\",\"e\",\"i\",\"o\",\"u\")\n word_array = word_array.rotate(1)\n end\n return \"#{word_array.join}ay\"\n end\nend", "def to_pig_latin(words)\n words.split(\" \").collect{|word| piglatinize(word)}.join(\" \")\n\nend", "def pig_latinify(wordstring)\n\t\tstr = wordstring.downcase.gsub(/\\s+/, \"\") #gsub.replaces\n\t\tif str.start_with?(\"a\") || str.start_with?(\"e\") || str.start_with?(\"i\") || str.start_with?(\"o\") || str.start_with?(\"u\")\n\t\t\treturn str + \"way\"\n\t\telsif str == \"shit\" || str == \"fuck\" || str == \"arse\" || str == \"munter\" || str == \"cock\" || str == \"pussy\" || str == \"asshole\" || str == \"motherfucker\" |\n\t\t\treturn str.gsub(\"a\", \"*\").gsub(\"e\", \"*\").gsub(\"i\", \"*\").gsub(\"o\", \"*\").gsub(\"u\", \"*\")\n\t\telse\n\t\t\tsuffix = str[0]\n\t\t\tstr[0] = \"\"\n\t\t\treturn str + suffix + \"ay\"\n\t\tend\n\tend", "def pig_latin(sentence)\n \n words = sentence.split\n result = words.map do |word|\n \tlatinize(word)\n end\n result.join(\" \")\nend", "def piglatinize(input)\n\t\t#splits the input to capture multiple words\n\t\tif input.split(\" \").length == 1\n\t\t\tpiglatinize_single_word(input)\n\t\telse piglatinize_sentence(input)\n end\n\tend", "def pig(word, howmany = 0)\r\n chars = word.split(//)\r\n lastletter_index = word.rindex(/\\w/)\r\n puncs = {}\r\n \r\n #grab punctuation, store info in hash\r\n chars.each_index { |x| puncs[x] = chars.at(x) if chars.at(x) =~ /\\W/ }\r\n\r\n #delete punctuation so we only deal with letters, does nothing if no punc \r\n chars.delete_if {|x| puncs.values.include?(x)} \r\n\r\n #not the most elegant for dealing with starts-with-vowel words, but more modular this way\r\n #skip this swapping stuff if it's a vowel for first letter\r\n if(howmany > 0) \r\n first = chars.slice!(0, howmany) #grab the first n chars, delete grabbed\r\n\r\n if(first[0] == first[0].upcase) #word was capitalized, swap order\r\n chars[0].upcase!\r\n first[0].downcase!\r\n end\r\n\r\n chars += first\r\n end\r\n\r\n #add back punctuation if it existed, does nothing if no punc\r\n puncs.keys.each { |key| chars.insert(key, puncs[key]) }\r\n \r\n #length == 1 means we got a single vowel like \"I\"; different rule\r\n chars.length == 1 ? chars << \"way\" : chars.insert(lastletter_index + 1, \"ay\") \r\n return chars.join(\"\")\r\nend", "def pig_latin(sentence)\nend", "def pig_sentence(string)\n pig_latin = \"\"\n string.split().each do |word|\n pig_latin += pig_word(word).downcase + \" \"\n end\n pig_latin.strip!\nend", "def to_pig_latin(phrase)\n\t\tphrase.split.collect{|word| piglatinize(word)}.join(\" \")\n\tend", "def piglatin(data)\n if data\n # + means space\n words = data.split(\"+\")\n piglatin_words = []\n\n words.each do |word|\n # vowel?\n if word[0].match(/[a,e,i,o,u]/)\n word = word + \"way\"\n # 'qu' at front?\n elsif word[0,2] == \"qu\"\n word = word[2..-1] + \"quay\"\n # consonant?\n elsif word[0].match(/[^a,e,i,o,u,0-9]/)\n word = word[1..-1] + word[0] + \"ay\"\n end\n\n piglatin_words.push(word)\n end\n\n piglatin_words.join(\" \")\n else\n \"Error: need input\"\n end\n end", "def pig_latin_sentence(sentence)\n word_array = sentence.split\n\n new_array = word_array.map {|each_word| pig_latin(each_word)}.join(\" \")\nend", "def pig_latin (string)\n if string.chr == \"a\" || string.chr == \"e\" || string.chr == \"i\" || string.chr == \"o\" || string.chr == \"u\" \n string + \"way\"\n else \n arr=[]\n arr = string.split(//) << string.split(//)[0]\n arr.delete_at(0)\n arr.join + 'ay'\n end\nend", "def pig_latin_word(word)\r\n\tif word[0].downcase =~ /[aeiou]/\r\n\t\tword << \"way\" \r\n\telse\r\n\t\tn = /[aeiou]/.match word.downcase\r\n\t\tn.to_s + n.post_match + n.pre_match + \"ay\"\r\n\tend\r\nend", "def pig_latin word\n vowel = word =~ /[aeio]|(?<!q)u/\n word[vowel..-1]+word[0...vowel]+'ay'\nend", "def pig_latin_word(english)\n vowels = [\"a\", \"e\", \"i\", \"o\", \"u\"]\n \n if vowels.include?(english[0].downcase)\n english\n else\n vowel_index = english.index(/[aeiouy]/)\n front_half = english.slice!(vowel_index..-1)\n back_half = english\n punct = front_half.slice!(/\\W$/)\n punct = \"\" if punct == nil\n pig_word = front_half + back_half + \"ay\" + punct\n end\nend", "def translate(sentence)\r\n words = sentence.split(\" \")\r\n words.collect! do |a|\r\n if(a =~ /\\w\\.\\.\\.\\w/) #matching e.g \"yes...no\"\r\n morewords = a.split(\"...\")\r\n ##\r\n #alternative: allows for recursion, but loses accuracy since \"a...b\" becomes \"a ... b\"\r\n #probably some non-messy way to make it work, and be less redundant too\r\n #\r\n #morewords.insert(1, \"...\")\r\n #translate(morewords.join(\" \"))\r\n pig(morewords[0], 1) + \"...\" + pig(morewords[1], 1)\r\n elsif(a =~ /\\w\\W\\w/ and !(a =~ /'/)) #matching e.g. \"steins;gate\", \"ninety-nine\", but not \"it's\"\r\n nonletter = a.scan(/\\W/)[0]\r\n morewords = a.split(/\\W/)\r\n #morewords.insert(1, nonletter)\r\n #translate(morewords.join(\" \"))\r\n pig(morewords[0], 1) + nonletter + pig(morewords[1], 1)\r\n elsif(a[0..1].match(/qu/)) #quiet = ietquay\r\n pig(a, 2)\r\n elsif(a[0..2].match(/sch|.qu/)) #school = oolschay, square = aresquay\r\n pig(a, 3)\r\n else\r\n x = a.index(/[AaEeIiOoUu]/) #starts with other consonant(s) or a vowel; find the first vowel\r\n if(!(x.nil?)) #found at least one vowel\r\n pig(a, x) \r\n else #x is nil, no vowels found\r\n a.index(/[[:alpha:]]/) ? pig(a, 1) : a #if it contains letters, attempt to process; otherwise, do nothing\r\n end\r\n end\r\n end\r\n return words.join(\" \")\r\nend", "def pig_latin_word(str)\n vowels = \"aeiou\"\n\n if vowels.include?(str[0])\n return str + \"yay\"\n else\n str.each_char.with_index do |char, index|\n if vowels.include?(char)\n return str[index..-1] + str[0...index] + \"ay\"\n end\n end\n end\nend", "def pig_latin(str)\n new_str = str.downcase.scan(/\\w+/)\n output = []\n vowels = [\"a\", \"e\", \"i\", \"o\", \"u\"]\n new_str.each do |element|\n first = []\n last = []\n temp = element.split(\"\")\n temp.each_with_index do |letter, index|\n if vowels.include?(letter)\n last = temp[0...index]\n last.push(\"ay\");\n first = temp[index..-1]\n break\n end\n end\n output.push(first.join(\"\").concat(\"-\"+last.join(\"\")))\n end\n output.join(\" \")\nend", "def pig_latin_word(string)\n array_of_char = string.downcase.split(//)\n\n if [\"a\",\"e\",\"i\",\"o\",\"u\",\"y\"].include?(array_of_char[0])\n array_of_char.push(\"ay\")\n elsif !([\"a\",\"e\",\"i\",\"o\",\"u\",\"y\"].include?(array_of_char[0]))\n consonant = array_of_char.delete_at(0)\n array_of_char.push(consonant, \"ay\")\n end\n\n return array_of_char.join\n\nend", "def pig_latin_sentence_reverse(sentence)\n sentence.downcase!\n\n x = sentence.split\n\n t = \"t\"\n h = \"h\"\n q = \"q\"\n u = \"u\"\n\n # this removes the \"ay\"\n x.map do |word|\n word.slice!(\"way\")\n word.slice!(\"ay\")\n end\n\n # this removes the \"th\" and \"qu\" from the end of the words and add it to the front\n x.map do |word|\n last_letter = word[-1]\n if word.include?(t && h)\n word.insert(0, h)\n word.insert(0, t)\n word.chop!\n if last_letter == t || h\n word.chop!\n end\n end\n # else\n if word.include?(u && q)\n word.insert(0, u)\n word.insert(0, q)\n word.chop!\n if last_letter == u || q\n word.chop!\n end\n end\n end\n\n # this changes the selected elements\n [x[2], x[3], x[6], x[7]].map do |word|\n word.insert(0, word[-1])\n if word[0] == word[-1]\n word.chop!\n word == word[0..-2]\n end\n x[0].capitalize!\n end\n\n x.join(\" \")\nend", "def pig_latin(string)\n # Your code goes here\n arr = string.split(\" \")\n\n pig_latin = []\n arr.map do |x|\n if arr.length == 1\n return x[0] + \"ay\"\n else\n \n word = x[1..-1] + x[0] + \"ay\"\n pig_latin.push(word)\n end\n \n end\n return pig_latin.join(\" \")\nend", "def translate(phrase)\n #split phrase into words\n word_array = phrase.split ' '\n #to_pig each word\n answer_array = word_array.map {|word| to_pig(word)}\n #join words back together\n answer = answer_array.join ' '\nend", "def pigLatin(sentence)\n\n #declare var to hold the split string\n splitSentence = sentence.split()\n #empty array to hold split strings\n result = \"\"\n #split the word into letters\n for word in splitSentence\n letters = word.split(//)\n first_letter = letters[0]\n letters.shift()\n letters.push(first_letter)\n letters.push(\"ay \")\n\n result += letters.join()\n\n end\n\n result.capitalize!.chop!()\n return result\nend", "def pig_latin_sentence(string)\n array_of_word = string.split(\" \")\n new_array_of_word = []\n\n array_of_word.each do |word|\n new_array_of_word.push(pig_latin_word(word))\n end\n\n return new_array_of_word.join(\" \")\n\nend", "def pig(word)\n letters = word.split(\"\")\n letters.keep_if {|letter| letter != \".\"}\n if letters.size == 1 || vowel?(letters[0])\n letters << \"way\"\n elsif letters.size > 1\n until vowel?(letters[0])\n letters << letters.shift\n end\n letters << \"ay\"\n end\n letters.join\n end", "def pigatize(text)\n if starts_with_vowel?(text)\n text + \"way\"\n else\n text.chars.rotate.join + \"ay\"\n end\nend", "def pig_latinize_string(text)\n a = text.split(' ')\n b= a.map {|word| pig_latinize_word(word)}\n b.join(' ')\n end", "def pig_it(sentence)\n sentence.split.map do |word|\n if ('a'..'z').cover?(word.downcase)\n word[1..-1] + word[0] + 'ay'\n else\n word\n end\n end.join(' ')\nend", "def to_pig_latin(text)\n\t\ttext.split(' ').map do |w|\n\t\t\tpiglatinize(w)\n\t\tend.join(' ')\n\tend", "def convert (str)\r\n# REFERENCE : Using logic from this source https://stackoverflow.com/questions/13498688/pig-latin-method-translation\r\n alpha = ('a'..'z').to_a\r\n vowels = %w[a e i o u]\r\n consonants = alpha - vowels\r\n lstr = str.downcase\r\n if vowels.include?(lstr[0])\r\n str + 'way'\r\n elsif consonants.include?(lstr[0]) && consonants.include?(lstr[1]) && consonants.include?(lstr[2])\r\n str[3..-1] + str[0..2] + 'ay'\r\n elsif consonants.include?(lstr[0]) && consonants.include?(lstr[1])\r\n str[2..-1] + str[0..1] + 'ay'\r\n elsif consonants.include?(lstr[0])\r\n str[1..-1] + str[0] + 'ay'\r\n else\r\n str # return unchanged\r\n end\r\nend", "def pig_it(string)\n words = string.split\n\n words.map do |word|\n if word.match(/[a-z]/i)\n word[1..word.size] << word[0] << 'ay'\n else\n word\n end\n end.join(' ')\nend", "def translate(str)\n words = str.split\n pig_words = []\n words.each do |word|\n pig_words << latinize(word)\n end\n\n pig_words.join(\" \")\nend", "def pig_it(str)\n \twords_from_sentence = str.split\n \twords_from_sentence.map! do |word|\n \t\tif word.length == 1\n \t\t\tif word.match? (/[^\\w]/)\n \t\t\t\tword\n \t\t\telse\n \t\t\t\tword << 'ay'\n \t\t\tend\n \t\telsif word[-1].match? (/[^\\w]/)\n \t\t\tlast_letter = word.slice!(-1)\n \t\t\tword << word.slice!(0) << 'ay' << last_letter\n \t\telse\n \t\t\tword << word.slice!(0) << 'ay'\n \t\tend\n \tend\n \twords_from_sentence.join(' ')\nend", "def pig_it(str)\n words = str.split\n pigified = []\n words.each do |word|\n if word =~ /\\w/\n word += \"#{word.chr}ay\"\n word[0] = ''\n pigified << word\n else pigified << word\n end\n end\n pigified.join(' ')\nend", "def pig_latin_chop(word)\n\t#split single word into characters\n\n\twordArray = word.split(\"\") \n\tvowels = ['a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U']\n\tuntil vowels.include?(wordArray[0])==true\n\t\tconsonant = wordArray.shift().downcase\n\t\twordArray = wordArray.push(consonant)\n\tend\n\tnewWord = wordArray.join()+ \"ay\"\nend", "def pig_it text\n text.split(' ').map do |word|\n if word == \"?\" || word == \"!\" || word == \".\" || word == \",\"\n word\n else\n (word[1..(word.length-1)] + word[0] + \"ay\")\n end\n end.join(' ')\nend", "def pig_it text\n answer = text.split(' ')\n answer.each_with_index do |str, index|\n if (!str.match(/[-!$%^&*()_+|~=`{}\\[\\]:\";'<>?,.\\/]/))\n firstLetter = str[0]\n str[0] = str[0].delete(str[0])\n answer[index] = str.concat(firstLetter) + \"ay\"\n end\n end \n answer.join(' ')\nend", "def pig_it(string)\n arr = string.split(\" \")\n result = \"\"\n arr.each do |word|\n # Check if word is containing only letters and not special characters\n if word.match? /\\A[a-zA-Z']*\\z/\n result += (word[1..-1] + word[0] + \"ay \")\n else\n result += (word + \" \")\n end\n end\n result[0...-1]\nend", "def pig_latin_txt(string)\n arr=[]\n arr = string.split.map!{|x| pig_latin(x)}\n arr.join(' ')\nend", "def pig_it(str)\r\n str.split.map { |w| w =~ /[a-z]/i ? w[1..-1] + w[0] + 'ay' : w }.join(' ')\r\nend", "def pig_latin_translate\n english_word_arr = []\n vowel_array = %w(a e i o u)\n \n print \"What word would you like to translate? \"\n input = gets.chomp!.downcase\n \n english_word_to_translate = input.split(/ /)\n \n english_word_to_translate.each do |word|\n english_word_arr = word.split(//)\n\n\n\n #split by words\n #split by character\n #Take first letter move to end\n #add 'Ay'\n #join and return word\n end\nend", "def pig_it(string)\n string2 = string.split.map{|e|e == '!' || e == '?' ? e : e.to_s << (e[0]) }.join(' ')\n\n string3 = string2.split.map{|e|e == '!' || e == '?' ? e : e.to_s << 'ay'}.join(' ')\n\n string3.split.map{|e| e == '!' || e == '?' ? e : e = e[1..-1]}.join(' ')\nend", "def pig_latin_name(word)\n \n letters = word.split(\"\")\n \n final_array = letters.clone\n letters.each do |letter| #[p, l, u, m]\n \n \n if is_consonants?(letter)\n final_array.rotate! \n # #puts \".........#{removed_consonant}\"\n # #letters.push(removed_consonant)\n # puts \".........#{final_array}..#{letters}\"\n else \n # puts \"*****#{final_array}.... #{letters}\"\n final_array.push(\"ay\")\n return final_array.join\n end\n end\nend", "def translate\n words\n words_array = []\n pig_latin_words_array = []\n @words_array.each do |word|\n if starts_with_vowel?(word)\n word += 'way'\n elsif !starts_with_vowel?(word[1..-1])\n word = word[2..-1] + word[0] + word[1] + 'ay'\n else\n word = word[1..-1] + word[0] + 'ay'\n end\n pig_latin_words_array << word\n end\n return pig_latin_words_array\n end", "def pig_it text\n arr = []\n text.split.map do |x|\n split_word = x.split('')\n unless /[[:punct:]]/.match(x)\n first_letter = split_word.first\n split_word.shift\n split_word << \"#{first_letter + 'ay'}\"\n end\n arr << split_word.join\n end\n arr.join(' ')\nend", "def translate(string)\n newArr = []\n vowels = [\"a\", \"e\", \"i\", \"o\", \"u\"]\n \n # * Split it into words\n words = string.split()\n\n # * For every word in the sentence...\n words.each do |word|\n # * If the word has 'qu'\n if word[1..2].downcase == \"qu\"\n newArr << word[3..-1] + word[0..2] + \"ay\"\n\n elsif word[0..1].downcase == \"qu\"\n newArr << word[2..-1] + word[0..1] + \"ay\"\n\n # * If it starts with a vowel\n elsif vowels.include?(word[0].downcase)\n newArr << word + \"ay\"\n\n # * If the first three consonants aren't vowels\n elsif not vowels.include?(word[0].downcase) and not vowels.include?(word[1]) and not vowels.include?(word[2])\n newArr << word[3..-1] + word[0..2] + \"ay\" \n # * ...or if the first two consonants aren't vowels\n elsif not vowels.include?(word[0].downcase) and not vowels.include?(word[1])\n newArr << word[2..-1] + word[0..1] + \"ay\" \n \n # * After all that, if it starts with one consonant\n else\n newArr << word[1..-1] + word[0] + \"ay\"\n end\n end\n\n newArr.join(\" \")\nend", "def translate word\n\n\tsplit = word.split(\" \")\n\tlatin = \"\"\n\tvowels = [\"a\", \"e\", \"i\", \"o\", \"u\"]\n\t\n\n\n\tsplit.each do |string|\n\n\t\ta = 0\n\t\tconsts = 0\n\n\t\twhile vowels.include?(string[a]) === false\n\t\t\tconsts = consts + 1\n\t\t\ta = a + 1\n\t\tend\n\n\t\tif string[consts -1] === \"q\"\n\t\t\tif string[consts] === \"u\"\n\t\t\t\tconsts = consts + 1\n\t\t\tend\n\t\tend\n\n\t\tb = string[0, consts]\n\n\t\t\n\t\tif consts === 1\n\t\t\tlatin = latin + string[consts, string.length-1] + string[0] + \"ay\"\n\t\telsif\tconsts > 1\n\t\t\tlatin = latin + string[consts, string.length-1] + b + \"ay\"\n\t\telse\n\t\t\tlatin = latin + string + \"ay\"\n\t\tend\n\n\tlatin = latin + \" \"\n\n\tend\n\n\tlatin.strip\n\t\nend", "def translate string\n\n\t#This splits the string into an array of words\n\twords = string.split(\" \")\n\t\n\t#Goes through each word in array words\n\tfor i in 0...words.length\n\n\t\t#This splits each word into an array of characters\n\t\tcharacters = words[i].chars\n\n\t\t#If a word begins with a vowel, add \"ay\" to the end of the word\n\t\tif isVowel characters[0]\n\n\t\t\tcharacters.push(\"a\", \"y\")\n\t\t\twords[i] = characters.join(\"\")\n\n\t\t#If a word does not begin with a vowel...\n\t\telse\n\n\t\t\t#While the first character is not a vowel, move it to the back of the word\n\t\t\twhile !(isVowel characters[0])\n\n\t\t\t\t#If the first character is a \"q,\"\n\t\t\t\tif characters[0] == \"q\"\n\n\t\t\t\t\t#and the next character is a \"u,\" push both the \"qu\" to the end\n\t\t\t\t\tif characters[1] == \"u\"\n\n\t\t\t\t\t\tconsonant = characters.shift\n\t\t\t\t\t\tcharacters.push(consonant)\n\t\t\t\t\t\tu = characters.shift\n\t\t\t\t\t\tcharacters.push(u)\n\n\t\t\t\t\tend\n\n\t\t\t\t#Otherwise, just push the first letter to the end\n\t\t\t\telse\n\n\t\t\t\t\tconsonant = characters.shift\n\t\t\t\t\tcharacters.push(consonant)\n\n\t\t\t\tend\n\n\t\t\tend\n\n\t\t\t#Then add \"ay\" to the end of the word\n\t\t\tcharacters.push(\"a\", \"y\")\n\t\t\twords[i] = characters.join(\"\")\n\n\t\tend\n\t\t\n\tend\n\n\t#Joins together all the words with a space in between them and returns the modified string as an answer\n\tanswer = words.join(\" \")\n\treturn answer\n\nend", "def translate(str)\n\tvowel=%w[a e i o u]\n\tcons=[*'a'..'z']-vowel\n\n\ta_str=str.split(\" \")\n\n\tfor i in 0..a_str.length-1\n\t\tif vowel.include?a_str[i][0]\n\t\t\tpig_l = a_str[i] + \"ay\"\n\t\t\treturn pig_l.split(\",\").join(\"\")\n\t\telsif cons.include?a_str[i][0]\n\t\t\tif cons.include?a_str[i][1]\n\t\t\t\tz=a_str[i].slice!(0..1)\n\t\t\telse\n\t\t\t\tz=a_str[i].slice!(0)\n\t\t\tend\n\t\t\tpig_l=a_str[i] + z+ \"ay\"\n\t\t\treturn pig_l.split(\",\").join(\"\")\n\t\tend\n\tend\nend", "def english_translate\n pig_latin_arr = []\n pig_latin = []\n print \"What word would you like to translate? \"\n input = gets.chomp!.downcase\n \n pig_latin_word_to_translate = input.split(/ /)\n\n pig_latin_word_to_translate.each do |word|\n pig_latin_arr = word.split(//)\n\n first_letter = pig_latin_word_to_translate.delete_at(0)\n new_letters = english_word_to_translate.join\n\n word = new_letters + first_letter + \"ay\"\n\n pig_latin << word\n end\n \n puts pig_latin.join(' ').capitalize\nend", "def translate( word )\n #Practicing regular expressions. Main idea: If I can find the first vowel then take the index\n #where that vowel is and split the word. If word has no vowels or first letter is a vowel,\n #just put word in new_word variable.\n\n phrase = \"\"\n\n word.split.each do | word |\n\n #If first letter is a vowel or no vowels in the word, just give the word\n if ( /[aeiou]/ =~ word ) == 0 || ( /[aeiou]/ =~ word ) == nil\n new_word = word\n\n #If my word starts with a qu then we'll split the word with the qu together\n elsif word[ 0..1 ] == \"qu\"\n new_word = word[ 2..word.length ] + word[ 0..1 ]\n\n #Keeping below if I wanna find a word that has a vowel \n #if word.split.any? { |letter| /[aeiou]/ =~ letter }\n\n #If my word starts with an squ then we'll split this word with the squ together\n elsif word[ 0..2 ] == \"squ\"\n new_word = word[ 3..word.length ] + word[ 0..2 ]\n\n else\n new_word = word[ ( /[aeiou]/ =~ word )..word.length ] + word[ 0..( ( /[aeiou]/ =~ word ) - 1 ) ]\n end\n\n #Add ay if vowel is at the front of the new word\n new_word += \"ay\" if new_word.split.any? { | letter | /[aeiou]/ =~ letter }\n\n #Adding the words together to form the output with space\n phrase += \"#{ new_word } \"\n\n end\n\n puts phrase\n phrase.strip\n\nend", "def pig_latin_str=(str)\r\n @pig_latin_str = str.split.map(&:to_s) # split the input to words arrays\r\n end", "def pig_consonant\n pig_latin = @word\n\nend", "def translate(word)\n split_words = word.split(' ')\n words = []\n vowels = %w[a e i o u]\n split_words.each do |word|\n word = qu_in_word(word)\n if vowels.include?(word[0])\n words.push(word + 'ay')\n else\n count = 0\n word.length.times do |number|\n vowels.include?(word[number]) ? break : count += 1\n end\n words.push(word[count..-1] + word[0..(count - 1)] + 'ay')\n end\n end\n words.join(' ')\nend", "def translate(sentence)\n #we .split that sentence. Because we do not give a limit, the sentence is automaticly split along the spaces.\n #we .map the result of the .split to make every word in the array a variable= word.\n sentence.split.map do |word|\n #We define what the first vowel of the word is by a different method (first_vowel) and assign it as variable v\n v = first_vowel(word)\n # we slice of the first vowel and the letter preceding that. then we add the first letter of the word at the end, and add +ay\n word.slice(v..-1) + word[0,v] + \"ay\"\n #We end the function and join the retunring array with spaces in between.\n end.join(\" \")\n end", "def translate(str)\n\n\n\n # Vowels to consider\n vowels = [\"a\", \"e\", \"i\", \"o\", \"u\"]\n \n # Special cases to consider\n two_letter_consonants = [\"ch\", \"sh\", \"qu\", \"th\", \"br\"]\n three_letter_consonants = [\"thr\", \"sch\", \"squ\"]\n\n words = str.split(\" \")\n result = []\n\n words.each do |word|\n if vowels.include?(word[0])\n result.push word << \"ay\"\n else \n if three_letter_consonants.include? (word[0] + word[1] + word[2])\n first_three_letters = word.slice!(0,3)\n \n # Add letters to end of word with 'ay'\n result.push word << first_three_letters << 'ay'\n elsif two_letter_consonants.include?(word[0] + word[1])\n first_two_letters = word.slice!(0,2)\n result.push word << first_two_letters << \"ay\"\n else \n first_letter = word.slice!(0)\n \n # Add first letter to end of word with 'ay'\n result.push word << first_letter << 'ay'\n end #End of special consonant check\n end \n end \n return result.join(\" \")\nend", "def pig_it_ms_two(str)\n pig = []\n str.split.each do |w|\n pig << w.chars.rotate.join + \"ay\" if w =~ /\\w/\n pig << w if w =~ /\\W/\n end\n pig.join(\" \")\nend", "def translate (sentence)\n\ttranslated = ''\n\twords = sentence.split(' ')\n\twords.each { |word|\n\t\tfound_vowels = word.scan(/^[aeiou]*/)\n\t\tfound_consonants = word.scan(/^[bcdfghjklmnpqrstvxzwy]*/)\n\t\tif !found_vowels[0].empty?\n\t\t\ttranslated << word << 'ay'\n\t\telsif !found_consonants[0].empty?\n\t\t\tword = word.tr(found_consonants[0], '')\n\t\t\ttranslated << word << found_consonants[0] << 'ay'\n\t\tend\n\t\tif words.length > 1\n\t\t\ttranslated << ' '\n\t\tend\n\t}\n\treturn translated.rstrip\nend" ]
[ "0.8841267", "0.87730575", "0.867668", "0.8656043", "0.8618591", "0.8613246", "0.8606145", "0.85803676", "0.85799867", "0.8579038", "0.85786974", "0.856355", "0.8539216", "0.8521281", "0.84993243", "0.84793234", "0.84407496", "0.8440136", "0.8426666", "0.8412286", "0.8398716", "0.8386795", "0.8380882", "0.83708334", "0.83652127", "0.8356386", "0.83492297", "0.8329493", "0.8304657", "0.82919663", "0.82751846", "0.8266383", "0.82604384", "0.8241824", "0.82396394", "0.8238167", "0.823328", "0.8229906", "0.82288677", "0.822492", "0.82245064", "0.82004863", "0.8200009", "0.81831485", "0.81734866", "0.8165184", "0.8152321", "0.8149299", "0.8136318", "0.81210846", "0.81188315", "0.8112504", "0.8100839", "0.80997944", "0.80657524", "0.8044816", "0.80426574", "0.8022503", "0.8015499", "0.7996872", "0.79813856", "0.796762", "0.7942388", "0.78854156", "0.7877452", "0.7828266", "0.7768346", "0.77451324", "0.76969224", "0.7694942", "0.76067644", "0.7597386", "0.75914246", "0.75887483", "0.75573325", "0.7544719", "0.74955475", "0.74196357", "0.7417285", "0.735384", "0.73274577", "0.7281285", "0.7277977", "0.72314245", "0.7220537", "0.72150946", "0.71651673", "0.71155614", "0.7112818", "0.71071124", "0.70757496", "0.7055341", "0.70203334", "0.7018367", "0.69040906", "0.6823686", "0.6788778", "0.67771304", "0.67473096", "0.67072666" ]
0.8566909
11
It is sometimes necessary to be able to break down a number into its prime factors. The process is called prime factorization. We can use a factor tree to determine the prime factorization of a number: 12 / \ / \ 4 3 / \ 2 2 Define a method `prime_factorization(n)` that breaks a number down into it's prime factors. example: prime_factorization(12) => [2,2,3]
def prime_factorization(num) # Base case - 1 is not a prime so we return an empty array here return [] if num == 1 # initialize i to 2, since it is the first prime # i = 2 # increment i until we find a prime factor i += 1 until is_prime?(i) && num % i == 0 # Add i to prime factors and make recursive call to find rest [i] + prime_factorization(num / i) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def prime_factorization(num)\n if is_prime?(num)\n return [num]\n end\n factors = []\n (2..num).each do |factor|\n if num % factor == 0\n factors << factor\n factors << prime_factorization(num/factor)\n \n break\n end\n end\n factors.flatten\n\nend", "def prime_factorization(num)\n return [] if num < 2\n\n # get all primes up to num recursively\n primes_factors = prime_factorization(num - 1)\n if prime?(num)\n primes_factors << num\n end\n\n primes_factors\nend", "def prime_factorization(num)\n return [num] if is_prime?(num)\n\n prime_factors = []\n prime_factors << first_factor(num)\n next_num = num / first_factor(num)\n prime_factors << prime_factorization(next_num)\n prime_factors.flatten\nend", "def prime_factorization(num)\n return [num] if is_prime?(num)\n prime_fact = []\n (2..num).each do |n|\n return [n] + prime_factorization(num / n) if num % n == 0\n end\n prime_fact\n end", "def prime_factors(number)\n return [] if number < 2\n return [number] if number < 4\n factors = []\n\n factor = 2\n while factor < number\n break if number % factor == 0\n factor += 1\n end\n factors << factor\n factors.concat(prime_factors(number / factor))\n factors.sort\nend", "def prime_factors(number)\n return [] if number < 2\n return [number] if number < 4\n factors = []\n\n factor = 2\n while factor < number\n break if number % factor == 0\n factor += 1\n end\n factors << factor\n factors.concat(prime_factors(number / factor))\n factors.sort\nend", "def prime_factorization(num)\n if is_prime(num)\n return [num]\n else\n n = 2\n while (num % n) != 0\n n += 1\n end\n return [n] + prime_factorization(num / n)\n end\nend", "def prime_factorization(num)\n return [num] if prime?(num)\n\n #otherwise break up into two factors, \n #and call prime_factorization on them both\n (2..num/2).each do |n| \n if num % n == 0\n return prime_factorization(n) + prime_factorization(num/n) \n end\n end\nend", "def prime_factorization(n)\n return [n] if is_prime?(n)\n\n # factors(n).each do |factor|\n # return [prime_factorization(factor), prime_factorization(n/factor)].flatten\n # end\n factor = factors(n)[0]\n prime_factorization(factor) + prime_factorization(n/factor)\n \n \nend", "def prime_factors(number)\n factors = []\n i = 0\n if prime?(number)\n return [number]\n else\n new_prime = @primes[-1] + 2\n while @primes[-1] * 2 <= number\n if prime?(new_prime)\n @primes << new_prime\n end\n new_prime += 2\n end\n while @primes[i] <= Math.sqrt(number)\n if number % @primes[i] == 0\n factors << @primes[i]\n number /= @primes[i]\n i = 0\n else\n i += 1\n end\n end\n factors << number\n end\n return factors\nend", "def prime_factors(n)\n return [] if n == 1\n factor = (2..n).find {|x| n % x == 0}\n [factor] + prime_factors(n / factor)\nend", "def prime_factorization(num)\n return [num] if prime?(num)\n [2,3,5].each do |factor|\n if num % factor == 0\n return [factor] + prime_factorization(num / factor)\n end\n end\nend", "def prime_factors(number)\n primes = []\n return primes unless number >= 1\n return primes << number if is_prime?(number)\n # until is_prime?(number) do\n (2..(number / 2)).to_a.each do |num|\n if number % num == 0 # Divisor\n if is_prime?(num)\n primes << num\n number /= num\n return (primes << prime_factors(number)).flatten\n # break\n end\n end\n end\n # end\n # primes << number\nend", "def factorize(test_number)\n return [] if test_number == 1\n prime_factor = (2..test_number).find {|divisor| test_number % divisor == 0}\n [prime_factor] + factorize(test_number / prime_factor)\nend", "def prime_factorization(num)\n # return [num] if prime?(num)\n # first_prime = find_prime_factor(num)\n # return [first_prime] + prime_factorization(num/first_prime)\n (2...(num/2)).each do |n|\n if num % n == 0\n multiplier = num / n\n return prime_factorization(n) + prime_factorization(multiplier)\n end\n end\n [num]\nend", "def prime_factors(number)\n fs = []\n f1 = factor(number)\n return [number] if f1 == 1\n f2 = number/f1\n fs.concat(prime_factors(f1))\n fs.concat(prime_factors(f2))\n return fs\n end", "def prime_factors(num)\n factors = factors(num)\n result = []\n factors.each do |fac|\n if prime?(fac)\n result << fac\n end\n end\n result\nend", "def prime_factors\n n = self\n factors = Hash.new(0)\n\n # Pull out twos manually\n while n % 2 == 0 do\n factors[2] += 1\n n /= 2\n end\n\n # Then use Fermat's method\n a = Math.sqrt(n).ceil\n b2 = a**2 - n\n until (b2**0.5).round**2 == b2 do\n a += 1\n b2 = a**2 - n\n end\n\n candidates = [(a - Math.sqrt(b2)).round, (a + Math.sqrt(b2)).round]\n candidates.each do |candidate|\n next if candidate == 1\n if candidate == n\n factors[n] += 1\n else\n candidate_factors = candidate.prime_factors\n if candidate_factors.length == 1\n factors[candidate_factors.first] += 1\n else\n candidates.concat candidate_factors\n end\n end\n end\n \n expanded = []\n factors.each do |prime, count|\n count.times { expanded << prime }\n end\n expanded.sort\n end", "def factors(num)\n factors = Prime.prime_division(num)\n result = []\n factors.each { |factor, power| result += [factor] * power }\n result\nend", "def prime_factorization(num)\n return [num] if is_prime?(num)\n\n (2..num).each do |fact|\n if num % fact == 0\n prime_factorization(fact)\n other_fact = num / fact\n prime_factorization(other_fact)\n end\n end\n\nend", "def prime_factorization(num)\n (2...num).each do |fact|\n if (num % fact == 0)\n otherFact = num / fact\n return [ *prime_factorization(fact), *prime_factorization(otherFact) ]\n end\n end\n\n [num]\nend", "def prime_factors(num)\n facs = factors(num)\n p_facs = []\n facs.each{|n| p_facs.push(n) if prime?(n)}\n p_facs\nend", "def prime_factorization(num)\n\n return [num] if prime?(num)\n\n (2...num).each do |divisor|\n if num % divisor == 0\n next_factor = num / divisor\n return [divisor, *prime_factorization(next_factor)]\n end\n end\n\nend", "def prime_factorization(num)\n\n (2...num).each do |factor|\n if num % factor == 0\n divisor = num / factor\n return prime_factorization(factor) + prime_factorization(divisor)\n end\n end\n [num]\nend", "def prime_factors( n )\nend", "def prime_factorization(num)\n return [num] if prime?(num)\n (2...num).each do |i|\n if prime?(i) && num % i == 0\n return [i].concat(prime_factorization(num / i))\n end\n end\nend", "def prime_factorization(num)\n (2...num).each do |fact|\n if num % fact == 0\n other_fact = num / fact\n return [ *prime_factorization(fact), *prime_factorization(other_fact) ]\n end\n end\n [ num ]\nend", "def prime_factors(num)\n\n if prime?(num)\n return [num]\n end\n\n primes = (2...num).to_a.select { |factor| prime?(factor) }\n\n \n \n factors = []\n\n while num > 1\n candidate = primes.shift\n\n if num % candidate == 0\n factors << candidate\n while num % candidate == 0\n num /= candidate\n end\n end\n end\n\n return factors\n \nend", "def prime_factorization(num)\n (2...num).each do |fact|\n if num % fact == 0\n other_fact = num / fact\n return [*prime_factorization(fact), *prime_factorization(other_fact)]\n end\n end\n [num]\nend", "def prime_factor(num)\n i = 2\n factors = []\n while i <= num\n if num % i == 0\n factors << i\n num = num / i\n else\n i += 1\n end\n end\n factors\nend", "def prime_factorisation(n)\n Prime.prime_division(n).flat_map { |factor, power| [factor] * power }\n end", "def factors(num)\n pn = num.prime_division\n ans = []\n pn.each_index do |i|\n ans << pn[i][0]\n end\n return ans\nend", "def prime_factorization(num)\n (2...num).each do |fact|\n if num % fact == 0 \n fact_2 = num / fact\n return [ *prime_factorization(fact), *prime_factorization(fact_2) ]\n end\n end\n\n [ num ]\nend", "def prime_factorization(num)\n (2...num).each do |factor|\n if num % factor == 0\n other = num / factor\n return prime_factorization(factor).concat(prime_factorization(other))\n end\n end\n\n [num]\nend", "def all_factorizations(num)\n Prime.prime_division(num)\nend", "def factor(n)\n return [] if n.zero?\n Prime.prime_division n\n end", "def findPrimeFactorsofaNumber(number)\n listofprimefactors = []\n possiblePrime = 2\n while number > 1 \n if number % possiblePrime == 0\n number /= possiblePrime\n listofprimefactors.push possiblePrime\n elsif possiblePrime < 3\n possiblePrime += 1\n else\n possiblePrime += 2\n end\n end\n return listofprimefactors\n end", "def prime_factorization(num)\n primes = [] \n i = 2 \n while num != 1\n while num % i == 0\n if is_prime?(i) \n num = num / i \n primes << i \n else\n i += 1 \n end \n end\n i += 1 \n end\n primes\nend", "def prime_factorization(num)\nend", "def prime_factors_helper(f, n)\n if f > n\n []\n elsif is_prime(f) && n % f == 0\n [f] + prime_factors_helper(f, n / f)\n else\n prime_factors_helper(f == 2 ? f + 1 : f + 2, n)\n end\nend", "def prime_factors(num)\n arr = factors(num)\n new_arr = []\n arr.each do |n|\n new_arr << n if prime?(n)\n end\n new_arr\nend", "def factors(num)\n factors = Prime.prime_division(num)\n result = []\n factors.each { |factor, power| result += [factor] * power }\n result\n end", "def prime_factors(n)\n factors = []\n d = 2\n while n > 1\n while n % d == 0\n factors << d\n n /= d\n end\n d = d + 1\n if d*d > n\n if n > 1\n factors << n\n break\n end\n end\n end\n return factors\nend", "def prime_factorization(n)\n (2...n).each do |num|\n if n % num == 0\n othernum = n / num\n return [*prime_factorization(num),*prime_factorization(othernum)]\n end\n end\n [n]\nend", "def prime_factors num\n\tfactors = []\n\ttest_value = 2\n\twhile num > 1 do\n\t\twhile num % test_value == 0 do\n\t\t\tfactors.push num\n\t\t\tnum = num / test_value\n\t\tend\n\t\ttest_value += 1\n\tend\n\treturn factors\nend", "def prime_factorization(num)\n (2...num).each do |fact|\n if num % fact == 0\n other_fact = num/fact\n return [*prime_factorization(fact),*prime_factorization(other_fact)]\n end\n end\n\n return [num]\nend", "def prime_factorization(num)\n\n (2...num).each do |i|\n if num % i == 0\n i2 = num / i\n return [*prime_factorization(i), *prime_factorization(i2)]\n end \n end\n [num]\nend", "def factors(number)\n divisors = []\n # 1 is always a divisor\n divisors << 1\n if number > 1\n # target number is also always a divisor\n divisors << number\n # start looking for other divisors from 2 on up.\n i = 2\n while (i <= Math.sqrt(number).to_i)\n # if number is evenly divisible by i, then retain i, and possibly also\n # the division of number/i.\n if (number % i == 0)\n divisors << i\n divisors << number/i if (i != number/i)\n end\n i += 1\n end\n divisors.sort!\n end\n divisors\nend", "def prime_factorization(num)\n \nend", "def prime_factorization(num)\n \nend", "def prime_factorization(num)\n \nend", "def prime_factors(num)\n require \"prime\"\n primes = []\n Prime.each{|prime| primes << prime if num % prime ==0 ; break if prime > num }\n primes\nend", "def prime_factors(num)\n factors(num).select {|n| prime?(n)}\nend", "def factors(number)\r\n divisor = number\r\n factors = []\r\n while divisor > 0 do \r\n factors << number / divisor if number % divisor == 0\r\n divisor -= 1\r\n end \r\n factors\r\nend", "def prime_factors(number, array=[])\n 2.upto(number) do |factor|\n if number % factor == 0\n array << factor\n number /= factor\n prime_factors(number, array)\n break\n end\n end\n array\nend", "def find_factors(number)\n\t# start with lowest prime number\n\tinteger = 2\n\n\t# make sure integer doesn't exceed the actual number\n\twhile integer <= number do\n\t\t# integer will be returned when if it is a factor of number\n\t\treturn integer if number % integer == 0\n\n\t\t# if integer is not a factor move to next integer\n\t\tinteger += 1\n\tend\nend", "def prime_factors(num)\n factors(num).select { |factor| prime?(factor) }\nend", "def prime_factors(number, array = [])\n return if number == 1\n 2.upto(number).each do |num|\n if number % num == 0\n number /= num\n array << num\n else\n end\n end\n prime_factors(number, array)\nend", "def prime_factors(n)\n factors = []\n old_n = n\n @primes.each { |prime|\n if @factors_hash[n]\n factors += @factors_hash[n]\n factors.uniq!\n break\n end\n if n % prime == 0\n factors.push(prime)\n n /= prime\n end\n break if prime >= n\n # If the remainder is a prime, add and break\n if @prime_hash[n]\n factors.push(n)\n break\n end\n }\n @factors_hash[old_n] = factors\n return factors\nend", "def factors(number)\n divisor = number\n factors = []\n #begin\n\twhile divisor > 0\n factors << number / divisor if number % divisor == 0\n divisor -= 1\n #end until divisor == 1\n\tend\n factors\nend", "def prime_factors(num)\r\n # your code goes here\r\n prime_factors = []\r\n for i in 1 .. num\r\n if num % i == 0 && prime?(i)\r\n prime_factors << i\r\n end\r\n end\r\n prime_factors\r\nend", "def prime_factors(n)\n\tfps = []\n\t# check for even\n\tif n % 2 == 0\n\t\tfps.push(2)\n\t\tn = div_factor(n, 2)\n\tend\n\t# check odd factors\n\tfact = 3\n\tmaxFact = Math.sqrt(n)\n\twhile n > 1 && fact < maxFact\n\t\tif n % fact == 0\n\t\t\tfps.push(fact)\n\t\t\tn = div_factor(n, fact)\n\t\t\tmaxFact = Math.sqrt(n)\n\t\tend\n\t\tfact = fact + 2\n\tend\n\tif n > fps.last\n\t\tfps.push(n)\n\tend\n\tfps.sort!\nend", "def prime_factors(num)\n\tfactors = []\n\tfactor = 2\n\tremainder = num\n\n\twhile (remainder > 1) && (factor <= num)\n\t\twhile (remainder % factor == 0)\n\t\t\tfactors << factor\n\t\t\tremainder /= factor\n\t\tend\n\n\t\tfactor += 1\n\tend\n\tfactors\nend", "def factors(number)\n divisor = number\n factors = []\n while divisor > 0 do\n factors << number / divisor if number % divisor == 0\n divisor -= 1\n end\n factors\nend", "def factors(number)\n divisor = number\n factors = []\n while divisor > 0 do\n factors << number / divisor if number % divisor == 0\n divisor -= 1\n end\n factors\nend", "def factors(number)\n divisor = number\n factors = []\n while divisor > 0 do\n factors << number / divisor if number % divisor == 0\n divisor -= 1\n end\n factors\nend", "def factors(number)\n divisor = number\n factors = []\n while divisor > 0 do\n factors << number / divisor if number % divisor == 0\n divisor -= 1\n end\n factors\nend", "def factors(number)\n divisor = number\n factors = []\n while divisor > 0 do\n factors << number / divisor if number % divisor == 0\n divisor -= 1\n end\n factors\nend", "def factors(number)\n divisor = number\n factors = []\n while divisor > 0 do\n factors << number / divisor if number % divisor == 0\n divisor -= 1\n end\n factors\nend", "def prime_factors(number)\n divisors = []\n divisor = 2\n\n while number > 1\n if number % divisor == 0\n number /= divisor\n divisors << divisor\n else\n divisor += 1\n end\n end\n\n divisors.uniq\nend", "def factors(number)\n divisor = number\n factors = []\n while divisor > 0\n factors << number / divisor if number % divisor == 0\n divisor -= 1\n end\n factors\nend", "def factors(num)\n prime?(num) ? [1, num].uniq : [*1..num].select { |i| num % i == 0}\nend", "def prime_factors(num)\n\tfactors(num).select { |n| prime?(n) }\nend", "def prime_factors\n if prime?\n [self]\n else\n pair = factorize\n (pair[0].prime_factors + pair[1].prime_factors).sort.uniq\n end\n end", "def factors_of(number)\n\t\tprimes, powers = number.prime_division.transpose\n\t\texponents = powers.map{|i| (0..i).to_a}\n\t\tdivisors = exponents.shift.product(*exponents).map do |powers|\n\t\t\tprimes.zip(powers).map{|prime, power| prime ** power}.inject(:*)\n\t\tend\n\t\tdivisors.sort.map{|div| [div, number / div]}\n\tend", "def factors(number)\n divisor = number\n factors = []\n loop do\n factors << number / divisor if number % divisor == 0\n divisor -= 1\n break if divisor == 0\n end\n factors\n \nend", "def old_factors(num)\n factors = []\n (1..num).each do |i|\n if num % i == 0\n factors << i\n end\n end\n factors\nend", "def prime_factors(n)\n factors = []\n divisor = 2\n\n while n > 1\n if (n % divisor).zero?\n power = 0\n n /= divisor while (n % divisor).zero? && (power += 1)\n factors << \"(#{divisor}#{power > 1 ? \"**#{power}\" : ''})\"\n end\n divisor += 1\n end\n\n factors.join\nend", "def factors(number)\n fs = [1,number]\n (2..Math.sqrt(number).to_i).each do |i|\n if number % i == 0\n fs << i\n fs << number/i unless number/i == i\n end\n end\n fs.sort\n end", "def factors(num)\n factors = []\n (1..num/2).each {|n| factors << n if num % n == 0}\n factors << num\nend", "def prime_factors(num)\n factors = []\n # Store all the factors in an array\n (2..num).each do |divisor|\n if num % divisor == 0\n factors << divisor\n end\n end\n\n # loop through factors array and return only the prime prime prime factors\n if factors.length > 0\n return factors.select { |factor| checkIfPrime(factor) }\n else\n return factors\n end\nend", "def find_prime_factors(numb)\n\tfactors = []\n\n\twhile numb > 1\n\t\ttest_num = 2\n\t\twhile true\n\t\t\tif is_factor?(numb,test_num)\n\t\t\t\tfactors << test_num\n\t\t\t\tbreak\n\t\t\tend\n\t\t\ttest_num += 1\n\t\tend\n\t\tnumb = numb/test_num\n\tend\n\n\treturn factors\nend", "def factors(number)\n divisor = number\n factors = []\n loop do\n break if divisor <= 0\n factors << number / divisor if number % divisor == 0\n divisor -= 1\n end\n factors\nend", "def prime_factorization_to_factors(factorization)\n\tif factorization.empty?\n\t\t[1]\n\telse\n\t\tprime_factor, multiplicity = factorization[0]\n\t\tfactors = prime_factorization_to_factors(factorization.drop(1))\n\t\tmultiplicity_array = Array.new(multiplicity + 1) { |i| prime_factor ** i }\n\t\tfactors.map { |factor| multiplicity_array.map { |multiple| multiple * factor } }.flatten\n\tend\nend", "def factors(number)\n divisor = number\n factors = []\n begin\n # evaluate statement on right side of shovel operator and if\n # divisor evenly divides number then add into factors array \n factors << number / divisor if number % divisor == 0\n # decrement divisor by 1\n divisor -= 1\n # stops when divisor is 0\n end until divisor == 0\n \n # return all factors in an array that divides evenly with \n # the number passed in as an argument when calling the function\n factors\nend", "def find_factors!\n (1..number).each do |n|\n break if @factors.include?(n)\n if number % n == 0\n @factors << n << (number / n)\n end\n end\n # handle any perfect squares\n\n @factors.uniq!\n end", "def factors(number)\n divisor = number\n factors = []\n loop do\n if number == 0 || number < 0\n break\n else factors << number / divisor if number % divisor == 0\n divisor -= 1\n break if divisor == 0\n end\n end\n factors\n end", "def prime_factor(n)\n factors = []\n p = 2\n\n\n while (p < n)\n\n return factors if ( factors.inject(:*).to_i >= n )\n\n if ( n % p == 0 )\n factors.push(p)\n end\n\n p += 1\n\n end\n\n\n return factors\nend", "def factors( n )\n p = Primer.ld( n )\n return n if p == n\n factors n.div( p )\nend", "def factors(number)\n divisor = number\n factors = []\n loop do\n break if number <= 0\n factors << number / divisor if number % divisor == 0\n divisor -= 1\n break if divisor == 0\n end \n factors\nend", "def find_factors(number)\n factors =[]\n for i in 1..number\n factors << i if number % i == 0\n end\n factors\nend", "def prime_factors(num)\n prime_facts = []\n\n (1..num).each do |i|\n if num % i == 0 && prime?(i)\n prime_facts << i\n end\n end\n\n return prime_facts\nend", "def factors(number)\n divisor = number\n factors = []\n while divisor > 0\n factors << (number / divisor) if ((number % divisor) == 0)\n divisor -= 1\n end\n factors\nend", "def factors(number)\n dividend = 1\n divisors = []\n while dividend <= number\n divisors << dividend if number % dividend == 0\n dividend += 1\n end\n divisors\nend", "def find_factors(num)\n raise ArgumentError, \"num must be >= 0\" if num < 0\n return [n] if num <= 1\n result = []\n\n n = num\n if n.even?\n while n % 2 == 0\n result << 2\n n /= 2\n end\n end\n\n div = 3\n\n while (n > 1)\n while n % div == 0\n result << div\n n /= div\n end\n div += 2\n\n if (div * div > n)\n result << n\n break\n end\n end\n\n result\nend", "def factors(num)\r\n factors = []\r\n sqrt = Math.sqrt(num)\r\n until num == 1\r\n\r\n factor_founded = false\r\n (2..sqrt).each do |i|\r\n if (num % i).zero?\r\n num /= i\r\n factors << i\r\n factor_founded = true\r\n break\r\n end\r\n end\r\n unless factor_founded\r\n factors << num\r\n num /= num\r\n end\r\n end\r\n return factors\r\nend", "def prime_factors_mult( n )\nend", "def factors_of(num)\n factors = []\n \n i = 1\n while i <= num\n # if num is divided by i\n if num % i == 0\n factors << i\n end\n \n i += 1\n end\n \n return factors\n end", "def prime_factors(n)\r\n num=Math.sqrt(n).round\r\n while num>0\r\n if n%num==0\r\n return num if prime?(num)\r\n end\r\n num-=1\r\n end\r\nend", "def prime_factors(num)\n array = []\n (1..num).each do |number|\n array << number if prime?(number) && num % number == 0\n end\n array.sort!\nend" ]
[ "0.84289056", "0.8248386", "0.82452244", "0.81594414", "0.8114608", "0.8114608", "0.81008667", "0.80888236", "0.803569", "0.8034098", "0.80324554", "0.80171794", "0.7986873", "0.7978031", "0.79566336", "0.79540265", "0.7942906", "0.79321647", "0.79179937", "0.7909866", "0.78841096", "0.7879674", "0.78722", "0.7868828", "0.78667194", "0.78548336", "0.7848556", "0.7842288", "0.7834065", "0.78160846", "0.7811766", "0.7802898", "0.7791305", "0.7789146", "0.7772015", "0.7764761", "0.77453655", "0.7744012", "0.77221453", "0.7717639", "0.77138335", "0.7704876", "0.77044445", "0.77009976", "0.769699", "0.7693387", "0.76931787", "0.769039", "0.7657467", "0.7657467", "0.7657467", "0.7653637", "0.76457787", "0.76440316", "0.76289475", "0.76279074", "0.7624993", "0.7617826", "0.7615812", "0.75994366", "0.7593764", "0.7580209", "0.75783825", "0.7577952", "0.7577952", "0.7577952", "0.7577952", "0.7577952", "0.7577952", "0.75759506", "0.7565848", "0.75608397", "0.75528544", "0.75493187", "0.75310165", "0.75268", "0.7522518", "0.75153786", "0.7510922", "0.750591", "0.7500274", "0.7498528", "0.74985063", "0.7490934", "0.7489153", "0.7487273", "0.7483783", "0.74815196", "0.7479508", "0.7478699", "0.74773604", "0.7474652", "0.7463379", "0.74529046", "0.7450217", "0.74495786", "0.7444844", "0.7438464", "0.7438379", "0.74349165" ]
0.8201956
3
Write a method that takes a string and an alphabet. It returns a copy of the string with the letters reordered according to their positions in the alphabet. If no alphabet is passed in, it defaults to normal alphabetical order (az). Do NOT use `Arraysort` or `Arraysort_by`. Example: `jumble_sort("hello")` => "ehllo" `jumble_sort("hello", ['o', 'l', 'h', 'e'])` => 'ollhe'
def jumble_sort(str, alphabet = nil) alphabet ||= ('a'..'z').to_a sorted = false until sorted sorted = true (0...str.length - 1).to_a.each do |i| if alphabet.index(str[i]) > alphabet.index(str[i + 1]) str[i], str[i + 1] = str[i + 1], str[i] sorted = false end end end str end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def jumble_sort(str, alphabet = nil)\n alphabet ||= (\"a\"..\"z\").to_a\n\n new_string = str.split(\"\").sort do |letter_a, letter_b|\n alphabet.find_index(letter_a) <=> alphabet.find_index(letter_b)\n end\n new_string.join\nend", "def jumble_sort(str, alphabet = nil)\n\nend", "def jumble_sort(str, alphabet = nil)\n\nend", "def jumble_sort(str, alphabet = nil)\n\nend", "def jumble_sort(str, alphabet = nil)\n return str.split(\"\").sort.join if alphabet.nil?\n #not done yet\nend", "def jumble_sort(str, alphabet = nil)\n alphabet ||= ('a'..'z').to_a\n sorted = \"\"\n alphabet.each do |c1|\n str.chars.each do |c2|\n sorted << c2 if c2 == c1\n end\n end\n sorted\nend", "def jumble_sort(str, alphabet = (\"a\"..\"z\").to_a)\n str_arr = []\n temp = []\n str.chars.each do |char1|\n if str_arr.empty?\n str_arr << char1\n temp << char1\n else\n temp.each_index do |i|\n if alphabet.index(str_arr[i]) < alphabet.index(char1)\n str_arr << char1\n else\n str_arr.insert(i,char1)\n end\n end\n end\n end\n str_arr.join(\"\")\nend", "def jumble_sort(str, alphabet = nil)\n return str.chars.sort.join(\"\") if alphabet.nil?\n new_string = \"\"\n alphabet.each do |letter|\n (str.count(letter)).times do\n new_string += letter\n end\n end\n new_string\nend", "def jumble_sort(str, alphabet = nil)\n return str.split(//).sort.join if alphabet.nil?\n\n str.split(//).sort_by { |x| alphabet.index(x) }.join\nend", "def jumble_sort(str, alphabet = nil)\n arr = str.split('')\n if alphabet.nil?\n arr.sort.join\n else\n arr.sort{|i, j| alphabet.index(i) <=> alphabet.index(j)}.join\n end\n\nend", "def jumble_sort(str, alphabet = nil)\n alphabet = ('a'..'z').to_a\n\n sorted = false\n while sorted\n sorted = true\n\n str.length.times do |i|\n break if i <= (str.length)\n if alphabet.index(str[i]) > alphabet.index(str[i + 1])\n str[i], str[i + 1] = str[i + 1], str[i]\n sorted = false\n end\n end\n end\n\n str\nend", "def jumble_sort(str, alphabet = nil)\n alphabet ||= ('a'..'z').to_a\n #access each letter\n #call both letters and switch if the letters if the index of first is higher than the index of the second\n\n letters = str.split('')\n i = 0\n while i < letters.length\n j = i + 1\n while j < letters.length\n if alphabet.index(letters[i]) > alphabet.index(letters[j])\n letters[i], letters[j] = letters[j], letters[i]\n end\n j += 1\n end\n i += 1\n end\n\n letters.join('')\nend", "def jumble_sort(str, alphabet = nil)\n alphabet ||= ('a'..'z').to_a\n arr = str.chars\n sorting = true\n while sorting\n sorting = false\n\n arr.each_with_index do |el, i|\n next if i == (arr.length - 1)\n if alphabet.index(el) > alphabet.index(arr[i+1])\n arr[i], arr[i + 1] = arr[i +1], arr[i]\n sorting = true\n end\n end\n\n end\n arr.join\nend", "def jumble_sort(str, alphabet = nil)\n alphabet ||= ('a'..'z').to_a\n final_str = \"\"\n \n alphabet.each do |alpha_char|\n if str.include?(alpha_char)\n str.count(alpha_char).times do\n final_str += alpha_char\n end\n end\n end\n \n final_str\nend", "def jumble_sort(str, alphabet = (\"a\"..\"z\"))\n char_count = Hash.new(0)\n str.each_char { |c| char_count[c] += 1 }\n jumbled_str = \"\"\n alphabet.each do |c|\n (0...char_count[c]).each { |n| jumbled_str << c }\n end\n jumbled_str\nend", "def jumble_sort(str, alphabet = nil)\n return str.chars.sort.join if alphabet == nil\n\n arr = []\n cur_len = 0\n alphabet.each do |c|\n break if cur_len >= str.length\n\n if str.include?(c)\n num = str.count(c)\n arr.push(c * num)\n cur_len += num\n end\n end\n\n arr.join\nend", "def alphabetized(string)\n string.delete(\"^A-Za-z\").chars.sort_by { |char| char.downcase}.join\nend", "def alphabetize(arr, rev = false)\n arr.sort!\nend", "def sort_letters(string)\n string.downcase.split('').sort.join('')\n end", "def alphabetize(arr, rev = false)\nend", "def alphabetized(str)\n alphabet = ('a'..'z').to_a + ('A'..'Z').to_a\n\n str.chars.delete_if { |char| alphabet.include?(char) == false }\n .sort_by { |letter| letter.downcase }.join('')\nend", "def alphabet_soup(str)\n str.split('').sort.join\nend", "def alphabetic(s)\n # pass\n s == s.split('').sort.join('')\nend", "def letters_sorted(word)\n word.split(\"\").sort\nend", "def alphabet_soup(str)\n p str.split(\"\").sort.join\nend", "def alphabetize(arr, rev=false)\n arr.sort!\n if rev\n arr.reverse!\n else\n arr\n end\nend", "def alphabetize(arr, rev = false)\n arr.sort!\n arr.reverse! if rev == true\nend", "def alphabetize(arr, rev=false)\n if rev == false\n arr.reverse! #this method doesn't default to alphabetizing an array when\n #it doesn't receive a second parameter.\n else\n arr.sort!\n end\nend", "def alphabetize(arr, rev=false)\n if rev\n arr.sort { |item1, item2| item2 <=> item1 }\n else\n arr.sort { |item1, item2| item1 <=> item2 }\n end\nend", "def alphabetize(arr, rev=false)\n if rev\n arr.sort { |item1, item2| item2 <=> item1 }\n else\n arr.sort { |item1, item2| item1 <=> item2 }\n end\nend", "def alphabetize(arr, rev=false)\n if rev\n arr.sort! {|first, second| second <=> first }\n else\n arr.sort! {|first, second| first <=> second }\n end\n return arr\nend", "def alphabetize(arr, rev = false)\n arr.sort!\n if rev == true\n arr.reverse!\n else\n \tarr\n end\nend", "def alphabetize(arr, rev = false)\n arr.sort!\n if rev == true\n arr.reverse!\n else\n \tarr\n end\nend", "def alphabetize(array)\n esp=\"abcĉdefgĝhĥijĵklmnoprsŝtuŭvz\" #esperanto alphabet\n ascii = \"@-\\\\\" #\"@-\\\\\" = \"@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\\\\"\n array.sort_by{|string| string.tr(esp, ascii)}\nend", "def alphabetize!\n sort! { |a, b| grouped_compare(a, b) }\n end", "def AlphabetSoup(str)\n str.chars.sort.to_s\nend", "def AlphabetSoup(str)\n str.chars.sort.to_s\nend", "def alphabetize(arr, rev = false)\n arr.sort!\n if rev == true\n arr.reverse\n else\n return arr\n\tend\nend", "def alphabeticShift(inputString)\n alpha = (\"a\"..\"z\").to_a + [\"a\"]\n array = inputString.split(\"\")\n \n for i in 0..(array.count-1)\n array[i] = alpha[alpha.index(array[i])+1]\n end\n array.join(\"\")\nend", "def alphabetize(arr)\n arr.sort_by do |word|\n word.chars.map { |letter| ESPERANTO_ALPHABET.index(letter) }\n end\nend", "def alpha_sort(phrase)\n char_count = Hash.new(0)\n\n phrase.split(\"\").each { |char| char_count[char]+=1 }\n\n single_chars = char_count.keys\n single_chars.delete(\" \")\n\n idx = 0\n sort_done = false\n num_of_sorts = single_chars.length - 2\n\n \n until sort_done\n changes = 0\n 0.upto(num_of_sorts) do |i|\n if single_chars[i] > single_chars[i+1]\n single_chars[i], single_chars[i+1] = single_chars[i+1], single_chars[i]\n changes += 1\n end\n end\n sort_done = true if changes == 0\n end\n\n single_chars.join\nend", "def AlphabetSoup(str)\n\t# splits str into an array of the characters making up str, sorts that arr, and then converts it to a single string\n\tstr.chars.sort.join('')\nend", "def alphabetize(arr)\n esperanto_alphabet = \"abcĉdefgĝhĥijĵklmnoprsŝtuŭvz\"\n arr.sort_by do |phrase|\n phrase.chars.map do |char|\n esperanto_alphabet.index(char)\n end\n end\nend", "def calculate_alphabet(str)\nend", "def alphabetize1(arr, rev=false)\n if rev!=false\n arr.sort! do |a, b|\n b <=> a # REVERSE ALPHABETICAL ORDER\n end\n else\n arr.sort! do |a, b|\n a <=> b\n end\n end\nend", "def alphabetize(arr, rev=false)\n\tif rev\n\t\tarr.sort { |item1, item2| item2 <=> item1 }\n\telse\n\t\tarr.sort { |item1, item2| item1 <=> item2 }\n\tend\nend", "def AlphabetSoup(str)\n str = str.split(\"\")\n str.sort!\n return str.join\nend", "def alphabetize (arr, rev=false)\n if rev==true\n arr.reverse!\n#{|firstItem, secondItem| secondItem <=> firstItem}\n else\n rev==false\n arr.sort!\n end\n end", "def alphabetized(s)\n s.scan(/[a-z]/i).sort_by(&:downcase).join\nend", "def AlphabetSoup(str)\n str.split(\"\").sort.join\nend", "def alphabetize(arr, rev = false)\n arr.sort!\n \n if rev == true\n arr.reverse!\n else\n arr\n end\n return arr\n end", "def alphabetized(str)\n array = str.chars\n array.delete_if { |x| x =~ /[\\W_]/ }\n array.sort { |a,b| a.downcase <=> b.downcase }.join\nend", "def alphabetic(s)\n s.chars.sort.join == s\nend", "def alphabetSoup(str)\n\treturn str.split('').sort().join('')\nend", "def alphabetize(arr)\n\nesperanto_ALPHABET = \"abcĉdefgĝhĥijĵklmnoprsŝtuŭvz\"\n\n arr.sort_by do |sentence|\n sentence.chars.collect do |letter|\n # binding.pry\n esperanto_ALPHABET.index(letter)\n # binding.pry \n\n end\n end\n\nend", "def alphabetic_number_sort(numbers)\n numbers.sort_by { |number| NUMBERS[number] }\nend", "def ordered_letters\n @word.chars.sort.join\n end", "def dealphabetize(\n alphabet = \"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\"\n )\n str = to_s\n alphabet = alphabet.to_s\n len = alphabet.length\n str.chars.inject(0) do |num, char|\n i = alphabet.index(char)\n raise(\"Character not in alphabet: '#{char}'\") if i.nil?\n\n num * len + i\n end\n end", "def letter_swap(str)\n\tcount = 0\n\tnew_str = \"\"\n\twhile count < str.length\n\t\tstr_to_int = (str[count].ord + 1)\n\t\tif str_to_int > 122\n\t\t\tstr_to_int = 97\n\t\tend\n\t\tnew_str += str_to_int.chr\n\t\tcount+=1\n\tend\n\treturn new_str\nend", "def reverse_ordered_letters\n ordered_letters.reverse\n end", "def check_input_vs_alphabet(string_array)\n braille_translated = []\n string_array.each do |letter|\n if letter == letter.upcase && letter != letter.downcase\n braille_translated << alpha.trans_braille[:shift]\n braille_translated << alpha.trans_braille[letter.downcase]\n else\n braille_translated << alpha.trans_braille[letter]\n end\n end\n sort_out(braille_translated)\n end", "def alphabetize(arr, rev=false) # Default value will be false for SECOND\n # parameter if ONLY ONE argument is passed\n arr.sort!\n if rev!=false # Executes line below if TWO arguments are passed (passing TWO\n # arguments will sort the array in DESCENDING order).\n arr.reverse!\n else # Executes line below if ONE argument is passed (passing ONE argument\n # will sort the array in ASCENDING order)\n arr.sort!\n end\nend", "def alphabetize\n\nend", "def letter_reverse str\n str.reverse!\nend", "def sort(word)\n\t# Downcase and converting string into array\n\tword = word.downcase().split(\"\")\n\tlen = word.length\n\n\t# Initializing loop variables\n\ti = 0\n\tj = 0\n\ttemp = 0\n\n\t# Sort the array\n\twhile i < len - 1\n\t\tj = i + 1\n\t\twhile j < len\n\t\t\tif word[i] > word[j]\n\t\t\t\t#swap characters in ascending order\n\t\t\t\ttemp = word[i]\n\t\t\t\tword[i] = word[j]\n\t\t\t\tword[j] = temp\n\t\t\tend\n\t\t\tj += 1\n\t\tend\n\t\ti += 1\n\tend\n\treturn word\nend", "def letter_hash s\n s.each_char.to_a.sort.join('')\nend", "def char_sorted(str) str.split('').sort.join end", "def AlphabetSoup(str)\n\tstr = str.split(\"\").sort.join(\"\")\n\treturn str\n\nend", "def sort3(strings, length)\n (length - 1).downto(0) do |i|\n buckets = Array.new(26) { [] }\n strings.each do |string|\n letter = string[i]\n buckets[letter.ord - \"a\".ord] << string\n end\n\n strings = []\n buckets.each do |bucket|\n bucket.each { |string| strings << string }\n end\n end\n\n strings\nend", "def alphabet_sort(array)\n alphabet = [\"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\", \"i\", \"j\", \"k\", \"l\", \"m\", \"n\", \"o\", \n \t\"p\", \"q\", \"r\", \"s\", \"t\", \"u\", \"v\", \"w\", \"x\", \"y\", \"z\"]\n counter = 1\n until counter == 100\n\n \tnew_array = array.each do |letter|\n \t\n \t\ti = 1\n \t index_of_letter_in_array = array.index(letter)\n \t index_of_next_letter_in_array = index_of_letter_in_array + i \n \t value_of_next_item_in_array = array[index_of_next_letter_in_array]\n \t \n \t until i == array[index_of_letter_in_array..-1].length\n \t \t\t if \talphabet.index(letter) > alphabet.index(value_of_next_item_in_array)\n\t\n \t \t\t\t\tarray[index_of_letter_in_array], array[index_of_next_letter_in_array] =\n \t \t\t\t\t array[index_of_next_letter_in_array], array[index_of_letter_in_array]\n \t \t\t\tend #if\n \t \t\t\t\n \t \t\t\ti += 1 \n \t \tindex_of_next_letter_in_array = index_of_letter_in_array + i \n \t \tvalue_of_next_item_in_array = array[index_of_next_letter_in_array]\n \t \tend #until\n \t \t\n \tend #do\n\n counter += 1\n\tend #until\n\tp new_array\n\nend", "def reverse_only_letters(s)\n letters = []\n alphabet = (\"a\"..\"z\").to_a\n \n s.each_char do |char|\n letters << char if alphabet.include?(char.downcase)\n end\n \n s.each_char.with_index do |char, idx|\n s[idx] = letters.pop if alphabet.include?(char.downcase)\n end\n s\nend", "def my_array_sorting_method(source)\n source.sort { |a,b| a.to_s <=> b.to_s } # sort string within array alphabetically\nend", "def alphabet\n 'abcdefghijklmnopqrstuvwxyz'\n end", "def do_sorting\n char_list_length = char_list.length\n\n loop do\n swapped = false\n (char_list_length - 1).times do | i |\n if char_list[i] > char_list[i+1]\n char_list[i], char_list[i+1] = char_list[i+1], char_list[i]\n num_list[i], num_list[i+1] = num_list[i+1], num_list[i]\n\n swapped = true\n end\n end\n break if not swapped\n end\n end", "def encrypt_letter alphabet, cipherbet, letter\n# default for things not found in alphabet is to just return as\n encrypted_letter = letter\n # look for letter using method from above, -1 means not found\n pos = get_position_in_list alphabet, letter\n if pos == -1\n return encrypted_letter\n else\n encrypted_letter = cipherbet[pos]\n if is_lowercase(letter) == true\n encrypted_letter = encrypted_letter.downcase\n end\n return encrypted_letter\n end\nend", "def generate_alphabet\n (\"a\"..\"z\").to_a\nend", "def alphabet\n ('a'..'z').to_a\n end", "def depunctuate(a_string)\n alphabet = [*\"A\"..\"Z\"] + [*\"a\"..\"z\"]\n result = \"\"\n a_string.length.times do |i|\n if alphabet.include?(a_string[i])\n result << a_string[i]\n end\n end\n result\nend", "def sortme(str)\n str.sort_by { |word| word.downcase }\nend", "def letter_changes(str)\n str.each_char.with_index do |char, idx|\n if char =~ /[A-Za-z]/\n if char =~ /[Zz]/\n str[idx] = 'a'\n else\n str[idx] = (char.ord + 1).chr\n end\n end\n end\n str.each_char.with_index do |char, idx|\n str[idx] = char.upcase if char =~ /[aeiou]/\n end\n str\nend", "def sorts(s)\n s = s.chars.sort.join\nend", "def sortme(names)\n names.sort\nend", "def alphabetic_number_sort2 num_arr\n num_arr.sort {|a, b| WORDS_ARR[a] <=> WORDS_ARR[b]}\nend", "def encrypt(password)\n alphabet = \"abcdefghijklmnopqrstuvwxyz\"\n index = 0\n while index < password.length\n letter = password[index]\n position = alphabet.index(letter) #magic\n\n if password[index] == \"z\"\n password[index] = \"a\"\n else\n password[index] = alphabet[position].next!\n end\n\n index += 1\n end\n return password\nend", "def swap_letters(word)\n word[0], word[-1] = word[-1], word[0]\n word\nend", "def letter_to_place(str)\n alphabet = 'abcdefghijklmnopqrstuvwxyz'\n arr = []\n str.each_char {|letter| arr << alphabet.index(letter) + 1}\n arr\nend", "def string_sort(str_arr)\n (str_arr.first.length - 1).downto(0) do |d|\n str_arr = merge_sort(str_arr, d)\n end\n str_arr\nend", "def my_array_sorting_method(source)\n sourceDup = source.dup\n # p sourceDup.sort_by{|word| word.to_s}\n\n return sourceDup.sort_by{|word| word.to_s}\nend", "def alphabetic_number_sort2(nums)\n nums.sort { |num1, num2| ENGLISH_NUMBERS[num1] <=> ENGLISH_NUMBERS[num2] }\nend", "def sortme( names )\n names.sort\nend", "def sortme( names )\n names.sort\nend", "def sortme( names )\n names.sort\nend", "def scramble_words(words)\n first_word = words[0]\n last_word = words[-1]\n alphabetically = words[1, (words.size - 2)].chars.sort\n alphabetically.unshift(first_word).push(last_word).join\nend", "def swap_letters(word)\n\n\tword[0], word[-1] = word[-1], word[0]\n\tword\n\t\nend", "def alphabetic_number_sort(arr)\n arr.sort { |a, b| INT_NAMES[a] <=> INT_NAMES[b] }\nend", "def reverse_letter(letter)\r\n alphabet = (\"a\"..\"z\").to_a\r\n index = alphabet.index(letter) \r\n alphabet[index-1]\r\nend", "def letter_changes(string)\n array = (\"a\"..\"z\").to_a\n\n result_array = string.chars.map do |char|\n case\n when char.downcase == \"x\" then char == \"x\" ? \"a\" : \"A\"\n when char.downcase == \"y\" then char == \"y\" ? \"b\" : \"B\"\n when char.downcase == \"z\" then char == \"z\" ? \"c\" : \"C\"\n when char.match(/[a-z]/) then array[array.index(char.downcase) + 3]\n when char.match(/[A-Z]/) then array[array.index(char.downcase) + 3].upcase\n else char\n end\n end\n result_array.join\nend", "def alphabetic_number_sort(numbers)\n result = []\n sorted_numbers = []\n\n numbers.each { |num| sorted_numbers << num}\n sorted_numbers.sort.each { |number| result << NUMBERS[number] }\n result\nend", "def alphabet\n ('A'..'Z').to_a\n end", "def alphabet\n ('A'..'Z').to_a\n end" ]
[ "0.82597476", "0.82006204", "0.82006204", "0.82006204", "0.81293917", "0.79909444", "0.798923", "0.78909403", "0.78866094", "0.7872284", "0.7859529", "0.7758186", "0.7693955", "0.7579312", "0.757669", "0.7435558", "0.7020224", "0.69431144", "0.68666995", "0.68644327", "0.68636775", "0.6863674", "0.67236996", "0.6584651", "0.6584545", "0.6516774", "0.6515784", "0.64750355", "0.6437149", "0.6437149", "0.64115393", "0.6410438", "0.6410438", "0.64080137", "0.6398427", "0.6394138", "0.6394138", "0.6355985", "0.6347873", "0.6347071", "0.63337165", "0.6325876", "0.63040525", "0.62904817", "0.62597847", "0.62596667", "0.6250847", "0.62406015", "0.6222827", "0.622226", "0.6216874", "0.62161636", "0.61893904", "0.61676985", "0.61475384", "0.6129919", "0.61098754", "0.60919493", "0.6072626", "0.6036089", "0.59569097", "0.5931726", "0.5929354", "0.59277713", "0.59067786", "0.588747", "0.58860475", "0.5859742", "0.58522034", "0.58380646", "0.5799401", "0.5790327", "0.5785679", "0.57796", "0.5775146", "0.5769436", "0.5763042", "0.57620114", "0.5749474", "0.57413906", "0.5737438", "0.57184744", "0.5709864", "0.57093716", "0.5708312", "0.5692729", "0.5691178", "0.5687572", "0.5683611", "0.5679858", "0.56660974", "0.56660974", "0.56640357", "0.5656254", "0.5654346", "0.5653498", "0.56479454", "0.5645604", "0.56425196", "0.56425196" ]
0.782901
11
Define a method `rec_sum(nums)` that returns the sum of all elements in an array recursively
def rec_sum(nums) return 0 if nums.empty? nums[0] + rec_sum(nums.drop(1)) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def rec_sum(nums)\n\nend", "def rec_sum(nums)\n\nend", "def sum(nums)\n return 0 if nums.empty?\n nums[0] + sum_rec(nums[1..-1])\nend", "def sum_rec(nums)\n return 0 if nums.empty?\n nums[0] + sum_rec(nums[1..-1])\nend", "def sum_rec(nums)\n return 0 if nums.empty?\n nums[0] + sum_rec(nums.drop(1))\nend", "def sum_rec(nums)\n return 0 if nums.length == 0\n sum_rec(nums[0...-1]) + nums[-1]\nend", "def recursive_sum(nums)\n return 0 if nums.empty?\n\n return nums.pop + recursive_sum(nums)\nend", "def sum_array_rec(array_to_sum)\n if(array_to_sum.length > 0)\n sum = array_to_sum[0]\n sum += sum_array_rec(array_to_sum[1..-1])\n else\n 0\n end\nend", "def sum_rec(num_array)\n return 0 if num_array.empty?\n\n num[0] + sum_rec(num_array.drop(1))\nend", "def sum_rec(numbers)\n # base case\n return 0 if numbers.empty?\n # inductive step\n numbers[0] + sum_rec(numbers[1..-1])\nend", "def sum_rec(numbers)\n return 0 if numbers.empty?\n num = numbers.pop\n num + sum_rec(numbers)\nend", "def sum_rec(nums)\nreturn nums[0] if nums.size == 1\nreturn 0 if nums.size == 0\n nums[0] + sum_rec(nums[1..-1])\nend", "def sum(nums)\n\treturn 0 if nums == []\n\tnums.reduce(:+)\nend", "def sum_arr_rec(arr)\n return 0 if arr.length == 0\n return arr[0] if arr.length == 1\n arr[0] + sum_arr_rec(arr[1..-1])\nend", "def sum_recur(array)\n #base case\n return 0 if array.empty?\n #iterative step\n array.first + sum_recur(array[1..-1])\nend", "def sum_recur(array)\n return 0 if array.empty?\n array.pop + sum_recur(array)\nend", "def sum_recursion(arr)\n return 0 if arr.empty?\n sum = arr.shift\n sum += sum_of_array(arr)\n # 2 + sum_of_array([3])\n #3 + sum_of_array([])\n\n\nend", "def RecursiveSum(arrayofNumbers) \n \n # Base Case: If the array is empty, return 0. \n \n if arrayofNumbers? \n return 0\n \n # Recursive code: Adding each element to the variable by calling the method. \n \n else\n Sum = arrayofNumbers.pop \n return Sum + RecursiveSum(arrayofNumbers) \n end\nend", "def sum_recur(array)\n return 0 if array.empty?\n array.first + sum_recur(array.drop(1))\nend", "def sum_recur(array)\n return 0 if array.length <= 0\n array[0] + sum_recur(array[1..-1])\nend", "def sum_recur(array)\n return 0 if array.empty?\n \n array[0] + sum_recur(array[1..-1])\nend", "def sum_recur(array)\n return 0 if array.empty?\n array.first + sum_recur(array.drop(1))\nend", "def recursive_sum(array)\n return array[0] if array.length == 1\n\n array[0] + recursive_sum(array[1..-1])\nend", "def sum_recur(array)\n sum = 0\n if array.empty?\n 0\n else\n sum = array.first\n sum += sum_recur(array.drop(1))\n sum\n end\nend", "def sum(nums)\n nums.reduce(&:+)\nend", "def sum_rec(arr)\n return 0 if arr.empty?\n arr[0] += sum_rec(arr.drop(1))\nend", "def sum_recur(array)\n#for array = []\n return 0 if array == []\n\n first_el = array.shift\n recursive_call = sum_recur(array)\n first_el + recursive_call\n\nend", "def add_nums_iterative(arr)\n return nil if arr.length == 0\n total = 0\n arr.each do |num|\n total += num\n end\n total\nend", "def recursive_sum(array)\n if array.length == 0\n return 0\n end\n recursive_sum(array[1..-1]) + array.first\nend", "def iterative_sum(arr)\n total = 0\n arr.each {|num| total += num}\n return total\nend", "def sum_recur(array)\n return 0 if array.empty?\n val = array.last\n val + sum_recur(array.take(array.length - 1))\nend", "def add_numbers(nums_array)\n return nums_array.first if nums_array.length == 1 #=> base case if the array is length 1 then just return the first element\n return nil if nums_array.length < 1 #=> return nil if the array length is less than 1\n \n nums_array.pop + add_numbers(nums_array) #=> inductive/recursive case taking the sum of the array and #pop the the last ele each time\nend", "def arr_sum(arr)\n return 0 if arr.empty?\n head = arr[0]\n tail = arr[1..-1]\n head.size + arr_sum(tail)\nend", "def sum_recur(array)\n return 0 if array.empty?\n dup = array.dup\n return dup[0] if dup.length == 1\n sum = dup.pop + sum_recur(dup)\n\nend", "def sum arr\n sum = arr.sum\n return sum\nend", "def sum_recur(array)\n return array.first if array.length == 1\n array[0] + sum_recur(array[1..-1])\nend", "def sum_rec(arr)\n return arr.first if arr.size <= 1\n arr.pop + sum_rec(arr)\nend", "def sum arr\n sum = 0\n arr.each do |n|\n sum+= n\n end\n return sum\nend", "def sum_recursive(num)\n # can also compute sum with symbol (1..5).inject(:+)\n (1..num).inject { |sum, n| sum + n }\nend", "def sum_array(numbers)\n return numbers.sum()\nend", "def add_numbers(num_array)\n return num_array[0] if num_array.length <= 1\n sum = num_array[0]\n sum += add_numbers(num_array[1..-1])\nend", "def sum arr\n #this is slightly too easy...\n arr.sum\nend", "def sum_recur(array)\n return array[0] if array.length == 1\n array[0] + sum_recur(array.drop(1))\nend", "def sum_recur(array)\n return array[0] if array.length == 1\n array[0] + sum_recur(array.drop(1))\nend", "def sum_recurse(num)\n return 0 if num == 0\n num[0] + sum_recurse(num.delete(1))\nend", "def sum_recur(array)\n \n if array.empty?\n return 0\n elsif array.length == 1\n return array[0]\n end\n \n return sum_recur(array[0...-1]) + array[-1]\n \n\nend", "def my_sum(arr)\n arr.inject(:+)\nend", "def sum(nums)\n total = 0\n nums.each do |n|\n total+= n\n end\n return total\nend", "def sum_array_recur(array)\n return nil if array.empty?\n return array[0] if array.length == 1\n\n array[0] + sum_array_recur(array[1..-1])\nend", "def sum_of_sums(arr)\n sum = 0\n total = 0\n\n arr.each do |num|\n sum += num\n total += sum\n end\n total\nend", "def sum_of_sums(arr)\n sum = 0\n total = 0\n\n arr.each do |num|\n sum += num\n total += sum\n end\n total\nend", "def sum_of_sums(array)\r\nend", "def arr_sum(array)\n sum = 0 # Declares initial value for variable 'sum' as 0\n array.each do |i| # Begin iterating each item of arr\n sum += i # add each number in array to the next item, continue until items exhausted\n end\n return sum # Returns new sum value\nend", "def sum (arr)\n\treturn arr.inject(0, :+)\nend", "def sum arr\n return 0 if arr.empty?\n arr.inject(:+)\nend", "def array_sum(arr)\n return 0 if arr.empty?\n\n arr.reduce(&:+)\nend", "def sum(array) \n if array == []\n 0\n else\n array[0] + sum(array[1..-1])\n end\nend", "def sum(arr)\n return 0 if arr.empty?\n el = arr.shift\n total = sum(arr)\n total + el\nend", "def iterative_sum(array)\n sum = 0\n array.each do |ele|\n sum += ele\n end\n sum\nend", "def iterative_sum(array)\n sum = 0\n array.each do |ele|\n sum += ele\n end\n sum\nend", "def sum(arr)\n arr.inject(:+)\nend", "def sum(array)\n array.sum\nend", "def sum(array_of_integers)\n # TODO\nend", "def sum arr\n sum = 0\n arr.each do |i|\n sum = sum + i\n end\n return sum\nend", "def sum_nums(num)\n (1..num).inject(&:+)\nend", "def sum(arr)\n arr.reduce(0, :+)\nend", "def add_numbers(nums_array)\n if nums_array.empty? \n 0\n else \n n = nums_array.pop\n return n + add_numbers(nums_array)\n end \nend", "def add_nums(arr)\n return nil if arr.length == 0\n return arr[0] if arr.length == 1\n arr[0] + add_nums(arr[1..-1])\nend", "def array_sum(arr)\n\n sum = 0\n arr.each {|n| sum += n}\n\n sum\nend", "def sum_of_arr(arr)\n arr.inject(:+)\nend", "def sum_an_array(arr)\n p arr\n return 0 if arr.empty?\n return arr[0] if arr.length == 1\n # first = arr[0]\n # rest = sum_an_array(arr[1..-1])\n # total = first + rest\n left = arr[0...arr.length/2]\n right = arr[arr.length/2..-1]\n p left\n p right\n left_sum = sum_an_array(left)\n right_sum = sum_an_array(right)\n total = left_sum + right_sum\nend", "def my_sum(array)\n sum = 0\n array.each do |num|\n sum += num\n end\n sum\nend", "def array_sum(arr)\n arr.reduce(:+)\nend", "def array_sum(arr)\n arr.reduce(:+)\nend", "def sum_array_iterative(arr)\n arr.inject(0) {|sum, el| sum + el}\nend", "def sum_of_arr(arr)\n sum = 0\n arr.each do |i|\n sum = sum + i\n end\n sum\nend", "def array_sum(arr)\n arr.reduce(:+)\n\nend", "def sum arr\n sum = 0\n arr.each { |a| sum += a }\n return sum\nend", "def sum(arr)\n return 0 if arr.empty?\n arr.reduce(:+)\nend", "def sum(numbers)\n numbers.reduce(&:+)\n end", "def sum arr\n rtn = 0\n arr.each { |n| rtn += n }\n return rtn\nend", "def sum arr\n res = 0\n arr.each {|i| res+=i}\n return res\nend", "def sum_array(array)\n array.sum\nend", "def sum arr\n arr.reduce(0, :+)\nend", "def sum arr\n arr.reduce(0, :+)\nend", "def array_sum(arr)\n if arr.length == 0\n return 0\n end\n arr.reduce(:+)\nend", "def sum(sums = Array[0])\n retVal = 0;\n sums.each do |i|\n retVal = (retVal + i.to_i);\n end\n retVal;\nend", "def sum_array(array)\n array.sum\nend", "def sum(arr)\n return 0 if arr.length.zero?\n\n arr.reduce(:+)\nend", "def sum arr\n sum_array = 0 \n arr.each { |x| sum_array = sum_array + x } \n return sum_array\nend", "def rec_sum(num)\n return num if num <= 1\n num + rec_sum(num - 1)\nend", "def add_numbers(nums_array)\n return 0 if nums_array.length == 0\n\n first = nums_array.shift\n\n first + add_numbers(nums_array)\nend", "def sum_numbers(root)\n return 0 if root.nil?\n nums = []\n inner_sum_numbers(root, 0, nums)\n nums.reduce(:+) #OR (&:+)\n#(5..10).reduce(:+) => 45\n# Same using a block and inject (5..10).inject { |sum, n| sum + n } => 45\n# Multiply some numbers(5..10).reduce(1, :*) => 151200\nend", "def my_sum(array)\n return nil if array.length == 0\n\n sum = 0\n array.each do |elem|\n sum = sum + elem\n end\n sum\nend", "def sum_of_sums(int_arr)\n sum = 0\n current_numbers = []\n int_arr.each { |int|\n current_numbers << int\n sum += current_numbers.sum\n }\n sum\nend", "def array_sum(arr)\n return 0 if arr.empty?\n arr.reduce(:+)\nend", "def array_sum(arr)\n return 0 if arr.empty?\n arr.reduce(:+)\nend", "def sum_of_sums(arr)\n total_sum = 0\n dup_arr = arr.dup # make a copy to avoid mutating original array\n until dup_arr.empty?\n total_sum += dup_arr.reduce(:+)\n dup_arr.pop\n end\n total_sum\nend", "def total(nums)\n sum = 0\n nums.each {|i| sum = (sum + i)}\nend", "def arr_sum(arr)\r\n sum_arr = 0\r\n arr.each { |i| sum_arr+=i}\r\n sum_arr\r\nend" ]
[ "0.8344894", "0.8344894", "0.83379805", "0.8250366", "0.8015812", "0.791744", "0.79006046", "0.78274053", "0.7825242", "0.7817675", "0.7757072", "0.7699849", "0.76764464", "0.7612195", "0.75971943", "0.75934255", "0.75595033", "0.75439817", "0.7517138", "0.7516624", "0.75071806", "0.75030166", "0.7493733", "0.74747574", "0.74651235", "0.7443902", "0.74382085", "0.7428922", "0.74149394", "0.73848003", "0.73439705", "0.7316663", "0.72676677", "0.72550344", "0.7229921", "0.72108644", "0.72033846", "0.7198471", "0.7183508", "0.71826726", "0.716476", "0.71554726", "0.71501094", "0.71501094", "0.7141979", "0.71377987", "0.7134622", "0.7125868", "0.712575", "0.711767", "0.711767", "0.7108191", "0.710529", "0.7103384", "0.70940334", "0.70915264", "0.70872974", "0.7087129", "0.70844835", "0.7066455", "0.7065098", "0.70624393", "0.7055155", "0.7051388", "0.70468247", "0.70389336", "0.7037432", "0.7031569", "0.70275366", "0.7017796", "0.70165354", "0.70155084", "0.70087624", "0.70087624", "0.70046884", "0.6998314", "0.69939876", "0.69870234", "0.69867605", "0.6986048", "0.69832724", "0.6980659", "0.69779813", "0.6972006", "0.69715613", "0.6969447", "0.6961375", "0.69595104", "0.6954772", "0.69537205", "0.6947374", "0.69439864", "0.694316", "0.6941063", "0.6932217", "0.6926766", "0.6926766", "0.69266444", "0.6920883", "0.69198436" ]
0.7893728
7
Write a method that returns b^n recursively. Your solution should accept negative values for n.
def exponent(b, n) return 1 if n == 0 if n > 0 b * exponent(b, n - 1) else 1.0/b * exponent(b, n + 1) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def exponentiation(b, n)\n return 1 if n == 0\n\n return exponentiation(b, n - 1) * b\nend", "def exponent(b, n)\n return 1 if n == 0\n\n if n > 0\n b * exponent(b, n - 1)\n else\n 1.0/b * exponent(b, n + 1)\n end\nend", "def power(b, n)\n\n\t# b^n.to_i\n\n\tb ** n\n\nend", "def my_pow(x, n)\n return x if n == 1\n return x * x if n == 2\n return x / x if n == -2\n\n if n > 0\n x * my_pow(x, n - 1)\n else\n my_pow(x, n + 1)\n end\nend", "def exponentiation1(b,n)\n return 1 if n == 0 \n b * exponentiation1(b, n - 1)\nend", "def exponentiation_1(b, n)\n return 1 if n == 0\n return b if n == 1\n b * exponentiation_1(b, n - 1)\nend", "def exponent_v1(b, n)\n puts s += 1\n if n == 0\n return 1\n end\n b * exponent_v1(b, n-1)\nend", "def exponent(b, n)\n return b if n == 1\n return 1 if n == 0\n if n >= 0\n exponent(b, n-1) * b\n else\n (1.0/b) * exponent(b, n+1)\n end\n end", "def exponentiation_1(b, n)\n return 1 if n == 0\n return b if n == 1\n b*exponentiation_1(b, n-1)\nend", "def power(x,n)\n n == 0 ? (return 1) : x*power(x,n-1)\n\nend", "def power(num, n)\n return num if n == 1\n multiply(num, power(num, n - 1))\nend", "def pow( x, n)\n if (n == 0)\n return (1)\n elsif (n % 2 == 0)\n value = pow(x, n / 2)\n return (value * value)\n else\n value = pow(x, n / 2)\n return (x * value * value)\n end\nend", "def exponent(b, n)\n\nend", "def exponent(b, n)\n\nend", "def exponent(b, n)\n\nend", "def power_of_n(n, power)\n result = 1\n power.times {result = multiply(n, result)} # similar to recursion\n result\nend", "def pow(x, n)\n if n == 0\n return 1\n elsif n % 2 == 0\n return pow(x, n/2) * pow(x, n/2)\n else\n return x*pow(x, n-1)\n end\nend", "def exp(b,n)\n return 1 if n == 0\n b * exp(b,n-1)\nend", "def exponentiation2(b, n)\n return 1 if n == 0\n return b if n == 1\n if n.even?\n exponentiation2(b, n / 2) ** 2\n else\n b * exponentiation2(b, (n - 1) / 2) ** 2\n end\nend", "def power(num, n)\n if n == 0\n 1\n elsif n > 0\n multiply(power(num, n - 1), num)\n else\n 1 / power(num, -n).to_f\n end\nend", "def perfect_power(n)\n\nend", "def exponentiation_2(b, n)\n return 1 if n == 0\n return b if n == 1\n\n if n.even?\n exponentiation_2(b, n / 2) ** 2\n else\n b * (exponentiation_2(b, (n - 1) / 2) ** 2)\n end\nend", "def exponent_v2(b, n)\n puts s += 1\n if n == 0 \n return 1\n elsif n == 1 \n return b\n elsif n.even?\n rec = exponent_v2(b, n / 2)\n rec * rec\n else \n rec = exponent_v2(b, (n - 1) / 2)\n b * rec * rec\n end\nend", "def exp(b, n)\n return b if n <= 1\n b * exp(b, n-1)\nend", "def exp(b,n) #First method\n return 1 if n == 0\n if n > 0\n b * exp(b,n - 1)\n else\n (1.0/b) * exp(b,n + 1) \n end\nend", "def bunny(n)\n # base case\n return 0 if n == 0\n # recursive case\n return 2 + bunny(n - 1)\nend", "def bunny(n)\n # base case\n return 0 if n == 0\n # recursive case\n return 2 + bunny(n-1)\nend", "def exp(b,n)\n return 1 if n == 0\n return b if n == 1\n\n if n.even?\n num = exp(b, n / 2)\n num * num\n else\n num = exp(b, (n - 1) / 2)\n b * num * num\n end\nend", "def exp(b, n)\n return b if n == 0 || n == 1\n \n if n.even?\n return exp(b, n / 2) ** 2\n else\n return b * exp(b, n - 1)\n end\nend", "def exp(b, n)\n return b if n == 0 || n == 1\n \n return b * exp(b, n - 1)\nend", "def power(n)\n n ** 2\nend", "def exp(b, n) # option 2\n return 1 if n == 0\n result = nil\n\n if n.even?\n result = exp(b, n / 2) ** 2\n else\n result = b * (exp(b, (n - 1) / 2) ** 2)\n end\n\n result\nend", "def power_of_n(num, exponent)\n num ** exponent\nend", "def bunny(n)\n raise ArgumentError if n < 0\n if n == 0 # base case\n return 0\n else\n return bunny(n - 1) + 2\n end\nend", "def bunny(n)\n if n < 0 \n raise ArgumentError, \"bunnies cannot be a negative number!\"\n elsif\n n == 0\n return n\n else\n return 2+ bunny(n-1)\n end\nend", "def bunny(n)\n if n <= 0\n return 0\n else\n return 2 + bunny(n-1)\n end\nend", "def general_power(n, x)\n multiply(n, 1)**(x)\nend", "def bunny(n)\n if n == 0\n return 0\n else\n return 2 + bunny(n - 1)\n end\nend", "def rpower(n) end", "def bunny(n)\n if n == 0\n return 0\n else\n return 2 + bunny(n-1)\n end \nend", "def potenz(x, n)\n check_pre((n.nat?))\n if (n == 1) then\n x\n elsif (n == 0) then\n 1\n else \n x*=potenz((x), n-1)\n end\n end", "def solve( n = 100 )\n max = 0\n 1.upto( n - 1 ) do |a|\n 1.upto( n - 1 ) do |b|\n m = (a**b).sum_digits\n max = m if m > max\n end\n end\n \n max\n end", "def bunny(n)\n if n < 1\n return 0\n else \n return 2 + bunny(n-1)\n end\nend", "def bunny(n)\n if n == 0\n return n\n else\n return 2 + bunny(n - 1)\n end\nend", "def modpow(a, b, n, m)\n if n == 0\n [1, 0]\n elsif n % 2 == 0\n modpow((a * a) % m, (a * b + b) % m, n / 2, m)\n else\n c, d = modpow(a, b, n - 1, m)\n [(a * c) % m, (a * d + b) % m]\n end\nend", "def q(n)\n if n == 1\n return 1\n else q(n-1) + (n*n*n)\n end\nend", "def jacobi(a, n)\n if a == 0\n n == 1 ? 1 : 0\n elsif a.odd?\n negpow((a-1)*(n-1)/4) * jacobi(n%a, a)\n else\n negpow((a**2-1)/8) * jacobi(a/2, n)\n end\nend", "def bunny(n)\n # raise NotImplementedError, \"Method not implemented\"\n if n == 0\n return 0\n else\n return 2 + bunny(n - 1)\n end\nend", "def bunny(n)\n if n === 0\n return 0\n end\n\n return 2 + bunny(n-1)\nend", "def bunny(n)\n if n == 0\n return 0\n elsif n == 1\n return 2 \n else\n 2 + bunny(n - 1)\n end \nend", "def bunny(n)\n if n == 0\n return n\n else\n return 2 + bunny(n-1)\n end\nend", "def solve( n = 30 )\n term = nil\n\n (2..10).each do |e|\n (2..100).each do |sum|\n if (sum**e).sum_digits == sum\n term, n = sum**e, n - 1 \n end\n break if 0 == n\n end\n break if 0 == n\n end\n\n term\n end", "def bunny(n)\n raise ArgumentError if !n\n \n return n if n <= 0 \n return 2 + bunny(n - 1)\nend", "def bunny(n)\n return 0 if n == 0\n return 2 + bunny(n - 1)\nend", "def bunny(n)\n return 0 if n == 0\n return 2 + bunny(n - 1)\nend", "def exp_1(b, n)\n return 1 if n == 0\n b * exp_1(b, n - 1)\nend", "def bunny(n)\n return 0 if n <= 0\n return 2 if n == 1\n return 2 + bunny(n-1)\nend", "def bunny(n)\n return 0 if n == 0\n return 2 + bunny( n - 1 )\nend", "def bunny(n)\n return 0 if n == 0\n return 2 + bunny(n-1)\nend", "def bunny(n)\n return 0 if n == 0\n return 2 + bunny(n-1)\nend", "def bunny(n) \n return 0 if n == 0\n return 2 + bunny(n - 1)\nend", "def factorialB(n, total=1)\n raise ArgumentError.new(\"Not an integer\") if\n !(n.class==Integer)\n raise ArgumentError.new(\"Not a non-negative integer\") if n < 0\n\n if n==0\n return total\n else\n return factorialB(n-1, n * total)\n end\nend", "def bunny(n)\n return 0 if n == 0\n return 2 + bunny(n-1)\nend", "def bunny(n)\n return 0 if n == 0\n return 2 + bunny(n-1)\nend", "def bunny(n)\n return 0 if n == 0\n return 2 + bunny(n-1)\nend", "def pow2(x, n)\n if n == 0\n return 1\n end\n temp = pow2(x, n/2)\n if n % 2 == 0\n return temp * temp\n else\n return x*temp*temp\n end\nend", "def exp1(b, n)\n return 1 if n == 0\n b * exp1(b, n - 1)\nend", "def factorial_recursive(n)\n if n < 0\n \"Invalid input\"\n elsif n == 0\n 1\n else\n n *= factorial_recursive(n-1)\n end\nend", "def bunny(n)\n return 0 if n == 0\n\n return 2 + bunny(n-1)\nend", "def bunny(n)\n # raise NotImplementedError, \"Method not implemented\"\n return 0 if n == 0\n return 2 + bunny(n - 1)\n\nend", "def bunny(n)\n return 0 if n == 0\n return 2 if n == 1\n return 2 + bunny(n - 1)\nend", "def jacobi(a, n)\n if n == 1\n return 1\n elsif a.zero?\n return 0\n elsif a == 1\n return 1\n elsif a == 2\n if [3, 5].include?(n % 8)\n return -1\n elsif [1, 7].include?(n % 8)\n return 1\n end\n elsif a < 0\n return (-1)**((n - 1) / 2) * jacobi(-1 * a, n)\n end\n\n if a.even?\n return jacobi(2, n) * jacobi(a / 2, n)\n elsif a % n != a\n return jacobi(a % n, n)\n else\n if a % 4 == n % 4 && a % 4 == 3\n return -1 * jacobi(n, a)\n else\n return jacobi(n, a)\n end\n end\nend", "def binomial_coefficient(n,k)\n return 1 if (k==0 or k==n)\n k=[k, n-k].min\n binding.pry\n permutations(n,k).quo(factorial(k))\n # The factorial way is\n # factorial(n).quo(factorial(k)*(factorial(n-k)))\n # The multiplicative way is\n # (1..k).inject(1) {|ac, i| (ac*(n-k+i).quo(i))}\n end", "def bunny(n)\n # raise NotImplementedError, \"Method not implemented\"\n return 2 + bunny(n - 1) unless n.zero?\n return 0 if n.zero?\nend", "def binomial_coefficient(n,k)\n return 1 if (k==0 or k==n)\n k=[k, n-k].min\n permutations(n,k).quo(factorial(k))\n # The factorial way is\n # factorial(n).quo(factorial(k)*(factorial(n-k)))\n # The multiplicative way is\n # (1..k).inject(1) {|ac, i| (ac*(n-k+i).quo(i))}\n end", "def power_of_n(number, power)\n array = [number] * power\n base_number = 1\n array.each do |num|\n base_number = multiply(base_number, num)\n end\n base_number\nend", "def bunny(n)\n return 0 if n == 0\n return 2 if n == 1\n return 2 + bunny(n-1)\nend", "def bunny(n)\n return n if n == 0\n return 2 + bunny(n-1)\nend", "def exp1(b, n)\n return 1 if n == 0\n p b * exp1(b, n - 1)\nend", "def bunny(n)\n return 0 if n < 1\n return 2 if n < 2\n return 2 + bunny(n-1)\nend", "def factorial_recursive(n)\n\tif (n==0)\n\t\treturn 1\n\telse\n\t\t\treturn n*factorial_recursive(n-1)\n\tend\nend", "def factorial_recursive n\n return 1 if n == 0\n n * factorial_recursive(n-1)\nend", "def power_to_the_n(number, power)\n return 1 if power == 0\n result = 1\n while power > 0\n result = multiply(result, number)\n power -= 1\n end\n result\nend", "def wonky_coins(n)\n return 1 if n == 0\n\n # call wonky_coins from inside itself. This is called *recursion*.\n return wonky_coins(n / 2) + wonky_coins(n / 3) + wonky_coins(n / 4)\nend", "def bunny(n)\n if n % 2 == 0\n return 0\n else\n return n + bunny(2-1)\n end\nend", "def factorial(n)\n # Input validation\n raise ArgumentError if n < 0 \n # Base case\n return 1 if n == 0 \n # Recursive case\n return n * factorial(n-1)\nend", "def binomial_coefficient(n, k)\n return 1 if n == k || k == 0\n return n if k == 1\n return -1 if n < k\n\n # calculate factorials\n fact_n = (2..n).inject(1) { |carry, i| carry * i }\n fact_k = (2..k).inject(1) { |carry, i| carry * i }\n fact_n_sub_k = (2..(n - k)).inject(1) { |carry, i| carry * i }\n\n fact_n / (fact_k * fact_n_sub_k)\n end", "def bunny(n)\n return 0 if n == 0\n return 2 if n == 1\n return bunny(n - 1) + bunny(1)\n\nend", "def exp2(b, n)\n return 1 if n == 0\n return b if n == 1\n if n.even?\n partial = exp2(b, n / 2)\n return partial * partial\n else\n partial = exp2(b, (n - 1) / 2)\n return b * (partial * partial)\n end\nend", "def factorial(n)\n\n raise ArgumentError unless n >= 0 \n return 1 if n == 1 || n == 0\n\n n * factorial(n - 1)\n\nend", "def power(nb1, nb2)\n return nb1 ** nb2\nend", "def factorial(n)\n raise ArgumentError if n < 0\n return 1 if n == 1 || n == 0\n return n * factorial(n-1)\nend", "def bunny(n)\n return n if n == 0\n return 2 + bunny(n-1)\n end", "def exp(b,n)\n return 1 if n == 0\n return b if n == 1\n case \n when n > 0 && n.even?\n exp(b,n/2) ** 2\n when n > 0 && n.odd?\n b * exp(b,(n-1)/2)**2\n when n < 0 && n.even?\n exp(1.0/b,n/2) ** 2\n when n < 0 && n.odd?\n 1.0/b * exp(b,(n+1)/2) **2\n end\nend", "def bunny(n)\n return 0 if n == 0\n\n return (2 + (2 * (n - 1)))\nend", "def bunny(n)\n\n return 0 if n == 0\n return 2 if n == 1\n bunny(n - 1) + 2\n\nend", "def binom(n, k)\n return 1 if k.zero? || (n - k).zero?\n return n if k == 1 || n - k == 1\n\n factorial(n) / (factorial(k) * factorial(n - k))\n end", "def factorial(n)\n raise ArgumentError if n < 0\n return 1 if n == 0\n return n * factorial(n-1)\nend", "def factorial(n)\n raise ArgumentError.new if n < 0 \n return 1 if n == 1 || n == 0 \n return n * factorial(n-1)\nend" ]
[ "0.7867685", "0.7708262", "0.76860213", "0.7595162", "0.75813276", "0.7523488", "0.75191253", "0.7430109", "0.7412472", "0.73890454", "0.73381114", "0.73173046", "0.73164076", "0.73164076", "0.73164076", "0.7310674", "0.7285143", "0.72811705", "0.7151168", "0.7126279", "0.71241736", "0.7120184", "0.7104152", "0.70747876", "0.7070633", "0.7029283", "0.7022627", "0.69739217", "0.6971352", "0.6966528", "0.69608223", "0.6943238", "0.69344825", "0.69276255", "0.6914665", "0.6904504", "0.687875", "0.6864744", "0.6849425", "0.68485373", "0.68474334", "0.6845072", "0.6816591", "0.6810241", "0.6805615", "0.6804493", "0.6793833", "0.678319", "0.67808694", "0.677773", "0.6773843", "0.6747774", "0.6744259", "0.674054", "0.6735539", "0.6734953", "0.6732868", "0.67268956", "0.6723226", "0.6723226", "0.67229944", "0.67218816", "0.67200756", "0.67200756", "0.67200756", "0.6690926", "0.6688783", "0.66883266", "0.66772765", "0.6674672", "0.6672853", "0.6670865", "0.66654414", "0.66621584", "0.6662", "0.6658771", "0.66460824", "0.66405237", "0.66231006", "0.66173434", "0.661552", "0.6609242", "0.66043055", "0.6597269", "0.65860784", "0.65851897", "0.65825737", "0.65754944", "0.6573457", "0.656905", "0.65673834", "0.65671486", "0.6566661", "0.6566122", "0.6564069", "0.65624774", "0.6562078", "0.6560448", "0.6560065" ]
0.7718268
2
Write a recursive method that returns the sum of the first n even numbers recursively. Assume n > 0.
def first_even_numbers_sum(n) return 2 if n == 1 2 * n + first_even_numbers_sum(n-1) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def first_even_numbers_sum(n)\n return 2 if n == 1\n 2 * n + first_even_numbers_sum(n-1)\n end", "def first_even_numbers_sum(n)\n\nend", "def first_even_numbers_sum(n)\n\nend", "def recursion(n)\n if n % 2 ==0\n n\n else\n recursion(n + 1)\nend\nend", "def even_num_rec(n)\n n = (0...n).to_a if n.is_a? Integer\n if n == []\n []\n else\n [n[0] * 2] + even_num_rec(n[1..-1])\n end\nend", "def fib_even_sum(n)\n fib_arr = [1, 1]\n sum = 0\n\n until fib_arr[-1] >= n\n fib_arr << (fib_arr[-2] + fib_arr[-1])\n sum += fib_arr[-2] if fib_arr[-2].even?\n end\n\n sum\nend", "def recursiveSumOfEvenNumbers array\n return 0 if array.empty?\n lastNumb = array.pop\n sum = recursiveSumOfEvenNumbers array\n if lastNumb % 2 == 0 then sum += lastNumb end\n return sum\nend", "def sum(n)\n return 1 if n == 1\n\n n + sum(n - 1)\nend", "def sum_even_fibonacci_numbers(num)\n even_fibonacci_numbers = fibonacci_numbers(num).select{|number| number.even?}\n even_fibonacci_numbers.inject(:+)\nend", "def fibs_sum(n)\n return 1 if n == 1 || n == 2\n sum = 0\n sum += (fibs_sum(n - 1) + fibs_sum(n - 2))\n \n \nend", "def rec_sum(n)\n if n == 0\n return 0\n else\n return n + rec_sum(n-1)\n end\nend", "def even_fibs_recursive(num, term1 = 1, term2 = 2, sum = 2)\n \n next_term = term1 + term2\n return sum if next_term >= num\n\n sum += next_term if next_term % 2 == 0\n\n even_fibs_recursive(num, term2, next_term, sum)\n\nend", "def sumOfEvenFibonacciNumbersUnderN(n)\n\n return 0 if n <= 2 \n \n fibonacci = [0,1]\n total = 0\n\n until fibonacci.last >= n\n \tfibonacci << fibonacci.last + fibonacci[-2]\n \ttotal += fibonacci[-1] if fibonacci[-1].even? \n end\n\n total \n\nend", "def sum_to(n)\n # if n < 2\n # 1\n # else\n # n + sum_to(n-1)\n # end\n return 1 if n < 2\n n + sum_to(n - 1)\nend", "def fibs_sum(n)\n return 0 if n == 0\n return 1 if n == 1\n\n fibs_sum(n - 1) + fibs_sum(n - 2) + 1\nend", "def fibs_sum(n)\n return 0 if n == 0\n return 1 if n == 1\n\n fibs_sum(n-1) + fibs_sum(n-2) + 1\nend", "def fibs_sum(n)\n return 0 if n == 0\n return 1 if n == 1\n\n fibs_sum(n-1) + fibs_sum(n-2) + 1\nend", "def fibs_sum(n)\n return 0 if n == 0\n return 1 if n == 1\n\n fibs_sum(n-1) + fibs_sum(n-2) + 1\nend", "def fibs_sum(n)\n return 0 if n == 0\n return 1 if n == 1\n\n fibs_sum(n-1) + fibs_sum(n-2) + 1\nend", "def row_sum_odd_numbers(n)\n starting_odd = (n * (n - 1) / 2) * 2 + 1\n sum_of_odd = 0\n (n).times do\n sum_of_odd += starting_odd\n starting_odd += 2\n end\n sum_of_odd\nend", "def even_fib_sum(n)\n f = ->(x){ x < 2 ? x : f[x-1] + f[x-2] }\n\n value =f[2]\n res = cnt = 0\n while value <= n\n res+=value if value.even?\n cnt+=1\n value=f[cnt]\n end\n res\nend", "def sum_to(n)\n return nil if n<0\n return 1 if n==1\n sum_to(n-1) + n\nend", "def row_sum_odd_numbers(n)\n b = (1..n).sum * 2 - 1\n a = b - 2 * (n - 1)\n (a..b).select{|i| i.odd?}.sum\n\n # # other solution:\n # n ** 3\nend", "def f(n)\n return 1 if n < 2\n return 2 if n == 2\n\n if n % 2 == 1\n return f( (n-1) /2)\n else\n tmp = n / 2\n m = 1\n while tmp % 2 == 0\n m+=1\n tmp = tmp / 2\n end\n return f(tmp) + m* f(tmp-1)\n end\nend", "def nth_even(n)\n (n * 2) - 2\nend", "def nth_even(n)\n (n*2) - (2)\nend", "def sum_even_odd(fake_num); end", "def sum_to(n)\n return nil if n < 1\n return 1 if n == 1\n sum_to(n - 1) + n\nend", "def sum_to(n)\n return nil if n < 1\n return 1 if n == 1\n\n n + sum_to(n - 1) \nend", "def sum_to(n)\n return n if n == 1\n n + sum_to(n-1)\nend", "def fib_sum(n)\n return n if ( 0..1 ).include? n\n ( fib_sum( n - 1 ) + fib_sum( n - 2 ) )\nend", "def sum_to(n)\n return nil if n < 0\n return n if n == 1\n\n n + sum_to(n - 1)\nend", "def f(n)\n return n if n.zero? || n == 1\n f(n - 1) + f(n - 2)\nend", "def sum_to(n)\n\n if n < 1\n return nil\n elsif n == 1\n return 1\n end\n\n n + sum_to(n - 1)\nend", "def sum_to(n)\n return 1 if n == 1\n return nil if n<1\n n + sum_to(n-1)\nend", "def sum_to(n)\n if n == 1\n return 1\n elsif n < 1\n return nil\n end\n\n n + sum_to(n - 1)\nend", "def sum_to(n)\n return n if n == 1 || n == 0\n return nil if n < 0\n n + sum_to(n - 1)\nend", "def fibs_sum(n) # my version\n return 1 if n == 1\n return 2 if n == 2\n\n current = single_fib(n)\n current += fibs_sum(n - 1)\nend", "def sum_even(nums)\n nums.select { |n| n.even? }.inject(&:+)\nend", "def sum_to(n)\n return nil if n < 1\n return n if n == 1\n n + sum_to(n - 1)\nend", "def sum_to(n)\n return nil if n < 1\n return n if n == 1\n \n n + sum_to(n - 1)\nend", "def even_fibonacci_sum(limit)\n fib_seq = fibonacci_sequence(limit)\n sum = 0\n fib_seq.each{|fib_num| fib_num%2 == 0 ? (sum += fib_num) : ()}\n\n return sum\nend", "def even_fibonacci_number(n)\n sum = 0\n fib1 = 0\n fib2 = 1\n while fib2 < n\n temp = fib1\n fib1 = fib2\n fib2+=temp\n sum += fib2 if fib2.even?\n end\n p sum\nend", "def sum_to(n)\n return 1 if n == 1\n return nil if n <= 0\n n + sum_to(n-1)\nend", "def even_fibonacci(n)\n\tif n == 0\n\t\treturn 0\n\telsif n == 1\n\t\treturn 2\n\telse\n\t\treturn 4*even_fibonacci(n-1)+even_fibonacci(n-2)\n\tend\nend", "def sum_to(n)\n return nil if n < 0\n return 0 if n == 0\n n + sum_to(n-1)\nend", "def sum_to(n)\n return nil if n < 0\n return n if n <= 1\n n + sum_to(n - 1) #if n > 0\nend", "def sum_to(n)\n n > 1 ? n + sum_to(n - 1) : n < 1 ? [].first : 1\n end", "def sum_of_even_fibonaccis2(n)\n\tfibs = []\n\tnth = 0\n\tfibs[nth] = fibonacci[nth]\nend", "def row_sum_odd_numbers(n)\n row = 1\n num = 1\n sum = 0\n while row <= n\n row.times do\n if row == n\n sum += num\n end\n num += 2\n end\n row += 1\n end\n return sum\nend", "def tail_sum(n, total = 0)\n return total if n == 0\n\n tail_sum(n - 1, total + n)\nend", "def sum_to(n)\n return n if n == 0\n return nil if n < 0\n n + sum_to(n - 1)\nend", "def fibsum(n)\n\tsum = 0\n\tfib = [1,2]\n\ttest = fib[-1]\n\twhile test <= n:\n\t\tsum += test if test % 2 == 0\n\t\tfib << test + fib[-2]\n\t\tfib.shift\n\t\ttest = fib[-1]\n\tend\n\tp sum\nend", "def sumOfEvenFibonacci(n)\n\t# sum of f(2),f(5),f(8),f(11),f(14),etc is needed. f(5) is 8, f(6) is 13, f(7) is 21\n\tsum = 10\n\tfn2 = 8\n\tfn1 = 13\n\tfn = 21\n\ti = 8\n\twhile (fn < n)\n\t\tif i % 3 == 0 then sum = sum + fn end\n\t\tfn2 = fn1\n\t\tfn1 = fn\n\t\tfn = fn1 + fn2\n\t\ti += 1\n\tend\n\treturn sum\nend", "def fiboEvenSum(number)\n\tsum = 0\n\tpreviousDigit = 1\n\tfiboDigit = 0;\n\n\twhile fiboDigit < number\n\t\ttemp = fiboDigit\n\t\tfiboDigit += previousDigit\n\t\tpreviousDigit = temp\n\t\tif fiboDigit % 2 == 0\n\t\t\tsum += fiboDigit \n\t\tend\n\tend \n\tsum\nend", "def sum_to(n)\n return nil if n <= 0 #negatives and 0\n return 1 if n == 1 #base step\n #inclusive step 1 + sum_to(n)\n n + sum_to(n - 1)\nend", "def sum_func(n)\n if n / 10 == 0\n return n\n else\n return n % 10 + sum_func(n/10)\n end\nend", "def fibonacci_recursive n\n return n if n < 2\n fibonacci_recursive(n-1) + fibonacci_recursive(n-2)\nend", "def sum_of_even(input_array)\n\teven_array = []\n\tinput_array.each do |number|\n\t\tif number%2 == 0\n\t\t\teven_array.push(number)\n\t\tend\n\tend\n\treturn even_array.inject(:+)\nend", "def sum_to(n)\n return nil if n < 0\n return n if n == 0\n n += sum_to(n - 1)\nend", "def sum_to(n)\n return 1 if n == 1\n return nil if n < 1\n n += sum_to(n - 1)\nend", "def even_fibonacci(limit, current, prev, sum = 0)\n return sum if current >= limit\n\n sum += current if (current % 2).zero?\n current, prev = current + prev, current\n even_fibonacci(limit, current, prev, sum)\nend", "def exponent_v2(b, n)\n puts s += 1\n if n == 0 \n return 1\n elsif n == 1 \n return b\n elsif n.even?\n rec = exponent_v2(b, n / 2)\n rec * rec\n else \n rec = exponent_v2(b, (n - 1) / 2)\n b * rec * rec\n end\nend", "def even_fibs_sum(num)\n fibs = [0,1]\n \n while fibs.max < num\n nexty = fibs[-1] + fibs[-2]\n fibs << nexty\n end\n \n sum = 0\n fibs.map {|x| sum += x if x.even? }\n \n return sum\nend", "def sum_of_even_digits(n) #adds every even digit\n n = n.to_s.split(//)\n reverse_cc = n.reverse.values_at(1,3,5,7,9,11,13,15).compact\n sum_evens = 0\n reverse_cc.each do |cc_number|\n doubled = cc_number.to_i * 2\n sum_evens += get_digit(doubled)\n end\n return sum_evens\nend", "def evenLoop(n)\n i = 0\n while i < n*2 do\n return i\n i+=2\n end\nend", "def sum(n)\n end", "def sum(n, m)\n if n > m\n return 0\n else\n return sum(n+1, m) + n\n end\nend", "def sum_to(n)\n (1..n).reduce(0) do |sum, value|\n sum + value\n end\nend", "def fib2(n)\n if n < 2\n n\n else\n fib2(n - 1) + fib2(n - 2)\n end\nend", "def oddCount n \r\n if (n % 2 == 0)\r\n return n / 2\r\n end\r\n return (n - 1) / 2\r\n end", "def problem2(num)\n f = [1,2]\n f.push(f[-2..-1].reduce(:+)) until f[-1] >= num\n f.select{|n| n.even?}.reduce(:+)\nend", "def fibonnaci_even(limit)\n fibonnacci = [1, 1]\n (1...limit).each { fibonnacci << fibonnacci.last(2).sum }\n fibo_even = fibonnacci.select { |num| num.even? }.sum\nend", "def sum_of_n_consecutive_numbers (n)\n n*(n+1)/2\nend", "def row_sum_odd_numbers(n)\n # (1..n).each_with_object([]) { |row, obj| obj << }\n # .at(n - 1)\n # arr = Array.new(n, 0)\n # num = 1\n # n.times do |x|\n \n # arr[x] += num\n # num += 2\n # end\n # arr\n min = n * (n - 1) + 1\n max = n * n + (n - 1)\n (min..max).reject(&:even?).inject(:+)\nend", "def evenLoop(n)\n total = n * 2\n for x in 1..total\n if x % 2 == 0\n x\n end\n end\nend", "def s1(n)\n if n.even? then 0\n else 1 end\nend", "def odd_nums_r (bound=99, n=3)\n if n <= bound\n puts n\n odd_nums_r(bound, n + 1)\n end\nend", "def even_valued_number(x)\n fib_array = [0,1]\n x.times do\n fib_array << fib_array[-1] + fib_array[-2]\n end\n fib_array.find_all{ |number| number % 2 == 0}.reduce(:+)\nend", "def bunny(n)\n # base case\n return 0 if n == 0\n # recursive case\n return 2 + bunny(n-1)\nend", "def fibs(n)\n return n if n <= 1\n fibs(n - 1) + fibs(n - 2)\nend", "def exp_2(b, n)\n return 1 if n == 0\n return b if n == 1\n\n even_rec = exp_2(b, n / 2) # if n.even?\n odd_rec = exp_2(b, (n - 1) / 2) # if n.odd?\n\n if n.even?\n even_rec * even_rec\n # exp(2, 8)\n # => [ exp(2, 4) ] * [ exp(2, 4) ]\n # => [ exp(2, 2) * exp(2, 2) ] * [ exp(2, 2) * exp(2, 2) ]\n # => [ exp(2, 1) * exp(2, 1) * exp(2, 1) * exp(2, 1) ] *[ exp(2, 1) * exp(2, 1) * exp(2, 1) * exp(2, 1) ]\n # => [ b * b * b * b * b * b * b * b ]\n else # n == odd\n b * odd_rec * odd_rec\n # => exp(2, 7)\n # => b * [ exp(2, 3) ] * [ exp(2, 3) ]\n # => b * [ b * exp(2, 1) * exp(2, 1) ] * [ b * exp(2, 1) * exp(2, 1) ]\n # => b * [ b * b * b ] * [ b * b * b ]\n end\n\nend", "def sum(n)\n result = 0\n n.each do |number|\n result = result + number\n end\n return result\n end", "def bunny(n)\n # base case\n return 0 if n == 0\n # recursive case\n return 2 + bunny(n - 1)\nend", "def fun1 n\n return 0 if n == 1\n return 1 + fun1(n/2)\nend", "def sum_numbers(arr, n)\n sum = 0\n index = 0\n\n arr.each do |i|\n if index != n \n sum += i\n else\n return sum\n end\n\n index += 1\n end\nend", "def sum_of_even_fibonaccis(limit)\n\n holder = [1,2]\n\n while ( holder[-1] + holder[-2] ) < limit\n holder << holder[-1] + holder[-2]\n end\n\n return holder.select { |n| n.even? }.reduce(:+)\n\nend", "def nth(n)\n\tif n <= 0 \n\t\treturn 0 \n\tend \n\tif n == 1\n\t\treturn 17 \n\telse \n\t\treturn nth(n-1) + 5 \n\tend \nend", "def square_sum_up_to n=100\r\n (n * (n + 1) / 2)**2\r\nend", "def even(n)\n n % 2 == 0\nend", "def even_fibonacci_sum(limit)\n array = [0, 1]\n array << (array[-1] + array[-2]) while (array[-1] + array[-2]) < limit\n array.select(&:even?).reduce(:+)\nend", "def bunny(n)\n if n % 2 == 0\n return 0\n else\n return n + bunny(2-1)\n end\nend", "def even_fibonacci(number)\n even_sum = 0\n fib1 = 1\n fib2 = 2\n fib_count = 0\n\n if number < 3\n even_sum = 0\n else\n while fib_count < number\n if fib2 % 2 === 0\n even_sum += fib2\n end\n fib_count = fib1 + fib2\n fib1 = fib2\n fib2 = fib_count\n end\n end\n\n puts even_sum\n return even_sum\nend", "def fib(n)\n if n<2\n return n\n else\n return fib(n-2)+fib(n-1)\n end\nend", "def fibonacci_recur(n)\n return 0 if n == 1\n return 1 if n == 2\n\n fibonacci_recur(n - 1) + fibonacci_recur(n - 2)\nend", "def next_step(n)\n if n.even?\n n/2.to_i\n else\n 3*n+1\n end\nend", "def square_of_sum(n)\n sum = 0\n (1..n).each {|i| sum = sum + i}\n sum * sum\n end", "def exponentiation_2(b, n)\n return 1 if n == 0\n return b if n == 1\n\n if n.even?\n exponentiation_2(b, n / 2) ** 2\n else\n b * (exponentiation_2(b, (n - 1) / 2) ** 2)\n end\nend", "def fib(n)\n\treturn n if (n < 2)\n\treturn fib(n - 1) + fib(n - 2)\nend", "def row_sum_odd_numbers(n)\n\tn**3\nend" ]
[ "0.88773525", "0.8361318", "0.8361318", "0.7575595", "0.7511886", "0.7442943", "0.7334038", "0.73173136", "0.7249176", "0.72258985", "0.72222763", "0.72195196", "0.71986216", "0.7167344", "0.71563643", "0.71517795", "0.71517795", "0.71517795", "0.71517795", "0.7151437", "0.7128636", "0.71247786", "0.7121537", "0.71168274", "0.71002984", "0.71000046", "0.70949805", "0.7062453", "0.7054256", "0.7053261", "0.7040451", "0.7039255", "0.70372057", "0.70325744", "0.7026855", "0.7022136", "0.7006043", "0.7005452", "0.6991958", "0.69901", "0.69779074", "0.6974072", "0.6971203", "0.69682837", "0.69649476", "0.69111085", "0.69088036", "0.68669075", "0.68487936", "0.6848366", "0.68473506", "0.684624", "0.6845727", "0.684456", "0.6804366", "0.6795059", "0.6794382", "0.6791501", "0.67809254", "0.67671454", "0.67667705", "0.67528373", "0.67500556", "0.6713371", "0.6704637", "0.66989696", "0.6696767", "0.6693497", "0.66880625", "0.6687121", "0.6683846", "0.668195", "0.666303", "0.666002", "0.66579854", "0.6654384", "0.66543204", "0.66252124", "0.6620089", "0.66193044", "0.6617569", "0.66101855", "0.6605983", "0.6602134", "0.6597752", "0.6594727", "0.6591929", "0.65903735", "0.65515167", "0.6549388", "0.6544647", "0.65441424", "0.6542762", "0.6541645", "0.65396345", "0.65210074", "0.65185946", "0.6517671", "0.6514964", "0.6512657" ]
0.88209176
1
Write a recursive method `string_include_key?(string, key)` that takes in a string to search and a key string. Return true if the string contains all of the characters in the key in the same order that they appear in the key. example_1: string_include_key?("cadbpc", "abc") => true example_2: string_include_key("cba", "abc") => false
def string_include_key?(string, key) return true if key.length == 0 next_key_char = key.chars.first key_index = string.index(next_key_char) return false if key_index.nil? string_include_key?(string[key_index+1..-1], key[1..-1]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def string_include_key?(string, key)\n return true if key == \"\"\n string.each_char.with_index do |char, idx|\n if char == key[0]\n return string_include_key(string[(idx + 1)..-1], key[1..-1])\n end\n end\n\n false\nend", "def string_include_key?(string, key)\n return true if key.length == 0\n return false if string.length == 0\n\n if string[0] == key[0]\n string_include_key?(string[1..-1], key[1..-1])\n else\n string_include_key?(string[1..-1], key)\n end\nend", "def string_include_key?(string, key)\n str_arr = string.split(\"\")\n key_arr = key.split(\"\")\n return true if key.length == 1 && str_arr.include?(key_arr.first)\n str_arr.each_index do |i|\n if str_arr[i] == key_arr.first\n bool = string_include_key?(str_arr.drop(i+1).join(\"\"), key_arr.drop(1).join(\"\"))\n if bool\n return true\n end\n end\n end\n false\n end", "def string_include_key?(string, key)\n return false if string.length < key.length\n key.each_char do |ele|\n return true if string.include?(ele)\n end\n\n \nend", "def string_include_key?(string, key)\n return true if string == key\n l = string.length\n k_l = key.length\n i = 0\n while i < (l - k_l)\n # return true if string[i ... i + k_l] == key\n return true if string_include_key?(string[i ... i+k_l], key)\n # val = string_include_key?(string[0 ... i], key)\n i += 1\n end\n false\nend", "def string_include_key?(string, key)\n \nend", "def string_include_key?(string, key)\n \nend", "def string_include_key?(string, key)\n \nend", "def item_included?(str, hash)\n hash.each do |key, value|\n return true if key == str\n end\n false\nend", "def include?(key)\n self.each_key.any? { |k|\n k.casecmp?(key)\n }\n end", "def contains(string)\n node = self.root\n string.each_char { |letter|\n if !node.has_key?(letter)\n return false\n end\n node = node[letter]\n }\n\n return node.has_key?(end_symbol)\n \n end", "def custom_include?(str, substr)\n # return true if substring is found anywhere\n # within the string. Return false otherwise.\n len = substr.length\n str.chars.each_with_index do |char, idx|\n return true if str[idx, len] == substr\n end\n false\nend", "def include?(searchstring, substring)\n\nend", "def in_all_strings?(long_strings, substring)\n long_strings.all?{ |el| el.include?(substring)}\nend", "def in_all_strings?(long_strings, substring)\n long_strings.each do |string|\n return false unless string.include?(substring)\n end\n\n return true\nend", "def find_match(key, value, key_str, search_str)\n \tif value.kind_of?(Array)\n \t\tvalue.each do |element_value|\n \t\t\t#puts \"key: \" + key + \", element_value: \" + element_value\n \t\t\tif (find_match(key, element_value, key_str, search_str))\n \t\t\t\treturn true\n \t\t\tend\n \t\tend\n\telsif value.kind_of?(Hash)\n\t\tvalue.each do |element_key, element_value|\n\t\t\tif (find_match(element_key, element_value, key_str, search_str))\n\t\t\t\treturn true\n\t\t\tend\n\t\tend\n\telse\n\t\tif (key == key_str && value.to_s == search_str)\n\t\t\treturn true\n\t\tend\n\tend\n\treturn false\n end", "def in_all_strings?(long_strings, substring)\n long_strings.all?{|str|str.include?(substring)}\n\nend", "def in_all_strings?(long_strings, substring)\n long_strings.all? { |string| string.include?(substring) }\nend", "def in_all_strings?(long_strings, substring)\n long_strings.all? { |string| string.include?(substring) }\nend", "def unlock(str)\n key = {\n 2 => ['a', 'b', 'c'],\n 3 => ['d', 'e', 'f'],\n 4 => ['g', 'h', 'i'],\n 5 => ['j', 'k', 'l'],\n 6 => ['m', 'n', 'o'],\n 7 => ['p', 'q','r', 's'],\n 8 => ['t', 'u', 'v'],\n 9 => ['w', 'x', 'y', 'z']\n }\n\n output = []\n str.downcase.chars.each {|x| key.any? {|k,v| output << k if v.include? x} }\n output.join\n\nend", "def in_all_strings?(long_strings, substring)\n long_strings.all? {|x| x.include?(substring) }\nend", "def in_all_strings?(long_strings, substring)\n long_strings.all? {|string| string.include?(substring)}\nend", "def in_all_strings?(long_strings, substring)\n long_strings.all? {|word| word.include?(substring)}\nend", "def in_all_strings?(long_strings, substring)\n new_arr = long_strings.select {|s| s.include?(substring)}\n return new_arr == long_strings\nend", "def string_include?(val)\n return false if !val.is_a?(String)\n ret = false\n for a in self\n ret = true if a.is_a?(String) && val.include?(a)\n end\n return ret\n end", "def include?(key); end", "def include?(key); end", "def wordInStrings(word, strings)\n for string in strings do\n\n if string.include? word\n return true\n end\n end\n\n return false\nend", "def include_key?(key)\n\t\t\ttrue\n\t\tend", "def sequence_search(seq, key)\n seq_array = seq.split(\"\")\n key_array = key.split(\"\")\n key_i = 0\n seq_array.length.times do |j|\n if seq_array[j] == key_array[key_i] \n key_i += 1\n if key_i == key_array.length \n return true\n end\n\n end\n end\n return false\nend", "def check_str(str,s)\n if str.include?s\n puts \"true\"\n else\n puts \"false\"\n end\nend", "def my_include?(dict, query)\n dict.each do |valid_word|\n if valid_word == query\n return true\n end\n end\n return false\nend", "def found_match(str)\n\tif dictionary.include?(str) # returns true if found in the dictionary\n\t\treturn str # don't stop the recursion, but return the word ?\n\tend\n\tfalse\nend", "def string_check(elem)\n (('a'..'z').to_a + ('A'..'Z').to_a).each { |k| return true if elem.include?(k) }\n false\n end", "def in_all_strings?(long_strings, substring)\n long_strings.all? { |long_string| sub_string?(long_string, substring) }\nend", "def in_all_strings?(long_strings, substring)\n long_strings.all? {|el| sub_string?(el, substring)}\nend", "def key?(key)\n keys.include?(key) || keys.map(&:to_s).include?(key)\n end", "def key?(key)\n keys.include?(key) || keys.map(&:to_s).include?(key)\n end", "def str_includes(str1, str2)\n if str2.downcase.include?(str1.downcase)\n true\n else\n false\n end\nend", "def contains?(string)\n node = @root\n string.each_char do |letter|\n return false unless node[letter]\n node = node[letter]\n end\n\n node[@end_symbol] ? true : false\n end", "def include?(key)\n @hash.has_key?(key.to_s)\n end", "def in_all_strings?(long_strings, substring)\n count = 0\n long_strings.each do |string|\n if sub_string?(string, substring)\n count += 1\n end\n end\n\n count == long_strings.length\nend", "def item_include?(array, string)\n match = false\n array.each do |el|\n if el == string\n match = true\n end\n end\n match\nend", "def matches?(config_array, content_string)\n config_array.each { |key| return true if /#{key}/.match(content_string) } unless config_array.nil?\n false\n end", "def include?(key)\n Options.check_valid_key(key)\n @data.include?(key.to_sym)\n end", "def in_all_strings?(long_strings, substring)\n long_strings.map do |str|\n str.split.any?(substring)\n end.all?(true)\nend", "def in_all_strings?(long_strings, short_string)\n long_strings.all? do |long_string|\n long_string.include?(short_string)\n end\nend", "def include?(key)\n has_key?(key)\n end", "def include?(key)\n value.include?(key)\n end", "def include_str_ary?(instr_ary)\n last_match = 0\n found = 0\n instr_ary.each do |instr|\n self[last_match..-1].each_with_index do |g_ins, idx|\n if g_ins.to_s.index instr\n found += 1\n last_match += idx + 1\n break\n end\n end\n end\n found == instr_ary.size\n end", "def is_string_contains_another_string?(char_string, char_set)\n (char_string.sub(char_set, '**').index('**') ? true : false) if(valid_strings?(char_string, char_set))\nend", "def match_string( tree, string )\n # puts \"Checking for `#{string}` in tree (#{tree}).\"\n\n if tree.empty?\n # puts \"Tree is empty, returning empty\"\n return [ ]\n\n elsif string.empty?\n # puts \"No search string, returning empty\"\n return [ ]\n\n else\n matches = [ ]\n\n tree.each do |key,val|\n # puts \"Checking for `#{string}` in `#{key}` branch.\"\n\n simdex = string.simdex(key)\n\n if 0 < simdex\n if string == key\n # puts \"Matched full word! #{string} is #{key}\"\n # matches = collect_keys(val, key).unshift(key)\n return collect_keys(val, key).unshift(key)\n # puts \"Got matches: #{matches}\"\n\n else\n leaf = string.leaf(simdex)\n # puts \"Got leaf #{leaf}\"\n\n check = match_string(val, leaf)\n # puts \"Got check: #{check}\"\n\n if !check.empty?\n # matches = (check.map { |m| key + m })\n return check.map { |m| key + m }\n # puts \"New matches: #{matches}\"\n end\n end\n\n # break\n\n else\n check = match_string(val, string)\n\n if !check.empty?\n matches += check\n end\n end\n end\n\n # if matches.empty?\n # # puts \"No matches (#{string})\"\n # else\n # # puts \"Returning matches (#{string}): #{matches}\"\n # end\n\n return matches\n end\n end", "def in_all_strings?(long_strings, short_string)\nend", "def item_included?(str, arr)\n arr.each do |item|\n return true if item == str\n end\n false\nend", "def match?(string)\n bigrams = get_bigrams(string)\n while bigrams.length > 1\n pair = bigrams.shift\n return true if bigrams[1..-1].include?(pair)\n end\nend", "def includes?(array, target)\n array.each do |k, v|\n if k == key\n return true\n elsif v.class.to_s == \"Array\"\n v.each do |inner_array|\n return has_key(inner_array, key)\n end\n else\n return false\n end\n end\n\nend", "def validate_string(string)\n stack = []\n lookup = { '(' => ')', '[' => ']', '{' => '}', '<' => '>' }\n left = lookup.keys\n right = lookup.values\n\n string.each_char do |char|\n if left.include? char\n stack << char\n elsif right.include? char\n return false if stack.empty? || (lookup[stack.pop] != char)\n end\n end\n\n return stack.empty?\nend", "def valid_key?(match_data)\n match_data[:key].to_i == (97 - match_data[1..-2].join.to_i) % 97\nend", "def custom_includee(string, substring)\n string.split(substring).length != 1\nend", "def permutations?(string1, string2) \n hash = {}\n if string1.length == string2.length\n string2.each_char do |char|\n if string1.include?(char)\n if hash[char] == true\n repeated = char+char\n hash[repeated] = true\n else \n hash[char] = true\n end\n else \n hash[char]= false\n end\n end\n else \n return false\n end\n\n occurences = 0\n hash.keys.each do |key|\n if hash[key] == true\n occurences +=1\n end\n end\n\n if occurences == string1.length\n return true\n else \n return false\n end\n\nend", "def str_include?(str, target_str)\n tmp = target_str.downcase\n if !!str.match(/#{tmp}/i)\n return true\n else\n return false\n end\n end", "def include?(key)\n current = @head\n while current.next_node != nil\n return true if current.value == key\n current = current.next_node\n end\n\n return true if current.value == key\n\n false\n end", "def contains_expected_keys?(data, *expected_keys)\n expected_keys.each do |expected_key|\n return false until data.keys.include? expected_key\n end\n return true\nend", "def repeating_letters?(str)\r\n # your code goes here\r\n str = str.downcase.split(\"\")\r\n temp = \"\"\r\n i = 0\r\n while i < str.length\r\n if temp.include?(str[i])\r\n return true\r\n else\r\n temp << str[i]\r\n end\r\n i += 1\r\n end\r\n false\r\nend", "def string_has_all_letters(str)\n result = {}\n str.each_char do |c|\n return true if result.length == 26\n if c == \" \"\n next\n elsif !result.include?(c)\n result[c] = c\n end\n end\n result.length == 26 ? true : false\nend", "def contains_string(given, string_array)\n is_present = false\n string_array.each do |file_name|\n is_present = true if given.downcase.include? file_name.downcase\n end\n\n is_present\nend", "def is_substring?(string1, string2)\n return true if string2.empty?\n return false if string2.length > string1.length\n\n string2_matchings = 0\n\n string1.each_char do |string1_char|\n if string2_matchings.zero?\n if string1_char == string2[0]\n string2_matchings += 1\n end\n else\n if string1_char == string2[string2_matchings]\n string2_matchings += 1\n else\n string2_matchings = 0\n end\n\n if string2_matchings == string2.length\n return true\n end\n end\n end\n\n false\nend", "def contains(input, substr)\n input.include?(substr) ? true : false\n end", "def contain_substrings?(str, sub1, sub2)\n sub1_length = sub1.size\n sub2_length = sub2.size\n start_idx_sub1 = 0\n start_idx_sub2 = 0\n sub1_found_idxs = []\n sub2_found_idxs = []\n\n 0.upto(str.size - 1) do |current_idx|\n # Find all indexes of sub1 in str\n if str[start_idx_sub1..current_idx] == sub1\n sub1_found_idxs << start_idx_sub1\n start_idx_sub1 = current_idx + 1\n elsif current_idx - start_idx_sub1 >= sub1_length - 1\n start_idx_sub1 += 1\n end\n\n # Find all indexes of sub2 in str\n if str[start_idx_sub2..current_idx] == sub2\n sub2_found_idxs << start_idx_sub2\n start_idx_sub2 = current_idx + 1\n elsif current_idx - start_idx_sub2 >= sub2_length - 1\n start_idx_sub2 += 1\n end\n end\n\n result(sub1_found_idxs, sub1_length, sub2_found_idxs, sub2_length) ? 'YES' : 'NO'\nend", "def is_in(char, a_str)\n\n a_str = a_str.chars.sort(&:casecmp).join\n length = a_str.length\n mid = length / 2\n if a_str == ''\n p false\n elsif a_str.length == 1\n a_str == char\n elsif char == a_str[mid]\n p true\n elsif char < a_str[mid]\n is_in(char, a_str[0..(mid-1)])\n else\n is_in(char, a_str[(mid+1)..-1])\n end\nend", "def common_substrings(string1, string2)\n string2.downcase.chars.each do |char|\n return false if string2.count(char) > string1.downcase.count(char)\n end\n true\nend", "def include?(key)\n return false unless @data.is_a?(Hash)\n\n @data.include?(compatible_key(key))\n end", "def in?(key)\n start_slot = hasher(key, @keys.size)\n position = start_slot\n found = false\n\n while @keys[position] != nil and !found\n if @keys[position] == key\n found = true\n else\n position = rehash(position, @keys.size)\n break if position == start_slot\n end\n end\n\n found\n end", "def is_a_partial_string?(containing_string, potentially_partial_string)\n return (containing_string.size > potentially_partial_string.size and containing_string.include?(potentially_partial_string) )\n end", "def isRepeated? subString, str\n\n if str.length % subString.length != 0 then return false end\n\n n = subString.length\n max_repetitions = str.length / n\n (0...max_repetitions).each do |i|\n if str[n*i, n] != subString then return false end\n end\n return true\nend", "def key_in_map?(arr,key)\n if arr.empty?\n return false\n else\n if arr[0][0] == key\n return true \n else\n key_in_map?(arr[1..-1], key)\n end\n end\n end", "def permut_sub_strings(b, s)\n hash = {}\n permutations(s).each do |str|\n hash[str] = true\n end\n for i in 0..b.size-s.size\n if (hash.key?(b[i..i+s.size]))\n return true\n end\n end\nend", "def substring_of_string(string, substring)\n sub_i = 0\n\n string.each_char.with_index do |char, i|\n if substring[sub_i] == char\n return true if sub_i == substring.length - 1\n sub_i += 1\n else\n if substring[0] == char\n sub_i = 1\n else\n sub_i = 0\n end\n end\n end\n\n false\nend", "def custom_start_with?(string, substring)\n array_of_strings = string.split(\" \")\n array_of_strings.first == substring ? true : false\nend", "def StringScramble(str1,str2)\n x = str1.chars\n y = str2.chars\n y.each do |s|\n \t# if i use return true if x.include?(s)\n \t# it doesn't work, why????????????????\n \t# since it will return true once if finds a match\n \t# then the function will stop running. \n \t return false if !x.include?(s) \n end\n return true \nend", "def contains_char(string, char)\n i = 0\n while i < string.length\n if string[i] == char\n return true\n end\n i += 1\n end\n return false\nend", "def first_anagram?(str1, str2)\r\n anagram_helper(str1).include?(str2) \r\n\r\nend", "def find_perm(key_str)\n key_arr = key_str.chars\n sorted_arr = key_arr.sort\n permut = key_arr.size.times.to_a.permutation.select do |perm|\n sorted_arr.values_at(*perm) == key_arr\n end.flatten\nend", "def substring_test(str1, str2)\n str1.chars.each_index do |i|\n (i + 1).upto(str1.length) do |n|\n return true if str2.downcase.include?(str1[i..n].downcase) && str1[i..n].length > 1\n end\n end\n false\nend", "def has_key?( key )\n key = UniMap.str_to_key( key ) unless key.is_a?( Key )\n key && contains_key( key )\n end", "def contain_substr(input, substr)\n input.include?(substr) ? true : false\n end", "def closest_string_in_front(key_string, sub_string)\n\n\t\tpositions = []\n\t\tlast_pos = nil\n\t\tmy_string = \" \" + to_str\n\t\tkey_pos = my_string.index(key_string)\n\t\tif key_pos.nil?\n\t\t\t#puts \"WARNING: closest_string_in_front PASSED A string THAT DID NOT INCLUDE key_string\"\n\t\t\treturn nil\n\t\telse\n\t\t\tmy_string = my_string.slice(0..key_pos+1)\n\t\tend\n\n\t\twhile (last_pos = my_string.index(sub_string, (last_pos ? last_pos + 1 : 0)))\n\t\t\tpositions << last_pos\n\t\tend\n\n\t\tif positions != []\n\t\t\treturn_string = my_string[key_pos-positions.map{|p| (p-key_pos).abs}.min..key_pos-1]\n\t\t\treturn return_string.match(sub_string).to_s\n\t\telse\n\t\t\treturn nil\n\t\tend\n\tend", "def check_inclusion(s1, s2)\n\treturn false if s1 == '' || s2 == ''\n\tk = s1.size\n\tn = s2.size\n h1 = {}\n # Store all elements of string p in hash h1.\n for i in 0..k-1 do\n \tif h1[s1[i]]\n \t\th1[s1[i]] = h1[s1[i]] + 1\n \telse\n \t\th1[s1[i]] = 1\n \tend\n end\n h2 = {}\n j = 0\n # Traverse each substring of length k.\n # Store elements of substring upto k length in hash h2.\n for i in 0..n-k do \t\n \twhile j < i+k do\n \t\tif h2[s2[j]]\n \t\t\th2[s2[j]] = h2[s2[j]]+1\n \t\telse\n \t\t\th2[s2[j]] = 1\t\n \t\tend\n \t\tj = j+1\n \tend\n \t# Return true if h1 equals to h2\n \treturn true if h1 == h2\n \t# After traversing, i will be i+1, so remove ith key from hash.\n \tif h2[s2[i]] > 1\n \t\th2[s2[i]] = h2[s2[i]] - 1\n \telse\n \t\th2.delete(s2[i])\n \tend\n end\n # Return false if all elements are traversed i.e permutation not found in string.\n return false\nend", "def contains?(key)\n position = search(key)\n (key <=> @keys[position]) == 0\n end", "def arr_in_phrase? (arr, string)\n\t#might be unefficient to recreate the reg each time, maybe better to return a regex?\n\treg = arr.map {|str| Regexp.escape(str)}\n\treg = /#{arr.join(\"|\")}/ \n\treturn reg === string\nend", "def in_all_strings?(long_strings, short_string)\n # sliding window\n\n # check each long_string\n long_strings.each do |s|\n in_string = false\n n = s.length - short_string.length\n\n # check each substring of a long string\n # if equal to short string\n (0..n).each do |i|\n # if we encounter the shortstring in the substring\n # then we should move on to the next long string\n if s.slice(i, short_string.length) == short_string\n in_string = true\n break\n end\n end\n # if we didn't find a substring in this long string\n # then we know that not all substrings are in the long string\n if in_string == false\n return false\n end\n end\n\n true\nend", "def contains_char(s1, s2)\n i = 0\n output = false\n while i < s1.length\n if s1[i] == s2\n output = true\n end\n i += 1\n end\n return output\nend", "def key_word?(line)\n k_list = [\n /^Skills:.*/ ,\n /^Note:.*/ ,\n /^Talents:.*/ ,\n /^Trappings:.*/ ,\n /^Career Entries:.*/ ,\n /^Career Exits:.*/ ,\n /^Career.*/ ,\n /^\\*.*/ ,\n ]\n ret = false\n k_list.each do |reg|\n if (line =~ reg)\n ret = true\n end\n end\n return ret\nend", "def include?(key)\n\t\tself.keywords.include?(key)\n\tend", "def contains?(key)\n @key_data.has_key?(key)\n end", "def matches?(input_string)\n @word_list.include? input_string\n end", "def strCheck(arr, str)\n arr.each do |i|\n if str == i\n return true\n end\n end\n return false\nend", "def solve(inp_str, bag_hash)\n\treturn bag_hash.select{ | k, v | v.include?(inp_str)}\nend", "def hash_query(search_str, arr, search_key, return_key)\n\tif arr != nil\n\t\tarr.find {|hash| hash[search_key] == search_str}[return_key]\n\tend\nend", "def include?(key)\n # Ensure a Ruby true is returned\n item_exists(key) == true\n end" ]
[ "0.89874685", "0.8913823", "0.8888482", "0.87212694", "0.85243636", "0.82422984", "0.82422984", "0.82422984", "0.66606194", "0.66560686", "0.63048655", "0.62778956", "0.6241291", "0.6210503", "0.6195383", "0.61917645", "0.61839944", "0.61603725", "0.61597145", "0.6120425", "0.61081225", "0.6101802", "0.60700524", "0.6017185", "0.59935445", "0.5990762", "0.5990762", "0.5981463", "0.5967458", "0.59591395", "0.59369504", "0.5907111", "0.5893163", "0.5862444", "0.5839395", "0.5825556", "0.58054155", "0.58054155", "0.5801224", "0.5795417", "0.5793607", "0.5759641", "0.57433826", "0.57371867", "0.5706169", "0.56835073", "0.5678196", "0.5666677", "0.5656333", "0.5653743", "0.56380737", "0.56221", "0.5619683", "0.5616663", "0.55859476", "0.5576114", "0.5564213", "0.55600655", "0.5559274", "0.55428743", "0.5529439", "0.5517187", "0.5514146", "0.5513247", "0.5512521", "0.54826295", "0.5466009", "0.54561913", "0.54408973", "0.54398847", "0.5437534", "0.5436967", "0.5430749", "0.54199624", "0.54174906", "0.54078066", "0.54046094", "0.53960377", "0.53959584", "0.5394107", "0.53931093", "0.53920686", "0.537777", "0.5370858", "0.53703797", "0.53670394", "0.5358913", "0.5356548", "0.53540313", "0.535126", "0.53297275", "0.5323336", "0.5322209", "0.5315251", "0.5297638", "0.52976066", "0.5290738", "0.5287125", "0.5283073", "0.52816015" ]
0.87752384
3
Write a recursive method that returns the first "num" factorial numbers in ascending order. Note that the 1st factorial number is 0!, which equals 1. The 2nd factorial is 1!, the 3rd factorial is 2!, etc.
def factorials_rec(num) return [1] if num == 1 facs = factorials_rec(num - 1) facs << facs.last * (num - 1) facs end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def first_factorial(num)\n if num < 2\n return 1\n else\n return num * first_factorial(num - 1)\n end\nend", "def FirstFactorial(num)\n if num > 1\n return num*(FirstFactorial(num-1)) \n end\n return num \nend", "def factorialrecursion num\n\tif num < 0\n\t\tnil\n\tend\n\t\n\tif num <= 1\n\t\t1\n\t\telse\n\t\t\tnum * factorial(num - 1)\n\t\tend\n\tend", "def factorial(num)\n\tif num <= 1\n\t\treturn 1\n\telse\n\t\tnum * factorial(num - 1)\n\tend\nend", "def FirstFactorial(num, a = 1)\n if (num == 1)\n return a\n end\n\n return FirstFactorial(num-1, a*num)\n \nend", "def FirstFactorial(num)\n result = 1\n \n while num > 1\n result *= num\n num -= 1\n end\n \n return result\nend", "def getFactorial(num)\n if (num == 1)\n sum = 1\n else\n sum = getFactorial(num-1)*num\n end\n return sum\nend", "def factorial(num)\n if num == 1\n 1\n else\n num * factorial(num - 1)\n end\nend", "def factorial(num)\n if num <= 1\n 1\n else\n num * factorial(num-1)\n end\nend", "def factorial(num)\n if num < 2 \n return 1\n end \n fac = num * factorial(num - 1)\nend", "def factorial num\n\tfactorial = 1\n\twhile num > 0\n\t\tfactorial *= num\n\t\tnum -= 1\n\tend\n\treturn factorial\nend", "def factorial_recursive(num)\n if num == 0\n 1\n else \n num * factorial_recursive(num-1)\n \n # 7 * 6 = 42\n # 42 * 5 = 210\n # 210 * 4 = 840\n # 840 * 3 = 2520\n # 2520 *2 = 5040\n # 5040* 1 = 5040\n end\nend", "def FirstFactorial(num)\n product = 1\n for x in num..1\n product *= x\n end\n return product\nend", "def factorial(num)\n\tfactor = 1\n\tfact = [0]\n\tif num == 0\n\t\tfactor\n\telse\n\t\tnum.times do |i|\n\t\t\tfact[i] = i+1\n\t\tend\n\t\tp fact\n\t\t(num-1).times do |i|\n\t\t\tfactor = factor * fact[i+1]\n\t\tend\n\t\tfactor\n\tend\nend", "def factorial(num)\n if num == 0\n 1\n else\n num * factorial(num - 1)\n end\nend", "def FirstFactorial(num)\n (1..num).reduce(:*) || 1\nend", "def factorial(num)\n if num > 0\n #until num == 1\n return num * factorial(num - 1)\n else\n return 1\n end\nend", "def first_factorial(num)\r\n (1..num).reduce(&:*)\r\nend", "def factorials_rec(num)\n if num == 1\n [1]\n else\n facs = factorials_rec(num - 1)\n facs << facs.last * (num - 1)\n facs\n end\nend", "def factorials_rec(num)\n if num == 1\n [1]\n else\n facs = factorials_rec(num - 1)\n facs << facs.last * (num - 1)\n facs\n end\nend", "def factorials_rec(num)\n if num == 1\n [1]\n else\n facs = factorials_rec(num - 1)\n facs << facs.last * (num - 1)\n facs\n end\nend", "def factorial(num)\n return 1 if num == 1\n num * factorial(num - 1)\nend", "def factorial(num)\n\treturn nil if num < 0\n\treturn 1 if num.equal?(0)\n\ti = 1\n\ttotal = 1\n\tnum.times do\n\t\ttotal *= i\n\t\ti += 1\n\tend\n\treturn total\nend", "def factorial(num)\n\tif num != 1\n\tputs num \n\n\tnum * factorial(num-1)\n\telse \n\treturn 1\n\tend\t\n\n\nend", "def factorial_recursive(num = 0)\n # this is a guard clause\n return \"Can not calculate factorial of a negative number\" if num < 0\n\n if num <= 1\n 1 # this is our base case\n else\n num * factorial_recursive(num - 1) # this is where the recursion happens\n end\nend", "def factorials_rec(num)\n if num == 1\n [1]\n else\n factorial = factorials_rec(num - 1)\n factorial << (num - 1) * factorial[-1]\n end\nend", "def factorials_rec(num)\n if num == 1\n return [1]\n else\n facs = factorials_rec(num - 1)\n facs << facs.last * (num - 1)\n facs\n end\nend", "def factorial(num)\n if num == 0\n return 1\n else\n value = num - 1\n until value == 0\n num *= value\n value -= 1\n end\n return num\n end\nend", "def factorial(num)\n raise ArgumentError if num < 0\n if num == 1 || num == 0 # base case\n return 1\n else\n return num * factorial(num - 1)\n end\nend", "def factorials_rec(num)\n return [1,1].take(num) if num < 2\n facts = factorials_rec(num - 1)\n facts + [facts.last * (num - 1)]\nend", "def recursive_fac(num)\n return num if num == 1\n tail_rec(num - 1) * num\nend", "def factorials_rec(num)\n return [1] if num <= 1\n fact = factorials_rec(num-1)\n fact << (num-1) * fact.last\nend", "def factorial(num)\n if num == 0 || num == 1\n return 1\n else\n arr = []\n (1..num).each do |x|\n arr.push(x)\n end\n until arr.length == 2 do\n arr.push(arr[-1] * arr[-2])\n arr.delete_at(-2)\n arr.delete_at(-2)\n end\n return arr[1]\n end\nend", "def factorials_rec(num)\n return [1] if num == 1\n prev = factorials_rec(num-1)\n prev + [prev.last * (num-1)]\nend", "def factorials_rec(num)\n return [1] if num <= 1\n res = factorials_rec(num-1)\n res.concat([(num-1)*res[-1]])\nend", "def factorials_rec(num)\n\n return [1] if num == 1\n\n prev_facs = factorials_rec(num - 1)\n prev_facs << (num - 1) * prev_facs[-1]\nend", "def factorial(num)\n return 1 if num.zero?\n\n num * factorial(num - 1)\nend", "def factorials_rec(num)\n return [1] if num == 1\n facs = factorials_rec(num - 1)\n facs << facs[-1] * (num - 1)\nend", "def factorials_rec(num)\n return [1] if num == 1\n factorials_rec(num-1) + [(1...num).to_a.reduce(:*)]\nend", "def factorials_rec(num)\n return [1] if num == 1\n previous_factorials = factorials_rec(num-1)\n next_factorial = [previous_factorials.last * (num-1)]\n previous_factorials + next_factorial\nend", "def factorial(number)\n if number == 0 #(limit)\n 1\n else\n number * factorial(number-1) #first number * number - 1 but the factorial calls the same method on the number - 1\n end\nend", "def factorials_rec(num)\n return [1] if num == 1\n\n facs = factorial_rec(num - 1)\n facs << facs.last * num\nend", "def factorial(number)\n if number == 0\n return 1\n elsif number == 1\n return 1\n else\n number*factorial(number-1)\n end\nend", "def factorials_rec(num)\n return [] if num == 0\n return [1] if num == 1\n prev = factorials_rec(num - 1)\n prev + [prev.last * (num - 1)]\nend", "def factorials_rec(num)\n return [1] if num == 1\n\n facs = factorials_rec(num - 1)\n facs << facs.last * num\n\n facs\nend", "def factorials_rec(num)\n return [1] if num == 1\n prev = factorials_rec(num - 1)\n prev << (num - 1) * prev[-1]\nend", "def factorials_rec(num)\n return [1] if num == 1\n\n factorials_rec(num-1) << factorials_rec(num-1).last * (num - 1)\nend", "def factorials_rec(num)\n if num == 1\n [num]\n else\n factorials = factorials_rec(num - 1)\n factorials << factorials.last * (num - 1)\n factorials\n end\nend", "def factorial(num)\n\tproduct = 1\n\twhile num > 1\n\t\tproduct = product*num\n\t\tnum -= 1\n\tend\n\tproduct\nend", "def factorials_rec(num)\n return [1] if num == 0\n num.times do |num|\n facs = factorials_rec(num-1)\n facs << num * facs.last\n facs\n end\nend", "def factorials_rec(num)\n return [1] if num == 1\n fact = factorials_rec(num-1)\n fact << fact.length * fact[-1]\nend", "def iterative_factorial(num)\n if num < 0 || !is_integer?(num)\n return Float::NAN\n elsif num == 0 || num==1\n 1\n else\n (1..num).inject(:*) || 1\n end\nend", "def factorial(number)\n if number == 0\n \treturn 1\n elsif number == 1\n \treturn 1\n end\n i=number-1\n f=number*i\n while i > 1\n \ti=i-1\n \tf=f*i\n end\n return f\nend", "def factorial(number)\n if number == 1\n return 1\n else\n return number * factorial(number - 1)\n end\nend", "def factorials_rec(num)\n #6 == [0!, 1!, 2!, 3!, 4!, 5!]\n return [1] if num == 1\n\n factorials_rec(num-1) + [(num-1) * factorials_rec(num-1).last]\nend", "def factorials_rec(num)\n if num == 1\n [1]\n else\n recs = factorials_rec(num - 1)\n recs << (num - 1) * recs.last\n end\nend", "def factorial_rec(num)\n return [1] if num == 1\n res = factorial_rec(num - 1)\n res << (num - 1) * res[-1]\nend", "def factorials_rec(num)\n return [1] if num <= 1\n\n result = factorials_rec(num-1)\n result << (num-1) * result[-1]\n\nend", "def factorial(number)\n\treturn 1 if number == 1 \n\treturn number * factorial(number-1)\nend", "def factorials_rec(num)\n return [1] if num == 0\n return [1] if num == 1\n \n prev = factorials_rec(num-1)\n prev << (num-1) * prev[-1]\nend", "def factorials_rec(num)\n return [1] if num == 1\n prev = factorials_rec(num - 1)\n prev << prev[-1] * (num - 1)\n prev\nend", "def FirstFactorial(num)\n arr = [*1..num]\n i = 0\n answer = 1\n while i < arr.length\n answer *= arr[i]\n i += 1\n end\nanswer\nend", "def factorial(number)\n if number == 0 \n return 1\n elsif number > 1 \n return number * factorial(number - 1)\n else\n return number\n end\nend", "def factorial(num)\n num == 1 ? num * 1 : num * factorial(num - 1)\nend", "def factorials_rec(num)\n return [1] if num==1\n return [1,1] if num==2\n factorials_rec(num-1) + [(num-1) * factorials_rec(num-1).last]\nend", "def iterative_factorial(num)\n\tif num < 0\n\t\treturn Float::NAN # a constant meaning \"Not a Number\"\n\tend\n\tmemo = 1\n\t(1..num).each do |i|\n\t\tmemo = memo*i\n\tend\n\tmemo\nend", "def factorials_rec(num)\r\n return [1,1].take(num) if num < 3\r\n factorials = factorials_rec(num - 1)\r\n factorials << factorials.last * (num -1)\r\nend", "def factorials_rec(num)\n return [1] if num == 1\n facs = factorials_rec(num - 1)\n facs << facs.last * num\nend", "def factorials_rec(num)\n return [1] if num == 1\n\n facs = factorials_rec(num - 1)\n facs << facs.last * (num - 1)\n facs\n\n\nend", "def recursive_factorial(n)\n return 1 if n < 1\n\n n * recursive_factorial(n - 1)\nend", "def factorials_rec(num)\n return [1] if num == 1\n previous_factorial = factorials_rec(num - 1)\n last_fac = previous_factorial.last\n previous_factorial + [last_fac * (num - 1)]\nend", "def factorial(number)\n if number < 0\n return nil\n elsif number <= 1\n 1\n else\n number * factorial(number-1)\n end\nend", "def factorial(number)\n if number == 0\n return 1\n else\n number*factorial(number-1)\n end\n\nend", "def getFactorial(number)\n factorial = 1\n if number > 0\n for i in 1..number\n factorial *= i\n end\n end\n return factorial\n end", "def factorial_of num \n\t(2..num).inject(1) {|product, x| product * x }\nend", "def iterative_factorial(num)\n return Float::NAN if !num.is_a?(Integer) || num < 0\n fact = 1\n (1..num).each {|i| fact *= i}\n fact\nend", "def factorial(factor)\n return 1 if factor == 1\n factor*factorial(factor-1)\nend", "def Factorial(num)\ncurrent = num\nproduct = 1\n\n\twhile current > 0\n\t\tproduct = product * current\n\t\tcurrent -= 1\n\tend\n\tproduct\nend", "def factorial num\n if num < 0\n return 'You can\\'t take the factorial of a negative number!'\n end\n if num <= 1\n 1\n else\n num * factorial(num-1)\n end\nend", "def factorials_rec(num)\n return [1] if num == 1\n\n facts = factorials_rec(num-1)\n\n facts << facts.last * (num - 1)\n\n facts\nend", "def factorial(number)\n return 1 if number <= 1\n number * factorial(number - 1)\nend", "def factorials_rec(num)\n return 1 if num == 0 \n return [1] if num == 1\n fact = [1]\n\n fact << [(fact[-1] * factorials_rec(num-1))]\n# (2) \n# 4 * fact_rc(3) 2\n# 3 * fact_rc(2) 6\n# 2 * fact_rc(1) 2\n# 1 * fact(rc 0 )\nend", "def iterative_factorial(num)\n\tif num < 0 || !(is_integer?(num))\n\t\tFloat::NAN\n\telsif num == (0 || 1)\n\t\t1\n\telse\n\t\tnum.downto(1).reduce(:*)\n\tend\nend", "def factorials_rec(num)\n return [] if num == 0\n factorials = []\n\n assessment_passer = factorials_rec(0)\n\n idx = 0\n while idx < num\n factorials << factorial_num(idx)\n idx += 1\n end\n\n factorials\nend", "def factorials_rec(num)\n answer = []\n return [1] if num == 1\n return [1, 1] if num == 2\n next_num = (num - 1) * factorials_rec(num - 1)[-1]\n answer << next_num\n #answer\nend", "def factorial(num)\n\tproduct = num\n \titer = num-1\n \twhile(iter>1)\n \tproduct *=iter\n \titer-= 1\n end\n return product\nend", "def factorial(number)\n # Your code goes here\n if(number > 1)\n number * factorial(number-1)\n else\n 1\n end\nend", "def factorial(num)\n if num < 0\n return \"You can't take the factorial of a negative number.\"\n end\n\n if num <= 1\n 1\n else\n num * factorial(num - 1)\n end\nend", "def factorial( n )\n if (n <= 1)\n return 1\n else\n return n*factorial( n-1 ).to_i\n end\nend", "def factorials_rec(num)\n return 'error' if num < 0\n return [1] if num == 1\n return [1, 1] if num == 2\n fac = factorials_rec(num - 1)\n fac << fac.last * (num - 1)\n fac\n\nend", "def factorial_1(num)\n factorial_count = 1\n while num > 0\n factorial_count *= num\n num -= 1\n end\n factorial_count\nend", "def factorial(number)\n if number == 0\n return 1\n else\n final_factorial = 1\n\n for x in 1..number\n final_factorial = final_factorial * x\n end\n\n return final_factorial\n end\nend", "def factorials_rec(num)\n return [1,1] if num == 2\n return [1] if num == 1\n\n factorial_array = factorials_rec(num-1)\n factorials = factorial_array + [(num-1) * factorial_array.last]\n factorials\nend", "def factorial((number))\nif number == 0\n return 1\n else\n result = 1\n while number > 1\n result = result * number\n number -= 1\n end\nend\n return result\nend", "def factorial(number)\n\ttotal = 1\n\tif number == 0\n\t\treturn 1\n\telse\n\t\twhile number > 1\n\t\t\ttotal *= number\n\t\t\tnumber -= 1\n\t\tend\n\t\treturn total\n\tend\nend", "def factorial(number)\n i = number\n total = number\n if number == 0 || number == 1\n return 1\n else\n while i > 1\n total=total * (i - 1)\n i -= 1\n end\n end\n return total\nend", "def factorial(number)\n if number == 0\n return 1\n else\n i = number-1\n while i >= 1\n number = number * i\n i = i - 1\n end\n return number\n end\nend", "def factorial(number)\n if number == 0\n return 1\n else\n i = number-1\n while i >= 1\n number = number * i\n i = i - 1\n end\n return number\n end\nend", "def factorial(num)\n product = 1\n\n i = 2 # 1 * 2 = 2, so just start from 2 and skip 1 as it doesn't matter\n while i <= num\n product *= i\n\n i += 1\n end\n\n return product\nend", "def factorial(number)\n if number <= 1\n return 1\n else\n result = 1\n (1..number).each {|x| result = result * x}\n return result\n end\nend" ]
[ "0.8557698", "0.8358884", "0.8140083", "0.810765", "0.80212927", "0.7778724", "0.7766124", "0.7759598", "0.775164", "0.7727939", "0.7718227", "0.77165973", "0.77111447", "0.77050495", "0.770471", "0.7693072", "0.76910025", "0.76594365", "0.76479346", "0.76479346", "0.76479346", "0.76333666", "0.7627931", "0.7626742", "0.76201934", "0.7582449", "0.75792855", "0.75382614", "0.75221086", "0.751518", "0.75134236", "0.7494733", "0.74817514", "0.7479818", "0.7473633", "0.747224", "0.7470168", "0.7457467", "0.7456595", "0.7447513", "0.7445335", "0.7439081", "0.74237204", "0.7421966", "0.7417295", "0.741646", "0.7406856", "0.7403851", "0.7390583", "0.73902965", "0.7384643", "0.7383666", "0.73834735", "0.73793155", "0.73709136", "0.7368947", "0.73688054", "0.7364437", "0.7355667", "0.73529834", "0.73490345", "0.73472774", "0.7335385", "0.7327855", "0.7327349", "0.7322205", "0.73186165", "0.7310983", "0.7307333", "0.73015165", "0.7293919", "0.7287681", "0.7273064", "0.7256766", "0.7252239", "0.7249338", "0.72476834", "0.72459364", "0.7239639", "0.7226329", "0.72235155", "0.72208023", "0.72047", "0.7194815", "0.7187888", "0.718781", "0.7184195", "0.71791536", "0.7175832", "0.7173892", "0.7173331", "0.7163504", "0.71595114", "0.71585375", "0.7157502", "0.7153865", "0.71521264", "0.71521264", "0.71484506", "0.7140064" ]
0.7458574
37
Write a method that finds the sum of the first n fibonacci numbers recursively. Assume n > 0.
def fibs_sum(n) return 0 if n == 0 return 1 if n == 1 fibs_sum(n-1) + fibs_sum(n-2) + 1 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fibs_sum(n)\n return 0 if n == 0\n return 1 if n == 1\n\n fibs_sum(n - 1) + fibs_sum(n - 2) + 1\nend", "def fibs_sum(n)\n return 1 if n == 1 || n == 2\n sum = 0\n sum += (fibs_sum(n - 1) + fibs_sum(n - 2))\n \n \nend", "def fib_sum(n)\n return n if ( 0..1 ).include? n\n ( fib_sum( n - 1 ) + fib_sum( n - 2 ) )\nend", "def fibs_sum(n) # my version\n return 1 if n == 1\n return 2 if n == 2\n\n current = single_fib(n)\n current += fibs_sum(n - 1)\nend", "def fibonacciRecursive(n)\n\tif n <= 1\n\t\treturn n\n\telse\n\t\treturn fibonacciRecursive(n - 1) + fibonacciRecursive(n - 2)\n\tend\nend", "def fibs(n)\n return n if n <= 1\n fibs(n - 1) + fibs(n - 2)\nend", "def fibonacci_recursive(n)\n if n == 0 || n == 1\n return n\n end\n # ex n = 5: fib(4) + fib(3) ==> fib(3) + fib(2) ==> fib(2) + 1 =\n return fibonacci_recursive(n-1) + fibonacci_recursive(n-2)\nend", "def fib(n)\n if n == 0 || n == 1\n return n\n else\n fib(n - 1) + fib(n - 2)\n end\n end", "def fibonacci_recursive n\n return n if n < 2\n fibonacci_recursive(n-1) + fibonacci_recursive(n-2)\nend", "def sum_of_fib(n)\n return fib(n+2)-1;\nend", "def fibo_finder(n)\n if n <= 1\n \tn\n else\n fibo_finder(n-1) + fibo_finder(n-2)\n end\nend", "def fibo_finder(n) \n if n == 0\n return 0\n elsif n ==1\n return 1\n else\n return (fibo_finder(n - 1) + fibo_finder(n - 2))\n end\nend", "def find_fib_nth(n)\n if n == 0\n 1\n elsif n == 1\n 1\n else\n return (find_fib_nth(n - 2) + find_fib_nth(n - 1))\n end\nend", "def recursive_fib n\n return 1 if n == 1 || n == 2\n recursive_fib(n-1) + recursive_fib(n-2)\nend", "def fibonacci(n)\n\tif n == 0 || n == 1\n\t\treturn 1\n\telse\n\t\treturn fibonacci(n-1) + fibonacci(n-2)\n\tend\nend", "def recursive_fibonacci(n)\n if (n == 1)\n return 0\n elsif (n == 2 || n == 3)\n return 1\n end\n return recursive_fibonacci(n - 2) + recursive_fibonacci(n - 1)\n end", "def fibs_rec(n)\n n == 0 || n == 1 ? n : fibs_rec(n-1) + fibs_rec(n-2)\n fibs(n)\nend", "def fibonacci(n)\n\treturn 0 if n == 0\n\treturn 1 if n == 1\n\tfibonacci(n-1) + fibonacci(n-2)\nend", "def fib(n)\n if n == 0 || n == 1\n return n\n else\n fib(n-1) + fib(n-2)\n end\nend", "def fib(n)\n return 0 if n == 0\n return 1 if n == 1\n\n return fib(n-1) + fib(n-2)\nend", "def fib(n)\n return 0 if n <= 0\n return 1 if n == 1\n\n fib(n - 1) + fib(n - 2)\nend", "def nth_fibonacci(n) \n if n == 1\n return 0\n elsif n == 2\n return 1\n end\n return nth_fibonacci(n-1) + nth_fibonacci(n-2)\nend", "def fibonacci(n)\n return 0 if n == 0\n return 1 if n == 1\n\n fibonacci(n - 1) + fibonacci(n - 2)\nend", "def fibonacci(n)\n if n <= 1\n return n\n else\n return fibonacci(n - 1) + fibonacci(n - 2)\n end\nend", "def fibonacci(n)\n return n if n == 1 || n == 0 \n fibonacci(n - 1) + fibonacci(n - 2)\nend", "def fibonacci(n)\n return n if (0..1).include? n\n (fibonacci(n - 1) + fibonacci(n - 2))\nend", "def fib(n)\n return 0 if n == 0\n return 1 if n == 1\n \n\n fib(n - 1) + fib(n - 2)\nend", "def fib_sum(n)\n #generate up to n recursive\n fib = [0, 1]\n i = 2\n while i < n\n fib << fib[i - 2] + fib[i - 1]\n i += 1\n end\n p fib\n # sum = 0\n accumulator = fib.first\n while !fib.empty?\n accumulator += fib.pop\n end\n #iterate and sum through the stack\n return accumulator\nend", "def fib(n)\n return n if (0..1).include? n\n fib(n-1) + fib(n-2)\nend", "def fibonacci(n)\n return n unless n > 1\n fibonacci(n -1) + fibonacci(n -2)\nend", "def fib_basic(n)\n if (0..1).include? n\n return n\n else\n (fib_basic(n - 1) + fib_basic(n - 2))\n end\nend", "def fibs_rec(n)\n return n if n <= 1\n return fibs_rec(n-2) + fibs_rec(n-1)\nend", "def fibonacci(n)\n if n == 0 or n == 1\n return n\n else\n return fibonacci(n - 1) + fibonacci(n - 2)\n end\nend", "def fib(n)\n return 1 if n == 2\n return 0 if n == 1\n\n fib(n-1) + fib(n-2)\nend", "def fibonacci(n)\r\n if n == 0\r\n return 0\r\n elsif n == 1\r\n return 1\r\n else\r\n return fibonacci(n-1) + fibonacci(n-2)\r\n end\r\nend", "def fibonacci( n )\n return n if ( 0..1 ).include? n\n ( fibonacci( n - 1 ) + fibonacci( n - 2 ) )\nend", "def fibonacci( n )\n return n if ( 0..1 ).include? n\n ( fibonacci( n - 1 ) + fibonacci( n - 2 ) )\nend", "def fibonacci( n )\n return n if ( 0..1 ).include? n\n ( fibonacci( n - 1 ) + fibonacci( n - 2 ) )\nend", "def fib(n)\n if n == 1 || n == 2\n return 1\n end\n return fib(n-1) + fib(n-2)\nend", "def fib(n)\n if n == 1 || n == 2\n return 1\n end\n return fib(n-1) + fib(n-2)\nend", "def fib(n)\n return 1 if n == 1 || n == 2\n fib(n-1) + fib(n-2)\nend", "def fib(n)\n if n == 1 || n == 2\n return 1\n end\n return fib(n - 1) + fib(n - 2)\nend", "def fib_rec(n)\n return 0 if n == 1\n return 1 if n == 2\n fib_rec(n - 1) + fib_rec(n - 2)\nend", "def fibs_rec(n)\n\treturn n if n <= 1\n\tfibs_rec(n-1) + fibs_rec(n-2)\nend", "def fibonacci(n)\n return 0 if n == 1\n return 1 if n == 2\n return fibonacci(n-1)+fibonacci(n-2)\nend", "def fib(n)\n return n if n <= 1\n fib(n-1) + fib(n-2)\nend", "def fibonacci(n)\n return 1 if n == 1\n return 1 if n == 2\n fibonacci(n - 1) + fibonacci(n - 2)\nend", "def fibo_n n\n\treturn n if (0..1).include? n\n\tfibo_n(n-2) + fibo_n(n-1)\nend", "def fib(n)\n return nil if n < 1\n return 1 if n == 1 || n == 2\n fib(n-1) + fib(n-2)\nend", "def fibonacci(n)\n return 1 if n == 1 || n == 2\n fibonacci(n - 1) + fibonacci(n - 2)\nend", "def fibonacci(n)\n return 1 if n == 1 || n == 2\n fibonacci(n - 1) + fibonacci(n - 2)\nend", "def fib(n)\n if (n <= 1) \n return n;\n else\n return fib(n-1)+fib(n-2);\n end\nend", "def fibonacciR( n )\r\n return n if n <= 1\r\n fibonacciR( n - 1) + fibonacciR( n - 2)\r\nend", "def fibonacci(n)\n raise ArgumentError, \"n cannot be less than 0\" if n < 0\n return 0 if n == 0 \n\n old_sum, new_sum = 0, 1\n return fib_helper(old_sum, new_sum, n)\nend", "def fibonacci(n)\n return 1 if n <= 2\n fibonacci(n - 2) + fibonacci(n - 1)\nend", "def fibonacci(n)\n if n == 0\n 1\n elsif n == 1\n 1\n else\n fibonacci(n-2) + fibonacci(n-1)\n end\nend", "def fibonnaci(n)\n if n == 1 || n == 2\n 1\n else\n fibonnaci(n - 1) + fibonnaci(n - 2)\n end\nend", "def fibonacci(n)\n return 1 if n <= 2\n fibonacci(n - 1) + fibonacci(n - 2)\nend", "def fibonacci(n)\n return 1 if n <= 2\n fibonacci(n - 1) + fibonacci(n - 2)\nend", "def fibonacci(n)\n if n < 2\n return n\n else\n fibonacci(n-1) + fibonacci(n-2)\n end\nend", "def recursive_fib(n)\n if n<2\n return n\n else\n return (recursive_fib(n-1)+recursive_fib(n-2))\n end \nend", "def fib(n)\n return 1 if n <= 2\n fib(n-1) + fib(n-2)\nend", "def fibonacci(n)\n return 1 if n == 1 || n == 2\n\n fibonacci(n - 1) + fibonacci(n - 2)\nend", "def fibonacci(n)\n return 1 if n <= 2\n fibonacci(n - 1 ) + fibonacci(n - 2)\nend", "def fibonacci(n)\n if n == nil || n < 0\n raise ArgumentError\n elsif n == 0\n return 0\n elsif n == 1\n return 1\n end\n\n first = 0\n second = 1\n\n index = 1\n while index < n\n holder = first + second\n first = second\n second = holder\n index += 1\n end\n return holder\nend", "def fib(n)\n return 1 if n <= 2\n fib(n - 1) + fib(n - 2)\nend", "def fibonacci_recur(n)\n return 0 if n == 1\n return 1 if n == 2\n\n fibonacci_recur(n - 1) + fibonacci_recur(n - 2)\nend", "def fibs_sum(n)\n\nend", "def fibs_sum(n)\n\nend", "def fibs_sum(n)\n\nend", "def fibs_sum(n)\n\nend", "def fibs_sum(n)\n\nend", "def fibonacci(n)\n \n return n if n == 1\n \n if n > 2 \n fibonacci(n-1) + fibonacci(n-2)\n else\n fibonacci(n-1)\n end\nend", "def fib n\n if n == 0\n 0\n elsif n == 1\n 1\n else\n fib(n-2) + fib(n-1)\n end\nend", "def fibonacci(n)\n if n < 2\n return n\n else\n return fibonacci(n-1) + fibonacci(n-2)\n end\nend", "def fib(n)\n\n if n == 1 or n == 2\n return 1\n else\n return fib(n-1) + fib(n-2)\n end\n\nend", "def fib(n) \n if n == 0\n return 0\n else\n\tfib_0 = 0\n\tfib_1 = 1\n\t(1..(n-1)).each do \n\t\ttemp = fib_0\n\t\tfib_0 = fib_1\n\t\tfib_1 = temp + fib_1\n\t\t\n\tend\n\treturn fib_1\n end\nend", "def fibonacci( n )\n return n if n <= 1 \n fibonacci( n - 1 ) + fibonacci( n - 2 ) \nend", "def fib(n)\n return 0 if n == 0\n return 1 if n == 1\n return 1 if n == 2\n # return 2 if n == 3\n fib(n - 1) + fib(n - 2)\nend", "def fibonacci(n)\n if n <= 2\n 1\n else\n fibonacci(n - 1) + fibonacci(n - 2)\n end\nend", "def fib(n)\n return 0 if n == 0\n return 1 if n == 1\n\n [fib(n-1),fib(n-2)].reduce(:+)\n\t\nend", "def fibonacci(n)\n if n == 1 || n == 2\n 1\n else\n fibonacci(n-1) + fibonacci(n-2)\n end\nend", "def get_nth_fib(n)\n if n == 2\n return 1\n elsif n == 1\n return 0\n else\n return get_nth_fib(n - 1) + get_nth_fib(n - 2)\n end\nend", "def fib_rec( n )\n $call_count += 1\n # Define the base case\n if n < 2\n return 1\n else\n # do the recursive calculation:\n return fib_rec( n - 1 ) + fib_rec( n - 2 )\n end\n\nend", "def fib(n)\n if n == 1 || n == 2\n n\n else\n fib(n-1) + fib(n-2)\n end\nend", "def fibs_rec(n)\n n <= 1 ? n : fibs_rec(n - 1) + fibs_rec(n - 2)\nend", "def fib(n)\n return 0 if n < 0\n return n if n < 2\n return fib(n-1) + fib(n-2)\nend", "def fibonacci(n)\n return 1 if n <= 2\n \n fibonacci(n - 1) + fibonacci(n - 2)\nend", "def fib(n)\n if n < 2\n 1\n else\n fib(n-2) + fib(n-1)\n end\nend", "def fib(n)\n if n == 0\n 0\n elsif n == 1 || n == 2\n 1\n else fib(n - 2) + fib(n - 1)\n end\nend", "def fibonacci(n)\n if n < 2\n n\n else\n fibonacci(n - 1) + fibonacci(n - 2)\n end\nend", "def get_nth_fib(n)\n if n == 0 || n == 1\n return 0\n elsif n == 2\n return 1\n else\n return get_nth_fib(n-1) + get_nth_fib(n-2)\n end\n\nend", "def fibonacci n\n return n if n < 2\n fibonacci(n - 1) + fibonacci(n - 2)\nend", "def fibs (n) #Non-recursive\n\n\t# n = number of Fibonacci sequence members.\n\t# 0, 1, 1, 2, 3, 5, 8, 13, ..\t\n\tfib_seq = []\n\t(0..n).each do |i|\n\t\tif i == 0\n\t\t\tfib_seq << 0\n\t\telsif i == 1\n\t\t\tfib_seq << 1\n\t\telse\n\t\t\tfib_seq << fib_seq[i-2] + fib_seq[i-1]\n\t\tend\n\tend\n\tfib_seq\nend", "def fib(n)\n # your implementation here\n if n==0 then\n 1\n elsif n==1 then\n 1\n else \n fib(n-2) + fib(n-1)\n end\nend", "def fib(n)\n return n if n < 2\n fib(n-1) + fib(n-2)\nend", "def fibonacci(n)\n if n == nil || n < 0\n raise ArgumentError\n end\n# base cases are 0 and 1 (0th place is 0, 1st place is 1)\n if n < 2\n return n\n end\n\n counter = 1\n left = 0\n right = 1\n\n while counter < n\n sum = left + right\n left = right\n right = sum\n counter += 1\n end\n return sum\nend" ]
[ "0.8981103", "0.87479585", "0.87065566", "0.86833096", "0.86395675", "0.8585491", "0.8540424", "0.85397935", "0.85042083", "0.8501192", "0.8486396", "0.8470936", "0.84407544", "0.84372413", "0.8435925", "0.8426029", "0.8420815", "0.84188473", "0.8410866", "0.84104073", "0.84059334", "0.8390522", "0.83890265", "0.8376364", "0.8374238", "0.8373865", "0.83629453", "0.83603555", "0.83474684", "0.83413446", "0.8339897", "0.8338685", "0.8338054", "0.8335896", "0.83350813", "0.83327377", "0.83327377", "0.83327377", "0.83247066", "0.83247066", "0.8318469", "0.83110607", "0.8308924", "0.83076173", "0.8296932", "0.82954174", "0.82950294", "0.82922685", "0.82921493", "0.8290572", "0.8290572", "0.8287636", "0.82841414", "0.828054", "0.82804006", "0.8271546", "0.8269859", "0.8268296", "0.8268296", "0.82567936", "0.82537615", "0.8252077", "0.8248075", "0.8247271", "0.82359415", "0.8234635", "0.8229937", "0.82296354", "0.82296354", "0.82296354", "0.82296354", "0.82296354", "0.8225679", "0.82165915", "0.82159793", "0.82106936", "0.8207811", "0.8206275", "0.8203501", "0.8191999", "0.8186684", "0.81851995", "0.81811005", "0.81807595", "0.81799763", "0.8175478", "0.8171926", "0.8171543", "0.81706357", "0.8165208", "0.8160703", "0.8159551", "0.81568307", "0.81503665", "0.81467295", "0.81445897", "0.81418544" ]
0.897471
4
Using recursion and the `is_a?` method, write an `Arraydeep_dup` method that will perform a "deep" duplication of the interior arrays.
def deep_dup(arr) arr.map{ |el| el.is_a?(Array) ? deep_dup(el) : el } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def deep_dup(arr)\n\nend", "def deep_dup(arr)\n\nend", "def deep_dup(arr)\n\nend", "def recursive_deep_dup(arr)\n # # does arr contain anymore arrays?\n # if !(arr.is_a? Array)\n # arr\n # else\n # arr[recursive_deep_dup(arr)].dup\n # arr_copy = arr.dup\n arr_copy = []\n arr.each do |sub|\n if sub.is_a? Array\n # sub_copy = sub.dup\n # p sub_copy\n # recursive_deep_dup(sub_copy)\n arr_copy << recursive_deep_dup(sub)\n else\n arr_copy << sub\n end\n end\n arr_copy\n # end\nend", "def deep_dup(arr)\n # new_array = []\n # arr.each do |el|\n # new_array << (el.is_a?(Array) ? deep_dup(el) : el)\n # end\n # new_array\nend", "def deep_dup(arr)\n copy = arr.dup\n copy.each_with_index do |el, i|\n copy[i] = deep_dup(el) if el.is_a?(Array)\n end\nend", "def deep_dup(arr)\n deep = []\n arr.each do |el|\n if el.is_a?(Array)\n deep << deep_dup(el)\n else\n deep << el\n end\n end\n deep\nend", "def recursive_deep_dup(arr)\n return arr unless arr.is_a?(Array)\n \n new_arr = []\n arr.each { |ele| new_arr << recursive_deep_dup(ele) }\n new_arr\nend", "def deep_dup(arr)\n return arr if !arr.kind_of?(Array)\n new_arr = []\n arr.each do |ele|\n new_arr << deep_dup(ele)\n end\n new_arr\nend", "def deep_dup(arr)\n if !arr.is_a?(Array)\n return arr\n end\n\n duped_arr = []\n arr.each do |el|\n duped_arr << deep_dup(el)\n end\n\n return duped_arr\nend", "def deep_dup(arr)\n ans = []\n arr.each do |elt| #can use map\n if elt.is_a?(Array)\n ans.concat([deep_dup(elt)])\n else\n ans << elt\n end\n end\n ans\nend", "def deep_dup(array_to_dup)\n [].tap do |duplicated_array|\n\n array_to_dup.each do |item|\n\n puts \"item is #{item}\"\n\n if item.is_a?(Array)\n duplicated_array << deep_dup(item)\n else\n duplicated_array << item\n end\n end\n end\nend", "def deep_dup(arr)\n return [arr] if !arr.is_a?(Array)\n res = []\n arr.each do |a|\n res += deep_dup(a)\n end \n res \nend", "def deep_dup(arr)\n new_arr = []\n arr.each do |el|\n if el.is_a?(Array)\n new_arr << deep_dup(el)\n else\n new_arr << el\n end\n end\n new_arr\nend", "def deep_dup(arr)\n return arr.dup if arr.none?{|ele| ele.is_a?(Array)}\n temp = arr[0]\n if temp.is_a?(Array)\n [arr[0].dup] + deep_dup(arr[1..-1])\n else\n [arr[0]] + deep_dup(arr[1..-1])\n end\nend", "def deep_dup(array)\n arr = []\n return [] if array.empty?\n return array if array.length == 1 \n array.each do |ele|\n if ele.is_a? Array \n arr << deep_dup(ele)\n else \n arr << ele\n end \n end \n arr \nend", "def deep_dup(arr)\n return [] if arr.length.zero?\n\n innerArr = []\n\n arr.each do |el|\n if el.is_a?(Array)\n innerArr << deep_dup(el)\n else\n innerArr << el\n end\n end\n\n innerArr\nend", "def deep_dup; end", "def deep_dup(arr)\n duper_arr = arr.dup.map { |item| item * 1 }\nend", "def deep_dup\n map(&:deep_dup)\n end", "def rec_deep_dup(input)\n if !input.is_a?(Array)\n input\n else\n result = []\n input.each do |element|\n result << rec_deep_dup(element)\n end\n end\nend", "def deep_dup(array)\n return array if !array.is_a?(Array)\n array.map do |x|\n deep_dup(x)\n end\n end", "def deep_dup(arr)\n new_arr = []\n return arr if !arr.is_a?(Array)\n # return arr.each if arr.is_a?\n\n if arr.is_a?(Array)\n arr.each do |value|\n new_arr << deep_dup(value)\n end\n end\n new_arr\nend", "def deep_dup(array)\n\n final_array = []\n return final_array if array.empty?\n\n array.each do |item|\n if item.is_a?(Array)\n final_array << deep_dup(item)\n else\n final_array << item\n end\n end\n\n final_array\nend", "def deep_dup\n dup\n end", "def deep_dup\n # noinspection RubyMismatchedReturnType\n dup\n end", "def deep_dup(outer)\n return outer if outer.empty?\n\n temp = []\n outer.each do |element|\n if element.is_a?(Array)\n temp << deep_dup(Array.new(element))\n else\n temp << element\n end\n end\n\n temp\nend", "def deep_dup(ary)\n ary.map { |sub_ary| sub_ary.map { |el| el } }\nend", "def deeper_dup(arr)\n duper_deeper_arr = arr.dup.map do |item|\n if item.kind_of?(Array)\n deeper_dup(item)\n else\n item = item * 1\n end\n end\n duper_deeper_arr \nend", "def deep_dup\n @map.map { |e| e.is_a?(Array) ? deep_dup(e) : ele }\n end", "def deep_dup\n duplicable? ? dup : self\n end", "def deep_dup\n duplicable? ? dup : self\n end", "def deep_dup\n puts \"warning: #{self.class}: deep_dup not implement\"\n end", "def deep_copy\n answer = []\n %w[1 2 3 4 5 6].each do |elem|\n answer << elem.dup\n end\n answer\nend", "def deep_duplicate(object)\n case object\n when Array\n object.map { |item| deep_duplicate(item) }\n when Hash\n hash = object.dup\n hash.each_pair { |key, value| hash[key] = deep_duplicate(value) }\n hash\n else\n object\n end\n end", "def deep_dup\n duped_board = []\n @board.each_with_index do |row, row_ind|\n duped_board << []\n\n row.each_with_index do |piece, column_ind|\n if piece.nil?\n duped_board[row_ind][column_ind] = nil\n next\n end\n\n new_piece = piece.dup\n duped_board[row_ind][column_ind] = new_piece\n new_piece.position = new_piece.position.dup\n end\n end\n self.class.new(duped_board)\n end", "def deep_clone; end", "def deep_dup(obj)\n if obj.is_a?(Hash)\n result = {}\n obj.each { |k,v| result[k] = deep_dup(v) }\n result\n elsif obj.is_a?(Array)\n obj.map { |el| deep_dup(el) }\n else\n dup_or_self(obj)\n end\n end", "def deep_dup\n Marshal.load(Marshal.dump(self))\n end", "def deep_dup\n new_board = Board.new(false)\n self.grid.each.with_index do |row, idx1|\n row.each.with_index do |cell, idx2|\n if self.grid[idx1][idx2].nil?\n next\n else\n new_board.grid[idx1][idx2] = self.grid[idx1][idx2].dup\n new_board.grid[idx1][idx2].board = new_board\n end\n end\n end\n new_board\n end", "def initialize_dup( hooked_array_dup )\n \n super\n \n hooked_array_dup.internal_array = hooked_array_dup.internal_array.dup\n\n end", "def deep_dup\n inject(self.class.new) do |new_hash, (key, value)|\n key = key.respond_to?(:deep_dup) ? key.deep_dup : key.dup?\n value = value.respond_to?(:deep_dup) ? value.deep_dup : value.dup?\n new_hash[key] = value\n new_hash\n end\n end", "def deep_copy\n deep_transform_values(&method(:_deep_copy))\n end", "def duplicate(array)\n array.uniq!\nend", "def dup\n\n # duplicate self\n rta = super\n\n # iterate through array and dup each hash\n rta.each_with_index do |w_hash, index|\n\n # dup the hash at this index\n rta[index] = w_hash.dup\n\n # to be complete, also dup the key/values in the hash, in case another hash/array is nested\n w_hash.each_pair do |k, v|\n rta[index][k] = v.dup if v.is_a? Hash\n end\n end\n\n # now everything should have new object_id's\n rta\n end", "def deep_dup\n new_board = Board.new(false)\n\n grid.flatten.compact.each do |piece|\n new_board[piece.pos.dup] =\n Piece.new(piece.pos.dup, new_board, piece.color)\n end\n\n new_board\n end", "def deep_dup()\n # avoid validation by using a empty Hash for the intial value.\n c = Data.new({})\n c.instance_variable_set(:@root, deep_dup_value(@root))\n c\n end", "def copy array\n array.map(&:clone)\nend", "def duplicate(stuff)\n duplicated_stuff = []\n stuff = [*stuff] unless stuff.is_a?(Enumerable)\n stuff.each do |obj|\n duplicated_stuff << duplicate_object(obj)\n end\n duplicated_stuff.length == 1 ? duplicated_stuff[0] : duplicated_stuff\n end", "def create_deep_copy(object)\n if object.is_a?(Array)\n return object.map { |e| create_deep_copy e }\n elsif object.is_a?(Hash)\n return {}.tap { |out| object.each { |k, v| out[create_deep_copy(k)] = create_deep_copy(v) unless k == :Parent } }\n elsif object.is_a?(String)\n return object.dup\n else\n return object # objects that aren't Strings, Arrays or Hashes (such as Symbols and Integers) won't be edited inplace.\n end\n end", "def __deep_copy__\n self.class.new(aliases) do |copy|\n each do |entry|\n copy.push(entry.__deep_copy__)\n end\n end\n end", "def duplicate\n @copy = self.deep_clone :no_duplicates => true, :never_clone => [:uuid, :updated_at,:created_at]\n @copy.static_page = self.static_page.duplicate\n self.sub_pages.each do |page| \n copy_of_page = page.duplicate\n @copy.sub_pages << copy_of_page\n copy_of_page.save\n end\n @copy.save\n @copy\n end", "def dup(array)\n output = []\n i = 0\n while i < array.length\n output << array[i]\n i += 1\n end\n return output\nend", "def deep_copy(obj); end", "def deep_dup(hash)\n hash.each_with_object({}) do |(key, value), dup|\n dup[key] = value.is_a?(Hash) ? deep_dup(value) : value\n end\n end", "def deep_copy(obj)\n if obj.is_a?(Hash)\n obj.inject({}) { |h, kv| h.merge(kv[0] => deep_copy(kv[1])) }\n elsif obj.is_a?(Array)\n obj.map { |el| deep_copy(el) }\n else\n obj\n end\n end", "def deep_clone\n cloned = self.clone\n cloned.initialize_from_copy(self)\n cloned\n end", "def deep_dup(value)\n return value if value.is_a?(DelayedEvaluator)\n\n visitor = lambda do |obj|\n obj = obj.dup rescue obj\n case obj\n when Hash\n obj.each { |k, v| obj[k] = visitor.call(v) }\n when Array\n obj.each_with_index { |v, i| obj[i] = visitor.call(v) }\n end\n obj\n end\n visitor.call(value)\n end", "def dup(n=1)\n n.times{dps.concat(dps)}\n self\nend", "def deep_clone(value)\n case value\n when Hash\n value.inject({}) do |result, kv|\n result[kv[0]] = deep_clone(kv[1])\n result\n end\n when Array\n value.inject([]) do |result, item|\n result << deep_clone(item)\n end\n else\n begin\n value.clone\n rescue TypeError\n value\n end\n end\n end", "def duplicate\n dup.tap do |c|\n c.page = nil\n columns.each do |column|\n c.columns << column.duplicate\n end\n pictures.each do |picture|\n c.pictures << picture.duplicate\n end\n end\n end", "def push_dup; end", "def deepen_copy! copier, src\n @a = @a.map { | x | copier[x] }\n end", "def two_array_copy(a)\n new_a = Array.new(a.length)\n new_a.each.dup\n return new_a\n end", "def deep_dup\n self.class.new(@parameters.deep_dup, @logging_context).tap do |duplicate|\n duplicate.permitted = @permitted\n end\n end", "def deep_clone\n Marshal.load(Marshal.dump(self))\n end", "def dup\n clone\n end", "def deep_copy\n copy = dup\n copy.values = {}\n @values.each { |k, v| copy.values[k] = v.clone }\n copy\n end", "def deep_clone\n Marshal::load(Marshal.dump(self))\n end", "def deep_clone\n return @deep_cloning_obj if @deep_cloning\n @deep_cloning_obj = clone\n @deep_cloning_obj.instance_variables.each do |var|\n val = @deep_cloning_obj.instance_variable_get(var)\n begin\n @deep_cloning = true\n val = val.deep_clone\n rescue TypeError, NoMethodError\n next\n ensure\n @deep_cloning = false\n end\n @deep_cloning_obj.instance_variable_set(var, val)\n end\n deep_cloning_obj = @deep_cloning_obj\n @deep_cloning_obj = nil\n deep_cloning_obj\n end", "def clone_args(arg)\n if arg.is_a?(Array)\n arg.map {|sub_arg| clone_args(sub_arg)}\n elsif arg.is_a?(Hash)\n Hash[arg.map {|k, v| [clone_args(k), clone_args(v)]}]\n else\n arg # Some objects (e.g. symbol) can't be dup'd.\n end\n end", "def __deep_copy__\n map { |value| value.__deep_copy__ }\n end", "def duplicates_subarray2(arr)\n arr_srt = arr.sort {|a, b| a.ord <=> b.ord}\n new_arr = [[arr_srt[0]]]\n arr_srt.each_with_index do |elm, idx|\n next if idx == 0\n if new_arr[-1].include? elm\n new_arr[-1] << elm\n else\n new_arr << [elm]\n end\n end\n new_arr\nend", "def dup\n self.class.new(\n self.class.attributes.keys.each_with_object({}) do |k, result|\n val = send(k)\n next if val.nil? || (val.respond_to?(:empty?) && val.empty?)\n\n result[k] = val.is_a?(Array) ? val.map(&:dup) : val.dup\n end\n )\n end", "def dup #$\n a = pop\n push a\n push a\n end", "def dup_args_alt(arr)\n arr == arr.uniq ? false : true\nend", "def deep_copy\n return Matrix.new(\n @matrix.map{|row| row.map{|e| e.dup}},\n @rownames.map{|e| e.dup},\n @colnames.map{|e| e.dup}\n )\n end", "def double_array(array)\n array.concat(array)\nend", "def duplicate_sub_arrays(array)\n array_hash = {}\n \n array.each do |sub_array|\n sorted_array = sub_array.sort\n \n if array_hash[sorted_array]\n return true\n else\n array_hash[sorted_array] = true\n end\n \n end\n \n return false\nend", "def flatten\n dup\n end", "def deep_dup\n #new_ops = operands.map(&:dup)\n new_ops = operands.map do |op|\n op.deep_dup\n end\n graph_name = RDF::Node.intern(new_ops.hash)\n log_debug(\"formula\") {\"dup: #{self.graph_name} to #{graph_name}\"}\n self.class.new(*new_ops, **@options.merge(graph_name: graph_name, formulae: formulae))\n end", "def create_copy(arr)\n copy = []\n arr.each { |e| copy.unshift(e) }\n copy\nend", "def deep_clone; Marshal::load(Marshal.dump(self)); end", "def clone_sexp(node)\n node.map do |part|\n # guess: arrays most common, then un-dupables, then dup-ables (strings only)\n if Array === part\n clone_sexp(part)\n elsif [Symbol, Fixnum, TrueClass, FalseClass, NilClass].any? { |k| k === part }\n part\n else\n part.dup\n end\n end\n end", "def deep_copy(config)\n config.each_with_object({}) do |(key, value), hash|\n hash[key] = if value.is_a?(Array)\n value.dup\n else\n value\n end\n end\n end", "def dedup_array(obj)\n if obj.is_a?(Hash)\n obj.map { |k, v| [k, dedup_array(v)] }.to_h\n elsif obj.is_a?(Array)\n obj.reverse.uniq { |h| h.respond_to?(:first) ? h.first : h }.reverse\n else obj\n end\nend", "def deep_copy\n Expression.new(name.deep_copy, value && value.deep_copy)\n end", "def deep_dup(index = {})\n return index[object_id] if index.key? object_id\n\n deep_dup_enumerable(self, index) { |new, k, v| new[k] = v }\n end", "def pack_consecutive_duplicates\n self.inject([[]]) do |array, current|\n if array[-1][-1] == current or array[-1][-1].nil?\n array[-1] << current\n else\n array << [current]\n end\n array\n end\n \n end", "def dup\n duped_board = Board.new(false)\n\n figures.each do |piece|\n duped_board[piece.position] = piece.class.new(duped_board, piece.color, piece.position.dup)\n end\n\n duped_board\n end", "def optimize(**options)\n self.deep_dup\n end", "def array_copy(a)\n n = []\n a.each do |i|\n n.push(i)\n end\n n\nend", "def pack(a)\n\treps = Hash.new(1)\n prev = nil\n \n # filter out repeats\n a.select! {|v| prev == v ? (reps[v] += 1; false) : prev = v}\n \n # replace with nested arrays\n reps.each {|k, v| a[a.index k] = Array.new(v, k)}\n \n a\nend", "def deep_copy\n Marshal.load(Marshal.dump(self))\n end", "def clone_for_recursion(child, association)\n self.class.new(\n # replication mode\n :mode => mode,\n\n # the new src_obj is of course the child\n :src_obj => child,\n\n # these stay the same\n :dest_mission => dest_mission,\n :deep_copy => deep_copy,\n :retain_link_on_promote => retain_link_on_promote,\n\n # this is always true since we go into a transaction first thing\n :in_transaction => true,\n\n # the current_assoc is the name of the association that is currently being replicated\n :current_assoc => association,\n\n # add the new copy to the list of copy parents\n :ancestors => ancestors + [dest_obj],\n\n # recursed always is true since we're recursing here\n :recursed => true\n )\n end", "def pbt_deep_dup_build(item_to_duplicate, &block)\n self.class.pbt_deep_dup_build(self, item_to_duplicate, &block)\n end", "def dup\n empty_board = Board.new(false)\n pieces.each do |piece|\n temp_color = (piece.color == :red) ? :red : :white\n temp_pos = [piece.pos[0], piece.pos[1]]\n temp_kinged = piece.kinged\n temp_piece = Piece.new(empty_board, temp_color, temp_pos, temp_kinged)\n\n # empty_board.add_piece(Piece.new(empty_board, temp_color, temp_pos, temp_kinged), temp_pos)\n end\n\n empty_board\n # duped_rows = rows.map(&:dup)\n #\n # duped_rows.each_with_index do |row, row_idx|\n # row.each_index do |col_idx|\n # next if duped_rows[row_idx].nil?\n # current_cell = duped_rows[row_idx][col_idx]\n #\n # next if current_cell.nil?\n # duped_rows[row_idx][col_idx] = current_cell.dup\n # end\n # end\n # duped_board = self.class.new(duped_rows, false)\n # duped_board.pieces.each do |piece|\n # piece.board = duped_board\n # end\n # duped_board\n\n end", "def deep_equals?(arr1, arr2)\n return false if arr1.length != arr2.length\n\n arr1.each_with_index do |x, i|\n return false if x.instance_of?(Array) && !deep_equals?(x, arr2[i])\n return false if x != arr2[i]\n end\n\n true\nend" ]
[ "0.85042363", "0.85042363", "0.85042363", "0.84489757", "0.82127714", "0.8200443", "0.8174736", "0.814522", "0.80592114", "0.80548733", "0.80500925", "0.8030352", "0.8012406", "0.79844856", "0.7955026", "0.79337823", "0.792694", "0.7918144", "0.79002017", "0.78950816", "0.78875107", "0.7869014", "0.78096175", "0.7767919", "0.7715139", "0.7711759", "0.76882935", "0.7643078", "0.7389444", "0.7377167", "0.73302925", "0.73302925", "0.73022765", "0.69454956", "0.67592573", "0.67261964", "0.6684489", "0.6643499", "0.65956175", "0.64586055", "0.6434983", "0.639248", "0.62862134", "0.6170135", "0.613123", "0.6098474", "0.60661596", "0.6062687", "0.6061345", "0.60181856", "0.59953666", "0.59861225", "0.5980862", "0.59513634", "0.59110683", "0.58957076", "0.58893085", "0.5841294", "0.58325773", "0.58032644", "0.5793621", "0.5777548", "0.5767427", "0.57429314", "0.57420635", "0.5735462", "0.57227784", "0.5722253", "0.57083005", "0.56984705", "0.56967264", "0.569441", "0.5692497", "0.56917864", "0.56622684", "0.56449777", "0.56391335", "0.5632547", "0.5622609", "0.5592196", "0.55809796", "0.55643743", "0.5520708", "0.5513647", "0.55111057", "0.5509019", "0.5507798", "0.54905015", "0.5488781", "0.54882956", "0.54790366", "0.5471792", "0.54670656", "0.5447807", "0.54084665", "0.5401969", "0.5396774", "0.53945625" ]
0.79173654
19
Write a method, `digital_root(num)`. It should Sum the digits of a positive integer. If it is greater than 9 (i.e. more than one digit), sum the digits of the resulting number. Keep repeating until there is only one digit in the result, called the "digital root". Do NOT use the built in `Integerto_s` or `Integerdigits` methods in your implementation. You may wish to use a helper function, `digital_root_step(num)` which performs one step of the process.
def digital_root(num) while num >= 10 num = digital_root_step(num) end num end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def digital_root(num)\n digits = []\n until num == 0\n digits << num % 10\n num /= 10\n end\n sum = digits.reduce(0, :+)\n sum < 10 ? sum : digital_root(sum)\nend", "def digital_root(num)\n while num >= 10\n num = digit_sum(digits(num))\n end\n num\nend", "def digital_root(num)\n return num if num < 10\n sum = 0\n sum += num % 10 + digital_root(num / 10)\n\n if sum > 10\n digital_root(sum)\n else\n sum\n end\n end", "def digital_root(num)\n return num if num < 10\n res = 0\n while num > 0\n res += num % 10\n num /= 10\n end \n digital_root(res)\nend", "def digital_root(num)\n return num if num < 10\n i = 1\n sum = 0\n while 10 ** (i - 1) <= num\n sum += num % (10 ** i) / (10 ** (i - 1))\n i += 1\n end\n\n return digital_root(sum)\nend", "def digital_root(number)\n while number >= 10 do\n number = _digital_root_sum(number)\n end\n number\nend", "def digital_root(num)\n while num > 9\n num = add_digits(num)\n end\n\n num\nend", "def digital_root(num)\n return num if num < 10\n \n sum = digital_root(num/10) + (num % 10)\n \n if sum > 10\n sum = digital_root(sum)\n else\n sum\n end\nend", "def digital_root(num)\n return num if num < 10\n digital_root((num % 10) + (num / 10))\nend", "def digital_root(num)\n return num if num < 11\n n = num % 10\n k = num / 10\n ans = n + k\n digital_root(ans)\nend", "def digital_root(num)\n array = []\n\n until num == 0\n array << num % 10\n num = num / 10\n end\n result = array.inject(:+)\n\n if result > 9\n digital_root(result)\n else\n result\n end\nend", "def digital_root(num)\n# sum variable \n# while loop => num > 0 \n# mod 10 add that to the sum var \n# div num by ten and reassign to num \n# check if sum >= 10 => digital_root(newNum) => return this\n\n sum = 0\n while num > 0 \n sum += num % 10 \n num /= 10\n end\n\n if sum >= 10 \n digital_root(sum)\n else \n sum \n end \nend", "def digital_root(num)\n return num if num < 10\n\n num = digital_root_step(num)\n\n (num > 10) ? digital_root(num) : num\nend", "def digital_root(n)\r\n while n > 9\r\n n = n.digits.inject(:+)\r\n end\r\n n\r\nend", "def digital_root(number)\n return number if number < 10\n\n digital_root((number / 10) + (number % 10))\nend", "def digital_root(integer)\r\n integer = integer\r\n loop do\r\n integer = integer.digits.sum\r\n break if integer.digits.size == 1\r\n digital_root(integer)\r\n end\r\n integer\r\nend", "def digital_root(num)\n until num < 10\n num = num.to_s.split(\"\")\n formatted = []\n num.each do |n|\n formatted << n.to_i\n end\n\n num = formatted.inject(:+)\n end\n num\nend", "def digital_root(num)\n\n while num > 10\n num = digital_root_step(num)\n end\n\n num\nend", "def digital_root(n)\n n < 10 ? n : digital_root(n.digits.sum)\nend", "def digital_root(num)\n\n total = digital_root_step(num)\n until total < 10\n total = digital_root_step(total)\n end\n total\nend", "def digital_root(num)\n if num < 10\n return num\n end\n recursion = num.to_s.split(\"\").map { |n| n.to_i }.reduce(:+)\n digital_root(recursion)\nend", "def digital_root1(number)\n return -1 if number < 0\n return number if number < 10\n\n sum = 0\n number.to_s.chars.map(&:to_i).each do |num|\n sum += num\n end\n\n if sum >= 10\n digital_root1(sum)\n else\n return sum\n end\nend", "def digital_root(n)\r\n digits = n.digits\r\n \r\n counter = digits.length\r\n\r\nuntil counter.size == 1\r\np sum = digits.sum\r\np sum.digits.sum\r\np counter -= 1\r\n end \r\n\r\nend", "def digital_root(num)\n until num < 10\n num = digital_root_step(num)\n end\n num\nend", "def digital_root(num)\n reductions = []\n\n if num < 10\n return num\n elsif num < 19\n until num < 10 \n reductions << (num / 10)\n num -= 1\n end\n reduced = reductions.reduce(:+)\n else\n num = num / 10\n reductions = []\n digital_root(num)\n end\n\nend", "def digital_root(n)\n # Return number if it can't be reduced further\n return n if n.size == 1\n # Evaluate the sum of digits use recursion on the sum\n digital_root(n.to_s.chars.inject {|sum, n| sum.to_i + n.to_i })\nend", "def digital_root(n)\n return n < 1 ? 0 : (n - 1) % 9 + 1\nend", "def digital_root(n)\n def sum_digits(n)\n digits = n.to_s.split(\"\") # This will be [\"1\", \"3\", \"2\", \"1\", \"8\", \"9\"]\n sum = 0\n digits.each do |number|\n sum += number.to_i\n end\n sum\n end\n value = sum_digits(n)\n loop do\n if value.to_s.length == 1\n return value\n else\n value = sum_digits(value)\n end\n end\nend", "def digital_root(n)\n until n < 10 do\n j = n\n n = 0\n until j < 1 do\n n += j % 10\n j /= 10\n end\n end\n return n\nend", "def digital_root(n)\n n < 10 ? n : digital_root(n / 10 + n % 10)\nend", "def digital_root(n)\n return n if n < 10\n \n n_arr = n.to_s.chars\n num = n_arr.first.to_i\n new_num = n_arr[1..-1].join.to_i\n digital_root(num + digital_root(new_num))\nend", "def digital_root(num)\n\nend", "def digital_root(num)\n\nend", "def digital_root(num)\n\nend", "def digital_root(n)\n arr = n.to_s.split('')\n if arr.length != 1\n tot = arr.inject(0){|sum,x| sum.to_i + x.to_i }\n while (tot >= 10)\n tot = tot.to_s.split('').inject(0){|sum,x| sum.to_i + x.to_i }\n end\n else \n return arr[0].to_i\n end\n return tot\n end", "def digital_root(int)\n\tif int.div(10) == 0\n\t\treturn int\n\telse\n\t\treturn digital_root(digital_sum(int))\n\tend\nend", "def digital_root(n)\n p '--- Jan-09-2017 problem2 --- '\n n = n.to_s.chars.map(&:to_i).reduce(:+) until n < 10\n n\nend", "def digital_root(n)\n num = 0\n n.to_s.split(\"\").each {|x| num += x.to_i}\n num.to_i > 9 ? digital_root(num.to_i) : num.to_i\nend", "def digital_root(number)\r\n # Your code goes here\r\n\r\n # int to array of numbers\r\n # seperate into digits\r\n # iterate\r\n # add them\r\n # return them (into another array?)\r\n\r\n #guard clause to make sure it's an integer?\r\n\r\n# if number !>= 0 && number !>= 1\r\n# if number == 0..9 dont run?\r\n\r\ndigits_arr = []\r\ndigital_root = []\r\n\r\nif !number.negative? # if number is not negative then run loop\r\n\r\n digits_arr = number.digits.reverse #this method wont work?\r\n\r\n #use to chr\r\n\r\n digital_root = digits_arr.sum\r\n\r\n root_digits = digital_root.digits.reverse\r\n\r\n digital_root_sum = \r\n\r\n\r\n digits_arr.each do |digit|\r\n #use sum method\r\n # if sum of digits_arr is == number then return true\r\n digit(i) + digit(i+1) #loop through add to next one - index?\r\n end\r\n\r\nelse \r\n return (-1) #if any negative argument is provided\r\n\r\nend\r\n\r\n\r\n# (&:to_i)\r\n# thats a short hand for map{|num| num.to_i}", "def digital_root(n)\n arr = n.to_s.split(\"\")\n total = []\n val, answer = 0, 0\n arr.each {|x| val += x.to_i}\n if val <= 9\n return val\n elsif val > 9\n total = val.to_s.split(\"\")\n total.each {|s| answer += s.to_i }\n return answer\n end\nend", "def digital_root(number)\n # return -1 if any negative number is provided\n if number < 0\n return -1\n end\n\n # split number into array \n number_array = number.to_s.scan(/\\d/).map {|i| i.to_i}\n # calculate sum of array while array.length > 1\n y = number_array.sum\n while y.to_s.length > 1\n y = number.to_s.scan(/\\d/).map {|i| i.to_i}\n y.sum\n end\n \nend", "def digital_root_alt(n)\n n < 10 ? n : digital_root(n.digits.sum)\nend", "def digital_helper(num)\n result = 0\n while num >= 10\n result += num % 10\n num = num/10\n end\n result + num\nend", "def digital_root(n)\n result = n.to_s.chars.map(&:to_i).inject(:+)\n return result if result.to_s.size == 1\n\n digital_root(result)\nend", "def sumdigit_r(num)\n if num < 10\n num\n else\n sumdigit_r(num/10) + num % 10\n end\nend", "def sumdig_r(num, result = 0)\n if num < 10\n result += num\n else\n result += num % 10\n result = sumdig_r(num / 10, result)\n end\n result\nend", "def digit_sum(num, digits)\n if digits == 1\n num\n else\n num % 10 + digit_sum(num / 10, digits - 1)\n end\nend", "def sum_digits(num)\n\nend", "def digital_sum(int)\n\tif int.div(10) == 0\n\t\treturn int.modulo(10)\n\telse\n\t\treturn int.modulo(10) + digital_sum(int.div(10))\n\tend\nend", "def super_digit(n)\n return n if n/10 == 0\n \n sum = n % 10\n while n/10 != 0\n n = n/10\n sum += n % 10\n end\n return super_digit(sum)\nend", "def super_digit(n)\n return n if n <= 9\n \n until n < 10\n sum = 0\n sum += (n % 10)\n sum += (n / 10)\n n = sum\n end\n\n return sum\nend", "def sumdig_r(n)\n return n if n < 10\n (n%10) + sumdig_r(n/10)\nend", "def sum_digits(n)\n return n if n <= 9\n n % 10 + sum_digits(n / 10)\nend", "def digit_sum (number)\n sum = 0\n base = 10\n while number > 0 do\n sum += number % base\n number /= base\n end\n return sum\nend", "def sumdig_r(n)\n\n # puts \"#{n} and n /10 is #{n/10} and n%10 is #{n%10}\"\n\n if (n<10) \n return n\n else\n return n%10 + sumdig_r(n/10)\n end\nend", "def super_digit(n)\n return n if n < 10\n\n sum = 0 \n\n while n > 0\n digit = n % 10\n n /= 10\n sum += digit\n end\n\n super_digit(sum)\n\nend", "def super_digit(n)\n #has to be a single digit \n if n < 10 \n return n\n else \n return super_digit(n.digits.sum)\n end \n \n \nend", "def super_digit(n, sum=0) \n return sum + n if n / 10 == 0\n return super_digit(super_digit(n/10, sum+(n%10)))\nend", "def super_digit(n)\n sum = 0;\n\n while n > 0 || sum > 9\n if n == 0\n n = sum\n sum = 0\n end\n sum += n % 10\n n /= 10\n end\n return sum\nend", "def super_digit(n)\n return n if n < 10 \n \n sum = 0\n until n == 0\n sum += n % 10\n n /= 10\n end\n \n return super_digit(sum) # I had n.digits.sum here earlier, but since #digits creates a new array, I thought this solution would be less expensive\nend", "def super_digit(n)\n return n if n < 10\n\n sum_digits = 0\n until n == 0\n sum_digits += n % 10\n n /= 10\n end\n\n super_digit(sum_digits)\nend", "def sum(num)\n digits = []\n sum = 0\n digits = num.digits\n sum = digits.sum\n return sum\nend", "def sum(num)\n num.digits.sum\nend", "def sum(num)\n num.digits.sum\nend", "def sum(num)\n num.digits.sum\nend", "def sum(num)\n num.digits.sum\nend", "def digital_root_best(n)\r\n n < 10 ? n : digital_root_best(n/10 + n%10)\r\nend", "def super_digit(n)\n return n.abs if n.abs < 10\n\n sum = recursive_digit_helper(n)\n\n return super_digit(sum)\nend", "def super_digit(n)\n while n > 9\n n = n % 10 + super_digit(n / 10)\n end\n return n\nend", "def super_digit(n)\n\n return n if n < 10\n super_digit(n.digits.sum)\n\nend", "def super_digit(n)\n return n if n < 10\n sum = super_digit_helper(n, 0)\n super_digit(sum)\nend", "def super_digit(n)\n return n if n < 10\n\n return super_digit(n.digits.sum)\nend", "def sum(number)\r\n number.digits.sum\r\nend", "def super_digit(n)\n if n >= 0 && n < 10 \n return n\n end\n digits_of_n = n.digits\n sum_digits = digits_of_n.sum\n\n return super_digit(sum_digits)\nend", "def super_digit(n)\n while n >= 10\n n = n % 10 + super_digit(n / 10)\n end\n return n\nend", "def sum_func(num)\n return num if num <= 1\n\n divided = num / 10\n moded = num % 10\n\n moded + sum_func(divided)\nend", "def super_digit(n)\n # base case\n return n if n/10 == 0\n \n # recursive case\n return super_digit(n/10 + n%10)\nend", "def super_digit(n)\n return n if n < 10\n return super_digit(n.digits.sum)\nend", "def super_digit(n)\n return n if n < 10\n super_digit(n.digits.sum)\nend", "def super_digit(n)\n return n if n < 10\n super_digit(n.digits.sum)\nend", "def sum(number)\n number.digits.sum\nend", "def sum(number)\n number.digits.sum\nend", "def sum_to_one_digit(num)\n if num < 1 or not num.is_a? Integer\n puts \"Num must be positive integer\"\n return false;\n end\n\n get_sum = ->(intgr) {\n digit_sum = 0\n intgr = intgr.to_s.split('')\n intgr.each do |i|\n digit_sum += i.to_i\n end\n return digit_sum\n }\n\n sum = get_sum.call(num)\n while sum.to_s.length > 1 do\n sum = get_sum.call(sum)\n end\n\n puts sum\n return sum\nend", "def super_digit(n)\n sum = 0\n\n if n < 10\n return sum + n\n else\n until n < 10\n sum += (n % 10)\n n /= 10\n end\n\n sum += n\n end\n\n return super_digit(n = sum)\nend", "def super_digit(n)\n sum = 0\n while n >= 10 do\n sum += n % 10\n n /= 10\n end\n sum += n\n return sum < 10 ? sum : super_digit(sum)\nend", "def digit_sum(int)\n return int.digits.sum\nend", "def super_digit(n)\n return n if n < 10 \n return super_digit(n.to_s.chars.map(&:to_i).sum)\nend", "def sum(num)\n\n\tarray_of_digits = num.digits\n\n\tarray_of_digits.sum\n\nend", "def sum(n)\n n.digits.sum\nend", "def super_digit(n)\n if 10 > n\n return n\n end\n\n last_digit = n % 10\n sum = n / 10 + last_digit \n \n return super_digit(sum)\nend", "def add_digits(num)\n return 0 if num == 0\n (num - 1) % 9 + 1\nend", "def sum(int)\n int.digits.sum\nend", "def super_digit(n)\n return n if n < 10\n sum = n.to_s.chars.map(&:to_i).sum\n return super_digit(sum)\nend", "def compute_number(digits)\n digits.length == 1 ? (digits.to_i) : (digits[-1].to_i + 10*compute_number(digits[0..-2]))\nend", "def sum_square_digits(q)\n sum = 0\n return 1 if q == 0\n until q == 0\n q, r = q / 10, q % 10\n sum += r*r\n end\n sum\nend", "def sum_of_digits(int)\n int.digits.sum\nend", "def sum(integer)\n integer.digits.sum\nend", "def super_digit(n)\n num_array = n.to_s.chars.map(&:to_i)\n sum = num_array.sum\n if sum <9\n return sum\n else \n return super_digit(sum)\n end\n \nend" ]
[ "0.85688275", "0.85077804", "0.83943987", "0.833194", "0.828805", "0.826393", "0.8259746", "0.82578325", "0.81562227", "0.8050004", "0.7998421", "0.7972975", "0.79618883", "0.79329646", "0.79190266", "0.79143006", "0.788124", "0.77757186", "0.77722305", "0.7758617", "0.7747764", "0.77338576", "0.7718214", "0.7644135", "0.7626723", "0.76178735", "0.7581541", "0.7569873", "0.7553802", "0.75353825", "0.751405", "0.7483229", "0.7483229", "0.7483229", "0.7452282", "0.7420445", "0.7377467", "0.7347868", "0.7302615", "0.727489", "0.7237145", "0.7187219", "0.7141274", "0.69737357", "0.6859773", "0.67944556", "0.6659948", "0.66260386", "0.6597749", "0.64259785", "0.64178693", "0.64167297", "0.6381349", "0.6359369", "0.6337805", "0.6317778", "0.62892395", "0.6286388", "0.6283319", "0.6261774", "0.6248655", "0.6246539", "0.6241805", "0.6241805", "0.6241805", "0.6241805", "0.6233706", "0.6192626", "0.61815286", "0.61790586", "0.61713487", "0.6144279", "0.61314684", "0.6130958", "0.61284775", "0.6113503", "0.61126065", "0.6108839", "0.6108828", "0.6108828", "0.6107624", "0.6107624", "0.6071144", "0.60702115", "0.6068796", "0.60558915", "0.6031849", "0.60318124", "0.60049856", "0.5991241", "0.59737444", "0.59686303", "0.5958587", "0.595637", "0.594523", "0.59361386", "0.59055936", "0.588575" ]
0.78652364
19
Write a method that doubles each element in an array. Assume all elements of the array are integers.
def doubler(array) array.map { |num| num * 2 } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def calculate_doubles(arr)\n arr.map {|a|a*2}\n\nend", "def calculate_doubles!(array)\n\t\n\tarray.map! { |num| num * 2}\nend", "def calculate_doubles(arr)\n doubled_array = []\n arr.each {|int| doubled_array.push(int * 2)}\n doubled_array\nend", "def calculate_doubles!(arr)\n arr.map! {|int| int * 2}\nend", "def double_array(array)\n array*2\nend", "def double_numbers(array)\n\tarray.map { |integer| integer * 2 }\t\nend", "def double_all array\n array.map { |i| i*2 }\nend", "def double_all(arr)\n doubles = []\n\n arr.each do |num|\n doubles.push(num * 2)\n end\n\n doubles\nend", "def double_array(array)\n\tn = [1, 2, 3]\n\tn * 2\nend", "def calculate_doubles(arr)\n array = []\n arr.each {|x| array << x + x}\n array\n\nend", "def double_array(input_array)\n \n double_array = []\n \n input_array.each do |number|\n double_array << number *= 2\n end\n return double_array\n\nend", "def calculate_doubles!(arr)\n\n arr.map! {|x| x + x}\n arr\n\nend", "def double_numbers(array)\n doubled_numbers = []\n array.each do |number|\n doubled_numbers << number * 2\n end\n return doubled_numbers\nend", "def double_array(arr)\n doubled_arr = arr.map do | element| \n element *2 \n end\n doubled_arr\nend", "def map(arr)\n i = 0\n # Double each item in the array and replace values.\n arr.each do |item|\n arr[i] = double(item)\n i += 1\n end\n # Return the new doubled array.\n # This is the result of the map function.\n return arr\nend", "def double_numbers(input_array)\n doubled_array =[]\n input_array.each {|num| doubled_array << num*2} \n doubled_array\nend", "def map_to_double(array)\n new_array = array.map{|n| n*2}\n return new_array\nend", "def map_to_double(source_array)\n \n i = 0\n new_array = []\n \n while i < source_array.length do\n new_array_value = source_array[i] * 2\n new_array << new_array_value\n \n i += 1\n end\n \n new_array\nend", "def calculate_doubles(array)\n\tmapped_array = array.map { |num| num * 2 }\nend", "def double_numbers(array)\n new_array = []\n\n array.each do |number|\n new_array << number *= 2\n end\n return new_array\nend", "def double_array(array)\n output_array = []\n\n array.each do |thing|\n output_array << thing * 2\n end\n\n return output_array\nend", "def double_eles(arr)\n arr.map do |ele|\n ele * 2\n end\nend", "def double_numbers!(numbers)\n counter = 0\n\n loop do\n break if counter == numbers.size\n\n numbers[counter] *= 2\n\n counter += 1\n end\n numbers\nend", "def double(*numbers)\n numbers.each do |x|\n puts x * 2\n end\nend", "def double_it(numbers)\n numbers.map{|number| number * 2}\nend", "def square_array(array)\n array.map do |element|\n element ** 2 \n end\nend", "def multiply_element(array)\n array.each do |x|\n x=x*x\n end\n end", "def square_array(array)\n array.collect {|num| num * num}\n \nend", "def map_to_double(source_array)\n array = []\n index = 0 \n \n while index < source_array.size do \n array.push(source_array[index] * 2)\n index += 1 \n end\n return array\nend", "def square_array(array)\n array.map! { |ele| ele ** 2 }\nend", "def double_numbers!(numbers)\n\n counter = 0\n loop do\n break if counter >= numbers.length\n numbers[counter] *= 2\n counter += 1\n end\n numbers # not really necessary, but good to have\n end", "def square_the_values(array_of_integers)\n # TODO\nend", "def double_each\n numbers = [1,2,3,4,5]\n doubled = []\n numbers.each do |number|\n doubled << number * 2\n end\n doubled\nend", "def double_it(numbers)\n numbers.map { |x| x * 2 }\nend", "def double_array(array)\n # your code here\nend", "def calculate_doubles!(arr)\n arr.map!{|a|a=a*2}\nend", "def doubler(array)\n array.map do |num|\n num *= 2\n end\n\nend", "def square_array(array)\n # Use an Enumerable to square every element in the passed in array\n # Return a new array of the results\n array.map do |n|\n n*n\nend\nend", "def multiply_me(array, int)\r\n\r\n arr = [] # empty array created\r\n\r\n i = 0 # iteration starts to multiply each item\r\n while i < array.length\r\n arr << array[i] * int # products collected\r\n i += 1\r\n end\r\n\r\n arr # result\r\nend", "def multiply(arr)\n arr.map { |i| i * 2 }\nend", "def double_it(numbers)\n numbers.map do |x|\n x * 2\n end\nend", "def multiply(array,mult)\n array.map{|num| num*mult}\nend", "def doubler(array)\r\n res = []\r\n array.each do |ele|\r\n res << ele * 2\r\n end\r\n res\r\nend", "def square_array(array)\n array.each_with_index do | num, index |\n array[index] = num * num\n end\nend", "def square_array(array)\n new_array = []\n array.each { |e| new_array << e ** 2 }\n new_array\nend", "def square_array(array)\n squared = []\n array.each { |element| squared << element ** 2 }\n squared\nend", "def square_array(some_array)\n some_array.collect {|num| num*num} \nend", "def multiply_by(array)\n return array.map { |el| el * 3}\nend", "def square_array(array)\n numbers = []\n array.each do |number| numbers << number ** 2\n end\n numbers\nend", "def square_array_2(array)\n array.collect { |i| i**2 }\n array\nend", "def multiply_els(array)\n\tarray.inject(1) { |num, item| num * item }\n\nend", "def square_array(some_array)\n some_array.map {|number| number ** 2}\nend", "def multiply_by_two(array)\n # double_numbers = []\n # array.each do |number|\n # double_numbers << number * 2\n # end\n # double_numbers\n array.map { |number| number * 2 }\nend", "def double_num(array)\n array.map do |num|\n if num % 2 == 0 then num*2\n else\n num\n end\n end\nend", "def double_numbers!(numbers)\n counter = 0\n\n loop do\n break if counter == numbers.size\n\n current_number = numbers[counter]\n numbers[counter] = current_number * 2\n\n counter += 1\n end\n\n numbers\nend", "def multiply_all_by(array, num)\n\n result = []\n array.each do |elem|\n result << elem * num\n end\n result\nend", "def multiply (array)\n\tarray.inject(1) do |result, element|\n\t\tresult * element\n\tend\nend", "def square_array(array)\narray.map { |to_square| to_square**2}\nend", "def square_array(array)\n\tsquared_nums = []\n\n array.each do |number|\n squared_nums << (number * number)\n end\n squared_nums\nend", "def square_array(array)\n new_array = []\n array.each{|a| new_array.push(a*a)}\n return new_array\nend", "def basic_9 (array_iterate)\n square_array = array_iterate.collect { |n| n * n}\n return square_array\nend", "def multiply_els(arr)\n\tarr.my_inject(1) do |res, i| \n\t\tres * i \n\tend\nend", "def square_array(array)\n square = []\n \n array.each do |num|\n square << num * num\n end\n square\nend", "def square_array(array)\n\n squared = []\n array.each do |num|\n squared.push(num * num)\n end\n\n squared\n \nend", "def square_array(numbers)\n numbers.map { |e| e ** 2 }\nend", "def custom_multiply(array, number)\n # Return a new array with the array that's passed in\n # as an argument multiplied by the number argument\n result = []\n number.times { array.each { |elem| result << elem } }\n result\nend", "def square_array2(array)\n return array.collect { |num| num ** 2 }\nend", "def multiply(array)\n array.inject(:*)\nend", "def multiply *array\n puts array.inspect\n array.flatten.inject(:*)\n end", "def multiply_by(num,arr)\n arr.map do |x|\n x * num\n end\nend", "def arr_product(arr)\n product = arr.reduce(:*)\n arr.map { |el| product / el }\nend", "def multiply_each (array, product=1)\n array.each do |x|\n product *= x\n end\n return product\nend", "def element_times_index(numbers)\n\tfor i in 0..numbers.length-1\n numbers[i] *= i\n end\n return numbers\nend", "def custom_multiply(array, number)\n result = []\n number.times { array.each { |element| result << element}}\n result\nend", "def multiply_by_two(array)\n array.map { |n| n * 2 }\nend", "def square_array_collect(array)\n array.collect{|num| num ** 2}\nend", "def square_array (array)\n\nnewarray = []\n\narray.each do |element|\n newarray.push(element**2) \nend\n\nnewarray\n\nend", "def compute_squares(array)\n arrayFinal = []\n array.each do |element|\n arrayFinal << element * element\n end\n return arrayFinal\nend", "def square_array_with_collect(array)\n array.collect{|element| element**2}\nend", "def squares(array)\n\t\n\tnew_array = array.map { |num| num * num}\n\tp new_array\nend", "def square_array(array)\n squared_array = []\n \n array.each do |number| \n squared_array << number**2 \n end\n \n squared_array\nend", "def doubler(numbers)\n\tdoubled_nums = [] # Creates empty array to store double nums\n\n\ti = 0\n\twhile i < numbers.length\n\t\told_elem = numbers[i] # Creates temporary variable to hold number for each iteration\n\t\tnew_elem = old_elem * 2 # Multiplies old element by two and saves to new variable\n\t\tdoubled_nums << new_elem\n\n\t\ti += 1 # Iterates upwards\n\tend\n\n\treturn doubled_nums\nend", "def arrMultiply(arr)\n (arr[0].to_i * arr[1].to_i).to_s\nend", "def square_array(array)\nnew_array = []\ncounter = 0\nwhile counter < array.length do\n new_array << array[counter] ** 2 #**squaring incrments\ncounter += 1 #increments plus 1 after squaring elements\nend\nreturn new_array #can also just write new_array without the retun before it \nend", "def multiply_els(array)\n array.my_inject(1) { |product, i| product * i }\nend", "def double_even_numbers(array)\n doubled_array = array.clone\n\n (array.length - 1).step(0, -2) do |i|\n doubled_array[i] += doubled_array[i]\n end\n\n doubled_array\n end", "def array_times_two(array)\n new_array = array.map{ |el| el * 2}\n end", "def map_to_square(source_array)\n \n i = 0\n new_array = []\n \n while i < source_array.length do\n new_array_value = source_array[i] ** 2\n new_array << new_array_value\n \n i += 1\n end\n \n new_array\nend", "def square_array(array)\n new_array = []\n array.each { |n| new_array << n*n }\n new_array\nend", "def square_array(array)\n squared = []\n count = 0\n while count < array.size do\n squared << (array[count] ** 2)\n count = count + 1\n end\n squared\nend", "def square_array(array)\n squared = []\n count = 0\n while count < array.size do\n squared << (array[count] ** 2)\n count = count + 1\n end\n squared\nend", "def square_array(array)\n counter = 0\n new_array = []\n while counter < array.length do\n new_array << array[counter] ** 2\n counter += 1\n end\n p new_array\nend", "def double_to_single_method(multiplied_integer_array)\n single_digit_array = []\n multiplied_integer_array.each do |value|\n if value > 9\n value = value - 9\n single_digit_array << value\n else\n value = value\n single_digit_array << value\n end\n end\n return single_digit_array\nend", "def mult5 array\n array.map do |value| \n value * 5 \n end\nend", "def arr_square()\n [1, 1, 2, 3, 5,].each{|x| puts x * x}\nend", "def square_array(some_array)\n array_squared = []\n some_array.each do |number|\n array_squared << number * number\n end \n return array_squared\nend", "def square_array(some_array)\n array_squared = []\n some_array.each do |item|\n array_squared << item*item\nend\n return array_squared\nend", "def doubler(arr)\n i = 0\n while i < arr.length\n arr[i] = arr[i] * 2\n i += 1\n end\n return arr\nend", "def multiply(array, num_two)\n array * num_two\nend" ]
[ "0.78323674", "0.7791123", "0.77871126", "0.7782026", "0.7671097", "0.7597189", "0.75927764", "0.7561571", "0.7515987", "0.747603", "0.73090553", "0.7289148", "0.7277876", "0.7251727", "0.7218472", "0.7213917", "0.7183743", "0.71794516", "0.71755594", "0.7169577", "0.7160739", "0.7057619", "0.7017276", "0.70084614", "0.6956769", "0.6950384", "0.6913133", "0.69033533", "0.689709", "0.68715197", "0.6862407", "0.68618864", "0.68293446", "0.6825241", "0.6788329", "0.6762002", "0.6750556", "0.6739801", "0.673786", "0.67292005", "0.6697936", "0.66746634", "0.6674629", "0.6656255", "0.6642003", "0.6635427", "0.66334254", "0.6625488", "0.66132534", "0.6610029", "0.66031754", "0.65980417", "0.6571571", "0.65677226", "0.6552207", "0.6538934", "0.6526868", "0.65099865", "0.648919", "0.64880383", "0.6480926", "0.6479923", "0.6476253", "0.6454091", "0.6438803", "0.643171", "0.6405329", "0.63975334", "0.6381964", "0.63751453", "0.6362556", "0.63514227", "0.6350817", "0.6350751", "0.6349396", "0.6326644", "0.632481", "0.6317585", "0.6314587", "0.6303339", "0.6301355", "0.6291486", "0.6289935", "0.62831366", "0.6281859", "0.6274366", "0.62690914", "0.62674284", "0.62612575", "0.6256546", "0.6256546", "0.6244386", "0.6238046", "0.6216764", "0.6214802", "0.62021685", "0.6199544", "0.61920583", "0.6181063" ]
0.6613417
49
Define a method `primes(num)` that returns an array of the first "num" primes. You may wish to use an `is_prime?` helper method.
def is_prime?(num) return false if num < 2 (2...num).none? { |factor| num % factor == 0 } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def primes(num)\n\twhole_array = (2..num).to_a\n\tprime_array = [whole_array.shift]\n\n\tuntil whole_array == []\n\t\twhole_array.delete_if { |x| x % prime_array.last == 0 }\n\t\tprime_array << whole_array.shift\n\tend\n\tprime_array\nend", "def get_primes num\n primes = []\n for i in 0 ... num do\n if check_prime?(i) == true\n primes.push(i)\n end\n end\n p primes\nend", "def first_n_primes(n)\n\t return \"n must be an integer.\" unless n.is_a? Integer\n\t return \"n must be greater than 0.\" if (n<=0)\n\n prime_array||=[]\n\tprime = Prime.new\n\tn.times {prime_array << prime.next } \n\tprime_array\nend", "def primes_less_than(num)\n require 'prime'\n arr = []\n Prime.each(num) do |prime| arr.push(prime)\n end\n num.prime? ? arr.pop : arr\n return arr\n end", "def primes_less_than(num)\n arr = []\n (2...num).each do |el|\n if is_prime?(el)\n arr << el\n end\n end\n arr\nend", "def primes_less_than(num)\n res = []\n (2...num).each do |i|\n res.push(i) if is_prime?(i) == true\n end\n res\nend", "def first_n_primes(n)\n\n #unless n.is_a? Integer\n # return \"n must be an integer.\"\n #end\n return \"n must be an integer.\" unless n.is_a? Integer\n\n #if n <= 0\n # return \"n must be greater than 0.\"\n #end\n return \"n must be greater than 0.\" if n <= 0\n \n #prime_array = [] if prime_array.nil?\n prime_array ||= []\n \n prime = Prime.new\n #for num in (1..n)\n # prime_array.push(prime.next)\n #end\n # n.times { prime_array.push(prime.next) }\n n.times { prime_array << prime.next }\n \n #return prime_array\n prime_array # implicit return!\n\nend", "def first_n_primes(n)\n\n \"n must be an integer.\" unless n.is_a? Integer\n\n \"n must be greater than 0.\" if n <= 0\n \n prime_array ||= []\n \n prime = Prime.new\n n.times { prime_array << prime.next }\nend", "def first_n_primes(n)\n\n unless n.is_a? Integer\n return \"n must be an integer.\"\n end\n\n if n <= 0\n return \"n must be greater than 0.\"\n end\n \n prime_array = [] if prime_array.nil?\n \n prime = Prime.new\n for num in (1..n)\n prime_array.push(prime.next)\n end\n return prime_array\nend", "def first_n_primes(n)\n\n return \"n must be an integer.\" unless n.is_a? Integer\n return \"n must be greater than 0.\" if n <= 0\n \n prime_array ||= []\n \n prime = Prime.new\n n.times {\n prime_array << prime.next \n }\n prime_array\nend", "def primes_less_than (num)\n arr=[]\n for n in 2..(num-1)\n if is_prime?(n)\n arr.push(n)\n end\n end\n p arr\n return arr\nend", "def pick_primes(numbers)\n\tprimes = []\n \tnumbers.each do |num| \n \tif isPrime(num) \n \tprimes.push(num)\n end\n end\n \treturn primes\nend", "def primes (number)\n primes_array = []\n Prime.each(number) do |p|\n primes_array.push(p)\n end\n\n primes_array\nend", "def primes()\n return [] if @number < 2\n # build Boolean array to use for sieve with buffer to align indices\n sieve_array = Array.new(2, false) + Array.new(@number-1, true)\n # perform Sieve of Eratosthenes eliminations\n (2..Math.sqrt(@number).to_i).each do |i|\n (i**2..@number).step(i) {|j| sieve_array[j] = false} if sieve_array[i] == true\n end\n # return numbers by corresponding index that are still true\n (2..@number).collect {|index| index if sieve_array[index] == true}.compact\n end", "def get_primes\n j = 0\n\n while j < @limit \n prime_number = is_prime\n if prime_number\n @prime_numbers.push(prime_number)\n j += 1\n end\n @count += 1\n end\n\n return @prime_numbers\n end", "def primes\n\t\t# primes = []\n\t\t# primes << 2\n\t\tprimes = [2] # combined previous two lines\n\t\tx = 3\n\n\t\tloop do\n\t\t\tbreak if primes.length == @n_primes # End loop when desired number has been calculated\n\t\t# while primes.length < @n_primes # Alternative 1 to loop do, break\n\t\t# until primes.length == @n_primes # Alternative 2 to loop do, break\n\t\t\ty = 3\n\t\t\ty += 2 until x % y == 0 # Loop to test if x is divisible by any odd number below it, y\n\t\t\tprimes << x if x == y # If the (odd) number was not divisible by any (odd) below itself, it is a prime\n\t\t\tx += 2\n\t\tend\n\n\t\treturn primes\n\tend", "def find_primes(num,prime_array=[])\n i = 2\n until num % i == 0 \n i += 1\n end\n prime_array << i\n return prime_array if num == i\n find_primes(num/i, prime_array) \nend", "def prime(number)\n prime_numbers = []\n (2..number).each do |current_number|\n if is_prime? current_number\n prime_numbers << current_number\n end\n end\n return prime_numbers\nend", "def all_primes(number)\n primes = []\n (2...number).each do |num|\n if prime?(num)\n primes << num \n end\n end\n primes\nend", "def prime_numbers(num)\n all_factors = factors(num)\n only_prime = []\n i = 0\n while i < all_factors.length\n if prime?(all_factors[i])\n only_prime += all_factors[i]\n end\n i += 1\n end\n only_prime\n end", "def primes\n return [] if self == 0\n return \"don't do that\" if self < 0\n list = [2]\n test = 3\n until list.length == self\n list << test if test.is_prime?\n test += 2\n end\n list\n end", "def pretentious_primes(arr, num)\n new_arr = []\n if num > 0\n arr.each do |ele|\n i = ele + 1\n count = 0\n while true\n if is_prime?(i)\n count += 1\n end\n if count == num\n new_arr << i\n break\n end\n i += 1\n end\n end\n else\n num = -1 * num\n end\n new_arr\nend", "def prime_list(number_of_primes)\n return [] if number_of_primes < 1\n prime_numbers = Array.new\n for num in 2..9999999 do\n if is_prime_num(num, prime_numbers)\n prime_numbers.push(num)\n break if prime_numbers.length == number_of_primes\n end\n end\n return prime_numbers\n end", "def pick_primes(numbers)\n return numbers.select { |num| prime?(num)}\nend", "def pretentious_primes(arr, num)\nend", "def pick_primes(numbers)\r\n return numbers.select { |num| prime?(num)}\r\nend", "def primes(num)\n \nend", "def primes(num)\n \nend", "def primes(num)\n \nend", "def primes(num)\n \nend", "def get_primes(limit)\n primes = []\n (2...limit).each do |number|\n primes << number if is_prime?(number)\n end\n primes\nend", "def select_primes(array)\n array.select { |num| is_prime?(num) }\nend", "def prime_factors(num)\n arr = []\n (1...num).each do |number|\n if is_prime(number) && num % number == 0\n arr << number\n end\n end\n return arr\nend", "def pick_primes(numbers)\n numbers.select { |num| prime?(num) }\nend", "def prime_factors(num)\n require \"prime\"\n primes = []\n Prime.each{|prime| primes << prime if num % prime ==0 ; break if prime > num }\n primes\nend", "def prime_factors(num)\n arr = []\n\tPrime.each(num) { |prime| num % prime == 0 ? arr.push(prime) : false }\n return arr\nend", "def primes_less_than(num)\n\toutput = []\n\t(2...num).each do |n|\n\t\toutput << n if is_prime?(n)\n\tend\n\toutput\nend", "def primes\n return [] if max_prime < 2\n\n candidates.each do |prime,_|\n # skip numbers we already know NOT to be prime (from previous iterations)\n next if candidates[prime] != :prime\n\n # find the prime number candidates greater than the current prime number\n candidates.select { |n,_| candidates[n].eql?(:prime) && n > prime }\n .each do |num,_|\n # mark numbers evenly divisible by the current prime as NOT PRIME\n @candidates[num] = :not_prime if (num % prime) == 0\n end\n end\n\n # convert numbers still marked as prime to an array of numbers\n candidates.map { |num,value| num if value.eql? :prime }.compact\n end", "def get_primes limit\n\tnums = (1...limit).select { |n| n.prime? }\n\n\tp nums\nend", "def prime (n)\n\n\t#create an Array\n\tprime_num = []\n\n\tfor num in (2..n)\n\t\tis_prime = factors(num)\n\t\tif (is_prime.length ==2)\n\t\t\tprime_num.push(num)\n\t\tend\n\tend\n\treturn prime_num\nend", "def primes(max)\n primes = []\n number = 2\n \n while number <= max\n primes << number if is_prime? number\n number += 1\n end\n primes\nend", "def primes(max)\n primes = []\n number = 2\n \n while number <= max\n primes << number if is_prime? number\n number += 1\n end\n primes\nend", "def get_primes(qyt)\n Prime.first qyt\nend", "def primes (n)\n return (1..n).select { |x| x.prime? }\nend", "def prime_factors(num)\n arr = (2..Math.sqrt(num).round).to_a\n primes = arr.each do |i|\n arr.select! {|j| j%i != 0 or j==i}\n end\n pfacts = primes.select {|i| num%i == 0}\n\n return [num] if pfacts.empty?\n return pfacts\nend", "def prime_factors(num)\n\tprimeFactors = []\n \t\n \t(1..num).each do |i|\n \tif num % i == 0 && isPrime(i)\n \tprimeFactors.push(i)\n end\n end\n \n \treturn primeFactors\nend", "def nth_Prime(num)\n\tprime_array = [2]\n\ti = 3\n\n\twhile prime_array.length < num\n\t\ti += 2\n\t\tif (i % 2 == 0)\n\t\t\tnext_num\n\t\tend\n\n\t\tprime = true\n\t\tprime_array.each do |j|\n\t\t\tif (i % j == 0)\n\t\t\t\tprime = false\n\t\t\t\tbreak\n\t\t\tend\n\t\tend\n\n\t\tif prime\n\t\t\tprime_array << i\n\t\tend\n\tend\n\tprime_array.last\nend", "def prime_factors(num)\n arr = factors(num)\n new_arr = []\n arr.each do |n|\n new_arr << n if prime?(n)\n end\n new_arr\nend", "def pick_primes(numbers)\n numbers.select { | n | is_prime(n) }\nend", "def prime_factors(num)\n arr = []\n (1..num).each { |n| arr << n if num%n==0 && prime?(n)}\n return arr\nend", "def prime_factors(num)\n factors = []\n # Store all the factors in an array\n (2..num).each do |divisor|\n if num % divisor == 0\n factors << divisor\n end\n end\n\n # loop through factors array and return only the prime prime prime factors\n if factors.length > 0\n return factors.select { |factor| checkIfPrime(factor) }\n else\n return factors\n end\nend", "def prime_factors(integer)\n primes = Prime.take(20)\n arr = []\n i = 0\n loop do \n if integer % primes[i] == 0\n integer = integer / primes[i]\n arr << primes[i]\n else\n i += 1\n end\n break if integer == 1\n end\n arr\nend", "def primes (n)\r\n primes = Array.new(n) { |index| index+=1 }\r\n return primes.select { |x| factors(x).length == 2 }\r\nend", "def prime_factors(num)\n factors = factors(num)\n result = []\n factors.each do |fac|\n if prime?(fac)\n result << fac\n end\n end\n result\nend", "def prime_factors(num)\n array = []\n (1..num).each do |number|\n array << number if prime?(number) && num % number == 0\n end\n array.sort!\nend", "def prime_factors(num)\n prime_facts = []\n \n (1..num).each do |i|\n if num % i == 0 && prime?(i)\n prime_facts << i\n end\n end\n \n return prime_facts\n end", "def prime_numbers\n # start with the first prime number\n primes = [2]\n # find the rest of the prime numbers\n (2..1000).each do |i|\n add_next_prime_number(primes)\n end\n return primes\nend", "def first_n_primes(n)\n return \"n must be an integer.\" unless n.is_a? Integer\n return \"n must be greater than 0.\" if n <= 0\n return Prime.first n\nend", "def primes(max)\n array = []\n i = 2\n while i < max.abs\n if is_prime?(i)\n array << i\n end\n i += 1\n end\n array\nend", "def find_prime_numbers(num)\n\tarr =[]\n (2..num).each{|x| arr.push(x)}\n\n i = 0\n p = arr[i]\n\n while p != arr[-1]\n\t arr.delete_if{|n| n%p == 0 && n != p}\n\t i+= 1\n\t p = arr[i]\n end\n return arr\nend", "def prime_factors(num)\n\n if prime?(num)\n return [num]\n end\n\n primes = (2...num).to_a.select { |factor| prime?(factor) }\n\n \n \n factors = []\n\n while num > 1\n candidate = primes.shift\n\n if num % candidate == 0\n factors << candidate\n while num % candidate == 0\n num /= candidate\n end\n end\n end\n\n return factors\n \nend", "def sieve(n)\n # initialize an empty array (this will store all primes between 2 and n)\n prime_array = []\n for i in 2..n\n if(is_prime(i))\n # if 'i' is a prime number, add it to the array\n prime_array.push(i)\n end\n end\n # finally, we'll return our array of prime numbers\n return prime_array\nend", "def find_primes(number)\n\tprimes = []\n\ttry_num = 2\n\tx = 2\n\tfactors = []\n\t\n\twhile primes.length != number\n\t\t#puts \"primes : #{primes}\"\n\t\t#puts \"try_num : #{try_num}\"\n\t\t#puts \"x : #{x}\"\n\t\t#puts \"factors : #{factors}\"\n\t\t\n\t\tif factors.length >= 1 && factors[0] != try_num\n\t\t\t#puts \"#{try_num} is not prime\"\n\t\t\ttry_num += 1\n\t\t\tx = 2\n\t\t\tfactors = []\n\t\t \n\t\telsif try_num % x == 0 && x == try_num\n\t\t\t#puts \"#{try_num} is prime\"\n\t\t\tprimes << try_num\n\t\t\ttry_num += 1\n\t\t\tx = 1\n\t\t\n\t\telsif try_num % x == 0\n\t\t\t#puts \"#{x} is factor of #{try_num}\"\n\t\t\tfactors << x\n\t\telse\n\t\t\n\t\tend\n\t\t\n\t\tx += 1\n\tend\n\tputs primes\n\treturn primes\nend", "def prime_factors(num)\n facs = factors(num)\n p_facs = []\n facs.each{|n| p_facs.push(n) if prime?(n)}\n p_facs\nend", "def first_n_primes(n)\n return \"n must be an integer.\" unless n.is_a? Integer\n return \"n must be greater than 0.\" unless n > 0\n return Prime.first n\nend", "def prime_factors(num)\n\tfactors(num).select { |n| prime?(n) }\nend", "def first_n_primes(n)\n return \"n must be an integer.\" unless n.is_a? Integer\n return \"n must be greater than 0.\" if n <= 0\n Prime.first n\nend", "def first_n_primes(n)\n return \"n must be an integer.\" unless n.is_a? Integer\n return \"n must be greater than 0.\" if n <= 0\n Prime.first n\nend", "def print_prime\n @n_primes = get_n_primes\n return [] if @n_primes == 0\n p_arr_len = @prime_numbers.length\n return @prime_numbers[0..@n_primes] if p_arr_len >= @n_primes\n (p_arr_len > 1) ? (n = @prime_numbers.last) : (n = 3)\n until @prime_numbers.length == @n_primes do\n @prime_numbers.push(n) if @prime_cache[n]\n (@prime_numbers.push(n) && @prime_cache[n] = true) if is_prime(n)\n n += 1\n end\n @prime_numbers\n end", "def first_n_primes(n)\n\n return \"n must be an integer.\" unless n.is_a? Integer\n\n return \"n must be greater than 0.\" if n <= 0\n\n return Prime.first n\n\nend", "def select_primes(possible_primes)\n possible_primes.select { |num| is_prime?(num) }\nend", "def prime_factors(num)\n prime_facts = []\n\n (1..num).each do |i|\n if num % i == 0 && prime?(i)\n prime_facts << i\n end\n end\n\n return prime_facts\nend", "def prime_factors(num)\n #initialize an array\n primeFacts = []\n \n #iterate each number from 1 until num\n (1..num).each do |nums|\n #if the remainder is 0 and nums is prime push nums\n if num % nums == 0 && prime?(nums)\n primeFacts << nums\n end\n end\n return primeFacts\nend", "def first_n_primes(n)\n\n # return \"n must be an integer.\" unless n.respond_to?(:next)\n return \"n must be an integer.\" unless n.is_a? Integer\n\n return \"n must be greater than 0.\" if n <= 0\n\n Prime.first n\nend", "def primeArray(number)\n @sieve = Array.new(number)\n \n for count in 2..Math.sqrt(number)\n next if @sieve[count]\n \n for inner_count in 2..number/count\n @sieve[count * inner_count] = true\n end\n end\n @sieve\nend", "def getPrimes()\n oldlimit = $primelimit + 1\n $primelimit *= 2\n\n for i in oldlimit...$primelimit\n isPrime = true\n $primes.each do |p|\n if i % p == 0\n isPrime = false\n break\n end\n end\n if isPrime\n $primes << i\n end\n end\n\nend", "def prime?(num)\r\n # your code goes here\r\n prime = []\r\n\r\n for i in 1 .. num\r\n if num % i == 0\r\n prime << i\r\n end\r\n end\r\n prime.length == 2\r\nend", "def specific_prime(n)\n\na = (2..n) # list of integers 2 through \nprimes = Array.new\n\nprimes = a.select { |x| (2..Math.sqrt(x)).none? { |d| (x % d).zero? }}\n\nputs primes[10000]\n# answer => 104,743\n\nend", "def isPrime(number)\n\t\tdivisores=[]\n\t\t1.upto(number){|num| \n\t\t\tif (number % num == 0 )\n\t\t\t\tdivisores.push num\n\t\t\tend\t\t\n\t\t}\n\t\treturn divisores\n\tend", "def largest_prime(num)\n\tresult = []\n\ti = 2\n\twhile i <= num\n\t\tif is_prime?(i)\n\t\t\tif num % i == 0 # Check for whole number if % by i \n\t\t\t\tnum = num / i # Update the num\n\t\t\t\tresult << i # Add i to the array\n\t\t\t\ti = 2 # Reset i to 2\t\n\t\t\tend\t\n\t\tend\n\t\ti += 1\t\n\tend\n\tresult\nend", "def prime_factors(num)\n factors(num).select { |factor| prime?(factor) }\nend", "def prime?(num)\n if num <= 1\n false\n elsif num == 2 || num == 3\n true\n elsif num > 3\n list_array = (2..num-1).to_a\n list_array.none? { |i| num % i == 0 }\n end\nend", "def prime_number(n)\n res = []\n prime = Array.new(n + 1, true)\n (2..n).each do |x|\n num = x * x\n break if num > n\n\n if prime[x]\n (num..n).step(x).each do |multiples|\n prime[multiples] = false\n end\n end\n end\n \n (2..n).each do |primes|\n res << primes if prime[primes]\n end\n res\nend", "def prime_factors(num)\n primes = (2..num).select { | n | isprime?(n) }\n primes.select { |prime| num % prime == 0 }\nend", "def collect_primes(number)\n \n sieve = [nil, nil] + (2 .. number).to_a\n \n (2 .. Math.sqrt(number)).each do |n|\n next unless sieve[n]\n (n*n).step(number, n) do |num|\n sieve[num] = nil\n end\n end\n \n primes = []\n sieve.each do |x|\n if x != nil\n primes << x\n end\n end\n return primes\nend", "def ruby_prime(n1, n2)\n prime_numbers = []\n (n1..n2).each do |num|\n if Prime.prime?(num)\n prime_numbers << num\n end\n end\n prime_numbers\nend", "def prime_factors(num)\r\n # your code goes here\r\n prime_factors = []\r\n for i in 1 .. num\r\n if num % i == 0 && prime?(i)\r\n prime_factors << i\r\n end\r\n end\r\n prime_factors\r\nend", "def next_prime(array)\r\n array.map {|num| prime?(num) ? next_prime(num) : num}\r\nend", "def nth_prime(n)\n nums = (0..10000).to_a\n result = []\n\n nums.each do |i| \n if prime?(i) == true\n result.push(i)\n end\n end\n\n\n return result[n]\nend", "def prime_factors(num)\n facs = (1..num).select {|x| num % x == 0 }\n facs.select {|x| prime?(x)}\nend", "def primes(top)\n n = 2\n primes = []\n loop do\n primes << n if (2..Math.sqrt(n)).all? {|x| n % x != 0 }\n return primes.last if primes.count == top\n n += 1\n end\nend", "def find_primes(int1, int2)\n nums = (int1..int2).to_a\n nums.select { |num| is_prime?(num) }\nend", "def GetPrimes (maximum)\n\t# Clear the input vector in case there is existing data\n\tprimes = []\n\t\n\t# There are no primes less than 2\n\tif (maximum < 2)\n\t\treturn\n\tend\n\t\n\t# Construct and execute the Sieve\n\tsqrtMaximum = Math.sqrt(maximum).to_i\n\tprimeTracker = Array.new(maximum,true)\n\t\n\tfor i in 2...sqrtMaximum\n\t\tif (!primeTracker[i])\n\t\t\tnext\n\t\tend\n\t\t\n\t\tfor j in ((i+i)...maximum).step(i)\n\t\t\tif (j < 0) # Guard against integer overflow\n\t\t\t\tbreak\n\t\t\tend\n\t\t\t\n\t\t\tprimeTracker[j] = false\n\t\tend\n\tend\n\t\n\treturn primeTracker\nend", "def prime_numbers\n s = (0..self).to_a\n s[0] = s[1] = nil\n s.each do |p|\n next unless p\n break if p * p > self\n (p*p).step(self, p) { |m| s[m] = nil }\n end\n s.compact\n end", "def find_primes_magic_value(magic_number)\n @primes = []\n number = 2\n while magic_number > 1\n if magic_number % number == 0\n magic_number /= number\n @primes << number\n end\n number += 1\n end\n\n end", "def primes_array(options = {})\n limit = options[:limit] || ARRAY_DEFAULT_LIMIT\n field = Array.new(limit+1, true)\n # sieve the number field\n 3.step(field.size / 2, 2) do |k|\n (3 * k).step(field.size, 2 * k) do |n|\n field[n] = false\n end\n end\n \n # collect the field into an array, starting with 3\n primes = [ 2 ]\n 3.step(field.size, 2) do |n|\n primes << n if field[n] \n end\n primes\n end", "def prime_factors(num)\n facts = []\n\n (1..num).each do |i|\n if num % i == 0 && prime?(i)\n facts << i\n end\n end\n \n return facts\nend", "def divisors(num)\n divisors_results = [] \n 2.upto(num - 1) do |n|\n divisors_results << n if num % n == 0\n end\n return \"#{num} is prime\" if divisors_results.empty?\n divisors_results\nend", "def primes(n)\nend", "def prime_factors(num)\n factors(num).select {|n| prime?(n)}\nend", "def nth_prime(num)\n\ti = 2\n\tprime_numbers = []\n\twhile true\n\t\tif is_prime?(i)\n\t\t\tprime_numbers << i\n\t\tend\n\t\tif prime_numbers.length == num\n\t\t\treturn prime_numbers[num-1]\n\t\tend\n\t\ti +=1\n\tend\nend" ]
[ "0.7643744", "0.7534903", "0.7441485", "0.7402979", "0.7356517", "0.73547095", "0.7348984", "0.73454016", "0.73451585", "0.7342191", "0.72874844", "0.72853553", "0.7260889", "0.7200118", "0.71627927", "0.7137368", "0.70895994", "0.70784783", "0.70361525", "0.70328224", "0.70058894", "0.6995304", "0.6980766", "0.6974524", "0.6958056", "0.6954386", "0.6952887", "0.6952887", "0.6952887", "0.6952887", "0.69424415", "0.6933915", "0.692781", "0.6914787", "0.6911015", "0.6899711", "0.6893694", "0.6893547", "0.6866918", "0.6860576", "0.6860081", "0.6860081", "0.68542266", "0.6820874", "0.68125105", "0.67888635", "0.6771829", "0.6755133", "0.67423034", "0.6703896", "0.66658145", "0.6653913", "0.6633708", "0.6622278", "0.6618865", "0.6612722", "0.6593363", "0.6583085", "0.6577722", "0.6577077", "0.65727365", "0.65576994", "0.65502614", "0.6547488", "0.65468127", "0.6543134", "0.6531078", "0.6531078", "0.6510135", "0.6510068", "0.65048194", "0.6497854", "0.6495996", "0.64913356", "0.648232", "0.647221", "0.64660543", "0.64619404", "0.64550865", "0.64361066", "0.64338076", "0.6421851", "0.6411359", "0.64048123", "0.640352", "0.6400143", "0.63857466", "0.6384295", "0.63806796", "0.63534725", "0.6353284", "0.6333531", "0.63214135", "0.63184583", "0.6307352", "0.63069993", "0.6306072", "0.6298397", "0.62819225", "0.62750524", "0.6264414" ]
0.0
-1
Write a method that returns the factors of a number in ascending order.
def factors(num) return nil if num <= 0 return [1] if num == 0 (1..num).select { |i| (num % i) == 0 } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def factors(num)\n\t((1..num).select {|n| num % n == 0 } ).sort\nend", "def factors(num)\n factors = []\n for factor in 1..num\n factors << factor if num % factor == 0\n end\n factors.sort\nend", "def factors(num)\n\nend", "def factors(num)\n\nend", "def factors(num)\n\nend", "def factors(num)\n result = []\n for i in 1..num\n if num % i == 0\n result << i\n end\n end\n result.sort\nend", "def factors(num)\n array = []\n (1..num).each do |number|\n array << number if num % number == 0\n end\n array.sort!\nend", "def factors(number)\r\n divisor = number\r\n factors = []\r\n while divisor > 0 do \r\n factors << number / divisor if number % divisor == 0\r\n divisor -= 1\r\n end \r\n factors\r\nend", "def factors(number)\n divisor = number\n factors = []\n #begin\n\twhile divisor > 0\n factors << number / divisor if number % divisor == 0\n divisor -= 1\n #end until divisor == 1\n\tend\n factors\nend", "def factors(num)\n factors = []\n (1..num).each do |factor|\n factors << factor if num % factor == 0\n end\n factors\nend", "def factors(number)\n fs = [1,number]\n (2..Math.sqrt(number).to_i).each do |i|\n if number % i == 0\n fs << i\n fs << number/i unless number/i == i\n end\n end\n fs.sort\n end", "def get_factors(num)\n factors = []\n (1..num).each do |i|\n factors << i if num % i == 0\n end\n factors\nend", "def factors(number)\n dividend = 1\n divisors = []\n while dividend <= number\n divisors << dividend if number % dividend == 0\n dividend += 1\n end\n divisors\nend", "def factors(number)\n divisor = number\n factors = []\n while divisor > 0\n factors << number / divisor if number % divisor == 0\n divisor -= 1\n end\n factors\nend", "def factors(num)\n factors = []\n (1..num).each do |n|\n factors << n if num % n == 0\n end\n factors\nend", "def factors(num)\n factors = []\n (1..num/2).each {|n| factors << n if num % n == 0}\n factors << num\nend", "def factors_of(num)\n factor_arr = []\n\n (1...num).reverse_each do |factor|\n if (num % factor).zero?\n factor_arr << factor\n end\n end\n\n factor_arr\nend", "def factors(number)\n divisor = number\n factors = []\n loop do\n factors << number / divisor if number % divisor == 0\n divisor -= 1\n break if divisor == 0\n end\n factors\n \nend", "def factors_of(num)\n # Write your code here\nend", "def factors(number)\n divisor = number\n factors = []\n while divisor > 0 do\n factors << number / divisor if number % divisor == 0\n divisor -= 1\n end\n factors\nend", "def factors(number)\n divisor = number\n factors = []\n while divisor > 0 do\n factors << number / divisor if number % divisor == 0\n divisor -= 1\n end\n factors\nend", "def factors(number)\n divisor = number\n factors = []\n while divisor > 0 do\n factors << number / divisor if number % divisor == 0\n divisor -= 1\n end\n factors\nend", "def factors(number)\n divisor = number\n factors = []\n while divisor > 0 do\n factors << number / divisor if number % divisor == 0\n divisor -= 1\n end\n factors\nend", "def factors(number)\n divisor = number\n factors = []\n while divisor > 0 do\n factors << number / divisor if number % divisor == 0\n divisor -= 1\n end\n factors\nend", "def factors(number)\n divisor = number\n factors = []\n while divisor > 0 do\n factors << number / divisor if number % divisor == 0\n divisor -= 1\n end\n factors\nend", "def factors(number)\n divisor = number\n factors = []\n while divisor > 0\n factors << (number / divisor) if ((number % divisor) == 0)\n divisor -= 1\n end\n factors\nend", "def factors(number)\n divisor = number\n factors = []\n loop do\n if number == 0 || number < 0\n break\n else factors << number / divisor if number % divisor == 0\n divisor -= 1\n break if divisor == 0\n end\n end\n factors\n end", "def factors_of(num)\n \n index = 1 \n \n factors = []\n \n while index <= num\n if num % index == 0 \n factors << index \n end \n \n index += 1 \n end \n \n return factors \n \nend", "def find_factors(number)\n factors =[]\n for i in 1..number\n factors << i if number % i == 0\n end\n factors\nend", "def factors( n )\n p = Primer.ld( n )\n return n if p == n\n factors n.div( p )\nend", "def factors(num)\n 1.upto(num).select { |x| num % x == 0 }\nend", "def factors(number)\n divisor = number\n factors = []\n loop do\n break if number <= 0\n factors << number / divisor if number % divisor == 0\n divisor -= 1\n break if divisor == 0\n end \n factors\nend", "def factors_of(num)\n factors = []\n \n i = 1\n while i <= num\n # if num is divided by i\n if num % i == 0\n factors << i\n end\n \n i += 1\n end\n \n return factors\n end", "def factors(number)\n divisor = number\n factors = []\n loop do\n break if divisor <= 0\n factors << number / divisor if number % divisor == 0\n divisor -= 1\n end\n factors\nend", "def factors(num)\n output_arr = []\n\n (1..num).each do |el|\n if num % el == 0\n output_arr << el\n end\n end\n\n output_arr.sort\nend", "def factors(num)\r\n # your code goes here\r\n\r\n factors = []\r\n for i in 1 .. num\r\n if num % i == 0\r\n factors << i\r\n end\r\n end\r\n factors\r\nend", "def factors(number)\n divisor = number\n factors = []\n begin\n # evaluate statement on right side of shovel operator and if\n # divisor evenly divides number then add into factors array \n factors << number / divisor if number % divisor == 0\n # decrement divisor by 1\n divisor -= 1\n # stops when divisor is 0\n end until divisor == 0\n \n # return all factors in an array that divides evenly with \n # the number passed in as an argument when calling the function\n factors\nend", "def factors(number)\n divisors = []\n # 1 is always a divisor\n divisors << 1\n if number > 1\n # target number is also always a divisor\n divisors << number\n # start looking for other divisors from 2 on up.\n i = 2\n while (i <= Math.sqrt(number).to_i)\n # if number is evenly divisible by i, then retain i, and possibly also\n # the division of number/i.\n if (number % i == 0)\n divisors << i\n divisors << number/i if (i != number/i)\n end\n i += 1\n end\n divisors.sort!\n end\n divisors\nend", "def factors(num)\n arr = [1]\n i = 1\n while i <= num\n arr << i if (num % i).zero?\n i += 1\n end\n arr.uniq.sort\nend", "def factors n\n 1.upto(Math.sqrt(n)).select{ |x| (n % x).zero?}.inject([]) do |arr,x|\n arr << x\n arr << n/x unless x == n/x\n arr.sort\n end\nend", "def factors(number)\n divisor = number\n factors = []\n begin\n factors << number / divisor if number % divisor == 0\n divisor -= 1\n end until divisor == 0\n factors\nend", "def factors(number)\n divisor = number\n factors = []\n begin\n factors << number / divisor if number % divisor == 0\n divisor -= 1\n end until divisor == 0\n factors\nend", "def factors(number)\n divisor = number\n factors = []\n begin\n factors << number / divisor if number % divisor == 0\n divisor -= 1\n end until divisor == 0\n factors\nend", "def factors(number)\n divisor = number\n factors = []\n begin\n factors << number / divisor if number % divisor == 0\n divisor -= 1\n end until divisor == 0\n factors\nend", "def factors(number)\n divisor = number\n factors = []\n begin\n factors << number / divisor if number % divisor == 0\n divisor -= 1\n end until divisor == 0\n factors\nend", "def factors(number)\n divisor = number\n factors = []\n begin\n factors << number / divisor if number % divisor == 0\n divisor -= 1\n end until divisor == 0\n factors\nend", "def factors(number)\n divisor = number\n factors = []\n while divisor != 0\n # not the cleanest way to do it, will return the same results\n # if we take the abs value of the number, removing the ternary operator\n factors << number / divisor if number % divisor == 0\n divisor > 0 ? divisor -= 1 : divisor += 1\n end\n factors\nend", "def factors(num)\n factors = []\n (1..num).each do |i| \n factors << i if num % i === 0\n end\n factors\nend", "def factors(number)\n dividend = number\n divisors = []\n number.times do\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n divisors\nend", "def factors(number)\n dividend = number\n divisors = []\n while number >= 1\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n break if dividend == 0\n end\n divisors\nend", "def factors(num)\r\n factors = []\r\n sqrt = Math.sqrt(num)\r\n until num == 1\r\n\r\n factor_founded = false\r\n (2..sqrt).each do |i|\r\n if (num % i).zero?\r\n num /= i\r\n factors << i\r\n factor_founded = true\r\n break\r\n end\r\n end\r\n unless factor_founded\r\n factors << num\r\n num /= num\r\n end\r\n end\r\n return factors\r\nend", "def old_factors(num)\n factors = []\n (1..num).each do |i|\n if num % i == 0\n factors << i\n end\n end\n factors\nend", "def factors(number)\n dividend = number\n divisors = []\n while number > 0\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n divisors\nend", "def factors(num)\n factors = Prime.prime_division(num)\n result = []\n factors.each { |factor, power| result += [factor] * power }\n result\nend", "def factors(number)\n factors = []\n divisor = number\n while divisor > 0 do\n factors << (number / divisor) if number % divisor == 0\n divisor -= 1\n end\n if divisor <= 0\n puts \"Invalid number: no 0's or negatives!\"\n else\n end\n factors\n end", "def factors_of(num)\n divide_by = []\n \n i = 1\n while i <= num\n if num % i == 0\n divide_by << i\n end\n \n i += 1\n end\n \n return divide_by\nend", "def factors(number)\n dividend = number\n divisors = []\n while dividend > 0\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n divisors\nend", "def factors(number)\n dividend = number\n divisors = []\n while dividend > 0\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n divisors\nend", "def factors(number)\n dividend = number\n divisors = []\n while dividend > 0\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n divisors\nend", "def factors(number)\n dividend = number\n divisors = []\n while dividend > 0\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n divisors\nend", "def factors(number)\n dividend = number\n divisors = []\n while dividend > 0\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n divisors\nend", "def factors(number)\n divisors = []\n if number > 0 \n dividend = number\n begin\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end until dividend == 0\n divisors\n end\n divisors\nend", "def factors(num)\n\n factors = []\n # iterate through all nums from 1 to num\n # add to factors if evenly divisible\n # return factors\n\n i = 1\n while i <= num\n factors << i if num % i == 0\n i += 1\n end\n\n factors\n\nend", "def factors(num)\n facs = [1]\n (2..num/2).each{|n| facs.push(n) if num % n == 0 }\n facs.push(num)\nend", "def factors num\n f = Array.new # creates a new array to store factors\n 1.upto(num) do |i|\n f << i if num%i == 0\n end\n f # returns factors\nend", "def factors(number)\n dividend = number\n divisors = []\n while dividend > 0\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end \n divisors\nend", "def factors num\n if num != 1\n #Start with 1 and num as the first factors\n c = 2\n 2.upto(num/2) { |f|\n if num % f == 0\n c += 1\n end\n }\n else\n c = 1\n end\n\n c\nend", "def factors(number)\n dividend = number\n divisors = []\n while dividend > 0 do\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n divisors\nend", "def factors(number)\n dividend = number\n divisors = []\n while dividend > 0 do\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n divisors\nend", "def factors(number)\n dividend = number\n divisors = []\n while dividend > 0 do\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n divisors\nend", "def factors(number)\n dividend = number\n divisors = []\n while dividend > 0 do\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n divisors\nend", "def factors(number)\n dividend = number\n divisors = []\n while dividend > 0 do\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n divisors\nend", "def factors(number)\n dividend = number\n divisors = []\n while dividend > 0 do\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n divisors\nend", "def factors(number)\n dividend = number\n divisors = []\n while dividend > 0 do\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n divisors\nend", "def factors(number)\n dividend = number\n divisors = []\n while dividend > 0 do\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n divisors\nend", "def factors(number)\n dividend = number\n divisors = []\n while dividend > 0 do\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n divisors\nend", "def factors(num)\n result = [1]\n\n (2..num).each do |el|\n result << el if num % el == 0\n end\n result\nend", "def factor(num)\n\tcurrent_factor = num/2\n\tfactors = []\n\tfactors << num\n\twhile current_factor > 0\n\t\tif num%current_factor == 0\n\t\t\tfactors << current_factor\n\t\t\tcurrent_factor -= 1\n\t\telse\n\t\t\tcurrent_factor -= 1\n\t\tend\n\tend\n\t\n\treturn factors\nend", "def factors(number)\n dividend = number\n divisors = []\n while dividend > 0 do\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n divisors\nend", "def find_factors(num)\n raise ArgumentError, \"num must be >= 0\" if num < 0\n return [n] if num <= 1\n result = []\n\n n = num\n if n.even?\n while n % 2 == 0\n result << 2\n n /= 2\n end\n end\n\n div = 3\n\n while (n > 1)\n while n % div == 0\n result << div\n n /= div\n end\n div += 2\n\n if (div * div > n)\n result << n\n break\n end\n end\n\n result\nend", "def factors(number)\n dividend = number\n divisors = []\n while dividend > 0 do\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\nend", "def factors(num)\n (1..num).select { |el| num % el == 0 }\nend", "def factors_of(num)\n\tnums = []\n \n\ti = 1\n\twhile i <= num\n\t\tif num % i == 0\n\t\t\tnums << i\n end\n\t\ti += 1\n end\n \n\treturn nums\nend", "def factors(num)\n factors = []\n (1..num).each do |i|\n factors << i if num % i == 0\n end\n \n factors\nend", "def factors(number)\n dividend = number\n divisors = []\n begin\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end until dividend == 0\n divisors\nend", "def factors(number)\n dividend = number\n divisors = []\n begin\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end until dividend == 0\n divisors\nend", "def factors(num)\n (1..num).select{|i| num % i == 0 }\nend", "def factors(number)\r\n divisor = number\r\n factors = []\r\n while divisor > 0 do \r\n factors << number / divisor if number % divisor == 0 #Allows you to determine if the result of the division is an integer number (no remainder).\r\n divisor -= 1\r\n end \r\n factors #with no return statement, the last line is returned - in this case we want to return 'factors'\r\nend", "def find_factors(number)\n\t# start with lowest prime number\n\tinteger = 2\n\n\t# make sure integer doesn't exceed the actual number\n\twhile integer <= number do\n\t\t# integer will be returned when if it is a factor of number\n\t\treturn integer if number % integer == 0\n\n\t\t# if integer is not a factor move to next integer\n\t\tinteger += 1\n\tend\nend", "def factors(num)\n facs = []\n i = 1\n while i <= num\n if num % i == 0\n facs << i\n end\n i += 1\n end\n facs\nend", "def factors(number)\n dividend = number\n divisors = []\n while dividend > 0\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end \n divisors\nend", "def factors(num)\n (1..num).select { |n| num%n == 0}\nend", "def factors_of(num)\n (1..num).select{|ele| num % ele == 0}\nend", "def factors(number)\n return \"number must be greatr than zero\" if (number == 0 || number < 0 )\n \n divisor = number\n factors = []\n begin\n factors << number / divisor if number % divisor == 0\n divisor -= 1\n end until divisor == 0\n factors\nend", "def factors(num)\n arr = []\n for i in 1..num\n if num%i == 0\n arr << i\n end\n end\n arr\nend", "def factors(num)\n arr = []\n (2..num).each do |ele|\n if (num % ele == 0)\n arr << ele\n end\n end\n return arr\nend", "def proper_factors(n)\n f = []\n 1.step((n/2).to_i, 1).each do |x|\n if n % x == 0\n f.push(x)\n end\n end\n f.sort\nend", "def factors(number)\n dividend = number\n divisors = []\n begin\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end until dividend == 0\ndivisors\nend", "def factors(num)\n return nil if num < 0\n return 1 if num == 1\n (1..num).select { |n| num % n == 0}\n\n\nend", "def factors(num)\n (1..num).select {|x| num % x == 0 }\nend" ]
[ "0.8575256", "0.8532261", "0.84801", "0.84801", "0.84801", "0.8478011", "0.8477378", "0.83777696", "0.83758056", "0.83459604", "0.8343072", "0.83401227", "0.83394605", "0.8335541", "0.8334777", "0.83283925", "0.831717", "0.8308934", "0.8308751", "0.8306715", "0.8306715", "0.8306715", "0.8306715", "0.8306715", "0.8306715", "0.8306223", "0.8293108", "0.828284", "0.8263457", "0.8262555", "0.82589656", "0.8257303", "0.825384", "0.8241848", "0.82366407", "0.8234455", "0.8232248", "0.8232091", "0.82254106", "0.82225275", "0.8222441", "0.8222441", "0.8222441", "0.8222441", "0.8221817", "0.8220656", "0.821778", "0.8206889", "0.8205384", "0.8205122", "0.8184918", "0.81831837", "0.8167484", "0.81657904", "0.8163399", "0.8161173", "0.81599754", "0.81599754", "0.81599754", "0.81599754", "0.81599754", "0.8159557", "0.8157975", "0.8153991", "0.8147879", "0.8139062", "0.8130481", "0.8128632", "0.8128632", "0.8128632", "0.8128632", "0.8128632", "0.8128632", "0.8128632", "0.8128632", "0.8128632", "0.8127093", "0.8126653", "0.8125773", "0.81210506", "0.8118973", "0.81023043", "0.8101314", "0.80968803", "0.80957204", "0.80957204", "0.8090223", "0.80869526", "0.8085958", "0.80847776", "0.80817866", "0.8081428", "0.8076611", "0.80744064", "0.80637985", "0.8060301", "0.8059127", "0.8046761", "0.8043816", "0.8040869" ]
0.8082092
90
Write an `Arraymy_controlled_flatten(n)` method that only flattens n levels of an array. For example, if you have an array with 3 levels of nested arrays, and run `arr.my_flatten(1)`, you should return an array with 1 level of nested arrays flattened. Example: `[1,[2,3], [4,[5]]].my_controlled_flatten(1)` => [1,2,3,4,[5]]
def my_controlled_flatten(level = nil) flattened = [] self.each do |ele| if ele.is_a?(Array) && level != 0 flattened += (level.nil? ? ele.my_controlled_flatten : ele.my_controlled_flatten(level - 1)) else flattened << ele end end flattened end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def my_controlled_flatten(n)\n flattened = []\n self.my_each do |el|\n if n > 0 && el.is_a?(Array)\n flattened += el.my_controlled_flatten(n - 1)\n else\n flattened << el\n end\n end\n flattened\n end", "def my_controlled_flatten(n)\n flattened = []\n\n self.each do |el|\n depth = 0\n if el.is_a?(Array)\n depth += 1\n flattened += el.my_flatten\n else\n flattened << el\n end\n end\n flattened\n end", "def my_controlled_flatten(n)\n return self if n < 1\n new_arr = []\n my_each {|el| new_arr += (el.is_a?(Array) ? el.my_controlled_flatten(n-1) : [el])}\n new_arr\n end", "def my_controlled_flatten(n)\n return self if n == 0\n new_arr = []\n self.each do |el|\n if el.is_a? (Array)\n new_arr += el.my_controlled_flatten(n-1)\n else\n new_arr << el\n end\n end\n new_arr\n end", "def my_controlled_flatten(n)\n return self if n == 0\n result = []\n self.each do |el|\n result << el unless el.is_a? Array\n result += el.my_controlled_flatten(n - 1) if el.is_a? Array\n end\n result\n end", "def my_controlled_flatten(n)\n return self if n == 0\n result = []\n self.each do |el|\n result << el unless el.is_a? Array\n result += el.my_controlled_flatten(n - 1) if el.is_a? Array\n end\n result\n end", "def my_controlled_flatten(n)\n return self if n == 0\n flattened = []\n\n self.each do |el|\n if el.is_a? Array\n next_val = n.nil? nil : n - 1\n flattened += el.my_controlled_flatten(next_val)\n else\n flattened += el\n end\n end\n\n flattened\n end", "def my_controlled_flatten(n)\n\n end", "def my_controlled_flatten(n)\n\n end", "def my_controlled_flatten(n=1)\n #here\n return self if n < 1\n\n results = []\n self.each do |el|\n if el.class == Array\n #here\n results += el.my_controlled_flatten(n-1)\n else\n results << el\n end\n end\n\n results\n\n end", "def using_flatten(array)\n array.flatten()\nend", "def using_flatten(array)\n array.flatten\nend", "def using_flatten(array)\n array.flatten\nend", "def using_flatten(arr)\n arr.flatten\nend", "def using_flatten(array)\n array.flatten\nend", "def using_flatten(array)\n array.flatten\nend", "def using_flatten(array)\n array.flatten\nend", "def using_flatten(array)\n array.flatten\nend", "def using_flatten(array)\n array.flatten\nend", "def using_flatten(array)\n array.flatten\nend", "def my_flatten(arr, flattened_arr = [])\nend", "def my_flatten\n flattened_array = []\n each do |item|\n if item.class != Array\n flattened_array << item\n else\n #recursevly call my flatten\n item.my_flatten.each { |sub_item| flattened_array << sub_item }\n end\n end\n flattened_array\n end", "def using_flatten(array)\n \n array.flatten\n \nend", "def using_flatten(array)\n array.flatten\n \nend", "def using_flatten (array)\n return array.flatten!\nend", "def using_flatten(array)\n array.flatten\n end", "def my_flatten\n arr = []\n i = 0\n while i < self.length\n if self[i].is_a? Array\n arr += self[i].my_flatten\n else\n arr << self[i]\n end\n i += 1\n end\n return arr\n end", "def flatten(array)\n array.flatten(1)\nend", "def flatten(array)\n array.flatten(1)\nend", "def my_flatten\n flattened = []\n self.my_each do |el|\n el.is_a?(Array) ? flattened += el.my_flatten : flattened << el\n end\n flattened\n end", "def my_flatten\n flattened = []\n self.my_each do |el|\n if el.is_a? Array\n flattened += el.my_flatten\n else\n flattened << el\n end\n end\n flattened\n end", "def my_flatten(array)\n print array.flatten\n end", "def my_flatten\n flattened = []\n self.my_each do |el|\n el.is_a?(Array) ? flattened.concat(el.my_flatten) : flattened << el\n end\n flattened\n end", "def my_flatten_recursive \n results = []\n self.my_each do |ele|\n if ele.is_a? Array \n results.concat(ele.my_flatten_recursive)\n else \n results<< ele\n end\n end\n results\n\n end", "def my_flatten\n # return self unless self.is_a?(Array)\n new_arr = []\n self.each do |el|\n if el.is_a?(Array)\n new_arr += el.my_flatten\n else\n new_arr << el\n end\n end\n new_arr\n end", "def my_flatten!\n self.replace(my_flatten)\n end", "def recursively_flatten_finite(array, out, level)\n ret = nil\n if level <= 0\n out.concat(array)\n else\n array.each do |o|\n if ary = Backports.is_array?(o)\n recursively_flatten_finite(ary, out, level - 1)\n ret = self\n else\n out << o\n end\n end\n end\n ret\n end", "def recursively_flatten_finite(array, out, level)\n ret = nil\n if level <= 0\n out.concat(array)\n else\n array.each do |o|\n if ary = Backports.is_array?(o)\n recursively_flatten_finite(ary, out, level - 1)\n ret = self\n else\n out << o\n end\n end\n end\n ret\n end", "def convert_1_level_deep(arr, result=[])\n arr.flatten.each_slice(3) { |ele| result.push(ele)}\n result\nend", "def flatten(data, level = 0)\n return [data] unless data.is_a?(Array) \n flat = []\n data.each do |ele|\n if ele.is_a?(Array)\n flat += flatten(ele, level + 1)\n else\n flat << ele\n end\n end\n flat\nend", "def flatten_array(arr)\n arr.flatten\nend", "def recursive_flatten(incoming_array, new_flattened_array = [])\n incoming_array.each do |item|\n if item.class == Array\n # Recursion\n recursive_flatten(item, new_flattened_array)\n else\n new_flattened_array << item\n end\n end\n new_flattened_array\n end", "def one_line_flatten(array, ret = [])\n array.each { |x| x.is_a?(Array) ? one_line_flatten(x, ret) : ret << x }; ret\nend", "def applying_flatten array_value\n return array_value.flatten!\n end", "def flatten\n\t\tmake_flat(@array)\n\tend", "def flatten_with_optional_argument!(level=-1)\n level = Backports.coerce_to_int(level)\n return flatten_without_optional_argument! if level < 0\n\n out = []\n ret = recursively_flatten_finite(self, out, level)\n replace(out) if ret\n ret\n end", "def flatten!() end", "def arr\n a = [1,2,[3,4,[5]]]\n return a.flatten\nend", "def flatten(a, flat=[])\n if a.class != Array\n # base case\n flat << a\n else\n a.each {|v| flatten(v, flat)}\n end\n flat\nend", "def flatten(depth = -1)\n to_a.flatten(depth)\n end", "def unflatten(flat_array)\n result = []\n x = 0\n\n while x < flat_array.length do \n if flat_array[x] < 3 \n result.push flat_array[x]\n x += 1\n else\n temp = [*flat_array[x...x + flat_array[x]]]\n result.push temp \n x += flat_array[x]\n end\n end\n result \nend", "def flatten() end", "def flatten_with_optional_argument!(level=-1)\n level = Backports.coerce_to_int(level)\n return flatten_without_optional_argument! unless level >= 0\n\n ret, out = nil, []\n ret = recursively_flatten_finite(self, out, level)\n replace(out) if ret\n ret\n end", "def flatten(array)\n a = []\n array.each do |n|\n if n.is_a? Array\n b = flatten(n)\n b.each { |x| a << x }\n else\n a << n\n end\n end\n a\nend", "def flatten_deeper(array)\n array.collect { |element| element.respond_to?(:flatten) ? element.flatten : element }.flatten\n end", "def my_flatten(final_arr = []) \n self.my_each do |el|\n debugger\n if el.class == Integer\n final_arr << el\n else\n el.my_flatten(final_arr)\n end\n end\n result\n end", "def flatten!\n\t\t@array = make_flat(@array)\n\tend", "def flatt(arr, flat_arr = [])\n arr.each do |element|\n if element.is_a?(Array)\n flatt(element, flat_arr)\n else\n flat_arr << element\n end\n end\n flat_arr\nend", "def flatten(array)\n return [] if array.empty?\n\n res = []\n array.each do |el|\n if el.is_a? Array\n res += flatten(el)\n else\n res << el\n end\n end\n res\nend", "def flatten(list)\n list.flatten\nend", "def flatten!\n self.replace(flatten)\n end", "def flatten(nested_array, result = [])\n nested_array.each do |integer|\n if integer.class == Array\n flatten(integer, result)\n else\n result << integer\n end\n end\n result\nend", "def flatten!\n # buggerit\n raise NotImplementedError\n end", "def flatten(array, result = [])\n array.each do |element|\n if element.is_a?(Array)\n flatten(element, result)\n else\n result << element\n end\n end\n result\nend", "def flatten(array)\n raise NonArrayError, 'argument must be an array' unless array.is_a? Array\n\n array.each_with_object([]) do |element, memo|\n if element.is_a?(Array)\n memo.push(*flatten(element))\n else\n memo.push(element)\n end\n end\nend", "def flatten!\n nil\n end", "def test_fix_nested_array\n array = [1, [2], [3, [4,[5]]], 6]\n array = array.flatten\n assert_equal [1,2,3,4,5,6], array\n end", "def flatten_aoi_recursive(array)\n return nil if array.nil?\n result = []\n array.each do |element|\n if element.is_a?(Array)\n f_array = flatten_aoi_recursive(element)\n f_array.each do |f_element|\n result << f_element\n end\n else\n result << element\n end\n end\n result\nend", "def flatten_deeper(array)\n array.collect do |element|\n (element.respond_to?(:flatten) && !element.is_a?(Hash)) ? element.flatten : element\n end.flatten\n end", "def flatten_array(array, result = [])\n array.each do |element|\n if element.is_a? Array\n flatten_array(element, result)\n else\n result << element\n end\n end\n result\nend", "def flatten(array)\n new_array = []\n array.each do |x|\n if x.class == Array\n x.each {|y| new_array.push(y)}\n else\n new_array.push(x)\n end\n end\n new_array\nend", "def flatten(array)\n return [] if array.empty? \n list = []\n head = array[0]\n rest = array[1..-1]\n if head.is_a? Array \n flatten(head) + flatten(rest)\n else \n list += [head] + flatten(rest)\n end \nend", "def _recursively_flatten_to!(array, out)\n array.each do |o|\n if NodeList === o\n _recursively_flatten_to!(o.nodes, out)\n elsif o.respond_to?(:to_ary)\n ary = Array === o ? o : o.to_ary\n _recursively_flatten_to!(ary, out)\n else\n out << o\n end\n end\n end", "def flatten\n map {|item| item.respond_to?(:flatten) ? item.flatten : item }.flatten\n end", "def flat(a)\n\tnew_arr = []\n\ta.each do |el|\n\t\tif el.is_a? Array\n\t\t\tel.each do |n|\n\t\t\t\tif el.is_a? Array\n\t\t\t\t\ta << n\n\t\t\t\telse\n\t\t\t\t\tnew_arr << n\n\t\t\t\tend\n\t\t\tend\n\t\telse\n\t\t\tnew_arr << el\t\n\t\tend\n\tend\n\tp new_arr\nend", "def flatten\n a=[]\n self.deep_each {|f| a << f}\n a\n end", "def flatten_array(arr)\n arr.each_with_object([]) do |item, flat|\n if item.is_a? Integer\n flat << item\n else\n flatten_array(item).each do |num|\n flat << num\n end\n end\n end\nend", "def flatten(array)\n container = []\n\n array.each do |element|\n if element.is_a?(Array)\n container += element\n else\n container << element\n end\n end\n\n container\nend", "def flat_map(n = 1, &f)\n _flat_map do |elem|\n if n.eql? 1\n yield elem\n else\n elem.flat_map n - 1, &f\n end\n end\n end", "def multi_dimensional_sum(array)\n\n puts \"With the built-in flatten method:\"\n puts array.flatten.inject { |acc, num| acc + num }\n\n puts \"With my flatten method:\"\n puts my_flatten(array).inject { |acc, num| acc + num}\n\n return \"----\"\n\nend", "def flatten_without_hooks!\n\n @without_hooks = true\n\n return_value = flatten!\n \n @without_hooks = false\n\n return return_value\n\n end", "def array_subsets(arr)\n return arr if arr.length == 0 || arr.length == 1\n new_arr = []\n new_arr << [arr[0]] + array_subsets(arr[1..-1])\n \n # length = 1\n # new_arr = [[]]\n # while length <= arr.length\n # arr.each do |el|\n # new_arr << Array.new(length) { el }\n # end\n # length += 1\n # end\nend", "def flatten(*args)\n new_array = []\n self.each do |v|\n if v.is_a?(Array)\n new_array.push( *(v.flatten(*args)) )\n else\n new_array << v\n end\n end\n new_array\n end", "def ensure_flat_array_value(value)\n if value.kind_of?(Array)\n value.flatten!\n else\n value = [value]\n end\n value\n end", "def flatten\n dup\n end", "def inject_deep_flat(list, remaining_path, multiplicity)\n return inject_deep(list, remaining_path) if multiplicity == 0\n\n flat_input = list.flat_map { |v| v.nil? ? [] : v }\n flat_output = inject_deep_flat(flat_input, remaining_path, multiplicity - 1)\n item_index = -1\n list.map { |v| v&.map { flat_output[item_index += 1] } }\n end", "def flatten(arr)\n\n flat = []\n\n arr.each do |el|\n if el.class != Array\n flat << el \n else\n #flatten(el).each {|char| flat << char}\n flat.push(*flatten(el))\n end\n end\n flat \nend", "def flatten\n self.class.new.flatten_merge(self)\n end", "def flatten\n self.class.new.flatten_merge(self)\n end", "def test_flatten_once\n ary = [1, [2, [3, 4]], [5]]\n flatter_ary = [1, 2, [3, 4], 5]\n assert_equal flatter_ary, OneLiner.flatten_once(ary)\n end", "def test_flatten_once\n ary = [1, [2, [3, 4]]]\n flatter_ary = [1, 2, [3, 4]]\n assert_equal flatter_ary, OneLiner.flatten_once(ary)\n end", "def subsets(arr)\n return [[]] if arr.empty?\n # debugger\n # take - return first n elements\n\n subArr = arr.take(arr.count - 1)\n\n subs = subsets(subArr)\n\n # concat Appends the elements of other_ary to self.\n # tyle co +\n subArrays = subs.map { |sub| sub + [arr.last] }\n subs.concat(subArrays)\nend", "def flat(arr1=[],arr2=[],i=0)\n if i >= arr1.length\n return arr2\n else\n if arr1[i].kind_of?(Array)\n flat(arr1[i],arr2) \n else\n arr2.push(arr1[i])\n end\n return flat(arr1,arr2,i+1)\n end\nend", "def flatten(value, named=false) # :nodoc:\n # Passes through everything that isn't an array of things\n return value unless value.instance_of? Array\n\n # Extracts the s-expression tag\n tag, *tail = value\n\n # Merges arrays:\n result = tail.\n map { |e| flatten(e) } # first flatten each element\n \n case tag\n when :sequence\n return flatten_sequence(result)\n when :maybe\n return named ? result.first : result.first || ''\n when :repetition\n return flatten_repetition(result, named)\n end\n \n fail \"BUG: Unknown tag #{tag.inspect}.\"\n end", "def flatten_object something\r\n if something.is_a? Hash\r\n super_flatten_hash(something)\r\n elsif something.is_a? Array\r\n super_flatten_array(something)\r\n else\r\n something\r\n end\r\nend", "def multi_dimensional_sum(array)\n array.flatten\nend", "def flatten\n # if any item is a Set or Java Collection, then convert those into arrays before recursively flattening the list\n if any? { |item| Set === item or Java::JavaUtil::Collection === item } then\n return map { |item| (Set === item or Java::JavaUtil::Collection === item) ? item.to_a : item }.flatten\n end\n base__flatten\n end", "def flatten_repetition(list, named) # :nodoc:\n if list.any? { |e| e.instance_of?(Hash) }\n # If keyed subtrees are in the array, we'll want to discard all \n # strings inbetween. To keep them, name them. \n return list.select { |e| e.instance_of?(Hash) }\n end\n\n if list.any? { |e| e.instance_of?(Array) }\n # If any arrays are nested in this array, flatten all arrays to this\n # level. \n return list.\n select { |e| e.instance_of?(Array) }.\n flatten(1)\n end\n \n # Consistent handling of empty lists, when we act on a named result \n return [] if named && list.empty?\n \n # If there are only strings, concatenate them and return that. \n foldl(list) { |s,e| s+e }\n end", "def flatten( level = 1 )\n\n load_parent_state\n \n return super\n\n end" ]
[ "0.8792398", "0.87656134", "0.8753098", "0.86528426", "0.8628412", "0.8628412", "0.8622892", "0.8345546", "0.8345546", "0.79406697", "0.7091221", "0.6984455", "0.6984455", "0.69825655", "0.6965448", "0.6965448", "0.6965448", "0.6965448", "0.6965448", "0.6965448", "0.6949501", "0.6920182", "0.6881509", "0.68727", "0.6855237", "0.6792475", "0.67898804", "0.6716181", "0.6716181", "0.6699823", "0.6692668", "0.66690934", "0.6632938", "0.6539805", "0.6485609", "0.64737326", "0.6463944", "0.6463944", "0.63572305", "0.6355861", "0.63508886", "0.63446623", "0.63133574", "0.6273023", "0.62700206", "0.6213996", "0.62090385", "0.62049556", "0.61442536", "0.6138462", "0.6119761", "0.61076516", "0.6095773", "0.60846645", "0.60765886", "0.60291326", "0.5989456", "0.59890574", "0.59476703", "0.59207726", "0.5918323", "0.5901237", "0.5891936", "0.58683133", "0.58613133", "0.58500737", "0.5778007", "0.57474554", "0.5718996", "0.5714194", "0.568977", "0.5662354", "0.5661384", "0.5599396", "0.55910397", "0.55791545", "0.55679834", "0.5565525", "0.5525645", "0.550969", "0.5496882", "0.54375386", "0.54338914", "0.54301", "0.5380958", "0.53780836", "0.5339988", "0.53126776", "0.53126776", "0.52690375", "0.5252187", "0.5144281", "0.51327384", "0.5057433", "0.50556886", "0.50451344", "0.50391364", "0.5030125", "0.502593" ]
0.78683156
10
GET /abooks GET /abooks.json
def index @abooks = Abook.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @books = Book.get_avaible_books\n end", "def index\n @books = Book.all\n render json: @books\n end", "def index\n @cookbooks = Cookbook.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @cookbooks }\n end\n end", "def index\n base_url = 'https://www.googleapis.com/books/v1/volumes?q=fiction&maxResults=20'\n and_key = '&key='\n key = ENV['GOOGLE_BOOKS_API_KEY'] \n googleurl = base_url + and_key + key\n\n response = RestClient.get(googleurl)\n @books = JSON.parse(response)\n\n respond_to do |format|\n format.html\n format.json { render json: @books }\n end\n\nend", "def index\n @books = Book.all\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @books }\n end\n end", "def index\n if params[:book_id]\n @book = Book.find(params[:book_id])\n recipes = @book.recipes\n render json: RecipeSerializer.new(recipes).to_serialized_json\n else \n recipes = Recipe.all.order(:name)\n render json: RecipeSerializer.new(recipes).to_serialized_json\n end\n end", "def index\n @books = Book.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @books }\n end\n end", "def index\n books = current_user.books.all\n render json: { books: books }\n end", "def index\n @books = Book.find_all_by_user_id(current_user)\n\n respond_to do |format|\n format.html\n format.json { render json: @books }\n end\n end", "def index\n @notebooks = Notebook.all\n render json: @notebooks\n end", "def list_books\n books = Book.all\n \n if books.count > 0\n render json: books\n else\n render json: {e:\"No books added\"}, :status => :error\n end\n end", "def index\n if current_user\n @books = current_user.books\n render json: @books, status: 201\n end\n end", "def index\n authorize! :query, Book\n @books = Book.order(:title)\n respond_to do |format|\n format.html\n format.json {render text: @books.to_json}\n format.xml {render text: @books.to_xml}\n end\n end", "def index\n @bookings = Booking.all\n\n render json: @bookings\n end", "def index\n @resumes = Resume.where(:book_id => params[:book_id])\n\n render json: @resumes\n end", "def index\r\n @books = Book.paginate(:page => params[:page], :per_page => 30)\r\n\r\n respond_to do |format|\r\n format.html # index.html.erb\r\n format.json { render json: @books }\r\n end\r\n end", "def index\n @book_pages = @book.book_pages\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @book_pages }\n end\n end", "def index\n @books = Book.extended_details\n\n render json: @books.as_json(\n only: [:id, :title, :author, :created_at, :total_income_cents, :copies_count, :remaining_copies_count, :loaned_copies_count]\n )\n end", "def scubooks\n sections = Section.all\n render json: sections\n end", "def index\n @title = \"List Books\"\n @books = Book.paginate :page=>params[:page], :per_page => 100, :order => 'title'\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @books }\n end\n end", "def index\n @unaffirmedbooks = Unaffirmedbook.all\n end", "def index\n @books = @collection.books\n #original: @books = Book.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @books }\n end\n end", "def index\n @user_books = UserBook.all\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @user_books }\n end\n end", "def index\n @bookings = Booking.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @bookings }\n end\n end", "def index\n @bookings = Booking.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @bookings }\n end\n end", "def index\n @bookings = Booking.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @bookings }\n end\n end", "def index\n @bookings = Booking.all\n\n respond_to do |format|\n format.html\n format.json { render :json => @bookings }\n end\n end", "def book\n @book = Book.published.find(params[:id])\n render json: @book\n end", "def index\n @notebooks = Notebook.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @notebooks }\n end\n end", "def index\n @notebooks = Notebook.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @notebooks }\n end\n end", "def index\n @books = []\n if (params[:q])\n @books = Book.where(params[:q])\n end\n render :json => @books\n end", "def show\n render json: @book\n end", "def show\n @book = Book.find(params[:id])\n\n respond_to do |format|\n\n format.json { render json: @book }\n end\n end", "def book\n fetch('harry_potter.books')\n end", "def index\n @bookmarks = Bookmark.all\n render json: { bookmarks: @bookmarks }, status: :ok\n end", "def fetch_books(term)\n response = RestClient.get(\"https://www.googleapis.com/books/v1/volumes?q=#{term}\")\n\n JSON.parse(response.body)\nend", "def index\n\t\tif (params[:data] != nil)\n\t\t\t@book = Book.new\n\t\t\t@client = Goodreads::Client.new(api_key: \"rSkvvZY8Wx27zcj4AfHA\", api_secret: \"S5WOpmY8pVtaEu1IwNn51DBafjoEIbjuxZdE6sNM\")\n\t\t\t@search = @client.search_books(params[:data])\n\t\t\t#@search = @client.search_books(\"the lord of the rings\")\n\t\t\t@results = @search.results.work\n\t\t\t#https://image.tmdb.org/t/p/w300_and_h450_bestv2\n\t\tend\n\n @books = Book.all\n end", "def show\n render json: @api_book\n end", "def index\n @books = Book.all\n do_response @books\n #\n #respond_to do |format|\n # format.html # index.html.erb\n #format.json { render :json => @books }\n #end\n end", "def show\n @cook_book = CookBook.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @cook_book }\n end\n end", "def index\n @books = Book.order('created_at DESC').page(params[:page]).per_page(10).search(params[:search], params[:id])\n respond_to do |format|\n format.json\n format.html\n end\n end", "def index\n @kbs = Kb.search(params[:q]).page(params[:page]).order(\"id desc\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @kbs }\n end\n end", "def get_books(response)\n response[\"items\"]\nend", "def index\n @chapters = @book.chapters\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @chapters }\n end\n end", "def index\n @chapters = @book.chapters\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @chapters }\n end\n end", "def fetch_books(term)\n response = RestClient.get(\"https://www.googleapis.com/books/v1/volumes?q=#{term}\")\n\n JSON.parse(response.body)\n end", "def show\n @cookbook = Cookbook.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @cookbook }\n end\n end", "def index\n @chapters = @book.chapters\n @chapter_list = @chapters.to_json(:only => [:name, :chapter_start, :chapter_end]) if @chapters.present?\n respond_to do |format|\n format.html\n format.json { \n render_json(@chapter_list)\n }\n end\n end", "def index\n render jsonapi: Book.search(params), include: [:genre, :author, :libraries]\n end", "def get_user_books\n user = User.find_by_id(params[:user_id])\n shelves = user.bookshelves\n \n @books = Array.new\n \n shelves.each do |s|\n s.books.each do |book|\n @books << book\n end\n end\n \n #books = Book.where(user_id: params[:user_id])\n \n render json: @books\n end", "def index\n @bounties = Bounty.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @bounties }\n end\n end", "def show\n find_book(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @book }\n end\n end", "def show\n @ebook = Ebook.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @ebook }\n end\n end", "def show\n\n @book = Book.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @book }\n end\n end", "def show\n\n @book = Book.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @book }\n end\n end", "def index\n info = Aws.get_recipes_from_db\n render :json => info\n end", "def fetch_book_info\n url = \"#{BASE_URL}/#{book_id}\"\n resp = RestClient::Request.execute(url: url, method: \"GET\")\n resp_obj = JSON.parse(resp)\n\n {\n id: book_id,\n title: resp_obj[\"volumeInfo\"][\"title\"],\n author: resp_obj[\"volumeInfo\"][\"authors\"][0],\n image: resp_obj[\"volumeInfo\"][\"imageLinks\"] ? resp_obj[\"volumeInfo\"][\"imageLinks\"][\"thumbnail\"] : DEFAULT_IMAGE\n }\n end", "def index\n respond_with Biblebook.all\n end", "def show\n @book = Book.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @book }\n end\n end", "def show\n @book = Book.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @book }\n end\n end", "def show\n @book = Book.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @book }\n end\n end", "def show\n @book = Book.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @book }\n end\n end", "def show\n @book = Book.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @book }\n end\n end", "def show\n @book = Book.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @book }\n end\n end", "def show\n @book = Book.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @book }\n end\n end", "def show\n @book = Book.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @book }\n end\n end", "def show\n @book = Book.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @book }\n end\n end", "def index\n\t\tboats = Boat.all\n \trender json: boats, status: 200\n\tend", "def index\n @ebooks = Ebook.all\n end", "def index\n recipes = Recipe.all\n render status: :ok, json: recipes\n end", "def show\n @authors_book = AuthorsBook.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @authors_book }\n end\n end", "def index\n @lbaas = Lbaa.all\n @lbaas = Lbaa.where(:section => 'A').order(\"id\")\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @lbaas }\n end\n end", "def index\n @awards = Award.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @awards }\n end\n end", "def list\n @books = Book.all\n end", "def show\n @book = Book.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @book }\n end\n end", "def index\n load_data\n @books = Book.all\n end", "def index\n @book_steps = @book.book_steps.all\n @book = @book\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @book_steps }\n end\n end", "def index\n\t\trender json: current_user.noteBooks.as_json(:include=> [:notes=>{:only=>[\"id\"]}])\n # render json: NoteBook.all.as_json(:include=> [:notes=>{:only=>[\"id\"]}])\n\tend", "def index\n @books = Book.page(params[:page]) # utilise le helper du gem kaminari pour faire la pagination des livres automatiquement\n end", "def show\r\n @book = Book.find(params[:id])\r\n\r\n respond_to do |format|\r\n format.html # show.html.erb\r\n format.json { render json: @book }\r\n end\r\n end", "def show\n @book_shelf = BookShelf.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @book_shelf }\n end\n end", "def index\n @cook_books = CookBook.all\n end", "def show\n @book = Book.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @book }\n end\n end", "def index\n # @bookings = Booking.all\n begin\n @response = Booking.get_bookings\n rescue RestClient::Exception => exception\n @error = exception.response\n end\n # binding.pry\n end", "def index\n bookings = Booking.all\n\n if bookings\n render json: { status: 'SUCCESS', message: 'Successfuly got all bookings', data: bookings }, status: :ok\n else\n render json: { status: 'ERROR', message: 'Something went wrong' }, status: :unprocessable_entity\n end\n end", "def index\n @bookings = Booking.all.map { |b| [b, b.contact, b.persons.first] }\n respond_to do |format|\n format.html\n format.json { render json: @bookings }\n end\n end", "def index\n @abets = Abet.all\n end", "def index\n @memos = @book.memos.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @memos }\n end\n end", "def index\n @cookbooks = Cookbook.all\n end", "def get_book(search)\n\trequest_string = \"https://www.googleapis.com/books/v1/volumes?q=#{search.gsub(\" \",\"+\")}\"\n\t\n\tsample_uri = URI(request_string) #opens a portal to the data at that link\n\tsample_response = Net::HTTP.get(sample_uri) #go grab the data in the portal\n\tsample_parsedResponse = JSON.parse(sample_response) #makes data easy to read\n\tsample_parsedResponse[\"items\"]\nend", "def index\n @phrasebooks = Phrasebook.all\n\n render json: @phrasebooks\n end", "def show\n @book_page = @book.book_pages.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @book_page }\n end\n end", "def index\n @books = Book.all\n end", "def index\n @books = Book.all\n end", "def index\n @books = Book.all\n end", "def index\n @books = Book.all\n end", "def index\n @books = Book.all\n end", "def index\n @books = Book.all\n end", "def index\n @books = Book.all\n end", "def index\n @books = Book.all\n end" ]
[ "0.6982796", "0.6957329", "0.6949324", "0.68977684", "0.6820236", "0.6779995", "0.6751502", "0.67465687", "0.6721131", "0.66992205", "0.6696414", "0.66711694", "0.6655469", "0.6625742", "0.6621738", "0.6601952", "0.6601003", "0.65989757", "0.65951073", "0.658131", "0.6559724", "0.6521323", "0.65102845", "0.65075266", "0.65075266", "0.65075266", "0.65006983", "0.6487098", "0.64671624", "0.64671624", "0.6417445", "0.6408019", "0.6405848", "0.6400879", "0.6385744", "0.6383013", "0.6381838", "0.63766146", "0.6371571", "0.63443357", "0.63402337", "0.6339239", "0.6338006", "0.63291425", "0.63291425", "0.63186675", "0.63018274", "0.62604475", "0.62460524", "0.62369126", "0.6235715", "0.62332284", "0.62254566", "0.62113523", "0.62113523", "0.62009525", "0.6197394", "0.61944836", "0.6189114", "0.6189114", "0.6189114", "0.6189114", "0.6189114", "0.6189114", "0.6189114", "0.6189114", "0.6189114", "0.6185486", "0.6180754", "0.6175782", "0.6170337", "0.616208", "0.61548305", "0.61504966", "0.6149463", "0.61434865", "0.6133885", "0.6126605", "0.6125574", "0.61239195", "0.6122995", "0.6121445", "0.61167693", "0.6116663", "0.61134785", "0.610036", "0.60999125", "0.6098639", "0.6075513", "0.6069437", "0.6058383", "0.60481405", "0.6045928", "0.6045928", "0.6045928", "0.6045928", "0.6045928", "0.6045928", "0.6045928", "0.6045928" ]
0.7113232
0
GET /abooks/1 GET /abooks/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n base_url = 'https://www.googleapis.com/books/v1/volumes?q=fiction&maxResults=20'\n and_key = '&key='\n key = ENV['GOOGLE_BOOKS_API_KEY'] \n googleurl = base_url + and_key + key\n\n response = RestClient.get(googleurl)\n @books = JSON.parse(response)\n\n respond_to do |format|\n format.html\n format.json { render json: @books }\n end\n\nend", "def index\n @books = Book.all\n render json: @books\n end", "def index\n @cookbooks = Cookbook.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @cookbooks }\n end\n end", "def book\n @book = Book.published.find(params[:id])\n render json: @book\n end", "def show\n @book = Book.find(params[:id])\n\n respond_to do |format|\n\n format.json { render json: @book }\n end\n end", "def index\n if params[:book_id]\n @book = Book.find(params[:book_id])\n recipes = @book.recipes\n render json: RecipeSerializer.new(recipes).to_serialized_json\n else \n recipes = Recipe.all.order(:name)\n render json: RecipeSerializer.new(recipes).to_serialized_json\n end\n end", "def index\n @resumes = Resume.where(:book_id => params[:book_id])\n\n render json: @resumes\n end", "def index\n @books = Book.all\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @books }\n end\n end", "def show\n @cookbook = Cookbook.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @cookbook }\n end\n end", "def index\n @abooks = Abook.all\n end", "def index\n @notebooks = Notebook.all\n render json: @notebooks\n end", "def show\n @cook_book = CookBook.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @cook_book }\n end\n end", "def index\n @books = Book.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @books }\n end\n end", "def index\n @bookings = Booking.all\n\n render json: @bookings\n end", "def index\n @books = Book.get_avaible_books\n end", "def scubooks\n sections = Section.all\n render json: sections\n end", "def show\n\n @book = Book.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @book }\n end\n end", "def show\n\n @book = Book.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @book }\n end\n end", "def show\n find_book(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @book }\n end\n end", "def index\n @books = Book.extended_details\n\n render json: @books.as_json(\n only: [:id, :title, :author, :created_at, :total_income_cents, :copies_count, :remaining_copies_count, :loaned_copies_count]\n )\n end", "def show\n @book = Book.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @book }\n end\n end", "def show\n @book = Book.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @book }\n end\n end", "def show\n @book = Book.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @book }\n end\n end", "def show\n @book = Book.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @book }\n end\n end", "def show\n @book = Book.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @book }\n end\n end", "def show\n @book = Book.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @book }\n end\n end", "def show\n @book = Book.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @book }\n end\n end", "def show\n @book = Book.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @book }\n end\n end", "def show\n @book = Book.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @book }\n end\n end", "def show\n render json: @api_book\n end", "def index\n @bookings = Booking.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @bookings }\n end\n end", "def index\n @bookings = Booking.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @bookings }\n end\n end", "def index\n @bookings = Booking.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @bookings }\n end\n end", "def index\n @bookings = Booking.all\n\n respond_to do |format|\n format.html\n format.json { render :json => @bookings }\n end\n end", "def show\n render json: @book\n end", "def index\n @books = Book.find_all_by_user_id(current_user)\n\n respond_to do |format|\n format.html\n format.json { render json: @books }\n end\n end", "def show\r\n @book = Book.find(params[:id])\r\n\r\n respond_to do |format|\r\n format.html # show.html.erb\r\n format.json { render json: @book }\r\n end\r\n end", "def show\n @book = Book.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @book }\n end\n end", "def index\n @book_pages = @book.book_pages\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @book_pages }\n end\n end", "def show\n @book = Book.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @book }\n end\n end", "def show\n @ebook = Ebook.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @ebook }\n end\n end", "def index\n @notebooks = Notebook.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @notebooks }\n end\n end", "def index\n @notebooks = Notebook.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @notebooks }\n end\n end", "def index\n @bookmarks = Bookmark.all\n render json: { bookmarks: @bookmarks }, status: :ok\n end", "def fetch_books(term)\n response = RestClient.get(\"https://www.googleapis.com/books/v1/volumes?q=#{term}\")\n\n JSON.parse(response.body)\nend", "def show\n @book_shelf = BookShelf.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @book_shelf }\n end\n end", "def index\n books = current_user.books.all\n render json: { books: books }\n end", "def show\n @authors_book = AuthorsBook.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @authors_book }\n end\n end", "def index\n @books = @collection.books\n #original: @books = Book.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @books }\n end\n end", "def index\n @title = \"List Books\"\n @books = Book.paginate :page=>params[:page], :per_page => 100, :order => 'title'\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @books }\n end\n end", "def index\r\n @books = Book.paginate(:page => params[:page], :per_page => 30)\r\n\r\n respond_to do |format|\r\n format.html # index.html.erb\r\n format.json { render json: @books }\r\n end\r\n end", "def show\n @book = Book.find_by_sql(\"SELECT * FROM Books B WHERE B.id = \" + params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @book }\n end\n end", "def index\n @bookings = Booking.all.map { |b| [b, b.contact, b.persons.first] }\n respond_to do |format|\n format.html\n format.json { render json: @bookings }\n end\n end", "def index\n authorize! :query, Book\n @books = Book.order(:title)\n respond_to do |format|\n format.html\n format.json {render text: @books.to_json}\n format.xml {render text: @books.to_xml}\n end\n end", "def index\n @bounties = Bounty.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @bounties }\n end\n end", "def index\n if current_user\n @books = current_user.books\n render json: @books, status: 201\n end\n end", "def index\n info = Aws.get_recipes_from_db\n render :json => info\n end", "def index\n\t\tboats = Boat.all\n \trender json: boats, status: 200\n\tend", "def fetch_book_info\n url = \"#{BASE_URL}/#{book_id}\"\n resp = RestClient::Request.execute(url: url, method: \"GET\")\n resp_obj = JSON.parse(resp)\n\n {\n id: book_id,\n title: resp_obj[\"volumeInfo\"][\"title\"],\n author: resp_obj[\"volumeInfo\"][\"authors\"][0],\n image: resp_obj[\"volumeInfo\"][\"imageLinks\"] ? resp_obj[\"volumeInfo\"][\"imageLinks\"][\"thumbnail\"] : DEFAULT_IMAGE\n }\n end", "def list_books\n books = Book.all\n \n if books.count > 0\n render json: books\n else\n render json: {e:\"No books added\"}, :status => :error\n end\n end", "def show\n @library_book = LibraryBook.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @library_book }\n end\n end", "def show\n @boat = Boat.find(params[:id])\n\n render json: @boat\n end", "def show\n @book_page = @book.book_pages.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @book_page }\n end\n end", "def get_books(response)\n response[\"items\"]\nend", "def index\n @user_books = UserBook.all\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @user_books }\n end\n end", "def index\n @lbaas = Lbaa.all\n @lbaas = Lbaa.where(:section => 'A').order(\"id\")\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @lbaas }\n end\n end", "def show\n @beer = BreweryDB.beer(params[:id]) \n render json: @beer\n end", "def show\n @booking = Booking.find(params[:id])\n render json: @booking\nend", "def show\n @title = \"Show Book\"\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @book }\n end\n end", "def index\n recipes = Recipe.all\n render status: :ok, json: recipes\n end", "def index\n @kbs = Kb.search(params[:q]).page(params[:page]).order(\"id desc\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @kbs }\n end\n end", "def show\n @bowl = Bowl.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @bowl }\n end\n end", "def index\n @chapters = @book.chapters\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @chapters }\n end\n end", "def index\n @chapters = @book.chapters\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @chapters }\n end\n end", "def show\n @bookself = Bookself.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @bookself }\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 fetch_books(term)\n response = RestClient.get(\"https://www.googleapis.com/books/v1/volumes?q=#{term}\")\n\n JSON.parse(response.body)\n end", "def index\n @books = []\n if (params[:q])\n @books = Book.where(params[:q])\n end\n render :json => @books\n end", "def book\n fetch('harry_potter.books')\n end", "def index\n @books = Book.all\n do_response @books\n #\n #respond_to do |format|\n # format.html # index.html.erb\n #format.json { render :json => @books }\n #end\n end", "def show\n @notebook = Notebook.find(params[:id])\n render json: @notebook\n end", "def show\n @businessbook = Businessbook.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @businessbook }\n end\n end", "def index\n @unaffirmedbooks = Unaffirmedbook.all\n end", "def show\n @boat = Boat.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json {render json: @boat}\n end\n end", "def show\n @borrower = Borrower.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @borrower }\n end\n end", "def show\n @breadcrumb = 'read'\n @bank = Bank.find(params[:id])\n @bank_offices = @bank.bank_offices.order(\"code\")\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @bank }\n end\n end", "def index\n\t\tboats = Assignment.all\n \trender json: boats, status: 200\n\tend", "def index\n @books = Book.order('created_at DESC').page(params[:page]).per_page(10).search(params[:search], params[:id])\n respond_to do |format|\n format.json\n format.html\n end\n end", "def show\n response = Aws.list_recipe(params[:id])\n render :json => response\n end", "def index\n @brags = Brag.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @brags }\n end\n end", "def index\n @biddings = Bidding.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @biddings }\n end\n end", "def show\n @book = Book.find_by_id(params[:id])\n if @book.present?\n render json: {\n type: 'success',\n result: @book\n }, status: :ok\n else\n render json: {\n type: 'failed',\n message: 'data with id:' + params[:id] + ' not found',\n result: {},\n }, status: :not_found\n end\n end", "def index\n @recipes = Recipe.all\n render json: @recipes\n end", "def show\n render \"api/v1/bounties/show\"\n end", "def index\n # @bookings = Booking.all\n begin\n @response = Booking.get_bookings\n rescue RestClient::Exception => exception\n @error = exception.response\n end\n # binding.pry\n end", "def show\n\t\t@booking = Booking.find(params[:id])\n\t\trender json: @booking, status: 200\n\tend", "def index\n @book_steps = @book.book_steps.all\n @book = @book\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @book_steps }\n end\n end", "def book(id)\n\t\t\tresponse = request('/book/show', :id => id)\n\t\t\tHashie::Mash.new(response['book'])\n\t\tend", "def show\n @baggage = Baggage.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @baggage }\n end\n end", "def index\n @chapters = @book.chapters\n @chapter_list = @chapters.to_json(:only => [:name, :chapter_start, :chapter_end]) if @chapters.present?\n respond_to do |format|\n format.html\n format.json { \n render_json(@chapter_list)\n }\n end\n end", "def show\n @holy_book = HolyBook.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @holy_book }\n end\n end" ]
[ "0.6811565", "0.6724151", "0.6673446", "0.6654508", "0.6644538", "0.65525883", "0.65376234", "0.6533649", "0.65321964", "0.6521902", "0.6511819", "0.6509823", "0.65060794", "0.64998686", "0.64294577", "0.64133376", "0.6406616", "0.6406616", "0.63970315", "0.63885933", "0.63845664", "0.63845664", "0.63845664", "0.63845664", "0.63845664", "0.63845664", "0.63845664", "0.63845664", "0.63845664", "0.63781923", "0.6369569", "0.6369569", "0.6369569", "0.6360652", "0.6355203", "0.63479114", "0.6344812", "0.63234246", "0.631802", "0.6316207", "0.6312799", "0.63028497", "0.63028497", "0.62956095", "0.6294179", "0.62787735", "0.6276417", "0.6266902", "0.6261829", "0.62597436", "0.6250056", "0.6238007", "0.622859", "0.6222798", "0.62219113", "0.6211671", "0.62053317", "0.6198623", "0.6177609", "0.6172029", "0.61642206", "0.61614555", "0.6152265", "0.6149667", "0.61435926", "0.6142254", "0.6138776", "0.61335194", "0.6127875", "0.6124012", "0.61150557", "0.60914165", "0.6087378", "0.6087378", "0.6071084", "0.6067837", "0.6067432", "0.6066909", "0.606581", "0.60649484", "0.60638165", "0.6060748", "0.60579026", "0.6053682", "0.60504264", "0.60481304", "0.6038505", "0.6036964", "0.60366964", "0.6028591", "0.60195976", "0.6008074", "0.6007422", "0.5999737", "0.59960043", "0.5991893", "0.5988715", "0.59840024", "0.59826916", "0.5973359", "0.597023" ]
0.0
-1
POST /abooks POST /abooks.json
def create @abook = Abook.new(abook_params) respond_to do |format| if @abook.save format.html { redirect_to @abook, notice: 'Abook was successfully created.' } format.json { render :show, status: :created, location: @abook } else format.html { render :new } format.json { render json: @abook.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @api_book = Api::Book.new(api_book_params)\n\n if @api_book.save\n render json: @api_book, status: :created, location: @api_book\n else\n render json: @api_book.errors, status: :unprocessable_entity\n end\n end", "def create\n @book = Book.new(book_params)\n\n if @book.save\n render json: @book, status: :created, location: @book\n else\n render json: @book.errors, status: :unprocessable_entity\n end\n end", "def create\n @book = Book.find(book_request_params[:book_id])\n @account = Account.find(params[:account_id])\n @book_request = BookRequest.new(book: @book, reader: @account, holder: @book.account)\n respond_to do |format|\n if @book_request.save\n format.json {\n render json:\n {\n book_id: @book_request.book_id,\n book_request_state: @book_request.state_name\n }\n }\n else\n format.json { render json: @book_request.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n decoded_token = JWT.decode book_params[:swipeChefToken], \"spaghetti\", true, { algorithm: 'HS256' }\n\n if decoded_token\n\n user_id = decoded_token[0]['id'].to_i\n\n @book = Book.find_or_create_by(user_id: user_id, recipe_id: params[:recipe_id])\n\n respond_to do |format|\n format.json { render json: @book}\n end\n end\n end", "def create\n @book = params[:book]\n add(@book)\n end", "def create\n @ebook = Ebook.new(params[:ebook])\n\n respond_to do |format|\n if @ebook.save\n format.html { redirect_to root_path, notice: 'Ebook was successfully created.' }\n format.json { render json: @ebook, status: :created, location: @ebook }\n else\n format.html { render action: \"new\" }\n format.json { render json: @ebook.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @cook_book = CookBook.new(params[:cook_book])\n\n respond_to do |format|\n if @cook_book.save\n format.html { redirect_to @cook_book, notice: 'Cook book was successfully created.' }\n format.json { render json: @cook_book, status: :created, location: @cook_book }\n else\n format.html { render action: \"new\" }\n format.json { render json: @cook_book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n\n\n @book = Book.new(book_params)\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n puts @book.as_json \n format.json { render :show, status: :created, location: @book }\n else\n \n format.html { render :new }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @cook_book = CookBook.new(cook_book_params)\n\n respond_to do |format|\n if @cook_book.save\n format.html { redirect_to @cook_book, notice: 'Cook book was successfully created.' }\n format.json { render :show, status: :created, location: @cook_book }\n else\n format.html { render :new }\n format.json { render json: @cook_book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @bookmark = Bookmark.new(params[:bookmark])\n# req = ActiveSupport::JSON.decode(request.body)\n# @bookmark = Bookmark.new(req)\n\n respond_to do |format|\n if @bookmark.save\n format.html { redirect_to @bookmark, notice: 'Bookmark was successfully created.' }\n format.json { render json: @bookmark, status: :created, location: @bookmarks }\n else\n format.html { render action: \"new\" }\n format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @book = Book.new(get_book_with_api(book_params[:title]))\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: '本を新規登録しました。' }\n format.json { render :show, status: :created, location: @book }\n else\n format.html { render :new }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @unaffirmedbook = Unaffirmedbook.new(unaffirmedbook_params)\n\n respond_to do |format|\n if @unaffirmedbook.save\n format.html { redirect_to @unaffirmedbook, notice: 'Unaffirmedbook was successfully created.' }\n format.json { render :show, status: :created, location: @unaffirmedbook }\n else\n format.html { render :new }\n format.json { render json: @unaffirmedbook.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n\n @book = Book.new(params[:book])\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to \"/books\", notice: 'Book was successfully created.' }\n format.json { render json: @book, status: :created, location: @book }\n else\n format.html { render action: \"new\" }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @book = Book.create( params[:book] )\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to books_path, notice: 'Book was successfully created.' }\n format.json { render json: @book, status: :created, location: @book }\n else\n format.html { render action: \"new\" }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @book = Book.new(params[:book])\n \n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render json: @book, status: :created, location: @book }\n else\n format.html { render action: \"new\" }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n\t\tboat = Boat.new(boat_params)\n \tif boat.save\n \t\trender json: boat, status: 201\n \tend\n\tend", "def create\n @book = Book.new(params[:book])\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render json: @book, status: :created, location: @book }\n else\n format.html { render action: \"new\" }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @book = Book.new(params[:book])\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render json: @book, status: :created, location: @book }\n else\n format.html { render action: \"new\" }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @book = Book.new(params[:book])\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render json: @book, status: :created, location: @book }\n else\n format.html { render action: \"new\" }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @book = Book.new(params[:book])\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render json: @book, status: :created, location: @book }\n else\n format.html { render action: \"new\" }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @book = Book.new(params[:book])\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render json: @book, status: :created, location: @book }\n else\n format.html { render action: \"new\" }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @book = Book.new(params[:book])\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to manage_books_path, notice: 'Book was successfully created.' }\n format.json { render json: @book, status: :created, location: @book }\n else\n format.html { render action: \"new\" }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @cookbook = Cookbook.new(cookbook_params)\n\n respond_to do |format|\n if @cookbook.save\n format.html { redirect_to cookbook_path(@cookbook), notice: 'Cookbook was successfully created.' }\n format.json { render action: 'show', status: :created, location: @cookbook }\n else\n format.html { render action: 'new' }\n format.json { render json: @cookbook.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n\t\tbooking = Booking.new(booking_params)\n\n\t if booking.save\n\t \tPeekBooker.use_a_boat(booking.size, booking.timeslot_id)\n\t \tPeekBooker.delete_overlap_assignments(booking.timeslot_id)\n\t \tPeekBooker.upd_availability(booking.timeslot_id)\n\t \t\n\t \trender json: booking, status: 201\n\t end\n\tend", "def create\n @ebook = Ebook.new(ebook_params)\n respond_to do |format|\n if @ebook.save\n format.html { redirect_to @ebook, notice: \"#{@ebook_name} was successfully created.\" }\n format.json { render action: 'show', status: :created, location: @ebook }\n else\n format.html { render action: 'new' }\n format.json { render json: @ebook.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @book = Book.new(params[:book])\n user_session = UserSession.new\n user_session.current_user.books << @book\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render json: @book, status: :created, location: @book }\n else\n format.html { render action: \"new\" }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @book_a_lawn = BookALawn.new(book_a_lawn_params)\n\n respond_to do |format|\n if @book_a_lawn.save\n format.html { redirect_to @book_a_lawn, notice: 'Book a lawn was successfully created.' }\n format.json { render action: 'show', status: :created, location: @book_a_lawn }\n else\n format.html { render action: 'new' }\n format.json { render json: @book_a_lawn.errors, status: :unprocessable_entity }\n end\n end\n end", "def store\n @book = Book.new(book_params)\n if @book.save\n render json: {\n type: 'success',\n result: @book\n }, status: :created\n else\n render json: {\n type: 'failed',\n message: @book.errors,\n result: {},\n }, status: :bad_request\n end\n end", "def create\n \n \n @booktitle = Book.find_by_title(book_params[:title])\n if Book.where(:title => book_params[:title]).present?\n @book = Book.find(@booktitle.id)\n @book.count = @book.count + book_params[:count].to_i\n else\n if !(Author.where(:name => book_params[:author_name]).present?)\n @author = Author.create(:name => book_params[:author_name],\n :category => book_params[:category])\n end\n @book = Book.new(book_params)\n @book.author_id = Author.find_by_name(book_params[:author_name]).id\n end\n\n \n respond_to do |format|\n if @book.save\n \n format.json { render json: @book, status: :created, location: @book }\n else\n \n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @title = \"Create New Book\"\n\n process_publisher\n\n all_book_params= params[:book]\n\n @book = Book.new(params[:book])\n\n process_authors\n\n process_subjects\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to edit_book_path(@book), notice: 'Book was successfully created.' }\n format.json { render json: @book, status: :created, location: @book }\n else\n format.html { render action: \"new\" }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n isbn = params[:isbn]\n uri = URI(\"http://107.170.7.58:4567/api/book\")\n parameters = {\"ext\" => \"json\", \"isbn\" => isbn.to_s}\n response = Net::HTTP.post_form(uri, parameters)\n list = JSON.parse(response.body)\n\n if list.empty?\n redirect_to(action: \"search\", error: isbn.to_s)\n else\n @edition = Edition.new(list[0][\"data\"])\n end\n end", "def index\n if params[:book_id]\n @book = Book.find(params[:book_id])\n recipes = @book.recipes\n render json: RecipeSerializer.new(recipes).to_serialized_json\n else \n recipes = Recipe.all.order(:name)\n render json: RecipeSerializer.new(recipes).to_serialized_json\n end\n end", "def create\n logger.debug \"#{book_params}\"\n @book = Book.new(book_params)\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render :show, status: :created, location: @book }\n else\n format.html { render :new }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @ab_chapter = AbChapter.new(ab_chapter_params)\n\n respond_to do |format|\n if @ab_chapter.save\n format.html { redirect_to @ab_chapter, notice: 'Ab chapter was successfully created.' }\n format.json { render action: 'show', status: :created, location: @ab_chapter }\n else\n format.html { render action: 'new' }\n format.json { render json: @ab_chapter.errors, status: :unprocessable_entity }\n end\n end\n end", "def call(params)\n @books = BookRepository.all\n self.body = JSON.dump(@books)\n end", "def create\n @book = Book.new(book_params)\n resort_orders\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render :show, status: :created, location: @book }\n else\n format.html { render :new }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @cookbooks = Cookbook.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @cookbooks }\n end\n end", "def create\n @book = @collection.books.build(params[:book])\n #original: @book = Book.new(params[:book])\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to book_series_collection_books_url(@book_series, @collection), notice: 'Book was successfully created.' }\n format.json { render json: @book, status: :created, location: @book }\n else\n format.html { render action: \"new\" }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n booking = Booking.create(booking_params)\n render json: booking\n end", "def create\n @book = Book.new(book_params)\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: t('common.message.created_success')}\n format.json { render :show, status: :created, location: @book }\n else\n format.html { render :new }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @books = Book.all\n render json: @books\n end", "def create\n @book = Book.new(book_params)\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render json: @book, status: :created, location: @book }\n else\n format.html { render action: \"new\" }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @boat = Boat.new(boat_params)\n\n if @boat.save\n render json: @boat, status: :created, location: @boat\n else\n render json: @boat.errors, status: :unprocessable_entity\n end\n end", "def create\n @book = Book.new(book_params)\n\n # 書籍情報を取得\n get_info\n\n if @res.present? && !@res.has_error? && @res.total_results != 0\n @book.isbn = @res.first_item.get('ItemAttributes/ISBN')\n @book.asin = @res.first_item.get('ASIN')\n @book.title = @res.first_item.get('ItemAttributes/Title')\n @book.publisher = @res.first_item.get('ItemAttributes/Manufacturer')\n @book.author = @res.first_item.get('ItemAttributes/Author')\n @book.description = @res.first_item.get('EditorialReviews/EditorialReview/Content')\n @book.image = @res.first_item.get('MediumImage/URL')\n @book.publish_date = @res.first_item.get('ItemAttributes/PublicationDate')\n @book.number_of_pages = @res.first_item.get('ItemAttributes/NumberOfPages')\n @book.price = @res.first_item.get('ItemAttributes/ListPrice/Amount')\n\n # 取得したISBNが登録されてない場合のみ、取得した書籍を登録する\n @find_book = Book.find_by(isbn: @book.isbn)\n if @find_book.nil?\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: @book.title + ' を新規登録しました。' }\n format.json { render :show, status: :created, location: @book }\n else\n format.html { render :new }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n else\n respond_to do |format|\n format.html { redirect_to @find_book, notice: @book.title + ' は既に登録されています。' }\n format.json { render :show, status: :created, location: @find_book }\n end\n end\n else\n respond_to do |format|\n format.html { redirect_to books_url, notice: '本が見つかりませんでした。' }\n format.json { head :no_content }\n end\n end\n end", "def create\n @book = Book.new(book_params)\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: \"Book was successfully created.\" }\n format.json { render :show, status: :created, location: @book }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @book = Book.new(book_params)\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: \"Book was successfully created.\" }\n format.json { render :show, status: :created, location: @book }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @book = Book.new(book_params)\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render :show, status: :created, location: @book }\n else\n format.html { render :new }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @book = Book.new(book_params)\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render :show, status: :created, location: @book }\n else\n format.html { render :new }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @book = Book.new(book_params)\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render :show, status: :created, location: @book }\n else\n format.html { render :new }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @book = Book.new(book_params)\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render :show, status: :created, location: @book }\n else\n format.html { render :new }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @book = Book.new(book_params)\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render :show, status: :created, location: @book }\n else\n format.html { render :new }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @book = Book.new(book_params)\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render :show, status: :created, location: @book }\n else\n format.html { render :new }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @book = Book.new(book_params)\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render :show, status: :created, location: @book }\n else\n format.html { render :new }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @book = Book.new(book_params)\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render :show, status: :created, location: @book }\n else\n format.html { render :new }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @book = Book.new(book_params)\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render :show, status: :created, location: @book }\n else\n format.html { render :new }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @book = Book.new(book_params)\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render :show, status: :created, location: @book }\n else\n format.html { render :new }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @book = Book.new(book_params)\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render :show, status: :created, location: @book }\n else\n format.html { render :new }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @book = Book.new(book_params)\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render :show, status: :created, location: @book }\n else\n format.html { render :new }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @book = Book.new(book_params)\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render :show, status: :created, location: @book }\n else\n format.html { render :new }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @book = Book.new(book_params_create)\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: '添加成功!' }\n format.json { render :show, status: :created, location: @book }\n else\n format.html { render :new }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @borrowed_book = BorrowedBook.new(borrowed_book_params)\n respond_to do |format|\n if @borrowed_book.save\n borrow(@borrowed_book)\n format.html { redirect_to @borrowed_book, notice: 'Borrowed book was successfully created.' }\n format.json { render :show, status: :created, location: @borrowed_book }\n else\n format.html { render :new }\n format.json { render json: @borrowed_book.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @abooks = Abook.all\n end", "def create\n @osoba = Osoba.new(params[:osoba])\n\n if @osoba.save\n render json: @osoba, status: :created, location: @osoba\n else\n render json: @osoba.errors, status: :unprocessable_entity\n end\n end", "def create\n\t\t@book = Book.new(params[:book])\n\t\t@book.user = current_user\n\n\t\trespond_to do |format|\n\t\t\tif @book.save\n\t\t\t\tformat.html { redirect_to @book, :notice => 'Book was successfully created.' }\n\t\t\t\tformat.json { render :json => @book, :status => :created, :location => @book }\n\t\t\telse\n\t\t\t\tformat.html { render :action => \"new\" }\n\t\t\t\tformat.json { render :json => @book.errors, :status => :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend", "def create\n @book = Book.new(book_params)\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render action: 'show', status: :created, location: @book }\n else\n format.html { render action: 'new' }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @borrowed_book = BorrowedBook.new(borrowed_book_params)\n\n respond_to do |format|\n if @borrowed_book.save\n format.html { redirect_to @borrowed_book, notice: \"Borrowed book was successfully created.\" }\n format.json { render :show, status: :created, location: @borrowed_book }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @borrowed_book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create(bin_params)\n @rest.post('save', bin_params)\n end", "def add_book_google\n book = Book.create(book_params)\n \n if book.valid?\n #Book was added to library\n #Add book to users bookshelf\n user = User.find_by_id(params[:user_id])\n \n shelf = user.bookshelves.first\n shelf.books << book\n \n shelf = user.bookshelves.first\n pp shelf.shelfitems\n \n if params[:finished] == \"true\"\n shelf.shelfitems.last.finished = true\n #shelf.shelfitems.last\n shelf.shelfitems.last.save\n end\n #si.finished = params[:finished]\n #si.save\n \n render json: {msg: \"Successfully created \" + book.title, shelf: shelf.books}, :status => :created\n else\n render json: {e: \"Error creating book\"}, :status => :error\n end\n end", "def create\n @tags_book = TagsBook.new(tags_book_params)\n\n @books = Book.all\n @tags = Tag.all\n\n respond_to do |format|\n if @tags_book.save\n format.html { redirect_to @tags_book, notice: \"Tags book was successfully created.\" }\n format.json { render :show, status: :created, location: @tags_book }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @tags_book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @poetry_anthology_book = current_user.poetry_anthology_books.build(poetry_anthology_book_params)\n\n respond_to do |format|\n if @poetry_anthology_book.save\n format.html { redirect_to @poetry_anthology_book, notice: \"Poetry anthology review was successfully created.\" }\n format.json { render :show, status: :created, location: @poetry_anthology_book }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @poetry_anthology_book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @book = Book.new(book_params)\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book }\n format.json { render action: 'show', status: :created, location: @book }\n else\n format.html { render action: 'new' }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n render json: Beverage.create!(beverage_post_params), status: :created\n end", "def create\n byebug\n @book = Book.new(book_params)\n respond_to do |format|\n if @book.save\n format.html { redirect_to [:admin, @book], notice: 'Book was successfully created.' }\n format.json { render action: 'show', status: :created, location: @book }\n else\n load_data\n format.html { render action: 'new' }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @read_book = ReadBook.new(read_book_params)\n\n respond_to do |format|\n if @read_book.save\n flash[:notice] = 'Read book was successfully created.'\n format.html { redirect_to read_books_url }\n format.json { render :show, status: :created, location: @read_book }\n else\n flash[:warning] = 'Failed'\n format.html { redirect_to read_books_url }\n format.json { render json: @read_book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @bookcabinet = Bookcabinet.new(bookcabinet_params)\n\n respond_to do |format|\n if @bookcabinet.save\n format.html { redirect_to @bookcabinet, notice: 'Bookcabinet was successfully created.' }\n format.json { render :show, status: :created, location: @bookcabinet }\n else\n format.html { render :new }\n format.json { render json: @bookcabinet.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @authors_book = AuthorsBook.new(params[:authors_book])\n\n respond_to do |format|\n if @authors_book.save\n format.html { redirect_to @authors_book, notice: 'Authors book was successfully created.' }\n format.json { render json: @authors_book, status: :created, location: @authors_book }\n else\n format.html { render action: \"new\" }\n format.json { render json: @authors_book.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n if params[:name].present?\n @json = Punk::API.beers_name!(params[:name])\n elsif params[:abv_gt].present?\n @json = Punk::API.beers_abv_gt!(params[:abv_gt])\n elsif params[:abv_lt].present?\n @json = Punk::API.beers_abv_lt!(params[:abv_lt])\n else\n @json = Punk::API.all_beers!(params)\n end\n\n render json: {\n beers: @json\n }\n create(@json)\n end", "def create\n @my_book = MyBook.new(my_book_params)\n\n respond_to do |format|\n if @my_book.save\n format.html { redirect_to @my_book, notice: 'My book was successfully created.' }\n format.json { render :show, status: :created, location: @my_book }\n else\n format.html { render :new }\n format.json { render json: @my_book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @booksinlist = Booksinlist.new(booksinlist_params)\n\n respond_to do |format|\n if @booksinlist.save\n format.html { redirect_to @booksinlist, notice: 'Booksinlist was successfully created.' }\n format.json { render :show, status: :created, location: @booksinlist }\n else\n format.html { render :new }\n format.json { render json: @booksinlist.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n\t\tclient = Goodreads::Client.new(api_key: \"rSkvvZY8Wx27zcj4AfHA\", api_secret: \"S5WOpmY8pVtaEu1IwNn51DBafjoEIbjuxZdE6sNM\")\n\t\tbook = client.book_by_isbn(book_params[:isbn])\n\t\t@book = Book.new(book_params)\n\n#\t\tputs book.title\n#\t\tputs book.description\n#\t\tputs book.work.original_title\n#\t\tputs book.num_pages\n#\t\tputs book.authors.author.name\n#\t\tputs book.publisher\n\n\t\t@book.titlelong = book.title\n\t\t@book.description = strip_tags(book.description)\n\t\tputs @book.description#.gsub(/<br\\s*\\?>/, '')\n\t\t@book.title = book.work.original_title\n\t\t@book.pages = book.num_pages\n\t\t@book.bookrating = book.average_rating\n\t\t@book.author = book.authors.author.name\n\t\t@book.publisher = book.publisher\n\n\t\t#book.search(\"9780545790352\", 5)\n\t\t#puts book.books.first.get_title\n\t\t#@show = Show.new(show_params)\n\t\t#@show.title = result[\"original_name\"]\n\t\t#@show.description = result[\"overview\"]\n\t\t#@show.seasons = result[\"number_of_seasons\"]\n\t\t#@show.episodes = result[\"number_of_episodes\"]\n\t\t#@show.episoderuntime = result[\"episode_run_time\"].dig(0)\n\t\t#@show.showrating = result[\"vote_average\"]\n\t\t#@show.airdate = result[\"first_air_date\"]\n\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render :show, status: :created, location: @book }\n else\n format.html { render :new }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @stuk_book = current_user.stuk_books.new(stuk_book_params)\n\n respond_to do |format|\n if @stuk_book.save\n format.html { redirect_to @stuk_book, notice: 'Stuk book was successfully created.' }\n format.json { render :show, status: :created, location: @stuk_book }\n else\n format.html { render :new }\n format.json { render json: @stuk_book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @book = Book.new(book_params)\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to admin_book_url(@book), notice: 'Book was successfully created.' }\n format.json { render :show, status: :created, location: @book }\n else\n format.html { render :new }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n puts \"post_params\"\n puts post_params\n if post_params[:book]\n response = RestClient::Request.execute(\n method: :get,\n url: post_params[:book]['self_link'],\n )\n response=JSON.parse(response)\n @book = Book.where(self_link: post_params[:book]['self_link']).first_or_create do |book|\n book.title=response['volumeInfo']['title']\n book.subtitle=response['volumeInfo']['subtitle']\n book.description=response['volumeInfo']['description']\n book.publisher=response['volumeInfo']['publisher']\n book.publication_date=response['volumeInfo']['publishedDate']\n if response['volumeInfo']['authors'] then book.author=response['volumeInfo']['authors'].join(', ') end\n if response['saleInfo']['listPrice'] then book.list_price=response['saleInfo']['listPrice']['amount'] end\n end\n puts @book\n if response['volumeInfo']['industryIdentifiers']\n response['volumeInfo']['industryIdentifiers'].each do |isbn_type|\n if isbn_type['type']=='ISBN_13'\n @book['ISBN_13']=isbn_type['identifier']\n elsif isbn_type['type']=='ISBN_10'\n @book['ISBN_10']=isbn_type['identifier']\n end\n end\n end\n if response['volumeInfo']['imageLinks']\n if response['volumeInfo']['imageLinks']['thumbnail']\n @book['cover_image']=response['volumeInfo']['imageLinks']['thumbnail']\n elsif response['volumeInfo']['imageLinks']['smallThumbnail']\n @book['cover_image']=response['volumeInfo']['imageLinks']['smallThumbnail']\n end\n end\n if @book.save\n # @posts.book_id=@book.id\n @post = current_user.posts.new(post_params.merge({book: @book}))\n\n respond_to do |format|\n if @post.save\n if params[:images]\n params[:images]['actual_product_image'].each do |image|\n @image = @post.images.create!(:actual_product_image => image)\n end\n end\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n if post_params['post_type']=='offer'\n format.html { render :new_offer }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n else\n format.html { render :new_request }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end\n end\n else\n if post_params['post_type']==\"offer\"\n redirect_to posts_new_offer_path, notice:\"Need Book Information\"\n else\n redirect_to posts_new_request_path, notice:\"Need Book Information\"\n end\n end\nend", "def create\n @book = Book.new(book_params)\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book}\n format.json { render action: 'show', status: :created, location: @book }\n else\n format.html { render action: 'new' }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @cookbook = Cookbook.new(cookbook_params)\n @cookbook.user_id = current_user.id\n\n respond_to do |format|\n if @cookbook.save\n format.html { redirect_to @cookbook, notice: 'Cookbook was successfully created.' }\n format.json { render :show, status: :created, location: @cookbook }\n else\n format.html { render :new }\n format.json { render json: @cookbook.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @book = Book.new(book_params)\n @categories = Category.all.order('name asc')\n respond_to do |format|\n if @book.save\n format.html { redirect_to books_url, notice: 'Book was successfully created.' }\n format.json { render :show, status: :created, location: @book }\n else\n @categories = Category.all.order('name asc')\n format.html { render :new }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @borrowed_book = BorrowedBook.new(borrowed_book_params)\n\n respond_to do |format|\n if @borrowed_book.save\n format.html { redirect_to @borrowed_book, notice: 'The book was successfully checked out.' }\n format.json { render :show, status: :created, location: @borrowed_book }\n else\n @borrowers = Borrower.order('name ASC')\n @borrower_count = Borrower.count\n format.html { render :new }\n format.json { render json: @borrowed_book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @bowl = Bowl.new(params[:bowl])\n \n # set the current user's id and the creation time for this bowl\n @bowl.user_id = session[:user].userid.to_i\n @bowl.created = Time.now\n \n respond_to do |format|\n if @bowl.save\n\n Rails.logger.info \"Adding contents for bowl\"\n \n params.keys.each do |param|\n if param.start_with?(\"input_\") and (params[param] != \"\") \n @bowl.contents.create(:bowl_id => @bowl.id, :dryfruit_id => param[6, 2], :quantity => params[param]) \n end\n end\n \n format.html { redirect_to bowls_path, :notice => 'Bowl was successfully created.' }\n format.json { render :json => @bowl, :status => :created, :location => @bowl }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @bowl.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @book = Book.new(params[:book])\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.xml { head :ok }\n format.json { render json: @book, status: :created, location: @book }\n\n else\n format.html { render action: \"new\" }\n format.xml { render xml: @book.errors, status: :unprocessable_entity}\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @book = Book.new(book_params)\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render :show, status: :created, location: @book }\n else\n format.html { render :new }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n getBookId = Book.where(name:@book.name)\n getBookId.each do |id_book|\n params[:amount_code].each do |value|\n Amount.new(code: value, book_id: id_book.id, active: 0).save\n end\n end\n end", "def create\n @book = Book.new(book_params)\n puts \"*** From create: \" \n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render :show, status: :created, location: @book }\n else\n format.html { render :new }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @notebook = Notebook.new(params[:notebook])\n\n if @notebook.save\n render json: @notebook, status: :created, location: @notebook\n else\n render json: @notebook.errors, status: :unprocessable_entity\n end\n end", "def create\r\n @book = Book.new(book_params)\r\n\r\n respond_to do |format|\r\n if @book.save\r\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\r\n format.json { render :show, status: :created, location: @book }\r\n else\r\n format.html { render :new }\r\n format.json { render json: @book.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end", "def add_book(book_title)\n @books << {\n title: book_title,\n rental_details: {\n student_name: \"\",\n date: \"\"\n }\n }\n end", "def scubooks\n sections = Section.all\n render json: sections\n end", "def index\n @notebooks = Notebook.all\n render json: @notebooks\n end", "def create\n @book = Book.new(params[:book])\n @book.user = current_user\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, :notice => 'Book was successfully created.' }\n format.json { render :json => @book, :status => :created, :location => @book }\n else\n render_error_response(\"\", \"new\", @book)\n end\n end\n end", "def create\n @book = current_user.books.new(book_params)\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render :show, status: :created, location: @book }\n else\n format.html { render :new }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @book_request = BookRequest.new(book_request_params)\n\n respond_to do |format|\n if @book_request.save\n format.html { redirect_to @book_request, notice: 'Book request was successfully created.' }\n format.json { render :show, status: :created, location: @book_request }\n else\n format.html { render :new }\n format.json { render json: @book_request.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @biography_book = current_user.biography_books.build(biography_book_params)\n\n respond_to do |format|\n if @biography_book.save\n format.html { redirect_to @biography_book, notice: \"Biography review was successfully created.\" }\n format.json { render :show, status: :created, location: @biography_book }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @biography_book.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.6125391", "0.6040874", "0.6029674", "0.58725584", "0.58690166", "0.5814412", "0.5790517", "0.5739043", "0.57092375", "0.5704596", "0.57025206", "0.56746817", "0.56602204", "0.56549394", "0.56280553", "0.56187016", "0.5566896", "0.5566896", "0.5566896", "0.5566896", "0.5566896", "0.5543045", "0.55422616", "0.5539745", "0.55307126", "0.55302995", "0.5517119", "0.5515093", "0.5500936", "0.55005974", "0.54845715", "0.54843235", "0.548377", "0.5481319", "0.54699165", "0.5463104", "0.54626006", "0.546064", "0.5457601", "0.54573154", "0.5453947", "0.5448943", "0.5446389", "0.54461926", "0.544557", "0.544557", "0.5434805", "0.5434805", "0.5434805", "0.5434805", "0.5434805", "0.5434805", "0.5434805", "0.5434805", "0.5434805", "0.5434805", "0.5434805", "0.5434805", "0.5434805", "0.54290974", "0.54284924", "0.5421388", "0.54187757", "0.5417529", "0.5409872", "0.54082316", "0.5403503", "0.54021424", "0.53963035", "0.53960824", "0.53925174", "0.5391062", "0.5389637", "0.53887", "0.53736585", "0.5371543", "0.5367916", "0.53649336", "0.53640884", "0.53612244", "0.5358095", "0.53562534", "0.53544384", "0.5353242", "0.53495336", "0.5346041", "0.53450555", "0.5344524", "0.53416646", "0.53340864", "0.53326565", "0.53294605", "0.53253806", "0.53242296", "0.5322943", "0.5320248", "0.5317684", "0.5317239", "0.5312645", "0.53114855" ]
0.6885678
0
PATCH/PUT /abooks/1 PATCH/PUT /abooks/1.json
def update respond_to do |format| if @abook.update(abook_params) format.html { redirect_to @abook, notice: 'Abook was successfully updated.' } format.json { render :show, status: :ok, location: @abook } else format.html { render :edit } format.json { render json: @abook.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def patch!\n request! :patch\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 patch\n headers = {\"If-Match\" => @version}\n response = @context.request :patch, \"#{@path}/#{@id}\", @data.to_json, headers\n @version += 1\n response\n # 'X-HTTP-Method-Override' => 'PATCH'\n end", "def update\n @book = Book.find(params[:id])\n\n respond_to do |format|\n if @book.update_attributes(params[:book])\n \n format.json { render json: @book, status: :created, location: @book }\n else\n \n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def update!(params)\n res = @client.put(path, nil, params, \"Content-Type\" => \"application/json\")\n @attributes = res.json if res.status == 201\n res\n end", "def update\n @cookbook = Cookbook.find(params[:id])\n\n respond_to do |format|\n if @cookbook.update_attributes(params[:cookbook])\n format.html { redirect_to @cookbook, notice: 'Cookbook was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @cookbook.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @api_book = Api::Book.find(params[:id])\n\n if @api_book.update(api_book_params)\n head :no_content\n else\n render json: @api_book.errors, status: :unprocessable_entity\n end\n end", "def update # PATCH\n raise NotImplementedError\n end", "def api_patch(path, data = {})\n api_request(:patch, path, :data => data)\n end", "def update\n respond_to do |format|\n if @cookbook.update(cookbook_params)\n format.html { redirect_to cookbook_path(@cookbook), notice: 'Cookbook was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @cookbook.errors, status: :unprocessable_entity }\n end\n end\n end", "def update(url, data)\n RestClient.put url, data, :content_type => :json\nend", "def put!\n request! :put\n end", "def restobooking\n @buchung = Buchung.find(params[:id])\n @buchung.status='B' \n \n respond_to do |format|\n if @buchung.update_attributes(params[:buchung])\n format.html { redirect_to @buchung, notice: 'Buchung wurde erfolgreich geaendert.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @buchung.errors, status: :unprocessable_entity }\n end\n end \n end", "def update\n req = ActiveSupport::JSON.decode(request.body)\n @bookmark = Bookmark.find(req)\n\n respond_to do |format|\n if @bookmark.update_attributes(params[:id])\n format.html { redirect_to @bookmark, notice: 'Bookmark was successfully updated.' }\n format.json { render json: @bookmark, status: :created, location: @bookmarks }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\r\n @book = Book.find(params[:id])\r\n\r\n respond_to do |format|\r\n if @book.update_attributes(params[:book])\r\n format.html { redirect_to books_url }\r\n format.json { head :no_content }\r\n else\r\n format.html { render action: \"edit\" }\r\n format.json { render json: @book.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end", "def update\n @book = Book.find(params[:id])\n\n respond_to do |format|\n if @book.update_attributes(params[:book])\n format.html { redirect_to @book, :notice => 'Book was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @book.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @ba_spec = BaSpec.find(params[:id])\n\n respond_to do |format|\n if @ba_spec.update_attributes(params[:ba_spec])\n format.html { redirect_to session[:return_to] }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @ba_spec.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @cookbook.update(cookbook_params)\n format.html { redirect_to @cookbook, notice: 'Cookbook was successfully updated.' }\n format.json { render :show, status: :ok, location: @cookbook }\n else\n format.html { render :edit }\n format.json { render json: @cookbook.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @book = Book.find(params[:id])\n\n respond_to do |format|\n if @book.update_attributes(params[:book])\n format.html { redirect_to @book, notice: 'Book was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @book = Book.find(params[:id])\n\n respond_to do |format|\n if @book.update_attributes(params[:book])\n format.html { redirect_to @book, notice: 'Book was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @book = Book.find(params[:id])\n\n respond_to do |format|\n if @book.update_attributes(params[:book])\n format.html { redirect_to @book, notice: 'Book was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @book = Book.find(params[:id])\n\n respond_to do |format|\n if @book.update_attributes(params[:book])\n format.html { redirect_to @book, notice: 'Book was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @book = Book.find(params[:id])\n\n respond_to do |format|\n if @book.update_attributes(params[:book])\n format.html { redirect_to @book, notice: 'Book was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @book = Book.find(params[:id])\n\n respond_to do |format|\n if @book.update_attributes(params[:book])\n format.html { redirect_to @book, notice: 'Book was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @book = Book.find(params[:id])\n\n respond_to do |format|\n if @book.update_attributes(params[:book])\n format.html { redirect_to @book, notice: 'Book was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @book = Book.find(params[:id])\n\n respond_to do |format|\n if @book.update_attributes(params[:book])\n format.html { redirect_to @book, notice: 'Book was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @book = Book.find(params[:id])\n\n respond_to do |format|\n if @book.update_attributes(params[:book])\n format.html { redirect_to @book, notice: 'Book was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @bla = Bla.find(params[:id])\n\n respond_to do |format|\n if @bla.update_attributes(params[:bla])\n format.html { redirect_to @bla, :notice => 'Bla was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @bla.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n\n if params[:action] == \"RETURN_BOOK\" \n @book.return()\n elseif params[:action] == \"BORROW_BOOK\"\n @book.borrow()\n end\n \n if @book.update(book_params)\n head :no_content\n else\n render json: @book.errors, status: :unprocessable_entity\n end\n end", "def update\n @book = Book.find(params[:id])\n \n respond_to do |format|\n if @book.update_attributes(params[:book])\n format.html { redirect_to @book, notice: 'Book was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @book = Book.find(params[:id])\n\n respond_to do |format|\n if @book.update_attributes(params[:book])\n format.html { redirect_to @book, notice: 'Book was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @book = @collection.books.find(params[:id])\n #original: @book = Book.find(params[:id])\n\n respond_to do |format|\n if @book.update_attributes(params[:book])\n format.html { redirect_to book_series_collection_books_url(@book_series, @collection), notice: 'Book was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @bowl = Bowl.find(params[:id])\n \n # set bowl modify time\n @bowl.modified = Time.now\n \n respond_to do |format|\n if @bowl.update_attributes(params[:bowl])\n \n Rails.logger.info \"Updating Bowl Contents\"\n \n # remove all contents for this bowl and add new\n @bowl.contents.delete_all(\"bowl_id=\" + @bowl.id)\n \n params.keys.each do |param|\n if param.start_with?(\"input_\") and (params[param] != \"\") \n @bowl.contents.create(:bowl_id => @bowl.id, :dryfruit_id => param[6, 2], :quantity => params[param]) \n end\n end\n\n format.html { redirect_to bowls_path, :notice => 'Bowl was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @bowl.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n params[:book_shelf]['user'] = User.where(:id => params[:book_shelf]['user']).first\n params[:book_shelf]['book'] = Book.where(:id => params[:book_shelf]['book']).first\n @book_shelf = BookShelf.find(params[:id])\n respond_to do |format|\n if @book_shelf.update_attributes(params[:book_shelf])\n format.html { redirect_to @book_shelf, notice: 'Book shelf was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @book_shelf.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @book.update_attributes(params[:book])\n format.html { redirect_to @book, notice: 'Book was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_by_body\n @person = Person.find(person_update_params[:id])\n\n if @person.update_attributes(person_update_params)\n render json: { status: 'PUT Success' }, status: :ok\n else\n render json: { status: 'Error', message:'Error updating person', person: @person.errors }, status: :unprocessable_entity\n end\n end", "def update\n @batch = Batch.find(params[:id])\n\n respond_to do |format|\n if @batch.update_attributes(params[:batch])\n format.html { redirect_to @batch, notice: 'Batch was successfully updated.' }\n format.json { respond_with_bip(@batch) }\n else\n format.html { redirect_to @batch }\n format.json { respond_with_bip(@batch) }\n end\n end\n end", "def patch(path, data)\n request 'PATCH', path, body: data.to_json\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 @book = Book.find(params[:id])\n\n respond_to do |format|\n if @book.update_attributes(book_params)\n format.html { redirect_to @book, notice: 'Book was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @cook_book = CookBook.find(params[:id])\n\n respond_to do |format|\n if @cook_book.update_attributes(params[:cook_book])\n format.html { redirect_to @cook_book, notice: 'Cook book was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @cook_book.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @book = Book.find(params[:id])\n\n respond_to do |format|\n if @book.update_attributes(params[:book])\n format.html { redirect_to manage_books_path, notice: 'Book was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_aos_version(args = {}) \n id = args['id']\n temp_path = \"/aosversions.json/{aosVersionId}\"\n path = temp_path\nargs.keys.each do |key|\n if (key == \"aosversionId\")\n args.delete(key)\n path = temp_path.gsub(\"{#{key}}\", id)\n end\nend\n puts \" PATH : #{path}\"\n put(path, args)\nend", "def update\n job = Job.find(params[:id])\n job.update_attributes(job_params)\n render json: job\n end", "def update\n @book = Book.find(params[:id])\n\n respond_to do |format|\n if @book.update_attributes(params[:book])\n format.html { redirect_to @book, notice: 'Book was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render layout: 'form', action: \"edit\" }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @look_book = LookBook.find(params[:id])\n\n respond_to do |format|\n if @look_book.update_attributes(params[:look_book])\n format.html { redirect_to @look_book, notice: 'Look book was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\", layout: \"forms\" }\n format.json { render json: @look_book.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @book.update(book_params)\n format.html { redirect_to @book }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @ebook = Ebook.find(params[:id])\n\n respond_to do |format|\n if @ebook.update_attributes(params[:ebook])\n format.html { redirect_to @ebook, notice: 'Ebook was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @ebook.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\t\trespond_to do |format|\n\t\t\tclient = Goodreads::Client.new(api_key: \"rSkvvZY8Wx27zcj4AfHA\", api_secret: \"S5WOpmY8pVtaEu1IwNn51DBafjoEIbjuxZdE6sNM\")\n\t\t\tbook = client.book_by_isbn(book_params[:isbn])\n\t\t\t@book.titlelong = book.title\n\t\t\t@book.description = strip_tags(book.description)\n\t\t\t@book.title = book.work.original_title\n\t\t\t@book.pages = book.num_pages\n\t\t\t@book.bookrating = book.average_rating\n\t\t\t@book.author = book.authors.author.name\n\t\t\t@book.publisher = book.publisher\n\t\t\t@book.save\n\t\t\tformat.html { redirect_to @book, notice: 'Book was successfully updated.' }\n\t\t\tformat.json { render :show, status: :ok, location: @book }\n\t\tend\n end", "def update\n respond_to do |format|\n if @book.update(book_params)\n format.html { redirect_to @book, notice: 'Book was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @book.update(book_params)\n format.html { redirect_to @book, notice: 'Book was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @book.update(book_params)\n format.html { redirect_to @book, notice: 'Book was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @book.update(book_params)\n format.html { redirect_to @book, notice: 'Book was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @data = @recipe.update(params[:id], recipe_params)\n render json: @data\n end", "def update\n put :update\n end", "def update\n @book = Book.find(params[:id])\n\n respond_to do |format|\n if @book.update_attributes(params[:book])\n format.html { redirect_to [current_user, @book], notice: 'Book was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @book = Book.find(params[:id])\n\n respond_to do |format|\n if @book.update_attributes(params[:book])\n format.html { redirect_to @book, notice: 'Book was successfully updated.' }\n format.xml { head :ok }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.xml { render xml: @book.errors, status: :unprocessable_entity}\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @book = Book.find(params[:id])\n @book.attributes = params[:book]\n # a break point for debugging:\n # debugger\n client = Goodreads.new\n book_info = client.book_by_isbn(params[:book][:isbn])\n @book.title = book_info.title if @book.title.blank?\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @boc.update(boc_params)\n format.html { redirect_to @boc, notice: 'Boc was successfully updated.' }\n format.json { render :show, status: :ok, location: @boc }\n else\n format.html { render :edit }\n format.json { render json: @boc.errors, status: :unprocessable_entity }\n end\n end\n end", "def update options={}\n client.put(\"/#{id}\", options)\n end", "def update\n @bob = Bob.find(params[:id])\n\n respond_to do |format|\n if @bob.update_attributes(params[:bob])\n format.html { redirect_to @bob, notice: 'Bob was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @bob.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @book1.update(book1_params)\n format.html { redirect_to @book1, notice: \"Book1 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @book1 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @book1.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @batch = Batch.find(params[:id])\n\n respond_to do |format|\n if @batch.update_attributes(params[:batch])\n format.html { redirect_to @batch, notice: 'Batch was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @batch.errors, status: :unprocessable_entity }\n end\n end\n end", "def jsonapi_update!(attributes)\n assign_jsonapi_attributes(attributes)\n save!\n end", "def update\n respond_to do |format|\n if @book.update(book_params)\n format.html { redirect_to [:admin, @book], notice: 'Book was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @jobber = Jobber.find(params[:id])\n\n respond_to do |format|\n if @jobber.update_attributes(params[:jobber])\n format.html { redirect_to @jobber, notice: 'Jobber was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @jobber.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n recipe.update(recipe_params)\n render json: recipe\n end", "def update\n @b = B.find(params[:id])\n\n respond_to do |format|\n if @b.update_attributes(params[:b])\n format.html { redirect_to @b, notice: 'B was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @b.errors, status: :unprocessable_entity }\n end\n end\n end", "def update(attrs, path=nil)\n resp = api_client.put(path || url, JSON.dump(attrs))\n refresh(JSON.load(resp.body))\n end", "def update\n if @boat.update(boat_params)\n head :no_content\n else\n render json: @boat.errors, status: :unprocessable_entity\n end\n end", "def update\n respond_to do |format|\n if @book_a_lawn.update(book_a_lawn_params)\n format.html { redirect_to @book_a_lawn, notice: 'Book a lawn was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @book_a_lawn.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @lob.update(lob_params)\n format.html { redirect_to root_url, notice: 'Lob was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @lob.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @asaaddrobj = Asaaddrobj.find(params[:id])\n\n respond_to do |format|\n if @asaaddrobj.update_attributes(params[:asaaddrobj])\n format.html { redirect_to @asaaddrobj, notice: 'Asaaddrobj was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @asaaddrobj.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @bl = Bl.find(params[:id])\n\n respond_to do |format|\n if @bl.update_attributes(params[:bl])\n format.html { redirect_to @bl, notice: 'Bl was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @bl.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n puts \"update #{@need.as_json} #{updated_params.as_json}\"\n respond_to do |format|\n if @need.update(updated_params)\n puts \"brucep update success\"\n format.html { redirect_to new_need_path }\n format.json { render :show, status: :ok, location: @need }\n else\n format.html { render :edit }\n format.json { render json: @need.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @kb = Kb.find(params[:id])\n\n respond_to do |format|\n if @kb.update_attributes(params[:kb])\n format.html { redirect_to @kb, :notice => 'Kb was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @kb.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @a = A.find(params[:id])\n\n respond_to do |format|\n if @a.update_attributes(params[:a])\n format.html { redirect_to @a, notice: 'A was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @a.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @bundle = Bundle.find(params[:id])\n\n respond_to do |format|\n if @bundle.update_attributes(params[:bundle])\n format.html { redirect_to @bundle, notice: 'Bundle was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @bundle.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @lob = Lob.find(params[:id])\n\n if @lob.update(lob_params)\n head :no_content\n else\n render json: @lob.errors, status: :unprocessable_entity\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 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 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 update\n respond_to do |format|\n if @book_request.update(book_request_params)\n format.html { redirect_to @book_request, notice: 'Book request was successfully updated.' }\n format.json { render :show, status: :ok, location: @book_request }\n else\n format.html { render :edit }\n format.json { render json: @book_request.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @notebook = Notebook.find(params[:id])\n\n respond_to do |format|\n if @notebook.update_attributes(params[:notebook])\n format.html { redirect_to @notebook, notice: 'Notebook was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @notebook.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @notebook = Notebook.find(params[:id])\n\n respond_to do |format|\n if @notebook.update_attributes(params[:notebook])\n format.html { redirect_to @notebook, notice: 'Notebook was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @notebook.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @user_book = UserBook.find(params[:id])\n\n respond_to do |format|\n if @user_book.update_attributes(params[:user_book])\n format.html { redirect_to new_user_book_path, notice: 'Your book was successfully updated. You can add more or go back to your shelf' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user_book.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @batch.update_attributes(params[:batch])\n format.html { redirect_to @batch, notice: 'Batch was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @batch.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n ingredient.update(ingredient_params)\n render json: ingredient\n end", "def update\n respond_to do |format|\n if @my_book.update(my_book_params)\n format.html { redirect_to @my_book, notice: 'My book was successfully updated.' }\n format.json { render :show, status: :ok, location: @my_book }\n else\n format.html { render :edit }\n format.json { render json: @my_book.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n #@jobapp = Jobapp.find(params[:id])\n\n respond_to do |format|\n if @jobapp.update_attributes(params[:jobapp])\n format.html { redirect_to @jobapp, notice: 'Jobapp was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @jobapp.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_job_success(job_id, success)\n RestClient.put \"#{rest_jobs_url}/#{job_id}\", {\"passed\" => success}.to_json, :content_type => :json\nend", "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 @book = Book.find(params[:id])\n respond_to do |format|\n if @book.update(book_params)\n format.html { redirect_to @book, notice: 'Book was successfully updated.' }\n format.json { render :show, status: :ok, location: @book }\n else\n format.html { render :edit }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @businessbook = Businessbook.find(params[:id])\n\n respond_to do |format|\n if @businessbook.update_attributes(params[:businessbook])\n format.html { redirect_to @businessbook, :notice => 'Businessbook was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @businessbook.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @cook_book.update(cook_book_params)\n format.html { redirect_to @cook_book, notice: 'Cook book was successfully updated.' }\n format.json { render :show, status: :ok, location: @cook_book }\n else\n format.html { render :edit }\n format.json { render json: @cook_book.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @osoba = Osoba.find(params[:id])\n\n if @osoba.update(params[:osoba])\n head :no_content\n else\n render json: @osoba.errors, status: :unprocessable_entity\n end\n end", "def update\n @request.assign_json_attributes(params) if @request.resume?\n respond_to do |format|\n if @request.update(request_params)\n format.html { redirect_to @request, notice: 'Request was successfully updated.' }\n format.json { render :show, status: :ok, location: @request }\n else\n format.html { render :edit }\n format.json { render json: @request.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @my_boice.update(my_boice_params)\n format.html { redirect_to @my_boice, notice: 'My boice was successfully updated.' }\n format.json { render :show, status: :ok, location: @my_boice }\n else\n format.html { render :edit }\n format.json { render json: @my_boice.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @book = Book.find_by_id(params[:id])\n\n if @book.present?\n if @book.update(book_params)\n render json: {\n type: 'success',\n result: @book\n }, status: :created\n else\n render json: {\n type: 'failed',\n message: @book.errors,\n result: {}\n }, status: :bad_request\n end\n else\n render json: {\n type: 'failed',\n message: 'data with id:' + params[:id] + ' not found',\n result: {},\n }, status: :not_found\n end\n end" ]
[ "0.63389295", "0.62552476", "0.62552476", "0.6253487", "0.6253081", "0.6228533", "0.62126774", "0.6208144", "0.6187638", "0.6162022", "0.61475354", "0.61317796", "0.60827076", "0.6082219", "0.60683763", "0.6060259", "0.6018262", "0.601791", "0.6011754", "0.5998342", "0.5998342", "0.5998342", "0.5998342", "0.5998342", "0.5998342", "0.5998342", "0.5998342", "0.5998342", "0.59976995", "0.59968567", "0.599613", "0.5992315", "0.59881085", "0.5980605", "0.59709954", "0.59503806", "0.5929469", "0.5922463", "0.5900709", "0.5900191", "0.58932745", "0.587967", "0.5874097", "0.5863616", "0.58617604", "0.5858476", "0.5856004", "0.5852921", "0.5850006", "0.58492446", "0.58414", "0.58414", "0.58414", "0.58414", "0.583897", "0.5838843", "0.58306694", "0.58257467", "0.58217746", "0.5815952", "0.5814843", "0.5813935", "0.58121985", "0.581126", "0.5808736", "0.57994276", "0.57965565", "0.5794624", "0.5784863", "0.57819664", "0.57801825", "0.5761192", "0.5755339", "0.5749242", "0.5740694", "0.5737564", "0.573379", "0.57289225", "0.572553", "0.57202244", "0.57155013", "0.5713468", "0.57132417", "0.5710089", "0.57086", "0.57086", "0.5706432", "0.570599", "0.57047516", "0.5694882", "0.5693215", "0.5690034", "0.5689186", "0.5688406", "0.5687685", "0.5687636", "0.56850755", "0.568262", "0.5682568", "0.56786346" ]
0.65643257
0
DELETE /abooks/1 DELETE /abooks/1.json
def destroy @abook.destroy respond_to do |format| format.html { redirect_to abooks_url, notice: 'Abook 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 delete_aos_version(args = {}) \n delete(\"/aosversions.json/#{args[:aosVersionId]}\", args)\nend", "def destroy\n @api_book.destroy\n\n head :no_content\n end", "def delete(path)\n RestClient.delete request_base+path\n end", "def destroy\n @ebooks.destroy :id\n respond_to do |format|\n format.html { redirect_to ebooks_url, notice: 'Ebook was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def cmd_delete argv\n setup argv\n uuid = @hash['uuid']\n response = @api.delete(uuid)\n msg response\n return response\n end", "def destroy\n @cookbook = Cookbook.find(params[:id])\n @cookbook.destroy\n\n respond_to do |format|\n format.html { redirect_to cookbooks_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @cook.destroy\n respond_to do |format|\n format.html { redirect_to cooks_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @lob.destroy\n respond_to do |format|\n format.html { redirect_to root_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @bread.destroy\n respond_to do |format|\n format.html { redirect_to breads_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @baton = Baton.find(params[:id])\n @baton.destroy\n\n respond_to do |format|\n format.html { redirect_to batons_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @bow.destroy\n respond_to do |format|\n format.html { redirect_to bows_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @basin = Basin.find(params[:id])\n @basin.destroy\n\n respond_to do |format|\n format.html { redirect_to basins_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 book = Book.find(params[:id])\n book.destroy\n \n render json: {}, status: 204\n end", "def destroy\n @cookbook.destroy\n respond_to do |format|\n format.html { redirect_to cookbooks_url }\n format.json { head :no_content }\n end\n end", "def delete(id)\n request(:delete, \"/recipes/#{id}.json\")\n end", "def destroy\n @ab_chapter.destroy\n respond_to do |format|\n format.html { redirect_to ab_chapters_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 path\n make_request(path, \"delete\", {})\n end", "def destroy\n @ebook.destroy\n respond_to do |format|\n format.html { redirect_to ebooks_url }\n format.json { head :no_content }\n end\n end", "def delete(*rest) end", "def destroy\n @boc.destroy\n respond_to do |format|\n format.html { redirect_to bocs_url, notice: 'Boc was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @cook_book = CookBook.find(params[:id])\n @cook_book.destroy\n\n respond_to do |format|\n format.html { redirect_to cook_books_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @book_shelf = BookShelf.find(params[:id])\n @book_shelf.destroy\n\n respond_to do |format|\n format.html { redirect_to book_shelves_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @ruby.destroy\n respond_to do |format|\n format.html { redirect_to rubies_url }\n format.json { head :no_content }\n end\n end", "def delete_json(path)\n url = [base_url, path].join\n resp = HTTParty.delete(url, headers: standard_headers)\n parse_json(url, resp)\n end", "def destroy\n @book = Book.find(params[:id])\n @book.destroy\n \n respond_to do |format|\n format.html { redirect_to books_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @batch = Batch.find(params[:id])\n @batch.destroy\n\n respond_to do |format|\n format.html { redirect_to recipe_path(@batch.recipe_id)}\n format.json { head :no_content }\n end\n end", "def destroy\n @book = Book.find_by_sql(\"SELECT * FROM Books B WHERE B.id = \" + params[:id]).first()\n @book.destroy\n\n respond_to do |format|\n format.html { redirect_to \"/books\" }\n format.json { head :no_content }\n end\n end", "def delete\n request(:delete)\n end", "def destroy\n @bicicletum.destroy\n respond_to do |format|\n format.html { redirect_to bicicleta_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @b = B.find(params[:id])\n @b.destroy\n\n respond_to do |format|\n format.html { redirect_to bs_url }\n format.json { head :no_content }\n end\n end", "def delete\n render json: Item.delete(params[\"id\"])\n end", "def destroy\n @title = \"Destroy Book\"\n\n # @book.destroy\n\n respond_to do |format|\n format.html { redirect_to books_url }\n format.json { head :ok }\n end\n end", "def delete(object)\n full_name = extract_full_name object\n post 'api/del', :id => full_name\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!( opts = {} )\n http_action :delete, nil, opts\n end", "def delete\n render json: Alien.delete(params[\"id\"])\n end", "def delete\n url = prefix + \"delete\" + id_param\n return response(url)\n end", "def destroy\n @book = Book.find(params[:id])\n @book.destroy\n\n respond_to do |format|\n \n format.json { render json: @book, status: :created, location: @book }\n end\n end", "def destroy\n @book = Book.find(params[:id])\n @book.destroy\n\n respond_to do |format|\n format.html { redirect_to books_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @book = Book.find(params[:id])\n @book.destroy\n\n respond_to do |format|\n format.html { redirect_to books_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @book = Book.find(params[:id])\n @book.destroy\n\n respond_to do |format|\n format.html { redirect_to books_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @book = Book.find(params[:id])\n @book.destroy\n\n respond_to do |format|\n format.html { redirect_to books_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @book = Book.find(params[:id])\n @book.destroy\n\n respond_to do |format|\n format.html { redirect_to books_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @book = Book.find(params[:id])\n @book.destroy\n\n respond_to do |format|\n format.html { redirect_to books_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @book = Book.find(params[:id])\n @book.destroy\n\n respond_to do |format|\n format.html { redirect_to books_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @book = Book.find(params[:id])\n @book.destroy\n\n respond_to do |format|\n format.html { redirect_to books_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @book = Book.find(params[:id])\n @book.destroy\n\n respond_to do |format|\n format.html { redirect_to books_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @book = Book.find(params[:id])\n @book.destroy\n\n respond_to do |format|\n format.html { redirect_to books_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @book = Book.find(params[:id])\n @book.destroy\n\n respond_to do |format|\n format.html { redirect_to books_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @book = Book.find(params[:id])\n @book.destroy\n\n respond_to do |format|\n format.html { redirect_to books_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @ba.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 @sabio = Sabio.find(params[:id])\n @sabio.destroy\n\n respond_to do |format|\n format.html { redirect_to sabios_url }\n format.json { head :ok }\n end\n end", "def destroy\n @book = Book.find(params[:id])\n @book.destroy\n\n respond_to do |format|\n format.html { redirect_to books_url }\n format.json { head :ok }\n end\n end", "def destroy\n @book = Book.find(params[:id])\n @book.destroy\n\n respond_to do |format|\n format.html { redirect_to books_url }\n format.json { head :ok }\n end\n end", "def destroy\n @bob = Bob.find(params[:id])\n @bob.destroy\n\n respond_to do |format|\n format.html { redirect_to bobs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @book = Book.find(params[:id])\n @book.destroy\n\n respond_to do |format|\n format.html { redirect_to books_url }\n format.json { head :ok }\n end \n end", "def destroy\n @bowl = Bowl.find(params[:id])\n @bowl.destroy\n\n respond_to do |format|\n format.html { redirect_to bowls_url }\n format.json { head :no_content }\n end\n end", "def delete\n client.delete(url)\n @deleted = true\nend", "def destroy\n @book1.destroy\n respond_to do |format|\n format.html { redirect_to book1s_url, notice: \"Book1 was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def delete!\n request! :delete\n end", "def destroy\n @aquarium = Aquarium.find(params[:id])\n @aquarium.destroy\n\n respond_to do |format|\n format.html { redirect_to aquaria_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @lob.destroy\n\n head :no_content\n end", "def destroy\n @operation.destroy\n respond_to do |format|\n format.html { redirect_to bank_books_path }\n format.json { head :no_content }\n end\n end", "def destroy\n # @bill_quorum = BillQuorum.find(params[:id])\n @bill_quorum.destroy\n\n respond_to do |format|\n format.html { redirect_to bill_quorums_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @ambit.destroy\n respond_to do |format|\n format.html { redirect_to ambits_url }\n format.json { head :no_content }\n end\n end", "def delete(id:)\n id_check(:id, id)\n\n cf_delete(path: \"/organizations/#{org_id}/railguns/#{id}\")\n end", "def destroy\n @book = Book.find(params[:id])\n @book.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 @ebook = Ebook.find(params[:id])\n @ebook.destroy\n\n respond_to do |format|\n format.html { redirect_to ebooks_url }\n format.json { head :no_content }\n end\n end", "def destroy\r\n @book = Book.find(params[:id])\r\n @book.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_to books_url }\r\n format.json { head :no_content }\r\n end\r\n end", "def destroy\n # @recipe = Recipe.find(params[:id])\n # @recipe.destroy\n #\n destroy! do |format|\n # format.html { redirect_to recipes_url }\n # format.json { head :ok }\n end\n end", "def destroy\r\n @book = Book.find(params[:id])\r\n @book.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_to books_url }\r\n format.json { head :ok }\r\n end\r\n end", "def delete\n \n end", "def destroy\n @book.destroy\n respond_to do |format|\n format.html { redirect_to books_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @book.destroy\n respond_to do |format|\n format.html { redirect_to books_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @book.destroy\n respond_to do |format|\n format.html { redirect_to books_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @book.destroy\n respond_to do |format|\n format.html { redirect_to books_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @book.destroy\n respond_to do |format|\n format.html { redirect_to books_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @book.destroy\n respond_to do |format|\n format.html { redirect_to books_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @book.destroy\n respond_to do |format|\n format.html { redirect_to books_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @baz1.destroy\n respond_to do |format|\n format.html { redirect_to baz1s_url, notice: \"Baz1 was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @bath.destroy\n respond_to do |format|\n format.html { redirect_to baths_url, notice: 'Bath was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @book_a_lawn.destroy\n respond_to do |format|\n format.html { redirect_to book_a_lawns_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 @record = Asset.find(params[:id])\n @record.trash\n respond_to do |format| \n format.json { head :no_content }\n end\n end", "def destroy\n @bl = Bl.find(params[:id])\n @bl.destroy\n\n respond_to do |format|\n format.html { redirect_to bls_url }\n format.json { head :no_content }\n end\n end", "def deletes_to(path,opts={},&block) #:nodoc: \n crud_to(:delete,path,opts[:params] || {},opts,&block)\n end", "def delete\n api(\"Delete\")\n end", "def destroy\n @bla = Bla.find(params[:id])\n @bla.destroy\n\n respond_to do |format|\n format.html { redirect_to blas_url }\n format.json { head :no_content }\n end\n end", "def delete\n \n end", "def destroy\n @brew.destroy\n respond_to do |format|\n format.html { redirect_to brews_url }\n format.json { head :no_content }\n end\n end", "def destroy\n return if new_record?\n \n @api.delete \"/items/#{shortcode_url}.json\"\n end", "def destroy\n @kb = Kb.find(params[:id])\n @kb.destroy\n\n respond_to do |format|\n format.html { redirect_to kbs_url }\n format.json { head :ok }\n end\n end", "def destroy\n @cookbook.destroy\n respond_to do |format|\n format.html { redirect_to cookbooks_url, notice: 'Cookbook was successfully destroyed.' }\n format.json { head :no_content }\n end\n end" ]
[ "0.702121", "0.6976222", "0.6811468", "0.67723113", "0.676742", "0.6674516", "0.6669128", "0.66688925", "0.6666575", "0.6654977", "0.66456056", "0.6628885", "0.66274464", "0.6623885", "0.66220206", "0.661985", "0.66136426", "0.6591164", "0.65891767", "0.65891767", "0.65891767", "0.65891767", "0.658106", "0.6566483", "0.6566269", "0.656116", "0.65557516", "0.654993", "0.65440047", "0.6530586", "0.65298545", "0.65210164", "0.6513214", "0.6512909", "0.6508038", "0.65036273", "0.64912605", "0.64910233", "0.6488416", "0.6486813", "0.6486813", "0.6485448", "0.6484751", "0.6482428", "0.6481335", "0.64804167", "0.64804167", "0.64804167", "0.64804167", "0.64804167", "0.64804167", "0.64804167", "0.64804167", "0.64804167", "0.64804167", "0.64804167", "0.64804167", "0.64779323", "0.647679", "0.64748746", "0.64748746", "0.64688796", "0.64630455", "0.6461119", "0.6460283", "0.64546776", "0.6453024", "0.644897", "0.64374775", "0.6436538", "0.64352304", "0.6424776", "0.6424059", "0.6422884", "0.6421573", "0.64199185", "0.6407764", "0.64075315", "0.64053774", "0.6403335", "0.6403335", "0.6403335", "0.6403335", "0.6403335", "0.6403335", "0.6403335", "0.64014465", "0.6399188", "0.63964766", "0.6392525", "0.6391218", "0.6390712", "0.63904613", "0.6389234", "0.63883907", "0.6385637", "0.638507", "0.63843435", "0.6380439", "0.6377458" ]
0.70690453
0
Use callbacks to share common setup or constraints between actions.
def set_abook @abook = Abook.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 abook_params params.require(:abook).permit(:title, :description, :sdescription, :image, :previewo, :previewt, :previewth, :price, :offerprice, :coupon, :author, :publication, :saving, :off) 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
new is initialized with an argument of a title pushes new instances into a class variable
def initialize(title) @title=title @@all << self end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initialize(name)\n @name = name\n @@all << self #pushes every instance into the @@all array\nend", "def initialize(name) #initial with name\n @name = name # set name instance varibale to the passing name\n @@all << self # keep track of all instances by putting each instance into the class variable all array\n end", "def new()\n trace(\"Instance #{index} created\")\n index += 1\n end", "def new; end", "def new; end", "def new; end", "def new; end", "def new; end", "def new; end", "def new; end", "def new; end", "def new; end", "def initialize (title)\n @title = title\n @@all << self \n end", "def initialize(name) #new is initialized with argument for name\n @name = name #HAS A name\n @@all << self #pushes new instances (self) in our class variable upon initialization\n end", "def instantiate!; end", "def new\n \n end", "def new\n \n end", "def new\n \n end", "def new\n \n end", "def new\n \n end", "def initialize(name) # initialize with name\n @name = name # set instance variable name = to the name thats passed\n @@all << self # pushes every instance into the class variable array all\n end", "def initialize(name) # takes name as input\n @name = name # instance variable for person name\n @species = \"human\" # set species to human\n @@all << self # pushes each instance to @@all array\n end", "def new\n \n end", "def new\n AwesomeObject.new(self)\n end", "def new\n AwesomeObject.new(self)\n end", "def initialize(name)\n @name = name #initialize any name\n @@all << self # pushing class into class variable\n end", "def initialize (name, age)\n @name = name\n @age = age \n @@all << self\n\nend", "def class() end", "def initialize(name, artist, genre) #pass in these 3 arguments to initialize a song by their parameters\n @name = name #setting instance var to local vars (local vars that are passed in and then saved as an instance)\n @artist = artist\n @genre = genre\n @@all << self #shovel all instances of this class into the empty array\n end", "def class=(_arg0); end", "def initialize (name)\n @name = name\n @@all_authors.push(self)\n #when an instance is made with its name, we push that intance to the array\n end", "def initialize(name)\n @name = name # starts with genre name\n @@all << self # pushes each instance to @@all array\n end", "def new\n @entry = @class.new\n @name = @class.name.underscore.humanize.split.map(&:capitalize).join(' ')\n end", "def initialize(title)\n @title = title\n @@all << self\n end", "def constructor; end", "def initialize name\n\t\t@name = name\n\t\t@@instances << self\n\tend", "def initialize\n @title\n @@all << self\n end", "def initialize(name, artist, genre)\n @name = name\n @artist = artist\n @genre = genre\n @@all << self\nend", "def initialize(species, weight, nickname, zoo)\n @species = species\n @weight = weight\n @nickname = nickname\n @zoo = zoo\n @@all << self\n\n #everytime a new animal object is created, its shoveled into the Animal class\n\nend", "def new(*args)\n self.class.new(*args)\n end", "def initialize(name)\n @name = name\n @@all << self\nend", "def myAnotherInstance = new ObjectOrientedProgramming()", "def new(*args) dup.initialize(*args) end", "def initialize(name, age, style)\n # - We assign our attributes (instance variables) here!\n @name = name\n @age = age\n @style = style\n\n # - As well as pushed all instances inside of our @@all\n @@all << self\n end", "def initialize(title)\n @title = title\n @@all << self # on init, add self instance of Project\n # to all instances of Project arr\n end", "def construct\n end", "def initialize(name)\n @name = name\n @@all << self #HAS MANY songs (array). We then push all instances onto our class variable upon creation\n end", "def new\n BaseObject.new(self)\n end", "def initialize(name) #automatically instantiates a new genre & requires an argument (name)\n @name = name #accepts a (name) for the new instance of genre\n @@all = [] #automatically stores the new instance of genre in the @@all = [] class variable\n @songs = [] #automatically stores instances of songs\n end", "def title(sym)\n\t\t@newClass = Object.const_set(sym, Class.new)\n\t\t@newClass.class_eval %{require 'yaml'\n\t\t\t\t\t\t\t\t\tdef self.load_from_file(filename)\n\t\t\t\t\t\t\t\t\t\tarr = YAML::load(File.open(filename)).values[0]\n\t\t\t\t\t\t\t\t\t\tret = Array.new\n\t\t\t\t\t\t\t\t\t\tarr.each do |n|\n\t\t\t\t\t\t\t\t\t\t\tbegin\n\t\t\t\t\t\t\t\t\t\t\t\tobj = self.new(n)\n\t\t\t\t\t\t\t\t\t\t\t\tret << obj\n\t\t\t\t\t\t\t\t\t\t\trescue\n\t\t\t\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\t\t\t\t#p ret\n\t\t\t\t\t\t\t\t\t\treturn ret\n\t\t\t\t\t\t\t\t\tend\n\t\t\t}\n\t\t@newClass.class_eval %{\n\t\t\t\t\t\t\t\t\tdef initialize(args)\n\t\t\t\t\t\t\t\t\t\targs.each do |arg|\n\t\t\t\t\t\t\t\t\t\t\tself.method(\"#\\{arg[0]\\}=\").call(arg[1])\n\t\t\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\t\t\tend\n\n\t\t\t\t\t\t\t\t\t}\n\t\t#puts @newClass\n end", "def self_new\n end", "def new(*args)\n self.class.new(*args)\n end", "def initialize(title)\n @title = title\n puts self\n end", "def initialize(name) # initialize with a name\n @name = name\n @@all << self # push each genre instance into the all array\n end", "def initialize(name) #when song is created a name is mandatory\n @name = name #writes/sets a name to the song\n @@all << self #pushes all song instances into songs class array\n end", "def initialize(name, years_experience)\n @name = name\n @years_experience = years_experience\n @@all << self #pushing each new Artist class instance into the array\n end", "def initialize(first_name, how_old)\n # @ vars are called _instance variables_\n @name = first_name\n @age = how_old\n # if self is in an instance method,\n # it refers to an instance!\n @@all << self\n end", "def new_object\n @object = scope.new params[object_name.to_sym]\n set_instance\n end", "def new(*args)\n o = self.allocate # Create a new object of this class\n o.initialize(*args) # Call the object's initialize method with our args\n o # Return new object; ignore return value of initialize\nend", "def new #:nodoc:\n end", "def initialize(author, title, word_count)\n @author = author\n @title = title\n @word_count = word_count\n @@all_books.push(self)\n\n # where when a book is made with Book.new, we pass it a name, title, and word count, all of which it can later access, the instanace is then pushed into an array that the class holds\n end", "def build_new(*args)\n self.class.new(*args)\n end", "def initialize(name, specialty)\n @name = name\n @specialty = specialty\n @@all << self\n\nend", "def new()\n #This is a stub, used for indexing\n end", "def initialize(name, breed, age) #initialize with 3 arguments.\n @name = name\n @breed = breed\n @age = age\n DOGS << self #showell into empty DOGS array. \nend", "def create(name)\n object = new(name)\n @instances.push(object)\n object\n end", "def initialize(name:, rating:, city:, total_rooms:, features:)\n @name = name\n @rating = rating\n @city = city\n @total_rooms = total_rooms\n @features = features\n @@hotels << self\n # self.class.count += 1\n\n end", "def initialize (name) #when a fish is created in CL ie. f1 = Fish.new('nemo'), this method will autorun, and you have to give it a name\n puts 'new fish is born'\n # health = 10 # local\n @health = 10 # increases to an instance variable\n @speed = 5\n @name = name\n stomach = [ ]\n\n end", "def initialize\n @by_class = {}\n end", "def new\n @class_register = ClassRegister.new\n end", "def new(*args,&block)\n Base.new(*args,&block)\n end", "def initialize(title)\n @title = title\n @@all << self\n end", "def instantiate(*args)\n clazz.new(*args)\n end", "def initialize(name, artist=nil)\n # has a name\n @name = name\n @artist = artist\n# new pushes new instances into a class variable called @@all upon initialization\n @@all << self\n end", "def really_new\n return self.new\n end", "def new \n end", "def initialize (name)\n @name = name #an artist has a name\n \n @@all << self \n \nend", "def initialize(x) # constructor \n @inst = x # instance variables start with @ \n @@cla += 1 # each object shares @@cla \n end", "def initialize(title)\n #create a instance variable for title\n @title = title\n end", "def initialize(name, age)\n @name = name\n @age = age \n @@all << self \n end", "def initialize(title)\n @title = title\n @author = author\n @@all << self\n end", "def initialize(name)\n @name = name\n @@all << self # adds the new dog instance to the @@all array\n end", "def initialize args\n index = 0\n puts args\n #iterates through all the instance variables declared at the time\n #of class creation and sets \n self.class.instance_variables.each do |instance_variable|\n\n #To set instance_variable as per new object values \n self.class.instance_variable_set( \"#{ instance_variable}\", args[ index ] )\n \n #To get value of class_variable i.e. returns array\n class_variable_array = self.class.class_variable_get( \"@#{ instance_variable }\" )\n \n #To push new args value into class variable\n self.class.class_variable_set( \"@#{ instance_variable }\", class_variable_array.push( \"#{ args[ index ] }\" ) ) \n index += 1\n end\n puts self.is_a? Sourcedetails\n end", "def initialize(name)\n @@count += 1\n @name = name #このクラス内であれば使用できる\n end", "def new\n \n end", "def new\n \n end", "def new\n \n end", "def new\n \n end", "def new\n \n end", "def initialize(name)\n # scoped to one instance\n\n @name = name\n # @cast = []\n @@all << self\n end", "def initialize(name, isSuperFan, birthMonth, performer=nil)\n @name = name\n @isSuperFan = isSuperFan\n @birthMonth = birthMonth\n @performer = performer\n @@all << self #self is instance being created here \n end", "def new(components)\n self.class.new(self, components)\n end", "def initialize(title)\n @title = title \n end", "def instance; end", "def instance; end", "def instance; end", "def new_song(name, genre)\n Song.new(name, self, genre)\nend", "def new(namespace, name, *args, &block); end", "def initialize #everytie an instance of the class is initialized, we should push it into the @@all class variable\n @@all << self\n end", "def initialize(new_name)\n\t\t@name = new_name\n\t\t\n\t\tif self.class == Player\t\t#Player for the first game app.rb \n\t\t\t@life_points=10\n\t\t\t@@all_players << self\t #adds new players if necessary \n\t\tend\n\n\tend" ]
[ "0.72222126", "0.7077006", "0.7055978", "0.6976549", "0.6976549", "0.6976549", "0.6976549", "0.6976549", "0.6976549", "0.6976549", "0.6976549", "0.6976549", "0.6931541", "0.6927776", "0.68961716", "0.6885669", "0.6885669", "0.6885669", "0.6885669", "0.6885669", "0.6832213", "0.6782297", "0.67820084", "0.6696551", "0.6696551", "0.6686634", "0.6662932", "0.66577405", "0.6648589", "0.66394085", "0.6639334", "0.66383845", "0.6633249", "0.66158956", "0.6611424", "0.6602105", "0.65788877", "0.6574879", "0.65585655", "0.6556235", "0.654992", "0.65448004", "0.65402263", "0.6522398", "0.65135205", "0.649952", "0.6488147", "0.64787316", "0.645732", "0.64405274", "0.64386535", "0.6432526", "0.6416224", "0.6413479", "0.6390511", "0.63890314", "0.63793594", "0.63716024", "0.6363819", "0.63530016", "0.63520133", "0.6339095", "0.63389564", "0.63383543", "0.6336799", "0.6336745", "0.63320976", "0.6329001", "0.6319054", "0.63091075", "0.6298244", "0.62956625", "0.6294457", "0.62864417", "0.6268786", "0.62600154", "0.62482125", "0.6235092", "0.62350494", "0.6234184", "0.6233156", "0.6229969", "0.622471", "0.6220205", "0.6214019", "0.6214019", "0.6214019", "0.6214019", "0.6214019", "0.6212246", "0.6211062", "0.62023985", "0.61974883", "0.6194929", "0.6194929", "0.6194929", "0.6192511", "0.6181081", "0.617567", "0.61734176" ]
0.66767985
26
author_name knows the name of its author returns nil if the post does not have an author
def author_name if self.author self.author.name else nil end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def author_name\n self.author ? self.author.name : nil\n end", "def author_name\n self.posts.first.author_name\n end", "def author_name\n self.author ? self.author.name : nil \n end", "def author_name\n self.author.name if author \n end", "def author_name\n author.full_name if author\n end", "def author_name\n if author\n author.full_name\n else\n 'No Author Found'\n end\n end", "def author\n @title_pages.each { |tp| tp.author and return tp.author }\n nil\n end", "def author_name\n self.author ? \"#{self.author}\" : 'Anonymous'\n end", "def author\n @author ||= begin\n UnfuddleAPI::People.find(self[:author_id]).username\n rescue\n ''\n end\n end", "def author\n commenter.try(:name)\n end", "def name\n author_hash[\"name\"]\n end", "def name\n author_hash[\"name\"]\n end", "def get_author_name(author)\n author_object = Author.find_by_var(\"authors\", \"id\", author) \n # => one Author Obj\n @author_name = author_object.name\n \n end", "def author\n @author ||= get_author\n end", "def author_name\n user_data.name || login\n end", "def author_name\n object.anonymous? ? '匿名用户' : object.author.name_or_login\n end", "def get_author()\n @author\n end", "def author\n val = authors and val.first\n end", "def get_author()\n return @author\n end", "def author_name\n if read_attribute('comment_body') =~ COMMENT_BODY_PARSER\n $1\n elsif created_by and created_by.sfcontact\n created_by.sfcontact.name\n end\n end", "def is_the_author_of_the_post(post)\n post.author_id == current_author.id\n end", "def\n get_author()\n @author\n end", "def get_author()\n if not self.check_metatags('author')\n return false\n end\n author = @@metadata['author'].gsub(/\\./,'_').gsub(/\\&/,'').gsub(/\\-/,'_').gsub(/\\s/,'_').gsub(/\\,/,'_').gsub(/\\_\\_/,'_')\n I18n.enforce_available_locales = false\n I18n.transliterate(author).downcase # Normalising\n end", "def author?\n !author.nil? && !author.empty?\n end", "def resolved_author; end", "def author\n @author\n end", "def posts_by_author(author_name, posts = nil)\n posts ||= published_weblog\n posts.select { |post| post._unwrap.attributes[:author_name] == author_name }\n end", "def author_string\n if !self.verbatim_author.nil?\n self.verbatim_author\n elsif !self.source_id.nil?\n self.source.authority_name\n else\n nil\n end\n end", "def author_full_name\n self.author.full_name\n end", "def check_author\n if self.author.blank?\n self.author = 'anon'\n end\n end", "def author_name\n user.blank? ? I18n.t('view.comments.anonymous') : user.name\n end", "def author\n authors.first\n end", "def author\n authors.first\n end", "def author\n traverse_element('meta',\n '{http://www.w3.org/1999/xhtml}meta') {|e|\n begin\n next unless e.fetch_attr('name').downcase == 'author'\n author = e.fetch_attribute('content').strip\n return author if !author.empty?\n rescue IndexError\n end\n }\n\n traverse_element('link',\n '{http://www.w3.org/1999/xhtml}link') {|e|\n begin\n next unless e.fetch_attr('rev').downcase == 'made'\n author = e.fetch_attribute('title').strip\n return author if !author.empty?\n rescue IndexError\n end\n } \n\n if channel = find_element('{http://purl.org/rss/1.0/}channel')\n channel.traverse_element('{http://purl.org/dc/elements/1.1/}creator') {|e|\n begin\n author = e.extract_text.strip\n return author if !author.empty?\n rescue IndexError\n end\n }\n channel.traverse_element('{http://purl.org/dc/elements/1.1/}publisher') {|e|\n begin\n author = e.extract_text.strip\n return author if !author.empty?\n rescue IndexError\n end\n }\n end\n\n nil\n end", "def author; @author; end", "def author; @author; end", "def author\n @author ||=\n convert_content(item_attributes!.author) ||\n convert_content(item_attributes!.creator) ||\n \"\"\n end", "def author\n\t\t@author\n\tend", "def get_author\n\t\t# TODO\n\t\tauthor_id\n\tend", "def default_author\n if author \n author \n else\n 'joe'\n end \n end", "def getAuthorName\n\t\treturn User.find(self.user_id).username\n\tend", "def the_author(content=nil)\n if node = content || @content || Content.get(params[:id]) \n author = node.author\n end\n end", "def author value = nil\n return @author if value.nil?\n @author = value\n end", "def get_linked_author_name_or_blank\n ret = get_author_name_or_blank\n ret = \"<a href=\\\"#{self.link}\\\" target=\\\"quote_extern\\\">#{ret}</a>\" unless ret.blank? or self.link.blank?\n ret\n end", "def author\n return User.find(self.user_id).user_name\n end", "def author_name\n \"#{author.first_name} #{author.last_name}\"\n end", "def validate_the_author_of_the_post(post)\n if !is_the_author_of_the_post(post)\n puts \">>>>>> Validation failed: Un-author action is prohibited!\"\n redirect_to post_path\n end\n end", "def author\n traverse_element('meta',\n '{http://www.w3.org/1999/xhtml}meta') {|e|\n begin\n next unless e.fetch_attr('name').downcase == 'author'\n author = e.fetch_attribute('content').strip\n return author if !author.empty?\n rescue IndexError\n end\n }\n\n traverse_element('link',\n '{http://www.w3.org/1999/xhtml}link') {|e|\n begin\n next unless e.fetch_attr('rev').downcase == 'made'\n author = e.fetch_attribute('title').strip\n return author if !author.empty?\n rescue IndexError\n end\n }\n\n if channel = find_element('{http://purl.org/rss/1.0/}channel')\n channel.traverse_element('{http://purl.org/dc/elements/1.1/}creator') {|e|\n begin\n author = e.extract_text.strip\n return author if !author.empty?\n rescue IndexError\n end\n }\n channel.traverse_element('{http://purl.org/dc/elements/1.1/}publisher') {|e|\n begin\n author = e.extract_text.strip\n return author if !author.empty?\n rescue IndexError\n end\n }\n end\n\n ['http://www.w3.org/2005/Atom', 'http://purl.org/atom/ns#'].each {|xmlns|\n each_child {|top|\n next unless top.elem?\n if top.name == \"{#{xmlns}}feed\"\n if feed_author = find_element(\"{#{xmlns}}author\")\n feed_author.traverse_element(\"{#{xmlns}}name\") {|e|\n begin\n author = e.extract_text.strip\n return author if !author.empty?\n rescue IndexError\n end\n }\n end\n end\n }\n }\n\n nil\n end", "def is_author?( author = '' )\n return false unless @is_author\n\n return true if author.blank?\n\n author_obj = get_queried_object\n\n author = [author].map {|a| a.to_s}\n\n if author.include?(author_obj.id.to_s)\n return true\n elsif author.include?(author_obj.nickname)\n return true\n elsif author.include?(author_obj.user_nicename)\n return true\n end\n false\n end", "def author_exuid\n author && author.to_param\n end", "def author\n name.split(/[\\/-]/).first\n end", "def author\n if @author.nil?\n @author = FeedTools::Author.new\n author_node = FeedTools::XmlHelper.try_xpaths(self.channel_node, [\n \"atom10:author\",\n \"atom03:author\",\n \"atom:author\",\n \"author\",\n \"managingEditor\",\n \"dc:author\",\n \"dc:creator\"\n ])\n unless author_node.nil?\n @author.raw = FeedTools::XmlHelper.try_xpaths(\n author_node, [\"text()\"], :select_result_value => true)\n @author.raw = FeedTools::HtmlHelper.unescape_entities(@author.raw)\n unless @author.raw.nil?\n raw_scan = @author.raw.scan(\n /(.*)\\((\\b[A-Z0-9._%-\\+]+@[A-Z0-9._%-]+\\.[A-Z]{2,4}\\b)\\)/i)\n if raw_scan.nil? || raw_scan.size == 0\n raw_scan = @author.raw.scan(\n /(\\b[A-Z0-9._%-\\+]+@[A-Z0-9._%-]+\\.[A-Z]{2,4}\\b)\\s*\\((.*)\\)/i)\n unless raw_scan.size == 0\n author_raw_pair = raw_scan.first.reverse\n end\n else\n author_raw_pair = raw_scan.first\n end\n if raw_scan.nil? || raw_scan.size == 0\n email_scan = @author.raw.scan(\n /\\b[A-Z0-9._%-\\+]+@[A-Z0-9._%-]+\\.[A-Z]{2,4}\\b/i)\n if email_scan != nil && email_scan.size > 0\n @author.email = email_scan.first.strip\n end\n end\n unless author_raw_pair.nil? || author_raw_pair.size == 0\n @author.name = author_raw_pair.first.strip\n @author.email = author_raw_pair.last.strip\n else\n unless @author.raw.include?(\"@\")\n # We can be reasonably sure we are looking at something\n # that the creator didn't intend to contain an email address\n # if it got through the preceeding regexes and it doesn't\n # contain the tell-tale '@' symbol.\n @author.name = @author.raw\n end\n end\n end\n if @author.name.blank?\n @author.name = FeedTools::HtmlHelper.unescape_entities(\n FeedTools::XmlHelper.try_xpaths(author_node, [\n \"atom10:name/text()\",\n \"atom03:name/text()\",\n \"atom:name/text()\",\n \"name/text()\",\n \"@name\"\n ], :select_result_value => true)\n )\n end\n if @author.email.blank?\n @author.email = FeedTools::HtmlHelper.unescape_entities(\n FeedTools::XmlHelper.try_xpaths(author_node, [\n \"atom10:email/text()\",\n \"atom03:email/text()\",\n \"atom:email/text()\",\n \"email/text()\",\n \"@email\"\n ], :select_result_value => true)\n )\n end\n if @author.url.blank?\n @author.url = FeedTools::HtmlHelper.unescape_entities(\n FeedTools::XmlHelper.try_xpaths(author_node, [\n \"atom10:url/text()\",\n \"atom03:url/text()\",\n \"atom:url/text()\",\n \"url/text()\",\n \"atom10:uri/text()\",\n \"atom03:uri/text()\",\n \"atom:uri/text()\",\n \"uri/text()\",\n \"@href\",\n \"@uri\",\n \"@href\"\n ], :select_result_value => true)\n )\n end\n if @author.name.blank? && !@author.raw.blank? &&\n !@author.email.blank?\n name_scan = @author.raw.scan(\n /\"?([^\"]*)\"? ?[\\(<].*#{@author.email}.*[\\)>].*/)\n if name_scan.flatten.size == 1\n @author.name = name_scan.flatten[0].strip\n end\n if @author.name.blank?\n name_scan = @author.raw.scan(\n /.*#{@author.email} ?[\\(<]\"?([^\"]*)\"?[\\)>].*/)\n if name_scan.flatten.size == 1\n @author.name = name_scan.flatten[0].strip\n end\n end\n end\n @author.name = nil if @author.name.blank?\n @author.raw = nil if @author.raw.blank?\n @author.email = nil if @author.email.blank?\n @author.url = nil if @author.url.blank?\n if @author.url != nil\n begin\n if !(@author.url =~ /^file:/) &&\n !FeedTools::UriHelper.is_uri?(@author.url)\n @author.url = FeedTools::UriHelper.resolve_relative_uri(\n @author.url, [author_node.base_uri, self.base_uri])\n end\n rescue\n end\n end\n if FeedTools::XmlHelper.try_xpaths(author_node,\n [\"@gr:unknown-author\"], :select_result_value => true) == \"true\"\n if @author.name == \"(author unknown)\"\n @author.name = nil\n end\n end\n end\n # Fallback on the itunes module if we didn't find an author name\n begin\n @author.name = self.itunes_author if @author.name.nil?\n rescue\n @author.name = nil\n end\n end\n return @author\n end", "def author\n @author ||= User.find_by_id(author_id) unless author_id.nil?\n end", "def post\n Post.all.select {|post| post.author == self}\n end", "def author\n props[ AUTHOR_PROP_NAME ] if props\n end", "def author_name\n h Settings.author_name\n end", "def author_name(book)\n \"#{book.author.first_name} #{book.author.last_name}\"\n end", "def current_author\n Author.find(current_user.id) unless current_user.nil?\n end", "def author\n author = self[:author] || ''\n\n if author.present?\n @author ||= Infopark::Crm::Contact.search(params: { login: author }).first\n @author ||= Infopark::Crm::Contact.search(params: { email: author }).first\n end\n end", "def author\n if user_id\n @author ||= Author.new(instance, user_id)\n else\n nil\n end\n end", "def author_name=(author_name)\n self.author = Author.find_or_create_by(name: author_name)\n end", "def author_name\n \"#{author.last_name}, #{author.first_name}\"\n end", "def author; User.get(self.author_id); end", "def set_author\n @author = Author.friendly.find(params[:author_name])\n end", "def author\n response = read(\"/user/#{@author}/about.json\", :handler => \"User\") if @author\n @author_data ||= response[0] if response\n end", "def author\n @info[:Author]\n end", "def initialize #initializes post belonging to author \r\n @post = author\r\n end", "def author\n @author ||= Readability::Document.new(@html).author\n end", "def author\n @node.at_xpath(\"author\").try(:content)\n end", "def authors\n author\n end", "def author\n @author ||= User.find_by_id(author_id)\n end", "def author\n user\n end", "def get_author\n \tUser.find(author_id)\n \tend", "def check_author\n return unless self.is_author\n\n self.name = BLARG_CONFIG['admin']['name']\n self.email = BLARG_CONFIG['admin']['email']\n self.url = BLARG_CONFIG['blog']['url']\n self.is_human = BLARG_CONFIG['comments']['is_human_answer']\n end", "def author_display(author)\n if (author.first.present? && author.last.present?)\n \"#{author.last}, #{author.first.slice(0,1)}\"\n elsif author.display.present?\n author.display\n elsif author.last.present?\n author.last\n else\n nil\n end\n end", "def get_author_name(options = {})\n if(self.author_id && (!options || !options[:force_cataloguer]) && (u = User.find(self.author_id)))\n n = u.name\n n += \" (\" + u.email + \")\" if(!options || !options[:omit_email])\n return n\n end\n if (self.user_id)\n u = User.find(self.user_id)\n n = u.name\n n += \" (\" + u.email + \")\" if(!options || !options[:omit_email])\n return n\n end\n \"\"\n end", "def has_author?(author)\n ret = false\n @authors.each{ |auth| ret = true if auth == author }\n ret\n end", "def resolved_author\n return @resolved_author if defined? @resolved_author\n\n sources = [page[\"author\"]]\n sources << page[\"authors\"].first if page[\"authors\"].is_a?(Array)\n sources << site[\"author\"]\n @resolved_author = sources.find { |s| !s.to_s.empty? }\n end", "def resolved_author\n return @resolved_author if defined? @resolved_author\n\n sources = [page[\"author\"]]\n sources << page[\"authors\"].first if page[\"authors\"].is_a?(Array)\n sources << site[\"author\"]\n @resolved_author = sources.find { |s| !s.to_s.empty? }\n end", "def get_author\n @current_author ||= session[:current_user_id] && Author.find(session[:current_user_id])\n end", "def page_author(author)\n content_for_layout :meta_author, author\n end", "def author\n @author_data ||= read(\"/user/#{@author}/about.json\", :handler => \"User\")\n end", "def meta_author\n \"Ahmed Nadar\"\n end", "def author; end", "def author\n page.version.author.name\n end", "def get_author_name_or_blank\n ret = \"\"\n ret += firstname unless firstname.blank?\n ret += \" \" unless firstname.blank? or name.blank?\n ret += name unless name.blank?\n ret\n end", "def author_id\n get_info[:authorID]\n end", "def get_poster_name post, sentFlg\n pname = set_poster(post, sentFlg).name rescue nil\n pname == @user.name ? 'Me' : pname\n end", "def author\n @author ||= AuthorDrop.new(:page => page, :site => site)\n end", "def author \n user.firstname + ' ' + user.lastname\n end", "def author=(author)\n\t \t@author = author #tells post its author name\n\t \tif !@author.posts.include?(self)\n\t \t\t@author.posts << self # add post to author collection if not already\n\t \tend\n\t end", "def is_author_of?(name)\n self.is_author? and !self.programs.find_by_name(name).nil?\n end", "def author\n \"#{user.name} (#{user.login})\"\n end", "def add_post(post)\n post.author = self \n end", "def construct_author_list(post, is_apa = false)\n author_names = []\n author_list = ''\n\n for author in post.authors\n author_names.push(author.name)\n end\n\n if is_apa\n author_names.sort!\n\n author_names.each_with_index do |name, index|\n author_names[index] = last_name_first_name(name)\n end\n else\n #reverse the first name only\n author_names[0] = last_name_first_name(author_names[0])\n end\n\n number_of_authors = author_names.length\n\n author_list = place_author_in_list(author_names)\n\n return author_list\n end", "def testimonial_author\n read_attribute(:testimonial_author) || name\n end", "def author_name_and_email\n if author\n \"#{author.name} (#{author.email})\"\n elsif !email.blank?\n \"Unlogged user (#{email})\"\n else\n \"Anonymous user\"\n end\n end", "def author\n User.find_by_id(self.author_id)\n end", "def add_post(post)\n post.author = self\n end", "def add_post(post)\n post.author = self\n end" ]
[ "0.8126534", "0.8126239", "0.8073739", "0.8004891", "0.7914814", "0.7884917", "0.7585794", "0.74104595", "0.73815733", "0.7375413", "0.73479724", "0.73479724", "0.7320386", "0.7221285", "0.7148087", "0.7141909", "0.71012664", "0.70949674", "0.70919853", "0.708323", "0.70443267", "0.70262945", "0.7005161", "0.7005122", "0.6994306", "0.69772947", "0.6965388", "0.69644403", "0.6959795", "0.6955925", "0.6946225", "0.68905544", "0.68905544", "0.6890505", "0.68769014", "0.68769014", "0.6863379", "0.6862544", "0.6849837", "0.68450844", "0.68419087", "0.68384075", "0.6825313", "0.67824805", "0.6743728", "0.67274964", "0.67256975", "0.67197263", "0.67196596", "0.6692921", "0.6691833", "0.668007", "0.66594446", "0.6652", "0.6648217", "0.6642828", "0.6631113", "0.66304696", "0.66165435", "0.6614995", "0.65888554", "0.6563072", "0.65482914", "0.6515908", "0.6514091", "0.6502809", "0.6495556", "0.6488946", "0.648389", "0.6474632", "0.6467489", "0.6466248", "0.64642715", "0.6458056", "0.6434258", "0.6415732", "0.64115024", "0.6404866", "0.6404866", "0.6399822", "0.639091", "0.63855356", "0.6383775", "0.6383511", "0.63807863", "0.6379409", "0.63776433", "0.6372936", "0.6370108", "0.6363417", "0.6362131", "0.6359266", "0.63549876", "0.6353884", "0.6341961", "0.6321744", "0.63215005", "0.6320825", "0.6320195", "0.6320195" ]
0.81866527
0
Reverse Geocoding Reverse geocoding is the process of converting a coordinate or location (latitude, longitude) to a readable address or place name. This permits the identification of nearby street addresses, places, and/or area subdivisions such as a neighborhood, county, state, or country.
def reverse(lat, lon, format, normalizecity, opts = {}) data, _status_code, _headers = reverse_with_http_info(lat, lon, format, normalizecity, opts) data end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reverse_geocode\n do_lookup(true) do |o,rs|\n if r = rs.first\n unless r.address.nil?\n o.__send__ \"#{self.class.geocoder_options[:fetched_address]}=\", r.address\n end\n r.address\n end\n end\n end", "def reverse_geocode\n result = Geokit::Geocoders::MultiGeocoder.reverse_geocode([latitude, longitude])\n if result.success\n self.address = result.full_address\n else\n self.address = \"#{latitude}, #{longitude}\"\n end\n end", "def reverse_geocode\n uri = URI::HTTP.build(:scheme => 'http',\n :host => 'maps.googleapis.com',\n :path => '/maps/api/geocode/json',\n :query => URI.encode_www_form(:latlng => \"#{self.lat},#{self.lng}\",\n :sensor => true))\n\n response = Net::HTTP.get_response(uri)\n\n if response.is_a?(Net::HTTPSuccess)\n json = JSON.parse(response.body)\n Rails.logger.error json\n begin\n self.address = json[\"results\"].first[\"formatted_address\"]\n self.zipcode = json[\"results\"].first[\"address_components\"].last[\"short_name\"]\n rescue Exception => e\n Rails.logger.error e\n end\n end\n self\n end", "def reverse_geocode_trip\n self.departure_location_address ||= Geocoder.search([departure_location_latitude, departure_location_longitude]).first.address\n self.arrival_location_address ||= Geocoder.search([arrival_location_latitude, arrival_location_longitude]).first.address\n end", "def reverse_geocoded_by(coordinates_attr, options = {}, &block)\n geocoder_init(\n :reverse_geocode => true,\n :fetched_address => options[:address] || :address,\n :coordinates => coordinates_attr,\n :reverse_block => block\n )\n end", "def reverse(latitude:, longitude:, raw: false)\n result = Geocoder.search([latitude, longitude])\n raw ? result&.data : format_result(result)\n end", "def geocode\n do_lookup(false) do |o,rs|\n if r = rs.first\n unless r.coordinates.nil?\n o.__send__ \"#{self.class.geocoder_options[:coordinates]}=\", r.coordinates.reverse\n end\n r.coordinates\n end\n end\n end", "def reverse_geocode(coordinates, options = {})\n if coordinates.size < 1\n raise ArgumentError, 'You must provide coordinates to reverse geocode.'\n elsif coordinates.size == 1\n reverse_geocode_single(coordinates.first, options)\n else\n reverse_geocode_batch(coordinates, options)\n end\n end", "def geocode_reverse(latitude,\r\n longitude,\r\n language_code = 'en',\r\n zoom = 'address')\r\n # Prepare query url.\r\n _path_url = '/geocode-reverse'\r\n _query_builder = Configuration.get_base_uri\r\n _query_builder << _path_url\r\n _query_url = APIHelper.clean_url _query_builder\r\n # Prepare headers.\r\n _headers = {\r\n 'accept' => 'application/json'\r\n }\r\n\r\n # Prepare form parameters.\r\n _parameters = {\r\n 'output-case' => 'camel',\r\n 'latitude' => latitude,\r\n 'longitude' => longitude,\r\n 'language-code' => language_code,\r\n 'zoom' => zoom\r\n }\r\n _parameters = APIHelper.form_encode_parameters(_parameters)\r\n # Prepare and execute HttpRequest.\r\n _request = @http_client.post(\r\n _query_url,\r\n headers: _headers,\r\n parameters: _parameters\r\n )\r\n CustomQueryAuth.apply(_request)\r\n _context = execute_request(_request)\r\n validate_response(_context)\r\n # Return appropriate response type.\r\n decoded = APIHelper.json_deserialize(_context.response.raw_body)\r\n GeocodeReverseResponse.from_hash(decoded)\r\n end", "def reverse_geocode(options = { :using => Geokit::Geocoders::MultiGeocoder })\n if options[:using].is_a?(String) || options[:using].is_a?(Symbol)\n provider = Geokit::Geocoders.const_get(\"#{Geokit::Inflector::camelize(options[:using].to_s)}Geocoder\")\n elsif options[:using].respond_to?(:do_reverse_geocode)\n provider = options[:using]\n else\n raise ArgumentError.new(\"#{options[:using]} is not a valid geocoder.\")\n end\n\n provider.send(:reverse_geocode, self)\n end", "def reverse_geocode\n fail\n end", "def reverse_geocode(ll, options={}, async = true)\n request(\"/Locations/#{ll}\", {:query => {:key => @key}}, async)\n end", "def geocode\n self.coordinates = RepairingGeocoder.calc_coordinates(obj_address, address_to)\n end", "def address\n # match Geocoder::Result::Google#formatted_address\n \"#{street}, #{city}, #{state} #{zip}, #{country}\"\n end", "def geocode_address\n full_address or address\n end", "def geocodeAddress address\n \t logger.debug address\n \t result = HTTParty.get(\"http://maps.googleapis.com/maps/api/geocode/json\",\n \t :query => {\n \t :address => address,\n \t :sensor => false \n \t })\n \t \n \t logger.debug \"address geocoded ***********\"\n \t logger.debug result\n \t logger.debug result.parsed_response[\"results\"][0][\"geometry\"][\"location\"]\n \t \n \t return result.parsed_response[\"results\"][0][\"geometry\"][\"location\"]\n \tend", "def regeocode\n self.geocode_address if self.address_changed? || self.city_changed? || self.state_changed?\n end", "def fetch_raw_response(query, reverse = false)\n return nil if query.blank?\n\n # name parameter based on forward/reverse geocoding\n param = reverse ? :latlng : :address\n\n # build URL\n params = { param => query, :sensor => \"false\" }\n url = \"http://maps.google.com/maps/api/geocode/json?\" + params.to_query\n\n # query geocoder and make sure it responds quickly\n begin\n resp = nil\n timeout(3) do\n Net::HTTP.get_response(URI.parse(url)).body\n end\n rescue SocketError, TimeoutError\n return nil\n end\n end", "def reverse_with_http_info(lat, lon, format, normalizecity, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ReverseApi.reverse ...'\n end\n # verify the required parameter 'lat' is set\n if @api_client.config.client_side_validation && lat.nil?\n fail ArgumentError, \"Missing the required parameter 'lat' when calling ReverseApi.reverse\"\n end\n if @api_client.config.client_side_validation && lat > 90\n fail ArgumentError, 'invalid value for \"lat\" when calling ReverseApi.reverse, must be smaller than or equal to 90.'\n end\n\n if @api_client.config.client_side_validation && lat < -90\n fail ArgumentError, 'invalid value for \"lat\" when calling ReverseApi.reverse, must be greater than or equal to -90.'\n end\n\n # verify the required parameter 'lon' is set\n if @api_client.config.client_side_validation && lon.nil?\n fail ArgumentError, \"Missing the required parameter 'lon' when calling ReverseApi.reverse\"\n end\n if @api_client.config.client_side_validation && lon > 180\n fail ArgumentError, 'invalid value for \"lon\" when calling ReverseApi.reverse, must be smaller than or equal to 180.'\n end\n\n if @api_client.config.client_side_validation && lon < -180\n fail ArgumentError, 'invalid value for \"lon\" when calling ReverseApi.reverse, must be greater than or equal to -180.'\n end\n\n # verify the required parameter 'format' is set\n if @api_client.config.client_side_validation && format.nil?\n fail ArgumentError, \"Missing the required parameter 'format' when calling ReverseApi.reverse\"\n end\n # verify enum value\n allowable_values = [\"json\"]\n if @api_client.config.client_side_validation && !allowable_values.include?(format)\n fail ArgumentError, \"invalid value for \\\"format\\\", must be one of #{allowable_values}\"\n end\n # verify the required parameter 'normalizecity' is set\n if @api_client.config.client_side_validation && normalizecity.nil?\n fail ArgumentError, \"Missing the required parameter 'normalizecity' when calling ReverseApi.reverse\"\n end\n # verify enum value\n allowable_values = [1]\n if @api_client.config.client_side_validation && !allowable_values.include?(normalizecity)\n fail ArgumentError, \"invalid value for \\\"normalizecity\\\", must be one of #{allowable_values}\"\n end\n allowable_values = [0, 1]\n if @api_client.config.client_side_validation && opts[:'addressdetails'] && !allowable_values.include?(opts[:'addressdetails'])\n fail ArgumentError, \"invalid value for \\\"addressdetails\\\", must be one of #{allowable_values}\"\n end\n allowable_values = [0, 1]\n if @api_client.config.client_side_validation && opts[:'namedetails'] && !allowable_values.include?(opts[:'namedetails'])\n fail ArgumentError, \"invalid value for \\\"namedetails\\\", must be one of #{allowable_values}\"\n end\n allowable_values = [0, 1]\n if @api_client.config.client_side_validation && opts[:'extratags'] && !allowable_values.include?(opts[:'extratags'])\n fail ArgumentError, \"invalid value for \\\"extratags\\\", must be one of #{allowable_values}\"\n end\n allowable_values = [0, 1]\n if @api_client.config.client_side_validation && opts[:'statecode'] && !allowable_values.include?(opts[:'statecode'])\n fail ArgumentError, \"invalid value for \\\"statecode\\\", must be one of #{allowable_values}\"\n end\n # resource path\n local_var_path = '/reverse.php'\n\n # query parameters\n query_params = opts[:query_params] || {}\n query_params[:'lat'] = lat\n query_params[:'lon'] = lon\n query_params[:'format'] = format\n query_params[:'normalizecity'] = normalizecity\n query_params[:'addressdetails'] = opts[:'addressdetails'] if !opts[:'addressdetails'].nil?\n query_params[:'accept-language'] = opts[:'accept_language'] if !opts[:'accept_language'].nil?\n query_params[:'namedetails'] = opts[:'namedetails'] if !opts[:'namedetails'].nil?\n query_params[:'extratags'] = opts[:'extratags'] if !opts[:'extratags'].nil?\n query_params[:'statecode'] = opts[:'statecode'] if !opts[:'statecode'].nil?\n query_params[:'showdistance'] = opts[:'showdistance'] if !opts[:'showdistance'].nil?\n query_params[:'postaladdress'] = opts[:'postaladdress'] if !opts[:'postaladdress'].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(['application/json'])\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] || 'Location' \n\n # auth_names\n auth_names = opts[:auth_names] || ['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: ReverseApi#reverse\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def geocode\n # address must note be blank start with a number\n return if address.index(/[1-9]/).nil?\n return if full_address.blank?\n return if not lat.nil? and not lng.nil?\n url = \"http://geocoder.ca/?locate=#{CGI.escape self.full_address}&geoit=xml&jsonp=1&auth=#{GEOCODER_CA_KEY}&callback=?\"\n # get the response and cut off the jsonp\n response = Curl.get(url).body_str.from(2).to(-3)\n json = JSON.parse response\n self.lng = json[\"longt\"]\n self.lat = json[\"latt\"]\n end", "def address_full\n \"#{self.address.titleize}, Toronto, ON\"\n end", "def do_lookup(reverse = false)\n options = self.class.geocoder_options\n if reverse and options[:reverse_geocode]\n query = to_coordinates\n elsif !reverse and options[:geocode]\n query = send(options[:user_address])\n else\n return\n end\n\n query_options = [:lookup, :ip_lookup, :language, :params].inject({}) do |hash, key|\n if options.has_key?(key)\n val = options[key]\n hash[key] = val.respond_to?(:call) ? val.call(self) : val\n end\n hash\n end\n results = Geocoder.search(query, query_options)\n\n # execute custom block, if specified in configuration\n block_key = reverse ? :reverse_block : :geocode_block\n if custom_block = options[block_key]\n custom_block.call(self, results)\n\n # else execute block passed directly to this method,\n # which generally performs the \"auto-assigns\"\n elsif block_given?\n yield(self, results)\n end\n end", "def reverse_with_http_info(lat, lon, format, normalizecity, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ReverseApi.reverse ...'\n end\n # verify the required parameter 'lat' is set\n if @api_client.config.client_side_validation && lat.nil?\n fail ArgumentError, \"Missing the required parameter 'lat' when calling ReverseApi.reverse\"\n end\n if @api_client.config.client_side_validation && lat > 90\n fail ArgumentError, 'invalid value for \"lat\" when calling ReverseApi.reverse, must be smaller than or equal to 90.'\n end\n\n if @api_client.config.client_side_validation && lat < -90\n fail ArgumentError, 'invalid value for \"lat\" when calling ReverseApi.reverse, must be greater than or equal to -90.'\n end\n\n # verify the required parameter 'lon' is set\n if @api_client.config.client_side_validation && lon.nil?\n fail ArgumentError, \"Missing the required parameter 'lon' when calling ReverseApi.reverse\"\n end\n if @api_client.config.client_side_validation && lon > 180\n fail ArgumentError, 'invalid value for \"lon\" when calling ReverseApi.reverse, must be smaller than or equal to 180.'\n end\n\n if @api_client.config.client_side_validation && lon < -180\n fail ArgumentError, 'invalid value for \"lon\" when calling ReverseApi.reverse, must be greater than or equal to -180.'\n end\n\n # verify the required parameter 'format' is set\n if @api_client.config.client_side_validation && format.nil?\n fail ArgumentError, \"Missing the required parameter 'format' when calling ReverseApi.reverse\"\n end\n # verify enum value\n if @api_client.config.client_side_validation && !['json'].include?(format)\n fail ArgumentError, \"invalid value for 'format', must be one of json\"\n end\n # verify the required parameter 'normalizecity' is set\n if @api_client.config.client_side_validation && normalizecity.nil?\n fail ArgumentError, \"Missing the required parameter 'normalizecity' when calling ReverseApi.reverse\"\n end\n # verify enum value\n if @api_client.config.client_side_validation && !['1'].include?(normalizecity)\n fail ArgumentError, \"invalid value for 'normalizecity', must be one of 1\"\n end\n if @api_client.config.client_side_validation && opts[:'addressdetails'] && !['0', '1'].include?(opts[:'addressdetails'])\n fail ArgumentError, 'invalid value for \"addressdetails\", must be one of 0, 1'\n end\n if @api_client.config.client_side_validation && opts[:'namedetails'] && !['0', '1'].include?(opts[:'namedetails'])\n fail ArgumentError, 'invalid value for \"namedetails\", must be one of 0, 1'\n end\n if @api_client.config.client_side_validation && opts[:'extratags'] && !['0', '1'].include?(opts[:'extratags'])\n fail ArgumentError, 'invalid value for \"extratags\", must be one of 0, 1'\n end\n # resource path\n local_var_path = '/reverse.php'\n\n # query parameters\n query_params = {}\n query_params[:'lat'] = lat\n query_params[:'lon'] = lon\n query_params[:'format'] = format\n query_params[:'normalizecity'] = normalizecity\n query_params[:'addressdetails'] = opts[:'addressdetails'] if !opts[:'addressdetails'].nil?\n query_params[:'accept-language'] = opts[:'accept_language'] if !opts[:'accept_language'].nil?\n query_params[:'namedetails'] = opts[:'namedetails'] if !opts[:'namedetails'].nil?\n query_params[:'extratags'] = opts[:'extratags'] if !opts[:'extratags'].nil?\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['key']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'Location')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ReverseApi#reverse\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def results\n @results ||= perform_reverse_geocode\n end", "def location_to_geocode(location)\n case location\n when Geocode then location\n when InstanceMethods then location.geocode\n when String, Fixnum then Geocode.find_or_create_by_query(location)\n end\n end", "def build_url(wonder)\n google_api_key = \"AIzaSyBP30mYnbwKpZ0lCHtp6FuvcNSjNG0GsGM\"\n geocode_url = \"https://maps.googleapis.com/maps/api/geocode/json?address=#{wonder}&key=#{google_api_key}\"\n encoded_url = URI.encode(geocode_url)\n return encoded_url\nend", "def geolocate\n \"#{self.address}\"', '\"#{self.state}\"', '\"#{self.zipcode}\"\n end", "def full_address\n \"#{street_address}, #{city}, #{ISO3166::Country.new(country_code.upcase).name}\"\n end", "def where_geocoder(query, near = nil)\n url = URI.parse GOOGLE_GEOCODER_URI\n near_query = nil\n if near && near.kind_of?(Hash)\n #near_query = \"ll=#{near[:latitude]},#{near[:longitude]}&spn=#{near[:span_latitude]},#{near[:span_longitude]}&gl=#{near[:country]}\" \n #near_query = \"ll=#{near[:latitude]},#{near[:longitude]}&spn=#{near[:span_latitude]},#{near[:span_longitude]}\" \n #near_query = \"gl=UK\"\n end\n \n response = Net::HTTP.start(url.host, url.port) do |http|\n http.get(\"#{GEOCODER_QUERY_STRING}#{CGI.escape(query)}&#{near_query}\")\n end\n\n results = JSON.parse(response.body)['Placemark']\n \n unless results.nil? || results.empty?\n results.map do |result|\n if result['AddressDetails'] && result['AddressDetails']['Accuracy'].to_i >= 0\n p = { :name => result['address'] }\n\n p[:address] = result['AddressDetails']['Country']['AdministrativeArea']['Locality']['Thoroughfare']['ThoroughfareName'] rescue nil\n p[:city] = result['AddressDetails']['Country']['AdministrativeArea']['Locality']['LocalityName'] rescue nil\n p[:region] = result['AddressDetails']['Country']['AdministrativeArea']['AdministrativeAreaName'] rescue nil\n p[:country] = result['AddressDetails']['Country']['CountryNameCode'] rescue nil\n p[:postal_code] = result['AddressDetails']['Country']['AdministrativeArea']['Locality']['PostalCode'] rescue nil\n p[:latitude] = result['Point']['coordinates'][1].to_f rescue nil\n p[:longitude] = result['Point']['coordinates'][0].to_f rescue nil\n p[:accuracy] = result['AddressDetails']['Accuracy'].to_i rescue nil\n p[:zoom] = ZOOM_FROM_ACCURACY[result['AddressDetails']['Accuracy'].to_i] #rescue 0\n\n p\n else\n nil\n end\n end\n else\n []\n end\n end", "def geocode_address\n geo = Geokit::Geocoders::MultiGeocoder.geocode(self.address_string)\n if geo.success\n self.lat, self.lng = geo.lat, geo.lng\n else\n puts geo.class\n errors.add(:address, \"Could not Geocode address\")\n end\n end", "def reverse(location, options = {})\n raise ArgumentError, 'Method must receive a location (array)' unless location && location.kind_of?(Array)\n options[:location] = location.join(',')\n call_api self, 1, 'reverse', options\n end", "def create_address(city, state, zip)\n call_address = Addressable::URI.new(\n :scheme => \"http\",\n :host => \"www.whitepages.com\",\n :path => \"search/FindNearby\",\n :query_values => {\n :utf8 => \"&#10003;\",\n :street => \"#{city}, #{state}\",\n :where => \"#{zip}\"\n }\n ).to_s\n end", "def full_street_address\n postcode_only_address\n end", "def reverse_ip(ipaddress)\n reverse_ip = IPAddr.new ipaddress\n reverse_ip.reverse\nend", "def geocode(address)\n result = Geocoder.search(address).first\n #result.latitude - float\n #result.longitude - float\n #result.coordinates - array of the above two\n #result.address - string\n #result.city - string\n #result.state - string\n #result.state_code - string\n #result.postal_code - string\n #result.country - string\n #result.country_code - string\n if result\n self.lat = result.latitude\n self.lng = result.longitude\n return true\n else\n return nil\n end\n end", "def geocode(s)\n @geocoder.run(s)\n end", "def postal_code_to_coordinate(postal_code, options = {})\n Services::PostalCodeToCoordinate.new(options).resolve(postal_code)\n end", "def full_street_address #Take all location fields, remove nil elements with .compact, then return a string for Geocoder\n [address_1, address_2, city, country, z_post_code].compact.join(', ')\n end", "def find_city(lat,lng)\n if Geocoder::Calculations.distance_between([lat,lng], [40.698390,-73.98843]) < 20\n \"newyork\"\n elsif\n Geocoder::Calculations.distance_between([lat,lng], [40.76813,-73.96439]) < 20\n \"newyork\"\n elsif\n Geocoder::Calculations.distance_between([lat,lng], [37.76423,-122.47743]) < 20\n \"sanfrancisco\"\n elsif\n Geocoder::Calculations.distance_between([lat,lng], [37.76912,-122.42593]) < 20\n \"sanfrancisco\"\n elsif\n Geocoder::Calculations.distance_between([lat,lng], [48.85887,2.30965]) < 20\n \"paris\"\n elsif\n Geocoder::Calculations.distance_between([lat,lng], [48.86068,2.36389]) < 20\n \"paris\"\n elsif\n Geocoder::Calculations.distance_between([lat,lng], [51.51,-0.13]) < 20\n \"london\"\n elsif\n Geocoder::Calculations.distance_between([lat,lng], [-23.57664,-46.69787]) < 20\n \"saopaulo\"\n elsif\n Geocoder::Calculations.distance_between([lat,lng], [-23.55838,-46.64362]) < 20\n \"saopaulo\"\n elsif\n Geocoder::Calculations.distance_between([lat,lng], [35.64446,139.70695]) < 20\n \"tokyo\"\n elsif\n Geocoder::Calculations.distance_between([lat,lng], [35.70136,139.73991]) < 20\n \"tokyo\"\n elsif\n Geocoder::Calculations.distance_between([lat,lng], [34.06901,-118.35904]) < 20\n \"losangeles\"\n elsif\n Geocoder::Calculations.distance_between([lat,lng], [34.07499,-118.28763]) < 20\n \"losangeles\"\n elsif\n Geocoder::Calculations.distance_between([lat,lng], [34.02663,-118.45998]) < 20\n \"losangeles\"\n elsif\n Geocoder::Calculations.distance_between([lat,lng], [50.07832,14.41619]) < 20\n \"prague\"\n else\n \"unknown\"\n end\n end", "def full_address\n \"#{region}, #{district}, #{street_type} #{street_name}, д. #{house_number} кв. #{apartment}\"\n end", "def generate_address\n name = self.name\n unless self.address\n key = ENV['GMAPS_KEY']\n search = name.gsub(\" \",\"+\")\n map_results = JSON.parse(open(\n \"https://maps.googleapis.com/maps/api/place/textsearch/json?location=41.310362,-72.928914&radius=500&key=#{key}&query=#{search}&sensor=true\").read)\n loc = map_results['results'].first\n if loc\n address = loc[\"formatted_address\"]\n lat = loc[\"geometry\"][\"location\"][\"lat\"]\n lng = loc[\"geometry\"][\"location\"][\"lng\"]\n else\n address = \"38 Hillhouse Avenue, New Haven, CT 06511\"\n lat = \"41.310362\"\n lng = \"-72.928914\"\n end\n self.attributes = {:address => address, :latitude => lat, :longitude => lng}\n end\n end", "def full_address(include_country = false, include_secondary = false)\n address = \"#{street_address(include_secondary)} #{postal_code} #{city}\"\n address = \"#{address} POLOGNE\" if include_country\n address\n end", "def residential_address\n return unless @user.loa3?\n\n dig_out('addresses', 'address_pou', VAProfile::Models::Address::RESIDENCE)\n end", "def lat_lng\n lng_lat.reverse\n end", "def geocode(address)\n q = { address: URI::encode(address) }\n q[:key] = @config[:api_key] if @config.has_key?(:api_key)\n\n res = get('/json', q)\n JSON::parse(res.body)\n end", "def geocode\n uri = URI::HTTP.build(:scheme => 'http',\n :host => 'maps.googleapis.com',\n :path => '/maps/api/geocode/json',\n :query => URI.encode_www_form(:address => \"#{self.address}\",\n :sensor => false))\n\n response = Net::HTTP.get_response(uri)\n if response.is_a?(Net::HTTPSuccess)\n json = JSON.parse(response.body)\n Rails.logger.error json\n location = json[\"results\"].first[\"geometry\"][\"location\"]\n self.lat = location[\"lat\"]\n self.lng = location[\"lng\"]\n end\n self\n end", "def decode_address address\n call_blockchain_api(\"decode_address/#{address}\")\n end", "def geocode_address\n self.latlon = Geocoder.new(request.ip)\n puts \" ** self.latlon: #{self.latlon.inspect}\"\n end", "def geocode\n name = params[:name].to_s\n if params[:format]\n name = Location.reverse_name(name) if params[:format] == \"scientific\"\n elsif @user = get_session_user!\n name = Location.reverse_name(name) if @user.location_format == :scientific\n end\n render(inline: Geocoder.new(name).ajax_response)\n end", "def address\n @address ||= best_guess_address(name)\n end", "def find_neighborhood\n results = Geocoder.search(\"#{coordinates[1]},#{coordinates[0]}\")\n unless results.blank?\n n = 0\n m = 0\n has_neighborhood = false\n (0..(results.count-1)).each do |i|\n if results[i].types.include?(\"neighborhood\")\n has_neighborhood = true\n n = i\n break\n end\n end\n if has_neighborhood\n (0..(results[n].address_components.count-1)).each do |i|\n if results[n].address_components[i][\"types\"].include?(\"neighborhood\")\n m = i\n break\n end\n end\n results[n].address_components[m][\"long_name\"]\n else\n return nil\n end\n else\n return nil\n end\n \n end", "def geocoding\n @geocoding ||= Geocoding::Gateway.new(client)\n end", "def full_street_address\n location + \"New York City, NY, USA\"\n end", "def gmaps4rails_address\n \"#{address}, #{city_state_zip}\"\n end", "def full_address\n \"#{address}, #{city}, #{state}, #{zip}\"\n end", "def optimistic_geo_wrapper(query)\n geocoded = nil\n result = ::Geocoder.search(query)\n puts result.inspect\n geocoded = result[0].data if result[0]\n geocoded\n end", "def to_coordinates\n coords = send(self.class.geocoder_options[:coordinates])\n coords.is_a?(Array) ? coords.reverse : []\n end", "def gmaps4rails_address\n \"#{address1}, #{address2}, #{city}, #{state}, #{zipcode}\"\n end", "def query_address2latlng(query_address)\n\t\tla_clave_esa = \"AIzaSyBtlkF4i2Mmv33\" + \"uVc4aVTA5JT94-eEnRTo\"\n\t\tgeocode_url = \"https://maps.googleapis.com/maps/api/geocode/json?address=\"+query_address+\"&key=\" + la_clave_esa\n\t\tgeocode_uri = URI.parse(geocode_url)\n\t\tgeocode_response = Net::HTTP.get_response(geocode_uri)\n\t\tgeocode_hash = JSON.parse geocode_response.body\n\t\t#pp geocode_hash\n\t\tlat = geocode_hash[\"results\"][0][\"geometry\"][\"location\"][\"lat\"]\n\t\tlng = geocode_hash[\"results\"][0][\"geometry\"][\"location\"][\"lng\"]\n\t\treturn lat.to_s + \",\" + lng.to_s\n\tend", "def gmaps4rails_address\n addr = if state and state.name.present?\n \"#{address_1}, #{city}, #{state.name} #{zip_code}\"\n elsif (address_1)\n \"#{address_1}, #{raw_seed}\"\n else\n \"1856 Stevenson Ave, Clearwater, Florida 33755\"\n end\n puts \"gmap input:#{addr}\"\n addr\n end", "def address(latitude, longitude)\n return nil if latitude.blank? || longitude.blank?\n return nil unless doc = search(\"#{latitude},#{longitude}\", true)\n # blindly use first result (assume it is most accurate)\n doc['results'].first['formatted_address']\n end", "def coordinates(user_address)\n geocoding_url = Addressable::URI.new(\n :scheme => \"https\",\n :host => \"maps.googleapis.com\",\n :path => \"maps/api/geocode/json\",\n :query_values => {:address => user_address,\n :sensor => false}\n ).to_s\n\n response = JSON.parse(RestClient.get(geocoding_url))\n location = response[\"results\"][0][\"geometry\"][\"location\"]\n location_string = \"#{location[\"lat\"]},#{location[\"lng\"]}\"\nend", "def geoAddress\n\n self.address + \",\" +self.region.name\n\n end", "def gmaps4rails_address\n \t\"#{address}, #{city}, #{state}\"\n end", "def geocode!\n result = GeoKit::Geocoders::YahooGeocoder.geocode \"#{@street}, #{@city}, #{@state} #{@zip}\"\n if result.success?\n @street = result.street_address\n @city = result.city\n @state = result.state\n @zip = result.zip\n @country = result.country_code\n @lat = result.lat\n @lng = result.lng\n @status = STATUS_GEOCODED\n else\n @status = STATUS_GEOCODE_ERROR\n end\n end", "def location\n c = Country.find_country_by_alpha2(country)\n country_name = !c.nil? ? c.name : nil\n if (postcode and country)\n return postcode + \", \" + (country_name or country)\n else\n return (postcode or country_name or country)\n end\n end", "def full_address\n \"#{address}, #{suburb}, #{state}, #{postcode}\"\n end", "def geocode(lat, lon, options = {})\n new(options.merge(lat: lat, lon: lon)).retrieve\n end", "def address\n '310 S Harrington'\n end", "def location_code\n # find the closest location\n location = area || city || province\n location.post_code\n end", "def new_input_set()\n return ReverseGeocodeInputSet.new()\n end", "def geocode\n fail\n end", "def geocode_address(address,\r\n country_code = nil,\r\n language_code = 'en',\r\n fuzzy_search = false)\r\n # Prepare query url.\r\n _path_url = '/geocode-address'\r\n _query_builder = Configuration.get_base_uri\r\n _query_builder << _path_url\r\n _query_url = APIHelper.clean_url _query_builder\r\n # Prepare headers.\r\n _headers = {\r\n 'accept' => 'application/json'\r\n }\r\n\r\n # Prepare form parameters.\r\n _parameters = {\r\n 'output-case' => 'camel',\r\n 'address' => address,\r\n 'country-code' => country_code,\r\n 'language-code' => language_code,\r\n 'fuzzy-search' => fuzzy_search\r\n }\r\n _parameters = APIHelper.form_encode_parameters(_parameters)\r\n # Prepare and execute HttpRequest.\r\n _request = @http_client.post(\r\n _query_url,\r\n headers: _headers,\r\n parameters: _parameters\r\n )\r\n CustomQueryAuth.apply(_request)\r\n _context = execute_request(_request)\r\n validate_response(_context)\r\n # Return appropriate response type.\r\n decoded = APIHelper.json_deserialize(_context.response.raw_body)\r\n GeocodeAddressResponse.from_hash(decoded)\r\n end", "def address_string\n \"#{address}, #{city}, #{state} #{zip}\"\n end", "def geo_code(params)\n if params\n geo_data = Geocoder.search(params[\"address\"]).first\n params[\"address\"] = geo_data.formatted_address\n params[\"lng\"] = geo_data.longitude\n params[\"lat\"] = geo_data.latitude\n params\n end\n end", "def fetch_address_and_geometry(save = false)\n coords = Geocoder.fetch_coordinates(\n send(self.class.geocoder_options[:method_name])\n )\n unless coords.blank?\n method = (save ? \"update\" : \"write\") + \"_attribute\"\n send method, self.class.geocoder_options[:formatted_address], coords[0]\n send method, self.class.geocoder_options[:geometry], coords[1]\n end\n coords\n end", "def address\n \"#{self.building} #{return_data_format(self.street)} #{self.zipcode}\"\n end", "def geocode_endpoints\n if start_address_changed?\n geocoded = Geocoder.search(start_address).first\n if geocoded\n self.start_latitude = geocoded.latitude\n self.start_longitude = geocoded.longitude\n end\n end\n # Repeat for destination\n if end_address_changed?\n geocoded = Geocoder.search(end_address).first\n if geocoded\n self.end_latitude = geocoded.latitude\n self.end_longitude = geocoded.longitude\n end\n end\n end", "def from_place_details details\n\n components = details[:address_components]\n unless components.nil?\n components.each do |component|\n types = component[:types]\n if types.nil?\n next\n end\n if 'street_address'.in? types\n self.address1 = component[:long_name]\n elsif 'route'.in? types\n self.route = component[:long_name]\n elsif 'street_number'.in? types\n self.street_number = component[:long_name]\n elsif 'administrative_area_level_1'.in? types\n self.state = component[:long_name]\n elsif 'locality'.in? types\n self.city = component[:long_name]\n elsif 'postal_code'.in? types\n self.zip = component[:long_name]\n end\n end\n end\n\n self.raw_address = details[:formatted_address]\n self.lat = details[:geometry][:location][:lat]\n self.lon = details[:geometry][:location][:lng]\n self.name = details[:name]\n self.google_place_id = details[:place_id]\n self.stop_code = details[:stop_code]\n self.types = details[:types]\n self.address_components_raw = details\n\n if self.raw_address.nil?\n self.raw_address = self.name\n end\n\n end", "def full_address\n \"#{address1} #{address2} #{city},#{state} #{postal_code} #{country}\"\n end", "def full_address\n\t\t\"#{street}, #{postal_code}, #{city}, #{country}\"\n\tend", "def address\n\t\tGeocoder.address([self.latitude, self.longitude])\n\tend", "def locate(address)\n get :geo, :q => address\n end", "def geocode\n geo = Geokit::Geocoders::MultiGeocoder.geocode address.gsub(/\\n/, ', ')\n if geo.success\n self.lat, self.lng = geo.lat, geo.lng\n else\n errors.add(:address, 'Problem locating address')\n end\n end", "def geocode_best_possible\n\n return unless addressable_type == 'Company'\n\n # don't Geocode if we're doing development or testing AND\n # we already have lat and long and nothing has changed\n return if dev_or_test_and_have_geo_unchanged?\n\n specificity_order = address_array\n\n most_specific = 0\n least_specific = specificity_order.size - 1\n\n geo_result = nil\n\n until most_specific > least_specific || geo_result.present?\n geocode_address = specificity_order[most_specific..least_specific].compact.join(', ')\n geo_result = Geocoder.search(geocode_address)\n most_specific += 1\n end\n\n unless geo_result.nil?\n self.latitude = geo_result[0].latitude\n self.longitude = geo_result[0].longitude\n end\n\n end", "def get_address\n welcome_message\n puts \"What is your location?\"\n user_location = Geocoder.search(gets.chomp)[0]\n if user_location != nil\n adr = user_location\n @city = adr.city\n @lat = adr.latitude\n @lon = adr.longitude\n else\n no_match\n end\n end", "def full_address\n [landmark_name, city, country].compact.join(', ')\n end", "def geocode(address)\n response = HTTParty.get(\"https://maps.googleapis.com/maps/api/geocode/json?address=#{address.gsub(' ','+')}&key=#{API_KEY}\")\n sleep(1)\n data = JSON.parse(response.body)['results']\n location = []\n location << data[0]['geometry']['location']['lat']\n location << data[0]['geometry']['location']['lng']\n end", "def gmaps4rails_address\n\t\t\"#{self.street}, #{self.city}, #{self.country}\" \n\tend", "def geocode(lat, long, range)\n @query[:geocode] = [lat, long, range].join(\",\")\n self\n end", "def geocode(lat, long, range)\n @query[:geocode] = [lat, long, range].join(\",\")\n self\n end", "def normalize_address(address)\n normalize(address).split(' ').map { |word| StreetAbbrevs[word] || word }.join(' ')\n end", "def convert_location(address)\n loc_query = Addressable::URI.new(\n :scheme => \"http\",\n :host => \"maps.googleapis.com\",\n :path => \"/maps/api/geocode/json\",\n :query_values => {:address => \"#{address}\",\n :sensor => \"false\"}\n )\n\n geolocation_json = RestClient.get(loc_query.to_s)\n location = JSON.parse(geolocation_json)\n\n latitude = location[\"results\"][0][\"geometry\"][\"location\"][\"lat\"]\n longitude = location[\"results\"][0][\"geometry\"][\"location\"][\"lng\"]\n\n [latitude, longitude]\n end", "def address\n @address ||=\n if address_attributes.present?\n GeocodedAddress.new(station.build_address(address_attributes))\n else\n NullAddress.new\n end\n end", "def geocoding_api_lookup\n location = self.address\n\n #result = Geocoder.search(location).first\n args = {postalcode: postcode, city: city, county: county, country: country, format: 'json'}\n result = nominatim_lookup(args)\n if result\n self.latitude = result[:lat]\n self.longitude = result[:lon]\n begin\n redis = Redis.new\n redis.set(location, [self.latitude, self.longitude].to_json)\n rescue Redis::RuntimeError => e\n raise e unless Rails.env.production?\n puts \"Redis error: #{e.message}\"\n end\n else\n self.update_column(:nominatim_count, self.nominatim_count + 1)\n end\n end", "def from_place_details details\n\n components = details[:address_components]\n unless components.nil?\n components.each do |component|\n types = component[:types]\n if types.nil?\n next\n end\n if 'street_address'.in? types\n self.address = component[:long_name]\n elsif 'route'.in? types\n self.route = component[:long_name]\n elsif 'street_number'.in? types\n self.street_number = component[:long_name]\n elsif 'administrative_area_level_1'.in? types\n self.state = component[:long_name]\n elsif 'locality'.in? types\n self.city = component[:long_name]\n elsif 'postal_code'.in? types\n self.zip = component[:long_name]\n end\n end\n end\n\n self.raw_address = details[:formatted_address]\n self.lat = details[:geometry][:location][:lat]\n self.lng = details[:geometry][:location][:lng]\n self.name = details[:name]\n self.google_place_id = details[:place_id]\n self.stop_code = details[:stop_code]\n self.types = details[:types]\n self.address_components_raw = details[:address_components]\n\n if self.raw_address.nil?\n self.raw_address = self.name\n end\n\n if self.name.nil?\n self.name = self.raw_address\n end\n\n self.save\n\n end", "def address_search\n coords = []\n places_near = []\n if params[:address].present?\n\t\t begin\n\t\t\t locations = Geocoder.search(\"#{params[:address]}\")\n if locations.present?\n locations.each do |l|\n x = Hash.new\n x[:coordinates] = l.coordinates\n x[:address] = l.address\n coords << x\n end\n end\n\t\t rescue\n\t\t\t coords = []\n\t\t end\n elsif params[:lat].present? && params[:lon].present?\n\t\t begin\n\t\t\t locations = Geocoder.search(\"#{params[:lat]}, #{params[:lon]}\")\n if locations.present?\n locations.each do |l|\n x = Hash.new\n x[:coordinates] = l.coordinates\n x[:address] = l.address\n coords << x\n end\n end\n\t\t rescue\n\t\t\t coords = []\n\t\t end\n end\n \n if params[:near_venue_id].present? && coords.present?\n x = Place.get_places_near(coords[0][:coordinates][0], coords[0][:coordinates][1], params[:near_venue_id])\n if x.present?\n x.each do |place|\n marker = Hash.new\n marker['id'] = place.id\n marker['lat'] = place.lat\n marker['lon'] = place.lon\n marker['popup'] = create_popup_text(place)\n marker['list'] = create_list_text(place)\n places_near << marker\n end\n end\n end\n\n respond_to do |format|\n format.json { render json: {matches: coords, places_near: places_near}.to_json }\n end\n end", "def geocode(address)\r\n\t\r\n\t\turi = URI.encode(\"#{@@google_base_url}#{address}\")\r\n\t\turl = URI.parse(uri)\r\n\t\thttp = Net::HTTP.new(url.host, url.port)\r\n\t\trequest = Net::HTTP::Get.new(url.request_uri)\r\n\t\tresponse = http.request(request)\t\r\n\t\t# throws exception\r\n\t\traise \"Bad response, code #{response.code}\" if response.code != \"200\"\r\n\t\t\r\n\t\t# result returned from Google Geocoding API\r\n\t\tresult = response.body\r\n\t\tjson_parsed = JSON.parse(result)\r\n\t\t\r\n\t\treturn json_parsed\r\n\tend", "def geocode!(instance)\n result = coordinates(instance).first\n if result\n {\n lat: result.latitude,\n lon: result.longitude,\n region: result.state_code,\n locality: result.city,\n postalcode: result.postal_code,\n address: result.address\n }\n else\n {}\n end\n end" ]
[ "0.7566016", "0.7546457", "0.72926354", "0.7209077", "0.6912252", "0.68828386", "0.6858201", "0.68352926", "0.6642573", "0.66420996", "0.65697587", "0.6517245", "0.6277231", "0.6028675", "0.59304166", "0.58426845", "0.5736893", "0.57335377", "0.5711746", "0.5682751", "0.5678295", "0.566781", "0.5639799", "0.56221026", "0.55871165", "0.55808", "0.5562776", "0.55259264", "0.5524677", "0.55137205", "0.547249", "0.5464471", "0.5456192", "0.5445057", "0.54402715", "0.5431187", "0.5404104", "0.53710544", "0.53663737", "0.53508747", "0.53405464", "0.5332215", "0.5324902", "0.53210646", "0.5303445", "0.5302529", "0.52981466", "0.5295124", "0.52877426", "0.52732277", "0.52662736", "0.52545065", "0.5249654", "0.5242229", "0.52340066", "0.52294207", "0.52264494", "0.5218246", "0.5210216", "0.52098805", "0.52013934", "0.519885", "0.51978546", "0.5196116", "0.5194609", "0.51879674", "0.51823854", "0.5181116", "0.51808417", "0.5177688", "0.51700467", "0.51652026", "0.51600623", "0.51578474", "0.5153356", "0.5149546", "0.5144868", "0.5143514", "0.5141", "0.51397926", "0.5139264", "0.51366615", "0.51365864", "0.5130074", "0.5124233", "0.512017", "0.5108501", "0.5108391", "0.51083565", "0.51034933", "0.51034933", "0.5100966", "0.51008475", "0.50890315", "0.50869846", "0.5084659", "0.5081914", "0.50792724", "0.5075732" ]
0.67838985
9
Reverse Geocoding Reverse geocoding is the process of converting a coordinate or location (latitude, longitude) to a readable address or place name. This permits the identification of nearby street addresses, places, and/or area subdivisions such as a neighborhood, county, state, or country.
def reverse_with_http_info(lat, lon, format, normalizecity, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: ReverseApi.reverse ...' end # verify the required parameter 'lat' is set if @api_client.config.client_side_validation && lat.nil? fail ArgumentError, "Missing the required parameter 'lat' when calling ReverseApi.reverse" end if @api_client.config.client_side_validation && lat > 90 fail ArgumentError, 'invalid value for "lat" when calling ReverseApi.reverse, must be smaller than or equal to 90.' end if @api_client.config.client_side_validation && lat < -90 fail ArgumentError, 'invalid value for "lat" when calling ReverseApi.reverse, must be greater than or equal to -90.' end # verify the required parameter 'lon' is set if @api_client.config.client_side_validation && lon.nil? fail ArgumentError, "Missing the required parameter 'lon' when calling ReverseApi.reverse" end if @api_client.config.client_side_validation && lon > 180 fail ArgumentError, 'invalid value for "lon" when calling ReverseApi.reverse, must be smaller than or equal to 180.' end if @api_client.config.client_side_validation && lon < -180 fail ArgumentError, 'invalid value for "lon" when calling ReverseApi.reverse, must be greater than or equal to -180.' end # verify the required parameter 'format' is set if @api_client.config.client_side_validation && format.nil? fail ArgumentError, "Missing the required parameter 'format' when calling ReverseApi.reverse" end # verify enum value if @api_client.config.client_side_validation && !['json'].include?(format) fail ArgumentError, "invalid value for 'format', must be one of json" end # verify the required parameter 'normalizecity' is set if @api_client.config.client_side_validation && normalizecity.nil? fail ArgumentError, "Missing the required parameter 'normalizecity' when calling ReverseApi.reverse" end # verify enum value if @api_client.config.client_side_validation && !['1'].include?(normalizecity) fail ArgumentError, "invalid value for 'normalizecity', must be one of 1" end if @api_client.config.client_side_validation && opts[:'addressdetails'] && !['0', '1'].include?(opts[:'addressdetails']) fail ArgumentError, 'invalid value for "addressdetails", must be one of 0, 1' end if @api_client.config.client_side_validation && opts[:'namedetails'] && !['0', '1'].include?(opts[:'namedetails']) fail ArgumentError, 'invalid value for "namedetails", must be one of 0, 1' end if @api_client.config.client_side_validation && opts[:'extratags'] && !['0', '1'].include?(opts[:'extratags']) fail ArgumentError, 'invalid value for "extratags", must be one of 0, 1' end # resource path local_var_path = '/reverse.php' # query parameters query_params = {} query_params[:'lat'] = lat query_params[:'lon'] = lon query_params[:'format'] = format query_params[:'normalizecity'] = normalizecity query_params[:'addressdetails'] = opts[:'addressdetails'] if !opts[:'addressdetails'].nil? query_params[:'accept-language'] = opts[:'accept_language'] if !opts[:'accept_language'].nil? query_params[:'namedetails'] = opts[:'namedetails'] if !opts[:'namedetails'].nil? query_params[:'extratags'] = opts[:'extratags'] if !opts[:'extratags'].nil? # header parameters header_params = {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # form parameters form_params = {} # http body (model) post_body = nil auth_names = ['key'] data, status_code, headers = @api_client.call_api(:GET, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => 'Location') if @api_client.config.debugging @api_client.config.logger.debug "API called: ReverseApi#reverse\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reverse_geocode\n do_lookup(true) do |o,rs|\n if r = rs.first\n unless r.address.nil?\n o.__send__ \"#{self.class.geocoder_options[:fetched_address]}=\", r.address\n end\n r.address\n end\n end\n end", "def reverse_geocode\n result = Geokit::Geocoders::MultiGeocoder.reverse_geocode([latitude, longitude])\n if result.success\n self.address = result.full_address\n else\n self.address = \"#{latitude}, #{longitude}\"\n end\n end", "def reverse_geocode\n uri = URI::HTTP.build(:scheme => 'http',\n :host => 'maps.googleapis.com',\n :path => '/maps/api/geocode/json',\n :query => URI.encode_www_form(:latlng => \"#{self.lat},#{self.lng}\",\n :sensor => true))\n\n response = Net::HTTP.get_response(uri)\n\n if response.is_a?(Net::HTTPSuccess)\n json = JSON.parse(response.body)\n Rails.logger.error json\n begin\n self.address = json[\"results\"].first[\"formatted_address\"]\n self.zipcode = json[\"results\"].first[\"address_components\"].last[\"short_name\"]\n rescue Exception => e\n Rails.logger.error e\n end\n end\n self\n end", "def reverse_geocode_trip\n self.departure_location_address ||= Geocoder.search([departure_location_latitude, departure_location_longitude]).first.address\n self.arrival_location_address ||= Geocoder.search([arrival_location_latitude, arrival_location_longitude]).first.address\n end", "def reverse_geocoded_by(coordinates_attr, options = {}, &block)\n geocoder_init(\n :reverse_geocode => true,\n :fetched_address => options[:address] || :address,\n :coordinates => coordinates_attr,\n :reverse_block => block\n )\n end", "def reverse(latitude:, longitude:, raw: false)\n result = Geocoder.search([latitude, longitude])\n raw ? result&.data : format_result(result)\n end", "def geocode\n do_lookup(false) do |o,rs|\n if r = rs.first\n unless r.coordinates.nil?\n o.__send__ \"#{self.class.geocoder_options[:coordinates]}=\", r.coordinates.reverse\n end\n r.coordinates\n end\n end\n end", "def reverse_geocode(coordinates, options = {})\n if coordinates.size < 1\n raise ArgumentError, 'You must provide coordinates to reverse geocode.'\n elsif coordinates.size == 1\n reverse_geocode_single(coordinates.first, options)\n else\n reverse_geocode_batch(coordinates, options)\n end\n end", "def reverse(lat, lon, format, normalizecity, opts = {})\n data, _status_code, _headers = reverse_with_http_info(lat, lon, format, normalizecity, opts)\n data\n end", "def reverse(lat, lon, format, normalizecity, opts = {})\n data, _status_code, _headers = reverse_with_http_info(lat, lon, format, normalizecity, opts)\n data\n end", "def geocode_reverse(latitude,\r\n longitude,\r\n language_code = 'en',\r\n zoom = 'address')\r\n # Prepare query url.\r\n _path_url = '/geocode-reverse'\r\n _query_builder = Configuration.get_base_uri\r\n _query_builder << _path_url\r\n _query_url = APIHelper.clean_url _query_builder\r\n # Prepare headers.\r\n _headers = {\r\n 'accept' => 'application/json'\r\n }\r\n\r\n # Prepare form parameters.\r\n _parameters = {\r\n 'output-case' => 'camel',\r\n 'latitude' => latitude,\r\n 'longitude' => longitude,\r\n 'language-code' => language_code,\r\n 'zoom' => zoom\r\n }\r\n _parameters = APIHelper.form_encode_parameters(_parameters)\r\n # Prepare and execute HttpRequest.\r\n _request = @http_client.post(\r\n _query_url,\r\n headers: _headers,\r\n parameters: _parameters\r\n )\r\n CustomQueryAuth.apply(_request)\r\n _context = execute_request(_request)\r\n validate_response(_context)\r\n # Return appropriate response type.\r\n decoded = APIHelper.json_deserialize(_context.response.raw_body)\r\n GeocodeReverseResponse.from_hash(decoded)\r\n end", "def reverse_geocode(options = { :using => Geokit::Geocoders::MultiGeocoder })\n if options[:using].is_a?(String) || options[:using].is_a?(Symbol)\n provider = Geokit::Geocoders.const_get(\"#{Geokit::Inflector::camelize(options[:using].to_s)}Geocoder\")\n elsif options[:using].respond_to?(:do_reverse_geocode)\n provider = options[:using]\n else\n raise ArgumentError.new(\"#{options[:using]} is not a valid geocoder.\")\n end\n\n provider.send(:reverse_geocode, self)\n end", "def reverse_geocode\n fail\n end", "def reverse_geocode(ll, options={}, async = true)\n request(\"/Locations/#{ll}\", {:query => {:key => @key}}, async)\n end", "def geocode\n self.coordinates = RepairingGeocoder.calc_coordinates(obj_address, address_to)\n end", "def address\n # match Geocoder::Result::Google#formatted_address\n \"#{street}, #{city}, #{state} #{zip}, #{country}\"\n end", "def geocode_address\n full_address or address\n end", "def geocodeAddress address\n \t logger.debug address\n \t result = HTTParty.get(\"http://maps.googleapis.com/maps/api/geocode/json\",\n \t :query => {\n \t :address => address,\n \t :sensor => false \n \t })\n \t \n \t logger.debug \"address geocoded ***********\"\n \t logger.debug result\n \t logger.debug result.parsed_response[\"results\"][0][\"geometry\"][\"location\"]\n \t \n \t return result.parsed_response[\"results\"][0][\"geometry\"][\"location\"]\n \tend", "def regeocode\n self.geocode_address if self.address_changed? || self.city_changed? || self.state_changed?\n end", "def fetch_raw_response(query, reverse = false)\n return nil if query.blank?\n\n # name parameter based on forward/reverse geocoding\n param = reverse ? :latlng : :address\n\n # build URL\n params = { param => query, :sensor => \"false\" }\n url = \"http://maps.google.com/maps/api/geocode/json?\" + params.to_query\n\n # query geocoder and make sure it responds quickly\n begin\n resp = nil\n timeout(3) do\n Net::HTTP.get_response(URI.parse(url)).body\n end\n rescue SocketError, TimeoutError\n return nil\n end\n end", "def reverse_with_http_info(lat, lon, format, normalizecity, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ReverseApi.reverse ...'\n end\n # verify the required parameter 'lat' is set\n if @api_client.config.client_side_validation && lat.nil?\n fail ArgumentError, \"Missing the required parameter 'lat' when calling ReverseApi.reverse\"\n end\n if @api_client.config.client_side_validation && lat > 90\n fail ArgumentError, 'invalid value for \"lat\" when calling ReverseApi.reverse, must be smaller than or equal to 90.'\n end\n\n if @api_client.config.client_side_validation && lat < -90\n fail ArgumentError, 'invalid value for \"lat\" when calling ReverseApi.reverse, must be greater than or equal to -90.'\n end\n\n # verify the required parameter 'lon' is set\n if @api_client.config.client_side_validation && lon.nil?\n fail ArgumentError, \"Missing the required parameter 'lon' when calling ReverseApi.reverse\"\n end\n if @api_client.config.client_side_validation && lon > 180\n fail ArgumentError, 'invalid value for \"lon\" when calling ReverseApi.reverse, must be smaller than or equal to 180.'\n end\n\n if @api_client.config.client_side_validation && lon < -180\n fail ArgumentError, 'invalid value for \"lon\" when calling ReverseApi.reverse, must be greater than or equal to -180.'\n end\n\n # verify the required parameter 'format' is set\n if @api_client.config.client_side_validation && format.nil?\n fail ArgumentError, \"Missing the required parameter 'format' when calling ReverseApi.reverse\"\n end\n # verify enum value\n allowable_values = [\"json\"]\n if @api_client.config.client_side_validation && !allowable_values.include?(format)\n fail ArgumentError, \"invalid value for \\\"format\\\", must be one of #{allowable_values}\"\n end\n # verify the required parameter 'normalizecity' is set\n if @api_client.config.client_side_validation && normalizecity.nil?\n fail ArgumentError, \"Missing the required parameter 'normalizecity' when calling ReverseApi.reverse\"\n end\n # verify enum value\n allowable_values = [1]\n if @api_client.config.client_side_validation && !allowable_values.include?(normalizecity)\n fail ArgumentError, \"invalid value for \\\"normalizecity\\\", must be one of #{allowable_values}\"\n end\n allowable_values = [0, 1]\n if @api_client.config.client_side_validation && opts[:'addressdetails'] && !allowable_values.include?(opts[:'addressdetails'])\n fail ArgumentError, \"invalid value for \\\"addressdetails\\\", must be one of #{allowable_values}\"\n end\n allowable_values = [0, 1]\n if @api_client.config.client_side_validation && opts[:'namedetails'] && !allowable_values.include?(opts[:'namedetails'])\n fail ArgumentError, \"invalid value for \\\"namedetails\\\", must be one of #{allowable_values}\"\n end\n allowable_values = [0, 1]\n if @api_client.config.client_side_validation && opts[:'extratags'] && !allowable_values.include?(opts[:'extratags'])\n fail ArgumentError, \"invalid value for \\\"extratags\\\", must be one of #{allowable_values}\"\n end\n allowable_values = [0, 1]\n if @api_client.config.client_side_validation && opts[:'statecode'] && !allowable_values.include?(opts[:'statecode'])\n fail ArgumentError, \"invalid value for \\\"statecode\\\", must be one of #{allowable_values}\"\n end\n # resource path\n local_var_path = '/reverse.php'\n\n # query parameters\n query_params = opts[:query_params] || {}\n query_params[:'lat'] = lat\n query_params[:'lon'] = lon\n query_params[:'format'] = format\n query_params[:'normalizecity'] = normalizecity\n query_params[:'addressdetails'] = opts[:'addressdetails'] if !opts[:'addressdetails'].nil?\n query_params[:'accept-language'] = opts[:'accept_language'] if !opts[:'accept_language'].nil?\n query_params[:'namedetails'] = opts[:'namedetails'] if !opts[:'namedetails'].nil?\n query_params[:'extratags'] = opts[:'extratags'] if !opts[:'extratags'].nil?\n query_params[:'statecode'] = opts[:'statecode'] if !opts[:'statecode'].nil?\n query_params[:'showdistance'] = opts[:'showdistance'] if !opts[:'showdistance'].nil?\n query_params[:'postaladdress'] = opts[:'postaladdress'] if !opts[:'postaladdress'].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(['application/json'])\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] || 'Location' \n\n # auth_names\n auth_names = opts[:auth_names] || ['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: ReverseApi#reverse\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def geocode\n # address must note be blank start with a number\n return if address.index(/[1-9]/).nil?\n return if full_address.blank?\n return if not lat.nil? and not lng.nil?\n url = \"http://geocoder.ca/?locate=#{CGI.escape self.full_address}&geoit=xml&jsonp=1&auth=#{GEOCODER_CA_KEY}&callback=?\"\n # get the response and cut off the jsonp\n response = Curl.get(url).body_str.from(2).to(-3)\n json = JSON.parse response\n self.lng = json[\"longt\"]\n self.lat = json[\"latt\"]\n end", "def address_full\n \"#{self.address.titleize}, Toronto, ON\"\n end", "def do_lookup(reverse = false)\n options = self.class.geocoder_options\n if reverse and options[:reverse_geocode]\n query = to_coordinates\n elsif !reverse and options[:geocode]\n query = send(options[:user_address])\n else\n return\n end\n\n query_options = [:lookup, :ip_lookup, :language, :params].inject({}) do |hash, key|\n if options.has_key?(key)\n val = options[key]\n hash[key] = val.respond_to?(:call) ? val.call(self) : val\n end\n hash\n end\n results = Geocoder.search(query, query_options)\n\n # execute custom block, if specified in configuration\n block_key = reverse ? :reverse_block : :geocode_block\n if custom_block = options[block_key]\n custom_block.call(self, results)\n\n # else execute block passed directly to this method,\n # which generally performs the \"auto-assigns\"\n elsif block_given?\n yield(self, results)\n end\n end", "def results\n @results ||= perform_reverse_geocode\n end", "def location_to_geocode(location)\n case location\n when Geocode then location\n when InstanceMethods then location.geocode\n when String, Fixnum then Geocode.find_or_create_by_query(location)\n end\n end", "def build_url(wonder)\n google_api_key = \"AIzaSyBP30mYnbwKpZ0lCHtp6FuvcNSjNG0GsGM\"\n geocode_url = \"https://maps.googleapis.com/maps/api/geocode/json?address=#{wonder}&key=#{google_api_key}\"\n encoded_url = URI.encode(geocode_url)\n return encoded_url\nend", "def geolocate\n \"#{self.address}\"', '\"#{self.state}\"', '\"#{self.zipcode}\"\n end", "def full_address\n \"#{street_address}, #{city}, #{ISO3166::Country.new(country_code.upcase).name}\"\n end", "def where_geocoder(query, near = nil)\n url = URI.parse GOOGLE_GEOCODER_URI\n near_query = nil\n if near && near.kind_of?(Hash)\n #near_query = \"ll=#{near[:latitude]},#{near[:longitude]}&spn=#{near[:span_latitude]},#{near[:span_longitude]}&gl=#{near[:country]}\" \n #near_query = \"ll=#{near[:latitude]},#{near[:longitude]}&spn=#{near[:span_latitude]},#{near[:span_longitude]}\" \n #near_query = \"gl=UK\"\n end\n \n response = Net::HTTP.start(url.host, url.port) do |http|\n http.get(\"#{GEOCODER_QUERY_STRING}#{CGI.escape(query)}&#{near_query}\")\n end\n\n results = JSON.parse(response.body)['Placemark']\n \n unless results.nil? || results.empty?\n results.map do |result|\n if result['AddressDetails'] && result['AddressDetails']['Accuracy'].to_i >= 0\n p = { :name => result['address'] }\n\n p[:address] = result['AddressDetails']['Country']['AdministrativeArea']['Locality']['Thoroughfare']['ThoroughfareName'] rescue nil\n p[:city] = result['AddressDetails']['Country']['AdministrativeArea']['Locality']['LocalityName'] rescue nil\n p[:region] = result['AddressDetails']['Country']['AdministrativeArea']['AdministrativeAreaName'] rescue nil\n p[:country] = result['AddressDetails']['Country']['CountryNameCode'] rescue nil\n p[:postal_code] = result['AddressDetails']['Country']['AdministrativeArea']['Locality']['PostalCode'] rescue nil\n p[:latitude] = result['Point']['coordinates'][1].to_f rescue nil\n p[:longitude] = result['Point']['coordinates'][0].to_f rescue nil\n p[:accuracy] = result['AddressDetails']['Accuracy'].to_i rescue nil\n p[:zoom] = ZOOM_FROM_ACCURACY[result['AddressDetails']['Accuracy'].to_i] #rescue 0\n\n p\n else\n nil\n end\n end\n else\n []\n end\n end", "def geocode_address\n geo = Geokit::Geocoders::MultiGeocoder.geocode(self.address_string)\n if geo.success\n self.lat, self.lng = geo.lat, geo.lng\n else\n puts geo.class\n errors.add(:address, \"Could not Geocode address\")\n end\n end", "def reverse(location, options = {})\n raise ArgumentError, 'Method must receive a location (array)' unless location && location.kind_of?(Array)\n options[:location] = location.join(',')\n call_api self, 1, 'reverse', options\n end", "def create_address(city, state, zip)\n call_address = Addressable::URI.new(\n :scheme => \"http\",\n :host => \"www.whitepages.com\",\n :path => \"search/FindNearby\",\n :query_values => {\n :utf8 => \"&#10003;\",\n :street => \"#{city}, #{state}\",\n :where => \"#{zip}\"\n }\n ).to_s\n end", "def full_street_address\n postcode_only_address\n end", "def reverse_ip(ipaddress)\n reverse_ip = IPAddr.new ipaddress\n reverse_ip.reverse\nend", "def geocode(address)\n result = Geocoder.search(address).first\n #result.latitude - float\n #result.longitude - float\n #result.coordinates - array of the above two\n #result.address - string\n #result.city - string\n #result.state - string\n #result.state_code - string\n #result.postal_code - string\n #result.country - string\n #result.country_code - string\n if result\n self.lat = result.latitude\n self.lng = result.longitude\n return true\n else\n return nil\n end\n end", "def geocode(s)\n @geocoder.run(s)\n end", "def postal_code_to_coordinate(postal_code, options = {})\n Services::PostalCodeToCoordinate.new(options).resolve(postal_code)\n end", "def full_street_address #Take all location fields, remove nil elements with .compact, then return a string for Geocoder\n [address_1, address_2, city, country, z_post_code].compact.join(', ')\n end", "def find_city(lat,lng)\n if Geocoder::Calculations.distance_between([lat,lng], [40.698390,-73.98843]) < 20\n \"newyork\"\n elsif\n Geocoder::Calculations.distance_between([lat,lng], [40.76813,-73.96439]) < 20\n \"newyork\"\n elsif\n Geocoder::Calculations.distance_between([lat,lng], [37.76423,-122.47743]) < 20\n \"sanfrancisco\"\n elsif\n Geocoder::Calculations.distance_between([lat,lng], [37.76912,-122.42593]) < 20\n \"sanfrancisco\"\n elsif\n Geocoder::Calculations.distance_between([lat,lng], [48.85887,2.30965]) < 20\n \"paris\"\n elsif\n Geocoder::Calculations.distance_between([lat,lng], [48.86068,2.36389]) < 20\n \"paris\"\n elsif\n Geocoder::Calculations.distance_between([lat,lng], [51.51,-0.13]) < 20\n \"london\"\n elsif\n Geocoder::Calculations.distance_between([lat,lng], [-23.57664,-46.69787]) < 20\n \"saopaulo\"\n elsif\n Geocoder::Calculations.distance_between([lat,lng], [-23.55838,-46.64362]) < 20\n \"saopaulo\"\n elsif\n Geocoder::Calculations.distance_between([lat,lng], [35.64446,139.70695]) < 20\n \"tokyo\"\n elsif\n Geocoder::Calculations.distance_between([lat,lng], [35.70136,139.73991]) < 20\n \"tokyo\"\n elsif\n Geocoder::Calculations.distance_between([lat,lng], [34.06901,-118.35904]) < 20\n \"losangeles\"\n elsif\n Geocoder::Calculations.distance_between([lat,lng], [34.07499,-118.28763]) < 20\n \"losangeles\"\n elsif\n Geocoder::Calculations.distance_between([lat,lng], [34.02663,-118.45998]) < 20\n \"losangeles\"\n elsif\n Geocoder::Calculations.distance_between([lat,lng], [50.07832,14.41619]) < 20\n \"prague\"\n else\n \"unknown\"\n end\n end", "def full_address\n \"#{region}, #{district}, #{street_type} #{street_name}, д. #{house_number} кв. #{apartment}\"\n end", "def generate_address\n name = self.name\n unless self.address\n key = ENV['GMAPS_KEY']\n search = name.gsub(\" \",\"+\")\n map_results = JSON.parse(open(\n \"https://maps.googleapis.com/maps/api/place/textsearch/json?location=41.310362,-72.928914&radius=500&key=#{key}&query=#{search}&sensor=true\").read)\n loc = map_results['results'].first\n if loc\n address = loc[\"formatted_address\"]\n lat = loc[\"geometry\"][\"location\"][\"lat\"]\n lng = loc[\"geometry\"][\"location\"][\"lng\"]\n else\n address = \"38 Hillhouse Avenue, New Haven, CT 06511\"\n lat = \"41.310362\"\n lng = \"-72.928914\"\n end\n self.attributes = {:address => address, :latitude => lat, :longitude => lng}\n end\n end", "def full_address(include_country = false, include_secondary = false)\n address = \"#{street_address(include_secondary)} #{postal_code} #{city}\"\n address = \"#{address} POLOGNE\" if include_country\n address\n end", "def residential_address\n return unless @user.loa3?\n\n dig_out('addresses', 'address_pou', VAProfile::Models::Address::RESIDENCE)\n end", "def lat_lng\n lng_lat.reverse\n end", "def geocode\n uri = URI::HTTP.build(:scheme => 'http',\n :host => 'maps.googleapis.com',\n :path => '/maps/api/geocode/json',\n :query => URI.encode_www_form(:address => \"#{self.address}\",\n :sensor => false))\n\n response = Net::HTTP.get_response(uri)\n if response.is_a?(Net::HTTPSuccess)\n json = JSON.parse(response.body)\n Rails.logger.error json\n location = json[\"results\"].first[\"geometry\"][\"location\"]\n self.lat = location[\"lat\"]\n self.lng = location[\"lng\"]\n end\n self\n end", "def geocode(address)\n q = { address: URI::encode(address) }\n q[:key] = @config[:api_key] if @config.has_key?(:api_key)\n\n res = get('/json', q)\n JSON::parse(res.body)\n end", "def decode_address address\n call_blockchain_api(\"decode_address/#{address}\")\n end", "def geocode_address\n self.latlon = Geocoder.new(request.ip)\n puts \" ** self.latlon: #{self.latlon.inspect}\"\n end", "def geocode\n name = params[:name].to_s\n if params[:format]\n name = Location.reverse_name(name) if params[:format] == \"scientific\"\n elsif @user = get_session_user!\n name = Location.reverse_name(name) if @user.location_format == :scientific\n end\n render(inline: Geocoder.new(name).ajax_response)\n end", "def address\n @address ||= best_guess_address(name)\n end", "def find_neighborhood\n results = Geocoder.search(\"#{coordinates[1]},#{coordinates[0]}\")\n unless results.blank?\n n = 0\n m = 0\n has_neighborhood = false\n (0..(results.count-1)).each do |i|\n if results[i].types.include?(\"neighborhood\")\n has_neighborhood = true\n n = i\n break\n end\n end\n if has_neighborhood\n (0..(results[n].address_components.count-1)).each do |i|\n if results[n].address_components[i][\"types\"].include?(\"neighborhood\")\n m = i\n break\n end\n end\n results[n].address_components[m][\"long_name\"]\n else\n return nil\n end\n else\n return nil\n end\n \n end", "def geocoding\n @geocoding ||= Geocoding::Gateway.new(client)\n end", "def full_street_address\n location + \"New York City, NY, USA\"\n end", "def gmaps4rails_address\n \"#{address}, #{city_state_zip}\"\n end", "def full_address\n \"#{address}, #{city}, #{state}, #{zip}\"\n end", "def to_coordinates\n coords = send(self.class.geocoder_options[:coordinates])\n coords.is_a?(Array) ? coords.reverse : []\n end", "def optimistic_geo_wrapper(query)\n geocoded = nil\n result = ::Geocoder.search(query)\n puts result.inspect\n geocoded = result[0].data if result[0]\n geocoded\n end", "def gmaps4rails_address\n \"#{address1}, #{address2}, #{city}, #{state}, #{zipcode}\"\n end", "def query_address2latlng(query_address)\n\t\tla_clave_esa = \"AIzaSyBtlkF4i2Mmv33\" + \"uVc4aVTA5JT94-eEnRTo\"\n\t\tgeocode_url = \"https://maps.googleapis.com/maps/api/geocode/json?address=\"+query_address+\"&key=\" + la_clave_esa\n\t\tgeocode_uri = URI.parse(geocode_url)\n\t\tgeocode_response = Net::HTTP.get_response(geocode_uri)\n\t\tgeocode_hash = JSON.parse geocode_response.body\n\t\t#pp geocode_hash\n\t\tlat = geocode_hash[\"results\"][0][\"geometry\"][\"location\"][\"lat\"]\n\t\tlng = geocode_hash[\"results\"][0][\"geometry\"][\"location\"][\"lng\"]\n\t\treturn lat.to_s + \",\" + lng.to_s\n\tend", "def gmaps4rails_address\n addr = if state and state.name.present?\n \"#{address_1}, #{city}, #{state.name} #{zip_code}\"\n elsif (address_1)\n \"#{address_1}, #{raw_seed}\"\n else\n \"1856 Stevenson Ave, Clearwater, Florida 33755\"\n end\n puts \"gmap input:#{addr}\"\n addr\n end", "def address(latitude, longitude)\n return nil if latitude.blank? || longitude.blank?\n return nil unless doc = search(\"#{latitude},#{longitude}\", true)\n # blindly use first result (assume it is most accurate)\n doc['results'].first['formatted_address']\n end", "def coordinates(user_address)\n geocoding_url = Addressable::URI.new(\n :scheme => \"https\",\n :host => \"maps.googleapis.com\",\n :path => \"maps/api/geocode/json\",\n :query_values => {:address => user_address,\n :sensor => false}\n ).to_s\n\n response = JSON.parse(RestClient.get(geocoding_url))\n location = response[\"results\"][0][\"geometry\"][\"location\"]\n location_string = \"#{location[\"lat\"]},#{location[\"lng\"]}\"\nend", "def geoAddress\n\n self.address + \",\" +self.region.name\n\n end", "def gmaps4rails_address\n \t\"#{address}, #{city}, #{state}\"\n end", "def geocode!\n result = GeoKit::Geocoders::YahooGeocoder.geocode \"#{@street}, #{@city}, #{@state} #{@zip}\"\n if result.success?\n @street = result.street_address\n @city = result.city\n @state = result.state\n @zip = result.zip\n @country = result.country_code\n @lat = result.lat\n @lng = result.lng\n @status = STATUS_GEOCODED\n else\n @status = STATUS_GEOCODE_ERROR\n end\n end", "def location\n c = Country.find_country_by_alpha2(country)\n country_name = !c.nil? ? c.name : nil\n if (postcode and country)\n return postcode + \", \" + (country_name or country)\n else\n return (postcode or country_name or country)\n end\n end", "def full_address\n \"#{address}, #{suburb}, #{state}, #{postcode}\"\n end", "def geocode(lat, lon, options = {})\n new(options.merge(lat: lat, lon: lon)).retrieve\n end", "def address\n '310 S Harrington'\n end", "def location_code\n # find the closest location\n location = area || city || province\n location.post_code\n end", "def new_input_set()\n return ReverseGeocodeInputSet.new()\n end", "def geocode\n fail\n end", "def geocode_address(address,\r\n country_code = nil,\r\n language_code = 'en',\r\n fuzzy_search = false)\r\n # Prepare query url.\r\n _path_url = '/geocode-address'\r\n _query_builder = Configuration.get_base_uri\r\n _query_builder << _path_url\r\n _query_url = APIHelper.clean_url _query_builder\r\n # Prepare headers.\r\n _headers = {\r\n 'accept' => 'application/json'\r\n }\r\n\r\n # Prepare form parameters.\r\n _parameters = {\r\n 'output-case' => 'camel',\r\n 'address' => address,\r\n 'country-code' => country_code,\r\n 'language-code' => language_code,\r\n 'fuzzy-search' => fuzzy_search\r\n }\r\n _parameters = APIHelper.form_encode_parameters(_parameters)\r\n # Prepare and execute HttpRequest.\r\n _request = @http_client.post(\r\n _query_url,\r\n headers: _headers,\r\n parameters: _parameters\r\n )\r\n CustomQueryAuth.apply(_request)\r\n _context = execute_request(_request)\r\n validate_response(_context)\r\n # Return appropriate response type.\r\n decoded = APIHelper.json_deserialize(_context.response.raw_body)\r\n GeocodeAddressResponse.from_hash(decoded)\r\n end", "def address_string\n \"#{address}, #{city}, #{state} #{zip}\"\n end", "def geo_code(params)\n if params\n geo_data = Geocoder.search(params[\"address\"]).first\n params[\"address\"] = geo_data.formatted_address\n params[\"lng\"] = geo_data.longitude\n params[\"lat\"] = geo_data.latitude\n params\n end\n end", "def fetch_address_and_geometry(save = false)\n coords = Geocoder.fetch_coordinates(\n send(self.class.geocoder_options[:method_name])\n )\n unless coords.blank?\n method = (save ? \"update\" : \"write\") + \"_attribute\"\n send method, self.class.geocoder_options[:formatted_address], coords[0]\n send method, self.class.geocoder_options[:geometry], coords[1]\n end\n coords\n end", "def geocode_endpoints\n if start_address_changed?\n geocoded = Geocoder.search(start_address).first\n if geocoded\n self.start_latitude = geocoded.latitude\n self.start_longitude = geocoded.longitude\n end\n end\n # Repeat for destination\n if end_address_changed?\n geocoded = Geocoder.search(end_address).first\n if geocoded\n self.end_latitude = geocoded.latitude\n self.end_longitude = geocoded.longitude\n end\n end\n end", "def address\n \"#{self.building} #{return_data_format(self.street)} #{self.zipcode}\"\n end", "def from_place_details details\n\n components = details[:address_components]\n unless components.nil?\n components.each do |component|\n types = component[:types]\n if types.nil?\n next\n end\n if 'street_address'.in? types\n self.address1 = component[:long_name]\n elsif 'route'.in? types\n self.route = component[:long_name]\n elsif 'street_number'.in? types\n self.street_number = component[:long_name]\n elsif 'administrative_area_level_1'.in? types\n self.state = component[:long_name]\n elsif 'locality'.in? types\n self.city = component[:long_name]\n elsif 'postal_code'.in? types\n self.zip = component[:long_name]\n end\n end\n end\n\n self.raw_address = details[:formatted_address]\n self.lat = details[:geometry][:location][:lat]\n self.lon = details[:geometry][:location][:lng]\n self.name = details[:name]\n self.google_place_id = details[:place_id]\n self.stop_code = details[:stop_code]\n self.types = details[:types]\n self.address_components_raw = details\n\n if self.raw_address.nil?\n self.raw_address = self.name\n end\n\n end", "def full_address\n \"#{address1} #{address2} #{city},#{state} #{postal_code} #{country}\"\n end", "def full_address\n\t\t\"#{street}, #{postal_code}, #{city}, #{country}\"\n\tend", "def address\n\t\tGeocoder.address([self.latitude, self.longitude])\n\tend", "def locate(address)\n get :geo, :q => address\n end", "def geocode\n geo = Geokit::Geocoders::MultiGeocoder.geocode address.gsub(/\\n/, ', ')\n if geo.success\n self.lat, self.lng = geo.lat, geo.lng\n else\n errors.add(:address, 'Problem locating address')\n end\n end", "def geocode_best_possible\n\n return unless addressable_type == 'Company'\n\n # don't Geocode if we're doing development or testing AND\n # we already have lat and long and nothing has changed\n return if dev_or_test_and_have_geo_unchanged?\n\n specificity_order = address_array\n\n most_specific = 0\n least_specific = specificity_order.size - 1\n\n geo_result = nil\n\n until most_specific > least_specific || geo_result.present?\n geocode_address = specificity_order[most_specific..least_specific].compact.join(', ')\n geo_result = Geocoder.search(geocode_address)\n most_specific += 1\n end\n\n unless geo_result.nil?\n self.latitude = geo_result[0].latitude\n self.longitude = geo_result[0].longitude\n end\n\n end", "def get_address\n welcome_message\n puts \"What is your location?\"\n user_location = Geocoder.search(gets.chomp)[0]\n if user_location != nil\n adr = user_location\n @city = adr.city\n @lat = adr.latitude\n @lon = adr.longitude\n else\n no_match\n end\n end", "def full_address\n [landmark_name, city, country].compact.join(', ')\n end", "def gmaps4rails_address\n\t\t\"#{self.street}, #{self.city}, #{self.country}\" \n\tend", "def geocode(address)\n response = HTTParty.get(\"https://maps.googleapis.com/maps/api/geocode/json?address=#{address.gsub(' ','+')}&key=#{API_KEY}\")\n sleep(1)\n data = JSON.parse(response.body)['results']\n location = []\n location << data[0]['geometry']['location']['lat']\n location << data[0]['geometry']['location']['lng']\n end", "def geocode(lat, long, range)\n @query[:geocode] = [lat, long, range].join(\",\")\n self\n end", "def geocode(lat, long, range)\n @query[:geocode] = [lat, long, range].join(\",\")\n self\n end", "def normalize_address(address)\n normalize(address).split(' ').map { |word| StreetAbbrevs[word] || word }.join(' ')\n end", "def convert_location(address)\n loc_query = Addressable::URI.new(\n :scheme => \"http\",\n :host => \"maps.googleapis.com\",\n :path => \"/maps/api/geocode/json\",\n :query_values => {:address => \"#{address}\",\n :sensor => \"false\"}\n )\n\n geolocation_json = RestClient.get(loc_query.to_s)\n location = JSON.parse(geolocation_json)\n\n latitude = location[\"results\"][0][\"geometry\"][\"location\"][\"lat\"]\n longitude = location[\"results\"][0][\"geometry\"][\"location\"][\"lng\"]\n\n [latitude, longitude]\n end", "def address\n @address ||=\n if address_attributes.present?\n GeocodedAddress.new(station.build_address(address_attributes))\n else\n NullAddress.new\n end\n end", "def geocoding_api_lookup\n location = self.address\n\n #result = Geocoder.search(location).first\n args = {postalcode: postcode, city: city, county: county, country: country, format: 'json'}\n result = nominatim_lookup(args)\n if result\n self.latitude = result[:lat]\n self.longitude = result[:lon]\n begin\n redis = Redis.new\n redis.set(location, [self.latitude, self.longitude].to_json)\n rescue Redis::RuntimeError => e\n raise e unless Rails.env.production?\n puts \"Redis error: #{e.message}\"\n end\n else\n self.update_column(:nominatim_count, self.nominatim_count + 1)\n end\n end", "def from_place_details details\n\n components = details[:address_components]\n unless components.nil?\n components.each do |component|\n types = component[:types]\n if types.nil?\n next\n end\n if 'street_address'.in? types\n self.address = component[:long_name]\n elsif 'route'.in? types\n self.route = component[:long_name]\n elsif 'street_number'.in? types\n self.street_number = component[:long_name]\n elsif 'administrative_area_level_1'.in? types\n self.state = component[:long_name]\n elsif 'locality'.in? types\n self.city = component[:long_name]\n elsif 'postal_code'.in? types\n self.zip = component[:long_name]\n end\n end\n end\n\n self.raw_address = details[:formatted_address]\n self.lat = details[:geometry][:location][:lat]\n self.lng = details[:geometry][:location][:lng]\n self.name = details[:name]\n self.google_place_id = details[:place_id]\n self.stop_code = details[:stop_code]\n self.types = details[:types]\n self.address_components_raw = details[:address_components]\n\n if self.raw_address.nil?\n self.raw_address = self.name\n end\n\n if self.name.nil?\n self.name = self.raw_address\n end\n\n self.save\n\n end", "def address_search\n coords = []\n places_near = []\n if params[:address].present?\n\t\t begin\n\t\t\t locations = Geocoder.search(\"#{params[:address]}\")\n if locations.present?\n locations.each do |l|\n x = Hash.new\n x[:coordinates] = l.coordinates\n x[:address] = l.address\n coords << x\n end\n end\n\t\t rescue\n\t\t\t coords = []\n\t\t end\n elsif params[:lat].present? && params[:lon].present?\n\t\t begin\n\t\t\t locations = Geocoder.search(\"#{params[:lat]}, #{params[:lon]}\")\n if locations.present?\n locations.each do |l|\n x = Hash.new\n x[:coordinates] = l.coordinates\n x[:address] = l.address\n coords << x\n end\n end\n\t\t rescue\n\t\t\t coords = []\n\t\t end\n end\n \n if params[:near_venue_id].present? && coords.present?\n x = Place.get_places_near(coords[0][:coordinates][0], coords[0][:coordinates][1], params[:near_venue_id])\n if x.present?\n x.each do |place|\n marker = Hash.new\n marker['id'] = place.id\n marker['lat'] = place.lat\n marker['lon'] = place.lon\n marker['popup'] = create_popup_text(place)\n marker['list'] = create_list_text(place)\n places_near << marker\n end\n end\n end\n\n respond_to do |format|\n format.json { render json: {matches: coords, places_near: places_near}.to_json }\n end\n end", "def geocode(address)\r\n\t\r\n\t\turi = URI.encode(\"#{@@google_base_url}#{address}\")\r\n\t\turl = URI.parse(uri)\r\n\t\thttp = Net::HTTP.new(url.host, url.port)\r\n\t\trequest = Net::HTTP::Get.new(url.request_uri)\r\n\t\tresponse = http.request(request)\t\r\n\t\t# throws exception\r\n\t\traise \"Bad response, code #{response.code}\" if response.code != \"200\"\r\n\t\t\r\n\t\t# result returned from Google Geocoding API\r\n\t\tresult = response.body\r\n\t\tjson_parsed = JSON.parse(result)\r\n\t\t\r\n\t\treturn json_parsed\r\n\tend", "def geocode!(instance)\n result = coordinates(instance).first\n if result\n {\n lat: result.latitude,\n lon: result.longitude,\n region: result.state_code,\n locality: result.city,\n postalcode: result.postal_code,\n address: result.address\n }\n else\n {}\n end\n end" ]
[ "0.7564929", "0.7546099", "0.7291449", "0.72085553", "0.6912238", "0.6884488", "0.6855514", "0.6835236", "0.678736", "0.678736", "0.66437846", "0.66417956", "0.65688074", "0.65170014", "0.6274152", "0.60239655", "0.5925795", "0.58385664", "0.5733644", "0.5732255", "0.57130766", "0.56784743", "0.5674795", "0.5666598", "0.56214124", "0.55832535", "0.55773264", "0.5558263", "0.5521875", "0.55194646", "0.55087334", "0.54756063", "0.5459929", "0.54518086", "0.5445383", "0.5435536", "0.54266244", "0.54016757", "0.5366767", "0.5362784", "0.53472877", "0.5335984", "0.53286505", "0.5322569", "0.5321644", "0.5298703", "0.5298524", "0.52978635", "0.5291178", "0.528406", "0.52704793", "0.52625126", "0.5251063", "0.52447635", "0.52375257", "0.52303433", "0.5226681", "0.5226632", "0.52138555", "0.5206776", "0.5204948", "0.5197608", "0.51948065", "0.5194034", "0.5191563", "0.5190577", "0.5184307", "0.5179045", "0.5177967", "0.5177076", "0.517395", "0.5170027", "0.5161211", "0.51558596", "0.51537436", "0.5148264", "0.5145329", "0.514153", "0.5141368", "0.51382035", "0.5136139", "0.51359487", "0.5134313", "0.5131628", "0.51262856", "0.51190585", "0.5115796", "0.5105196", "0.5104242", "0.5103622", "0.5100969", "0.5100969", "0.5097226", "0.50969464", "0.5085568", "0.508299", "0.50817925", "0.5076367", "0.5075504", "0.5072102" ]
0.5641033
24
GET /requests/devolutions/products/details/1 GET /requests/devolutions/products/details/1.json
def show @requests_devolutions_products_detail = Requests::Devolutions::Products::Detail.find(params[:id]) respond_to do |format| format.html end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n json_response(@api_v1_product)\n end", "def show\n @requests_transferences_products_detail = Requests::Transferences::Products::Detail.find(params[:id])\n respond_to do |format|\n format.html\n end\n end", "def show\n @product = Product.find(params[:id])\n json_response(params)\n end", "def show\n @products = Product.find_by_id(params[:id])\n msg = { status: 200 , product: @products }\n respond_to do |format|\n format.html { render json: msg }\n format.json { render json: msg }\n end\n end", "def show\n render json: @product, status: 200\n end", "def product(name)\n get(\"/apiproducts/#{name}\")\n end", "def new\n @requests_devolutions_products_detail = Requests::Devolutions::Products::Detail.new\n respond_to do |format|\n end\n end", "def show\n product = Product.find_by_id(params[:id])\n\n render json: product\n end", "def show\n @requests_devolutions_product = Requests::Devolutions::Product.find(params[:id])\n respond_to do |format|\n format.js\n end\n end", "def view_product\n to_json(\n only: [:id, :title, :description, :key_information],\n methods: [:photo_url, :net_mrp, :mrp_per_unit, :quantity],\n :include => {\n store: {\n only: [:name, :id],\n methods: [:full_address]\n }\n }\n )\n end", "def show\n result = Product.find(params[:id])\n render json: {\n status: :ok,\n product: result\n } \n end", "def show\n @product = Product.eager_loading.find_by_uuid(params[:id])\n\n respond_to do |format|\n format.html { redirect_to edit_shop_product_path(@product.shop_id, @product)}\n format.json { render json: @product.as_json(:include => {:product_variants => {:include => [:option_types,:pictures]}, :shipping_category => {}}, :methods => [:taxon_ids]) }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n render json: @product\n end", "def show\n render json: @product_management\n end", "def get_products()\n\tputs \"Getting products\"\n\tresponse = request_get(\"/api/product\")\n\tputs response.body\nend", "def show\n @product = @person.products.find(params[:id])\n\n respond_to do |format|\n format.json { render :json => @product }\n end\n end", "def show\n render json: @product\n end", "def show\n # is_my_resource(params[:id])\n\n # prossumerProductsIds = Prossumer.find(params[:id]).products.ids\n render json: ProductAuth.where({product_id: params[:id], group_id: params[:group_id]}).first.as_json(:include => :product)\n end", "def getProduct( product_id)\n params = Hash.new\n params['product_id'] = product_id\n return doCurl(\"get\",\"/product\",params)\n end", "def show\n render json: @product\n end", "def show\n @product = Product.find(params[:id])\n render json: @product, status: :ok\n end", "def show\n @product = ProductProduct.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @supplier = Supplier.find(params[:supplier_id])\n @product = @supplier.products.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @product }\n end\n end", "def show\n respond_to do |format|\n format.html\n format.json { render :json => @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n render json: @product\n end", "def show\n @product = Product.find(params[:id])\n @donor = Donor.all\n @event = Event.all\n @category = Category.all\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n render :json => Producto.find(params[:id])\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n \n @product = Product.find(params[:id])\n @vendors = @product.vendor(:all)\n #@vendors = Vendor.find(params[:id])\n #@vendors = Vendor.all\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @prod = Prod.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @prod }\n end\n end", "def show\n @shopifyproduct = Shopifyproduct.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @shopifyproduct }\n end\n end", "def details(options = {})\n if @existing_options == options\n @response\n else\n @existing_options = options\n response = SageWorld::Client.new(find_product_params(@product_id ,options)).send_request\n @response = SageWorld::ResponseHandler.new(response)\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @product }\n end\n end", "def products\n request :public, :get, :products\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json=> @product }\n end\n end", "def show\n puts \"the params are #{params}\" \n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @prod = Prod.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @prod }\n end\n end", "def show\n @related_product = RelatedProduct.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @related_product }\n end\n end", "def show\n @onecompany_product = Onecompany::Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @onecompany_product }\n end\n end", "def show\n @product = Product.find(params[:id])\n @photos = @product.photos\n\t@related_products = Product.where(\"category_id = ? and manufacturer_id = ? and id <> ?\", @product.category, @product.manufacturer,@product.id ).limit(6)\n @reviews = @product.reviews.paginate(:page => params[:page], :per_page => 10)\n @manufacturer_products = @product.manufacturer.products.where(\"id <> ?\",@product.id).limit(5) unless @product.manufacturer.nil?\n if (current_user != nil)\n @cart = User.find(session[:user_id]).cart\n end\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @team_product_request = TeamProductRequest.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @team_product_request }\n end\n end", "def show\n @product2 = Product2.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product2 }\n end\n end", "def show\n @store2product = Store2product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @store2product }\n end\n end", "def show\n @datasources_product = DatasourcesProduct.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @datasources_product }\n end\n end", "def show\n @product = Product.find(params[:id]) \n # @product_id = @product.id\n # @review = Review.find(@product_id)\n\n # @reviews = Review.where(:product_id => params[:id])\n @reviews = Review.where(:product_id => @product.id)\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product_lot = ProductLot.find(params[:id])\n render json: @product_lot, root: false\n end", "def show\n @design = Design.find(params[:id])\n @products = @design.products\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @design }\n end\n end", "def getKind\n @products = Product.where(\"kind = ?\", params[:kind]).available.PriceOrder.paginate(page: params[:page], per_page: 5)\n render json: @products\n end", "def show\n @productiondetail = Productiondetail.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @productiondetail }\n end\n end", "def InfoProducto\n \tid = params[:id]\n @productos = Producto.find_by_sql(\"select distinct productos.nombre as nombreProducto, productos.id as idProducto, productos.oferta, productos.compra, laboratorios.nombre as nombreLaboratorio, presentacions.descripcion, plan_pacientes.id, \n\t\tplan_pacientes.nombre as nombrePlanPaciente, plan_pacientes.id as idPlanPaciente,\n\t\tsustancia.descripcion as descripcionSustancia\n\t\t from productos, presentacions, plan_pacientes, laboratorios, sustancia where \n\t\tproductos.presentacion_id = presentacions.id and\n\t\tproductos.laboratorio_id = laboratorios.id and\n\t\tproductos.sustancium_id = sustancia.id and\n\t\tproductos.id = #{id} LIMIT 1\")\n render json: @productos\n end", "def index\n @api_v1_products = Product.all\n json_response(@api_v1_products)\n end", "def get_product\n json_response({ message: 'NOT IMPLEMENTED' })\n end", "def show\n @home_searches_product = Home::Searches::Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @home_searches_product }\n end\n end", "def show\n @product = @user.products.find(params[:id])\n # was @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product_item = ProductItem.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @product_item }\n end\n end", "def show\n @magento_product = MagentoProduct.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @magento_product }\n end\n end", "def show\n if is_my_resource(@product.prossumer_id)\n render json: @product.as_json({\n cycle_id: params[:cycle_id],\n include: {\n prossumer: {\n except: [:encrypted_password, :salt, :confirm_hash]\n },\n product_category: {}\n }\n })\n end\n end", "def show\n @size_to_product = SizeToProduct.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @size_to_product }\n end\n end", "def show\n @carts_product = @cart.carts_products.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @carts_product }\n end\n end", "def show\n @review = Review.find(params[:id])\n @product = @review.product\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @review }\n end\n end", "def show\n respond_with @product\n end", "def show\n @productsbind = Productsbind.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @productsbind }\n end\n end", "def show\n # @ccbs_product = CcbsProduct.find(params[:id])\n\n prd_attribute = PrdAttribute.find(params[:id], :include => :products)\n product = Product.find(prd_attribute.products[0].id, :include => [:prd_subscriptions, :prd_additional_services])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @ccbs_product }\n format.json {\n\n ccbs_product = CcbsProduct.new\n tariff_list = ccbs_product.set_fields(prd_attribute, product.prd_subscriptions, product.prd_additional_services)\n\n # product에 대해 전달\n results = mapping_to_hash(ccbs_product,CcbsProduct.json_mapping_table)\n ccbs_product.send_to_ccbs('POST', results.to_json)\n\n # tariff에 대해서 전달\n tariff_list.each { |product_tariff| \n to_ccbs_hash = mapping_to_hash(product_tariff, CcbsProductTariff.json_mapping_table)\n product_tariff.send_to_ccbs(\"POST\", to_ccbs_hash.to_json) }\n\n render :json => results\n } \n end\n end", "def show\n @product_cost = ProductCost.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @product_cost }\n end\n end", "def show\n @productonegocio = Productonegocio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @productonegocio }\n end\n end", "def find_resource\n if !params[:format].nil? && params[:format] == \"json\"\n begin\n p \"i came in\"\n p params[:id]\n Product.find_by_id(params[:id])\n rescue Exception => e\n error = error_response_method($e2)\n render :json => error\n end\n else\n Product.find_by_permalink!(params[:id])\n end\n end", "def show\n authenticate_rem\n follower = @current_user || User.find_by_id(params[:user_id])\n render json: Product.find(params[:id]).simple_info(follower), status: :ok\n end", "def show\n @pro_wmall_product = Wmall::Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @pro_wmall_product }\n end\n end", "def security_advisories_product_get_with_http_info(product, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: DefaultApi.security_advisories_product_get ...\"\n end\n # verify the required parameter 'product' is set\n if @api_client.config.client_side_validation && product.nil?\n fail ArgumentError, \"Missing the required parameter 'product' when calling DefaultApi.security_advisories_product_get\"\n end\n # resource path\n local_var_path = \"/security/advisories/product\"\n\n # query parameters\n query_params = {}\n query_params[:'product'] = product\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['psirt_openvuln_api_auth']\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: DefaultApi#security_advisories_product_get\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def show\n @product = Product.find(params[:id])\n\n @comment = Comment.find(:all, :conditions => {:product_id =>@product.id})\n @questions = Question.find(:all, :conditions => {:product_id =>@product.id})\n @answer = Answer.find(:all)\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def get_products\n products = response['products']\n products_ops = []\n products.each_value do |value|\n product = {}\n product[:sku] = value['sku']\n product[:product_family] = value['productFamily']\n product[:pricing_list_id] = pricing_list.id\n attributes = value['attributes']\n product[:service_code] = attributes['servicecode']\n product[:location] = attributes['location']\n product[:location_type] = attributes['locationType']\n product[:usage_type] = attributes['usagetype']\n product[:operation] = attributes['operation']\n product[:request_description] = attributes['requestDescription']\n product[:request_type] = attributes['requestType']\n product[:service_name] = attributes['servicename']\n product[:pricing_list_id] = pricing_list.id\n product[:created_at] = Time.zone.now.utc\n product[:updated_at] = Time.zone.now.utc\n products_ops << product\n end\n products_ops\n end", "def show\n @product = Product.find(params[:id])\n\n\n respond_to do |format|\n format.html # show.html.erb\n #format.json { respond_with @product.to_json(:method => ['color', 'size']) }\n format.json {render :json => @product.to_json(:methods => [:color, :size])}\n end\n end", "def show\n @product = Product.where([\"id = ?\", params[:id].to_i]).first\n raise NoProductError if @product.blank?\n\n @providers = @product.providers\n @product_contents = @product.contents\n\n @shop = @product.shop\n raise NoShopError if @shop.blank?\n \n @reviews = @product.reviews\n @review_images = @product.review_images\n \n @main_review = @reviews.first\n @main_image = @product.images.try(:first)\n @countries = Country.all\n\n add_breadcrumb \"#{@shop.name} - #{@product.name} 商品詳細\", product_path\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @ordered_product = OrderedProduct.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @ordered_product }\n end\n end", "def show\n @add_product = AddProduct.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @add_product }\n end\n end" ]
[ "0.7218091", "0.7158551", "0.70554394", "0.6978709", "0.6977609", "0.69348764", "0.6933271", "0.6928328", "0.6925765", "0.69160664", "0.6910675", "0.6902752", "0.68951666", "0.6875545", "0.6854568", "0.68179977", "0.6794714", "0.67926866", "0.6785334", "0.6773074", "0.67609227", "0.6725109", "0.6712539", "0.67035025", "0.6685933", "0.6672313", "0.66581655", "0.66486245", "0.6623348", "0.66175485", "0.6616506", "0.6616506", "0.6616506", "0.6616506", "0.6616506", "0.6616506", "0.6616506", "0.6616506", "0.6616506", "0.6616506", "0.6616506", "0.6616506", "0.6616506", "0.6616506", "0.6616506", "0.6616506", "0.6616506", "0.6616506", "0.6616506", "0.6616506", "0.66162235", "0.6611178", "0.6606406", "0.6600403", "0.6586658", "0.6584559", "0.6584559", "0.6584559", "0.6584055", "0.6581643", "0.6581214", "0.65747905", "0.6567376", "0.6564017", "0.6546664", "0.6534384", "0.6517622", "0.65118086", "0.6498065", "0.648871", "0.6470233", "0.6467172", "0.6463785", "0.645948", "0.64569336", "0.6444927", "0.64398324", "0.64202034", "0.6416484", "0.6416093", "0.6415987", "0.6415358", "0.64092916", "0.63950926", "0.6392743", "0.63912475", "0.6387728", "0.63873637", "0.63847023", "0.63828653", "0.63808423", "0.63737226", "0.6370302", "0.6354202", "0.63492566", "0.634577", "0.63401026", "0.6339255", "0.6332489", "0.6331193" ]
0.7594424
0
GET /requests/devolutions/products/details/new GET /requests/devolutions/products/details/new.json
def new @requests_devolutions_products_detail = Requests::Devolutions::Products::Detail.new respond_to do |format| end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @product = Product.new\n\n render json: @product\n end", "def new\n get_product\n @product_detail = @product.details.new\n end", "def new\n @product = ProductProduct.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @product }\n end\n end", "def new\n @product = Product.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @product }\n end\n end", "def new\n @product = Product.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @product }\n end\n end", "def new\n @product = Product.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @product }\n end\n end", "def new\n @product = Product.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @product }\n end\n end", "def new\n @product = Product.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @product }\n end\n end", "def new\n @product = Product.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @product }\n end\n end", "def new\n @product = Product.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @product }\n end\n end", "def new\n @product = Product.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @product }\n end\n end", "def new\n @product = Product.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @product }\n end\n end", "def new\n @product = Product.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @product }\n end\n end", "def new\n @product = Product.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @product }\n end\n end", "def new\n @product = Product.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @product }\n end\n end", "def new\n @product = Product.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @product }\n end\n end", "def new\n @product = Product.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @product }\n end\n end", "def new\n @product = Product.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @product }\n end\n end", "def new\n @product = Product.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @product }\n end\n end", "def new\n @product = Product.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @product }\n end\n end", "def new\n @product = Product.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @product }\n end\n end", "def new\n @product = Product.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @product }\n end\n end", "def new\n @product = Product.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @product }\n end\n end", "def new\n @product = Product.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @product }\n end\n end", "def new\n @product = Product.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @product }\n end\n end", "def new\n @product = Product.new\n \n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @product }\n end\n end", "def new\n @product = Product.new\n #@product = Product.find(params[:product_id])\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @product }\n end\n end", "def new\n @product = Product.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @product }\n end\n end", "def new\n @product = Product.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @product }\n end\n end", "def new\n @product = Product.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @product }\n end\n end", "def new\n @product = Product.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @product }\n end\n end", "def new\n @product = Product.find(params[:product_id])\n @purchase = Purchase.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @purchase }\n end\n end", "def new\n @product = Product.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json=> @product }\n end\n end", "def new\n @add_product = AddProduct.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @add_product }\n end\n end", "def new\n @prod = Prod.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @prod }\n end\n end", "def new\n @shopifyproduct = Shopifyproduct.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @shopifyproduct }\n end\n end", "def new\n @related_product = RelatedProduct.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @related_product }\n end\n end", "def new\n @onecompany_product = Onecompany::Product.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @onecompany_product }\n end\n end", "def new\n @magento_product = MagentoProduct.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @magento_product }\n end\n end", "def new\n @product2 = Product2.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @product2 }\n end\n end", "def new\n print params\n @product_sold = ProductSold.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @product_sold }\n end\n end", "def new\n @team_product_request = TeamProductRequest.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @team_product_request }\n end\n end", "def new\n @productiondetail = Productiondetail.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @productiondetail }\n end\n end", "def new\n @product_item = ProductItem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @product_item }\n end\n end", "def new\n @title = t('view.transfer_products.new_title')\n @transfer_product = TransferProduct.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @transfer_product }\n end\n end", "def new\n @product = Product.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @product }\n format.json { render :json => @product }\n end\n end", "def new\n flash[:notice]=\"\"\n @cities = City.all\n \n $product = Product.new\n $product.created_at=$product.format_admission_date\n $products=Array.new\n #Obtengo la lista de notas de retiro para mostrar en el autocom´ete\n #En la lista muestro todas las notas de retiro no procesadas cuya fecha sea hasta 31 dias antes de la fecha actual\n $retire_notes= RetireNote.find(:all, :conditions=> \"retire_note_state_id= 2 and date between current_date-31 and current_date\")\n $receivers = Receiver.find(:all)\n \n $addresses=Array.new\n $item = 1\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: $product }\n end\n end", "def new\n @store2product = Store2product.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @store2product }\n end\n end", "def new\n @product = Product.new\n @units = Unit.all\n @brands = Brand.all\n @categories = Category.all\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @product }\n end\n end", "def new\n @shop = Shop.where([\"id = ?\", params[:shop_id]]).first\n raise \"お探しのお店が見つかりません\" unless @shop.present?\n @product = Product.new\n @provider = Provider.new\n @product_types = ProductType.all\n @countries = Country.all\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @product }\n end\n end", "def new\n\t\t@product = Product.new\n\t\t@products = Product.all\n\t\t@attachment_file = AttachmentFile.new\n\t\t@action = 'create'\n\t\trespond_to do |format|\n\t\t format.html # new.html.erb\n\t\t format.json { render :json => @product }\n\t\tend\n end", "def new\n @supplier = Supplier.find(params[:supplier_id])\n @product = @supplier.products.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @product }\n end\n end", "def new\n @logical_product = LogicalProduct.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @logical_product }\n end\n end", "def new\n @product_line = ProductLine.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @product_line }\n end\n end", "def new\n @product_delivered = ProductDelivered.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @product_delivered }\n end\n end", "def new\n @producto = Producto.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @producto }\n end\n end", "def new\n @physical_data_product = PhysicalDataProduct.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @physical_data_product }\n end\n end", "def new\n @star_product = Star::Product.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @star_product }\n end\n end", "def new\n @producttype = Producttype.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @producttype }\n end\n end", "def create\n get_product\n @product_detail = @product.details.create(params[:product_detail])\n end", "def new\n @produto = Produto.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @produto }\n end\n end", "def new\n @product = Product.new\n @product.photos.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @product }\n end\n end", "def new\n @product_transaction = ProductTransaction.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @product_transaction }\n end\n end", "def new\n @productonegocio = Productonegocio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @productonegocio }\n end\n end", "def new\n @datasources_product = DatasourcesProduct.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @datasources_product }\n end\n end", "def new\n @product = Product.new\n @categories = Category.find(:all)\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @product }\n end\n end", "def new\n @product = Product.new\n\n respond_with @product\n end", "def new\n @product_cost = ProductCost.new\n\t@products = Product.find_all\n\t@tax_masters = TaxMaster.find_all\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @product_cost }\n end\n end", "def new\n @size_to_product = SizeToProduct.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @size_to_product }\n end\n end", "def new\n @product = Product.new\n respond_with @product\n end", "def new\n @product_storage = ProductStorage.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @product_storage }\n end\n end", "def new\n @product = Product.new\n redirect_to @product\n\n # respond_to do |format|\n # format.html # new.html.erb\n # format.json { render json: @product }\n # end\n end", "def new\n @p_detail = PDetail.new\n @products = Product.all\n @product_types = ProductType.all\n if session[:created_purchase] == nil\n @purchase = Purchase.new\n @purchase.date = Time.now\n @purchase.save\n session[:purchase_id] = @purchase.id\n session[:created_purchase] = \"true\"\n end\n @p_details = PDetail.where(:purchase_id => session[:purchase_id]).order(\"created_at DESC\")\n \n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @p_detail }\n end\n end", "def new\n @tipo_product = TipoProduct.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tipo_product }\n end\n end", "def new\n @pro_wmall_product = Wmall::Product.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @pro_wmall_product }\n end\n end", "def new\n default_data\n @product = Product.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @product }\n end\n end", "def new\n @product = Product.find(params[:product_id])\n @goal = Goal.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @goal }\n end\n end", "def new\n @requests_devolutions_product = Requests::Devolutions::Product.new\n @hide_status_select = true\n respond_to do |format|\n format.js # new.html.erb\n end\n end", "def new\n @product_price = ProductPrice.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @product_price }\n end\n end", "def new\n @purchase = Purchase.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @purchase }\n end\n end", "def new\n @purchase = Purchase.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @purchase }\n end\n end", "def new\n @purchase = Purchase.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @purchase }\n end\n end", "def new\n @productsbind = Productsbind.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @productsbind }\n end\n end", "def new\n @product = Product.init.with_user(current_user.id).first || Product.new\n @product.user = current_user\n @product.force_save\n\n return redirect_to(edit_product_path(@product))\n\n @page_title = \"Sell your product\"\n @product = Product.new\n @tags = Tag.main.with_children.all\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @product }\n end\n end", "def new\n @zorgproduct = Zorgproduct.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @zorgproduct }\n end\n end", "def new\n @carts_product = @cart.carts_products.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @carts_product }\n end\n end", "def new\n @venue_product = VenueProduct.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @venue_product }\n end\n end", "def new\n @product_subscription = ProductSubscription.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @product_subscription }\n end\n end", "def new\n if params[:product_id]\n @badge.product = Product.find(params[:product_id])\n end\n respond_to do |format|\n format.html { render_template } # new.html.erb\n format.xml { render xml: @badge }\n end\n end", "def new\n @requests_transferences_product = Requests::Transferences::Product.find(params[\"header_id\"])\n @requests_transferences_products_detail = Requests::Transferences::Products::Detail.new\n @requests_transferences_products_details = @requests_transferences_product.details.paginate(:page => params[:page])\n respond_to do |format|\n format.js{ render 'update_list_form' }\n end\n end", "def new\n @invoice = Invoice.new\n @invoice.products_invoice.build\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @invoice }\n end\n end", "def new\n @product = Product.new\n 5.times { @product.photos.build }\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @product }\n end \n end", "def new\n @product_cat = ProductCat.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @product_cat }\n end\n end", "def new\n @breadcrumb = 'create'\n @product = $product\n @supplier = $supplier\n @purchase_price = PurchasePrice.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @purchase_price }\n end\n end", "def new\n @product = Product.new\n @shop = current_user.shops.find_by_uuid(params[:shop_id])\n @product.product_variants.build\n\n respond_to do |format|\n format.html\n format.json { render json: @product}\n end\n end", "def new\n @product = Product.new\n @product.photos.build\n @listings = Product.order.product_order\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @product }\n end\n end", "def new\n @product_import = ProductImport.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @product_import }\n end\n end", "def new\n @product = Product.new\n @product.product_base_id = params[:product_basis_id]\n\n respond_to do |format|\n if params[:product_basis_id]\n format.html # new.html.erb\n format.json { render json: @product }\n else\n flash[:warn] = \"Escolha o produto base para criar um novo produto!\"\n format.html { redirect_to product_bases_path }# new.html.erb\n format.json { render json: @product }\n end\n end\n end", "def new\n @product_owner = ProductOwner.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @product_owner }\n end\n end", "def new\n @product_maintenance = ProductMaintenance.new\n @categories = Category.all\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @product_maintenance }\n end\n end" ]
[ "0.7427585", "0.73749167", "0.7350126", "0.730964", "0.730964", "0.730964", "0.730964", "0.730964", "0.730964", "0.730964", "0.730964", "0.730964", "0.730964", "0.730964", "0.730964", "0.730964", "0.730964", "0.730964", "0.730964", "0.730964", "0.730964", "0.730964", "0.730964", "0.730964", "0.7309291", "0.73023933", "0.7275473", "0.725396", "0.725396", "0.725396", "0.725396", "0.72444236", "0.72365975", "0.72297275", "0.7170809", "0.71522236", "0.7138595", "0.70639294", "0.7047011", "0.7043783", "0.70409125", "0.704009", "0.70282096", "0.70100105", "0.700712", "0.6993063", "0.69927996", "0.69723815", "0.6970679", "0.6968483", "0.6951821", "0.6926853", "0.6917844", "0.69161886", "0.691314", "0.69131005", "0.6896385", "0.68936795", "0.6888207", "0.6887708", "0.6883733", "0.68828744", "0.68792766", "0.6877594", "0.687695", "0.6857835", "0.6849593", "0.68487287", "0.6839752", "0.68378085", "0.6831203", "0.6826115", "0.6819748", "0.68180543", "0.67896736", "0.67842466", "0.6781739", "0.67640543", "0.6753653", "0.6742464", "0.6742464", "0.6742464", "0.6737364", "0.6732697", "0.6718725", "0.6714786", "0.6714026", "0.67102647", "0.6700772", "0.6698832", "0.66961575", "0.66942203", "0.6691323", "0.6688172", "0.6687914", "0.66821903", "0.6681802", "0.6681221", "0.66795605", "0.666942" ]
0.7500732
0
POST /requests/devolutions/products/details POST /requests/devolutions/products/details.json
def create @requests_devolutions_products_detail = Requests::Devolutions::Products::Detail.new(params[:requests_devolutions_products_detail]) @requests_devolutions_products_detail.requests_devolutions_product = Requests::Devolutions::Product.find(params["header_id"]) @requests_devolutions_products_details = @requests_devolutions_products_detail.requests_devolutions_product.details.paginate(:page => params[:page]) respond_to do |format| if @requests_devolutions_products_detail.save format.js{ @requests_devolutions_product = @requests_devolutions_products_detail.requests_devolutions_product #@orders_productions_details = @production.details @requests_devolutions_products_detail = Requests::Devolutions::Products::Detail.new render 'update_list_form' } else format.html { @notice = 'Error al guardar el registro.'; redirect_to :back } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @requests_devolutions_products_detail = Requests::Devolutions::Products::Detail.new\n respond_to do |format|\n end\n end", "def create\n get_product\n @product_detail = @product.details.create(params[:product_detail])\n end", "def create\n\n product_details = params.permit(:title, :inventory_count, :price)\n success = Product.create(product_details)\n\n render json: { success: success }\n end", "def show\n @requests_devolutions_products_detail = Requests::Devolutions::Products::Detail.find(params[:id])\n respond_to do |format|\n format.html\n end\n end", "def create\n @requests_transferences_products_detail = Requests::Transferences::Products::Detail.new(params[:requests_transferences_products_detail])\n @requests_transferences_products_detail.requests_transferences_product = Requests::Transferences::Product.find(params[\"header_id\"])\n @requests_transferences_products_details = @requests_transferences_products_detail.requests_transferences_product.details.paginate(:page => params[:page])\n respond_to do |format|\n if @requests_transferences_products_detail.save\n format.js{ \n @requests_transferences_product = @requests_transferences_products_detail.requests_transferences_product\n #@orders_productions_details = @production.details\n @requests_transferences_products_detail = Requests::Transferences::Products::Detail.new\n render 'update_list_form' \n }\n else\n format.html { @notice = 'Error al guardar el registro.'; redirect_to :back }\n end\n end\n end", "def product_info\n params['productinfo']\n end", "def view_product\n to_json(\n only: [:id, :title, :description, :key_information],\n methods: [:photo_url, :net_mrp, :mrp_per_unit, :quantity],\n :include => {\n store: {\n only: [:name, :id],\n methods: [:full_address]\n }\n }\n )\n end", "def create\n @product = Product.new(params[:product])\n @product.shop = Shop.find_by_uuid params[:shop_id]\n\n respond_to do |format|\n if @product.save!\n format.html { redirect_to shop_products_path(@product.shop.uuid), notice: 'Product was successfully created.' }\n format.json { render json: @product.to_json(:include => {:product_variants => {:include => [:option_types,:pictures]}})}\n else\n format.html { render action: \"new\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def product_info\n params['productinfo']\n end", "def update_products_details; end", "def create\n @requests_devolutions_product = Requests::Devolutions::Product.new(params[:requests_devolutions_product])\n @requests_devolutions_product.status = @default_status\n @requests_devolutions_product.user = current_user\n respond_to do |format|\n if @requests_devolutions_product.save\n format.js { render action: 'show' }\n else\n format.js {\n render action: \"new\"}\n end\n end\n end", "def create\n @admin_product_detail = ProductDetail.new(admin_product_detail_params)\n\n respond_to do |format|\n if @admin_product_detail.save\n format.html { redirect_to @admin_product_detail, notice: 'Product detail was successfully created.' }\n format.json { render :show, status: :created, location: @admin_product_detail }\n else\n format.html { render :new }\n format.json { render json: @admin_product_detail.errors, status: :unprocessable_entity }\n end\n end\n end", "def product_params\n params.require(:product).permit(:name, :details)\n end", "def product_detail_params\n params.require(:product_detail).permit(:product_variant_id, :variant_value_id)\n end", "def new\n get_product\n @product_detail = @product.details.new\n end", "def details\n data = Storm::Base::SODServer.remote_call '/Product/details',\n :code => @code\n self.from_hash data\n end", "def show\n @requests_transferences_products_detail = Requests::Transferences::Products::Detail.find(params[:id])\n respond_to do |format|\n format.html\n end\n end", "def create\n newProduct = Product.new(products_params)\n if newProduct.save\n msg = { status: 201 , product: newProduct }\n respond_to do |format|\n format.html { render json: msg }\n format.json { render json: msg }\n end\n else\n msg = { status: 422 }\n respond_to do |format|\n format.html { render json: msg }\n format.json { render json: msg }\n end\n end\n end", "def create\n @info_product = InfoProduct.new(info_product_params)\n\n respond_to do |format|\n if @info_product.save\n format.html { redirect_to @info_product, notice: 'Info product was successfully created.' }\n format.json { render action: 'show', status: :created, location: @info_product }\n else\n format.html { render action: 'new' }\n format.json { render json: @info_product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = @collection.products.build(product_params)\n\n if @product.save\n render json: @product, status: :created#, location: @collection\n else\n render json: @product.errors, status: :unprocessable_entity\n end\n end", "def new\n @requests_transferences_product = Requests::Transferences::Product.find(params[\"header_id\"])\n @requests_transferences_products_detail = Requests::Transferences::Products::Detail.new\n @requests_transferences_products_details = @requests_transferences_product.details.paginate(:page => params[:page])\n respond_to do |format|\n format.js{ render 'update_list_form' }\n end\n end", "def details(options = {})\n if @existing_options == options\n @response\n else\n @existing_options = options\n response = SageWorld::Client.new(find_product_params(@product_id ,options)).send_request\n @response = SageWorld::ResponseHandler.new(response)\n end\n end", "def create\n @product = Product.new(product_params)\n @product.user = current_api_v1_user\n respond_to do |format|\n if @product.save\n params[:product][:properties].try(:each) do |k,v|\n @product.product_properties.create(property: Property.find(k), value: v)\n end\n params[:product][:colors].try(:each) do |c|\n @product.colors.create(name: c[:name].downcase, code: c[:code])\n end\n params[:product][:photos].try(:each) do |c|\n @product.photos.create(image: c)\n end\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created}\n else\n format.html { render :new }\n format.json { render json: @product.errors.full_messages, status: :unprocessable_entity }\n end\n end\n end", "def show\n # @ccbs_product = CcbsProduct.find(params[:id])\n\n prd_attribute = PrdAttribute.find(params[:id], :include => :products)\n product = Product.find(prd_attribute.products[0].id, :include => [:prd_subscriptions, :prd_additional_services])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @ccbs_product }\n format.json {\n\n ccbs_product = CcbsProduct.new\n tariff_list = ccbs_product.set_fields(prd_attribute, product.prd_subscriptions, product.prd_additional_services)\n\n # product에 대해 전달\n results = mapping_to_hash(ccbs_product,CcbsProduct.json_mapping_table)\n ccbs_product.send_to_ccbs('POST', results.to_json)\n\n # tariff에 대해서 전달\n tariff_list.each { |product_tariff| \n to_ccbs_hash = mapping_to_hash(product_tariff, CcbsProductTariff.json_mapping_table)\n product_tariff.send_to_ccbs(\"POST\", to_ccbs_hash.to_json) }\n\n render :json => results\n } \n end\n end", "def show\n @requests_devolutions_product = Requests::Devolutions::Product.find(params[:id])\n respond_to do |format|\n format.js\n end\n end", "def show\n json_response(@api_v1_product)\n end", "def new\n @product = Product.find(params[:product_id])\n @purchase = Purchase.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @purchase }\n end\n end", "def create\n @product = Product.new(product_params)\n\n if @product.save\n render json: @product, status: :created, location: @product\n else\n render json: @product.errors, status: :unprocessable_entity\n end\n end", "def new\n @product = Product.new\n @shop = current_user.shops.find_by_uuid(params[:shop_id])\n @product.product_variants.build\n\n respond_to do |format|\n format.html\n format.json { render json: @product}\n end\n end", "def product_detail_params\n params.require(:product_detail).permit(:model_id, :product_id, :price, :shoping_card_id)\n end", "def create\n @product = Product.new(product_params)\n if @product.save\n render json: {id: @product.id}\n else\n render json: {msg: @product.errors.full_messages.first}, status: :unprocessable_entity\n end\n end", "def show\n render json: @product_management\n end", "def create\n @product_management = ProductManagement.new(product_management_params)\n\n if @product_management.save\n render json: @product_management, status: :created, location: @product_management\n else\n render json: @product_management.errors, status: :unprocessable_entity\n end\n end", "def product_details\n if macys?\n color_size = product_color_size.match(/Color: (.*), Size: (.*)/)\n raise \"Unable to parse color and size from '#{product_color_size}'.\" if color_size.nil?\n product_info = {\n 'title' => product_title,\n 'color' => color_size[1],\n 'size' => color_size[2],\n }\n else\n product_info = {\n 'title' => product_title,\n 'color' => product_color,\n 'size' => product_size.sub('Size: ', ''),\n 'id' => product_id.sub('Web ID: ', ''),\n 'price' => Currency.parse(product_price.sub('PRICE: ', '')).last,\n }\n end\n product_info\n end", "def show\n render json: @product, status: 200\n end", "def product_params\n params.require(:product).permit(\n :id,\n :name,\n :brand,\n :description,\n :status,\n :user_id,\n :price,\n :usd_price,\n :cad_price,\n :currency,\n :created_at,\n :updated_at,\n :photo,\n :size_details,\n :shipping_charge,\n :product_return_policy,\n :category_id,\n :cad_domestic_shipping,\n :cad_foreign_shipping,\n :usd_domestic_shipping,\n :usd_foreign_shipping,\n :factory_sku,\n :units_attributes => [\n :id,\n :product_id,\n :size,\n :quantity,\n :quantity_sold,\n :colour,\n :_destroy\n ],\n :order_ids => [],\n :country_ids => [],\n :productfotos_attributes => [\n :id,\n :product_id,\n :foto,\n :_destroy\n ],\n :features_attributes => [\n :id,\n :name,\n :description,\n :_destroy\n ]\n )\n end", "def create\n @detail = Detail.new(detail_params)\n @detail.product_id = params[:product_id]\n \n if @detail.save\n flash[:success] = 'Detalle de Producto agregado exitosamente. '\n redirect_to product_path(params[:product_id])\n else\n flash[:error] = \"Something went wrong\"\n redirect_to product_path(params[:product_id])\n end\n end", "def create\n @product = Product.new(product_params)\n\n if @product.save\n render json: @product, status: :created\n else\n render json: @product.errors, status: :unprocessable_entity\n end\n end", "def create\n if @product.save\n render :show, status: :created, location: api_v1_product_path(@product)\n else\n render json: @product.errors, status: :unprocessable_entity\n end\n end", "def create\n @product = Product.new(product_args)\n\n if @product.save\n render json: Product.all, status: :created\n else\n render json: @product.errors, status: :unprocessable_entity\n end\n end", "def new\n @product_detail = ProductDetail.new\n \n # support for user contribute organization role and name\n 1.times do \n @product_detail.product_detail_organizations.build\n end\n \n # support for user contribute key/value pair entries\n 3.times do \n @product_detail.product_detail_entries.build\n end\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @product_detail }\n end\n end", "def new\n @supplier = Supplier.find(params[:supplier_id])\n @product = @supplier.products.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @product }\n end\n end", "def create\n if params[:products]\n params[:products].each do |product|\n @product = Product.new(name: product[:name],\n brand: product[:brand],\n model: product[:model],\n sku: product[:sku],\n price: product[:price],\n desc: product[:desc])\n if !@product.save\n render json: @product.errors.full_messages, status: 422\n end\n end\n render 'api/products/index'\n else\n @product = Product.new(product_params)\n if @product.save\n render 'api/products/show'\n else\n render json: @product.errors.full_messages, status: 422\n end\n end\n end", "def create\n @product = Product.new(product_params)\n\n #permitted_columns = params[:products_purposes_relations].permit(:product_id, :purpose_id, :stars)\n # @products_purposes_relation = @product.products_purposes_relations.create(permitted_columns)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: t('create_success') }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n \n end", "def create\n @product = Product.create!(product_params)\n json_response(@product, :created)\n end", "def product_params\n params.fetch(:product, {}).permit(\n :code, :name, :short_name,\n :price, :cost, :on_hand, :weight, :volume, :unit_id,\n :product_type_id, :brand_id, :product_model_id, \n :model_from_year, :model_to_year,\n :length, :width, :thickness, :tinting,\n # frontend\n :product_intro_link, :short_description,\n :is_call, :is_bestseller, :is_sold_out, :is_new,\n :is_deal, :deal_price, :deal_percent, :deal_from_date, :deal_to_date, \n :meta_keywords, :meta_description, :published,\n # end frontend\n :stock_min, :stock_max, :description, :description_2, :internal_note, :point_enabled, :category_id,\n customer_tax_ids: [], vendor_tax_ids: [],\n :product_images_attributes => [ :id, :image_url, :image_url_cache, :product_id, :description, :is_main, :_destroy ],\n :products_units_attributes => [ :id, :unit_id, :conversion_value, :price, :code, :product_id, :_destroy ],\n :products_parts_attributes => [ :id, :part_id, :quantity, :total, :product_id, :_destroy ],\n :products_gifts_attributes => [ :id, :gift_id, :quantity, :price, :product_id, :_destroy ]\n )\n end", "def new\n @shopifyproduct = Shopifyproduct.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @shopifyproduct }\n end\n end", "def new\n @product = Product.new\n @product.photos.build\n @listings = Product.order.product_order\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @product }\n end\n end", "def send_product(product)\n request(product, \"product\", :post, {method: \"add\"})\n end", "def create\n @product = Product.new(params[:product])\n\n if @product.save\n \n respond_with(@product, :location=>products_url)\n else\n respond_with(@product, :head=>:bad_request)\n end\n end", "def create\n @product = @productable.products.find(params[:product_id])\n ids = params[:products]\n reals = @productable.products.map(&:id) # Make a lambda with this\n present_prod = ids.select { |n| reals.include?(n) } # And this\n if @product.update(product_relations: present_prod)\n render json: @product, status: 200\n else\n render json: @product.errors, status: 422\n end\n end", "def new\n @product = Product.new\n @units = Unit.all\n @brands = Brand.all\n @categories = Category.all\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @product }\n end\n end", "def new\n @product = Product.new\n\n render json: @product\n end", "def product_params\n params.require(:product).permit(:title, :description, :image_url, :price, :detail_text_1, :detail_image_url_1, :detail_text_2, :detail_image_url_2, :detail_text_3, :detail_image_url_3, :detail_text_4, :detail_image_url_4, :detail_text_5, :detail_image_url_5, :detail_text_6, :detail_image_url_6, :detail_text_7, :detail_image_url_7, :detail_text_8, :detail_image_url_8, :detail_text_9, :detail_image_url_9, :detail_text_10, :detail_image_url_10,:detail_text_11, :detail_image_url_11, :detail_text_12, :detail_image_url_12, :detail_text_13, :detail_image_url_13, :detail_text_14, :detail_image_url_14, :detail_text_15, :detail_image_url_15)\n end", "def show\n @products = Product.find_by_id(params[:id])\n msg = { status: 200 , product: @products }\n respond_to do |format|\n format.html { render json: msg }\n format.json { render json: msg }\n end\n end", "def new\n @deal = Deal.find(params[:deal_id]) \n\n token_pipedrive = \"api_token=57f839e9a500cf2ef6b9dc8b156bce2c09a0905d\"\n uri_pipedrive_prod = \"http://api.pipedrive.com/v1/deals/#{@deal.pipedrive_id}/products?start=0&#{token_pipedrive}\"\n\n respprod = Net::HTTP.get_response(URI.parse(uri_pipedrive_prod))\n parsedprod = JSON.parse(respprod.body)\n\n parsedprod[\"data\"].each do |registro|\n @item = @deal.items.build\n @item.unique_id = registro[\"id\"]\n @item.pipe_deal_id = registro[\"deal_id\"]\n @item.order_nr = registro[\"order_nr\"]\n @item.product_id = registro[\"product_id\"]\n @item.item_price = registro[\"item_price\"]\n @item.sum = registro[\"sum\"]\n @item.currency = registro[\"currency\"]\n @item.name = registro[\"name\"]\n @item.quantity = registro[\"quantity\"]\n\n uritpprod = \"http://api.pipedrive.com/v1/products/#{registro[\"product_id\"]}?#{token_pipedrive}\"\n resptpprod = Net::HTTP.get_response(URI.parse(uritpprod))\n parsedtpprod = JSON.parse(resptpprod.body)\n \n @item.product_code = parsedtpprod[\"data\"][\"code\"]\n @item.save\n end\n\n redirect_to :action => :index\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 @physical_data_product = PhysicalDataProduct.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @physical_data_product }\n end\n end", "def show\n render json: @product\n end", "def product_params\n params.require(:product).permit(:title, :body_html, :image, :price, :product_type, :compare_at_price, :cost, :sku, :barcode,:tracked, :available,:quantity, :incoming, :continue_selling, :weight, :weight_unit, :countries, :inventory_quantity, :inventory_item_id, :inventory_management, :inventory_policy, :requires_shipping, :fulfillment_service, :location_id, :location, :vendor)\n end", "def create\n @product_target = ProductTarget.new(product_target_params)\n @product_target.shop = @shop.id\n\n respond_to do |format|\n if @product_target.save\n format.html { redirect_to @product_target, notice: 'Product target was successfully created.' }\n format.json { render :show, status: :created, location: @product_target }\n else\n format.html { render :new }\n format.json { render json: @product_target.errors, status: :unprocessable_entity }\n end\n end\n end", "def add_product\n @product = Spree::Product.find(params[:product_id])\n\n puts (\"WTTTTFFFFFFFFFFF\")\n puts @product.inspect\n respond_to do |format|\n format.js {}\n end\n\n\n end", "def create\n @product = current_vendor.vendor_products.new(vendor_product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to vendor_products_url, notice: 'product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def show\n render json: @product_buy_click\n end", "def get_products\n products = response['products']\n products_ops = []\n products.each_value do |value|\n product = {}\n product[:sku] = value['sku']\n product[:product_family] = value['productFamily']\n product[:pricing_list_id] = pricing_list.id\n attributes = value['attributes']\n product[:service_code] = attributes['servicecode']\n product[:location] = attributes['location']\n product[:location_type] = attributes['locationType']\n product[:usage_type] = attributes['usagetype']\n product[:operation] = attributes['operation']\n product[:request_description] = attributes['requestDescription']\n product[:request_type] = attributes['requestType']\n product[:service_name] = attributes['servicename']\n product[:pricing_list_id] = pricing_list.id\n product[:created_at] = Time.zone.now.utc\n product[:updated_at] = Time.zone.now.utc\n products_ops << product\n end\n products_ops\n end", "def create\n @product = Product.new(product_params)\n\n if @product.save\n render json: @product, status: :created, location: @product\n else\n render json: @product.errors, status: :unprocessable_entity\n end\n end", "def product_params\n params.require(:product).permit(:name, :product_type, :product_subtype, :vintage, :country, :region, :brand_id, :user_id, :image, :remote_image_url, :appellation, :vineyard, :grape_varietals, :clones, :soil, :plot_characteristics, :yield, :vineyard_practices, :harvest, :yeast, :accolades, :producer, :bottle_size, :vinification_methods, :description, :shelf_talker, :tech_sheet, :case_card)\n end", "def show\n result = Product.find(params[:id])\n render json: {\n status: :ok,\n product: result\n } \n end", "def update\n product = Product.find(params[:id])\n product_details = params.permit(:title, :inventory_count, :price)\n\n product.update(product_details)\n\n render json: product\n end", "def show\n @product = Product.find(params[:id])\n @donor = Donor.all\n @event = Event.all\n @category = Category.all\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n \n end", "def create\n\n print params['details[color]']\n @product = Product.new(product_params)\n @root_categories = Category.roots\n if @product.save\n respond_to do |format|\n if @product.save\n (params[:product_images]['image']).each do |img|\n @product_images = @product.product_images.create!(:image => img,:product_id => @product.id)\n end\n\n (params[:detail]['color']).each do |c|\n @product_colors = ColorProduct.create!(:product_id => @product.id, :color_id => c)\n end\n\n (params[:detail]['size']).each do |s|\n @product_colors = SizeProduct.create!(:product_id => @product.id, :size_id => s)\n end\n format.html { redirect_to @product, notice: \"Product was successfully created.\" }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n else\n render action: :new\n end\n end", "def show\n @product = Product.find(params[:id])\n json_response(params)\n end", "def product(name)\n get(\"/apiproducts/#{name}\")\n end", "def show\n @product = Product.eager_loading.find_by_uuid(params[:id])\n\n respond_to do |format|\n format.html { redirect_to edit_shop_product_path(@product.shop_id, @product)}\n format.json { render json: @product.as_json(:include => {:product_variants => {:include => [:option_types,:pictures]}, :shipping_category => {}}, :methods => [:taxon_ids]) }\n end\n end", "def show\n render json: @product\n end", "def create\n product = Product.find(params[:product_id])\n @product_to_tracker = @tracker.product_to_trackers.build(product: product)\n\n respond_to do |format|\n if @product_to_tracker.save\n format.html { redirect_to @product_to_tracker.tracker, notice: t('.sucessfull_notice') }\n format.json { render :show, status: :created, location: @product_to_tracker }\n format.js { flash[:notice] = t('.sucessfull_notice')}\n else\n format.html { render :new }\n format.js { flash[:notice] = t('.unsucessfull_notice')}\n format.json { render json: @product_to_tracker.errors, status: :unprocessable_entity }\n end\n end\n end", "def product_params\n params.require(:product).permit(:name, :soil, :utilization, :active, :photo, :description, :cycle_id, :purpose_ids =>[], :products_purposes_relation_ids =>[], :cultivation_ids =>[])\n end", "def new\n @product = ProductProduct.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @product }\n end\n end", "def post_to_newgistics\n document = Spree::Newgistics::DocumentBuilder.build_product([self])\n response = Spree::Newgistics::HTTPManager.post('/post_products.aspx', document)\n\n if response.status == 200\n errors = Nokogiri::XML(response.body).css('errors').children.any?\n update_column(:posted_to_newgistics, true) unless errors\n end\n\n end", "def new\n # @product = Product.new\n\n @farm = Farm.find(params[:farm_id]) \n @products = @farm.products.build \n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @product }\n end\n end", "def omega\n products = GetProducts.new.send_request\n SaveProducts.new(products[:productRecords]).save\n end", "def new\n flash[:notice]=\"\"\n @cities = City.all\n \n $product = Product.new\n $product.created_at=$product.format_admission_date\n $products=Array.new\n #Obtengo la lista de notas de retiro para mostrar en el autocom´ete\n #En la lista muestro todas las notas de retiro no procesadas cuya fecha sea hasta 31 dias antes de la fecha actual\n $retire_notes= RetireNote.find(:all, :conditions=> \"retire_note_state_id= 2 and date between current_date-31 and current_date\")\n $receivers = Receiver.find(:all)\n \n $addresses=Array.new\n $item = 1\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: $product }\n end\n end", "def create\n @product = Product.new(product_params)\n\n if @product.save\n render json: @product, status: :created\n else\n render json: @product.errors, status: :unprocessable_entity\n end\n end", "def new\n @requests_devolutions_product = Requests::Devolutions::Product.new\n @hide_status_select = true\n respond_to do |format|\n format.js # new.html.erb\n end\n end", "def new\n @product = Product.new\n #@product = Product.find(params[:product_id])\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @product }\n end\n end", "def product_params\n params.require(:product).permit(:title, :status, :special, :key_code, :brand, :category_id, :stock, :price, :currency, :width_mm, :height_mm, :depth_mm, :description, :characteristics, :data_sheet, :data_sheet_file, :information, :external_link, :slug)\n end", "def product_detail_params\n #params.fetch(:product_detail, {})\n params.require(:product_detail).permit(:product_name,:product_code,:grade,:formula,:molar_mass,{product_images: []}, product_pricings_attributes: [:pakaging, :price])\n end", "def show\n @product = Product.find(params[:id])\n @line_item = LineItem.create!\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def update\n @requests_devolutions_products_detail = Requests::Devolutions::Products::Detail.find(params[:id])\n @requests_devolutions_product = @requests_devolutions_products_detail.requests_devolutions_product;\n @requests_devolutions_products_details = @requests_devolutions_product.details.paginate(:page => params[:page])\n respond_to do |format|\n if @requests_devolutions_products_detail.update_attributes(params[:requests_devolutions_products_detail])\n format.js{ \n @requests_devolutions_products_detail = Requests::Devolutions::Products::Detail.new\n render 'update_list_form' \n }\n else\n format.html { \n @notice = \"Error al actualizar el registro\"\n redirect_to :back }\n end\n end\n end", "def new\n @p_detail = PDetail.new\n @products = Product.all\n @product_types = ProductType.all\n if session[:created_purchase] == nil\n @purchase = Purchase.new\n @purchase.date = Time.now\n @purchase.save\n session[:purchase_id] = @purchase.id\n session[:created_purchase] = \"true\"\n end\n @p_details = PDetail.where(:purchase_id => session[:purchase_id]).order(\"created_at DESC\")\n \n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @p_detail }\n end\n end", "def create\n @record = Product.new(params[:product])\n @record.save!\n respond_to do |format| \n format.html { head :no_content}\n format.json { render json: {} }\n end\n end", "def product_params\r\n params.require(:product).permit(:code, :name, :barcode, :price_in, :price_out, :section_id, :unit_id, :refill, :unit_refill_id, :service, :discount_value, :tax, :note)\r\n end", "def product_params\n params.require(:product).permit(:name, :sub_category_id, :user_id, :availablity, :price, :condition, :description, :specification, :sku, :details, :photos, :colors, :properties)\n end", "def info_product_params\n params.require(:info_product).permit(:title, :description, :image_id, :price)\n end", "def create\n @shopifyproduct = Shopifyproduct.new(params[:shopifyproduct])\n\n respond_to do |format|\n if @shopifyproduct.save\n format.html { redirect_to @shopifyproduct, notice: 'Shopifyproduct was successfully created.' }\n format.json { render json: @shopifyproduct, status: :created, location: @shopifyproduct }\n else\n format.html { render action: \"new\" }\n format.json { render json: @shopifyproduct.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product_spec = ProductSpec.new(product_spec_params)\n\n respond_to do |format|\n if @product_spec.save\n format.html { redirect_to @product_spec, notice: 'Product spec was successfully created.' }\n format.json { render :show, status: :created, location: @product_spec }\n else\n format.html { render :new }\n format.json { render json: @product_spec.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @product = Product.new\n \n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @product }\n end\n end", "def create\n @product_maintenance = ProductMaintenance.new(params[:product_maintenance])\n @so_detail = SoDetail.new(params[:so_detail])\n\n respond_to do |format|\n if @product_maintenance.save\n format.html { redirect_to product_maintenances_path, notice: 'Product successfully added!' }\n format.json { render json: @product_maintenance, status: :created, location: @product_maintenance }\n else\n format.html { render action: \"new\" }\n format.json { render json: @product_maintenance.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @onecompany_product = Onecompany::Product.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @onecompany_product }\n end\n end", "def create\n ActiveRecord::Base.transaction do\n begin\n @api_v1_product = Product.create!(api_v1_product_params)\n\n json_response @api_v1_product, :created\n rescue => ex\n json_response({error: ex.message}, :unprocessable_entity)\n raise ActiveRecord::Rollback\n end\n end\n end" ]
[ "0.71484536", "0.69727653", "0.6856084", "0.6842989", "0.6611098", "0.65442276", "0.6543582", "0.6534524", "0.6507852", "0.65026474", "0.65018326", "0.64723074", "0.64519846", "0.64393574", "0.6437788", "0.6427423", "0.63870835", "0.63652235", "0.63645047", "0.6362649", "0.6337613", "0.6330358", "0.63302", "0.63271713", "0.63043505", "0.62948316", "0.6282686", "0.6279375", "0.6276426", "0.62723416", "0.62589085", "0.62566954", "0.62543166", "0.62499815", "0.62457865", "0.62379265", "0.62341917", "0.62236565", "0.6215373", "0.6203745", "0.61995745", "0.6197811", "0.61961037", "0.6187463", "0.61837083", "0.61760074", "0.6173979", "0.6170365", "0.6154996", "0.61477983", "0.61406654", "0.61402255", "0.6140002", "0.613984", "0.6135254", "0.6122945", "0.61165667", "0.61159414", "0.6107777", "0.6095349", "0.609438", "0.6093243", "0.6091605", "0.60877997", "0.6087554", "0.6083682", "0.60806394", "0.6075964", "0.6073053", "0.6061772", "0.6057806", "0.6052421", "0.6044676", "0.60403144", "0.6036175", "0.6035205", "0.6034462", "0.6027356", "0.6027235", "0.60193557", "0.6016983", "0.60168403", "0.6016811", "0.6015709", "0.60054845", "0.6003441", "0.5997738", "0.59940445", "0.5993321", "0.599034", "0.5989755", "0.59827775", "0.5981784", "0.5974533", "0.5969924", "0.59534717", "0.5952726", "0.5947312", "0.5946284", "0.5946279" ]
0.68423057
4
PUT /requests/devolutions/products/details/1 PUT /requests/devolutions/products/details/1.json
def update @requests_devolutions_products_detail = Requests::Devolutions::Products::Detail.find(params[:id]) @requests_devolutions_product = @requests_devolutions_products_detail.requests_devolutions_product; @requests_devolutions_products_details = @requests_devolutions_product.details.paginate(:page => params[:page]) respond_to do |format| if @requests_devolutions_products_detail.update_attributes(params[:requests_devolutions_products_detail]) format.js{ @requests_devolutions_products_detail = Requests::Devolutions::Products::Detail.new render 'update_list_form' } else format.html { @notice = "Error al actualizar el registro" redirect_to :back } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n product = Product.find(params[:id])\n product_details = params.permit(:title, :inventory_count, :price)\n\n product.update(product_details)\n\n render json: product\n end", "def update_products_details; end", "def update\n begin\n @api_v1_product.update!(api_v1_product_params)\n head :no_content\n rescue => ex\n json_response({error: ex.message}, :unprocessable_entity)\n end\n end", "def update\n get_product\n @product_detail = @product.details.find(params[:id])\n @product_detail.update_attributes(params[:product_detail])\n end", "def update\n return unless product_params\n render json: @product.simple_info, status: :ok if @product.update!(@product_params)\n rescue => e\n render json: { error: e }, status: :ok\n end", "def update\n if @product.update(product_params)\n render json: @product, status: :ok#, location: @collection\n else\n render json: @product.errors, status: :unprocessable_entity\n end\n end", "def update\n updateProduct = Product.find_by_id(params[:id])\n updateProduct.update(products_params)\n if updateProduct != nil\n msg = { status: 200 , product: updateProduct }\n respond_to do |format|\n format.html { render json: msg }\n format.json { render json: msg }\n end\n else\n msg = { status: 422 }\n respond_to do |format|\n format.html { render json: msg }\n format.json { render json: msg }\n end\n end\n end", "def update\n @record = Product.find(params[:id])\n @record.update_attributes(params[:product])\n \n respond_to do |format|\n format.json {\n render json: {}\n }\n end\n end", "def update_product_info\n update_info = params[:product]\n market = Market.find(params[:place_id])\n product = market.products.find(update_info[:id])\n if product.update(update_info)\n response = {status: \"OK\", code: 200}\n else\n response = { status: \"Not Ok\", code: 201}\n end\n respond_to do |format|\n format.json{render json: response.to_json }\n end\n end", "def update\n @product = Product.eager_loading.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to shop_products_path(@product.shop.uuid), notice: 'Product was successfully updated.' }\n format.json { render json: @product.to_json(:include => {:product_variants => {:include => [:option_types,:pictures]}})}\n else\n format.html { render action: \"edit\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @angular = Product.find(params[:id])\n \n @angular.update_attributes(title: params[:products][:title], description: params[:products][:description])\n respond_to do |format|\n if @angular.valid?\n format.html { redirect_to store_index_path, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @angular.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @product.update(product_params)\n render json: @product\n else\n render json: @product.errors, status: :unprocessable_entity\n end\n end", "def update\n @product = Product.find(params[:id])\n\n if @product.update(product_params)\n head :no_content\n else\n render json: @product.errors, status: :unprocessable_entity\n end\n end", "def update\n respond_to do |format|\n if @product_spec.update(product_spec_params)\n format.html { redirect_to @product_spec, notice: 'Product spec was successfully updated.' }\n format.json { render :show, status: :ok, location: @product_spec }\n else\n format.html { render :edit }\n format.json { render json: @product_spec.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n \n respond_to do |format|\n if @product_detail.update(product_detail_params)\n format.html { redirect_to product_details_path, notice: 'Product detail was successfully updated.' }\n format.json { render :show, status: :ok, location: @product_detail }\n else\n format.html { render :edit }\n format.json { render json: @product_detail.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @product_management = ProductManagement.find(params[:id])\n\n if @product_management.update(product_management_params)\n head :no_content\n else\n render json: @product_management.errors, status: :unprocessable_entity\n end\n end", "def set_api_v1_product\n begin\n @api_v1_product = Product.find(params[:id])\n rescue => ex\n json_response({error: ex.message}, :not_found)\n end\n end", "def update\n product_params = params.require(:product).\n permit(:id, :value)\n\n if product = Product.find_by(external_id: product_params[:id])\n product.value = product_params[:value]\n product.save\n render json: {}, status: :ok\n else\n\n render json: {\n errors: {\n message: \"product not found\",\n product_id: product_params[:id]\n }\n }, status: :unprocessable_entity\n end\n end", "def update\n @supplier = Supplier.find(params[:supplier_id])\n @product = @supplier.products.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to @supplier, :notice => 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @product.errors, :status => :unprocessable_entity }\n end\n end\n end", "def new\n @requests_devolutions_products_detail = Requests::Devolutions::Products::Detail.new\n respond_to do |format|\n end\n end", "def update\n respond_to do |format|\n if @os_product.update(os_product_params)\n format.html { redirect_to @os_product, notice: 'Os product was successfully updated.' }\n format.json { render :show, status: :ok, location: @os_product }\n else\n format.html { render :edit }\n format.json { render json: @os_product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @info_product.update(info_product_params)\n format.html { redirect_to @info_product, notice: 'Info product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @info_product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @product_to_tracker.update(product_to_tracker_params)\n format.html { redirect_to @product_to_tracker, notice: t('.notice') }\n format.json { render :show, status: :ok, location: @product_to_tracker }\n else\n format.html { render :edit }\n format.json { render json: @product_to_tracker.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @product.update(product_params)\n render :show, status: :ok, location: api_v1_product_path(@product)\n else\n render json: @product.errors, status: :unprocessable_entity\n end\n end", "def update\n respond_to do |format|\n if @product_summary.update(product_summary_params)\n format.html { redirect_to @product_summary, notice: 'Product summary was successfully updated.' }\n format.json { head :no_content }\n # Cập nhật tên của sản phẩm trong bảng Product\n if @product_summary.quality !=0\n # Cập nhật thông tin khi ProductSummary Câp nhật Name vào bảng Product\n @pro = Product.where(\n :product_code => @product_summary.product_code,\n :skull_id => @product_summary.skull_id,\n :warehouse_id => @product_summary.warehouse_id)\n @pro.each do |pro|\n Product.update(pro.id,name:@product_summary.name)\n end\n end\n else\n format.html { render action: 'edit' }\n format.json { render json: @product_summary.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n product = Product.find_by id: (params[:id])\n product.name = (params[:name])\n product.description = (params[:description])\n product.active = (params[:active])\n product.user_id = (params[:user_id])\n product.url_img = (params[:url_img])\n if product.save\n render json: '[{\"message\":\"The product was Updated\"}]', status: :ok\n else\n render json: product.errors, status: :unprocessable_entity\n end\n rescue ActiveRecord::InvalidForeignKey\n render json: '[{\"error\":\"No valid foreign keys asignation\"}]', status: 422\n end", "def update\n @product.assign_attributes object_params.reject{|_, v| v.blank?}\n # In a normal app we have a pre filled form of the object to update,\n # so when we do a PATCH (or PUT) we send all the attributes again,\n # in the API we permit to send any field to update, so we need to remove\n # all the blank params of the object to prevent validations triggers of\n # attributes that we don't send to update\n if @product.save\n render json: @product.to_json\n else\n render json: @product.errors, status: :unprocessable_entity\n end\n end", "def update\n @product.update(product_params)\n set_products\n end", "def update\n @product = @person.products.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(params[:model])\n flash[:notice] = 'Product was successfully updated.'\n format.json { render :json=>nil }\n else\n format.json { render :json => @product.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @product_request.update(product_request_params)\n format.html { redirect_to @product_request, notice: 'Product request was successfully updated.' }\n format.json { render :show, status: :ok, location: @product_request }\n else\n format.html { render :edit }\n format.json { render json: @product_request.errors, status: :unprocessable_entity }\n end\n end\n end", "def product_updates\n if params[\"product_id\"] == \"new\"\n @product = Product.new\n @product.florist_id = session[\"found_florist_id\"] \n else\n @product = Product.where(id: params[\"product_id\"]).first\n end\n @product.product_type= params[\"product_type\"]\n @product.name = params[\"product_name\"]\n if params[\"items_per_bunch\"] && params[\"items_per_bunch\"].to_f > 0\n @product.items_per_bunch = params[\"items_per_bunch\"].to_f * 100\n if params[\"cost_per_bunch\"] && params[\"cost_per_bunch\"].to_f > 0\n @product.cost_per_bunch = params[\"cost_per_bunch\"].to_f * 100.round(2)\n numerator = params[\"cost_per_bunch\"].to_f * 100.0.round(2)\n denominator = params[\"items_per_bunch\"].to_f * 100.0.round(2)\n \n @product.cost_for_one = (numerator / denominator).round(2)*100\n end\n end\n if params[\"markup\"] && params[\"markup\"].to_f >= 0 \n @product.markup = params[\"markup\"].to_f * 100\n end\n @product.status = params[\"status\"]\n if params[\"display_name\"] == \"\" || params[\"display_name\"] == nil\n @product.display_name = @product.name\n else\n @product.display_name = params[\"display_name\"]\n end\n @product.updated_by = Employee.where(id: session[\"found_user_id\"]).first.name\n @product.florist_id = session[\"found_florist_id\"]\n if @product.save\n redirect_to \"/product/#{@product.id}\" and return\n else\n render(:product_updates) and return\n end \n end", "def update\n @shopifyproduct = Shopifyproduct.find(params[:id])\n\n respond_to do |format|\n if @shopifyproduct.update_attributes(params[:shopifyproduct])\n format.html { redirect_to @shopifyproduct, notice: 'Shopifyproduct was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @shopifyproduct.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n #Find product by productID\n @product = Product.find_by(productID: params[:id])\n \n respond_to do |format|\n if @product.update_attributes(product_params)\n format.html { redirect_to products_path, notice: 'Product has been updated.' }\n format.json { render :index, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @admin_product_detail.update(admin_product_detail_params)\n format.html { redirect_to @admin_product_detail, notice: 'Product detail was successfully updated.' }\n format.json { render :show, status: :ok, location: @admin_product_detail }\n else\n format.html { render :edit }\n format.json { render json: @admin_product_detail.errors, status: :unprocessable_entity }\n end\n end\n end", "def replace_product_by_id_with_http_info(product_id, product, opts = {})\n if api_client.config.debugging\n api_client.config.logger.debug 'Calling API: Product.replace_product_by_id ...'\n end\n # verify the required parameter 'product_id' is set\n if api_client.config.client_side_validation && product_id.nil?\n fail ArgumentError, \"Missing the required parameter 'product_id' when calling Product.replace_product_by_id\"\n end\n # verify the required parameter 'product' is set\n if api_client.config.client_side_validation && product.nil?\n fail ArgumentError, \"Missing the required parameter 'product' when calling Product.replace_product_by_id\"\n end\n # resource path\n local_var_path = '/products/{productId}'.sub('{' + 'productId' + '}', product_id.to_s)\n\n # query parameters\n query_params = opts\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = api_client.object_to_http_body(product)\n auth_names = []\n data, status_code, headers = api_client.call_api(:PUT, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'Product')\n if api_client.config.debugging\n api_client.config.logger.debug \"API called: Product#replace_product_by_id\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def update\n @onecompany_product = Onecompany::Product.find(params[:id])\n\n respond_to do |format|\n if @onecompany_product.update_attributes(params[:onecompany_product])\n format.html { redirect_to @onecompany_product, notice: 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @onecompany_product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n \n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = @productable.products.find(params[:product_id])\n ids = params[:products]\n reals = @productable.products.map(&:id) # Make a lambda with this\n present_prod = ids.select { |n| reals.include?(n) } # And this\n if @product.update(product_relations: present_prod)\n render json: @product, status: 200\n else\n render json: @product.errors, status: 422\n end\n end", "def update\n @product = Product.find(params[:id])\n if @product.update(product_params)\n # Respond to html with a redirect and json\n respond_to do |format|\n format.html do\n flash[:notice] = 'Quantity added'\n redirect_to products_path\n end\n format.json do\n render json: @product.to_json\n end\n end\n else\n respond_to do |format|\n format.html do\n flash.now[:error] = 'Error updating quantity'\n render :edit\n end\n format.json do\n render json: { errors: @product.errors.full_messages }, status: 422\n end\n end\n end\n end", "def create\n @requests_devolutions_products_detail = Requests::Devolutions::Products::Detail.new(params[:requests_devolutions_products_detail])\n @requests_devolutions_products_detail.requests_devolutions_product = Requests::Devolutions::Product.find(params[\"header_id\"])\n @requests_devolutions_products_details = @requests_devolutions_products_detail.requests_devolutions_product.details.paginate(:page => params[:page])\n respond_to do |format|\n if @requests_devolutions_products_detail.save\n format.js{ \n @requests_devolutions_product = @requests_devolutions_products_detail.requests_devolutions_product\n #@orders_productions_details = @production.details\n @requests_devolutions_products_detail = Requests::Devolutions::Products::Detail.new\n render 'update_list_form' \n }\n else\n format.html { @notice = 'Error al guardar el registro.'; redirect_to :back }\n end\n end\n end", "def editProd()\n if(!authenticateAdmin(params[:admin_id], params[:admin_auth_key]))\n render json: {status: false, reason: \"Authentication Failed\", data: \"\"}\n return\n end\n p = Product.find(params[:id])\n status = p.update(name: params[:name], price: params[:price].to_f, category_id: params[:cat_id])\n error = \"\"\n if(p.errors.full_messages.count > 0)\n error = c.errors.full_messages[0]\n end\n render json: {status: status, reason: error, data: \"\"}\n end", "def update\n @products = params[:inputprod]\n @quantity = params[:inputcantidad]\n \n respond_to do |format|\n if @service_order.update(service_order_params)\n ServiceOrderDetail.delete_all(:service_order_id => params[:id])\n cont =0\n @products.each do |p|\n detalle = ServiceOrderDetail.new(product_id: p, quantity: @quantity[cont], service_order_id:@service_order.id)\n detalle.save\n cont +=1\n end\n \n format.html { redirect_to @service_order, notice: 'Service order was successfully updated.' }\n format.json { render :show, status: :ok, location: @service_order }\n else\n format.html { render :edit }\n format.json { render json: @service_order.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @requests_transferences_products_detail = Requests::Transferences::Products::Detail.find(params[:id])\n @requests_transferences_product = @requests_transferences_products_detail.requests_transferences_product;\n @requests_transferences_products_details = @requests_transferences_product.details.paginate(:page => params[:page])\n respond_to do |format|\n if @requests_transferences_products_detail.update_attributes(params[:requests_transferences_products_detail])\n format.js{ \n @requests_transferences_products_detail = Requests::Transferences::Products::Detail.new\n render 'update_list_form' \n }\n else\n format.html { \n @notice = \"Error al actualizar el registro\"\n redirect_to :back }\n end\n end\n end", "def update\n @product = Product.find(params[:id])\n \n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @so_product.update(so_product_params)\n format.html { redirect_to @so_product, notice: 'So product was successfully updated.' }\n format.json { render :show, status: :ok, location: @so_product }\n else\n format.html { render :edit }\n format.json { render json: @so_product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @productinfo.update(productinfo_params)\n format.html { redirect_to @productinfo, notice: 'Productinfo was successfully updated.' }\n format.json { render :show, status: :ok, location: @productinfo }\n else\n format.html { render :edit }\n format.json { render json: @productinfo.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @product = TempProduct.find(params[:id])\n @product.qty = params[:qty]\n # save product\n if @product.save\n # success\n render :json => { :success => true }\n else\n # failed\n render :json => { :success => false }\n end\n end", "def update\n @produto.update(produto_params)\n respond_with @produto\n end", "def update\n authorize @product\n respond_to do |format|\n if @product.update(product_params)\n\n require 'mixpanel-ruby'\n tracker = Mixpanel::Tracker.new(ENV['MIXPANEL_PROJECT_TOKEN'])\n tracker.track(current_user.id, 'Product Update', @product.attributes)\n\n format.html { redirect_to @product, notice: I18n.t('products.update.success') }\n format.json { render :show, status: :ok, location: @product }\n else\n\n require 'mixpanel-ruby'\n tracker = Mixpanel::Tracker.new(ENV['MIXPANEL_PROJECT_TOKEN'])\n tracker.track(current_user.id, 'Product Update Failed', @product.attributes)\n\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @product.update(product_params)\n Inventory.where(product: @product).each do |inventory|\n inventory.update_discounted_price\n inventory.save\n end\n if params.key?(:pictures) && params[:pictures].present?\n params[:pictures].each do |picture_file|\n @product.pictures.create(picture_file: picture_file)\n end\n end\n format.html { redirect_to admin_product_path(@product), notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @product.update!(product_params)\n format.html { redirect_to products_url, notice: 'Product was successfully updated.' }\n format.json { render json: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @productrequest.update(productrequest_params)\n format.html { redirect_to @productrequest, notice: 'Productrequest was successfully updated.' }\n format.json { render :show, status: :ok, location: @productrequest }\n else\n format.html { render :edit }\n format.json { render json: @productrequest.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @product.update(product_params)\n format.html do\n redirect_to @product, notice: 'Product was successfully updated.'\n end\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit , status: :unprocessable_entity }\n format.json do\n render json: @product.errors, status: :unprocessable_entity\n end\n end\n end\n end", "def create\n get_product\n @product_detail = @product.details.create(params[:product_detail])\n end", "def update\n @product_detail = ProductDetail.find(params[:id])\n\n respond_to do |format|\n if @product_detail.update_attributes(params[:product_detail])\n format.html { redirect_to(@product_detail, :notice => 'Product detail was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @product_detail.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n puts params\n old_product = Product.find_by_name_and_is_deleted(params[:product][:name],true)\n unless old_product.nil?\n old_product.update_attributes(:version=>params[:product][:version],:release_date=>params[:product][:release_date],:is_deleted=>false)\n respond_to do |format|\n format.html { redirect_to products_url }\n end \n else\n @product = Product.new(params[:product])\n @product.is_deleted = false\n \n respond_to do |format|\n if @product.save\n format.html { redirect_to products_url }\n format.json { render json: @product, status: :created, location: @product }\n else\n format.html { render action: \"new\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end\n end", "def update\n @team_product_request = TeamProductRequest.find(params[:id])\n\n respond_to do |format|\n if @team_product_request.update_attributes(params[:team_product_request])\n format.html { redirect_to @team_product_request, notice: 'Team product request was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @team_product_request.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: \"Product was successfully updated.\" }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @product = Product.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to @product, notice: t(:product_updated) }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @my_product.update(my_product_params)\n render :show, status: :ok\n else\n render json: @my_product.errors, status: :unprocessable_entity\n end\n end", "def add_item_value_twenty_four\n response_search = Partay.get('http://shoponline.tescolotus.com/api/v1/search/products?query=Sugar&page=1&sortBy=Relevance', :headers => {'Content-Type' => 'application/json', 'language' => 'en-gb', 'region' => 'TH', 'userId' => access_token})\n puts search_result=JSON(response_search['productItems'][0])\n puts productid =JSON(search_result)[\"product\"][\"id\"]\n items_json_responses = {'items' => [{'id'=>'6071448594','oldValue'=>0.0,'oldUnitChoice'=>'pcs','newUnitChoice'=>'pcs','newValue'=>24.0}]}.to_json\n puts items_json_responses\n response = Partay.put('http://shoponline.tescolotus.com/api/v1/trolley/items/', :headers => {'Content-Type' => 'application/json', 'language' => 'en-GB', 'region' => 'TH', 'userId' => access_token}, :body => items_json_responses)\n puts response\n end", "def update\n @product = Product.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to @product,\n :notice=> 'Product was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action=> \"edit\" }\n format.json { render :json=> @product.errors,\n :status=> :unprocessable_entity }\n end\n end\n end", "def update\n @product = Product.find(params[:id])\n @product.name_prefix = @product.name.first.upcase\n respond_to do |format|\n if @product.update_attributes(params[:product])\n\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { render action: 'show', status: :created, location: @product }\n else\n format.html { render action: 'edit' }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_product(product, id)\n request(customer, \"product\", :post, {id: id, method: \"edit\"})\n end", "def update\n\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @own_product.update(own_product_params)\n format.html { redirect_to @own_product, notice: 'Own product was successfully updated.' }\n format.json { render :show, status: :ok, location: @own_product }\n else\n format.html { render :edit }\n format.json { render json: @own_product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok}\n else\n format.html { render :edit }\n format.json { render json: @product.errors.full_messages, status: :unprocessable_entity }\n end\n end\n end", "def update\n @product = Product.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to @product, :notice => 'Product was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @product.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @product = Product.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to @product, :notice => 'Product was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @product.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @product = Product.find(params[:id])\n\n if @product.update_attributes(params[:product])\n respond_to do |format|\n format.html { redirect_to products_path, notice: 'Product was successfully updated.' }\n format.json { head :no_content }\n end\n else\n format.html { render action: \"edit\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end", "def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Your product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @product = Product.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to @product, :notice => 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @product.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @product = Product.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to @product, :notice => 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @product.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @product.update(vendor_product_params)\n format.html { redirect_to vendor_products_url, notice: 'Vendor product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @product = current_user.user_info.products.find(params[:id])\n @product = Product.find(params[:id]) if current_user.user_info.admin \n respond_to do |format|\n if @product.update_attributes(params[:product])\n Shopify.modify @product\n format.html { redirect_to :action => 'index' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def product_params\n params.require(:product).permit(:name, :details)\n end", "def product_params\n params.require(:product).permit(\n :id,\n :name,\n :brand,\n :description,\n :status,\n :user_id,\n :price,\n :usd_price,\n :cad_price,\n :currency,\n :created_at,\n :updated_at,\n :photo,\n :size_details,\n :shipping_charge,\n :product_return_policy,\n :category_id,\n :cad_domestic_shipping,\n :cad_foreign_shipping,\n :usd_domestic_shipping,\n :usd_foreign_shipping,\n :factory_sku,\n :units_attributes => [\n :id,\n :product_id,\n :size,\n :quantity,\n :quantity_sold,\n :colour,\n :_destroy\n ],\n :order_ids => [],\n :country_ids => [],\n :productfotos_attributes => [\n :id,\n :product_id,\n :foto,\n :_destroy\n ],\n :features_attributes => [\n :id,\n :name,\n :description,\n :_destroy\n ]\n )\n end", "def update\n # updating hard info\n hard_info = HardInfo.where(use_case_no: @use_case.use_case_no, client_name: @use_case.client_name, product_name: @use_case.product_name)\n hard_info.first.update(use_case_params.except(\n :division,\n :sc_tel,\n :project_no,\n :industry,\n :service_product,\n :customer_count,\n :vendor_count,\n :product_count,\n :vehicle_count,\n :driver_count,\n :sc_name,\n :memo,\n :use_case_code\n )\n )\n #--\n respond_to do |format|\n if @use_case.update(use_case_params)\n format.html { redirect_to @use_case }\n format.json { render :show, status: :ok, location: @use_case }\n else\n format.html { render :edit }\n format.json { render json: @use_case.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.72421026", "0.7078214", "0.69090635", "0.686018", "0.678667", "0.67352563", "0.66542846", "0.6654134", "0.6609205", "0.6443004", "0.6409627", "0.63984656", "0.63694954", "0.63638735", "0.6353361", "0.6352648", "0.6351733", "0.63419265", "0.63127553", "0.6309887", "0.6294969", "0.6287428", "0.62776214", "0.62730306", "0.62476856", "0.6244757", "0.624304", "0.624236", "0.6207306", "0.6207059", "0.6201534", "0.61831963", "0.6173948", "0.617206", "0.61622214", "0.6152948", "0.6142746", "0.61320156", "0.6125101", "0.6121468", "0.6121397", "0.61054677", "0.6103136", "0.6101334", "0.6094622", "0.6089582", "0.60844344", "0.60840523", "0.60763603", "0.6075838", "0.6073342", "0.6069773", "0.6067873", "0.60658264", "0.6065159", "0.6054787", "0.604771", "0.60474503", "0.6046333", "0.60442483", "0.6042099", "0.6042015", "0.60389197", "0.6033322", "0.60314107", "0.6029608", "0.6029088", "0.6026424", "0.6025074", "0.6025074", "0.6020581", "0.60193056", "0.6016954", "0.6016954", "0.6016696", "0.6016225", "0.6009141", "0.6008049", "0.60074407", "0.60074", "0.60074", "0.60074", "0.60074", "0.60074", "0.60074", "0.60074", "0.60074", "0.60074", "0.60074", "0.60074", "0.60074", "0.60074", "0.60074", "0.60074", "0.60074", "0.60074", "0.60074", "0.60074", "0.60074", "0.60074" ]
0.6348054
17
return word with guesses filled in
def current_word #for each char in the word, either fill it in if its guessed or replace with '_' my_word = "" word.each_char do |c| if guesses.include? c my_word << c else my_word << "_" end end my_word end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def guessed_word()\r\n\t\tresult = ''\r\n\r\n\t\t# TODO: fill in method body\r\n\t\t\r\n\t\treturn result\r\n\tend", "def word_with_guesses\n word_to_display = ''\n self.word.chars do |letter|\n # if we find letter in the word to be in guessed letters\n # replace it with the actual letter\n if self.guesses.include? letter\n word_to_display += letter\n else\n word_to_display += '-'\n end\n end\n return word_to_display\n end", "def get_word\n @word_to_guess.join\n end", "def word_with_guesses\n guesses_list = @guesses.to_s\n guesses_rx = /[^ #{guesses_list}]/\n @masked = @word.gsub(guesses_rx, \"-\")\n @masked.scan(/[a-z\\-]/).join\n end", "def initialize word \n @word = word\n @guesses = ''\n @wrong_guesses = ''\n end", "def initialize(word)\n @word = word\n @guesses=''\n @wrong_guesses=''\n @word_with_guesses=''\n @check_win_or_lose=''\n for i in 0..word.length-1\n @word_with_guesses[i]='-'\n end\n end", "def fill_blanks(guess)\n i = 0\n guess.upcase!\n \n for i in 0..@word.length\n if(@word[i] == guess)\n @ingame_word[i] = guess\n end\n end\n \n end", "def fill_correct_guess(guess)\n indexes = find_guess_position(guess)\n indexes.map do |index|\n @incomplete_word[index] = guess\n end\n end", "def initialize(word)\n @word = word\n @guesses = ''\n @wrong_guesses = ''\n end", "def initialize(word)\n @word = word\n @guesses = ''\n @wrong_guesses = ''\n end", "def initialize(word)\n @word = word\n @guesses = ''\n @wrong_guesses = ''\n end", "def initialize(word)\n @word = word\n @guesses = ''\n @wrong_guesses = ''\n end", "def setguessword\n\t\t@starting_word.each_index do |index|\n\t\t\t@guessing_word[index]=\"_ \"\n\t\tend\n\t\treturn @guessing_word\n\tend", "def display_word(word, guesses)\n mask_word = \"\"\n word.chars.each do |char|\n if guesses.include?(char)\n mask_word += char\n else\n mask_word += \"_\"\n end\n end\n return mask_word\nend", "def initialize(word)\n @word = word\n @guesses = \"\"\n @wrong_guesses = \"\"\n end", "def initialize(word)\n @word = word\n @guesses = \"\"\n @wrong_guesses = \"\"\n end", "def initialize(word)\n @word = word\n @guesses = ''\n @wrong_guesses = ''\n @word_with_guesses = ''\n @wrong_word_with_guesses = ''\n @check_win_or_lose\n i = 0\n while i < @word.length do\n @word_with_guesses << '-'\n i=i+1\n end\n end", "def displayresults (word, guesses)\n\t0.upto (word.size) do |n|\n\t\n\t\tif guesses.include?(word[n,1]) then\n\t\t\t@result[n]= word[n,1]\n\t\t\n\t\tif @result[n] != \"\"\n\t\t\tthen @result[n]= word[n,1]\n\t\telse @result[n]=\"_\"\n\t\tend\t\n\tend\n \nend\nend", "def initialize()\n @word = ''\n @guesses = ''\n @wrong_guesses = ''\n end", "def to_s()\r\n\t\treturn guessed_word().split('').join(' ')\r\n\tend", "def initialize()\n @word = get_random_word\n @guesses = ''\n @wrong_guesses = ''\n end", "def guessed_wrong_letter()\n if $hidden_word_arr.exclude?($input)\n $guessed.append($input)\n end\n end", "def current_word()\n current = $build_word.join(\" \") # return a string of placeholder underscores + correctly guessed letters\nend", "def given_word(word)\n @guessword = word.to_s.split('')\n end", "def word_with_guesses\n\t @word.gsub(/[^ #{@guesses}]/, '-')\n end", "def fill_word(word_guess)\n\t\tword_guess_arr = @word_guess.scan\n\t\t\n\n\tend", "def initialize(word)\n @word = word\n @guesses = ''\n @wrong_guesses = ''\n self\n end", "def answer_update \r\n\t\t@guess_word.each_index do |i|\r\n\t\t\t@guess_word[i] ||= \"_\"\r\n\t\tend \r\n\t\tp @guess_word\r\n\tend", "def set_guess\n @guess = Array.new(@word.length, '*')\n end", "def feedback(guess_word)\n guessword_array=guess_word.split(\"\")\n word_array=@word.split(\"\")\n guessword_array.each do |letter|\n if word_array.include?(letter)\n @result[word.index(letter)]=letter\n end\n end\n puts \"here is your feedback: #{@result}\"\n end", "def word_to_guess (user_word)\n\t\tuser_word.downcase!\n\t\t@number_guess = user_word.length\n\t\t@answer_word = user_word.split(\"\")\n\tend", "def guess(letter)\r\n\t\t@guessed << letter.downcase\r\n\t\t@word[0].each_index do |i| #Iterate through indexes instead of values\r\n\t\t\tif @word.dig(0,i) == letter #since @word is an array inside an array, dig helps us look in word ([0]) each index for the letter.\r\n\t\t\t\t@hidden_word[i] = letter #if found, substitute \"_\" for the letter guessed in the same index for @hidden_word\r\n\t\t\tend\r\n\t\tend\r\n\t\tp @hidden_word #give feedback of results\r\n\tend", "def guesses\r\n \t@guesses.join(' ')\r\n end", "def word_status\n\t\t@ans_word.length.times do\n\t\t\t@guess << \"_\"\n\t\tend\n\t\tputs \"Guesser, your secret word has #{@ans_word.length} characters: #{@guess*\"\"}\"\n\tend", "def guess\n\t\tcollect_words_of_length\n\t\tputs \"Already guessed letters by computer: #{@guessed_letters}\"\n\t\t@guessing_letter = nil\n\t\twhile @guessing_letter == nil || invalid?(@guessing_letter)\n\t\t\t@guessing_letter = guessing_letter\n\t\tend\n\t\t@guessed_letters << @guessing_letter\n\t\t@guessing_letter\n\tend", "def initialize(word)\n @word = word.downcase\n @guesses = ''\n @wrong_guesses = ''\n end", "def initialize(word)\n @word = word.downcase\n @guesses = ''\n @wrong_guesses = ''\n @word_with_guesses = \" \"\n for i in 0...@word.length\n @word_with_guesses[i] = \"-\"\n end\n @check_win_or_lose = :play\n\n end", "def whole_word_guess(input,dead_man)\n guessed_word_array = input.split(//)\n if guessed_word_array == @correct_word_array\n win\n else\n puts \"The word you have guessed is incorrect!\"\n dead_man.wrong_guesses += 1\n display(dead_man) \n end\n end", "def guess(guess)\r\n\t\t# Make sure the guess is either a letter or the whole word\r\n\t\tif guess.length != 1 && guess.length != @win_word.length\r\n\t\t\tp @remaining_guesses.to_s + \" guesses left\"\r\n\t\t\tp \"Guess a letter, or the complete word!\"\r\n\t\t# check for repeated guesses\r\n\t\telsif @past_guesses.include? guess\r\n\t\t\tp @remaining_guesses.to_s + \" guesses left\"\r\n\t\t\tp @hint\r\n\t\t\tp \"You guessed that already!\"\r\n\t\t# check if they guessed the entire word correctly\r\n\t\telsif guess == @win_word\r\n\t\t\twin\r\n\t\t# if the letter is not in the word\r\n\t\telsif !@win_word.include? guess\r\n\t\t\t# Add guess to arrayof past guesses\r\n\t\t\t@past_guesses << guess\r\n\t\t\tif @remaining_guesses == 1\r\n\t\t\t\tlose\r\n\t\t\telse\r\n\t\t\tguesses_remaining\r\n\t\t\tp @remaining_guesses.to_s + \" guesses left\"\r\n\t\t\tp @hint\r\n\t\t\tp \"Sorry, try again!\"\r\n\t\t\tend\r\n\t\t# if the letter is in the word\r\n\t\telsif @win_word.include? guess\r\n\t\t\t# Add guess to arrayof past guesses\r\n\t\t\t@past_guesses << guess\r\n\t\t\tguesses_remaining\r\n\t\t\tp @remaining_guesses.to_s + \" guesses left\"\r\n\t\t\tupdate_hint(guess)\r\n\t\t\tif @hint_str == @win_word\r\n\t\t\t\twin\r\n\t\t\telse\r\n\t\t\t\tp \"Nice guess!\"\r\n\t\t\tend\r\n\t\telse\r\n\t\t\tp \"Error\"\r\n\t\tend\r\n\r\n\tend", "def new_game\n\t\t# Get the full list of words\n\t\twords = File.readlines('wordlist.txt')\n\t\tvalid_words = []\n\t\twords.each do |w| \n\t\t\t# Take all new lines and returns out\n\t\t\tw.gsub!(/\\r\\n/, \"\")\n\t\t\t# Word is valid if it's between 5 and 12 characters and isn't a proper noun. (no fair using names and such!) \n\t\t\tvalid_words << w if w.length.between?(5,12) && w[0] != w[0].upcase\n\t\tend\n\t\t# Split secret word into an array of letters\n\t\t@word = valid_words.sample.split(\"\").to_a\n\t\t# This holds user's guess. Originally populated with \"_\" for each letter\n\t\t@guess = \"\"\n\t\t@word.length.times { @guess += \"_\"}\n\t\t# Holds user's wrong letters. Originally populated with 9 x \"_\"\n\t\t@wrong_letters = \"\"\n\t\t9.times { @wrong_letters += \"_\"}\n\t\t@turn = 0\n\t\tputs \"Your task is to guess the secret word, letter by letter.\"\n\t\tputs \"You have only 9 wrong letters before you lose, so guess carefully!\"\n\t\tputs\n\t\tputs \"Here is your word. Each _ is a letter.\"\n\t\tputs\n\t\tget_guess\n\tend", "def make_guess(word)\n guess = word.upcase\n \n # If the game is over, let the player know.\n if @guesses_left == 0\n p \"This game is over!\"\n\n # Congratulatory message if they got it.\n elsif guess == @secret_word\n @number_of_guesses += 1\n p \"Congratulations! You got the word in #{@number_of_guesses} guesses!\"\n \n # If they already guessed the word:\n elsif @guessed_words.index(guess) != nil\n p \"You already guessed that word!\"\n p \"The secret word is: \" + feedback(guess)\n return \"You already guessed that word!\"\n\n # Count the guess and provide feedback on it.\n else\n\n @guessed_words.push(guess)\n @number_of_guesses += 1\n @guesses_left -= 1\n \n p \"Correct letters:\"\n p feedback(guess)\n\n # If that was the last guess, let the player know.\n if @guesses_left == 0\n p \"That was your last guess! Game over.\"\n\n else\n get_guesses_left\n \n end # control flow/guessed_word\n end # end control flow/make_guess\n end", "def blank_word(word)\n @guessword2 = word.gsub(/[a-z]/, '_').split('')\n end", "def guessed_word(word)\n\t\tif @ans_word == word\n\t\t\tputs \"You are a genious\"\n\t\telse\n\t\t\tputs \"guess again\"\n\t\t\t@guess_word.pop\n\t\tend\n\tend", "def guess_letters\n guess_array = []\n @current_word.each do\n guess_array << \"_\"\n end\n return guess_array\n end", "def reset_game\n\t\t\t@word = @@dictionary.sample.downcase[0..-3] #strips away \\r and \\n characters\n\t\t\t@guesses = 5\n\t\t\t@guess_map = Array.new(@guesses) {false}\n\t\t\t# puts @guess_map\n\t\tend", "def check_guess\n @guess_count += 1 # Increment guess count\n @guess_feedback = \"\"\n return true if @input == @current_word # Return true value if input is same as chosen word - correctly guessed word\n i = 0\n @input.split('').each do |letter| # Split user input and check if each letter is in exact position as chosen word, or if it is somewhere or not in the word at all\n # Use << to append to string as this is faster and doesn't create new string objects, as opposed to concatenation using a +\n # Below line uses nested ternary operators, where the condition is first evaluated and then if true, the first statement is executed, if false, the second statement is executed\n # This allows the code to be more readable and shorter\n @current_word.index(letter) == i ? (@guess_feedback << \"exact \") : (@current_word.index(letter).nil? ? (@guess_feedback << \"miss \") : (@guess_feedback << \"near \"))\n i += 1\n end\n puts @guess_feedback\n end", "def word_checker(user_guess)\n i = -1\n instances = []\n# Checks for the index of the first instance of user_guess AFTER index number i\n# Stops when @word.index(user_guess,i+1) returns nil\n while i = @word.index(user_guess,i+1)\n instances << i\n end\n\n# replace dashes in word display with the correctly guessed letters\n instances.each do |i| @word_display[i] = user_guess end\nend", "def guessed_letters()\n guessed = $bucket.join(\" \") # return a string of guessed letters\nend", "def look\n\t\t#This is for the animation\n\t\tlines = []\n\t\tlines << \"#{@fill_in_word}\"\n\t\tlines << \"\"\n\t\tlines << \"incorrect letters: #{@bad_guesses.join(\", \")}\"\n\t\tlines << \"\"\n\t\tlines << \"turn: #{@turns}\"\n\t\tlines << \"\"\n\t\tlines << \"bad guesses left: #{@guesses}\"\n\tend", "def blank_word(word)\n @blanks = \"-\" * word.length \n p @blanks\n @guess_count = @new_word.length + 2\n puts \"You have #{@guess_count} tries to guess the word\"\n @blanks\n end", "def setprintword()\n\t\treturn @guessing_word.join(\" \")\n\tend", "def show_letter\n split_blanks = hidden_word.split(\"\")\n occurences = []\n occurences = (0 ... secret_word.length).find_all { |i| secret_word[i,1] == current_guess}\n occurences.each { |i| split_blanks[i] = current_guess}\n @hidden_word = split_blanks.join(\"\")\n puts hidden_word\n end", "def add_to_guess\n @guess = @guess.map!.with_index do |character, index|\n @word.downcase[index] == @letter ? @word[index] : character\n end\n end", "def guess(word_pattern, possible_words)\n all_words = possible_words.flatten\n guess = $avail_letters.sort_by {|c|\n all_words.select{|w|w.index c}.length}.last\n $avail_letters -= [guess]\n $guess = guess\nend", "def current_status\n result = \"\"\n\n @guessing_word.split(\"\").each { |letter|\n if @guess_array.include?(letter)\n result << letter\n else\n result << \"_ \"\n end\n }\n \n return result\n end", "def guess(word, guesses_left)\n @left.shift\n end", "def show_letter\n split_blanks = hidden_word.split(\" \")\n occurences = []\n occurences = (0 ... @secret_word.length).find_all { |i| @secret_word[i,1] == @current_guess}\n occurences.each { |i| split_blanks[i] = @current_guess}\n @hidden_word = split_blanks.join(\" \")\n hidden_word\n end", "def input_evaluation(guess, correct_word)\n if correct_word.word.include?(guess)\n # We learned that .each_with_index can be used to locate each letter corresponding with each spacific index\n # Then if the letter matches it will subsitue the \"_\", at the correct index, with the corresponding letter\n correct_word.word.each_with_index do |letter, index|\n if letter == guess\n correct_word.progress[index] = guess\n end\n end\n else\n # Storing wrong letters into an array and updating max_guesses\n correct_word.wrong_guesses << guess\n correct_word.max_guesses -= 3\n end\nend", "def guess!(letter)\n self.word.include? letter\n self.letter = letter\n end", "def reset\n @guessed = []\n @to_guess = get_word\n @guessing = Array.new(@to_guess.length, \"_\")\n @lives = 10\n end", "def output_word\n p @guessedWord\n end", "def initialize(word)\n @guesses = ''\n @wrong_guesses = ''\n @word = word.downcase\n end", "def guess(letters)\n raise ArgumentError if letters == \"\"\n raise ArgumentError if letters !~ %r{\\w}\n letters.downcase!\n if @word.include?(letters) \n !@guesses.include?(letters) ? @guesses << letters : false\n\n else\n @wrong_guesses.include?(letters) ? false : wrong_guesses << letters \n end\n end", "def good_guess(pattern)\n merge(pattern)\n @dictionary.keep_only_words_that_match(@solution)\n @possible_letters.delete(letter_in(pattern))\n end", "def print_puzzle(word,guessed_letters = [])\n word.each_char do |char|\n if guessed_letters.include?(char)\n print \"#{char}\"\n else\n print \"-\"\n end\n end\nend", "def guess(word_pattern, possible_words)\r\n all_words = possible_words.flatten\r\n guess = $avail_letters.sort_by {|c|\r\n all_words.select{|w|w.index c}.length}.last\r\n $avail_letters -= [guess]\r\n $guess = guess\r\nend", "def guess_hidden_word\n puts (\"Enter your guess: \")\n end", "def check_guess\n @already_guessed.push(@guess)\n if @secret_word.include?(@guess)\n @secret_word.split(\"\").each_with_index do |letter, index|\n if letter == @guess\n @blanks[index] = letter\n end\n end\n else\n @guesses_left -= 1\n @missed_letters.push(@guess)\n end\n @blanks\n end", "def guess(input,dead_man)\n input.upcase!\n if input.length == 1\n letter_guess(input,dead_man) \n else\n whole_word_guess(input,dead_man)\n end\n end", "def make_guess(word)\n raise_if_complete\n\n correct = word.downcase == password.word\n guesses.create!(word: word, correct: correct)\n self.game_state = 'lost' if lives_left.zero?\n self.game_state = 'won' if correct\n save!\n correct\n end", "def draw_board #Draws the blanks and correctly guessed letters\n\t$winning_word.each_with_index do |letter, index|\n\t\tif $current[index] == nil\n\t\t\t$current[index] = \"_\"\n\t\telse\n\t\t\t$current[index]\n\t\tend\n\tend\n\tputs $current.join(\" \")\n\tputs \"Previously incorrect guesses: #{$already_guessed}\"\nend", "def correctly_picked(game_data)\n missing_letters = game_data.randomly_picked_word - game_data.chosen_letters\n display_array = []\n game_data.randomly_picked_word.each do |letter|\n display_array << if missing_letters.include? letter\n ' _ '\n else\n \" #{letter} \"\n end\n end\n display_array.join\n end", "def initialize(word)\n @word = word\n @guesses = \"\"\n @wrong_guesses = \"\"\n @word_with_guesses = word.gsub(/./, \"-\") \n @check_win_or_lose = :play\n @wrong_count = 0\n end", "def win\n puts \"\\n\"\n @letters_guessed_array = @correct_word_array\n puts @letters_guessed_array.join(\" \")\n puts \"\\n\"\n puts \"You have guess the whole word correctly! You have saved\"\n puts \"this man from a hanging!\"\n end", "def initialize(win_word)\r\n\t# Set winning word\r\n\t\t@win_word = win_word\r\n\t# Initialize remaining guesses to win_word length plus 5\r\n\t\t@remaining_guesses = win_word.length + 5\r\n\t# Initialize array to store past guesses to check for repeats\r\n\t\t@past_guesses = []\r\n\t# Initialize string to represent current state of word, or, hint\r\n\t\thint = \"\"\r\n\t\thint_length = win_word.length\r\n\t\thint_length.times { hint = hint + \"_ \" }\r\n\t\t@hint = hint\r\n\t\tputs \"Ok! User 2 please take over.\"\r\n\t\tputs \"Guess the word!\"\r\n\t\tputs \"Here's a hint: #{@hint}\"\r\n\tend", "def guessed?\n \t(word.split('') - selected_letters).empty?\n\tend", "def print_word\n\t\t$current_print = []\n\t\t@player.word_to_guess.each_with_index do |i,index|\n\t\t\tif @player.correct_letters.include? i\n\t\t\t\t$current_print << \"#{i}\"\n\t\t\telse\n\t\t\t\t$current_print << \" _\"\n\t\t\tend\n\t\tend\n\t\tprint $current_print.join\n\tend", "def select_word\r\n\t\t@answer = @words[rand(27)]\r\n\r\n\r\n\t\t# this would be a list of hashes\r\n\t\t@question = \"\"\r\n \t@tempque=\"\"\r\n\t\tfor x in 0..@answer.length\r\n\r\n\t\t\t@question=@question+\"#\"\r\n \t\t@tempque=@tempque+\"#\"\r\n\t\tend\r\n\t\treturn @answer\r\n\r\n\tend", "def replace_correct_letters\n result = @secret_word\n @secret_word.split('').each do |letter|\n unless @characters_guessed_correctly.include? letter\n result = result.gsub(letter, '_')\n end\n end\n @word_guessed = result\n result\n end", "def word\n options = []\n case @theme\n when \"default\"\n options = [\"cast\", \"puppy\", \"pineapple\", \"bananas\"]\n @word_to_guess = options.sample\n when \"food\"\n options = [\"mango\", \"papaya\", \"guava\", \"apples\", \"lychee\"]\n @word_to_guess = options.sample\n when \"hacker\"\n options = [\"bandwidth\", \"synthesize\", \"bypass\", \"cyberpunk\", \"firewall\"]\n @word_to_guess = options.sample\n when \"game of thrones\"\n options = [\"stark\", \"lannister\", \"arya\", \"hodor\", \"meereen\"]\n @word_to_guess = options.sample\n when \"lord of the rings\"\n options = [\"lothorien\", \"galadriel\", \"frodo\", \"bombadil\", \"goldberry\"]\n @word_to_guess = options.sample\n end\n end", "def turn_taken(guess, phrase)\n if guess.nil?\n @incorrect_guesses << \"[nil]\"\n elsif !guess.respond_to?(:downcase)\n @incorrect_guesses << \"[invalid]\"\n elsif guess.empty?\n @incorrect_guesses << \"[empty]\"\n else\n guess = guess.downcase.strip.gsub(/ /, \"/\")\n\n if guess.size > 1 && guess.size < phrase.size\n # This is a word guess, do not allow part of a word guesses\n words = phrase.split(\"/\")\n matching_words = words.select {|w| w == guess}\n if matching_words.size == 0\n @incorrect_guesses << guess\n return\n end\n end\n \n matches = phrase.all_indices(guess)\n \n if matches.empty? || @correct_guesses.index(guess) != nil # No matches or a repeated correct guess\n @incorrect_guesses << guess\n else\n @correct_guesses << guess\n \n matches.each do |i|\n x = 0\n guess.each_char do |c|\n @current_pattern[i + x] = c\n x = x + 1\n end\n end\n \n @found_phrase = @current_pattern.index(\"_\") == nil\n end\n end\n end", "def guess(letter)\r\n\t\t\r\n\t\tif(@word.include?(letter))\r\n\t\t @good_guesses.add(letter)\r\n\t end\r\n\t\r\n\tend", "def start_guess\r\n\t\tuntil @is_over == true\r\n\t#player enters 1 letter string\r\n\r\n\t\t\tputs \"guess a letter you've already guessed #{@used}. #{@tries-@guess_count} attempts remain\"\r\n\t\t\tputs @blanks.join\r\n\t\t\tletter = gets.chomp\r\n\t#if letter is not in guessed box take a turn away\r\n\t\t\tif @used.include?(letter) == false\r\n\t\t\t\t@guess_count += 1\r\n\t\t\t\tif @tries == @guess_count \r\n\t\t\t\t\t@is_over = true\r\n\t\t\t\tend\r\n\t\t#if letter is in the world replace the blank\r\n\t\t\t\tif @word.include?(letter)\r\n\t\t\t\t\twordindex = @word.index(letter)\r\n\t\t\t\t\t@blanks[wordindex] = letter\r\n\t\t\t\t\tif @blanks.include?(\"_ \") == false\r\n\t\t\t\t\t\t@is_over = true\r\n\t\t\t\t\tend\r\n\t\t#if letter is not in the world add to guessed box\r\n\t\t\t\telse\r\n\t\t\t\t\t@used << letter\r\n\t\t\t\tend\r\n\t#if letter is in guessed box don't consume a turn\r\n\t\t\telse\r\n\t\t\t\tputs \"you already tried that letter\"\r\n\t\t\tend\r\n\t\tend\r\n\r\n\t#end:\r\n\t#if word is guessed correctly print congrants\r\n\t\tif @blanks.include?(\"_ \")\r\n\t\t\tputs \"haha try harder next time\"\r\n\t#if word is guessed wrong print taunt\r\n\t\telse\r\n\t\t\tputs \"well done! you guessed the word\"\r\n\t\tend\r\n\tend", "def guess(letter)\r\n if word_has?(letter)\r\n \tput_letter_on_board(letter)\r\n else\r\n wrong_letter(letter) if !@guesses.include? letter\r\n end\r\n end", "def redacted_word\n @secret_word.chars.map { |c| @guessed_characters.include?(c.to_sym) ? c : '_' }.join('')\n end", "def guesses_s(guesses)\n str = \"\"\n guesses.each() {|letter| str << \"#{letter} \"}\n return str\nend", "def initialize(word=WordGuesserGame.get_random_word, guesses = '',wrong_guesses='')\n @word = word\n @guesses = guesses\n @wrong_guesses = wrong_guesses\n end", "def initialize()\n @word = ''\n @guesses = ''\n @wrong_guesses = ''\n @word_with_guesses = '-'*word.length\n @check_win_or_lose = :play\n end", "def update_teaser last_guess\n new_teaser = @word_teaser.split\n new_teaser.each_with_index do |letter, index|\n if letter == \"_\" && @words.first[index] == last_guess\n new_teaser[index] = last_guess\n end\n end\n @word_teaser = new_teaser.join(' ')\n end", "def guess_word(word)\n won = won?(word)\n @tries_left -= 1 unless won\n won\n end", "def make_guess(guess)\n @previous_guesses << guess \n display_string = show_progress()\n if !goal_word.include?(guess) \n guess_counter()\n end \n if display_string == @goal_word\n @player_won = true \n end\n end", "def get_guess\n\t\t# There are turns left...\n\t\tif @turn < 9\n\t\t\tshow_board\n\t\t\tputs \"Enter your letter guess...\"\n\t\t\tletter = gets.chomp.downcase\n\t\t\tvalidate_letter(letter)\n\t\t# No turns left, show losing message and delete game if it was previously saved\n\t\telse\n\t\t\tputs\n\t\t\tshow_board\n\t\t\tputs \"Dangit, you ran out of turns!\"\n\t\t\tputs \"The word was #{@word.join}...\"\n\t\t\tif @running_saved_game != nil\n\t\t\t\tover_write_data\n\t\t\tend\n\t\t\tgo_again\n\t\tend\n\tend", "def guessed_word(alphabet,position)\n\t\tindex = position-1\n\n\t\t# Check for repeating guess by comparing already existing guesses from the hash.\n\t\tif guessed_words.keys.index(position) != nil && guessed_words[position].upcase == alphabet.upcase\n\t\t\tputs \"Don't repeat the same guess\"\n\t\t\tputs \"You have #{guesses} guesses left.\"\n\n\t\t# If the guess is same as that of the original word's letter, its a correct guess\n\t\telsif original_word[index] == alphabet.upcase\n\t\t\thidden_word[index] = alphabet.upcase\n\t\t\tguesses_history(alphabet,position)\n\t\t\tputs \"Congrats!!! Your guess is correct.\"\n\t\t\tputs \"You have #{guesses_left} guesses left.\"\n\t\t# Additional condition for downcase correct guesses.\n\t\telsif original_word[index] == alphabet.downcase\n\t\t\thidden_word[index] = alphabet.downcase\n\t\t\tguesses_history(alphabet,position)\n\t\t\tputs \"Congrats!!! Your guess is correct.\"\n\t\t\tputs \"You have #{guesses_left} guesses left.\"\n\n\t\t# Other than repeat and correct guess, all other guesses are worng and just add the guesses to the hash to show repeat case in future.\n\t\telse\n\t\t\tputs \"Sorry! That's a wrong guess.\"\n\t\t\tputs \"You have #{guesses_left} guesses left.\"\n\t\t\tguesses_history(alphabet,position)\n\t\tend\n\t\tputs \"The status of the word is: #{hidden_word}\" \n\tend", "def play_new_game\n #get new code word\n @word_master.choose_code_word\n @code_word = @word_master.code_word\n @good_guesses = Array.new(@code_word.length, '_ ')\n #tells you rules\n puts \"Try to figure out the word. If you guess 6 wrong letters, you lose!\"\n #starts playing\n game_loop\n end", "def getguess guess\r\n\t\t\t\t\t@spin_flag = false\r\n\t\t\t\t if guess.length == 1\r\n\t\t\t\t if check_repeated_choice guess\r\n\t\t\t\t @message = \"Already guessed this letter!\"\r\n\t\t\t\t if @console\r\n\t\t\t\t\t\t\t\t@output.puts \"#{@message}\"\r\n\t\t\t\t\t\t\t\tword_input = take_user_word_input\r\n\t\t\t\t\t\t\t\tvalid = false\r\n\t\t\t\t\t\t\t while !valid do\r\n\t\t if validate_input word_input\r\n\t\t valid = true\r\n\t\t else\r\n\t\t @output.puts \"Invalid input\"\r\n\t\t word_input = take_user_word_input\r\n\t\t end\r\n\t\t\t\t\t\t\t end\r\n\t\t\t\t\t\t\t\tif check_enter word_input\r\n\t\t\t\t\t\t\t\t\t\t@break_flag = true\r\n\t\t\t\t\t\t\t\telse\r\n\t\t\t\t\t\t\t\t getguess word_input\r\n\t\t\t\t\t\t\t\tend\r\n\t\t\t\t\t\telse\r\n\t\t\t\t\t\t\t@spin_flag = true\r\n\t\t\t\t end\r\n\t\t\t\t else\r\n\t\t\t\t \t@message=\"Guess a letter from the word/phrase.\"\r\n\t\t\t\t @guess_counter+=1\r\n\t\t\t\t check_guess guess\r\n\t\t\t\t set_guess_analysis guess\r\n\t\t\t\t end\r\n\t\t\t\t success = check_phrase @resulta.join(',').gsub(\",\",\"\")\r\n\t\t\t\t return success ? true : false\r\n\t\t\t\telse\r\n\t\t\t\t\t if check_phrase guess\r\n\t\t\t\t\t\t phrase = @secretword.chars\r\n\t\t\t\t\t\t i = 0\r\n\t\t\t\t\t\t while i < phrase.length do\r\n\t\t\t\t\t\t\t\t\t\t@resulta[i] = phrase[i]\r\n\t\t\t\t\t\t\t\t\t\ti += 1\r\n\t\t\t\t\t\t end\r\n\t\t\t\t\t\t return true\r\n\t\t\t\t\t else\r\n\t\t\t\t\t\t @num_guessed = 0\r\n\t\t\t\t\t\t incrementturn\r\n\t\t\t\t\t\t @guess_counter+=1\r\n\t\t\t\t\t\t set_guess_analysis guess\r\n\t\t\t\t\t\t return false\r\n\t\t\t\t\t end\r\n\t\t\t\tend\r\n\t\t\t\tend", "def solved? (guesses, word)\n\tsolved = true\n\thits = []\n\tword.length.times do |i|\n\t\thits << word[i]\n\tend\n\thits.each do |hit|\n\t\tunless guesses.include? hit\n\t\t\tsolved = false\n\t\tend\n\tend\n\tsolved\n\n\n\t\nend", "def update_word_state\n @secret.chars.each_with_index do |letter, idx| \n @word_state[idx] = letter if @guesses[-1] == letter\n end\n @word_state\n end", "def word_with_blanks\n word_with_blanks = []\n @word.split('').each do |letter|\n if !@letters_guessed.include?(letter)\n word_with_blanks << '_'\n else\n word_with_blanks << letter\n end\n end\n word_with_blanks.join(' ')\n end", "def initialize(word)\n # Make the word lowercase\n @word = word.downcase\n @guesses = ''\n @wrong_guesses = ''\n @word_with_guesses = ''\n end", "def check_guess(input)\n @guessed_letters.push(input)\n if @secret_word.match?(input)\n @secret_word.split(//).each_with_index { |char, index| @guessed_word[index] = char if char == input }\n else\n puts 'Incorrect'\n @guesses_left -= 1\n @wrong_letters.push(input)\n end\n end" ]
[ "0.8030174", "0.80026644", "0.788203", "0.7563455", "0.7493515", "0.7299315", "0.7279139", "0.7190165", "0.7189548", "0.7189548", "0.7189548", "0.7189548", "0.7153519", "0.7141275", "0.71179014", "0.71179014", "0.70854473", "0.7074733", "0.70745134", "0.70645607", "0.7062662", "0.70229846", "0.6994211", "0.69821906", "0.69720954", "0.6971133", "0.6957033", "0.6903694", "0.67793286", "0.6776018", "0.6772763", "0.6747036", "0.67413455", "0.6735812", "0.67357874", "0.6723922", "0.6723176", "0.67130256", "0.67110324", "0.6706958", "0.6706", "0.67054164", "0.66919905", "0.6667365", "0.66644806", "0.6653327", "0.66480005", "0.6644227", "0.6630897", "0.6626667", "0.66235334", "0.66030306", "0.6596004", "0.6580943", "0.657036", "0.6563544", "0.6554805", "0.654885", "0.65468323", "0.6546096", "0.65435106", "0.65366554", "0.65358585", "0.6531005", "0.65253687", "0.6508948", "0.6498477", "0.6494431", "0.6478223", "0.64696395", "0.6466868", "0.6443911", "0.64344704", "0.6429913", "0.6428756", "0.6426775", "0.6413486", "0.63932747", "0.6385482", "0.63790655", "0.6376524", "0.63707393", "0.63705146", "0.63700354", "0.6367153", "0.6367057", "0.63634086", "0.6359436", "0.6355405", "0.6343109", "0.6331442", "0.63284785", "0.6324271", "0.62944084", "0.627772", "0.6277422", "0.6273839", "0.6269586", "0.6266269", "0.6266148" ]
0.77189225
3
Check whether the maze has been solved
def target_reached? @current_value == @target_value end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def solved?\n !@grid.nil? && @grid.missing == 0\n end", "def solved?\n !@grid.nil? && @grid.missing == 0\n end", "def solved?\n cols = @grid.transpose\n return false unless (0..8).all? {|i| check_cols(i) && check_row(i)}\n (0..2).each do |horiz| \n (0..2).each {|vert| return false unless check_square(horiz,vert)}\n end\n true\n end", "def solved?\n @state == @goal\n end", "def is_solution? \n zero= false\n 0.upto(@width-1) do |x|\n 0.upto(@height-1) do |y|\n if @pole[x][y]==0\n zero = true\n break\n end\n end\n end\n print \"Je to reseni, pyco!\\n\" if !zero\n return !zero \n end", "def solved?\n end", "def done?\n # legal_moves(state).empty?\n # Try to speed up by disregarding possibility of draw\n false\n end", "def solved?\n @solution != nil\n end", "def solvable?\n find_solution > 0\n end", "def solve\n traverse maze.cell_at(0,0)\n maze\n end", "def solve\r\n matrix = @maze\r\n finished = false\r\n\r\n start = Discovered.new(@starting_point[:x],@starting_point[:y],nil)\r\n frontier = []\r\n visited = []\r\n frontier << start\r\n\r\n while !frontier.empty? && !finished\r\n \r\n current_node = frontier.shift # take first item from queue\r\n if visited.include? [current_node.x,current_node.y]\r\n next\r\n else\r\n visited << [current_node.x,current_node.y]\r\n x = current_node.x\r\n y = current_node.y\r\n if (matrix[y][x] == 'G')\r\n finished = true\r\n else\r\n frontier << look_for_valid_moves(x,y,matrix,current_node,visited)\r\n frontier.flatten!\r\n end\r\n end\r\n end\r\n\r\n if finished\r\n @labyrinth.maze[:graphic_matrix][current_node.y][current_node.x] = 'X'\r\n while !current_node.parent.nil?\r\n current_node = current_node.parent\r\n @labyrinth.maze[:graphic_matrix][current_node.y][current_node.x] = @labyrinth.maze[:graphic_matrix][current_node.y][current_node.x] == 'S' ? 'S' : '.'\r\n end\r\n puts \"Maze solved:\\n\"\r\n @labyrinth.to_screen\r\n else\r\n print \"Goal was not found... :(\"\r\n end\r\n end", "def solve(begX, begY, endX, endY)\n\t\tstart = [begX, begY]\n\t\tstack = []\n\t\tmove_trace = []\n\t\t#checks to see if start or end have \"wall\" value\n\t\tif get_value(begX, begY) == 1 || get_value(endX, endY) == 1\n\t\t\tputs \"Invalid start or finish location\"\n\t\t\treturn false\n\t\tend\n\t\tstack.push(start)\n\t\tmove_trace.push(start)\n\t\twhile !stack.empty?\n\t\t\tcurrent = stack.pop()\n\t\t\tif current == [endX, endY]\n\t\t\t\tputs \"The maze is solved\"\n\t\t\t\tputs \"The cells you visited are: \"\n\t\t\t\treturn move_trace\n\t\t\tend\t\t\n\n\t\t\ttrace(current).each do |node|\n\t\t\t\tif !move_trace.include? node\n\t\t\t\t\tstack.push(node)\n\t\t\t\t\tmove_trace.push(node)\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\tputs \"Cannot be solved\"\n\t\treturn false\n\tend", "def solved?\n\t\n\t\t# pour toutes les pièces\n\t\t(0..8).each { |i|\n\t\t\t# la case est encore vide : solved = false\n\t\t\treturn false if @cases[i] == nil\n\t\t\t\n\t\t\t# sinon, est-ce que les pièces matchent entre elles.\n\t\t\treturn false if not self.match?(i)\n\t\t}\n\t\t\n\t\t# sinon, ca match partout : le puzzle est résolu (solved) !\n\t\treturn true\n\tend", "def solved?(board)\n if\n board.each do |row|\n end\n else\n false\n end\n\nend", "def solvable?\n return true if full?\n\n state_array_copy = @state_array.dup\n start_index = state_array_copy.index(false)\n index_stack = [start_index]\n connected_found = 0\n until index_stack.empty?\n index = index_stack.pop\n next if state_array_copy[index]\n\n state_array_copy[index] = true\n connected_found += 1\n index_stack += neighbor_indices(index)\n end\n return false unless connected_found + @num_occupied == @size ** @dimension\n\n num_dead_ends = (0...@size ** @dimension).to_a.count do |index|\n !@state_array[index] && neighbor_indices(index).count { |neighbor_index| !@state_array[neighbor_index] } == 1\n end\n return num_dead_ends <= 1\n end", "def find_solution\n if solve(@start_point[0], @start_point[1])\n @maze.each { |row| puts row.join(\"\") }\n else\n puts \"no solution found\"\n end\n end", "def is_solved?\n return false unless is_rows_valid?\n return false unless is_columns_valid?\n return false unless is_subgrids_valid?\n true\n end", "def solve(start_cell, end_cell)\n @cells_to_visit << start_cell\n result = trace(start_cell, end_cell) # returns true if maze is solvable and false if not\n if result == true\n return find_path # if solvable, returns the solved path\n end\n return false # if not solvable, returns false\n end", "def solve\n possibleMovements.each do |delta|\n moveBy delta\n break if solve\n undoMoveBy delta\n end\n adjacentToFinish?\n end", "def check_place(place)\r\n\t\tif place.x.between?(0, @n-1) && place.y.between?(0,@m-1)\r\n\t\t\treturn (@maze[place.y][place.x]== 0)\r\n\t\telse return false end\r\n\tend", "def solved?\n first_empty_index.nil? && legal?\n end", "def solved?\n # Return whether the total passed in is equal to the total for a valid house.\n def is_valid_house_total?(total)\n return total == 45\n end\n\n # Return the total of adding up all the cells in this house.\n def house_total(house)\n return house.inject(0) {|sum, cell| sum + cell.to_i }\n end\n\n ## Check whether all the houses in the puzzle have valid totals.\n ##\n\n each_row do |row|\n return false unless is_valid_house_total?(house_total(row))\n end\n\n each_column do |column|\n return false unless is_valid_house_total?(house_total(column))\n end\n\n each_nonet do |nonet|\n return false unless is_valid_house_total?(house_total(nonet))\n end\n end", "def valid\n for i in 0..(@n-1)\n for j in 0..(@m-1)\n return false if @maze_table[2*j+1][2*i+1] == \"1\"\n walls = 0\n walls += 1 if @maze_table[2*j][2*i+1] == \"1\"\n walls += 1 if @maze_table[2*j+2][2*i+1] == \"1\"\n walls += 1 if @maze_table[2*j+1][2*i+2] == \"1\"\n walls += 1 if @maze_table[2*j+1][2*i] == \"1\"\n return false if walls < 1 || walls > 3\n end\n end\n for i in 0..(@maze_table.size-1)\n return false if @maze_table[i][0] == \"0\" || @maze_table[i][2*@n] == \"0\"\n end\n for i in 0..(@maze_table[0].size-1)\n return false if @maze_table[0][i] == \"0\" || @maze_table[2*@m][i] == \"0\"\n end\n return true\n end", "def solve(file)\n maze = Maze.new\n maze.create_maze(file)\n my_course = maze.get_course\n solution = Array.new\n \n solution.push(maze.get_start)\n sol = 0\n while !solution.empty?\n temp = solution.pop\n if temp.get_mode == \"End\"\n sol = 1\n end\n \n if !temp.get_directions.empty? && temp.get_mode != \"flag\"\n temp.change_mode(\"flag\")\n \n if temp.get_directions.has_key?(\"u\") && temp.get_y != 0\n solution.push(my_course[temp.get_x][temp.get_y-1])\n end\n if temp.get_directions.has_key?(\"d\") && temp.get_y != my_course.size-1\n solution.push(my_course[temp.get_x][temp.get_y+1])\n end\n if temp.get_directions.has_key?(\"l\") && temp.get_x != 0\n solution.push(my_course[temp.get_x-1][temp.get_y])\n end\n if temp.get_directions.has_key?(\"r\") && temp.get_x != my_course.size-1\n solution.push(my_course[temp.get_x+1][temp.get_y]) \n end\n end\n end\n \n if sol == 0\n puts \"false\"\n else\n puts \"true\"\n end\n \n end", "def board_solved?\r\n # Check that all the cells are filled with values\r\n #\r\n (0 .. 8).each do |row|\r\n (0 .. 8).each do |col|\r\n return false unless board[row][col] > 0\r\n end\r\n end\r\n \r\n # Check column constraints\r\n #\r\n @board.each do |column|\r\n return false unless column.uniq.size == 9\r\n end\r\n \r\n # Check row constraints\r\n #\r\n @board.transpose.each do |column|\r\n return false unless column.uniq.size == 9\r\n end\r\n \r\n # Check box constraints\r\n #\r\n (0 .. 2).each do |box_x|\r\n (0 .. 2).each do |box_y|\r\n box_vals = []\r\n \r\n (0 .. 2).each do |i|\r\n (0 .. 2).each do |j|\r\n box_vals << @board[3 * box_x + i][3 * box_y + j]\r\n end\r\n end\r\n \r\n return false unless box_vals.uniq.size == 9\r\n end\r\n end\r\n \r\n true\r\n end", "def found_goal?(neighbors) \n neighbors.each do |neighb| \n if grid.is_goal? neighb\n set_position(neighb) \n return true\n end\n end\n return false\n end", "def solved?\n result = false\n @data.each do |turn|\n result = turn[:key].red >= 4 if !turn[:key].nil?\n break if result == true\n end\n @solved = result\n result\n end", "def check?\n king_coords = current_player_king_coordinates\n return true unless build_DANGER_moves_array.empty?\n end", "def solved?\n self.fittest.fitness >= 1.0\n end", "def complete?\n if @puzzle.include? \".\"\n return false\n else\n return true\n end\n end", "def solved?\n unknown_count == 0\n end", "def valid_move?(position)\n position && @maze[position] != \"*\" && @times_visited[position] < 2 && position[0] < @maze.maze.length && position[1] < find_max_row_length \n end", "def done?(state)\n legal_moves(state).empty?\n end", "def verifierCorrect()\n return @solution.equals(@partie.getCurrentGrid())\n end", "def solve(begX, begY, endX, endY)\n # set solution to false\n solution = false\n # create a temp array that is a copy of the maze\n temp = @maze\n # creates an empty queue\n queue = Queue.new\n # enqueue the beginning coordinates as an array\n queue.enq([begX, begY])\n while !queue.empty? && !solution\n # create a current value that is the array of the currently examined coordinates\n # get x and y separate for simplicity\n current = queue.pop\n x=current[0]\n y=current[1]\n # if x and y are the end coordinates, push them on to the maze trace array\n # and set solution to true to trigger an end to the while loop\n if x == endX && y == endY\n @maze_trace.push(current)\n solution = true\n else\n # else still push the coordinates to the trace array\n # set the corresponding value in the temp array to 1\n # enqueue the coordinates above, below, left and right of current\n # only enqueue the elements that pass the check_path method\n # note that we change the temp value to \"1\" so that previously visited coordinates\n # fail the check_path method. This ensures we don't revisit coordinates\n @maze_trace.push(current)\n temp[x][y] = \"1\"\n queue.enq([x+1,y]) if check_path(x+1,y,temp)\n queue.enq([x-1,y]) if check_path(x-1,y,temp)\n queue.enq([x,y+1]) if check_path(x,y+1,temp)\n queue.enq([x,y-1]) if check_path(x,y-1,temp)\n end\n end\n if solution\n puts \"Path found from point #{begX},#{begY} to point #{endX},#{endY}\"\n else\n puts \"No path exists between given points\"\n # If the path is not found clear the maze_trace array which has elements stored nonetheless\n @maze_trace.clear\n end\n end", "def valid_edge(x, y)\n if x < m and x > 0 and y < n and y > 0 and maze_mat[x][y] == 0\n return true\n end\n false\n end", "def is_visited?(x, y)\n @maze[x][y] == 'V'\n end", "def set_posts\n # puts @@START.to_s\n @maze.each_with_index do |row, i|\n row.each_with_index do |col, j|\n # puts \"@maze[i][j] is #{@maze[i][j]}\"\n @start = [i,j] if @maze[i][j] == @@START\n @end = [i,j] if @maze[i][j] == @@END\n\n if @start && @end\n return true\n end\n end\n end\n\n return false if !(@start && @end)\n return true\n end", "def check_for_error\n start_x = @maze[:start_x]\n start_y = @maze[:start_y]\n stop_x = @maze[:stop_x]\n stop_y = @maze[:stop_y]\n if @maze[:matrix][start_y][start_x] == @maze[:wall] || @maze[:matrix][stop_y][stop_x] == @maze[:wall]\n raise \"Start or Goal cannot be a wall!!!\"\n end\n end", "def solved?\n\t\treturn @blocks.clues == showingClues\n\tend", "def has_possible_moves\n \t\t@mowers.each do |mower|\n \t\t\treturn true if mower.can_move? && !mower.is_going_outside?(lawn_x, lawn_y)\n\t \tend\n \t\treturn false\n \tend", "def solvable?\n\t\tsteps > 0\n\tend", "def solved?\n @solution !~ /-/\n end", "def solvable?\n steps > 0\n end", "def solved?(board_array)\n return valid?(board_array) && valid?(transpose_arrays(board_array)) && valid?(create_grid(board_array))\nend", "def new_game?\n moves.empty?\n end", "def has_possible_moves\n \t\t@mowers.each do |mower|\n \t\t\treturn true if mower.can_move?(lawn_mowers_positions)\n\t \tend\n \t\treturn false\n \tend", "def solved?\n letter = won_across?\n return letter if letter\n letter = won_up_and_down?\n return letter if letter\n letter = won_diagonally?\n return letter if letter\n false\n end", "def complete?(params)\n if @puzzle.complete?\n if @puzzle.to_s == @solution.to_s\n return JSON.generate({complete: true, accurate: true})\n else\n return JSON.generate({complete: true, accurate: false})\n end\n else\n return JSON.generate({complete: false, accurate: false})\n end\n end", "def finished?\n !board[1..-1].include?(false)\n end", "def solve\n\t\t\n\t\tcell_index = 0\n\t\t# move to the right position..\n\t\t# puts @unsolved.length.to_s + \" unknown cells!\"\n\n\t\twhile cell_index >= 0 && cell_index < @unsolved.length do\n\t\t\tcell = @unsolved[cell_index];\n\t\t\t\n\t\t\tpossible = cell.nextPossible()\t\n\n\t\t\tif possible > 9 || possible <= 0\n\t\t\t\tcell.set(0)\n\t\t\t\tcell_index -= 1\n\t\t\telse\n\t\t\t\tcell.set(possible)\n\t\t\t\tcell_index += 1\n\t\t\tend\t\t\t\t\t\t\t\n\t\tend\n\n\t\tif cell_index < 0\n\t\t\treturn false\n\t\telse\n\t\t\treturn true\n\t\tend\n\tend", "def finished?\n #positions = {:a => 25, :b => 30}\n @position.each do |pl, pos|\n if pos >= @length\n return true\n else\n return false\n end\n end\n end", "def done?(state)\n state[:position][0][0] == 0\n end", "def winner?\n directions = [[1,0], [1,-1], [1,1], [0,1]]\n max_x = grid[0].length\n max_y = grid.length\n directions.each do |dx, dy|\n for x in (0...max_x) do\n for y in (0...max_y) do\n last_x = x + 3 * dx\n last_y = y + 3 * dy\n if 0 <= last_x && last_x < max_x && 0 <= last_y && last_y < max_y\n val = get_cell(x, y).value\n if (!val.empty? && val == get_cell(x + dx, y + dy).value && \n val == get_cell(x + 2 * dx, y + 2 * dy).value &&\n val == get_cell(x + 3 * dx, y + 3 * dy).value)\n return true\n end\n end\n end\n end\n end\n return false\n end", "def solved?\n p @solved\n end", "def can_go_up?(the_maze, floor, position)\r\n (floor - 1 > -1) and (the_maze[floor - 1][position] == \"0\") \r\nend", "def completed?\n min_moves == moves_count.value\n end", "def solution_exists?\n ! @solved_node.nil?\n end", "def found_exit?(the_maze, floor, position) \r\n (floor == 0 or floor == the_maze.size - 1) or (position == 0 or position == the_maze[floor].size - 1)\r\nend", "def valid?\n 1.upto(puzzle.size) { |index| return false unless valid_row?(index - 1) && valid_column?(index - 1) }\n sections.all? { |section| valid_section?(section) }\n end", "def final?\n self.winner || self.moves.empty?\n end", "def solve(begX, begY, endX, endY)\n #first create two points object as starting point and destination\n start = Point.new(begX,begY)\n @final = Point.new(endX,endY)\n #first initialize these objects in case that there are\n #data left after last iteration of solve\n @tnode = nil\n @traceSet = Set.new\n @traceArray = Array.new\n if start.isEqual(@final)\n @tnode = start\n true\n else\n @traceSet.add(start.to_S)\n @traceArray.push(start)\n\n #start sloving\n newp = @traceArray.shift\n #we don't stop until all the possible pathes are tested\n\n while newp != nil && @tnode == nil do\n #test each route and if we reach the destination, immediately break\n #the while loop\n\n #test if we can move upward\n move(2*newp.x+1,2*newp.y,newp.x,newp.y-1,newp)\n\n #test if we can move downward\n move(2*newp.x+1,2*newp.y+2,newp.x,newp.y+1,newp)\n\n #test if we can move leftward\n move(2*newp.x,2*newp.y+1,newp.x-1,newp.y,newp)\n\n #test if we can move rightward\n move(2*newp.x+2,2*newp.y+1,newp.x+1,newp.y,newp)\n\n #move to the next cell\n newp = @traceArray.shift\n end\n\n #if the current cell is nil, it means we have no solution for this maze puzzle\n if newp == nil\n false\n else #else return true\n true\n end\n end\n end", "def done?(assignments)\n \tassignments.size == problem.vars.size\n end", "def pathfinder(maze, counter=0, unexplored_territory=true, starting_cell=[])\n\n # This while loop goes over the maze once, looking for a 'F' in a cell (maze[row][col]), and adding 0 to ENWS if possible\n while counter==0\n maze.each_with_index do |array, row|\n array.each_with_index do |cell, col|\n if cell == 'F' # Looking for the first starter cell\n [[0,1],[-1,0],[0,-1],[1,0]].each do |mod|# east, north, west, south checked one at a time\n maze[row+mod[0]][col+mod[1]] = counter if maze[row+mod[0]][col+mod[1]] == ' '\n end\n end\n end\n end\n counter+=1\n end\n\n print_maze(maze).inspect if $debug\n no_solution = false\n\n\n # This while loop goes through and looks for either blank spaces adjacent to numbers, or 'S' in a cell.\n while unexplored_territory\n dig_dug = true\n maze.each_with_index do |array, row|\n array.each_with_index do |cell, col|\n if cell == (counter-1) # mapping out the maze, one by one\n [[0,1],[-1,0],[0,-1],[1,0]].each do |mod|# east, north, west, south checked one at a time\n if maze[row+mod[0]][col+mod[1]] == 'S'\n unexplored_territory, starting_cell, dig_dug = false, [row, col], false\n elsif maze[row+mod[0]][col+mod[1]] == ' '\n maze[row+mod[0]][col+mod[1]], dig_dug = counter, false\n end\n end\n end\n end\n end\n unexplored_territory, no_solution = false, true if dig_dug # check for progress, no solutions found if true\n counter+=1\n if $debug\n system('clear') or system('cls')\n print_maze(maze)\n sleep(1.0/4.0) if $slow\n end\n end\n\n counter = counter - 3 # Getting the counter ready for reverse mapping\n return [['No Solution']] if no_solution # 5.\tIF there is no solution, then print an appropriate message and re-display the menu\n unless no_solution\n\n\n # This while loop goes and looks for the route back following descending numbers.\n while counter >= 0\n maze[starting_cell[0]][starting_cell[1]] = '*'\n [[0,1],[-1,0],[0,-1],[1,0]].each do |mod|# east, north, west, south checked one at a time\n if maze[starting_cell[0]+mod[0]][starting_cell[1]+mod[1]].is_a?(Integer) && maze[starting_cell[0]+mod[0]][starting_cell[1]+mod[1]] == counter\n starting_cell = [starting_cell[0]+mod[0],starting_cell[1]+mod[1]]\n end\n end\n counter -= 1\n end\n\n maze[starting_cell[0]][starting_cell[1]] = '*' # Sets the last cell to *\n\n\n # This set of loops goes through and clears out integers from the maze\n maze.each_with_index do |row, r|\n row.each_with_index do |col, c|\n if col.is_a?(Integer)\n maze[r][c] = ' '\n end\n end\n end\n\n # Return the finished product\n maze\n end\nend", "def no_problem_corners?(cell)\n maze.corners_of(cell).all? do |corner|\n num_shared = maze.shared_edges(cell, corner).count { |edge| maze.is? edge, type: :path }\n maze.is?(corner, type: :wall) || 1 == num_shared\n end\n end", "def solvable?\n @cube_state.solvable?\n end", "def is_exit?(cell)\n @maze[cell.x][cell.y] == 'G'\n end", "def solved?\n empty_slots.empty? # => same as empty_slots.length == 0\n end", "def solve_maze\n matrix = @maze[:matrix] # get matrix from maze hash\n exit_found = false # exit not found yet\n room = Room.new(@maze[:start_x], @maze[:start_y], nil) # create new room from start position\n queue = Queue.new # queue to store the current working nodes' children\n queue << room # add the new room to queue\n\n # if path not found and queue not empty\n while !queue.empty? && !exit_found\n room = queue.pop # get the next room to search for a path\n x = room.x\n y = room.y\n if (x == @maze[:stop_x] && y == @maze[:stop_y]) # if found\n exit_found = true\n else # if not found\n matrix[y][x] = '*' # Mark node as visited sto we do not check it again (bfs algorithm)\n\n # push to queue the children of node room. We are pushing the up, down, left or right room if they are not a wall and we\n # we haven't visited them yet\n queue << Room.new(x+1,y,room) if open_room(x+1,y,matrix) and !visited(x+1, y, matrix)\n queue << Room.new(x-1,y,room) if open_room(x-1,y,matrix) and !visited(x-1,y,matrix)\n queue << Room.new(x,y+1,room) if open_room(x,y+1,matrix) and !visited(x, y+1, matrix)\n queue << Room.new(x,y-1,room) if open_room(x,y-1,matrix) and !visited(x, y-1, matrix)\n end\n end\n\n # if goal found store the last room to @maze[:path]. The last room has a reference(:parent) to the previous room. So we can trace the path\n if exit_found\n @status.found = true\n @maze[:path] = room\n else\n @status.found = false\n end\n\n # yields x, y coordinates of path starting from goal to start\n def yield_path\n room = @maze[:path]\n while room.parent\n yield room.x, room.y\n room = room.parent\n end\n end\n\n # get an array of path\n def path_array\n path = []\n yield_path do |x, y|\n path << [x,y]\n end\n path.reverse\n end\n end", "def valid_move?\r\n TABLE_MATRIX.include? [latitude, longitude]\r\n end", "def solved\n all_queens_placed && attacks_possible != true\n end", "def cleared_way?(correct_mov)\n\t\t#loops while the start node coordinate is different from the final node coordinate.\n\t\twhile @start_coord != @final_coord\n\t\t\t#sums the start node coordinate with the basic move of the corresponding piece.\n\t\t\t@start_coord = [@start_coord[0] + correct_mov[0], @start_coord[1] + correct_mov[1]]\n\t\t\tx_new = \"\"\n\t\t\t#transform the Y axis of the coordinate into a string.\n\t\t\ty_new = @start_coord[1].to_s\n\t\t\t#transform the X axis of the coordinate back into a letter.\n\t\t\t@letter_convertion.each do |key, value|\n\t\t\t\tif @start_coord[0] == value\n\t\t\t\t\tx_new = key\n\t\t\t\tend\n\t\t\tend\n\n\t\t\t#saves the new translation coordinate following the syntax letter+number.\n\t\t\t@mov_translation = x_new + y_new\n\t\n\t\t\t#returns false if the node in the new coordinate is not nil and if it is different from the final node coordinate.\n\t\t\tif @board[@mov_translation].name != nil && @mov_translation != @second_coord_convertion\n\t\t\t\treturn false\n\t\t\t#if the destination node color is different from the current player color and the translation coordinate equals to the final node coordinate.\n\t\t\telsif @board[@mov_translation].color != @current_player.color && @mov_translation == @second_coord_convertion\n\t\t\t\treturn true\n\t\t\t#if the destination node color equals to the current player color, check analyzing is in progress and the node name of the translation coordinate equals to king.\n\t\t\telsif @board[@mov_translation].color == @current_player.color && (@board[@mov_translation].name == \"king\" && @check_on_curse == true)\n\t\t\t\treturn true\t\n\t\t\tend\t\t\n\t\tend\n\tend", "def is_in_mc?(position)\n @minimal_solution[position]\n end", "def valid_move?(row, col, queens)\n # Go through each of the current valid moves\n queens.each do |q_pos|\n # Grab the coords\n q_row, q_col = q_pos\n\n # If the coords to be checked land on either the same col or row as an existing\n # valid move, the coords are invalid\n return false if q_row == row || q_col == col\n # Check to see if the slope between the coords and any valid moves is equal to 1.\n # Having a slope of 1 on board means the two points are on the same diagonal line.\n return false if ((row - q_row) / (col - q_col).to_f).abs == 1\n end\n\n true\nend", "def done_or_not(board)\n validate = rows(board) && columns(board) && regions(board)\n if validate\n \"Finished!\"\n else\n \"Try again!\"\n end\nend", "def open_room(x,y,matrix)\n return false if (x < 0 || x > matrix.max.size - 1 || y < 0 || y > matrix.size-1)\n return matrix[y][x] != @maze[:wall]\n end", "def any_mines_detonated?\n for x in 0..@row_count - 1 do\n for y in 0..@column_count - 1 do\n if @cleared_field[[x,y]] && @mine_field[[x,y]]\n return true\n break\n end\n end\n end\n false\n\n end", "def solved?\n !!self.answers.select {|x| x.correct}[0]\n end", "def solved sol\n\tfor i in 0...sol.size\n\t\tfor j in 0...sol[i].size\n\t\t\tif sol[i][j].ord < 'a'.ord\n\t\t\t\treturn false\n\t\t\tend\n\t\tend\n\tend\n\n\treturn true\nend", "def valid_position?(pos)\n r,c = pos\n row_len = @maze[0].length\n col_len = @maze[0].length\n\n # is within bounds of the maze\n r >= 0 && c >= 0 && r < row_len && c < col_len\n end", "def valid?(move,visited)\n return true if (move[0]>-1 && move[0]<8) && (move[1]>-1 && move[0]<8) && (!visited[move[0]][move[1]])\n end", "def solve(begX, begY, endX, endY); MazeSolver.new(plane,graph).solve(begX, begY, endX, endY) end", "def check_matrix\n @matrix.each_with_index do |current_point, i|\n @edges.clear # Set up the edge buffer.\n check_triangles(current_point)\n check_edges(i)\n end\n end", "def solve(args)\n @seen_stack, @need_to_check, solved = [], [], false\n current_cell, finish = map[args[:begX]][args[:begY]], map[args[:endX]][args[:endY]]\n @seen_stack.push(current_cell)\n @need_to_check.push(current_cell)\n\n until @need_to_check.empty? || solved\n current_cell = @need_to_check.shift\n @seen_stack.push(current_cell)\n check_possible_paths(current_cell, finish)\n solved = true if current_cell == finish\n end\n solved\n end", "def finished?\n current_step > 1 && current_step >= game_length + 1\n end", "def any_mines_detonated?\n (0...row_count).to_a.each do |row|\n (0...column_count).to_a.each do |col|\n if @cleared[row][col] == true && @mines[row][col] == true\n return true\n end\n end\n end\n return false\n end", "def done?\n beam.empty?\n end", "def solved?(board)\n board.all? { |row| row.flatten.length == 9 && row.sort == [1,2,3,4,5,6,7,8,9] }\nend", "def can_move(i,j)\n\t\t#posición es 0\n\t\tif @laberinto[i,j] == 0\n\t\t\t#no se a pasado antes por ahi\n\t\t\tif @travel_path.count([i,j]) == 0\n\t\t\t\treturn true\n\t\t\telse \n\t\t\t\treturn false\n\t\t\tend\n\t\telse\n\t\t\treturn false\n\t\tend\n\tend", "def full?(board) #check if the board is full\n board.each_with_index do |position, index|\n if position_taken?(board, index) == false \n return false\n end\n end\n return true\nend", "def check_valid (size)\n #checks length of string correct according to n x m\n if @arg.length != size\n puts \"String length incorrect\"\n end\n #checks if outer wall is all 1's\n string=''\n @col_nums.times do\n string+='1'\n end\n if !@arg[0..@col_nums-1].eql? string\n puts \"Invalid maze (outer wall)\"\n end\n (0..@row_nums*@col_nums-1).step(@col_nums) do |i|\n if @arg[i] != \"1\" || @arg[i-1] != \"1\"\n puts \"Invalid maze (outer wall)\"\n break\n end\n end\n #cell centers should be 0's\n #takes values of cell centers and uses coordinates for make_cell method\n (@col_nums..@row_nums*@col_nums-1).step(@col_nums*2) do |i|\n (1..@col_nums-2).step(2) do |j|\n if @arg[i+j]!=\"0\"\n puts \"Invalid maze (cell center)\"\n break\n else\n make_cell(i+j)\n end\n end\n end\n #cell corners should be 1's\n (0..@row_nums*@col_nums-1).step(@col_nums*2) do |i|\n (0..@col_nums-2).step(2) do |j|\n if @arg[i+j]!=\"1\"\n puts \"Invalid maze (cell corner)\"\n break\n end\n end\n end\n end", "def finished? nodes\n nodes.each { |k,v| return false if !v.done && v.distance != -1 }\n return true \n end", "def won?\n for x in 0..@matrix.length - 1\n for y in 0..@matrix[x].length - 1\n return false if @matrix[x][y] == \"OO\"\n end\n end\n\n true\n end", "def valid_move?(i, j)\n return false if i < 1 or i > @gsize or j < 1 or j > @gsize\n return @ban[j][i].empty?\n end", "def solved\n @solved = @rows.flatten.include?(\"0\") ? false : true\n end", "def been_to?(matrix)\n previous_states.each do |state|\n return true if matrix[0] == state[0] &&\n matrix[1] == state[1] &&\n matrix[2] == state[2]\n end\n\n false\n end", "def is_valid?(x, y)\n return false if x < 0 || x >= @matrix.first.length\n return false if y < 0 || y >= @matrix.length\n return false unless @matrix[y][x] == 1\n return false if @visited[y][x]\n true\n end", "def done?\n puts \"iteration: #{@iterations += 1}\"\n return true if @iterations >= @max_iterations\n return false unless @simplex.permutation(2).map { |e|\n l = Math.sqrt((e[0] - e[1]).to_a.map{ |f| f**2 }.inject(&:+))\n l <= 0.5\n }.all?\n\n _f = 1/3 * @simplex.map(&:result).inject(&:+)\n _d = 1/3 * @simplex.map{ |e| (e.result - _f)**2 }.inject(&:+)\n _d <= TOLERANCE**2\n end", "def reachable(current_pos, maze)\n n = [current_pos, [-1, 0]].transpose.map(&:sum)\n ne = [current_pos, [-1, 1]].transpose.map(&:sum)\n e = [current_pos, [0, 1]].transpose.map(&:sum)\n se = [current_pos, [1, 1]].transpose.map(&:sum)\n s = [current_pos, [1, 0]].transpose.map(&:sum)\n sw = [current_pos, [1, -1]].transpose.map(&:sum)\n w = [current_pos, [0, -1]].transpose.map(&:sum)\n nw = [current_pos, [-1, -1]].transpose.map(&:sum)\n\n # check if valid index\n reachable = [n, ne, e, se, s, sw, w, nw].select do |pos|\n y, x = pos\n if y < 0 || x < 0\n false\n elsif x > maze[0].length - 1 || y > maze.length - 1\n false\n else\n true\n end\n end\n\n # filter out wall\n reachable.select do |pos|\n y, x = pos\n maze[y][x] != \"*\"\n end\n end", "def valid?\n 81.times do |i|\n return false if @board[i] == 0\n return false unless check?(i)\n end\n\n true\n end", "def check_diagonal\n RulesContracts.classic_model(@game_state_model)\n # testing for bitboard errors\n # (0..7).each { |y|\n # (0..7).each { |x|\n # if @grid[y][x] == 1 and y <= 4 and x >= 3\n # puts \" #{x}/#{y} #{@grid[y][x]} || #{x-1}/#{y+1} #{@grid[y + 1][x - 1]} || #{x-2}/#{y+2} #{@grid[y + 2][x - 2]} || #{x-3}/#{y+3} #{@grid[y + 3][x - 3]}\"\n # puts \"#{@grid[y][x] == 1 and @grid[y + 1][x - 1] == 1 and @grid[y + 2][x - 2] == 1 and @grid[y + 3][x - 3] == 1}\"\n # end\n # }\n # }\n \n (0..7).each { |y|\n (0..7).each { |x|\n if y <= 4 and x <= 4\n if @grid[y][x] == 2 and @grid[y + 1][x + 1] == 2 and @grid[y + 2][x + 2] == 2 and @grid[y + 3][x + 3] == 2\n @winner = 1\n return true\n elsif @grid[y][x] == 1 and @grid[y + 1][x + 1] == 1 and @grid[y + 2][x + 2] == 1 and @grid[y + 3][x + 3] == 1\n @winner = 0\n return true\n end \n end\n if y <= 4 and x >= 3\n if @grid[y][x] == 2 and @grid[y + 1][x - 1] == 2 and @grid[y + 2][x - 2] == 2 and @grid[y + 3][x - 3] == 2\n @winner = 1\n return true\n elsif @grid[y][x] == 1 and @grid[y + 1][x - 1] == 1 and @grid[y + 2][x - 2] == 1 and @grid[y + 3][x - 3] == 1\n @winner = 0\n return true\n end\n end\n if y >= 3 and x <= 4\n if @grid[y][x] == 2 and @grid[y - 1][x + 1] == 2 and @grid[y - 2][x + 2] == 2 and @grid[y - 3][x + 3] == 2\n @winner = 1\n return true\n elsif @grid[y][x] == 1 and @grid[y - 1][x + 1] == 1 and @grid[y - 2][x + 2] == 1 and @grid[y - 3][x + 3] == 1\n @winner = 0\n return true\n end \n end\n if y >= 3 and x >= 3\n \n if @grid[y][x] == 2 and @grid[y - 1][x - 1] == 2 and @grid[y - 2][x - 2] == 2 and @grid[y - 3][x - 3] == 2\n @winner = 1\n return true\n elsif @grid[y][x] == 1 and @grid[y - 1][x - 1] == 1 and @grid[y - 2][x - 2] == 1 and @grid[y - 3][x - 3] == 1\n @winner = 0\n return true\n end \n \n end \n }\n }\n return false\n end" ]
[ "0.7384006", "0.72615165", "0.72250617", "0.7160867", "0.695254", "0.6948034", "0.6912617", "0.6813264", "0.6771722", "0.67707443", "0.67015135", "0.6670485", "0.6668237", "0.66547185", "0.66277486", "0.6622541", "0.66212934", "0.66190505", "0.6603029", "0.6593161", "0.6579342", "0.65678173", "0.6542992", "0.652534", "0.6518315", "0.65166", "0.6471024", "0.6466834", "0.6458616", "0.645792", "0.6449515", "0.6434022", "0.6427889", "0.64021695", "0.6395025", "0.63901407", "0.6382955", "0.63819975", "0.6344505", "0.63058555", "0.6288316", "0.6285831", "0.6268886", "0.6257847", "0.6240857", "0.6237102", "0.6200694", "0.6192808", "0.61927515", "0.6191835", "0.6188072", "0.6177891", "0.61773616", "0.61696213", "0.6165365", "0.6158835", "0.6136096", "0.6135538", "0.61274654", "0.6122548", "0.61157787", "0.60960436", "0.6094944", "0.6078509", "0.60782814", "0.6077641", "0.60701984", "0.60614747", "0.60583603", "0.605678", "0.6043899", "0.60429513", "0.60429114", "0.60390884", "0.6037238", "0.6036849", "0.60361326", "0.6035752", "0.6031753", "0.6027469", "0.60273916", "0.6025735", "0.6016032", "0.6014867", "0.60115665", "0.60038185", "0.60037994", "0.60014606", "0.59821934", "0.5979709", "0.59768736", "0.59497076", "0.5946317", "0.5940545", "0.59388745", "0.5927841", "0.59263015", "0.5923471", "0.59177285", "0.5908012", "0.5901436" ]
0.0
-1
Generate the next round of paths
def next_paths Operations.list.map do |operation| new_value = Operations.send(operation, @current_value) operation_history = @operation_history + [operation] Path.new(new_value, @target_value, operation_history: operation_history) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def paths(n)\n return nCr(2*(n-1),n)\nend", "def path(k)\n x = k\n y = 1 - k\n path = []\n direction = 1\n (k*8).times do |i|\n path.push(x.to_s + ';' + y.to_s)\n if direction == 1\n y += 1\n direction = 2 if y == k\n elsif direction == 2\n x -= 1\n direction = 3 if x * (-1) == k\n elsif direction == 3\n y -= 1\n direction = 4 if y * (-1) == k\n elsif direction == 4\n x += 1\n end\n end\n path\nend", "def next_step position, tabu_list\n paths = get_all_paths_from position, tabu_list\n probabilities = paths.map {|path| probability(path.first, path.last, 0, tabu_list)}\n path_probabilities = paths.zip probabilities\n picked_number = rand\n\t path_probabilities.each { |pair|\n\t path = pair.first\n\t prob = pair.last\n\t\t picked_number -= prob\n\t\t return path.last if picked_number <= 0.0\r\n\t }\n end", "def create_path(paths, index, current_stop)\n next_stops = @bus_routes.find_next_stops(current_stop)\n\n unless next_stops.size == 0\n path = Array.new(paths[index])\n next_stops.each do |next_stop|\n if next_stop == next_stops[0]\n paths[index] << next_stop.id\n create_path(paths, index, next_stop)\n else\n path_1 = Array.new(path)\n path_1 << next_stop.id\n paths << path_1\n create_path(paths, paths.size-1, next_stop)\n end\n end\n end\n end", "def paths(points)\n paths = []\n (0...(points.count-1)).each do |point_1|\n ((point_1+1)...points.count).each do |point_2|\n paths << [point_1,point_2]\n end\n end\n paths\nend", "def next_step_from(paths)\n paths.map do |path|\n possible_neighbours(path.most_recent_step.coordinate, @max_x, @max_y) \n .map { |c| coord_to_step_on_path(c, path) }\n .reject { |p| p == nil }\n end\n .flatten\n end", "def find_paths(grid_size)\n # array/list sums records the sum of paths in a grid of size sums[i+1]\n sums = [1] * 20\n for i in 0...grid_size\n for j in 0...i do\n sums[j] = (sums[j] + sums[j-1])\n end\n sums[i] = 2 * sums[i-1]\n end\n sums[grid_size - 1]\nend", "def gen_first_path(path_length)\n # we will now generate an array with path_length number of elements\n # the elements will be randomly selected numbers from (1.. path_length ^ 2)\n # to avoid duplicate numbers we will kepp track of which ones have already been used\n # in another local array\n\n used = []\n\n path = {}\n\n path_length.times do |k, v|\n random = gen_uniq_rand(path_length ** 2, used)\n used << random\n path[random] = 0\n end\n\n path\nend", "def calc_path\n endpoint = grid.target\n while endpoint\n search.path[endpoint] = true\n endpoint = search.came_from[endpoint]\n end\n end", "def new_paths_in(folder, count)\n first_node = ensure_unique_node(folder.path, SecureRandom.hex(8))\n remainder = count - 1\n remainder.times.inject([first_node]) do |nodes|\n path = File.join nodes.last.path, SecureRandom.hex(8)\n nodes << Folder.new(path)\n end\n end", "def generate_paths_for(offsets, piece, game)\n board = game.board\n pieces = game.pieces\n moves = {}\n offsets.each do |offset|\n i = 1\n last_tile = piece.position\n # max length of a path in any direction is 7\n 7.times do |n|\n next_tile ||= \"\"\n adjusted_offset = offset * i \n coords = offsets_to_coordinates([adjusted_offset], piece, game)\n next_tile = coords unless coords.nil?\n move = { next_tile => [] }\n case \n when wrapped?(next_tile, last_tile)\n break\n when chess_board.is_piece?(next_tile, game)\n if next_tile != \"\" && chess_board.is_enemy?(next_tile, piece.color, game) \n moves.merge!( move ) \n break\n else\n break\n end\n else\n moves.merge!( move ) unless next_tile == \"\"\n end\n i += 1\n last_tile = next_tile\n end\n end\n moves\n end", "def lattice_paths(grid_size)\n grid_dimension = grid_size + 1\n grid = Array.new(grid_dimension * grid_dimension) { 1 }\n (grid_size - 1).downto(0) do |x|\n (grid_size - 1).downto(0) do |y|\n pos = (y * grid_dimension) + x\n grid[pos] = grid[pos + 1] + grid[pos + grid_dimension]\n end\n end\n grid[0]\nend", "def get_path(start, finish) \n @retreat_algorithm.set_graph(memory.construct_grid) \n @retreat_algorithm.run(start, finish)\n end", "def build_paths(start)\n step = 0\n visited = []\n unvisited = [[board_node_by_location(start),step]]\n \n while !unvisited.empty?\n node = unvisited[0][0]\n step = unvisited[0][1] + 1\n \n node.neighbors.each do |x|\n if not_visited(board_node_by_location(x),visited, unvisited)\n unvisited << [board_node_by_location(x),step]\n end\n end\n visited << unvisited.shift\n end\n return visited\nend", "def lattice_paths(grid_size)\n # Initialization\n intersections = Array.new(grid_size + 1)\n intersections.map! { |r| Array.new(grid_size + 1) }\n\n # Base case - at the bottom and right edges, there is only one route remaining.\n # Technically the bottom-right point has no routes remaining, but it doesn't matter here.\n (0..grid_size).each do |i|\n intersections[i][grid_size] = 1\n intersections[grid_size][i] = 1\n end\n\n calculate_routes(0, 0, intersections)\n\n intersections[0][0]\nend", "def next_path map, h, w\n\n\tlow = map[h][w].to_i\n\tlh = h\n\tlw = w\n\n\tif h - 1 >= 0\n\t\tnh = h - 1\n\t\tnw = w\n\t\tnorth = map[nh][nw].to_i\n\t\tif north < low\n\t\t\tlow = north\n\t\t\tlh = nh\n\t\t\tlw = nw\n\t\tend\n\tend\n\n\tif w - 1 >= 0\n\t\twh = h\n\t\tww = w - 1\n\t\twest = map[wh][ww].to_i\n\t\tif west < low\n\t\t\tlow = west\n\t\t\tlh = wh\n\t\t\tlw = ww\n\t\tend\n\tend\n\t\n\tif w + 1 < map[0].size\n\t\teh = h\n\t\tew = w + 1\n\t\teast = map[eh][ew].to_i\n\t\tif east < low\n\t\t\tlow = east\n\t\t\tlh = eh\n\t\t\tlw = ew\n\t\tend\n\tend\n\n\tif h + 1 < map.size\n\t\tsh = h + 1\n\t\tsw = w\n\t\tsouth = map[sh][sw].to_i\n\t\tif south < low\n\t\t\tlow = south\n\t\t\tlh = sh\n\t\t\tlw = sw\n\t\tend\n\tend\n\n\treturn lh, lw\nend", "def simulate_path\n path = [initial_per_share]\n t = 0\n while t < duration - 1e-6\n t += dt\n path << path.last * Math.exp(drift * dt + volatility * Math.sqrt(dt) * OptionValue.gaussian(0, 1))\n end\n path\n end", "def path_to_next_position(next_position)\n path = []\n diff1 = next_position[0] - current_position[0]\n diff2 = next_position[1] - current_position[1]\n symb_d1 = 0\n symb_d2 = 0\n symb_d1 = diff1.abs/diff1 if diff1 != 0\n symb_d2 = diff2.abs/diff2 if diff2 != 0\n if diff1 == 0\n (diff2-1).abs.times{|num|\n path << [current_position[0]+symb_d1*(num+1),current_position[1]+symb_d2*(num+1)]\n }\n elsif diff2 == 0\n (diff1-1).abs.times{|num|\n path << [current_position[0]+symb_d1*(num+1),current_position[1]+symb_d2*(num+1)]\n }\n end\n path\n end", "def steps (x, y, path)\n if x == 0 && y == 0\n then puts (path)\n return\n end\n if x > 0\n then steps(x - 1, y, path + \"R\")\n steps(x - 1, y + 1, path + \"L\")\n end\n if y > 0\n then steps(x, y - 1, path + \"H\")\n end\nend", "def number_of_paths(n)\n return 0 if n < 0\n return 1 if n == 1 || n == 0\n number_of_paths(n - 1) + number_of_paths(n - 2) + number_of_paths(n - 3)\nend", "def build_path(start, finish)\n path = [finish]\n loop do\n vertex = path.last\n d = graph[*vertex]\n neighbours = get_neighbours(*vertex)\n next_vertex = neighbours.select{|n_vert| graph[*n_vert] == d - 1}.first\n path << next_vertex if next_vertex\n break if vertex == start\n end\n path\n end", "def run\n closed_squares = []\n opened_squares = [@start]\n\n @start.current_path_cost = 0\n\n while opened_squares.any?\n current_square = opened_squares.sort do |a, b|\n a.estimated_total_cost(@finish) <=> b.estimated_total_cost(@finish)\n end.first\n\n if current_square == @finish\n return find_path(current_square)\n end\n\n closed_squares.push(current_square)\n opened_squares.delete(current_square)\n\n @board.neighbours(current_square).each do |neighbour|\n if closed_squares.include?(neighbour)\n next\n end\n\n if !opened_squares.include?(neighbour)\n opened_squares.push(neighbour)\n end\n\n if current_square.current_path_cost + neighbour.move_cost >= neighbour.current_path_cost\n next\n end\n\n neighbour.path_via = current_square\n neighbour.current_path_cost = current_square.current_path_cost + neighbour.move_cost \n end\n end\n end", "def shortest_path\n initial_position_obj = { position: start_position, source: {} }\n\n knights_path = [initial_position_obj]\n\n while knights_path.present?\n current_position = knights_path.shift\n\n position = current_position[:position]\n\n if position == end_position\n return path_to_destination(current_position, initial_position_obj)\n end\n\n add_possible_destination(position, current_position, knights_path)\n end\n end", "def solve( start, finish )\n return [start] if start == finish\n \n seen = {start => true}\n paths = [[start]]\n \n until paths.first.last == finish\n path = paths.shift\n \n new_paths = [path.dup << path.last * 2, path.dup << path.last + 2]\n new_paths << (path.dup << path.last / 2) if path.last.even?\n \n new_paths.each do |new_path|\n unless seen[new_path.last]\n paths << new_path\n seen[new_path.last] = true\n end\n end\n end\n \n paths.shift\nend", "def paths(arr, s, d)\n if invalid?(arr, s, d)\n return\n end\n\n if s == d\n $path_count = $path_count + 1\n return\n end\n\n cells = valid_cells(arr, s)\n cells.each do |cell|\n paths(arr, cell, d)\n end\nend", "def paths()\n assert( @maximum.exists?, \"you cannot obtain paths() for an infinite Repeater\" )\n assert( @maximum <= 10, \"if you really need to obtain paths() for a Repeater with greater than 10 elements, change this assertion\" )\n \n #\n # First, compile the element to its paths. We will end up with a BranchPoint.\n \n element_paths = nil\n if @element.is_an?(ExpressionForm) then\n element = @element.paths\n else\n element = BranchPoint.new( Sequence.new(@element) )\n end\n \n #\n # Next, produce a BranchPoint with a Sequence for each count we are doing.\n \n run = Sequence.new()\n minimum.times do\n run << element\n end\n \n result = BranchPoint.new( run )\n (maximum - minimum).times do\n run = Sequence.new( run, element )\n run.minimal = false\n result << run\n end\n \n \n #\n # Finally, get the paths of the produced Sequence.\n \n return result.paths\n end", "def find_path_brute_force( board, start_point )\n options = get_options( start_point, board )\n\n # Bottom right corner\n if options.length == 0\n return { points: [start_point], best_value: get_value( start_point, board ) }\n end\n\n # If there's only one option, this works fine still.\n first_result = find_path_brute_force( board, options.first )\n second_result = find_path_brute_force( board, options.last )\n if first_result[:best_value] > second_result[:best_value]\n return {\n points: [start_point] + first_result[:points],\n best_value: first_result[:best_value] + get_value( start_point, board )\n }\n else\n return {\n points: [start_point] + second_result[:points],\n best_value: second_result[:best_value] + get_value( start_point, board )\n }\n end\nend", "def routes_for(grid_size)\n choices = grid_size * 2\n \n factorial(choices) / (factorial(grid_size) * factorial(choices - grid_size))\nend", "def generate_match_paths(matches, players)\n i, matches_per_round = 1, 2\n round_depth = Math.log2(players.length).ceil\n query = MatchPath.select(:parent_match_id, :child_match_id, :result)\n .where(parent_match_id: matches).reorder(parent_match_id: :asc)\n \n match_paths = Array.new(round_depth, [])\n match_paths[0] = [matches.first]\n\n while (i < round_depth)\n j, k = 0, 0\n match_paths[i] = Array.new(matches_per_round, nil)\n while (k < match_paths[i - 1].count)\n results = query.where(child_match_id: match_paths[i - 1][k])\n if (!results.blank?)\n results.each do |row|\n match_paths[i][j] = row.parent_match_id\n j += 1\n end\n else\n match_paths[i][j] = nil\n j += 1\n end\n k += 1\n end\n\n i += 1\n matches_per_round *= 2\n end\n return match_paths\n end", "def count_paths(grid_size)\n factorial(2*grid_size) / (factorial(grid_size) * factorial(grid_size))\nend", "def knight_path(from, to)\r\n\topen_queue = [PositionPath.new( from, [copy(from)] )]\r\n\tputs open_queue.inspect\r\n\tputs open_queue.empty?\r\n\tdiscovered = [from]\r\n\r\n\tuntil open_queue.empty?\r\n\t\tcurrent = open_queue.shift\r\n\t\tputs current.inspect\r\n\r\n\t\treturn current.path if current.position == to\r\n\t\tvalid_moves(current.position).each do |move|\r\n\t\t\tputs \"ruch #{move} jest ok\"\r\n\t\t\tunless discovered.include?(move)\r\n\t\t\t\tputs \"tego ruchu jeszce nie bylo = #{move}\"\r\n\t\t\t\tdiscovered << move\r\n\t\t\t\topen_queue.push(make_position_path(current, move)) \r\n\t\t\t\tputs \"open_queue = #{open_queue.size}\"\r\n\t\t\tend\r\n\t\tend\r\n\tend\r\n\t\r\nend", "def draw_route\n # Delete all sprites in drawing of path\n @arrow_path.each{|a| a.dispose}\n @arrow_path = []\n \n return if @passed_positions.empty?\n start_pos = [@unit.x, @unit.y]\n new_pos = start_pos\n type = \"\"\n # Get direction from unit to first tile in path\n last_dir = case [@passed_positions[0].x - @unit.x, @passed_positions[0].y - @unit.y]\n when [0, 1] then 2\n when [-1,0] then 4\n when [1, 0] then 6\n when [0,-1] then 8\n end\n # Loop through path positions, evaluating two elements at a time\n for i in 0...@passed_positions.size\n p1 = @passed_positions[i]\n p1 = [p1.x, p1.y]\n p2 = (@passed_positions[i+1] == nil ? 0 : @passed_positions[i+1])\n if p2.is_a?(MoveTile)\n p2 = [p2.x, p2.y] \n # Figure out the direction taken to get from p1 to p2\n dir = [p2[0] - p1[0], p2[1] - p1[1]]\n dir = case dir\n when [0, 1] then 2\n when [-1,0] then 4\n when [1, 0] then 6\n when [0,-1] then 8\n end\n else\n dir = 0\n end\n # Evaluate the last direction taken to get to current spot\n case last_dir\n when 2\n new_pos[1] += 1\n type = case dir\n when 0 then \"d\"\n when 2 then \"v\"\n when 4 then \"ru\"\n when 6 then \"lu\"\n end\n when 4\n new_pos[0] -= 1\n type = case dir\n when 0 then \"l\"\n when 2 then \"ld\"\n when 4 then \"h\"\n when 8 then \"lu\"\n end\n when 6\n new_pos[0] += 1\n type = case dir\n when 0 then \"r\"\n when 2 then \"rd\"\n when 6 then \"h\"\n when 8 then \"ru\"\n end\n when 8\n new_pos[1] -= 1\n type = case dir\n when 0 then \"u\"\n when 4 then \"rd\"\n when 6 then \"ld\"\n when 8 then \"v\"\n end\n end\n last_dir = dir\n @arrow_path.push(Arrow_Sprite.new($spriteset.viewport1, type, new_pos))\n end\n end", "def move_to_next_generation\n @x.times{ |r|\n @y.times{|c| \n @mat[r][c].step_generation\n }\n } \n end", "def gen_path(options = {})\n path = Array.new(options[:length])\nend", "def cardinal_paths(direction)\n off_gen = CardinalOffsetGenerator.new(coordinates, direction)\n off_gen.moves\n end", "def knight_path(start, finish)\n\nend", "def processNextStart()\n while true\n path = starts.next\n if building_path\n if compare.call path.first, building_path.first\n add_path path\n else\n return next_path(path)\n end\n else\n next_path(path)\n end\n end\n rescue Pacer::EmptyPipe, java.util.NoSuchElementException\n if building_path\n r = building_path\n self.building_path = nil\n r\n else\n raise EmptyPipe.instance\n end\n end", "def yield_path\n room = @maze[:path]\n while room.parent\n yield room.x, room.y\n room = room.parent\n end\n end", "def mutate s, num_paths, mut_rate\n b = s.map{|i| i.clone}\n b.each{|i| i.path = sample_from((0..(num_paths - 1)).to_a - [i.path], 1)[0] if rand <= mut_rate and num_paths > 1}\n b\n end", "def find_min_path(i, j)\n return 1 if i == 0 || j == 0\n return find_min_path(i-1, j) + find_min_path(i, j-1)\nend", "def generate_next\n session[:solution] == nil && generate\n\n session[:marker] += NPREVIEWS\n\n if session[:marker] >= session[:solution].length\n session[:marker] = 0\n end\n\n session[:solution] && load_sections\n end", "def find_path(start, target)\n node = build_path(start, target)\n path = [node]\n until node.next_node.nil? do\n node = node.next_node\n path.push(node)\n end\n path = path.reverse\n puts \"You made it in #{path.length} moves. Here is your path: \"\n path.each do |node|\n puts \"[#{node.x}], [#{node.y}]\"\n end\nend", "def unique_path(m, n, cache = {})\n return 1 if m == 1 || n == 1\n if cache[[m, n]]\n return cache[[m,n]]\n end\n cache[[m,n]] = unique_path(m-1, n) + unique_path(m, n-1)\nend", "def construct_solution\n path = [@root]\n tabu_list = [@root]\n until @ends.include?(last = path.last)\n step = next_step last, tabu_list\n path << step\n end\n path\n end", "def unique_paths_with_obstacles(obstacle_grid)\n m, n = obstacle_grid.length, obstacle_grid[0].length\n m.times do |i|\n n.times do |j|\n if obstacle_grid[i][j] == 1\n obstacle_grid[i][j] = 0\n elsif i == 0 && j == 0\n obstacle_grid[i][j] = 1\n elsif i == 0\n obstacle_grid[i][j] = obstacle_grid[i][j-1] * 1\n elsif j == 0\n obstacle_grid[i][j] = obstacle_grid[i-1][j] * 1\n else \n obstacle_grid[i][j] = obstacle_grid[i-1][j] + obstacle_grid[i][j - 1]\n end \n end \n end \n\n obstacle_grid[m-1][n-1]\nend", "def path_count(steps, current=0)\n if current == steps\n 1\n elsif current > steps\n 0\n else\n path_count(steps, current + 1) +\n path_count(steps, current + 2) +\n path_count(steps, current + 3)\n end\nend", "def count_ways_up_stairs(steps)\n return 0 if steps < 0\n return steps if steps <= 2\n\n paths = []\n paths[0] = 1\n paths[1] = 1\n paths[2] = 2\n\n (3...steps).each do |i|\n count = paths[0] + paths[1] + paths[2]\n paths[0] = paths[1]\n paths[1] = paths[2]\n paths[2] = count\n end\n\n paths[2]\nend", "def getShortestPath(max_jumps, random=true)\n checkValidSetup\n \n sequenceOfDives = DiveSequence.new\n \n move_pairs =\n @movePool.values.map { |a| @movePool.values.map { |b| [a, b] } }. # make some arrays of move pairs\n inject([]) { |result, move_pairs| result.concat(move_pairs) }. # concatenate those into a single array of move pairs\n reject { |a, b| a == b } # throw away pairs of the same move\n \n move_pairs.sort! { |x,y| x[0].symbol.rjust(3) << x[1].symbol.rjust(3) <=> y[0].symbol.rjust(3) << y[1].symbol.rjust(3) } unless random\n\n lastMove = random ? move_pairs[rand(move_pairs.length)].first : move_pairs.first.first\n currentDive = Dive.new(lastMove)\n \n while !move_pairs.empty? && ((max_jumps <= 0) || (sequenceOfDives.length < max_jumps)) # if max_jumps > 0 them limit jumps to max_jumps\n currentDivePoints = lastMove.points unless currentDive.length > 1\n\n nextMove =\n if !(next_moves = move_pairs.select { |a, b| a == lastMove }.map { |a, b| b } - currentDive).empty?\n # standard random call for next move when there are loads of moves available\n random ? next_moves[rand(next_moves.length)] : next_moves.first\n elsif !(next_moves = move_pairs.map { |a, b| a } - currentDive).empty?\n # nothing left in last permutation, just get a new starting position\n random ? next_moves[rand(next_moves.length)] : next_moves.first\n else\n # just pull anything from the move pool that has not been used, nothing left at all to use!\n anymovepool = @movePool.values.reject { |move| currentDive.include?(move) }\n random ? anymovepool[rand(anymovepool.length)] : anymovepool.first\n end\n\n currentDivePoints += nextMove.points\n currentDive << nextMove\n \n # clean up, remove the pair lastMove-nextMove\n move_pairs.delete([lastMove, nextMove])\n\n # puts (lastMove.points.to_s + \"_\" + nextMove.points.to_s + \" \" + currentDivePoints.to_s + \":\" + (currentDive.collect {|a| a.symbol + \"-\"}).to_s)\n\n if (currentDivePoints < @minPointsPerRound)\n lastMove = nextMove\n else\n # remember that a sequence such as ABC also has the pair CA in it because ABC is ABCABCABC... delete movePermutation CA\n move_pairs.delete([currentDive.first, currentDive.last])\n\n sequenceOfDives << currentDive\n\n lastMove = (random ? move_pairs[rand(move_pairs.length)].first : move_pairs.first.first) unless move_pairs.empty?\n currentDive = Dive.new(lastMove)\n end\n end\n \n sequenceOfDives\n end", "def knight_moves(initial, final)\n @board.check_impossible_move(initial, final)\n\n search_queue = [Vertex.new(initial)]\n\n until search_queue.empty?\n test_vertex = search_queue.shift\n\n return show_path(make_path(test_vertex)) if test_vertex.value == final\n \n @board.possible_moves(test_vertex.value).each do |move|\n new_vertex = Vertex.new(move)\n new_vertex.parent = test_vertex\n test_vertex.children << move\n search_queue << new_vertex\n end \n\n end\n \"No path was found :(\"\n end", "def calculate_path(actor)\n reset_baconator(actor)\n node_search do |current_node|\n process_single_node(current_node)\n end\n end", "def next_gen\n @grid.calc_new_generation\n @generation += 1\n @current_gen_same_as_prev = @grid.current_gen_same_as_prev\n end", "def next_step_to_shortest_path(from_x, from_y, to_x, to_y)\n move = shortest_path(from_x, from_y, to_x, to_y)&.first\n return nil unless move\n if move[0] == from_x && move[1] == from_y + 1\n return 'S'\n elsif move[0] == from_x && move[1] == from_y - 1\n return 'N'\n elsif move[0] == from_x + 1 && move[1] == from_y\n return 'E'\n elsif move[0] == from_x - 1 && move[1] == from_y\n return 'W'\n end\n raise 'This should not happen'\n end", "def draw_paths; end", "def knight_path(from, to)\n\topen_queue = [PositionPath.new( from, [copy(from)] )]\n\tdiscovered = [from]\n\n\tuntil open_queue.empty?\n\t\tcurrent = open_queue.shift\n\n\t\treturn current.path if current.position == to\n\t\tvalid_moves(current.position).each do |move|\n\t\t\tunless discovered.include?(move)\n\t\t\t\tdiscovered << move\n\t\t\t\topen_queue.push(make_position_path(current, move)) \n\t\t\tend\n\t\tend\n\tend\n\t\nend", "def construct_path(current_node, last_film)\n path = [last_film]\n return path if current_node.predecessor.empty?\n\n while current_node.predecessor[1]\n path.unshift(current_node.predecessor[0])\n return \"Kevin Bacon is more than 6 connections away.\" if path.length > 6\n current_node = current_node.predecessor[1]\n end\n path\n end", "def get_path(node, root)\r\n path = []\r\n until path.last == root.current_case\r\n path << node.current_case\r\n node = node.parent\r\n end\r\n\r\n puts \"You made it in #{path.size - 1} moves! Here's your path:\"\r\n path.reverse.each { |c| puts c.inspect }\r\n end", "def path(start, goals, mode=:move_to, ignore={})\n start = start.map(&:to_i)\n goals = goals.flatten.size == 3 ? [goals.flatten] : goals\n\n if goals.reject { |goal| (start[0] - goal[0]).abs + (start[1] - goal[1]).abs + (start[2] - goal[2]).abs > MAX_PATH_SIZE }.empty?\n puts \"target too far away\"\n return nil\n elsif mode == :move_to && goals.select { |g| allowed?(*g) }.empty?\n puts \"can't go there...\"\n return nil\n # elsif mode == :next_to && goals.map { |g| available(*g, :next_to).any? { |l| allowed?(*l) } }.empty?\n # puts \"nothing to move next to anymore...\"\n # return nil\n end\n visited = {}\n next_to = {}\n examined = 0\n\n heap = Heap.new { |a, b| a.cost <=> b.cost }\n heap.add Path.new(start, goals, [])\n\n while !heap.empty?\n point = heap.next\n\n if point.path.size > MAX_PATH_SIZE\n puts \"examined #{examined} paths before giving up\"\n return nil\n end\n\n next if visited[point.point]\n visited[point.point] = point\n\n examined += 1\n\n case mode\n when :move_to\n if goals.include?(point.point)\n final_path = point.path + [point.point]\n final_path.shift # don't need the start point, we're already there\n # puts \"examined #{examined} paths\"\n return final_path\n end\n\n when :away_from\n above = point.point.dup\n above[1] += 1\n if !goals.include?(point.point) && !goals.include?(above)\n final_path = point.path + [point.point]\n return final_path\n end\n\n when :next_to\n next_to[point.point] ||= available(*point.point, :build)\n available_for_building = next_to[point.point]\n if available_for_building.any? { |a| goals.include? a }\n final_path = point.path + [point.point]\n final_path.shift # don't need the start point, we're already there\n # puts \"examined #{examined} paths\"\n return final_path\n end\n\n else\n raise \"unknown pathfinding mode: #{mode.inspect}\"\n end\n\n next_available = available(*point.point, :move, ignore).each do |test|\n next if visited[test]\n heap.add Path.new(test, goals, point.path + [point.point])\n end\n end\n nil\n end", "def find_path()\n visited = Array.new(8) {Array.new(8)}\n return [] if @destination == @currentPosition\n paths = [[@currentPosition]]\n visited[@currentPosition[0]][@currentPosition[1]] = true\n\n until paths.empty?\n new_paths = []\n paths.each do |path|\n next_positions = possibleMoves(path.last, visited)\n next_positions.each do |move|\n newpath = path.dup << move\n if move == @destination #if we reached our destination stop and return the path\n return newpath\n end\n visited[move[0]][move[1]] = true\n new_paths.push(newpath)\n end\n end\n paths = new_paths\n end\n end", "def draw_route\n # Delete all sprites in drawing of path\n if @arrow_path != nil\n @arrow_path.each{|a|\n a.dispose\n }\n end\n # Initialize variables\n @arrow_path = []\n return if @passed_positions.empty?\n start_pos = [@selected_unit.x, @selected_unit.y]\n new_pos = start_pos\n type = \"\"\n # Get direction from unit to first tile in path\n last_dir = case [@passed_positions[0].x - @selected_unit.x, @passed_positions[0].y - @selected_unit.y]\n when [0, 1] then 2\n when [-1,0] then 4\n when [1, 0] then 6\n when [0,-1] then 8\n end\n # Loop through path positions, evaluating two elements at a time\n for i in 0...@passed_positions.size\n p1 = @passed_positions[i]\n p1 = [p1.x, p1.y]\n p2 = (@passed_positions[i+1] == nil ? 0 : @passed_positions[i+1])\n if p2.is_a?(MoveTile)\n p2 = [p2.x, p2.y] \n # Figure out the direction taken to get from p1 to p2\n dir = [p2[0] - p1[0], p2[1] - p1[1]]\n dir = case dir\n when [0, 1] then 2\n when [-1,0] then 4\n when [1, 0] then 6\n when [0,-1] then 8\n end\n else\n dir = 0\n end\n # Evaluate the last direction taken to get to current spot\n case last_dir\n when 2\n new_pos[1] += 1\n case dir\n when 0 then type = \"d\"\n when 2 then type = \"v\"\n when 4 then type = \"ru\"\n when 6 then type = \"lu\"\n end\n when 4\n new_pos[0] -= 1\n case dir\n when 0 then type = \"l\"\n when 2 then type = \"ld\"\n when 4 then type = \"h\"\n when 8 then type = \"lu\"\n end\n when 6\n new_pos[0] += 1\n case dir\n when 0 then type = \"r\"\n when 2 then type = \"rd\"\n when 6 then type = \"h\"\n when 8 then type = \"ru\"\n end\n when 8\n new_pos[1] -= 1\n case dir\n when 0 then type = \"u\"\n when 4 then type = \"rd\"\n when 6 then type = \"ld\"\n when 8 then type = \"v\"\n end\n end\n last_dir = dir\n @arrow_path.push(Arrow_Sprite.new(@arrows_viewport, type, new_pos))\n end\n end", "def robot_paths(x, y, map={})\n if x == 0 && y == 0\n 0\n elsif (x == 0 && y >= 0) || (x >= 0 && y == 0)\n 1\n elsif map[x] && map[x][y]\n map[x][y]\n else\n result = robot_paths(x - 1, y, map) + robot_paths(x, y - 1, map)\n map[x] ? map[x][y] = result : map[x] = {y => result}\n map[x][y]\n end\nend", "def get_path(double_array, path_cost, path_time)\n double_array.each do |path|\n correct_path = []\n cost = 0\n time = 0\n count = 0\n until count == path.size - 1\n correct_edge = @edge_array.find { |i| \n i.source == path[count] && i.destination == path[count+1] \n }\n cost += correct_edge.cost\n time += correct_edge.time\n count += 1\n end\n if cost == path_cost && time == path_time\n return path\n end\n end\n end", "def path_finder \n until queue.empty? \n current_node = queue.shift()\n generate_neighbours(current_node)\n current_node.neighbour_nodes.each do |neighbour|\n track_visited(current_node, neighbour)\n correct_node?(neighbour) ? (return neighbour.visited) : (queue << neighbour)\n end\n end\n end", "def getPath(location1, location2)\n accTime = 0.0 # accumulated driving time in seconds\n fullPath = \"\" # track this path\n\n # counters for distances traveled\n needX = (@locations[location2].x - @locations[location1].x)\n needY = (@locations[location2].y - @locations[location1].y)\n currentX = @locations[location1].x\n currentY = @locations[location1].y\n\n absX = needX.abs # Absolute distance to be traveled in X direction \n absY = needY.abs # Absolute distance to be traveled Y\n if (absX > 2 || absY > 2) # allow for a \"looser\" travel algorithm for longer distances\n loose = true # This is meant to meander a bit outside of a direct path to see\n else # if any advantage can be gained\n loose = false\n end\n \n if absX == 0 # sign is 0 is there is no travel needed in X direction\n signX = 0\n else # Otherwise, sign will be +1 or -1, depending on direction we need to go \n signX = needX / absX # direction we are going X\n end\n if absY == 0 # same treatment for Y\n signY = 0\n else\n signY = needY / absY # direction we are going Y\n end\n\n fullPath << \"Moving from location #{@locations[location1].name} to #{@locations[location2].name}:\\n\"\n\n counter = 1\n while (needX != 0 || needY != 0) do\n # make a move\n # if running the more \"loose\" algorithm, then possibly start with one, two, or three counter-intuitive moves\n if loose && counter == 1 && rand(3) == 1\n moves = rand(3) + 1 # do 1, 2, or 3 counter-intuitive moves\n case rand(2) # what direction?\n when 0 # make an \"exploratory\" move in the X direction\n fullPath << \" Exploring X direction #{moves} moves, \"\n needX += signX * moves # make the move if still need progress in this direction\n currentX -= signX * moves\n speed = Rules::SPEED_LIMITX[currentY] # get the speed limit on this \"street\"\n fullPath << \"speed limit is #{speed}, \"\n speed = speed.to_f / 3600.0 # convert speed from mph to miles per second\n time = moves / speed # time required is dist traveled (1 mile) / speed\n fullPath << \"time required #{time.round(2)}\\n\"\n accTime += time # Add travel time this move, in seconds\n counter += 1\n next\n\n when 1 # make an \"exploratory\" move in the Y direction\n fullPath << \" Exploring Y direction #{moves} moves, \"\n needY += signY * moves # make the move if still need progress in this direction\n currentY -= signY * moves\n speed = Rules::SPEED_LIMITY[currentX] # get the speed limit on this \"street\"\n fullPath << \"speed limit is #{speed}, \"\n speed = speed.to_f / 3600.0 # convert speed from mph to miles per second\n time = moves / speed # time is dist traveled (1 mile) / speed\n fullPath << \"time required #{time.round(2)}\\n\" \n accTime += time # Add travel time this move, in seconds\n counter += 1\n next\n end\n end\n\n case rand(2) # choose a move (one mile) at random, either in X direction or Y\n when 0 # moving in the X direction\n next if needX == 0 # try another move if we don't need to move in X direction\n fullPath << \" Moving X direction, \"\n needX -= signX # make the move if still need progress in this direction\n currentX += signX\n speed = Rules::SPEED_LIMITX[currentY] # get the speed limit on this \"street\"\n fullPath << \"speed limit is #{speed}, \"\n speed = speed.to_f / 3600.0 # convert speed from mph to miles per second\n time = 1.0 / speed # time required is dist traveled (1 mile) / speed\n fullPath << \"time required #{time.round(2)}\\n\"\n accTime += time # Add travel time this move, in seconds\n when 1 # moving in the Y direction\n\n next if needY == 0 # try another move if we don't need to move in Y direction\n fullPath << \" Moving Y direction, \"\n needY -= signY # make the move if still need progress in this direction\n currentY += signY\n speed = Rules::SPEED_LIMITY[currentX] # get the speed limit on this \"street\"\n fullPath << \"speed limit is #{speed}, \"\n speed = speed.to_f / 3600.0 # convert speed from mph to miles per second\n time = 1.0 / speed # time is dist traveled (1 mile) / speed\n fullPath << \"time required #{time.round(2)}\\n\" \n accTime += time # Add travel time this move, in seconds \n end\n counter += 1\n end \n\n # Confirm that we are at the end point, otherwise the code is jacked up!! \n puts \" Travel error!\" if currentX != @locations[location2].x || currentY != @locations[location2].y\n accTime = accTime.round(2) # reduce precision to hundreths of a second\n return [accTime, fullPath]\n end", "def next(node)\n @path[@path.index(node) + 1]\n end", "def unique_paths_iterative(m, n)\n return 0 if m == 0 || n == 0\n\n grid = Array.new(m) { Array.new(n) {0} }\n grid[0][0] = 1\n\n row = 0\n column = 0\n\n while row < m\n while column < n\n # check top\n if row > 0\n grid[row][column] += grid[row - 1][column]\n end\n # check left\n if column > 0\n grid[row][column] += grid[row][column - 1]\n end\n\n column += 1\n end\n column = 0\n row += 1\n end\n\n grid[row - 1][column - 1]\nend", "def generate\n cells.destroy_all\n \n x = 0\n while x < width do\n y = 0\n while y < height do\n cells.create(:x => x, :y => y)\n y += 1\n end\n x += 1\n end\n \n # A wall is like this: [cell1,cell2]\n walls = []\n \n cells.each do |cell|\n walls += ([cell]*4).zip(cell.neighbours)\n end\n \n walls.shuffle!\n \n walls.each do |cell, neighbour|\n cell.create_edge_to_and_from(neighbour) unless neighbour.nil? || cell.reachable?(neighbour)\n end\n \n @solution ||= cells.first.shortest_path_to(cells.last)\n end", "def step_through_iterative_division_maze_generator(grid, state)\n unless state[:finished_init]\n draw_canvas_border(grid)\n state[:finished_init] = true\n end\n new_chamber = divide(grid, state[:current_chamber])\n if new_chamber\n state[:current_chamber] = new_chamber[0]\n state[:todo_chamber].push(new_chamber[1])\n elsif !state[:todo_chamber].empty?\n state[:current_chamber] = state[:todo_chamber].pop\n elsif !state[:generation_complete]\n state[:generation_complete] = true\n end\nend", "def calculate_route\n\t\t@cl = init_loc\n\t\t@steps << cl\n\n\t\twhile not at_rightmost_side?\n\t\t\t@cl = next_step\n\t\t\t@steps << cl\n\t\tend \t\t\n\tend", "def solve\n @second > @first ? right_hand_solve : left_hand_solve\n if @path.length > 10\n \"#{@path[0..3]}, ... #{@path[-3..-1]} steps: #{@path.length}\"\n else\n @path\n end\n end", "def make_paths\n visited = {}\n path = []\n return path if @nmap.empty? || @nnmap.empty?\n\n # 0 is false\n @nmap.each do |k, _|\n visited[k] = 0\n end\n\n # for each node that is not an end node to an end node\n @nnmap.each do |s, _|\n # if s is an end node\n @paths << [s] if @ends.include? s\n\n # for each end node as desintation\n @ends.each do |d|\n get_allpaths(s, d, visited, path)\n end\n end\n @paths.sort_by(&:length).reverse\n end", "def render_path\n # If the star and target are disconnected there will only be one path\n # The path should not render in that case\n unless search.path.size == 1\n search.path.each_key do | cell |\n # Renders path on both grids\n outputs.solids << [scale_up(cell), path_color]\n end\n end\n end", "def lattice_path(array)\n temp = [1]\n count = 2\n sum = array[0] + array[1]\n temp.push(sum)\n while count < array.length - 1\n sum = sum + array[count]\n temp << sum\n count += 1\n end\n \n temp << array.last\n sum = temp.inject(:+)\n temp << (sum * 2)\n return temp\nend", "def knights_moves(start, finish)\n board = create_board\n\n path = []\n queue = []\n\n queue << start\n\n loop do\n \tcurrent_node = board[queue[0][0]][queue[0][1]]\n\n current_node.moves.each do |node|\n unless node == start || board[node[0]][node[1]].parent != nil\n board[node[0]][node[1]].parent = queue[0] \n queue << node\n end\t\n end\n\n if queue.include? finish\n\n parent = board[finish[0]][finish[1]].parent\n path << parent\n\n loop do\n \tparent = board[parent[0]][parent[1]].parent\n \tbreak if parent == nil\n \tpath.unshift(parent)\n end\n\n path << finish\n break\n end\n\n \tqueue.shift\n end\n puts \"You can make it in #{path.length-1} steps!\"\n path\nend", "def step(n=10, &blk)\n (n-1).times do\n random_join\n yield resulting_maze if block_given?\n\n vertical_connections\n yield resulting_maze if block_given?\n end\n final_row\n yield resulting_maze if block_given?\n\n self\n end", "def path(c,r, matrix_map)\n \n \n\nend", "def find_path(positions, start, finish)\n # Will hold MoveTiles that form a path from start to finish\n path = [finish]\n # Get finish tile first so that we can work backwards in making the path\n chosen = finish\n movetile = chosen\n # Endless loop ZOMG\n while true\n t_x, t_y = movetile.x, movetile.y\n # Generate list of tiles surrounding this tile\n surrounding = []\n surrounding.push(positions[t_x][t_y+1]) if valid?(t_x, t_y+1)\n surrounding.push(positions[t_x][t_y-1]) if valid?(t_x, t_y-1)\n surrounding.push(positions[t_x+1][t_y]) if valid?(t_x+1, t_y)\n surrounding.push(positions[t_x-1][t_y]) if valid?(t_x-1, t_y)\n \n surrounding.compact!\n surrounding.delete(0)\n consider = []\n lowest_cost = 99\n # Evaluate surrounding tiles to find lowest cost\n surrounding.each{|tile|\n # If tile has a total move cost that is at least equal to the current best\n if tile.total_cost <= lowest_cost\n # If even lower, remove previous considerations and set new best\n if tile.total_cost < lowest_cost\n consider.clear\n lowest_cost = tile.total_cost\n end\n # Add this tile to be considered\n consider.push(tile)\n end\n }\n # Choose a tile from list\n chosen = consider[rand(consider.size)]\n # Return path if that last tile was the final one\n return path.reverse! if [chosen.x, chosen.y] == [start.x, start.y]\n # Add chosen tile to path\n path.push(chosen)\n # Evaluate this tile next\n movetile = chosen\n end\n end", "def find_path(positions, start, finish)\n # Will hold MoveTiles that form a path from start to finish\n path = [finish]\n # Get finish tile first so that we can work backwards in making the path\n chosen = finish\n movetile = chosen\n # Endless loop ZOMG\n while true\n t_x, t_y = movetile.x, movetile.y\n # Generate list of tiles surrounding this tile\n surrounding = []\n surrounding.push(positions[t_x][t_y+1]) if valid?(t_x, t_y+1)\n surrounding.push(positions[t_x][t_y-1]) if valid?(t_x, t_y-1)\n surrounding.push(positions[t_x+1][t_y]) if valid?(t_x+1, t_y)\n surrounding.push(positions[t_x-1][t_y]) if valid?(t_x-1, t_y)\n \n surrounding.compact!\n surrounding.delete(0)\n consider = []\n lowest_cost = 99\n # Evaluate surrounding tiles to find lowest cost\n surrounding.each{|tile|\n # If tile has a total move cost that is at least equal to the current best\n if tile.total_cost <= lowest_cost\n # If even lower, remove previous considerations and set new best\n if tile.total_cost < lowest_cost\n consider.clear\n lowest_cost = tile.total_cost\n end\n # Add this tile to be considered\n consider.push(tile)\n end\n }\n # Choose a tile from list\n chosen = consider[rand(consider.size)]\n # Return path if that last tile was the final one\n return path.reverse! if [chosen.x, chosen.y] == [start.x, start.y]\n # Add chosen tile to path\n path.push(chosen)\n # Evaluate this tile next\n movetile = chosen\n end\n end", "def plan(s1, s2)\r\n if s1 == s2\r\n return []\r\n end\r\n\r\n condensed_path = Array.new\r\n full_path = Array.new\r\n temp = BFS.new(graph, find_node(s1)).shortest_path_to(find_node(s2))\r\n\r\n temp.each {|x| full_path.push(x.to_s)}\r\n condensed_path.push(full_path.first)\r\n condensed_path = condensed_path + transfer_stations(full_path)\r\n \r\n if condensed_path.last != full_path.last #need to test this more\r\n condensed_path << full_path.last\r\n end\r\n\r\n return condensed_path\r\n end", "def next_distances(save = true) ; next_task(@@DISTANCE_TASKS, save) ; end", "def greedy_salesman (cities)\n path = []\n not_visited = cities\n path.push(not_visited.shift)\n loop do\n current = path.last\n # for testing, only prints if PRINT_STEPS is set to true at the top of the file\n puts \"current: \" + current.name + \" (\" + current.x.round(2).to_s + \",\" + current.y.round(2).to_s + \")\" if PRINT_STEPS\n next_city = nearest_possible_neighbor(current,not_visited)\n path.push(not_visited.delete(next_city))\n break if not_visited.empty?\n end\n path\nend", "def get_num_paths(grid_width)\n n, r = grid_width * 2, grid_width\n ((n - r + 1)..n).inject(:*) / (1..r).inject(:*)\nend", "def stair_climb(n)\n routes = [[[]], [[1]], [[1, 1], [2]]] # like fibb sequence\n\n (3).upto(n) do |dest_step|\n current_routes = []\n (1).upto(3) do |last_step|\n routes[dest_step - last_step].each do |route|\n current_routes << [last_step] + route\n end\n end\n routes << current_routes\n end\n\n routes[n]\n end", "def find_path(start_node, end_node, grid)\n start_node = sanitize(start_node)\n end_node = sanitize(end_node)\n if grid.nil?\n [start_node]\n else\n _max_x = grid.max_x\n _max_y = grid.max_y\n\n @current_grid = grid.inner_grid.clone\n\n raise 'max_x & max_y required' unless _max_x && _max_y\n\n _start_node = start_node.clone\n _end_node = end_node.clone\n\n heuristic = @heuristic.new(_end_node, @weight)\n\n _start_node[:f] = 0 # sum of g and h\n _start_node[:g] = 0 # steps to start node\n _start_node[:h] = nil # steps to end node\n _start_node[:opened] = true\n\n # use heap or tree for better perf\n open = []\n open.push _start_node\n\n while !open.empty? do\n _current_node = open.pop\n\n _current_node[:closed] = true\n @current_grid[node_to_a(_current_node)] = _current_node\n\n if node_to_a(_current_node) == node_to_a(_end_node)\n return final_path(_current_node)\n end\n\n new_g = _current_node[:g] + 1\n\n x = _current_node[:x]\n y = _current_node[:y]\n\n neighbors = []\n\n neighbors << [x-1, y] if x > 0\n neighbors << [x, y-1] if y > 0\n neighbors << [x+1, y] if x < _max_x-1\n neighbors << [x, y+1] if y < _max_y-1\n\n _neighbors = neighbors.map do |position|\n node = @current_grid[position]\n if node.nil? || node[:walkable]\n node ||= {}\n @current_grid[position] = node.merge({\n x: position.first,\n y: position[1],\n closed: false,\n opened: false\n })\n end\n end.compact\n\n _neighbors.each do |neighbor|\n if (!neighbor[:opened] || new_g < neighbor[:g])\n neighbor[:g] = new_g\n neighbor[:h] ||= heuristic.h(neighbor)\n neighbor[:f] = neighbor[:g] + neighbor[:h]\n neighbor[:parent] = node_to_a(_current_node)\n\n if (!neighbor[:opened])\n open.push neighbor\n neighbor[:opened] = true\n else\n # ???\n puts \"got here some how!!!\"\n end\n end\n end\n\n open.sort_by! {|i| [-i[:f], -i[:h]]}\n # grid_p\n end\n end\n end", "def step_through_maze_generator(grid, state)\n case state[:algorithm]\n when MazeAlgorithm::DEPTH_FIRST\n step_through_depth_first_maze_generator(grid, state[:algorithm_state])\n when MazeAlgorithm::ITERATIVE_DIVISION\n step_through_iterative_division_maze_generator(grid, state[:algorithm_state])\n end\nend", "def path_finder(start_node=START_NODE, goal_node=GOAL_NODE)\n\t\n\t# INITIALIZE\n\tvalid = valid_nodes # largest set\n\treachable = [start_node] # nodes we can reach from current node\n\texplored = [] # nodes we've already considered\n\t# nodes reachable, valid, and not explored\n\topen_nodes = valid.select{|node| reachable.include?(node)}.select{|node| !explored.include?(node)} \n\t# record node path {node => previous_node}\n\tnodes_path = {start_node => nil} \n\t\n\twhile !open_nodes.empty?\n # node = choose_node(reachable)\n\t\tnode = open_nodes.sample # random node in open_nodes\n\t\t\n\t\treturn build_path(goal_node, nodes_path) if node==goal_node # STOP if reached goal! \n \n # Don't repeat ourselves.\n reachable.delete(node) # remove current node from reachable\n explored.push(node) # add node to explored\n \n # What nodes are now open from this node?\n # Adjacent, not in explored, and valid (not an obstacle and in maze)\n new_reachable = (get_adjacent_nodes(node) - explored) & valid\n\t\t# ADD new nodes to reachable\n new_reachable.each do |adj_node|\n if !reachable.include?(adj_node)\n # adjacent.previous = node # Remember how we got there.\n nodes_path[adj_node] = node # {[0,3] => [0,2]}\n reachable << adj_node\n end\n end\n \n\t\t# REFRESH OPEN NODES\n open_nodes = valid.select{|node| reachable.include?(node)}.select{|node| !explored.include?(node)} \n \n end\n \n\treturn nil # open_nodes empty - no path found\nend", "def path(source, target, meta)\n # retrieve the path to the target node, using the meta hash\n # that was constructed at each iteration of the `each` iteration\n predecessor = target\n result_path = []\n\n # follow the leads from the back\n until predecessor == source\n result_path << predecessor.number\n predecessor = meta[predecessor]\n end\n\n # add the source, since now `predecessor == source` is true\n result_path << source.number\n result_path.reverse.join(\", \")\nend", "def find_path(source, target, map)\n @main_loop_count = 0\n\n max_y = map.size - 1\n max_x = map[0].size - 1\n target_x = target[0]\n target_y = target[1]\n # target heuristic is 0\n target = [target_x, target_y, 0]\n\n # Sets up the search to begin from the source\n source = source.dup.push((target_x - source[0]).abs + (target_y - source[1]).abs)\n came_from = {}\n came_from[source] = nil\n frontier = [source]\n\n # Until the target is found or there are no more cells to explore from\n until came_from.has_key?(target) || frontier.empty?\n @main_loop_count += 1\n\n # Take the next frontier cell\n new_frontier = frontier.shift\n\n # Find the adjacent neighbors\n adjacent_neighbors = []\n\n # Gets all the valid adjacent_neighbors into the array\n # From southern neighbor, clockwise\n nfx = new_frontier[0]\n nfy = new_frontier[1]\n adjacent_neighbors << [nfx , nfy - 1, (target_x - nfx).abs + (target_y - nfy + 1).abs] unless nfy == 0\n adjacent_neighbors << [nfx - 1, nfy - 1, (target_x - nfx + 1).abs + (target_y - nfy + 1).abs] unless nfx == 0 || nfy == 0\n adjacent_neighbors << [nfx - 1, nfy , (target_x - nfx + 1).abs + (target_y - nfy).abs] unless nfx == 0\n adjacent_neighbors << [nfx - 1, nfy + 1, (target_x - nfx + 1).abs + (target_y - nfy - 1).abs] unless nfx == 0 || nfy == max_y\n adjacent_neighbors << [nfx , nfy + 1, (target_x - nfx).abs + (target_y - nfy - 1).abs] unless nfy == max_y\n adjacent_neighbors << [nfx + 1, nfy + 1, (target_x - nfx - 1).abs + (target_y - nfy - 1).abs] unless nfx == max_x || nfy == max_y\n adjacent_neighbors << [nfx + 1, nfy , (target_x - nfx - 1).abs + (target_y - nfy).abs] unless nfx == max_x\n adjacent_neighbors << [nfx + 1, nfy - 1, (target_x - nfx - 1).abs + (target_y - nfy + 1).abs] unless nfx == max_x || nfy == 0\n\n new_neighbors = adjacent_neighbors.select do |neighbor|\n # That have not been visited and are not walls\n unless came_from.has_key?(neighbor) || map[neighbor[1]][neighbor[0]] != '.'\n # Add them to the frontier and mark them as visited\n # frontier << neighbor\n came_from[neighbor] = new_frontier\n end\n end\n\n # Sort the frontier so cells that are close to the target are then prioritized\n if new_neighbors.length > 0\n new_neighbors = merge_sort(new_neighbors)\n if frontier.length > 0 && new_neighbors[0][2] >= frontier[0][2]\n frontier = merge_sort(new_neighbors.concat(frontier))\n else\n frontier = new_neighbors.concat(frontier)\n end\n end\n end\n\n # If the search found the target\n if came_from.has_key?(target)\n # Calculates the path between the target and star for the greedy search\n # Only called when the greedy search finds the target\n path = []\n next_endpoint = came_from[target]\n while next_endpoint\n path << [next_endpoint[0], next_endpoint[1]]\n next_endpoint = came_from[next_endpoint]\n end\n path\n else\n return nil\n end\n end", "def next_generation\n new_grid = generate_grid\n\n @x.times do |x|\n @y.times do |y|\n # If there are more than one nodes on a square, rotate them.\n if @grid[x][y].length > 1\n new_nodes = []\n @grid[x][y].each do |node|\n # Don't want to introduce nil elements into the grid\n new_direction = rotate_direction(node)\n new_nodes << new_direction unless new_direction.nil?\n end\n\n @grid[x][y] = new_nodes\n end\n\n # If we are at an edge, reverse direction\n @grid[x][y].each do |node|\n if (x == 0 and node == :left) or\n (x == @x - 1 and node == :right) or\n (y == 0 and node == :up) or\n (y == @y - 1 and node == :down)\n\n @grid[x][y].delete node\n\n # Don't want to introduce nil elements into the grid.\n new_direction = reverse_direction(node)\n @grid[x][y] << new_direction unless new_direction.nil?\n end\n end\n\n # Finally, perform the relevant moves\n @grid[x][y].each do |node|\n case node\n when :up\n new_grid[x][y-1] << :up\n when :down\n new_grid[x][y+1] << :down\n when :left\n new_grid[x-1][y] << :left\n when :right\n new_grid[x+1][y] << :right\n end\n end\n end\n end\n\n return new_grid\n end", "def pathfind begTile, endTile\n @traveled_tiles = [begTile]\n @current_tiles = [begTile]\n @next_tiles = Array.new\n #iterate through the maze one movement at a time, hard stop when all tiles have been exhausted\n while (!@current_tiles.include? endTile) && @traveled_tiles.length < @maze.size\n @current_tiles.each do |tile|\n (get_adjacent_floors tile).each do |next_tile|\n #makes sure no tiles are double counted, the first to hit will always be the shortest\n if (next_tile.is_floor) && (!@next_tiles.include? next_tile) && (!@traveled_tiles.include? next_tile)\n @next_tiles.push next_tile\n next_tile.previous_tile tile\n end\n end\n end\n @traveled_tiles.concat @next_tiles\n @current_tiles = @next_tiles.dup\n @next_tiles.clear\n end\n endTile.get_path\n end", "def next_round\n if @round > 1\n puts \"----- NEW TURN -----\"\n end\n # next round\n @round += 1\n @players.rotate!\n end", "def route_go_ride(from, dest)\n from = from.map{|x|x+1}\n dest = dest.map{|x|x+1}\n\n x=from[0]\n y=from[1]\n\n route = \"The route is\\n\\tstart at (#{x},#{y})\"\n\n if from[0]!=dest[0]\n if from[0]<dest[0]\n until x == dest[0]\n x = x + 1\n end\n route += \"\\n\\tgo to (#{x},#{y})\"\n route += \"\\n\\tturn right\" if y>dest[1]\n route += \"\\n\\tturn left\" if y<dest[1]\n\n else from[0]>dest[0]\n until x == dest[0]\n x = x - 1\n end\n route += \"\\n\\tgo to (#{x},#{y})\"\n route += \"\\n\\tturn left\" if y>dest[1]\n route += \"\\n\\tturn right\" if y<dest[1]\n end\n end\n\n if from[1]!=dest[1]\n if from[1]<dest[1]\n until y == dest[1]\n y = y + 1\n end\n route += \"\\n\\tgo to (#{x},#{y})\"\n else from[1]>dest[1]\n until y == dest[1]\n y = y - 1\n end\n route += \"\\n\\tgo to (#{x},#{y})\"\n end\n end\n\n route += \"\\n\\tfinish at (#{x},#{y})\"\n route\n\n end", "def lattice_path(array)\n temp = [1]\n sum = array[0] + array[1]\n temp << sum\n sum = sum + array[2]\n temp << sum\n temp << array.last\n sum = temp.inject(:+)\n temp << (sum * 2)\n return temp\nend", "def next_generation!\n @grid = next_generation\n end", "def roptions(height = @height)\n return [[]] if height < 0\n\n result = []\n\n @steps.each do |step_size|\n result << [step_size] if height == step_size\n\n paths = roptions(height - step_size).flatten\n puts paths.inspect\n paths.each do |path|\n next if path.nil?\n\n result << step_size << path\n end\n end\n\n result\n=begin results = []\n\n @steps.each do |step_size|\n #puts height\n #puts step_size\n\n paths = roptions(height - step_size, step_size)\n \n next if paths == [nil] # not a valid path\n \n paths.each do |path|\n results << ([step_size] + [path]).flatten\n end\n end\n=end\n #results\n end", "def unique_paths(m, n, cache = {})\n return 0 if m < 0 || n < 0\n return 1 if m == 1 || n == 1\n\n result = (cache[[m - 1, n]] || unique_paths(m - 1, n, cache)) + (cache[[m, n - 1]] || unique_paths(m, n -1, cache))\n cache[[m, n]] = result\n result\nend", "def unique_path(rows, columns)\n # build the grid\n grid = Array.new(rows)\n grid.map! { |row| Array.new(columns) }\n \n # populate the first column\n rows.times { |row| grid[row][0] = 1 }\n\n # populate the first row\n columns.times { |col| grid[0][col] = 1 }\n \n # populate the whole grid\n (1...rows).each do |row|\n (1...columns).each do |col|\n grid[row][col] = grid[row - 1][col] + grid[row][col - 1]\n end\n end\n\n # return the value for down-right corner\n grid[rows - 1][columns - 1]\nend", "def reconstruct_path(came_from, current)\n while came_from.include?(current)\n current = came_from[current]\n current.path!\n end\n @start.start!\n @end.end!\n end", "def assign_paths\n self.path = generate_path(self)\n end", "def test_shortest_path\n expected = Amazeingly::Path.new([\n { step_number: 1, room: @rooms_collection.find(6), collected_objects: [] },\n { step_number: 2, room: @rooms_collection.find(5), collected_objects: [] },\n { step_number: 3, room: @rooms_collection.find(7), collected_objects: [] },\n { step_number: 4, room: @rooms_collection.find(4), collected_objects: [] }\n ])\n\n assert_equal expected, @path_finder.shortest_path(from_room: @rooms_collection.find(6), to_room: @rooms_collection.find(4))\n end", "def lesstrips(start, finish, max_distance)\n total_paths, distance = 0, 0\n path, paths = [], []\n visited = [start]\n cycles = all_cycles # all cycles in graph\n puts \"MAX DISTANCE = #{max_distance}\\n\"\n total_paths += lesstrips_dfs(start, finish, max_distance, distance, visited, path, paths, cycles)\n puts \"\\n==> Total paths from #{start} to #{finish}, with distance < #{max_distance}: #{total_paths}\\n\"\n total_paths\n end" ]
[ "0.6833168", "0.65635276", "0.6379017", "0.63330495", "0.63083893", "0.62988335", "0.6287713", "0.6273768", "0.6251025", "0.61220175", "0.61073124", "0.61034083", "0.60669386", "0.60412073", "0.59958404", "0.5950208", "0.5924406", "0.58955294", "0.58699673", "0.5850981", "0.5850446", "0.58504134", "0.58462095", "0.5843915", "0.5819875", "0.58186173", "0.57968473", "0.5795895", "0.5789934", "0.57783663", "0.57705843", "0.57571024", "0.57328546", "0.5726563", "0.571368", "0.5701161", "0.56841654", "0.56653655", "0.56540716", "0.5630558", "0.5613233", "0.5605725", "0.5600997", "0.5599313", "0.55937725", "0.55832964", "0.5566628", "0.55560154", "0.5553131", "0.5548909", "0.55459017", "0.5543856", "0.55430204", "0.55428", "0.5541038", "0.55369824", "0.55363715", "0.55354476", "0.5526117", "0.55149597", "0.55066514", "0.5489927", "0.54817986", "0.5476732", "0.5475595", "0.5466643", "0.546578", "0.54602367", "0.5455139", "0.54473233", "0.54418635", "0.54415685", "0.54332185", "0.5428585", "0.542514", "0.54217607", "0.54217607", "0.5407191", "0.540668", "0.54062426", "0.53962106", "0.53889924", "0.53888524", "0.538767", "0.5384815", "0.53784597", "0.5374591", "0.5372604", "0.536994", "0.53636575", "0.5360177", "0.5350279", "0.534802", "0.5343102", "0.53411365", "0.5340308", "0.5328128", "0.5323842", "0.5321612", "0.5315661" ]
0.71066934
0
GET /student_categories GET /student_categories.json
def index # @student_categories = StudentCategory.all respond_to do |format| format.html # index.html.erb format.json { render json: @student_categories } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n # @student_category = StudentCategory.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @student_category }\n end\n end", "def get_categories\r\n categories = Taxonomy.get_categories\r\n render json: categories, root: 'categories', adapter: :json, status: :ok\r\n end", "def categories\n\t\tbegin\n\t\t\t@categories = Category.select(:id, :name)\n\t\t\trender json: @categories\n\t\trescue Exception => e\n\t\t\terror_handling_bad_request(e)\n\t\tend\n\tend", "def GetCategories params = {}\n\n params = params.merge(path: 'categories.json')\n APICall(params)\n\n end", "def get_students\n @course = Course.find(params[:course_id])\n\n render json: @course.students\n end", "def categories\n get('venues/categories').categories\n end", "def index\n @incidentcategories = Incidentcategory.all\n json_response(@incidentcategories)\n end", "def index\n @st_categories = StCategory.all\n end", "def new\n # @student_category = StudentCategory.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @student_category }\n end\n end", "def categories\n\t\trender :json => {:status => 1, :categories => {\"1\" => \"Apparel & Accessories\", \"2\" => \"Arts and Crafts\", \"3\" => \"Electronics\", \n\t\t\t\"4\" => \"Home Appliances\", \"5\" => \"Kids & Baby\", \"6\" => \"Movies, Music, Books & Games\", \"7\" => \"Motor Vehicles\", \n\t\t\t\"8\" => \"Office & Education\", \"9\" => \"Parties & Events\", \"10\" => \"Spaces & Venues\", \"11\" => \"Sports & Outdoors\", \"12\" => \"Tools & Gardening\", \"13\" => \"Other\"}}, :status => 200\n\t\treturn\n\tend", "def get_subcategories\r\n sub_categories = Taxonomy.get_subcategories\r\n render json: sub_categories, root: 'categories', adapter: :json, status: :ok\r\n end", "def index\n categories = Category.all\n render json:categories\n end", "def index\n @section_categories = SectionCategory.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @section_categories }\n end\n end", "def index\n @categories = Category.all\n @categories.each do |category|\n authorize! :read, category\n end\n render json: @categories\n end", "def categories(sport_id)\n get(\"sports/en/sports/sr:sport:#{sport_id}/categories.xml\")\n end", "def index\n @students = Student.all\n render json: @students\n end", "def index\n @student_types = StudentType.all\n\n render json: @student_types\n end", "def index\n\n\n @categories = Category.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @categories }\n end\n end", "def index\n @categories = Category.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @categories }\n end\n end", "def index\n @categories = Category.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @categories }\n end\n end", "def index\n @categories = Category.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @categories }\n end\n end", "def index\n @categories = Category.all \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @categories }\n end\n end", "def students\n @course = Course.find(params[:id])\n\t\t@students = @course.students\n\t\t@other_students = Student.find(:all, :conditions => [\"id not in (select student_id from courses_students where course_id=?)\", @course.id])\n\n respond_to do |format|\n format.html # students.html.erb\n format.json { render :json => @students }\n end\n end", "def categories(make, year)\n make_id = get_object_id make\n response = get_url \"Categories/#{make_id}/#{year}\"\n response_obj = JSON.parse response\n response_obj[\"GetCategoriesResult\"].map{|r| Models::Category.from_response_hash(r)}\n end", "def get_categories\n @categories = Category.all\n end", "def get_custom_gradebook_categories(course_id)\r\n relative_url = Path::COURSES_GRADEBOOK_CUSTOMCATEGORIES % [course_id]\r\n get(relative_url)\r\n end", "def get_categories_list\n args = receive_should_validate?\n get('redtube.Categories.getCategoriesList', {}, [], args[:should_validate])\n end", "def index\n authorize! :read, Course\n\n if is_student?\n @course_sections = Course.find_student_courses(current_user.id)\n else\n @course_sections = Course.find_professor_courses(current_user.id)\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @courses }\n end\n end", "def index\n @service_categories = ServiceCategory.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @service_categories }\n end\n end", "def index\n @categories = CategoryService.index\n end", "def index\n @categories = current_user.categories\n end", "def categories\n # @categories = Category.get_categories(@user.id)\n #@categories =Category.all.select(:id).select(:name).select(:description).select(:logo_url)\n @categories =Category.all\n user_cat= @user.categories.collect(&:id)\n categories = []\n @categories.each do |cat|\n cat_attr = cat.attributes\n user_cat.include?(cat.id) ? cat_attr.merge!('user_category' => true) : cat_attr.merge!('user_category' => false)\n categories << cat_attr\n end\n @categories = categories\n\n respond_to do |format|\n if @categories.blank?\n format.json {render json:{:success => false, :status_code => 404, :message => \"No category found\"}}\n format.xml {render xml:{:success => false, :status_code => 404, :message => \"No category found\"}}\n format.html {render json: {:success => false, :status_code => 404, :message => \"No category found\"}}\n else\n format.html {render json: {:success => true, :status_code => 200, :categories => @categories}}\n format.json {render json: {:success => true, :status_code => 200, :categories => @categories}}\n format.xml {render xml: {:success => true, :status_code => 200, :categories => @categories}}\n end\n end\n end", "def categories(query_object)\n\t\tdata = do_get_json(CATEGORIES_ENDPOINT, query_object)\n\tend", "def getCategories(_, _, _)\n @db.categories\n end", "def courses\n @courses = Course.where(faculty_id: params[:faculty_id]).order(:name)\n respond_to do |format|\n format.json { render json: @courses }\n end\n end", "def index\n categories = @vertical.catgories.order('created_at DESC');\n render json: {status: 'SUCCESS', message:'Loaded categories', data:categories},status: :ok\n end", "def show\n @course_category = CourseCategory.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @course_category }\n end\n end", "def index\n @standard_categories = StandardCategory.where course:@course\n end", "def index\n\t @categories = Category.all\n\n\t respond_to do |format|\n\t\tformat.html # index.html.erb\n\t\tformat.json { render json: @categories }\n\t end\n\tend", "def getcategories\n category_size = RequirementCategory.all.length\n current_offset = (params[:payload][:pagenumber] - 1)*10\n direction = params[:payload][:direction]\n\n respond_to do |format|\n format.json {\n\n \tif current_offset + direction < category_size && current_offset + direction >= 0\n offset = current_offset + direction\n \t@categories = RequirementCategory.all.offset(offset).take(10) \n \trender :json => @categories\n else\n \trender :nothing => true, :status => 200, :content_type => 'text/html'\n end\n }\n end\n\n\tend", "def index\n @categories=Category.root\n respond_with @categories\n end", "def index\n @categories = Category.all\n @categories= @categories.sort_by(&:name)\n render json: @categories\n end", "def GetCategory id\n\n APICall(path: \"categories/#{id}.json\")\n\n end", "def index\n @question_categories = QuestionCategory.with_questions()\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @question_categories }\n end\n end", "def index\n @course = Course.select('course.*','course_cate.*').joins(:cate_course)\n \n render :json =>@course.group_by { |t| t.cate_course.name }\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 categories\n parsed_json['data']\n end", "def index\n @categories = StudentAttachmentCategory.fetch_all # default.to_a + StudentAttachmentCategory.all\n end", "def student_show\n @course = Course.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @course }\n end\n \n end", "def create\n # @student_category = StudentCategory.new(params[:student_category])\n\n respond_to do |format|\n if @student_category.save\n format.html { redirect_to @student_category, notice: 'Student category was successfully created.' }\n format.json { render json: @student_category, status: :created, location: @student_category }\n else\n format.html { render action: \"new\" }\n format.json { render json: @student_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @students = Student.all\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @students }\n end\n end", "def getCategoryAll()\n params = Hash.new\n return doCurl(\"get\",\"/category/all\",params)\n end", "def index\n @categories = Category.all\n respond_with(@categories)\n end", "def index\n @students = Student.all\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 @students = Student.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @students }\n end\n end", "def get_categories(query_obj=nil)\n uri = URI.parse(@uri + \"/Categories\")\n results = get(uri,query_obj)\n end", "def index\n\n\n @categories = Category.all\n @htmlmenu = infoaddresstree\n\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @categories }\n end\n\n end", "def show\n render json: category\n end", "def getCategoryList\n categoryDump = @course.assessment_categories\n categories = {}\n for cat in categoryDump do\n categories[cat.name] = cat.id\n end\n return categories\n end", "def index\n @categories = Category.all\n render :json => @categories, :except => [:created_at, :updated_at]\n end", "def index\n @students = Student.all\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 # logger.info \"☻ request query parameters: #{request.query_parameters}\"\n\n # logger.info \"--> #{request.fullpath}\"\n # logger.info \"--> GITHUB_KEY: #{ENV['GITHUB_KEY']}\"\n # logger.info \"--> GITHUB_SECRET: #{ENV['GITHUB_SECRET']}\"\n\n class_name = params[:class_name] || \"unknown\"\n year = params[:year] || \"2011\"\n semester = params[:semester] || \"summer\"\n\n if params[:class_name]\n @students = Student.where(class_name: class_name, year: year, semester: semester)\n else\n @students = Student.where(year: 2011, semester: \"summer\", class_name: \"unallocated\")\n end\n\n # @students = Student.all\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 @study_courses = StudyCourse.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @study_courses }\n end\n end", "def index\n @categories = Category.roots\n end", "def show\n render json: {teacher: @course.teacher, course: @course, categories: @course.categories, training_sessions: @course.training_sessions}\n end", "def index\n @training_categories = @ministry.training_categories\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @training_categories }\n end\n end", "def index\n @stylist_categories = StylistCategory.all\n end", "def index\n\n # dla formularza new\n @category = current_user.categories.build if signed_in?\n\n # dla tabeli index\n # @categories = Category.all\n @categories = Category.find(:all, :conditions => [\"\\\"isDefault\\\" = ? or user_id = ?\", true, current_user.id])\n\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @categories }\n end\n end", "def categories\n category\n end", "def category\n client.categories.find(data[\"categoryId\"])\n end", "def index\n respond_to do |format|\n format.html { @categories = Category.all }\n format.json { @categories = Category.order(:name) }\n end\n end", "def show\n render json: @category\n end", "def index\n @categories = Category.all\n end", "def index\n @categories = Category.all\n end", "def index\n @categories = Category.all\n end", "def index\n @categories = Category.all\n end", "def index\n @categories = Category.all\n end", "def index\n @categories = Category.all\n end", "def index\n @categories = Category.all\n end", "def index\n @categories = Category.all\n end", "def index\n @categories = Category.all\n end", "def index\n @categories = Category.all\n end", "def index\n @categories = Category.all\n end", "def index\n @categories = Category.all\n end", "def index\n @categories = Category.all\n end", "def index\n @categories = Category.all\n end", "def index\n @categories = Category.all\n end", "def index\n @categories = Category.all\n end", "def index\n @categories = Category.all\n end", "def index\n @categories = Category.all\n end", "def index\n @categories = Category.all\n end", "def index\n @categories = Category.all\n end", "def index\n @categories = Category.all\n end", "def index\n @categories = Category.all\n end", "def index\n @categories = Category.all\n end", "def index\n @categories = Category.all\n end", "def index\n @courses = Course.all\n render json: @courses, status: :ok\n end", "def categories\n response[\"categories\"].map!{|category| Foursquared::Response::Category.new(client, category)} if response[\"categories\"]\n end", "def index\n @student_profiles = StudentProfile.all \n render json: @student_profiles\n end", "def show\n render json: @student\n end" ]
[ "0.6934892", "0.6927601", "0.6902103", "0.674329", "0.66500926", "0.64506054", "0.64237016", "0.6378067", "0.63600516", "0.6348026", "0.63244313", "0.63234967", "0.63000333", "0.6292553", "0.62393785", "0.6192926", "0.6173628", "0.61670274", "0.615083", "0.6150037", "0.6150037", "0.61449575", "0.6124806", "0.61126685", "0.61029345", "0.61016124", "0.6095727", "0.6082954", "0.6073883", "0.6058051", "0.60534585", "0.60452944", "0.6041897", "0.6033731", "0.60299957", "0.60200846", "0.60023403", "0.59708774", "0.59611124", "0.59583247", "0.59561026", "0.59372586", "0.5933285", "0.5910986", "0.5907639", "0.58946216", "0.5880039", "0.58709043", "0.5867365", "0.58637744", "0.5857439", "0.58552665", "0.584592", "0.58405447", "0.58405447", "0.5839904", "0.5835827", "0.5831614", "0.58270425", "0.5822957", "0.58109826", "0.58043665", "0.5800909", "0.57969666", "0.57924944", "0.57913667", "0.57899946", "0.5788555", "0.57831496", "0.57812124", "0.57719296", "0.57716894", "0.5766106", "0.5766106", "0.5766106", "0.5766106", "0.5766106", "0.5766106", "0.5766106", "0.5766106", "0.5766106", "0.5766106", "0.5766106", "0.5766106", "0.5766106", "0.5766106", "0.5766106", "0.5766106", "0.5766106", "0.5766106", "0.5766106", "0.5766106", "0.5766106", "0.5766106", "0.5766106", "0.5766106", "0.5765534", "0.5762066", "0.5758373", "0.5757077" ]
0.77031684
0
GET /student_categories/1 GET /student_categories/1.json
def show # @student_category = StudentCategory.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @student_category } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n # @student_categories = StudentCategory.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @student_categories }\n end\n end", "def get_categories\r\n categories = Taxonomy.get_categories\r\n render json: categories, root: 'categories', adapter: :json, status: :ok\r\n end", "def categories\n\t\tbegin\n\t\t\t@categories = Category.select(:id, :name)\n\t\t\trender json: @categories\n\t\trescue Exception => e\n\t\t\terror_handling_bad_request(e)\n\t\tend\n\tend", "def new\n # @student_category = StudentCategory.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @student_category }\n end\n end", "def get_students\n @course = Course.find(params[:course_id])\n\n render json: @course.students\n end", "def GetCategories params = {}\n\n params = params.merge(path: 'categories.json')\n APICall(params)\n\n end", "def index\n @incidentcategories = Incidentcategory.all\n json_response(@incidentcategories)\n end", "def show\n @course_category = CourseCategory.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @course_category }\n end\n end", "def index\n categories = Category.all\n render json:categories\n end", "def GetCategory id\n\n APICall(path: \"categories/#{id}.json\")\n\n end", "def index\n @st_categories = StCategory.all\n end", "def index\n\n\n @categories = Category.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @categories }\n end\n end", "def index\n @section_categories = SectionCategory.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @section_categories }\n end\n end", "def index\n @categories = Category.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @categories }\n end\n end", "def index\n @categories = Category.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @categories }\n end\n end", "def index\n @categories = Category.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @categories }\n end\n end", "def index\n @categories = Category.all \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @categories }\n end\n end", "def index\n @categories = Category.all\n @categories.each do |category|\n authorize! :read, category\n end\n render json: @categories\n end", "def index\n @student_types = StudentType.all\n\n render json: @student_types\n end", "def get_subcategories\r\n sub_categories = Taxonomy.get_subcategories\r\n render json: sub_categories, root: 'categories', adapter: :json, status: :ok\r\n end", "def categories\n\t\trender :json => {:status => 1, :categories => {\"1\" => \"Apparel & Accessories\", \"2\" => \"Arts and Crafts\", \"3\" => \"Electronics\", \n\t\t\t\"4\" => \"Home Appliances\", \"5\" => \"Kids & Baby\", \"6\" => \"Movies, Music, Books & Games\", \"7\" => \"Motor Vehicles\", \n\t\t\t\"8\" => \"Office & Education\", \"9\" => \"Parties & Events\", \"10\" => \"Spaces & Venues\", \"11\" => \"Sports & Outdoors\", \"12\" => \"Tools & Gardening\", \"13\" => \"Other\"}}, :status => 200\n\t\treturn\n\tend", "def index\n @students = Student.all\n render json: @students\n end", "def show\n render json: category\n end", "def index\n @standard_categories = StandardCategory.where course:@course\n end", "def student_show\n @course = Course.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @course }\n end\n \n end", "def show\n render json: @category\n end", "def index\n @categories = CategoryService.index\n end", "def get_student\n @student = Student.find(params[:std_id])\n render json: @student\n end", "def category\n client.categories.find(data[\"categoryId\"])\n end", "def index\n categories = @vertical.catgories.order('created_at DESC');\n render json: {status: 'SUCCESS', message:'Loaded categories', data:categories},status: :ok\n end", "def getCategories(_, _, _)\n @db.categories\n end", "def index\n @service_categories = ServiceCategory.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @service_categories }\n end\n end", "def create\n # @student_category = StudentCategory.new(params[:student_category])\n\n respond_to do |format|\n if @student_category.save\n format.html { redirect_to @student_category, notice: 'Student category was successfully created.' }\n format.json { render json: @student_category, status: :created, location: @student_category }\n else\n format.html { render action: \"new\" }\n format.json { render json: @student_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n\t @categories = Category.all\n\n\t respond_to do |format|\n\t\tformat.html # index.html.erb\n\t\tformat.json { render json: @categories }\n\t end\n\tend", "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_categories\n @categories = Category.all\n end", "def students\n @course = Course.find(params[:id])\n\t\t@students = @course.students\n\t\t@other_students = Student.find(:all, :conditions => [\"id not in (select student_id from courses_students where course_id=?)\", @course.id])\n\n respond_to do |format|\n format.html # students.html.erb\n format.json { render :json => @students }\n end\n end", "def index\n\n # dla formularza new\n @category = current_user.categories.build if signed_in?\n\n # dla tabeli index\n # @categories = Category.all\n @categories = Category.find(:all, :conditions => [\"\\\"isDefault\\\" = ? or user_id = ?\", true, current_user.id])\n\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @categories }\n end\n end", "def categories\n # @categories = Category.get_categories(@user.id)\n #@categories =Category.all.select(:id).select(:name).select(:description).select(:logo_url)\n @categories =Category.all\n user_cat= @user.categories.collect(&:id)\n categories = []\n @categories.each do |cat|\n cat_attr = cat.attributes\n user_cat.include?(cat.id) ? cat_attr.merge!('user_category' => true) : cat_attr.merge!('user_category' => false)\n categories << cat_attr\n end\n @categories = categories\n\n respond_to do |format|\n if @categories.blank?\n format.json {render json:{:success => false, :status_code => 404, :message => \"No category found\"}}\n format.xml {render xml:{:success => false, :status_code => 404, :message => \"No category found\"}}\n format.html {render json: {:success => false, :status_code => 404, :message => \"No category found\"}}\n else\n format.html {render json: {:success => true, :status_code => 200, :categories => @categories}}\n format.json {render json: {:success => true, :status_code => 200, :categories => @categories}}\n format.xml {render xml: {:success => true, :status_code => 200, :categories => @categories}}\n end\n end\n end", "def courses\n @courses = Course.where(faculty_id: params[:faculty_id]).order(:name)\n respond_to do |format|\n format.json { render json: @courses }\n end\n end", "def index\n @question_categories = QuestionCategory.with_questions()\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @question_categories }\n end\n end", "def index\n @categories = Category.all\n @categories= @categories.sort_by(&:name)\n render json: @categories\n end", "def categories\n get('venues/categories').categories\n end", "def categories(sport_id)\n get(\"sports/en/sports/sr:sport:#{sport_id}/categories.xml\")\n end", "def show\n if params[:category_id]\n @category = Category.find(params[:category_id])\n #category = Category.find(params[:category_id])\n @tutorials = Tutorial.where(:category_id => @category)\n else\n @tutorials = Tutorial.all\n end\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @category }\n end\n end", "def index\n @categories = current_user.categories\n end", "def show\n @course = Course.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @student }\n end\n end", "def set_mg_student_category\n @student_category = MgStudentCategory.find(params[:id])\n end", "def index\n @categories=Category.root\n respond_with @categories\n end", "def index\n @categories = Category.all\n render :json => @categories, :except => [:created_at, :updated_at]\n end", "def getcategories\n category_size = RequirementCategory.all.length\n current_offset = (params[:payload][:pagenumber] - 1)*10\n direction = params[:payload][:direction]\n\n respond_to do |format|\n format.json {\n\n \tif current_offset + direction < category_size && current_offset + direction >= 0\n offset = current_offset + direction\n \t@categories = RequirementCategory.all.offset(offset).take(10) \n \trender :json => @categories\n else\n \trender :nothing => true, :status => 200, :content_type => 'text/html'\n end\n }\n end\n\n\tend", "def index\n @training_categories = @ministry.training_categories\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @training_categories }\n end\n end", "def show\n render json: {teacher: @course.teacher, course: @course, categories: @course.categories, training_sessions: @course.training_sessions}\n end", "def index\n @categories = StudentAttachmentCategory.fetch_all # default.to_a + StudentAttachmentCategory.all\n end", "def index\n @students = Student.all\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @students }\n end\n end", "def index\n @course = Course.select('course.*','course_cate.*').joins(:cate_course)\n \n render :json =>@course.group_by { |t| t.cate_course.name }\n end", "def index\n authorize! :read, Course\n\n if is_student?\n @course_sections = Course.find_student_courses(current_user.id)\n else\n @course_sections = Course.find_professor_courses(current_user.id)\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @courses }\n end\n end", "def index\n @students = Student.all\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 @students = Student.all\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 @benefit_categories = BenefitCategory.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @benefit_categories }\n end\n end", "def category\n @services = Service.where(\"category = ?\", params[:category])\n @category = Service.categories.key(params[:category].to_i)\n end", "def show\n @user = current_user\n respond_to do |format|\n if @user.categories.exists?(params[:id])\n @category = @user.categories.find(params[:id])\n format.html\n format.json { render :json => @category }\n else\n format.html { redirect_to user_path(current_user), :notice => \"No such category exists\" }\n format.json { head :not_found, :status => :not_found }\n end\n end\n end", "def index\n @students = Student.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @students }\n end\n end", "def get_category id\n\t\t\t\t\tFreshdesk::Api::Client.convert_to_hash( @connection.get CATEGORIES, id )\n\t\t\t\tend", "def get_category\n json_response({ message: 'NOT IMPLEMENTED' })\n end", "def show\n render json: @student\n end", "def categories(query_object)\n\t\tdata = do_get_json(CATEGORIES_ENDPOINT, query_object)\n\tend", "def destroy\n # @student_category = StudentCategory.find(params[:id])\n @student_category.destroy\n\n respond_to do |format|\n format.html { redirect_to student_categories_url }\n format.json { head :ok }\n end\n end", "def show\n @section_category = SectionCategory.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @section_category }\n end\n end", "def getCategory( category_id)\n params = Hash.new\n params['category_id'] = category_id\n return doCurl(\"get\",\"/category\",params)\n end", "def index\n respond_to do |format|\n format.html { @categories = Category.all }\n format.json { @categories = Category.order(:name) }\n end\n end", "def show\n render json: @accessory_category\n end", "def new\n @news = News.new\n @cats = News.all.distinct(:category)\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @news }\n end\n end", "def index\n @categories = Category.all\n end", "def index\n @categories = Category.all\n end", "def index\n @categories = Category.all\n end", "def index\n @categories = Category.all\n end", "def index\n @categories = Category.all\n end", "def index\n @categories = Category.all\n end", "def index\n @categories = Category.all\n end", "def index\n @categories = Category.all\n end", "def index\n @categories = Category.all\n end", "def index\n @categories = Category.all\n end", "def index\n @categories = Category.all\n end", "def index\n @categories = Category.all\n end", "def index\n @categories = Category.all\n end", "def index\n @categories = Category.all\n end", "def index\n @categories = Category.all\n end", "def index\n @categories = Category.all\n end", "def index\n @categories = Category.all\n end", "def index\n @categories = Category.all\n end", "def index\n @categories = Category.all\n end", "def index\n @categories = Category.all\n end", "def index\n @categories = Category.all\n end", "def index\n @categories = Category.all\n end", "def index\n @categories = Category.all\n end", "def index\n @categories = Category.all\n end", "def get_custom_gradebook_categories(course_id)\r\n relative_url = Path::COURSES_GRADEBOOK_CUSTOMCATEGORIES % [course_id]\r\n get(relative_url)\r\n end", "def show\n render json: @student_type\n end", "def show\n @consumer_category = ConsumerCategory.find(params[:id])\n\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @consumer_category }\n end\n end" ]
[ "0.7759597", "0.6814022", "0.6791496", "0.66728014", "0.66453403", "0.66340023", "0.6506893", "0.6480909", "0.64319426", "0.6423036", "0.6359196", "0.6353617", "0.6347104", "0.6327567", "0.6326933", "0.6326933", "0.63242084", "0.6309942", "0.6287733", "0.6257623", "0.6236738", "0.62229073", "0.61870956", "0.61614794", "0.61508214", "0.61421525", "0.61388123", "0.61270016", "0.6120942", "0.61176157", "0.6094525", "0.60819346", "0.6063735", "0.6041047", "0.60399085", "0.60395753", "0.6032104", "0.60314626", "0.6031152", "0.60306066", "0.6027387", "0.6025248", "0.6017215", "0.601608", "0.6011016", "0.5988413", "0.5986894", "0.5982335", "0.5974285", "0.5960121", "0.5958522", "0.5956829", "0.59523374", "0.595062", "0.59492373", "0.5945076", "0.5942445", "0.59420425", "0.59420425", "0.5935164", "0.59290826", "0.59177524", "0.5915909", "0.5913441", "0.59119886", "0.59119046", "0.59084123", "0.59083354", "0.5903882", "0.5901524", "0.58983326", "0.58971494", "0.5895821", "0.589423", "0.589423", "0.589423", "0.589423", "0.589423", "0.589423", "0.589423", "0.589423", "0.589423", "0.589423", "0.589423", "0.589423", "0.589423", "0.589423", "0.589423", "0.589423", "0.589423", "0.589423", "0.589423", "0.589423", "0.589423", "0.589423", "0.589423", "0.589423", "0.5891779", "0.5889769", "0.58886105" ]
0.73360837
1
GET /student_categories/new GET /student_categories/new.json
def new # @student_category = StudentCategory.new respond_to do |format| format.html # new.html.erb format.json { render json: @student_category } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n # @student_category = StudentCategory.new(params[:student_category])\n\n respond_to do |format|\n if @student_category.save\n format.html { redirect_to @student_category, notice: 'Student category was successfully created.' }\n format.json { render json: @student_category, status: :created, location: @student_category }\n else\n format.html { render action: \"new\" }\n format.json { render json: @student_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @course_category = CourseCategory.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @course_category }\n end\n end", "def new\n @category = Category.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @category }\n end\n end", "def new\n @category = Category.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @category }\n end\n end", "def new\n @category = Category.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @category }\n end\n end", "def new\n @category = Category.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @category }\n end\n end", "def new\n @category = Category.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @category }\n end\n end", "def new\n @category = Category.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @category }\n end\n end", "def new\n @category = Category.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @category }\n end\n end", "def new\n @category = Category.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @category }\n end\n end", "def new\n @category = Category.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @category }\n end\n end", "def new\n @category = Category.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @category }\n end\n end", "def new\n @category = Category.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @category}\n end\n end", "def new\n @category = current_mall.categories.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @category }\n end\n end", "def new\n puts @category.inspect\n @internal = @category.internals.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @internal }\n end\n end", "def new\n @level_category = LevelCategory.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @level_category }\n end\n end", "def new\n @category = Category.new\n\n # @categories = Category.all\n\n # respond_to do |format|\n # format.html # new.html.erb\n # format.json { render json: @category }\n # end\n end", "def new\n @service_category = ServiceCategory.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @service_category }\n end\n end", "def new\n @student = Student.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @student }\n end\n end", "def new\n @student = Student.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @student }\n end\n end", "def new\n @student = Student.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @student }\n end\n end", "def new\n @student = Student.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @student }\n end\n end", "def new\n @student = Student.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @student }\n end\n end", "def new\n @student = Student.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @student }\n end\n end", "def new\n @student = Student.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @student }\n end\n end", "def new\n @student = Student.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @student }\n end\n end", "def new\n @student = Student.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @student }\n end\n end", "def new\n @student = Student.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @student }\n end\n end", "def new\n @student = Student.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @student }\n end\n end", "def new\n @finding_category = FindingCategory.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @finding_category }\n end\n end", "def new\n @category_type = CategoryType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @category_type }\n end\n end", "def new\n @consumer_category = ConsumerCategory.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @consumer_category }\n end\n end", "def new\n @taxonomy_category = TaxonomyCategory.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @taxonomy_category }\n end\n end", "def new\n @category = Category.new\n @category_group = CategoryGroup.find_by_id(params[:category_group_id]) if params[:category_group_id]\n respond_to do |format|\n format.html { render template:'categories/new', layout:'minimal' }\n format.json { render json: @category }\n end\n end", "def create\n @course_category = CourseCategory.new(params[:course_category])\n\n respond_to do |format|\n if @course_category.save\n format.html { redirect_to @course_category, notice: 'Course category was successfully created.' }\n format.json { render json: @course_category, status: :created, location: @course_category }\n else\n format.html { render action: \"new\" }\n format.json { render json: @course_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\r\n @administration_category = Category.new\r\n\r\n respond_to do |format|\r\n format.html # new.html.erb\r\n format.json { render json: @administration_category }\r\n end\r\n end", "def new\n @recipe_category = RecipeCategory.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @recipe_category }\n end\n end", "def new\n\n #@category = Category.new\n @category = current_user.categories.build if signed_in?\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @category }\n end\n end", "def new\n @cat = Cat.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @cat }\n end\n end", "def new\n @cat = Cat.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @cat }\n end\n end", "def new\n @student = Student.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @student }\n end\n end", "def new\n @student = Student.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @student }\n end\n end", "def new\n @categoria = Categoria.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @categoria }\n end\n end", "def new\n # @student = Student.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @student }\n end\n end", "def new\n @mat_category = MatCategory.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @mat_category }\n end\n end", "def new\n @productcategory = Productcategory.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @productcategory }\n end\n end", "def new\n @super_category = SuperCategory.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @super_category }\n end\n end", "def new\n @student_major = StudentMajor.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @student_major }\n end\n end", "def new\n @question_category = QuestionCategory.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @question_category }\n end\n end", "def new\n @categories = Category.where(validity: true)\n @category = Category.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @category }\n end\n end", "def new\n @studentset = Studentset.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @studentset }\n end\n end", "def create\n @student = Student.new(student_params)\n\n respond_to do |format|\n if @student.save\n format.html { redirect_to @student, notice: 'Student was successfully created.' }\n format.json { render :show, status: :created, location: @student }\n # Add the course just created to this student's courses, better use the drop down list \n if params[:course] != nil then\n @student.courses << Course.find(params[:course][:id])\n end\n else\n format.html { render :new }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @post_category = Post::Category.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @post_category }\n end\n end", "def create\n @st_category = StCategory.new(st_category_params)\n\n respond_to do |format|\n if @st_category.save\n format.html { redirect_to @st_category, notice: 'St category was successfully created.' }\n format.json { render :show, status: :created, location: @st_category }\n else\n format.html { render :new }\n format.json { render json: @st_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @kategory = Kategory.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @kategory }\n end\n end", "def new\n @category = Category.new\n @top_categories = Category.top_categories\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @category }\n end\n end", "def new\n return unless representsCompany?\n\n @category = Category.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @category }\n end\n end", "def new\n @student = current_user.students.build(params[:student])\n\n respond_to do |format|\n format.html # new.html.erb\n format.js # new.js.erb\n format.json { render json: @student }\n end\n end", "def new\n @product = Product.new\n @categories = Category.find(:all)\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @product }\n end\n end", "def new\n @technology = Technology.new\n @categories = Category.find(:all)\n\n if @categories.count == 0\n flash[:error] = 'You need to create a category before you can create a technology'\n redirect_to new_category_path and return\n end\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @technology }\n end\n end", "def new\n @exercise_categories = ExerciseCategory.all\n @exercise_category = ExerciseCategory.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @exercise_category }\n end\n end", "def new\n @news = News.new\n @cats = News.all.distinct(:category)\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @news }\n end\n end", "def new\n # category instance\n @category = Category.new\n end", "def new\n @category = Category.new\n end", "def new\n @category = Category.new\n end", "def new\n @category = Category.new\n end", "def new\n @category = Category.new\n end", "def new\n @category = Category.new\n end", "def new\n @category = Category.new\n end", "def new\n @category = Category.new\n end", "def new\n @category = Category.new\n end", "def create\n @mg_student_category = MgStudentCategory.new(mg_create_student_category_params)\n @mg_student_category.save\n redirect_to '/student_categories'\n\n \n end", "def new\n\t\t@category = Category.new\n\tend", "def new\n\t\t@category = Category.new\n\tend", "def create\n json_create(category_params, Category)\n end", "def new\n @pcategory = Pcategory.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @pcategory }\n end\n end", "def create\n category = @current_user.categories.create!(category_params)\n render json: { category: category }\n end", "def new\n \t@category = Category.new\n end", "def new\n @student = Student.find(params[:student_id])\n @inschool = @student.inschools.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @inschool }\n end\n end", "def new\n @exam_category = ExamCategory.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @exam_category }\n end\n end", "def new\n \t@category =Category.new\n end", "def new\n @categorias_tipo = CatTipo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @categorias_tipo }\n end\n end", "def new\n @member_category = MemberCategory.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @member_category }\n end\n end", "def create\n @category = current_user.categories.new(name: params[:name])\n if @category.save\n render \"create.json.jbuilder\", status: :created\n else\n render json: { errors: @category.errors.full_messages }, status: :unprocessable_entity\n end\n end", "def new\n @model = Model.new\n# @model.build_category\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @model }\n end\n end", "def new\n @model = Model.new\n# @model.build_category\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @model }\n end\n end", "def new\n #if a category linked to us, use it for forms\n begin\n @category = Category.find(params[:category_id])\n category_id = @category.id\n rescue\n @category = nil\n category_id = nil\n end\n\n @specification = Specification.new(:category_id => category_id)\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @specification }\n end\n end", "def new\n @job_category = JobCategory.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @job_category }\n end\n end", "def new\n @quest = Quest.new\n\t@categories = find_all_categories\n\t\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @quest }\n end\n end", "def new\n @classtable = Classtable.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @classtable }\n end\n end", "def new\n @category = Category.new\n respond_with(@category)\n end", "def new\n @category = Category.new\n respond_with(@category)\n end", "def new\n @category = Category.new\n respond_with(@category)\n end", "def new\n @category = Category.new\n @title = \"Новая категория\"\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @category }\n end\n end", "def new\n @category_history = CategoryHistory.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @category_history }\n end\n end", "def new\n @study_course = StudyCourse.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @study_course }\n end\n end", "def new\n @course = Course.new\n 1.times { @course.lessons.build }\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @course }\n end\n end", "def new\n @cat = Category.new\n end", "def create\n @category = Category.new(params[:category])\n\n respond_to do |format|\n if @category.save\n format.html { redirect_to api_v1_categories_path, notice: 'Category was successfully created.' }\n format.json { render json: @category, status: :created, location: @category }\n else\n format.html { render action: \"new\" }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n get_supplier\n get_categories\n @supplier_category = @supplier.categories.new\n end" ]
[ "0.75486434", "0.7330655", "0.7260932", "0.72467655", "0.72467655", "0.72467655", "0.72467655", "0.72467655", "0.72467655", "0.72467655", "0.72467655", "0.72467655", "0.72153485", "0.7145538", "0.710887", "0.7052048", "0.6957772", "0.6948832", "0.6942383", "0.6942383", "0.6942383", "0.6942383", "0.6942383", "0.6942383", "0.6942383", "0.6942383", "0.6942383", "0.6942383", "0.6942383", "0.69303095", "0.6928455", "0.69210315", "0.6894538", "0.68917215", "0.6881577", "0.68807226", "0.6880114", "0.68728507", "0.68715537", "0.68715537", "0.68537176", "0.68537176", "0.68395156", "0.6818323", "0.6813674", "0.6802465", "0.6790248", "0.6775716", "0.6775593", "0.6763455", "0.6749361", "0.6748721", "0.6743119", "0.6729016", "0.6722241", "0.6712727", "0.67031306", "0.6698698", "0.66978717", "0.6684264", "0.6669857", "0.66696584", "0.66677165", "0.66675216", "0.66675216", "0.66675216", "0.66675216", "0.66675216", "0.66675216", "0.66675216", "0.66675216", "0.66592866", "0.66582125", "0.66582125", "0.66509455", "0.66498524", "0.66469985", "0.66424453", "0.6640607", "0.66368175", "0.6634685", "0.6632857", "0.66305983", "0.6628354", "0.6626084", "0.6626084", "0.66151005", "0.6614423", "0.6613725", "0.6605556", "0.6597102", "0.6597102", "0.6597102", "0.6595066", "0.65898776", "0.65890634", "0.65846765", "0.6583765", "0.65828377", "0.6578281" ]
0.78738594
0
POST /student_categories POST /student_categories.json
def create # @student_category = StudentCategory.new(params[:student_category]) respond_to do |format| if @student_category.save format.html { redirect_to @student_category, notice: 'Student category was successfully created.' } format.json { render json: @student_category, status: :created, location: @student_category } else format.html { render action: "new" } format.json { render json: @student_category.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @mg_student_category = MgStudentCategory.new(mg_create_student_category_params)\n @mg_student_category.save\n redirect_to '/student_categories'\n\n \n end", "def index\n # @student_categories = StudentCategory.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @student_categories }\n end\n end", "def CreateCategory params = {}\n \n APICall(path: 'categories.json',method: 'POST',payload: params.to_json)\n \n end", "def create\n @student = Student.new(student_params)\n\n respond_to do |format|\n if @student.save\n format.html { redirect_to @student, notice: 'Student was successfully created.' }\n format.json { render :show, status: :created, location: @student }\n # Add the course just created to this student's courses, better use the drop down list \n if params[:course] != nil then\n @student.courses << Course.find(params[:course][:id])\n end\n else\n format.html { render :new }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n category = @current_user.categories.create!(category_params)\n render json: { category: category }\n end", "def new\n # @student_category = StudentCategory.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @student_category }\n end\n end", "def create\n @student = Student.new(student_params)\n\n if @student.save\n render json: @student, status: :created\n else\n render json: @student.errors, status: :unprocessable_entity\n end\n end", "def create\n json_create(category_params, Category)\n end", "def create\n @st_category = StCategory.new(st_category_params)\n\n respond_to do |format|\n if @st_category.save\n format.html { redirect_to @st_category, notice: 'St category was successfully created.' }\n format.json { render :show, status: :created, location: @st_category }\n else\n format.html { render :new }\n format.json { render json: @st_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def user_category\n # byebug\n @user = User.where(contact: params[:contact]).first\n params[:category_ids].each do |category|\n @user.user_categories.create!(category_id: category, user_id: @user.id)\n end\n render json: {status: \"SUCCESS\", message: \"user-data\", data: \"category saved\"}, status: :ok\n end", "def create\n @student_type = StudentType.new(student_type_params)\n\n if @student_type.save\n render json: @student_type, status: :created, location: @student_type\n else\n render json: @student_type.errors, status: :unprocessable_entity\n end\n end", "def create\n @student = Student.new(student_params)\n @student.count = 0\n @student.password = \"default\"\n if params[:student][:group_ids] \n params[:student][:group_ids].each { |group_id| \n @student.groups << Group.find(group_id)\n }\n end\n\n respond_to do |format|\n if @student.save\n @students = Student.all\n format.html { render action: \"index\", notice: \"Student was successfully created.\" }\n format.json { render :index, status: :created}\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n if @student.isAdmin\n @student.groups = []\n end\n end", "def create_category payload\n\t\t\t\t\tFreshdesk::Api::Client.convert_to_hash( @connection.post CATEGORIES, payload )\n\t\t\t\tend", "def create\n @student = Student.new(student_params)\n\n respond_to do |format|\n if @student.save\n relate_with_courses\n format.html { redirect_to admin_student_path(@student), notice: 'Student was successfully created.' }\n format.json { render :show, status: :created, location: @student }\n else\n format.html { render :new }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @student = current_user.students.build(params[:student])\n\n respond_to do |format|\n if @student.save\n format.html { redirect_to root_url, notice: 'Student was successfully created.' }\n format.json { render json: @student, status: :created, location: @student }\n else\n format.html { render action: \"new\" }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @incidentcategory = Incidentcategory.new(incidentcategory_params)\n\n if @incidentcategory.save\n json_response(@incidentcategory)\n else\n render json: @incidentcategory.errors, status: :unprocessable_entity\n end\n end", "def create\n @categoria = Categoria.new(categoria_params)\n if @categoria.save\n render json: @categoria\n else\n render json: @categoria.errors, status: :unprocessable_entity\n end\n end", "def create\n @category = Category.new(category_params)\n @category.save\n render json: { params: params, notice: 'Categoria registrada exitosamente' }\n end", "def create\n if @category.save\n render json: @category, status: :created, location: @category\n else\n render json: @category.errors, status: :unprocessable_entity\n end\n end", "def create\n @student = Student.new(params[:student])\n current_user.groups[0].students << @student\n respond_to do |format|\n if @student.save\n format.js \n else\n format.js \n end\n end\n end", "def create\n @category = current_user.categories.new(name: params[:name])\n if @category.save\n render \"create.json.jbuilder\", status: :created\n else\n render json: { errors: @category.errors.full_messages }, status: :unprocessable_entity\n end\n end", "def create\n @course_category = CourseCategory.new(params[:course_category])\n\n respond_to do |format|\n if @course_category.save\n format.html { redirect_to @course_category, notice: 'Course category was successfully created.' }\n format.json { render json: @course_category, status: :created, location: @course_category }\n else\n format.html { render action: \"new\" }\n format.json { render json: @course_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @student = Student.new(student_params)\n\n if @student.save\n render :show, status: :created, location: @student\n else\n render json: @student.errors, status: :unprocessable_entity\n end\n end", "def create\n @student = current_user.students.create(student_params)\n\n respond_to do |format|\n if @student.save\n format.html { redirect_to @student, notice: 'Registro Exitoso.' }\n format.json { render :show, status: :created, location: @student }\n else\n format.html { render :new }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @student = Student.new(params[:student])\n\n respond_to do |format|\n if @student.save\n format.html { redirect_to @student, :notice => 'Student was successfully created.' }\n format.json { render :json => @student, :status => :created, :location => @student }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @student.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @student = Student.new(params[:student])\n\n respond_to do |format|\n if @student.save\n format.html { redirect_to @student, :notice => 'Student was successfully created.' }\n format.json { render :json => @student, :status => :created, :location => @student }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @student.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @student = @school.students.new(student_params)\n\n respond_to do |format|\n if @student.save\n format.html { redirect_to manage_school_school_path(@school), notice: 'Student was successfully created.' }\n format.json { render :show, status: :created, location: @student }\n else\n format.html { render :new }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n category = Category.create(category_params)\n\n \n if category\n render json:{\n status: :created,\n category: category}\n else\n render json: { status: 500 }\n end\n end", "def create\n @student = Student.new(params[:student])\n\n respond_to do |format|\n if @student.save\n format.html { redirect_to @student, notice: 'Student was successfully created.' }\n format.json { render json: @student, status: :created, location: @student }\n else\n format.html { render action: \"new\" }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @student = Student.new(params[:student])\n\n respond_to do |format|\n if @student.save\n format.html { redirect_to @student, notice: 'Student was successfully created.' }\n format.json { render json: @student, status: :created, location: @student }\n else\n format.html { render action: \"new\" }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @student = Student.new(params[:student])\n\n respond_to do |format|\n if @student.save\n format.html { redirect_to @student, notice: 'Student was successfully created.' }\n format.json { render json: @student, status: :created, location: @student }\n else\n format.html { render action: \"new\" }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @student = Student.new(params[:student])\n\n respond_to do |format|\n if @student.save\n format.html { redirect_to @student, notice: 'Student was successfully created.' }\n format.json { render json: @student, status: :created, location: @student }\n else\n format.html { render action: \"new\" }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @student = Student.new(params[:student])\n\n respond_to do |format|\n if @student.save\n format.html { redirect_to @student, notice: 'Student was successfully created.' }\n format.json { render json: @student, status: :created, location: @student }\n else\n format.html { render action: \"new\" }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @student = Student.new(params[:student])\n\n respond_to do |format|\n if @student.save\n format.html { redirect_to @student, notice: 'Student was successfully created.' }\n format.json { render json: @student, status: :created, location: @student }\n else\n format.html { render action: \"new\" }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @student = Student.new(params[:student])\n\n respond_to do |format|\n if @student.save\n format.html { redirect_to @student, notice: 'Student was successfully created.' }\n format.json { render json: @student, status: :created, location: @student }\n else\n format.html { render action: \"new\" }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @student = Student.new(params[:student])\n\n respond_to do |format|\n if @student.save\n format.html { redirect_to root_path, notice: 'Student details were successfully created.' }\n format.json { render json: @student, status: :created, location: @student }\n else\n format.html { render action: \"new\" }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n # @student = Student.new(params[:student])\n\n respond_to do |format|\n if @student.save\n format.html { redirect_to @student, notice: 'Student was successfully created.' }\n format.json { render json: @student, status: :created, location: @student }\n else\n format.html { render action: \"new\" }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @student = @current_lop.students.build(student_params)\n\n respond_to do |format|\n if @student.save\n format.html { redirect_to lop_students_url, notice: 'Student was successfully created.' }\n format.json { render :show, status: :created, location: @student }\n else\n format.html { render :new }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @enrolled_student = EnrolledStudent.new(params[:enrolled_student])\n\n respond_to do |format|\n if @enrolled_student.save\n format.html { redirect_to @enrolled_student, notice: 'Enrolled student was successfully created.' }\n format.json { render json: @enrolled_student, status: :created, location: @enrolled_student }\n else\n format.html { render action: \"new\" }\n format.json { render json: @enrolled_student.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @group_student = GroupStudent.new(group_student_params)\n\n respond_to do |format|\n if @group_student.save\n format.html { redirect_to @group_student, notice: 'Group student was successfully created.' }\n format.json { render :show, status: :created, location: @group_student }\n else\n format.html { render :new }\n format.json { render json: @group_student.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @student_major = StudentMajor.new(student_major_params)\n\n respond_to do |format|\n if @student_major.save\n format.html { redirect_to @student_major, notice: 'Student major was successfully created.' }\n format.json { render json: @student_major, status: :created, location: @student_major }\n else\n format.html { render action: \"new\" }\n format.json { render json: @student_major.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @specialization_category = SpecializationCategory.new(specialization_category_params)\n\n respond_to do |format|\n if @specialization_category.save\n format.html { redirect_to @specialization_category, notice: 'Specialization category was successfully created.' }\n format.json { render :show, status: :created, location: @specialization_category }\n else\n format.html { render :new }\n format.json { render json: @specialization_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @student = Student.new(student_params)\n\n respond_to do |format|\n if @student.save\n format.html { redirect_to @student, notice: \"Student was successfully created.\" }\n format.json { render json :show, status: :created, location: @student }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @student_app_cat_regno = StudentAppCatRegno.new(student_app_cat_regno_params)\n\n respond_to do |format|\n if @student_app_cat_regno.save\n format.html { redirect_to @student_app_cat_regno, notice: 'Student app cat regno was successfully created.' }\n format.json { render :show, status: :created, location: @student_app_cat_regno }\n else\n format.html { render :new }\n format.json { render json: @student_app_cat_regno.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n\t\tp = params[:student]\n\t\thash = { :original_name => p['original_name'], :sort_name => Student.make_sort_name(p['original_name']), :other_name => p['other_name'],\n\t\t\t:gender => p['gender'] == 'Male' ? 'M' : 'F', :born => VagueDate.factory(p['born']).to_s, :died => VagueDate.factory(p['died']).to_s,\n\t\t\t:home_town => p['home_town']['town'], :home_state => p['home_town']['state'], :home_country => p['home_town']['country'],\n\t\t\t:biographical_notes => p['biographical_notes'], :quotes => p['quotes'], :additional_notes => p['additional_notes'], :private_notes => p['private_notes'], :is_stub => 0\n\t\t}\n\n\t\t@student = Student.new(hash)\n\t\t@student.generate_unique_name()\n\n\t\trespond_to do |format|\n\t\t\tif @student.save\n\t\t\t\tmarriages = parse_array(p['marriage'])\n\t\t\t\tmarriages.each {|marriage|\n\t\t\t\t\tif !marriage['name'].blank?\n\t\t\t\t\t\tMarriage.create_marriage(@student, { :name => marriage['name'] }, marriage['date'])\n\t\t\t\t\tend\n\t\t\t\t}\n\t\t\t\tresidences = parse_array(p['residence'])\n\t\t\t\tresidences.each {|residence|\n\t\t\t\t\tif !residence.blank?\n\t\t\t\t\t\tStudentResidence.create_residence(@student, residence)\n\t\t\t\t\tend\n\t\t\t\t}\n\t\t\t\tBrowse.student_changed(@student, nil)\n\t\t\t\tsolr().add_object(@student.to_solr())\n\n\t\t\t\tformat.html { redirect_to(@student, :notice => 'The student was successfully created.') }\n\t\t\telse\n\t\t\t\tformat.html {\n\t\t\t\t\t@page_title = 'Student'\n\t\t\t\t\tnew_setup()\n\t\t\t\t\trender :action => \"new\"\n\t\t\t\t}\n\t\t\tend\n\t\tend\n\tend", "def create\n @student_sub_course = StudentSubCourse.new(params[:student_sub_course])\n\n respond_to do |format|\n if @student_sub_course.save\n format.html { redirect_to @student_sub_course, notice: 'Student sub course was successfully created.' }\n format.json { render json: @student_sub_course, status: :created, location: @student_sub_course }\n else\n format.html { render action: \"new\" }\n format.json { render json: @student_sub_course.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @standard_category = StandardCategory.new(standard_category_params)\n\n respond_to do |format|\n if @standard_category.save\n format.html { redirect_to [@standard_category.course,@standard_category], notice: 'Standard category was successfully created.' }\n format.json { render :show, status: :created, location: @standard_category }\n else\n format.html { render :new }\n format.json { render json: @standard_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @category = current_mall.categories.new(params[:category])\n\n if @category.save\n render json: @category, status: :created\n else\n render json: @category.errors, status: :unprocessable_entity\n end\n end", "def create\n @student = Student.new(student_params)\n\n respond_to do |format|\n if @student.save\n format.html { redirect_to @student, notice: 'Student was successfully created.' }\n format.json { render :show, status: :created, location: @student }\n else\n format.html { render :new }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @student = Student.new(student_params)\n\n respond_to do |format|\n if @student.save\n format.html { redirect_to @student, notice: 'Student was successfully created.' }\n format.json { render :show, status: :created, location: @student }\n else\n format.html { render :new }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @student = Student.new(student_params)\n\n respond_to do |format|\n if @student.save\n format.html { redirect_to @student, notice: 'Student was successfully created.' }\n format.json { render :show, status: :created, location: @student }\n else\n format.html { render :new }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @student = Student.new(student_params)\n\n respond_to do |format|\n if @student.save\n format.html { redirect_to @student, notice: 'Student was successfully created.' }\n format.json { render :show, status: :created, location: @student }\n else\n format.html { render :new }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @student = Student.new(student_params)\n\n respond_to do |format|\n if @student.save\n format.html { redirect_to @student, notice: 'Student was successfully created.' }\n format.json { render :show, status: :created, location: @student }\n else\n format.html { render :new }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @student = Student.new(student_params)\n\n respond_to do |format|\n if @student.save\n format.html { redirect_to @student, notice: 'Student was successfully created.' }\n format.json { render :show, status: :created, location: @student }\n else\n format.html { render :new }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @student = Student.new(student_params)\n\n respond_to do |format|\n if @student.save\n format.html { redirect_to @student, notice: 'Student was successfully created.' }\n format.json { render :show, status: :created, location: @student }\n else\n format.html { render :new }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @student = Student.new(student_params)\n\n respond_to do |format|\n if @student.save\n format.html { redirect_to @student, notice: 'Student was successfully created.' }\n format.json { render :show, status: :created, location: @student }\n else\n format.html { render :new }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @student = Student.new(student_params)\n\n respond_to do |format|\n if @student.save\n format.html { redirect_to @student, notice: 'Student was successfully created.' }\n format.json { render :show, status: :created, location: @student }\n else\n format.html { render :new }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @student = Student.new(student_params)\n\n respond_to do |format|\n if @student.save\n format.html { redirect_to @student, notice: 'Student was successfully created.' }\n format.json { render :show, status: :created, location: @student }\n else\n format.html { render :new }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @student = Student.new(student_params)\n\n respond_to do |format|\n if @student.save\n format.html { redirect_to @student, notice: 'Student was successfully created.' }\n format.json { render :show, status: :created, location: @student }\n else\n format.html { render :new }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @student = Student.new(student_params)\n\n respond_to do |format|\n if @student.save\n format.html { redirect_to @student, notice: 'Student was successfully created.' }\n format.json { render :show, status: :created, location: @student }\n else\n format.html { render :new }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @student = Student.new(student_params)\n @student.course_id = cookies[:id_curso]\n\n respond_to do |format|\n if @student.save\n cookies.delete(:arch_nombre)\n cookies.delete(:arch_email)\n cookies.delete(:arch_tel)\n format.html { redirect_to @student, notice: 'Se creó el registro de alumna satisfactoriamente.' }\n format.json { render :show, status: :created, location: @student }\n else\n format.html { render :new }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @incidentcategory = Incidentcategory.new(incidentcategory_params)\n\n respond_to do |format|\n if @incidentcategory.save\n format.html { redirect_to incidentcategories_path, notice: 'Incidentcategory was successfully created.' }\n format.json { render :show, status: :created, location: @incidentcategory }\n else\n format.html { render :new }\n format.json { render json: @incidentcategory.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @student = Student.new(student_params)\n\n respond_to do |format|\n if @student.save\n format.html { redirect_to @student,\n notice: 'Student was successfully created.' }\n format.json { render :show, status: :created, location: @student }\n else\n format.html { render :new }\n format.json { render json: @student.errors,\n status: :unprocessable_entity }\n end\n end\n end", "def create\n @category = Category.new(category_params)\n authorize! :create, @category\n if @category.save\n render json: @category, status: :created\n else\n render json: @category.errors, status: :unprocessable_entity\n end\n end", "def create\n @student = Student.new(student_params)\n\n respond_to do |format|\n if @student.save\n format.html { redirect_to @student, notice: '生徒情報が追加されました' }\n format.json { render :show, status: :created, location: @student }\n else\n format.html { render :new }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @student = Student.new(student_params)\n @user = User.find_by_id(params[:user])\n @student.user = @user\n @department = Department.find_by_id(params[:department])\n @student.department = @department\n respond_to do |format|\n if @student.save\n format.html { redirect_to @student, notice: 'Student was successfully created.' }\n format.json { render :show, status: :created, location: @student }\n else\n format.html { render :new }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @dojo_student = DojoStudent.new(params[:dojo_student])\n\n respond_to do |format|\n if @dojo_student.save\n format.html { redirect_to @dojo_student, notice: 'Dojo student was successfully created.' }\n format.json { render json: @dojo_student, status: :created, location: @dojo_student }\n else\n format.html { render action: \"new\" }\n format.json { render json: @dojo_student.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @studentsection = Studentsection.new(studentsection_params)\n\n respond_to do |format|\n if @studentsection.save\n format.html { redirect_to @studentsection, notice: 'Studentsection was successfully created.' }\n format.json { render :show, status: :created, location: @studentsection }\n else\n format.html { render :new }\n format.json { render json: @studentsection.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @studentset = Studentset.new(params[:studentset])\n\n respond_to do |format|\n if @studentset.save\n format.html { redirect_to @studentset, notice: 'Studentset was successfully created.' }\n format.json { render json: @studentset, status: :created, location: @studentset }\n else\n format.html { render action: \"new\" }\n format.json { render json: @studentset.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @exam_category = ExamCategory.new(params[:exam_category])\n\n respond_to do |format|\n if @exam_category.save\n format.html { redirect_to @exam_category, notice: 'Exam category was successfully created.' }\n format.json { render json: @exam_category, status: :created, location: @exam_category }\n else\n format.html { render action: \"new\" }\n format.json { render json: @exam_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @student = Student.new(student_params)\n\n respond_to do |format|\n if @student.save\n format.html { redirect_to @student, notice: 'Student was successfully created.' }\n format.json { render action: 'show', status: :created, location: @student }\n else\n format.html { render action: 'new' }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @student = Student.new(student_params)\n\n respond_to do |format|\n if @student.save\n format.html { redirect_to @student, notice: 'Student was successfully created.' }\n format.json { render action: 'show', status: :created, location: @student }\n else\n format.html { render action: 'new' }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @student = Student.new(student_params)\n\n respond_to do |format|\n if @student.save\n format.html { redirect_to [:admin, @student], notice: 'Student was successfully created.' }\n format.json { render :show, status: :created, location: @student }\n else\n format.html { render :new }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @status_category = StatusCategory.new(status_category_params)\n\n respond_to do |format|\n if @status_category.save\n format.html { redirect_to @status_category, notice: 'Status category was successfully created.' }\n format.json { render :show, status: :created, location: @status_category }\n else\n format.html { render :new }\n format.json { render json: @status_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @category = Category.new(params[:category])\n\n respond_to do |format|\n if @category.save\n format.html { redirect_to api_v1_categories_path, notice: 'Category was successfully created.' }\n format.json { render json: @category, status: :created, location: @category }\n else\n format.html { render action: \"new\" }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @student = current_user.students.build(student_params)\n @student.status = 'imcomplete'\n respond_to do |format|\n if @student.save\n format.html { redirect_to students_url, notice: 'Student was successfully created.' }\n format.json { render :show, status: :created, location: @student }\n else\n format.html { render :new }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @skill_category = SkillCategory.new(skill_category_params)\n\n respond_to do |format|\n if @skill_category.save\n format.html { redirect_to @skill_category, notice: 'Skill category was successfully created.' }\n format.json { render :show, status: :created, location: @skill_category }\n else\n format.html { render :new }\n format.json { render json: @skill_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @enrolled = Enrolled.new(:student_id => current_student.student_id, :course_id => params[:course_id])\n\n respond_to do |format|\n if @enrolled.save\n format.html { redirect_to @enrolled, notice: 'Enrolled was successfully created.' }\n format.json { render json: @enrolled, status: :created, location: @enrolled }\n else\n format.html { render action: \"new\" }\n format.json { render json: @enrolled.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @student = current_user.students.build(student_params)\n # @student = Student.new(student_params)\n # @student.user_id = current_user.id\n\n respond_to do |format|\n if @student.save\n format.html { redirect_to admissions_url, success: 'Student record was successfully created.' }\n format.json { render :show, status: :created, location: @student }\n else\n format.html { render :new }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @class_student = ClassStudent.new(class_student_params)\n\n respond_to do |format|\n if @class_student.save\n format.html { redirect_to @class_student, notice: 'Class student was successfully created.' }\n format.json { render action: 'show', status: :created, location: @class_student }\n else\n format.html { render action: 'new' }\n format.json { render json: @class_student.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @sitecategory = Sitecategory.new(sitecategory_params)\n\n respond_to do |format|\n if @sitecategory.save\n format.html { redirect_to @sitecategory, notice: 'Sitecategory was successfully created.' }\n format.json { render :show, status: :created, location: @sitecategory }\n else\n format.html { render :new }\n format.json { render json: @sitecategory.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @student = Student.new(admin_student_params)\n\n respond_to do |format|\n if @student.save\n format.html { redirect_to @student, notice: 'Student was successfully created.' }\n format.json { render :show, status: :created, location: @student }\n else\n format.html { render :new }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @manage_student = Manage::Student.new(manage_student_params)\n\n respond_to do |format|\n if @manage_student.save\n format.html { redirect_to @manage_student, notice: 'Student was successfully created.' }\n format.json { render :show, status: :created, location: @manage_student }\n else\n format.html { render :new }\n format.json { render json: @manage_student.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @stylist_category = StylistCategory.new(stylist_category_params)\n\n respond_to do |format|\n if @stylist_category.save\n ServiceStylist.create(stylist_category_id: @stylist_category.id, service_category_id: @stylist_category.service_category_id)\n format.html { redirect_to new_salon_path, notice: 'Stylist category was successfully created.' }\n format.json { render :show, status: :created, location: @stylist_category }\n else\n format.html { render :new }\n format.json { render json: @stylist_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def destroy\n # @student_category = StudentCategory.find(params[:id])\n @student_category.destroy\n\n respond_to do |format|\n format.html { redirect_to student_categories_url }\n format.json { head :ok }\n end\n end", "def create\n @admin_student_major = Admin::StudentMajor.new(admin_student_major_params)\n\n respond_to do |format|\n if @admin_student_major.save\n format.html { redirect_to admin_student_majors_url, notice: 'Student major was successfully created.' }\n format.json { render :show, status: :created, location: admin_student_majors_url }\n else\n format.html { render :new }\n format.json { render json: @admin_student_major.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @student = @group.students.new(student_params)\n respond_to do |format|\n if @student.save\n format.html { redirect_to group_students_path(@group), notice: 'Student was successfully created.' }\n else\n format.html { redirect_to group_students_path(@group), notice: \"Student couldn't be created\" }\n end\n end\n end", "def create\n @student = Student.new(student_params)\n\n respond_to do |format|\n if @student.save\n\n #-CONNECT THE SCHOOL AND THE STUDENT IF @school IS PRESENT\n @student.schools << @school if @school\n\n format.html { redirect_to school_student_path(@student.school,@student), notice: 'Student creation successful.' }\n format.json { render :show, status: :created, location: @student }\n else\n format.html { render :new }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @admin_student = Admin::Student.new(admin_student_params)\n\n respond_to do |format|\n if @admin_student.save\n format.html { redirect_to @admin_student, notice: \"Student was successfully created.\" }\n format.json { render :show, status: :created, location: @admin_student }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @admin_student.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @student = Student.find(params[:student_id])\n @student_book = @student.student_books.new(student_book_params)\n authorize! :create, @student_book\n\n respond_to do |format|\n if @student.save\n format.html { redirect_to student_student_books_path(@student), notice: 'Student book was successfully created.' }\n format.json { render :show, status: :created, location: @student_book }\n else\n format.html { render :new }\n format.json { render json: @student_book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @book = Book.new(book_params)\n @categories = Category.all.order('name asc')\n respond_to do |format|\n if @book.save\n format.html { redirect_to books_url, notice: 'Book was successfully created.' }\n format.json { render :show, status: :created, location: @book }\n else\n @categories = Category.all.order('name asc')\n format.html { render :new }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @student = Student.new(student_params)\n @student.user_id = current_user.id\n\n respond_to do |format|\n if @student.save\n format.html { redirect_to @student, notice: 'Estudiante ha sido satisfactoriamente creado.' }\n format.json { render action: 'show', status: :created, location: @student }\n else\n format.html { render action: 'new' }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n \n category = params[:category]\n category_name = category['name']\n \n write_log(\"category.to_s: #{category.to_s}\",\n __FILE__.split(\"/\")[-1],\n __LINE__.to_s)\n \n cats = []\n if category_name != nil\n cats = category_name.split(\" \")\n end\n \n write_log(\"cats.size: #{cats.size}\",\n __FILE__.split(\"/\")[-1],\n __LINE__.to_s)\n\n if cats.size > 1\n \n flag = true\n counter = 0\n \n cats.each do |cat|\n # @category = Category.new(params[:category])\n # @category = Category.new(name=cat)\n @category = Category.new({\"name\"=> cat, \"genre_id\"=> category['genre_id']})\n \n if @category.save\n else\n counter += 1\n end\n end#cats.each do |cat|\n \n respond_to do |format|\n format.html { redirect_to @category, \n notice: \"New categories: Created => #{cats.size - counter}, Failed => #{counter}\" }\n format.json { render json: @category, status: :created, location: @category }\n end\n \n else#if cats.size > 1\n @category = Category.new(params[:category])\n \n respond_to do |format|\n if @category.save\n format.html { redirect_to @category, notice: 'Category was successfully created.' }\n format.json { render json: @category, status: :created, location: @category }\n else\n format.html { render action: \"new\" }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end#if cats.size > 1\n \n \n # @category = Category.new(params[:category])\n# \n # respond_to do |format|\n # if @category.save\n # format.html { redirect_to @category, notice: 'Category was successfully created.' }\n # format.json { render json: @category, status: :created, location: @category }\n # else\n # format.html { render action: \"new\" }\n # format.json { render json: @category.errors, status: :unprocessable_entity }\n # end\n # end\n end", "def create\n @student = Student.new(student_params)\n\n respond_to do |format|\n if @student.save\n format.html { redirect_to @student, notice: 'Student Info was successfully created.' }\n format.json { render action: 'show', status: :created, location: @student }\n else\n format.html { render action: 'new' }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @categor = Categor.new(categor_params)\n\n respond_to do |format|\n if @categor.save\n format.html { redirect_to @categor, notice: 'Categor was successfully created.' }\n format.json { render :show, status: :created, location: @categor }\n else\n format.html { render :new }\n format.json { render json: @categor.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @category = Category.new(category_params)\n\n respond_to do |format|\n if @category.save\n format.html { redirect_to admin_dashboard_categories_path, notice: 'Category was successfully created.' }\n format.json { render :show, status: :created, location: @category }\n else\n format.html { render :new }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @indcategory = Indcategory.new(indcategory_params)\n\n respond_to do |format|\n if @indcategory.save\n format.html { redirect_to @indcategory, notice: 'Indcategory was successfully created.' }\n format.json { render :show, status: :created, location: @indcategory }\n else\n format.html { render :new }\n format.json { render json: @indcategory.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @student_type = StudentType.new(student_type_params)\n\n respond_to do |format|\n if @student_type.save\n format.html { redirect_to @student_type, notice: 'Student type was successfully created.' }\n format.json { render :show, status: :created, location: @student_type }\n else\n format.html { render :new }\n format.json { render json: @student_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @student_group_association = StudentGroupAssociation.new(student_group_association_params)\n\n respond_to do |format|\n if @student_group_association.save\n format.html { redirect_to @student_group_association, notice: 'Student group association was successfully created.' }\n format.json { render :show, status: :created, location: @student_group_association }\n else\n format.html { render :new }\n format.json { render json: @student_group_association.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @student = Student.new(params[:student])\n @student.idSchool = current_user.teacher.idSchool \n\n respond_to do |format|\n if @student.save\n StdTeacher.create(idStd: @student.id, idTeacher: current_user.teacher.id, idGroup: @student.idGroup)\n format.html { redirect_to students_path, notice: 'Student was successfully created.' }\n format.json { render json: @student, status: :created, location: @student }\n else\n format.html { render action: \"new\" }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.66422796", "0.65858465", "0.65275466", "0.63772106", "0.6323289", "0.6309006", "0.6262785", "0.62537557", "0.623655", "0.61883944", "0.6133598", "0.6127766", "0.6109378", "0.61086607", "0.6081514", "0.60611075", "0.60261834", "0.6024759", "0.6021749", "0.6009296", "0.59765345", "0.5951738", "0.59379166", "0.5933802", "0.59272087", "0.59272087", "0.59137183", "0.5907063", "0.5892222", "0.5892222", "0.5892222", "0.5892222", "0.5892222", "0.5892222", "0.5892222", "0.5874811", "0.5868658", "0.5862383", "0.5854239", "0.585102", "0.5838705", "0.58373475", "0.58353394", "0.58282226", "0.582767", "0.5827657", "0.5824593", "0.58186835", "0.5813483", "0.5812549", "0.5812549", "0.5812549", "0.5812549", "0.5812549", "0.5812549", "0.5812549", "0.5812549", "0.5812549", "0.5812549", "0.5812549", "0.5809811", "0.5802566", "0.5801925", "0.57974756", "0.57893765", "0.5788943", "0.57865864", "0.5786302", "0.5766758", "0.5765627", "0.57653475", "0.57645553", "0.57627153", "0.57344186", "0.57318157", "0.57297295", "0.57290804", "0.572393", "0.5710146", "0.57077974", "0.57027316", "0.5699975", "0.56830436", "0.5682606", "0.56804323", "0.5675238", "0.5674691", "0.56731486", "0.5663689", "0.5658336", "0.5652779", "0.56524825", "0.5652128", "0.5651296", "0.5650818", "0.564676", "0.56465775", "0.56432146", "0.5640216", "0.56401026" ]
0.7259163
0
PUT /student_categories/1 PUT /student_categories/1.json
def update # @student_category = StudentCategory.find(params[:id]) respond_to do |format| if @student_category.update_attributes(params[:student_category]) format.html { redirect_to @student_category, notice: 'Student category was successfully updated.' } format.json { head :ok } else format.html { render action: "edit" } format.json { render json: @student_category.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def UpdateCategory params = {}\n \n APICall(path: 'categories.json',method: 'PUT',payload: params.to_json)\n \n end", "def update\n json_update(category,category_params, Category)\n end", "def update_categories(categories, options = {} )\n options.merge!(:docid => self.docid, :categories => categories)\n resp = @conn.put do |req|\n req.url \"categories\"\n req.body = options.to_json\n end\n\n resp.status \n end", "def set_mg_student_category\n @student_category = MgStudentCategory.find(params[:id])\n end", "def update\n if @student.update(student_params)\n render json: @student\n else\n render json: @student.errors, status: :unprocessable_entity\n end\n end", "def create\n # @student_category = StudentCategory.new(params[:student_category])\n\n respond_to do |format|\n if @student_category.save\n format.html { redirect_to @student_category, notice: 'Student category was successfully created.' }\n format.json { render json: @student_category, status: :created, location: @student_category }\n else\n format.html { render action: \"new\" }\n format.json { render json: @student_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @st_category.update(st_category_params)\n format.html { redirect_to @st_category, notice: 'St category was successfully updated.' }\n format.json { render :show, status: :ok, location: @st_category }\n else\n format.html { render :edit }\n format.json { render json: @st_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @student_type = StudentType.find(params[:id])\n\n if @student_type.update(student_type_params)\n head :no_content\n else\n render json: @student_type.errors, status: :unprocessable_entity\n end\n end", "def update\n if @category.update(category_params)\n render json: @category, status: :ok\n else\n render json: @category.errors, status: :unprocessable_entity\n end\n end", "def update\n respond_to do |format|\n if @standard_category.update(standard_category_params)\n format.html { redirect_to [@standard_category.course,@standard_category], notice: 'Standard category was successfully updated.' }\n format.json { render :show, status: :ok, location: @standard_category }\n else\n format.html { render :edit }\n format.json { render json: @standard_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def user_category_edit\n @user = User.where(contact: params[:contact]).first\n @user.categories.destroy_all\n params[:category_ids].each do |category|\n @user.user_categories.create!(category_id: category, user_id: @user.id)\n end\n render json: {status: \"SUCCESS\", message: \"user-categories\", data: \"categories updated\"}, status: :ok\n end", "def update\n @student = @user.student\n @subject_competency_array = params[:student][:subjects_of_interest]\n #remove subjects in dB before update\n @student[:subjects_of_interest].delete_if do |s|\n s != nil\n end\n @student.save\n @subject_competency_array.each do |s|\n @student.subjects_of_interest.push({\n \"subject\" => s[:subject],\n \"competency\" => s[:competency]\n })\n end\n @student.save\n respond_to do |format|\n if @student.update(student_params)\n format.html { redirect_to user_profile_url, notice: 'Profile was successfully updated.' }\n else\n render :action => 'new'\n end\n end\n end", "def update\n @student_category.update(mg_student_category_params)\n redirect_to '/student_categories'\n\n # respond_to do |format|\n # if @mg_action.update(mg_action_params)\n # format.html { redirect_to @mg_action, notice: 'Mg action was successfully updated.' }\n # format.json { render :show, status: :ok, location: @mg_action }\n # else\n # format.html { render :edit }\n # format.json { render json: @mg_action.errors, status: :unprocessable_entity }\n # end\n # end\n end", "def update\n @course_category = CourseCategory.find(params[:id])\n\n respond_to do |format|\n if @course_category.update_attributes(params[:course_category])\n format.html { redirect_to @course_category, notice: 'Course category was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @course_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @student = Student.find(params[:id])\n @student.update_attributes(params[:student])\n end", "def update\n params[:book][:category_ids] = nil if params[:book][:category_ids].nil?\n respond_to do |format|\n if @book.update(book_params)\n format.html { redirect_to books_url, notice: 'Book was successfully updated.' }\n format.json { render :show, status: :ok, location: @book }\n else\n @categories = Category.all.order('name asc')\n format.html { render :edit }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n # @student_categories = StudentCategory.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @student_categories }\n end\n end", "def destroy\n # @student_category = StudentCategory.find(params[:id])\n @student_category.destroy\n\n respond_to do |format|\n format.html { redirect_to student_categories_url }\n format.json { head :ok }\n end\n end", "def update\n if @categoria.update(categoria_params)\n render json: @categoria\n else\n render json: @categoria.errors, status: :unprocessable_entity \n end\n end", "def update\n update! {admin_categories_path}\n end", "def update\n begin\n student = Student.find(params[:id])\n student.update_attributes!(student_params)\n\n render json: {status: 'SUCCESS', message:\"Student updated Successfully with name #{student.name}\", data:student}, status: :ok\n rescue => error\n render json: {status: 'ERROR', message:'Student Update failed!', data:error}, status: :unprocessable_entity\n end\n end", "def update\n @category = Category.find(params[:id])\n\n respond_to do |format|\n if @category.update_attributes(params[:category])\n format.html { redirect_to api_v1_categories_path, notice: 'Category was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @incidentcategory.update(incidentcategory_params)\n json_response(@incidentcategory)\n else\n render json: @incidentcategory.errors, status: :unprocessable_entity\n end\n end\n end", "def update\n respond_to do |format|\n if @category.update(category_params)\n format.json { render :show, status: :ok, location: @category }\n else\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @student = User::Student.find(params[:id])\n respond_to do |format|\n if @student.update(student_params)\n format.html { redirect_to user_student_path(@user, @student), notice: 'Student was successfully updated.' }\n format.json { render :show, status: :ok, location: user_student_path(@user, @student) }\n else\n format.html { render :edit }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @student.update(student_params)\n render :show, status: :ok, location: @student\n else\n render json: @student.errors, status: :unprocessable_entity\n end\n end", "def update\n @category = Category.find(params[:id])\n @category.update_attributes(params[:category])\n respond_with(@category, location: categories_url)\n end", "def set_st_category\n @st_category = StCategory.find(params[:id])\n end", "def update\n # @student = Student.find(params[:id])\n\n respond_to do |format|\n if @student.update_attributes(params[:student])\n format.html { redirect_to @student, notice: 'Student was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @exam_category = ExamCategory.find(params[:id])\n\n respond_to do |format|\n if @exam_category.update_attributes(params[:exam_category])\n format.html { redirect_to @exam_category, notice: 'Exam category was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @exam_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @category.update(params[:category])\n head :no_content\n else\n render json: @category.errors, status: :unprocessable_entity\n end\n end", "def putCategory( category_id, language, name)\n params = Hash.new\n params['category_id'] = category_id\n params['language'] = language\n params['name'] = name\n return doCurl(\"put\",\"/category\",params)\n end", "def update\n @headline = t(:update_category)\n @category = Category.find(params[:id])\n\n respond_to do |format|\n if @category.update_attributes(params[:category])\n format.html { redirect_to @category, notice: t(:updated_category_success) }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @student_major = StudentMajor.find(params[:id])\n\n respond_to do |format|\n if @student_major.update_attributes(student_major_params)\n format.html { redirect_to @student_major, notice: 'Student major was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @student_major.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @studentset = Studentset.find(params[:id])\n\n respond_to do |format|\n if @studentset.update_attributes(params[:studentset])\n format.html { redirect_to @studentset, notice: 'Studentset was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @studentset.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @category.update_attributes(params[:category])\n respond_with(@category)\n end", "def update\n category= Category.find(params[:id])\n category.update(category_params)\n \n end", "def update\n @student = current_user.teacher.students.find(params[:id])\n\n respond_to do |format|\n if @student.update_attributes(params[:student])\n StdTeacher.where(\"idStd = ? AND idTeacher = ?\", @student.id, current_user.teacher.id).update_all(idGroup: @student.idGroup)\n format.html { redirect_to students_path, notice: 'Student was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @student = Student.find(params[:id])\n\n respond_to do |format|\n if @student.update_attributes(params[:student])\n format.html { redirect_to @student, notice: 'Student was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @student = Student.find(params[:id])\n\n respond_to do |format|\n if @student.update_attributes(params[:student])\n format.html { redirect_to students_path, notice: 'Student was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @category.update(category_params)\n end", "def update\n category = Documents::Category.find(params[:id])\n category.update!(category_params)\n redirect_to categories_path\n end", "def update\n @student = Student.find(params[:id])\n\n respond_to do |format|\n if @student.update_attributes(params[:student])\n format.html { redirect_to @student, notice: 'Student was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @student = Student.find(params[:id])\n\n respond_to do |format|\n if @student.update_attributes(params[:student])\n format.html { redirect_to @student, notice: 'Student was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @student = Student.find(params[:id])\n\n respond_to do |format|\n if @student.update_attributes(params[:student])\n format.html { redirect_to @student, notice: 'Student was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @student = Student.find(params[:id])\n\n respond_to do |format|\n if @student.update_attributes(params[:student])\n format.html { redirect_to @student, notice: 'Student was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @student = Student.find(params[:id])\n\n respond_to do |format|\n if @student.update_attributes(params[:student])\n format.html { redirect_to @student, notice: 'Student was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @category.update(category_params)\n format.html { redirect_to api_v1_category_path(@category), notice: 'Category was successfully updated.' }\n format.json { render :show, status: :ok, location: @category }\n else\n format.html { render :edit }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @student = Student.find(params[:id])\n\n respond_to do |format|\n if @student.update_attributes(params[:student])\n format.html { redirect_to @student, :notice => 'Student was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @student.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @student = Student.find(params[:id])\n\n respond_to do |format|\n if @student.update_attributes(params[:student])\n format.html { redirect_to @student, :notice => 'Student was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @student.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @specialization_category.update(specialization_category_params)\n format.html { redirect_to @specialization_category, notice: 'Specialization category was successfully updated.' }\n format.json { render :show, status: :ok, location: @specialization_category }\n else\n format.html { render :edit }\n format.json { render json: @specialization_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @skill_category.update(skill_category_params)\n format.html { redirect_to @skill_category, notice: 'Skill category was successfully updated.' }\n format.json { render :show, status: :ok, location: @skill_category }\n else\n format.html { render :edit }\n format.json { render json: @skill_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @student_sub_course = StudentSubCourse.find(params[:id])\n\n respond_to do |format|\n if @student_sub_course.update_attributes(params[:student_sub_course])\n format.html { redirect_to @student_sub_course, notice: 'Student sub course was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @student_sub_course.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @catalog_category.update(catalog_category_params)\n format.html { redirect_to catalog_categories_url }\n format.json { render :show, status: :ok, location: @catalog_category }\n else\n format.html { render :edit }\n format.json { render json: @catalog_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @categories = Category.all\n @users = User.all\n respond_to do |format|\n if @book.update(book_params)\n format.html { redirect_to @book, notice: 'Book was successfully updated.' }\n format.json { render :show, status: :ok, location: @book }\n else\n format.html { render :edit }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n get_supplier\n @supplier_category = @supplier.categories.find(params[:id])\n @supplier_category.update_attributes(params[:supplier_category])\n end", "def update\n respond_to do |format|\n if @student_class.update(student_class_params)\n format.html { redirect_to @student_class, notice: \"Student class was successfully updated.\" }\n format.json { render :show, status: :ok, location: @student_class }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @student_class.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\t\t@ssccategory = Ssccategory.find(params[:id])\n\n\t\t@ssccategory.modified_by = 1\n\n\t\tif @ssccategory.update_attributes(params[:ssccategory])\n\t\t\tflash[:notice] = 'Ssccategory Updated Sucessfully.'\n\t\t\tredirect_to :action => 'show', :id => @ssccategory\n\t\telse\n\t\t\trender :action => 'edit'\n\t\tend\n\tend", "def update\n @student = Student.find(params[:id])\n\n respond_to do |format|\n if @student.update_attributes(params[:student]) and\n @student.usuario.update_attributes(params[:student][:usuario_attributes])\n format.html { redirect_to [:admin, @student], notice: 'Student was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @dojo_student = DojoStudent.find(params[:id])\n\n respond_to do |format|\n if @dojo_student.update_attributes(params[:dojo_student])\n format.html { redirect_to @dojo_student, notice: 'Dojo student was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @dojo_student.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n unless @category.name == \"ROOT\"\n if @category.update(category_params)\n render 'show', :status => 200, :layout => false, notice: 'Category was successfully created.'\n else\n render :json => {:message => \"Error in updating category\"}, notice: @category.errors, :layout => false, :status => 400\n end\n else\n render :json => {:message => \"Root can't be edited.\"}, :layout => false, :status => 400\n end\n end", "def update\n @student = Student.find(params[:id])\n if @student.klass and @student.klass.id != params[:student][:klass_id].to_i\n @student.papers.delete_all\n end\n if(@student.update_attributes(params[:student])) \n # TODO redesign this when we do wizard flows for right-bar actions\n if(session[:redirect]) and session[:redirect] == student_path(@student)\n render :update do |page|\n # TODO wizard for adding subjects or render breadcrumbs thru ajax\n page.redirect_to session[:redirect]\n end\n else\n render :template => 'students/update_success'\n end\n else\n render :template => 'students/update_failure'\n end\n end", "def update\n respond_to do |format|\n if @status_category.update(status_category_params)\n format.html { redirect_to @status_category, notice: 'Status category was successfully updated.' }\n format.json { render :show, status: :ok, location: @status_category }\n else\n format.html { render :edit }\n format.json { render json: @status_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @enrolled_student = EnrolledStudent.find(params[:id])\n\n respond_to do |format|\n if @enrolled_student.update_attributes(params[:enrolled_student])\n format.html { redirect_to @enrolled_student, notice: 'Enrolled student was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @enrolled_student.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n # @student_category = StudentCategory.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @student_category }\n end\n end", "def update\n respond_to do |format|\n if @book_category.update(book_category_params)\n format.html { redirect_to @book_category, notice: 'Book category was successfully updated.' }\n format.json { render :show, status: :ok, location: @book_category }\n else\n format.html { render :edit }\n format.json { render json: @book_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @stylist_category.update(stylist_category_params)\n format.html { redirect_to @stylist_category, notice: 'Stylist category was successfully updated.' }\n format.json { render :show, status: :ok, location: @stylist_category }\n else\n format.html { render :edit }\n format.json { render json: @stylist_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @student_entity.update(student_entity_params)\n format.json { render :show, status: :ok, location: @student_entity }\n else\n format.json { render json: @student_entity.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @user = User.find_by_id(params[:user])\n @student.user = @user\n @department = Department.find_by_id(params[:department])\n @student.department = @department\n respond_to do |format|\n if @student.update(student_params)\n format.html { redirect_to @student, notice: 'Student was successfully updated.' }\n format.json { render :show, status: :ok, location: @student }\n else\n format.html { render :edit }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_categories_course\n @categories_course = CategoriesCourse.find(params[:id])\n end", "def update\n respond_to do |format|\n if @student_type.update(student_type_params)\n format.html { redirect_to @student_type, notice: 'Student type was successfully updated.' }\n format.json { render :show, status: :ok, location: @student_type }\n else\n format.html { render :edit }\n format.json { render json: @student_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def show\n # @student_category = StudentCategory.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @student_category }\n end\n end", "def update\n respond_to do |format|\n if @student.update(student_params)\n format.html { redirect_to @student, notice: \"Student was successfully updated.\" }\n format.json { render :show, status: :ok, location: @student }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @student.update(student_params)\n format.html { redirect_to @student, notice: \"Student was successfully updated.\" }\n format.json { render :show, status: :ok, location: @student }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @student.update(student_params)\n format.html { redirect_to @student, notice: \"Student was successfully updated.\" }\n format.json { render :show, status: :ok, location: @student }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @question_category = QuestionCategory.find(params[:id])\n\n respond_to do |format|\n if @question_category.update_attributes(params[:question_category])\n format.html { redirect_to @question_category, notice: 'Question category was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @question_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @service_category = ServiceCategory.find(params[:id])\n\n respond_to do |format|\n if @service_category.update_attributes(params.require(:service_category).permit(:name))\n format.html { redirect_to service_categories_url,\n notice: 'ServiceCategory was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @service_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @student = Student.new(student_params)\n\n respond_to do |format|\n if @student.save\n format.html { redirect_to @student, notice: 'Student was successfully created.' }\n format.json { render :show, status: :created, location: @student }\n # Add the course just created to this student's courses, better use the drop down list \n if params[:course] != nil then\n @student.courses << Course.find(params[:course][:id])\n end\n else\n format.html { render :new }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @class_student.update(class_student_params)\n format.html { redirect_to @class_student, notice: 'Class student was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @class_student.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @student.update(student_params)\n format.html { redirect_to @student,\n notice: 'Student was successfully updated.' }\n format.json { render :show, status: :ok, location: @student }\n else\n format.html { render :edit }\n format.json { render json: @student.errors,\n status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @student.update(student_params)\n format.html { redirect_to @student, notice: 'Student was successfully updated.' }\n format.json { render :show, status: :ok, location: @student }\n else\n format.html { render :edit }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @student.update(student_params)\n format.html { redirect_to @student, notice: 'Student was successfully updated.' }\n format.json { render :show, status: :ok, location: @student }\n else\n format.html { render :edit }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @student.update(student_params)\n format.html { redirect_to @student, notice: 'Student was successfully updated.' }\n format.json { render :show, status: :ok, location: @student }\n else\n format.html { render :edit }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @student.update(student_params)\n format.html { redirect_to @student, notice: 'Student was successfully updated.' }\n format.json { render :show, status: :ok, location: @student }\n else\n format.html { render :edit }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @student.update(student_params)\n format.html { redirect_to @student, notice: 'Student was successfully updated.' }\n format.json { render :show, status: :ok, location: @student }\n else\n format.html { render :edit }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @student.update(student_params)\n format.html { redirect_to @student, notice: 'Student was successfully updated.' }\n format.json { render :show, status: :ok, location: @student }\n else\n format.html { render :edit }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @student.update(student_params)\n format.html { redirect_to @student, notice: 'Student was successfully updated.' }\n format.json { render :show, status: :ok, location: @student }\n else\n format.html { render :edit }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @student.update(student_params)\n format.html { redirect_to @student, notice: 'Student was successfully updated.' }\n format.json { render :show, status: :ok, location: @student }\n else\n format.html { render :edit }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @student.update(student_params)\n format.html { redirect_to @student, notice: 'Student was successfully updated.' }\n format.json { render :show, status: :ok, location: @student }\n else\n format.html { render :edit }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @student.update(student_params)\n format.html { redirect_to @student, notice: 'Student was successfully updated.' }\n format.json { render :show, status: :ok, location: @student }\n else\n format.html { render :edit }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @student.update(student_params)\n format.html { redirect_to @student, notice: 'Student was successfully updated.' }\n format.json { render :show, status: :ok, location: @student }\n else\n format.html { render :edit }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @student.update(student_params)\n format.html { redirect_to @student, notice: 'Student was successfully updated.' }\n format.json { render :show, status: :ok, location: @student }\n else\n format.html { render :edit }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @student.update(student_params)\n format.html { redirect_to @student, notice: 'Student was successfully updated.' }\n format.json { render :show, status: :ok, location: @student }\n else\n format.html { render :edit }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @student.update(student_params)\n format.html { redirect_to @student, notice: 'Student was successfully updated.' }\n format.json { render :show, status: :ok, location: @student }\n else\n format.html { render :edit }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @student.update(student_params)\n format.html { redirect_to @student, notice: 'Student was successfully updated.' }\n format.json { render :show, status: :ok, location: @student }\n else\n format.html { render :edit }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @student.update(student_params)\n format.html { redirect_to @student, notice: 'Student was successfully updated.' }\n format.json { render :show, status: :ok, location: @student }\n else\n format.html { render :edit }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @student.update(student_params)\n format.html { redirect_to @student, notice: 'Student was successfully updated.' }\n format.json { render :show, status: :ok, location: @student }\n else\n format.html { render :edit }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @consumer_category = ConsumerCategory.find(params[:id])\n\n respond_to do |format|\n if @consumer_category.update_attributes(params[:consumer_category])\n format.html { redirect_to @consumer_category, notice: 'Consumer category was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @consumer_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @mg_student_category = MgStudentCategory.new(mg_create_student_category_params)\n @mg_student_category.save\n redirect_to '/student_categories'\n\n \n end", "def update\n @taxonomy_category = TaxonomyCategory.find(params[:id])\n\n respond_to do |format|\n if @taxonomy_category.update_attributes(params[:taxonomy_category])\n format.html { redirect_to @taxonomy_category, notice: 'Taxonomy category was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @taxonomy_category.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.6710342", "0.64764243", "0.6471951", "0.6228575", "0.61961347", "0.61764073", "0.6159607", "0.6087562", "0.6031057", "0.60020834", "0.5995422", "0.59750146", "0.59722286", "0.5968835", "0.5929871", "0.59199893", "0.5916816", "0.5897858", "0.588357", "0.58741325", "0.58663934", "0.58653903", "0.5825599", "0.5814866", "0.5786107", "0.57843393", "0.5783183", "0.57799816", "0.5774852", "0.57638824", "0.5763125", "0.576249", "0.57585186", "0.57553536", "0.57445055", "0.573743", "0.57284164", "0.5713165", "0.5709527", "0.57076734", "0.570425", "0.5701786", "0.56984484", "0.56984484", "0.56984484", "0.56984484", "0.56984484", "0.56813633", "0.56811684", "0.56811684", "0.56811297", "0.56749296", "0.5671369", "0.56656915", "0.5657891", "0.5657157", "0.56512755", "0.5647831", "0.56436723", "0.56363904", "0.5632547", "0.5630907", "0.5628367", "0.5625045", "0.56218237", "0.5621375", "0.5619508", "0.5618742", "0.56128675", "0.56083345", "0.5603662", "0.5598888", "0.5598591", "0.5598591", "0.5598591", "0.55959034", "0.55909216", "0.5590713", "0.558976", "0.55880266", "0.55875164", "0.55875164", "0.55875164", "0.55875164", "0.55875164", "0.55875164", "0.55875164", "0.55875164", "0.55875164", "0.55875164", "0.55875164", "0.55875164", "0.55875164", "0.55875164", "0.55875164", "0.55875164", "0.55875164", "0.5576814", "0.55765176", "0.55764544" ]
0.70322895
0
DELETE /student_categories/1 DELETE /student_categories/1.json
def destroy # @student_category = StudentCategory.find(params[:id]) @student_category.destroy respond_to do |format| format.html { redirect_to student_categories_url } format.json { head :ok } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @student_category.destroy\n respond_to do |format|\n format.html { redirect_to mg_student_categories_url, notice: 'successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @student.delete\n respond_to do |format|\n format.html { redirect_to students_url }\n format.json { head :no_content }\n end\n end", "def destroy\n student.destroy\n respond_to do |format|\n format.html { redirect_to admin_students_path }\n format.json { head :no_content }\n end\n end", "def destroy\n @student.destroy\n respond_to do |format|\n format.html { redirect_to students_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @student.destroy\n respond_to do |format|\n format.html { redirect_to students_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @student.destroy\n respond_to do |format|\n format.html { redirect_to students_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @student.destroy\n respond_to do |format|\n format.html { redirect_to students_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @student_type.destroy\n\n head :no_content\n end", "def destroy\n # @student = Student.find(params[:id])\n @student.destroy\n\n respond_to do |format|\n format.html { redirect_to students_url }\n format.json { head :ok }\n end\n end", "def destroy\n @studentset = Studentset.find(params[:id])\n @studentset.destroy\n\n respond_to do |format|\n format.html { redirect_to studentsets_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @student_entity.destroy\n render json: {msg: 'deleted successfully'}, status: 200\n end", "def destroy\n @student = Student.find(params[:id])\n @student.destroy\n\n respond_to do |format|\n format.html { redirect_to students_path }\n format.json { head :no_content }\n end\n end", "def destroy\n @student = Student.find(params[:id])\n @student.destroy\n\n respond_to do |format|\n format.html { redirect_to students_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @student = Student.find(params[:id])\n @student.destroy\n\n respond_to do |format|\n format.html { redirect_to students_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @student = Student.find(params[:id])\n @student.destroy\n\n respond_to do |format|\n format.html { redirect_to students_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @student = Student.find(params[:id])\n @student.destroy\n\n respond_to do |format|\n format.html { redirect_to students_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @student = Student.find(params[:id])\n @student.destroy\n\n respond_to do |format|\n format.html { redirect_to students_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @student = Student.find(params[:id])\n @student.destroy\n\n respond_to do |format|\n format.html { redirect_to students_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @student = Student.find(params[:id])\n @student.destroy\n\n respond_to do |format|\n format.html { redirect_to students_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @student = Student.find(params[:id])\n @student.destroy\n\n respond_to do |format|\n format.html { redirect_to students_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @student = Student.find(params[:id])\n @student.destroy\n\n respond_to do |format|\n format.html { redirect_to students_url }\n format.json { head :ok }\n end\n end", "def destroy\n @student.destroy\n respond_to do |format|\n format.html { redirect_to group_students_path(@group), notice: 'Student was successfully deleted.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @dojo_student = DojoStudent.find(params[:id])\n @dojo_student.destroy\n\n respond_to do |format|\n format.html { redirect_to dojo_students_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @class_student.destroy\n respond_to do |format|\n format.html { redirect_to class_students_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @student.destroy\n respond_to do |format|\n format.html { redirect_to students_url, notice: \"Student was successfully removed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @student.destroy\n respond_to do |format|\n format.html { redirect_to students_url, notice: \"Student was successfully deleted.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @student.destroy\n respond_to do |format|\n format.html { redirect_to students_url, notice: 'Se borró el registro de alumna satisfactoriamente.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @student = Student.find(params[:id])\n @student.destroy\n\n respond_to do |format|\n format.html { redirect_to login_index_url }\n format.json { head :ok }\n end\n end", "def destroy\n @student.destroy\n respond_to do |format|\n format.html { redirect_to students_url, notice: '生徒情報は削除されました' }\n format.json { head :no_content }\n end\n end", "def destroy\n @studentsection.destroy\n respond_to do |format|\n format.html { redirect_to studentsections_url, notice: 'Studentsection was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @student.destroy\n respond_to do |format|\n format.html { redirect_to @student.school, notice: 'Student deletion successful.' }\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 #@incidentcategory.destroy\n render json: {}, status: 200\n end", "def destroy\n @st_category.destroy\n respond_to do |format|\n format.html { redirect_to st_categories_url, notice: 'St category was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @student.destroy\n respond_to do |format|\n format.html { redirect_to admin_students_url, notice: 'Student was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @student.destroy\n respond_to do |format|\n format.html { redirect_to admin_students_url, notice: 'Student was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @student.destroy\n respond_to do |format|\n format.html { redirect_to admin_students_url, notice: 'Student was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @student_sub_course = StudentSubCourse.find(params[:id])\n @student_sub_course.destroy\n\n respond_to do |format|\n format.html { redirect_to student_sub_courses_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @student.destroy\n respond_to do |format|\n format.html {\n flash[:success] = \"Estudante apagado.\"\n redirect_to students_url\n }\n format.json { head :no_content }\n end\n end", "def destroy\n @student_major = StudentMajor.find(params[:id])\n @student_major.destroy\n\n respond_to do |format|\n format.html { redirect_to student_majors_url }\n format.json { head :no_content }\n end\n end", "def destroy\r\n @student1 = Student1.find(params[:id])\r\n @student1.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_to student1s_url }\r\n format.json { head :no_content }\r\n end\r\n end", "def destroy\n @student_type.destroy\n respond_to do |format|\n format.html { redirect_to student_types_url, notice: 'Student type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @category.destroy\n render json: @category, status: :ok\n end", "def destroy\n delete_with_references(@student,students_path)\n end", "def destroy\n @student.destroy\n respond_to do |format|\n format.html { redirect_to active_students_url, notice: 'Student was successfully deleted.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @student.destroy\n respond_to do |format|\n format.html { redirect_to user_students_url(@user), notice: 'Student was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @student.destroy\n respond_to do |format|\n format.html { redirect_to students_url, notice: 'Student was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @student.destroy\n respond_to do |format|\n format.html { redirect_to students_url, notice: 'Student was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @student.destroy\n respond_to do |format|\n format.html { redirect_to students_url, notice: 'Student was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @student.destroy\n respond_to do |format|\n format.html { redirect_to students_url, notice: 'Student was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @student.destroy\n respond_to do |format|\n format.html { redirect_to students_url, notice: 'Student was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @student.destroy\n respond_to do |format|\n format.html { redirect_to students_url, notice: 'Student was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @student.destroy\n respond_to do |format|\n format.html { redirect_to students_url, notice: 'Student was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @student.destroy\n respond_to do |format|\n format.html { redirect_to students_url, notice: 'Student was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @student.destroy\n respond_to do |format|\n format.html { redirect_to students_url, notice: 'Student was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @student.destroy\n respond_to do |format|\n format.html { redirect_to students_url, notice: 'Student was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @student.destroy\n respond_to do |format|\n format.html { redirect_to students_url, notice: 'Student was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @student.destroy\n respond_to do |format|\n format.html { redirect_to students_url, notice: 'Student was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @student.destroy\n respond_to do |format|\n format.html { redirect_to students_url, notice: 'Student was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @student.destroy\n respond_to do |format|\n format.html { redirect_to students_url, notice: 'Student was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @student.destroy\n respond_to do |format|\n format.html { redirect_to students_url, notice: 'Student was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @student.destroy\n respond_to do |format|\n format.html { redirect_to students_url, notice: 'Student was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @student.destroy\n respond_to do |format|\n format.html { redirect_to students_url, notice: 'Student was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @student.destroy\n respond_to do |format|\n format.html { redirect_to students_url, notice: 'Student was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @student.destroy\n respond_to do |format|\n format.html { redirect_to students_url, notice: 'Student was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @student.destroy\n respond_to do |format|\n format.html { redirect_to students_url, notice: 'Student was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @student.destroy\n respond_to do |format|\n format.html { redirect_to students_url, notice: 'Student was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @student.destroy\n respond_to do |format|\n format.html { redirect_to students_url, notice: 'Student was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @student.destroy\n respond_to do |format|\n format.html { redirect_to students_url, notice: 'Student was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n Student.delete(params[:id])\n respond_to do |format|\n format.html { redirect_to students_url, notice: 'Student was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @student_class.destroy\n respond_to do |format|\n format.html { redirect_to student_classes_url, notice: \"Student class was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @student.destroy\n respond_to do |format|\n format.html { redirect_to students_url, notice: \"Student was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @student.destroy\n respond_to do |format|\n format.html { redirect_to students_url, notice: \"Student was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @student.destroy\n respond_to do |format|\n format.html { redirect_to students_url, notice: \"Student was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @student.destroy\n respond_to do |format|\n format.html { redirect_to students_url,\n notice: 'Student was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @student = Student.find(params[:student_id])\n @lunchdetention = Lunchdetention.find(params[:id])\n @lunchdetention.destroy\n\n respond_to do |format|\n format.html { redirect_to student_url(@student) }\n format.json { head :no_content }\n end\n end", "def destroy\n @indexstudent = Indexstudent.find(params[:id])\n @indexstudent.destroy\n\n respond_to do |format|\n format.html { redirect_to indexstudents_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @student = @current_lop.students.find(params[:id])\n if @student.destroy\n respond_to do |format|\n format.html { redirect_to students_url, notice: 'Student was successfully destroyed.' }\n format.json { head :no_content }\n end\n end\n end", "def destroy\n @enrolled_student = EnrolledStudent.find(params[:id])\n @enrolled_student.destroy\n\n respond_to do |format|\n format.html { redirect_to enrolled_students_url }\n format.json { head :ok }\n end\n end", "def destroy\n @student = Student.find(params[:id])\n @student.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_students_url, notice: 'Student was successfully destroyed' }\n format.json { head :no_content }\n end\n end", "def destroy\n @admin_student_major.destroy\n respond_to do |format|\n format.html { redirect_to admin_student_majors_url, notice: 'Student major was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n begin\n student = Student.find(params[:id])\n student.destroy!\n\n render json: {status: 'SUCCESS', message:\"Student deleted Successfully with name #{student.name}\"}, status: :ok\n rescue => error\n render json: {status: 'ERROR', message:'Student Update failed!', data:error}, status: :unprocessable_entity\n end\n end", "def destroy\n @admin_student.destroy\n respond_to do |format|\n format.html { redirect_to admin_students_url, notice: \"Student was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @student = Student.find(params[:id])\n @student.destroy\n respond_to do |format|\n format.html { redirect_to students_url, notice: 'Студент був видалений.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @student_test = StudentTest.find(params[:id])\n @student_test.destroy\n\n respond_to do |format|\n format.html { redirect_to student_tests_url }\n format.json { head :ok }\n end\n end", "def DeleteCategory id\n \n APICall(path: \"categories/#{id}.json\",method: 'DELETE')\n \n end", "def destroy\n @student = Student.find(params[:id])\n id = @student.usuario_id\n @usuario = Usuario.find(id)\n @usuario.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_students_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @course_category = CourseCategory.find(params[:id])\n @course_category.destroy\n\n respond_to do |format|\n format.html { redirect_to course_categories_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @student_action.destroy\n respond_to do |format|\n format.html { redirect_to student_actions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @group_student.destroy\n respond_to do |format|\n format.html { redirect_to group_students_url, notice: 'Group student was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @student_interest.destroy\n respond_to do |format|\n format.html { redirect_to student_interests_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @section_category = SectionCategory.find(params[:id])\n @section_category.destroy\n\n respond_to do |format|\n format.html { redirect_to root_path }\n format.json { head :no_content }\n end\n end", "def destroy\n @student = Student.find(params[:id])\n @student.destroy\n flash[:notice] = \"Student has been deleted successfully\"\n respond_to do |format|\n format.html { redirect_to students_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @student.destroy\n respond_to do |format|\n format.html { redirect_to import_students_url, notice: 'Student was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @student_user = StudentUser.find(params[:id])\n @student_user.destroy\n\n respond_to do |format|\n format.html { redirect_to student_users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @manage_student.destroy\n respond_to do |format|\n format.html { redirect_to manage_students_url, notice: 'Student was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @standard_category.destroy\n respond_to do |format|\n format.html { redirect_to course_standard_categories_url(@course), notice: 'Standard category was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @student = Student.find(params[:id])\n @student.destroy\n end", "def destroy\n @student.destroy\n respond_to do |format|\n format.html { redirect_to manage_school_school_path(@school), notice: 'Student was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @student.destroy\n respond_to do |format|\n format.html { redirect_to visitors_url, notice: 'El estudiante fue borrado.' }\n format.json { head :no_content }\n end\n end" ]
[ "0.7558042", "0.7288963", "0.7162421", "0.7134572", "0.7134572", "0.7134572", "0.7134572", "0.7104059", "0.7089248", "0.7079892", "0.7051919", "0.7047926", "0.70442444", "0.70442444", "0.70442444", "0.70442444", "0.70442444", "0.70442444", "0.70442444", "0.70442444", "0.7032796", "0.70175517", "0.70002115", "0.6981951", "0.69791424", "0.6963321", "0.69456095", "0.69277", "0.69144034", "0.6906366", "0.6863727", "0.6863069", "0.6855912", "0.6850249", "0.68474334", "0.68474334", "0.68474334", "0.6846659", "0.6839835", "0.6838722", "0.68328404", "0.6828326", "0.6824449", "0.68232906", "0.6818836", "0.68103707", "0.68078655", "0.68078655", "0.68078655", "0.68078655", "0.68078655", "0.68078655", "0.68078655", "0.68078655", "0.68078655", "0.68078655", "0.68078655", "0.68078655", "0.68078655", "0.68078655", "0.68078655", "0.68078655", "0.68078655", "0.68078655", "0.68078655", "0.68078655", "0.68078655", "0.68078655", "0.68078655", "0.6807374", "0.68049365", "0.6803802", "0.6803802", "0.6803802", "0.6802795", "0.6799779", "0.6797214", "0.6784073", "0.67766607", "0.6762519", "0.6759248", "0.6752331", "0.67480093", "0.67435193", "0.67327", "0.67323184", "0.6730853", "0.67287844", "0.6724951", "0.6724406", "0.6723568", "0.6712936", "0.6712416", "0.67111814", "0.6707431", "0.6697673", "0.66961294", "0.6694862", "0.66930246", "0.66849357" ]
0.7850941
0
Execute a search query against a search index
def search(builder) send_and_receive connection_config[:url], builder.blacklight_params end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def search(index, query, options = {})\n raise NotImplementedError, 'Search has not been implemented'\n end", "def execute_search(query)\n search_resource.retrieve(query)\n end", "def search(index, body)\n handler.search index: index, body: body\n end", "def search(query); end", "def query_for_index(query, index)\n search_url = \"http://ajax.googleapis.com/ajax/services/search/#{index}?v=1.0&q=#{URI.escape(query)}\"\n @res[search_url] = ''\n \n @multi.add(Curl::Easy.new(search_url) do|cfg|\n cfg.headers['Referer'] = @referer\n cfg.on_body{|data| @res[cfg.url] << data; data.size }\n cfg.on_success {|easy| yield(JSON.parse(@res[easy.url])) }\n end)\n end", "def execute\n @model_class.search(KEYWORD)\n end", "def search(index_path, query)\n results = Connection.post(\n [index_path, \"_search\"].join(\"/\"),\n :body => MultiJson.encode(query.body)\n )\n results_body = MultiJson.decode(results.body)\n if results.success?\n ElasticSearch::Results.new query, results_body, @conversions\n else\n raise QueryError.new(results_body[\"error\"], results_body[\"status\"])\n end\n end", "def query_search(query, options={})\n run_query query, options\n end", "def execute_search\n variables = @search_stack.map { |el| el[0] }\n searches = @search_stack.map { |el| el[1] }\n @hits = Algolia.multiple_queries(searches)['results']\n variables.each_with_index do |variable, index|\n instance_variable_set \"@#{variable}\", SearchResults.new(@hits[index])\n end\n end", "def search index:, query_string: nil, query: nil, sort: nil\n if query_string\n log.info \"Searching elastic search for #{query_string} on #{index}\"\n uri = URI(\"http://#{@host}:#{@port_s}/#{index}/_search?q=#{query_string}&sort=#{sort}\")\n req = Net::HTTP::Post.new(uri)\n else\n log.debug \"Searching elastic search index #{index} for body #{query}\"\n uri = URI(\"http://#{@host}:#{@port_s}/#{index}/_search\")\n req = Net::HTTP::Post.new(uri)\n req.body = query.is_a?(String) ? query : query.to_json\n end\n\n run(uri, req)\n end", "def search_for(*args, &block)\n __elasticsearch__.search(*args, &block)\n end", "def search(query)\n @search_svc.search query\n end", "def search(index, query_or_params = nil)\n params = case query_or_params\n when String\n { 'Keywords' => query_or_params }\n else\n query_or_params\n end\n rebuild params.merge! 'Operation' => 'ItemSearch',\n 'SearchIndex' => Utils.camelize(index.to_s)\n\n check_response\n end", "def execute(index)\n matches = index.hashes_for @search_term, restrict_type: @object_type, restrict_field: @field_name\n return matches.map do |matched_object|\n # Polymorphism of some kind would probably be cleaner than this, but this is literally the\n # only part of the codebase that cares, so... ¯\\_(ツ)_/¯\n case @object_type\n when 'organization'\n ticket_matches = if matched_object['_id']\n index.hashes_for matched_object['_id'], restrict_type: 'ticket', restrict_field: 'organization_id'\n end\n user_matches = if matched_object['_id']\n index.hashes_for matched_object['_id'], restrict_type: 'user', restrict_field: 'organization_id'\n end\n next {\n '_tickets' => ticket_matches&.map { |t| t.slice('_id', 'subject')},\n '_users' => user_matches&.map { |t| t.slice('_id', 'name')},\n }.merge(matched_object)\n when 'ticket'\n asignee_matches = if matched_object['assignee_id']\n index.hashes_for matched_object['assignee_id'], restrict_type: 'user', restrict_field: '_id'\n end\n submitter_matches = if matched_object['submitter_id']\n index.hashes_for matched_object['submitter_id'], restrict_type: 'user', restrict_field: '_id'\n end\n organization_matches = if matched_object['organization_id']\n index.hashes_for matched_object['organization_id'], restrict_type: 'organization', restrict_field: '_id'\n end\n next {\n '_assignee' => asignee_matches&.map { |t| t.slice('_id', 'name') },\n '_submitter' => submitter_matches&.map { |t| t.slice('_id', 'name') },\n '_organization' => organization_matches&.map { |t| t.slice('_id', 'name') },\n }.merge(matched_object)\n when 'user'\n asignee_matches = if matched_object['_id']\n index.hashes_for matched_object['_id'], restrict_type: 'ticket', restrict_field: 'assignee_id'\n end\n submitter_matches = if matched_object['_id']\n index.hashes_for matched_object['_id'], restrict_type: 'ticket', restrict_field: 'submitter_id'\n end\n organization_matches = if matched_object['organization_id']\n index.hashes_for matched_object['organization_id'], restrict_type: 'organization', restrict_field: '_id'\n end\n next {\n '_assigned_tickets' => asignee_matches&.map { |t| t.slice('_id', 'subject') },\n '_submitted_tickets' => submitter_matches&.map { |t| t.slice('_id', 'subject') },\n '_organization' => organization_matches&.map { |t| t.slice('_id', 'name') },\n }.merge(matched_object)\n\n end \n end\n end", "def index\n @search = params[\"search\"]\n if @search.present?\n client = Client.new(@search)\n response = client.call\n\n new_results = StoreSearch.new(@search, response).run\n if new_results\n scope_to_use = client.find_search_key || \"random\"\n\n if scope_to_use == \"category\"\n searches = Search.with_category(@search[\"category\"])\n @searches = Search.paginate(page: params[:page], per_page: 5).where(id: searches.map(&:id))\n # TODO recover former sintax\n # @searches = Search.paginate(page: params[:page], per_page: 5)\n # .with_category(@search[\"category\"])\n elsif scope_to_use == \"text\"\n @searches = Search.paginate(page: params[:page], per_page: 5)\n .with_text(@search[\"text\"])\n elsif scope_to_use == \"random\"\n @searches = Search.paginate(page: params[:page], per_page: 5)\n .created_randomly\n else\n @searches = Search.paginate(page: params[:page], per_page: 5)\n end\n else\n @searches = Search.paginate(page: params[:page], per_page: 5)\n end\n end\n \n @searches ||= Search.paginate(page: params[:page], per_page: 5)\n @search = Search.new()\n end", "def search(params = {})\n Search.new(params).execute\n end", "def search(params = {})\n Search.new(params).execute\n end", "def search(args = {})\n query = self::Query.new(args)\n args[:body] = query.to_hash\n\n args[:index] = configuration.index\n args[:type] = type\n\n result = client.search args\n\n result_list = result[\"hits\"][\"hits\"].map do |item|\n model = new(item[\"_source\"])\n model.id = item[\"_id\"]\n model.version = item[\"_version\"]\n model\n end\n\n ResultList.new(result_list, Integer(args.fetch(:from, 0)), result[\"hits\"][\"total\"])\n end", "def execute\n # build the query string\n # run the query\n # return the results\n end", "def search\n engine = BentoSearch.get_engine(params[:engine_id])\n # put it in an iVar mainly for testing purposes.\n @engine = engine\n\n\n unless engine.configuration.allow_routable_results == true\n raise AccessDenied.new(\"engine needs to be registered with :allow_routable_results => true\")\n end\n\n @results = engine.search safe_search_args(engine, params)\n # template name of a partial with 'yield' to use to wrap the results\n @partial_wrapper = @results.display_configuration.lookup!(\"ajax.wrapper_template\")\n\n # partial HTML results\n render \"bento_search/search/search\", :layout => false\n\n end", "def execute_search(&on_result)\n Fast.public_send(search_method_name,\n expression,\n @files,\n parallel: parallel?,\n on_result: on_result)\n end", "def index!\n set_search_text!\n set_query_attributes!\n update_columns text: self.text, query: self.query\n end", "def perform(params)\n if use_with_connection\n with_connection { search(params) }\n else\n search(params)\n end\n end", "def search(query, options = {}); end", "def search(*args)\n search_internal([\"SEARCH\"], *args)\n end", "def run_query(terms)\n return Book.run_search(terms)\nend", "def search(query, idx, type = 'document')\n response = request(\n :search,\n index: idx,\n type: type,\n body: query\n ) || (return {})\n parse_response(response)\n end", "def run(query,*args)\n with_query(query,*args) do\n if self.search_method\n run_custom_search\n else\n run_default_search\n end\n end\n end", "def index_request( params={} )\n res = @http_client.post_form( URI.parse(\"#{self.url}/select\"), params.update({ \"wt\" => \"ruby\" }) )\n\n if res.code.to_i != 200\n raise IndexSearchError, \"Index Search Error: #{res.body}\"\n else\n return eval(res.body)\n end\n end", "def query(index, types, query, options=nil)\n query = {'q' => query} if query.is_a?(String)\n resp = get do |req|\n req.url \"#{index}/#{types}/_search\", query\n req.body = options if options\n end\n resp.body\n end", "def test_search_with_many_results\n internal = @service.indexes.fetch(\"_internal\")\n internal.refresh()\n if internal.fetch(\"totalEventCount\").to_i < 150\n fail(\"Need at 150 events in index _internal for this test.\")\n end\n\n job = @service.jobs.create(\"search index=_internal | head 150\")\n while !job.is_done?()\n sleep(0.1)\n end\n\n stream = job.results(:count => 0)\n results = Splunk::ResultsReader.new(stream)\n count = 0\n results.each do |event|\n count += 1\n end\n assert_equal(150, count)\n\n stream = job.preview(:count => 0)\n results = Splunk::ResultsReader.new(stream)\n count = 0\n results.each do |event|\n count += 1\n end\n assert_equal(150, count)\n end", "def index\n @docs = SearchController.search(params[:query]) if params[:query].present?\n end", "def search\n @query = params[:keywords].nil? ? \"\" : params[:keywords]\n\n # prepare filters\n filters = apply_filters\n\n # do the search itself\n ultrasphinx_search(filters)\n params[:filter] = false;\n\n respond_to do |format|\n format.html { render :partial => 'dt/projects/search_results', :layout => 'layouts/dt_application'}\n end\n end", "def search \n\n end", "def search\n\n end", "def search(query)\n params = { key: self.api_key, cx: self.search_engine_id, q: query }\n uri = URI(BASE_URL)\n uri.query = URI.encode_www_form(params)\n request = build_request(uri)\n\n response = self.execute_search(uri, request)\n format_response(response)\n end", "def search\n\n end", "def search\n end", "def search(params={})\n rpc_call :search, params\n end", "def AddQuery(query, index = '*', comment = '')\n # build request\n \n # mode and limits\n request = Request.new\n request.put_int @offset, @limit, @mode, @ranker\n # process the 'expr' ranker\n if @ranker == SPH_RANK_EXPR\n request.put_string @rankexpr\n end\n\n request.put_int @sort\n\n request.put_string @sortby\n # query itself\n request.put_string query\n # weights\n request.put_int_array @weights\n # indexes\n request.put_string index\n # id64 range marker\n request.put_int 1\n # id64 range\n request.put_int64 @min_id.to_i, @max_id.to_i \n \n # filters\n request.put_int @filters.length\n @filters.each do |filter|\n request.put_string filter['attr']\n request.put_int filter['type']\n\n case filter['type']\n when SPH_FILTER_VALUES\n request.put_int64_array filter['values']\n when SPH_FILTER_RANGE\n request.put_int64 filter['min'], filter['max']\n when SPH_FILTER_FLOATRANGE\n request.put_float filter['min'], filter['max']\n else\n raise SphinxInternalError, 'Internal error: unhandled filter type'\n end\n request.put_int filter['exclude'] ? 1 : 0\n end\n \n # group-by clause, max-matches count, group-sort clause, cutoff count\n request.put_int @groupfunc\n request.put_string @groupby\n request.put_int @maxmatches\n request.put_string @groupsort\n request.put_int @cutoff, @retrycount, @retrydelay\n request.put_string @groupdistinct\n \n # anchor point\n if @anchor.empty?\n request.put_int 0\n else\n request.put_int 1\n request.put_string @anchor['attrlat'], @anchor['attrlong']\n request.put_float @anchor['lat'], @anchor['long']\n end\n \n # per-index weights\n request.put_int @indexweights.length\n @indexweights.each do |idx, weight|\n request.put_string idx\n request.put_int weight\n end\n \n # max query time\n request.put_int @maxquerytime\n \n # per-field weights\n request.put_int @fieldweights.length\n @fieldweights.each do |field, weight|\n request.put_string field\n request.put_int weight\n end\n \n # comment\n request.put_string comment\n \n # attribute overrides\n request.put_int @overrides.length\n for entry in @overrides do\n request.put_string entry['attr']\n request.put_int entry['type'], entry['values'].size\n entry['values'].each do |id, val|\n assert { id.instance_of?(Fixnum) || id.instance_of?(Bignum) }\n assert { val.instance_of?(Fixnum) || val.instance_of?(Bignum) || val.instance_of?(Float) }\n \n request.put_int64 id\n case entry['type']\n when SPH_ATTR_FLOAT\n request.put_float val\n when SPH_ATTR_BIGINT\n request.put_int64 val\n else\n request.put_int val\n end\n end\n end\n \n # select-list\n request.put_string @select\n \n # store request to requests array\n @reqs << request.to_s;\n return @reqs.length - 1\n end", "def create_search_index\n Tire.index self.index_name\n end", "def execute(from = 0, size = SEARCH_SIZE)\n self.query[:body][:from] = from\n self.query[:body][:size] = size\n response = search(query)\n SearchLogResult.new(response, from, size, self)\n end", "def search\n end", "def search\n end", "def search\n end", "def search\n end", "def search\n end", "def search\n end", "def search\n end", "def search\n end", "def search\n end", "def search\n end", "def RunQueries\n if @reqs.empty?\n @error = 'No queries defined, issue AddQuery() first'\n return false\n end\n\n req = @reqs.join('')\n nreqs = @reqs.length\n @reqs = []\n response = PerformRequest(:search, req, nreqs)\n \n # parse response\n begin\n results = []\n ires = 0\n while ires < nreqs\n ires += 1\n result = {}\n \n result['error'] = ''\n result['warning'] = ''\n \n # extract status\n status = result['status'] = response.get_int\n if status != SEARCHD_OK\n message = response.get_string\n if status == SEARCHD_WARNING\n result['warning'] = message\n else\n result['error'] = message\n results << result\n next\n end\n end\n \n # read schema\n fields = []\n attrs = {}\n attrs_names_in_order = []\n \n nfields = response.get_int\n while nfields > 0\n nfields -= 1\n fields << response.get_string\n end\n result['fields'] = fields\n \n nattrs = response.get_int\n while nattrs > 0\n nattrs -= 1\n attr = response.get_string\n type = response.get_int\n attrs[attr] = type\n attrs_names_in_order << attr\n end\n result['attrs'] = attrs\n \n # read match count\n count = response.get_int\n id64 = response.get_int\n \n # read matches\n result['matches'] = []\n while count > 0\n count -= 1\n \n if id64 != 0\n doc = response.get_int64\n weight = response.get_int\n else\n doc, weight = response.get_ints(2)\n end\n \n r = {} # This is a single result put in the result['matches'] array\n r['id'] = doc\n r['weight'] = weight\n attrs_names_in_order.each do |a|\n r['attrs'] ||= {}\n \n case attrs[a]\n when SPH_ATTR_BIGINT\n # handle 64-bit ints\n r['attrs'][a] = response.get_int64\n when SPH_ATTR_FLOAT\n # handle floats\n r['attrs'][a] = response.get_float\n\t\t\t\twhen SPH_ATTR_STRING\n\t\t\t\t # handle string\n\t\t\t\t r['attrs'][a] = response.get_string\n else\n # handle everything else as unsigned ints\n val = response.get_int\n if attrs[a]==SPH_ATTR_MULTI\n r['attrs'][a] = []\n 1.upto(val) do\n r['attrs'][a] << response.get_int\n end\n elsif attrs[a]==SPH_ATTR_MULTI64\n r['attrs'][a] = []\n\t\t\t\t\tval = val/2\n 1.upto(val) do\n r['attrs'][a] << response.get_int64\n end\n else\n r['attrs'][a] = val\n end\n end\n end\n result['matches'] << r\n end\n result['total'], result['total_found'], msecs, words = response.get_ints(4)\n result['time'] = '%.3f' % (msecs / 1000.0)\n \n result['words'] = {}\n while words > 0\n words -= 1\n word = response.get_string\n docs, hits = response.get_ints(2)\n result['words'][word] = { 'docs' => docs, 'hits' => hits }\n end\n \n results << result\n end\n #rescue EOFError\n # @error = 'incomplete reply'\n # raise SphinxResponseError, @error\n end\n \n return results\n end", "def get_search(index, expression)\n chef_server.search.query(index, expression, rows: 1).rows.first\n end", "def search\n\n # define the elasticsearch result \"size\" (limit)\n limit = params['limit'].to_i\n # define the elasticsearch result \"from\" (offset)\n offset = params['offset'].to_i\n # Pass through\n hack = params['hack']\n # Default output\n searchResults = ''\n # If we have filters, we need to parse them\n if params['filters'].present?\n filters = []\n # For each of the filters format them and stuff them into an array\n params['filters'].each do |key, filter|\n\n if [\n 'properties.educationalAlignment.properties.targetName',\n 'properties.inLanguage',\n 'properties.isBasedOnUrl',\n 'properties.thumbnailUrl',\n 'properties.timeRequired',\n 'properties.typicalAgeRange',\n 'properties.url',\n 'properties.useRightsUrl'\n ].include?(key)\n searchKey = \"schema-org.#{key}.original\"\n matchTerm = 'term'\n else\n searchKey = \"schema-org.#{key}\"\n matchTerm = 'match'\n end\n\n if filter.keys.count > 1\n # This is more complex because this filter type needs the keys or'd together\n orFilters = []\n filter.keys.each do |f|\n orFilters << { 'query' => { matchTerm => { searchKey => f.to_s } } }\n end\n filters << { 'or' => orFilters }\n else\n # This should be simple, there is only one of this filter key\n filters << { 'query' => { matchTerm => { searchKey => filter.keys.first.to_s } } }\n end\n end\n\n # If the query is present we need to match it\n if params['query'].present?\n query = { 'match' => { '_all' => params['query'] } }\n filter = { 'and' => filters }\n # If no query is present then we can wildcard against anything\n else\n query = { 'match_all' => { } }\n filter = { 'and' => filters }\n end\n # if not filter is present then just match against query\n else\n query = { 'match' => { '_all' => params['query'] } }\n end\n\n # Build the payload from the various parts\n payload = {\n 'size' => limit,\n 'from' => offset,\n 'query' => {\n 'filtered' => {\n 'query' => query,\n 'filter' => filter\n }\n },\n \"facets\" => {\n \"intendedEndUserRole\" => {\n \"terms\" => {\n \"field\" => \"schema-org.properties.intendedEndUserRole.original\",\n \"global\" => true,\n \"all_terms\" => true\n }\n },\n \"typicalAgeRange\" => {\n \"terms\" => {\n \"field\" => \"schema-org.properties.typicalAgeRange.original\",\n \"global\" => true,\n \"all_terms\" => true\n }\n },\n \"educationalUse\" => {\n \"terms\" => {\n \"field\" => \"schema-org.properties.educationalUse.original\",\n \"global\" => true,\n \"all_terms\" => true\n }\n },\n \"interactivityType\" => {\n \"terms\" => {\n \"field\" => \"schema-org.properties.interactivityType.original\",\n \"global\" => true,\n \"all_terms\" => true\n }\n },\n \"learningResourceType\" => {\n \"terms\" => {\n \"field\" => \"schema-org.properties.learningResourceType.original\",\n \"global\" => true,\n \"all_terms\" => true\n }\n },\n \"mediaType\" => {\n \"terms\" => {\n \"field\" => \"schema-org.properties.mediaType.original\",\n \"global\" => true,\n \"all_terms\" => true\n }\n }\n }\n }\n\n#puts \"PAYLOAD\"; puts Rails.configuration.elastic_search_url; puts payload.to_json\n\n # Okay after all that mess, lets make the request\n request = RestClient::Request.new( :method => :get, :url => Rails.configuration.elastic_search_url, :payload => payload.to_json )\n # Since this can error lets catch it\n begin\n searchResults = request.execute\n results = JSON.parse(searchResults)\n results[:hack] = hack\n\n#puts \"RESPONSE\"; puts results.to_json\n\n respond_to do |format|\n format.json { render json: results }\n end\n rescue => e\n # @TODO Need to return the correct error type and then an error message to be shown to user.\n respond_to do |format|\n format.json { render json: searchResults }\n end\n#puts \"ERROR!\"; puts e.response\n end\n\n end", "def search(term, opts = {})\n raise \"Index not found at path #{@index_path}\" unless File.exists? @index_path\n\n results = []\n\n query = make_query(term, opts[:exact])\n\n @index.execute(\"SELECT sequence_number, kanji, kana, senses, bm25(search) as score FROM search WHERE search MATCH ? LIMIT ?\", query, opts[:max_results]) do |row|\n entry = Entry.from_sql(row)\n score = 0.0\n\n is_exact_match = entry.kanji.include?(term) || entry.kana.include?(term)\n score = 1.0 if is_exact_match\n\n should_add = !opts[:exact] || (opts[:exact] && is_exact_match)\n\n # add the result\n results << [score, entry] if should_add\n end\n\n # Sort the results by first column (score) and return only the second column (entry)\n results.sort_by { |entry| -entry[0] }.map { |entry| entry[1] }\n end", "def search\n # Query\n @q = params[:q]\n @query = @q.split(/\\s(?=(?:[^\"]|\"[^\"]*\")*$)/).map do |i|\n (i =~ /^(?:([A-Za-z_]+):)?\"?(.*?)\"?$/) ? [$2, $1] : [i, nil]\n end\n # Results\n return if (m = @project.miga).nil? or\n (r = m.result(:project_stats)).nil? or\n (db_file = r.file_path(:metadata_index)).nil?\n db = SQLite3::Database.new db_file\n @results = nil\n @query.each do |q|\n q[0] = q[0].downcase.gsub(/[^A-Za-z0-9\\-]+/, \" \")\n res = db.execute(\"select distinct(name) from metadata \" +\n \"where value like ? #{\"and field=?\" unless q[1].nil?}\",\n [\"% #{q[0]} %\"] + (q[1].nil? ? [] : [q[1]])).flatten\n @results.nil? ? @results=res :\n @results.select!{ |i| res.include? i }\n end\n reference_datasets\n end", "def simple_search(query)\n search({:query => query})\n end", "def search(args = {})\n search_args = {}\n search_args[:body] = self::ElasticsearchQuery.new(args).to_hash\n search_args[:index] = configuration.index\n search_args[:type] = type\n\n result = client.search search_args\n ids = result[\"hits\"][\"hits\"].map {|item| item[\"_source\"][\"id\"] } # use to get the records and sort them in that order\n result_list = includes(:translations, [:master => [:prices, :images]]).where(id: ids).index_by(&:id).slice(*ids).values\n\n # Convert all facets to facet objects\n facet_list = result[\"facets\"].map do |tuple|\n name = tuple[0]\n hash = tuple[1]\n type = hash[\"_type\"]\n body = hash.except!(\"_type\")\n Spree::Search::Elasticsearch::Facet.new(name: name, search_name: name, type: type, body: body)\n end\n\n ResultList.new(\n results: result_list,\n from: Integer(args.fetch(:from, 0)),\n total: result[\"hits\"][\"total\"],\n facets: facet_list\n )\n end", "def search(db, locale, version, query, view = settings.view)\n return get_from_db_or_cache(db, nil, {:trx => CouchDBTransaction::SEARCH, :locale => locale, :version => version, :query => query, :view => view})\n end", "def search(user, query, collection, wiki)\n end", "def multi_index_elastic_search(params={})\n params = format_params(params)\n \n search = Tire.search params[:indexes], :load => false, :from => params[:offset] do \n query do\n boolean do\n should { match :name, \"#{params[:q]}*\", :type => :phrase_prefix }\n should { match :content, params[:q], :type => :phrase}\n end\n end\n facet \"item_type\" do terms :_type end\n highlight :content, :title\n sort { by \"_score\"}\n\n end\n end", "def execute\n reset\n params = @query.to_params\n @solr_result = @connection.request(\"/#{request_handler}\", params, {:header => {'Content-Type' => 'application/x-www-form-urlencoded'}})\n self\n end", "def perform_search\n if self.class == Alchemy::Admin::PagesController && params[:query].blank?\n params[:query] = 'lorem'\n end\n return if params[:query].blank?\n @search_results = search_results\n if paginate_per\n @search_results = @search_results.page(params[:page]).per(paginate_per)\n end\n end", "def search\n @search = Sunspot.search(Job) do\n keywords(params[:searchterm])\n end\n end", "def search(search_builder = {}, eds_params = {})\n send_and_receive(blacklight_config.solr_path, search_builder, eds_params)\n end", "def search; end", "def search\n @hits = []\n\n if params[:query]\n search = DesignMethod.solr_search do\n fulltext params[:query] do\n highlight\n minimum_match 0\n end\n end\n store_location\n @hits = search.hits\n @results = search.results\n end\n\n respond_to do |format|\n format.html\n format.json { render json: @results }\n end\n end", "def perform\n # This will allow us to switch backend data structure for\n # searching pretty easily.\n perform_by_mysql\n end", "def search_with_index query\n docs = []\n return docs if query.terms.empty?\n load if @content.nil?\n return docs if @content.nil?\n index = {}\n query.terms.each do |term|\n if term.operator == :eq && term.value.class != Regexp\n set = @attribute_storage[term.field][term.value]\n else\n set = @content.select do |doc|\n term.compare(doc.send(term.field))\n end\n end\n\n if !set.nil? && !set.empty?\n if docs.empty?\n docs = set\n if query.relation == :and\n docs.each do |value|\n index[value] = nil\n end\n end\n else\n if query.relation == :or\n docs += set\n else\n set.each do |value|\n if !index.has_key? value\n docs << value\n index[value] = nil\n end\n end\n end\n end\n end\n end\n docs\n end", "def search(options = {})\n reset_errors\n options.symbolize_keys!\n begin\n\tresult = connection.search(options)\n\tadd_error(operation_error)\n rescue => e\n\tresult = []\n\tadd_error(e.message)\n end\n result\n end", "def search\r\nend", "def index\n # @search = Shelter.search do\n # fulltext params[:search]\n # end\n # @shelters = @search.results\n @shelters = Shelter.all\nend", "def search_from_fresh_index( query, page )\n begin\n @search_data = @index.search( query, page )\n return true\n rescue IndexSearchError => error\n @errors.push({\n :highlight => \"The search term you used has caused an error on the search engine, please try another search term without any special characters in it.\",\n :full_text => error\n })\n return false\n end\n end", "def search\nend", "def search(*args)\n search_provider.search(*args)\n end", "def index\n # Generate sunspot search\n @records = record_default_search\n\n respond_with(@records)\n end", "def search!(\n query, case_sensitive: false, whole_sentence: true,\n limit: 10, skip: 0, sentence_limit: 80\n )\n results = search(\n query,\n case_sensitive: case_sensitive,\n whole_sentence: whole_sentence,\n limit: limit,\n skip: skip\n )\n\n results.each do |doc|\n doc.search!(\n query,\n case_sensitive: case_sensitive,\n whole_sentence: whole_sentence,\n sentence_limit: sentence_limit\n )\n yield(doc) if block_given?\n end\n\n results\n end", "def search(*args, &block)\n name_or_options = args.pop\n\n if name_or_options.is_a?(Hash)\n options = name_or_options\n name = args.pop\n else\n name = name_or_options\n end\n\n name ||= @searches.size\n options ||= {}\n indices = options.delete(:index) || options.delete(:indices)\n\n @searches << { :name => name, :search => Tire::Search::Search.new(indices, options, &block) }\n end", "def index\n query = search_params[\"search\"]\n if query\n @documents = Document.search(query)\n else\n @documents = Document.all\n end\n end", "def search(query, state = 'open')\n Core.search(:user => @user, :repo => @repo, :state => state, :search_term => query)\n end", "def search(*args)\n options = args.extract_options!\n options[:class] = self\n args << options\n ThinkingSphinx::Search.search(*args)\n end", "def index\n @searches = Search.where(save_search: true, user_id: current_user.id, searchType: params[:searchType])\n @search_type = params[:searchType]\n end", "def search_setup(index:'', type:'', source:[], query:nil)\n @logger.info('Setup the ES search options: ')\n @logger.info(\"index=#{index} type=#{type} source=#{source} query=#{query}\")\n\n @index = index\n @type = type\n @source = source.dup\n @query = query\n end", "def search(query)\n\n\t\t@vquery = VectorData.new\n\t\tquery_terms = query.split\n\t\tt_i = 0\n\n\t\t# For each term in the dictionary.\n\t\t@index.each do |term, data|\n\n\t\t\t# Calculate the weight for the query vector\n\t\t\tif(query_terms.include?(term))\n\n\t\t\t\tweight = (1 + Math.log(query_terms.count(term)))\n\n\t\t\t\t@vquery.norm = weight*weight\n\t\t\t\t@vquery.t_id.push(t_i)\n\t\t\t\t@vquery.w.push(weight)\n\t\t\tend\n\n\t\t\t\tt_i += 1\n\t\tend\n\n\t\t@vquery.norm = Math.sqrt(@vquery.norm)\n\n\t\t# Returns empty if their are no terms matched to the index\n\t\treturn [] if (@vquery.norm == 0)\n\n\t\t# The array to collect the relevance scores\n\t\tscores = []\n\n\t\t# Calculates the similarity between each document and query\n\t\t@vdocs.each do |d_id, doc|\n\n\t\t\tweights_sum = 0\n\n\t\t\t# Multiplies their weights to find the corresponding weights\n\t\t\t# This is using the cosine similarity formula\n\t\t\t@vquery.t_id.each_with_index do |termid, i|\n\t\t\t\tif(doc.t_id.include?(termid))\n\t\t\t\t\tk = doc.t_id.index(termid)\n\t\t\t\t\tweights_sum += @vquery.w[i] * doc.w[k]\n\t\t\t\tend\n\t\t\tend\n\n\t\t\t# Skip if the weights_sum is equal to 0\n\t\t\tnext if(weights_sum == 0)\n\n\t\t\t# Applying the cosine similarity formula\n\t\t\tsim = (weights_sum) / (doc.norm * @vquery.norm)\n\n\t\t\tscores.push([d_id, sim])\n\t\tend\n\n\t\t# Sorts the array by the highest relevance and returns the array\n\t\treturn scores.sort{ |x,y| y[1] <=> x[1]}\n\n\tend", "def execute\n reset\n params = @query.to_params\n @solr_result = @connection.post \"#{request_handler}\", :data => params\n self\n end", "def search\n @documents = api.form(\"everything\")\n .query(%([[:d = fulltext(document, \"#{params[:q]}\")]]))\n .page(params[:page] ? params[:page] : \"1\")\n .page_size(params[:page_size] ? params[:page_size] : \"20\")\n .submit(ref)\n end", "def find_for_index(filter_conditions:)\n search.where(filter_conditions)\n end", "def build_index\n @search = RSemantic::Search.new(@documents.map(&:text), @options)\n end", "def queryCSV(query)\n#\turi = URI.parse(\"http://127.0.0.1:9200/vccpe/_search?pretty\")\n#\trequest = Net::HTTP::Get.new(uri)\n#\trequest.basic_auth(\"logserver\", \"logserver\")\n#\trequest.body = JSON.dump({\n# \t\"size\" => 1,\n#\t\"sort\" => [\n#\t{\n#\t\"@timestamp\" => {\n#\t\"order\" => \"desc\"\n#\t}\n#\t}\n#\t],\n# \t\"query\" => {\n# \t\"filtered\" => {\n# \t\"query\" => {\n# \"query_string\" => {\n# \t\"query\" => \"#{query}\",\n# \"analyze_wildcard\" => true\n# }\n# \t},\n# \t\"filter\" => {\n# \"bool\" => {\n# \t\"must\" => [\n#\t{\n#\t\"range\" => {\n#\t\"@timestamp\" => {\n#\t\"lte\" => \"#{timestamp_id}\",\n#\t\"gt\" => \"#{timestamp_id_minus6m}\"\n#\t}\n#\t}\n#\t}\n#\t],\n# \t\"must_not\" => []\n# \t}\n# \t}\n# \t}\n# \t},\n# \t\"aggs\" => {\n# \t\"index\" => {\n# \t\"terms\" => {\n# \"field\" => \"_index\",\n# \"size\" => 1\n# \t}\n# \t},\n# \t\"uid\" => {\n# \t\"terms\" => {\n# \"field\" => \"_uid\",\n# \"size\" => 1\n# \t}\n# \t}\n# \t}\n#\t})\n\n\turi = URI.parse(\"http://127.0.0.1:9200/vccpe/_search?pretty\")\n\trequest = Net::HTTP::Get.new(uri)\n\trequest.basic_auth(\"logserver\", \"logserver\")\n\trequest.body = JSON.dump({\n \t\"size\" => 0,\n \t\"query\" => {\n \t\"filtered\" => {\n \t\"query\" => {\n \"query_string\" => {\n \t\"query\" => \"#{query}\",\n \"analyze_wildcard\" => true\n }\n \t},\n \t\"filter\" => {\n \"bool\" => {\n \t\"must\" => [],\n \t\"must_not\" => []\n \t}\n \t}\n \t}\n \t},\n \t\"aggs\" => {\n \t\"index\" => {\n \t\"terms\" => {\n \"field\" => \"_index\",\n \"size\" => 0\n \t}\n \t},\n \t\"uid\" => {\n \t\"terms\" => {\n \"field\" => \"_uid\",\n \"size\" => 0\n \t}\n \t}\n \t}\n\t})\n\n\treq_options = {\n\t\tuse_ssl: uri.scheme == \"https\",\n\t}\n\n\tresponse = Net::HTTP.start(uri.hostname, uri.port, req_options) do |http|\n\t\thttp.request(request)\n\tend\n\n\t#puts response.body\n\t#jsonResponse = JSON.parse(response.body)\n\t#return jsonResponse[\"hits\"][\"hits\"][0][\"_source\"][\"status\"]\n\n\n\t#puts response.body\n\tjsonResponse = JSON.parse(response.body)\n\t#puts jsonResponse\n\t#information about index\n\tindex = jsonResponse[\"aggregations\"][\"index\"][\"buckets\"][0][\"key\"]\n\t#information about number of documents in index\n\tdoc_count = jsonResponse[\"aggregations\"][\"index\"][\"buckets\"][0][\"doc_count\"]\n\t#puts doc_count\n\t#concatenated messages from multiple documents\n\tmessageResponse = []\n\t#messageResponse = \"\"\n\tfor i in 0...doc_count\n\t\t#information about documents in index\n\t\ttypeAndId = jsonResponse[\"aggregations\"][\"uid\"][\"buckets\"][i][\"key\"].split('#')\n\n\t\turi = URI.parse(\"http://127.0.0.1:9200/#{index}/#{typeAndId[0]}/#{typeAndId[1]}?pretty\")\n\t\trequest = Net::HTTP::Get.new(uri)\n\t\trequest.basic_auth(\"logserver\", \"logserver\")\n\t\treq_options = {\n\t\t\tuse_ssl: uri.scheme == \"https\",\n\t\t}\n\n\t\tresponse = Net::HTTP.start(uri.hostname, uri.port, req_options) do |http|\n\t\t\thttp.request(request)\n\t\tend\n\n\t\t#puts JSON.parse(response.body)[\"_source\"][\"message\"]\n\t\tmessageResponse.push(JSON.parse(response.body)[\"_source\"][\"message\"])\n\t\t#messageResponse << JSON.parse(response.body)[\"_source\"][\"message\"]\n\tend\n\n\treturn messageResponse\nend", "def keyword\n\n @search_text = params[\"search_text\"] ||= \"\"\n\n add_breadcrumb \"Keyword Search: '#{@search_text}'\"\n\n if @search_text.blank? or @search_text.length < 2\n @keyword_search_results = KeywordSearchIndex.where(\"1 = 2\")\n else\n\n # here we build the query one clause at a time based on the input params. The query\n # is of the form:\n #\n # where organization_id IN (?) AND (search_text LIKE ? OR search_text_like ? OR ... )\n\n where_clause = 'organization_id IN (?) AND ('\n values = []\n # The organization is scoped to search across all objects that are owned by\n # the user's list of organizations\n orgs = @organization_list.dup\n # add org = 0 to get objects that are not indexed by org and are by\n # contract available to users of all organizations\n orgs << 0\n values << orgs\n\n search_params = []\n @search_text.split(\",\").each_with_index do |search_string|\n search_params << 'search_text LIKE ?'\n values << \"%#{search_string.strip}%\"\n end\n\n where_clause << search_params.join(' OR ')\n where_clause << ')'\n\n @keyword_search_results = KeywordSearchIndex.where(where_clause, *values)\n\n end\n\n @num_rows = @keyword_search_results.count\n cache_list(@keyword_search_results, INDEX_KEY_LIST_VAR)\n\n respond_to do |format|\n format.html\n format.json {\n render :json => {\n :total => @num_rows,\n :rows => data\n }\n }\n end\n\n end", "def index\n if is_legacy_search?()\n Rails.logger.warn(\"Redirected legacy search for #{request.url}\")\n redirect_to \"#{search_url()}?q=#{params[\"querytext\"]}\"\n else\n @presenter = execute_search()\n @presenter.user = current_user\n if @presenter.num_found == 0\n Rails.logger.warn(\"No results were found. Search: #{@presenter.search_qs}\")\n end\n if params[\"format\"] == \"json\"\n render :json => @presenter.results.to_json\n return\n end\n\n if ENV[\"NOTICE_BANNER\"]\n flash[:notice] = ENV[\"NOTICE_BANNER\"]\n end\n\n render \"results\"\n end\n rescue => ex\n backtrace = ex.backtrace.join(\"\\r\\n\")\n Rails.logger.error(\"Could not render search. Exception: #{ex} \\r\\n #{backtrace}\")\n render \"error\", status: 500\n end", "def search(node, qry)\n node.search(qry)\n end", "def execute_lucene_in_node_browser(query, options={})\n visit URIS[:node_browser_uri]\n select 'lucene', :from => 'nodebrowser-search'\n fill_in 'nodebrowser-query', :with => query\n click_on 'Execute'\n click_on 'Execute'\n header = find 'h2', :text => 'Results'\n check_text = /Results \\((?<count>\\d+)\\)/\n\n while (header.text =~ check_text).nil? do\n click_on 'Execute'\n return count\n end\n end", "def run_query(query_file , exp , o = {})\n index_path = o[:index_path] || @index_path\n cmd = fwrite('cmd_galago_run_query.log' , \"#{$galago_path}/bin/galago batch-search --index=#{index_path} #{o[:param_query]} \\\n #{to_path(query_file)} |grep -e ^[0-9] > #{to_path(exp+'.res')}\" , :mode=>'a')\n `#{cmd}`\n end", "def search(*args)\n end", "def index\n query = params[:query].to_s.strip\n search = Sunspot.new_search(Work)\n @count = {}\n unless query.blank?\n @query = query.dup\n query = query.gsub(' ', ' ')\n search.build do\n fulltext query\n end\n end\n\n set_role_query(current_user, search)\n\n unless params[:mode] == 'add'\n patron = @patron\n subject = @subject\n work = @work\n work_merge_list = @work_merge_list\n search.build do\n with(:patron_ids).equal_to patron.id if patron\n with(:subject_ids).equal_to subject.id if subject\n with(:original_work_ids).equal_to work.id if work\n with(:work_merge_list_ids).equal_to work_merge_list.id if work_merge_list\n end\n end\n\n role = current_user.try(:role) || Role.find('Guest')\n search.build do\n with(:required_role_id).less_than_or_equal_to role.id\n end\n\n page = params[:page] || 1\n search.query.paginate(page.to_i, Work.default_per_page)\n @works = search.execute!.results\n @count[:total] = @works.total_entries\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @works }\n format.atom\n end\n end", "def index\n __log_activity(anonymous: true)\n __debug_route\n err = nil\n prm = paginator.initial_parameters\n playback = prm.delete(:search_call)\n s_params = (playback || prm).except(*Paginator::NON_SEARCH_KEYS)\n q_params = s_params.extract!(*search_query_keys).compact_blank!\n if q_params.blank?\n if s_params.present?\n redirect_to prm.merge!(q: SearchTerm::NULL_SEARCH)\n else\n render 'search/advanced'\n end\n return\n end\n prm = prm.slice(*Paginator::NON_SEARCH_KEYS).merge!(s_params, q_params)\n titles = title_results?\n @list = index_search(titles: titles, save: !playback, **prm)\n err = @list.exec_report if @list.error?\n # noinspection RubyMismatchedArgumentType\n paginator.finalize(@list, as: (titles ? :titles : :records), **prm)\n respond_to do |format|\n format.html\n format.json { render_json index_values }\n format.xml { render_xml index_values(item: :record) }\n end\n rescue => error\n err = error\n ensure\n failure_status(err)\n end", "def index\n\n # search query\n if params[:q].nil?\n @shops = Shop.all\n else\n @shops = Shop.search_with_elasticsearch(params[:q]).records\n end\n\n if params[:filter].present?\n if params[:filter] == 'name'\n @shops = @shops.order('title ASC')\n elsif params[:filter] == 'date'\n @shops = @shops.order('updated_at DESC')\n elsif params[:filter] == 'location'\n define_location\n @shops = @shops.near([@latitude, @longitude], 8_000_000, order: 'distance')\n end\n else\n @shops = @shops.order('updated_at DESC')\n end\n\n @shops = @shops.page(params[:page]).per(20)\n\n end", "def base_search(params, query)\n log.debug(\"Processing by #{self.class}#search\")\n log.debug(\" Parameters: #{params.inspect}\")\n log.debug(\" Query: #{query.inspect}\")\n end", "def index\n @tasks = Task.includes(:user).order(sort_column + \" \" + sort_direction)\n puts \"Search query vals\"\n puts params[:search_query]\n\n if (params[:search_query] && params[:search_field])\n @tasks = Task.search(params[:search_query], params[:search_field]).order(sort_column + \" \" + sort_direction)\n end\n end" ]
[ "0.7664244", "0.74799204", "0.7432244", "0.7231149", "0.71710896", "0.7119934", "0.70745397", "0.7041897", "0.6940841", "0.693646", "0.6836037", "0.68158954", "0.6806255", "0.6720312", "0.6710814", "0.6685125", "0.6685125", "0.66830516", "0.6675249", "0.6671008", "0.66688955", "0.66314757", "0.6619738", "0.6577913", "0.6576453", "0.65723646", "0.6538479", "0.6489396", "0.648131", "0.6478328", "0.64680445", "0.64449054", "0.6413118", "0.6412944", "0.6410823", "0.6396953", "0.6383379", "0.6381701", "0.6374403", "0.6370839", "0.6370389", "0.63526946", "0.63447374", "0.63447374", "0.63447374", "0.63447374", "0.63447374", "0.63447374", "0.63447374", "0.63447374", "0.63447374", "0.63447374", "0.6339803", "0.6306487", "0.6297275", "0.6296001", "0.6295727", "0.6286675", "0.62854683", "0.6282917", "0.62823933", "0.6281028", "0.6278227", "0.6274994", "0.626056", "0.62404394", "0.62370235", "0.622738", "0.6222105", "0.6208104", "0.62071013", "0.6202846", "0.61966026", "0.6192086", "0.61907697", "0.6187621", "0.6175957", "0.616818", "0.61680484", "0.61651456", "0.61572665", "0.61568975", "0.6151853", "0.6150166", "0.6143111", "0.61391014", "0.6131677", "0.6124926", "0.61178774", "0.61168045", "0.6116325", "0.6115843", "0.61063", "0.60920393", "0.6086023", "0.60806155", "0.60798067", "0.6078219", "0.60728276", "0.60713106", "0.6069163" ]
0.0
-1
end of action say
def index end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def end() end", "def end; end", "def end; end", "def end; end", "def end\n end", "def end\n end", "def end\n end", "def end\n end", "def at_end; end", "def ends_with_goodbye\n /WRITE ME/\n end", "def act\n exit 1\n end", "def act\n exit 1\n end", "def done!(msg=\"\")\n out \"#{msg} (#{self.end!}s)\\n\"\n end", "def finish\n noth\n end", "def finish\r\n #\r\n end", "def end(arg0)\n end", "def _end!; end", "def end_game\n puts \"Thank to play my game. See you again.\"\n end", "def ended msg\n end", "def bye; end", "def finish\n #\n end", "def finish\n end", "def finish\n #\n end", "def exit\n \"Goodbye! Thanks for playing!\"\n end", "def done\n end", "def done\n end", "def end_game\n puts \"Merci, Aur revoir\"\n end", "def finish; end", "def finish; end", "def finish; end", "def finish; end", "def finish; end", "def finish; end", "def finish; end", "def finish; end", "def goodbye\n puts GOODBYE\n end", "def end_game\n\t\tputs \"Thank you for playing the Secret Number Game, #{@player}.\"\n\tend", "def proceed!; end", "def proceed!; end", "def action(message)\n print(6, message)\n end", "def user_message_end(msg)\n user_message(msg, 0, \"<<<\")\n end", "def goodbye\n puts \"\", \"Thank you! Goodbye :)\"\n end", "def halt; end", "def halt; end", "def goodbye\n\t\tputs \"\\nThanks for playing #{self.player_name}!\\n\"\n\t\tputs \"You finished with #{player_record[\"Wins\"]} wins and #{player_record[\"Losses\"]} losses\"\n\tend", "def done; end", "def quit; end", "def quit; end", "def exit() end", "def exit_game\n print clear_screen, \"\\n\"\n print \"\\\"What business is it of yours where I'm from, friendo?\\\"\", \"\\n\"\n print '-- Anton Chigurh : No Country for Old Men', \"\\n\\n\"\n throw :exit\n end", "def action_error\n puts\n puts \"Sorry, I don't recognize that command.\"\n puts\nend", "def goodbye \nputs \"see you tomorrow for more Makeup :)\"\nend", "def q\r\n @_done = true\r\n puts\r\n \"Bye bye for now!\"\r\n end", "def end!\n throw :end\n end", "def end_hook(hook, status, output); end", "def act\n end", "def main_end ; end", "def action_complete() self.finished = true; end", "def bark\n say('ouah ouah')\n nil\n end", "def exit \n \"exit\" \n end", "def at_exit\n\n\t\tend", "def finish(options); end", "def done(command)\n end", "def done\n puts \"Done\"\n end", "def forge_end\n command_back\n end", "def onEnd\r\n end", "def finished; end", "def action; end", "def action; end", "def action; end", "def action; end", "def action; end", "def say_goodbye\n\t\tgoodbye = \"Thanks for playing the Virtual Crazy\" +\n\t\t\t\t\"8-Ball game!\\n\\n\"\n\tend", "def end_hook name\n # this should be implemented in sub-classes\n end", "def end\n\t\tputs \"----- GAME OVER -----\"\n\t\tputs \"Good bye!\"\n\tend", "def end \n \tif @human_player.life_points == 0\n\t\tputs \" Looser tu as perdu...\"\n\t\telsif @enemies.empty? == true\n\t\tputs \"__________________________________\"\n\t\tputs \" VICTOIRE !!! $$$$ \"\n\t\tputs \" ___________________________________\"\n\t\tend\n\tend", "def speak2\n puts \"Goodbye world\"\n end", "def someone_did_quit(stem, person, msg)\n end", "def setup_end_action\n @break_action = true\n @finish = true\n end", "def ending\n abstract!\n end", "def endMission _args\n \"endMission _args;\" \n end", "def exit_now\n\t\tputs \"Goodbye!\"\n\tend", "def say_goodbye\r\n\t\tgoodbye = \"Thanks for playing the Virtual Crazy 8-Ball game! \\n\\n\" +\r\n\t\t\"Student: T. J. Flesher \\n\\nhttp://www.bellevue.edu/\"\t\t\r\n\t\tputs goodbye\r\n\tend", "def shout\n 'Yay!'\n end", "def exit!() end", "def success_case\n\tputs \" - Ok #{@name}, c'est ton choix #{@answer_play}\" \n\tputs \" \"\n end", "def end_game\n\t\tputs \"Goodbye!\"\n\t\texit\n\tend", "def end_game\n end", "def seeYa()\n abort(\"\\nQuiting now. Bye!\") \nend", "def goodbye\n puts \"Thanks for using the Card Seeker. Come back soon.\"\n end", "def done\nend", "def after_action verb = nil, &block\n playbook.after_action verb, &block\n end", "def goodbye\n puts \"Thank you for using the Covid 19 CLI Tracker. Please Wash Your Hands.\"\n end", "def command(action)\n Hangman.save(self) if action == 'save'\n puts '', 'Do you want to leave this game? (y/n)'\n 'exit' if gets.chomp.downcase == 'y'\n end", "def goodbye \n\t\tsystem(\"clear\")\n puts \"#######################\"\n puts \"# #\"\n puts \"# Thank you for #\"\n puts \"# #\"\n puts \"# visiting the #\"\n puts \"# #\"\n puts \"# Bank of Hamish #\"\n puts \"# #\"\n puts \"# GOODBYE! #\"\n puts \"# #\"\n puts \"# #\"\n\t\tputs \"#######################\"\n\tend", "def good_bye\n puts \"Gracias por visitarnos. Regresa pronto\" \n end", "def bye\n puts \"bye\"\n end", "def goodbye \n puts \"Don't leave hungry!\"\n end", "def halt\n end", "def end_game\n\n end", "def exit\n raise ActionExit.new\n end" ]
[ "0.7374835", "0.7194678", "0.7194678", "0.7194678", "0.7107693", "0.706036", "0.706036", "0.703784", "0.6919161", "0.6805067", "0.6761479", "0.6761479", "0.6737829", "0.6705001", "0.66922545", "0.66743594", "0.66459185", "0.6605531", "0.66036904", "0.65987283", "0.65784043", "0.65685123", "0.6557499", "0.6546798", "0.65432936", "0.65432936", "0.6537126", "0.65366864", "0.65366864", "0.65366864", "0.65366864", "0.65366864", "0.65366864", "0.65366864", "0.65366864", "0.65254444", "0.6507868", "0.6504612", "0.6504612", "0.6472768", "0.64667815", "0.64414513", "0.64347875", "0.64347875", "0.6414658", "0.64126444", "0.6399537", "0.6399537", "0.639746", "0.63974404", "0.639665", "0.6392169", "0.6390816", "0.63810754", "0.63677275", "0.63642234", "0.635793", "0.63561565", "0.6355413", "0.63458467", "0.6330649", "0.6323775", "0.63234943", "0.6319864", "0.6313215", "0.630445", "0.62993425", "0.62982416", "0.62982416", "0.62982416", "0.62982416", "0.62982416", "0.6290545", "0.62870246", "0.628652", "0.6281202", "0.62811524", "0.6270687", "0.6270087", "0.62552065", "0.62475175", "0.62463534", "0.6239282", "0.62387216", "0.62344104", "0.6221445", "0.622068", "0.62111014", "0.6210042", "0.62092614", "0.6200746", "0.61937165", "0.6191357", "0.61798507", "0.61735797", "0.6172983", "0.6172285", "0.6160498", "0.6153046", "0.61440563", "0.61302346" ]
0.0
-1
Chooses the words that make up the password.
def choose_words(size: 4) chosen = words.sample(size) block_given? ? (yield chosen) : chosen end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def pick_secret_word\n\t\tFile.read(\"5desk.txt\").lines.select {|word| (4..9).cover?(word.size)}.sample.strip\n\tend", "def pick_secret_word\n\t\t@secret_word = @dictionary.sample.chomp.downcase\n\t\t@secret_word.length\n\tend", "def is_valid_passchars?(passphrase)\n words = passphrase.split(' ').map { |word| word.chars.sort.join('') }\n words.uniq.length == words.length\nend", "def suggestion\n\t\tnewpass = @pass\n\t\tr = /[^a]/\n\t\tnewpass = newpass.sub(/[a-z]/, \"#{rand(10)}\")\n\t\tnewpass = newpass.sub(/[a-z]/, '$')\n\t\tnewpass = newpass.sub(/[a-z]/, ' ')\n\t\tif newpass.length <= 13\n\t\t\ttime = Time .new\n\t\t\tnewpass = \"#{newpass} #{time.to_i}\"\n\t\tend\n\t\t_score = Password. new(newpass).strength\n\t\treturn @pass = newpass\n\tend", "def make_password(phrase)\n phrase.split(\" \").map do |x|\n x = x[0]\n x = \"1\" if x == \"i\" || x == \"I\"\n x = \"0\" if x == \"o\" || x == \"O\"\n x = \"5\" if x == \"s\" || x == \"S\"\n x\n end.join()\nend", "def restricted_password\n return nil if game_state == 'active'\n\n password.word\n end", "def not_forbidden?(password)\n forbidden_words = [\"password\"] # can add words to this list as necessary.\n result = true\n forbidden_words.each {|word| result = false if password.downcase.include?(word)}\n result\nend", "def pick_secret_word\n\t\t@secret_word.length\n\tend", "def pick_secret_word\n @word = dictionary.sample\n word\n end", "def get_word\n dictionary_file = '5desk.txt'\n dictionary = File.readlines(dictionary_file)\n until @secret_word.length > 5 && @secret_word.length < 12\n @secret_word = dictionary.sample.rstrip.downcase\n end\n @secret_word\n end", "def make_up_password\n\to = [('a'..'z'), ('A'..'Z'), ('0'..'9')].map { |i| i.to_a }.flatten\n\tpass = (0...12).map { o[rand(o.length)] }.join + \"@\"\n\tputs \"Using #{pass} for password\\n\"\n\treturn pass\nend", "def check_password_contents\n if /[a-zA-Z]+/.match(@password) && /\\d+/.match(@password) && /[[:punct:]]/.match(@password)\n else\n generate\n end\n end", "def next_password(pw)\n l = pw.length\n pos = l - 1\n\n next_pw = pw.dup\n loop do\n if pos < 0\n next_pw = \"a\" + next_pw\n break\n elsif next_pw[pos] != 'z'\n next_pw[pos] = (next_pw[pos].ord + 1).chr\n next_pw[pos] = (next_pw[pos].ord + 1).chr if DENY_LETTERS.include? next_pw[pos]\n break\n else\n next_pw[pos] = 'a'\n pos -= 1\n end\n end\n next_pw\n end", "def generate_secret_word\n dictionary = File.open('5desk.txt', 'r').readlines\n legal_words = []\n\n dictionary.each do |line|\n word = line.chomp\n legal_words << word if legal_word?(word)\n end\n\n legal_words.sample\n end", "def word_picker\n dictionary = File.readlines('lib/5desk.txt')\n word = dictionary.sample(1)[0].chomp.downcase\n word = dictionary.sample(1)[0].chomp.downcase until word.length.between?(5, 12)\n word\n end", "def generate_password\n [*('a'..'z'), *('A'..'Z'), *('0'..'9')].sample(8).join\n end", "def valid_passwords(input)\n # Filter map is fun. If the output is falsy it filters it out, otherwise it\n # keeps our shiny new transformed output. Think of it as combining `select`\n # and `map` into one function. I believe it was added in 2.7\n input.filter_map do\n # Yes yes, english operators are evil and I should quit stealing from Perl\n # early escapes. It's still useful as `next` returns `nil` if `extract_password`\n # happens to return `nil`, meaning no matches, or an invalid line of input.\n extracted_password = extract_password(_1) or next\n\n # Now this line is fun! This is why we transformed the input into symbol\n # keys. This is one-line right hand assignment, which means each of those\n # keys are now valid variables we can use in the rest of the function.\n #\n # I may well ask if MatchData can behave more like this naturally later,\n # could you imagine how useful that'd be?\n extracted_password => {\n input:, low_count:, high_count:, target_letter:, password:\n }\n\n # Now to make those counts into ints we can use.\n low_count = low_count.to_i\n high_count = high_count.to_i\n\n # Then pull out the counts of each letter in the word, and get\n # only our target letter out of it. Again, not the most efficient, but\n # not the point of this exercise. Optimizing that is left as an\n # exercise to the reader.\n target_letter_count = letter_counts(password)[target_letter]\n\n # Now then, if that target letter count is between our high and low\n # bounds we return the input, otherwise we return `nil` meaning it's\n # invalid and it gets filtered out.\n (low_count..high_count).include?(target_letter_count) ? input : nil\n end\nend", "def password\n puts \"Please provide a four digit password!\"\n #sets a pin globally!\n $pin = gets.chomp\n unless $pin.length != 4 \n #$accounthash = {pw: $pin}\n choose(\" \")\n else\n puts \"The password should have four digits! Please try again!\"\n password\n end\n end", "def validate(passphrase)\n words = passphrase.split\n words == words.uniq\nend", "def generate_password\n charset = %w{ 2 3 4 6 7 9 A C D E F G H J K M N P Q R T V W X Y Z @ # $ & ! }\n (0...6).map{ charset.to_a[rand(charset.size)] }.join\n end", "def random_password\r\n chars = (\"a\"..\"z\").to_a + (\"1\"..\"9\").to_a \r\n newpass = Array.new(8, '').collect{chars[rand(chars.size)]}.join\r\n end", "def load_secret_word\n @secret_word = File.readlines('5desk.txt').sample.downcase.strip\n until @secret_word.length > 5 && @secret_word.length < 12\n puts \"Choosing secret word...\"\n @secret_word = File.readlines('5desk.txt').sample.downcase.strip\n end\n @secret_display = %{#{\"_\" * @secret_word.length}} # change this to update based on previous guesses\n end", "def select_word\r\n\t\t@answer = @words[rand(27)]\r\n\r\n\r\n\t\t# this would be a list of hashes\r\n\t\t@question = \"\"\r\n \t@tempque=\"\"\r\n\t\tfor x in 0..@answer.length\r\n\r\n\t\t\t@question=@question+\"#\"\r\n \t\t@tempque=@tempque+\"#\"\r\n\t\tend\r\n\t\treturn @answer\r\n\r\n\tend", "def generate_password\n ['test', 'guest'].sample\nend", "def secret_word\n\t\tselected_text = []\n\t\ttext = File.open('5desk.txt').each do |line|\n\t\t\tif line.strip.size >=5 && line.strip.size <=12\n\t\t\t\tselected_text << line.strip\n\t\t\tend\n\t\tend\n\t\tselected_text[rand(selected_text.size)].downcase.chomp\n\tend", "def get_the_word\n words = File.readlines(\"5desk.txt\")\n words = words.map do |word|\n word.strip\n end\n words = words.select do |word|\n (word.length > 4) && (word.length < 13)\n end\n words.sample.upcase.split(\"\")\n end", "def scramble_words(chars = WordChars)\n\t\tgsub(/(#{chars})(#{chars}+)(?=#{chars})/) { $1 + $2.randomize }\n\tend", "def cryptic_dictionary(words)\nend", "def password\n @password ||= match[4]\n end", "def generate_password(l)\n vow = %w(a e i o u)\n con = %w(b c d f g h j k l m n p q r s t v x y z)\n\n pw = ''\n state = if rand < 0.8 then :c else :v end\n for i in 0..l\n case state\n when :v\n pw << vow[rand(vow.size)]\n state = :c if rand > 0.4\n when :c\n pw << con[rand(con.size)]\n state = :v if rand > 0.1\n end\n end\n return pw\n end", "def display\n\t\tsecret_word_display = []\n\t\t@secret_word.split(\"\").each do |char|\n\t\t\tif @guessed_letters.include?(char)\n\t\t\t\tsecret_word_display << char\n\t\t\telse\n\t\t\t\tsecret_word_display << \"_\"\n\t\t\tend\n\t\tend\n\t\tputs \"Secret word: #{secret_word_display.join(\" \")}\"\n\tend", "def passwords\n @passwords ||= STDIN.read.split(\"\\n\").map do |password|\n a, b, c = password.split\n {\n position_1: a.split(\"-\").first.to_i,\n position_2: a.split(\"-\").last.to_i,\n letter: b.chars.first,\n password: c\n }\n end\nend", "def is_password(password)\n if password.downcase == \"password\"\n puts \"Password cannot be the word password\"\n else \n puts \"Acceptable\"\n end\nend", "def new(options= {})\n password = \"\"\n total_length = (options[:length] || 12).to_i\n word_count = (options[:words] || 2).to_i\n digit_length = (options[:digits] || 2).to_i\n word_options = options.slice(:language, :dictionary)\n length_variance = 3\n \n validate_word_count(word_count)\n \n total_digits = digit_length * (word_count - 1)\n avg_word_length = (total_length - total_digits) / word_count\n \n validate_avg_word_length(avg_word_length)\n\n word_count.downto(1) do |n|\n length_needed = total_length - password.length\n break if length_needed <= 0\n\n if n == 1 # this is the last word\n word_options[:exact] = length_needed\n else # not the last word\n word_options[:min] = [1, avg_word_length - length_variance].max\n # max_length = total remaining length - remaining digits and words\n word_options[:max] = length_needed - ((n-1) * (digit_length + avg_word_length))\n end\n password << pick_dictionary_word(word_options)\n password << pick_random_number(digit_length).to_s if digit_length > 0 && n > 1\n end\n\n return password\n end", "def show_word(secretword)\n\t\tanswers = []\n\t\tsecretword.length.times do\n\t\t\tanswers.push(\"\")\n\t\tend\n\t\tanswers\n\tend", "def setsecretword word\r\n\t\t @secretword = word\r\n\t\t templ = createtemplate\r\n\t\t\t\t\tword_templ = templ.gsub(\"[\",\"\").gsub(\"]\",\"\")\r\n\t\t\t\t\ti=0\r\n\t\t\t\t\tsec_word_array=@secretword.chars\r\n\t\t\t\t\twhile i < sec_word_array.length do\r\n\t\t\t\t\t\tif sec_word_array[i] == \" \"\r\n\t\t\t\t\t @resulta[i] = \" \"\r\n\t\t\t\t\t else\r\n\t\t\t\t\t \t@resulta[i] = \"_\"\r\n\t\t\t\t end\r\n\t\t\t\t i+=1\r\n\t\t\t\t end\r\n\t\t end", "def standard_password\n \"!@Cd5678\"\n end", "def password\n @password ||= match[4]\n end", "def random_new_password\n if self.random_password_length == 0\n nil\n else\n new_password = String.new\n for i in 0 .. self.random_password_length\n new_password += self.random_password_contains_of.scan(/./).sort_by {rand}.first\n end\n new_password\n end\n end", "def select_word\n @answer = \"\"\n @word = \"\"\n while not is_valid?\n @word = IO.readlines(\"../5desk.txt\")[rand(61405)].chomp\n end\n @word.downcase!\n puts @word\n @word.scan(/./){@answer << '*'}\n puts @answer\n end", "def decrypt(word)\n counter = 0\n password = \"\"\n\n until counter == word.length\n alphabet = \"abcdefghijklmnopqrstuvwxyz\"\n letter = alphabet.index(word[counter]) - 1\n counter += 1\n password = alphabet[letter] + password\n\n end\n password.reverse\n end", "def choices\n return [\"hello\", \"goodbye\", \"yay\"] #FIXME\n #Randomly pick 3 other words that are not the same as the current word\n #FIXME: 1..20 should be the number of words we have\n selectedWordIds = (1..20).sort_by{rand}[1..4] # first four ids are our four words\n selectedWordIds.delete(self.wordid)\n selectedWords = selectedWordIds.map { |wordid| Word.findWord(java.lang.Integer.new(wordid)).first.first }\n selectedWords.shuffle\n return selectedWords\n end", "def test_rejects_passwords_containing_forbidden_words\n result = valid_password?(\"1Abjpasswordils&a\")\n refute(result, \"'1Abjpasswordils&a' should be invalid because it contains 'password'\")\n end", "def is_valid_passphrase?(passphrase)\n words = passphrase.split(' ')\n words.uniq.length == words.length\nend", "def dictionary_attack dictionary\n\t\tfile = File.open(dictionary, \"rb\")\n\t\twordlist = file.readlines\n\t\twordlist.each do |line|\n\t\t\tif(check_password? line.chomp)\n\t\t\t\treturn line\n\t\t\tend\n\t\tend\n\t\treturn false\n\tend", "def decode_pass_word val\n Sequel.lit \"\\ncrypt(\\n?\\n, pswd_hash)\", val\n end", "def getsecretword\r\n\t\t return @secretword\r\n\t\t end", "def responses\n\t\t_score = Password. new(@pass).strength\n\t\tif (_score >= 50)\n\t\t\treturn \"Congratulations is Strong Password.\"\n\t\telsif (_score > 10 && _score < 50)\n\t\t\treturn \"Weak Password. try with '#{suggestion}'\"\n\t\telse\n\t\t\treturn \"Unacceptable Password, try again with a better password.\"\n\t\tend\n\tend", "def new_password(data)\n data.strip!\n unless data =~ /^\\w{6,20}$/\n ask_password\n return\n end\n @display.echo_on\n @new_password = data\n ask_color\n end", "def password_rule_test_sets\n {\n 'not set': 'pass',\n 'parameter with NoEcho': 'pass',\n 'parameter with NoEcho and Default value': 'fail',\n 'parameter as a literal in plaintext': 'fail',\n 'as a literal in plaintext': 'fail',\n 'from Secrets Manager': 'pass',\n 'from Secure Systems Manager': 'pass',\n 'from Systems Manager': 'fail'\n }\nend", "def get_password\n status = true\n while status == true\n @password = @@prompt.mask(\"Create a password with at least 5 character\") do |q|\n q.validate(/[a-z\\ ]{5,15}/)\n end\n @password_2 = @@prompt.mask(\"Retype your password\") do |q|\n q.validate(/[a-z\\ ]{5,15}/)\n end\n if @password == @password_2\n system(\"clear\")\n status = false \n break\n else @password != @password_2\n puts \"Wrong password, try again\".colorize(:red)\n status = true\n end\n end\n end", "def password_special_character(pass)\n characters = ['!', '#', '$']\n if characters.select { |value| pass.include? value }.empty?\n 'Sorry, password must have a special character.'\n else\n 'Yay, password includes a special character.'\n end\nend", "def block_word?(string)\n hash = { 'B' => 'O', 'G' => 'T', 'V' => 'I', \n 'X' => 'K', 'R' => 'E', 'L' => 'Y',\n 'D' => 'Q', 'F' => 'S', 'Z' => 'M',\n 'C' => 'P', 'J' => 'W', 'N' => 'A', 'H' => 'U'}\n\n banned_letters = []\n bool = true\n letters = string.upcase.chars\n letters.each do |letter|\n if hash.has_key?(letter)\n banned_letters << hash[letter]\n elsif hash.has_value?(letter)\n banned_letters << hash.key(letter)\n end\n end\n banned_letters.each do |letter|\n if letters.include?(letter)\n bool = false\n break\n else\n next\n end\n end\n bool\nend", "def pick_mystery_word\n @picked_word = self.dict.sample\n self.picked_word.length\n end", "def HidePasswords(_in)\n ret = \"\"\n\n if _in != nil\n parts = Builtins.splitstring(_in, \" \")\n\n first = true\n Builtins.foreach(parts) do |p|\n cmdopt = p\n if Builtins.regexpmatch(p, \"^INST_PASSWORD=\")\n cmdopt = \"INST_PASSWORD=******\"\n elsif Builtins.regexpmatch(p, \"^FTPPASSWORD=\")\n cmdopt = \"FTPPASSWORD=********\"\n end\n if first\n first = false\n else\n ret = Ops.add(ret, \" \")\n end\n ret = Ops.add(ret, cmdopt)\n end\n else\n ret = nil\n end\n\n ret\n end", "def autocomplete(input, dictionary)\n results = []\n sanitized_input = input.gsub(/[^A-Za-z]/, '')\n\n dictionary.each do |word|\n break if results.length >= 5\n next unless word.downcase.start_with?(sanitized_input)\n results << word\n end\n results\nend", "def input_acceptable_password\n fill_in(PASSWORD_INPUT_ID, :with => 'qwerty12345')\n end", "def password_complexity\n if password.present? and not password.match(/\\A(?=.*[a-z])(?=.*[A-Z])(?=.*\\d).*/)\n errors.add :password, I18n.t('weak_password')\n end\n end", "def get_word\n words = File.readlines(\"lib/5desk.txt\")\n words.each { |word| word.chomp! }\n words_list = words.select { |word| word.length.between?(5, 12)}\n\n words_list.sample.downcase.split(\"\")\n end", "def extract_password(line) =\n line.match(PASSWORD_INFO)&.named_captures&.transform_keys(&:to_sym)", "def choose_code_word\n dictionary = []\n File.readlines(\"word_list.txt\").each do |word|\n if word.length > 4 && word.length < 13\n dictionary.push(word.strip.downcase)\n end\n end\n @code_word = dictionary[rand(dictionary.length)]\n end", "def get_current_state_of_word()\r\n\r\n wordString = \"\"\r\n\r\n for i in 0..@secretWordLength-1 do\r\n\r\n key = @secretWord[i]\r\n\r\n if @lettersGuessed[key] == true \r\n wordString += key\r\n elsif @lettersGuessed[key] == false\r\n wordString += \"_ \" \r\n end\r\n\r\n end\r\n\r\n return wordString\r\n end", "def possible_words\n\t\t\t@dictionary.grep to_r\n\t\tend", "def receive_secret_length\n puts \"How long is your word?\"\n word_length = gets.chomp.to_i\n dictionary.select! { |dictionary_word| dictionary_word.length == word_length }\n nil\n end", "def passwords\n transform_users do |name, entry|\n plaintext = entry.fetch(:password).to_s\n @hashers.fetch(name).call(plaintext)\n end\n end", "def scrambled_words\n print \"Enter a word: \"\n response = gets.chomp\n scrambled_version = response[0] + response[1..-2].chars.shuffle.join + response[-1]\n puts \"Scrambled version: #{scrambled_version}\"\nend", "def main\n range = (168630..718098).to_a\n range.map!(&:to_s)\n range.filter! { |input| is_valid_password?(input) }\n\n puts \"There are #{range.length} valid passwords\"\nend", "def selectWord\n\twords = [\n\t\t\"anvil\",\n\t\t\"black\",\n\t\t\"break\",\n\t\t\"clear\",\n\t\t\"doubt\",\n\t\t\"exist\",\n\t\t\"first\",\n\t\t\"girth\",\n\t\t\"heart\",\n\t\t\"icons\",\n\t\t\"joker\",\n\t\t\"loath\",\n\t\t\"mirth\",\n\t\t\"notch\",\n\t\t\"overt\",\n\t\t\"print\",\n\t\t\"qualm\",\n\t\t\"react\",\n\t\t\"solid\",\n\t\t\"trick\",\n\t\t\"until\",\n\t\t\"viola\",\n\t\t\"water\",\n\t\t\"young\",\n\t\t\"zebra\"\n\t]\n\treturn words[Random.rand(words.length)]\nend", "def borrow(speech)\n answer = []\n speech.split(' ').each do |word|\n word.split('').each do |char|\n ascii = char.ord\n if (ascii >= 97 && ascii <= 122) || (ascii >= 65 && ascii <= 90)\n answer << char.downcase\n end\n end\n end\n answer.join\nend", "def password\n 'password'.gsub('', '')\n end", "def initialize(secretWord, maxWrongGuesses)\n @correctlyGuessedLetters = Set.new\n @incorrectlyGuessedLetters = Set.new\n @incorrectlyGuessedWords = Set.new\n\t\t@secretWord = secretWord.upcase\n\t\t@guessedSoFar = MYSTERY_LETTER*@secretWord.length\n\t\t@maxWrongGuesses = maxWrongGuesses\n end", "def feedback(word)\n feedback = \"\"\n\n if word.length == 1\n unique_letters = [word]\n else \n unique_letters = word.chars.uniq\n end \n\n @secret_word.each_char { |ch|\n letter_exits = false\n unique_letters.each do |letter|\n if letter == ch\n feedback << letter + \" \"\n letter_exits = true\n end\n end\n if letter_exits == false\n feedback << \"_ \"\n end\n }\n return feedback\n end", "def select_passwords(id)\n return db_connection().execute('SELECT p.name as pass_name, random_str, c.name as cat_name, c.id as cat_id, p.id as pass_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 end", "def hack(words)\n candidates = words.clone\n word_to_guess = candidates.pop\n\n while !candidates.empty?\n puts \"Try the word: #{word_to_guess}\"\n puts \"What was the likeness?\"\n\n key_likeness = gets.to_i\n if key_likeness == word_to_guess.length\n puts \"Nicee hackeeer!!\"\n break\n end\n\n words.each do |word|\n next if !candidates.include?(word)\n\n likeness = get_likeness(word_to_guess, word)\n\n if key_likeness == 0\n candidates -= [word] if likeness > 0\n else\n candidates -= [word] if likeness < key_likeness\n end\n end\n\n puts \"Candidates left: #{candidates.join(', ')}\"\n word_to_guess = candidates.pop\n end\nend", "def redacted_word\n @secret_word.chars.map { |c| @guessed_characters.include?(c.to_sym) ? c : '_' }.join('')\n end", "def password; end", "def password; end", "def password; end", "def password; end", "def password; end", "def password; end", "def password=(should); end", "def get_next_char extracted_password, options\n num_chars_to_go = options[:length] - extracted_password.length\n remainder = \".{#{num_chars_to_go-1}}\"\n possible_charset = options[:charset]\n while possible_charset.length > 1\n charset_slices = possible_charset.chars.each_slice((possible_charset.size/2.0).round).to_a.map(&:join)\n char_test = \"[#{charset_slices[1]}]\"\n regex = ['^', extracted_password, char_test, remainder, '$'].join\n matched = password_matches?(regex)\n puts ' ' * 18 + \"> Matched: #{matched ? 'yes' : 'no'}\"\n matching_slice = matched ? 1 : 0\n possible_charset = charset_slices[matching_slice]\n puts ' ' * 6 + \"> #{possible_charset}\"\n end\n possible_charset\n end", "def set_word\n dic = File.read(\"dic.txt\").downcase.split\n dic.reject! {|word| word.length<5 || word.length>12}\n word = dic.sample\n end", "def get_word(difficulty)\n WORDS.select{|word| word.length == difficulty}.sample\nend", "def strong_password\n /^(?=.*\\d)(?=.*[a-z])(?=.*[\\W_]).{6,}$/i\n end", "def encrypt(password)\n\tsplit_string = string.password(//)\n\tsplit_string.each do |letter|\n\t\tletter.next\n\tend\n\nend", "def guess(word_pattern, possible_words)\n all_words = possible_words.flatten\n guess = $avail_letters.sort_by {|c|\n all_words.select{|w|w.index c}.length}.last\n $avail_letters -= [guess]\n $guess = guess\nend", "def split_secret\n counter = 0\n while counter < @secret_word.length\n @secret_array << @secret_word[counter]\n counter += 1\n end\n @secret_array\n end", "def secret_word=(word)\n @secret_word = word.upcase\n @secret_word_length = word.length\n end", "def combinations\nputs \"Enter text\"\ntext = gets.chomp\nputs text\nwords = text.scan /\\w/\n\n\n\nputs words\nend", "def get_appropriate_words(dictionary)\n\t\tnew_dictionary = []\n\t\tdictionary.each do |word|\n\t\t\tword.gsub!(\"\\r\\n\",\"\")\n\t\t\tif word.length >= 5 and word.length <= 12\n\t\t\t\tnew_dictionary << word\n\t\t\tend\n\t\tend\n\t\tnew_dictionary\n\tend", "def password\n end", "def password\n end", "def generate_password( length_of_pass, special_char )\n chars = []\n (\"a\"..\"z\").each {|ele| chars << ele}\n (\"A\"..\"Z\").each {|ele| chars << ele}\n (\"0\"..\"9\").each {|ele| chars << ele}\n if(special_char)\n [\"@\", \"!\", \"_\",].each {|ele| chars << ele}\n end\n newpass = \"\"\n 1.upto(length_of_pass) { |i| newpass << chars[rand(chars.size-1)] }\n #self.password\n self.unencrypted_password = newpass\n self.password_confirmation = newpass\n @unencrypted = true\n end", "def autocomplete(input, dictionary)\n words = Array.new\n dictionary.each do |word|\n if (word.gsub(/[^a-zA-Z]/, '')).downcase.start_with? (input.gsub(/[^a-zA-Z]/, '')).downcase\n words << word\n end\n end\n return words.first(5)\nend", "def choose_word\n @word = @lines[rand(0..(@lines.length - 1))].chomp\n choose_word if @word.length < 5 || @word.length > 12\n end", "def existing_words\n draw_current = draw\n p \"The 7 letters drawn are:\"\n p draw_current\n p \"-\"*70\n\n combinations = combine(draw_current).flat_map{ |w| w.permutation.to_a}.uniq.map { |e| e.join }\n combinations.map{|i| search(i, UPPER_BOUND_INI, LOWER_BOUND_INI, NO_ITERATION_INI)}.flatten.reject{|x| x==nil}\nend", "def password\n\n end", "def choose_word\n words = File.readlines(\"5desk.txt\")\n words.map! { |word| word.chomp } # Remove newline characters from the file\n words.select! { |word| (word.size >= 5) && (word.size <= 12) }\n words.sample\n end", "def is_password_password(pass)\n if pass.downcase == 'password'\n 'Sorry, password cannot be password.'\n else\n 'Yay, password is not password.'\n end\nend" ]
[ "0.6634776", "0.66284984", "0.66254437", "0.65524787", "0.654974", "0.65060174", "0.6445963", "0.6393818", "0.63682526", "0.632968", "0.63202065", "0.6303105", "0.6294683", "0.6282696", "0.6260989", "0.62464064", "0.62313306", "0.6196371", "0.61936104", "0.61721146", "0.6166814", "0.60829127", "0.607036", "0.6066701", "0.6037189", "0.603463", "0.60289735", "0.6024355", "0.6012204", "0.60042644", "0.5988807", "0.5982086", "0.5972912", "0.59555054", "0.5942112", "0.59349877", "0.5933362", "0.5921243", "0.59187233", "0.5892751", "0.5882961", "0.5874802", "0.5872823", "0.5863109", "0.58593875", "0.5856995", "0.58561033", "0.5852174", "0.5850001", "0.58498937", "0.58434916", "0.58301115", "0.582342", "0.5820832", "0.5814008", "0.57848644", "0.57846916", "0.5759376", "0.57548803", "0.57524526", "0.5752394", "0.57461953", "0.5739581", "0.57376534", "0.5734708", "0.5725225", "0.571272", "0.5703399", "0.57019573", "0.56954706", "0.569077", "0.5686437", "0.56777453", "0.56766397", "0.56753975", "0.56665003", "0.56665003", "0.56665003", "0.56665003", "0.56665003", "0.56665003", "0.5664241", "0.5654701", "0.5651946", "0.56434506", "0.5638918", "0.5637222", "0.5631882", "0.562988", "0.56179565", "0.56156254", "0.5613684", "0.56125844", "0.56125844", "0.56088877", "0.5607076", "0.5606132", "0.5590649", "0.5589216", "0.55824566", "0.55783147" ]
0.0
-1
GET /cake_flavors GET /cake_flavors.json
def index @cake_flavors = CakeFlavor.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def flavors()\n return get_request(address(\"/flavors/detail\"), @token)\t\n end", "def index\n @flavors = Flavor.all\n end", "def list_flavors_detail()\n response = dbreq(\"GET\", dbmgmthost, \"#{dbmgmtpath}/flavors/detail\", dbmgmtport, dbmgmtscheme)\n CloudDB::Exception.raise_exception(response) unless response.code.to_s.match(/^20.$/)\n flavors = CloudDB.symbolize_keys(JSON.parse(response.body)[\"flavors\"])\n return flavors\n end", "def list_flavors()\n response = dbreq(\"GET\", dbmgmthost, \"#{dbmgmtpath}/flavors\", dbmgmtport, dbmgmtscheme)\n CloudDB::Exception.raise_exception(response) unless response.code.to_s.match(/^20.$/)\n flavors = CloudDB.symbolize_keys(JSON.parse(response.body)[\"flavors\"])\n return flavors\n end", "def show\n @flavor = compute.get_flavor(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @flavor }\n end\n end", "def index\n @frosting_flavors = FrostingFlavor.all\n end", "def index\n @flavia = Flavium.all\n end", "def add_to_cake\n @cake = Cake.find(params[:cake_id])\n @cake.cake_flavors << @cake_flavor\n\n render json: @cake, include: :cake_flavors\n end", "def flavor\n if ENV[\"CHEF_API_FLAVOR\"]\n ENV[\"CHEF_API_FLAVOR\"].to_sym\n elsif config[\"CHEF_API_FLAVOR\"]\n config[\"CHEF_API_FLAVOR\"]\n else\n endpoint.include?(\"/organizations\") ? :enterprise : :open_source\n end\n end", "def index\n @store_flavors = StoreFlavor.all\n end", "def new\n @flavor = Flavor.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @flavor }\n end\n end", "def flavor\n fetch('dessert.flavor')\n end", "def create\n @cake_flavor = CakeFlavor.new(cake_flavor_params)\n\n respond_to do |format|\n if @cake_flavor.save\n format.html { redirect_to @cake_flavor, notice: 'Cake flavor was successfully created.' }\n format.json { render :show, status: :created, location: @cake_flavor }\n else\n format.html { render :new }\n format.json { render json: @cake_flavor.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @flavor_groups = FlavorGroup.all\n end", "def index\n flavors = []\n cs_id = params[:compute_site_id]\n\n if optimizer_query?\n tmpls = VirtualMachineTemplate.\n active.\n on_active_tenant.\n includes(\n tenants: [\n virtual_machine_flavors: [\n :os_families, :flavor_os_families\n ]\n ]\n )\n .where(appliance_type_id: appl_type_id)\n tmpls = tmpls.on_tenant(cs_id) if cs_id\n\n unless tmpls.blank?\n _, _, flavor, _ = Optimizer.instance\n .select_tmpl_and_flavor_and_tenant(tmpls, nil, params)\n\n flavors = [flavor]\n end\n else\n flavors = VirtualMachineFlavor.with_prefs(params).where(filter)\n flavors = flavors.on_tenant(cs_id) if cs_id\n end\n flavors = flavors.first(limit) if limit\n\n respond_with flavors\n end", "def set_cake_flavor\n @cake_flavor = CakeFlavor.find(params[:id])\n end", "def set_cake_flavor\n @cake_flavor = CakeFlavor.find(params[:id])\n end", "def select_flavor\n compute.flavors.map { |f| [f.name, f.id] }\n end", "def new\n @flavours = @provider.get_flavors\n puts \"getting the flavors #{@flavours.inspect}\"\n @images = @provider.get_images\n puts \"getting the flavors #{@images.inspect}\"\n @instance = @provider.instances.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @instance }\n end\n end", "def flavor\n self.class.flavors[@flavor_id]\n end", "def incrementally_list_flavors(offset=nil, limit=nil, opts={}, &block)\n incrementally_list_resources(:get, detailed_path(\"/flavors\", opts), offset, limit, opts, &block)\n end", "def get_flavor(id)\n response = @connection.req('GET', \"/flavors/#{id}\")\n flavor_info = JSON.parse(response.body)['flavor']\n OpenStack::Compute::Flavor.new(flavor_info)\n end", "def destroy\n @cake_flavor.destroy\n respond_to do |format|\n format.html { redirect_to cake_flavors_url, notice: 'Cake flavor was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def create\n @flavor = Flavor.new(flavor_params)\n\n respond_to do |format|\n if @flavor.save\n format.html { redirect_to @flavor, notice: 'Flavor was successfully created.' }\n format.json { render :show, status: :created, location: @flavor }\n else\n format.html { render :new }\n format.json { render json: @flavor.errors, status: :unprocessable_entity }\n end\n end\n end", "def show\n @cake = Cake.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @cake }\n end\n end", "def index\n respond_to do |format|\n format.html { @chefs = Chef.all }\n format.json { @chefs = Chef.order(:name) }\n end\n end", "def index\n @flavors = Flavor.all\n @flavors = @flavors.active(params[:active]) if params[:active].present?\n @flavors = @flavors.inactive(params[:inactive]) if params[:inactive].present?\n @flavors = @flavors.alphabetical(params[:alphabetical]) if params[:alphabetical].present?\n end", "def get_flavor(id)\n CloudServers::Flavor.new(self,id)\n end", "def get_colours\n @item = Item.find(params[:id])\n @colours = @item.variants_for(:colour, params[:size], nil)\n respond_to do |format|\n format.json { render :json => @colours }\n end\n end", "def get_brandings\n request :get, \"/v3/brandings.json\"\n end", "def show\n json_response(@fav)\n end", "def index\n @themes = Theme.all\n json_response(@themes)\n end", "def show\n @fabric = Fabric.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @fabric }\n end\n end", "def show\n @farm = Farm.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @farm }\n end\n end", "def show\n render json: @brand_category\n end", "def flavor f\n @logger.debug \"OpenStack: Looking up flavor '#{f}'\"\n @compute_client.flavors.find { |x| x.name == f } || raise(\"Couldn't find flavor: #{f}\")\n end", "def index\n @fabricas = Fabrica.all\n end", "def update\n respond_to do |format|\n if @cake_flavor.update(cake_flavor_params)\n format.html { redirect_to @cake_flavor, notice: 'Cake flavor was successfully updated.' }\n format.json { render :show, status: :ok, location: @cake_flavor }\n else\n format.html { render :edit }\n format.json { render json: @cake_flavor.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_flavor\n @flavor = Flavor.find(params[:id])\n end", "def set_flavor\n @flavor = Flavor.find(params[:id])\n end", "def index\n render json: @owner.cats\n end", "def flavor\n return @flavor\n end", "def show\n @cloud = Cloud.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @cloud }\n end\n end", "def index\n @electors = Elector.all\n\n render json: @electors\n end", "def index\n @choices = Choice.all\n\n render json: @choices\n end", "def set_flavium\n @flavium = Flavium.find(params[:id])\n end", "def show\n @farm = Farm.find(params[:id])\n @herds = Herd.where(:farm_id => @farm.id)\n respond_to do |format|\n format.html # index.html.erbb\n format.json { render :json => @farm }\n end\n end", "def index\n @glasses = Glass.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @glasses }\n end\n end", "def index\n @brand_categories = BrandCategory.all\n\n render json: @brand_categories\n end", "def index\n @variants = Variant.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @variants }\n end\n end", "def index\n info = Aws.get_recipes_from_db\n render :json => info\n end", "def show\n render json: @favorite\n end", "def flavor_faves\n @flavors=Flavor.all\n @flavors=@flavors.order(svy_vote: :desc).limit(5)\n @first=@flavors.first\n end", "def list_all_aos_version_boxes(args = {}) \n get(\"/aosversions.json/aosversionbox\", args)\nend", "def show\n @brand = Brand.find(params[:id])\n @makers = @brand.makers\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @brand }\n end\n end", "def show\n render json: @favorite_route\n end", "def create\n @frosting_flavor = FrostingFlavor.new(frosting_flavor_params)\n\n respond_to do |format|\n if @frosting_flavor.save\n format.html { redirect_to @frosting_flavor, notice: 'Frosting flavor was successfully created.' }\n format.json { render :show, status: :created, location: @frosting_flavor }\n else\n format.html { render :new }\n format.json { render json: @frosting_flavor.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @breeds = Breed.all\n\n render json: @breeds\n end", "def get_flavor(id)\n CloudDB::Flavor.new(self,id)\n end", "def index\n colorizers = Colorizer.all\n\n render json: colorizers\n end", "def demo\n render json: Cat.all\n end", "def show\n render json: @pizza\n end", "def show\n #show all kind categories\n @categories = Category.where(:category_id => params[:id])\n @freds = Fred.where(:category_id => params[:id]).order(\"updated_at DESC\")\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @categories }\n end\n end", "def create\n @flavium = Flavium.new(flavium_params)\n\n respond_to do |format|\n if @flavium.save\n format.html { redirect_to @flavium, notice: 'Flavium was successfully created.' }\n format.json { render :show, status: :created, location: @flavium }\n else\n format.html { render :new }\n format.json { render json: @flavium.errors, status: :unprocessable_entity }\n end\n end\n end", "def show\n @family = get_family(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @family }\n end\n end", "def index\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @service_pricing_schemes }\n end\n end", "def create\n @store_flavor = StoreFlavor.new(store_flavor_params)\n\n respond_to do |format|\n if @store_flavor.save\n format.html { redirect_to @store_flavor, notice: 'Store flavor was successfully created.' }\n format.json { render :show, status: :created, location: @store_flavor }\n else\n format.html { render :new }\n format.json { render json: @store_flavor.errors, status: :unprocessable_entity }\n end\n end\n end", "def cake_flavor_params\n params.require(:cake_flavor).permit(:flavor_name)\n end", "def index\n @apps = @client.apps\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @apps }\n end\n end", "def show\n family = current_family\n p current_family\n render json: family.as_json\n end", "def show\n render json: @family_image\n end", "def index\n @cabines = Cabine.all\n render json: @cabines\n end", "def list\n @collections = Admin::Collection.names\n\n render json: { collections: @collections }\n end", "def show\n @fav = Fav.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @fav }\n end\n end", "def show\n @village = Village.find(params[:id])\n @collections = @village.collections\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @village }\n end\n end", "def index\n @majors = majors\n respond_to do |format|\n format.json{\n return render json: ret\n }\n end\n end", "def index\n @convention_categories = ConventionCategory.sorted\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @convention_categories }\n end\n end", "def index\n @favoritos = Favorito.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @favoritos }\n end\n end", "def index\n pet_type = PetType.find(params[:pet_type_id])\n @pet_breeds = pet_type.pet_breeds.select { | match | match.published }\n\n respond_to do | format |\n format.html #index.html.erb\n format.json { render json: @pet_breeds }\n end\n end", "def index\n @varieties = Variety.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @varieties }\n end\n end", "def destroy\n @frosting_flavor.destroy\n respond_to do |format|\n format.html { redirect_to frosting_flavors_url, notice: 'Frosting flavor was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def index\n @breeds = Breed.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @breeds }\n end\n end", "def list\n @colors = Admin::Color.all\n\n render json: { colors: @colors }\n end", "def index\n @admin_villages = Admin::Village.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @admin_villages }\n end\n end", "def show\n @convention_category = ConventionCategory.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @convention_category }\n end\n end", "def create\n\t\t@flavor = Flavor.new(flavor_params)\n\t\t\n\t\t# matching corresponding color to selected category\n\t\tcolors = {\"Floral\": \"rgb(255, 92, 197)\", \"Citrus\": \"rgb(255, 168, 66)\", \"Apple / Pear\": \"rgb(66, 217, 13)\", \"Melon\": \"rgb(98, 255, 160)\", \"Grape\": \"rgb(119, 217, 67)\", \"Tropical Fruit\": \"rgb(255, 244, 0)\", \"Stone Fruit\": \"rgb(255, 124, 0)\", \"Berry\": \"rgb(208, 27, 232)\", \"Dried Fruit\": \"rgb(184, 83, 12)\", \"Chocolate\": \"rgb(97, 55, 3)\", \"Sweet and Sugary\": \"rgb(255, 254, 229)\", \"Nutty\": \"rgb(143, 82, 5)\", \"Grain / Cereal\": \"rgb(196, 126, 166)\", \"Roast\": \"rgb(76, 50, 0)\", \"Spice\": \"rgb(255, 0 , 33)\", \"Savory\": \"rgb(132, 21, 7)\", \"Earthy\": \"rgb(66, 36, 0)\", \"Vegetal\": \"rgb(43, 71, 0)\", \"Herbal\": \"rgb(21, 151, 20)\"}\n\n\t\t@flavor.color = colors[:\"#{params[:flavor][:category]}\"]\n\n\t\t# if other was selected, then replace note value\n\t\tif params[:flavor][:note] == \"Other\" && params[:flavor][:other].length > 2\n\t\t\t@flavor.note = params[:flavor][:other].chomp.capitalize\n\t\t# if other was selected but nothing valid was written, flash error\n\t\telsif params[:flavor][:note] == \"Other\" && params[:flavor][:other].length < 3\n\t\t\tflash[:error] = \"Please type a valid custom note when selecting 'Other'.\"\n\t\tend\n\n\t\t# makes sure all values are there before saving\n\t\tif @flavor.save\n\t\t\tredirect_to new_beanformed_company_bean_flavor_path(params[:company_id], params[:bean_id])\n\t\telse \n\t\t\tflash[:error] = \"Select all fields\"\n\t\tend\n\tend", "def index\n @facts = fact_type.all\n @title = fact_type\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @facts }\n end\n end", "def update\n respond_to do |format|\n if @flavor.update(flavor_params)\n format.html { redirect_to @flavor, notice: 'Flavor was successfully updated.' }\n format.json { render :show, status: :ok, location: @flavor }\n else\n format.html { render :edit }\n format.json { render json: @flavor.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @api_versions = ApiVersion.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @api_versions }\n end\n end", "def get_favourite_restaurants\n @profile = Profile.find(params[:id])\n @restaurants = @profile.favourites\n\n render status: 200, json: @restaurants\n end", "def show\n @favorite_bundle = FavoriteBundle.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @favorite_bundle }\n end\n end", "def index\n @pizzas = Pizza.all\n render json: @pizzas\n end", "def index\n @heroes = Hero.all\n\n render json: @heroes\n end", "def index\n @vegetables = Vegetable.all\n end", "def index\n @favorite_routes = FavoriteRoute.all\n render json: @favorite_routes\n end", "def index\n @web_car_galleries = WebCarGallery.all\n\n render json: @web_car_galleries\n end", "def index\n response = HTTParty.get('http://okta-api:8080/pets/v1/cats', {headers: {\"X-Token\"=> session[:oktastate][:credentials][:token]}})\n if response.code == 200\n @cats = JSON.parse(response.body)\n else\n @cats = []\n end\n end", "def index\n @fake_libraries = FakeLibrary.all\n\n render json: ({fake_libraries: @fake_libraries})\n end", "def destroy\n compute.delete_flavor(params[:id])\n \n\n respond_to do |format|\n format.html { redirect_to flavors_path }\n format.json { head :ok }\n end\n end", "def list_all_aos_versions(args = {}) \n get(\"/aosversions.json/all\", args)\nend" ]
[ "0.78807485", "0.71675557", "0.70889527", "0.69904155", "0.6783881", "0.670636", "0.6580068", "0.652218", "0.6369831", "0.6318258", "0.63060945", "0.62686247", "0.6204976", "0.6161162", "0.6123502", "0.61148125", "0.61148125", "0.60916233", "0.6086261", "0.6080107", "0.6067512", "0.5976617", "0.59340256", "0.59244627", "0.5907724", "0.58158565", "0.5804228", "0.57761574", "0.5775146", "0.5753986", "0.57474077", "0.5680771", "0.5663245", "0.564746", "0.56386757", "0.563105", "0.56306046", "0.56301314", "0.561928", "0.561928", "0.56087327", "0.5593672", "0.5586331", "0.55853564", "0.5571544", "0.5562219", "0.5513895", "0.55121964", "0.5492673", "0.54875785", "0.54779696", "0.5475844", "0.5473473", "0.54660714", "0.5465027", "0.54612416", "0.5452679", "0.5445539", "0.54451686", "0.54373825", "0.54303384", "0.54154235", "0.5396012", "0.539397", "0.5390481", "0.53883857", "0.53868103", "0.53766024", "0.5370096", "0.5368669", "0.53655785", "0.53648835", "0.53585654", "0.5355519", "0.535457", "0.53544134", "0.534901", "0.53484774", "0.5342219", "0.53412426", "0.5333993", "0.5332628", "0.5328036", "0.53227407", "0.53199905", "0.53179264", "0.53170735", "0.5313914", "0.5313653", "0.53110963", "0.5310042", "0.53067976", "0.5306688", "0.5301208", "0.5297893", "0.52961934", "0.5295737", "0.5295677", "0.5294147", "0.52906835" ]
0.7617719
1
GET /cake_flavors/1 GET /cake_flavors/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def flavors()\n return get_request(address(\"/flavors/detail\"), @token)\t\n end", "def index\n @cake_flavors = CakeFlavor.all\n end", "def index\n @flavors = Flavor.all\n end", "def show\n @flavor = compute.get_flavor(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @flavor }\n end\n end", "def list_flavors_detail()\n response = dbreq(\"GET\", dbmgmthost, \"#{dbmgmtpath}/flavors/detail\", dbmgmtport, dbmgmtscheme)\n CloudDB::Exception.raise_exception(response) unless response.code.to_s.match(/^20.$/)\n flavors = CloudDB.symbolize_keys(JSON.parse(response.body)[\"flavors\"])\n return flavors\n end", "def new\n @flavor = Flavor.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @flavor }\n end\n end", "def index\n @frosting_flavors = FrostingFlavor.all\n end", "def index\n @flavia = Flavium.all\n end", "def add_to_cake\n @cake = Cake.find(params[:cake_id])\n @cake.cake_flavors << @cake_flavor\n\n render json: @cake, include: :cake_flavors\n end", "def list_flavors()\n response = dbreq(\"GET\", dbmgmthost, \"#{dbmgmtpath}/flavors\", dbmgmtport, dbmgmtscheme)\n CloudDB::Exception.raise_exception(response) unless response.code.to_s.match(/^20.$/)\n flavors = CloudDB.symbolize_keys(JSON.parse(response.body)[\"flavors\"])\n return flavors\n end", "def set_cake_flavor\n @cake_flavor = CakeFlavor.find(params[:id])\n end", "def set_cake_flavor\n @cake_flavor = CakeFlavor.find(params[:id])\n end", "def flavor\n if ENV[\"CHEF_API_FLAVOR\"]\n ENV[\"CHEF_API_FLAVOR\"].to_sym\n elsif config[\"CHEF_API_FLAVOR\"]\n config[\"CHEF_API_FLAVOR\"]\n else\n endpoint.include?(\"/organizations\") ? :enterprise : :open_source\n end\n end", "def show\n @cake = Cake.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @cake }\n end\n end", "def get_flavor(id)\n response = @connection.req('GET', \"/flavors/#{id}\")\n flavor_info = JSON.parse(response.body)['flavor']\n OpenStack::Compute::Flavor.new(flavor_info)\n end", "def flavor\n fetch('dessert.flavor')\n end", "def create\n @cake_flavor = CakeFlavor.new(cake_flavor_params)\n\n respond_to do |format|\n if @cake_flavor.save\n format.html { redirect_to @cake_flavor, notice: 'Cake flavor was successfully created.' }\n format.json { render :show, status: :created, location: @cake_flavor }\n else\n format.html { render :new }\n format.json { render json: @cake_flavor.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @flavours = @provider.get_flavors\n puts \"getting the flavors #{@flavours.inspect}\"\n @images = @provider.get_images\n puts \"getting the flavors #{@images.inspect}\"\n @instance = @provider.instances.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @instance }\n end\n end", "def flavor\n self.class.flavors[@flavor_id]\n end", "def index\n @store_flavors = StoreFlavor.all\n end", "def get_flavor(id)\n CloudServers::Flavor.new(self,id)\n end", "def show\n @fabric = Fabric.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @fabric }\n end\n end", "def create\n @flavor = Flavor.new(flavor_params)\n\n respond_to do |format|\n if @flavor.save\n format.html { redirect_to @flavor, notice: 'Flavor was successfully created.' }\n format.json { render :show, status: :created, location: @flavor }\n else\n format.html { render :new }\n format.json { render json: @flavor.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @flavor_groups = FlavorGroup.all\n end", "def destroy\n @cake_flavor.destroy\n respond_to do |format|\n format.html { redirect_to cake_flavors_url, notice: 'Cake flavor was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def index\n flavors = []\n cs_id = params[:compute_site_id]\n\n if optimizer_query?\n tmpls = VirtualMachineTemplate.\n active.\n on_active_tenant.\n includes(\n tenants: [\n virtual_machine_flavors: [\n :os_families, :flavor_os_families\n ]\n ]\n )\n .where(appliance_type_id: appl_type_id)\n tmpls = tmpls.on_tenant(cs_id) if cs_id\n\n unless tmpls.blank?\n _, _, flavor, _ = Optimizer.instance\n .select_tmpl_and_flavor_and_tenant(tmpls, nil, params)\n\n flavors = [flavor]\n end\n else\n flavors = VirtualMachineFlavor.with_prefs(params).where(filter)\n flavors = flavors.on_tenant(cs_id) if cs_id\n end\n flavors = flavors.first(limit) if limit\n\n respond_with flavors\n end", "def set_flavor\n @flavor = Flavor.find(params[:id])\n end", "def set_flavor\n @flavor = Flavor.find(params[:id])\n end", "def select_flavor\n compute.flavors.map { |f| [f.name, f.id] }\n end", "def show\n @farm = Farm.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @farm }\n end\n end", "def show\n @cloud = Cloud.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @cloud }\n end\n end", "def index\n respond_to do |format|\n format.html { @chefs = Chef.all }\n format.json { @chefs = Chef.order(:name) }\n end\n end", "def flavor f\n @logger.debug \"OpenStack: Looking up flavor '#{f}'\"\n @compute_client.flavors.find { |x| x.name == f } || raise(\"Couldn't find flavor: #{f}\")\n end", "def update\n respond_to do |format|\n if @cake_flavor.update(cake_flavor_params)\n format.html { redirect_to @cake_flavor, notice: 'Cake flavor was successfully updated.' }\n format.json { render :show, status: :ok, location: @cake_flavor }\n else\n format.html { render :edit }\n format.json { render json: @cake_flavor.errors, status: :unprocessable_entity }\n end\n end\n end", "def incrementally_list_flavors(offset=nil, limit=nil, opts={}, &block)\n incrementally_list_resources(:get, detailed_path(\"/flavors\", opts), offset, limit, opts, &block)\n end", "def get_colours\n @item = Item.find(params[:id])\n @colours = @item.variants_for(:colour, params[:size], nil)\n respond_to do |format|\n format.json { render :json => @colours }\n end\n end", "def get_flavor(id)\n CloudDB::Flavor.new(self,id)\n end", "def show\n json_response(@fav)\n end", "def set_flavium\n @flavium = Flavium.find(params[:id])\n end", "def show\n render json: @brand_category\n end", "def show\n @banana = Banana.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @banana }\n end\n end", "def show\n @convention_category = ConventionCategory.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @convention_category }\n end\n end", "def index\n info = Aws.get_recipes_from_db\n render :json => info\n end", "def flavor\n return @flavor\n end", "def show\n @family = get_family(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @family }\n end\n end", "def get_brandings\n request :get, \"/v3/brandings.json\"\n end", "def index\n @themes = Theme.all\n json_response(@themes)\n end", "def new\n @cake = Cake.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @cake }\n end\n end", "def show\n @farm = Farm.find(params[:id])\n @herds = Herd.where(:farm_id => @farm.id)\n respond_to do |format|\n format.html # index.html.erbb\n format.json { render :json => @farm }\n end\n end", "def get_flavor(id)\n OpenStack::Compute::Flavor.new(self,id)\n end", "def show\n @appliance_type = ApplianceType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @appliance_type }\n end\n end", "def show\n @version = Version.find(params[:id])\n @versionconfig= @version.version_configurations.all\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @version }\n end\n end", "def index\n render json: @owner.cats\n end", "def show\n @fav = Fav.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @fav }\n end\n end", "def show\n @favorite_bundle = FavoriteBundle.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @favorite_bundle }\n end\n end", "def index\n @choices = Choice.all\n\n render json: @choices\n end", "def index\n @glasses = Glass.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @glasses }\n end\n end", "def index\n @flavors = Flavor.all\n @flavors = @flavors.active(params[:active]) if params[:active].present?\n @flavors = @flavors.inactive(params[:inactive]) if params[:inactive].present?\n @flavors = @flavors.alphabetical(params[:alphabetical]) if params[:alphabetical].present?\n end", "def index\n @fabricas = Fabrica.all\n end", "def flavor_faves\n @flavors=Flavor.all\n @flavors=@flavors.order(svy_vote: :desc).limit(5)\n @first=@flavors.first\n end", "def update\n @flavor = Flavor.find(params[:id])\n\n respond_to do |format|\n if @flavor.update_attributes(params[:flavor])\n format.html { redirect_to @flavor, :notice => 'Flavor was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @flavor.errors, :status => :unprocessable_entity }\n end\n end\n end", "def index\n @facts = fact_type.all\n @title = fact_type\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @facts }\n end\n end", "def show\n @vegetable = Vegetable.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @vegetable }\n end\n end", "def show\n render json: @pizza\n end", "def show\n @vachana = Vachana.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @vachana }\n end\n end", "def show\n @vachana = Vachana.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @vachana }\n end\n end", "def index\n @variants = Variant.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @variants }\n end\n end", "def show\n @cvi = Cvi.find(params[:id])\n @animals = @cvi.animals\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @cvi }\n end\n end", "def show\n @fish_type = FishType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @fish_type }\n end\n end", "def show\n render json: @favorite\n end", "def show\n @variety = Variety.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @variety }\n end\n end", "def show\n family = current_family\n p current_family\n render json: family.as_json\n end", "def show\n @belief = Belief.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @belief }\n end\n end", "def show\n @food = Food.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @food }\n end\n end", "def show\n render json: @favorite_route\n end", "def show\n mix = BreedMix.find(params[:id])\n render json: mix\n end", "def show\n\n @food = Food.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @food }\n end\n end", "def index\n @apps = @client.apps\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @apps }\n end\n end", "def show\n #show all kind categories\n @categories = Category.where(:category_id => params[:id])\n @freds = Fred.where(:category_id => params[:id]).order(\"updated_at DESC\")\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @categories }\n end\n end", "def update\n respond_to do |format|\n if @flavor.update(flavor_params)\n format.html { redirect_to @flavor, notice: 'Flavor was successfully updated.' }\n format.json { render :show, status: :ok, location: @flavor }\n else\n format.html { render :edit }\n format.json { render json: @flavor.errors, status: :unprocessable_entity }\n end\n end\n end", "def show\n @api_version = ApiVersion.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @api_version }\n end\n end", "def show\n @appliance_manufacturer = ApplianceManufacturer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @appliance_manufacturer }\n end\n end", "def show\n @instance = Instance.find(params[:id])\n @flavor = Flavor.find_by_flavor_id(@instance.flavor_id)\n @image = Image.find_by_image_id(@instance.image_id)\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @instance }\n end\n end", "def show\n @brand = Brand.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @brand }\n end\n end", "def show\n @brand = Brand.find(params[:id])\n @makers = @brand.makers\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @brand }\n end\n end", "def show\n @favourite_food = FavouriteFood.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @favourite_food }\n end\n end", "def index\n @api_versions = ApiVersion.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @api_versions }\n end\n end", "def show\n render json: @bike_type\n end", "def show\n render json: @family_image\n end", "def demo\n render json: Cat.all\n end", "def create\n @frosting_flavor = FrostingFlavor.new(frosting_flavor_params)\n\n respond_to do |format|\n if @frosting_flavor.save\n format.html { redirect_to @frosting_flavor, notice: 'Frosting flavor was successfully created.' }\n format.json { render :show, status: :created, location: @frosting_flavor }\n else\n format.html { render :new }\n format.json { render json: @frosting_flavor.errors, status: :unprocessable_entity }\n end\n end\n end", "def show\n @brand_category = BrandCategory.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @brand_category }\n end\n end", "def show\n @scheme = Scheme.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @scheme }\n end\n end", "def show\n @forest = Forest.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @forest }\n end\n end", "def show\n @village = Village.find(params[:id])\n @collections = @village.collections\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @village }\n end\n end", "def show\n @tango = Tango.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tango }\n end\n end", "def set_frosting_flavor\n @frosting_flavor = FrostingFlavor.find(params[:id])\n end", "def index\n @varieties = Variety.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @varieties }\n end\n end", "def destroy\n compute.delete_flavor(params[:id])\n \n\n respond_to do |format|\n format.html { redirect_to flavors_path }\n format.json { head :ok }\n end\n end", "def index\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @service_pricing_schemes }\n end\n end", "def show\n render json: Festival.build_for(params[:id]).to_json\n end" ]
[ "0.76378876", "0.7489924", "0.70809793", "0.70580685", "0.6725686", "0.6595451", "0.6561023", "0.65489906", "0.65204555", "0.6498862", "0.63780916", "0.63780916", "0.63148826", "0.63035715", "0.6289663", "0.62692475", "0.62571025", "0.6246953", "0.6245626", "0.61637634", "0.6084293", "0.60643977", "0.60144633", "0.6008303", "0.5995103", "0.59729224", "0.59168816", "0.59168816", "0.5910615", "0.5898131", "0.58870655", "0.58814627", "0.58169323", "0.5815337", "0.581193", "0.5798561", "0.57923794", "0.57799256", "0.5755542", "0.56976724", "0.5686898", "0.568609", "0.5674552", "0.5670056", "0.5668177", "0.56656003", "0.5652209", "0.5649069", "0.5633833", "0.563185", "0.5629478", "0.5629392", "0.5625837", "0.5625826", "0.5620156", "0.5618359", "0.5615496", "0.5608837", "0.5593603", "0.559209", "0.55742836", "0.55735177", "0.5565928", "0.556407", "0.55578274", "0.55578274", "0.555303", "0.55445635", "0.5542469", "0.5541597", "0.55412984", "0.5536215", "0.55342424", "0.5531341", "0.5529474", "0.5526575", "0.5526287", "0.5523525", "0.55228645", "0.55216914", "0.5516", "0.55107486", "0.5508111", "0.5506876", "0.54965454", "0.5495218", "0.54949933", "0.5486554", "0.54860353", "0.54845583", "0.5478643", "0.54786384", "0.5476261", "0.54738384", "0.54726046", "0.54703695", "0.5467708", "0.54606134", "0.5459948", "0.54544854", "0.54374063" ]
0.0
-1
POST /cake_flavors POST /cake_flavors.json
def create @cake_flavor = CakeFlavor.new(cake_flavor_params) respond_to do |format| if @cake_flavor.save format.html { redirect_to @cake_flavor, notice: 'Cake flavor was successfully created.' } format.json { render :show, status: :created, location: @cake_flavor } else format.html { render :new } format.json { render json: @cake_flavor.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @flavor = Flavor.new(flavor_params)\n\n respond_to do |format|\n if @flavor.save\n format.html { redirect_to @flavor, notice: 'Flavor was successfully created.' }\n format.json { render :show, status: :created, location: @flavor }\n else\n format.html { render :new }\n format.json { render json: @flavor.errors, status: :unprocessable_entity }\n end\n end\n end", "def add_to_cake\n @cake = Cake.find(params[:cake_id])\n @cake.cake_flavors << @cake_flavor\n\n render json: @cake, include: :cake_flavors\n end", "def create\n @flavium = Flavium.new(flavium_params)\n\n respond_to do |format|\n if @flavium.save\n format.html { redirect_to @flavium, notice: 'Flavium was successfully created.' }\n format.json { render :show, status: :created, location: @flavium }\n else\n format.html { render :new }\n format.json { render json: @flavium.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @frosting_flavor = FrostingFlavor.new(frosting_flavor_params)\n\n respond_to do |format|\n if @frosting_flavor.save\n format.html { redirect_to @frosting_flavor, notice: 'Frosting flavor was successfully created.' }\n format.json { render :show, status: :created, location: @frosting_flavor }\n else\n format.html { render :new }\n format.json { render json: @frosting_flavor.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @store_flavor = StoreFlavor.new(store_flavor_params)\n\n respond_to do |format|\n if @store_flavor.save\n format.html { redirect_to @store_flavor, notice: 'Store flavor was successfully created.' }\n format.json { render :show, status: :created, location: @store_flavor }\n else\n format.html { render :new }\n format.json { render json: @store_flavor.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n # {\"vcpus\": 1, \"disk\": 1, \"name\": \"test\", \"rxtx_factor\": 1, \"OS-FLV-EXT-DATA:ephemeral\": 1, \"ram\": 512, \"id\": 6, \"swap\": 1}}'\n @flavor = compute.create_flavor(\"rxtx_factor\"=>1,\"OS-FLV-EXT-DATA:ephemeral\"=>params[:ephemeral],:vcpus=>params[:vcpus],:disk=>params[:disk],:name=>params[:name],:ram=>params[:ram],:id=>params[:id],:swap=>params[:swap])\n\n respond_to do |format|\n format.html { redirect_to flavors_path, :notice => 'Flavor was successfully created.' }\n format.json { render :json => @flavor, :status => :created, :location => @flavor }\n end\n end", "def create\n @flavor_group = FlavorGroup.new(flavor_group_params)\n\n respond_to do |format|\n if @flavor_group.save\n format.html { redirect_to @flavor_group, notice: 'Flavor group was successfully created.' }\n format.json { render :show, status: :created, location: @flavor_group }\n else\n format.html { render :new }\n format.json { render json: @flavor_group.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @cake_flavors = CakeFlavor.all\n end", "def new\n @flavor = Flavor.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @flavor }\n end\n end", "def cake_flavor_params\n params.require(:cake_flavor).permit(:flavor_name)\n end", "def create\n\t\t@flavor = Flavor.new(flavor_params)\n\t\t\n\t\t# matching corresponding color to selected category\n\t\tcolors = {\"Floral\": \"rgb(255, 92, 197)\", \"Citrus\": \"rgb(255, 168, 66)\", \"Apple / Pear\": \"rgb(66, 217, 13)\", \"Melon\": \"rgb(98, 255, 160)\", \"Grape\": \"rgb(119, 217, 67)\", \"Tropical Fruit\": \"rgb(255, 244, 0)\", \"Stone Fruit\": \"rgb(255, 124, 0)\", \"Berry\": \"rgb(208, 27, 232)\", \"Dried Fruit\": \"rgb(184, 83, 12)\", \"Chocolate\": \"rgb(97, 55, 3)\", \"Sweet and Sugary\": \"rgb(255, 254, 229)\", \"Nutty\": \"rgb(143, 82, 5)\", \"Grain / Cereal\": \"rgb(196, 126, 166)\", \"Roast\": \"rgb(76, 50, 0)\", \"Spice\": \"rgb(255, 0 , 33)\", \"Savory\": \"rgb(132, 21, 7)\", \"Earthy\": \"rgb(66, 36, 0)\", \"Vegetal\": \"rgb(43, 71, 0)\", \"Herbal\": \"rgb(21, 151, 20)\"}\n\n\t\t@flavor.color = colors[:\"#{params[:flavor][:category]}\"]\n\n\t\t# if other was selected, then replace note value\n\t\tif params[:flavor][:note] == \"Other\" && params[:flavor][:other].length > 2\n\t\t\t@flavor.note = params[:flavor][:other].chomp.capitalize\n\t\t# if other was selected but nothing valid was written, flash error\n\t\telsif params[:flavor][:note] == \"Other\" && params[:flavor][:other].length < 3\n\t\t\tflash[:error] = \"Please type a valid custom note when selecting 'Other'.\"\n\t\tend\n\n\t\t# makes sure all values are there before saving\n\t\tif @flavor.save\n\t\t\tredirect_to new_beanformed_company_bean_flavor_path(params[:company_id], params[:bean_id])\n\t\telse \n\t\t\tflash[:error] = \"Select all fields\"\n\t\tend\n\tend", "def flavors()\n return get_request(address(\"/flavors/detail\"), @token)\t\n end", "def flavor_params\n params.require(:flavor).permit(:name, :flavorImgURL)\n end", "def index\n @flavors = Flavor.all\n end", "def set_cake_flavor\n @cake_flavor = CakeFlavor.find(params[:id])\n end", "def set_cake_flavor\n @cake_flavor = CakeFlavor.find(params[:id])\n end", "def destroy\n @cake_flavor.destroy\n respond_to do |format|\n format.html { redirect_to cake_flavors_url, notice: 'Cake flavor was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def create\n @fact = @cat.facts.create!({ fact: api_request })\n if @fact.save\n render json: @fact\n else\n render error: { message: \"Não foi possível criar esse fato para este gatinho! :(\" }, status: 400\n end\n end", "def new\n @flavours = @provider.get_flavors\n puts \"getting the flavors #{@flavours.inspect}\"\n @images = @provider.get_images\n puts \"getting the flavors #{@images.inspect}\"\n @instance = @provider.instances.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @instance }\n end\n end", "def create\n @farm = Farm.new(farm_params)\n\n if @farm.save\n render :show, status: :created, location: api_farm_url(@farm)\n else\n render json: @farm.errors, status: :unprocessable_entity\n end\n end", "def flavor_params\n params.require(:flavor).permit(:name, :active)\n end", "def index\n @frosting_flavors = FrostingFlavor.all\n end", "def create\n if (session[:user_id] == nil) || (session[:role] == false)\n puts \"here is flavors new, but this person is not admin --> go to users path\"\n flash[:notice] = 'You are not allowed to this page. Only admin can manage flavors'\n redirect_to root_path\n end\n uploaded_io = params[:flavor][:flavorImgURL]\n orders_dir = Rails.root.join('public','flavorsUploads')\n Dir.mkdir(orders_dir) unless File.exists?(orders_dir) \n File.open(Rails.root.join('public', 'flavorsUploads', uploaded_io.original_filename), 'wb') do |file|\n file.write(uploaded_io.read)\n logger.debug uploaded_io.read\n end\n aux = {name: params[:flavor][:name],flavorImgURL: uploaded_io.original_filename};\n @flavor = Flavor.new(aux)\n respond_to do |format|\n if @flavor.save\n format.html { redirect_to @flavor, notice: 'Flavor was successfully created.' }\n format.json { render :show, status: :created, location: @flavor }\n else\n format.html { render :new }\n format.json { render json: @flavor.errors, status: :unprocessable_entity }\n end\n end\n end", "def frosting_flavor_params\n params.require(:frosting_flavor).permit(:frosting_name)\n end", "def create\n render json: Beverage.create!(beverage_post_params), status: :created\n end", "def set_flavor\n @flavor = Flavor.find(params[:id])\n end", "def set_flavor\n @flavor = Flavor.find(params[:id])\n end", "def update\n respond_to do |format|\n if @cake_flavor.update(cake_flavor_params)\n format.html { redirect_to @cake_flavor, notice: 'Cake flavor was successfully updated.' }\n format.json { render :show, status: :ok, location: @cake_flavor }\n else\n format.html { render :edit }\n format.json { render json: @cake_flavor.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @farm = Farm.new(params[:farm])\n\n respond_to do |format|\n if @farm.save\n format.html { redirect_to @farm, notice: 'Farm was successfully created.' }\n format.json { render json: @farm, status: :created, location: @farm }\n else\n format.html { render action: \"new\" }\n format.json { render json: @farm.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @farm = Farm.new(params[:farm])\n\n respond_to do |format|\n if @farm.save\n format.html { redirect_to @farm, notice: 'Farm was successfully created.' }\n format.json { render json: @farm, status: :created, location: @farm }\n else\n format.html { render action: \"new\" }\n format.json { render json: @farm.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @cake = Cake.new(params[:cake])\n\n respond_to do |format|\n if @cake.save\n format.html { redirect_to @cake, notice: 'Cake was successfully created.' }\n format.json { render json: @cake, status: :created, location: @cake }\n else\n format.html { render action: \"new\" }\n format.json { render json: @cake.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @cake_cake = CakeCake.new(cake_cake_params)\n\n respond_to do |format|\n if @cake_cake.save\n format.html { redirect_to @cake_cake, notice: 'Cake cake was successfully created.' }\n format.json { render :show, status: :created, location: @cake_cake }\n else\n format.html { render :new }\n format.json { render json: @cake_cake.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @farm = Farm.new(params[:farm])\n @farm.save\n respond_with(@farm)\n end", "def list_flavors()\n response = dbreq(\"GET\", dbmgmthost, \"#{dbmgmtpath}/flavors\", dbmgmtport, dbmgmtscheme)\n CloudDB::Exception.raise_exception(response) unless response.code.to_s.match(/^20.$/)\n flavors = CloudDB.symbolize_keys(JSON.parse(response.body)[\"flavors\"])\n return flavors\n end", "def create\n @cloud = Cloud.new(params[:cloud])\n\n respond_to do |format|\n if @cloud.save\n format.html { redirect_to @cloud, :notice => 'Cloud was successfully created.' }\n format.json { render :json => @cloud, :status => :created, :location => @cloud }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @cloud.errors, :status => :unprocessable_entity }\n end\n end\n end", "def flavium_params\n params.require(:flavium).permit(:flaviaUno, :flaviaDue)\n end", "def create\n @farm_field = FarmField.new(farm_field_params)\n\n if @farm_field.save\n render :show, status: :created, location: api_farm_field_url(@farm_field)\n else\n render json: @farm_field.errors, status: :unprocessable_entity\n end\n end", "def index\n @flavia = Flavium.all\n end", "def destroy\n @frosting_flavor.destroy\n respond_to do |format|\n format.html { redirect_to frosting_flavors_url, notice: 'Frosting flavor was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def index\n @flavor_groups = FlavorGroup.all\n end", "def list_flavors_detail()\n response = dbreq(\"GET\", dbmgmthost, \"#{dbmgmtpath}/flavors/detail\", dbmgmtport, dbmgmtscheme)\n CloudDB::Exception.raise_exception(response) unless response.code.to_s.match(/^20.$/)\n flavors = CloudDB.symbolize_keys(JSON.parse(response.body)[\"flavors\"])\n return flavors\n end", "def set_flavium\n @flavium = Flavium.find(params[:id])\n end", "def create\n @stuffing_cake = StuffingCake.new(stuffing_cake_params)\n\n respond_to do |format|\n if @stuffing_cake.save\n format.html { redirect_to @stuffing_cake, notice: 'Stuffing cake was successfully created.' }\n format.json { render :show, status: :created, location: @stuffing_cake }\n else\n format.html { render :new }\n format.json { render json: @stuffing_cake.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @flower = Flower.new(params[:flower])\n\n respond_to do |format|\n if @flower.save\n format.html { redirect_to @flower, notice: 'Flower was successfully created.' }\n format.json { render json: @flower, status: :created, location: @flower }\n else\n format.html { render action: \"new\" }\n format.json { render json: @flower.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n mix = BreedMix.new(mix_params)\n\n if mix.save\n render json: mix\n else\n render json: mix.errors, status: :unprocessable_entity\n end\n end", "def create\n @featuring = Featuring.new(featuring_params)\n\n respond_to do |format|\n if @featuring.save\n format.html { redirect_to @featuring, notice: 'Featuring was successfully created.' }\n format.json { render :show, status: :created, location: @featuring }\n else\n format.html { render :new }\n format.json { render json: @featuring.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @os_family = OsFamily.new(os_family_params)\n\n respond_to do |format|\n if @os_family.save\n format.html { redirect_to @os_family, notice: 'Os family was successfully created.' }\n format.json { render :show, status: :created, location: @os_family }\n else\n format.html { render :new }\n format.json { render json: @os_family.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @fish_type = FishType.new(params[:fish_type])\n\n respond_to do |format|\n if @fish_type.save\n format.html { redirect_to @fish_type, notice: 'Fish type was successfully created.' }\n format.json { render json: @fish_type, status: :created, location: @fish_type }\n else\n format.html { render action: \"new\" }\n format.json { render json: @fish_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @flavor.update(flavor_params)\n format.html { redirect_to @flavor, notice: 'Flavor was successfully updated.' }\n format.json { render :show, status: :ok, location: @flavor }\n else\n format.html { render :edit }\n format.json { render json: @flavor.errors, status: :unprocessable_entity }\n end\n end\n end", "def destroy\n compute.delete_flavor(params[:id])\n \n\n respond_to do |format|\n format.html { redirect_to flavors_path }\n format.json { head :ok }\n end\n end", "def show\n @flavor = compute.get_flavor(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @flavor }\n end\n end", "def set_frosting_flavor\n @frosting_flavor = FrostingFlavor.find(params[:id])\n end", "def update\n @flavor = Flavor.find(params[:id])\n\n respond_to do |format|\n if @flavor.update_attributes(params[:flavor])\n format.html { redirect_to @flavor, :notice => 'Flavor was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @flavor.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @brand_category = BrandCategory.new(brand_category_params)\n\n if @brand_category.save\n render json: @brand_category, status: :created, location: @brand_category\n else\n render json: @brand_category.errors, status: :unprocessable_entity\n end\n end", "def create\n @control_family = ControlFamily.new(params[:control_family])\n\n respond_to do |format|\n if @control_family.save\n format.html { redirect_to @control_family, :notice => 'Control family was successfully created.' }\n format.json { render :json => @control_family, :status => :created, :location => @control_family }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @control_family.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @variation = Variation.new(variation_params)\n\n respond_to do |format|\n if @variation.save\n format.html { redirect_to @variation, notice: \"Variation was successfully created.\" }\n format.json { render :show, status: :created, location: @variation }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @variation.errors, status: :unprocessable_entity }\n end\n end\nend", "def create\n @forest = Forest.new(params[:forest])\n\n respond_to do |format|\n if @forest.save\n format.html { redirect_to @forest, notice: 'Forest was successfully created.' }\n format.json { render json: @forest, status: :created, location: @forest }\n else\n format.html { render action: \"new\" }\n format.json { render json: @forest.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @flower = Flower.new(flower_params)\n\n respond_to do |format|\n if @flower.save\n format.html { redirect_to @flower, notice: 'Flower was successfully created.' }\n format.json { render :show, status: :created, location: @flower }\n else\n format.html { render :new }\n format.json { render json: @flower.errors, status: :unprocessable_entity }\n end\n end\n end", "def flavor\n if ENV[\"CHEF_API_FLAVOR\"]\n ENV[\"CHEF_API_FLAVOR\"].to_sym\n elsif config[\"CHEF_API_FLAVOR\"]\n config[\"CHEF_API_FLAVOR\"]\n else\n endpoint.include?(\"/organizations\") ? :enterprise : :open_source\n end\n end", "def create\n @stage = Stage.new(stage_params)\n\n if @stage.save\n render json: @stage, status: :created\n else\n render json: @stage.errors, status: :unprocessable_entity\n end\n end", "def create\n @brand = Brand.new(params[:brand])\n\n respond_to do |format|\n if @brand.save\n format.html { redirect_to @brand, notice: 'Brand was successfully created.' }\n format.json { render json: @brand, status: :created, location: @brand }\n else\n format.html { render action: \"new\", layout: \"editor\" }\n format.json { render json: @brand.errors, status: :unprocessable_entity }\n end\n end\n end", "def select_flavor\n compute.flavors.map { |f| [f.name, f.id] }\n end", "def create\n @variation = Variation.new(variation_params)\n\n respond_to do |format|\n if @variation.save\n format.html { redirect_to @variation, notice: 'Variação criada com sucesso.' }\n format.json { render :show, status: :created, location: @variation }\n else\n format.html { render :new }\n format.json { render json: @variation.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @elector = Elector.new(elector_params)\n\n if @elector.save\n render json: @elector, status: :created, location: @elector\n else\n render json: @elector.errors, status: :unprocessable_entity\n end\n end", "def flavor_group_params\n params.require(:flavor_group).permit(:name, :mnemonic, {flavor_ids: []}, :poster)\n end", "def create\n @choice = Choice.new(choice_params)\n\n if @choice.save\n render json: @choice, status: :created, location: @choice\n else\n render json: @choice.errors, status: :unprocessable_entity\n end\n end", "def create\n @farming = Farming.new(farming_params)\n\n respond_to do |format|\n if @farming.save\n format.html { redirect_to @farming, notice: 'Farming was successfully created.' }\n format.json { render :show, status: :created, location: @farming }\n else\n format.html { render :new }\n format.json { render json: @farming.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @forest = Forest.new(forest_params)\n\n respond_to do |format|\n if @forest.save\n format.html { redirect_to @forest, notice: 'Forest was successfully created.' }\n format.json { render action: 'show', status: :created, location: @forest }\n else\n format.html { render action: 'new' }\n format.json { render json: @forest.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @fabric = Fabric.new(params[:fabric])\n\n respond_to do |format|\n if @fabric.save\n format.html { redirect_to @fabric, notice: 'Fabric was successfully created.' }\n format.json { render json: @fabric, status: :created, location: @fabric }\n else\n format.html { render action: \"new\" }\n format.json { render json: @fabric.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @store_flavors = StoreFlavor.all\n end", "def create\n @fruit = Fruit.new(fruit_params)\n\n respond_to do |format|\n if @fruit.save\n format.html { redirect_to @fruit, notice: 'Fruit was successfully created.' }\n format.json { render :show, status: :created, location: @fruit }\n else\n format.html { render :new }\n format.json { render json: @fruit.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @banana = Banana.new(params[:banana])\n\n respond_to do |format|\n if @banana.save\n format.html { redirect_to @banana, :notice => 'Banana was successfully created.' }\n format.json { render :json => @banana, :status => :created, :location => @banana }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @banana.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @fabrica = Fabrica.new(fabrica_params)\n\n respond_to do |format|\n if @fabrica.save\n format.html { redirect_to @fabrica, notice: 'Fabrica was successfully created.' }\n format.json { render action: 'show', status: :created, location: @fabrica }\n else\n format.html { render action: 'new' }\n format.json { render json: @fabrica.errors, status: :unprocessable_entity }\n end\n end\n end", "def add_aos_version_box(args = {}) \n post(\"/aosversions.json/aosversionbox\", args)\nend", "def create\n @farm = Farm.new(farm_params)\n\n respond_to do |format|\n if @farm.save\n format.html { redirect_to @farm, notice: '農家登録が完了しました。' }\n format.json { render :show, status: :created, location: @farm }\n else\n format.html { render :new }\n format.json { render json: @farm.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @hero = Hero.new(hero_params)\n\n if @hero.save\n render json: @hero, status: :created, location: @hero\n else\n render json: @hero.errors, status: :unprocessable_entity\n end\n end", "def create\n @brand = Brand.new(params[:brand])\n\n respond_to do |format|\n if @brand.save\n format.html { redirect_to brands_path, notice: 'Brand was successfully created.' }\n format.json { render json: @brand, status: :created, location: @brand }\n else\n format.html { render action: \"new\" }\n format.json { render json: @brand.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @frosting_flavor.update(frosting_flavor_params)\n format.html { redirect_to @frosting_flavor, notice: 'Frosting flavor was successfully updated.' }\n format.json { render :show, status: :ok, location: @frosting_flavor }\n else\n format.html { render :edit }\n format.json { render json: @frosting_flavor.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n\t\trespond_with Species.create(species_params)\n\tend", "def create\n @food = @fridge.foods.create(food_params)\n respond_with @food, location: -> { kitchen_board_path }\n end", "def create\n redirect_to root_url\n\n # @fluke = Fluke.new(fluke_params)\n\n # respond_to do |format|\n # if @fluke.save\n # format.html { redirect_to @fluke, notice: 'Fluke was successfully created.' }\n # format.json { render :show, status: :created, location: @fluke }\n # else\n # format.html { render :new }\n # format.json { render json: @fluke.errors, status: :unprocessable_entity }\n # end\n # end\n end", "def flavor\n fetch('dessert.flavor')\n end", "def new\n @farm = Farm.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @farm }\n end\n end", "def create\n @appliance_type = ApplianceType.new(params[:appliance_type])\n\n respond_to do |format|\n if @appliance_type.save\n format.html { redirect_to @appliance_type, notice: 'Appliance type was successfully created.' }\n format.json { render json: @appliance_type, status: :created, location: @appliance_type }\n else\n format.html { render action: \"new\" }\n format.json { render json: @appliance_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @favorite = Favorite.new(favorite_params)\n if @favorite.save\n render json: FavoriteSerializer.new(@favorite), status: :created\n else\n render json: @favorite.errors.full_messages.to_sentence, status: :unprocessable_entity\n end\n end", "def create\r\n @brand = Brand.new(params[:brand])\r\n\r\n respond_to do |format|\r\n if @brand.save\r\n format.html { redirect_to administration_brands_url, notice: 'Brand was successfully created.' }\r\n format.json { render json: @brand, status: :created, location: @brand }\r\n else\r\n format.html { render action: \"new\" }\r\n format.json { render json: @brand.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end", "def create\n @brand = Brand.new(brand_params)\n\n respond_to do |format|\n if @brand.save\n format.html { redirect_to cp_brand_url(@brand), notice: 'Бренд создан.' }\n format.json { render :show, status: :created, location: @brand }\n else\n format.html { render :new }\n format.json { render json: @brand.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_jobfamily\n @jobfamily = @company.jobfamilies.create(name: params[:jobfamily][:name])\n respond_to do |format|\n format.json { render json: @jobfamily }\n end\n end", "def create\n @favo = Favo.new(favo_params)\n\n respond_to do |format|\n if @favo.save\n format.html { redirect_to @favo, notice: 'Favo was successfully created.' }\n format.json { render :show, status: :created, location: @favo }\n else\n format.html { render :new }\n format.json { render json: @favo.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @fav = Fav.new(params[:fav])\n\n respond_to do |format|\n if @fav.save\n format.html { redirect_to @fav, notice: 'Fav was successfully created.' }\n format.json { render json: @fav, status: :created, location: @fav }\n else\n format.html { render action: \"new\" }\n format.json { render json: @fav.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @species = Species.new(species_params)\n\n respond_to do |format|\n if @species.save\n format.html { redirect_to @species, notice: 'Species was successfully created.' }\n format.json { render :show, status: :created, location: @species }\n else\n format.html { render :new }\n format.json { render json: @species.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n respond_to do |format|\n require 'rest-client'\n response = RestClient.post('localhost:3001/colores/', color_params.as_json, {:Authorization => 'admin irizREhyoG6Ejwr4AcjsQME9'})\n if response.code == 200\n @color = JSON.parse(response.body)\n format.html { redirect_to @color, notice: \"Color was successfully created.\" }\n format.json { render :show, status: :created, location: @color }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @color.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @background_option = BackgroundOption.new(background_option_params)\n\n respond_to do |format|\n if @background_option.save\n format.html { redirect_to background_options_url, notice: 'Background option was successfully created.' }\n format.json { render :show, status: :created, location: @background_option }\n else\n format.html { render :new }\n format.json { render json: background_options_url.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @cake = Cake.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @cake }\n end\n end", "def create\n @fridge = Fridge.new(params[:fridge])\n\n respond_to do |format|\n if @fridge.save\n format.html { redirect_to @fridge, notice: 'Fridge was successfully created.' }\n format.json { render json: @fridge, status: :created, location: @fridge }\n else\n format.html { render action: \"new\" }\n format.json { render json: @fridge.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @farm = Farm.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @farm }\n end\n end", "def create\n plant = Plant.create(plant_params)\n render json: plant, status: :created\n end", "def create\n @appliance_manufacturer = ApplianceManufacturer.new(params[:appliance_manufacturer])\n\n respond_to do |format|\n if @appliance_manufacturer.save\n format.html { redirect_to @appliance_manufacturer, notice: 'Appliance manufacturer was successfully created.' }\n format.json { render json: @appliance_manufacturer, status: :created, location: @appliance_manufacturer }\n else\n format.html { render action: \"new\" }\n format.json { render json: @appliance_manufacturer.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @variety = Variety.new(variety_params)\n\n respond_to do |format|\n if @variety.save\n format.html { redirect_to admin_varieties_path, notice: 'La variedad fue creada' }\n format.json { render :show, status: :created, location: @variety }\n format.js{}\n else\n format.html { render :new }\n format.js{}\n format.json { render json: @variety.errors, status: :unprocessable_entity }\n end\n end\n end", "def add_aos_version(args = {}) \n post(\"/aosversions.json/\", args)\nend" ]
[ "0.716318", "0.70878196", "0.6626092", "0.6584757", "0.65699923", "0.65650886", "0.6531805", "0.6441508", "0.6396541", "0.6383742", "0.629688", "0.61868054", "0.60363275", "0.6026922", "0.6013406", "0.6013406", "0.5935032", "0.5909869", "0.5831824", "0.58270085", "0.5799477", "0.57192236", "0.57189554", "0.5668326", "0.5667798", "0.5634975", "0.5634975", "0.56340146", "0.5633307", "0.5633307", "0.561166", "0.5546674", "0.55345064", "0.5501235", "0.5476464", "0.5464531", "0.543819", "0.54308194", "0.5415262", "0.5402577", "0.53921884", "0.53895086", "0.53868145", "0.5377013", "0.5361788", "0.53585964", "0.532365", "0.5323222", "0.53174907", "0.5310245", "0.53014344", "0.5297439", "0.5296336", "0.529289", "0.52908766", "0.5277081", "0.5269071", "0.5261009", "0.525742", "0.52484304", "0.52456915", "0.52421194", "0.5236951", "0.5235557", "0.5235349", "0.5219333", "0.5218835", "0.52179056", "0.5217354", "0.5216474", "0.5208498", "0.5205454", "0.5196561", "0.5195182", "0.517695", "0.5175459", "0.5174024", "0.5169976", "0.51658434", "0.5160771", "0.5156018", "0.5155958", "0.51544446", "0.51401496", "0.5133319", "0.5132349", "0.51301545", "0.51290977", "0.5124777", "0.5124652", "0.5122028", "0.51199925", "0.5118123", "0.5094157", "0.50938123", "0.5091445", "0.5087456", "0.50679404", "0.5065267", "0.50572354" ]
0.7437367
0
PATCH/PUT /cake_flavors/1 PATCH/PUT /cake_flavors/1.json
def update respond_to do |format| if @cake_flavor.update(cake_flavor_params) format.html { redirect_to @cake_flavor, notice: 'Cake flavor was successfully updated.' } format.json { render :show, status: :ok, location: @cake_flavor } else format.html { render :edit } format.json { render json: @cake_flavor.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @flavor = Flavor.find(params[:id])\n\n respond_to do |format|\n if @flavor.update_attributes(params[:flavor])\n format.html { redirect_to @flavor, :notice => 'Flavor was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @flavor.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @flavor.update(flavor_params)\n format.html { redirect_to @flavor, notice: 'Flavor was successfully updated.' }\n format.json { render :show, status: :ok, location: @flavor }\n else\n format.html { render :edit }\n format.json { render json: @flavor.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @frosting_flavor.update(frosting_flavor_params)\n format.html { redirect_to @frosting_flavor, notice: 'Frosting flavor was successfully updated.' }\n format.json { render :show, status: :ok, location: @frosting_flavor }\n else\n format.html { render :edit }\n format.json { render json: @frosting_flavor.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @store_flavor.update(store_flavor_params)\n format.html { redirect_to @store_flavor, notice: 'Store flavor was successfully updated.' }\n format.json { render :show, status: :ok, location: @store_flavor }\n else\n format.html { render :edit }\n format.json { render json: @store_flavor.errors, status: :unprocessable_entity }\n end\n end\n end", "def add_to_cake\n @cake = Cake.find(params[:cake_id])\n @cake.cake_flavors << @cake_flavor\n\n render json: @cake, include: :cake_flavors\n end", "def update\n respond_to do |format|\n if @flavium.update(flavium_params)\n format.html { redirect_to @flavium, notice: 'Flavium was successfully updated.' }\n format.json { render :show, status: :ok, location: @flavium }\n else\n format.html { render :edit }\n format.json { render json: @flavium.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_cake_flavor\n @cake_flavor = CakeFlavor.find(params[:id])\n end", "def set_cake_flavor\n @cake_flavor = CakeFlavor.find(params[:id])\n end", "def update\n respond_to do |format|\n if @flavor_group.update(flavor_group_params)\n format.html { redirect_to @flavor_group, notice: 'Flavor group was successfully updated.' }\n format.json { render :show, status: :ok, location: @flavor_group }\n else\n format.html { render :edit }\n format.json { render json: @flavor_group.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @fabric = Fabric.find(params[:id])\n\n respond_to do |format|\n if @fabric.update_attributes(params[:fabric])\n format.html { redirect_to @fabric, notice: 'Fabric was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @fabric.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @cake_cake.update(cake_cake_params)\n format.html { redirect_to @cake_cake, notice: 'Cake cake was successfully updated.' }\n format.json { render :show, status: :ok, location: @cake_cake }\n else\n format.html { render :edit }\n format.json { render json: @cake_cake.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @cake = Cake.find(params[:id])\n\n respond_to do |format|\n if @cake.update_attributes(params[:cake])\n format.html { redirect_to @cake, notice: 'Cake was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @cake.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @stuffing_cake.update(stuffing_cake_params)\n format.html { redirect_to @stuffing_cake, notice: 'Stuffing cake was successfully updated.' }\n format.json { render :show, status: :ok, location: @stuffing_cake }\n else\n format.html { render :edit }\n format.json { render json: @stuffing_cake.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @cake.update(cake_params)\n format.html { redirect_to @cake, notice: 'Cake was successfully updated.' }\n format.json { render :show, status: :ok, location: @cake }\n else\n format.html { render :edit }\n format.json { render json: @cake.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if (session[:user_id] == nil) || (session[:role] == false)\n puts \"here is flavors new, but this person is not admin --> go to users path\"\n flash[:notice] = 'You are not allowed to this page. Only admin can manage flavors'\n redirect_to root_path\n end\n aux = {name: params[:flavor][:name]}\n uploaded_io = params[:flavor][:flavorImgURL]\n logger.debug(\"uploaded_io type\")\n if(uploaded_io)\n File.open(Rails.root.join('public', 'flavorsUploads', uploaded_io.original_filename), 'wb') do |file|\n file.write(uploaded_io.read)\n end\n aux[:flavorImgURL]= uploaded_io.original_filename;\n end\n respond_to do |format|\n if @flavor.update(aux)\n format.html { redirect_to @flavor, notice: 'Flavor was successfully updated.' }\n format.json { render :show, status: :ok, location: @flavor }\n else\n format.html { render :edit }\n format.json { render json: @flavor.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @fucker = Fucker.find(params[:id])\n\n respond_to do |format|\n if @fucker.update_attributes(params[:fucker])\n format.json { head :no_content }\n else\n format.json { render json: @fucker.errors, status: :internal_server_error }\n end\n end\n end", "def set_flavor\n @flavor = Flavor.find(params[:id])\n end", "def set_flavor\n @flavor = Flavor.find(params[:id])\n end", "def update\n @farm = Farm.find(params[:id])\n\n respond_to do |format|\n if @farm.update_attributes(params[:farm])\n format.html { redirect_to @farm, notice: 'Farm was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @farm.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @farm = Farm.find(params[:id])\n\n respond_to do |format|\n if @farm.update_attributes(params[:farm])\n format.html { redirect_to @farm, notice: 'Farm was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @farm.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @farm = Farm.find(params[:id])\n\n respond_to do |format|\n if @farm.update_attributes(params[:farm])\n format.html { redirect_to @farm, notice: 'Farm was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @farm.errors, status: :unprocessable_entity }\n end\n end\n end", "def update(url, data)\n RestClient.put url, data, :content_type => :json\nend", "def update\n if @farm.update(farm_params)\n render :show, status: :ok, location: api_farm_url(@farm)\n else\n render json: @farm.errors, status: :unprocessable_entity\n end\n end", "def update\n respond_to do |format|\n if @coffeeshop.update(coffeeshop_params)\n format.html { redirect_to @coffeeshop, notice: 'Coffeeshop was successfully updated.' }\n format.json { render :show, status: :ok, location: @coffeeshop }\n else\n format.html { render :edit }\n format.json { render json: @coffeeshop.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @chef.update(chef_params)\n format.html { redirect_to [:admin, @chef], notice: t('messages.updated', model:Chef.model_name.human) }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @chef.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_frosting_flavor\n @frosting_flavor = FrostingFlavor.find(params[:id])\n end", "def put!\n request! :put\n end", "def update\n respond_to do |format|\n if @os_family.update(os_family_params)\n format.html { redirect_to @os_family, notice: 'Os family was successfully updated.' }\n format.json { render :show, status: :ok, location: @os_family }\n else\n format.html { render :edit }\n format.json { render json: @os_family.errors, status: :unprocessable_entity }\n end\n end\n end", "def api_patch(path, data = {})\n api_request(:patch, path, :data => data)\n end", "def update\n @flower = Flower.find(params[:id])\n\n respond_to do |format|\n if @flower.update_attributes(params[:flower])\n format.html { redirect_to @flower, notice: 'Flower was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @flower.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @cake_flavor = CakeFlavor.new(cake_flavor_params)\n\n respond_to do |format|\n if @cake_flavor.save\n format.html { redirect_to @cake_flavor, notice: 'Cake flavor was successfully created.' }\n format.json { render :show, status: :created, location: @cake_flavor }\n else\n format.html { render :new }\n format.json { render json: @cake_flavor.errors, status: :unprocessable_entity }\n end\n end\n end", "def patch\n headers = {\"If-Match\" => @version}\n response = @context.request :patch, \"#{@path}/#{@id}\", @data.to_json, headers\n @version += 1\n response\n # 'X-HTTP-Method-Override' => 'PATCH'\n end", "def update\n @favorite_bundle = FavoriteBundle.find(params[:id])\n\n respond_to do |format|\n if @favorite_bundle.update_attributes(params[:favorite_bundle])\n format.html { redirect_to @favorite_bundle, notice: 'Favorite bundle was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @favorite_bundle.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n require 'rest-client'\n response = RestClient.put('localhost:3001/colores/'+@color.id.to_s, color_params.as_json, {:Authorization => 'admin irizREhyoG6Ejwr4AcjsQME9'})\n if response.code == 200\n @color = JSON.parse(response.body)\n\n format.html { redirect_to @color, notice: \"Color was successfully updated.\" }\n format.json { render :show, status: :ok, location: @color }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @color.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n params[:family][:name] = params[:family][:name].split(\" \").map{|a| a.capitalize}.join(\" \")\n if @family.update(family_params)\n format.json { render :show, status: :ok, location: @family }\n format.html { redirect_to @family, notice: 'Family was successfully updated.' }\n else\n format.json { render json: @family.errors, status: :unprocessable_entity }\n format.html { render :edit }\n end\n end\n end", "def cake_flavor_params\n params.require(:cake_flavor).permit(:flavor_name)\n end", "def destroy\n @cake_flavor.destroy\n respond_to do |format|\n format.html { redirect_to cake_flavors_url, notice: 'Cake flavor was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def update\n respond_to do |format|\n @family.slug=nil\n if @family.update(family_params)\n format.html { redirect_to @family, notice: 'La familia fue actualizada exitosamente.' }\n format.json { render :show, status: :ok, location: @family }\n else\n format.html { render :edit }\n format.json { render json: @family.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @family.update(family_params)\n format.html { redirect_to @family, notice: 'Family was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @family.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @fridge = Fridge.find(params[:id])\n\n respond_to do |format|\n if @fridge.update_attributes(params[:fridge])\n format.html { redirect_to @fridge, notice: 'Fridge was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @fridge.errors, status: :unprocessable_entity }\n end\n end\n end", "def patch!\n request! :patch\n end", "def update\n respond_to do |format|\n if @cloud.update(cloud_params)\n format.html { redirect_to @cloud, notice: 'Cloud was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @cloud.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_tenant_circle(args = {}) \n put(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend", "def update_aos_version(args = {}) \n id = args['id']\n temp_path = \"/aosversions.json/{aosVersionId}\"\n path = temp_path\nargs.keys.each do |key|\n if (key == \"aosversionId\")\n args.delete(key)\n path = temp_path.gsub(\"{#{key}}\", id)\n end\nend\n puts \" PATH : #{path}\"\n put(path, args)\nend", "def 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 options={}\n client.put(\"/#{id}\", options)\n end", "def update\n @spoofer = Spoofer.find(params[:id])\n\n respond_to do |format|\n if @spoofer.update_attributes(params[:spoofer])\n format.html { redirect_to @spoofer, notice: 'Spoofer was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @spoofer.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @cloud = Cloud.find(params[:id])\n\n respond_to do |format|\n if @cloud.update_attributes(params[:cloud])\n format.html { redirect_to @cloud, :notice => 'Cloud was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @cloud.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update_plant\n @plant.deleted = false\n\n respond_to do |format|\n if set_attributes_from_filemaker(@plant)\n format.json do\n render status: :created,\n json: {\n id: @plant.id,\n botanical_name: @plant.botanical_name,\n alternative_names: @plant.alternative_names,\n updated_at: @plant.updated_at,\n visible: (!@plant.deleted).to_s\n }\n end\n else\n format.json do\n render json: @plant.errors, status: :unprocessable_entity\n end\n end\n end\n end", "def update\n @bundle = Bundle.find(params[:id])\n\n\n respond_to do |format|\n params[:bundle][:category] = params[:bundle][:category].strip.downcase\n params[:bundle][:style] = params[:bundle][:style].strip.downcase\n params[:bundle][:color] = params[:bundle][:color].strip.downcase\n params[:bundle][:brand] = params[:bundle][:brand].strip.downcase\n params[:bundle][:make] = params[:bundle][:make].strip.downcase\n params[:bundle][:location] = params[:bundle][:location].strip.downcase\n\n if @bundle.update_attributes(params[:bundle])\n format.html { redirect_to @bundle, notice: 'Bundle was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @bundle.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @fact.update(fact_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: @fact.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @featuring.update(featuring_params)\n format.html { redirect_to @featuring, notice: 'Featuring was successfully updated.' }\n format.json { render :show, status: :ok, location: @featuring }\n else\n format.html { render :edit }\n format.json { render json: @featuring.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @fabrica.update(fabrica_params)\n format.html { redirect_to @fabrica, notice: 'Fabrica was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @fabrica.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @background_option.update(background_option_params)\n format.html { redirect_to background_options_url, notice: 'Background option was successfully updated.' }\n format.json { render :show, status: :ok, location: @background_option }\n else\n format.html { render :edit }\n format.json { render json: background_options_url.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @fred = Fred.find(params[:id])\n\n respond_to do |format|\n if @fred.update_attributes(params[:fred])\n format.html { redirect_to @fred, notice: 'Fred was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @fred.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n ingredient.update(ingredient_params)\n render json: ingredient\n end", "def update\n respond_to do |format|\n if @cookbook.update(cookbook_params)\n format.html { redirect_to cookbook_path(@cookbook), notice: 'Cookbook was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @cookbook.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @fish_type = FishType.find(params[:id])\n\n respond_to do |format|\n if @fish_type.update_attributes(params[:fish_type])\n format.html { redirect_to @fish_type, notice: 'Fish type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @fish_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @patch.update(patch_params)\n format.html { redirect_to @patch, notice: 'Patch was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @patch.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @fruit.update(fruit_params)\n format.html { redirect_to @fruit, notice: 'Fruit was successfully updated.' }\n format.json { render :show, status: :ok, location: @fruit }\n else\n format.html { render :edit }\n format.json { render json: @fruit.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @belief = Belief.find(params[:id])\n\n respond_to do |format|\n if @belief.update_attributes(params[:belief])\n format.html { redirect_to @belief, :notice => 'Belief was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @belief.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @on_stage.update(on_stage_params)\n format.html { redirect_to @on_stage.french_scene, notice: 'Appearance was successfully updated.' }\n format.json { respond_with_bip(@on_stage) }\n else\n format.html { render :edit }\n format.json { respond_with_bip(@on_stage) }\n end\n end\n end", "def update # PATCH\n raise NotImplementedError\n end", "def update\n respond_to do |format|\n if @flower.update(flower_params)\n format.html { redirect_to @flower, notice: 'Flower was successfully updated.' }\n format.json { render :show, status: :ok, location: @flower }\n else\n format.html { render :edit }\n format.json { render json: @flower.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @flower.update(flower_params)\n format.html { redirect_to @flower, notice: 'Flower was successfully updated.' }\n format.json { render :show, status: :ok, location: @flower }\n else\n format.html { render :edit }\n format.json { render json: @flower.errors, status: :unprocessable_entity }\n end\n end\n end", "def update!(params)\n res = @client.put(path, nil, params, \"Content-Type\" => \"application/json\")\n @attributes = res.json if res.status == 201\n res\n end", "def update\n @patch = Patch.find(params[:id])\n\n respond_to do |format|\n if @patch.update_attributes(params[:patch])\n format.html { redirect_to @patch, notice: 'Patch was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @patch.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @banana = Banana.find(params[:id])\n\n respond_to do |format|\n if @banana.update_attributes(params[:banana])\n format.html { redirect_to @banana, :notice => 'Banana was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @banana.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n recipe.update(recipe_params)\n render json: recipe\n end", "def update\n @control_family = ControlFamily.find(params[:id])\n\n respond_to do |format|\n if @control_family.update_attributes(params[:control_family])\n format.html { redirect_to @control_family, :notice => 'Control family was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @control_family.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\n respond_to do |format|\n if @favoritepizza.update(favoritepizza_params)\n format.html { redirect_to @favoritepizza, notice: 'Favoritepizza was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @favoritepizza.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @glass = Glass.find(params[:id])\n\n respond_to do |format|\n if @glass.update_attributes(params[:glass])\n format.html { redirect_to @glass, notice: 'Glass was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @glass.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @admin_features_brand.update(admin_features_brand_params)\n format.html { redirect_to @admin_features_brand, notice: 'Features brand was successfully updated.' }\n format.json { render :show, status: :ok, location: @admin_features_brand }\n else\n format.html { render :edit }\n format.json { render json: @admin_features_brand.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @moose = Moose.find(params[:id])\n\n respond_to do |format|\n if @moose.update_attributes(params[:moose])\n format.html { redirect_to @moose, notice: 'Moose was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @moose.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n keystone.update_tenant({:id=>params[:id],:name=>params[:name],:description=>params[:description],:enabled=>params[:enabled]})\n respond_to do |format|\n format.html { redirect_to tenants_path, :notice => 'Tenant was successfully updated.' }\n format.json { head :ok }\n end\n end", "def update\n @kickoff = Kickoff.find(params[:id])\n\n respond_to do |format|\n if @kickoff.update_attributes(params[:kickoff])\n format.html { redirect_to @kickoff, notice: 'Kickoff was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @kickoff.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @appliance_type = ApplianceType.find(params[:id])\n\n respond_to do |format|\n if @appliance_type.update_attributes(params[:appliance_type])\n format.html { redirect_to @appliance_type, notice: 'Appliance type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @appliance_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_features(client_id)\n response = self.class.put(\"https://app.klipfolio.com/api/1.0/clients/#{client_id}/features\", basic_auth: @auth, headers: { \"Content-Type\" => \"application/json\" },\n body: {\n features:[{\"name\":\"public_dashboards\",\"enabled\":true},\n {\"name\":\"published_dashboards\",\"enabled\":true},\n {\"name\":\"downloadable_reports\",\"enabled\":true},\n {\"name\":\"scheduled_emails\",\"enabled\":true}]\n }.to_json)\n puts response.body\n puts \"Client's features were updated.\" if response.success?\n end", "def update\n @species = Species.find(params[:id])\n @species.update_attributes(params[:species])\n \n respond_with(@species, :location => admin_species_path(@species))\n end", "def update\n respond_to do |format|\n if @fish.update(fish_params)\n format.html { redirect_to @fish, notice: 'Fish was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @fish.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @data = @recipe.update(params[:id], recipe_params)\n render json: @data\n end", "def update\n\t respond_to do |format|\n\t\t if @convention.update(convention_params)\n\t\t\t format.html { redirect_to @convention, notice: 'Convention was successfully updated.' }\n\t\t\t format.json { head :no_content }\n\t\t else\n\t\t\t format.html { render action: 'edit' }\n\t\t\t format.json { render json: @convention.errors, status: :unprocessable_entity }\n\t\t end\n\t end\n end", "def index\n @cake_flavors = CakeFlavor.all\n end", "def update\n @box = Box.find(params[:id])\n\n respond_to do |format|\n if @box.update_attributes(params[:box])\n format.html { redirect_to @box, notice: 'Box was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @box.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @blueprint.update(blueprint_params)\n format.html { redirect_to @blueprint, notice: 'Blueprint was successfully updated.' }\n format.json { render :show, status: :ok, location: @blueprint }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @blueprint.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @stuff = Stuff.find(params[:id])\n\n respond_to do |format|\n if @stuff.update_attributes(params[:stuff])\n format.html { redirect_to @stuff, :notice => 'Stuff was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @stuff.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @api_version = ApiVersion.find(params[:id])\n\n respond_to do |format|\n if @api_version.update_attributes(params[:api_version])\n format.html { redirect_to admin_api_versions_path, flash: {success: t('app.msgs.success_updated', :obj => t('mongoid.models.api_version.one'))} }\n format.json { head :no_content }\n else\n set_tabbed_translation_form_settings('advanced')\n format.html { render action: \"edit\" }\n format.json { render json: @api_version.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n put :update\n end", "def update\n @boxtype = Boxtype.find(params[:id])\n\n respond_to do |format|\n if @boxtype.update_attributes(params[:boxtype])\n format.html { redirect_to @boxtype, notice: 'Boxtype was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @boxtype.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @animal = Animal.find(params[:id])\n @species = ['Lion', 'Koala', 'Panda']\n @zoo = Zoo.find(params[:zoo_id])\n\n respond_to do |format|\n\n if @animal.update_attributes(params[:animal])\n format.html { redirect_to zoo_animal_path(params[:zoo_id],@animal.id),\n notice: 'animal was successfully updated.' }\n format.json { head :no_content }\n else\n\n format.html { render action: \"edit\"}\n format.json { render json: @animal.errors,\n status: :unprocessable_entity }\n end\n end\n end", "def patch\n end", "def update\n @food = Food.find(params[:id])\n\n respond_to do |format|\n if @food.update_attributes(params[:food])\n format.html { redirect_to foods_path(), notice: 'Food was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @food.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @foam = Foam.find(params[:id])\n\n respond_to do |format|\n if @foam.update_attributes(params[:foam])\n format.html { redirect_to @foam, notice: 'Foam was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @foam.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @fact.update(fact_params)\n format.html { redirect_to @fact, notice: 'Fact was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @fact.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @farm = Farm.find(params[:id])\n\n respond_to do |format|\n if @farm.update_attributes(params[:farm])\n format.html { redirect_to(\"/farmview\", :notice => 'Farm was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @farm.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @jogo.update(jogo_params)\n format.html { redirect_to @jogo, notice: 'Jogo was successfully updated.' }\n format.json { render :show, status: :ok, location: @jogo }\n else\n format.html { render :edit }\n format.json { render json: @jogo.errors, status: :unprocessable_entity }\n end\n end\n end", "def patch(path, data)\n request 'PATCH', path, body: data.to_json\n end" ]
[ "0.6868971", "0.67433983", "0.65769887", "0.6314366", "0.6303884", "0.61911196", "0.6128536", "0.6128536", "0.60558414", "0.5978746", "0.5922216", "0.58937526", "0.5844243", "0.58376735", "0.5712817", "0.5701882", "0.5693686", "0.5693686", "0.5690351", "0.5690351", "0.5690351", "0.5628537", "0.56268454", "0.560725", "0.5602574", "0.55959344", "0.5595721", "0.55865526", "0.55731595", "0.55634165", "0.55583394", "0.55521595", "0.5527129", "0.5518444", "0.5512317", "0.5501775", "0.5499826", "0.54822683", "0.54820925", "0.54732513", "0.5471034", "0.5463607", "0.54606086", "0.54525495", "0.5449166", "0.5449166", "0.5448934", "0.5448249", "0.5441138", "0.5440222", "0.54399747", "0.5437721", "0.54320383", "0.54303247", "0.54226315", "0.54225224", "0.54196215", "0.5417772", "0.5417407", "0.54171604", "0.540285", "0.5397359", "0.539055", "0.53862727", "0.5382026", "0.5382026", "0.5374314", "0.537237", "0.53700477", "0.53687793", "0.5365336", "0.5364635", "0.5364635", "0.5358467", "0.5357986", "0.535713", "0.5353787", "0.53531796", "0.53500545", "0.5347361", "0.5346828", "0.5346823", "0.5346628", "0.5342487", "0.53354543", "0.53310376", "0.53299665", "0.5327416", "0.5313023", "0.5312056", "0.5310916", "0.5308095", "0.530668", "0.53043634", "0.52972513", "0.52972186", "0.5296103", "0.52940255", "0.52923435", "0.5292212" ]
0.7133959
0
DELETE /cake_flavors/1 DELETE /cake_flavors/1.json
def destroy @cake_flavor.destroy respond_to do |format| format.html { redirect_to cake_flavors_url, notice: 'Cake flavor was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n compute.delete_flavor(params[:id])\n \n\n respond_to do |format|\n format.html { redirect_to flavors_path }\n format.json { head :ok }\n end\n end", "def destroy\n @frosting_flavor.destroy\n respond_to do |format|\n format.html { redirect_to frosting_flavors_url, notice: 'Frosting flavor was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @cake = Cake.find(params[:id])\n @cake.destroy\n\n respond_to do |format|\n format.html { redirect_to cakes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @store_flavor.destroy\n respond_to do |format|\n format.html { redirect_to store_flavors_url, notice: 'Store flavor was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @cake_cake.destroy\n respond_to do |format|\n format.html { redirect_to cake_cakes_url, notice: 'Cake cake was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @flavium.destroy\n respond_to do |format|\n format.html { redirect_to flavia_url, notice: 'Flavium was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @fabric = Fabric.find(params[:id])\n @fabric.destroy\n\n respond_to do |format|\n format.html { redirect_to fabrics_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @cake.destroy\n respond_to do |format|\n format.html { redirect_to cakes_url, notice: 'Cake was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete_aos_version(args = {}) \n delete(\"/aosversions.json/#{args[:aosVersionId]}\", args)\nend", "def destroy\n @stuffing_cake.destroy\n respond_to do |format|\n format.html { redirect_to stuffing_cakes_url, notice: 'Stuffing cake was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @flavor_group.destroy\n respond_to do |format|\n format.html { redirect_to flavor_groups_url, notice: 'Flavor group was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @fabrica.destroy\n respond_to do |format|\n format.html { redirect_to fabricas_url }\n format.json { head :no_content }\n end\n end", "def destroy\n if session[:role] ||session[:role] == False then\n redirect_to root_path()\n end\n @flavor.destroy\n respond_to do |format|\n format.html { redirect_to flavors_url, notice: 'Flavor was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @ruby.destroy\n respond_to do |format|\n format.html { redirect_to rubies_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @cloud.delete\n respond_to do |format|\n format.html { redirect_to clouds_url }\n format.json { head :no_content }\n end\n end", "def delete(id:)\n id_check(:id, id)\n\n cf_delete(path: \"/organizations/#{org_id}/railguns/#{id}\")\n end", "def destroy\n @appliance.destroy\n respond_to do |format|\n format.html { redirect_to user_appliances_url, notice: 'Appliance was successfully destroyed.' }\n format.json { head :no_content }\n end\n=======\nend", "def destroy\n @bg_setup = BgSetup.find(params[:id])\n @bg_setup.destroy\n\n respond_to do |format|\n format.html { redirect_to bg_setups_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @banana = Banana.find(params[:id])\n @banana.destroy\n\n respond_to do |format|\n format.html { redirect_to bananas_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @variant.destroy\n respond_to do |format|\n format.html { redirect_to edit_admin_good_url(@variant.good, anchor: \"variants\") }\n format.json { head :no_content }\n end\n end", "def destroy\n @forest.destroy\n respond_to do |format|\n format.html { redirect_to forests_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @appliance_type = ApplianceType.find(params[:id])\n @appliance_type.destroy\n\n respond_to do |format|\n format.html { redirect_to appliance_types_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @fixture = Fixture.find(params[:id])\n @fixture.destroy\n\n respond_to do |format|\n format.json { head :no_content }\n end\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 @forest = Forest.find(params[:id])\n @forest.destroy\n\n respond_to do |format|\n format.html { redirect_to forests_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @clapme_stage.destroy\n respond_to do |format|\n format.html { redirect_to website_stages_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @convention.destroy\n respond_to do |format|\n format.html { redirect_to conventions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @coffeeshop.destroy\n respond_to do |format|\n format.html { redirect_to coffeeshops_url, notice: 'Coffeeshop was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @kota_stone.destroy\n respond_to do |format|\n format.html { redirect_to kota_stones_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @admin_showcase.destroy\n respond_to do |format|\n format.html { redirect_to admin_showcases_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @cloud = Cloud.find(params[:id])\n @cloud.destroy\n\n respond_to do |format|\n format.html { redirect_to clouds_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @buckle.destroy\n respond_to do |format|\n format.html { redirect_to admin_buckles_path }\n format.json { head :no_content }\n end\n end", "def destroy\n @catebg = Catebg.find(params[:id])\n @catebg.destroy\n\n respond_to do |format|\n format.html { redirect_to catebgs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @baton = Baton.find(params[:id])\n @baton.destroy\n\n respond_to do |format|\n format.html { redirect_to batons_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @background_option.destroy\n respond_to do |format|\n format.html { redirect_to background_options_url, notice: 'Background option was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @farmacium.destroy\n respond_to do |format|\n msg = { :status => \"ok\", :message => \"Eliminado!\" }\n format.json { render :json => msg }\n end\n end", "def delete\n client.delete(\"/#{id}\")\n end", "def destroy\n @version = Version.find(params[:id])\n @versionconfig = @version.version_configurations.destroy_all\n @version.destroy\n\n respond_to do |format|\n format.html { redirect_to [@application, @version] }\n format.json { head :no_content }\n end\n end", "def destroy\n @cakestore.destroy\n respond_to do |format|\n format.html { redirect_to cakestores_url, notice: 'Cakestore was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @dish_mixture.destroy\n respond_to do |format|\n format.html { redirect_to dish_mixtures_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @bagtype = Bagtype.find(params[:id])\n @bagtype.destroy\n\n respond_to do |format|\n format.html { redirect_to bagtypes_url }\n format.json { head :ok }\n end\n end", "def destroy\n @distro.destroy\n respond_to do |format|\n format.html { redirect_to distros_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @major.destroy\n respond_to do |format|\n format.html { redirect_to majors_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @cow.destroy\n respond_to do |format|\n format.html { redirect_to kine_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 @api_version = ApiVersion.find(params[:id])\n @api_version.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_api_versions_url, flash: {success: t('app.msgs.success_deleted', :obj => t('mongoid.models.api_version.one'))} }\n format.json { head :no_content }\n end\n end", "def destroy\n @green = Green.find(params[:id])\n @green.destroy\n\n respond_to do |format|\n format.html { redirect_to scaffold_greens_url }\n format.json { head :ok }\n end\n end", "def destroy\n @test_stuff.destroy\n respond_to do |format|\n format.html { redirect_to test_stuffs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @admin_features_brand.destroy\n respond_to do |format|\n format.html { redirect_to admin_features_brands_url, notice: 'Features brand was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @coffeeshoplist.destroy\n respond_to do |format|\n format.html { redirect_to coffeeshoplists_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @variety.destroy\n respond_to do |format|\n format.html { redirect_to admin_varieties_path, notice: 'La variedad fue eliminada' }\n format.json { head :no_content }\n end\n end", "def destroy\n @adminkefu.destroy\n respond_to do |format|\n format.html { redirect_to adminkefus_path, notice: 'Test was successfully destroyed.' }\n format.json { head :no_adminkefu }\n end\n end", "def destroy\n @cfg.destroy\n respond_to do |format|\n format.html { redirect_to cfgs_url, notice: 'Cfg was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @api_version = ApiVersion.find(params[:id])\n @api_version.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_api_versions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @shelf.destroy\n\n respond_to do |format|\n format.html { redirect_to shelves_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @tea_club.destroy\n respond_to do |format|\n format.html { redirect_to tea_clubs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @vachana = Vachana.find(params[:id])\n @vachana.destroy\n\n respond_to do |format|\n format.html { redirect_to vachanas_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @vachana = Vachana.find(params[:id])\n @vachana.destroy\n\n respond_to do |format|\n format.html { redirect_to vachanas_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @food = Food.find(params[:id])\n @food.destroy\n\n respond_to do |format|\n format.html { redirect_to foods_url }\n format.json { head :ok }\n end\n end", "def destroy\n @food = Food.find(params[:id])\n @food.destroy\n\n respond_to do |format|\n format.html { redirect_to foods_url }\n format.json { head :ok }\n end\n end", "def destroy\n @mixture.destroy\n respond_to do |format|\n format.html { redirect_to mixtures_url, notice: \"Mixture was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @shelf.destroy\n respond_to do |format|\n format.html { redirect_to shelves_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @fixture = Fixture.find(params[:id])\n @fixture.destroy\n\n respond_to do |format|\n format.html { redirect_to fixtures_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @fixture = Fixture.find(params[:id])\n @fixture.destroy\n\n respond_to do |format|\n format.html { redirect_to fixtures_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @kela.destroy\n respond_to do |format|\n format.html { redirect_to kelas_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @stuff = Stuff.find(params[:id])\n @stuff.destroy\n\n respond_to do |format|\n format.html { redirect_to stuff_index_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @ruby = Ruby.find(params[:id])\n @ruby.destroy\n\n respond_to do |format|\n format.html { redirect_to rubies_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @adocao_animal = AdocaoAnimal.find(params[:id])\n @adocao_animal.destroy\n\n respond_to do |format|\n format.html { redirect_to adocao_animals_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @wild_type_background.destroy\n respond_to do |format|\n format.html { redirect_to wild_type_backgrounds_url, notice: \"Wild type background was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n chef_rest_v1.delete(\"clients/#{@name}\")\n end", "def destroy\n @bracket_golfer.destroy\n respond_to do |format|\n format.html { redirect_to bracket_golfers_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @featuring.destroy\n respond_to do |format|\n format.html { redirect_to featuring_index_url, notice: 'Featuring was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @stuff = Stuff.find(params[:id])\n @stuff.destroy\n\n respond_to do |format|\n format.html { redirect_to stuffs_url }\n format.json { head :ok }\n end\n end", "def destroy\n @cephalopod.destroy\n respond_to do |format|\n format.html { redirect_to cephalopods_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @coffee1.destroy\n respond_to do |format|\n format.html { redirect_to coffee1s_url, notice: 'Coffee1 was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @fascicle.destroy\n respond_to do |format|\n format.html { redirect_to fascicles_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @stage.destroy\n render json: {message: 'Etapa Excluida'}, status: :ok\n end", "def destroy\n @fatcat.destroy\n respond_to do |format|\n format.html { redirect_to fatcats_url, notice: 'Fatcat was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @animal.destroy\n\n respond_to do |format|\n format.html { redirect_to animals_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @convention_category = ConventionCategory.find(params[:id])\n @convention_category.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_convention_categories_url }\n format.json { head :ok }\n end\n end", "def destroy\n @stage.destroy\n respond_to do |format|\n format.html { redirect_to stages_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @glo_collection.destroy\n respond_to do |format|\n format.html { redirect_to glo_collections_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 @fish_type = FishType.find(params[:id])\n @fish_type.destroy\n\n respond_to do |format|\n format.html { redirect_to fish_types_url }\n format.json { head :no_content }\n end\n end", "def destroy\n animal = Animal.find(params[:id])\n animal.destroy\n head 204\n end", "def destroy\n @farm = Farm.find(params[:id])\n @farm.destroy\n\n respond_to do |format|\n format.html { redirect_to farms_url }\n format.json { head :ok }\n end\n end", "def destroy\n @blueprint.destroy\n respond_to do |format|\n format.html { redirect_to blueprints_url, notice: 'Blueprint was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @farm = Farm.find(params[:id])\n @farm.destroy\n\n respond_to do |format|\n format.html { redirect_to farms_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @farm = Farm.find(params[:id])\n @farm.destroy\n\n respond_to do |format|\n format.html { redirect_to farms_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @farm = Farm.find(params[:id])\n @farm.destroy\n\n respond_to do |format|\n format.html { redirect_to farms_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @flavor.active=\"false\"\n @flavor.save\n respond_to do |format|\n format.html { redirect_to flavors_url, notice: 'Flavor was successfully made inactive.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @admin_stage.destroy\n respond_to do |format|\n format.html { redirect_to admin_stages_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @fabricsofaset.destroy\n respond_to do |format|\n format.html { redirect_to fabricsofasets_url, notice: 'Fabricsofaset was successfully destroyed.' }\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 @flower = Flower.find(params[:id])\n @flower.destroy\n\n respond_to do |format|\n format.html { redirect_to flowers_url }\n format.json { head :ok }\n end\n end", "def destroy\n @three60.destroy\n respond_to do |format|\n format.html { redirect_to edit_admin_good_url(@good, anchor: \"three60\") }\n format.json { head :no_content }\n end\n end", "def destroy\n @fact.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 @bg_check.destroy\n respond_to do |format|\n format.html { redirect_to bg_checks_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @database = Database.find(params[:id])\n path = @database.path\n delete = %x[rm -R #{path}]\n @database.destroy\n\n respond_to do |format|\n format.html { redirect_to databases_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @chicken_adoption.destroy\n respond_to do |format|\n format.html { redirect_to chicken_adoptions_url, notice: 'Chicken adoption was successfully destroyed.' }\n format.json { head :no_content }\n end\n end" ]
[ "0.7586125", "0.7065672", "0.7026094", "0.6979786", "0.69694257", "0.68794614", "0.68777996", "0.682137", "0.6812025", "0.67566043", "0.6740801", "0.66935563", "0.6620424", "0.65605843", "0.6536122", "0.6529574", "0.64735293", "0.6461297", "0.6457156", "0.6454956", "0.64340883", "0.64334893", "0.64172816", "0.6412857", "0.6411946", "0.63956237", "0.6387276", "0.6386223", "0.6380183", "0.63790953", "0.63692486", "0.63680625", "0.6362859", "0.6361702", "0.63616073", "0.63569856", "0.6351184", "0.63492197", "0.6349086", "0.6334503", "0.6333145", "0.6332996", "0.6320984", "0.6317015", "0.6309199", "0.630718", "0.63046724", "0.6292154", "0.62907183", "0.6285555", "0.6282462", "0.6274124", "0.6271244", "0.6270295", "0.62676007", "0.62665784", "0.62648576", "0.62648576", "0.6264498", "0.6264498", "0.6261935", "0.62586635", "0.62577194", "0.62577194", "0.62565374", "0.6256313", "0.62560016", "0.6252439", "0.6251265", "0.6245402", "0.6239177", "0.6234806", "0.62346154", "0.6230486", "0.62270397", "0.6225872", "0.62255335", "0.6225149", "0.6223466", "0.6222767", "0.62210125", "0.62203443", "0.62196124", "0.6219285", "0.6216206", "0.62142545", "0.6213429", "0.6212764", "0.6212764", "0.6212764", "0.6210614", "0.62094617", "0.62037647", "0.62020075", "0.6200794", "0.62000453", "0.6198207", "0.61968523", "0.6193181", "0.6188918" ]
0.78703517
0
Use callbacks to share common setup or constraints between actions.
def set_cake_flavor @cake_flavor = CakeFlavor.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_handler\n end", "def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end", "def before_actions(*logic)\n self.before_actions = logic\n end", "def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end", "def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end", "def 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 action; end", "def action; end", "def action; end", "def action; end", "def action; end", "def workflow\n end", "def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end", "def before(action)\n invoke_callbacks *self.class.send(action).before\n end", "def before_dispatch(env); end", "def process_action(...)\n send_action(...)\n end", "def setup\n # override and do something appropriate\n end", "def after_actions(*logic)\n self.after_actions = logic\n end", "def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end", "def setup(_context)\n end", "def setup(resources) ; end", "def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end", "def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end", "def determine_valid_action\n\n end", "def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end", "def 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 setup( *args )\n\t\t\tself.class.setupBlocks.each {|sblock|\n\t\t\t\tdebugMsg \"Calling setup block method #{sblock}\"\n\t\t\t\tself.send( sblock )\n\t\t\t}\n\t\t\tsuper( *args )\n\t\tend", "def action\n end", "def setup\n @setup_proc.call(self) if @setup_proc\n end", "def config(action, *args); 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 before_action \n end", "def action\n end", "def setup\n # override this if needed\n end", "def matt_custom_action_begin(label); 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 setup_signals; 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 after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend", "def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend", "def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action.respond_to?('weak!') ? action.weak! : action\n end", "def after_set_callback; end", "def setup\n #implement in subclass;\n end", "def initialize(*args)\n super\n @action = :set\nend", "def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end", "def lookup_action; end", "def around_hooks; end", "def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end", "def release_actions; end", "def setup(easy)\n super\n easy.customrequest = @verb\n end", "def save_action; end", "def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end", "def action_target()\n \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 setup(&blk)\n @setup_block = blk\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 callback_phase\n super\n end", "def advice\n end", "def call\n setup_context\n super\n end", "def _handle_action_missing(*args); end", "def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end", "def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend", "def duas1(action)\n action.call\n action.call\nend" ]
[ "0.6162554", "0.60452986", "0.5945278", "0.59169763", "0.58877826", "0.5834763", "0.5775349", "0.5704972", "0.5704972", "0.56543803", "0.5621491", "0.5427202", "0.54093206", "0.54093206", "0.54093206", "0.53975695", "0.53776276", "0.53562194", "0.5340594", "0.5337824", "0.5328757", "0.5310255", "0.5300339", "0.5298796", "0.5295774", "0.5256034", "0.5243039", "0.5236007", "0.5235239", "0.5235239", "0.5235239", "0.5235239", "0.5235239", "0.52321917", "0.5227032", "0.52216744", "0.5216349", "0.52161187", "0.5210265", "0.5207244", "0.5177388", "0.5177142", "0.51747334", "0.516293", "0.51629275", "0.5155534", "0.51540613", "0.515197", "0.5151636", "0.5145279", "0.51380795", "0.5135777", "0.5117378", "0.5115066", "0.5115066", "0.5110235", "0.5106418", "0.50917816", "0.50909185", "0.50855017", "0.5082105", "0.506359", "0.5055345", "0.50546116", "0.50523037", "0.50523037", "0.50327307", "0.5024364", "0.5021113", "0.50174654", "0.50163317", "0.5000553", "0.50002855", "0.49991882", "0.49905527", "0.49905527", "0.49849054", "0.4982546", "0.4980941", "0.4979153", "0.49693102", "0.4967172", "0.49594432", "0.49564302", "0.49552485", "0.49533385", "0.49506924", "0.49452737", "0.49442786", "0.49347955", "0.49341312", "0.49295264", "0.49261844", "0.4925649", "0.49251428", "0.4920729", "0.49177617", "0.4916373", "0.49158472", "0.4915794", "0.49156648" ]
0.0
-1
Only allow a list of trusted parameters through.
def cake_flavor_params params.require(:cake_flavor).permit(:flavor_name) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def allowed_params\n ALLOWED_PARAMS\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def parameters_list_params\n params.require(:parameters_list).permit(:name, :description, :is_user_specific)\n end", "def param_whitelist\n [:role, :title]\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 strong_params\n params.require(:user).permit(param_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 allow_params_authentication!; end", "def whitelisted_args\n args.select &:allowed\n end", "def safe_list_sanitizer; end", "def safe_list_sanitizer; end", "def safe_list_sanitizer; end", "def filtered_parameters; end", "def sanitize_params_for user, params, allowed_params\n params.each do |key, val|\n #if allowed_params.include?(key)\n #sanitize!(user, params, key) if key =~ /_attributes|_ids$/\n #else\n #params.delete(key)\n #end\n params.delete(key) unless allowed_params.include?(key.to_sym)\n end\n end", "def strong_params\n params.require(:team_member).permit(param_whitelist)\n end", "def expected_permitted_parameter_names; end", "def sanitize_parameters!(sanitizer, params)\n # replace :readwrite with :onlyif\n if params.has_key?(:readwrite)\n warn \":readwrite is deprecated. Replacing with :onlyif\"\n params[:onlyif] = params.delete(:readwrite)\n end\n\n # add default parameters\n bindata_default_parameters.each do |k,v|\n params[k] = v unless params.has_key?(k)\n end\n\n # ensure mandatory parameters exist\n bindata_mandatory_parameters.each do |prm|\n if not params.has_key?(prm)\n raise ArgumentError, \"parameter ':#{prm}' must be specified \" +\n \"in #{self}\"\n end\n end\n\n # ensure mutual exclusion\n bindata_mutually_exclusive_parameters.each do |param1, param2|\n if params.has_key?(param1) and params.has_key?(param2)\n raise ArgumentError, \"params #{param1} and #{param2} \" +\n \"are mutually exclusive\"\n end\n end\n end", "def strong_params\n params.require(:education).permit(param_whitelist)\n end", "def safe_list_sanitizer=(_arg0); end", "def safe_list_sanitizer=(_arg0); end", "def safe_list_sanitizer=(_arg0); end", "def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end", "def param_whitelist\n [:rating, :review]\n end", "def check_params; true; end", "def strong_params\n params.require(:experience).permit(param_whitelist)\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 allowed?(*_)\n true\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 allowed_params(parameters)\n parameters.select do |name, values|\n values.location != \"path\"\n end\n end", "def secure_params\n return @secure_params if @secure_params\n\n defn = implementation_class.definition\n field_list = [:master_id] + defn.field_list_array\n\n res = params.require(controller_name.singularize.to_sym).permit(field_list)\n res[implementation_class.external_id_attribute.to_sym] = nil if implementation_class.allow_to_generate_ids?\n @secure_params = res\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 permitir_parametros\n \t\tparams.permit!\n \tend", "def strong_params\n params.require(:community).permit(param_whitelist)\n end", "def permit( params, whitelist, name = nil )\n raise 'Parametrization not yet configured' unless @configured\n whitelist ||= []\n px = params.respond_to?( :permit ) ? params : ActionController::Parameters.new( params )\n px = dig(px, name)\n px.permit( *whitelist )\n end", "def valid_params?; 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 url_allowlist=(_arg0); 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 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 list_params\n params.permit(:list_name)\n end", "def valid_params_request?; end", "def safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\n end", "def param_list(param_type, name, type, required, description = nil, allowed_values = [], hash = {})\n hash.merge!({allowable_values: {value_type: \"LIST\", values: allowed_values}})\n param(param_type, name, type, required, description, hash)\n end", "def safelists; end", "def authorize_own_lists\n authorize_lists current_user.lists\n end", "def listed_params\n params.permit(:listed, :list_id, :listable_id, :listable_type, :campsite_id)\n end", "def lists_params\n params.require(:list).permit(:name)\n\n end", "def list_params\n params.require(:list).permit(:name, :user_id)\n end", "def list_params\n params.require(:list).permit(:name, :description, :type, :privacy, :allow_edit, :rating, :votes_count, :user_id)\n end", "def check_params\n true\n end", "def authorize_own_or_shared_lists\n authorize_lists current_user.all_lists\n end", "def user_pref_list_params\n\t\tparams.require(:user).permit(:preference_list)\n\tend", "def may_contain!(*keys)\n self.allow_only_permitted = true\n self.permitted_keys = [*permitted_keys, *keys].uniq\n end", "def filter_parameters; end", "def filter_parameters; end", "def whitelist; end", "def article_params_whitelist\n params.require(:article).permit(:title, :description, category_ids: [])\n end", "def list_params\n params.require(:list).permit(:name)\n end", "def list_params\n params.permit(:name)\n end", "def recipient_list_params\n params.require(:recipient_list).permit(:name, :list, :references)\n end", "def cancan_parameter_sanitizer\n resource = controller_name.singularize.to_sym\n method = \"#{resource}_params\"\n params[resource] &&= send(method) if respond_to?(method, true)\n end", "def list_params\n params.require(:list).permit(:name).merge(user_id: current_user.id)\n end", "def whitelist_place_params\n params.require(:place).permit(:place_name, :unlock, :auth, :is_deep_checked, :parent_ADM4, :parent_ADM3, :parent_ADM2, :parent_ADM1, :parent_country, feature_code: [], same_as: [], related_authority: [], altlabel: [], note: []) # Note - arrays need to go at the end or an error occurs!\n end", "def list_params\n params.fetch(:list, {}).permit(:user_id, :name, :active)\n end", "def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end", "def secure_params(require_param, permit_keys)\n params.require(require_param).permit(*permit_keys)\n end", "def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end", "def permitted_params\n []\n end", "def price_list_params\n params.fetch(:price_list, {}).permit(:name, :valid_from, :valid_to, :active,\n :all_warehouses, :all_users, :all_contact_groups,\n warehouse_ids: [], price_lists_user_ids: [], contact_group_ids: [])\n end", "def params(list)\n @declared_params = list\n end", "def admin_review_params\n params.fetch(:review, {}).permit(whitelisted_params)\n end", "def saved_list_params\n params.require(:saved_list).permit(:user_id)\n end", "def allow(ids); end", "def list_params\n params.require(:list).permit(:name)\n end", "def list_params\n params.require(:list).permit(:name)\n end", "def list_params\n params.require(:list).permit(:name)\n end", "def filter_params(param_set, **kwargs)\r\n begin\r\n key = kwargs[:key]\r\n params.require(key).permit(*param_set)\r\n rescue Exception\r\n params.permit(*param_set)\r\n end\r\n end", "def valid_parameters\n sort_symbols(@interface.allowed_parameters)\n end", "def validate_paramified_params\n self.class.paramify_methods.each do |method|\n params = send(method)\n transfer_errors_from(params, TermMapper.scope(params.group)) if !params.valid?\n end\n end", "def list_params\n params.require(:list).permit(:name)\n end", "def secure_params\n return @secure_params if @secure_params\n\n @implementation_class = implementation_class\n resname = @implementation_class.name.ns_underscore.gsub('__', '_').singularize.to_sym\n @secure_params = params.require(resname).permit(*permitted_params)\n end", "def refine_permitted_params(param_list)\n res = param_list.dup\n\n ms_keys = res.select { |a| columns_hash[a.to_s]&.array }\n ms_keys.each do |k|\n res.delete(k)\n res << { k => [] }\n end\n\n res\n end", "def recipient_list_params\n params.require(:recipient_list).permit(:name, :description, recipient_id_array: [])\n end", "def safelist; end", "def sponsor_params\n params.require(:sponsor).permit(WHITE_LIST)\n end", "def valid_for_params_auth?; end", "def default_param_whitelist\n [\"mode\"]\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 shopping_list_params\n params.require(:shopping_list).permit!\n end", "def permitted_params\n declared(params, include_missing: false)\n end", "def permitted_params\n declared(params, include_missing: false)\n end", "def safe_params\n params.except(:host, :port, :protocol).permit!\n end", "def permitters\n @_parametrizr_permitters || {}\n end", "def allow_params(action, keys: nil, except: nil, &blk)\n keys &&= Array.wrap(keys)\n keys ||= User.field_names\n except &&= Array.wrap(except)\n except ||= %i[id email]\n devise_parameter_sanitizer.permit(action, keys: keys, except: except, &blk)\n end", "def list_params\n if current_user && current_user.role == 'admin'\n params.require(:list).permit(:name, :url, :description, :user_id,\n ideas_attributes: [:id, :list_id, :body, :due_date, :completion_status, :_destroy])\n else\n params.require(:list).permit(:name, :description,\n ideas_attributes: [:body, :due_date, :completion_status]) \n end\n end", "def whitelist(params)\n send_request_of_type(GlobalConstant::PrivateOpsApi.private_ops_api_type, 'post', '/token-sale/whitelist', params)\n end", "def valid_access_params\n params.require(:valid_access).permit(:wish_list_id, :user_id)\n end", "def url_allowlist; end", "def ensure_redirected_params_are_safe!(passed_params)\n unless passed_params.is_a?(ActionController::Parameters) && passed_params.permitted?\n error_message = if passed_params.is_a?(ActionController::Parameters)\n unsafe_parameters = passed_params.send(:unpermitted_keys, params)\n \"[Rails::Prg] Error - Must use permitted strong parameters. Unsafe: #{unsafe_parameters.join(', ')}\"\n else\n \"[Rails::Prg] Error - Must pass strong parameters.\"\n end\n raise error_message\n end\n end", "def data_collection_params\n allow = [:name,:description,:institution,:collection_name,:country_id,:province_id,:city_id]\n params.require(:data_collection).permit(allow)\n end", "def quote_params\n params.permit!\n end" ]
[ "0.69497335", "0.6812623", "0.6803639", "0.6795365", "0.67448795", "0.67399913", "0.6526815", "0.6518771", "0.64931697", "0.6430388", "0.6430388", "0.6430388", "0.63983387", "0.6356042", "0.63535863", "0.63464934", "0.63444513", "0.6337208", "0.6326454", "0.6326454", "0.6326454", "0.63140553", "0.6299814", "0.62642586", "0.626006", "0.62578833", "0.6236823", "0.6227561", "0.6221758", "0.62200165", "0.620879", "0.61983657", "0.6195055", "0.6172993", "0.6156856", "0.61558664", "0.61521494", "0.6135789", "0.6121145", "0.61118174", "0.60736513", "0.6071645", "0.60632104", "0.60549796", "0.6043906", "0.6034662", "0.60207325", "0.6018568", "0.6016575", "0.60103434", "0.60084206", "0.600763", "0.6007443", "0.6003619", "0.6003619", "0.5995791", "0.5993301", "0.5993231", "0.5984926", "0.597122", "0.5968121", "0.5965808", "0.59640145", "0.59632224", "0.59602356", "0.59332967", "0.5927556", "0.5922805", "0.5909745", "0.5905083", "0.5904304", "0.5893434", "0.58888215", "0.58823985", "0.58823985", "0.58823985", "0.5873434", "0.58619875", "0.58533794", "0.5845531", "0.58426666", "0.58360124", "0.583218", "0.5828041", "0.5827927", "0.5816121", "0.5814705", "0.5812719", "0.581121", "0.5803423", "0.5803423", "0.57995003", "0.5794207", "0.5784923", "0.5781365", "0.5776385", "0.5774859", "0.57671493", "0.5766998", "0.57618684", "0.5758038" ]
0.0
-1
GET /product_classifies GET /product_classifies.json
def index search_txt = params['search_txt'] if search_txt != nil && search_txt != "" @search_txt = search_txt @product_classifies = ProductClassify.where("name LIKE '%#{search_txt}%'").order("created_at desc").page params[:page] else @product_classifies = ProductClassify.order("created_at desc").page params[:page] end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @product_classify = ProductClassify.new(product_classify_params)\n\n respond_to do |format|\n if @product_classify.save\n format.html { redirect_to :product_classifies, notice: '产品分类添加成功。' }\n format.json { render :show, status: :created, location: @product_classify }\n else\n format.html { render :new }\n format.json { render json: @product_classify.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_product_classify\n @product_classify = ProductClassify.find(params[:id])\n end", "def update\n respond_to do |format|\n if @product_classify.update(product_classify_params)\n format.html { redirect_to :product_classifies, notice: '产品分类修改成功。' }\n format.json { render :show, status: :ok, location: @product_classify }\n else\n format.html { render :edit }\n format.json { render json: @product_classify.errors, status: :unprocessable_entity }\n end\n end\n end", "def classifications(classification)\n params = {\n classification: classification\n }.compact\n\n _get(\"/account/classifications\", params) { |json| json }\n end", "def index\n @classifieds = Classified.all\n end", "def create\n @classified = Classified.new(classified_params)\n respond_to do |format|\n if @classified.save\n format.html { redirect_to @classified, notice: 'Classified was successfully created.' }\n format.json { render :show, status: :created, location: @classified }\n else\n format.html { render :new }\n format.json { render json: @classified.errors, status: :unprocessable_entity }\n end\n end\n end", "def product_classify_params\n params.require(:product_classify).permit(:name, :intro)\n end", "def create\n Rails.logger.debug \"[ClassificationsController.create] params.class: #{params.class}, params: #{params}\"\n @classifaction = Classification.new transaction_data: params\n @classifaction.classifiers << StatusCodeClassifier.classify( @classifaction.transaction_data )\n @classifaction.classify\n\n if @classifaction.save\n render json: @classifaction.as_jsonapi, status: :created\n else\n render json: { error: 'oops' }, status: 500\n end\n end", "def set_classified\n @classified = Classified.find(params[:id])\n end", "def set_classified\n @classified = Classified.find(params[:id])\n end", "def create\n #@classified = Classified.new(classified_params)\n @classified = current_user.classifieds.new(classified_params)\n\n respond_to do |format|\n if @classified.save\n format.html { redirect_to @classified, notice: 'Classified was successfully created.' }\n format.json { render :show, status: :created, location: @classified }\n else\n format.html { render :new }\n format.json { render json: @classified.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @item_classifications = ItemClassification.all\n end", "def index\n @category_classifieds = CategoryClassified.all\n end", "def index\n #deeply nested... so starts with gyms,goes to trainers,goes to clients.\n #since clients belongs to trainer we use trainer here..\n #but in trainers_controller the trainers belongs to gyms so gyms is used orignally.\n @product=Product.find(params[:product_id])\n @reviews=Review.where(product_id: @product.id)\n render json:@reviews, status: :ok\n end", "def show\n @shopifyproduct = Shopifyproduct.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @shopifyproduct }\n end\n end", "def set_recipe_classify\n @recipe_classify = RecipeClassify.find(params[:id])\n end", "def new\n @classified = Classified.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @classified }\n end\n end", "def create\n @category_classified = CategoryClassified.new(category_classified_params)\n\n respond_to do |format|\n if @category_classified.save\n format.html { redirect_to @category_classified, notice: 'Category classified was successfully created.' }\n format.json { render :show, status: :created, location: @category_classified }\n else\n format.html { render :new }\n format.json { render json: @category_classified.errors, status: :unprocessable_entity }\n end\n end\n end", "def show\n @home_searches_product = Home::Searches::Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @home_searches_product }\n end\n end", "def show\n @product = Product.eager_loading.find_by_uuid(params[:id])\n\n respond_to do |format|\n format.html { redirect_to edit_shop_product_path(@product.shop_id, @product)}\n format.json { render json: @product.as_json(:include => {:product_variants => {:include => [:option_types,:pictures]}, :shipping_category => {}}, :methods => [:taxon_ids]) }\n end\n end", "def destroy\n @product_classify.destroy\n respond_to do |format|\n format.html { redirect_to product_classifies_url, notice: '产品分类删除成功。' }\n format.json { head :no_content }\n end\n end", "def show\n render json: @product, status: 200\n end", "def show\n @review = Review.find(params[:id])\n @product = @review.product\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @review }\n end\n end", "def index\n @products = Product.order('category, priority desc, price')\n @basket_size = count_basket_items\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @products }\n end\n end", "def customize\n return unless @product\n\n @variants = @product.variants_including_master.active(current_currency).includes([:option_values, :images])\n @product_properties = @product.product_properties.includes(:property)\n\n referer = request.env['HTTP_REFERER']\n if referer\n begin\n referer_path = URI.parse(request.env['HTTP_REFERER']).path\n # Fix for #2249\n rescue URI::InvalidURIError\n # Do nothing\n else\n if referer_path && referer_path.match(/\\/t\\/(.*)/)\n @taxon = Taxon.find_by_permalink($1)\n end\n end\n end\n\n respond_with(@product)\n end", "def show\n @test.relations = Relation.joins(:question).where(\"relations.test_id = ?\", @test.id).select(\"relations.id, questions.identifier, questions.description\")\n @quantity = Relation.joins(:question).where(\"relations.test_id = ?\", @test.id).select(\"relations.id, questions.identifier, questions.description\").count(:all)\n questions = Question.where(\"questions.id IN (?)\", Relation.where(\"test_id = ?\", @test.id).select(\"question_id\"))\n classificat = Classification.all\n\n classifications = []\n \n questions.each do |question|\n classif = {}\n value = false\n if classifications === []\n classif['classification'] = question.classification_id\n classif['quantity'] = 1\n classifications.push(classif)\n else\n for i in 0..classifications.length-1\n if classifications[i]['classification'] === question.classification_id\n classifications[i]['quantity'] = classifications[i]['quantity'] + 1 \n value = true\n break\n end\n end\n if value === false\n classif['classification'] = question.classification_id\n classif['quantity'] = 1\n classifications.push(classif) \n end\n end\n end\n\n classificat.each do |classif|\n for i in 0..classifications.length-1\n if classifications[i]['classification'] === classif.id\n classifications[i]['classification'] = classif.description\n break\n end\n end\n end\n @classifications = classifications\n end", "def get_product\n json_response({ message: 'NOT IMPLEMENTED' })\n end", "def show\n if @product.present?\n render json: {is_success: true, error_code: 200, message: \"Found Successfully\", result: @product}, status: 200\n end\n end", "def show\n @classified = Classified.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @classified }\n end\n end", "def show\n @product = Product.find(params[:id])\n @photos = @product.photos\n\t@related_products = Product.where(\"category_id = ? and manufacturer_id = ? and id <> ?\", @product.category, @product.manufacturer,@product.id ).limit(6)\n @reviews = @product.reviews.paginate(:page => params[:page], :per_page => 10)\n @manufacturer_products = @product.manufacturer.products.where(\"id <> ?\",@product.id).limit(5) unless @product.manufacturer.nil?\n if (current_user != nil)\n @cart = User.find(session[:user_id]).cart\n end\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n result = Product.find(params[:id])\n render json: {\n status: :ok,\n product: result\n } \n end", "def with_photo\n @classifieds = Classified.with_photos\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @classifieds }\n end\n end", "def index\n @products = Product.all\n @users = Product.find(:all)\n #--------amazon cloud search-----------------------------------------------------------\n #searcher = CloudSearch::Searcher.new\n #@resp = searcher.with_fields(:id, :actor, :director, :title, :year, :text_relevance)\n # .with_query(\"star wars\")\n # .search\n #--------------------------------------------------------------------------------------\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @products }\n format.xml { render :xml => @products }\n end\n end", "def show\n @category = Category.find(params[:id])\n @categories = Category.order(\"name ASC\")\n @product_list = @category.products_sorted_by_average_product_rating\n @review = Review.new\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @category }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n @comment = Comment.find(:all, :conditions => {:product_id =>@product.id})\n @questions = Question.find(:all, :conditions => {:product_id =>@product.id})\n @answer = Answer.find(:all)\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def classification(query, set=nil)\n is_valid_with_error(__method__, [:ipv4, :domain], query)\n if domain?(query)\n query = normalize_domain(query)\n end\n if set.nil?\n get('actions/classification', {'query' => query})\n else\n is_valid_with_error(__method__.to_s, [:classification], set)\n post('actions/classification', { 'query' => query, 'classification' => set })\n end\n end", "def view_product\n to_json(\n only: [:id, :title, :description, :key_information],\n methods: [:photo_url, :net_mrp, :mrp_per_unit, :quantity],\n :include => {\n store: {\n only: [:name, :id],\n methods: [:full_address]\n }\n }\n )\n end", "def new\n @shopifyproduct = Shopifyproduct.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @shopifyproduct }\n end\n end", "def create\n @classifier = Classifier.new(classifier_params)\n\n respond_to do |format|\n if @classifier.save\n format.html { redirect_to @classifier, notice: 'Classifier was successfully created.' }\n format.json { render :show, status: :created, location: @classifier }\n else\n format.html { render :new }\n format.json { render json: @classifier.errors, status: :unprocessable_entity }\n end\n end\n end", "def show\n # @ccbs_product = CcbsProduct.find(params[:id])\n\n prd_attribute = PrdAttribute.find(params[:id], :include => :products)\n product = Product.find(prd_attribute.products[0].id, :include => [:prd_subscriptions, :prd_additional_services])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @ccbs_product }\n format.json {\n\n ccbs_product = CcbsProduct.new\n tariff_list = ccbs_product.set_fields(prd_attribute, product.prd_subscriptions, product.prd_additional_services)\n\n # product에 대해 전달\n results = mapping_to_hash(ccbs_product,CcbsProduct.json_mapping_table)\n ccbs_product.send_to_ccbs('POST', results.to_json)\n\n # tariff에 대해서 전달\n tariff_list.each { |product_tariff| \n to_ccbs_hash = mapping_to_hash(product_tariff, CcbsProductTariff.json_mapping_table)\n product_tariff.send_to_ccbs(\"POST\", to_ccbs_hash.to_json) }\n\n render :json => results\n } \n end\n end", "def show\n @product = Product.find(params[:id]) \n # @product_id = @product.id\n # @review = Review.find(@product_id)\n\n # @reviews = Review.where(:product_id => params[:id])\n @reviews = Review.where(:product_id => @product.id)\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n render json: @product\n end", "def show\n @body_style_product_feature = BodyStyleProductFeature.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @body_style_product_feature }\n end\n end", "def get_product_count_types\n types = CountType.where(product_id: params[:product_id]).order(\"name ASC\").map { |type| [type.id, type.name] }\n render :json => types.to_json.to_s.to_json\n end", "def create\n @shopifyproduct = Shopifyproduct.new(params[:shopifyproduct])\n\n respond_to do |format|\n if @shopifyproduct.save\n format.html { redirect_to @shopifyproduct, notice: 'Shopifyproduct was successfully created.' }\n format.json { render json: @shopifyproduct, status: :created, location: @shopifyproduct }\n else\n format.html { render action: \"new\" }\n format.json { render json: @shopifyproduct.errors, status: :unprocessable_entity }\n end\n end\n end", "def show\n @products = Product.find_by_id(params[:id])\n msg = { status: 200 , product: @products }\n respond_to do |format|\n format.html { render json: msg }\n format.json { render json: msg }\n end\n end", "def products\n end", "def create\n @item_classification = ItemClassification.new(item_classification_params)\n\n respond_to do |format|\n if @item_classification.save\n format.html { redirect_to @item_classification, notice: 'Classificação criada com sucesso.' }\n format.json { render :show, status: :created, location: @item_classification }\n else\n format.html { render :new }\n format.json { render json: @item_classification.errors, status: :unprocessable_entity }\n end\n end\n end", "def show\n render json: @product\n end", "def product_info\n {\n product_name: {\n default_value: 'similarity detection reference tool'\n },\n product_version: '1.0',\n description: {\n default_value: 'LTI 2.1 tool provider reference implementation'\n },\n product_family: {\n code: 'similarity detection reference tool',\n vendor: {\n code: 'Instructure.com',\n vendor_name: {\n default_value: 'Instructure'\n },\n description: {\n default_value: 'Canvas Learning Management System'\n }\n }\n }\n }\n end", "def show\n render json: @food_product\n end", "def index\n respond_to do |format|\n format.html { render_template } # index.html.erb\n format.xml { render xml: @product_training_classes }\n end\n end", "def index\n 3.times { @product.product_specifications.build }\n respond_to do |format|\n format.html { render_template } # index.html.erb\n format.xml { render xml: @product_specifications }\n end\n end", "def create\n @clasification = Clasification.new(clasification_params)\n\n respond_to do |format|\n if @clasification.save\n format.html { redirect_to @clasification, notice: \"Clasification was successfully created.\" }\n format.json { render :show, status: :created, location: @clasification }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @clasification.errors, status: :unprocessable_entity }\n end\n end\n end", "def show\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product_type }\n end\n end", "def show\n @recommendation = Recommendation.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @recommendation }\n end\n end", "def show\n @occasion = Occasion.find(params[:id])\n @products = Product.all\n @productcats = ProductCat.all\n @gift_types = GiftType.all\n @order = Order.new\n @subscription = Subscription.new\n if @my_recommendation = @occasion.product_recommendations.first\n @recommendation = current_user.recommendations.find_by_product_id_and_occasion_id(@my_recommendation.id,@occasion.id) || current_user.recommendations.build(:product_id => @my_recommendation.id, :occasion_id => @occasion.id)\n end\n\n if @my_recommendation\n @product = Product.find(@my_recommendation.id)\n end\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @occasion }\n end\n end", "def show\n @product = Product.find(params[:id])\n @donor = Donor.all\n @event = Event.all\n @category = Category.all\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def index\n if params[:product_id]\n @promotions = Product.find(params[:product_id]).promotions\n else\n @promotions = Promotion.all\n end\n\n render json: @promotions\n end", "def show\n @star_product = Star::Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @star_product }\n end\n end", "def create\n @product = Product.new(product_args)\n\n if @product.save\n render json: Product.all, status: :created\n else\n render json: @product.errors, status: :unprocessable_entity\n end\n end", "def fetch\n Product.includes(:reviews).all\n end", "def show\n respond_to do |format|\n format.html\n format.json { render :json => @product }\n end\n end", "def create\n # See below... slightly ugly\n product_by_type\n respond_to do |format|\n if @product.save\n flash[:notice] = 'Product was successfully created.'\n format.html { redirect_to products_url }\n format.xml { head :created, :location => products_url }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @product.errors.to_xml }\n end\n end\n end", "def index\n @product_specifications = ProductSpecification.all\n end", "def set_category_classified\n @category_classified = CategoryClassified.find(params[:id])\n end", "def show\n @product = Product.find(params[:id])\n json_response(params)\n end", "def create\n @product = Product.new(params[:product])\n @manufacturers = Manufacturer.all\n @categories = Category.all\n respond_to do |format|\n if @product.save\n \n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render json: @product, status: :created, location: @product }\n else\n format.html { render action: \"new\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @products = Product.all\n render json: {is_success: true, error_code: 200, message: \"Products Found Successfully\", result: @products}, status: 200\n end", "def index\n @products = Product.all\n msg = { status: 200 , product: @products }\n respond_to do |format|\n format.html { render json: msg }\n format.json { render json: msg }\n end\n end", "def index\n @classifiers = Classifier.all\n end", "def show\n json_response(@api_v1_product)\n end", "def index\n @user_interactive_products = UserInteractiveProduct.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @user_interactive_products }\n end\n end", "def get_products_by_category\n json_response({ message: 'NOT IMPLEMENTED' })\n end", "def show\n @product = ProductProduct.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def index\n @products = Product.all\n respond_to do |format|\n format.html\n format.json { render :json => @product }\n end\n end", "def create\n if @product.save\n render :show, status: :created, location: api_v1_product_path(@product)\n else\n render json: @product.errors, status: :unprocessable_entity\n end\n end", "def show\n @productcategory = Productcategory.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @productcategory }\n end\n end", "def user_products\n @products = current_user.products\n\n respond_to do |format|\n format.html\n format.json { render json: @products }\n end\n end", "def products\n coach.courts\n end", "def show\n @productonegocio = Productonegocio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @productonegocio }\n end\n end", "def search\n\n @artists = Artist.where{name.like my{\"%#{params[:name_like]}%\"}}\n\n limit_search_for_product_type = params[\"for-product\"]\n unless limit_search_for_product_type.blank?\n raise \"'#{limit_search_for_product_type}' is not a known product type.\" unless Artist::PRODUCT_ARTIST_PRACTICES_MAPPING.has_key? limit_search_for_product_type.to_sym\n #limit on artists having practices compliant with product type\n @artists = @artists.operates_as(Artist::PRODUCT_ARTIST_PRACTICES_MAPPING[limit_search_for_product_type.to_sym])\n end\n\n \trespond_with @artists do |format|\n format.json { render :json => @artists.limit(5).map{ |a| {name: a.name, id: a.id} } }\n end\n end", "def index\n @product_cats = ProductCat.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @product_cats }\n end\n end", "def show\n @product_cat = ProductCat.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product_cat }\n end\n end", "def index\n @tipo_products = TipoProduct.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tipo_products }\n end\n end", "def show\n @product = Product.where([\"id = ?\", params[:id].to_i]).first\n raise NoProductError if @product.blank?\n\n @providers = @product.providers\n @product_contents = @product.contents\n\n @shop = @product.shop\n raise NoShopError if @shop.blank?\n \n @reviews = @product.reviews\n @review_images = @product.review_images\n \n @main_review = @reviews.first\n @main_image = @product.images.try(:first)\n @countries = Country.all\n\n add_breadcrumb \"#{@shop.name} - #{@product.name} 商品詳細\", product_path\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def index\n @clasifications = Clasification.all\n end", "def index\n @title = t('admin.promotions.index.title')\n @promotions = ( @product ? @product.promotions : Promotion.all )\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @promotions }\n end\n end", "def show\n @product_category = ProductCategory.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @product_category }\n end\n end", "def index\n @food_products = FoodProduct.all\n render json: @food_products\n end", "def product_skus_json\n @product_skus_json = []\n @order = Spree::Order.find_by_id(params[:order_id])\n @products = @order.seller.products.where(:kit_id=>nil) if @order.present?\n @products.each do |product|\n product_variants = []\n product_variants << (product.variants.present? ? product.variants : product.master)\n product_variants = product_variants.flatten\n product_variants.each do |pv|\n #name = (pv.option_values.present? ? (product.name+\" -> \"+pv.option_values.first.presentation+\" (\"+pv.sku.to_s+\")\") : (product.name+\" (\"+pv.sku.to_s+\")\"))\n if !pv.parent_id.present?\n name = pv.sku.to_s\n @product_skus_json << {'label' => name, 'id' => pv.id} if name.downcase.include? params[:term].downcase\n end\n end\n end if @products.present?\n render :json=>@product_skus_json.to_json\n end", "def show\n @product = Product.find(params[:id])\n\n render json: @product\n end", "def create\n product = Product.new(product_params)\n if product.save\n render json: ProductSerializer.new(product).serialized_json\n end\n end", "def classified_params\n params.require(:classified).permit(:title, :description, :price, :location,:category_id,{images: []}, :images_cache)\n end", "def show\n @product = Product.find(params[:id])\n\n\n respond_to do |format|\n format.html # show.html.erb\n #format.json { respond_with @product.to_json(:method => ['color', 'size']) }\n format.json {render :json => @product.to_json(:methods => [:color, :size])}\n end\n end", "def show\n @product = Product.find(params[:id])\n render json: @product, status: :ok\n end", "def create\n models = params[:product][:models_attributes]\n if !models.nil?\n models.each do |model|\n model[1][:characteristics] = sanitize_attributes(model[1][:characteristics])\n end\n end\n clean_params = product_params\n clean_params[:specifications] = sanitize_data(clean_params[:specifications])\n clean_params[:features] = sanitize_data(clean_params[:features])\n clean_params[:attributes_titles] = sanitize_attributes(clean_params[:attributes_titles])\n\n @product = Product.new(clean_params)\n respond_to do |format|\n if @product.save\n format.html { redirect_to [:admin, @product], notice: 'Product was successfully created.' }\n format.json { render action: 'show', status: :created, location: @product }\n else\n format.html { render action: 'new' }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def show\n @magento_product = MagentoProduct.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @magento_product }\n end\n end", "def create\n @product_use_printrun = ProductUsePrintrun.new(params[:product_use_printrun])\n @product_categories = ProductCategory.find(:all)\n checked_features = check_features_using_helper( params[:product_prints_list], ProductCategory, @product_use_printrun.product_categories )\n respond_to do |format|\n if @product_use_printrun.save\n flash[:notice] = 'ProductUsePrintrun was successfully created.'\n format.html { redirect_to :controller => 'product_categories', :action => \"index\" }\n format.xml { render :xml => @product_use_printrun, :status => :created, :location => @product_use_printrun }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @product_use_printrun.errors, :status => :unprocessable_entity }\n end\n end\n end", "def classify(text)\n choose classifications(text)\n end" ]
[ "0.6844924", "0.6745986", "0.62244594", "0.60901225", "0.5894066", "0.5810741", "0.5747263", "0.57136434", "0.5658734", "0.5658734", "0.5609556", "0.556197", "0.5499586", "0.546859", "0.54645693", "0.5433276", "0.542446", "0.5407946", "0.53917056", "0.53910464", "0.5390255", "0.53714174", "0.53638697", "0.53611064", "0.53463274", "0.53393817", "0.5328786", "0.5319806", "0.53029335", "0.52919996", "0.5289124", "0.5278839", "0.527095", "0.5261091", "0.52500176", "0.5247319", "0.5245389", "0.5244005", "0.5242412", "0.52409476", "0.52397054", "0.5235106", "0.5233333", "0.52305114", "0.5225956", "0.52152133", "0.5211212", "0.52097917", "0.5208398", "0.52061594", "0.5203499", "0.51970536", "0.51951873", "0.51930153", "0.5190107", "0.5188974", "0.5184539", "0.5181696", "0.51671", "0.51656735", "0.51643056", "0.5164193", "0.5161799", "0.51579505", "0.5153611", "0.5153497", "0.5146372", "0.51364243", "0.51296216", "0.511528", "0.51143354", "0.51113033", "0.5109492", "0.5104955", "0.5103181", "0.50969154", "0.5094815", "0.5093091", "0.50919235", "0.5090847", "0.5087243", "0.50852424", "0.5081339", "0.5068745", "0.5067502", "0.5066068", "0.50622594", "0.50547427", "0.50520325", "0.50381714", "0.5037596", "0.50332403", "0.50316083", "0.50287485", "0.5028459", "0.50273097", "0.5026391", "0.50210994", "0.5020782", "0.50137746" ]
0.50745887
83
GET /product_classifies/1 GET /product_classifies/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_product_classify\n @product_classify = ProductClassify.find(params[:id])\n end", "def create\n @product_classify = ProductClassify.new(product_classify_params)\n\n respond_to do |format|\n if @product_classify.save\n format.html { redirect_to :product_classifies, notice: '产品分类添加成功。' }\n format.json { render :show, status: :created, location: @product_classify }\n else\n format.html { render :new }\n format.json { render json: @product_classify.errors, status: :unprocessable_entity }\n end\n end\n end", "def classifications(classification)\n params = {\n classification: classification\n }.compact\n\n _get(\"/account/classifications\", params) { |json| json }\n end", "def index\n @classifieds = Classified.all\n end", "def update\n respond_to do |format|\n if @product_classify.update(product_classify_params)\n format.html { redirect_to :product_classifies, notice: '产品分类修改成功。' }\n format.json { render :show, status: :ok, location: @product_classify }\n else\n format.html { render :edit }\n format.json { render json: @product_classify.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @classified = Classified.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @classified }\n end\n end", "def index\n @item_classifications = ItemClassification.all\n end", "def create\n @classified = Classified.new(classified_params)\n respond_to do |format|\n if @classified.save\n format.html { redirect_to @classified, notice: 'Classified was successfully created.' }\n format.json { render :show, status: :created, location: @classified }\n else\n format.html { render :new }\n format.json { render json: @classified.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_classified\n @classified = Classified.find(params[:id])\n end", "def set_classified\n @classified = Classified.find(params[:id])\n end", "def show\n @review = Review.find(params[:id])\n @product = @review.product\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @review }\n end\n end", "def show\n @classified = Classified.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @classified }\n end\n end", "def show\n @home_searches_product = Home::Searches::Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @home_searches_product }\n end\n end", "def create\n Rails.logger.debug \"[ClassificationsController.create] params.class: #{params.class}, params: #{params}\"\n @classifaction = Classification.new transaction_data: params\n @classifaction.classifiers << StatusCodeClassifier.classify( @classifaction.transaction_data )\n @classifaction.classify\n\n if @classifaction.save\n render json: @classifaction.as_jsonapi, status: :created\n else\n render json: { error: 'oops' }, status: 500\n end\n end", "def index\n #deeply nested... so starts with gyms,goes to trainers,goes to clients.\n #since clients belongs to trainer we use trainer here..\n #but in trainers_controller the trainers belongs to gyms so gyms is used orignally.\n @product=Product.find(params[:product_id])\n @reviews=Review.where(product_id: @product.id)\n render json:@reviews, status: :ok\n end", "def show\n @shopifyproduct = Shopifyproduct.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @shopifyproduct }\n end\n end", "def index\n @category_classifieds = CategoryClassified.all\n end", "def show\n @product = Product.find(params[:id]) \n # @product_id = @product.id\n # @review = Review.find(@product_id)\n\n # @reviews = Review.where(:product_id => params[:id])\n @reviews = Review.where(:product_id => @product.id)\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n render json: @product, status: 200\n end", "def show\n @recommendation = Recommendation.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @recommendation }\n end\n end", "def show\n @clasificacion_pegi = ClasificacionPegi.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @clasificacion_pegi }\n end\n end", "def create\n #@classified = Classified.new(classified_params)\n @classified = current_user.classifieds.new(classified_params)\n\n respond_to do |format|\n if @classified.save\n format.html { redirect_to @classified, notice: 'Classified was successfully created.' }\n format.json { render :show, status: :created, location: @classified }\n else\n format.html { render :new }\n format.json { render json: @classified.errors, status: :unprocessable_entity }\n end\n end\n end", "def show\n @product = Product.eager_loading.find_by_uuid(params[:id])\n\n respond_to do |format|\n format.html { redirect_to edit_shop_product_path(@product.shop_id, @product)}\n format.json { render json: @product.as_json(:include => {:product_variants => {:include => [:option_types,:pictures]}, :shipping_category => {}}, :methods => [:taxon_ids]) }\n end\n end", "def set_recipe_classify\n @recipe_classify = RecipeClassify.find(params[:id])\n end", "def show\n @category = Category.find(params[:id])\n @categories = Category.order(\"name ASC\")\n @product_list = @category.products_sorted_by_average_product_rating\n @review = Review.new\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @category }\n end\n end", "def product_classify_params\n params.require(:product_classify).permit(:name, :intro)\n end", "def show\n @classification = Classification.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @classification }\n end\n end", "def show\n @productcategory = Productcategory.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @productcategory }\n end\n end", "def show\n result = Product.find(params[:id])\n render json: {\n status: :ok,\n product: result\n } \n end", "def show\n @star_product = Star::Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @star_product }\n end\n end", "def show\n @product = Product.find(params[:id])\n @photos = @product.photos\n\t@related_products = Product.where(\"category_id = ? and manufacturer_id = ? and id <> ?\", @product.category, @product.manufacturer,@product.id ).limit(6)\n @reviews = @product.reviews.paginate(:page => params[:page], :per_page => 10)\n @manufacturer_products = @product.manufacturer.products.where(\"id <> ?\",@product.id).limit(5) unless @product.manufacturer.nil?\n if (current_user != nil)\n @cart = User.find(session[:user_id]).cart\n end\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n json_response(@api_v1_product)\n end", "def show\n @productonegocio = Productonegocio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @productonegocio }\n end\n end", "def show\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product_type }\n end\n end", "def show\n render json: @product\n end", "def show\n @product_category = ProductCategory.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @product_category }\n end\n end", "def show\n @occasion = Occasion.find(params[:id])\n @products = Product.all\n @productcats = ProductCat.all\n @gift_types = GiftType.all\n @order = Order.new\n @subscription = Subscription.new\n if @my_recommendation = @occasion.product_recommendations.first\n @recommendation = current_user.recommendations.find_by_product_id_and_occasion_id(@my_recommendation.id,@occasion.id) || current_user.recommendations.build(:product_id => @my_recommendation.id, :occasion_id => @occasion.id)\n end\n\n if @my_recommendation\n @product = Product.find(@my_recommendation.id)\n end\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @occasion }\n end\n end", "def show\n @product_cat = ProductCat.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product_cat }\n end\n end", "def destroy\n @product_classify.destroy\n respond_to do |format|\n format.html { redirect_to product_classifies_url, notice: '产品分类删除成功。' }\n format.json { head :no_content }\n end\n end", "def show\n render json: @product\n end", "def show\n render json: @food_product\n end", "def new\n @shopifyproduct = Shopifyproduct.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @shopifyproduct }\n end\n end", "def index\n @clasifications = Clasification.all\n end", "def show\n if @product.present?\n render json: {is_success: true, error_code: 200, message: \"Found Successfully\", result: @product}, status: 200\n end\n end", "def show\n @product = Product.find(params[:id])\n json_response(params)\n end", "def show\n @tipo_product = TipoProduct.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tipo_product }\n end\n end", "def show\n @product = ProductProduct.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @products = Product.find_by_id(params[:id])\n msg = { status: 200 , product: @products }\n respond_to do |format|\n format.html { render json: msg }\n format.json { render json: msg }\n end\n end", "def show\n @test.relations = Relation.joins(:question).where(\"relations.test_id = ?\", @test.id).select(\"relations.id, questions.identifier, questions.description\")\n @quantity = Relation.joins(:question).where(\"relations.test_id = ?\", @test.id).select(\"relations.id, questions.identifier, questions.description\").count(:all)\n questions = Question.where(\"questions.id IN (?)\", Relation.where(\"test_id = ?\", @test.id).select(\"question_id\"))\n classificat = Classification.all\n\n classifications = []\n \n questions.each do |question|\n classif = {}\n value = false\n if classifications === []\n classif['classification'] = question.classification_id\n classif['quantity'] = 1\n classifications.push(classif)\n else\n for i in 0..classifications.length-1\n if classifications[i]['classification'] === question.classification_id\n classifications[i]['quantity'] = classifications[i]['quantity'] + 1 \n value = true\n break\n end\n end\n if value === false\n classif['classification'] = question.classification_id\n classif['quantity'] = 1\n classifications.push(classif) \n end\n end\n end\n\n classificat.each do |classif|\n for i in 0..classifications.length-1\n if classifications[i]['classification'] === classif.id\n classifications[i]['classification'] = classif.description\n break\n end\n end\n end\n @classifications = classifications\n end", "def show\n @product = Product.find(params[:id])\n\n render json: @product\n end", "def show\n @body_style_product_feature = BodyStyleProductFeature.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @body_style_product_feature }\n end\n end", "def show\n @product = Product.find(params[:id])\n @donor = Donor.all\n @event = Event.all\n @category = Category.all\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def get_product\n json_response({ message: 'NOT IMPLEMENTED' })\n end", "def index\n @project_classifications = ProjectClassification.all\n end", "def show\n @onecompany_product = Onecompany::Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @onecompany_product }\n end\n end", "def show\n @citizenship_class = @grantee.citizenship_classes.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @citizenship_class }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n @comment = Comment.find(:all, :conditions => {:product_id =>@product.id})\n @questions = Question.find(:all, :conditions => {:product_id =>@product.id})\n @answer = Answer.find(:all)\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n respond_to do |format|\n format.html\n format.json { render :json => @product }\n end\n end", "def show\n @product = Product.where([\"id = ?\", params[:id].to_i]).first\n raise NoProductError if @product.blank?\n\n @providers = @product.providers\n @product_contents = @product.contents\n\n @shop = @product.shop\n raise NoShopError if @shop.blank?\n \n @reviews = @product.reviews\n @review_images = @product.review_images\n \n @main_review = @reviews.first\n @main_image = @product.images.try(:first)\n @countries = Country.all\n\n add_breadcrumb \"#{@shop.name} - #{@product.name} 商品詳細\", product_path\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n render json: @product, status: :ok\n end", "def show\n @carts_product = @cart.carts_products.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @carts_product }\n end\n end", "def create\n @clasification = Clasification.new(clasification_params)\n\n respond_to do |format|\n if @clasification.save\n format.html { redirect_to @clasification, notice: \"Clasification was successfully created.\" }\n format.json { render :show, status: :created, location: @clasification }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @clasification.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @classifiers = Classifier.all\n end", "def index\n 3.times { @product.product_specifications.build }\n respond_to do |format|\n format.html { render_template } # index.html.erb\n format.xml { render xml: @product_specifications }\n end\n end", "def new\n @star_product = Star::Product.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @star_product }\n end\n end", "def create\n @classifier = Classifier.new(classifier_params)\n\n respond_to do |format|\n if @classifier.save\n format.html { redirect_to @classifier, notice: 'Classifier was successfully created.' }\n format.json { render :show, status: :created, location: @classifier }\n else\n format.html { render :new }\n format.json { render json: @classifier.errors, status: :unprocessable_entity }\n end\n end\n end", "def show\n product = Product.find_by_id(params[:id])\n\n render json: product\n end", "def show\n @product = @person.products.find(params[:id])\n\n respond_to do |format|\n format.json { render :json => @product }\n end\n end", "def show\n # @ccbs_product = CcbsProduct.find(params[:id])\n\n prd_attribute = PrdAttribute.find(params[:id], :include => :products)\n product = Product.find(prd_attribute.products[0].id, :include => [:prd_subscriptions, :prd_additional_services])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @ccbs_product }\n format.json {\n\n ccbs_product = CcbsProduct.new\n tariff_list = ccbs_product.set_fields(prd_attribute, product.prd_subscriptions, product.prd_additional_services)\n\n # product에 대해 전달\n results = mapping_to_hash(ccbs_product,CcbsProduct.json_mapping_table)\n ccbs_product.send_to_ccbs('POST', results.to_json)\n\n # tariff에 대해서 전달\n tariff_list.each { |product_tariff| \n to_ccbs_hash = mapping_to_hash(product_tariff, CcbsProductTariff.json_mapping_table)\n product_tariff.send_to_ccbs(\"POST\", to_ccbs_hash.to_json) }\n\n render :json => results\n } \n end\n end", "def show\n @producttype = Producttype.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @producttype }\n end\n end", "def index\n @citizenship_classes = @grantee.citizenship_classes.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @citizenship_classes }\n end\n end", "def create\n @category_classified = CategoryClassified.new(category_classified_params)\n\n respond_to do |format|\n if @category_classified.save\n format.html { redirect_to @category_classified, notice: 'Category classified was successfully created.' }\n format.json { render :show, status: :created, location: @category_classified }\n else\n format.html { render :new }\n format.json { render json: @category_classified.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @tipo_products = TipoProduct.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tipo_products }\n end\n end", "def show\n @proficiency = Proficiency.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @proficiency }\n end\n end", "def with_photo\n @classifieds = Classified.with_photos\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @classifieds }\n end\n end", "def index\n respond_to do |format|\n format.html { render_template } # index.html.erb\n format.xml { render xml: @product_training_classes }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n render json: @product\n end", "def index\n @product_cats = ProductCat.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @product_cats }\n end\n end", "def fetch\n Product.includes(:reviews).all\n end", "def show\n @user_interactive_product = UserInteractiveProduct.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @user_interactive_product }\n end\n end", "def show\n @product_type = ProductType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @product_type }\n end\n end", "def new\n @product = Product.new\n @categories = Category.find(:all)\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @product }\n end\n end", "def index\n @products = Product.order('category, priority desc, price')\n @basket_size = count_basket_items\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @products }\n end\n end", "def view_product\n to_json(\n only: [:id, :title, :description, :key_information],\n methods: [:photo_url, :net_mrp, :mrp_per_unit, :quantity],\n :include => {\n store: {\n only: [:name, :id],\n methods: [:full_address]\n }\n }\n )\n end", "def show\n @product = Product.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product_cost = ProductCost.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @product_cost }\n end\n end", "def index\n if params[:product_id]\n @promotions = Product.find(params[:product_id]).promotions\n else\n @promotions = Promotion.all\n end\n\n render json: @promotions\n end", "def show\n render json: @product_management\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end" ]
[ "0.67501", "0.6646705", "0.62797654", "0.61795616", "0.6048743", "0.5894845", "0.58254766", "0.58219004", "0.5773847", "0.5773847", "0.5762598", "0.5757497", "0.5748493", "0.5729011", "0.571064", "0.56998605", "0.5691853", "0.56774294", "0.5668963", "0.56607413", "0.5651636", "0.56273884", "0.5619526", "0.5606931", "0.5596092", "0.5592405", "0.5584218", "0.5581225", "0.55728626", "0.5571475", "0.5548074", "0.55451137", "0.5544839", "0.5537942", "0.553673", "0.5531412", "0.55270356", "0.552118", "0.5517157", "0.5502766", "0.5499531", "0.5489579", "0.5488947", "0.5481639", "0.5481271", "0.54650605", "0.54554355", "0.5455019", "0.5445063", "0.5443632", "0.5442761", "0.5431922", "0.5430816", "0.5430306", "0.54300743", "0.542461", "0.5423249", "0.5420526", "0.5417644", "0.53972167", "0.5390363", "0.53822976", "0.53814673", "0.5366291", "0.5359913", "0.53592336", "0.53584963", "0.5354661", "0.53513795", "0.535076", "0.53501886", "0.5345852", "0.53444093", "0.53415173", "0.53412485", "0.53393155", "0.5337937", "0.5337588", "0.53361315", "0.53271085", "0.5324774", "0.5316423", "0.5312406", "0.53081685", "0.53068507", "0.5306025", "0.5304031", "0.5301158", "0.52981937", "0.52894974", "0.5288714", "0.5288714", "0.5288714", "0.5288714", "0.5288714", "0.5288714", "0.5288714", "0.5288714", "0.5288714", "0.5288714", "0.5288714" ]
0.0
-1
POST /product_classifies POST /product_classifies.json
def create @product_classify = ProductClassify.new(product_classify_params) respond_to do |format| if @product_classify.save format.html { redirect_to :product_classifies, notice: '产品分类添加成功。' } format.json { render :show, status: :created, location: @product_classify } else format.html { render :new } format.json { render json: @product_classify.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_product_classify\n @product_classify = ProductClassify.find(params[:id])\n end", "def create\n @classified = Classified.new(classified_params)\n respond_to do |format|\n if @classified.save\n format.html { redirect_to @classified, notice: 'Classified was successfully created.' }\n format.json { render :show, status: :created, location: @classified }\n else\n format.html { render :new }\n format.json { render json: @classified.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n Rails.logger.debug \"[ClassificationsController.create] params.class: #{params.class}, params: #{params}\"\n @classifaction = Classification.new transaction_data: params\n @classifaction.classifiers << StatusCodeClassifier.classify( @classifaction.transaction_data )\n @classifaction.classify\n\n if @classifaction.save\n render json: @classifaction.as_jsonapi, status: :created\n else\n render json: { error: 'oops' }, status: 500\n end\n end", "def update\n respond_to do |format|\n if @product_classify.update(product_classify_params)\n format.html { redirect_to :product_classifies, notice: '产品分类修改成功。' }\n format.json { render :show, status: :ok, location: @product_classify }\n else\n format.html { render :edit }\n format.json { render json: @product_classify.errors, status: :unprocessable_entity }\n end\n end\n end", "def product_classify_params\n params.require(:product_classify).permit(:name, :intro)\n end", "def create\n @category_classified = CategoryClassified.new(category_classified_params)\n\n respond_to do |format|\n if @category_classified.save\n format.html { redirect_to @category_classified, notice: 'Category classified was successfully created.' }\n format.json { render :show, status: :created, location: @category_classified }\n else\n format.html { render :new }\n format.json { render json: @category_classified.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n #@classified = Classified.new(classified_params)\n @classified = current_user.classifieds.new(classified_params)\n\n respond_to do |format|\n if @classified.save\n format.html { redirect_to @classified, notice: 'Classified was successfully created.' }\n format.json { render :show, status: :created, location: @classified }\n else\n format.html { render :new }\n format.json { render json: @classified.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @classifier = Classifier.new(classifier_params)\n\n respond_to do |format|\n if @classifier.save\n format.html { redirect_to @classifier, notice: 'Classifier was successfully created.' }\n format.json { render :show, status: :created, location: @classifier }\n else\n format.html { render :new }\n format.json { render json: @classifier.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @item_classification = ItemClassification.new(item_classification_params)\n\n respond_to do |format|\n if @item_classification.save\n format.html { redirect_to @item_classification, notice: 'Classificação criada com sucesso.' }\n format.json { render :show, status: :created, location: @item_classification }\n else\n format.html { render :new }\n format.json { render json: @item_classification.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n models = params[:product][:models_attributes]\n if !models.nil?\n models.each do |model|\n model[1][:characteristics] = sanitize_attributes(model[1][:characteristics])\n end\n end\n clean_params = product_params\n clean_params[:specifications] = sanitize_data(clean_params[:specifications])\n clean_params[:features] = sanitize_data(clean_params[:features])\n clean_params[:attributes_titles] = sanitize_attributes(clean_params[:attributes_titles])\n\n @product = Product.new(clean_params)\n respond_to do |format|\n if @product.save\n format.html { redirect_to [:admin, @product], notice: 'Product was successfully created.' }\n format.json { render action: 'show', status: :created, location: @product }\n else\n format.html { render action: 'new' }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @shopifyproduct = Shopifyproduct.new(params[:shopifyproduct])\n\n respond_to do |format|\n if @shopifyproduct.save\n format.html { redirect_to @shopifyproduct, notice: 'Shopifyproduct was successfully created.' }\n format.json { render json: @shopifyproduct, status: :created, location: @shopifyproduct }\n else\n format.html { render action: \"new\" }\n format.json { render json: @shopifyproduct.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(product_args)\n\n if @product.save\n render json: Product.all, status: :created\n else\n render json: @product.errors, status: :unprocessable_entity\n end\n end", "def create\n @clasification = Clasification.new(clasification_params)\n\n respond_to do |format|\n if @clasification.save\n format.html { redirect_to @clasification, notice: \"Clasification was successfully created.\" }\n format.json { render :show, status: :created, location: @clasification }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @clasification.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product_use_printrun = ProductUsePrintrun.new(params[:product_use_printrun])\n @product_categories = ProductCategory.find(:all)\n checked_features = check_features_using_helper( params[:product_prints_list], ProductCategory, @product_use_printrun.product_categories )\n respond_to do |format|\n if @product_use_printrun.save\n flash[:notice] = 'ProductUsePrintrun was successfully created.'\n format.html { redirect_to :controller => 'product_categories', :action => \"index\" }\n format.xml { render :xml => @product_use_printrun, :status => :created, :location => @product_use_printrun }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @product_use_printrun.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @called_from = params[:called_from] || 'product'\n respond_to do |format|\n if @product_training_class.save\n format.html { redirect_to([:admin, @product_training_class.training_class], notice: 'Product/training class was successfully created.') }\n format.xml { render xml: @product_training_class, status: :created, location: @product_training_class }\n format.js\n website.add_log(user: current_user, action: \"Added training class for #{@product_training_class.product.name}\")\n else\n format.html { render action: \"new\" }\n format.xml { render xml: @product_training_class.errors, status: :unprocessable_entity }\n end\n end\n end", "def classified_params\n params.require(:classified).permit(\n :id,\n :title,\n :document_type,\n :document_number,\n :seller_name,\n :email,\n :landline,\n :cell_phone,\n :description,\n :price,\n :user_id,\n :bonded,\n :classified_conditional\n )\n end", "def create\n @product = Product.find(product_review_params[:product_id])\n @product_review = ProductReview.new(product_review_params)\n\n respond_to do |format|\n if @product_review.save\n format.html { redirect_to @product, notice: 'Product review was successfully created.' }\n format.json { render :show, status: :created, location: @product_review }\n else\n format.html { render :new }\n format.json { render json: @product_review.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(params[:product])\n @manufacturers = Manufacturer.all\n @categories = Category.all\n respond_to do |format|\n if @product.save\n \n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render json: @product, status: :created, location: @product }\n else\n format.html { render action: \"new\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(product_params)\n\n if @product.save\n render json: @product, status: :created\n else\n render json: @product.errors, status: :unprocessable_entity\n end\n end", "def set_classified\n @classified = Classified.find(params[:id])\n end", "def set_classified\n @classified = Classified.find(params[:id])\n end", "def create\n @business = Business.new(business_params)\n @business.save\n extract_classifications\n respond_to do |format|\n format.html { redirect_to \"/businesses/upload/#{@business.id}\", notice: 'Product was successfully updated.' }\n end\n end", "def create\n # See below... slightly ugly\n product_by_type\n respond_to do |format|\n if @product.save\n flash[:notice] = 'Product was successfully created.'\n format.html { redirect_to products_url }\n format.xml { head :created, :location => products_url }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @product.errors.to_xml }\n end\n end\n end", "def create\n @product = Product.new(params[:product])\n\n collect_and_assign_product_attributes\n collect_and_assign_new_categories\n\n respond_to do |format|\n if @product.save\n flash[:notice] = 'Product was successfully created.'\n format.html { redirect_to(admin_product_path(@product)) }\n format.xml { render :xml => @product, :status => :created, :location => @product }\n else\n assign_lovs\n format.html { render :action => \"new\" }\n format.xml { render :xml => @product.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(product_params)\n\n if @product.save\n render json: @product, status: :created, location: @product\n else\n render json: @product.errors, status: :unprocessable_entity\n end\n end", "def create # rubocop:disable MethodLength\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html do\n redirect_to @product, notice: 'Product was successfully created.'\n end\n format.json { render :show, status: :created, location: @product }\n else\n @categories = Category.all\n format.html { render :new }\n format.json do\n render json: @product.errors, status: :unprocessable_entity\n end\n end\n end\n end", "def create\n product = Product.new(product_params)\n if product.save\n render json: ProductSerializer.new(product).serialized_json\n end\n end", "def create\n @product = Product.create!(product_params)\n json_response(@product, :created)\n end", "def create\n @taxon_name_classification = TaxonNameClassification.new(taxon_name_classification_params)\n\n respond_to do |format|\n if @taxon_name_classification.save\n format.html { redirect_to @taxon_name_classification.taxon_name.metamorphosize, notice: 'Taxon name classification was successfully created.' }\n format.json { render json: @taxon_name_classification, status: :created, location: @taxon_name_classification.metamorphosize }\n else\n format.html { redirect_to :back, notice: 'Taxon name classification was NOT successfully created.' }\n format.json { render json: @taxon_name_classification.errors, status: :unprocessable_entity }\n end\n end\n end", "def classified_params\n params.require(:classified).permit(:title, :description, :price, :location,:category_id,{images: []}, :images_cache)\n end", "def create\n product = Product.new(\n name: params[:name],\n net_price: params[:net_price]\n )\n\n if product.save\n format_response({ success: true, message: \"Product '#{product.name}' has been created\" }) and return\n else\n format_response({ success: false, message: product.errors.full_messages.to_sentence }) and return\n end\n end", "def create\n @classification = Classification.new(classification_params)\n\n respond_to do |format|\n if @classification.save\n format.html { redirect_to @classification, notice: t('controller.successfully_created', model: t('activerecord.models.classification')) }\n format.json { render json: @classification, status: :created, location: @classification }\n else\n @classification_types = ClassificationType.all\n format.html { render action: \"new\" }\n format.json { render json: @classification.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(product_params)\n\n if @product.save\n render json: @product, status: :created\n else\n render json: @product.errors, status: :unprocessable_entity\n end\n end", "def create\n @product = Product.new(params[:product])\n @category = @product.category\n \n if @product.category.wishlist?\n \t@product.status = \"0\"\n \t@product.status_date = Time.now\n \t\n \t#we are a wish list item... check to see if anybody is looking for us.\n \t#maybe we ignore this step here and leave it to daily processing.\n end\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render json: @product, status: :created, location: @product }\n else\n format.html { render action: \"new\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(params[:product])\n\n respond_to do |format|\n if @product.save\n prefix = @product.name.first.upcase\n @product.update_attribute(:name_prefix, prefix)\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render json: @product, status: :created, location: @product }\n else\n format.html { render action: \"new\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n pfid = begin\n self.product_family_id\n rescue NoMethodError\n 0\n end\n connection.post(\"/product_families/#{pfid}/products.#{self.class.format.extension}\", encode, self.class.headers).tap do |response|\n self.id = id_from_response(response)\n load_attributes_from_response(response)\n end\n end", "def create\n pfid = begin\n self.product_family_id\n rescue NoMethodError\n 0\n end\n connection.post(\"/product_families/#{pfid}/products.#{self.class.format.extension}\", encode, self.class.headers).tap do |response|\n self.id = id_from_response(response)\n load_attributes_from_response(response)\n end\n end", "def create\n @discounts_product = DiscountsProduct.new(discounts_product_params)\n\n respond_to do |format|\n if @discounts_product.save\n format.html { redirect_to @discounts_product, notice: 'Discounts product was successfully created.' }\n format.json { render :show, status: :created, location: @discounts_product }\n else\n format.html { render :new }\n format.json { render json: @discounts_product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(product_params)\n @product.user = current_api_v1_user\n respond_to do |format|\n if @product.save\n params[:product][:properties].try(:each) do |k,v|\n @product.product_properties.create(property: Property.find(k), value: v)\n end\n params[:product][:colors].try(:each) do |c|\n @product.colors.create(name: c[:name].downcase, code: c[:code])\n end\n params[:product][:photos].try(:each) do |c|\n @product.photos.create(image: c)\n end\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created}\n else\n format.html { render :new }\n format.json { render json: @product.errors.full_messages, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = @collection.products.build(product_params)\n\n if @product.save\n render json: @product, status: :created#, location: @collection\n else\n render json: @product.errors, status: :unprocessable_entity\n end\n end", "def create\n @product = Product.new(product_params)\n if @product.save\n render json: {id: @product.id}\n else\n render json: {msg: @product.errors.full_messages.first}, status: :unprocessable_entity\n end\n end", "def create\n @home_searches_product = Home::Searches::Product.new(params[:home_searches_product])\n\n respond_to do |format|\n if @home_searches_product.save\n format.html { redirect_to @home_searches_product, notice: 'Product was successfully created.' }\n format.json { render json: @home_searches_product, status: :created, location: @home_searches_product }\n else\n format.html { render action: \"new\" }\n format.json { render json: @home_searches_product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @review = Review.new(review_params)\n @review.user = current_user\n @product = Product.find(params[:product_id])\n @review.product = @product\n\n respond_to do |format|\n if @review.save\n format.html { redirect_to @product, notice: 'Review was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { redirect_to @product, notice: 'There was an error!' }\n format.json { render json: @review.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = current_user.products.new(name: product_params[:name],description:product_params[:description],price:product_params[:price])\n @product.brand = Brand.find_by(brandName: product_params[:brand])\n @product.categories = Category.where(category:product_params[:category])\n respond_to do |format|\n if @product.save \n format.html { redirect_to new_product_location_path(@product), notice: \"Product was successfully created.\"}\n format.json { render json: @product}\n \n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(params[:product])\n @product.image = params[:image] if params[:image]\n #params[:product][:category_ids].each{|c|\n # @product.category = c\n #}\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render json: @product, status: :created, location: @product }\n else\n format.html { render action: \"new\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def post_to_newgistics\n document = Spree::Newgistics::DocumentBuilder.build_product([self])\n response = Spree::Newgistics::HTTPManager.post('/post_products.aspx', document)\n\n if response.status == 200\n errors = Nokogiri::XML(response.body).css('errors').children.any?\n update_column(:posted_to_newgistics, true) unless errors\n end\n\n end", "def create\n @product = Product.new(product_params)\n\n if @product.save\n render json: @product, status: :created, location: @product\n else\n render json: @product.errors, status: :unprocessable_entity\n end\n end", "def create\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @star_product = Star::Product.new(params[:star_product])\n\n respond_to do |format|\n if @star_product.save\n format.html { redirect_to @star_product, notice: 'Product was successfully created.' }\n format.json { render json: @star_product, status: :created, location: @star_product }\n else\n format.html { render action: \"new\" }\n format.json { render json: @star_product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product_variation = ProductVariation.new(product_variation_params)\n\n respond_to do |format|\n if @product_variation.save\n format.html { redirect_to @product_variation, notice: 'Product variation was successfully created.' }\n format.json { render :show, status: :created, location: @product_variation }\n else\n format.html { render :new }\n format.json { render json: @product_variation.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n return unless product_params\n render json: Product.create_product(\n @product_params,\n category_list,\n @current_user.id\n ).simple_info, status: :created\n rescue => e\n render json: { error: e }, status: :bad_request\n end", "def create\n @project_classification = ProjectClassification.new(project_classification_params)\n\n respond_to do |format|\n if @project_classification.save\n format.html { redirect_to project_classifications_path, notice: 'Project classification was successfully created.' }\n format.json { render :show, status: :created, location: @project_classification }\n else\n format.html { render :new }\n format.json { render json: @project_classification.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n if @product.save\n render :show, status: :created, location: api_v1_product_path(@product)\n else\n render json: @product.errors, status: :unprocessable_entity\n end\n end", "def create_product(prod)\n\n purchase_price = BigDecimal.new(\"0.0\")\n purchase_price = BigDecimal.new(prod['purchase_price'].to_s) unless prod['purchase_price'].nil?\n sales_price = nil\n sales_price = BigDecimal.new(prod['sales_price']) unless prod['sales_price'].nil?\n weight = 0\n weight = prod['weight'].to_f unless prod['weight'].nil?\n manufacturer_product_code = prod['manufacturer_product_code']\n stock = prod['stock'].to_i unless prod['stock'].nil?\n\n tax_percentage = prod['tax_percentage'] || 8.0\n tax_class = TaxClass.where(:percentage => tax_percentage).first unless tax_percentage.nil?\n if tax_class.nil?\n tax_class = TaxClass.create(:percentage => 8.0, :name => \"8.0\")\n end\n\n prod['description'].blank? ? description = \"No description\" : description = prod['description']\n \n is_featured = false\n is_featured = true if [\"yes\", \"true\", \"1\"].include?(prod['featured'])\n is_visible = true\n is_visible = false if [\"no\", \"false\", \"0\"].include?(prod['visible'])\n is_build_to_order = false\n is_build_to_order = true if [\"yes\", \"true\", \"1\"].include?(prod['build_to_order'])\n \n supplier = Supplier.find_by_name(prod['supplier'])\n\n product = Product.where(:name => prod['name'],\n :description => description,\n :weight => weight,\n :sales_price => sales_price,\n :supplier_id => supplier,\n :tax_class_id => tax_class,\n :purchase_price => purchase_price,\n :manufacturer_product_code => manufacturer_product_code,\n :is_featured => is_featured,\n :is_visible => is_visible,\n :is_build_to_order => is_build_to_order,\n :stock => stock).first\n if product.nil?\n product = Product.create(:name => prod['name'],\n :description => description,\n :weight => weight,\n :sales_price => sales_price,\n :supplier => supplier,\n :tax_class => tax_class,\n :purchase_price => purchase_price,\n :manufacturer_product_code => manufacturer_product_code,\n :is_featured => is_featured,\n :is_visible => is_visible,\n :is_build_to_order => is_build_to_order,\n :stock => stock)\n end\n if prod['category']\n category = Category.where(:name => prod['category']).first\n category = Category.create(:name => prod['category']) if category.nil?\n product.categories << category\n product.save\n end\n\n\n # Ugly, but at least it makes test authors know what went wrong\n if product.errors.empty?\n return product\n else\n puts \"Errors creating product: #{product.errors.full_messages}\"\n return false\n end\nend", "def create\n @body_style_product_feature = BodyStyleProductFeature.new(params[:body_style_product_feature])\n\n respond_to do |format|\n if @body_style_product_feature.save\n format.html { redirect_to @body_style_product_feature, notice: 'Body style product feature was successfully created.' }\n format.json { render json: @body_style_product_feature, status: :created, location: @body_style_product_feature }\n else\n format.html { render action: \"new\" }\n format.json { render json: @body_style_product_feature.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @brand_product = BrandProduct.new(params[:brand_product])\n @review = @product.reviews.build(params[:brand_product][:review])\n respond_to do |format|\n if @brand_product.save\n format.html { redirect_to @brand_product, notice: 'Brand product was successfully created.' }\n format.json { render json: @brand_product, status: :created, location: @brand_product }\n else\n format.html { render action: \"new\" }\n format.json { render json: @brand_product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product_product_attribute = ProductProductAttribute.new(product_product_attribute_params)\n\n respond_to do |format|\n if @product_product_attribute.save\n format.html { redirect_to @product_product_attribute, notice: 'Product product attribute was successfully created.' }\n format.json { render :show, status: :created, location: @product_product_attribute }\n else\n format.html { render :new }\n format.json { render json: @product_product_attribute.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product_cost = ProductCost.new(params[:product_cost])\n\t@products = Product.find_all\n\t@tax_masters = TaxMaster.find_all\n\n respond_to do |format|\n if @product_cost.save\n format.html { redirect_to @product_cost, :notice => 'Product cost was successfully created.' }\n format.json { render :json => @product_cost, :status => :created, :location => @product_cost }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @product_cost.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @user_interactive_product = UserInteractiveProduct.new(params[:user_interactive_product])\n\n respond_to do |format|\n if @user_interactive_product.save\n format.html { redirect_to @user_interactive_product, notice: 'User interactive product was successfully created.' }\n format.json { render json: @user_interactive_product, status: :created, location: @user_interactive_product }\n else\n format.html { render action: \"new\" }\n format.json { render json: @user_interactive_product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @cp_product = Product.new(cp_product_params)\n\n respond_to do |format|\n if @cp_product.save\n format.html { redirect_to cp_product_url(@cp_product), notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @cp_product }\n else\n format.html { render :new }\n format.json { render json: @cp_product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n if signed_in?\n @classified = current_user.classifieds.build(params[:classified])\n else\n if user_present?(params[:email]) # checks whether user is already present ...and if present assigns it to @user\n redirect_to signin_path, notice: 'This account is already in use.Please sign in to use it'\n return\n else\n create_impulse_signup params[:email]\n end\n @classified = @user.classifieds.build(params[:classified])\n end\n respond_to do |format|\n if @classified.save\n if signed_in?\n format.html { redirect_to @classified, notice: 'Classified was successfully created.' }\n else\n format.html { redirect_to @classified, notice: 'Classified was successfully created..Please confirm your email account by clicking on the link we sent you' }\n end\n format.json { render json: @classified, status: :created, location: @classified }\n else\n format.html { render action: 'new' }\n format.json { render json: @classified.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n \n end", "def destroy\n @product_classify.destroy\n respond_to do |format|\n format.html { redirect_to product_classifies_url, notice: '产品分类删除成功。' }\n format.json { head :no_content }\n end\n end", "def create\n @product_submit = ProductSubmit.new(product_submit_params)\n\n respond_to do |format|\n if @product_submit.save\n format.html { redirect_to \"/\", notice: 'Thank you for submitting a product. We are excited to check it out!' }\n format.json { render :show, status: :created, location: \"/\" }\n else\n format.html { render :new }\n format.json { render json: @product_submit.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to products_url, notice: \"Product was successfully created.\" }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(params[:product])\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, :notice => 'Product was successfully created.' }\n format.json { render :json => @product, :status => :created, :location => @product }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @product.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(params[:product])\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, :notice => 'Product was successfully created.' }\n format.json { render :json => @product, :status => :created, :location => @product }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @product.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(params[:product])\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, :notice => 'Product was successfully created.' }\n format.json { render :json => @product, :status => :created, :location => @product }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @product.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(params[:product])\n if @product.special_price_id.to_i!=0\n @product.sales_price = @product.special_price.try(:price_each_size).to_f * @product.size.to_f\n end\n\n if @product.try(:category).try(:name)==\"SPAREPART\"\n get_sparepart\n else\n get_unit\n end\n\n @product.save\n\n respond_to do |format|\n format.html { redirect_to @product }\n format.js\n # if @product.save && @product.try(:category).try(:name)==\"SPAREPART\"\n # format.html { redirect_to @product, notice: 'Product was successfully created.' }\n # format.json { render json: @product, status: :created, location: @product }\n # elsif @product.save && @product.try(:category).try(:name)==\"UNIT\"\n # format.html { redirect_to unit_show_product_path(@product), notice: 'Product was successfully created.' }\n # format.json { render json: @product, status: :created, location: @product }\n # else\n # format.html { redirect_to @product, notice: 'Product was successfully created.' }\n # format.json { render json: @product.errors, status: :unprocessable_entity }\n # end\n end\n end", "def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to products_url, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: products_url }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_product_art_request\n request_class = product.product_request_class.constantize\n request = request_class.new(art_request_id: self.id)\n request.save!\n end", "def create\n @product = Product.new(params[:product])\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to products_path, notice: 'Product was successfully created.' }\n format.json { render json: @product, status: :created, location: @product }\n else\n format.html { render action: \"new\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @groceryproduct = Groceryproduct.new(groceryproduct_params)\n\n respond_to do |format|\n if @groceryproduct.save\n format.html { redirect_to @groceryproduct, notice: 'Groceryproduct was successfully created.' }\n format.json { render action: 'show', status: :created, location: @groceryproduct }\n else\n format.html { render action: 'new' }\n format.json { render json: @groceryproduct.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(params[:product])\n respond_to do |format|\n if @product.save\n current_user.user_info.products.push @product\n Shopify.create @product\n format.html { redirect_to :action => 'index' }\n format.json { render json: @product, status: :created, location: @product }\n else\n format.html { render action: \"new\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product_spec = ProductSpec.new(product_spec_params)\n\n respond_to do |format|\n if @product_spec.save\n format.html { redirect_to @product_spec, notice: 'Product spec was successfully created.' }\n format.json { render :show, status: :created, location: @product_spec }\n else\n format.html { render :new }\n format.json { render json: @product_spec.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(params[:product])\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product,\n :notice=> 'Product was successfully created.' }\n format.json { render :json=> @product, :status=> :created,\n :location=> @product }\n else\n format.html { render :action=> \"new\" }\n format.json { render :json=> @product.errors,\n :status=> :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: \"Product was successfully created.\" }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @recipe_prod = RecipeProd.new(recipe_prod_params)\n\n respond_to do |format|\n if @recipe_prod.save\n format.html { redirect_to @recipe_prod, notice: 'Recipe prod was successfully created.' }\n format.json { render :show, status: :created, location: @recipe_prod }\n else\n format.html { render :new }\n format.json { render json: @recipe_prod.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n newProduct = Product.new(products_params)\n if newProduct.save\n msg = { status: 201 , product: newProduct }\n respond_to do |format|\n format.html { render json: msg }\n format.json { render json: msg }\n end\n else\n msg = { status: 422 }\n respond_to do |format|\n format.html { render json: msg }\n format.json { render json: msg }\n end\n end\n end", "def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to products_url, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product_sku = ProductSku.new(product_sku_params)\n\n respond_to do |format|\n if @product_sku.save\n format.html { redirect_to @product_sku, notice: 'Product sku was successfully created.' }\n format.json { render :show, status: :created, location: @product_sku }\n else\n format.html { render :new }\n format.json { render json: @product_sku.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product_specification = ProductSpecification.new(product_specification_params)\n\n respond_to do |format|\n if @product_specification.save\n format.html { redirect_to @product_specification, notice: 'Product specification was successfully created.' }\n format.json { render :show, status: :created, location: @product_specification }\n else\n format.html { render :new }\n format.json { render json: @product_specification.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(name: product_params[:name], description: product_params[:description], product_type: product_params[:product_type],\n dimensions: product_params[:dimensions], weight: product_params[:weight], material: product_params[:material], product_code: product_params[:product_code],\n is_new_release: product_params[:is_new_release], collection_id: product_params[:collection_id], sub_collection_id: product_params[:sub_collection_id])\n respond_to do |format|\n if product_params[:product_images_attributes]\n product_params[:product_images_attributes].each do |pia|\n @product_image = ProductImage.new(product_image: pia[:product_image], product_id: Product.last.id+1)\n if not @product_image.valid?\n format.html { render :new }\n format.json { render json: @product_image.errors, status: :unprocessable_entity }\n break\n end\n end\n end\n if @product.save\n # if product_params[:product_images_attributes]\n # product_params[:product_images_attributes].each do |pi|\n # @product.product_images.create(product_image: pi[:product_image])\n # end\n # end\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(product_params)\n \n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def recipe_classify_params\n params.require(:recipe_classify).permit(:name, :recipe_classify_id)\n end", "def create\n @recommendation = Recommendation.new(recommendation_params)\n respond_to do |format|\n if @recommendation.save\n format.html { redirect_to @recommendation, notice: \"Recommendation was successfully created.\" }\n format.json { render :show, status: :created, location: @recommendation }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @recommendation.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @magento_product = MagentoProduct.new(params[:magento_product])\n\n respond_to do |format|\n if @magento_product.save\n format.html { redirect_to @magento_product, notice: 'Magento product was successfully created.' }\n format.json { render json: @magento_product, status: :created, location: @magento_product }\n else\n format.html { render action: \"new\" }\n format.json { render json: @magento_product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @preproduct = Preproduct.new(preproduct_params)\n\n respond_to do |format|\n if @preproduct.save\n format.html { redirect_to new_product_path , notice: 'Product was successfully created.' }\n else\n format.html { render :new }\n end\n end\n end", "def create\n @product = Product.new(params[:product])\n @product.shop = Shop.find_by_uuid params[:shop_id]\n\n respond_to do |format|\n if @product.save!\n format.html { redirect_to shop_products_path(@product.shop.uuid), notice: 'Product was successfully created.' }\n format.json { render json: @product.to_json(:include => {:product_variants => {:include => [:option_types,:pictures]}})}\n else\n format.html { render action: \"new\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(product_params)\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render json: @product }\n format.js { render status: :ok }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n format.js { render status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(params[:product])\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render json: @product, status: :created, location: @product }\n else\n format.html { render action: \"new\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(params[:product])\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render json: @product, status: :created, location: @product }\n else\n format.html { render action: \"new\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(params[:product])\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render json: @product, status: :created, location: @product }\n else\n format.html { render action: \"new\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(params[:product])\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render json: @product, status: :created, location: @product }\n else\n format.html { render action: \"new\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(params[:product])\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render json: @product, status: :created, location: @product }\n else\n format.html { render action: \"new\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(params[:product])\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render json: @product, status: :created, location: @product }\n else\n format.html { render action: \"new\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(params[:product])\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render json: @product, status: :created, location: @product }\n else\n format.html { render action: \"new\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(params[:product])\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render json: @product, status: :created, location: @product }\n else\n format.html { render action: \"new\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(params[:product])\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render json: @product, status: :created, location: @product }\n else\n format.html { render action: \"new\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.6588511", "0.64679235", "0.6444138", "0.639454", "0.6318923", "0.61670583", "0.6091584", "0.60356516", "0.6025881", "0.59911597", "0.5871508", "0.58268404", "0.57872295", "0.57741004", "0.5759996", "0.57037616", "0.5698544", "0.56933355", "0.5682692", "0.5638086", "0.5638086", "0.56264067", "0.5624913", "0.56212103", "0.56111526", "0.56062603", "0.5589142", "0.55878353", "0.5578553", "0.5567456", "0.55638206", "0.55627227", "0.5553646", "0.5551279", "0.55439293", "0.55348796", "0.55348796", "0.553417", "0.5533475", "0.5526992", "0.55225354", "0.5518641", "0.5515431", "0.5509184", "0.550655", "0.5505772", "0.5502684", "0.5501785", "0.55012995", "0.54907435", "0.5486592", "0.5486157", "0.5479199", "0.54670644", "0.546607", "0.5459932", "0.5455865", "0.5454452", "0.5444308", "0.54412055", "0.54380494", "0.5437866", "0.5435628", "0.54292184", "0.54262924", "0.5425216", "0.5425216", "0.5425216", "0.54233694", "0.5421914", "0.5419418", "0.54089665", "0.54075277", "0.53978336", "0.53965044", "0.5394133", "0.53899", "0.53777546", "0.5377376", "0.5373426", "0.53727114", "0.53658676", "0.53630096", "0.53592026", "0.5356118", "0.53559816", "0.5353413", "0.5351162", "0.5349903", "0.5343272", "0.5342783", "0.5340519", "0.5340519", "0.5340519", "0.5340519", "0.5340519", "0.5340519", "0.5340519", "0.5340519", "0.5340519" ]
0.75399023
0