query
stringlengths
7
9.55k
document
stringlengths
10
363k
metadata
dict
negatives
listlengths
0
101
negative_scores
listlengths
0
101
document_score
stringlengths
3
10
document_rank
stringclasses
102 values
POST /adversaires POST /adversaires.json
def create @adversaire = Adversaire.new(params[:adversaire]) @equipe = Equipe.find(params[:equipe_id]) respond_to do |format| if @adversaire.save format.html { redirect_to @equipe, :notice => 'Adversaire was successfully created.' } format.json { render :json => @adversaire, :status => :created, :location => @equipe } else format.html { render :action => "new" } format.json { render :json => @adversaire.errors, :status => :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @adversaires = Adversaire.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @adversaires }\n end\n end", "def new\n @equipe = Equipe.find(params[:equipe_id])\n \n @adversaire = Adversaire.new\n @adversaire.equipe = @equipe\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @adversaire }\n end\n end", "def create\n @serv_adicionale = ServAdicionale.new(params[:serv_adicionale])\n\n respond_to do |format|\n if @serv_adicionale.save\n format.html { redirect_to @serv_adicionale, notice: 'Serv adicionale was successfully created.' }\n format.json { render json: @serv_adicionale, status: :created, location: @serv_adicionale }\n else\n format.html { render action: \"new\" }\n format.json { render json: @serv_adicionale.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n params.permit(:intitule, :estObligatoire, :nombreDeCaractere, :ordre, :sondage_id)\n ajout = QuestionOuverteService.instance.creerQuestionOuverte(params[:intitule], params[:estObligatoire], params[:nombreDeCaractere], params[:ordre], params[:sondage_id])\n (ajout != nil) ? (render json: ajout, status: :ok) : (render json: nil, status: :not_found)\n end", "def create\n @respuesta = Respuesta.new(params[:respuesta])\n\n if @respuesta.save\n render json: @respuesta, status: :created, location: @respuesta\n else\n render json: @respuesta.errors, status: :unprocessable_entity\n end\n end", "def create\n @adscripcion = Adscripcion.new(adscripcion_params)\n\n respond_to do |format|\n if @adscripcion.save\n format.html { redirect_to @adscripcion, notice: 'Adscripcion was successfully created.' }\n format.json { render :show, status: :created, location: @adscripcion }\n else\n format.html { render :new }\n format.json { render json: @adscripcion.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @budget = Budget.new(budget_params)\n @client = Client.new\n @clients = Client.all\n respond_to do |format|\n if @budget.save\n format.html { redirect_to @budget, notice: 'El presupuesto se creó correctamente' }\n format.json { render :show, status: :created, location: @budget }\n else\n format.html { render :new }\n format.json { render json: @budget.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @descuento_adicional = DescuentoAdicional.new(descuento_adicional_params)\n\n respond_to do |format|\n if @descuento_adicional.save\n format.html { redirect_to @descuento_adicional, notice: 'Descuento adicional fue creado exitosamente.' }\n format.json { render :show, status: :created, location: @descuento_adicional }\n else\n format.html { render :new }\n format.json { render json: @descuento_adicional.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n params.permit(:intituleSondage, :descriptionSondage, :categorie_id, :administrateur_id)\n ajout = SondageService.instance.creerNouveauSondage(params[:intituleSondage], params[:descriptionSondage], params[:categorie_id], params[:administrateur_id])\n (ajout != nil) ? (render json: ajout, status: :ok) : (render json: nil, status: :not_found)\nend", "def create\n @ordene = Ordene.new(ordene_params)\n\n respond_to do |format|\n if @ordene.save\n format.html { redirect_to @ordene, notice: 'O de Trabajo creada con exito.' }\n format.json { render :show, status: :created, location: @ordene }\n else\n format.html { render :new }\n format.json { render json: @ordene.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @relatorio_pedagogicos = RelatorioPedagogico.all\n authorize @relatorio_pedagogicos\n\n @relatorio_pedagogico = RelatorioPedagogico.new(relatorio_pedagogico_params)\n\n respond_to do |format|\n if @relatorio_pedagogico.save\n format.html { redirect_to @relatorio_pedagogico, notice: 'Relatório pedagógico criado com sucesso!' }\n format.json { render :show, status: :created, location: @relatorio_pedagogico }\n else\n format.html { render :new }\n format.json { render json: @relatorio_pedagogico.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @relatorio_gerals = RelatorioGeral.all\n authorize @relatorio_gerals\n\n @relatorio_geral = RelatorioGeral.new(relatorio_geral_params)\n\n respond_to do |format|\n if @relatorio_geral.save\n format.html { redirect_to @relatorio_geral, notice: 'Relatório geral criado com sucesso!' }\n format.json { render :show, status: :created, location: @relatorio_geral }\n else\n format.html { render :new }\n format.json { render json: @relatorio_geral.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n movimiento_caja = MovimientoCaja.find(params[:movimiento_caja_id])\n @movimiento_de_cajas_detalle = movimiento_caja.movimiento_de_cajas_detalles.create(params[:movimiento_caja])\n respond_to do |format|\n if @movimiento_de_cajas_detalle.save\n format.html { redirect_to [@movimiento_de_cajas_detalle.movimiento_caja, @movimiento_de_cajas_detalle] }\n format.json { render :show, status: :created, location: [@movimiento_de_cajas_detalle.movimiento_caja, @movimiento_de_cajas_detalle] }\n else\n format.html { render :new }\n format.json { render json: @movimiento_de_cajas_detalle.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @detalle_orden_trabajo = DetalleOrdenTrabajo.new(detalle_orden_trabajo_params)\n @detalle_orden_trabajo.orden_trabajo = @orden_trabajo\n\n respond_to do |format|\n if @detalle_orden_trabajo.save\n format.html { redirect_to @detalle_orden_trabajo.orden_trabajo, notice: 'Detalle fue creado con éxito.' }\n format.json { render :show, status: :created, location: @detalle_orden_trabajo }\n else\n format.html { render :new }\n format.json { render json: @detalle_orden_trabajo.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @estacionamiento = Estacionamiento.new(estacionamiento_params)\n @lista_departamentos = Ubigeo.find_by_sql(\"select distinct idDepartamento, Departamento from ubigeos\")\n @lista_provincias = Ubigeo.find_by_sql(\"select distinct idProvincia, Provincia from ubigeos\")\n @lista_distritos = Ubigeo.find_by_sql(\"select distinct idDistrito, Distrito from ubigeos\")\n @serv_adicinales = ServAdicinale.all\n\n respond_to do |format|\n if @estacionamiento.save\n format.html { redirect_to @estacionamiento, notice: 'Estacionamiento was successfully created.' }\n format.json { render :show, status: :created, location: @estacionamiento }\n else\n format.html { render :new }\n format.json { render json: @estacionamiento.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @laboratorio = Laboratorio.new(laboratorio_params)\n get_responsavel\n puts \"O responsavel é: #{@laboratorio.responsavel_id}\"\n if (@responsavel != \"sem_responsavel\")\n @laboratorio.docentes << Docente.find(@laboratorio.responsavel_id)\n puts \"Add relação entre #{@laboratorio.nome} e #{Docente.find(@laboratorio.responsavel_id).user.nome}\"\n end\n respond_to do |format|\n if @laboratorio.save\n format.html { redirect_to @laboratorio, notice: 'Laboratorio was successfully created.' }\n format.json { render :show, status: :created, location: @laboratorio }\n else\n format.html { render :new }\n format.json { render json: @laboratorio.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @serv_adicionale = ServAdicionale.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @serv_adicionale }\n end\n end", "def create\n @serie_detalle = SerieDetalle.new(serie_detalle_params)\n\n respond_to do |format|\n if @serie_detalle.save\n format.html { redirect_to @serie_detalle, notice: 'Serie detalle was successfully created.' }\n format.json { render :show, status: :created, location: @serie_detalle }\n else\n format.html { render :new }\n format.json { render json: @serie_detalle.errors, status: :unprocessable_entity }\n end\n end\n end", "def show\n @adversaire = Adversaire.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @adversaire }\n end\n end", "def create\n @descuento_adicional = DescuentoAdicional.new(descuento_adicional_params)\n\n respond_to do |format|\n if @descuento_adicional.save\n format.html { redirect_to @descuento_adicional, notice: 'Descuento adicional was successfully created.' }\n format.json { render :show, status: :created, location: @descuento_adicional }\n else\n format.html { render :new }\n format.json { render json: @descuento_adicional.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @liquidacion = Liquidacion.new\n\n #Levanto de conceptos, todos los conceptos que son requeridos para liquidacion de auxiliares \n @conceptos = Concepto.where(:anhomes => 201407).order(:codigo_concepto) \n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @liquidacion }\n end\n end", "def create\n item_exists = false\n item_id = params[:detalle_ot_presupuesto][:repuesto_servicio_id].to_i\n @orden_trabajo_presupuesto.detalle_ot_presupuestos.each do |detail|\n if detail.repuesto_servicio_id == item_id\n # Ya existe el item en la factura, agregar cantidad\n item_exists = true\n @detalle_ot_presupuesto = detail\n @saved_sale_detail = detail.id\n break\n end\n end\n if item_exists\n @detalle_ot_presupuesto.cantidad += params[:detalle_ot_presupuesto][:cantidad].to_i\n @detalle_ot_presupuesto.precio_venta= params[:detalle_ot_presupuesto][:precio_venta].to_f\n @detalle_ot_presupuesto.save!\n else\n detalle_ot_presupuesto = DetalleOtPresupuesto.new(detalle_ot_presupuesto_params)\n @orden_trabajo_presupuesto.detalle_ot_presupuestos << detalle_ot_presupuesto\n end\n\n respond_to do |format|\n \n if @orden_trabajo_presupuesto.save\n format.html {redirect_to @orden_trabajo_presupuesto, notice: 'El detalle se agregó correctamente.'}\n format.json {render :show, status: :created, location: @detalle_compra}\n else\n format.html {render :new}\n format.json {render json: @detalle_ot_presupuesto.errors, status: :unprocessable_entity}\n end\n end\n end", "def create\n @safra_verdoso = SafraVerdoso.new(params[:safra_verdoso])\n\n respond_to do |format|\n if @safra_verdoso.save\n format.html { redirect_to \"/safra_produtos/#{@safra_verdoso.safra_produto_id}/descontos\"}\n format.json { render json: @safra_verdoso, status: :created, location: @safra_verdoso }\n else\n format.html { render action: \"new\" }\n format.json { render json: @safra_verdoso.errors, status: :unprocessable_entity }\n end\n end\n end", "def adquirir(id)\n @client.post(Route.new([ROTA_DID_ESTOQUE, id.to_s]))\n end", "def create\n @asiento = Asiento.new(params[:asiento])\n\n respond_to do |format|\n if @asiento.save\n format.html { redirect_to @asiento, :notice => 'El apunte fue creado.' }\n format.json { render :json => @asiento, :status => :created, :location => @asiento }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @asiento.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @administracao_relatorios_diario = Administracao::RelatoriosDiario.new(administracao_relatorios_diario_params)\n\n respond_to do |format|\n if @administracao_relatorios_diario.save\n format.html { redirect_to @administracao_relatorios_diario, notice: 'Relatorios diario was successfully created.' }\n format.json { render :show, status: :created, location: @administracao_relatorios_diario }\n else\n format.html { render :new }\n format.json { render json: @administracao_relatorios_diario.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @respuesta = Respuesta.new(params[:respuesta])\n\n respond_to do |format|\n if @respuesta.save\n format.html { redirect_to @respuesta, notice: 'Respuesta was successfully created.' }\n format.json { render json: @respuesta, status: :created, location: @respuesta }\n else\n format.html { render action: \"new\" }\n format.json { render json: @respuesta.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @asiento_de_servicio = AsientoDeServicio.new(asiento_de_servicio_params)\n\n respond_to do |format|\n if @asiento_de_servicio.save\n format.html { redirect_to @asiento_de_servicio, notice: 'Asiento de servicio was successfully created.' }\n format.json { render :show, status: :created, location: @asiento_de_servicio }\n else\n format.html { render :new }\n format.json { render json: @asiento_de_servicio.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @pagos_servicio = PagosServicio.new(pagos_servicio_params)\n respond_to do |format|\n if @pagos_servicio.save\n @caja = Caja.where(estado: 0).last\n @mov_caja = MovCaja.create!(caja_id: @caja.id, concepto: @pagos_servicio.servicio, ingreso: 0, egreso: @pagos_servicio.monto, saldo: @caja.cierre.to_i - @pagos_servicio.monto.to_i)\n @caja.update(cierre: @caja.cierre.to_i - @pagos_servicio.monto.to_i, salida: @caja.salida.to_i + @pagos_servicio.monto.to_i)\n format.html { redirect_to @pagos_servicio, notice: 'Se ha registrado el pago correctamente.' }\n format.json { render :show, status: :created, location: @pagos_servicio }\n else\n format.html { render :new }\n format.json { render json: @pagos_servicio.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @adquisicion = Adquisicion.new(adquisicion_params)\n\n respond_to do |format|\n if @adquisicion.save\n format.html { redirect_to @adquisicion, notice: 'Adquisicion was successfully created.' }\n format.json { render :show, status: :created, location: @adquisicion }\n else\n format.html { render :new }\n format.json { render json: @adquisicion.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @notadedebito = Notadedebito.find(params[:notadedebito_id])\n @renglon_notadebito = @notadedebito.renglon_notadebitos.create(params[:renglon_notadebito])\n\n respond_to do |format|\n if @renglon_notadebito.save\n format.html { redirect_to @notadebito, notice: 'Renglon notadebito was successfully created.' }\n format.json { render json: @renglon_notadebito}\n else\n format.html { render action: \"new\" }\n format.json { render json: @renglon_notadebito.errors}\n end\n end\n end", "def create\n @dynamique = Dynamique.new(params[:dynamique])\n\n respond_to do |format|\n if @dynamique.save\n format.html { redirect_to @dynamique, notice: 'Dynamique was successfully created.' }\n format.json { render json: @dynamique, status: :created, location: @dynamique }\n else\n format.html { render action: \"new\" }\n format.json { render json: @dynamique.errors, status: :unprocessable_entity }\n end\n end\n end", "def asignar_cliente\n @usuario = Usuario.find(params[:responsable])\n @clientes = params[:cliente]\n respond_to do |format|\n if @usuario.responsable? or @usuario.transcriptor?\n for cliente in @clientes.values\n nuevo = Cliente.create(:usuario_id => @usuario.id, :cliente_id => cliente)\n @usuario.clientes << nuevo\n end \n format.html { redirect_to @usuario, notice: 'Clientes asignados satisfactoriamente'}\n else \n format.html { redirect_to update_usuario_path, notice: 'Error en servidor. Intente más tarde' }\n end\n end\n end", "def create\n doc = Nokogiri::XML(request.body.read)\n cvNode = doc.xpath('elwak/checklisten_vorlage')\n cv = ChecklistenVorlage.new({\n objekt_id: cvNode.xpath('objekt_id').text.to_s, \n bezeichner: cvNode.xpath('bezeichner').text.to_s, \n version: cvNode.xpath('version').text.to_s.to_i, \n inaktiv: cvNode.xpath('inaktiv').text.to_s.to_bool \n })\n cv.save\n\n cvNode.xpath('checklisten_eintrags/checklisten_eintrag').each do |ceNode|\n ce = ChecklistenEintrag.new({\n checklisten_vorlage_id: cv.id,\n bezeichner: ceNode.xpath('bezeichner').text.to_s,\n was: ceNode.xpath('was').text.to_s,\n wann: ceNode.xpath('wann').text.to_s,\n typ: ceNode.xpath('typ').text.to_s.to_i,\n position: ceNode.xpath('position').text.to_s.to_i\n })\n ce.save\n end\n\n respond_to do |format|\n format.xml {render :xml => '<?xml version=\"1.0\" encoding=\"UTF-8\"?><success />'}\n end\n end", "def create\n @diet = Diet.new(diet_params)\n @diet.user = @current_user\n\n if @diet.save\n render json: @diet, status: 201, location: @diet, root: true\n else\n render json: @diet.errors, status: 422\n end\n end", "def create\n @post = Post.create(post_params)\n puts \"LLLLLOOOOOOOLLLLLL\"\n puts current_usuario.to_json\n @post = current_usuario.posts.create(post_params)\n \n @post.sangre = current_usuario.tipoDeSangre\n\n\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n \n @selecciones = Seleccion.where(\"cliente_id = ?\",usuario_actual.id)\n respond_to do |format|\n unless @selecciones.empty?\n @peso_total = Seleccion.peso_total(usuario_actual.id)\n @precio_total = Seleccion.precio_total(usuario_actual.id)\n @tarjetas = usuario_actual.tdc\n @orden = Orden.new(:direccion_entrega=>usuario_actual.direccion)\n t = Time.now\n fecha = t.strftime(\"%Y-%m-%d\")\n client = Savon::Client.new(\"http://192.168.1.121/DistribuidorFIF/webservices/servicio.php?wsdl\")\n preorden = \"<solicitud_pedido>\n <num_orden>001</num_orden>\n <nombre_comercio>Tukiosquito</nombre_comercio>\n <fecha_solicitud>\"+fecha.to_s+\"</fecha_solicitud>\n <nombre_cliente>\"+usuario_actual.nombre+\" \"+usuario_actual.apellido+\"</nombre_cliente>\n <direccion_comercio>\n <avenida>Sucre</avenida>\n <calle>-</calle>\n <edificio_casa>CC Millenium</edificio_casa>\n <local_apt>C1-15</local_apt>\n <parroquia>Leoncio Martinez</parroquia>\n <municipio>Sucre</municipio>\n <ciudad>Caracas</ciudad>\n <estado>Miranda</estado>\n <pais>Venezuela</pais>\n </direccion_comercio>\n <direccion_destino>\n <avenida>Santa Rosa</avenida>\n <calle>Tierras Rojas</calle>\n <edificio_casa>Villa Magica</edificio_casa>\n <local_apt>69</local_apt>\n <parroquia> </parroquia>\n <municipio>Zamora</municipio>\n <ciudad>Cua</ciudad>\n <estado>Miranda</estado>\n <pais>Venezuela</pais>\n </direccion_destino>\"\n @selecciones.each do |seleccion|\n p = Producto.find(seleccion.producto_id)\n preorden = preorden+\"\n <articulo>\n <id>\"+p.id.to_s+\"</id>\n <descripcion>\"+p.descripcion+\"</descripcion>\n <peso>\"+p.peso.to_s+\"</peso>\n <cantidad>\"+seleccion.cantidad.to_s+\"</cantidad>\n <precio>\"+p.precio.to_s+\"</precio>\n </articulo>\"\n end\n preorden = preorden+\"</solicitud_pedido>\"\n response = client.request :ejemplo, body: { \"value\" => preorden } \n if response.success? \n respuesta = response.to_hash[:ejemplo_response][:return]\n datos = XmlSimple.xml_in(respuesta)\n end\n\n @precio_envio = datos[\"num_orden\"][0]\n #@arreglo = XmlSimple.xml_in('')\n #@xml = XmlSimple.xml_out(@arreglo, { 'RootName' => 'solicitud_pedido' })\n #url = 'http://192.168.1.101/Antonio/tukyosquito/proyecto/servicio/servicio.php'\n #cotizacion = SOAP::RPC::Driver.new(url)\n #cotizacion.add_method('obtener','asd')\n #tdc = Tarjeta.where(\"id = ? AND cliente_id = ?\",params[:orden][:tarjeta_id],usuario_actual.id)\n #@respuesta = cotizacion.obtener('123')\n format.html # new.html.erb\n else\n format.html { redirect_to carrito_path, notice: 'No tiene productos agregados al carro de compras para generar una orden.' }\n end\n end\n end", "def create\n @respuesta = Respuesta.new(respuesta_params)\n\n respond_to do |format|\n if @respuesta.save\n format.html { redirect_to @respuesta, notice: 'Respuesta was successfully created.' }\n format.json { render :show, status: :created, location: api_v1_respuesta_url(@respuesta) }\n else\n format.html { render :new }\n format.json { render json: @respuesta.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @vehicule_perso = VehiculePerso.new(params[:vehicule_perso])\n\n respond_to do |format|\n if @vehicule_perso.save\n format.html { redirect_to @vehicule_perso, :notice => 'Le véhicule personnel a bien été ajouté' }\n format.json { render :json => @vehicule_perso, :status => :created, :location => @vehicule_perso }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @vehicule_perso.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @detalle = Detalle.new(params[:detalle])\n\n respond_to do |format|\n if @detalle.save\n format.html { redirect_to @detalle, notice: 'Detalle was successfully created.' }\n format.json { render json: @detalle, status: :created, location: @detalle }\n else\n format.html { render action: \"new\" }\n format.json { render json: @detalle.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @trabajo = Trabajo.new(trabajo_params)\n @cliente = Cliente.find(params[:cliente_id])\n @trabajo.cliente = @cliente\n\n respond_to do |format|\n if @trabajo.save\n TrabajoMailer.detalle_trabajo(current_user, @cliente, @trabajo).deliver\n\n format.html { redirect_to cliente_path(@cliente), notice: 'Trabajo was successfully created.' }\n format.json { render :show, status: :created, location: @trabajo }\n else\n format.html { render :new }\n format.json { render json: @trabajo.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @paciente = Paciente.new(paciente_params)\n @paciente.user=current_user\n\n respond_to do |format|\n if @paciente.save\n historial=Historial.new\n historial.paciente=@paciente\n historial.save\n\n format.html { redirect_to @paciente, notice: 'Paciente creado exitosamente.' }\n format.json { render :show, status: :created, location: @paciente }\n else\n format.html { render :new }\n format.json { render json: @paciente.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @relcliruta = Relcliruta.new(relcliruta_params)\n\n respond_to do |format|\n if @relcliruta.save\n format.html { redirect_to @relcliruta, notice: 'Relcliruta was successfully created.' }\n format.json { render :show, status: :created, location: @relcliruta }\n format.js {flash.now[:notice] = 'El cliente se ha agregado de forma exitosa.'} #ajax\n else\n format.html { render :new }\n format.json { render json: @relcliruta.errors, status: :unprocessable_entity }\n format.js {flash.now[:alert] = 'Error al agregar el cliente.'} #ajax\n end\n end\n end", "def add_relation\n #add relation\n @word.word_roots.create(@word_root)\n respond_to do |format|\n format.js\n end\n end", "def create\n @ordene = Ordene.new(ordene_params)\n\n respond_to do |format|\n\n # if @ordene.aceptar\n\n if @ordene.save\n format.html { redirect_to @ordene, notice: 'Ordene was successfully created.' }\n\t format.json { render :show, status: :created, location: @ordene }\n else\n\t format.html { render :new }\n format.json { render json: @ordene.errors, status: :unprocessable_entity }\n\t end\n end\n #end\n end", "def create\n #Parámetros permitidos.\n pago_params\n\n #Asignación de variables.\n fact = params[:pago][:factura_id]\n fecha = params[:pago][:fechapago]\n factura = Factura.find_by(id: fact)\n\n #Editar pago.\n @pago = Pago.new\n @pago.factura_id = fact\n @pago.fechapago = fecha\n @pago.monto = factura.total\n\n respond_to do |format|\n if @pago.save\n #Inserción en la cuenta corriente cliente por el haber.\n ctactecli = Ctactecli.find_by(cliente_id: factura.cliente_id)\n detallectactecli = Detallectactecli.new\n detallectactecli.ctactecli_id = factura.cliente_id\n detallectactecli.fechadetalle = Date.today\n detallectactecli.tipodetalle = 'Crédito por factura'\n detallectactecli.haber = factura.total\n detallectactecli.save\n ctactecli.saldo = ctactecli.saldo - factura.total\n ctactecli.save\n\n format.json { render :show, status: :created, location: @pago }\n puts'Pago guardado'\n #format.html { redirect_to @pago, notice: 'Pago was successfully created.' }\n else\n format.json { render json: @pago.errors, status: :unprocessable_entity }\n puts'Pago no guardado'\n #format.html { render :new }\n end\n end\n end", "def create\n @departure = Departure.new(departure_params)\n respond_to do |format|\n if @departure.save\n @stuffs = Stuff.ordered\n format.html { redirect_to departures_url, notice: 'Entrada criada com sucesso!' }\n format.json { render :show, status: :created, location: @entry }\n format.js\n else\n @stuff = Stuff.find(params[\"departure\"][\"stuff_id\"])\n format.js { render :new }\n end\n end\n end", "def create\n @departamento = Departamento.new(departamento_params)\n\n if @departamento.save\n render json: @departamento, status: :created, location: @departamento\n else\n render json: @departamento.errors, status: :unprocessable_entity\n end\n end", "def create\n\n respond_to do |format|\n if @especialidad.save\n format.html { redirect_to @especialidad, notice: 'Servicio creado exitosamente.' }\n format.json { render :show, status: :created, location: @especialidad }\n else\n format.html { render :new }\n format.json { render json: @especialidad.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @adjunto = Adjunto.new(params[:adjunto])\n\n respond_to do |format|\n if @adjunto.save\n format.html { redirect_to(@adjunto, :notice => 'Adjunto was successfully created.') }\n format.xml { render :xml => @adjunto, :status => :created, :location => @adjunto }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @adjunto.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @asistencia_domingo = AsistenciaDomingo.new(asistencia_domingo_params)\n\n asistencia_reunion_evangelist_id = asistencia_reunion_evangelist_param[:asistencia_reunion_evangelist_id]\n asistencia_reunion_planificacion_id = asistencia_reunion_planificacion_param[:asistencia_reunion_planificacion_id]\n\n if @asistencia_domingo.save\n redirect_to controller: 'reporte_semanal_celulas', action: 'new', asistencia_domingo_id: @asistencia_domingo.id, asistencia_reunion_evangelist_id: asistencia_reunion_evangelist_id, asistencia_reunion_planificacion_id: asistencia_reunion_planificacion_id , notice: 'Asistencia domingos was successfully created.'\n return\n end\n\n respond_to do |format|\n if !@asistencia_domingo.save\n format.html { render :new }\n format.json { render json: @asistencia_domingo.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @descuento = Descuento.new(descuento_params)\n\n respond_to do |format|\n if @descuento.save\n format.html { redirect_to @descuento, notice: 'Descuento fue creado exitosamente.' }\n format.json { render :show, status: :created, location: @descuento }\n else\n format.html { render :new }\n format.json { render json: @descuento.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @dias_semanas_vaga = DiasSemanasVaga.new(dias_semanas_vaga_params)\n\n respond_to do |format|\n if @dias_semanas_vaga.save\n format.html { redirect_to @dias_semanas_vaga, notice: 'Dias semanas vaga was successfully created.' }\n format.json { render :show, status: :created, location: @dias_semanas_vaga }\n else\n format.html { render :new }\n format.json { render json: @dias_semanas_vaga.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @organisme = Organisme.new(organisme_params)\n params[:departements] ||= []\n @organisme.departements.delete_all\n @dep_table = params[:departements]\n logger.debug \"Departements table sent : #@dep_table\"\n @dep_table.each do |depid|\n @organisme.departements << Departement.find(depid)\n end\n respond_to do |format|\n if @organisme.save\n format.html { redirect_to action: \"index\", notice: 'Organisme was successfully created.' }\n format.json { render :index, status: :created, location: @organisme }\n else\n format.html { render :new }\n format.json { render json: @organisme.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @apoio_educacioanl = ApoioEducacioanl.new(apoio_educacioanl_params)\n\n respond_to do |format|\n if @apoio_educacioanl.save\n format.html { redirect_to @apoio_educacioanl, notice: 'Apoio educacioanal foi cadastrado com Sucesso !' }\n format.json { render :show, status: :created, location: @apoio_educacioanl }\n else\n format.html { render :new }\n format.json { render json: @apoio_educacioanl.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @djoque = Djoque.new(djoque_params)\n @djoque.djoker = current_djoker\n respond_to do |format|\n if @djoque.save\n format.html { redirect_to @djoque, notice: \"Votre Djoque à bien été créée :p\" }\n format.json { render :show, status: :created, location: @djoque }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @djoque.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n authorize! :create, @mesasredonda\n @mesasredonda = Mesasredonda.new(params[:mesasredonda])\n\n respond_to do |format|\n if @mesasredonda.save\n format.html { redirect_to @mesasredonda, notice: 'Mesa redonda cadastrada com sucesso.' }\n format.json { render json: @mesasredonda, status: :created, location: @mesasredonda }\n else\n format.html { render action: \"new\" }\n format.json { render json: @mesasredonda.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @adres_kontr = AdresKontr.new(adres_kontr_params)\n\n respond_to do |format|\n if @adres_kontr.save\n format.html { redirect_to @adres_kontr, notice: 'Adres kontr was successfully created.' }\n format.json { render :show, status: :created, location: @adres_kontr }\n else\n format.html { render :new }\n format.json { render json: @adres_kontr.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @lista_desejo = ListaDesejo.new(lista_desejo_params)\n\n respond_to do |format|\n if @lista_desejo.save\n format.html { redirect_to back_uri, warning: 'Adicionado a lista de desejos.' }\n format.json { render :show, status: :created, location: @lista_desejo }\n else\n format.html { render :new }\n format.json { render json: @lista_desejo.errors, status: :unprocessable_entity }\n end\n end\n end", "def create \n \n respond_to do |format|\n if @paciente.save\n format.html { redirect_to @paciente, notice: 'Paciente creado exitosamente.' }\n format.json { render :show, status: :created, location: @paciente }\n else \n format.html { render :new}\n format.json { render json: @paciente.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @adquisicione = Adquisicione.new(adquisicione_params)\n\n respond_to do |format|\n if @adquisicione.save\n format.html { redirect_to @adquisicione, notice: 'Adquisicione was successfully created.' }\n format.json { render :show, status: :created, location: @adquisicione }\n else\n format.html { render :new }\n format.json { render json: @adquisicione.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @status_del_admitido = StatusDelAdmitido.new(params[:status_del_admitido])\n\n respond_to do |format|\n if @status_del_admitido.save\n format.html { redirect_to @status_del_admitido, notice: 'Status del admitido was successfully created.' }\n format.json { render json: @status_del_admitido, status: :created, location: @status_del_admitido }\n else\n format.html { render action: \"new\" }\n format.json { render json: @status_del_admitido.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @adherent = Adherent.new(adherent_params)\n\n respond_to do |format|\n if @adherent.save\n format.html { redirect_to @adherent, notice: 'Adherent was successfully created.' }\n format.json { render :show, status: :created, location: @adherent }\n else\n format.html { render :new }\n format.json { render json: @adherent.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @objeto = DetallePedido.new(detalle_pedido_params)\n\n respond_to do |format|\n if @objeto.save\n set_redireccion\n format.html { redirect_to @redireccion, notice: 'Detalle pedido was successfully created.' }\n format.json { render :show, status: :created, location: @objeto }\n else\n format.html { render :new }\n format.json { render json: @objeto.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @observacionactividadadecuacion = Observacionactividadadecuacion.new(observacionactividadadecuacion_params)\n\n respond_to do |format|\n if @observacionactividadadecuacion.save\n format.html { redirect_to @observacionactividadadecuacion, notice: 'Observacionactividadadecuacion was successfully created.' }\n format.json { render :show, status: :created, location: @observacionactividadadecuacion }\n else\n format.html { render :new }\n format.json { render json: @observacionactividadadecuacion.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n #@pasien = Pasien.find(params[:pasien_id])\n #@hasil = @pasien.hasils.create(params[:hasil])\n #redirect_to pasien_path(@post)\n @hasil = Hasil.create(params[:hasil])\n\n respond_to do |format|\n if @hasil.save\n format.html { redirect_to @hasil, notice: 'Hasil was successfully created.' }\n format.json { render json: @hasil, status: :created, location: @hasil }\n else\n format.html { render action: \"new\" }\n format.json { render json: @hasil.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @relatestagiario = Relatestagiario.new(params[:relatestagiario])\n\n respond_to do |format|\n if @relatestagiario.save\n flash[:notice] = 'RELATÓRIO SALVO COM SUCESSO.'\n format.html { redirect_to(@relatestagiario) }\n format.xml { render :xml => @relatestagiario, :status => :created, :location => @relatestagiario }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @relatestagiario.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n set_assoc_work_param()\n @transcription = Transcription.new(params[:transcription])\n\n respond_to do |format|\n if @transcription.save\n int_rebuild_value = \"0\"\n if (params[:rebuild])\n int_rebuild_value = params[:rebuild]\n end\n if int_rebuild_value.to_i > 0\n int_tei_ret = doeditiontei(@transcription.digital_edition_id)\n end\n arr_prev_page_data = get_prev_page_last_line_data(@transcription.page_id)\n do_page_lines(arr_prev_page_data[0], arr_prev_page_data[1], @transcription.page_id)\n dopagetei(@transcription.page_id)\n str_redirect_link = \"/pages/\"+@transcription.page_id.to_s+\"/edit?notice=New%20Transcription%20Saved%20With%20ID%20\"+@transcription.id.to_s\n format.html { redirect_to str_redirect_link }\n format.json { render json: @transcription, status: :created, location: @transcription }\n else\n format.html { render action: \"new\" }\n format.json { render json: @transcription.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @actividad = Actividad.new(params[:actividad])\n respond_to do |format|\n if @actividad.save \n @actividad.visitadors.each do |v|\n pu = PuntuacionesActividad.new(:actividad_id => @actividad.id, :visitador_id => v.id, :puntuacion => @actividad.puntuacion)\n pu.save\n end\n format.html { redirect_to @actividad, notice: 'Actividad was successfully created.' }\n format.json { render json: @actividad, status: :created, location: @actividad }\n else\n format.html { render action: \"new\" }\n format.json { render json: @actividad.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @aprendiz = Aprendiz.new(aprendiz_params)\n\n respond_to do |format|\n if @aprendiz.save\n format.html { redirect_to @aprendiz, notice: 'Aprendiz was successfully created.' }\n format.json { render :show, status: :created, location: @aprendiz }\n else\n format.html { render :new }\n format.json { render json: @aprendiz.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @solution = @idea.solutions.new(feature: params[:toSent]) #@idea.solutions.new(params[:solution])\n\n if @solution.save\n render json: { text: \"success\", id: \"#{@solution.id}\" }\n else\n render json: { text: \"fail\"}\n end\n end", "def new_for_order\n @cliente = Cliente.new\n\n respond_to do |format|\n format.html\n format.json { render json: @cliente }\n end\n end", "def create\n @consulta = Consulta.new(params[:consulta])\n\n if @consulta.save\n render json: @consulta, status: :created, location: @consulta\n else\n render json: @consulta.errors, status: :unprocessable_entity\n end\n end", "def create\n @ajudante = current_usuario.ajudantes.build(ajudante_params)\n\n respond_to do |format|\n if @ajudante.save\n format.html { redirect_to @ajudante, notice: \"Ajudante foi criado com sucesso.\" }\n format.json { render :show, status: :created, location: @ajudante }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @ajudante.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @detalle = Detalle.new(detalle_params)\n\n respond_to do |format|\n if @detalle.save\n format.html { redirect_to @detalle, notice: 'Detalle was successfully created.' }\n format.json { render :show, status: :created, location: @detalle }\n else\n format.html { render :new }\n format.json { render json: @detalle.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @contrato = Contrato.new(contrato_params)\n\n respond_to do |format|\n if @contrato.save\n @contrato.anadir_conceptosdepago(@contrato.fecha_inicio, @contrato.fecha_fin)\n format.html { redirect_to @contrato, notice: 'Contrato fue creado exitosamente.' }\n format.json { render :show, status: :created, location: @contrato }\n else\n format.html { render :new }\n format.json { render json: @contrato.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @admin_interview = Interview.new(params[:interview])\n\n respond_to do |format|\n if @admin_interview.save\n format.html { redirect_to [:admin, @admin_interview], notice: 'Entrevista criada com sucesso.' }\n format.json { render json: [:admin, @admin_interview], status: :created, location: @admin_interview }\n else\n format.html { render action: \"new\" }\n format.json { render json: [:admin, @admin_interview.erros], status: :unprocessable_entity }\n end\n end\n end", "def create\n @historico_converca = HistoricoConverca.new(historico_converca_params) \n\n @historico_converca.user_id = current_user.id\n respond_to do |format|\n if @historico_converca.save\n @historico_converca = HistoricoConverca.new\n @historicos = Venda.where(cliente_id: params[:id], orcamento: true)\n format.js { render :create, notice: 'Venda atualiza!', location: @historicos }\n else\n format.html { render 'vendas/new' } \n end\n end\n end", "def create\n @topes_legale = TopesLegale.new(topes_legale_params)\n\n respond_to do |format|\n if @topes_legale.save\n format.html { redirect_to @topes_legale, notice: 'Tope legal creado exitosamente.' }\n format.json { render :show, status: :created, location: @topes_legale }\n else\n format.html { render :new }\n format.json { render json: @topes_legale.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @paciente_serviciocomplementario = PacienteServiciocomplementario.new(paciente_serviciocomplementario_params)\n\n respond_to do |format|\n if @paciente_serviciocomplementario.save\n format.html {redirect_to @paciente_serviciocomplementario, notice: 'Paciente serviciocomplementario was successfully created.'}\n format.json {render :show, status: :created, location: @paciente_serviciocomplementario}\n else\n format.html {render :new}\n format.json {render json: @paciente_serviciocomplementario.errors, status: :unprocessable_entity}\n end\n end\n end", "def create\n @archdiocese = Archdiocese.new(archdiocese_params)\n\n if @archdiocese.save\n render json: @archdiocese, status: :created, location: @archdiocese\n else\n render json: @archdiocese.errors, status: :unprocessable_entity\n end\n end", "def create\n @relatorio_plano_de_voo = RelatorioPlanoDeVoo.new(relatorio_plano_de_voo_params)\n\n respond_to do |format|\n if @relatorio_plano_de_voo.save\n format.html { redirect_to @relatorio_plano_de_voo, notice: 'Relatorio plano de voo was successfully created.' }\n format.json { render :show, status: :created, location: @relatorio_plano_de_voo }\n else\n format.html { render :new }\n format.json { render json: @relatorio_plano_de_voo.errors, status: :unprocessable_entity }\n end\n end\n end", "def crediario_params\n params.require(:crediario).permit(:client_id, :amount, :emission, :maturity, :doc_number, :printed, :status)\n end", "def create\n logger.debug(\"Creando calabaza aa #{params[:deuda][:deuda_original_id]} #{params}\")\n @deuda = Deuda.new(params[:deuda])\n if(params[:deuda].has_key?(:deuda_original_id))\n logger.debug(\"Se slecciono deuda original\")\n if(@deuda.credito.present?)\n logger.debug(\"Estaba asociado con un credito\")\n @deuda.credito.deudas.delete(@deuda)\n end\n @deuda.credito_id=nil\n end\n\n respond_to do |format|\n if @deuda.save\n format.html { redirect_to @deuda, notice: 'Deuda was successfully created.' }\n format.json { render json: @deuda, status: :created, location: @deuda }\n else\n format.html { render action: \"new\" }\n format.json { render json: @deuda.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @substancia = Substancia.new(substancia_params)\n\n respond_to do |format|\n if @substancia.save\n format.html { redirect_to @substancia, notice: 'Substancia was successfully created.' }\n format.json { render :show, status: :created, location: @substancia }\n else\n format.html { render :new }\n format.json { render json: @substancia.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n\n @etablissement = Etablissement.find(params[:etablissement_id]) \n @mission = @etablissement.missions.new(mission_params)\n\n @mission.benevole = current_benevole\n #@etablissement = Etablissement.find(params[:id])\n\n respond_to do |format|\n @mission.save\n if @mission.save\n MissionMailer.new_mission_b(Mission.last).deliver_now\n MissionMailer.new_mission_e(Mission.last).deliver_now\n format.html { redirect_to @etablissement, notice: 'La Proposition a bien été crée.' }\n format.json { render :show, status: :created, location: @mission }\n else\n format.html { render :new }\n format.json { render json: @mission.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @enfermedade = Enfermedade.new(enfermedade_params)\n\n respond_to do |format|\n if @enfermedade.save\n format.html { redirect_to new_padecimiento_path, notice: 'Ahora, por favor dinos a qué eres alérgico' }\n\n else\n format.html { render action: 'new' }\n format.json { render json: @enfermedade.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @caja = Caja.new\n @persona = Persona.new\n @apertura_cajas = AperturaCaja.all\n @apertura_caja = AperturaCaja.new\n @apertura_cajas_detalles = AperturaCajasDetalle.all\n @apertura_cajas_detalle = AperturaCajasDetalle.new\n @apertura_caja.apertura_cajas_detalles.build\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @apertura_cajas }\n end\n end", "def create\n @adicional_desconto = AdicionalDesconto.new(params[:adicional_desconto])\n\n respond_to do |format|\n if @adicional_desconto.save\n flash[:notice] = 'Adicional / Desconto cadastrado com sucesso.'\n #format.html { redirect_to(@adicional_desconto) }\n format.html { redirect_to(adicional_descontos_path) }\n format.xml { render :xml => @adicional_desconto, :status => :created, :location => @adicional_desconto }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @adicional_desconto.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @jornada = Jornada.new(params[:jornada])\n\n respond_to do |format|\n if @jornada.save\n format.html { redirect_to jornadas_path, notice: 'La jornada se ha creado correctamente' }\n format.json { render json: @jornada, status: :created, location: @jornada }\n else\n format.html { render action: \"new\" }\n format.json { render json: @jornada.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @puntaje = Puntaje.new\n atributos\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @puntaje }\n end\n end", "def new\n @puntaje = Puntaje.new\n atributos\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @puntaje }\n end\n end", "def create\n @factura = Factura.find(params[:factura_id])\n @renglon_factura = @factura.renglon_facturas.build(params[:renglon_factura])\n #@factura.renglon_facturas << @renglon_factura\n\n respond_to do |format|\n if @renglon_factura.save\n format.html { redirect_to @factura, :notice => 'Renglon factura was successfully created.' }\n format.json { render json: @renglon_factura }\n else\n format.html { render :action => \"new\" }\n format.json { render json: @renglon_factura.errors }\n #@renglon_factura.delete()\n end\n end\n end", "def create\n @responsavel = Responsavel.new(responsavel_params)\n\n if @responsavel.save\n render json: @responsavel, status: :created, location: @responsavel\n else\n render json: @responsavel.errors, status: :unprocessable_entity\n end\n end", "def create\n @recibo = Recibo.find(params[:recibo_id])\n @renglon_recdetalle = @recibo.renglon_recdetalles.create(params[:renglon_recdetalle])\n\n respond_to do |format|\n if @renglon_recdetalle.save\n format.html { redirect_to @recibo, notice: 'Renglon recdetalle was successfully created.' }\n format.json { render json: @renglon_recdetalle }\n else\n format.html { render action: \"new\" }\n format.json { render json: @renglon_recdetalle.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @relatory = Relatory.new(relatory_params)\n\n respond_to do |format|\n if @relatory.save\n format.html { redirect_to @relatory, notice: 'Relatório Salvo.' }\n format.json { render :show, status: :created, location: @relatory }\n else\n format.html { render :new }\n format.json { render json: @relatory.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @antecedente = @patient.create_antecedente(params[:antecedente])\n\n respond_to do |format|\n if @antecedente.save\n format.html { redirect_to [@patient, @antecedente], notice: 'Antecedente creado satisfactoriamente.' }\n format.json { render json: @antecedente, status: :created, location: @antecedente }\n else\n format.html { render action: \"new\" }\n format.json { render json: @antecedente.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @unsolved = Unsolved.new(unsolved_params)\n respond_to do |format|\n if @unsolved.save\n format.html { redirect_to @unsolved, notice: 'Unsolved problem was successfully added.' }\n format.json { render json: @unsolved, status: :created, location: @unsolved }\n end\n end\n end", "def create\n @novedad_mecanica = @unidad.novedades_mecanicas.build(novedad_mecanica_params)\n\n respond_to do |format|\n if @novedad_mecanica.save\n format.html { redirect_to [@unidad,@novedad_mecanica], notice: 'Novedad mecanica was successfully created.' }\n format.json { render :show, status: :created, location: @novedad_mecanica }\n else\n format.html { render :new }\n format.json { render json: @novedad_mecanica.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @admin_digersayfa = Admin::Digersayfa.new(admin_digersayfa_params)\n @turad = { 0 => \"Bilim İnsanları\", 1 => \"Resmi Evraklar\", 2 => \"İlginç Bilgiler\", 3 => \"Motivasyon\", 4 => \"Sınav Sistemi\"}\n @tur = { 0 => \"biliminsanlari\", 1 => \"resmievraklar\", 2 => \"ilgincbilgiler\", 3 => \"motivasyon\", 4 => \"sinavsistemi\"}\n\n respond_to do |format|\n if @admin_digersayfa.save\n Admin::Duyuru.create(aciklama: @admin_digersayfa.created_at.to_s.split(\" \")[0] + \" \" + @turad[@admin_digersayfa.tur] + \" \" + @admin_digersayfa.baslik + \" yazısı eklenmiştir.<a href=/\" + @tur[@admin_digersayfa.tur] + \"> Yazıya ulaşmak için tıklayınız. </a>\", tur: 0)\n format.html { redirect_to @admin_digersayfa, notice: 'Yazı başarılı bir şekilde oluşturuldu.' }\n format.json { render :show, status: :created, location: @admin_digersayfa }\n else\n format.html { render :new }\n format.json { render json: @admin_digersayfa.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.6595888", "0.6097787", "0.5984594", "0.59205884", "0.59102035", "0.5710794", "0.57097685", "0.57028395", "0.56891876", "0.56860554", "0.5677027", "0.56554306", "0.55997515", "0.5596368", "0.5591963", "0.55614734", "0.55543166", "0.55108947", "0.55046207", "0.549766", "0.5494242", "0.54839444", "0.547284", "0.54710555", "0.5468357", "0.54548746", "0.54531944", "0.54275304", "0.5426797", "0.54263884", "0.5421978", "0.54209155", "0.54178065", "0.5412667", "0.54053944", "0.5401458", "0.5395193", "0.5380233", "0.5368951", "0.53676516", "0.5360449", "0.5357286", "0.53523475", "0.535203", "0.534033", "0.53349775", "0.533187", "0.53269374", "0.5322885", "0.53228486", "0.5318996", "0.53181535", "0.5315364", "0.5314154", "0.52977383", "0.5297564", "0.52963614", "0.5296311", "0.5295267", "0.52917194", "0.5286474", "0.52864647", "0.5281827", "0.52812994", "0.52795947", "0.52783567", "0.5277774", "0.52740586", "0.5271276", "0.5266951", "0.5263652", "0.5259957", "0.52599496", "0.52599233", "0.5258876", "0.5258692", "0.52578366", "0.525723", "0.52564496", "0.5254664", "0.5249868", "0.52468467", "0.52439886", "0.52439016", "0.5241971", "0.524023", "0.52389735", "0.52368957", "0.52331597", "0.5229853", "0.52263105", "0.52263105", "0.5225149", "0.52215135", "0.5221431", "0.5219794", "0.52179796", "0.5217979", "0.52130246", "0.52118766" ]
0.69416124
0
PUT /adversaires/1 PUT /adversaires/1.json
def update @adversaire = Adversaire.find(params[:id]) @equipe = Equipe.find(params[:equipe_id]) respond_to do |format| if @adversaire.update_attributes(params[:adversaire]) format.html { redirect_to @equipe, :notice => 'Adversaire was successfully updated.' } format.json { head :no_content } else format.html { render :action => "edit" } format.json { render :json => @adversaire.errors, :status => :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @serv_adicionale = ServAdicionale.find(params[:id])\n\n respond_to do |format|\n if @serv_adicionale.update_attributes(params[:serv_adicionale])\n format.html { redirect_to @serv_adicionale, notice: 'Serv adicionale was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @serv_adicionale.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @adversaire = Adversaire.new(params[:adversaire])\n @equipe = Equipe.find(params[:equipe_id])\n\n respond_to do |format|\n if @adversaire.save\n format.html { redirect_to @equipe, :notice => 'Adversaire was successfully created.' }\n format.json { render :json => @adversaire, :status => :created, :location => @equipe }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @adversaire.errors, :status => :unprocessable_entity }\n end\n end\n end", "def actualizacion \n fiesta.update (params[:id]) \n render json: fiesta\n end", "def update\n @safra_verdoso = SafraVerdoso.find(params[:id])\n\n respond_to do |format|\n if @safra_verdoso.update_attributes(params[:safra_verdoso])\n format.html { redirect_to \"/safra_produtos/#{@safra_verdoso.safra_produto_id}/descontos\"}\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @safra_verdoso.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @respuesta = Respuesta.find(params[:id])\n\n if @respuesta.update(params[:respuesta])\n head :no_content\n else\n render json: @respuesta.errors, status: :unprocessable_entity\n end\n end", "def update\n render json: Alien.update(params[\"id\"], params[\"alien\"])\n end", "def new\n @equipe = Equipe.find(params[:equipe_id])\n \n @adversaire = Adversaire.new\n @adversaire.equipe = @equipe\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @adversaire }\n end\n end", "def activo_update\n respond_to do |format|\n activo = params[:presentacion][:activo]\n id = params[:id]\n Presentacion.where(id: id).update_all(activo: activo )\n msg = { :status => \"ok\", :message => \"Actualizado!\" }\n format.json { render :json => msg }\n end\n end", "def update\n @asiento = Asiento.find(params[:id])\n\n respond_to do |format|\n if @asiento.update_attributes(params[:asiento])\n format.html { redirect_to @asiento, :notice => 'El apunte fue cambiado.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @asiento.errors, :status => :unprocessable_entity }\n end\n end\n end", "def activo_update\n respond_to do |format|\n activo = params[:laboratorio][:activo]\n id = params[:id]\n Laboratorio.where(id: id).update_all(activo: activo )\n msg = { :status => \"ok\", :message => \"Actualizado!\" }\n format.json { render :json => msg }\n end\n end", "def index\n @adversaires = Adversaire.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @adversaires }\n end\n end", "def update\n @vocacionada = Vocacionada.find(params[:id])\n\n respond_to do |format|\n if @vocacionada.update_attributes(params[:vocacionada])\n format.html { redirect_to vocacionadas_url}\n flash[:notice] = \"Registro alterado com sucesso!\"\n else\n format.html { render action: \"edit\" }\n format.json { render json: @vocacionada.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @observacao_vocacionada = ObservacaoVocacionada.find(params[:id])\n\n respond_to do |format|\n if @observacao_vocacionada.update_attributes(params[:observacao_vocacionada])\n format.html { redirect_to @observacao_vocacionada}\n flash[:notice] = \"Registro alterado com sucesso!\"\n else\n format.html { render action: \"edit\" }\n format.json { render json: @observacao_vocacionada.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @agency = Agency.find(params[:id])\n\n if @agency.update(agency_params)\n #head :no_content\n render json: @agency, status: :accepted, location: @agency #sera? status accepted? \n else\n render json: @agency.errors, status: :unprocessable_entity\n end\n end", "def update\n @consulta = Consulta.find(params[:id])\n\n if @consulta.update(params[:consulta])\n head :no_content\n else\n render json: @consulta.errors, status: :unprocessable_entity\n end\n end", "def update\n @relatorio_pedagogicos = RelatorioPedagogico.all\n authorize @relatorio_pedagogicos\n\n respond_to do |format|\n if @relatorio_pedagogico.update(relatorio_pedagogico_params)\n format.html { redirect_to @relatorio_pedagogico, notice: 'Relatório pedagógico atualizado com sucesso!' }\n format.json { render :show, status: :ok, location: @relatorio_pedagogico }\n else\n format.html { render :edit }\n format.json { render json: @relatorio_pedagogico.errors, status: :unprocessable_entity }\n end\n end\n end", "def show\n @adversaire = Adversaire.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @adversaire }\n end\n end", "def update\n respond_to do |format|\n if @asiento_de_servicio.update(asiento_de_servicio_params)\n format.html { redirect_to @asiento_de_servicio, notice: 'Asiento de servicio was successfully updated.' }\n format.json { render :show, status: :ok, location: @asiento_de_servicio }\n else\n format.html { render :edit }\n format.json { render json: @asiento_de_servicio.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @responsavel = Responsavel.find(params[:id])\n\n if @responsavel.update(responsavel_params)\n head :no_content\n else\n render json: @responsavel.errors, status: :unprocessable_entity\n end\n end", "def update\n @servicio = Servicio.find(params[:id])\n\n respond_to do |format|\n if @servicio.update_attributes(params[:servicio])\n format.html { redirect_to @servicio, :notice => 'Servicio was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @servicio.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @servico.update(servico_params)\n format.html { redirect_to servicos_url, notice: 'Serviço atualizado com sucesso.' }\n format.json { render :show, status: :ok, location: @servico }\n else\n format.html { render :edit }\n format.json { render json: @servico.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n authorize! :update, Cargo\n respond_to do |format|\n # if !@cargo.sueldos.where(created_at: Time.now.beginning_of_month..Time.now.end_of_month).empty?\n nuevo = false\n if $quincena == 0\n nuevo = @cargo.sueldos.where(created_at: Time.now.beginning_of_month..(Time.now.beginning_of_month + 14.days)).empty?\n else\n nuevo = @cargo.sueldos.where(created_at: (Time.now.beginning_of_month + 15.days)..Time.now.end_of_month).empty?\n end\n key, value = params[:cargo][:sueldos_attributes].first\n\n if nuevo\n\n viejo = @cargo.sueldos.where(activo: true).last\n\n @cargo.sueldos.update_all(activo: false)\n crear = @cargo.sueldos.new\n crear.monto = params[:cargo][:sueldos_attributes][key][:monto]\n crear.sueldo_integral = params[:cargo][:sueldos_attributes][key][:sueldo_integral]\n\n params[:cargo][:sueldos_attributes][key][:monto] = viejo.monto\n params[:cargo][:sueldos_attributes][key][:sueldo_integral] = viejo.sueldo_integral\n\n end\n if @cargo.update(cargo_params)\n log(\"Se ha actualizado el cargo: #{@lt}\", 1)\n\n format.html { redirect_to @cargo, notice: 'Los datos del cargo fueron actualizados exitosamente.' }\n format.json { render :show, status: :ok, location: @cargo }\n else\n format.html { render :edit }\n format.json { render json: @cargo.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @os_entregavel.update(os_entregavel_params)\n if @os_entregavel.ordem_servico.id!=nil\n format.html { redirect_to \"/ordem_servicos/\"+@os_entregavel.ordem_servico.id.to_s, notice: 'Os entregavel foi atualizado(a)' }\n format.json { head :no_content }\n else\n format.html { redirect_to @os_entregavel, notice: 'Os entregavel foi atualizado(a)' }\n format.json { render :show, status: :ok, location: @os_entregavel }\n end\n else\n format.html { render :edit }\n format.json { render json: @os_entregavel.errors, status: :unprocessable_entity }\n end\n end\n end", "def activo_update\n respond_to do |format|\n activo = params[:producto][:activo]\n id = params[:id]\n Producto.where(id: id).update_all(activo: activo )\n msg = { :status => \"ok\", :message => \"Actualizado!\" }\n format.json { render :json => msg }\n end\n end", "def update\n respond_to do |format|\n if @sivic_discipulo.update(sivic_discipulo_params_netested)\n format.html { redirect_to @sivic_discipulo, notice: 'Registro alterado com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @sivic_discipulo.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @descuento_adicional.update(descuento_adicional_params)\n format.html { redirect_to @descuento_adicional, notice: 'Descuento adicional fue actualizado exitosamente.' }\n format.json { render :show, status: :ok, location: @descuento_adicional }\n else\n format.html { render :edit }\n format.json { render json: @descuento_adicional.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @relatorio_gerals = RelatorioGeral.all\n authorize @relatorio_gerals\n\n respond_to do |format|\n if @relatorio_geral.update(relatorio_geral_params)\n format.html { redirect_to @relatorio_geral, notice: 'Relatório geral atualizado com sucesso!' }\n format.json { render :show, status: :ok, location: @relatorio_geral }\n else\n format.html { render :edit }\n format.json { render json: @relatorio_geral.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n activo = params[:lab_far][:activo]\n farmacia_id = session[:farmacia_id]\n id = params[:id]\n LabFar.where(laboratorio_id: id, farmacium_id:farmacia_id).update_all(activo: activo )\n msg = { :status => \"ok\", :message => \"Actualizado!\" }\n format.json { render :json => msg }\n end\n end", "def update\n authorize! :update_almacen,Sigesp::Solicitud\n if @sigesp_solicitud.update(sigesp_solicitud_alamcen_params)\n return render json: { url: sigesp_solicitudsalmacen_path(@sigesp_solicitud)} \n else\n return render json:@sigesp_solicitud.errors ,status: :unprocessable_entity\n end \n end", "def update\n @respuesta = Respuesta.find(params[:id])\n\n respond_to do |format|\n if @respuesta.update_attributes(params[:respuesta])\n format.html { redirect_to @respuesta, notice: 'Respuesta was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @respuesta.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @voluntario = Voluntario.find(params[:id])\n params[:voluntario].delete :inclusoes\n\n respond_to do |format|\n if @voluntario.update_attributes(params[:voluntario])\n format.html { redirect_to(@voluntario, :notice => 'Voluntário atualizado com sucesso.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @voluntario.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @cliente = Cliente.find(params[:cliente_id])\n @pago = @cliente.pagos.find(params[:id])\n\n respond_to do |format|\n if @pago.update_attributes(params[:pago])\n format.html { redirect_to [@cliente, @pago], notice: 'Pago was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @pago.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @solicitacoes_avaliacoes_servico.update(solicitacoes_avaliacoes_servico_params)\n format.html { redirect_to @solicitacoes_avaliacoes_servico, notice: 'Solicitacoes avaliacoes servico was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @solicitacoes_avaliacoes_servico.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @observacao_vocacionada = ObservacaoVocacionada.new\n\n if params[:vocacionada]\n @observacao_vocacionada.vocacionada_id = params[:vocacionada]\n end\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @observacao_vocacionada }\n end\n end", "def update\n @mission = Mission.find(params[:id])\n\n respond_to do |format|\n if @mission.update_attributes(params[:mission])\n format.html { redirect_to @mission, :notice => 'Changements bien pris en compte' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @mission.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @agency = Agency.find(params[:id])\n\n if @agency.update(agency_params)\n #head :no_content\n render json: @agency, status: :accepted, location: @agency #sera? status accepted? \n else\n render json: @agency.errors, status: :unprocessable_entity\n end\n end", "def update\n @advertise = Advertise.find(params[:id])\n authorize! :update, @advertise, :message => 'Acceso denegado.'\n campusAdvertise = Advertise.find(params[:advertise_id][:campus_ids]) rescue []\n @advertise.campuses=campusAdvertise\n respond_to do |format|\n if @advertise.update_attributes(params[:advertise])\n format.html { redirect_to @advertise, notice: t(\"activerecord.alerts.advertise.updated\") }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @advertise.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @budget.update(budget_params)\n format.html { redirect_to @budget, notice: 'El presupuesto se actualizó correctamente' }\n format.json { render :show, status: :ok, location: @budget }\n else\n format.html { render :edit }\n format.json { render json: @budget.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @votaciones_hist.update(votaciones_hist_params)\n format.html { redirect_to @votaciones_hist, notice: 'Votaciones hist was successfully updated.' }\n format.json { render :show, status: :ok, location: @votaciones_hist }\n else\n format.html { render :edit }\n format.json { render json: @votaciones_hist.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n historial_params = params[:historial]\n with_bill = historial_params.delete(:with_bill)\n @historial = Historial.find(params[:id])\n\n respond_to do |format|\n if @historial.update_attributes(historial_params)\n if with_bill.present?\n format.html { redirect_to new_bill_path(\n client_id: @historial.cliente_id,\n historial_id: @historial.id\n ), notice: 'Presupuesto actualizado =)'}\n else\n format.html { redirect_to @historial, notice: 'Presupuesto actualizado =)' }\n end\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @historial.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n obtener_datos()\n @status = params[:statusproyect]\n @cliente = params[:cliente] + \" \" +params[:cliente_apellido]\n respond_to do |format|\n if @ventum.update(cliente: @cliente, clave:@clave, fecha:@fecha, iva:@iva,subtotal:@preciofinal ,total:@totalcosto, descuentogeneral: @descglobal , distribuidor: @distribuidor, status: @status)\n @detail.each do |x|\n x.destroy\n end\n salvar()\n format.html { redirect_to @ventum, notice: 'Venta actualizada correctamente.' }\n format.json { render :show, status: :ok, location: @ventum }\n else\n format.html { render :edit }\n format.json { render json: @ventum.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n render json: Company.update(params[\"id\"], params[\"company\"])\n end", "def update\n if @diet.update(diet_params)\n head :no_content, status: 204\n else\n render json: @diet.errors, status: 422\n end\n end", "def pro_farm_update\n respond_to do |format|\n activo = params[:pro_far][:activo_produc]\n farmacia_id = session[:farmacia_id]\n id = params[:id]\n ProFar.where(producto_id: id, farmacium_id:farmacia_id).update_all(activo_produc: activo )\n msg = { :status => \"ok\", :message => \"Actualizado!\" }\n format.json { render :json => msg }\n end\n end", "def update\n respond_to do |format|\n if @agenda.update(agenda_params)\n format.html { redirect_to @agenda, notice: 'Agenda was successfully updated.' }\n format.json { head :no_content }\n else\n @cidades = Cidade.order('cidade ASC')\n format.html { render action: 'edit' }\n format.json { render json: @agenda.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n\t\t\t@cliente.attributes = cliente_params\n\t\t\tif @cliente.vendedor_id_changed?\n\t\t\t\t@cliente.fecha_asignacion = Time.now\n\t\t\tend\n if @cliente.save\n format.html { redirect_to @cliente, notice: 'El cliente se actualizó exitosamente.' }\n format.json { render :show, status: :ok, location: @cliente }\n else\n format.html { render :edit }\n format.json { render json: @cliente.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @dress = Dress.find(params[:id])\n\n respond_to do |format|\n if @dress.update_attributes(params[:dress])\n format.html { redirect_to @dress, notice: 'Vestido atualizado com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @dress.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @adscripcion.update(adscripcion_params)\n format.html { redirect_to @adscripcion, notice: 'Adscripcion was successfully updated.' }\n format.json { render :show, status: :ok, location: @adscripcion }\n else\n format.html { render :edit }\n format.json { render json: @adscripcion.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @oferta_academica = OfertaAcademica.find(params[:id])\n\n if @oferta_academica.update(params[:oferta_academica])\n head :no_content\n else\n render json: @oferta_academica.errors, status: :unprocessable_entity\n end\n end", "def update\n @cliente = Cliente.find(params[:id])\n\n respond_to do |format|\n if @cliente.update_attributes(params[:cliente])\n format.html { redirect_to @cliente, notice: 'Cliente atualizado com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @cliente.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n set_funcionario\n if @ordem_servico.update(ordem_servico_params)\n format.html { redirect_to @ordem_servico, notice: t('messages.cadastro_atualizado') }\n format.json { render :show, status: :ok, location: @ordem_servico }\n else\n format.html { render :edit }\n format.json { render json: @ordem_servico.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n unless possui_acesso?()\n return\n end\n @aviso = Aviso.find(params[:id])\n\n respond_to do |format|\n if @aviso.update_attributes(params[:aviso])\n format.html { redirect_to @aviso, notice: 'Aviso was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @aviso.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @repuesto_servicio.update(repuesto_servicio_params)\n format.html { redirect_to @repuesto_servicio, notice: 'Repuesto o servicio fue actualizado con éxito.' }\n format.json { render :show, status: :ok, location: @repuesto_servicio }\n else\n format.html { render :edit }\n format.json { render json: @repuesto_servicio.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n #if @auditv.update(audit_params)\n if @auditv.update(cabecera_params)\n format.html { redirect_to @auditv, notice: 'Auditoria Vidres/BPH/BPM/FD actualitzada.' }\n format.json { render :show, status: :ok, location: @auditv }\n else\n format.html { render :edit }\n format.json { render json: @auditv.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @objeto.update(revista_params)\n format.html { redirect_to @objeto, notice: 'Revista was successfully updated.' }\n format.json { render :show, status: :ok, location: @objeto }\n else\n format.html { render :edit }\n format.json { render json: @objeto.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @paciente = Paciente.find(params[:id])\n\n respond_to do |format|\n if @paciente.update_attributes(params[:paciente])\n format.html { redirect_to @paciente, notice: 'Paciente atualizado com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @paciente.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @solicitud_servicio = SolicitudServicio.find(params[:id])\n\n respond_to do |format|\n if @solicitud_servicio.update_attributes(params[:solicitud_servicio])\n format.html { redirect_to @solicitud_servicio, notice: 'Solicitud servicio was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @solicitud_servicio.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @descuento_adicional.update(descuento_adicional_params)\n format.html { redirect_to @descuento_adicional, notice: 'Descuento adicional was successfully updated.' }\n format.json { render :show, status: :ok, location: @descuento_adicional }\n else\n format.html { render :edit }\n format.json { render json: @descuento_adicional.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @servidor.update(servidor_params)\n format.html { redirect_to @servidor, notice: 'Servidor atualizado com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @servidor.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @entrada_inventario = EntradaInventario.find(params[:id])\n\n respond_to do |format|\n if @entrada_inventario.update_attributes(params[:entrada_inventario])\n format.html { redirect_to @entrada_inventario, notice: 'Entrada inventario was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @entrada_inventario.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 @departamento = Departamento.find(params[:id])\n\n if @departamento.update(departamento_params)\n head :no_content\n else\n render json: @departamento.errors, status: :unprocessable_entity\n end\n end", "def add_aos_version(args = {}) \n post(\"/aosversions.json/\", args)\nend", "def update\n @periodo_academico = PeriodoAcademico.find(params[:id])\n\n if @periodo_academico.update(params[:periodo_academico])\n head :no_content\n else\n render json: @periodo_academico.errors, status: :unprocessable_entity\n end\n end", "def update\n @revenu = @foyer.revenus.find(params[:id])\n\n respond_to do |format|\n if @revenu.update_attributes(params[:revenu])\n flash[:notice] = 'Revenu a bien été mis à jour.'\n format.html { redirect_to foyer_revenus_url(@foyer) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @revenu.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @novedad.update(novedad_params)\n format.html { redirect_to @novedad, notice: 'Novedad editada correctamente.' }\n format.json { render :show, status: :ok, location: @novedad }\n else\n format.html { render :edit }\n format.json { render json: @novedad.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @advogados_escritorio = AdvogadosEscritorio.find(params[:id])\n\n respond_to do |format|\n if @advogados_escritorio.update_attributes(params[:advogados_escritorio])\n flash[:notice] = t('general.messages.update_success', model_name: t('activerecord.models.advogados_escritorio'))\n format.html { redirect_to edit_advogados_escritorio_path(@advogados_escritorio) }\n format.json { head :no_content }\n format.js { render action: 'save.js.erb' }\n else\n flash.now[:error] = t('general.messages.update_error', model_name: t('activerecord.models.advogados_escritorio'))\n format.html { render action: \"edit\" }\n format.json { render json: @advogados_escritorio.errors, status: :unprocessable_entity }\n format.js { render action: 'save.js.erb' }\n end\n end\n end", "def update\n @apuesta_detail = ApuestaDetail.find(params[:id])\n\n respond_to do |format|\n if @apuesta_detail.update_attributes(params[:apuesta_detail])\n format.html { redirect_to @apuesta_detail, notice: 'Apuesta detail was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @apuesta_detail.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @arrendimientospago = Arrendimientospago.find(params[:id])\n\n respond_to do |format|\n if @arrendimientospago.update_attributes(params[:arrendimientospago])\n format.html { redirect_to(@arrendimientospago, :notice => 'Arrendimientospago was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @arrendimientospago.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @encuesta1.update(encuesta1_params)\n format.html { redirect_to @encuesta1, notice: 'Encuesta1 was successfully updated.' }\n format.json { render :show, status: :ok, location: @encuesta1 }\n else\n format.html { render :edit }\n format.json { render json: @encuesta1.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @vano = Vano.find(params[:id])\n\n respond_to do |format|\n if @vano.update_attributes(params[:vano])\n format.html { redirect_to @vano, notice: 'Vano was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @vano.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @os_nivel_servico.update(os_nivel_servico_params)\n format.html { redirect_to @os_nivel_servico, notice: 'Os nivel servico foi atualizado(a)' }\n format.json { render :show, status: :ok, location: @os_nivel_servico }\n else\n format.html { render :edit }\n format.json { render json: @os_nivel_servico.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n client=Client.find_by_id params[:id]\n if client!= nil\n client.cedula=params[:cedula] ? params[:cedula]: client.cedula\n client.sector=params[:sector] ? params[:sector]: client.sector\n client.nombre=params[:nombre] ? params[:nombre]: client.nombre\n client.telefono=params[:telefono] ? params[:telefono]: client.telefono\n client.pagina=params[:pagina] ? params[:pagina]: client.pagina\n client.direccion=params[:direccion] ? params[:direccion]: client.direccion\n if client.save\n render(json: client, status: 201)\n end \n else\n render(json: client.errors, status: 404)\n end \n end", "def update\n respond_to do |format|\n if @responsible.update(responsible_params)\n format.html { redirect_to @responsible, notice: 'Responsavel editado com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @responsible.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n puts \"HACE ALGOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO\"\n if !params[:reserva][:tipo_reserva].blank?\n @tipo_reserva = TipoReserva.find(params[:reserva][:tipo_reserva])\n @reserva.tipo_reserva = @tipo_reserva\n end\n\n if !params[:reserva][:habitacion].blank?\n @habitacion = Habitacion.find(params[:reserva][:habitacion])\n @reserva.habitacion = @habitacion\n end\n\n if !params[:reserva][:cliente].blank?\n @cliente = Cliente.find(params[:reserva][:cliente])\n @reserva.cliente = @cliente\n end\n if !params[:reserva][:confirmada].blank?\n @reserva.confirmada = params[:reserva][:confirmada]\n end\n if @reserva.update(reserva_params)\n format.html { redirect_to reservas_url, notice: 'Reserva modificada con exito.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @reserva.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @agente = Agente.find(params[:id])\n\n respond_to do |format|\n if @agente.update_attributes(params[:agente])\n format.html { redirect_to @agente, notice: 'Agente se ha actualizado correctamente.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @agente.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @objeto.update(detalle_pedido_params)\n set_redireccion\n format.html { redirect_to @redireccion, notice: 'Detalle pedido was successfully updated.' }\n format.json { render :show, status: :ok, location: @objeto }\n else\n format.html { render :edit }\n format.json { render json: @objeto.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\n @empresa_servicio = EmpresaServicio.find(params[:id])\n respond_to do |format|\n if @empresa_servicio.update_attributes(params[:empresa_servicio])\n\n format.html { redirect_to empresa_empresa_servicios_path, notice: \"Los datos del servicio fueron actualizados para la empresa #{@empresa_servicio.empresa.nombre_empresa}\"}\n \n else\n format.html { render action: \"edit\" }\n format.json { render json: @empresa_servicio.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @venta = Venta.find(params[:id])\n\n respond_to do |format|\n if @venta.update_attributes(params[:venta])\n format.html { redirect_to @venta, notice: 'Venta was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @venta.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @tipo_agressor.update(tipo_agressor_params)\n format.html { redirect_to @tipo_agressor, notice: @@msgs }\n format.json { render :show, status: :ok, location: @tipo_agressor }\n else\n format.html { render :edit }\n format.json { render json: @tipo_agressor.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @atricle.update(atricle_params)\n format.html { redirect_to @atricle, notice: \"Atricle was successfully updated.\" }\n format.json { render :show, status: :ok, location: @atricle }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @atricle.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n authorize! :update, @theorem\n if @theorem.update(theorem_params)\n render json: @theorem, status: :ok, location: @theorem\n else\n render json: @theorem.errors, status: :unprocessable_entity\n end\n end", "def update\n @paciente = Paciente.find(params[:paciente_id])\n @visita = Visita.find(params[:id])\n\n respond_to do |format|\n if @visita.update_attributes(params[:visita])\n format.html { redirect_to(paciente_visitas_url, :notice => 'La Visita se modifico exitosamente.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @visita.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @lease = Lease.find(params[:id])\n\n respond_to do |format|\n if @lease.update_attributes(params[:lease])\n format.html { redirect_to cars_url, :notice => 'Lease was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @lease.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n pai = params[:pai] ? Conta.find_by_id(params[:pai]): nil\n \n respond_to do |format|\n if @conta.update(nome: conta_params[:nome], status: conta_params[:status], pai: pai) \n #format.json { render :show, status: :ok, location: @conta }\n format.json { render json: @conta.to_json, status: :ok }\n else \n format.json { render json: @conta.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n #parametros_autocomplete!(params[:estudiante][:persona])\n @estudiante = Estudiante.find(params[:id])\n \n begin\n @estudiante.persona_id = params[:persona][:id]\n rescue\n end\n\n respond_to do |format|\n if @estudiante.update_attributes(params[:estudiante])\n format.html { redirect_to @estudiante, notice: 'Estudiante actualizado' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @estudiante.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @article = Article.find(params[:id])\n\n\n respond_to do |format|\n if @article.update_attributes(params[:article])\n undo_link = view_context.link_to(\"undo\", revert_version_path(@article.versions.last), :method => :post)\n format.html { redirect_to @article, notice: \"Article was successfully updated. #{undo_link}\" }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @article.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @pedido.update(pedido_params)\n format.html { redirect_to itens_pedido_path, notice: 'Pedido atualizado com sucesso.' }\n format.json { render :show, status: :ok, location: @pedido }\n else\n format.html { render :edit }\n format.json { render json: @pedido.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @habito.update(habito_params)\n format.html { redirect_to index_habito_path(params[:habito][:paciente_id]), notice: 'Datos actualizados correctamente' }\n format.json { render :show, status: :ok, location: @habito }\n else\n format.html { render :edit }\n format.json { render json: @habito.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @niveau = Niveau.find(params[:id])\n authorize! :update, @niveau\n respond_to do |format|\n if @niveau.update_attributes(params[:niveau])\n format.html { redirect_to @niveau, notice: 'Niveau werd succesvol gewijzigd.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @niveau.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @vehicule_perso = VehiculePerso.find(params[:id])\n\n respond_to do |format|\n if @vehicule_perso.update_attributes(params[:vehicule_perso])\n format.html { redirect_to @vehicule_perso, :notice => 'Le véhicule personnel a bien été modifié' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @vehicule_perso.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n movimiento_caja = MovimientoCaja.find(params[:movimiento_caja_id])\n @movimiento_de_cajas_detalle = movimiento_caja.movimiento_de_cajas_detalles.find(params[:id])\n respond_to do |format|\n if @movimiento_de_cajas_detalle.update(movimiento_de_cajas_detalle_params)\n format.html { redirect_to [@movimiento_de_cajas_detalle.movimiento_caja, @movimiento_de_cajas_detalle] }\n format.json { render :show, status: :ok, location: [@movimiento_de_cajas_detalle.movimiento_caja, @movimiento_de_cajas_detalle] }\n else\n format.html { render :edit }\n format.json { render json: @movimiento_de_cajas_detalle.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @representante_athlete.update_attributes(params[:representante_athlete])\n format.html { redirect_to representante_athletes_url, notice: 'Atleta atualizado com sucesso' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @representante_athlete.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @ordene.update(ordene_params)\n format.html { redirect_to @ordene, notice: 'O de Trabajo actualizada con exito.' }\n format.json { render :show, status: :ok, location: @ordene }\n else\n format.html { render :edit }\n format.json { render json: @ordene.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n authorize @lease\n respond_to do |format|\n if @lease.update(lease_params)\n format.html { redirect_to @lease, success: I18n.t('notices.updated', entity: Lease.model_name.human, title: @lease.reference) }\n format.json { render :show, status: :ok, location: @lease }\n else\n format.html { render :edit }\n format.json { render json: @lease.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @ranchada.update(ranchada_params)\n actualizar_dependencias\n AuditoriaDataAccess.log current_user, Auditoria::MODIFICACION, Auditoria::RANCHADA, @ranchada\n format.html { redirect_to ranchadas_url, notice: I18n.t('common.exito.actualizacion_ranchada') }\n format.json { render :show, status: :ok, location: @ranchada }\n else\n if @ranchada.zone\n @zonas = Zone.where(:area_id => @ranchada.zone.area.id)\n else\n @zonas = Zone.zonas_primer_area\n @ranchada.area_id = @zonas.first.area_id\n @ranchada.zone_id = @zonas.first.id\n end\n\n format.html { render :edit }\n format.json { render json: @ranchada.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to_update({thing: @author})\n end", "def update\n respond_to do |format|\n if @concepto_de_pago.update(concepto_de_pago_params)\n format.html { redirect_to @concepto_de_pago, notice: 'Concepto de pago fue actualizado exitosamente.' }\n format.json { render :show, status: :ok, location: @concepto_de_pago }\n else\n format.html { render :edit }\n format.json { render json: @concepto_de_pago.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @realiza = Realiza.find(params[:id])\n @pagamento=Pagamento.new(:servico_id=>@realiza.servico_id,:cliente_id=>@realiza.cliente_id,:valor=>@realiza.servico.preco,\n :formapagamentoe_id=>params[:pagamento])\n respond_to do |format|\n if @realiza.update_attributes(params[:realiza]) and @pagamento.save\n format.html { redirect_to @realiza, notice: 'Realiza was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @realiza.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @orphan.update(orphan_params)\n format.html { redirect_to @orphan, notice: 'Orphan was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @orphan.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.6274904", "0.61585337", "0.6100573", "0.6089805", "0.60569453", "0.60055006", "0.5990302", "0.59811807", "0.59247917", "0.59129006", "0.59076166", "0.5906806", "0.5903343", "0.58729", "0.58480173", "0.5806164", "0.57998765", "0.57883483", "0.57594556", "0.57495445", "0.57274526", "0.57263666", "0.57246053", "0.57227015", "0.57174397", "0.5709982", "0.57064015", "0.569869", "0.5690219", "0.56900305", "0.5689354", "0.5683046", "0.5680461", "0.56768066", "0.5674774", "0.5672461", "0.5669302", "0.5664643", "0.56531596", "0.56485707", "0.5637653", "0.5636566", "0.5631069", "0.56210995", "0.5618391", "0.5617876", "0.5614504", "0.56132895", "0.5606986", "0.56044996", "0.5602843", "0.5602319", "0.55930173", "0.55906737", "0.55892855", "0.5586473", "0.5584644", "0.55831766", "0.55828327", "0.5581707", "0.5581415", "0.5580595", "0.55741006", "0.5572485", "0.556816", "0.55677277", "0.556556", "0.556452", "0.5564295", "0.55632114", "0.55615807", "0.55605924", "0.5559443", "0.5552542", "0.55523443", "0.55510193", "0.5548893", "0.5544576", "0.5544472", "0.5541219", "0.55405", "0.55403787", "0.55397654", "0.55384606", "0.55377275", "0.5536718", "0.55363107", "0.5529654", "0.5529207", "0.55271834", "0.55270714", "0.5525056", "0.5524986", "0.55231524", "0.55217165", "0.552128", "0.5519445", "0.55193955", "0.55177575", "0.5517009" ]
0.6757945
0
DELETE /adversaires/1 DELETE /adversaires/1.json
def destroy @equipe = Equipe.find(params[:equipe_id]) @adversaire = Adversaire.find(params[:id]) @adversaire.destroy respond_to do |format| format.html { redirect_to @equipe } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @serv_adicionale = ServAdicionale.find(params[:id])\n @serv_adicionale.destroy\n\n respond_to do |format|\n format.html { redirect_to serv_adicionales_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @respuesta = Respuesta.find(params[:id])\n @respuesta.destroy\n\n respond_to do |format|\n format.html { redirect_to respuestas_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @dynamique = Dynamique.find(params[:id])\n @dynamique.destroy\n\n respond_to do |format|\n format.html { redirect_to dynamiques_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @descuento_adicional.destroy\n respond_to do |format|\n format.html { redirect_to descuento_adicionals_url, notice: 'Descuento adicional fue eliminado exitosamente.' }\n format.json { head :no_content }\n end\n end", "def delete\n render json: Alien.delete(params[\"id\"])\n end", "def delete\n unless possui_acesso?()\n return\n end\n @aviso = Aviso.find(params[:id])\n @aviso.destroy\n\n respond_to do |format|\n format.html { redirect_to avisos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @asignatura.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n @unidad.destroy\n respond_to do |format|\n format.html { redirect_to unidades_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @especialidad.destroy\n respond_to do |format|\n format.html { redirect_to especialidads_url, notice: 'Servicio eliminado exitosamente.' }\n format.json { head :no_content }\n end\n end", "def delete\n client.delete(\"/#{id}\")\n end", "def delete_aos_version(args = {}) \n delete(\"/aosversions.json/#{args[:aosVersionId]}\", args)\nend", "def destroy\n @safra_verdoso = SafraVerdoso.find(params[:id])\n @safra_verdoso.destroy\n\n respond_to do |format|\n format.html { redirect_to \"/safra_produtos/#{@safra_verdoso.safra_produto_id}/descontos\"}\n format.json { head :no_content }\n end\n end", "def destroy\n# redirect_to activacionclientets_path # ted esto para evitar que borren por la web. ok. Que valla al index. provisional ok.\n \n #@activacionclientet.destroy\n respond_to do |format|\n format.html { redirect_to activacionclientets_url, notice: 'Activacionclientes no se puede eliminar por esta via. Contacte el administrador.' } # ted esto para evitar que borren por la web\n format.json { head :no_content }\n end\n end", "def destroy\n @datos_insumos_reactivo.destroy\n respond_to do |format|\n format.html { redirect_to datos_insumos_reactivos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @humanidades1 = Humanidades1.find(params[:id])\n @humanidades1.destroy\n\n respond_to do |format|\n format.html { redirect_to humanidades1s_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @descuento = Descuento.find(params[:id])\n @descuento.destroy\n\n respond_to do |format|\n format.html { redirect_to descuentos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @datosgenerale.destroy\n respond_to do |format|\n format.html { redirect_to datosgenerales_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @detalle = Detalle.find(params[:id])\n @detalle.destroy\n\n respond_to do |format|\n format.html { redirect_to detalles_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @respuesta = Respuesta.find(params[:id])\n @respuesta.destroy\n\n head :no_content\n end", "def destroy\n @detalle_documento_de_compra.destroy\n respond_to do |format|\n format.html { redirect_to :back, notice: 'Linea eliminada' }\n format.json { head :no_content }\n end\n end", "def destroy\n @descuento_adicional.destroy\n respond_to do |format|\n format.html { redirect_to descuento_adicionals_url, notice: 'Descuento adicional was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @aucrecord.destroy\n respond_to do |format|\n format.html { redirect_to aucrecords_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @adres_kontr.destroy\n respond_to do |format|\n format.html { redirect_to adres_kontr_index_url, notice: 'Adres kontr was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @adscripcion.destroy\n respond_to do |format|\n format.html { redirect_to adscripciones_url, notice: 'Adscripcion was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @retroalimentacion = Retroalimentacion.find(params[:id])\n @retroalimentacion.destroy\n\n respond_to do |format|\n format.html { redirect_to retroalimentacions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @observacao_vocacionada = ObservacaoVocacionada.find(params[:id])\n @observacao_vocacionada.destroy\n\n respond_to do |format|\n format.html { redirect_to observacao_vocacionadas_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @actividad = Actividad.find(params[:id])\n @actividad.destroy\n\n respond_to do |format|\n format.html { redirect_to actividads_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @asignatura = Asignatura.find(params[:id])\n @asignatura.destroy\n\n respond_to do |format|\n format.html { redirect_to asignaturas_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @asignatura = Asignatura.find(params[:id])\n @asignatura.destroy\n\n respond_to do |format|\n format.html { redirect_to asignaturas_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @asiento = Asiento.find(params[:id])\n @asiento.destroy\n\n respond_to do |format|\n format.html { redirect_to asientos_url }\n format.json { head :ok }\n end\n end", "def destroy\n @detalle_orden_trabajo.destroy\n respond_to do |format|\n format.html { redirect_to @orden_trabajo, notice: 'Detalle fue eliminado con éxito.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @asociado = Asociado.find(params[:id])\n @asociado.destroy\n\n respond_to do |format|\n format.html { redirect_to asociados_url }\n format.json { head :ok }\n end\n end", "def destroy\n @relatestagiario = Relatestagiario.find(params[:id])\n @relatestagiario.destroy\n\n respond_to do |format|\n format.html { redirect_to(relatestagiarios_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @doctor_cliente = DoctorCliente.find(params[:id])\n @doctor_cliente.destroy\n\n respond_to do |format|\n format.html { redirect_to doctor_clientes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @novedad.destroy\n respond_to do |format|\n format.html { redirect_to novedads_url, notice: 'Novedad eliminada correctamente.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @cliente.destroy\n respond_to do |format|\n format.html { redirect_to clientes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @apuesta_detail = ApuestaDetail.find(params[:id])\n @apuesta_detail.destroy\n\n respond_to do |format|\n format.html { redirect_to apuesta_details_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @advert.destroy\n respond_to do |format|\n format.html { redirect_to adverts_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @adjunto = Adjunto.find(params[:id])\n @adjunto.destroy\n\n respond_to do |format|\n format.html { redirect_to(adjuntos_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @actividad.destroy\n respond_to do |format|\n format.html { redirect_to actividads_url, notice: 'Actividad was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @adecuacionactividad.destroy\n respond_to do |format|\n format.html { redirect_to adecuacionactividads_url, notice: 'Adecuacionactividad was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @contador.destroy\n respond_to do |format|\n format.html { redirect_to contadors_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @gran_unidad.destroy\n respond_to do |format|\n format.html { redirect_to gran_unidad_index_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @substancia.destroy\n respond_to do |format|\n format.html { redirect_to substancias_url, notice: 'Substancia was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @visitante.destroy\n respond_to do |format|\n format.html { redirect_to visitantes_url, notice: 'Visitante was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def 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 @reconocimiento = Reconocimiento.find(params[:id])\n @reconocimiento.destroy\n\n respond_to do |format|\n format.html { redirect_to reconocimientos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @solicitud.destroy\n respond_to do |format|\n format.html { redirect_to solicitudes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @servico_pacote.destroy\n respond_to do |format|\n format.html { redirect_to servico_pacotes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @prueba_json.destroy\n respond_to do |format|\n format.html { redirect_to prueba_jsons_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @advert = Advert.find(params[:id])\n @advert.destroy\n\n respond_to do |format|\n format.html { redirect_to adverts_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @advert = Advert.find(params[:id])\n @advert.destroy\n\n respond_to do |format|\n format.html { redirect_to adverts_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @advert1.destroy\n respond_to do |format|\n format.html { redirect_to advert1s_url, notice: 'Advert1 was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @detalle.destroy\n respond_to do |format|\n format.html { redirect_to detalles_url, notice: 'Detalle was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @cliente = Cliente.find(params[:id])\n @cliente.destroy\n\n respond_to do |format|\n format.html { redirect_to clientes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @cliente = Cliente.find(params[:id])\n @cliente.destroy\n\n respond_to do |format|\n format.html { redirect_to clientes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @cliente = Cliente.find(params[:id])\n @cliente.destroy\n\n respond_to do |format|\n format.html { redirect_to clientes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @addre = Addre.find(params[:id])\n @addre.destroy\n\n respond_to do |format|\n format.html { redirect_to addres_url }\n format.json { head :no_content }\n end\n end", "def destroy\r\n @sivic_rede.destroy\r\n respond_to do |format|\r\n format.html { redirect_to sivic_redes_url }\r\n format.json { head :no_content }\r\n end\r\n end", "def destroy\n @trein_consul_comercial.destroy\n respond_to do |format|\n format.html { redirect_to trein_consul_comercials_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @fulcliente = Fulcliente.find(params[:id])\n @fulcliente.destroy\n\n respond_to do |format|\n format.html { redirect_to fulclientes_url }\n format.json { head :ok }\n end\n end", "def destroy\n @cliente = Cliente.find(params[:id])\n @cliente.destroy\n\n respond_to do |format|\n format.html { redirect_to clientes_url }\n format.json { head :ok }\n end\n end", "def destroy\n @dato = Dato.find(params[:id])\n @dato.destroy\n\n respond_to do |format|\n format.html { redirect_to datos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @humanidades2 = Humanidades2.find(params[:id])\n @humanidades2.destroy\n\n respond_to do |format|\n format.html { redirect_to humanidades2s_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @prioridad.destroy\n respond_to do |format|\n format.html { redirect_to prioridads_url, notice: 'Se ha eliminado la Prioridad.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @prioridade_adocao = PrioridadeAdocao.find(params[:id])\n @prioridade_adocao.destroy\n\n respond_to do |format|\n format.html { redirect_to prioridade_adocoes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @diagnoz = Diagnoz.find(params[:id])\n @diagnoz.destroy\n\n respond_to do |format|\n format.html { redirect_to diagnozs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @annonce.destroy\n respond_to do |format|\n format.html { redirect_to annonces_url, notice: 'Votre annonce à été supprimé avec succès.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @verbindung = Verbindung.find(params[:id])\n @verbindung.destroy\n\n respond_to do |format|\n format.html { redirect_to verbindungs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @requerimiento = Requerimiento.find(params[:id])\n @requerimiento.destroy\n\n respond_to do |format|\n format.html { redirect_to requerimientos_url }\n format.json { head :ok }\n end\n end", "def destroy\r\n @sivic_contcelula.destroy\r\n respond_to do |format|\r\n format.html { redirect_to sivic_contcelulas_url }\r\n format.json { head :no_content }\r\n end\r\n end", "def destroy\n @adopcion.destroy\n respond_to do |format|\n format.html { redirect_to adopcions_url, notice: 'Adopcion Eliminada.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @repuestum = Repuestum.find(params[:id])\n @repuestum.destroy\n\n respond_to do |format|\n format.html { redirect_to repuesta_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @adquisicione.destroy\n respond_to do |format|\n format.html { redirect_to adquisiciones_url, notice: 'Adquisicione was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @line = Line.find(params[:id])\n @line.destroy\n\n respond_to do |format|\n format.html { redirect_to budget_path(@line.budget) }\n format.json { head :no_content }\n end\n end", "def destroy\n @historial_odt = HistorialOdt.find(params[:id])\n @historial_odt.destroy\n\n respond_to do |format|\n format.html { redirect_to historial_odts_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @lineamiento.destroy\n respond_to do |format|\n format.html { redirect_to lineamientos_url, notice: 'Lineamiento was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @autorizacion.destroy\n respond_to do |format|\n format.html { redirect_to autorizacions_url, notice: 'Autorizacion was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @antecedente = Antecedente.find(params[:id])\n @antecedente.destroy\n\n respond_to do |format|\n format.html { redirect_to antecedentes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @updaterete = Updaterete.find(params[:id])\n @updaterete.destroy\n\n respond_to do |format|\n format.html { redirect_to updateretes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @estacionamiento = Estacionamiento.find(params[:id])\n @estacionamiento.destroy\n\n respond_to do |format|\n format.html { redirect_to estacionamientos_url }\n format.json { head :ok }\n end\n end", "def destroy\n @asociacion.destroy\n respond_to do |format|\n format.html { redirect_to asociaciones_url, notice: 'Asociacion was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @sugerencia = Sugerencia.find(params[:id])\n @sugerencia.destroy\n\n respond_to do |format|\n format.html { redirect_to sugerencias_url }\n format.json { head :ok }\n end\n end", "def destroy\n @consulta_viaje.destroy\n respond_to do |format|\n format.html { redirect_to consulta_viajes_url, notice: 'Consulta viaje was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @rescate.destroy\n respond_to do |format|\n format.html { redirect_to rescates_url, notice: 'Rescate fue eleminado' }\n format.json { head :no_content }\n end\n end", "def destroy\n @clientes_servico.destroy\n respond_to do |format|\n format.html { redirect_to clientes_servicos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @reprogramacion = Reprogramacion.find(params[:id])\n @reprogramacion.destroy\n\n respond_to do |format|\n format.html { redirect_to reprogramaciones_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @dang_vien.destroy\n respond_to do |format|\n format.html { redirect_to dang_viens_url, notice: 'Dang vien was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @status_ativ = StatusAtiv.find(params[:id])\n @status_ativ.destroy\n\n respond_to do |format|\n format.html { redirect_to status_ativs_url }\n format.json { head :no_content }\n end\n end", "def destroy\r\n @sivic_relatorioscelula.destroy\r\n respond_to do |format|\r\n format.html { redirect_to sivic_relatorioscelulas_url }\r\n format.json { head :no_content }\r\n end\r\n end", "def destroy\n @adquisicion.destroy\n respond_to do |format|\n format.html { redirect_to adquisicions_url, notice: 'Adquisicion was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @tipo_agressor.destroy\n respond_to do |format|\n format.html { redirect_to tipo_agressores_url, notice: @@msgs }\n format.json { head :no_content }\n end\n end", "def destroy\n @ad = Ad.find(params[:id])\n @ad.destroy\nrender json: 1\n end", "def destroy\n @asistencia_domingo.destroy\n respond_to do |format|\n format.html { redirect_to asistencia_domingos_url, notice: 'Asistencia domingo was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @venta = Venta.find(params[:id])\n @venta.destroy\n\n respond_to do |format|\n format.html { redirect_to ventas_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @advert.destroy\n respond_to do |format|\n format.html { redirect_to admin_adverts_url, notice: 'Advert was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n #--ADICIONADO\n @cliente.perfilclientes.destroy\n #--ADICIONADO\n @cliente.destroy\n respond_to do |format|\n format.html { redirect_to clientes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @administracao_relatorios_diario.destroy\n respond_to do |format|\n format.html { redirect_to administracao_relatorios_diarios_url, notice: 'Relatorios diario was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @historial = Historial.find(params[:id])\n @historial.destroy\n\n respond_to do |format|\n format.html { redirect_to historials_url }\n format.json { head :ok }\n end\n end", "def destroy\n @detalhe.destroy\n respond_to do |format|\n format.html { redirect_to detalhes_url }\n format.json { head :no_content }\n end\n end" ]
[ "0.7122333", "0.6964952", "0.69625217", "0.69597495", "0.695259", "0.6923468", "0.6904102", "0.6899791", "0.68929213", "0.6891559", "0.68866503", "0.68860847", "0.68840605", "0.68811786", "0.6878483", "0.6855115", "0.68507683", "0.6849284", "0.6842502", "0.68303394", "0.68281776", "0.68278724", "0.68228483", "0.6822806", "0.6810948", "0.6802073", "0.6800763", "0.6791007", "0.6791007", "0.6789468", "0.6788143", "0.6785286", "0.67740136", "0.6773163", "0.67629707", "0.676186", "0.6761606", "0.67604405", "0.6759014", "0.6758978", "0.6754414", "0.6753545", "0.675302", "0.6751744", "0.67515355", "0.67371505", "0.6731197", "0.6730103", "0.672989", "0.6729594", "0.672638", "0.672638", "0.6724683", "0.6718322", "0.6713192", "0.6713192", "0.6713192", "0.6712983", "0.6711169", "0.6706818", "0.67064846", "0.67049617", "0.6701004", "0.6692037", "0.6689636", "0.66828215", "0.66826856", "0.66777027", "0.6677544", "0.6677127", "0.6674013", "0.66739297", "0.66732675", "0.6672184", "0.6671321", "0.66705424", "0.66702646", "0.66648096", "0.66647685", "0.6662064", "0.66613233", "0.66604966", "0.66597825", "0.66597253", "0.66584295", "0.66577893", "0.6654891", "0.6654097", "0.6651094", "0.6648835", "0.6648583", "0.6648238", "0.66472656", "0.66456705", "0.66446704", "0.66444856", "0.6642403", "0.66417134", "0.66415405", "0.6641137" ]
0.7383552
0
Reconfigures the provided option, setting its value to `value`.
def call(value) raise NotImplementedError end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def call(value)\n Datadog.logger.debug { \"Reconfigured tracer option `#{@setting_key}` with value `#{value}`\" }\n\n if value.nil?\n # Restore the local configuration value\n configuration_object.unset_option(\n @setting_key,\n precedence: Core::Configuration::Option::Precedence::REMOTE_CONFIGURATION\n )\n else\n configuration_object.set_option(\n @setting_key,\n value,\n precedence: Core::Configuration::Option::Precedence::REMOTE_CONFIGURATION\n )\n end\n end", "def configure_setting(name, value)\n configure do |settings|\n settings.unset!(name)\n settings[name] = parse_setting(settings.setting(name), value)\n end\n end", "def update_option(opt, val)\n @options[opt] = val\n end", "def option(key, value)\n key = Bcpm::Match.engine_options[key.to_s] if key.kind_of? Symbol\n \n if value.nil?\n @options.delete key\n else\n @options[key] = value\n end\n end", "def setUserOptions option, value\n uOptions[option].delete\n uOptions[option] = value\n end", "def []=(config_option, value)\n @configuration[config_option.to_sym] = value\n end", "def set(option, value=self)\n if value == self && option.kind_of?(Hash)\n @app.options.merge!(option)\n else\n @app.options.merge!(option => value)\n end\n end", "def set(option, value=nil)\n if value.nil?\n self.options = option.to_hash\n else\n write_option option, value\n end\n end", "def set_opt(opt, value)\n opt = opt.to_sym\n if @options.key?(opt)\n @options[opt] = value\n @opt_set = true\n else\n msg = \"Illegal option '#{opt}', specify one of: #{@options.keys.join(', ')}\"\n raise ArgumentError.new(msg)\n end\n end", "def option_replace(key, default = nil)\n value = @options[key] || default\n @options.delete(key) if @options.has_key?(key)\n value\n end", "def setOption(key, value)\n self.options[key] = value\n\n return self\n end", "def processor_option(option, value = nil)\n _processor_options[option.to_sym] = value\n end", "def set(option, value)\n define_method(option) { value }\n end", "def vash_munge_value(val); self.class.munge_option_value(val); end", "def set_option(field, value)\n return @opts[field] if value.nil?\n Scope.new(collection, selector, @opts.merge(field => value))\n end", "def with_value(value)\n options[:value] = value\n self\n end", "def set(option, value)\n @context.send \"#{option}=\".to_sym, value\n end", "def set_opt(option, value)\n type = @@option_types.fetch(option) \\\n { raise ArgumentError, \"Unknown option: #{option}\" }\n \n unless type == :string\n if type == :bool\n valptr = FFI::MemoryPointer.new(:int)\n valptr.write_int(value ? 1 : 0)\n else\n valptr = FFI::MemoryPointer.new(type)\n valptr.send :\"write_#{type}\", value\n end\n value = valptr\n end\n \n rc = LibZMQ.zmq_setsockopt @pointer, option, value, value.size\n ZMQ.error_check true if rc==-1\n \n value\n end", "def configure(option)\n config.merge(option)\n end", "def set_option(key, value = nil, meta_key = \"_default\")\n return if key.nil?\n data = cama_options(meta_key)\n data[key] = fix_meta_var(value)\n set_meta(meta_key, data)\n value\n end", "def []=( name, value )\n @options[ name ] = value\n end", "def option key, value\n @options[ key ] = value\n end", "def option(name, value = nil)\n default_options[name] = value\n end", "def internal_set(symbol, value)\n if configurables.key?(symbol)\n configurables[symbol].set(configuration, value)\n elsif config_contexts.key?(symbol)\n config_contexts[symbol].restore(value.to_hash)\n else\n if config_strict_mode == :warn\n Chef::Log.warn(\"Setting unsupported config value #{symbol}.\")\n elsif config_strict_mode\n raise UnknownConfigOptionError, \"Cannot set unsupported config value #{symbol}.\"\n end\n configuration[symbol] = value\n end\n end", "def set! name, value\n fail(\"options already set: #{name.inspect}\") if (\n respond_to?(name) || has_key?(name)\n )\n self[name] = value\n getter_unless_defined name, name\n end", "def set!(value)\n @mutex.synchronize do\n old_value = @value\n @value = value\n @full_condition.signal\n apply_deref_options(old_value)\n end\n end", "def set(opt,val)\n if opt.is_a?(Symbol)\n setopt(sym2curl(opt), val)\n else\n setopt(opt.to_i, val)\n end\n end", "def set(key, value)\n @options[key] = value\n end", "def set(key, value)\n @options[key] = value\n end", "def set(option, value=self, &block)\n if block_given?\n write_option option, block\n elsif value == self\n self.options = option.to_hash\n else\n write_option option, value\n end\n end", "def set option_value\n self.select option_value\n end", "def clear(option)\n @client.call('config.unset', option)\n end", "def set(option, value=(not_set = true), &block)\n raise ArgumentError, 'value not set' if block and !not_set\n\n if not_set\n set_options option\n return self\n end\n\n if respond_to?(\"#{option}=\")\n return __send__(\"#{option}=\", value)\n end\n\n self\n end", "def config=(value); end", "def set_option(key, value)\r\n\t\t\tif value.is_a? Array\r\n\t\t\t\tvalue = value.join \",\"\r\n\t\t\tend\r\n\t\t\tself.options[key] = value\r\n\t\tend", "def set_config(key, value)\n\n # TODO Currently protected and private settings are not\n # excluded from the inheritance chain, so this error would\n # only be raised if someone typoed a key.\n raise \"#{key} is not a registered or inherited configuration option for #{self.class}\" \\\n unless self.class.default_config.keys.include?(key.to_s)\n\n default_value = self.class.default_config[key][1]\n value = default_value if value == :default\n config = configurations.where('key = ?', key.to_s).first\n if config\n if value == default_value # setting back to default\n config.destroy\n else\n config.update_attributes(value: value.to_s) # changing a custom setting\n end\n else\n return true if value == default_value # don't create a record for the default\n configurations.create(key: key.to_s, value: value.to_s)\n end\n end", "def set_opt(opt, default)\n if opt\n opt\n else\n default\n end\n end", "def update_value(new_value)\n if @type != :slider\n value_index = @values.index(new_value)\n new_value = @values[value_index || 0]\n end\n $options.send(setter, new_value)\n end", "def set_option(option, value, handle, type = :easy)\n type = type.to_sym unless type.is_a?(Symbol)\n raise NameError, \"Ethon::Curls::Options unknown type #{type}.\" unless respond_to?(OPTION_STRINGS[type])\n opthash=send(OPTION_STRINGS[type], nil)\n raise Errors::InvalidOption.new(option) unless opthash.include?(option)\n\n case opthash[option][:type]\n when :none\n return if value.nil?\n value=1\n va_type=:long\n when :int\n return if value.nil?\n va_type=:long\n value=value.to_i\n when :bool\n return if value.nil?\n va_type=:long\n value=(value&&value!=0) ? 1 : 0\n when :time\n return if value.nil?\n va_type=:long\n value=value.to_i\n when :enum\n return if value.nil?\n va_type=:long\n value = case value\n when Symbol\n opthash[option][:opts][value]\n when String\n opthash[option][:opts][value.to_sym]\n else\n value\n end.to_i\n when :bitmask\n return if value.nil?\n va_type=:long\n value = case value\n when Symbol\n opthash[option][:opts][value]\n when Array\n value.inject(0) { |res,v| res|opthash[option][:opts][v] }\n else\n value\n end.to_i\n when :string\n va_type=:string\n value=value.to_s unless value.nil?\n when :string_as_pointer\n va_type = :pointer\n s = ''\n s = value.to_s unless value.nil?\n value = FFI::MemoryPointer.new(:char, s.bytesize)\n value.put_bytes(0, s)\n when :string_escape_null\n va_type=:string\n value=Util.escape_zero_byte(value) unless value.nil?\n when :ffipointer\n va_type=:pointer\n raise Errors::InvalidValue.new(option,value) unless value.nil? or value.is_a? FFI::Pointer\n when :curl_slist\n va_type=:pointer\n raise Errors::InvalidValue.new(option,value) unless value.nil? or value.is_a? FFI::Pointer\n when :buffer\n raise NotImplementedError, \"Ethon::Curls::Options option #{option} buffer type not implemented.\"\n when :dontuse_object\n raise NotImplementedError, \"Ethon::Curls::Options option #{option} type not implemented.\"\n when :cbdata\n raise NotImplementedError, \"Ethon::Curls::Options option #{option} callback data type not implemented. Use Ruby closures.\"\n when :callback\n va_type=:callback\n raise Errors::InvalidValue.new(option,value) unless value.nil? or value.is_a? Proc\n when :socket_callback\n va_type=:socket_callback\n raise Errors::InvalidValue.new(option,value) unless value.nil? or value.is_a? Proc\n when :timer_callback\n va_type=:timer_callback\n raise Errors::InvalidValue.new(option,value) unless value.nil? or value.is_a? Proc\n when :debug_callback\n va_type=:debug_callback\n raise Errors::InvalidValue.new(option,value) unless value.nil? or value.is_a? Proc\n when :progress_callback\n va_type=:progress_callback\n raise Errors::InvalidValue.new(option,value) unless value.nil? or value.is_a? Proc\n when :off_t\n return if value.nil?\n va_type=:int64\n value=value.to_i\n end\n\n if va_type==:long or va_type==:int64 then\n bits=FFI.type_size(va_type)*8\n tv=((value<0) ? value.abs-1 : value)\n raise Errors::InvalidValue.new(option,value) unless tv<(1<<bits)\n end\n send(FUNCS[type], handle, opthash[option][:opt], va_type, value)\n end", "def with_override(flag)\n raise ConfigNotApplied if !config\n\n reset if @tracer && !@tracer.in_progress?\n config.override = flag\n self\n end", "def set_option(value)\r\n\t\tif value.is_a? Array\r\n\t\t\tvalue.each do |cur_value|\r\n\t\t\t\to_v = OptionValue.find(cur_value)\r\n\t\t\t\tself.line_item_option_values << LineItemOptionValue.new(:option_value => cur_value, :extra_cost => o_v.extra_cost, :extra_weight => o_v.extra_weight)\r\n\t\t\tend\r\n\t\telse\r\n\t\t\to_v = OptionValue.find(value)\r\n\t\t\tself.line_item_option_values << LineItemOptionValue.new(:option_value => value, :extra_cost => o_v.extra_cost, :extra_weight => o_v.extra_weight)\r\n\t\tend\r\n\tend", "def handle_failed_option param, value\n @options_ok = false\n end", "def set!(path, value)\n setProperty path, value\n save if respond_to? :save # Only Configuration can save\n value\n end", "def explicitly_set_value=(value)\n @explicitly_set_value = value\n end", "def set_option_value\n @option_value = OptionValue.find(params[:id])\n end", "def tcfg_set(key, value)\n tier_code_defaults[key] = value\n tcfg_reset\n value\n end", "def default_option(option, value)\n default_options[option.to_sym] = value\n end", "def []=(key, value)\n @_options_lookup[key] ||= {}\n super\n end", "def value=(value)\n debug \"set value\"\n file = Tempfile.new('openldap_confgi', '/tmp')\n begin\n file << \"dn: cn=config\\n\"\n file << \"changetype: modify\\n\"\n file << \"replace: #{name}\\n\"\n file << \"#{name}: #{value}\\n\"\n file.close\n # file.path\n Puppet.debug(IO.read file.path)\n\n begin\n ldapmodify(['-Y','EXTERNAL','-H','ldapi:///','-f',file.path])\n rescue Exception => e\n raise Puppet::Error, \"LDIF content:\\n#{IO.read file.path}\\nError message: #{e.message}\"\n end\n ensure\n file.unlink\n end\n @property_hash[:value] = value\n end", "def options=(value)\n @@options.merge!(value)\n end", "def mutate(field, value)\n @opts.merge!(field => value) unless value.nil?\n self\n end", "def value=(new_value)\n if @value.nil?\n @value = new_value\n else\n api.put_config_vars app.name, key => new_value\n @value = new_value\n end\n end", "def remove_configuration(value)\n @children['configuration'][:value].delete(value)\n end", "def set(setting, value = nil)\n if value\n command \"set #{setting}=#{value}\"\n else\n command \"set #{setting}\"\n end\n self\n end", "def reset_options\n VALID_OPTIONS_KEYS.each do |key|\n send(\"#{key}=\", default_options[key])\n end\n end", "def call(_value)\n fail NotImplementedError,\n \"you must override the `call' method for option #{self.class}\"\n end", "def reset\n VALID_CONFIG_OPTIONS.each { |opt| self.send(\"#{opt}=\", nil) }\n self.logger = nil\n end", "def reset\n @options = Marshal.load(@default)\nend", "def call(_value)\n raise NotImplementedError,\n \"you must override the `call' method for option #{self.class}\"\n end", "def propagate_option(option, value = nil)\n @cl_propagate << option\n @cl_propagate << value unless value.nil?\n end", "def config_set key, value\n n_config = config.dup\n n_config[key]=value\n self.config= n_config\n end", "def config_set key, value\n n_config = config.dup\n n_config[key]=value\n self.config= n_config\n end", "def reset\n VALID_CONFIG_OPTIONS.each { |opt| self.reset_attribute(opt) }\n end", "def reset_conf(&block)\n reset_conf_sub\n yield\n\n # reset again to go back to default setting later. Otherwise,\n # above setting is kept later.\n reset_conf_sub\n end", "def set(instance, value)\n set!(instance, coerce(value))\n end", "def opts_reset!(hash)\n opts.reset!\n opts.configure_from_hash(hash)\n end", "def unshift_option_value argv, initial_option, value_str\n # recurse to handle option through regular code paths\n argv.unshift \"--\" + initial_option\n argv.unshift value_str\n end", "def set_server_option(opt)\n check_connection\n @protocol.set_option_command opt\n self\n end", "def set(value)\n execute_only(:set, value)\n end", "def e_set_setting(key, value)\n set_option(key, value, '_setting_ecommerce')\n end", "def set_value(value)\n @value = value\n end", "def replace_config(file = '', options = { attempt: 0 })\n options[:attempt] = options.key?(:attempt) ? options[:attempt] : 0\n\n # Only save the original file if this is our first attempt\n if File.exist?(@config) && options[:attempt] == 0\n File.rename(@config, @config + '.tmp')\n elsif File.exist?(@config)\n File.delete(@config)\n end\n\n FileUtils.cp(file, @config) if File.exist?(file)\n FileUtils.chmod(0666, @config) if File.exist?(@config)\n\n # Check file contents for the correct app_version, try again if it fails\n if options[:app_version] && options[:attempt] < 5\n unless File.read(@config).include?(options[:app_version])\n options[:attempt] += 1\n replace_config(file, options)\n end\n\n return if options[:attempt] != 0\n end\n\n return if file.empty?\n\n # Check for database options\n if options[:database]\n options[:database].each do |key, value|\n swap(\n @config,\n /'#{key}' => .*?,/,\n \"'#{key}' => '#{value}',\"\n )\n end\n\n options.delete(:database)\n end\n\n options.delete(:app_version)\n options.each do |key, value|\n swap(\n @config,\n /\\$config\\['#{key}'\\]\\s+=\\s+.*?;/,\n \"$config['#{key}'] = '#{value}';\"\n )\n end\n end", "def set(receiver, value)\n unless value.respond_to?(:config)\n value = default.merge(value)\n value = type.init(value)\n end\n \n receiver.send(writer, value)\n end", "def set_spec_option(obj, property, value, modifier = nil)\n unless value.nil?\n # Modifier is a method like :to_s or :to_i\n value = value.to_s if [true, false].include?(value)\n value = value.send(modifier) unless modifier.nil?\n _log.info \"#{property} was set to #{value} (#{value.class})\"\n obj.send(\"#{property}=\", value)\n else\n value = obj.send(property.to_s)\n if value.nil?\n _log.info \"#{property} was NOT set due to nil\"\n else\n _log.info \"#{property} inheriting value from spec: #{value} (#{value.class})\"\n end\n end\n end", "def default=( val )\r\n @opts[:default] = val\r\n end", "def delayed_option(option, value, object)\n @delayed_options << {\n :option => option.to_s, \n :value => value, \n :object => object\n }\n end", "def delayed_option(option, value, object)\n @delayed_options << {\n :option => option.to_s, \n :value => value, \n :object => object\n }\n end", "def package_settings=(opts)\n reinstall(opts)\n end", "def package_settings=(opts)\n reinstall(opts)\n end", "def reset!\n configure do |c|\n DEFAULTS.each { |k, v| c.send(\"#{k}=\", v) }\n end\n end", "def set!(instance, value)\n instance.instance_variable_set(@instance_variable_name, value)\n self\n end", "def config(value,options)\n\n end", "def config(value,options)\n\n end", "def reset\n VALID_CONFIG_KEYS.each do |k, v|\n send(\"#{k}=\", v)\n end\n self.rpc_spec_path = ::ENV.fetch('RPC_SPEC_PATH', DEFAULT_RSPEC_PATH).to_s\n options\n end", "def set_component_settings_value(index, value)\n if @handle.ptr == nil\n raise \"this is disposed\"\n end\n if value.handle.ptr == nil\n raise \"value is disposed\"\n end\n Native.LayoutEditor_set_component_settings_value(@handle.ptr, index, value.handle.ptr)\n value.handle.ptr = nil\n end", "def set(key, *value)\n run { conf.set(key, value, config_params) }\n end", "def set_option_default(option)\n\t\tvalue = nil\n\t\tcase option\n\t\twhen 'badge'\n\t\t\tvalue = 1\n\t\telse\n\t\t\traise \"Option not supported: #{option_name}\"\n\t\tend\n\t\tdebug_log \"Setting default for option: #{option}\"\n\t\tset_option(option, value)\n\tend", "def []=(key_name, value)\n @options[key_name.to_s()] = value\n end", "def delete_option(key, meta_key = \"_default\")\n values = cama_options(meta_key)\n key = key.to_sym\n values.delete(key) if values.has_key?(key)\n set_meta(meta_key, values)\n end", "def optimize=(value)\n set_attr(:optimize, value ? 2 : 1)\n @optimize = value\n end", "def set(value)\n if value\n redis.set key, self.class.cast_to_redis(value, @options)\n else\n redis.del key\n end\n ensure\n notify_changed\n end", "def setConfig(key,value)\n @state.config[key] = value\n end", "def reset(value=0)\n @value = value\n end", "def options=(value)\n @@options = value\n end", "def options=(value)\n @@options = value\n end", "def unregister(option)\n @registry.delete(option)\n @options.delete_if {|key, value| option == value }\n option\n end", "def update!(value:, **)\n @value = value\n self\n end", "def has_option(opt, value)\n options[opt] = value\n end", "def revert_to!(value)\n revert_to(value)\n reset_version if saved = save\n saved\n end", "def swap_rspec_configuration(key, value); end", "def set_value(value)\n send(\"set_#{value[:type]}_value\", value)\n end" ]
[ "0.7694386", "0.6517668", "0.63965523", "0.62105966", "0.6131494", "0.6083835", "0.6018801", "0.6017789", "0.5912808", "0.58869994", "0.58243126", "0.57893103", "0.5787713", "0.5778378", "0.57754105", "0.57529026", "0.57093865", "0.57069963", "0.5667481", "0.5635249", "0.56292075", "0.56266385", "0.55975455", "0.5593249", "0.5562932", "0.55266994", "0.5520575", "0.5513955", "0.5513955", "0.5503364", "0.54803306", "0.5364721", "0.5364565", "0.53505844", "0.53471875", "0.5330946", "0.53104246", "0.52897966", "0.5245254", "0.52200663", "0.5208172", "0.51876116", "0.5180212", "0.5180046", "0.51761943", "0.51723456", "0.51448554", "0.5142738", "0.5139275", "0.51314497", "0.5124234", "0.51171887", "0.50803566", "0.5069077", "0.5056674", "0.50328976", "0.50216186", "0.5018571", "0.50159574", "0.5007967", "0.5005721", "0.5005721", "0.4994769", "0.4992863", "0.49897867", "0.49877095", "0.49876797", "0.4972609", "0.495603", "0.4949729", "0.49487367", "0.494582", "0.49360758", "0.49231184", "0.49228477", "0.492156", "0.492156", "0.49172494", "0.49172494", "0.49117985", "0.49036604", "0.48956546", "0.48956546", "0.48845333", "0.48756996", "0.48723912", "0.486229", "0.4860952", "0.48554552", "0.4854422", "0.48537356", "0.484755", "0.48468098", "0.48467177", "0.48467177", "0.48384586", "0.48346114", "0.48291245", "0.4826783", "0.48175973", "0.48097256" ]
0.0
-1
Reconfigures the provided option, setting its value to `value`.
def call(value) Datadog.logger.debug { "Reconfigured tracer option `#{@setting_key}` with value `#{value}`" } if value.nil? # Restore the local configuration value configuration_object.unset_option( @setting_key, precedence: Core::Configuration::Option::Precedence::REMOTE_CONFIGURATION ) else configuration_object.set_option( @setting_key, value, precedence: Core::Configuration::Option::Precedence::REMOTE_CONFIGURATION ) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def configure_setting(name, value)\n configure do |settings|\n settings.unset!(name)\n settings[name] = parse_setting(settings.setting(name), value)\n end\n end", "def update_option(opt, val)\n @options[opt] = val\n end", "def option(key, value)\n key = Bcpm::Match.engine_options[key.to_s] if key.kind_of? Symbol\n \n if value.nil?\n @options.delete key\n else\n @options[key] = value\n end\n end", "def setUserOptions option, value\n uOptions[option].delete\n uOptions[option] = value\n end", "def []=(config_option, value)\n @configuration[config_option.to_sym] = value\n end", "def set(option, value=self)\n if value == self && option.kind_of?(Hash)\n @app.options.merge!(option)\n else\n @app.options.merge!(option => value)\n end\n end", "def set(option, value=nil)\n if value.nil?\n self.options = option.to_hash\n else\n write_option option, value\n end\n end", "def set_opt(opt, value)\n opt = opt.to_sym\n if @options.key?(opt)\n @options[opt] = value\n @opt_set = true\n else\n msg = \"Illegal option '#{opt}', specify one of: #{@options.keys.join(', ')}\"\n raise ArgumentError.new(msg)\n end\n end", "def option_replace(key, default = nil)\n value = @options[key] || default\n @options.delete(key) if @options.has_key?(key)\n value\n end", "def setOption(key, value)\n self.options[key] = value\n\n return self\n end", "def processor_option(option, value = nil)\n _processor_options[option.to_sym] = value\n end", "def set(option, value)\n define_method(option) { value }\n end", "def vash_munge_value(val); self.class.munge_option_value(val); end", "def set_option(field, value)\n return @opts[field] if value.nil?\n Scope.new(collection, selector, @opts.merge(field => value))\n end", "def with_value(value)\n options[:value] = value\n self\n end", "def set(option, value)\n @context.send \"#{option}=\".to_sym, value\n end", "def set_opt(option, value)\n type = @@option_types.fetch(option) \\\n { raise ArgumentError, \"Unknown option: #{option}\" }\n \n unless type == :string\n if type == :bool\n valptr = FFI::MemoryPointer.new(:int)\n valptr.write_int(value ? 1 : 0)\n else\n valptr = FFI::MemoryPointer.new(type)\n valptr.send :\"write_#{type}\", value\n end\n value = valptr\n end\n \n rc = LibZMQ.zmq_setsockopt @pointer, option, value, value.size\n ZMQ.error_check true if rc==-1\n \n value\n end", "def configure(option)\n config.merge(option)\n end", "def set_option(key, value = nil, meta_key = \"_default\")\n return if key.nil?\n data = cama_options(meta_key)\n data[key] = fix_meta_var(value)\n set_meta(meta_key, data)\n value\n end", "def []=( name, value )\n @options[ name ] = value\n end", "def option key, value\n @options[ key ] = value\n end", "def option(name, value = nil)\n default_options[name] = value\n end", "def internal_set(symbol, value)\n if configurables.key?(symbol)\n configurables[symbol].set(configuration, value)\n elsif config_contexts.key?(symbol)\n config_contexts[symbol].restore(value.to_hash)\n else\n if config_strict_mode == :warn\n Chef::Log.warn(\"Setting unsupported config value #{symbol}.\")\n elsif config_strict_mode\n raise UnknownConfigOptionError, \"Cannot set unsupported config value #{symbol}.\"\n end\n configuration[symbol] = value\n end\n end", "def set! name, value\n fail(\"options already set: #{name.inspect}\") if (\n respond_to?(name) || has_key?(name)\n )\n self[name] = value\n getter_unless_defined name, name\n end", "def set!(value)\n @mutex.synchronize do\n old_value = @value\n @value = value\n @full_condition.signal\n apply_deref_options(old_value)\n end\n end", "def set(opt,val)\n if opt.is_a?(Symbol)\n setopt(sym2curl(opt), val)\n else\n setopt(opt.to_i, val)\n end\n end", "def set(key, value)\n @options[key] = value\n end", "def set(key, value)\n @options[key] = value\n end", "def set(option, value=self, &block)\n if block_given?\n write_option option, block\n elsif value == self\n self.options = option.to_hash\n else\n write_option option, value\n end\n end", "def set option_value\n self.select option_value\n end", "def clear(option)\n @client.call('config.unset', option)\n end", "def set(option, value=(not_set = true), &block)\n raise ArgumentError, 'value not set' if block and !not_set\n\n if not_set\n set_options option\n return self\n end\n\n if respond_to?(\"#{option}=\")\n return __send__(\"#{option}=\", value)\n end\n\n self\n end", "def config=(value); end", "def set_option(key, value)\r\n\t\t\tif value.is_a? Array\r\n\t\t\t\tvalue = value.join \",\"\r\n\t\t\tend\r\n\t\t\tself.options[key] = value\r\n\t\tend", "def set_config(key, value)\n\n # TODO Currently protected and private settings are not\n # excluded from the inheritance chain, so this error would\n # only be raised if someone typoed a key.\n raise \"#{key} is not a registered or inherited configuration option for #{self.class}\" \\\n unless self.class.default_config.keys.include?(key.to_s)\n\n default_value = self.class.default_config[key][1]\n value = default_value if value == :default\n config = configurations.where('key = ?', key.to_s).first\n if config\n if value == default_value # setting back to default\n config.destroy\n else\n config.update_attributes(value: value.to_s) # changing a custom setting\n end\n else\n return true if value == default_value # don't create a record for the default\n configurations.create(key: key.to_s, value: value.to_s)\n end\n end", "def set_opt(opt, default)\n if opt\n opt\n else\n default\n end\n end", "def update_value(new_value)\n if @type != :slider\n value_index = @values.index(new_value)\n new_value = @values[value_index || 0]\n end\n $options.send(setter, new_value)\n end", "def set_option(option, value, handle, type = :easy)\n type = type.to_sym unless type.is_a?(Symbol)\n raise NameError, \"Ethon::Curls::Options unknown type #{type}.\" unless respond_to?(OPTION_STRINGS[type])\n opthash=send(OPTION_STRINGS[type], nil)\n raise Errors::InvalidOption.new(option) unless opthash.include?(option)\n\n case opthash[option][:type]\n when :none\n return if value.nil?\n value=1\n va_type=:long\n when :int\n return if value.nil?\n va_type=:long\n value=value.to_i\n when :bool\n return if value.nil?\n va_type=:long\n value=(value&&value!=0) ? 1 : 0\n when :time\n return if value.nil?\n va_type=:long\n value=value.to_i\n when :enum\n return if value.nil?\n va_type=:long\n value = case value\n when Symbol\n opthash[option][:opts][value]\n when String\n opthash[option][:opts][value.to_sym]\n else\n value\n end.to_i\n when :bitmask\n return if value.nil?\n va_type=:long\n value = case value\n when Symbol\n opthash[option][:opts][value]\n when Array\n value.inject(0) { |res,v| res|opthash[option][:opts][v] }\n else\n value\n end.to_i\n when :string\n va_type=:string\n value=value.to_s unless value.nil?\n when :string_as_pointer\n va_type = :pointer\n s = ''\n s = value.to_s unless value.nil?\n value = FFI::MemoryPointer.new(:char, s.bytesize)\n value.put_bytes(0, s)\n when :string_escape_null\n va_type=:string\n value=Util.escape_zero_byte(value) unless value.nil?\n when :ffipointer\n va_type=:pointer\n raise Errors::InvalidValue.new(option,value) unless value.nil? or value.is_a? FFI::Pointer\n when :curl_slist\n va_type=:pointer\n raise Errors::InvalidValue.new(option,value) unless value.nil? or value.is_a? FFI::Pointer\n when :buffer\n raise NotImplementedError, \"Ethon::Curls::Options option #{option} buffer type not implemented.\"\n when :dontuse_object\n raise NotImplementedError, \"Ethon::Curls::Options option #{option} type not implemented.\"\n when :cbdata\n raise NotImplementedError, \"Ethon::Curls::Options option #{option} callback data type not implemented. Use Ruby closures.\"\n when :callback\n va_type=:callback\n raise Errors::InvalidValue.new(option,value) unless value.nil? or value.is_a? Proc\n when :socket_callback\n va_type=:socket_callback\n raise Errors::InvalidValue.new(option,value) unless value.nil? or value.is_a? Proc\n when :timer_callback\n va_type=:timer_callback\n raise Errors::InvalidValue.new(option,value) unless value.nil? or value.is_a? Proc\n when :debug_callback\n va_type=:debug_callback\n raise Errors::InvalidValue.new(option,value) unless value.nil? or value.is_a? Proc\n when :progress_callback\n va_type=:progress_callback\n raise Errors::InvalidValue.new(option,value) unless value.nil? or value.is_a? Proc\n when :off_t\n return if value.nil?\n va_type=:int64\n value=value.to_i\n end\n\n if va_type==:long or va_type==:int64 then\n bits=FFI.type_size(va_type)*8\n tv=((value<0) ? value.abs-1 : value)\n raise Errors::InvalidValue.new(option,value) unless tv<(1<<bits)\n end\n send(FUNCS[type], handle, opthash[option][:opt], va_type, value)\n end", "def with_override(flag)\n raise ConfigNotApplied if !config\n\n reset if @tracer && !@tracer.in_progress?\n config.override = flag\n self\n end", "def set_option(value)\r\n\t\tif value.is_a? Array\r\n\t\t\tvalue.each do |cur_value|\r\n\t\t\t\to_v = OptionValue.find(cur_value)\r\n\t\t\t\tself.line_item_option_values << LineItemOptionValue.new(:option_value => cur_value, :extra_cost => o_v.extra_cost, :extra_weight => o_v.extra_weight)\r\n\t\t\tend\r\n\t\telse\r\n\t\t\to_v = OptionValue.find(value)\r\n\t\t\tself.line_item_option_values << LineItemOptionValue.new(:option_value => value, :extra_cost => o_v.extra_cost, :extra_weight => o_v.extra_weight)\r\n\t\tend\r\n\tend", "def handle_failed_option param, value\n @options_ok = false\n end", "def set!(path, value)\n setProperty path, value\n save if respond_to? :save # Only Configuration can save\n value\n end", "def explicitly_set_value=(value)\n @explicitly_set_value = value\n end", "def set_option_value\n @option_value = OptionValue.find(params[:id])\n end", "def tcfg_set(key, value)\n tier_code_defaults[key] = value\n tcfg_reset\n value\n end", "def default_option(option, value)\n default_options[option.to_sym] = value\n end", "def []=(key, value)\n @_options_lookup[key] ||= {}\n super\n end", "def value=(value)\n debug \"set value\"\n file = Tempfile.new('openldap_confgi', '/tmp')\n begin\n file << \"dn: cn=config\\n\"\n file << \"changetype: modify\\n\"\n file << \"replace: #{name}\\n\"\n file << \"#{name}: #{value}\\n\"\n file.close\n # file.path\n Puppet.debug(IO.read file.path)\n\n begin\n ldapmodify(['-Y','EXTERNAL','-H','ldapi:///','-f',file.path])\n rescue Exception => e\n raise Puppet::Error, \"LDIF content:\\n#{IO.read file.path}\\nError message: #{e.message}\"\n end\n ensure\n file.unlink\n end\n @property_hash[:value] = value\n end", "def options=(value)\n @@options.merge!(value)\n end", "def mutate(field, value)\n @opts.merge!(field => value) unless value.nil?\n self\n end", "def value=(new_value)\n if @value.nil?\n @value = new_value\n else\n api.put_config_vars app.name, key => new_value\n @value = new_value\n end\n end", "def remove_configuration(value)\n @children['configuration'][:value].delete(value)\n end", "def set(setting, value = nil)\n if value\n command \"set #{setting}=#{value}\"\n else\n command \"set #{setting}\"\n end\n self\n end", "def reset_options\n VALID_OPTIONS_KEYS.each do |key|\n send(\"#{key}=\", default_options[key])\n end\n end", "def call(_value)\n fail NotImplementedError,\n \"you must override the `call' method for option #{self.class}\"\n end", "def reset\n VALID_CONFIG_OPTIONS.each { |opt| self.send(\"#{opt}=\", nil) }\n self.logger = nil\n end", "def reset\n @options = Marshal.load(@default)\nend", "def call(_value)\n raise NotImplementedError,\n \"you must override the `call' method for option #{self.class}\"\n end", "def propagate_option(option, value = nil)\n @cl_propagate << option\n @cl_propagate << value unless value.nil?\n end", "def config_set key, value\n n_config = config.dup\n n_config[key]=value\n self.config= n_config\n end", "def config_set key, value\n n_config = config.dup\n n_config[key]=value\n self.config= n_config\n end", "def reset\n VALID_CONFIG_OPTIONS.each { |opt| self.reset_attribute(opt) }\n end", "def reset_conf(&block)\n reset_conf_sub\n yield\n\n # reset again to go back to default setting later. Otherwise,\n # above setting is kept later.\n reset_conf_sub\n end", "def opts_reset!(hash)\n opts.reset!\n opts.configure_from_hash(hash)\n end", "def set(instance, value)\n set!(instance, coerce(value))\n end", "def unshift_option_value argv, initial_option, value_str\n # recurse to handle option through regular code paths\n argv.unshift \"--\" + initial_option\n argv.unshift value_str\n end", "def set_server_option(opt)\n check_connection\n @protocol.set_option_command opt\n self\n end", "def set(value)\n execute_only(:set, value)\n end", "def e_set_setting(key, value)\n set_option(key, value, '_setting_ecommerce')\n end", "def replace_config(file = '', options = { attempt: 0 })\n options[:attempt] = options.key?(:attempt) ? options[:attempt] : 0\n\n # Only save the original file if this is our first attempt\n if File.exist?(@config) && options[:attempt] == 0\n File.rename(@config, @config + '.tmp')\n elsif File.exist?(@config)\n File.delete(@config)\n end\n\n FileUtils.cp(file, @config) if File.exist?(file)\n FileUtils.chmod(0666, @config) if File.exist?(@config)\n\n # Check file contents for the correct app_version, try again if it fails\n if options[:app_version] && options[:attempt] < 5\n unless File.read(@config).include?(options[:app_version])\n options[:attempt] += 1\n replace_config(file, options)\n end\n\n return if options[:attempt] != 0\n end\n\n return if file.empty?\n\n # Check for database options\n if options[:database]\n options[:database].each do |key, value|\n swap(\n @config,\n /'#{key}' => .*?,/,\n \"'#{key}' => '#{value}',\"\n )\n end\n\n options.delete(:database)\n end\n\n options.delete(:app_version)\n options.each do |key, value|\n swap(\n @config,\n /\\$config\\['#{key}'\\]\\s+=\\s+.*?;/,\n \"$config['#{key}'] = '#{value}';\"\n )\n end\n end", "def set_value(value)\n @value = value\n end", "def set(receiver, value)\n unless value.respond_to?(:config)\n value = default.merge(value)\n value = type.init(value)\n end\n \n receiver.send(writer, value)\n end", "def default=( val )\r\n @opts[:default] = val\r\n end", "def set_spec_option(obj, property, value, modifier = nil)\n unless value.nil?\n # Modifier is a method like :to_s or :to_i\n value = value.to_s if [true, false].include?(value)\n value = value.send(modifier) unless modifier.nil?\n _log.info \"#{property} was set to #{value} (#{value.class})\"\n obj.send(\"#{property}=\", value)\n else\n value = obj.send(property.to_s)\n if value.nil?\n _log.info \"#{property} was NOT set due to nil\"\n else\n _log.info \"#{property} inheriting value from spec: #{value} (#{value.class})\"\n end\n end\n end", "def delayed_option(option, value, object)\n @delayed_options << {\n :option => option.to_s, \n :value => value, \n :object => object\n }\n end", "def delayed_option(option, value, object)\n @delayed_options << {\n :option => option.to_s, \n :value => value, \n :object => object\n }\n end", "def package_settings=(opts)\n reinstall(opts)\n end", "def package_settings=(opts)\n reinstall(opts)\n end", "def reset!\n configure do |c|\n DEFAULTS.each { |k, v| c.send(\"#{k}=\", v) }\n end\n end", "def set!(instance, value)\n instance.instance_variable_set(@instance_variable_name, value)\n self\n end", "def config(value,options)\n\n end", "def config(value,options)\n\n end", "def reset\n VALID_CONFIG_KEYS.each do |k, v|\n send(\"#{k}=\", v)\n end\n self.rpc_spec_path = ::ENV.fetch('RPC_SPEC_PATH', DEFAULT_RSPEC_PATH).to_s\n options\n end", "def set_component_settings_value(index, value)\n if @handle.ptr == nil\n raise \"this is disposed\"\n end\n if value.handle.ptr == nil\n raise \"value is disposed\"\n end\n Native.LayoutEditor_set_component_settings_value(@handle.ptr, index, value.handle.ptr)\n value.handle.ptr = nil\n end", "def set(key, *value)\n run { conf.set(key, value, config_params) }\n end", "def set_option_default(option)\n\t\tvalue = nil\n\t\tcase option\n\t\twhen 'badge'\n\t\t\tvalue = 1\n\t\telse\n\t\t\traise \"Option not supported: #{option_name}\"\n\t\tend\n\t\tdebug_log \"Setting default for option: #{option}\"\n\t\tset_option(option, value)\n\tend", "def []=(key_name, value)\n @options[key_name.to_s()] = value\n end", "def delete_option(key, meta_key = \"_default\")\n values = cama_options(meta_key)\n key = key.to_sym\n values.delete(key) if values.has_key?(key)\n set_meta(meta_key, values)\n end", "def optimize=(value)\n set_attr(:optimize, value ? 2 : 1)\n @optimize = value\n end", "def set(value)\n if value\n redis.set key, self.class.cast_to_redis(value, @options)\n else\n redis.del key\n end\n ensure\n notify_changed\n end", "def reset(value=0)\n @value = value\n end", "def setConfig(key,value)\n @state.config[key] = value\n end", "def options=(value)\n @@options = value\n end", "def options=(value)\n @@options = value\n end", "def unregister(option)\n @registry.delete(option)\n @options.delete_if {|key, value| option == value }\n option\n end", "def update!(value:, **)\n @value = value\n self\n end", "def has_option(opt, value)\n options[opt] = value\n end", "def revert_to!(value)\n revert_to(value)\n reset_version if saved = save\n saved\n end", "def swap_rspec_configuration(key, value); end", "def force_option_config_parse\n return if disabled?\n\n @secondary_key_set = false\n @secondary_key = nil\n @use_current_version_set = false\n @use_current_version = nil\n\n option_configs force: true, raise_bad_configs: true\n end" ]
[ "0.65158695", "0.63972855", "0.62106466", "0.61317176", "0.60825855", "0.6017806", "0.601639", "0.59119356", "0.58890015", "0.58227146", "0.57885504", "0.5786829", "0.5778286", "0.57754695", "0.5751139", "0.5707841", "0.5706225", "0.56685907", "0.5634623", "0.5628221", "0.56256264", "0.55963665", "0.5591613", "0.5561708", "0.5525491", "0.5520993", "0.55127996", "0.55127996", "0.55014414", "0.54779756", "0.5366214", "0.5363448", "0.53491265", "0.53454083", "0.5329685", "0.5311227", "0.52879477", "0.5244461", "0.5221761", "0.5206342", "0.5187492", "0.51799685", "0.5178468", "0.5174911", "0.5170471", "0.5143997", "0.5142825", "0.5138438", "0.51309377", "0.51242703", "0.5115624", "0.5079821", "0.50679064", "0.5058172", "0.5031857", "0.5023057", "0.50208503", "0.50147", "0.5008095", "0.50051236", "0.50051236", "0.49961406", "0.49945205", "0.49899507", "0.49886292", "0.49877176", "0.4972676", "0.4954084", "0.49489433", "0.49466014", "0.49464253", "0.4935168", "0.49231791", "0.4922711", "0.49218273", "0.49218273", "0.4919719", "0.4919719", "0.49137956", "0.49035358", "0.48942643", "0.48942643", "0.48858577", "0.4873196", "0.48709247", "0.48624936", "0.4859926", "0.4856657", "0.48555803", "0.48525983", "0.4847114", "0.4845881", "0.48455885", "0.48455885", "0.4840513", "0.4833469", "0.48283914", "0.482789", "0.4818398", "0.48099983" ]
0.76933825
0
The base where `setting_key` will apply
def configuration_object Datadog.configuration.tracing end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def settings(key)\n self_settings = self.super_settings(key)\n return self_settings if self_settings.value?\n# self.dmptemplate.settings(key)\n self.template.settings(key) unless self.template.nil?\n end", "def build_top_level_setting\n Grape::Util::InheritableSetting.new.tap do |setting|\n # Doesn't try to inherit settings from +Grape::API::Instance+ which also responds to\n # +inheritable_setting+, however, it doesn't contain any user-defined settings.\n # Otherwise, it would lead to an extra instance of +Grape::Util::InheritableSetting+\n # in the chain for every endpoint.\n setting.inherit_from superclass.inheritable_setting if defined?(superclass) && superclass.respond_to?(:inheritable_setting) && superclass != Grape::API::Instance\n end\n end", "def setting_for(key)\n ensure_config_loaded!\n setting_class.find_by_key(key.to_s)\n end", "def setting(key)\n @settings[key]\n end", "def settings( key )\n if @settings[key].is_a? Proc\n @settings[key] = @settings[key].call\n end\n\n @settings[key]\n end", "def inheritable_setting\n @inheritable_setting ||= Grape::Util::InheritableSetting.new.tap { |new_settings| new_settings.inherit_from top_level_setting }\n end", "def config_for_key(key)\n settings.config[key]\n end", "def [](key)\n initialize_cache unless @initialized\n return @settings[key]\n end", "def base\n return @config[\"base\"]\n end", "def settings\n base_configuration.settings + self.class.settings\n end", "def inheritable_settings\n return @inheritable_settings\n end", "def setting(key)\n @setting_cache ||= {}\n return @setting_cache[key] if @setting_cache[key].present?\n\n log \"looking up business setting: <strong>#{key}</strong>\"\n setting = Setting.business(business).key(key).first\n raise \"Unknown Setting key:#{key}\" if setting.nil?\n\n @setting_cache[key] = setting\n setting\n end", "def setting; end", "def base; @options[:base]; end", "def settings\r\n Mutable[self]\r\n end", "def defines_setting?(key)\n @settings.key?(key)\n end", "def settings\n\t\traise NotImplementedError\n\tend", "def settings(key)\n ENV[key.to_s.upcase] || monk_settings(key)\nend", "def project_setting(key)\n data.config[config[:environment]][key]\n end", "def extract_base_config(whole)\n whole = whole.symbolize_keys\n whole.except(:connections, :databases, :db_adapter, :id, :namespace, :state_cache, :state_cache_store, :sticky_slave, :sticky_slaves, :sticky_master, :verbose)\n end", "def initialize_setting\n unless new_record?\n if cached_setting.nil?\n create_setting\n if self.class.respond_to?(:object_caches_suffix)\n clear_cache! caches_suffix_list= [], object_caches_suffix=[\"setting\"]\n end\n end\n parameterize_name = setting_options[:name].downcase.parameterize.underscore\n setting_options[:options].except(:validations).keys.each do |opt_key|\n send(\"#{parameterize_name}_#{opt_key}=\", cached_setting.get_setting_of(opt_key))\n end\n end\n end", "def setting_key\n sql_cmd = <<SQLCMD\nSELECT max(s.created_at), max(s.updated_at), count(*)\nFROM (\n#{setting_key_tables.collect{|t| 'SELECT created_at, updated_at FROM ' + t.to_s.tableize }.join(' UNION ALL ') }\n) s\nSQLCMD\n\n connection.select_one(sql_cmd).inspect\n end", "def value_provider_options\n @value_provider_options ||= if superclass.respond_to?(:value_provider_options)\n my_settings = Settings.new(self)\n my_settings.raw_settings = superclass.value_provider_options.raw_settings.dup\n my_settings\n else\n Settings.new(self)\n end\n end", "def value\n case ALLOWED_SETTINGS[object['key']]\n when :easy\n ::EasySetting.value(object['key'], object['project'].try(:id))\n when :redmine\n if object['key'] == 'date_format'\n ::Setting.date_format.presence || ::I18n.t('date.formats.default')\n else\n ::Setting.send(object['key'])\n end\n when :time_entry\n ::EasyGlobalTimeEntrySetting.value(object['key'], ::User.current.roles)\n else\n raise GraphQL::ExecutionError, \"Unknow setting '#{object['key']}'\"\n end\n end", "def setting(key)\n @hash[key]\n end", "def get_override_settings\n {}\n end", "def method_missing(method, *args, &block)\n settings.public_send(method) || data.public_send(method) || super\n end", "def compute_effective_settings\n execution_context.inject({}) { |m,(level, identifier)|\n level_attrs = @settings_hierarchy[level]\n next if level_attrs.nil?\n identifier_attrs = level_attrs[identifier]\n next if identifier_attrs.nil?\n context_settings = identifier_attrs['settings']\n next if context_settings.nil?\n context_settings.each { |key, val|\n m[key] = val\n }\n m\n }\n end", "def options\n base.merge(routing_key: routing_key)\n end", "def settings=(_arg0); end", "def settings=(_arg0); end", "def get_setting(key)\n setting = nil\n\n @lock.synchronize do\n setting = @settings\n keys = key.to_s.downcase.split(/\\./)\n\n keys.each do |k|\n item = eval(\"setting.#{k}\") if setting.is_a?(OpenStruct)\n return nil unless item\n setting = item\n end\n end\n\n setting\n end", "def setting_name\n return @setting_name\n end", "def value_cache_options\n @value_cache_options ||= if superclass.respond_to?(:value_cache_options)\n my_settings = Settings.new(self)\n my_settings.raw_settings = superclass.value_cache_options.raw_settings.dup\n my_settings\n else\n Settings.new(self)\n end\n end", "def specialist_setting\n\tend", "def [](key)\n ensure_config_loaded!\n if setting = setting_for(key.to_s)\n setting.value\n end\n end", "def set_defaultsettings\n AppSettings.item.to_hash.each do |setting, value|\n s = RailsSettings::Settings.new \n s.var = setting.to_s\n s.value = value[:default]\n s.thing_id = self.id\n s.thing_type = \"Group\" \n s.save\n end\n end", "def settings\n {}\n end", "def settings\n {}\n end", "def find_setting(setting_key:)\n return settings.detect do |setting|\n setting.key.to_sym == setting_key.to_sym\n end\n end", "def setting_extra_methods\n belongs_to :account\n def self.get_all_settings(conditions = {})\n $CURRENT_ACCOUNT = nil\n with_exclusive_scope{find(:all, :conditions => conditions)}\n end\n end", "def top_level_setting\n @top_level_setting ||= build_top_level_setting\n end", "def configuration(key = :default)\n configurations[configuration_key(key)]\n end", "def settings\n {}\n end", "def ensure_setting\n self.setting ||= Setting.build_default(self)\n end", "def [](key)\n key = normalize_key(key)\n\n @settings[key] && @settings[key].value\n end", "def base_package\n base = {\n 'Packaging' => {\n 'Code' => PACKAGING_TYPES[@model.packaging_type]\n },\n 'PackageWeight' => {\n 'UnitOfMeasurement' => {\n 'Code' => WEIGHT_UNITS[@model.weight_units]\n },\n 'Weight' => @model.weight,\n :order! => ['UnitOfMeasurement', 'Weight']\n },\n 'PackageServiceOptions' => {}\n }\n\n if @model.insured_value\n base['PackageServiceOptions']['InsuredValue'] = {\n 'CurrencyCode' => 'USD',\n 'MonetaryValue' => @model.insured_value\n }\n end\n\n if @model.declared_value\n base['PackageServiceOptions']['DeclaredValue'] = {\n 'CurrencyCode' => 'USD',\n 'MonetaryValue' => @model.declared_value\n }\n end\n\n base\n end", "def get_setting_value(key, hash_setting = nil)\n hash_setting ||= get_setting\n \n hash_setting[key] || self.class.default_value(key)\n end", "def mile_setting\n\t\t@setting = Setting.first\n\tend", "def secret_key_base=(_arg0); end", "def secret_key_base=(_arg0); end", "def get_setting(key, default)\r\n setting = Setting.where(key: key).first\r\n setting && !setting.value.blank? ? setting.value : default\r\n end", "def settings; end", "def settings; end", "def get(key)\n settings.find_by_key(key).try(:value)\n end", "def base_key\n\t\tself.split('.')[0]\n\tend", "def get_settings\n settings.get\n end", "def config_source(key)\n return :cli if @original_config.include? key\n return :config if config_file_settings.key? key\n return :cli_default if default_config.include? key\n return :config_default if config_file_defaults.key? key # must come after :config check\n\n nil\n end", "def default_build_settings(key: nil, optional: true)\n options[:scheme] ||= schemes.first if is_workspace\n build_settings(key: key, optional: optional)\n end", "def settings\n @settings ||= {}\n end", "def [](key)\n setting_obj = setting(key)\n setting_obj ? setting_obj.value : nil\n end", "def setting_provided?(key)\n !settings[key].nil?\n end", "def settings\n @settings ||= {}\n end", "def settings\n @settings ||= {}\n end", "def settings\n @settings ||= {}\n end", "def setting(key)\n keys = [key]\n case key\n when String\n keys << key.to_sym\n when Symbol\n keys << key.to_s\n end\n\n # Scan all possible keys to see if the config has a matching value\n keys.inject(nil) do |rv, k|\n v = @config[k]\n break v unless v.nil?\n end\n end", "def setting(key)\n keys = [key]\n case key\n when String\n keys << key.to_sym\n when Symbol\n keys << key.to_s\n end\n\n # Scan all possible keys to see if the config has a matching value\n keys.inject(nil) do |rv, k|\n v = @config[k]\n break v unless v.nil?\n end\n end", "def settings\n # TODO\n {}\n end", "def _setting_object_method(config_key)\n key = config_key.to_s.sub(/_objects$/, '').to_sym\n @setting_objects[key]\n end", "def from_setting_or_image_info(key, val=nil, default=nil)\n @settings[key] = val unless val.nil?\n return @settings[key] if @settings.include?(key)\n return image_info[key] unless image_info.nil?\n return default # otherwise\n end", "def default_settings\n {}\n end", "def replicable_opts(key)\n self.class.replication_options[key]\n end", "def settings\n attributes.fetch(:settings)\n end", "def inherited(base)\n base.instance_variable_set(\"@counter_key\", counter_key)\n base.instance_variable_set(\"@key_template\", key_template)\n super\n end", "def method_missing(method, *args, &blk)\n if settings.respond_to? method, true\n settings.__send__(method, *args, &blk)\n else\n super\n end\n end", "def page_settings(key)\n # We use #fetch instead of #[] so that an exception is raised on\n # non-existing keys.\n # We need `english_bound` for englarged copies because the text box\n # is different between bound and stitched in english.\n # All foreign files are forced to stitched since text boxes between\n # bound and stitched are identical. That way we have a single\n # source of data and no duplication.\n {\n english_bound: {\n paperwidth: '8.5truein',\n paperheight: '11truein',\n inner: '1.304655truein',\n outer: '1.345345truein',\n top: '1.06154truein',\n bottom: '0.66855truein',\n headsep: '0.1106in', # We want this dimension to scale with geometry package \\mag.\n footskip: '0.351in', # We want this dimension to scale with geometry package \\mag.\n },\n english_stitched: {\n paperwidth: '8.5truein',\n paperheight: '11truein',\n inner: '1.304655truein',\n outer: '1.345345truein',\n top: '1.06154truein',\n bottom: '0.66855truein',\n headsep: '0.1106in', # We want this dimension to scale with geometry package \\mag.\n footskip: '0.351in', # We want this dimension to scale with geometry package \\mag.\n },\n foreign_stitched: {\n paperwidth: '8.5truein',\n paperheight: '11truein',\n inner: '1.528125truein',\n outer: '1.555165truein',\n top: '1.04425truein',\n bottom: '0.70715truein',\n headsep: '0.172in', # We want this dimension to scale with geometry package \\mag.\n footskip: '0.25in', # We want this dimension to scale with geometry package \\mag.\n },\n }.fetch(key)\n end", "def setting(name)\n @settings[normalize_key(name)]\n end", "def settings\n self.class.settings\n end", "def base_cache_key\n return @base_cache_key if @base_cache_key\n @base_cache_key = safe_name(@base_name)\n end", "def settings\n end", "def initialize settings\n super\n end", "def override_department_setting_for_cops(base_hash, derived_hash); end", "def set_defaultsettings\r\n AppSettings.item.to_hash.each do |setting, value|\r\n s = RailsSettings::Settings.new \r\n s.var = setting.to_s\r\n s.value = value[:default]\r\n s.thing_id = self.id\r\n s.thing_type = \"Item\" \r\n s.save\r\n end\r\n end", "def set_setting\n @setting = Setting.find_by_key(params[:id])\n end", "def base\n @info[:base]\n end", "def get_site_setting(site, setting = nil)\n if setting && site_settings(site) && site_settings(site)[setting.to_sym]\n site_settings(site)[setting.to_sym]\n else \n nil\n end\n end", "def setting\n return @setting\n end", "def [](k)\n keys = k.to_s.split('/')\n result = read_settings(keys.shift)\n while result && keys.any?\n result = result[keys.shift]\n end\n result\n end", "def default_settings()\n @default_settings ||= {}\n end", "def [](key)\n (@configuration ||= setup)[key]\n end", "def [](key)\n (@configuration ||= setup)[key]\n end", "def get_settings(service, number)\n hash = client.get(Settings.get_path(service, number))\n return nil if hash.nil?\n\n hash['settings'] = Hash[['general.default_host', 'general.default_ttl'].collect { |var| [var, hash.delete(var)] }]\n Settings.new(hash, self)\n end", "def initialize(setting = Setting.find_or_create)\n self.setting = setting\n end", "def config\n Setting[klass_name]\n end", "def parental_control_settings\n return @parental_control_settings\n end", "def user_settings_hash\n fail 'sub class to implement'\n end", "def setting_index\n end", "def method_missing(name)\n @settings[name.to_sym]\n end", "def settings(*keys)\n return @settings.dup if keys.empty?\n entries = @settings.reject {|k, v| !keys.include?(k)}\n keys.size == 1 ? entries.values.first : entries\n end", "def settings\n @settings ||= settings_class&.new(self)\n end", "def base\n @base\n end" ]
[ "0.7133781", "0.648585", "0.6442454", "0.6413651", "0.64020663", "0.63138145", "0.62761515", "0.6249901", "0.61908674", "0.61645323", "0.61010903", "0.6077919", "0.5959357", "0.5933034", "0.5932983", "0.5906075", "0.59060407", "0.5885649", "0.58824235", "0.58414584", "0.57913697", "0.57807153", "0.5766066", "0.5734364", "0.5713671", "0.5710278", "0.57081735", "0.56905127", "0.56864786", "0.56795675", "0.56795675", "0.5671776", "0.5669079", "0.5662761", "0.5649903", "0.5624628", "0.5623817", "0.5623144", "0.5623144", "0.5622019", "0.56147283", "0.56138057", "0.55894095", "0.5580303", "0.5571711", "0.55633986", "0.5550689", "0.5549409", "0.554122", "0.5537527", "0.5537527", "0.553521", "0.5535154", "0.5535154", "0.55295175", "0.55244124", "0.55193454", "0.5513198", "0.55086994", "0.54977435", "0.5496406", "0.54954463", "0.54904103", "0.5489148", "0.5489148", "0.5483637", "0.5483637", "0.5474973", "0.5473393", "0.54694283", "0.5466053", "0.54599804", "0.54513675", "0.54477334", "0.54464227", "0.54434705", "0.5433933", "0.5432167", "0.54277307", "0.54268473", "0.54268366", "0.54226357", "0.5419668", "0.5419648", "0.5418517", "0.5411497", "0.5409237", "0.5408511", "0.53983086", "0.5395408", "0.5395408", "0.5393119", "0.5389696", "0.5389641", "0.53869665", "0.5376111", "0.5368217", "0.5356426", "0.53539836", "0.5348838", "0.5347826" ]
0.0
-1
call this method if you want to log someone in
def set_current_user(user) sha1 = Digest::SHA1.hexdigest(user.id.to_s + Time.now.to_i.to_s) cookies[:remember_token] = { :value => sha1, :expires => 3.years.from_now } user.remember_token = sha1 user.save @current_user = user end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def log_in\n end", "def logging_in\n \t\t\n \tend", "def logged_in\r\n end", "def logging_in\n end", "def login\n end", "def login\n make_login_call\n end", "def login\n end", "def login\n end", "def login\n end", "def login\n end", "def login\n end", "def login\n end", "def login\n end", "def login\n end", "def login\n end", "def login; end", "def login\n\n end", "def login\n\n end", "def login\n self.login\n end", "def logged_in_user\n unless logged_in?\n puts \"not logged in\"\n end\n end", "def login\n\tend", "def sign_in(user)\n login_as user\n end", "def logged_in_account\n unless logged_in?\n redirect_to login_path\n end\n \tend", "def signin\n\t\t\t# Author\n\t\t\tauthorize! :login, nil\n\t\tend", "def autenticathe_login!\n unless someone_is_logged_in?\n store_location\n flash[:danger] = \"Por favor, Inicie sesion.\"\n redirect_to welcome_path\n end\n end", "def logging_in\n current_user.absorb_from(guest_user)\n end", "def user_login(user)\n click_log_in\n fill_login_credentials(user)\n end", "def logged_in_account\n unless logged_in?\n redirect_to login_path\n end\n end", "def login\n\t\tif @current_user != nil\n\t\t\tredirect_to user_path(@current_user.id)\n\t\tend\n\tend", "def log_in\n @user = User.new\n end", "def sign_in\n end", "def run()\n login()\n end", "def login_helper\n username = prompt.ask(\"Enter Username\")\n password = prompt.ask(\"Enter Password\")\n if User.find_by(name: username, password: password)\n self.user = User.find_by(name: username, password: password)\n # no music yet\n puts \"Let's Get Cookin, #{self.user.name.upcase}!!!\"\n sleep(1.5)\n main_menu\n else\n puts \"Incorrect Username or Password\"\n sleep(1.5)\n login_page\n end\n end", "def login(user=:joerg)\r\n login_as(user)\r\n end", "def sign_in\n\tend", "def logged_in_user\n unless logged_in?\n redirect_to login_url, flash: { danger: 'Por favor, faça login' }\n end\n end", "def logging_in \n @user = User.find(current_user.id)\n sign_in @user\n\n redirect_to after_sign_in_path_for(@user)\n end", "def sign_in\n\n end", "def logged_in\n if current_user == nil\n redirect_to new_user_session_path\n end\n end", "def logged_in_user\n unless logged_in?\n flash[:info] = \"Please log in!\"\n redirect_to login_url\n end\n end", "def ensure_logged_in\n login! if @user.nil?\n end", "def try_to_login\n User.login(self.name, self.password)\n end", "def logged_in_user\n unless logged_in?\n redirect_to '/login'\n end\n end", "def signin\n end", "def log_in (user)\n\t\t#Session is a rails method which saves something called as userid in a cookie\n\t\tsession[:user_name]=user.username\n\n\tend", "def log_in(user_id)\n session[:user_id] = user_id\n end", "def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Primero has Log In\"\n redirect_to login_url\n end\n end", "def logged_in_user\n \tunless logged_in?\n \t\tflash[:danger] = \"Please log in.\"\n \t\tredirect_to login_url\n \tend\n end", "def logged_in_user\n unless logged_in?\n redirect_to login_url\n end\n end", "def login_admin_anna\n user = User.find_by(name: \"Anna\")\n log_in(user)\n end", "def authenticate_user\n \tif !logged_in?\n \tredirect_to login_url\n \tend\n end", "def login_user\n puts \"Please enter your name\"\n name = CLI.gets_with_quit\n\n if self.user_exists(name)\n user = self.find_user(name)\n if check_password(user)\n CLI.active_user = user\n # fall through to CLI.start\n else\n CLI.start\n end\n\n else\n puts \"Sorry, User not found!\"\n if CLI.yes_no(\"Sign Up\")\n self.signup_user(name)\n else\n CLI.start\n end\n end\n end", "def log_in_as(user)\n puts 'logging in!!'\n session[:name] = user.name\n end", "def logged_in_user\n unless logged_in?\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end", "def login\n receive_until_token(@login_token)\n enter_login unless @logged_in\n if @password # if password was passed, else try without password\n receive_until_token(@password_token)\n enter_password unless @logged_in\n end\n receive_until_token(@prompt)\n @logger.info(\"logged in\") if @logger\n end", "def logged_in_user\n \t\tunless logged_in?\n \t\t\tflash[:error] = \"You must be logged in\"\n \t\tredirect_to login_path\n \t\tend\n \tend", "def login\n username.set 'tomsmith'\n password.set 'SuperSecretPassword!'\n end", "def require_login\n end", "def log()\n if user_signed_in?\n else\n \tredirect_to \"http://localhost:3000/users/sign_in\"\n end\n end", "def login\n @current_user = nil\n system 'clear'\n puts \"--------LOGIN--------\"\n username = @prompt.ask(\"Username: \", required: true)\n if User.all.map(&:name).include?(username)\n @current_user = User.all.find{|user_instance| user_instance.name == username}\n if password\n main_menu\n end\n else\n if @prompt.yes?(\"There is no user by this name. Would you like to create an account?\")\n create_account\n end\n end\n end", "def login_from_config\n self.current_user = User.find(BETY_USER) if defined? BETY_USER\n end", "def log_in_user\n unless log_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_path\n end\n end", "def log_in?\n if current_user\n redirect_to user_path\n end\n end", "def logged_in_user\n unless logged_in?\n #We store the location where the users want to go\n #and then ask them to log in, once they log in, we will\n #redirect them to that location.\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end", "def logged_in_user\n\t\tunless logged_in?\n\t\t\tstore_location\n\t\t\tflash[:danger] = \"Log in\"\n\t\t\tredirect_to login_url\n\t\tend\n\tend", "def default_login\n login(\"rohitsjce@gmail.com\",\"codetheoryio\")\n end", "def logged_in_user\n unless logged_in?\n store_location\n flash_please_log_in\n redirect_to login_url\n end\n end", "def logged_in_user\n unless logged_in?\n flash[:danger] = \"Please log in.\"\n redirect_to root_path\n end\n end", "def log_in(user)\n session[:user_id] = user.id\n end", "def simple_sign_in(user)\n\t\tself.current_user = user\n\tend", "def log_on_user(user,session,cookies)\n raise NotImplementedError\n end", "def logged_in_user\n if user_signed_in? then\n \n else\n redirect_to root_path\n end \n \n end", "def logged_in\n if current_user == nil\n redirect_to new_user_session_path\n end\n end", "def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"You must be logged in to use this feature. Please login or make an account.\"\n redirect_to login_url\n end\n end", "def logged_in_user\n unless logged_in?\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end", "def logged_in_user\n unless logged_in?\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end", "def logged_in_user\n unless logged_in?\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end", "def logged_in_user\n unless logged_in?\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end", "def logged_in_user\n unless logged_in?\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end", "def logged_in_user\n unless logged_in?\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end", "def logged_in_user\n unless logged_in?\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end", "def logged_in_user\n unless logged_in?\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end", "def logged_in_user\n unless logged_in?\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end", "def logged_in_user\n unless logged_in?\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end", "def logged_in_user\n unless logged_in?\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end", "def logged_in_user\n unless logged_in?\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end", "def logged_in_user\n unless logged_in?\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end", "def logged_in_user\n unless logged_in?\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end", "def logged_in_user\n unless logged_in?\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end", "def logged_in_user\n unless logged_in?\n flash[:danger] = \"Please log in.\"\n redirect_to login_path\n end\n end", "def autologin_the_user\n #unless logged_in?\n # FrontendUserSession.create(params[:frontend_user_session])\n #end\n end", "def logged_in_user\n unless logged_in?\n # store current location to automatically redirect user after login\n store_location\n # show a flash message on the page\n flash[:danger] = \"Per favore effettua il login\"\n # redirect user to login page\n redirect_to login_url\n end\n end", "def logged_in_user\n unless logged_in?\n \n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end", "def logged_in_user\n \n unless logged_in?\n\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end", "def logged_in_user\n unless logged_in?\n store_location\n flash.now[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end", "def login\n capture_session(self.class.post( \"/api/login\", {:body => {:user => @user, :passwd => @password, :api_type => 'json'}, :debug_output => @debug} ) )\n logged_in?\n end", "def log_in(user)\n email = $credentials[user]['email']\n password = $credentials[user]['password']\n case user\n when 'User A'\n transporter.go_to_url(USER_A_HOST)\n set_field('identifier', email)\n click_btn('Next')\n set_field('password', password)\n click_btn('Next')\n when 'User B'\n transporter.go_to_url(USER_B_HOST)\n end\n end", "def logged_in_user\n unless logged_in?\n redirect_to login_url, flash: { danger: \"Please log in.\" }\n end\n end", "def author_login\r\n user.login if user\r\n end", "def logged_in_user\n unless logged_in?\n flash[:danger] = \"Please log in\"\n redirect_to login_url\n end\n end", "def logged_in_user\n\t\tunless logged_in?\n\t\tstore_location\n\t\tflash[ :danger] = \"Please log in\"\n\t\tredirect_to login_url\n\tend\n\tend" ]
[ "0.8026422", "0.7781602", "0.7730076", "0.7654372", "0.7555326", "0.7553889", "0.747378", "0.747378", "0.747378", "0.747378", "0.747378", "0.747378", "0.747378", "0.747378", "0.747378", "0.74429035", "0.7375008", "0.7375008", "0.7322554", "0.73092467", "0.73064697", "0.7276077", "0.7268567", "0.7264648", "0.72283375", "0.72171164", "0.7182189", "0.71730703", "0.7169455", "0.7161981", "0.71440923", "0.71313673", "0.71105987", "0.7097884", "0.708733", "0.7026137", "0.7020608", "0.70202446", "0.7017243", "0.7006707", "0.7004422", "0.7002229", "0.70005196", "0.69881564", "0.69850713", "0.6984758", "0.6976971", "0.6973488", "0.6969716", "0.6964465", "0.6961498", "0.6959543", "0.6958908", "0.6958903", "0.6956035", "0.6954325", "0.69530606", "0.6952122", "0.69480085", "0.693333", "0.69331837", "0.69194514", "0.6919242", "0.6915306", "0.69140464", "0.69129866", "0.69089025", "0.69083464", "0.69069254", "0.68883157", "0.6887073", "0.6886887", "0.6883943", "0.68766975", "0.68729615", "0.68729615", "0.68729615", "0.68729615", "0.68729615", "0.68729615", "0.68729615", "0.68729615", "0.68729615", "0.68729615", "0.68729615", "0.68729615", "0.68729615", "0.68729615", "0.68729615", "0.68699014", "0.6865958", "0.6864984", "0.68645895", "0.68517035", "0.68496305", "0.6849348", "0.6847284", "0.6842922", "0.684262", "0.6841587", "0.6839487" ]
0.0
-1
call this if you want to log someone out
def unset_current_user unless current_user.nil? current_user.remember_token = nil current_user.save end cookies[:remember_token] = nil end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def log_out\n\t\tforget(current_user) #call user.forget\n\t\tsession.delete(:user_id)\n\t\t@current_user = nil\n\tend", "def log_out\n\t\t# current_user.delete_auth_token # won't work with curl, but html is good\n\t\tsession.delete(:user_id)\n\t\t@current_user = nil\n\tend", "def log_out\n forget(current_user)\n\t\tsession.delete(:user_id)\n\t\t@current_user = nil\n\tend", "def log_out\n reset_session\n @current_user = nil\n end", "def log_out\n\t \tsession.delete(:user_id)\n\t \t@current_user =nil\n\t end", "def log_out\n\t\tsession.delete(:user_id)\n\t\t@current_user = nil\n\tend", "def log_out\n\t\tsession.delete(:user_id)\n\t\t@current_user = nil\n\tend", "def log_out\n\t\tsession.delete(:user_id)\n\t\t@current_user = nil\n\tend", "def log_out\n\t\tsession.delete(:user_id)\n\t\t@current_user = nil\n\tend", "def log_out\n\t\tsession.delete(:user_id)\n\t\t@current_user = nil\n\tend", "def log_out\n\t\tforget(current_user)\n\t\tsession.delete(:user_id)\n\t\t@current_user = nil\n\tend", "def log_out\n\t\tforget(current_user)\n\t\tsession.delete(:user_id)\n\t\t@current_user = nil\n\tend", "def log_out\n\t\tforget(current_user)\n\t\tsession.delete(:user_id)\n\t\t@current_user = nil\n\tend", "def log_out\n\t\tforget(current_user)\n\t\tsession.delete(:user_id)\n\t\t@current_user = nil\n\tend", "def log_out\n\t\tforget(current_user)\n\t\tsession.delete(:user_id)\n\t\t@current_user = nil\n\tend", "def log_out\n forget current_user\n reset_session\n @current_user = nil\n end", "def log_out\n if !current_user.nil?\n forget(current_user)\n\n session.delete(:user_id)\n session.delete(:user_type)\n @current_user = nil\n end\n end", "def logged_out\n end", "def logged_out\n end", "def logged_out\n end", "def log_out\n forget(current_user)\n reset_session\n @current_user = nil\n end", "def log_out\n \tsession.delete(:user_id)\n \t@current_user = nil\n end", "def log_out\n forget(current_user)\n session.delete(:user_id)\n session.delete(:user_type_string)\n @current_user = nil\n end", "def log_out\n\t\tsession.delete(:user_id)\n\t\t@current_user= nil\n\tend", "def log_out\n\t\tsession.delete(:authorization)\n\tend", "def log_out\n forget(current_user)\n session.delete(:user_id)\n @current_user = nil\n flash[:danger] = 'Logoff realizado!'\n end", "def log_out\n session.delete(:user_id)\n session.delete(:type)\n @current_user = nil\n end", "def log_out\n forget current_user\n session.delete :user_id\n @current_user = nil\n end", "def log_out\n session.delete(:user_credentials)\n @current_user = nil\n end", "def log_out\n\tforget(current_user)\n\tsession.delete(:user_id)\n\t@current_user = nil\nend", "def log_out\n session.delete(:user_id)\n session.delete(:user_type)\n session.delete(:user_email)\n @current_user = nil\n end", "def log_out\n\t\tsession[:user_id] = nil\n\tend", "def log_out\r\n forget(current_user)\r\n session.delete(:user_id)\r\n @current_user = nil\r\n end", "def log_out\n session.delete(:uid)\n @current_user = nil\n end", "def log_out\n\t\tforget(current_user)\n\t\tsession.delete(:user_id)\n\t\t@current_user = nil\n\t\t# Setting @current_user to nil would only matter if @current_user were created before the destroy action (which it isn’t) and if we didn’t issue an immediate redirect (which we do). This is an unlikely combination of events, and with the application as presently constructed it isn’t necessary, but because it’s security-related I include it for completeness\n\tend", "def log_out\n session.delete(:email)\n @current_user = nil\n end", "def log_out\n forget(current_user)\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n forget(current_user)\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n session.delete(:user_id)\n session.delete(:user_name)\n session.delete(:user_email)\n @current_user = nil\n end", "def log_out\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n forget(current_user)\n\t\tsession.delete(:user_id)\n\t\t@current_user = nil\n\tend", "def log_out\n\t\tsuper\n\t\t@current_user = nil\n\tend", "def log_out \n session.clear\n @current_user = nil\n end", "def log_out\n session.delete(:user_id)\n forget(@current_user)\n @current_user=nil\n end", "def log_out\n session.delete(:user_id)\n @current_user = nil \n end", "def log_out\n session.delete(:user_id)\n @current_user = nil\n\n end", "def log_out\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n forget(current_user)\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n forget(current_user)\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n forget(current_user)\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n forget(current_user)\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n forget(current_user)\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n forget(current_user)\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n forget(current_user)\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n forget(current_user)\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n forget(current_user)\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n forget(current_user)\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n forget(current_user)\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n forget(current_user)\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n forget(current_user)\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n forget(current_user)\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n forget(current_user)\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n forget(current_user)\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n forget(current_user)\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n forget(current_user)\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n forget(current_user)\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n forget(current_user)\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n forget(current_user)\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n forget(current_user)\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n forget(current_user)\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n forget(current_user)\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n forget(current_user)\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n forget(current_user)\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n\t\tsession.delete(:id)\n\t\t@current_user = nil\n\t\tadmin_session(false)\n\tend" ]
[ "0.82659775", "0.8235964", "0.8176305", "0.81750834", "0.8143294", "0.8123878", "0.8123878", "0.8123878", "0.8123878", "0.8123437", "0.8113428", "0.8113428", "0.8113428", "0.8113428", "0.8113428", "0.811233", "0.81044745", "0.80966556", "0.80966556", "0.80966556", "0.80868566", "0.8077156", "0.80455387", "0.8038367", "0.8023326", "0.80231255", "0.8018841", "0.8015307", "0.80136746", "0.8004867", "0.7999158", "0.7998082", "0.79942733", "0.7994041", "0.79855657", "0.7984182", "0.7982299", "0.7981752", "0.79808664", "0.7969082", "0.7969082", "0.7969082", "0.7969082", "0.7969082", "0.796797", "0.79628444", "0.79600465", "0.7952402", "0.7952209", "0.7944737", "0.7944238", "0.79426503", "0.79426503", "0.79426503", "0.79426503", "0.79426503", "0.79426503", "0.79426503", "0.79426503", "0.79426503", "0.79426503", "0.79426503", "0.79426503", "0.79426503", "0.79426503", "0.79426503", "0.79426503", "0.79426503", "0.79426503", "0.79426503", "0.79426503", "0.79426503", "0.79426503", "0.79426503", "0.79217017", "0.79217017", "0.79217017", "0.79217017", "0.79217017", "0.79217017", "0.79217017", "0.79217017", "0.79217017", "0.79217017", "0.79217017", "0.79217017", "0.79217017", "0.79217017", "0.79217017", "0.79217017", "0.79217017", "0.79217017", "0.79217017", "0.79217017", "0.79217017", "0.79217017", "0.79217017", "0.79217017", "0.79217017", "0.79205745", "0.79201937" ]
0.0
-1
getter that will increment the next_bib value in the database and return the result
def next_bib self[:next_bib] = self[:next_bib] + 1 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def next_bib\n self[:next_bib] = self.inc(next_bib: 1)[:next_bib]\n\tend", "def next_id\n self.latest_id += 1\n end", "def next\n\t\tself + 1\n\tend", "def next_id\n (@curr_id +=1).to_s\n end", "def increment\n curr_value = counter\n self.counter = curr_value + 1\n save\n curr_value\n end", "def next_year\n AcademicYear.find_by(year: self.year + 1)\n end", "def next_revision_number\n # Need to retrieve existing revision numbers to sort them as integers\n sql = \"SELECT revision FROM #{Changeset.table_name} \" \\\n \"WHERE repository_id = #{id} AND revision NOT LIKE 'tmp%'\"\n @current_revision_number ||= (self.class.connection.select_values(sql).collect(&:to_i).max || 0)\n @current_revision_number += 1\n end", "def get_next_number\n if project && number.blank?\n last_invoice_number = Invoice.where(:project_id => project.id).max(:number)\n self.number = last_invoice_number ? ((last_invoice_number + 1).to_i) : 1\n end\n end", "def inc_seq_no!()\n @seq_no += 1\n return(nil)\n end", "def incr\n add(1)\n end", "def next\n return Question.find_by(id: self.id + 1)\n end", "def get_next_membership_number\n self.class.connection.execute(\"SELECT nextval('membership_number_seq')\").getvalue(0, 0).to_s\n end", "def next_version\n (new_record? ? 0 : versions.calculate(:maximum, version_column).to_i) + 1\n end", "def next_auto_ref\n count = -1\n User.transaction do\n self.lock!\n count = self.image_ref_count + 1\n # for some reason update_attributes doesn't appear to work here\n self.image_ref_count = count\n self.save!\n end\n count\n end", "def get_next\n r = nil\n iterator_lock do\n if @iterator <= @last_id\n r = get(@iterator)\n @iterator += 1\n @iterator_file.write(\"#{@iterator.to_s(36)}\\n\")\n r\n else\n nil\n end\n end\n end", "def next_id\n self[:next_id]\n end", "def next\n next? ? @current + 1 : nil\n end", "def increment\n self.visits = self.visits.to_i.next\n self.save\n end", "def next_id\n @imutex.synchronize do\n @mid += 1\n end\n end", "def getNextSequence(table,db)\n\t\tif db[table].count == 0\n\t\t\treturn 1\n\t\telse\n\t\t\tdb[table].find().sort(_id: -1).limit(1).each do |document|\n\t\t\t\treturn document[:_id]+1\n\t\t\tend\n\t\tend\n\tend", "def increment\n self.class.increment(self)\n end", "def next_journal_id\r\n id = journal_ids.max { |p,q| p <=> q }\r\n id.nil? ? 1 : id + 1\r\n end", "def increment_public_id\n if self.public_id.blank?\n self.public_id = Compound.exists? ? Compound.order(:public_id).last.public_id.next : 'RDDB00001'\n end\n end", "def next_available_number\n request :get_next_available_number\n end", "def next_available_number\n request :get_next_available_number\n end", "def next_sequence_number!\n sequence_number && @sequence_number += 1\n end", "def next_revision\n self.class.find(:first, :conditions => {:revisable_original_id => revisable_original_id, :revisable_number => revisable_number + 1})\n end", "def next\n versionable.versions.next_version( self.number )\n end", "def next_page_number\n self.pages.count + 1\n end", "def next_uid\n LdapUser.all(limit: 1, sort_by: :uidnumber, order: :desc).first[:uidnumber]+1\n end", "def next_page\n if next_page?\n @query[:startPage] += 1\n fetch\n end\n end", "def next_id\n @id ||= 0\n @id += 1\n end", "def next_note\n Note.new(self).succ.to_s\n end", "def increment_and_save!\n update_and_save { self.last_value = (last_value || 0) + 1 }\n end", "def nextVersion\n newRevision(@year, @month, @revCount.nil? ? 1 : @revCount + 1)\n end", "def inc_books\n\t\t@books += 1\n\tend", "def next_id\n next_chapter = Chapter.where(\"book_id=? and section_id=? and sequence>=? and id<>?\",self.book_id,self.section_id,self.sequence,self.id).order(\"sequence asc\").limit(1)\n if next_chapter.count==0\n next_chapter = Chapter.where(\"book_id=? and section_id>? \",self.book_id,self.section_id).order(\"sequence asc\").limit(1)\n end\n \n if next_chapter.count==1\n next_chapter.first.id\n else\n 0\n end\n \n end", "def next\n @next ||= Changeset.where([\"id > ? AND repository_id = ?\", id, repository_id]).order('id ASC').first\n end", "def next\n return @page + 1\n end", "def next_available_number\n session.request Debtor.soap_action(:get_next_available_number)\n end", "def next_revision\n self.class.find_by(\n revisable_original_id: revisable_original_id,\n revisable_number: revisable_number + 1\n )\n end", "def read_next_id\n id = nil\n list = current_list\n\n if @co_index <= list.size\n id = list[@co_index - 1][:id]\n end\n\n @co_index += 1\n\n id\n end", "def increment\n Dictionary.db.zincrby @key, 1, @value\n end", "def next_number\n Sequence.next_val\n end", "def next_number(number)\n return number += 1\nend", "def next_doi!\n with_lock do\n next_number = last_doi_issued.succ\n next_doi = \"#{doi_publisher_prefix}/#{doi_journal_prefix}.#{next_number}\"\n if self.class.valid_doi?(next_doi)\n update_column :last_doi_issued, next_number\n return next_doi\n else\n raise InvalidDoiError, \"Attempted to generate the next DOI, but it was in an invalid DOI format: #{next_doi}\"\n end\n end\n end", "def next\n @next ||= WikiContent::Version.\n reorder('version ASC').\n includes(:author).\n where(\"wiki_content_id = ? AND version > ?\", wiki_content_id, version).first\n end", "def next_id\n (all.map(&:id).max || 0) + 1\n end", "def set_next_seqno\n a = self.pcp_subject.pcp_items\n m = a.maximum( :seqno ) || 0\n n = a.count\n self.seqno = ( n > m ? n : m ) + 1\n end", "def next_txn_num\n @txn_num += 1\n end", "def next_number\n counter.call(files.last_number).to_s\n end", "def next_sequence_id\n last_sequence_id + 1\n end", "def increment_downloads\n self.downloads = self.downloads+1\n self.save\n end", "def increment\n @value += 1\n end", "def __to_inc__\n self\n end", "def next\n \t\tNote.where([\"id > ?\", self.id]).first\n\tend", "def next_sequence_value(sequence_name)\n @connection.query(\"SELECT NEXT VALUE FOR #{sequence_name} FROM RDB$DATABASE\")[0][0]\n end", "def next_number(number)\n number.to_i\n return number+=1\nend", "def next_version_number\n # This returns a PGresult object\n # [http://rubydoc.info/github/ged/ruby-pg/master/PGresult]\n result = Match.connection.execute(\"SELECT nextval('play_version_seq')\")\n result[0]['nextval']\n end", "def get_next_version(object_doc, collection_name)\n logger.debug \"Get next version number for document in collection (#{collection_name}) with uuid (#{object_doc['@uuid']})\"\n object_array =collection_by_name(collection_name).find(\"@uuid\" => object_doc[\"@uuid\"]).sort(\"@version\",-1).to_a\n if (object_array.count < 1)\n version = 0\n else\n version = object_array[0][\"@version\"]\n end\n version += 1\n version\n end", "def get_next_patid\n\t\tStudySubject.maximum(:patid).to_i + 1\n#\n#\tWhat happens if/when this goes over 4 digits? \n#\tThe database field is only 4 chars.\n#\n\tend", "def next_number\n self.to_a.size + 1\n end", "def next_branch_tag\n @last_branch_tag.succ!\n end", "def next_number(num)\n return num += 1\nend", "def next_page\n @current_page + 1 if has_next_page?\n end", "def next\n next_qtr_code = quarter_code_id == 4 ? 1 : quarter_code_id + 1\n next_year = quarter_code_id == 4 ? year + 1 : year\n Quarter.find_easily(next_qtr_code, next_year)\n end", "def succ\n return self + 1\n end", "def increment \n\t\t@counter = @counter + 1\n\tend", "def next_row\n @current_row += 1\n end", "def next_page\n page + 1 if pages.include?(page + 1)\n end", "def next\n last? ? nil : locate + 1\n end", "def next_match_number\n # This returns a PGresult object\n # [http://rubydoc.info/github/ged/ruby-pg/master/PGresult]\n result = Match.connection.execute(\"SELECT nextval('match_number_seq')\")\n result[0]['nextval']\n end", "def get_next_ordinal\n # largest_ordinal = 0\n # self.lesson_modules.each do | lesson_module | \n # largest_ordinal = lesson_module.lesson_ordinal if lesson_module.lesson_ordinal > largest_ordinal\n # end\n # return largest_ordinal + 1\n\n # Alternative\n return self.lesson_modules.max_by(&:lesson_ordinal).lesson_ordinal + 1\n end", "def next_id\n next_id = \"sdc:\" + (current_id.to_i + 1).to_s\n next_id\n end", "def next_order_number\n return 0 unless highest_order_number\n highest_order_number + 1\n end", "def increment\n @counter = @counter + 1\n end", "def next_id\n COUNTER_LOCK.synchronize do\n @@id_counter += 1\n end\n end", "def next_release\n return @next_release if @next_release\n list = `git branch -a | grep origin\\/RB-`\n list_numbers = []\n list.each do |item|\n item =~ /RB-([0-9].*)/\n list_numbers << $1.to_i\n end\n @next_release = list_numbers.sort.last.to_i + 1\nend", "def next\n @count += 1\n self\n end", "def next_revision(revision)\n revision.to_i + 1\n end", "def get_next_id\n id = 0\n contacts = read_contacts\n contacts.each do |contact|\n if id < contact[:id]\n id = contact[:id]\n end\n end\n id + 1\nend", "def next_file_number\r\n most_recent_file_number + 1\r\n end", "def test_next\n\t\tassert_equal(6, @freeid.next, \"Extras not working\")\n\t\tassert_equal(1, @freeid.next, \"Last not working\")\n\t\tassert_equal(2, @freeid.next, \"Last not incrementing\")\n\tend", "def next\n update_current(list_index_of(@current))\n end", "def next_page\n return if page >= total_pages\n page + 1\n end", "def increment\n topic.increment(1)\n end", "def increment_order!\n @current += 1\n end", "def next\n \tself.class.where(\"id > ?\", id).first\n \tend", "def next!\r\n @cur = @cache[@idx+=1]\r\n end", "def set_key\n last_key = Issue.find_by_sql('select max(issueId) as maxid from issue')[0].maxid\n self.issueId = last_key.to_i + 1\n end", "def next\n @pointer += 1\n end", "def get_next_url\n @index = @index + 1\n link = @url.to_s + \"?PageNumber=\"\n link = link + @index.to_s\n \n return link\nend", "def get_next_url\n @index = @index + 1\n link = @url.to_s + \"?PageNumber=\"\n link = link + @index.to_s\n \n return link\nend", "def next\n\t\t# Use up all of the extras\n\t\treturn @extras.pop if !@extras.empty?\n\t\t# Then track the last freeid used (which should always be the max)\n\t\treturn (@last+=1)-1\n\tend", "def next_page\n if pages.any? && pages_count > pages.last\n pages.last + 1\n end\n end", "def get_next_url\n\n @index = @index + 1\n\n link = @url.to_s + \"?PageNumber=\"\n\n link = link + @index.to_s\n\n return link\n\nend", "def get_next_url\n\n @index = @index + 1\n\n link = @url.to_s + \"?PageNumber=\"\n\n link = link + @index.to_s\n\n return link\n\nend", "def next_number(number)\n return number +1\nend", "def next_sequence_number\n last_sequence_number ? last_sequence_number.next : 0\n end", "def next\n\t\tself.class.where(\"id > ?\", id).first\n\tend" ]
[ "0.848909", "0.66430503", "0.64042443", "0.63620085", "0.6321063", "0.6306583", "0.6282942", "0.6275506", "0.62644005", "0.624657", "0.6228603", "0.61961347", "0.61890036", "0.6177413", "0.61709696", "0.6167986", "0.6123598", "0.61110866", "0.61020774", "0.6096994", "0.6091907", "0.608716", "0.6059612", "0.60501474", "0.60501474", "0.60468435", "0.603374", "0.6024559", "0.6022038", "0.5995612", "0.59926057", "0.5990113", "0.5988278", "0.5984626", "0.5971823", "0.59363395", "0.59312195", "0.5925816", "0.5922071", "0.5908944", "0.59063303", "0.5884114", "0.58825344", "0.587755", "0.5874405", "0.5864802", "0.5852915", "0.58500975", "0.5844921", "0.5843492", "0.58367586", "0.5835953", "0.5830422", "0.58265114", "0.5821683", "0.58016634", "0.5801103", "0.5798986", "0.5791765", "0.5784802", "0.57814455", "0.5779996", "0.5773024", "0.5769556", "0.5763825", "0.5763377", "0.5751603", "0.57498795", "0.5748503", "0.5728127", "0.5725837", "0.5716052", "0.5710207", "0.5708527", "0.5702801", "0.5701339", "0.5697553", "0.5690318", "0.56895405", "0.56880987", "0.5686498", "0.56855994", "0.5683843", "0.5677783", "0.56698626", "0.5664176", "0.56630456", "0.56545836", "0.5650032", "0.56447786", "0.5631373", "0.56255025", "0.56255025", "0.5618894", "0.5618648", "0.56139934", "0.56139934", "0.561006", "0.56080437", "0.56053525" ]
0.8294113
1
returns a Placing instance with its name set to the name of the age group the racer will be competing in
def get_group racer if racer && racer.birth_year && racer.gender quotient=(date.year-racer.birth_year)/10 min_age=quotient*10 max_age=((quotient+1)*10)-1 gender=racer.gender name=min_age >= 60 ? "masters #{gender}" : "#{min_age} to #{max_age} (#{gender})" Placing.demongoize(:name=>name) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_group racer\n\t\tif racer && racer.birth_year && racer.gender\n\t\t\tquotient=(date.year-racer.birth_year)/10\n\t\t\tmin_age=quotient*10\n\t\t\tmax_age=((quotient+1)*10)-1\n\t\t\tgender=racer.gender\n\t\t\tname=min_age >= 60 ? \"masters #{gender}\" : \"#{min_age} to #{max_age} (#{gender})\"\n\t\t\tPlacing.demongoize(:name=>name)\n\t\tend\n\tend", "def assign_group\n return unless group.nil?\n\n self.group = Group.find_by(name: 'Pilot')\n end", "def lay_egg\n egg = nil\n if @sex == Female\n @birth_count +=1\n egg = EggObject.new(Position.new([@position.x, @position.y, @position.z]))\n end\n egg\n end", "def placement_group\n @group.placement_group\n end", "def set_placing\n @placing = Placing.find(params[:id])\n end", "def team\n return group\n end", "def innings_name\n \"#{match.matchname}: Batting team: #{self.battingteam}\"\n end", "def age_group\n # NOTE: This method may be called before saving, so database queries are a no-no!\n\n season = self.performance.contest.season\n\n if self.solo? || (self.accompaniment? && !self.performance.category.popular?)\n # Soloists and non-popular accompanists have their own age group\n calculate_age_group(self.participant.birthdate, season)\n elsif self.ensemble?\n # Ensemble players share an age group\n ensemble_appearances = self.performance.appearances.select(&:ensemble?)\n calculate_age_group(ensemble_appearances.map { |a| a.participant.birthdate }, season)\n else\n # Pop accompanists share an age group (excluding the soloist)\n accompanist_appearances = self.performance.appearances.select(&:accompaniment?)\n calculate_age_group(accompanist_appearances.map { |a| a.participant.birthdate }, season)\n end\n end", "def new\n \t@group = Group.new\n end", "def new\n @group = LunchGroup.new\n end", "def get_group(gid)\n\t\t\t@group_name=GROUPS[gid.to_s]\n\t\tend", "def new\n @group = Group.new \n end", "def new\n @group = Group.new\n end", "def new\n @group = Group.new\n end", "def new\n @group = Group.new\n end", "def new\n @group = Group.new\n end", "def new\n @group = Group.new\n end", "def << group\n group.set_fleet @fleet.name\n end", "def new\n @group = Group.new\n end", "def add_age_group( grp )\n # NOTE: Age Group diagnosis is never 'positive'\n add_diagnosis_i( Diagnosis::AGEGRP_NAME, Diagnosis::AGEGRP_SYM, \n false, grp.to_i )\n end", "def group\n @group ||= Group.new @instance, group_id\n end", "def group\n @group.name\n end", "def set_grape\n @grape = Composition.find(params[:id])\n end", "def group; Group.get(self.group_id); end", "def display_name\n override_attr(:name, award_name) + (group == award.group ? '' : \" (#{group})\")\n end", "def new_group(stone,lives)\n group = @garbage_groups.pop\n if group\n return group.recycle!(stone,lives)\n else\n @num_groups += 1\n return Group.new(self,stone,lives,@num_groups)\n end\n end", "def groups\n\nroster = [ \"Caroline Artz\", \"Syema Ailia\", \"Alan Alcesto\", \"Daniel Andersen\", \"James Artz\", \"Darius Atmar\", \"Brian Bensch\", \"Nicola Beuscher\", \"Kris Bies\", \"Logan Bresnahan\", \"William Brinkert\", \"Laura C.\", \"Scott Chou\", \"Bernice Anne W Chua\", \"Abraham Clark\", \"Jon Clayton\", \"Kevin Corso\", \"Jacob Crofts\", \"John D.\", \"Katy D.\", \"Emmanuel Kaunitz\", \"Amaar Fazlani\", \"Solomon Fernandez\", \"Edward Gemson\", \"Jamar Gibbs\", \"Chris Gomes\", \"Will Granger\", \"Christopher M. Guard\", \"Adell H.\", \"James Hwang\", \"Matt H.\", \"Michael H.\", \"Peter H.\", \"Ryan Ho\", \"Igor Kazimirov\", \"Walter Kerr\", \"Karla King\", \"Becky Lehmann\", \"Malia Lehrer\", \"Carolina Medellin\", \"Timothy Meixell\", \"Lorena Mesa\", \"Chris Miklius\", \"Joshua Monzon\", \"Shea Munion\", \"Bryan Munroe\", \"Neal Peters\", \"Trevor Newcomb\", \"Aleksandra Nowak\", \"Morgan O.\", \"Fatma Ocal\", \"Van Phan\", \"Luis Fernando Plaz\", \"Nalie Polen\", \"Alicia Quezada\", \"Celeen R.\", \"Jessie Richardson\", \"Gary S.\", \"Iulia S.\", \"Nimi Samocha\", \"Zach Schatz\", \"Schwartz\", \"Pratik Shah\", \"Josh Shin\", \"Shawn Spears\", \"Sasha ilor\", \"Nil Thacker\", \"Nasha Thapliyal\", \"Sabrina Unrein\", \"Brian Wagner\", \"Clinton Weber\", \"Gregory Wehmeier\", \"Michael Whelpley\", \"Alexander Williams\", \"Peter N Wood\", \"Caitlyn Y.\", \"Ryan Zell\",\"random name\"]\n#initial solution\n\n=begin\n group_arrays = []\n i = 0\n while i < roster.length\n group_arrays << roster[i..i+3]\n i += 4\n end\n\n extra = []\n i = 0\n group_arrays.each { |group|\n if group.length < 3\n extra = group #take contents of group and add it to a different group\n if group_arrays[i].length == 5\n i += 1\n end\n group_arrays[i].concat(extra)\n group.pop\n end\n }\n puts group_arrays.to_s\nend\n\n=end\n\n# If I run this program 3 times, it will return the exact same groups\n#The program could be set up to store past groups, but I'd have to make some updates\n#no groups would be impacted by 1 person leaving, once 2 people left I could run the code again though.\n#biggest issue is I can empty the last array, but it doesn't delete the brackets. so that's a thing.\n\n#refactored solution:\n\n group_arrays = []\n while roster.length > 0\n group_arrays << roster.slice!(0..3)\n end\n\n left_overs = group_arrays[-1]\n\n i = 0\n group_arrays.each { |array|\n if left_overs.length < 3 && left_overs.length > 0\n group_arrays[i].push(left_overs[0])\n left_overs.shift\n if group_arrays[i].length == 5\n i += 1\n end\n elsif array.length > 5\n left_overs.push(array[-1])\n array.pop\n end\n }\n puts group_arrays.to_s\nend", "def name\n @named_dog\n end", "def group_creator\n group = Random.new.rand(1..3)\n return group\nend", "def group\n @group\n end", "def group\n Group.get!(gidnumber)\n end", "def create\n #1st you retrieve the group thanks to params[:group_id]\n #2nd you create the trainer wih arguments in params [:gardener]\n @gardener= Gardener.find(params[:gardener_id])\n @living_arrangement = @gardener.build_living_arrangement living_arrangement_params\n if @living_arrangement.save\n redirect_to new_gardener_farming_resource_path(@gardener)\n #render \"living_arrangements/new\", id:@gardener \n else\n render :new\n end\n end", "def age_group(age)\n if age <= 17\n return \"kid\"\n elsif age > 17 && age < 64\n return \"adult\"\n else\n return \"senior\"\n end\nend", "def create\n @group = Group.new(group_params)\n\n #salvo il gruppo nel gamer\n @group.creator=current_gamer\n if @group.region != @group.creator.nation\n flash.now[:danger] = \"different nation selected: #{@group.creator.nation} #{@group.region}\"\n render 'new'\n else\n\n @group.members << current_gamer\n\n respond_to do |format|\n if @group.save\n format.html { redirect_to @group, notice: 'Group was successfully created.' }\n format.json { render :show, status: :created, location: @group }\n else\n format.html { render :new }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end\n end", "def create\n @placing = Placing.new(placing_params)\n\n respond_to do |format|\n if @placing.save\n format.html { redirect_to @placing.edition, notice: 'Placing was successfully created.' }\n format.json { render :show, status: :created, location: @placing }\n else\n format.html { render :new }\n format.json { render json: @placing.errors, status: :unprocessable_entity }\n end\n end\n end", "def get_instance_by_name(group, name)\n get_instances(group).each {|instance|\n return instance if (instance.tags['name_s'] || \"\").casecmp(name) == 0\n return instance if (instance.tags['Name'] || \"\").casecmp(name) == 0\n }\n raise \"unknown instance: #{name} in group #{group} \"\n end", "def name\n \"#{self[:afi]} #{self[:type]} #{self[:grp_name]}\"\n end", "def name\n 'occupant'\n end", "def age_groups\n get_endpoint(Bestsellers::AgeGroup.path).map{|g|\n Bestsellers::AgeGroup.new(g)\n }\n end", "def add_girl(input_name)\n if check_if_exists?(input_name)\n found = @band2.find do |girl|\n girl.stage_name == input_name\n end\n raise ArgumentError, \"You didn't choose from the list\" if found == nil\n append_member(found)\n else\n raise \"You already have a girl of that name\"\n end\n end", "def named_placement_groups\n @named_placement_groups ||= Hash[placement_groups.map { |pg| [pg.group_name, pg] }]\n end", "def legal_age_group_rule\n return @legal_age_group_rule\n end", "def look_up_planet (choice)\n @planets.each do |planet|\n if planet[:name] == choice\n return planet\n end\n end\n end", "def new\n @participant = Participant.new\n @families = (Family.all || []).sort_by{ |f| f.familyname }\n end", "def group_name\n @attributes[:group_name]\n end", "def group_name\n @attributes[:group_name]\n end", "def membergroups_playerslounge_label\n $tracer.trace(__method__)\n return ToolTag.new(div.className(\"/parent-group-title/\").innerText(\"/Player's Lounge/\"), __method__)\n end", "def name\n @this_dogs_name\n end", "def name\n @this_dogs_name\n end", "def name\n @this_dogs_name\n end", "def name\n @this_dogs_name\n end", "def add!(p)\n raise Exception.new(\"Object is not a Population or PopulationGroup\") if !p.is_a?(Population) && !p.is_a?(PopulationGroup)\n population_group_members.find_or_create_by_population_groupable_type_and_population_groupable_id(p.class.to_s, p.id)\n end", "def name\n @this_dogs_name\n end", "def name \n @this_dogs_name\n end", "def place\n Place.new(place_name, organisation_name)\n end", "def display_name\n group_name\n end", "def group_name\n group.name if group\n end", "def name\n @this_dogs_name\n end", "def set_grooming\n @grooming = Grooming.find(params[:id])\n end", "def name\n @this_dog_name\n end", "def breed_group\n return data.breed_groupes\n end", "def parse\n split_name\n Governator::Name.new(original, first, middle, nickname, last, suffix)\n end", "def group_name_from_pid(value)\n begin\n group = Hydramata::Group.load_instance_from_solr(value)\n rescue => e\n logger.debug(\"DEBUG: Helper method group_name_from_pid raised an error when loading #{value}. Error was #{e}\")\n end\n group.nil? ? value : group.title\n end", "def load_group\n @group = Group.find_by_name(params[:id].titleize) or raise ActiveRecord::RecordNotFound\n end", "def create_group_stage_game(game) \n \n if Game.cup_home_away_exist?(self, game[0], game[1]) \n \n standing = Standing.find(:first, :conditions => [\"cup_id = ? and item_id = ? and item_type = ?\", self.id, game[0].id, game[0].class.to_s])\n\n last_game = get_the_last_game \n \n return Game.create!(:name => \"Group #{standing.group_stage_name}\", \n :cup_id => self.id, :home_id => game[0].id ,:away_id => game[1].id, \n :starts_at => last_game['starts_at'], :ends_at => last_game['ends_at'], \n :reminder_at => last_game['reminder_at'], :deadline_at => last_game['deadline_at'], \n :type_name => 'GroupStage', :jornada => last_game['jornada'],\n :points_for_single => POINTS_FOR_SINGLE, :points_for_double => POINTS_FOR_DOUBLE, \n :points_for_winner => POINTS_FOR_WINNER, :points_for_draw => POINTS_FOR_DRAW, \n :points_for_goal_difference => POINTS_FOR_GOAL_DIFFERENCE,\n :points_for_goal_total => POINTS_FOR_GOAL_TOTAL)\n end\n end", "def group(name)\n @_group = name\n end", "def group\n @group\n end", "def create_pop_group( name ) \n return \"Group #{name} already exists.\" if NodeGroup.find_by_name( name )\n \n unless File.exists?( SpkDashboard::DATA_PATH + \"/data_#{name}\" )\n return \"No params file found to create group #{name}. FILE: #{SpkDashboard::DATA_PATH + \"/data_#{name}\"}\"\n end\n \n params = self.read_group_params( name )\n \n nodegroup = NodeGroup.new(\n :name => name,\n :node_group_names => [ \"spk_base\" ],\n :parameter_attributes => params )\n \n if nodegroup.save \n return \"Successfully created group #{name}\"\n else\n return \"Failed to create group #{pop}\"\n end\n \n end", "def populate(occupancy)\n\t\tputs \"Placing #{occupancy} people in the building\"\n\t\tArray.new(occupancy).map{\n\t\t\t|person| Person.new(Faker::Name.first_name, floors.sample, floors.sample, self)\n\t\t}\n\tend", "def group_name\n @group_name ||= self.class.group_name(group)\n end", "def name\n @this_dogs_name\n end", "def name\n return 'AedgSmallToMediumOfficeRoofConstruction'\n end", "def ship_name(group)\n\t\tgroup.ship.name \n\tend", "def group_name\n data[:group_name]\n end", "def index\n @placings = Placing.all\n end", "def bear_name(name)\n return name\n end", "def name\n #IMPLEMENTING INSTANCE VARIABLES using @\n @this_dogs_name\n end", "def create\n @grape = Composition.new(grape_params)\n @grape.grapename = Grape.find( params[ :grapename ] )\n respond_to do |format|\n if @grape.save\n format.html { redirect_to @grape, notice: 'Composition was successfully created.' }\n format.json { render :show, status: :created, location: @grape }\n else\n format.html { render :new }\n format.json { render json: @grape.errors, status: :unprocessable_entity }\n end\n end\n end", "def game(name)\n\t\t\traise ArgumentError, 'BGGPlays::game Argument is not string' unless name.is_a? String \n\t\t\t#validates string\n\t\t\tname.to_s\n\t\t\tselect(:bg_name, name)\n\t\tend", "def set_name\n while !Provider.where(name: self.name).blank? do\n self.name = \"#{self.name}_1\"\n end\n # hagan que busque los que tengan el mismo nombre que se intenta guardar\n # agregue \"_1\" al name si ya hay alguno con el nombre no \n # importa que ya tenga \"_1\" le agregarian otro, ej. \"steren_1_1\"\n # self.name entrega el nombre que esta tratandose \n # de asignar al objeto instanciado\n end", "def set_assign_group_place\n @assign_group_place = AssignGroupPlace.find(params[:id])\n end", "def yourself(stage_name, firstname, surname, quirk, special_talent)\n\n if check_if_exists?(stage_name)\n you = SpiceGirl.new(stage_name, firstname, surname, quirk, special_talent)\n append_member(you)\n else\n raise \"You already have a girl of that name\"\n end\n end", "def pt_memb_name\n {:name=>$game_party.members[@party_index_tb].name}\n end", "def initialize(name,age)\n\t\t@name = name\n\t\t@age = age\n\t\t@pets = {}\t\t\n\tend", "def add_planet_by_name(name)\n planet = get_space_body_by_name(name)[0]\n Planet.new(planet)\n end", "def new\n @substitute = Substitute.new\n # Bug to solve here - the member can visit another club and use that session club_id\n @users = User.find(:all, :conditions => [\"club_id=? and status=?\", session[:club_id], \"granted\"], :include => :membership, :order => \"surname ASC\")\n @team = Team.find_by_id(params[:team_id])\n @title = \"Create a Substitute for \" + @team.description\n @races = Race.find(:all, :conditions => [\"team_id=?\", params[:team_id]], :order => [\"date DESC\"], :include => :event)\n \n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @substitute }\n end\n end", "def create\n @assign_group_place = AssignGroupPlace.new(assign_group_place_params)\n @assign_group_place.save\n end", "def initialize(name, breed, owner_name)\n @name = name # this returns name of the dog\n @breed = breed # returns the breed classification\n @owner = Owner.new(owner_name, self) # returns Owner when #class is called on #owner \n end", "def team\n @team ||= Struct.new(:name, :domain).new(@team_name, @domain)\n end", "def initialize (name)\n @name = name\n @life_points = 10\n end", "def new_place\n @place = Place.new\n @category = get_lookup_values(\"Place_Type\")\n end", "def set_grave\n @grave = Grave.find(params[:id])\n end", "def name\n name = \"Cess Pool\"\n end", "def new\n save_navi_state(['groups_title', 'new_group'])\n @group = Group.new\n end", "def setup_group(new_group)\n # original alignment\n @altered_alignment = false\n # set new own group\n @group = new_group\n # set up enemy groups\n @negative = $game_system.alignments[@group].enemies.clone\n # set up ally groups\n @positive = $game_system.alignments[@group].allies.clone\n # set up always-neutral groups\n @neutral = $game_system.alignments[@group].neutral.clone\n end", "def initialize(name)\n @pets = {fishes: [], cats: [], dogs: []}\n @@owners << self\n @species = \"human\" \n end", "def age_group(family)\n family.map do |family_member, information|\n if information['age'] >= 100\n family[family_member]['age_group'] = 'senior'\n elsif information['age'] <= 100 && information['age'] >= 20\n family[family_member]['age_group'] = 'adult'\n else\n family[family_member]['age_group'] = 'kid'\n end\n end\n\n family\nend", "def get_group\n @group = Group.find(params[:id])\n end", "def name\n\t\tsuper || game.name\n\tend", "def group\n @group ||= producer.groups.first\n end" ]
[ "0.70971876", "0.5949645", "0.59472334", "0.57195187", "0.56466264", "0.5625743", "0.5339288", "0.5335686", "0.5334706", "0.53182876", "0.52509105", "0.5249419", "0.52217895", "0.52217895", "0.52217895", "0.52217895", "0.52217895", "0.5219858", "0.52095926", "0.5207008", "0.51854277", "0.51613563", "0.51451224", "0.5143319", "0.51201475", "0.5120056", "0.51172054", "0.510217", "0.5073553", "0.50443006", "0.50438154", "0.5039855", "0.5039343", "0.5021023", "0.5009875", "0.49960366", "0.4995453", "0.4981214", "0.49791324", "0.49733847", "0.4971654", "0.49575928", "0.4954692", "0.4948242", "0.49436888", "0.49436888", "0.49360162", "0.4932704", "0.4932704", "0.4932704", "0.4932704", "0.4924516", "0.49154073", "0.49095538", "0.4884476", "0.48828554", "0.4875512", "0.4872143", "0.4871113", "0.48679405", "0.4865298", "0.48603562", "0.48600796", "0.48507398", "0.48406985", "0.48398134", "0.4838236", "0.48341992", "0.48326156", "0.48292375", "0.48259082", "0.48191682", "0.48179018", "0.48130122", "0.48054", "0.4802825", "0.47942838", "0.47851613", "0.47808674", "0.4779401", "0.47768807", "0.4774878", "0.47665974", "0.47622848", "0.47585928", "0.4755084", "0.47548935", "0.47533244", "0.4749947", "0.4749313", "0.47469047", "0.47361216", "0.47287866", "0.4728671", "0.4727809", "0.47246143", "0.4721314", "0.47208604", "0.47203454", "0.47187796" ]
0.7204882
0
create a new Entrant for the Race for a supplied Racer
def create_entrant racer # build a new Entrant entrant = Entrant.new { |r| # clone the relevant Race information within Entrant.race r.build_race(self.attributes.symbolize_keys.slice(:_id, :n, :date)) # clone the RaceInfo attributes within Entrant.racer r.build_racer(racer.info.attributes) # determine the group for the racer and assign it to the entrant r.group = get_group(r.racer) } # validate the Entrant if entrant.validate # assign a new unique bib number from the database and save to the database entrant.bib = self.next_bib # save new bib number of race to races collection self.save # save entrant object to results collection entrant.save # clone race events into entrant self.events.each do |event| entrant.results.create(:event=>event) end end # return the Entrant entrant end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_entrant racer\n\t\tentrant = Entrant.new\n\t\tentrant.race = self.attributes.symbolize_keys.slice(:_id, :n, :date)\n\t\tentrant.racer = racer.info.attributes\n\t\tentrant.group = self.get_group(racer)\n\t\tevents.each do |event|\n \t \tif event\n \t\tentrant.send(\"#{event.name}=\", event)\n \t\tend\n \tend\n \tentrant.validate\n\t\tif (entrant.valid?) \n\t\t\tentrant.bib = next_bib\n\t\t\tentrant.save\n\t\tend\n\t\treturn entrant\n\tend", "def create\n @racer = Racer.new(racer_params)\n\t\t@race = Race.find(racer_params[:race_id])\n\t\t@racer.race_id = nil\n respond_to do |format|\n @race.racers << @racer\n if @racer.save\n #format.html { redirect_to @racer, notice: 'Racer was successfully created.' }\n format.html { redirect_to racers_path(:race_id => racer_params[:race_id]), notice: 'Racer was successfully created.' }\n format.json { render :show, status: :created, location: @racer }\n else\n format.html { render :new }\n format.json { render json: @racer.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @election = Election.find(params[:election_id])\n @race = @election.races.build(params[:race])\n\n respond_to do |format|\n if @race.save\n format.html { redirect_to [@election, @race], notice: 'Race was successfully created.' }\n format.json { render json: @race, status: :created, location: [@election, @race] }\n else\n format.html { render action: \"new\" }\n format.json { render json: @race.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @race = Race.new(race_params)\n\n respond_to do |format|\n if @race.save\n format.html { redirect_to @race, notice: 'Race was successfully created.' }\n format.json { render :show, status: :created, location: @race }\n else\n format.html { render :new }\n format.json { render json: @race.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @race = Race.new(race_params)\n\n respond_to do |format|\n if @race.save\n format.html { redirect_to @race, notice: 'Race was successfully created.' }\n format.json { render :show, status: :created, location: @race }\n else\n format.html { render :new }\n format.json { render json: @race.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @race = Race.new(params[:race])\n\n respond_to do |format|\n if @race.save\n flash[:notice] = 'Race was successfully created.'\n format.html { redirect_to(event_path(@race.event)) }\n format.xml { render :xml => @race, :status => :created, :location => @race }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @race.errors, :status => :unprocessable_entity }\n end\n end\n end", "def new\n @renter = Renter.new\n end", "def create\n @entrant = Entrant.new(params[:entrant])\n\n respond_to do |format|\n if @entrant.save\n format.html { redirect_to @entrant, notice: 'Entrant was successfully created.' }\n format.json { render json: @entrant, status: :created, location: @entrant }\n else\n format.html { render action: \"new\" }\n format.json { render json: @entrant.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @renter = Renter.new\n end", "def set_racer\n @racer = Racer.find(params[:id])\n\t\t\t@race = @racer.race_id\n end", "def create\n @raceentry = Raceentry.new(params[:raceentry])\n\n respond_to do |format|\n if @raceentry.save\n format.html { redirect_to @raceentry, notice: 'Raceentry was successfully created.' }\n format.json { render json: @raceentry, status: :created, location: @raceentry }\n else\n format.html { render action: \"new\" }\n format.json { render json: @raceentry.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @engineer = Engineer.new(engineer_params)\n r = Rentee.find(params[:rentee_id])\n @engineer.rentee = r\n if @engineer.save\n end\n\n respond_to do |format|\n if @engineer.save\n format.html { redirect_to [@engineer.rentee, @engineer], notice: 'Engineer was successfully created.' }\n format.json { render :show, status: :created, location: @engineer }\n else\n format.html { render :new }\n format.json { render json: @engineer.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_race\n @race = Race.find(params[:id])\n end", "def set_race\n @race = Race.find(params[:id])\n end", "def set_race\n @race = Race.find(params[:id])\n end", "def set_race\n @race = Race.find(params[:id])\n end", "def set_race\n @race = Race.find(params[:id])\n end", "def initialize(name, race)\n # validate inputs here, ck4\n @name = name\n @race = race\n @body_parts = @race.body_parts.map{ |part| part.clone }\n @attributes = new_attributes # uses @race\n @health = @race.health\n @statuses = [] # none to start\n end", "def create(name, race, cclass, session_key)\n\n\t\t\t\tuser = API::UserMethods::Helpers::Auth::get_logged_in_user(session_key)\n\t\t\t\treturn APIError.new(13, []) if user.nil?\n\t\t\t\treturn APIError.new(11, [name]) if reserved? name\n\t\t\t\treturn APIError.new(2, [user.username, name]) if exists?(user, name)\n\n\t\t\t\tr = Races.get(race)\n\t\t\t\tc = CharClasses.get(cclass)\n\n\t\t\t\tstats = CharStats.create(\n\t\t\t\t\t\t:strength => 1,\n\t\t\t\t\t\t:speed => 1,\n\t\t\t\t\t\t:serenity => 1,\n\t\t\t\t\t\t:stamina => 1,\n\t\t\t\t\t\t:sorcery => 1\n\t\t\t\t)\n\n\t\t\t\tchar = Character.create(\n\t\t\t\t\t\t:name => name,\n\t\t\t\t\t\t:user => user,\n\t\t\t\t\t\t:race => r,\n\t\t\t\t\t\t:cclass => c,\n\t\t\t\t\t\t:stats => stats\n\t\t\t\t)\n\n\t\t\t\tstats.character = char\n\t\t\t\tstats.save\n\n\t\t\t\treturn char\n\n\t\t\tend", "def to_race\n return self\n end", "def set_race\n @race = Race.friendly.find(params[:race_id])\n end", "def _create_resevation(base, subject, owner)\n\t\t\t\t\t\n\t\t\t\t\t# Create reservation\n\t\t\t\t\treservation = RicReservation.reservation_model.new\n\t\t\t\t\treservation.kind = \"event\"\n\t\t\t\t\treservation.event = self\n\t\t\t\t\treservation.date_from = base\n\t\t\t\t\treservation.date_to = base + (self.date_to - self.date_from).to_i.days\n\t\t\t\t\treservation.time_from = self.time_from\n\t\t\t\t\treservation.time_to = self.time_to\n\n\t\t\t\t\t# Bind subject\n\t\t\t\t\tif !subject.nil?\n\t\t\t\t\t\treservation.size = subject.size\n\t\t\t\t\t\treservation.subject = subject\n\t\t\t\t\telse\n\t\t\t\t\t\treservation.size = self.default_reservation_size\n\t\t\t\t\tend\n\n\t\t\t\t\t# Bind owner\n\t\t\t\t\tif !owner.nil?\n\t\t\t\t\t\treservation.owner_name = owner.name if !owner.name.nil?\n\t\t\t\t\t\treservation.owner = owner if owner.is_a?(ActiveRecord::Base) # In case owner is not ActiveRecord, only name can be stored\n\t\t\t\t\tend\n\n\t\t\t\t\treturn reservation\n\t\t\t\tend", "def create_college_enrollment_from(attrs, participant_id)\n log \" -> Creating CollegeEnrollment record\"\n ce = CollegeEnrollment.create(\n :participant_id => participant_id,\n :institution_id => Institution.find_by_opeid(attrs[\"College Code/Branch\"]).try(:id),\n :began_on => Date.parse(attrs[\"Enrollment Begin\"]),\n :ended_on => Date.parse(attrs[\"Enrollment End\"]),\n :enrollment_status => attrs[\"Enrollment Status\"],\n :class_level => attrs[\"Class Level\"],\n :major_1 => attrs[\"Enrollment Major 1\"],\n :major_1_cip => attrs[\"Enrollment CIP 1\"],\n :major_2 => attrs[\"Enrollment Major 2\"],\n :major_2_cip => attrs[\"Enrollment CIP 2\"],\n :source => \"clearinghouse\",\n :clearinghouse_request_id => self.id\n )\n log \" #{ce.inspect}\"\n log \" Errors: #{ce.errors.messages.inspect}\" unless ce.valid?\n ce\n end", "def create\n @arl = Arl.create(arl_params)\n end", "def set_racer\n\t # @racer = Racer.find(params[:id])\n\t end", "def create\n\t \t#byebug\n\t\tif !request.accept || request.accept == \"*/*\"\n\t\t\trender plain: \"#{params[:race][:name]}\", status: :ok\n\t\telse\n\t\t @race = Race.create(race_params)\n\t\t render plain: \"#{@race.name}\", status: :created\n\t\tend\n\t end", "def create\n @cage = Cage.find(params[:cage_id])\n @entrance = @cage.entrances.build(params[:entrance])\n\n respond_to do |format|\n if @entrance.save\n format.html { redirect_to cage_entrance_path(@cage, @entrance), notice: 'Entrance was successfully created.' }\n format.json { render json: @entrance, status: :created, location: cage_entrance_path(@cage, @entrance) }\n else\n format.html { render action: \"new\" }\n format.json { render json: @entrance.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n mod_params = entrant_params\n date = entrant_params[:date].to_datetime\n date = date.change(hour: params[:time].split(':')[0].to_i, minute: params[:time].split(':')[1].to_i)\n mod_params[:guess] = date\n mod_params.delete('date')\n mod_params.delete('time')\n @entrant = Entrant.create(mod_params)\n\n # respond_to do |format|\n # if @entrant.save\n # format.html { redirect_to @entrant, notice: 'Entrant was successfully created.' }\n # format.json { render :show, status: :created, location: @entrant }\n # else\n # format.html { render :new }\n # format.json { render json: @entrant.errors, status: :unprocessable_entity }\n # end\n # end\n render json: {entrant: @entrant}, status: 200\n end", "def guardian_create_enrollment_ticket(body)\n raise Auth0::InvalidParameter, 'Must supply a valid body' if body.to_s.empty?\n\n path = \"#{guardian_enrollments_path}/ticket\"\n post(path, body)\n end", "def create\n \n @race = Race.new(race_params)\n\t@race.user_id = session[:user_id]\n\t\n\tnum = params[:no_racers].to_i\n\n\ti = 0\n\t#$num = 5\n\n\t(1..num).each do |i|\n\t\tputs \"Racer - \" + i.to_s\n \t\t@racer = Racer.new(:name => \"Racer \" + i.to_s )\n \t\t@racer.race = @race\n\t\t@race.racers << @racer\n \t\ti +=1\n \t\t\n\tend\n\t\n\t\n\tnum = params[:no_rzs].to_i\n\t\n\ti = 1\n\t#$num = 5\n\t\n\t(1..num).each do |i|\n\t\tputs \"RZ - \" + i.to_s\n \t\t@rz = Rz.new(:name => \"RZ\"+i.to_s)\n\t\t@race.rzs << @rz\n \t\ti +=1\n\tend\n\t\n\t@race.rzs.each do |rz|\n\t\tputs 'rzrecord RZ' + rz.id.to_s\n\t\t@race.racers.each do |racer|\n\t\t\t\tputs 'rzrecord Racer' + racer.id.to_s\n\t\t\trzRecord = RzRecord.new()\n\t\t\trzRecord.racer = racer\n\t\t\trzRecord.race = @race\n\t\t\trzRecord.rz = rz\n\t\t\trz.rz_records << rzRecord\n\t\t\tracer.rz_records << rzRecord\n\t\tend\n\tend \n\t\t\n\n respond_to do |format|\n if @race.save\n format.html { render :edit, :race => @race, notice: 'Race was successfully created.' }\n format.json { render :show, status: :created, location: @race }\n else\n format.html { render :new }\n format.json { render json: @race.errors, status: :unprocessable_entity }\n end\n end\n end", "def race= (races)\n write_attribute(:race, races - [\"\"])\n end", "def acquire_new_plane(aircrafttype)\n home_airport = self.home_airport_game\n param_array = [aircrafttype,self,home_airport]\n new_plane = PlaneCreator.new(param_array).manufacture\n finalize_acquisition_and_save(new_plane)\n end", "def race=( race )\n\t\t@race.race= race\n\t\tif @race.data.has_key?('Prohibited Classes') and @race.data['Prohibited Classes'].include?(@character_class.to_s)\n\t\t\t@change_error = \"A #{race} cannot be a #{@character_class.to_s}. Setting the class to the racial default.\"\n\t\t\t$log.info \"Resetting character class to the default class for the race, #{@race.data['Default Class']}\"\n\t\t\t@character_class = NERO_Class.new(@race.data['Default Class'])\n\t\tend\n\t\t@build.legalize\n\tend", "def create\n @enrollment = Enrollment.new(enrollment_params)\n @registry = @enrollment.registry\n @participants = Participant.all - @registry.participants\n @coordinators = @registry.coordinators\n\n respond_to do |format|\n if @enrollment.save\n format.html { redirect_to @enrollment, notice: 'Enrollment was successfully created.' }\n format.json { render :show, status: :created, location: @enrollment }\n else\n format.html { render :new }\n format.json { render json: @enrollment.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_racer\n @racer = Racer.find(params[:id])\n end", "def set_racer\n\t #@racer = Racer.find(params[:id])\n\t end", "def create\n @renter = Renter.new(renter_params)\n\n respond_to do |format|\n if @renter.save\n format.html { redirect_to @renter, notice: 'Renter was successfully created.' }\n format.json { render :show, status: :created, location: @renter }\n else\n format.html { render :new }\n format.json { render json: @renter.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @entrant = Entrant.new(params[:entrant])\n\n respond_to do |format|\n if @entrant.save\n \n Pusher['chatroom'].trigger('welcome', {\n :new_member_msg => \"Welcome to the chatroom!\"\n })\n \n format.html { redirect_to @entrant, notice: 'Entrant was successfully created.' }\n format.json { render json: @entrant, status: :created, location: @entrant }\n else\n format.html { render action: \"new\" }\n format.json { render json: @entrant.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_race\n\t @race=Race.where(:_id=>params[:id]).first\n\t end", "def create_enrollment\n\n end", "def assign_role(character)\n Role.new(self, character)\n end", "def create\n @enqury = Enqury.new(enqury_params)\n\n respond_to do |format|\n if @enqury.save\n format.html { redirect_to @enqury, notice: 'Enqury was successfully created.' }\n format.json { render :show, status: :created, location: @enqury }\n else\n format.html { render :new }\n format.json { render json: @enqury.errors, status: :unprocessable_entity }\n end\n end\n end", "def initialize( name, race, gender, alignment )\n\n # Choose the trait module to include\n case race\n when \"dwarf\"\n self.class.send( :include, DwarfTraits )\n when \"elf\"\n self.class.send( :include, ElfTraits )\n else\n self.class.send( :include, HumanTraits )\n end\n\n # Compile equipment proficiencies\n equipProf = EQUIPMENT_PROFICIENCY + WEAPON_FAMILIARITIES\n equipProf.uniq!\n\n # Cleric Specific Data\n @spells = LEVEL_1_SPELLS\n @orisons = ORISONS\n\n className = \"cleric\"\n\n super( name, race, gender, alignment, className, FORTITUDE_SAVE, REFLEX_SAVE, WILL_SAVE, HP, ATTACK_BONUS,\n SKILL_RANKS, SKILLS, SPEED, DARKVISION_RANGE, equipProf, IMMUNITIES, LEVEL_BONUSES,\n STARTING_BONUSES, ATTACK_BONUSES, DEFENSE_BONUSES )\n\n end", "def create\n\n randomRace if params[:npc][:race_id].size == 0\n @npc = Race.find(params[:npc][:race_id]).npcs.create(npc_params)\n \n respond_to do |format|\n if @npc.save\n format.html { redirect_to @npc, notice: 'Npc was successfully created.' }\n format.json { render :show, status: :created, location: @npc }\n else\n format.html { render :new }\n format.json { render json: @npc.errors, status: :unprocessable_entity }\n end\n end\n \n end", "def race_params\n params.require(:race).permit(:name, :position)\n end", "def set_other_race\n @other_race = OtherRace.find(params[:id])\n end", "def create\n # Instantiate a new object using form parameters\n attrs = params.permit(:coursenumber, :title, :description, :start_date, :end_date, :created_at, :updated_at, :status, :active, :inactivation_request)\n @instructor = Instructor.find_by_email params[:email]\n\n attrs[:instructor] = @instructor\n if @instructor\n @course = Course.create(attrs)\n redirect_to courses_path\n else\n @course = Course.new\n render new_course_path\n end\n end", "def set_entrant\n @entrant = Entrant.find(params[:id])\n end", "def create\n #@enrollment = Enrollment.new(params[:enrollment])\n\n respond_to do |format|\n @enrollment = Enrollment.shard_for( params[:enrollment][:classroom_id] ).create!( params[:enrollment] )\n if @enrollment\n format.html { redirect_to @enrollment, notice: 'Enrollment was successfully created.' }\n format.json { render json: @enrollment, status: :created, location: @enrollment }\n else\n format.html { render action: \"new\" }\n format.json { render json: @enrollment.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_organizer_role\n Role.where(name: 'track_organizer', resource: self).first_or_create(description: 'For the organizers of the Track')\n end", "def create_organizer_role\n Role.where(name: 'track_organizer', resource: self).first_or_create(description: 'For the organizers of the Track')\n end", "def race_params\n params.require(:race).permit(:name, :current_heat, :round_start_interval, :start_date, :lock_racer_list_finish, :auto_sync)\n end", "def create\n raise HttpException.new(402, \"Agree to terms!\") unless current_user.customer_object.has_agreed_terms?\n raise HttpException.new(402, \"Unpaid subscription!\") if !current_user.active_account? && !current_user.customer_object.trial_active?\n\n if params[:market_id]\n market = Market.find(params[:market_id])\n #Eventing.report(current_user, 'createRoster', :contest_type => contest_type.name, :buy_in => contest_type.buy_in)\n raise HttpException.new(403, \"This market is closed\") unless Market.find(params[:market_id]).accepting_rosters?\n in_progress_rosters = current_user.rosters.where(:state => 'in_progress')\n in_progress_rosters.first.destroy if in_progress_rosters.count > 5\n Eventing.report(current_user, 'createRoster', :buy_in => Roster::DEFAULT_BUY_IN)\n roster = Roster.create!(:owner_id => current_user.id,\n :market_id => market.id,\n :takes_tokens => false,\n :buy_in => Roster::DEFAULT_BUY_IN,\n :remaining_salary => Roster::DEFAULT_REMAINING_SALARY,\n :state => 'in_progress')\n else\n contest_type = ContestType.find(params[:contest_type_id])\n Eventing.report(current_user, 'createRoster', :contest_type => contest_type.name, :buy_in => contest_type.buy_in)\n roster = Roster.generate(current_user, contest_type)\n end\n\n existing_roster = Roster.find(params[:copy_roster_id]) if params[:copy_roster_id]\n roster.build_from_existing(existing_roster) if existing_roster\n render_api_response roster\n end", "def race_params\n params.require(:race).permit(:category_id, :race_time, :name, :description, :intermediate_points, :status)\n end", "def create\n\t\t\t@investor = params[:id].present? ? Investor.find(params[:id]) : Investor.new\n\t\tend", "def _create_reservation(subject, owner = nil)\n\t\t\t\t\t\n\t\t\t\t\t# Create reservation\n\t\t\t\t\treservation = RicReservation.reservation_model.new\n\t\t\t\t\treservation.kind = \"resource\"\n\t\t\t\t\treservation.resource = self\n\n\t\t\t\t\t# Bind subject\n\t\t\t\t\treservation.date_from = subject.date_from\n\t\t\t\t\treservation.time_from = subject.time_from\n\t\t\t\t\treservation.date_to = subject.date_to\n\t\t\t\t\treservation.time_to = subject.time_to\n\t\t\t\t\treservation.subject = subject\n\t\t\t\t\t\n\t\t\t\t\t# Bind owner\n\t\t\t\t\tif !owner.nil?\n\t\t\t\t\t\treservation.owner_name = owner.name if !owner.name.nil?\n\t\t\t\t\t\treservation.owner = owner if owner.is_a?(ActiveRecord::Base) # In case owner is not ActiveRecord, only name can be stored\n\t\t\t\t\tend\n\n\t\t\t\t\treturn reservation\n\t\t\t\tend", "def race; end", "def race; end", "def race; end", "def race; end", "def race; end", "def race; end", "def race_params\n params.require(:race).permit(:name)\n end", "def create\n @race_car = RaceCar.new(race_car_params)\n\n respond_to do |format|\n if @race_car.save\n format.html { redirect_to @race_car, notice: 'Race car was successfully created.' }\n format.json { render :show, status: :created, location: @race_car }\n else\n format.html { render :new }\n format.json { render json: @race_car.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n super do\n case @user.role\n when 'trainee'\n trainee = Trainee.new(user_id: @user.id)\n trainee.save\n when 'trainer'\n trainer = Trainer.new(user_id: @user.id)\n trainer.save\n end\n end\n end", "def create\n @renter = Renter.new(renter_params)\n @renter.user = current_user\n\n respond_to do |format|\n if @renter.save\n format.html {\n if current_user.has_role?(:realtor) || current_user.has_role?(:vip_realtor)\n redirect_to root_path, notice: 'Заявка отправлена'\n else\n redirect_to @renter, notice: 'Запись успешно добавлена.'\n end\n }\n format.json { render action: 'show', status: :created, location: @renter }\n else\n format.html { render action: 'new' }\n format.json { render json: @renter.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @game_races = GameRaces.new(params[:game_races])\n\n respond_to do |format|\n if @game_races.save\n flash[:notice] = 'GameRaces was successfully created.'\n format.html { redirect_to(@game_races) }\n format.xml { render :xml => @game_races, :status => :created, :location => @game_races }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @game_races.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create_enemy(pos, movement, enemy_type = :enemy1)\n sprite, life, amplitude, tags =\n case enemy_type\n when :enemy1 then [@screen.make_basic_enemy_sprite, 20, rand * 20, [:enemy]]\n when :enemy2 then [@screen.make_enemy2_enemy_sprite, 400, 40, [:enemy, :boss]]\n when :honda then [@screen.make_flying_honda, 1000, 0, [:enemy, :boss]]\n when :mario_kart_fish then [@screen.make_mario_kart_fish, 1000, 0, [:enemy, :boss, :rotating, :mario_kart_fish]]\n else fail enemy_type.to_s\n end\n traj = SinusoidalTraj.new(@clock, pos, movement, amplitude, rand * 0.05, rand)\n enemy = Enemy.new(sprite, traj).with(:life => life, :tags => tags)\n enemy.revolutions_per_second = 0 if enemy_type == :mario_kart_fish\n return enemy\n end", "def create\n @arcone = Arcone.new(params[:arcone])\n\n respond_to do |format|\n if @arcone.save\n format.html { redirect_to @arcone, notice: 'Arcone was successfully created.' }\n format.json { render json: @arcone, status: :created, location: @arcone }\n else\n format.html { render action: \"new\" }\n format.json { render json: @arcone.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_armors \n armor = Armor.create(name: 'Light Armor', armor_rating: 5, cost: 0, :merchant_id => self.id)\n\n armor1 = Armor.create(name: 'Medium Armor', armor_rating: 10, cost: 15, :merchant_id => self.id)\n\n armor2 = Armor.create(name: 'Dragonbone Armor', armor_rating: 15 , cost: 45, :merchant_id => self.id )\n\n end", "def create\n @enrolment = Enrolment.new(enrolment_params)\n\n respond_to do |format|\n if @enrolment.save\n format.html { redirect_to @enrolment, notice: \"Enrolment was successfully created.\" }\n format.json { render :show, status: :created, location: @enrolment }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @enrolment.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @course = Course.new(course_params)\n\n if @course.save\n @course.generate_join_token\n if current_user.has_role? :instructor\n current_user.courses << @course\n current_user.add_role :instructor, @course\n current_user.add_role :grader, @course\n end\n\n flash[:notice] = \"Course created successfully.\"\n redirect_to @course\n else\n render :action => :new\n end\n end", "def create\n @enrollment = @parent.enrollments.build enrollment_params\n if @enrollment.save\n render :show, status: :created, location: api_v1_mutant_enrollment_url(@enrollment.mutant_id, @enrollment)\n else\n render json: @enrollment.errors, status: :unprocessable_entity\n end\n end", "def current_enrollment\n return nil unless current_user\n @enrollment = Enrollment.where(program_uuid: stress_less_program.uuid, user_uuid: current_user.uuid).first\n\n if @enrollment.nil?\n log \"I'm CREATING AN ENROLLEMENT\"\n \n # Need to create a new enrollment and associated action plan\n @enrollment = Enrollment.create!(program_uuid: stress_less_program.uuid, user_uuid: current_user.uuid, last_seen:Time.now)\n \n assessment = current_lead ? current_lead.assessment : nil\n assessment.update_attributes(enrollment_uuid:@enrollment.uuid) if assessment\n\n # 2.26.14 gh: adding support for the mini baseline assessment as a pre-registration activity\n if baseline_assessment = find_baseline_assessment_from_session\n baseline_assessment.enrollment = @enrollment\n baseline_assessment.save!\n\n # send the results\n Resque.enqueue(SendMiniBaselineResultsEmail, baseline_assessment.uuid, session)\n end\n\n # create the initial action plan\n @action_plan = current_action_plan\n end\n\n @enrollment\n end", "def enroll!(course_id)\n self.enrollments.create!(course_id:course_id)\n end", "def create_random_Ant\n\n myAnt = Ant.new\n\n myAnt.x = @x\n myAnt.y = @y\n myAnt.anthill = self\n rand_number = rand(3)\n if rand_number == 0\n myAnt = create_Forager(myAnt)\n elsif rand_number == 1\n myAnt = create_Builder(myAnt)\n else\n myAnt = create_Warrior(myAnt)\n \n end\n\n Meadow.instance.add_AntToCell(myAnt, @x, @y)\n @food -= 1 \n end", "def race_params\n params.require(:race).permit(:name, :place, :date)\n end", "def create\n # when Accept is not specified or MIME type\n if !request.accept || request.accept == \"*/*\"\n # params_spec\n if params[:race]\n render plain: \"#{params[:race][:name]}\", status: :ok\n else\n # uri_spec\n render plain: :nothing, status: :ok\n end\n # render plain: \"#{params[:race][:name]}\", status: :ok\n elsif request.accept && request.accept != \"*/*\"\n # add a new Race to the db\n # Explicit hash arguments\n # name = params[:race][:name]\n # date = params[:race][:date]\n\n # Hash mass assignment\n # @race = Race.create(params[:race].to_hash.slice(:name, :date))\n\n # white-listed mass assignment\n race = Race.create(race_params)\n render plain: race.name, status: :created\n else\n end\n end", "def create\n @renter = Renter.new(renter_params)\n if @renter.save\n flash[:success] = \"Yeni kiracı başarıyla eklendi.\"\n redirect_to renters_path\n else\n render 'new'\n end\n end", "def new\n @election = Election.find(params[:election_id])\n @race = @election.races.build\n @race.race_candidates.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @race }\n end\n end", "def create\n @race_discipline = RaceDiscipline.new(params[:race_discipline])\n\n respond_to do |format|\n if @race_discipline.save\n format.html { redirect_to(admin_race_discipline_path(@race_discipline), :notice => 'RaceDiscipline was successfully created.') }\n format.xml { render :xml => @race_discipline, :status => :created, :location => @race_discipline }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @race_discipline.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @endroit = Endroit.new(params[:endroit])\n\n respond_to do |format|\n if @endroit.save\n format.html { redirect_to @endroit, notice: 'Endroit was successfully created.' }\n format.json { render json: @endroit, status: :created, location: @endroit }\n else\n format.html { render action: \"new\" }\n format.json { render json: @endroit.errors, status: :unprocessable_entity }\n end\n end\n end", "def enroll_editor_in_case\n Enrollment.find_or_create_by case_id: self.case.id,\n reader_id: editor.id\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 new_endorsement\n endorsement = Endorsement.take\n\n NotifierMailer.new_endorsement endorsement.organization.id, endorsement.id\n end", "def new_agent(market, starting_funds)\n EconomicAgent.new(self, market, starting_funds, @inventory.clone)\n end", "def race_params\n\t params.require(:race).permit(:name, :date)\n\t end", "def create\n raise SecurityTransgression unless Enrollment.can_be_created_by? current_user\n @enrollment = Enrollment.new(enrollment_params)\n\n if @enrollment.save\n redirect_to welcome_index_path, notice: 'Enrollment was successfully created.'\n else\n render action: 'new'\n end\n end", "def racer_params\n params.require(:racer).permit(:name, :bib, :order, :boat_class, :age_class, :race_id)\n end", "def race=(r)\n if not r.allows_32pt\n # It's an 28 point build.\n @attributes.maxbuypoints = 28\n end\n # Copy over the base attributes from the race.\n @attributes.base = r.base_attributes \n # Clear out level 1 feats gained, and copy the new ones over.\n if not @race == nil\n @race.feats_gained.each { |f|\n @levels[0].feats_gained.delete f\n }\n end\n @levels[0].feats_gained.concat r.feats_gained\n \n # Special setter.\n @race = r\n end", "def create\n @atr = Atr.new(params[:atr])\n\n respond_to do |format|\n if @atr.save\n format.html { redirect_to @atr, notice: 'Atr was successfully created.' }\n format.json { render json: @atr, status: :created, location: @atr }\n else\n format.html { render action: \"new\" }\n format.json { render json: @atr.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n return @tandem if @tandem\n\n @tandem = Tandem.create\n @tandem.participations.create(\n user: @creator,\n confirmed: true,\n language: @language_to_learn\n )\n\n TandemInviter.new(@tandem).invite(@invited)\n @tandem\n end", "def race\n @race\n end", "def new_talent(email)\n Talent.new( :name => \"Zaphod\",\n :description => \"Has two heads\",\n :phone => \"098-987-9877\",\n :email => email,\n :address => \"The Heart of gold\",\n :comments => \"Just this guy\",\n :type_id => 3)\n end", "def newstudent firstname, lastname, course\n $roster << {firstname: firstname, lastname: lastname, course: course}\nend", "def set_race_car\n @race_car = RaceCar.find(params[:id])\n end", "def create\n @race_result = RaceResult.new(params[:race_result])\n\n respond_to do |format|\n if @race_result.save\n flash[:notice] = 'RaceResult was successfully created.'\n format.html { redirect_to(@race_result) }\n format.xml { render :xml => @race_result, :status => :created, :location => @race_result }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @race_result.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create_character(user, name: \"Testy McTesterson\", race: Race.first, starting_points: 20, starting_florins: 0, starting_death_thresholds: 10, state: \"active\", title: \"\", no_title: false, declared_on: 5.years.ago)\n character = user.characters.create_with(race: race, starting_points: starting_points, starting_florins: starting_florins, starting_death_thresholds: starting_death_thresholds, state: state, title: title, declared_on: declared_on, no_title: no_title).find_or_create_by!(name: name)\n guild_membership = character.guild_memberships.build\n guild_membership.character = character\n guild_membership.start_points = 0\n guild_membership.declared_on = character.declared_on\n guild_membership.provisional = false\n guild_membership.approved = true\n character.save!\n character\n end", "def create_reservation(subject, owner = nil)\n\t\t\t\t\t\n\t\t\t\t\t# Create reservation\n\t\t\t\t\treservation = _create_reservation(subject, owner)\n\n\t\t\t\t\t# Store\n\t\t\t\t\treservation.save\n\n\t\t\t\t\treturn reservation\n\t\t\t\tend", "def create\n # .permit Hay que indicar los parametros permitidos (se recomienda hacer en el modelo)\n @entrada = Entrada.new(entrada_params) \n if @entrada.save\n redirect_to @entrada # Te muestra la entrada recien creada\n else\n redirect_to new_entrada_path\n end\n end" ]
[ "0.7477985", "0.66777647", "0.62276137", "0.5967927", "0.5967927", "0.58257663", "0.581496", "0.5790698", "0.5737334", "0.57169336", "0.5685861", "0.56776965", "0.56316113", "0.56316113", "0.56316113", "0.56316113", "0.56316113", "0.5503881", "0.54605424", "0.5459186", "0.5407139", "0.53932196", "0.53910047", "0.5388532", "0.5371241", "0.533071", "0.5326391", "0.52886343", "0.5277393", "0.52757233", "0.5266715", "0.5248395", "0.5242863", "0.524203", "0.52133226", "0.5190121", "0.51820457", "0.5176967", "0.51746655", "0.51542807", "0.51484025", "0.51287", "0.5122869", "0.51226383", "0.5122423", "0.5120857", "0.50816613", "0.5074036", "0.5065483", "0.50566494", "0.50566494", "0.5050246", "0.5029759", "0.5024001", "0.5015048", "0.50130373", "0.499457", "0.499457", "0.499457", "0.499457", "0.499457", "0.499457", "0.49781528", "0.49746627", "0.49742803", "0.49706888", "0.49629843", "0.49589556", "0.49519098", "0.4950413", "0.49442658", "0.4939945", "0.49261504", "0.49191174", "0.49160308", "0.4915577", "0.49080068", "0.49075726", "0.48909256", "0.48822", "0.48803496", "0.48772845", "0.48688075", "0.48653296", "0.48556343", "0.4855333", "0.485134", "0.48485282", "0.4842142", "0.4840343", "0.48244756", "0.48159608", "0.48100084", "0.48083073", "0.48066488", "0.48066282", "0.48035952", "0.47999454", "0.47958174", "0.47940516" ]
0.8058066
0
default curl Accept header Also used by browsers to request various web assets like woff files
def accept_all(env) env["HTTP_ACCEPT"] == "*/*" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def default_accept_header\n RDF::Util::File::HttpAdapter.default_accept_header.sub(/, \\*\\/\\*;q=0\\.1\\Z/, '')\n end", "def prefered_http_accept\n Rack::Utils.best_q_match(@request.env[\"HTTP_ACCEPT\"], %w(text/html application/json))\n end", "def accept(env)\n Rack::AcceptMediaTypes.new(env['HTTP_ACCEPT']).prefered.to_s.gsub(/\\*/, '.*')\n end", "def default_octokit_headers\n {\n :accept => ::Octokit::Default.default_media_type,\n :content_type => \"application/json\",\n :user_agent => ::Octokit::Default.user_agent\n # :accept_encoding => \"gzip;q=1.0,deflate;q=0.6,identity;q=0.3\"\n }\n end", "def vary_by_accept\n response.headers['Vary'] = 'Accept'\n end", "def accept_header(request)\n raise NotImplementedError\n end", "def accept()\n @accept ||= Accept.parse(@request.env['HTTP_ACCEPT'])\n end", "def accept(type)\n headers(HTTP::Headers::ACCEPT => HTTP::MimeType.normalize(type))\n end", "def accept_header(request)\n request.env[HEADER_ACCEPT]\n end", "def scan_accept_header(accept)\n if match = accept.match(FORMAT)\n @version = match[:version]\n @content_type = [match[:mime_base], match[:mime_type]].join(\"/\")\n @media_type_options = match[:options].scan(/(\\.\\w+)/).map do |option|\n option.first.sub!(/^\\./, \"\")\n end\n end\n end", "def name\n 'Accept-Encoding'\n end", "def options\n head :status => 200, :'Access-Control-Allow-Headers' => 'accept, content-type'\n end", "def get_accept_header(media_type)\n media_types = { hale: 'application/vnd.hale+json' }\n { 'Accept' => media_types[media_type] }\n end", "def initialize(options={})\n @default_accept = options.fetch(:accept, 'application/hal+json')\n end", "def vary_headers; end", "def no_accept_header(env)\n env[\"HTTP_ACCEPT\"] == nil || env[\"HTTP_ACCEPT\"] == \"\"\n end", "def matches?(req)\n @default || (req.try(:headers).try(:[],'Accept') &&\n req.headers['Accept'].include?(\"application/api.brightwheel.v#{@version}\"))\n end", "def request_headers\n { 'Accept-Encoding'=>'gzip, deflate', 'User-Agent'=>'Ruby'}\n end", "def match_accept(mimetype)\n if @env[\"HTTP_ACCEPT\"].to_s.split(',').any?{|s| s.strip == mimetype}\n response[\"Content-Type\"] = mimetype\n end\n end", "def check_accept_header!\n return if request.headers[\"Accept\"] == \"application/vnd.api+json\"\n\n error!(\"415 Unsupported Media Type\", 415)\n end", "def set_header_options(curl)\n summary = summary_for_feed\n \n unless summary.nil?\n curl.headers['If-None-Match'] = summary[:etag] unless summary[:etag].nil?\n curl.headers['If-Modified-Since'] = summary[:last_modified] unless summary[:last_modified].nil?\n end\n \n curl\n end", "def select_header_accept(accepts)\n return nil if accepts.nil? || accepts.empty?\n # use JSON when present, otherwise use all of the provided\n json_accept = accepts.find { |s| json_mime?(s) }\n json_accept || accepts.join(',')\n end", "def select_header_accept(accepts)\n return nil if accepts.nil? || accepts.empty?\n # use JSON when present, otherwise use all of the provided\n json_accept = accepts.find { |s| json_mime?(s) }\n json_accept || accepts.join(',')\n end", "def select_header_accept(accepts)\n return nil if accepts.nil? || accepts.empty?\n # use JSON when present, otherwise use all of the provided\n json_accept = accepts.find { |s| json_mime?(s) }\n json_accept || accepts.join(',')\n end", "def select_header_accept(accepts)\n return nil if accepts.nil? || accepts.empty?\n # use JSON when present, otherwise use all of the provided\n json_accept = accepts.find { |s| json_mime?(s) }\n json_accept || accepts.join(',')\n end", "def select_header_accept(accepts)\n return nil if accepts.nil? || accepts.empty?\n # use JSON when present, otherwise use all of the provided\n json_accept = accepts.find { |s| json_mime?(s) }\n json_accept || accepts.join(',')\n end", "def provides(*formats)\n generate_type_hash = Proc.new{ |header| \n type, *params = header.split(/;\\s*/)\n Hash[*params.map{|p| p.split(/\\s*=\\s*/)}.flatten].merge(\"type\" => type)\n }\n supported_formats = formats.map do |f| \n # selects the correct mime type if a symbol is given\n f.is_a?(Symbol) ? ::Rack::Mime::MIME_TYPES[\".#{f.to_s}\"] : f\n end.compact.map do |f|\n generate_type_hash.call(f)\n end\n # request.accept is an Array\n accepted_formats = request.accept.map do |f| \n generate_type_hash.call(f)\n end\n selected_format = nil\n accepted_formats.each{ |accepted_format| \n selected_format = supported_formats.detect{ |supported_format| \n Regexp.new(Regexp.escape(accepted_format[\"type\"]).gsub(\"\\\\*\", \".*?\"), Regexp::IGNORECASE) =~ supported_format[\"type\"] &&\n (accepted_format[\"level\"] || INFINITY).to_f >= (supported_format[\"level\"] || 0).to_f\n }\n break unless selected_format.nil?\n } \n if selected_format.nil?\n content_type :txt\n halt 406, supported_formats.map{|f| \n output = f[\"type\"]\n output.concat(\";level=#{f[\"level\"]}\") if f.has_key?(\"level\")\n output\n }.join(\",\")\n else\n response.headers['Content-Type'] = \"#{selected_format[\"type\"]}#{selected_format[\"level\"].nil? ? \"\" : \";level=#{selected_format[\"level\"]}\"}\"\n end\n end", "def _negotiate(request)\n header = request.env[Const::ENV_HTTP_ACCEPT]\n if @lookup.key?(header)\n @lookup[header]\n else\n accepts = request.acceptable_media\n @lookup[header] = accepts.empty? ? @provides.first : request.preferred_media_from(*@provides)\n end\n rescue\n @lookup[header] = nil # The Accept request-header is malformed.\n end", "def default_http_header; end", "def accepts\n fetch_header(\"action_dispatch.request.accepts\") do |k|\n header = get_header(\"HTTP_ACCEPT\").to_s.strip\n\n v = if header.empty?\n [content_mime_type]\n else\n Mime::Type.parse(header)\n end\n set_header k, v\n rescue ::Mime::Type::InvalidMimeType => e\n raise InvalidType, e.message\n end\n end", "def header_accepts_json\n { \"Accepts\" => \"application/json\" }\n end", "def matchers?(req)\n @default || req.headers['Accept'].include?(\"application/vnd.glass.v#{@version}\")\n end", "def select_header_accept(accepts)\n return nil if accepts.nil? || accepts.empty?\n # use JSON when present, otherwise use all of the provided\n json_accept = accepts.find { |s| json_mime?(s) }\n return json_accept || accepts.join(',')\n end", "def default_filters!\n before do\n request.path_info =~ /\\.([^\\.\\/]+)$/\n @_content_type = ($1 || :html).to_sym\n content_type(@_content_type, :charset => 'utf-8') rescue content_type('application/octet-stream')\n end\n end", "def accept_helper\n content_type = MediaType.parse(request.content_type || 'application/octet-stream')\n acceptable = resource.content_types_accepted.find {|ct, _| content_type.match?(ct) }\n if acceptable\n resource.send(acceptable.last)\n else\n 415\n end\n end", "def accept_format\n return \"\" if env['HTTP_ACCEPT'].nil?\n \n format = env['HTTP_ACCEPT'].scan(/[^;,\\s]*\\/[^;,\\s]*/)[0].split(\"/\")[1]\n \n # Exception for HTML if path contains .format\n if format == 'html' and path_info =~ /.\\w+$/\n path_format = path_info.split(\".\").last\n if path_format != 'html'\n format = path_format\n end\n end\n \n if format =~ /[+]/\n format = format.split(\"+\")[0]\n end\n \n format\n end", "def parsed_content_type_header; end", "def set_media_type\n media_types = self.class.head(@endpoint).headers['accept']\n Occi::Log.debug(\"Available media types: #{media_types}\")\n @media_type = case media_types\n when /application\\/occi\\+json/\n 'application/occi+json'\n else\n 'text/plain'\n end\n end", "def standard_headers\n {\n 'Accept' => 'application/json',\n 'Content-Type' => 'application/json',\n 'User-Agent' => 'chef-pedant rspec tests',\n 'X-Chef-Version' => KNIFE_VERSION\n }\n end", "def vary_headers=(_arg0); end", "def respond_to\n mimes = Rack::Accept::MediaType.new request.env['HTTP_ACCEPT']\n accepted = AcceptableModel::Artist.version_mapper.collect { |mime| mime[:version] }\n response = mimes.best_of(accepted)\n content_type response\n response\n end", "def accept(accept)\n supported_accept = [:xml, :json]\n raise \"Supported Accept values #{supported_accept}\" unless supported_accept.include? accept\n @accept = accept\n end", "def accept_encoding=(value)\n Curl.set_option(:accept_encoding, value_for(value, :string), handle)\n end", "def connection_options\n {\n :headers => {\n # :accept => default_media_type,\n :user_agent => user_agent\n }\n }\n end", "def preflight\n head 200\n end", "def options\n opts = fetch('options', {})\n headers = fetch('headers', {})\n if value = accept\n headers[:accept] = value\n end\n opts[:raw] = key?('raw') ? self['raw'] : false\n opts[:headers] = headers unless headers.empty?\n opts\n end", "def accept_header?\n return request.headers['Accept']&.include?('application/fhir+json') if params.permit(:_format)[:_format].nil?\n\n ['json', 'application/json', 'application/fhir+json'].include?(params.permit(:_format)[:_format]&.downcase)\n end", "def call(env)\n if scan_accept_header(env[\"HTTP_ACCEPT\"])\n env[\"app.api.version\"] = version\n env[\"app.api.media-type-options\"] = media_type_options\n env[\"HTTP_ACCEPT\"] = content_type\n end\n\n @app.call(env)\n end", "def matches?(request)\n @default || request.headers['Accept'].include?(\"application/vnd.medexprimereemr.v#{@version}\")\n end", "def connection_options\n {\n :headers => {\n :accept => default_media_type,\n :user_agent => user_agent\n }\n }\n end", "def connection_options\n {\n :headers => {\n :accept => default_media_type,\n :user_agent => user_agent\n }\n }\n end", "def default_headers\n {:accept => \"application/json\", :content_type => \"application/json\"}\n end", "def accept_json\n logger.debug(request.accept)\n unless request.accept? 'application/json'\n response.headers['Accept'] = 'application/json'\n halt_response(\"Accept header should contains 'application/json' type\", 406)\n end\n rescue NoMethodError => e\n #error in sinatra 1.4.4 (https://github.com/sinatra/sinatra/issues/844, https://github.com/sinatra/sinatra/pull/805)\n response.headers['Accept'] = 'application/json'\n halt_response(\"Accept header should contains 'application/json' type\", 406)\n end", "def content_headers\n { 'User-Agent' => \"Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.0.7) Gecko/2009021906 Firefox/3.0.7\",\n 'Accept-language' => 'enUS' }\n end", "def accept_response_type\n mimes = @scope.opts[:type_routing][:mimes]\n\n @env['HTTP_ACCEPT'].to_s.split(/\\s*,\\s*/).map do |part|\n mime, _= part.split(/\\s*;\\s*/, 2)\n if sym = mimes[mime]\n response[RodaResponseHeaders::VARY] = (vary = response[RodaResponseHeaders::VARY]) ? \"#{vary}, Accept\" : 'Accept'\n return sym\n end\n end\n\n nil\n end", "def negotiate_mime(order); end", "def respond_to\n env['HTTP_ACCEPT'] ||= 'text/html'\n Rack::RespondTo.env = env\n\n super { |format|\n yield(format).tap do |response|\n type = Rack::RespondTo::Helpers.match(Rack::RespondTo.media_types, format).first\n content_type(type) if type\n end\n }\n end", "def check_headers(headers)\n # check version from Accept headers; expect custom media type `spoonlibrary`\n accept = headers[:accept]\n accept&.include?(\"application/vnd.spoonlibrary.#{version}+json\")\n end", "def enforce_accept(request, config)\n return unless request.accept_header?\n\n accept_types = ::Rack::Utils.q_values(request.accept).map(&:first)\n return if accept_types.any? { |mime_type| accepted_mime_type?(mime_type, config) }\n\n yield\n end", "def content_type; end", "def content_type; end", "def content_type; end", "def content_type; end", "def content_type; end", "def content_type; end", "def content_type; end", "def content_type; end", "def accept\n @env['HTTP_ACCEPT'].to_s.split(',').map { |a| a.strip }\n end", "def requested()\n @requested ||= ( extension ? Accept.new( Accept.parse( MimeTypes[ extension ].join(\",\") ) + accept ).uniq : accept )\n end", "def test_get_with_media_type_negotiation_and_various_accept\n root.expects(:get).returns(@entities).at_least_once\n\n assert_equal STATUS_OK, get('HTTP_ACCEPT' => 'application/json').status\n assert_equal \"{foo: 'Yalrightmate'}\", last_response.body\n assert_equal 'application/json', last_response.media_type\n assert last_response.headers['Vary'].split(/,\\s*/).include?('Accept')\n\n assert_equal STATUS_NOT_ACCEPTABLE, get('HTTP_ACCEPT' => '*/*; q=0').status\n assert_equal STATUS_NOT_ACCEPTABLE, get('HTTP_ACCEPT' => 'application/bollocks; q=1').status\n assert_equal STATUS_OK, get('HTTP_ACCEPT' => 'text/*').status\n assert_equal 'text/html', last_response.media_type\n # orders by q-value, default of 1\n assert_equal 'application/json', get('HTTP_ACCEPT' => 'application/json, text/html; q=0.5').media_type\n assert_equal 'application/json', get('HTTP_ACCEPT' => 'application/json; q=0.8, text/html; q=0.5').media_type\n assert_equal 'text/html', get('HTTP_ACCEPT' => 'application/json; q=0.4, text/html; q=0.5').media_type\n # text/html is more specific than text/*\n assert_equal STATUS_NOT_ACCEPTABLE, get('HTTP_ACCEPT' => 'text/*; q=0').status\n assert_equal STATUS_OK, get('HTTP_ACCEPT' => 'text/*; q=0, text/html; q=1').status\n\n assert_equal STATUS_OK, get('HTTP_ACCEPT' => 'text/*; q=0, */*; q=1').status\n assert_not_equal 'text/html', last_response.media_type\n\n # doesn't just look for the highest q-value that matches, but uses the matching rules and their specificities of matching to\n # construct a media_type => q-value mapping and then uses that to prioritize what's available:\n assert_equal 'application/yaml', get('HTTP_ACCEPT' => 'application/*; q=0.6, application/json; q=0.4').media_type\n assert_equal 'application/json', get('HTTP_ACCEPT' => 'application/*; q=0.6, application/yaml; q=0.4').media_type\n end", "def content_type_header(request)\n raise NotImplementedError\n end", "def default_headers\n @default_headers ||= {}\n {\n 'user-agent' => 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.0.1) Gecko/2008070206 Firefox/3.0.1',\n 'accept' => 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',\n 'accept-language' => 'en-us,en;q=0.5',\n 'accept-charset' => 'ISO-8859-1,utf-8;q=0.7,*;q=0.7',\n 'keep-alive' => 300,\n 'connection' => 'keep-alive'\n }.each { |k,v| @default_headers[k] ||= v }\n @default_headers['accept-encoding'] = 'gzip,deflate' if @accept_compressed\n @default_headers\n end", "def matches?(request)\n request.headers.fetch(:accept).include?(\"application/vnd.pieforproviders.v#{version}+json\")\n end", "def configure_compression(options, env)\n return unless (env[:method] == :get) &&\n !options[:head].key?('accept-encoding')\n\n options[:head]['accept-encoding'] = 'gzip, compressed'\n end", "def headers\n {\n # Declare that you expect response in XML after a _successful_\n # response.\n \"Accept\" => \"application/xml\",\n\n # Promise to send XML.\n \"Content-Type\" => \"application/xml; charset=utf-8\",\n\n # All requests will be authenticated using HTTP Basic Auth, as\n # described in rfc2617. Your library probably has support for\n # basic_auth built in, I've passed the Authorization header\n # explicitly here only to show what happens at HTTP level.\n \"Authorization\" => \"Basic #{auth_string}\",\n\n # Tell Harvest a bit about your application.\n \"User-Agent\" => HarvestConfig.attrs[:user_agent]\n }\n end", "def curl\n hs = \"\"\n self.context.header_decorator.headers.each_pair do |k,v|\n hs << \" -H '#{k}:#{v}' \"\n end\n\n \"curl #{hs} -v '#{Arrest::Source.source.url}/#{self.resource_location}'\"\n end", "def test_send_file_headers_bang\n # Do it a few times: the resulting headers should be identical\n # no matter how many times you send with the same options.\n # Test resolving Ticket #458.\n 5.times do\n get :test_send_file_headers_bang\n\n assert_equal \"image/png\", response.content_type\n assert_equal %(disposition; filename=\"filename\"; filename*=UTF-8''filename), response.get_header(\"Content-Disposition\")\n assert_equal \"binary\", response.get_header(\"Content-Transfer-Encoding\")\n end\n end", "def http_head_with_tingyun(*args, &blk)\n self._ty_http_verb = :HEAD\n http_head_without_tingyun(*args, &blk)\n end", "def default_headers\n {\n :content_type => :json,\n :accept => :json\n }\n end", "def content_type\n 'application/octet-stream'\n end", "def connection_options\n {\n headers: {\n accept: default_media_type,\n user_agent: user_agent\n }\n }\n end", "def connection_options\n {\n headers: {\n accept: default_media_type,\n user_agent: user_agent\n }\n }\n end", "def handle_headers_for_json\n response[HDR_A_C_ALLOW_ORIGIN] = request.env[HDR_ORIGIN] if request.env.has_key? HDR_ORIGIN\n content_type :json\n end", "def validate_content_type!\n head 406 unless request.headers['Accept'] === 'application/json'\n end", "def set_content_type(response, format)\n raise NotImplementedError\n end", "def set_content_type(response, format)\n raise NotImplementedError\n end", "def connection_options\n {\n :headers => {\n :accept => media_type,\n :user_agent => user_agent\n }\n }\n end", "def add_content_type\n header[:content_type] = 'text/plain'\n end", "def head!\n request! :head\n end", "def content_type_header(request)\n request.content_type\n end", "def test_changes_empty_content_type_to_text_plain\n response = Typhoeus.get(\"http://127.0.0.1:9080/api/compressible/1000?content_type=\", http_options)\n assert_response_code(200, response)\n assert_equal(\"text/plain\", response.headers[\"content-type\"])\n end", "def set_content_type\n case params['format']\n when 'xml'\n response.headers['Content-Type'] = \"application/xml; charset=utf-8\"\n when 'json', 'csv'\n response.headers['Content-Type'] = \"application/json; charset=utf-8\"\n else\n raise \"Unexpected format!\"\n end\n end", "def set_headers # :nodoc:\n {\n 'User-Agent' => \"twm-ruby-#{VERSION}\",\n 'Content-Type' => 'application/json; charset=utf-8',\n 'Accept' => 'application/json'\n }\n end", "def http_after_get(request, response)\n return unless (response.header('Content-Type') || '').index('text/vcard')\n\n mime_type = Box.new('')\n target = negotiate_v_card(request.header('Accept'), mime_type)\n mime_type = mime_type.value\n\n new_body = convert_v_card(\n response.body,\n target\n )\n\n response.body = new_body\n response.update_header('Content-Type', \"#{mime_type}; charset=utf-8\")\n response.update_header('Content-Length', new_body.bytesize)\n end", "def use_cross_origin\n cross_origin :allow_origin => '*',\n :allow_methods => [:get],\n :expose_headers => ['Content-Type', ]\nend", "def response_media_type(options={})\n options = {:halt_if_unacceptable => false}.merge(options)\n accept = env['HTTP_ACCEPT']\n if accept =~ /\\S/\n begin\n best_media_type = env['rack-accept.request'].best_media_type(supported_media_types)\n rescue RuntimeError => e\n # TODO: this is a crappy way to recognize this exception \n raise unless e.message =~ /Invalid header value/\n end\n if best_media_type\n best_media_type\n else\n if options[:halt_if_unacceptable]\n logger.error \"received Accept header of #{accept.inspect}; halting with 406\"\n message = I18n.t('app.errors.request.accept',\n :default => \"The request indicated that no supported media type is acceptable. Supported media types are: %{supported_media_types}. The request specified Accept: %{accept}\",\n :accept => accept,\n :supported_media_types => supported_media_types.join(', ')\n )\n halt_error(406, {'Accept' => [message]})\n else\n supported_media_types.first\n end\n end\n else\n supported_media_types.first\n end\n end", "def curl(server, url, args:{}, file:\"\", post:false, json:false, getfile:nil)\n cmd = \"\"\n # Getfile needs json to remove html, but don't parse as json\n cmd << if getfile.nil? then '-i ' else '-H \"Accept: application/json\" ' end\n cmd << '-X POST ' if post\n cmd << '-H \"Accept: application/json\" ' if json\n cmd << \"-F \\'file=@#{file}\\' \" if file != \"\"\n args.each_pair { |k,v| cmd << \"-F \\'#{k}=#{v}\\' \" }\n\n pipe = getfile.nil? ? '' : '-o ' + File.join($workdir, getfile)\n url2 = !getfile.nil? ? url + getfile + \"/\" : url\n\n res = run(\"curl http://#{server}#{url2} #{cmd}#{pipe}\")\n # clean up json output\n if json\n i = res =~ /{/\n res = res[i..-1] if i\n res = JSON::parse(res)\n end\nend", "def headers\n [\n { :key => \"User-Agent\", :value => user_agent},\n { :key => \"Content-Type\", :value => \"application/json; charset=utf-8\" },\n { :key => \"Accept\", :value => \"application/json\"}\n ]\n end", "def content_mime_type; end", "def select_header_content_type(content_types)\n # use application/json by default\n return 'application/json' if content_types.nil? || content_types.empty?\n # use JSON when present, otherwise use the first one\n json_content_type = content_types.find { |s| json_mime?(s) }\n json_content_type || content_types.first\n end" ]
[ "0.6825097", "0.64791125", "0.6403577", "0.6371897", "0.6367981", "0.62955797", "0.6257307", "0.62529063", "0.6214424", "0.618227", "0.61762315", "0.61665905", "0.6166253", "0.6115122", "0.6065883", "0.6029473", "0.6023836", "0.5999954", "0.5914391", "0.58629346", "0.58546996", "0.58255523", "0.58255523", "0.58255523", "0.58255523", "0.58255523", "0.5801028", "0.5801004", "0.5782328", "0.5773281", "0.57348865", "0.57186323", "0.5707484", "0.5688859", "0.5680978", "0.5666988", "0.5660394", "0.563412", "0.5626114", "0.5589152", "0.55566835", "0.55532694", "0.55402756", "0.55169344", "0.55146855", "0.55018973", "0.54991966", "0.5482599", "0.5476448", "0.5472266", "0.5472266", "0.5461198", "0.54596", "0.54589653", "0.5457152", "0.5452739", "0.5451089", "0.5445367", "0.5440671", "0.54215425", "0.54215425", "0.54215425", "0.54215425", "0.54215425", "0.54215425", "0.54215425", "0.54215425", "0.5409668", "0.5395173", "0.5376798", "0.5376668", "0.5366478", "0.53549856", "0.5348052", "0.5342636", "0.53168446", "0.53087944", "0.5295846", "0.5295244", "0.5292697", "0.5273757", "0.5273757", "0.52491975", "0.523931", "0.52262175", "0.52262175", "0.5219693", "0.520043", "0.518718", "0.51869714", "0.51744777", "0.5170126", "0.5160843", "0.51555866", "0.51332", "0.5090394", "0.50751936", "0.5069566", "0.50669956", "0.50646627" ]
0.5816417
26
No browser ever makes a request without an accept header, so it must be an API request if there is no Accept header
def no_accept_header(env) env["HTTP_ACCEPT"] == nil || env["HTTP_ACCEPT"] == "" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_accept_header!\n return if request.headers[\"Accept\"] == \"application/vnd.api+json\"\n\n error!(\"415 Unsupported Media Type\", 415)\n end", "def check_json_api_headers\n unless request.headers[\"Content-Type\"] && request.headers[\"Content-Type\"].\n include?(\"application/vnd.api+json\")\n return render json: \"\", status: :unsupported_media_type\n end\n\n unless request.headers[\"Accept\"] &&\n request.headers[\"Accept\"].include?(\"application/vnd.api+json\")\n return render json: \"\", status: :not_acceptable\n end\n end", "def ensure_json_request\n return if params[:format] == 'json' || request.headers['Accept'] =~ /json/\n head :not_acceptable\n end", "def validate_content_type!\n head 406 unless request.headers['Accept'] === 'application/json'\n end", "def check_header\n if ['POST', 'PUT', 'PATCH'].include? request.method\n head :not_acceptable and return unless request.content_type == 'application/vnd.api+json'\n end\n end", "def check_format\n # This allows us to support content negotiation\n if request.headers['HTTP_ACCEPT'].nil? || request.format == '*/*'\n request.format = 'xml'\n end\n\n request_format = request.format.symbol\n if request_format != :xml && request_format != :json\n # 406 is the default status code when the format is not support\n head :not_acceptable\n end\n end", "def prefered_http_accept\n Rack::Utils.best_q_match(@request.env[\"HTTP_ACCEPT\"], %w(text/html application/json))\n end", "def accept_header(request)\n raise NotImplementedError\n end", "def matches?(req)\n @default || (req.try(:headers).try(:[],'Accept') &&\n req.headers['Accept'].include?(\"application/api.brightwheel.v#{@version}\"))\n end", "def accept_json\n logger.debug(request.accept)\n unless request.accept? 'application/json'\n response.headers['Accept'] = 'application/json'\n halt_response(\"Accept header should contains 'application/json' type\", 406)\n end\n rescue NoMethodError => e\n #error in sinatra 1.4.4 (https://github.com/sinatra/sinatra/issues/844, https://github.com/sinatra/sinatra/pull/805)\n response.headers['Accept'] = 'application/json'\n halt_response(\"Accept header should contains 'application/json' type\", 406)\n end", "def prefer_json?\n prefered_http_accept == \"application/json\"\n end", "def accept_header?\n return request.headers['Accept']&.include?('application/fhir+json') if params.permit(:_format)[:_format].nil?\n\n ['json', 'application/json', 'application/fhir+json'].include?(params.permit(:_format)[:_format]&.downcase)\n end", "def ensure_json_request\n return render_message({status:ERR_STATUS,responseMessage: NOT_ACCEPTABLE_MESSAGE, responseCode: NOT_ACCEPTABLE }) unless request.format == :json\n end", "def check_header\n if ['POST','PUT','PATCH'].include? request.method\n if request.content_type != \"application/vnd.api+json\"\n head 406 and return\n end\n end\n end", "def default_accept_header\n RDF::Util::File::HttpAdapter.default_accept_header.sub(/, \\*\\/\\*;q=0\\.1\\Z/, '')\n end", "def ensure_json_content_type\n request.headers['Content-Type'] =~ /application\\/json/\n end", "def header_accepts_json\n { \"Accepts\" => \"application/json\" }\n end", "def matches?(request)\n request.headers.fetch(:accept).include?(\"application/vnd.pieforproviders.v#{version}+json\")\n end", "def verify_requested_format!\n mimes = collect_mimes_from_class_level\n collector = ActionController::MimeResponds::Collector.new(mimes, request.variant)\n\n unless collector.negotiate_format(request)\n raise ActionController::UnknownFormat\n end\n end", "def test_get_with_media_type_negotiation_and_various_accept\n root.expects(:get).returns(@entities).at_least_once\n\n assert_equal STATUS_OK, get('HTTP_ACCEPT' => 'application/json').status\n assert_equal \"{foo: 'Yalrightmate'}\", last_response.body\n assert_equal 'application/json', last_response.media_type\n assert last_response.headers['Vary'].split(/,\\s*/).include?('Accept')\n\n assert_equal STATUS_NOT_ACCEPTABLE, get('HTTP_ACCEPT' => '*/*; q=0').status\n assert_equal STATUS_NOT_ACCEPTABLE, get('HTTP_ACCEPT' => 'application/bollocks; q=1').status\n assert_equal STATUS_OK, get('HTTP_ACCEPT' => 'text/*').status\n assert_equal 'text/html', last_response.media_type\n # orders by q-value, default of 1\n assert_equal 'application/json', get('HTTP_ACCEPT' => 'application/json, text/html; q=0.5').media_type\n assert_equal 'application/json', get('HTTP_ACCEPT' => 'application/json; q=0.8, text/html; q=0.5').media_type\n assert_equal 'text/html', get('HTTP_ACCEPT' => 'application/json; q=0.4, text/html; q=0.5').media_type\n # text/html is more specific than text/*\n assert_equal STATUS_NOT_ACCEPTABLE, get('HTTP_ACCEPT' => 'text/*; q=0').status\n assert_equal STATUS_OK, get('HTTP_ACCEPT' => 'text/*; q=0, text/html; q=1').status\n\n assert_equal STATUS_OK, get('HTTP_ACCEPT' => 'text/*; q=0, */*; q=1').status\n assert_not_equal 'text/html', last_response.media_type\n\n # doesn't just look for the highest q-value that matches, but uses the matching rules and their specificities of matching to\n # construct a media_type => q-value mapping and then uses that to prioritize what's available:\n assert_equal 'application/yaml', get('HTTP_ACCEPT' => 'application/*; q=0.6, application/json; q=0.4').media_type\n assert_equal 'application/json', get('HTTP_ACCEPT' => 'application/*; q=0.6, application/yaml; q=0.4').media_type\n end", "def api_request?\n request.format.json? || request.format.js? || request.format.xml? || request.format.fbtab?\n end", "def check_request_format\n unless request.content_type == 'application/json'\n error = ErrorSerializer.serialize({ format: \"Invalid request format. Only JSON requests are supported.\" })\n render json: error, status: :unsupported_media_type\n end\n end", "def validate_response_format\n accept = request.headers[\"Accept\"]\n return :json if accept.include?(\"json\") || accept.include?(\"*/*\")\n raise IssuesController::UnsupportedMediaTypeError, \"Invalid Response Format #{accept} requested\"\n end", "def status_not_acceptable\n respond_to do |format|\n format.any { head :not_acceptable }\n end\n end", "def catch_bad_request_headers\n if request.headers[\"accept\"] == \"application/json\"\n render plain: \"Invalid request header: we do not provide a JSON version of our search results.\", status: 406\n end\n end", "def default_format_json\n if(request.headers['HTTP_ACCEPT'].nil? && params[:format].nil?) ||\n (request.headers['HTTP_ACCEPT'] != 'application/xml' && params[:format] != 'xml')\n request.format = 'json'\n end\n end", "def matchers?(req)\n @default || req.headers['Accept'].include?(\"application/vnd.glass.v#{@version}\")\n end", "def accept_all(env)\n env[\"HTTP_ACCEPT\"] == \"*/*\"\n end", "def accept()\n @accept ||= Accept.parse(@request.env['HTTP_ACCEPT'])\n end", "def check_format\n redirect_to root_url unless params[:format] == 'json' || request.headers[\"Accept\"] =~ /json/\n end", "def matches?(request)\n @default || request.headers['Accept'].include?(\"application/vnd.medexprimereemr.v#{@version}\")\n end", "def default_octokit_headers\n {\n :accept => ::Octokit::Default.default_media_type,\n :content_type => \"application/json\",\n :user_agent => ::Octokit::Default.user_agent\n # :accept_encoding => \"gzip;q=1.0,deflate;q=0.6,identity;q=0.3\"\n }\n end", "def check_headers(headers)\n # check version from Accept headers; expect custom media type `spoonlibrary`\n accept = headers[:accept]\n accept&.include?(\"application/vnd.spoonlibrary.#{version}+json\")\n end", "def allow_only_standard_requests\n if params[:format] && ([\"html\", \"js\", \"json\", \"xml\", \"rss\"].exclude?(params[:format]))\n raise ActionController::RoutingError.new('No route matches \"'+request.url+'\"')\n end\n end", "def check_format\n not_found unless request.xhr?\n end", "def content_type_header?\n request.headers['Content-Type']&.include?('application/fhir+json')\n end", "def from_api?; false end", "def post_header(request)\n if request.headers[\"content-type\"] == 'application/json' && request.headers[\"accept\"] == 'application/json'\n true\n else\n false\n end\n end", "def accept(env)\n Rack::AcceptMediaTypes.new(env['HTTP_ACCEPT']).prefered.to_s.gsub(/\\*/, '.*')\n end", "def enforce_accept(request, config)\n return unless request.accept_header?\n\n accept_types = ::Rack::Utils.q_values(request.accept).map(&:first)\n return if accept_types.any? { |mime_type| accepted_mime_type?(mime_type, config) }\n\n yield\n end", "def vary_by_accept\n response.headers['Vary'] = 'Accept'\n end", "def _negotiate(request)\n header = request.env[Const::ENV_HTTP_ACCEPT]\n if @lookup.key?(header)\n @lookup[header]\n else\n accepts = request.acceptable_media\n @lookup[header] = accepts.empty? ? @provides.first : request.preferred_media_from(*@provides)\n end\n rescue\n @lookup[header] = nil # The Accept request-header is malformed.\n end", "def api_request?\n false\n end", "def make_not_acceptable_body( response )\n\t\t# :TODO: Unless it was a HEAD request, the response SHOULD include\n\t\t# an entity containing a list of available entity characteristics and\n\t\t# location(s) from which the user or user agent can choose the one\n\t\t# most appropriate. The entity format is specified by the media type\n\t\t# given in the Content-Type header field. Depending upon the format\n\t\t# and the capabilities of the user agent, selection of the most\n\t\t# appropriate choice MAY be performed automatically. However, this\n\t\t# specification does not define any standard for such automatic\n\t\t# selection. [RFC2616]\n\t\treturn \"No way to respond given the requested acceptance criteria.\"\n\tend", "def determine_request_type\n if request.request_method == 'GET'\n case params[:format] # explicit format parameter\n when 'html'\n return :html\n when 'json'\n return :json\n end\n end\n all_ok = request.accept.include?('*/*')\n json_ok = request.accept.find { |header| header =~ /json/ }\n html_ok = request.accept.find { |header| header =~ /html/ }\n\n if all_ok\n if request.xhr?\n :json\n else\n :html\n end\n elsif json_ok and not html_ok\n :json\n elsif html_ok and not json_ok\n :html\n else\n :html\n end\n end", "def valid_request(h = {})\n h.merge!({:use_route => :sensit_api, :format => \"json\", :api_version => \"1\"})\n end", "def accept_header(request)\n request.env[HEADER_ACCEPT]\n end", "def initialize(options={})\n @default_accept = options.fetch(:accept, 'application/hal+json')\n end", "def yadis_request?(request)\n (request.env['HTTP_ACCEPT'] && request.env['HTTP_ACCEPT'].include?('application/xrds+xml'))\n end", "def accept_helper\n content_type = MediaType.parse(request.content_type || 'application/octet-stream')\n acceptable = resource.content_types_accepted.find {|ct, _| content_type.match?(ct) }\n if acceptable\n resource.send(acceptable.last)\n else\n 415\n end\n end", "def status_unsupported_media_type\n respond_to do |format|\n format.any { head :unsupported_media_type }\n end\n end", "def accepts\n fetch_header(\"action_dispatch.request.accepts\") do |k|\n header = get_header(\"HTTP_ACCEPT\").to_s.strip\n\n v = if header.empty?\n [content_mime_type]\n else\n Mime::Type.parse(header)\n end\n set_header k, v\n rescue ::Mime::Type::InvalidMimeType => e\n raise InvalidType, e.message\n end\n end", "def preflight\n head 200\n end", "def request_json\n @request.headers[\"Content-Type\"] = 'application/json'\n @request.headers[\"Accept\"] = 'application/json'\n end", "def acceptable_request!(env)\n case Halcyon.config[:allow_from].to_sym\n when :all\n # allow every request to go through\n when :halcyon_clients\n # only allow Halcyon clients\n raise Exception::Forbidden.new unless env['USER_AGENT'] =~ /JSON\\/1\\.1\\.\\d+ Compatible \\(en-US\\) Halcyon::Client\\(\\d+\\.\\d+\\.\\d+\\)/\n when :local\n # do not allow for requests from an outside host\n raise Exceptions::Forbidden.new unless ['localhost', '127.0.0.1', '0.0.0.0'].member? env[\"REMOTE_ADDR\"]\n else\n logger.warn \"Unrecognized allow_from configuration value (#{Halcyon.config[:allow_from].to_s}); use all, halcyon_clients, or local. Allowing all requests.\"\n end\n end", "def try_options\n\t\t\treturn unless request.http_method == :OPTIONS\n\n\t\t\tallow = available_endpoint&.allow\n\t\t\thalt 404 unless allow\n\t\t\tresponse.headers['Allow'] = allow\n\t\tend", "def api_only; end", "def api_only; end", "def api_only; end", "def not_acceptable(message = nil)\n http_error(406, message, VARY)\n end", "def validate_content_type!\n return if request.content_type == \"application/json\"\n return if request.get? && request.content_type == \"text/plain\"\n return if !request.get? && request.content_type == \"application/x-www-form-urlencoded\"\n\n raise ActionController::BadRequest, \"Invalid content type\"\n end", "def check_accept_encoding\n if accept = @stream.request.headers[ACCEPT_ENCODING_KEY]\n accept.split(',').map(&:strip).each do |encoding|\n case encoding\n when GZIP_ENCODING\n if @stream.connection.server.options[:gzip]\n @gzip = true\n @headers[CONTENT_ENCODING_KEY] = GZIP_ENCODING\n break\n end\n\n # \"deflate\" has issues: https://zlib.net/zlib_faq.html#faq39\n #\n when DEFLATE_ENCODING\n if @stream.connection.server.options[:deflate]\n @deflate = true\n @headers[CONTENT_ENCODING_KEY] = DEFLATE_ENCODING\n break\n end\n\n end\n end\n end\n end", "def include_default_headers\n\t\t\tapi_header\n\t\t\tapi_response_format\n\t\tend", "def content_type_header(request)\n raise NotImplementedError\n end", "def response_media_type(options={})\n options = {:halt_if_unacceptable => false}.merge(options)\n accept = env['HTTP_ACCEPT']\n if accept =~ /\\S/\n begin\n best_media_type = env['rack-accept.request'].best_media_type(supported_media_types)\n rescue RuntimeError => e\n # TODO: this is a crappy way to recognize this exception \n raise unless e.message =~ /Invalid header value/\n end\n if best_media_type\n best_media_type\n else\n if options[:halt_if_unacceptable]\n logger.error \"received Accept header of #{accept.inspect}; halting with 406\"\n message = I18n.t('app.errors.request.accept',\n :default => \"The request indicated that no supported media type is acceptable. Supported media types are: %{supported_media_types}. The request specified Accept: %{accept}\",\n :accept => accept,\n :supported_media_types => supported_media_types.join(', ')\n )\n halt_error(406, {'Accept' => [message]})\n else\n supported_media_types.first\n end\n end\n else\n supported_media_types.first\n end\n end", "def call(env)\n if scan_accept_header(env[\"HTTP_ACCEPT\"])\n env[\"app.api.version\"] = version\n env[\"app.api.media-type-options\"] = media_type_options\n env[\"HTTP_ACCEPT\"] = content_type\n end\n\n @app.call(env)\n end", "def request_headers\n { 'Accept-Encoding'=>'gzip, deflate', 'User-Agent'=>'Ruby'}\n end", "def treat_as_standard_html_request?\n !request.format.json? and !request.format.print? and !request.format.video?\n end", "def treat_as_standard_html_request?\n !request.format.json? and !request.format.print? and !request.format.video?\n end", "def validate_content_type!\n if request.headers['Content-Type'] =~ /multipart\\/form-data/\n head 406 unless request.headers['Content-Length'].present? &&\n request.headers['Accept'] === 'application/json'\n else\n head 406 unless request.headers['Accept'] === 'application/json'\n end\n end", "def accept(type)\n headers(HTTP::Headers::ACCEPT => HTTP::MimeType.normalize(type))\n end", "def should_send_raw?\n request.headers[\"HTTP_ACCEPT\"].include?(\"*/*\") &&\n controller.params[:format].nil? &&\n resource.respond_to?(:content_type) &&\n resource.content_type != 'text/x-markdown'\n end", "def options\n head :status => 200, :'Access-Control-Allow-Headers' => 'accept, content-type'\n end", "def respond_to\n mimes = Rack::Accept::MediaType.new request.env['HTTP_ACCEPT']\n accepted = AcceptableModel::Artist.version_mapper.collect { |mime| mime[:version] }\n response = mimes.best_of(accepted)\n content_type response\n response\n end", "def provides(*formats)\n generate_type_hash = Proc.new{ |header| \n type, *params = header.split(/;\\s*/)\n Hash[*params.map{|p| p.split(/\\s*=\\s*/)}.flatten].merge(\"type\" => type)\n }\n supported_formats = formats.map do |f| \n # selects the correct mime type if a symbol is given\n f.is_a?(Symbol) ? ::Rack::Mime::MIME_TYPES[\".#{f.to_s}\"] : f\n end.compact.map do |f|\n generate_type_hash.call(f)\n end\n # request.accept is an Array\n accepted_formats = request.accept.map do |f| \n generate_type_hash.call(f)\n end\n selected_format = nil\n accepted_formats.each{ |accepted_format| \n selected_format = supported_formats.detect{ |supported_format| \n Regexp.new(Regexp.escape(accepted_format[\"type\"]).gsub(\"\\\\*\", \".*?\"), Regexp::IGNORECASE) =~ supported_format[\"type\"] &&\n (accepted_format[\"level\"] || INFINITY).to_f >= (supported_format[\"level\"] || 0).to_f\n }\n break unless selected_format.nil?\n } \n if selected_format.nil?\n content_type :txt\n halt 406, supported_formats.map{|f| \n output = f[\"type\"]\n output.concat(\";level=#{f[\"level\"]}\") if f.has_key?(\"level\")\n output\n }.join(\",\")\n else\n response.headers['Content-Type'] = \"#{selected_format[\"type\"]}#{selected_format[\"level\"].nil? ? \"\" : \";level=#{selected_format[\"level\"]}\"}\"\n end\n end", "def test_changes_empty_content_type_to_text_plain\n response = Typhoeus.get(\"http://127.0.0.1:9080/api/compressible/1000?content_type=\", http_options)\n assert_response_code(200, response)\n assert_equal(\"text/plain\", response.headers[\"content-type\"])\n end", "def set_default_format_json\n if params[:format] && params[:format] != 'json'\n head :bad_request\n else\n request.format = 'json' unless params[:format]\n end\n end", "def get_accept_header(media_type)\n media_types = { hale: 'application/vnd.hale+json' }\n { 'Accept' => media_types[media_type] }\n end", "def json_response?(headers)\n (headers['Content-Type'] == 'application/json')\n end", "def set_default_response_format\n request.format = :json unless params[:format]\n end", "def handle_headers_for_json\n response[HDR_A_C_ALLOW_ORIGIN] = request.env[HDR_ORIGIN] if request.env.has_key? HDR_ORIGIN\n content_type :json\n end", "def show406\n render '406', status: :not_acceptable\n end", "def default_headers\n {:accept => \"application/json\", :content_type => \"application/json\"}\n end", "def api_request(url, media_type = '')\n parse_request_result api_request_raw(ensure_max_per_page(url), media_type)\n end", "def scan_accept_header(accept)\n if match = accept.match(FORMAT)\n @version = match[:version]\n @content_type = [match[:mime_base], match[:mime_type]].join(\"/\")\n @media_type_options = match[:options].scan(/(\\.\\w+)/).map do |option|\n option.first.sub!(/^\\./, \"\")\n end\n end\n end", "def skip_http_headers; end", "def call(env)\n req_type = accept(env)\n !req_type.empty? && @mime_types.any? {|type| type.match(/#{req_type}/) } ?\n @app.call(env) :\n Rack::Response.new([], 406).finish\n end", "def api_request?\n is_api_request = request.path_info =~ /\\// ||\n request.path_info =~ /\\/fonts/ ||\n request.path_info =~ /\\/connect/\n !is_api_request\n end", "def status_bad_request\n respond_to do |format|\n format.any { head :bad_request }\n end\n end", "def content_type_is_json_but_invalid_json_provided?\n content_type_json? && ((request_body_required? || any_request_body?) && invalid_json?)\n end", "def set_json_api_header\n response.set_header(\"Content-Type\", \"application/vnd.api+json\")\n end", "def accept(accept)\n supported_accept = [:xml, :json]\n raise \"Supported Accept values #{supported_accept}\" unless supported_accept.include? accept\n @accept = accept\n end", "def request_valid?(data)\n ln = 0\n data.each_line {|l|\n ln += 1\n }\n if ln > 1\n return true\n else\n puts \"\\e[1;31mCatch GET's without header information / Other \\e[0m\\ \"\n return false # Due to single GET Requests to no headers \n end\n end", "def show\n respond_to do |format|\n format.any { head :no_content }\n end\n end", "def api_data\n accept = request.headers['Accept']\n \n if accept\n mime_type, version = accept.gsub(/\\s/, \"\").split(\";\")\n mime_type, format = mime_type.split(\"+\")\n version = version.split(\"=\").pop.to_i unless version.nil?\n end\n\n {mime_type: mime_type, format: format, version: version}\n end", "def match?(request)\n request.content_type =~ %r{^application/json.*}\n end", "def content_type; end", "def content_type; end", "def content_type; end", "def content_type; end" ]
[ "0.7697095", "0.7233592", "0.70484567", "0.6956011", "0.68605506", "0.68258375", "0.6760034", "0.67585355", "0.67549103", "0.6737145", "0.6674046", "0.65703475", "0.65351933", "0.6440902", "0.63286555", "0.6308815", "0.62895906", "0.6261089", "0.6255518", "0.62498856", "0.6243185", "0.62392193", "0.6237763", "0.6229064", "0.62210804", "0.6209932", "0.62073565", "0.61773676", "0.61570364", "0.61433977", "0.6105263", "0.60936403", "0.60737145", "0.60534", "0.602125", "0.59924406", "0.59908336", "0.5986479", "0.5983215", "0.59768295", "0.59737337", "0.59550595", "0.5954494", "0.5944097", "0.5929906", "0.5926907", "0.59107405", "0.59040695", "0.58993256", "0.58913785", "0.5881934", "0.58218294", "0.58103424", "0.5794783", "0.5781709", "0.57745916", "0.5773326", "0.5773326", "0.5773326", "0.5747411", "0.57440495", "0.5741443", "0.57383114", "0.5729284", "0.57250655", "0.5718632", "0.5702214", "0.5690596", "0.5690596", "0.5688573", "0.568053", "0.5677299", "0.56597114", "0.56519866", "0.5647091", "0.5636332", "0.5573709", "0.55677783", "0.5564602", "0.5558979", "0.55411935", "0.55409354", "0.55363387", "0.55346686", "0.5520762", "0.55144143", "0.55091083", "0.55057853", "0.54971504", "0.54850066", "0.54822594", "0.5481786", "0.5476259", "0.54750025", "0.5464739", "0.5463793", "0.5462237", "0.5462237", "0.5462237", "0.5462237" ]
0.7058104
2
calls the private methods below passing in the given attributes
def virus_effects predicted_deaths speed_of_spread end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def attributes=(_arg0); end", "def initialize_attributes(attributes); end", "def attributes(*args)\n args.each do |attr|\n attribute(attr)\n end\n end", "def method_missing(method, *args, &block)\n @attributes.send(method, *args, &block)\n end", "def method_missing(method, *args, &block)\n @attributes.send(method, *args, &block)\n end", "def attributes(*args)\n args.each { |attr| attribute(attr) }\n end", "def method_missing(method, *args, &block)\n attributes.public_send(method, *args, &block)\n end", "def initialize_attributes(attributes)\n @attributes = attributes\n @attributes.keys.each do |attr_name|\n define_singleton_method(attr_name) { self[attr_name] }\n end\n end", "def method_missing(method_name, *args, &block)\n attributes.send(method_name.to_s, *args, &block)\n end", "def setup_object_attributes; end", "def initialize(attributes)\n attributes.each {|key, value| self.send((\"#{key}=\"), value)}\n end", "def process_attrasgn exp\n process_call exp\n end", "def process_attrasgn exp\n process_call exp\n end", "def update_accessors_from_attributes(attributes)\n if attributes[:guests]\n # Clear existing accessors and add selected ones\n clear_accessors\n attributes[:guests].each do |guest_id|\n if g = Guest.find(guest_id.to_i)\n authorize_for_user(g, g.current_circle)\n end\n end\n end\n if attributes[:circles]\n attributes[:circles].each do |circle_id|\n if c = Circle.find(circle_id.to_i)\n authorize_for_group(c)\n end\n end\n end\n end", "def allowed_attributes=(_arg0); end", "def allowed_attributes=(_arg0); end", "def attributes; end", "def attributes; end", "def attributes; end", "def attributes; end", "def attributes; end", "def attributes; end", "def attributes; end", "def attributes; end", "def attributes; end", "def attributes; end", "def attributes; end", "def define_attributes(*args)\n options = args.extract_options!\n options[:access_level] ||= :public\n # Initialize each attribute\n args.each do |arg|\n self.initialize_attribute(\n Array.wrap(arg),\n options[:access_level]\n )\n end\n\n self.define_attribute_methods(\n args,\n options[:access_level]\n )\n end", "def initialize(attributes = {})\n self.class.set_attrb_accessors\n\n #cheeto = Student.new(name: \"cheeto\", grade: 6)\n attributes.each do |property, value|\n #interpolation converts symbol to string\n self.send(\"#{property}=\", value)\n end\n end", "def create_attributes(klass, members); end", "def helper_attr(*attrs); end", "def initialize (attributes)\n attributes.each do |key, value|\n self.send((\"#{key}=\"), value)\n end\n end", "def initialize(attr)\n #iterate over each key/value pair in attribute hash\n attr.each do |k,v|\n #name of key becomes setter\n #value associated with key is the name of value you want to pass to method\n self.send(\"#{k}=\", v)\n #send method is another way of calling a method on an object\n #same as instance_of_user.key = value\n #when you want to mass assign, send is better than .name= method\n end\n end", "def method_missing(method_name, *args)\n method_match, attribute_name, equal_sign = method_name.to_s.match(/\\A([^=]+)(=)?\\Z/).to_a\n if attribute_name && self.class.valid_attributes.include?(attribute_name.to_sym)\n if equal_sign \n attributes[attribute_name.to_sym] = args.first\n else\n attributes[attribute_name.to_sym]\n end\n else\n super\n end\n end", "def method_missing(method_name, *args, &block)\n if attrs.keys.include? method_name.to_s\n attrs[method_name.to_s]\n else\n super(method_name)\n end\nend", "def attributes(*args)\n attr_accessor(*args)\n end", "def request_attributes *list_of_attributes\n assert_needed_attributes *list_of_attributes\n logger.info \"Requesting attributes #{needed_attributes} of #{self} ##{id}\"\n request_dependencies # Launch all objects that we depend on\n bkg_launch attrib_needed?\n end", "def initialize(**attributes)\n @attr = {}\n attributes\n end", "def add_student_attributes(attributes_hash)\n attributes_hash.each do |attr, value| #from the hash get each attribute and value\n self.send(\"#{attr}=\", value) #send the studen tthe new attribute/value key pair\n end #end the each-do\n self #call self\n end", "def setAttributes _obj, _args\n \"_obj setAttributes _args;\" \n end", "def initialize(args)\n @attributes = args\n end", "def tributes *attrs\n if attrs.empty? \n @tributes ||= []\n else \n @tributes = attrs\n super *attrs\n end \n end", "def attribute=(_arg0); end", "def attribute=(_arg0); end", "def method_missing(method_name, *args, &block)\n return super unless define_attribute_methods\n self.send(method_name, *args, &block)\n end", "def assign_attributes(**attributes)\n end", "def initialize(attributes)\n attributes.each do |k,v|\n send(\"#{k}=\", v)\n end\n end", "def initialize(attributes)\n attributes.each do |k,v|\n send(\"#{k}=\", v)\n end\n end", "def method_missing(method_sym, *arguments)\n method_name = method_sym.to_s\n attribute_name = method_name.gsub(/(\\?$)|(=$)/, '')\n if @attributes.include?(attribute_name.to_sym) || method_name[-1] == '=' || method_name[-1] == '?'\n generate_methods!(attribute_name, method_name)\n send(method_sym, *arguments)\n else\n super(method_sym, *arguments)\n end\n end", "def initialize(attributes)\n attributes.each do |k,v|\n send(\"#{k}=\", v) if respond_to?(\"#{k}=\")\n end\n end", "def method_missing method_name,*method_args, &method_block\n if method_name.end_with?('_name') || method_name.end_with?('_names')\n attribute = method_name.to_s.gsub(/_name(s)?$/,'')\n args.fetch(attribute)\n elsif method_name.end_with?('_value')\n attribute = method_name.to_s.gsub('_value','')\n attribute_name = send(\"#{attribute}_name\")\n item.send attribute_name\n elsif method_name.end_with?('_values')\n attribute = method_name.to_s.gsub('_values','')\n attribute_names = send(\"#{attribute}_names\")\n attribute_names.map{|attribute_name| item.send(attribute_name) }\n else\n super\n end\n end", "def initialize(attributes)\n attributes.each {|key, value| self.send(\"#{key}=\", value)}\n end", "def initialize(params = {})\n # Your #initialize method should iterate through each of the\n # attr_name, value pairs.\n params.each do | attr_name, value |\n # For each attr_name,\n # it should first convert the name to a symbol\n attr_name = attr_name.to_sym\n # check whether the attr_name is among the columns\n # Hint: we need to call ::columns on a class object\n # not the instance.\n # For example, we can call Dog::columns but not dog.columns.\n if self.class.columns.include?(attr_name)\n # calls appropriate setter method for each item in params\n # Use #send; avoid using @attributes or\n # attributes inside #initialize.\n self.send(\"#{attr_name}=\", value)\n else\n # If it is not, raise an error\n raise \"unknown attribute '#{attr_name}'\"\n end\n end\n end", "def initialize(**attributes)\n attributes.map { |(k, v)| public_send(\"#{k}=\", v) }\n end", "def set_attributes_to_reader\n if !@attributes.empty?\n @attributes.each { |ele|\n self.class.__send__(:attr_reader, ele.downcase)\n }\n end\n\nend", "def method_missing(name, *args, &block)\n unless self.attributes.include?(name.to_s)\n super(name, *args, &block)\n else\n self.attributes[name.to_s]\n end\n end", "def method_missing(name, *args, &block)\n unless self.attributes.include?(name.to_s)\n super(name, *args, &block)\n else\n self.attributes[name.to_s]\n end\n end", "def init_attributes(attributes)\n self.attributes = attributes.symbolize_keys\n end", "def attributes=(attributes)\r\n attributes.symbolize_keys!\r\n roles = attributes.delete :roles\r\n memberships = attributes.delete :memberships\r\n returning super do \r\n update_roles roles if roles \r\n update_memberships memberships if memberships\r\n end\r\n end", "def initialize(attributes)\n return if attributes.nil?\n \n # attributes = new_attributes.dup\n attributes.stringify_keys!\n \n attributes.each do |k, v|\n respond_to?(:\"#{k}=\") ? send(:\"#{k}=\", v) : raise(UnknownAttributeError, \"unknown attribute: #{k}\")\n end\n \n @test = false unless test?\n \n if test?\n @email = \"xmltest@freightquote.com\"\n @password = \"xml\"\n end\n \n end", "def initialize *args\n @attributes = {}\n opts = args.last.is_a?(Hash) ? args.pop : {}\n each_with_index { |(name, _), i| send \"#{name}=\", args[i] } unless args.empty?\n opts.each { |name, value| send \"#{name}=\", value }\n end", "def define_attributes\n @info.attributes.each do |attr|\n rname = underscore(attr.name)\n self.class.__send__(:define_method, rname) { self[attr.name] } if attr.readable?\n self.class.__send__(:define_method, rname + \"=\") {|v| self[attr.name] = v } if attr.writable?\n end\n end", "def method_missing(meth, *args, &block)\n if attributes.has_key?(meth)\n attributes[meth]\n else\n super\n end\n end", "def initialize(attributes)\n @name = attributes.fetch(:name)\n @id = attributes.fetch(:id)\n # @artist = attributes.fetch(:artist)\n # @genre = attributes.fetch(:genre)\n # @year = attributes.fetch(:year)\n # @in_inventory = attributes.fetch(:in_inventory, true) \n end", "def method_missing( symbol, *arguments )\n if symbol.to_s =~ /(.+)=/ && arguments.size == 1 then\n @attributes[ $1.to_sym ] = arguments.first\n elsif @attributes.has_key?( symbol ) && arguments.empty? then\n @attributes[ symbol ]\n else\n super symbol, arguments\n end\n end", "def method_missing(method, *args)\n if method.to_s =~ /=$/\n @attributes[ method.to_s.gsub(/=$/, '').to_sym ] = args\n else\n @attributes[method]\n end\n end", "def attributes\n end", "def initialize(*args)\n params = args[0]\n attribute_keys.each { |k| self.__send__(\"#{k}=\", params[k]) if params.key?(k) } if params\n end", "def attributes(*attrs)\n @attributes = attrs\n attr_reader(*attrs)\n end", "def assert_known_attributes(klass, attribute_hash); end", "def initialize(attributes = {})\n attributes.each do |name, value|\n public_send(\"#{name}=\", value)\n end\n end", "def initialize(attributes = {})\n attributes.each do |name, value|\n public_send(\"#{name}=\", value)\n end\n end", "def modify( attributes )\n\t\tattributes = stringify_keys( attributes )\n\n\t\tsuper\n\n\t\tself.uri( attributes['uri'] )\n\t\tself.http_method( attributes['http_method'] )\n\t\tself.http_version( attributes['http_version'] )\n\t\tself.expected_status( attributes['expected_status'] )\n\t\tself.body( attributes['body'] )\n\t\tself.body_mimetype( attributes['body_mimetype'] )\n\tend", "def add_student_attributes(attributes_hash) #instance variables assign to key,value\n attributes_hash.each do |key,value| \n if key == :twitter\n @twitter = value\n elsif\n key == :linkedin\n @linkedin = value\n elsif\n key == :github\n @github = value\n elsif\n key == :blog\n @blog = value\n elsif\n key == :profile_quote\n @profile_quote = value\n elsif\n key == :profile_url\n @profile_url = value\n elsif\n key == :bio\n @bio = value\n end\n end\n # binding.pry\n end", "def method_missing(sym, *arguments, &blk)\n super unless defined?(attributes) && attributes.is_a?(Hash)\n if attributes.has_key? sym\n attributes[sym]\n else\n super\n end\n end", "def initialize(params={})super(params)\n # Define accessor and query methods for each attribute.\n attrs.each do |attribute|\n self.class.send :attr_accessor, attribute\n define_attr_query attribute\n end\n\n # Set instance variables and initialize @attributes with any\n # attribute values that were passed in the params hash.\n @attributes = {}\n params.each do |k,v|\n if attrs.include? k.to_s\n send(\"#{k}=\", v)\n @attributes[k] = v\n end\n end\n end", "def process_attrasgn(exp)\n process_call(exp)\n end", "def initialize(attributes = {})\n @attributes = attributes\n super @attributes.slice(*self.class.special_attrs).merge(data: @attributes.except(*self.class.special_attrs))\n end", "def initialize(attributes = {})\n# puts attributes\n attributes = attributes.reduce({}){ |hash, (k, v)|\n key = k.to_s.underscore\n hash = hash.merge( key => v ) if @@fields.find_index(key.to_sym)\n hash\n }\n HashWithIndifferentAccess.new(attributes)\n attributes.each do |k,v|\n self.send (k + '=').to_sym, v # grazie, DM\n end\n super\n raise ArgumentError.new(\"Citation ID can't be nil\") if self.citation_id.nil?\n raise ArgumentError.new(\"Citation type can't be nil. CitationID: #{self.citation_id}\") if self.citation_type.nil?\n raise ArgumentError.new(\"Citation type must be JOURNAL or NON JOURNAL. CitationID: #{self.citation_id}\") if self.citation_type != \"JOURNAL\" && self.citation_type != \"NON_JOURNAL\"\n raise ArgumentError.new(\"Citation must have a title. CitationID: #{self.citation_id}\") if self.title.nil?\n end", "def initialize(attributes)\n attributes.each do |key, value|\n setter_method = \"#{key}=\".to_sym\n send(setter_method, value)\n end\n end", "def attr_reader(*attrs)\n attrs.each do |attr|\n define_attribute_method(attr)\n define_predicate_method(attr)\n end\n end", "def initialize(*attrs)\n set_attributes(attrs.extract_options!)\n end", "def init_super_attrs(args={}, inst)\n\t\t\t\targs_keys = args.keys\n\n\t\t\t\tif @@required_attrs.any?\n\t\t\t\t\t# Checks if args_keys has all attr in the \n\t\t\t\t\t# @@required_attrs. If args is empty, it will\n\t\t\t\t\t# raise an StandardError\n\t\t\t\t\tif args_keys.any?\n\t\t\t\t\t\tnot_set_attrs = []\n\t\t\t\t\t\t@@required_attrs.each do |req|\n\t\t\t\t\t\t\tnot_set_attrs << req unless args_keys.include?(req)\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\traise StandardError.new(\"Required attributes: #{not_set_attrs.join(\", \")}\") if not_set_attrs.any?\n\t\t\t\t\telse\n\t\t\t\t\t\traise StandardError.new(\"Required attributes: #{@@required_attrs.join(\", \")}\")\n\t\t\t\t\tend\n\n\t\t\t\tend\n\t\t\t\t\n\t\t\t\t# Inits the arguments passed via the\n\t\t\t\t# initilize method.\n\t\t\t\targs_keys.each {|key| self.instance_method(\"#{key}=\").bind(inst).call(args[key]) }\n\t\t\tend", "def do_bean_set_attributes(params)\n return if !params || params.empty?\n new_attributes = @remote_strategy.set_attributes(@ancestry, params, @client_info)\n super(new_attributes)\n #rescue Exception => e\n # puts \"Error setting attributes: #{e.message}\"\n # return e\n end", "def method_missing(name, *args, &block)\n @attributes[name]\n end", "def initialize(*args)\n @args = args\n assign_attributes\n end", "def add_additional_attributes\n\n\t\t#gets an array of scraped attributes from the Scraper Class method #scrape_specific_concert\n\t\tattribute_array = SfBayAreaConcertsCliApp::Scraper.scrape_specific_concert(self.url)\n\t\n\t\t#assigns the attributes to the concert instance based on the array index\n\t\tself.ticket_price = attribute_array[0]\n\t\tself.bio = attribute_array[1]\n\t\tself.artist_website = attribute_array[2]\n\t\tself.where_to_find_music = attribute_array[3]\n\t\tself.facebook = attribute_array[4]\n\t\tself.twitter = attribute_array[5]\n\t\tself.instagram = attribute_array[6]\n\t\tself.youtube = attribute_array[7]\n\t\tself.buy_tickets_link = attribute_array[8]\n\t\t\n\tend", "def initialize(attributes)\n super\n end", "def attributes(_record)\n raise 'Abstract method attributes should be overriden'\n end", "def process_attributes(params, attributes)\n # Get the id of the section corresponding to :section_name\n unless params[:section_name].blank?\n section = Section.find_by_name(params[:section_name])\n unless section.blank?\n attributes[:section_id] = section.id\n end\n end\n\n parameters = [:last_name, :first_name, :type, :grace_credits, :email, :id_number, :hidden]\n parameters.each do |key|\n unless params[key].blank?\n attributes[key] = params[key]\n end\n end\n\n attributes\n end", "def method_missing *args\n # if the first entry of the parameter-array is a known attribute\n # proceed with the assignment\n if args.size == 1\n attributes[args.first.to_sym] # return the attribute-value\n elsif args[0][-1] == \"=\" \n if args.size == 2\n#\tif rid.rid? \n#\t update set:{ args[0][0..-2] => args.last }\n#\telse\n\t self.attributes[ args[0][0..-2] ] = args.last\n#\tend\n else\n\t self.attributes[ args[0][0..-2] ] = args[1 .. -1]\n#\tupdate set: {args[0][0..-2] => args[1 .. -1] } if rid.rid?\n end\n else\n raise NameError, \"Unknown method call #{args.first.to_s}\", caller\n end\n end", "def initialize(attributes)\n @attributes = attributes\n end", "def initialize(attributes)\n @attributes = attributes\n end", "def initialize(attributes)\n @attributes = attributes\n end", "def initialize(attributes)\n @attributes = attributes\n end", "def initialize(attributes)\n @attributes = attributes\n end", "def initialize(attributes={})\n attributes.each {|key, value| self.send(\"#{key}=\", value)}\n end", "def attributes(*attrs, **args)\n attrs.each { |attr| attribute(attr, **args) }\n end", "def sf_attributes(*attrs)\n attrs.each do |attr|\n sf_attribute attr\n end\n end", "def initialize(attributes = {})\n attributes.each do |attr, value|\n send(\"#{attr}=\", value) if respond_to?(attr.to_sym)\n end \n end", "def method_missing(method, *args, &block)\n if respond_to_without_attributes?(method, true)\n super\n else\n match = matched_attribute_method(method.to_s)\n match ? attribute_missing(match, *args, &block) : super\n end\n end" ]
[ "0.7211032", "0.67893666", "0.6716527", "0.66168666", "0.65419316", "0.6541509", "0.652478", "0.6515039", "0.6420641", "0.6336361", "0.63285196", "0.62964886", "0.62964886", "0.6227347", "0.62199205", "0.62199205", "0.6219378", "0.6219378", "0.6219378", "0.6219378", "0.6219378", "0.6219378", "0.6219378", "0.6219378", "0.6219378", "0.6219378", "0.6219378", "0.6193721", "0.61536807", "0.6139921", "0.6126966", "0.61161286", "0.61039805", "0.6089927", "0.6089109", "0.608728", "0.60839325", "0.6078342", "0.60681415", "0.6066885", "0.6049622", "0.60431147", "0.6040682", "0.6040682", "0.6034516", "0.6019294", "0.60148644", "0.60148644", "0.60077024", "0.60065204", "0.5999658", "0.5989207", "0.5986699", "0.5979033", "0.5976282", "0.5961596", "0.5961596", "0.59608775", "0.5959398", "0.5941134", "0.5939041", "0.59330934", "0.59329814", "0.59151155", "0.58998716", "0.58961165", "0.58927613", "0.5892318", "0.588916", "0.58842015", "0.5868381", "0.5868381", "0.58664256", "0.5860348", "0.5851065", "0.5843192", "0.5840427", "0.58275515", "0.5822328", "0.5821151", "0.58093446", "0.5806374", "0.58029974", "0.57917213", "0.57897854", "0.57842785", "0.57793754", "0.57727295", "0.5769036", "0.5765821", "0.5765476", "0.5764804", "0.5764804", "0.5764804", "0.5764804", "0.5764804", "0.5761323", "0.5756453", "0.57488936", "0.5742706", "0.5742451" ]
0.0
-1
takes attributes in based upon population density and preforms calculation providing anticipated deaths
def predicted_deaths # predicted deaths is solely based on population density if @population_density >= 200 number_of_deaths = (@population * 0.4) elsif @population_density >= 150 number_of_deaths = (@population * 0.3) elsif @population_density >= 100 number_of_deaths = (@population * 0.2) elsif @population_density >= 50 number_of_deaths = (@population * 0.1) else number_of_deaths = (@population * 0.05) end print "#{@state} will lose #{number_of_deaths.floor} people in this outbreak" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def predicted_deaths #(population_density, population, state)\n # predicted deaths is solely based on population density\n\n\n if @population_density >= 200\n number_of_deaths = (@population * 0.4).floor\n elsif @population_density < 200 && @population_density >= 50\n number_of_deaths = (@population * (@population_density.to_i/50) * 0.1).floor\n else\n number_of_deaths = (@population * 0.05).floor\n end\n\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak!!!\\n\"\n\n end", "def predicted_deaths #(population_density, population, state)\n # predicted deaths is solely based on population density\n\n #popd = [200, 150, 100, 50]\n #perc = [0.4, 0.3, 0.2, 0.1]\n\n #popd[i]\n\n if @population_density < 50\n number_of_deaths = (@population * 0.05)\n elsif @population_density >= 200\n number_of_deaths = (@population * 0.4).floor\n elsif @population_density >= 150\n number_of_deaths = (@population * 0.3).floor\n elsif @population_density >= 100\n number_of_deaths = (@population * 0.2).floor\n else @population_density >= 50\n number_of_deaths = (@population * 0.1).floor\n end\n\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\n\n end", "def predicted_deaths#(population_density, population, state)\r\n # predicted deaths is solely based on population density\r\n number_of_deaths = (@population * 0.4).floor if @population_density >= 200\r\n \r\n number_of_deaths = (@population * 0.3).floor if @population_density >= 150\r\n \r\n number_of_deaths = (@population * 0.2).floor if @population_density >= 100\r\n \r\n number_of_deaths = (@population * 0.1).floor if @population_density >= 50\r\n \r\n number_of_deaths = (@population * 0.05).floor if @population_density >= 0\r\n \r\n # end\r\n # print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\r\n end", "def predicted_deaths #(population_density, population, state)\n # predicted deaths is solely based on population density\n fractions = [0.4, 0.3, 0.2, 0.1, 0.05]\n density = [200, 150, 100, 50, 0]\n \n index = 0\n while index < density.length\n if @population_density >= density[index]\n number_of_deaths = (@population * fractions[index]).floor\n break\n end\n index += 1\n end\n \n # if @population_density >= density[0]\n # number_of_deaths = (@population * fractions[0]).floor\n # elsif @population_density >= density[1]\n # number_of_deaths = (@population * fractions[1]).floor\n # elsif @population_density >= density[2]\n # number_of_deaths = (@population * fractions[2].floor\n # elsif @population_density >= density[3]\n # number_of_deaths = (@population * fractions[3]).floor\n # else\n # number_of_deaths = (@population * fractions[4]).floor\n # end\n\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\n\n end", "def predicted_deaths\n # predicted deaths is solely based on population density\n if @population_density >= 200\n number_of_deaths = (@population * 0.4).floor\n elsif @population_density < 50\n number_of_deaths = (@population * 0.05).floor\n else\n multiplier = (@population_density/50).floor\n number_of_deaths = (@population * (multiplier * 0.1)).floor\n end\n end", "def predicted_deaths #(population_density, population, state)\r\n # predicted deaths is solely based on population density\r\n if @population_density >= 200\r\n multiplier = 0.4\r\n elsif @population_density >= 150\r\n multiplier = 0.3\r\n elsif @population_density >= 100\r\n multiplier = 0.2\r\n elsif @population_density >= 50\r\n multiplier = 0.1\r\n else\r\n multiplier = 0.05\r\n end\r\n number_of_deaths = (@population * multiplier).floor\r\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\r\n\r\n end", "def predicted_deaths #(population_density, population, state)\n # predicted deaths is solely based on population density\n\n # Refactored method by simplifying the calculation to make the code more DRY\n if @population_density < 50\n number_of_deaths = (@population * 0.05).floor\n else\n number_of_deaths = (@population *(@population_density/50 * 0.1)).floor\n end\n\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\n\n # Original method \n # if @population_density >= 200\n # number_of_deaths = (@population * 0.4).floor\n # elsif @population_density >= 150\n # number_of_deaths = (@population * 0.3).floor\n # elsif @population_density >= 100\n # number_of_deaths = (@population * 0.2).floor\n # elsif @population_density >= 50\n # number_of_deaths = (@population * 0.1).floor\n # else\n # number_of_deaths = (@population * 0.05).floor\n # end\n\n end", "def predicted_deaths(population_density, population, state)\n \n number_of_deaths = (@population * 0.05).floor if @population_density < 50\n number_of_deaths = (@population * 0.1).floor if @population_density >= 50\n number_of_deaths = (@population * 0.2).floor if @population_density >= 100\n number_of_deaths = (@population * 0.3).floor if @population_density >= 150\n number_of_deaths = (@population * 0.4).floor if @population_density >= 200\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\n\n end", "def predicted_deaths\n \n # predicted deaths is solely based on population density \n \n death_rate = (@population_density / 500).round(1) \n death_rate = 0.4 if @population_density >= 250\n death_rate = 0.1 if @population_density < 50\n \n (@population * death_rate).floor\n\n end", "def predicted_deaths(population_density, population)\n # predicted deaths is solely based on population density\n\n n = [50, 100, 150, 200]\n \n if @population_density >= n[3]\n coefficient = n[3]/500.0\n elsif @population_density >= n[2]\n coefficient = n[2]/500.0\n elsif @population_density >= n[1]\n coefficient = n[1]/500.0\n elsif @population_density >= n[0]\n coefficient = n[0]/500.0\n else\n coefficient = 0.05\n end\n \n number_of_deaths = (@population * coefficient).floor\n end", "def predicted_deaths\n\n # predicted deaths is solely based on population density\n\n # Write a method that takes population_density and based on that number, provides a different output for each grade\n\n if @population_density >= 200\n number_of_deaths = (@population * 0.4).floor\n elsif @population_density >= 150\n number_of_deaths = (@population * 0.3).floor\n elsif @population_density >= 100\n number_of_deaths = (@population * 0.2).floor\n elsif @population_density >= 50\n number_of_deaths = (@population * 0.1).floor\n else\n number_of_deaths = (@population * 0.05).floor\n end\n\n end", "def predicted_deaths(population_density, population)\n # predicted deaths is solely based on population density\n if @population_density >= 200\n number_of_deaths = (@population * 0.4).floor\n elsif @population_density >= 150\n number_of_deaths = (@population * 0.3).floor\n elsif @population_density >= 100\n number_of_deaths = (@population * 0.2).floor\n elsif @population_density >= 50\n number_of_deaths = (@population * 0.1).floor\n else\n number_of_deaths = (@population * 0.05).floor\n end\n\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\n\n end", "def predicted_deaths(population_density, population)\n # predicted deaths is solely based on population density\n if @population_density >= 200\n number_of_deaths = (@population * 0.4).floor\n elsif @population_density >= 150\n number_of_deaths = (@population * 0.3).floor\n elsif @population_density >= 100\n number_of_deaths = (@population * 0.2).floor\n elsif @population_density >= 50\n number_of_deaths = (@population * 0.1).floor\n else\n number_of_deaths = (@population * 0.05).floor\n end\n\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\n\n end", "def predicted_deaths(population_density, population)\n # predicted deaths is solely based on population density\n case @population_density\n when 200..Float::INFINITY\n rate = 0.4\n when 150..199\n rate = 0.3\n when 100..149\n rate = 0.2\n when 50..99\n rate = 0.1\n else rate = 0.05\n end\n\n number_of_deaths = (@population * rate).floor\n\n number_of_deaths\n\n end", "def predicted_deaths #(population_density, population, state)\n # predicted deaths is solely based on population density\n if @population_density >= 200\n number_of_deaths = (@population * 0.4).floor\n elsif @population_density >= 150\n number_of_deaths = (@population * 0.3).floor\n elsif @population_density >= 100\n number_of_deaths = (@population * 0.2).floor\n elsif @population_density >= 50\n number_of_deaths = (@population * 0.1).floor\n else\n number_of_deaths = (@population * 0.05).floor\n end\n\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\n\n end", "def predicted_deaths(population_density, population, state)\n if @population_density < 50\n number_of_deaths = (@population * 0.05).floor\n else\n number_of_deaths = (@population_density * (0.1 * (@population / 50)) ).floor\n end\n\n # if @population_density >= 200\n # number_of_deaths = (@population * 0.4).floor\n # elsif @population_density >= 150\n # number_of_deaths = (@population * 0.3).floor\n # elsif @population_density >= 100\n # number_of_deaths = (@population * 0.2).floor\n # elsif @population_density >= 50\n # number_of_deaths = (@population * 0.1).floor\n # else \n # number_of_deaths = (@population * 0.05).floor\n # end\n\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\n\n end", "def predicted_deaths #(population_density, population, state)\r\n # predicted deaths is solely based on population density\r\n # case @population_density\r\n # \twhen @population_density >= 200 then number_of_deaths = (@population * 0.4).floor\r\n # \twhen @population_density >= 150 then number_of_deaths = (@population * 0.3).floor\r\n # end\r\n \r\n if @population_density >= 200\r\n number_of_deaths = (@population * 0.4).floor\r\n elsif @population_density >= 150\r\n number_of_deaths = (@population * 0.3).floor\r\n elsif @population_density >= 100\r\n number_of_deaths = (@population * 0.2).floor\r\n elsif @population_density >= 50\r\n number_of_deaths = (@population * 0.1).floor\r\n else\r\n number_of_deaths = (@population * 0.05).floor\r\n end\r\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\r\n end", "def predicted_deaths #(population_density, population, state)\n # predicted deaths is solely based on population density\n\n # perhaps a case statement is a little more dry?\n case\n when @population_density >= 200 then number_of_deaths = (@population * 0.4).floor\n when @population_density >= 150 then number_of_deaths = (@population * 0.3).floor\n when @population_density >= 100 then number_of_deaths = (@population * 0.2).floor\n when @population_density >= 50 then number_of_deaths = (@population * 0.1).floor\n when @population_density < 50 then number_of_deaths = (@population * 0.05).floor\n end\n\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\n\n end", "def predicted_deaths(population_density, population, state)\n if @population_density >= 200\n number_of_deaths = (@population * 0.4).floor\n elsif @population_density >= 150\n number_of_deaths = (@population * 0.3).floor\n elsif @population_density >= 100\n number_of_deaths = (@population * 0.2).floor\n elsif @population_density >= 50\n number_of_deaths = (@population * 0.1).floor\n else \n number_of_deaths = (@population * 0.05).floor\n end\n\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\n\n end", "def predicted_deaths(population_density, population, state)\n if @population_density >= 200\n number_of_deaths = (@population * 0.4).floor\n elsif @population_density >= 150\n number_of_deaths = (@population * 0.3).floor\n elsif @population_density >= 100\n number_of_deaths = (@population * 0.2).floor\n elsif @population_density >= 50\n number_of_deaths = (@population * 0.1).floor\n else \n number_of_deaths = (@population * 0.05).floor\n end\n\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\n\n end", "def predicted_deaths(population_density, population, state)\n if @population_density >= 200\n number_of_deaths = (@population * 0.4).floor\n elsif @population_density >= 150\n number_of_deaths = (@population * 0.3).floor\n elsif @population_density >= 100\n number_of_deaths = (@population * 0.2).floor\n elsif @population_density >= 50\n number_of_deaths = (@population * 0.1).floor\n else \n number_of_deaths = (@population * 0.05).floor\n end\n\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\n\n end", "def predicted_deaths(population_density, population, state)\n if @population_density >= 200\n number_of_deaths = (@population * 0.4).floor\n elsif @population_density >= 150\n number_of_deaths = (@population * 0.3).floor\n elsif @population_density >= 100\n number_of_deaths = (@population * 0.2).floor\n elsif @population_density >= 50\n number_of_deaths = (@population * 0.1).floor\n else \n number_of_deaths = (@population * 0.05).floor\n end\n\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\n\n end", "def predicted_deaths(population_density, population, state)\n if @population_density >= 200\n number_of_deaths = (@population * 0.4).floor\n elsif @population_density >= 150\n number_of_deaths = (@population * 0.3).floor\n elsif @population_density >= 100\n number_of_deaths = (@population * 0.2).floor\n elsif @population_density >= 50\n number_of_deaths = (@population * 0.1).floor\n else \n number_of_deaths = (@population * 0.05).floor\n end\n\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\n\n end", "def predicted_deaths(population_density, population, state)\n if @population_density >= 200\n number_of_deaths = (@population * 0.4).floor\n elsif @population_density >= 150\n number_of_deaths = (@population * 0.3).floor\n elsif @population_density >= 100\n number_of_deaths = (@population * 0.2).floor\n elsif @population_density >= 50\n number_of_deaths = (@population * 0.1).floor\n else \n number_of_deaths = (@population * 0.05).floor\n end\n\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\n\n end", "def predicted_deaths(population_density)\n # predicted deaths is solely based on population density\n \n pop = @population_density\n case pop \n when pop >= 200 \n number_of_deaths = (@population * 0.4).floor\n when pop >= 150 \n number_of_deaths = (@population * 0.3).floor\n when pop >= 100 \n number_of_deaths = (@population * 0.2).floor\n when pop >= 50 \n number_of_deaths = (@population * 0.1).floor \n else \n number_of_deaths = (@population * 0.05).floor\n end\n\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\n\n end", "def predicted_deaths\n # predicted deaths is solely based on population density\n \n # if @population_density >= 50 \n # number_of_deaths = (@population / 500).floor\n # else\n # number_of_deaths = (@population * 0.05).floor\n # end\n \n if @population_density >= 200\n (@population * 0.4).floor\n elsif @population_density >= 150\n (@population * 0.3).floor\n elsif @population_density >= 100\n (@population * 0.2).floor\n elsif @population_density >= 50\n (@population * 0.1).floor\n else\n (@population * 0.05).floor\n end\n\n end", "def predicted_deaths #(population_density, population, state)\n # predicted deaths is solely based on population density\n ## Refactored for Release: 8\n if @population_density >= 200\n (@population * 0.4).floor\n elsif @population_density >= 150\n (@population * 0.3).floor\n elsif @population_density >= 100\n (@population * 0.2).floor\n elsif @population_density >= 50\n (@population * 0.1).floor\n else\n (@population * 0.05).floor\n end\n\n # print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\n\n end", "def predicted_deaths #(population_density, population, state)\n # predicted deaths is solely based on population density\n case when @population_density >= 200\n number_of_deaths = (@population * 0.4).floor\n when @population_density >= 150\n number_of_deaths = (@population * 0.3).floor\n when @population_density >= 100\n number_of_deaths = (@population * 0.2).floor\n when @population_density >= 50\n number_of_deaths = (@population * 0.1).floor\n when\n number_of_deaths = (@population * 0.05).floor\n end\n\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\n\n end", "def predicted_deaths(population_density, population, state)\n if @population_density >= 200\n number_of_deaths = (@population * 0.4).floor\n elsif @population_density >= 150\n number_of_deaths = (@population * 0.3).floor\n elsif @population_density >= 100\n number_of_deaths = (@population * 0.2).floor\n elsif @population_density >= 50\n number_of_deaths = (@population * 0.1).floor\n else \n number_of_deaths = (@population * 0.05).floor\n end\n\n\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\n\n end", "def predicted_deaths(population_density, population, state)\n if population_density >= 200 # predicted_deaths passes in the population density and population and uses a ratio to determine the number effected by the virus\n number_of_deaths = (population * 0.4).floor\n elsif population_density >= 150\n number_of_deaths = (population * 0.3).floor\n elsif population_density >= 100\n number_of_deaths = (population * 0.2).floor\n elsif population_density >= 50\n number_of_deaths = (population * 0.1).floor\n else \n number_of_deaths = (population * 0.05).floor\n end\n\n print \"#{state} will lose #{number_of_deaths} people in this outbreak\"\n\n end", "def predicted_deaths()\n # predicted deaths is solely based on population density\n if @population_density >= 200\n number_of_deaths = (@population * 0.4)\n elsif @population_density >= 150\n number_of_deaths = (@population * 0.3)\n elsif @population_density >= 100\n number_of_deaths = (@population * 0.2)\n elsif @population_density >= 50\n number_of_deaths = (@population * 0.1)\n else\n number_of_deaths = (@population * 0.05)\n end\n\n end", "def predicted_deaths#(population_density, population, state)\n # predicted deaths is solely based on population density\n if @population_density >= 200\n number_of_deaths = (@population * 0.4).floor\n elsif @population_density >= 150\n number_of_deaths = (@population * 0.3).floor\n elsif @population_density >= 100\n number_of_deaths = (@population * 0.2).floor\n elsif @population_density >= 50\n number_of_deaths = (@population * 0.1).floor\n else\n number_of_deaths = (@population * 0.05).floor\n end\n\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\n\n end", "def predicted_deaths\n # predicted deaths is solely based on population density\n if @population_density >= 200\n number_of_deaths = (@population * 0.4).floor\n elsif @population_density <= 50\n number_of_deaths = (@population * 0.05).floor\n else\n multipler_var = (@population_density / 50) * 0.1\n number_of_deaths = (@population * multipler_var).floor\n end\n end", "def predicted_deaths(population_density, population, state)\n # predicted deaths is solely based on population density\n if @population_density >= 200\n number_of_deaths = (@population * 0.4).floor\n elsif @population_density >= 150\n number_of_deaths = (@population * 0.3).floor\n elsif @population_density >= 100\n number_of_deaths = (@population * 0.2).floor\n elsif @population_density >= 50\n number_of_deaths = (@population * 0.1).floor\n else\n number_of_deaths = (@population * 0.05).floor\n end\n\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\n\n end", "def predicted_deaths(population_density, population, state)\n # predicted deaths is solely based on population density\n if @population_density >= 200\n number_of_deaths = (@population * 0.4).floor\n elsif @population_density >= 150\n number_of_deaths = (@population * 0.3).floor\n elsif @population_density >= 100\n number_of_deaths = (@population * 0.2).floor\n elsif @population_density >= 50\n number_of_deaths = (@population * 0.1).floor\n else\n number_of_deaths = (@population * 0.05).floor\n end\n\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\n\n end", "def predicted_deaths(population_density, population, state)\n # predicted deaths is solely based on population density\n if @population_density >= 200\n number_of_deaths = (@population * 0.4).floor\n elsif @population_density >= 150\n number_of_deaths = (@population * 0.3).floor\n elsif @population_density >= 100\n number_of_deaths = (@population * 0.2).floor\n elsif @population_density >= 50\n number_of_deaths = (@population * 0.1).floor\n else\n number_of_deaths = (@population * 0.05).floor\n end\n\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\n\n end", "def predicted_deaths(population_density, population, state)\n # predicted deaths is solely based on population density\n if @population_density >= 200\n number_of_deaths = (@population * 0.4).floor\n elsif @population_density >= 150\n number_of_deaths = (@population * 0.3).floor\n elsif @population_density >= 100\n number_of_deaths = (@population * 0.2).floor\n elsif @population_density >= 50\n number_of_deaths = (@population * 0.1).floor\n else\n number_of_deaths = (@population * 0.05).floor\n end\n\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\n\n end", "def predicted_deaths(population_density, population, state)\n # predicted deaths is solely based on population density\n if @population_density >= 200\n number_of_deaths = (@population * 0.4).floor\n elsif @population_density >= 150\n number_of_deaths = (@population * 0.3).floor\n elsif @population_density >= 100\n number_of_deaths = (@population * 0.2).floor\n elsif @population_density >= 50\n number_of_deaths = (@population * 0.1).floor\n else\n number_of_deaths = (@population * 0.05).floor\n end\n\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\n\n end", "def predicted_deaths\r\n # predicted deaths is solely based on population density\r\n if @population_density >= 200\r\n (@population * 0.4).floor\r\n elsif @population_density >= 150\r\n (@population * 0.3).floor\r\n elsif @population_density >= 100\r\n (@population * 0.2).floor\r\n elsif @population_density >= 50\r\n (@population * 0.1).floor\r\n else\r\n (@population * 0.05).floor\r\n end\r\n\r\n \r\n\r\n end", "def predicted_deaths\n # predicted deaths is solely based on population density\n \n if @population_density >= 200\n (0.4*@population).floor\n elsif @population_density >= 150\n (0.3*@population).floor\n elsif @population_density >= 100\n (0.2*@population).floor\n elsif @population_density >= 50\n (0.1*@population).floor\n else\n (0.05*@population).floor\n end\n\n\n end", "def predicted_deaths\n \n # predicted deaths is based on population density\n if @population_density >= 200\n factor = 0.4\n elsif @population_density >= 150\n factor = 0.3\n elsif @population_density >= 100\n factor = 0.2\n elsif @population_density >= 50\n factor = 0.1\n else\n factor = 0.05\n end\n\n @number_of_deaths = (@population * factor).floor\n\n end", "def predicted_deaths\n # predicted deaths is solely based on population density\n if @population_density >= 200\n @number_of_deaths = (@population * 0.4).floor\n elsif @population_density >= 150\n @number_of_deaths = (@population * 0.3).floor\n elsif @population_density >= 100\n @number_of_deaths = (@population * 0.2).floor\n elsif @population_density >= 50\n @number_of_deaths = (@population * 0.1).floor\n else\n @number_of_deaths = (@population * 0.05).floor\n end\n end", "def predicted_deaths(state_density, population)\n # predicted deaths is solely based on population density\n number_of_deaths = ''\n hash = {200 => 0.4, 150 => 0.3, 100 => 0.2, 50 => 0.1}\n\n hash.each do |density, float|\n if @population_density >= density\n number_of_deaths = (@population * float).floor\n else\n number_of_deaths = (@population * 0.05).floor\n end\n number_of_deaths\n end\n\n # if @population_density >= 200\n # number_of_deaths = (@population * 0.4).floor\n # elsif @population_density >= 150\n # number_of_deaths = (@population * 0.3).floor\n # elsif @population_density >= 100\n # number_of_deaths = (@population * 0.2).floor\n # elsif @population_density >= 50\n # number_of_deaths = (@population * 0.1).floor\n # else\n # number_of_deaths = (@population * 0.05).floor\n # end\n\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\n\n end", "def predicted_deaths\n # predicted deaths is solely based on population density\n if @population_density >= 200\n @population * 0.4\n elsif @population_density >= 150\n @population * 0.3\n elsif @population_density >= 100\n @population * 0.2\n elsif @population_density >= 50\n @population * 0.1\n else\n @population * 0.05\n end\n end", "def predicted_deaths\n # predicted deaths is solely based on population density\n if @population_density >= 200\n number_of_deaths = (@population * 0.4).floor\n elsif @population_density >= 150\n number_of_deaths = (@population * 0.3).floor\n elsif @population_density >= 100\n number_of_deaths = (@population * 0.2).floor\n elsif @population_density >= 50\n number_of_deaths = (@population * 0.1).floor\n else\n number_of_deaths = (@population * 0.05).floor\n end\n\n end", "def predicted_deaths\r\n # predicted deaths is solely based on population density\r\n\r\n densities = {0 => 0.05, 50 => 0.1, 100 => 0.2, 150 => 0.3, 200 => 0.4}\r\n\r\n densities.each do |density, ratio|\r\n if @population_density >= density\r\n @number_of_deaths = (@population * ratio).floor\r\n end\r\n end\r\n\r\n=begin - refactored\r\n if @population_density >= 200\r\n number_of_deaths = (@population * 0.4).floor\r\n elsif @population_density >= 150\r\n number_of_deaths = (@population * 0.3).floor\r\n elsif @population_density >= 100\r\n number_of_deaths = (@population * 0.2).floor\r\n elsif @population_density >= 50\r\n number_of_deaths = (@population * 0.1).floor\r\n else\r\n number_of_deaths = (@population * 0.05).floor\r\n end\r\n=end\r\n\r\n print \"#{@state} will lose #{@number_of_deaths} people in this outbreak\"\r\n\r\n end", "def predicted_deaths#(population_density, population, state)\n # predicted deaths is solely based on population density\n # if population_density >= 200\n # number_of_deaths = (population * 0.4).floor\n # elsif population_density >= 150\n # number_of_deaths = (population * 0.3).floor\n # elsif population_density >= 100\n # number_of_deaths = (population * 0.2).floor\n # elsif population_density >= 50\n # number_of_deaths = (population * 0.1).floor\n # else\n # number_of_deaths = (population * 0.05).floor\n # end\n pop_percentage = 0.0\n density_test = 50\n if population_density >= 50\n while population_density >= density_test do \n pop_percentage += 0.1\n density_test += 50\n end\n number_of_deaths = (population * pop_percentage).floor\n else\n number_of_deaths = (population * 0.05).floor\n end\n print \"#{state} will lose #{number_of_deaths} people in this outbreak\"\n end", "def predicted_deaths\n # predicted deaths is solely based on population density\n death_multiplier = {0 => 0.05, 50 => 0.1, 100 => 0.2, 150 => 0.3, 200 => 0.4}\n death_multiplier.each do |density, multiplier|\n if @population_density >= density\n @number_of_deaths = (@population * multiplier).floor\n end\n \n end\n # if @population_density >= 200\n # number_of_deaths = (@population * 0.4).floor\n # elsif @population_density >= 150\n # number_of_deaths = (@population * 0.3).floor\n # elsif @population_density >= 100\n # number_of_deaths = (@population * 0.2).floor\n # elsif @population_density >= 50\n # number_of_deaths = (@population * 0.1).floor\n # else\n # number_of_deaths = (@population * 0.05).floor\n # end\n print \"#{@state} will lose #{@number_of_deaths} people in this outbreak\"\n end", "def predicted_deaths\r\n # predicted deaths is solely based on population density\r\n if @population_density >= 200\r\n @number_of_deaths = (@population * 0.4).floor\r\n elsif @population_density >= 150\r\n @number_of_deaths = (@population * 0.3).floor\r\n elsif @population_density >= 100\r\n @number_of_deaths = (@population * 0.2).floor\r\n elsif @population_density >= 50\r\n @number_of_deaths = (@population * 0.1).floor\r\n else\r\n @number_of_deaths = (@population * 0.05).floor\r\n end\r\n end", "def predicted_deaths#(population_density, population, state)\n # predicted deaths is solely based on population density\n if @population_density >= 200\n number_of_deaths = death_percentage(0.4)\n elsif @population_density >= 150\n number_of_deaths = death_percentage(0.3)\n elsif @population_density >= 100\n number_of_deaths = death_percentage(0.2)\n elsif @population_density >= 50\n number_of_deaths = death_percentage(0.1)\n else\n number_of_deaths = death_percentage(0.05)\n end\n\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\n\n end", "def predicted_deaths()\n # predicted deaths is solely based on population density\n case @population_density\n when 200..1000\n @number_of_deaths = (@population * 0.4).floor\n when 150...200\n @number_of_deaths = (@population * 0.3).floor\n when 100...150\n @number_of_deaths = (@population * 0.2).floor\n when 50...100\n @number_of_deaths = (@population * 0.1).floor\n else\n @number_of_deaths = (@population * 0.05).floor\n end\n end", "def predicted_deaths\n case @population_density\n when 0..50 then (@population * 0.05).floor\n when 51..100 then (@population * 0.1).floor\n when 101..150 then (@population * 0.2).floor\n when 151..200 then (@population * 0.3).floor\n else (@population * 0.4).floor\n end\n end", "def predicted_deaths\n # predicted deaths is solely based on population density\n if @population_density >= 200\n number_of_deaths = (@population * 0.4).floor\n elsif @population_density >= 150\n number_of_deaths = (@population * 0.3).floor\n elsif @population_density >= 100\n number_of_deaths = (@population * 0.2).floor\n elsif @population_density >= 50\n number_of_deaths = (@population * 0.1).floor\n else\n number_of_deaths = (@population * 0.05).floor\n end\n end", "def predicted_deaths\n # predicted deaths is solely based on population density\n if @population_density >= 200\n number_of_deaths = (@population * 0.4).floor\n elsif @population_density >= 150\n number_of_deaths = (@population * 0.3).floor\n elsif @population_density >= 100\n number_of_deaths = (@population * 0.2).floor\n elsif @population_density >= 50\n number_of_deaths = (@population * 0.1).floor\n else\n number_of_deaths = (@population * 0.05).floor\n end\n end", "def predicted_deaths#(population_density, population, state)\n # predicted deaths is solely based on population density\n factor = case population_density\n when 0...50 then 0.05\n when 50...100 then 0.1\n when 100...150 then 0.2\n when 150...200 then 0.3\n else 0.4 \n end\n number_of_deaths = (population * factor).floor\n\n print \"#{state} will lose #{number_of_deaths} people in this outbreak\"\n\n end", "def predicted_deaths(population_density, population, state)\n # predicted deaths is solely based on population density\n if population_density >= 200\n number_of_deaths = (population * 0.4).floor\n elsif population_density >= 150\n number_of_deaths = (population * 0.3).floor\n elsif population_density >= 100\n number_of_deaths = (population * 0.2).floor\n elsif population_density >= 50\n number_of_deaths = (population * 0.1).floor\n else\n number_of_deaths = (population * 0.05).floor\n end\n\n print \"#{state} will lose #{number_of_deaths} people in this outbreak\"\n\n end", "def predicted_deaths(population_density, population, state)\n # predicted deaths is solely based on population density\n if population_density >= 200\n number_of_deaths = (population * 0.4).floor\n elsif population_density >= 150\n number_of_deaths = (population * 0.3).floor\n elsif population_density >= 100\n number_of_deaths = (population * 0.2).floor\n elsif population_density >= 50\n number_of_deaths = (population * 0.1).floor\n else\n number_of_deaths = (population * 0.05).floor\n end\n\n print \"#{state} will lose #{number_of_deaths} people in this outbreak\"\n\n end", "def predicted_deaths\n # predicted deaths is solely based on population density\n if @population_density >= 200\n multiplier = 0.4\n elsif @population_density >= 150\n multiplier = 0.3\n elsif @population_density >= 100\n multiplier = 0.2\n elsif @population_density >= 50\n multiplier = 0.1\n else\n multiplier = 0.05\n end\n (@population * multiplier).floor\n end", "def predicted_deaths(population_density, population, state)\n case \n when @population_density >= 200 then number_of_deaths = (@population * 0.4).floor\n when @population_density >= 150 then number_of_deaths = (@population * 0.3).floor\n when @population_density >= 100 then number_of_deaths = (@population * 0.2).floor\n when @population_density >= 50 then number_of_deaths = (@population * 0.1).floor\n else\n number_of_deaths = (@population * 0.05).floor\n end\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\n end", "def predicted_deaths\r\n # predicted deaths is solely based on population density \r\n\r\n # multiplier when population density is less than 50\r\n multiplier = 0.05\r\n\r\n # sets new population density variable to have a mximum of 200\r\n max_pop = 200\r\n population_density_temp = [@population_density, max_pop].min\r\n \r\n multiplier = 0.1 * (population_density_temp / 50).floor if population_density_temp >= 50\r\n\r\n number_of_deaths = (@population * multiplier).floor\r\n\r\n\r\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\r\n\r\n end", "def predicted_deaths#(population_density, population, state)\n # predicted deaths is solely based on population density\n\n x = 1\n\n number_of_deaths = (@population * x).floor\n case @population_density\n\n when (150...200)\n x = 0.3\n when (100...150)\n x = 0.2\n when (50...100)\n x = 0.1\n when (0...50)\n x= 0.05\n else\n x = 0.4\n end\n\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\n\n end", "def predicted_deaths #(population_density, population, state)\n # How are arguements initialized inside a method?\n # => As local variables.\n \n # population NOT @population\n \n # predicted deaths is solely based on population density\n if @population_density >= 200\n @number_of_deaths = (@population * 0.4).floor\n elsif @population_density >= 150\n @number_of_deaths = (@population * 0.3).floor\n elsif @population_density >= 100\n @number_of_deaths = (@population * 0.2).floor\n elsif @population_density >= 50\n @number_of_deaths = (@population * 0.1).floor\n else\n @number_of_deaths = (@population * 0.05).floor\n end\n end", "def predicted_deaths(@population_density, @population, @state)\n # predicted deaths is solely based on population density\n if @population_density >= 200\n number_of_deaths = (@population * 0.4).floor\n elsif @population_density >= 150\n number_of_deaths = (@population * 0.3).floor\n elsif @population_density >= 100\n number_of_deaths = (@population * 0.2).floor\n elsif @population_density >= 50\n number_of_deaths = (@population * 0.1).floor\n else\n number_of_deaths = (@population * 0.05).floor\n end\n\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\n\n end", "def predicted_deaths\n # predicted deaths is solely based on population density\n case @population_density\n when 0..50 then (@population * 0.05).floor\n when 51..100 then (@population * 0.1).floor\n when 101..150 then (@population * 0.2).floor\n when 151..200 then (@population * 0.3).floor\n else (@population * 0.4).floor\n end\n\n end", "def predicted_deaths\n # predicted deaths is solely based on population density\n if @population_density >= 200\n rate = 0.4\n elsif @population_density >= 150\n rate = 0.3\n elsif @population_density >= 100\n rate = 0.2\n elsif @population_density >= 50\n rate = 0.1\n else\n rate = 0.05\n end\n \n @number_of_deaths = (@population * rate).floor\n\n \n\n end", "def predicted_deaths(population_density, population, state)\n case\n when @population_density >= 200 then number_of_deaths = (@population * 0.4).floor\n when @population_density >= 150 then number_of_deaths = (@population * 0.3).floor\n when @population_density >= 100 then number_of_deaths = (@population * 0.2).floor\n when @population_density >= 50 then number_of_deaths = (@population * 0.1).floor\n else (@population * 0.05).floor\n end\n\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\n\n end", "def predicted_deaths\n # predicted deaths is solely based on population density\n \n density = [200, 150, 100, 50, 0]\n multiplier = [0.4, 0.3, 0.2, 0.1, 0.05]\n density.length.times do |x|\n @population_density >= density[x]\n @number_of_deaths = (@population * multiplier[x]).floor \n end\n# if @population_density >= 200\n# number_of_deaths = (@population * 0.4).floor\n# elsif @population_density >= 150\n# number_of_deaths = (@population * 0.3).floor\n# elsif @population_density >= 100\n# number_of_deaths = (@population * 0.2).floor\n# elsif @population_density >= 50\n# number_of_deaths = (@population * 0.1).floor\n# else\n# number_of_deaths = (@population * 0.05).floor\n# end\n\n print \"#{@state} will lose #{@number_of_deaths} people in this outbreak\"\n\n end", "def predicted_deaths\n # predicted deaths is solely based on population density\n @number_of_deaths = (@population * factor).floor\n if @population_density >= 200\n factor = 0.4\n elsif @population_density >= 150\n factor = 0.3\n elsif @population_density >= 100\n factor = 0.2\n elsif @population_density >= 50\n factor = 0.1\n else\n factor = 0.05\n end\n end", "def predicted_deaths(population_density, population, state)\n # predicted deaths is solely based on population density\n speed = 0.0\n if @population_density >= 200\n number_of_deaths = (@population * 0.4).floor\n speed += 0.5\n elsif @population_density >= 150\n number_of_deaths = (@population * 0.3).floor\n speed += 1\n elsif @population_density >= 100\n number_of_deaths = (@population * 0.2).floor\n speed += 1.5\n elsif @population_density >= 50\n number_of_deaths = (@population * 0.1).floor\n speed += 2.0\n else\n number_of_deaths = (@population * 0.05).floor\n speed += 2.5\n end\n\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak and will spread across the state in #{speed} months.\\n\\n\"\n #puts \" and will spread across the state in #{speed} months.\\n\\n\"\n\n end", "def predicted_deaths #(population_density, population, state)\n \n # How are arguements initialized inside a method?\n # - As local variables.\n \n \n # predicted deaths is solely based on population density\n if @population_density >= 200\n number_of_deaths = (@population * 0.4).floor #.floor is to always round down the number\n elsif @population_density >= 150\n number_of_deaths = (@population * 0.3).floor\n elsif @population_density >= 100\n number_of_deaths = (@population * 0.2).floor\n elsif @population_density >= 50\n number_of_deaths = (@population * 0.1).floor\n else\n number_of_deaths = (@population * 0.05).floor\n end\n\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\n\n end", "def predicted_deaths\r\n # predicted deaths is solely based on population density\r\n number_of_deaths=0\r\n density=[200,150,100,50,0]\r\n death_percentage=[0.4, 0.3, 0.2, 0.1, 0.05]\r\n\r\n density.each_index do |index|\r\n if @population_density >= density[index]\r\n number_of_deaths = (@population * death_percentage[index]).floor\r\n break\r\n end\r\n end\r\n=begin\r\n if @population_density >= 200\r\n number_of_deaths = (@population * 0.4).floor\r\n elsif @population_density >= 150\r\n number_of_deaths = (@population * 0.3).floor\r\n elsif @population_density >= 100\r\n number_of_deaths = (@population * 0.2).floor\r\n elsif @population_density >= 50\r\n number_of_deaths = (@population * 0.1).floor\r\n else\r\n number_of_deaths = (@population * 0.05).floor\r\n end\r\n=end\r\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\r\n\r\n end", "def predicted_deaths\n # predicted deaths is solely based on population density\n \n\n\n\n\n if @population_density >= 200\n number_of_deaths = (@population * 0.4).floor\n elsif @population_density >= 150\n number_of_deaths = (@population * 0.3).floor\n elsif @population_density >= 100\n number_of_deaths = (@population * 0.2).floor\n elsif @population_density >= 50\n number_of_deaths = (@population * 0.1).floor\n else\n number_of_deaths = (@population * 0.05).floor\n end\n\n\n\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\n\n end", "def predicted_deaths\n case @population_density\n # predicted deaths is solely based on population density\n when @population_density >= 200\n number_of_deaths = (@population * 0.4).floor\n when @population_density >= 150\n number_of_deaths = (@population * 0.3).floor\n when @population_density >= 100\n number_of_deaths = (@population * 0.2).floor\n when @population_density >= 50\n number_of_deaths = (@population * 0.1).floor\n else\n number_of_deaths = (@population * 0.05).floor\n end\n\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\n\n end", "def predicted_deaths #(population_density, population, state)\n # predicted deaths is solely based on population density\n # if @population_density >= 200\n # number_of_deaths = (@population * 0.4).floor\n # elsif @population_density >= 150\n # number_of_deaths = (@population * 0.3).floor\n # elsif @population_density >= 100\n # number_of_deaths = (@population * 0.2).floor\n # elsif @population_density >= 50\n # number_of_deaths = (@population * 0.1).floor\n # else\n # number_of_deaths = (@population * 0.05).floor\n # end\n\n # print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\n pdeathshash1 = {0..49 => (@population * 0.05).floor, 50..99 => (@population * 0.1).floor, 100..149 => (@population * 0.2).floor, 150..199 => (@population * 0.3).floor, 200..10000000 => (@population * 0.04).floor}\n pdeathshash1.each do |range, deaths|\n if (range).include?(@population_density.floor)\n print \"#{@state} will lose #{deaths} people in this outbreak\"\n end\n end\n\n\n end", "def predicted_deaths\n # predicted deaths is solely based on population density\n\n if @population_density >= 200\n death_rate = 0.4\n elsif @population_density >= 150\n death_rate = 0.3\n elsif @population_density >= 100\n death_rate = 0.2\n elsif @population_density >= 50\n death_rate = 0.1\n else\n death_rate = 0.05\n end\n \n (@population * death_rate).floor\n\n end", "def predicted_deaths(population_density, population, state)\n # predicted deaths is solely based on population density\n speed = 0\n if @population_density >= 200\n number_of_deaths = (@population * 0.4).floor\n speed += 0.5\n elsif @population_density >= 150\n number_of_deaths = (@population * 0.3).floor\n speed += 1\n elsif @population_density >= 100\n number_of_deaths = (@population * 0.2).floor\n speed += 1.5\n elsif @population_density >= 50\n number_of_deaths = (@population * 0.1).floor\n speed += 2\n else\n number_of_deaths = (@population * 0.05).floor\n speed += 2.5\n end\n\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\n\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n\n end", "def predicted_deaths #(population_density, population, state)\n # predicted deaths is solely based on population density\n if @population_density >= 200\n @number_of_deaths = (@population * 0.4).floor\n elsif @population_density >= 150\n @number_of_deaths = (@population * 0.3).floor\n elsif @population_density >= 100\n @number_of_deaths = (@population * 0.2).floor\n elsif @population_density >= 50\n @number_of_deaths = (@population * 0.1).floor\n else\n @number_of_deaths = (@population * 0.05).floor\n end\n \nend", "def predicted_deaths\n # predicted deaths is solely based on population density\n \n if @population_density >= 50\n multiplication_factor = (@population_density.fdiv(50)).floor.fdiv(10)\n # (density / 50), rounded down to int, then divided by 10\n # ex: 200 / 50 = 4, 4/10 = 0.4\n # ex: 185 / 50 = 3.7, rounded to 3, 3/10 = 0.3\n else # if population density < 50\n multiplication_factor = 0.05\n end\n \n \n \n number_of_deaths = (@population * multiplication_factor).floor\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\n\n end", "def predicted_deaths\n # predicted deaths is solely based on population density\n if @population_density >= 200; number_of_deaths = (@population * 0.4).floor\n elsif @population_density >= 150; number_of_deaths = (@population * 0.3).floor\n elsif @population_density >= 100; number_of_deaths = (@population * 0.2).floor\n elsif @population_density >= 50; number_of_deaths = (@population * 0.1).floor\n else number_of_deaths = (@population * 0.05).floor\n end\n end", "def predicted_deaths\r\n\r\n number_of_deaths = (population * 0.05).floor\r\n \r\n 4.times do |i|\r\n if population_density >= 50*(i+1)\r\n number_of_deaths = (population * 0.1*(i+1)).floor\r\n end\r\n end\r\n print \"#{state} will lose #{number_of_deaths} people in this outbreak\"\r\n\r\n end", "def predicted_deaths\n # predicted deaths is solely based on population density\n \n if @population_density >= 200\n rate = 0.4\n elsif @population_density >= 150\n rate = 0.3\n elsif @population_density >= 100\n rate = 0.2\n elsif @population_density >= 50\n rate = 0.1\n else\n rate = 0.05\n end\n\n (@population * rate).floor\n\n end", "def predicted_deaths\n # predicted deaths is solely based on population density\n #if @population_density >= 200\n # number_of_deaths = (@population * 0.4).floor\n #elsif @population_density >= 150\n # number_of_deaths = (@population * 0.3).floor\n #elsif @population_density >= 100\n # number_of_deaths = (@population * 0.2).floor\n #elsif @population_density >= 50\n # number_of_deaths = (@population * 0.1).floor\n #else\n # number_of_deaths = (@population * 0.05).floor\n #end\n if @population_density >= 50\n mult_factor = (@population_density.fdiv(50)).floor.fdiv(10)\n # pop_density / 50,(fdiv returns float which is more precise), floor it, then divide by 10\n # example: 200/50 = 4, 4/10 = 0.4\n # example: 100/50 = 2, 2/10 = 0.2\n else\n mult_factor = 0.05\n end\n\n number_of_deaths = (@population * mult_factor).floor\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\n end", "def predicted_deaths#(population_density, population, state)\n # predicted deaths is solely based on population density\n if @population_density >= 200\n number_of_deaths = (@population * 0.4).floor\n elsif @population_density >= 150\n number_of_deaths = (@population * 0.3).floor\n elsif @population_density >= 100\n number_of_deaths = (@population * 0.2).floor\n elsif @population_density >= 50\n number_of_deaths = (@population * 0.1).floor\n else\n number_of_deaths = (@population * 0.05).floor\n end\n\n#Attempting another solution:\n# if @population_density < 50\n# number_of_deaths = (@population * 0.05).floor\n# elsif @population_density > 200\n# number_of_deaths = (@population * 0.04).floor\n# else\n# multiplier = (@population_density/50 * 0.1)\n# number_of_deaths = (@population * multiplier).floor\n# end\n\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\n\n end", "def predicted_deaths \n case @population_density\n when (0..49)\n rate = 0.05\n when (50..99)\n rate = 0.1\n when (100..149)\n rate = 0.2\n when (150..199)\n rate = 0.3\n else #(200+)\n rate = 0.4\n end\n (@population * rate).floor\n end", "def predicted_deaths #(population_density, population, state)\r\n # predicted deaths is solely based on population density\r\n if @population_density >= 200\r\n num = 0.4\r\n elsif @population_density >= 150\r\n num = 0.3\r\n elsif @population_density >= 100\r\n num = 0.2\r\n elsif @population_density >= 50\r\n num = 0.1\r\n else\r\n num = 0.05\r\n end\r\nnumber_of_deaths = (@population * num).floor\r\n\r\n end", "def predicted_deaths\n \n \n # predicted deaths is solely based on population density\n \n # no variable stated since @population_density is already being evaluted\n case \n when @population_density >= 200 then number_of_deaths = (@population * 0.4).floor\n when @population_density >= 150 then number_of_deaths = (@population * 0.3).floor\n when @population_density >= 100 then number_of_deaths = (@population * 0.2).floor\n when @population_density >= 50 then number_of_deaths = (@population * 0.1).floor\n else number_of_deaths = (@population * 0.05).floor\n end\n\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\n\n end", "def death_factor \n\n if @population_density >= 200\n 0.4\n elsif @population_density >= 150\n 0.3\n elsif @population_density >= 100\n 0.2\n elsif @population_density >= 50\n 0.1\n else\n 0.05\n end\n end", "def predicted_deaths\n # predicted deaths is solely based on population density\n\n # number_of_deaths = (@population * (@population_density/500.0)).floor\n\n if @population_density >= 200\n number_of_deaths = (@population * 0.4).floor\n elsif @population_density >= 150\n number_of_deaths = (@population * 0.3).floor\n elsif @population_density >= 100\n number_of_deaths = (@population * 0.2).floor\n elsif @population_density >= 50\n number_of_deaths = (@population * 0.1).floor\n else\n number_of_deaths = (@population * 0.05).floor\n end\n\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\n\n end", "def predicted_deaths\n predicted deaths is solely based on population density\n if @population_density >= 200\n number_of_deaths = (@population * 0.4).floor\n elsif @population_density >= 150\n number_of_deaths = (@population * 0.3).floor\n elsif @population_density >= 100\n number_of_deaths = (@population * 0.2).floor\n elsif @population_density >= 50\n number_of_deaths = (@population * 0.1).floor\n else\n number_of_deaths = (@population * 0.05).floor\n\n# maybe need to find a way to write an algorithm that factors population density in number ranges\n\n # if @population_density >= 150\n # number_of_deaths = (@population * 0.3).floor\n # elsif @population_density >= 50\n # number_of_deaths = (@population * 0.2).floor\n # else\n # number_of_deaths = (@population * 0.05).floor\n\n end\n\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\n\n end", "def predicted_deaths\n # (population_density, population, state)\n # predicted deaths is solely based on population density\n if @population_density >= 200\n number_of_deaths = (@population * 0.4).floor\n elsif @population_density >= 150\n number_of_deaths = (@population * 0.3).floor\n elsif @population_density >= 100\n number_of_deaths = (@population * 0.2).floor\n elsif @population_density >= 50\n number_of_deaths = (@population * 0.1).floor\n else\n number_of_deaths = (@population * 0.05).floor\n end\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\n #.floor => returns the largest integer less than or equal to float (rounds down to nearest integer)\n end", "def predicted_deaths\r\n # predicted deaths is solely based on population density\r\n \r\n \r\n\r\n if @population_density >= 200\r\n x = 0.4\r\n\r\n elsif @population_density >= 150\r\n x = 0.3\r\n elsif @population_density >= 100\r\n x = 0.2\r\n\r\n elsif @population_density >= 50\r\n x = 0.1\r\n\r\n else\r\n x = 0.05\r\n end\r\n number_of_deaths = (@population * x).floor \r\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\r\n\r\n end", "def predicted_deaths(population_density, population, state) # defining a method which takes three arguments, \n # => and using an if-elsif tree to calculate number of deaths\n # => If population density falls within a particular range, multiply population by a value\n # and round it down to the nearest integer.\n # => Use string interpolation to print string which includes state name and the number\n # of deaths.\n=begin\n if @population_density >= 200\n number_of_deaths = (@population * 0.4).floor\n elsif @population_density >= 150\n number_of_deaths = (@population * 0.3).floor\n elsif @population_density >= 100\n number_of_deaths = (@population * 0.2).floor\n elsif @population_density >= 50\n number_of_deaths = (@population * 0.1).floor\n else \n number_of_deaths = (@population * 0.05).floor\n end\n\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\n=end\n predictor = case @population_density\n when 0..50\n 0.05\n when 50..100\n 0.1\n when 100..150\n 0.2\n when 150..200\n 0.3\n else\n 0.4\n end\n return (@population_density * predictor).floor\n end", "def predicted_deaths\n # predicted deaths is solely based on population density\n \n if @population_density < 50\n \tnumber_of_deaths = (@population * 0.05).floor\n elsif @population_density < 100\n \tnumber_of_deaths = (@population * 0.1).floor\n elsif @population_density < 150\n \tnumber_of_deaths = (@population * 0.2).floor\n elsif @population_density < 200\n \tnumber_of_deaths = (@population * 0.3).floor\n elsif @population_density >= 200\n \tnumber_of_deaths = (@population * 0.4).floor\n end\n\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\n\n end", "def predicted_deaths\n # predicted deaths is solely based on population density\n case @population_density\n when 0...50 then number_of_deaths = calc_density(0.05)\n when 50...100 then number_of_deaths = calc_density(0.1)\n when 100...150 then number_of_deaths = calc_density(0.2)\n when 150...200 then number_of_deaths = calc_density(0.3)\n else number_of_deaths = calc_density(0.4)\n end\n\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\n\n end", "def predicted_deaths\n # predicted deaths is solely based on population density\n\n thresholds = [50,100,150,200]\n number_of_deaths = 0\n\n thresholds.each do |threshold|\n if @population_density >= threshold\n number_of_deaths = (@population * threshold/500).floor\n else\n number_of_deaths = (@population * 0.05).floor\n end\n end\n\n # if @population_density >= 200\n # number_of_deaths = (@population * 0.4).floor\n # elsif @population_density >= 150\n # number_of_deaths = (@population * 0.3).floor\n # elsif @population_density >= 100\n # number_of_deaths = (@population * 0.2).floor\n # elsif @population_density >= 50\n # number_of_deaths = (@population * 0.1).floor\n # else\n # number_of_deaths = (@population * 0.05).floor\n # end\n\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\n\n end", "def predicted_deaths\n # predicted deaths is solely based on population density\n\n\n if @population_density >= 200\n rate = 0.4\n elsif @population_density >= 150\n rate = 0.3\n elsif @population_density >= 100\n rate = 0.2\n elsif @population_density >= 50\n rate = 0.1\n else\n rate = 0.05\n end\n number_of_deaths = (@population * rate).floor\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\n end", "def predicted_deaths\n # predicted deaths is solely based on population density\n # if @population_density >= 200\n # number_of_deaths = (@population * 0.4).floor\n # elsif @population_density >= 150\n # number_of_deaths = (@population * 0.3).floor\n # elsif @population_density >= 100\n # number_of_deaths = (@population * 0.2).floor\n # elsif @population_density >= 50\n # number_of_deaths = (@population * 0.1).floor\n # else\n # number_of_deaths = (@population * 0.05).floor\n # end\n\n #defined number in original if else method as death ratio (aka .4 or .3 or .2)\n #changed the death ratio from a discrete range od numbers to a continuous funtion\n #using the equation for a line to get more accurate number of deaths\n #b = .05\n #y = @population_density\n #x = death_ration\n # m = 571\n # x = y/m - b\n\n death_ratio = @population_density / 571\n if death_ratio > 1\n death_ratio = 0.99\n end\n\n number_of_deaths = (@population * death_ratio).floor\n\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\n\n end", "def predicted_deaths # this is going to print out the deaths for each state on the outbreak which is going to be based on population and population density\n \n death_percent = 0.1 if @population_density >= 50\n death_percent = 0.2 if @population_density >= 100\n death_percent = 0.3 if @population_density >= 150\n death_percent = 0.4 if @population_density >= 200\n death_percent = 0.05 if @population_density < 50\n number_of_deaths = (@population * death_percent).floor\n \n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\n \n end", "def predicted_deaths\n if @population_density >= 200\n multiplier = 0.4\n elsif @population_density >= 150\n multiplier = 0.3\n elsif @population_density >= 100\n multiplier = 0.2\n elsif @population_density >= 50\n multiplier = 0.1\n else\n multiplier = 0.05\n end\n number_of_deaths = (@population * multiplier).floor\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\n end", "def predicted_deaths #(population_density, population, state)\r\n # predicted deaths is solely based on population density\r\n case\r\n when @population_density >= 200 then number_of_deaths = (@population * 0.4).floor\r\n when @population_density >= 150 then number_of_deaths = (@population * 0.3).floor\r\n when @population_density >= 100 then number_of_deaths = (@population * 0.2).floor\r\n when @population_density >= 50 then number_of_deaths = (@population * 0.1).floor\r\n when @population_density < 50 then number_of_deaths = (@population * 0.05).floor\r\n end\r\n \r\n \r\n \r\n# if @population_density >= 200\r\n# number_of_deaths = (@population * 0.4).floor\r\n# elsif @population_density >= 150\r\n# number_of_deaths = (@population * 0.3).floor\r\n# elsif @population_density >= 100\r\n# number_of_deaths = (@population * 0.2).floor\r\n# elsif @population_density >= 50\r\n# number_of_deaths = (@population * 0.1).floor\r\n# else\r\n# number_of_deaths = (@population * 0.05).floor\r\n# end\r\n\r\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\r\n\r\n end", "def predicted_deaths\n # predicted deaths is solely based on population density\n number_of_deaths = 0\n density_hash = {200 => 0.4, 150 => 0.3, 100 => 0.2, 50 => 0.1,0 => 0.05}\n density_hash.each_key { |key|\n if @population_density >= key\n number_of_deaths = (@population * density_hash[key]).floor\n end\n }\n\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\n\n end" ]
[ "0.76750445", "0.7655298", "0.76462144", "0.7643955", "0.7642", "0.7636896", "0.76294565", "0.7614499", "0.7598468", "0.7597625", "0.75833505", "0.7582063", "0.7582063", "0.7557443", "0.75538945", "0.75524235", "0.7544485", "0.7541529", "0.75355726", "0.75355726", "0.75355726", "0.75355726", "0.75355726", "0.75355726", "0.7530923", "0.7528489", "0.75283384", "0.752816", "0.7522611", "0.75204355", "0.7517386", "0.75056064", "0.75035626", "0.7500923", "0.7500923", "0.7500923", "0.7500923", "0.7500923", "0.7491003", "0.7489264", "0.74850446", "0.7476074", "0.74754417", "0.7474849", "0.74731016", "0.74666387", "0.7459235", "0.7457379", "0.74572027", "0.7451466", "0.7442356", "0.7441663", "0.7441214", "0.7441214", "0.7436256", "0.74360156", "0.74350506", "0.743222", "0.7425607", "0.74239343", "0.7423209", "0.7420974", "0.7419231", "0.7413266", "0.74030167", "0.7402844", "0.7396973", "0.7396099", "0.73932546", "0.73731565", "0.73537815", "0.7345494", "0.73440564", "0.73438066", "0.73420423", "0.7338986", "0.7337301", "0.73368734", "0.73354083", "0.7324982", "0.7322982", "0.73227304", "0.7314408", "0.72946805", "0.72916186", "0.7288803", "0.7285944", "0.728194", "0.72747666", "0.7271362", "0.7266501", "0.7261178", "0.72539425", "0.72534627", "0.72506875", "0.7249541", "0.7245528", "0.7244194", "0.72398424", "0.72392434", "0.722707" ]
0.0
-1
takes attributes in based upon population density and preforms calculation providing the speed at which it will spread
def speed_of_spread #in months # We are still perfecting our formula here. The speed is also affected # by additional factors we haven't added into this functionality. if @population_density >= 200 speed = 0.5 elsif @population_density >= 150 speed = 1 elsif @population_density >= 100 speed = 1.5 elsif @population_density >= 50 speed = 2 else speed = 2.5 end puts " and will spread across the state in #{speed} months.\n\n" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def speed_of_spread\n if @population_density >= 200\n speed = 0.5\n else @population_density < 200\n multiplier = (@population_density/50).floor\n speed = 2.5 - (multiplier * 0.5)\n end\n end", "def speed_of_spread #(population_density, state) #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n \n\n if @population_density >= 200\n @speed += 0.5\n elsif @population_density >= 150\n @speed += 1\n elsif @population_density >= 100\n @speed += 1.5\n elsif @population_density >= 50\n @speed += 2\n else\n @speed += 2.5\n end\n\n end", "def speed_of_spread #(population_density, state) #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n @speed = 0.0\n # REFACTOR: Rename speed variable to time or months.\n \n\n if @population_density >= 200\n @speed += 0.5\n elsif @population_density >= 150\n @speed += 1\n elsif @population_density >= 100\n @speed += 1.5\n elsif @population_density >= 50\n @speed += 2\n else\n @speed += 2.5\n end\n end", "def speed_of_spread #(population_density, state) #in months\r\n # We are still perfecting our formula here. The speed is also affected\r\n # by additional factors we haven't added into this functionality.\r\n\r\n if @population_density >= 200\r\n speed = 0.5\r\n elsif @population_density >= 150\r\n speed = 1\r\n elsif @population_density >= 100\r\n speed = 1.5\r\n elsif @population_density >= 50\r\n speed = 2\r\n else\r\n speed = 2.5\r\n end\r\n\r\n end", "def speed_of_spread\n #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n\n if @population_density >= 200\n speed += 0.5\n elsif @population_density >= 150\n speed += 1\n elsif @population_density >= 100\n speed += 1.5\n elsif @population_density >= 50\n speed += 2\n else\n speed += 2.5\n end\n end", "def speed_of_spread(population_density) #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n\n case @population_density\n when 200..Float::INFINITY\n speed += 0.5\n when 150..199\n speed += 1\n when 100..149\n speed += 1.5\n when 50..99\n speed += 2\n else speed += 2.5\n end\n\n speed\n\n end", "def speed_of_spread\n #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n\n if @population_density >= 200\n speed += 0.5\n elsif @population_density >= 150\n speed += 1\n elsif @population_density >= 100\n speed += 1.5\n elsif @population_density >= 50\n speed += 2\n else\n speed += 2.5\n end\n end", "def speed_of_spread\n #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n\n if @population_density >= 200\n speed += 0.5\n elsif @population_density >= 150\n speed += 1\n elsif @population_density >= 100\n speed += 1.5\n elsif @population_density >= 50\n speed += 2\n else\n speed += 2.5\n end\n end", "def speed_of_spread() # in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n\n if @population_density >= 200\n speed += 0.5\n elsif @population_density >= 150\n speed += 1\n elsif @population_density >= 100\n speed += 1.5\n elsif @population_density >= 50\n speed += 2\n else\n speed += 2.5\n end\n\n end", "def speed_of_spread(population_density) #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n\n if @population_density >= 200\n speed = 0.5\n elsif @population_density >= 150\n speed = 1\n elsif @population_density >= 100\n speed = 1.5\n elsif @population_density >= 50\n speed = 2\n else\n speed = 2.5\n end\n\n speed\n end", "def speed_of_spread() #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n @speed = 0.0\n\n case @population_density\n when 200..1000\n @speed += 0.5\n when 150...200\n @speed += 1\n when 100...200\n @speed += 1.5\n when 50...100\n @speed += 2\n else\n @speed += 2.5\n\n end\n\n end", "def speed_of_spread #in months\r\n # We are still perfecting our formula here. The speed is also affected\r\n # by additional factors we haven't added into this functionality.\r\n speed = 0.0\r\n\r\n if @population_density >= 200\r\n speed += 0.5\r\n elsif @population_density >= 150\r\n speed += 1\r\n elsif @population_density >= 100\r\n speed += 1.5\r\n elsif @population_density >= 50\r\n speed += 2\r\n else\r\n speed += 2.5\r\n end\r\n\r\n \r\n\r\n end", "def speed_of_spread #(population_density, state) #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n\n when @population_density >= 200 then speed += 0.5\n when @population_density >= 150 then speed += 1\n when @population_density >= 100 then speed += 1.5\n when @population_density >= 50 then speed += 2\n else speed += 2.5\nend", "def speed_of_spread #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n\n if @population_density >= 200\n speed += 0.5\n elsif @population_density >= 150\n speed += 1\n elsif @population_density >= 100\n speed += 1.5\n elsif @population_density >= 50\n speed += 2\n else\n speed += 2.5\n end\n @speed = speed\n end", "def speed_of_spread #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n\n if @population_density >= 200\n speed += 0.5\n elsif @population_density >= 150\n speed += 1\n elsif @population_density >= 100\n speed += 1.5\n elsif @population_density >= 50\n speed += 2\n else\n speed += 2.5\n end\n\n end", "def speed_of_spread #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n\n if @population_density >= 200\n speed += 0.5\n elsif @population_density >= 150\n speed += 1\n elsif @population_density >= 100\n speed += 1.5\n elsif @population_density >= 50\n speed += 2\n else\n speed += 2.5\n end\n\n end", "def speed_of_spread #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n\n if @population_density >= 200\n speed += 0.5\n elsif @population_density >= 150\n speed += 1\n elsif @population_density >= 100\n speed += 1.5\n elsif @population_density >= 50\n speed += 2\n else\n speed += 2.5\n end\n\n end", "def speed_of_spread #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n\n if @population_density >= 200\n speed += 0.5\n elsif @population_density >= 150\n speed += 1\n elsif @population_density >= 100\n speed += 1.5\n elsif @population_density >= 50\n speed += 2\n else\n speed += 2.5\n end\n\n end", "def speed_of_spread #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n\n if @population_density >= 200\n @speed = 0.5\n elsif @population_density >= 150\n @speed = 1\n elsif @population_density >= 100\n @speed = 1.5\n elsif @population_density >= 50\n @speed = 2\n else\n @speed = 2.5\n end\n\n \n\n end", "def speed_of_spread #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n\n if @population_density >= 200\n speed += 0.5\n elsif @population_density >= 150\n speed += 1\n elsif @population_density >= 100\n speed += 1.5\n elsif @population_density >= 50\n speed += 2\n else\n speed += 2.5\n end\n end", "def speed_of_spread #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n\n if @population_density >= 200\n speed += 0.5\n elsif @population_density >= 150\n speed += 1\n elsif @population_density >= 100\n speed += 1.5\n elsif @population_density >= 50\n speed += 2\n else\n speed += 2.5\n end\n\n \n\n end", "def speed_of_spread\r\n # We are still perfecting our formula here. The speed is also affected\r\n # by additional factors we haven't added into this functionality.\r\n case @population_density\r\n when 200..Float::INFINITY\r\n speed = 0.5\r\n when 150..199\r\n speed = 1\r\n when 100..149\r\n speed = 1.5\r\n when 50..99\r\n speed = 2\r\n else\r\n speed = 2.5\r\n end\r\n\r\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\r\n\r\n end", "def speed_of_spread #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n\n if @population_density >= 200\n speed = 0.5\n elsif @population_density >= 150\n speed = 1\n elsif @population_density >= 100\n speed = 1.5\n elsif @population_density >= 50\n speed = 2\n else\n speed = 2.5\n end\n end", "def speed_of_spread \n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n\n if @population_density >= 200\n speed += 0.5\n elsif @population_density >= 150\n speed += 1\n elsif @population_density >= 100\n speed += 1.5\n elsif @population_density >= 50\n speed += 2\n else\n speed += 2.5\n end\n\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n\n end", "def speed_of_spread\n # (population_density, state) #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n if @population_density >= 200\n speed += 0.5\n elsif @population_density >= 150\n speed += 1\n elsif @population_density >= 100\n speed += 1.5\n elsif @population_density >= 50\n speed += 2\n else\n speed += 2.5\n end\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n end", "def speed_of_spread #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n # speed = 0.0\n\n if @population_density >= 200\n 0.5\n elsif @population_density >= 150\n 1\n elsif @population_density >= 100\n 1.5\n elsif @population_density >= 50\n 2\n else\n 2.5\n end\n end", "def speed_of_spread #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n\n STATE_FORMULA.each do |state_size, calculation|\n if @population_density >= calculation[:pop_density]\n return speed += calculation[:speed]\n end\n end\n speed += 2.5\n end", "def speed_of_spread #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n case @population_density\n when 0..50 then 2.5\n when 51..100 then 2\n when 101..150 then 1.5\n when 151..200 then 1\n else 0.5\n end\n\n end", "def speed_of_spread #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n case @population_density\n when 0..50 then 2.5\n when 51..100 then 2\n when 101..150 then 1.5\n when 151..200 then 1\n else 0.5\n end\n end", "def speed_of_spread #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n\n if @population_density >= 200\n speed += 0.5\n elsif @population_density <= 50\n speed += 2.5\n else\n months = 2.5 - ((@population_density.floor / 50) * 0.5)\n speed += months\n end\n end", "def speed_of_spread #(population_density, state) #in months\r\n # We are still perfecting our formula here. The speed is also affected\r\n # by additional factors we haven't added into this functionality.\r\n\r\n if @population_density >= 200\r\n speed = 0.5\r\n elsif @population_density >= 150\r\n speed = 1\r\n elsif @population_density >= 100\r\n speed = 1.5\r\n elsif @population_density >= 50\r\n speed = 2\r\n else\r\n speed = 2.5\r\n end\r\n\r\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\r\n\r\n end", "def speed_of_spread\n more_dense = @population_density >= 200\n dense = @population_density >= 150\n medium_dense = @population_density >= 100\n low_dense = @population_density >= 50#in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n\n # if @population_density >= 200\n # speed += 0.5\n # elsif @population_density >= 150\n # speed += 1\n # elsif @population_density >= 100\n # speed += 1.5\n # elsif @population_density >= 50\n # speed += 2\n # else\n # speed += 2.5\n # end\n\n if more_dense\n speed += 0.5\n elsif dense\n speed += 1\n elsif medium_dense\n speed += 1.5\n elsif low_dense\n speed += 2\n else\n speed += 2.5\n end\n\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n\n end", "def speed_of_spread(state_density) #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n hash = {200=>0.5, 150=>1, 100=>1.5, 50=>2}\n\n hash.each do |density, float|\n if @population_density >= density\n speed = float\n else\n speed = 2.5\n end\n speed\n end\n\n # if @population_density >= 200\n # speed += 0.5\n # elsif @population_density >= 150\n # speed += 1\n # elsif @population_density >= 100\n # speed += 1.5\n # elsif @population_density >= 50\n # speed += 2\n # else\n # speed += 2.5\n # end\n\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n\n end", "def speed_of_spread#(population_density, state) #in months\r\n # We are still perfecting our formula here. The speed is also affected\r\n # by additional factors we haven't added into this functionality.\r\n speed = 0.0\r\n\r\n if @population_density >= 200\r\n speed += 0.5\r\n elsif @population_density >= 150\r\n speed += 1\r\n elsif @population_density >= 100\r\n speed += 1.5\r\n elsif @population_density >= 50\r\n speed += 2\r\n else\r\n speed += 2.5\r\n end\r\n\r\n # puts \" and will spread across the state in #{speed} months.\\n\\n\"\r\n\r\n end", "def speed_of_spread #(population_density, state) #in months\r\n # We are still perfecting our formula here. The speed is also affected\r\n # by additional factors we haven't added into this functionality.\r\n speed = 0.0\r\n\r\n if @population_density >= 200\r\n speed += 0.5\r\n elsif @population_density >= 150\r\n speed += 1\r\n elsif @population_density >= 100\r\n speed += 1.5\r\n elsif @population_density >= 50\r\n speed += 2\r\n else\r\n speed += 2.5\r\n end\r\n\r\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\r\n\r\n end", "def speed_of_spread #(population_density, state) #in months\r\n # We are still perfecting our formula here. The speed is also affected\r\n # by additional factors we haven't added into this functionality.\r\n speed = 0.0\r\n if @population_density >= 200\r\n speed += 0.5\r\n elsif @population_density >= 150\r\n speed += 1\r\n elsif @population_density >= 100\r\n speed += 1.5\r\n elsif @population_density >= 50\r\n speed += 2\r\n else\r\n speed += 2.5\r\n end\r\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\r\n end", "def speed_of_spread #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n\n if @population_density >= 200\n speed += 0.5\n elsif @population_density >= 150\n speed += 1\n elsif @population_density >= 100\n speed += 1.5\n elsif @population_density >= 50\n speed += 2\n else\n speed += 2.5\n end\n return speed\n end", "def speed_of_spread(population_density) #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n\n if @population_density >= 200\n speed += 0.5\n elsif @population_density >= 150\n speed += 1\n elsif @population_density >= 100\n speed += 1.5\n elsif @population_density >= 50\n speed += 2\n else\n speed += 2.5\n end\n\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n\n end", "def speed_of_spread(population_density) #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n\n if @population_density >= 200\n speed += 0.5\n elsif @population_density >= 150\n speed += 1\n elsif @population_density >= 100\n speed += 1.5\n elsif @population_density >= 50\n speed += 2\n else\n speed += 2.5\n end\n\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n\n end", "def speed_of_spread #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n case true\n when @population_density >= 200 then speed += 0.5\n when @population_density >= 150 then speed += 1\n when @population_density >= 100 then speed += 1.5\n when @population_density >= 50 then speed += 2\n else speed += 2.5\n end\n end", "def speed_of_spread\n #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n\n if @population_density > 200\n speed += 0.5\n elsif @population_density <= 200 && @population_density >= 50\n speed = (@population_density/50 =+.5)\n else\n speed += 2.5\n end\n\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n\n end", "def speed_of_spread #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n\n if @population_density >= 200\n 0.5\n elsif @population_density >= 150\n 1\n elsif @population_density >= 100\n 1.5\n elsif @population_density >= 50\n 2\n else\n 2.5\n end\n\n end", "def speed_of_spread #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n \n if @population_density >= 200\n 0.5\n elsif @population_density >= 150\n 1\n elsif @population_density >= 100\n 1.5\n elsif @population_density >= 50\n 2\n else\n 2.5\n end\n\n \n\n end", "def speed_of_spread(@population_density, @state) #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n\n if @population_density >= 200\n speed += 0.5\n elsif @population_density >= 150\n speed += 1\n elsif @population_density >= 100\n speed += 1.5\n elsif @population_density >= 50\n speed += 2\n else\n speed += 2.5\n end\n\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n\n end", "def speed_of_spread\r\n # in months\r\n # We are still perfecting our formula here. The speed is also affected\r\n # by additional factors we haven't added into this functionality.\r\n speed = 0.0\r\n\r\n if @population_density >= 200\r\n speed += 0.5\r\n elsif @population_density >= 150\r\n speed += 1\r\n elsif @population_density >= 100\r\n speed += 1.5\r\n elsif @population_density >= 50\r\n speed += 2\r\n else\r\n speed += 2.5\r\n end\r\n\r\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\r\n\r\n end", "def speed_of_spread #(population_density, state) #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n # speed = 0.0\n if @population_density >= 200\n speed = 0.5\n elsif @population_density >= 150\n speed = 1\n elsif @population_density >= 100\n speed = 1.5\n elsif @population_density >= 50\n speed = 2\n else\n speed = 2.5\n end\n\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n end", "def speed_of_spread(population_density, state) #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n\n if @population_density >= 200\n speed += 0.5\n elsif @population_density >= 150\n speed += 1\n elsif @population_density >= 100\n speed += 1.5\n elsif @population_density >= 50\n speed += 2\n else\n speed += 2.5\n end\n\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n\n end", "def speed_of_spread(population_density, state) #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n\n if @population_density >= 200\n speed += 0.5\n elsif @population_density >= 150\n speed += 1\n elsif @population_density >= 100\n speed += 1.5\n elsif @population_density >= 50\n speed += 2\n else\n speed += 2.5\n end\n\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n\n end", "def speed_of_spread(population_density, state) #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n\n if @population_density >= 200\n speed += 0.5\n elsif @population_density >= 150\n speed += 1\n elsif @population_density >= 100\n speed += 1.5\n elsif @population_density >= 50\n speed += 2\n else\n speed += 2.5\n end\n\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n\n end", "def speed_of_spread(population_density, state) #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n\n if @population_density >= 200\n speed += 0.5\n elsif @population_density >= 150\n speed += 1\n elsif @population_density >= 100\n speed += 1.5\n elsif @population_density >= 50\n speed += 2\n else\n speed += 2.5\n end\n\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n\n end", "def speed_of_spread #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n \n if @population_density >= 200\n 0.5\n elsif @population_density >= 150\n 1\n elsif @population_density >= 100\n 1.5\n elsif @population_density >= 50\n 2\n else\n 2.5\n end\n\n end", "def speed_of_spread #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n\n if @population_density >= 200\n 0.5\n elsif @population_density >= 150\n 1\n elsif @population_density >= 100\n 1.5\n elsif @population_density >= 50\n 2\n else\n 2.5\n end\n end", "def speed_of_spread\r\n #in months\r\n # We are still perfecting our formula here. The speed is also affected\r\n # by additional factors we haven't added into this functionality.\r\n speed = 0.0\r\n\r\n if @population_density >= 200\r\n speed += 0.5\r\n elsif @population_density >= 150\r\n speed += 1\r\n elsif @population_density >= 100\r\n speed += 1.5\r\n elsif @population_density >= 50\r\n speed += 2\r\n else\r\n speed += 2.5\r\n end\r\n\r\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\r\n\r\n end", "def speed_of_spread(speed) #(population_density, state) #in months\r\n # We are still perfecting our formula here. The speed is also affected\r\n # by additional factors we haven't added into this functionality.\r\n #speed = 0.0\r\n\r\n #if @population_density >= 200\r\n # speed += 0.5\r\n #elsif @population_density >= 150\r\n # speed += 1\r\n #elsif @population_density >= 100\r\n # speed += 1.5\r\n #elsif @population_density >= 50\r\n # speed += 2\r\n #else\r\n # speed += 2.5\r\n #end\r\n\r\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\r\n\r\n end", "def speed_of_spread #(population_density, state) #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n ## Refactored for Release: 8\n if @population_density >= 200\n 0.5\n elsif @population_density >= 150\n 1\n elsif @population_density >= 100\n 1.5\n elsif @population_density >= 50\n 2\n else\n 2.5\n end\n\n # puts \" and will spread across the state in #{speed} months.\\n\\n\"\n\n end", "def speed_of_spread #in months\n speed = case @population_density\n when (0..49) then 2.5\n when (50..99) then 2 \n when (100..149) then 1.5 \n when (150..199) then 1\n else 0.5\n end\n end", "def speed_of_spread #(population_density, state) #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n\n if @population_density >= 200\n speed += 0.5\n elsif @population_density >= 150\n speed += 1\n elsif @population_density >= 100\n speed += 1.5\n elsif @population_density >= 50\n speed += 2\n else\n speed += 2.5\n end\n\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n\n end", "def speed_of_spread #(population_density, state) #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n\n if @population_density >= 200\n speed += 0.5\n elsif @population_density >= 150\n speed += 1\n elsif @population_density >= 100\n speed += 1.5\n elsif @population_density >= 50\n speed += 2\n else\n speed += 2.5\n end\n\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n\n end", "def speed_of_spread #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n \n if @population_density >= 200\n 0.5\n elsif @population_density >= 150\n 1\n elsif @population_density >= 100\n 1.5\n elsif @population_density >= 50\n 2\n else\n 2.5\n end\n end", "def speed_of_spread\r\n #(population_density, state) <---- deleted, not necessary\r\n #in months\r\n # We are still perfecting our formula here. The speed is also affected\r\n # by additional factors we haven't added into this functionality.\r\n speed = 0.0\r\n\r\n case population_density\r\n when 0..49 then speed += 2.5\r\n when 50..99 then speed += 2\r\n when 100..150 then speed += 1.5\r\n when 151..200 then speed += 1\r\n else speed += 0.5\r\n end\r\n\r\n\r\n # if population_density >= 200\r\n # speed += 0.5\r\n # elsif population_density >= 150\r\n # speed += 1\r\n # elsif population_density >= 100\r\n # speed += 1.5\r\n # elsif population_density >= 50\r\n # speed += 2\r\n # else\r\n # speed += 2.5\r\n # end\r\n\r\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\r\n\r\n end", "def speed_of_spread#(population_density, state) #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n\n speed += 0.5 if @population_density >= 200\n speed += 1 if @population_density >= 150\n speed += 1.5 if @population_density >= 100\n speed += 2 if @population_density >= 50\n speed += 2.5 if @population_density < 50\n\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n\n end", "def speed_of_spread(population_density, state) #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n\n if population_density >= 200\n speed += 0.5\n elsif population_density >= 150\n speed += 1\n elsif population_density >= 100\n speed += 1.5\n elsif population_density >= 50\n speed += 2\n else\n speed += 2.5\n end\n\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n\n end", "def speed_of_spread #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n\n case @population_density\n when (0..49)\n 2.5\n when (50..99)\n 2\n when (100..149)\n 1.5\n when (150..199)\n 1\n else #(200+)\n 0.5\n end\n end", "def speed_of_spread#(population_density, state) #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.5\n density = 200\n\n while @population_density <= density\n density -= 50\n speed += 0.5\n end\n\n # speed = 0\n # if @population_density >= 200\n # speed += 0.5\n # elsif @population_density >= 150\n # speed += 1\n # elsif @population_density >= 100\n # speed += 1.5\n # elsif @population_density >= 50\n # speed += 2\n # else\n # speed += 2.5\n # end\n\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n\n end", "def speed_of_spread(population_density, state) #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n\n case @population_density \n when 200..\n speed += 0.5\n when 150..199\n speed += 1\n when 100..149\n speed += 1.5\n when 50..99\n speed += 2\n else\n speed += 2.5\n end\n\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n\n end", "def speed_of_spread \r\n #in months\r\n # We are still perfecting our formula here. The speed is also affected\r\n # by additional factors we haven't added into this functionality.\r\n speed = case @population_density\r\n when 151...200 then 1.0\r\n when 101...150 then 1.5\r\n when 51...100 then 2.0\r\n when 0...50 then 2.5\r\n else 0.5\r\n end\r\n\r\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\r\n\r\n end", "def speed_of_spread #(population_density, state) #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n\n case when @population_density >= 200\n speed += 0.5\n when @population_density >= 150\n speed += 1\n when @population_density >= 100\n speed += 1.5\n when @population_density >= 50\n speed += 2\n when\n speed += 2.5\n end\n\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n\n end", "def speed_of_spread(population_density, state) #in months\n speed = 0.0 # forces float\n\n if @population_density >= 200\n speed += 0.5\n elsif @population_density >= 150\n speed += 1\n elsif @population_density >= 100\n speed += 1.5\n elsif @population_density >= 50\n speed += 2\n else \n speed += 2.5\n end\n\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n\n end", "def speed_of_spread#(population_density, state) #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n index = 0\n density = [200, 150, 100, 50, 0]\n speed = [0.5, 1, 1.5, 2, 2.5]\n\n while index < density.length\n if @population_density >= density[index]\n puts \" and will spread across the state in #{speed[index]} months.\\n\\n\"\n break\n end\n index += 1\n end\n # if @population_density >= 200\n # speed += 0.5\n # elsif @population_density >= 150\n # speed += 1\n # elsif @population_density >= 100\n # speed += 1.5\n # elsif @population_density >= 50\n # speed += 2\n # else\n # speed += 2.5\n # end\n\n\n end", "def speed_of_spread(population_density, state) #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n multiples_of_fifty = (population_density / 50).to_i\n speed = 0.5\n if population_density < 200\n speed = 2.5 - (multiples_of_fifty * speed)\n end\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n\n end", "def speed_of_spread#(population_density, state) #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n\n if population_density >= 200\n speed += 0.5\n elsif population_density >= 150\n speed += 1\n elsif population_density >= 100\n speed += 1.5\n elsif population_density >= 50\n speed += 2\n else\n speed += 2.5\n end\n\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n\n end", "def speed_of_spread # REFACTOR\n speed = 0.0\n\n if @population_density >= 200\n speed += 0.5\n elsif @population_density >= 150\n speed += 1\n elsif @population_density >= 100\n speed += 1.5\n elsif @population_density >= 50\n speed += 2\n else \n speed += 2.5\n end\n\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n\n end", "def speed_of_spread\n #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n\n if @population_density >= 200\n speed += 0.5\n elsif @population_density >= 150\n speed += 1\n elsif @population_density >= 100\n speed += 1.5\n elsif @population_density >= 50\n speed += 2\n else\n speed += 2.5\n end\n\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n\n end", "def speed_of_spread #(population_density, state) #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n\n case @population_density\n when 200..10000 then speed = 0.5\n when 150...200 then speed = 1\n when 100...150 then speed = 1.5\n when 50...100 then speed = 2\n else\n speed = 2.5 \n end\n\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n\n end", "def speed_of_spread #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n if @population_density >= 200\n @number_of_months += 0.5\n elsif @population_density >= 150\n @number_of_months += 1\n elsif @population_density >= 100\n @number_of_months += 1.5\n elsif @population_density >= 50\n @number_of_months += 2\n else\n @number_of_months += 2.5\n end\n end", "def speed_of_spread \n #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n\n if @population_density >= 200\n speed += 0.5\n elsif @population_density >= 150\n speed += 1\n elsif @population_density >= 100\n speed += 1.5\n elsif @population_density >= 50\n speed += 2\n else\n speed += 2.5\n end\n\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n\n end", "def speed_of_spread #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n @speed = if @population_density >= 200\n 0.5\n elsif @population_density >= 150\n 1\n elsif @population_density >= 100\n 1.5\n elsif @population_density >= 50\n 2\n else\n 2.5\n end\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n end", "def speed_of_spread#(population_density, state) #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n # refactoring of speed_of_spread took # speed out of the if confiditional statement and set the return value for each statement to speed just once \n\n speed = if @population_density >= 200\n \t\t\t0.5\n \t\telsif @population_density >= 150\n \t\t\t1\n \t\telsif @population_density >= 100\n \t\t1.5\n \t\telsif @population_density >= 50\n \t\t2\n \t\telse\n \t\t2.5\n \t\tend\n\tputs \" and will spread across the state in #{speed} months.\\n\\n\"\n end", "def speed_of_spread(population_density) #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n pop = @population_density\n case pop \n when pop >= 200 \n speed += 0.5\n when pop >= 150 \n speed += 1\n when pop >= 100 \n speed += 1.5\n when pop >= 50 \n speed += 2\n else \n speed += 2.5\n end\n\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n\n end", "def speed_of_spread #(population_density, state) #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n \n\n#Method should be able to have add greater speed to to pop density numbers that are lower then each other at increments of 50.\n#steps \n# if @population_density >= 200\n# speed += 0.5\n# elsif @population_density >= 150\n# speed += 1\n# elsif @population_density >= 100\n# speed += 1.5\n# elsif @population_density >= 50\n# speed += 2\n# else\n# speed += 2.5\n# end\n\n\n# puts \" and will spread across the state in #{speed} months.\\n\\n\"\n\n# end\n\n# end\n speedhash1 = {0..49 => 2.5, 50..99 => 2.0, 100..149 => 1.5, 150..199 => 1.0, 200..103589999 => 0.5}\n speedhash1.each do |range, speed|\n if (range).include?(@population_density.floor)\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n end\n end\n\n\n # puts \" and will spread across the state in #{speed} months.\\n\\n\"\n\n end", "def speed_of_spread(population_density, state) #in months\n\n speed = 2.5 if @population_density < 50\n speed = 2 if @population_density >= 50\n speed = 1.5 if @population_density >= 100\n speed = 1 if @population_density >= 150\n speed = 0.5 if @population_density >= 200\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n\n end", "def speed_of_spread\n speed = 0.0\n density_hash = {200=> 0.5, 150=> 0.5, 100=> 1.5, 50=> 2, 0=> 2.5}\n density_hash.each do |key, value|\n if @population_density >= key\n speed += value\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n return\n end\n end\n end", "def speed_of_spread(population_density, state) #in months\n speed = 0.0\n\n if @population_density >= 200\n speed += 0.5\n elsif @population_density >= 150\n speed += 1\n elsif @population_density >= 100\n speed += 1.5\n elsif @population_density >= 50\n speed += 2\n else \n speed += 2.5\n end\n\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n\n end", "def speed_of_spread(population_density, state) #in months\n speed = 0.0\n\n if @population_density >= 200\n speed += 0.5\n elsif @population_density >= 150\n speed += 1\n elsif @population_density >= 100\n speed += 1.5\n elsif @population_density >= 50\n speed += 2\n else \n speed += 2.5\n end\n\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n\n end", "def speed_of_spread(population_density, state) #in months\n speed = 0.0\n\n if @population_density >= 200\n speed += 0.5\n elsif @population_density >= 150\n speed += 1\n elsif @population_density >= 100\n speed += 1.5\n elsif @population_density >= 50\n speed += 2\n else \n speed += 2.5\n end\n\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n\n end", "def speed_of_spread(population_density, state) #in months\n speed = 0.0\n\n if @population_density >= 200\n speed += 0.5\n elsif @population_density >= 150\n speed += 1\n elsif @population_density >= 100\n speed += 1.5\n elsif @population_density >= 50\n speed += 2\n else \n speed += 2.5\n end\n\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n\n end", "def speed_of_spread #in months\r\n # We are still perfecting our formula here. The speed is also affected\r\n # by additional factors we haven't added into this functionality.\r\n speed = 0.0\r\n\r\n # spread_rates = {200 => 0.5, 150 => 1, 100 => 1.5, 50 => 2, 0 => 2.5}\r\n spread_rates = {0 => 2.5, 50 => 2, 100 => 1.5, 150 => 1, 200 => 0.5}\r\n\r\n spread_rates.each do |density, rate|\r\n if @population_density >= density\r\n speed = rate\r\n end\r\n end\r\n\r\n=begin - refactored\r\n if @population_density >= 200\r\n speed += 0.5\r\n elsif @population_density >= 150\r\n speed += 1\r\n elsif @population_density >= 100\r\n speed += 1.5\r\n elsif @population_density >= 50\r\n speed += 2\r\n else\r\n speed += 2.5\r\n end\r\n=end\r\n\r\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\r\n\r\n end", "def speed_of_spread #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n\n if @population_density >= 200\n speed = 0.5\n elsif @population_density >= 150\n speed = 1\n elsif @population_density >= 100\n speed = 1.5\n elsif @population_density >= 50\n speed = 2\n else\n speed = 2.5\n end\n\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n\n # if @population_density % 50 == 0 \n # speed += 0.5\n # else\n # speed += 2.5\n # end\n\n end", "def speed_of_spread #(population_density, state) #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n\n case\n when @population_density >= 200\n speed += 0.5\n when @population_density >= 150\n speed += 1\n when @population_density >= 100\n speed += 1.5\n when @population_density >= 50\n speed += 2\n else\n speed += 2.5\n end\n\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n\n end", "def speed_of_spread#(population_density, state) #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n # speed = 0.0\n case @population_density\n when (151...200)\n speed = 1\n\n when (100...150)\n speed = 1.5\n\n when (50...100)\n speed = 2\n\n when (0..50)\n speed = 2.5\n\n else\n speed = 0.5\n\n end\n\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n\n end", "def speed_of_spread #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 2.5\n\n if @population_density >= 200\n speed = 0.5\n elsif @population_density >= 50 && @population_density < 200\n speed = speed - ((@population_density / 50).floor / 2.0)\n #subtracts 0.5 from speed for every 50 pop density rounding down.\n end\n\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n\n end", "def speed_of_spread #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n # speed = 0.0\n\n if @population_density >= 200\n @speed = 0.5\n elsif @population_density >= 150\n @speed = 1\n elsif @population_density >= 100\n @speed = 1.5\n elsif @population_density >= 50\n @speed = 2\n else\n @speed = 2.5\n end\n\n # puts \" and will spread across the state in #{speed} months.\\n\\n\"\n\n end", "def speed_of_spread\n #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n if population_density >= 200\n speed = 0.5\n elsif population_density >= 150\n speed = 1\n elsif population_density >= 100\n speed = 1.5\n elsif population_density >= 50\n speed = 2\n else\n speed = 2.5\n end\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n end", "def speed_of_spread() #in months\r\n # We are still perfecting our formula here. The speed is also affected\r\n # by additional factors we haven't added into this functionality.\r\n speed = 0.0\r\n\r\n if @population_density >= 200\r\n speed += 0.5\r\n elsif @population_density >= 150\r\n speed += 1\r\n elsif @population_density >= 100\r\n speed += 1.5\r\n elsif @population_density >= 50\r\n speed += 2\r\n else\r\n speed += 2.5\r\n end\r\n\r\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\r\n\r\n end", "def speed_of_spread #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n @months_to_spread = 0.0\n\n if @population_density >= 200\n @months_to_spread += 0.5\n elsif @population_density >= 150\n @months_to_spread += 1\n elsif @population_density >= 100\n @months_to_spread += 1.5\n elsif @population_density >= 50\n @months_to_spread += 2\n else\n @months_to_spread += 2.5\n end\n\n end", "def speed_of_spread #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n @months_to_spread = 0.0\n\n if @population_density >= 200\n @months_to_spread += 0.5\n elsif @population_density >= 150\n @months_to_spread += 1\n elsif @population_density >= 100\n @months_to_spread += 1.5\n elsif @population_density >= 50\n @months_to_spread += 2\n else\n @months_to_spread += 2.5\n end\n\n end", "def speed_of_spread #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0 #this can be made into a class attribute allowing a getter\n\n if @population_density >= 200\n speed += 0.5\n elsif @population_density >= 150\n speed += 1\n elsif @population_density >= 100\n speed += 1.5\n elsif @population_density >= 50\n speed += 2\n else\n speed += 2.5\n end\n #Print method can be removed allowing information to be printed in the driver code\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n\n end", "def speed_of_spread #in months\r\n # We are still perfecting our formula here. The speed is also affected\r\n # by additional factors we haven't added into this functionality.\r\n \r\n\r\n if @population_density >= 200\r\n speed = 0.5\r\n\r\n elsif @population_density >= 150\r\n speed = 1\r\n\r\n elsif @population_density >= 100\r\n speed = 1.5\r\n\r\n elsif @population_density >= 50\r\n speed = 2\r\n\r\n else\r\n speed = 2.5\r\n end\r\n\r\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\r\n\r\n end", "def speed_of_spread #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n\n # if @population_density >= 200\n # speed += 0.5\n # elsif @population_density >= 150\n # speed += 1\n # elsif @population_density >= 100\n # speed += 1.5\n # elsif @population_density >= 50\n # speed += 2\n # else\n # speed += 2.5\n # end\n\n if (@population_density >= 50) && (@population_density <= 200) \n speed += (2.5 - (@population_density / 100).floor)\n elsif @population_density > 200\n speed += 0.5\n else\n speed += 2.5\n end\n\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n\n end", "def speed_of_spread #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n if @population_density >= 200\n speed += 0.5\n elsif @population_density >= 50 && @population_density < 200\n speed = 2.5 - (0.5)*(@population_density.to_i / 50.to_i).to_f\n # elsif @population_density >= 150\n # speed += 1\n # elsif @population_density >= 100\n # speed += 1.5\n # elsif @population_density >= 50\n # speed += 2\n else\n speed += 2.5\n end\n\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n\n end", "def speed_of_spread #in months\r\n # We are still perfecting our formula here. The speed is also affected\r\n # by additional factors we haven't added into this functionality.\r\n speed = 0.0\r\n# As population density increases, the rate of spread decreases\r\n if @population_density >= 200\r\n speed += 0.5\r\n elsif @population_density >= 150\r\n speed += 1\r\n elsif @population_density >= 100\r\n speed += 1.5\r\n elsif @population_density >= 50\r\n speed += 2\r\n else\r\n speed += 2.5\r\n end\r\n\r\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\r\n\r\n end" ]
[ "0.80283123", "0.79928255", "0.7940139", "0.79339826", "0.78185743", "0.7814368", "0.7773902", "0.7773902", "0.7769669", "0.77674353", "0.7691136", "0.7685977", "0.7661941", "0.75963223", "0.75612056", "0.75612056", "0.75612056", "0.75514895", "0.7546612", "0.751866", "0.7477009", "0.7412219", "0.74113107", "0.7407091", "0.7406973", "0.7401691", "0.73984206", "0.73934394", "0.73851603", "0.73696595", "0.73688793", "0.7362747", "0.7354425", "0.734736", "0.73452634", "0.73432815", "0.7341698", "0.7324152", "0.7324152", "0.7323558", "0.7321015", "0.731475", "0.73133445", "0.7295986", "0.72955525", "0.72804254", "0.7278319", "0.7278319", "0.7278319", "0.7278319", "0.727579", "0.7264425", "0.7264407", "0.72588617", "0.7251021", "0.72474396", "0.7244542", "0.7244542", "0.7244328", "0.7238181", "0.7217522", "0.72147095", "0.72083426", "0.72072643", "0.7189752", "0.7175167", "0.71735066", "0.7173452", "0.71715975", "0.7148829", "0.7137527", "0.7132707", "0.7131075", "0.71236897", "0.7120628", "0.71168154", "0.71142566", "0.7102246", "0.7100342", "0.7093327", "0.70932704", "0.7086487", "0.70853925", "0.70853925", "0.70853925", "0.70853925", "0.7083754", "0.70802903", "0.7056736", "0.7053069", "0.70452404", "0.7030122", "0.7025207", "0.7022152", "0.7021851", "0.7021851", "0.70146114", "0.700897", "0.7001921", "0.6992826", "0.69906896" ]
0.0
-1
Subject can be set in your I18n file at config/locales/en.yml with the following lookup: en.user_mailer.newsletter.subject
def newsletter(newsletter, user) @newsletter = newsletter @greeting = "Repeat Eats Newsletter!" mail to: user.email, subject: @newsletter.title end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def message_subject=(value)\n @message_subject = value\n end", "def subject (recipient)\n subject_variables = alert_variables[:subject].dup\n subject_variables.merge!(recipient_details(recipient))\n subject = \"#{I18n.t(\"#{recipient_type.to_s}_subject_#{alert_name.to_s}\", subject_variables)}\"\n subject\n end", "def subject\n @subject ||= Envelope::MessageTools.normalize(message.subject || '')\n end", "def set_EmailSubject(value)\n set_input(\"EmailSubject\", value)\n end", "def set_EmailSubject(value)\n set_input(\"EmailSubject\", value)\n end", "def set_EmailSubject(value)\n set_input(\"EmailSubject\", value)\n end", "def set_EmailSubject(value)\n set_input(\"EmailSubject\", value)\n end", "def subject\n self['subject'] || msg['subject']\n end", "def translate(mapping, key)\n I18n.t(:\"#{mapping.name}_subject\", :scope => [:devise, :mailer, key],\n :default => [:subject, key.to_s.humanize])\n end", "def subject=(string)\n set('Subject', string)\n end", "def subject=(subject); @message_impl.setSubject subject; end", "def subject\n @mail.subject\n end", "def subject_for(template, attributes = {})\n subject = EmailTemplate.subject_for(template)\n subject = I18n.t(\"email_templates.#{template}.default_subject\") if subject.nil?\n subject = \"No Subject\" if subject.nil?\n Florrick.convert(subject, add_default_attributes(attributes))\n end", "def translate(mapping, key)\n I18n.t(:\"notifications_subject\", :scope => [:eventifier, :notifications, key],\n :default => [:subject, key.to_s.humanize])\n end", "def formatted_subject(text)\n name = PersonMailer.global_prefs.app_name\n label = name.blank? ? \"\" : \"[#{name}] \"\n \"#{label}#{text}\"\n end", "def set_Subject(value)\n set_input(\"Subject\", value)\n end", "def set_Subject(value)\n set_input(\"Subject\", value)\n end", "def set_Subject(value)\n set_input(\"Subject\", value)\n end", "def set_Subject(value)\n set_input(\"Subject\", value)\n end", "def set_Subject(value)\n set_input(\"Subject\", value)\n end", "def set_Subject(value)\n set_input(\"Subject\", value)\n end", "def set_Subject(value)\n set_input(\"Subject\", value)\n end", "def set_Subject(value)\n set_input(\"Subject\", value)\n end", "def setSubject(subject)\n @fields['subject'] = subject\n self\n end", "def setSubject(subject)\n @fields['subject'] = subject\n self\n end", "def setSubject(subject)\n @fields['subject'] = subject\n self\n end", "def setSubject(subject)\n @fields['subject'] = subject\n self\n end", "def subject_name=(value)\n @subject_name = value\n end", "def subject\n @subject ||= \"(sans sujet)\"\n if @no_header_subject.nil?\n \"#{header_subject}#{@subject}\"\n else\n @subject\n end\n end", "def subject() self.headers[\"Subject\"] || \"[NO SUBJECT]\" end", "def subject\n @options.fetch(:subject) { \"Invitation\" }\n end", "def subject_name\n subject_full_name\n end", "def get_email_subject(email_type)\n email_subject = email_type\n case(email_type)\n when \"welcome\"\n email_subject = \"Welcome to Aspera Files\"\n when \"reset\"\n email_subject = \"Password Reset\"\n end\n return email_subject\n end", "def subject_name\n return @subject_name\n end", "def subject_titles\n @subject_titles ||= sw_subject_titles\n end", "def SetSubject(subject)\n\t\t#Subject of document\n\t\t@subject = subject\n\tend", "def subject=(value)\n @subject = value\n end", "def subject=(value)\n @subject = value\n end", "def subject=(value)\n @subject = value\n end", "def subject=(value)\n @subject = value\n end", "def subject=(value)\n @subject = value\n end", "def subject=(value)\n @subject = value\n end", "def set_subject(subject)\n\t\tend", "def subject_alternative_name\n extensions[R509::Cert::Extensions::SubjectAlternativeName]\n end", "def message_subject\n return @message_subject\n end", "def subject\n self['subject']\n end", "def subject(options = {})\n options = { :capitalize => true, :case => Grammar::Case::SUBJECT }.merge(options)\n pronoun_or_noun(@subject, @audience, options)\n end", "def subject\n title \n end", "def email_subject(form)\n \"#{form.type_of_enquiry} - #{reference}\"\n end", "def newsletter(user, subject, text)\n @user = user\n @text = text\n\n mail(to: user.email, subject: subject)\n end", "def subject\n message.subject\n end", "def deliver_invitation(options = {})\n super(options.merge(subject: _('A Data Management Plan in %{application_name} has been shared with you') % {application_name: Rails.configuration.branding[:application][:name]}))\n end", "def compose_email\n @title = t 'conclusion_draft_review.send_by_email'\n end", "def email_subject\n sponsor_name = @config.plan.sponsor_name\n display_date = @date.to_s()\n if @config.div_id.present?\n email_subject = \"Payroll report for #{sponsor_name} for division #{@config.division_name}: #{display_date}\"\n else\n email_subject = \"Payroll report for #{sponsor_name}: #{display_date}\"\n end\n return email_subject\n end", "def newsletter_email\n UserMailer.newsletter_email\n end", "def get_subject_name\n subject_name = subject_header.text.sub! 'Subject:', ''\n subject_name = subject_name.strip!\n subject_name\n end", "def get_subject\n\t\tend", "def mmm_test_subj_call\n ->(candidate) { I18n.t('email.test_monthly_mail_subject_initial_input', candidate_account_name: candidate.account_name) }\n end", "def subject; @message_impl.getSubject; end", "def subject\n @subject=EzCrypto::Name.new(@cert.subject) unless @subject\n @subject\n end", "def newsletter_email(newsletter)\n @newsletter = newsletter\n\tmail(to: @newsletter.email, subject: \" Alex Shyaka from the Therailsshop coding club\")\n end", "def email_subject(&blk)\n @email_subject_block = blk if blk\n @email_subject_block\n end", "def konsalt_mail params\n build_params params\n send_email t('emails.konsalta_mail.subject')\n end", "def choose_subject(action, params = {})\n scope = [:mailers, mailer_name, action]\n key = :subject\n experiment_name = \"#{mailer_name}_mailer_#{action}_subject\".to_sym\n if experiment_active?(experiment_name)\n scope << key\n key = ab_test(experiment_name)\n end\n params.merge!(scope: scope)\n I18n.t(key, params)\n end", "def data_subject=(value)\n @data_subject = value\n end", "def subject_names\n @subject_names ||= sw_subject_names\n end", "def normalize_subject_name\n self.subject = subject.downcase.titleize\n end", "def set_title\n @title = t(:message_2, :scope => [:controller, :exams])\n end", "def user_added_email(user)\n ActsAsTenant.without_tenant do\n @course = user.course\n end\n @recipient = user.user\n\n I18n.with_locale(@recipient.locale) do\n mail(to: @recipient.email, subject: t('.subject', course: @course.title))\n end\n end", "def getEmailDefaults(subject, toEmail, ccEmail = nil)\n if Rails.env.eql? 'development'\n subject = \"[BASL-DEV] #{subject}\"\n toEmail = 'paigepon@gmail.com'\n ccEmail = toEmail\n else\n subject = \"[BASL] #{subject}\"\n end\n mailInfo = {\n :to => toEmail,\n :subject => subject,\n :cc => ccEmail\n }\n mailInfo\n end", "def i18n_label\n \"email.#{name}_label\"\n end", "def default_i18n_subject(interpolations = {})\n ''\n end", "def custom_mail( user, subject, title, contents )\n @user = user\n @host = GogglesCore::AppConstants::WEB_MAIN_DOMAIN_NAME\n @contents = contents\n @title = title\n #subject: \"[#{ GogglesCore::AppConstants::WEB_APP_NAME }@#{ @host }] #{ subject }\",\n mail(\n subject: \"#{ subject } [#{GogglesCore::AppConstants::WEB_APP_NAME}]\",\n to: user.email,\n date: Time.now\n )\n end", "def course_notification_item_details(course)\n t('notifications.subscribe_course')\n end", "def send_subscribe_email(subscriptor)\n @subscriptor = subscriptor\n @subject = \"Thanks for subscribe for our amazing app\"\n mail(to: @subscriptor.email, subject: @subject)\n # mail(to: , from: , subject:)\n end", "def subject_topic\n map_field(:subject_topic)&.map { |a| a.gsub(/ \\$[a-z] /, '--') }\n end", "def reminder_email(user)\n @user = user\n I18n.with_locale user.locale do\n mail to: @user.email\n end\n end", "def subject=(subject)\n self.subjects = [subject]\n end", "def subject_contains=(value)\n @subject_contains = value\n end", "def set_subject\n @subject = Subject.friendly.find(params[:id])\n end", "def set_additional_subject\n @additional_subject = AdditionalSubject.find(params[:id])\n end", "def x509v3_subject_alternative_name\n @x509v3_subject_alternative_name ||= if (node = @node.search('X509v3SubjectAlternativeName'))\n X509v3SubjectAlternativeName.new(node)\n end\n end", "def send_signup_email(newsletter)\n @newsletter = newsletter\n\tmail(to: @newsletter.email, subject: \" Therailsshop is humbled by your subscription\")\n end", "def set_subject\n @subject = Subject.find(params[:subject_id])\n end", "def set_subject\n\t\t\t@subject = Subject.find(params[:id])\n\t\tend", "def welcome_email(resource)\n \n @resource = resource\n\n mail :to => @resource.email, :from => \"email@domain.com\", :subject => \"Subject line\"\n \n end", "def email_welcome_and_pass\r\nold_gt = I18n.locale\r\nI18n.locale = self.language unless self.language.blank?\r\nUserMailer.deliver_account_infos(self, @password) # Uniq time with decoded password\r\nI18n.locale = old_gt\r\nend", "def set_subject_and_message(form, subject, message)\n raise Impostor::MissingTemplateMethodError.new(\"set_subject_and_message must be implemented\")\n end", "def set_title\n @title = t(:message_0, :scope => [:controller, :scholarships])\n end", "def subscribe(subscriber)\n @subscriber = subscriber\n mail to: subscriber.email, subject: \"Subscription Confirmation: Welcome, #{subscriber.name}!\"\n end", "def newsletter_unsubscribe_alert(subscription, email)\n\t\t@list_name = User.human_attribute_name subscription\n\t\t@email = email\n\t\tsendgrid_category 'Newsletter Unsubscribe Alert'\n\t\tmail subject: \"User with email #{email} has unsubscribed from \\\"#{@list_name}\\\" newsletters\", to: ADMIN_EMAIL\n\tend", "def title_for_user_applied_to_travel\n I18n.t(\"notification.user_applied_to_travel.title\")\n end", "def subject\n map_field(:subject)&.map { |a| a.gsub(/ \\$[a-z] /, '--') }\n end", "def setup_email(user)\n @recipients = user.email\n @body[:user] = user\n @from = FROM_EMAIL\n @subject = case ENV['RAILS_ENV'] \n when 'development': \"[YourApp Development] \"\n when 'staging': \"[YourApp Staging] \"\n else \"[YourApp] \"\n end\n @sent_on = Time.now\n headers \"Reply-to\" => FROM_EMAIL\n end", "def translation_scope\n \"mailers.#{mailer_name.tr(\"/\", \".\").sub(\"_mailer\", \"\")}.#{action_name}\"\n end", "def subject(options)\n case [options[:person], options[:plurality]]\n when %i[first singular]\n 'I'\n when %i[first plural]\n 'we'\n when %i[second singular], %i[second plural]\n 'you'\n when %i[third singular]\n 'he'\n when %i[third plural]\n 'they'\n end\n end", "def set_email_newsletter_subscription\n @email_newsletter_subscription = EmailNewsletterSubscription.find(params[:id])\n end", "def set_subject\n @subject = Subject.find(params[:id])\n end", "def set_subject\n @subject = Subject.find(params[:id])\n end", "def set_subject\n @subject = Subject.find(params[:id])\n end" ]
[ "0.70856094", "0.6955006", "0.6880311", "0.68272316", "0.6825893", "0.6792881", "0.6791113", "0.6741581", "0.6727536", "0.6702391", "0.6658228", "0.6657666", "0.658742", "0.656914", "0.65605366", "0.64660364", "0.64660364", "0.64660364", "0.64660364", "0.64660364", "0.64660364", "0.64660364", "0.64660364", "0.6413639", "0.6413639", "0.6413639", "0.6413639", "0.64013916", "0.63886076", "0.6359265", "0.6294962", "0.62574476", "0.622656", "0.6226335", "0.620192", "0.6200857", "0.6184829", "0.6184829", "0.6184829", "0.6184829", "0.6184829", "0.6184829", "0.6167541", "0.6123787", "0.61165696", "0.6105022", "0.60139704", "0.6005234", "0.5999659", "0.5984133", "0.59786224", "0.5975311", "0.5971159", "0.59709674", "0.59406394", "0.5915634", "0.58944494", "0.58921355", "0.588729", "0.5878874", "0.5873647", "0.58633703", "0.58581066", "0.58453554", "0.580879", "0.5800886", "0.57929724", "0.5783985", "0.5765963", "0.57632446", "0.57576466", "0.57525283", "0.5728327", "0.57030207", "0.5666243", "0.5649095", "0.564638", "0.56343085", "0.56132793", "0.5592611", "0.5574867", "0.5560634", "0.55300814", "0.5524898", "0.55191475", "0.55163324", "0.5502612", "0.549245", "0.5484834", "0.54841775", "0.5465703", "0.5462308", "0.5451228", "0.5444511", "0.5442992", "0.5440325", "0.54398894", "0.54343414", "0.54343414", "0.54343414" ]
0.573055
72
Subject can be set in your I18n file at config/locales/en.yml with the following lookup: en.user_mailer.contactUs.subject
def contactUs(name, email, phone, question, contact_pref) @contact_pref = contact_pref @name = name @email = email @phone = phone @question = question @greeting = @name + " " + "Has a question!" @subject = "User Question" mail to: "bubba99207@gmail.com", subject: @subject end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def translate(mapping, key)\n I18n.t(:\"#{mapping.name}_subject\", :scope => [:devise, :mailer, key],\n :default => [:subject, key.to_s.humanize])\n end", "def message_subject=(value)\n @message_subject = value\n end", "def subject (recipient)\n subject_variables = alert_variables[:subject].dup\n subject_variables.merge!(recipient_details(recipient))\n subject = \"#{I18n.t(\"#{recipient_type.to_s}_subject_#{alert_name.to_s}\", subject_variables)}\"\n subject\n end", "def subject\n self['subject'] || msg['subject']\n end", "def subject\n @subject ||= Envelope::MessageTools.normalize(message.subject || '')\n end", "def subject\n @mail.subject\n end", "def set_EmailSubject(value)\n set_input(\"EmailSubject\", value)\n end", "def set_EmailSubject(value)\n set_input(\"EmailSubject\", value)\n end", "def translate(mapping, key)\n I18n.t(:\"notifications_subject\", :scope => [:eventifier, :notifications, key],\n :default => [:subject, key.to_s.humanize])\n end", "def set_EmailSubject(value)\n set_input(\"EmailSubject\", value)\n end", "def set_EmailSubject(value)\n set_input(\"EmailSubject\", value)\n end", "def formatted_subject(text)\n name = PersonMailer.global_prefs.app_name\n label = name.blank? ? \"\" : \"[#{name}] \"\n \"#{label}#{text}\"\n end", "def subject=(subject); @message_impl.setSubject subject; end", "def subject\n @subject ||= \"(sans sujet)\"\n if @no_header_subject.nil?\n \"#{header_subject}#{@subject}\"\n else\n @subject\n end\n end", "def subject_name=(value)\n @subject_name = value\n end", "def subject=(string)\n set('Subject', string)\n end", "def email_subject(form)\n \"#{form.type_of_enquiry} - #{reference}\"\n end", "def subject() self.headers[\"Subject\"] || \"[NO SUBJECT]\" end", "def subject_for(template, attributes = {})\n subject = EmailTemplate.subject_for(template)\n subject = I18n.t(\"email_templates.#{template}.default_subject\") if subject.nil?\n subject = \"No Subject\" if subject.nil?\n Florrick.convert(subject, add_default_attributes(attributes))\n end", "def set_Subject(value)\n set_input(\"Subject\", value)\n end", "def set_Subject(value)\n set_input(\"Subject\", value)\n end", "def set_Subject(value)\n set_input(\"Subject\", value)\n end", "def set_Subject(value)\n set_input(\"Subject\", value)\n end", "def set_Subject(value)\n set_input(\"Subject\", value)\n end", "def set_Subject(value)\n set_input(\"Subject\", value)\n end", "def set_Subject(value)\n set_input(\"Subject\", value)\n end", "def set_Subject(value)\n set_input(\"Subject\", value)\n end", "def setSubject(subject)\n @fields['subject'] = subject\n self\n end", "def setSubject(subject)\n @fields['subject'] = subject\n self\n end", "def setSubject(subject)\n @fields['subject'] = subject\n self\n end", "def setSubject(subject)\n @fields['subject'] = subject\n self\n end", "def headers\n { subject: \"#{I18n.t('cms.contact_form.subject_prefix')}: #{reason}: #{subject}\",\n to: Account.current.preferred_support_email,\n from: Account.current.preferred_support_email,\n reply_to: %(\"#{name}\" <#{email}>) }\n end", "def subject_name\n return @subject_name\n end", "def subject_name\n subject_full_name\n end", "def subject\n @options.fetch(:subject) { \"Invitation\" }\n end", "def headers\n {\n :subject => \"Contact Form:#{subject}\",\n :to => Sufia::Engine.config.contact_email, \n :from => Sufia::Engine.config.from_email\n }\n end", "def get_email_subject(email_type)\n email_subject = email_type\n case(email_type)\n when \"welcome\"\n email_subject = \"Welcome to Aspera Files\"\n when \"reset\"\n email_subject = \"Password Reset\"\n end\n return email_subject\n end", "def message_subject\n return @message_subject\n end", "def subject=(value)\n @subject = value\n end", "def subject=(value)\n @subject = value\n end", "def subject=(value)\n @subject = value\n end", "def subject=(value)\n @subject = value\n end", "def subject=(value)\n @subject = value\n end", "def subject=(value)\n @subject = value\n end", "def email_subject\n sponsor_name = @config.plan.sponsor_name\n display_date = @date.to_s()\n if @config.div_id.present?\n email_subject = \"Payroll report for #{sponsor_name} for division #{@config.division_name}: #{display_date}\"\n else\n email_subject = \"Payroll report for #{sponsor_name}: #{display_date}\"\n end\n return email_subject\n end", "def set_subject(subject)\n\t\tend", "def subject\n message.subject\n end", "def getEmailDefaults(subject, toEmail, ccEmail = nil)\n if Rails.env.eql? 'development'\n subject = \"[BASL-DEV] #{subject}\"\n toEmail = 'paigepon@gmail.com'\n ccEmail = toEmail\n else\n subject = \"[BASL] #{subject}\"\n end\n mailInfo = {\n :to => toEmail,\n :subject => subject,\n :cc => ccEmail\n }\n mailInfo\n end", "def subject(options = {})\n options = { :capitalize => true, :case => Grammar::Case::SUBJECT }.merge(options)\n pronoun_or_noun(@subject, @audience, options)\n end", "def headers\n { subject: \"#{site_name} contact form\", to: site_email, from: email }\n end", "def choose_subject(action, params = {})\n scope = [:mailers, mailer_name, action]\n key = :subject\n experiment_name = \"#{mailer_name}_mailer_#{action}_subject\".to_sym\n if experiment_active?(experiment_name)\n scope << key\n key = ab_test(experiment_name)\n end\n params.merge!(scope: scope)\n I18n.t(key, params)\n end", "def subject\n self['subject']\n end", "def deliver_invitation(options = {})\n super(options.merge(subject: _('A Data Management Plan in %{application_name} has been shared with you') % {application_name: Rails.configuration.branding[:application][:name]}))\n end", "def headers\n {\n :subject => \"Contact from website\",\n :to => Site.current.preferred_contact_email,\n :from => %(\"#{lastname}\" <#{email}>)\n }\n end", "def headers\n {\n :subject => \"Contact from website\",\n :to => Site.current.preferred_contact_email,\n :from => %(\"#{lastname}\" <#{email}>)\n }\n end", "def headers\n {\n :subject => %(#{subject}),\n :to => Contact.first.email,\n :body => %(#{message}),\n :from => %(\"#{email}\")\n }\n end", "def user_added_email(user)\n ActsAsTenant.without_tenant do\n @course = user.course\n end\n @recipient = user.user\n\n I18n.with_locale(@recipient.locale) do\n mail(to: @recipient.email, subject: t('.subject', course: @course.title))\n end\n end", "def contact_us_template\n 'contact_us'\n end", "def SetSubject(subject)\n\t\t#Subject of document\n\t\t@subject = subject\n\tend", "def email_subject(&blk)\n @email_subject_block = blk if blk\n @email_subject_block\n end", "def subject; @message_impl.getSubject; end", "def custom_mail( user, subject, title, contents )\n @user = user\n @host = GogglesCore::AppConstants::WEB_MAIN_DOMAIN_NAME\n @contents = contents\n @title = title\n #subject: \"[#{ GogglesCore::AppConstants::WEB_APP_NAME }@#{ @host }] #{ subject }\",\n mail(\n subject: \"#{ subject } [#{GogglesCore::AppConstants::WEB_APP_NAME}]\",\n to: user.email,\n date: Time.now\n )\n end", "def i18n_label\n \"email.#{name}_label\"\n end", "def get_subject_name\n subject_name = subject_header.text.sub! 'Subject:', ''\n subject_name = subject_name.strip!\n subject_name\n end", "def contact_message(contact, store, email)\n @contact = contact\n @store = store\n\n mail(to: email, subject: 'Thanks for contact us')\n end", "def headers\n {\n subject: I18n.t('contact.subject'),\n to: info_email,\n from: \"Deskspotting <#{info_email}>\"\n }\n end", "def contact_us(contact)\n @contact = contact\n mail( to: TO, subject: \"Contact Us Request by #{@contact.name.camelcase} #{Time.current.strftime('%b %d, %Y %H:%M %p')}\")\n end", "def subject(options)\n case [options[:person], options[:plurality]]\n when %i[first singular]\n 'I'\n when %i[first plural]\n 'we'\n when %i[second singular], %i[second plural]\n 'you'\n when %i[third singular]\n 'he'\n when %i[third plural]\n 'they'\n end\n end", "def set_subject_and_message(form, subject, message)\n raise Impostor::MissingTemplateMethodError.new(\"set_subject_and_message must be implemented\")\n end", "def normalize_subject_name\n self.subject = subject.downcase.titleize\n end", "def setup_email(user)\n @recipients = user.email\n @body[:user] = user\n @from = FROM_EMAIL\n @subject = case ENV['RAILS_ENV'] \n when 'development': \"[YourApp Development] \"\n when 'staging': \"[YourApp Staging] \"\n else \"[YourApp] \"\n end\n @sent_on = Time.now\n headers \"Reply-to\" => FROM_EMAIL\n end", "def compose_email\n @title = t 'conclusion_draft_review.send_by_email'\n end", "def mmm_test_subj_call\n ->(candidate) { I18n.t('email.test_monthly_mail_subject_initial_input', candidate_account_name: candidate.account_name) }\n end", "def subject\n @subject=EzCrypto::Name.new(@cert.subject) unless @subject\n @subject\n end", "def headers\n {\n :subject => \"澄清:對於#{candidate_name}的#{record_type}\",\n # :to => \"wevote@watchout.tw\",\n :to => Setting.email.clarify,\n :from => %(\"#{name}\" <#{email}>)\n }\n end", "def email_us(subject, body)\n unless ENV['RACK_ENV'] == 'development'\n recipient = \"The Awesome Team <openhsv@gmail.com>\"\n\n # First, instantiate the Mailgun Client with your API key\n mg_client = Mailgun::Client.new ENV['MAILGUN_PRIVATE']\n\n # Define your message parameters\n message_params = { from: 'postmaster@sandboxa148f93a5c5f4813a81365d1b873ee8f.mailgun.org',\n to: recipient,\n subject: subject,\n html: body,\n text: Nokogiri::HTML(body).text\n }\n\n # Send your message through the client\n mg_client.send_message 'sandboxa148f93a5c5f4813a81365d1b873ee8f.mailgun.org', message_params\n end # unless ENV['RACK_ENV'] == 'development'\n end", "def contact_mail\n @greeting = \"お問い合わせ\"\n # @contact = contact\n\n mail to: \"to@example.org\"\n\n mail subject: \"myAppからお問い合わせがありました\"\n end", "def get_subject\n\t\tend", "def subject\n title \n end", "def new_contact_intro_email(user, contact)\n if user.name.present?\n @name = user.name.titlecase\n else\n @name = user.email\n end\n\n @signature = user.signature\n @email = user.email\n\n mail to: contact.email, reply_to: @email, from: \"\\\"#{@name}\\\" <#{@email}>\", subject: \"#{@name} wants to stay in touch with you!\"\n Email.create(:user_id => user.id, :sent_to => contact.id, :title => \"new_contact_intro_email\", :contacts => contact.id)\n end", "def translation_scope\n \"mailers.#{mailer_name.tr(\"/\", \".\").sub(\"_mailer\", \"\")}.#{action_name}\"\n end", "def headers\n {\n :subject => \"Contact ULAP Research\",\n :to => \"ulap.research@gmail.com\",\n :from => %(\"#{name}\" <#{email}>)\n }\n end", "def headers\n {\n :subject => \"#{subject}\",\n :to => \"tempress@temple.edu\",\n :from => %(\"#{name}\" <#{email}>)\n }\n end", "def set_title\n @title = t(:message_2, :scope => [:controller, :exams])\n end", "def build_email_kase(options={})\n EmailKase.new({\n :kase => self,\n :subject => \"%{name} wants to know what you think\".t % {:name => self.person.casualize_name}\n }.merge(options))\n end", "def headers\r\n {\r\n :subject => \"My Contact Form\",\r\n :to => \"alama.tounkara@gmail.com\",\r\n :from => %(\"#{name}\" <#{email}>)\r\n }\r\n end", "def contact_us\r\n\t@title = \"Contact Us\"\r\n end", "def data_subject=(value)\n @data_subject = value\n end", "def headers\r\n {\r\n :subject => \"JP Health Insurance Contact Form\",\r\n :to => [\"contact@jpfinancialgroupllc.com\", \"chamiesemarion@gmail.com\", \"cc@ccevans.com\"],\r\n :from => %(\"#{name}\" <#{email}>)\r\n }\r\n end", "def subject_names\n @subject_names ||= sw_subject_names\n end", "def default_sender_address\n address = Mail::Address.new(Gitlab.config.gitlab.email_from)\n address.display_name = \"GitLab\"\n address\n end", "def community_member_email(sender, recipient, email_subject, email_content, community)\n @email_type = \"email_from_admins\"\n set_up_layout_variables(recipient, community, @email_type)\n with_locale(recipient.locale, community.locales.map(&:to_sym), community.id) do\n @email_content = email_content\n @no_recipient_name = true\n premailer_mail(:to => recipient.confirmed_notification_emails_to,\n :from => community_specific_sender(community),\n :subject => email_subject,\n :reply_to => \"\\\"#{sender.name(community)}\\\"<#{sender.confirmed_notification_email_to}>\")\n end\n end", "def newcompany_email(company)\n @company = company\n @message = t('mailers.company.created')\n \n emails = AdminUser.all.collect(&:email).join(\",\")\n\n mail(:to => emails, :subject => \"#{t('site_title')}: #{@message}\")\n \n end", "def contact(contact)\n @recipients = App[:recipients]\n @body[:contact] = contact\n @from = App[:from]\n @subject =\"咨询\"+ contact.name\n @sent_on = Time.now\n end", "def konsalt_mail params\n build_params params\n send_email t('emails.konsalta_mail.subject')\n end", "def subject_titles\n @subject_titles ||= sw_subject_titles\n end", "def default_i18n_subject(interpolations = {})\n ''\n end", "def headers\n {\n :subject => \"My Contact Form\",\n :to => \"cmaxwell@ojala.com\",\n :from => %(\"#{name}\" <#{email}>)\n }\n end", "def headers\n {\n :subject => \"My Contact Form\",\n :to => \"ahamdi.it@gmail.com\",\n :from => %(\"#{name}\" <#{email}>)\n }\n end", "def notify_course_teaching_assignment( user , course ) \n @course = course\n @subject = @course.subject \n @school = @subject.school\n @user = user\n mail( :to => user.email, \n :subject => \"potoSchool | Tuga Mengajar pelajaran #{@subject.name}, kelas #{@course.name} \" )\n end" ]
[ "0.71999085", "0.71812636", "0.71363145", "0.69230187", "0.68938017", "0.67406553", "0.6725831", "0.6724764", "0.66969573", "0.66559994", "0.66541964", "0.6632981", "0.6627675", "0.66057485", "0.65181434", "0.6511013", "0.6488825", "0.6427663", "0.6367147", "0.6342508", "0.6342508", "0.6342508", "0.6342508", "0.6342508", "0.6342508", "0.6342508", "0.6342508", "0.6306356", "0.6306356", "0.6306356", "0.6306356", "0.628321", "0.62800425", "0.6277895", "0.6250475", "0.6242603", "0.623537", "0.62253046", "0.6214926", "0.6214926", "0.6214926", "0.6214926", "0.6214926", "0.6214926", "0.61936", "0.61531794", "0.61108816", "0.6106525", "0.6084198", "0.60729736", "0.6064559", "0.6057088", "0.60523397", "0.604051", "0.604051", "0.60024816", "0.59969145", "0.5993984", "0.5971998", "0.5969575", "0.5953589", "0.59447575", "0.5918031", "0.59033346", "0.5902686", "0.58925045", "0.58712244", "0.5868402", "0.58631736", "0.58599913", "0.5856116", "0.5836504", "0.5829554", "0.5821082", "0.58141875", "0.58038145", "0.57980084", "0.5783515", "0.57400787", "0.57326424", "0.5726326", "0.5725633", "0.57110626", "0.5699307", "0.5695361", "0.56936985", "0.56913954", "0.56900865", "0.56884927", "0.56834537", "0.56808937", "0.5673251", "0.56638366", "0.5660017", "0.5651145", "0.56501716", "0.56495863", "0.5644915", "0.56447554", "0.5644355" ]
0.59062636
63
define the arguments that the user will input
def arguments(model) args = OpenStudio::Ruleset::OSArgumentVector.new # create an argument for a space type to be used in the model, to see if one should be mapped as ceiling return air plenum spaceTypes = model.getSpaceTypes usedSpaceTypes_handle = OpenStudio::StringVector.new usedSpaceTypes_displayName = OpenStudio::StringVector.new spaceTypes.each do |spaceType| #todo - I need to update this to use helper so GUI sorts by display name if spaceType.spaces.size > 0 # only show space types used in the building usedSpaceTypes_handle << spaceType.handle.to_s usedSpaceTypes_displayName << spaceType.name.to_s end end # make an argument for space type ceilingReturnPlenumSpaceType = OpenStudio::Ruleset::OSArgument::makeChoiceArgument("ceilingReturnPlenumSpaceType", usedSpaceTypes_handle, usedSpaceTypes_displayName,false) ceilingReturnPlenumSpaceType.setDisplayName("This space type should be part of a ceiling return air plenum.") #ceilingReturnPlenumSpaceType.setDefaultValue("We don't want a default, this is an optional argument") args << ceilingReturnPlenumSpaceType # make an argument for material and installation cost # todo - I would like to split the costing out to the air loops weighted by area of building served vs. just sticking it on the building costTotalHVACSystem = OpenStudio::Ruleset::OSArgument::makeDoubleArgument("costTotalHVACSystem",true) costTotalHVACSystem.setDisplayName("Total Cost for HVAC System ($).") costTotalHVACSystem.setDefaultValue(0.0) args << costTotalHVACSystem #make an argument to remove existing costs remake_schedules = OpenStudio::Ruleset::OSArgument::makeBoolArgument("remake_schedules",true) remake_schedules.setDisplayName("Apply recommended availability and ventilation schedules for air handlers?") remake_schedules.setDefaultValue(true) args << remake_schedules return args end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def arguments; end", "def arguments; end", "def arguments; end", "def arguments\n \"\"\n end", "def args; end", "def args; end", "def args; end", "def args; end", "def args; end", "def args; end", "def args; end", "def args; end", "def args; end", "def args; end", "def args; end", "def args; end", "def args; end", "def args; end", "def args; end", "def args; end", "def args; end", "def args; end", "def args; end", "def args; end", "def get_input \n puts \"to save this game, input 's,filename'\"\n puts \"to load a game, input 'l,filename'\"\n puts \"input a coordinate to access. prefix with r for reveal or f for flag\"\n puts \"example 'f,1,2' places a flag at 1,2\"\n input = gets.chomp\n \n args = input.split(',')\n end", "def args(*) end", "def arguments(required, *optional)\n puts \"required: #{required}\"\n puts \"optional: #{optional}\"\nend", "def args()\n #This is a stub, used for indexing\n end", "def arguments()\n args = OpenStudio::Ruleset::OSArgumentVector.new\n\n #make an argument for the variable name\n variable_name = OpenStudio::Ruleset::OSArgument::makeStringArgument(\"variable_name\",true)\n variable_name.setDisplayName(\"Enter Variable Name.\")\n variable_name.setDescription(\"Valid values can be found in the eplusout.rdd file after a simulation is run.\")\n args << variable_name\n \n #make an argument for the electric tariff\n reporting_frequency_chs = OpenStudio::StringVector.new\n reporting_frequency_chs << \"Detailed\"\n reporting_frequency_chs << \"Timestep\"\n reporting_frequency_chs << \"Zone Timestep\"\n reporting_frequency_chs << \"Hourly\"\n reporting_frequency_chs << \"Daily\"\n reporting_frequency_chs << \"Monthly\"\n reporting_frequency_chs << \"Runperiod\"\n reporting_frequency = OpenStudio::Ruleset::OSArgument::makeChoiceArgument('reporting_frequency', reporting_frequency_chs, true)\n reporting_frequency.setDisplayName(\"Reporting Frequency.\")\n reporting_frequency.setDefaultValue(\"Hourly\")\n args << reporting_frequency\n\n #make an argument for the key_value\n key_value = OpenStudio::Ruleset::OSArgument::makeStringArgument(\"key_value\",true)\n key_value.setDisplayName(\"Enter Key Name.\")\n key_value.setDescription(\"Enter * for all objects or the full name of a specific object to.\")\n key_value.setDefaultValue(\"*\")\n args << key_value\n \n env = OpenStudio::Ruleset::OSArgument.makeStringArgument(\"env\", true)\n env.setDisplayName(\"availableEnvPeriods\")\n env.setDescription(\"availableEnvPeriods\")\n env.setDefaultValue(\"RUN PERIOD 1\")\n args << env\n \n return args\n end", "def arguments\n args = OpenStudio::Measure::OSArgumentVector.new\n\n # make an argument for the variable name\n variable_name = OpenStudio::Measure::OSArgument.makeStringArgument('variable_name', true)\n variable_name.setDisplayName('Enter Variable Name.')\n variable_name.setDescription('Valid values can be found in the eplusout.rdd file after a simulation is run.')\n args << variable_name\n\n # make an argument for the electric tariff\n reporting_frequency_chs = OpenStudio::StringVector.new\n reporting_frequency_chs << 'Detailed'\n reporting_frequency_chs << 'Timestep'\n reporting_frequency_chs << 'Zone Timestep'\n reporting_frequency_chs << 'Hourly'\n reporting_frequency_chs << 'Daily'\n reporting_frequency_chs << 'Monthly'\n reporting_frequency_chs << 'Runperiod'\n reporting_frequency = OpenStudio::Measure::OSArgument.makeChoiceArgument('reporting_frequency', reporting_frequency_chs, true)\n reporting_frequency.setDisplayName('Reporting Frequency.')\n reporting_frequency.setDefaultValue('Hourly')\n args << reporting_frequency\n\n # make an argument for the key_value\n key_value = OpenStudio::Measure::OSArgument.makeStringArgument('key_value', true)\n key_value.setDisplayName('Enter Key Name.')\n key_value.setDescription('Enter * for all objects or the full name of a specific object to.')\n key_value.setDefaultValue('*')\n args << key_value\n\n env = OpenStudio::Measure::OSArgument.makeStringArgument('env', true)\n env.setDisplayName('availableEnvPeriods')\n env.setDescription('availableEnvPeriods')\n env.setDefaultValue('RUN PERIOD 1')\n args << env\n\n args\n end", "def set_arguments (args)\n end", "def handle_arguments(args)\n if input_file.nil?\n print_usage\n true\n else\n args.help || args.version\n end\n end", "def arguments=(_arg0); end", "def command_line\r\n ARGV.each do |arg|\r\n if arg == \"instructions\"\r\n instructions\r\n elsif arg == \"calculator\"\r\n ask_for_digits\r\n else\r\n \r\n end\r\n end\r\n \r\n end", "def prescreen_input(args)\n if ((args.nil?) || (args.empty?))\n ['-eq', Date.today.strftime('%Y-%m-%d')]\n elsif ((args.length == 1) && (args[0].is_date?))\n ['-eq', args[0]]\n else\n args\n end\nend", "def varios_args(*args)\n puts \"Tamanho de args: #{args.size}\"\n args.each { |x| p x}\n end", "def process_arguments\n @e_addr = @options.email\n @r_name = @options.run_names\n @m_name = @options.machine_names\n @action = @options.action\n @snfs = @options.snfs\n end", "def arguments\n args = OpenStudio::Measure::OSArgumentVector.new\n\n # url of the city database\n city_db_url = OpenStudio::Measure::OSArgument.makeStringArgument('city_db_url', true)\n city_db_url.setDisplayName('City Database Url')\n city_db_url.setDescription('Url of the City Database')\n city_db_url.setDefaultValue('')\n args << city_db_url\n\n # project id to update\n project_id = OpenStudio::Measure::OSArgument.makeStringArgument('project_id', true)\n project_id.setDisplayName('Project ID')\n project_id.setDescription('Project ID to generate reports for.')\n project_id.setDefaultValue('0')\n args << project_id\n\n # datapoint id to update\n datapoint_id = OpenStudio::Measure::OSArgument.makeStringArgument('datapoint_id', true)\n datapoint_id.setDisplayName('Datapoint ID')\n datapoint_id.setDescription('Datapoint ID to generate reports for.')\n datapoint_id.setDefaultValue('0')\n args << datapoint_id\n\n return args\n end", "def validate_args (args)\n\t# todo\nend", "def args() return @args end", "def input=(_arg0); end", "def process_inputs(args)\n @input = ((name = args[:in_file]) && (IO.read(name, mode: \"rb\"))) ||\n args[:in_str] ||\n fail(\"An input must be specified.\")\n\n @generator = args[:generator] ||\n ((key = args[:key]) && Generator.new(key)) ||\n fail(\"A key or generator must be specified.\")\n\n @window = args[:window] || 16\n\n #The filler value is for testing purposes only. It should\n #not be specified when secure operation is desired.\n @fill_value = args[:filler]\n end", "def parse_args\r\n if(cmd.args =~ /\\=/)\r\n self.names = InputFormatter.titlecase_arg(cmd.args.before(\"=\"))\r\n self.action_args = cmd.args.after(\"=\")\r\n elseif (cmd.args && one_word_command)\r\n self.names = InputFormatter.titlecase_arg(cmd.args)\r\n self.action_args = \"\"\r\n else\r\n self.names = enactor.name\r\n self.action_args = cmd.args\r\n end\r\n\r\n self.names = self.names ? self.names.split(/[ ,]/) : nil\r\n\r\n self.combat_command = cmd.switch ? cmd.switch.downcase : nil\r\n end", "def manage_args(*args)\n end", "def arguments(model)\n args = OpenStudio::Ruleset::OSArgumentVector.new\n \n #make an argument for your name\n user_name = OpenStudio::Ruleset::OSArgument::makeStringArgument(\"user_name\",true)\n user_name.setDisplayName(\"What is your name?\")\n args << user_name\n\n #make an argument to add new space true/false\n add_space = OpenStudio::Ruleset::OSArgument::makeBoolArgument(\"add_space\",true)\n add_space.setDisplayName(\"Add a space to your model?\")\n add_space.setDefaultValue(true)\n args << add_space\n \n return args\n end", "def greeting\n puts \"Hello, MTA rider! How can we help?\"\n puts \"please enter one of the following commands:\"\n puts \"lines / stops the_line / calculate Departing_Line Departing_Stop Arriving_Line Arriving_Stop\"\n user_call, *user_args = gets.chomp\n user_args.to_s\n # user_args.split(\" \")\n # puts user_input\n\n if user_call == lines\n show_lines()\n elsif user_call == stops\n show_stops(user_args[0])\n elsif user_call == calculate\n if user_args.length < 4\n puts 'please enter \"Departing_Line Departing_Stop Arriving_Line Arriving_Stop\"'\n puts 'or enter \"exit\" to return to the home screen' \n user_input = gets.chomp\n if user_input == \"exit\"\n greeting()\n end \n user_input = user_input.split(\" \")\n calculate(user_input[0], user_input[1], user_input[2], user_input[3])\n else\n calculate(user_args[0], user_args[1], user_args[2], user_args[3])\n end\n else\n \n end\nend", "def arguments(model)\n args = OpenStudio::Measure::OSArgumentVector.new\n\n\n\n # Make an argument for evap effectiveness\n input_csv_path = OpenStudio::Measure::OSArgument::makeStringArgument(\"input_csv_folder_path\",true)\n input_csv_path.setDisplayName(\"raw_data_input_folder_path\")\n input_csv_path.setDefaultValue(\"data_file\")\n args << input_csv_path\n\n test_numbers = OpenStudio::StringVector.new\n test_numbers << 'Test_3'\n test_numbers << 'Test_6'\n test_numbers << 'Test_8'\n \n test_names = OpenStudio::StringVector.new\n test_names << 'UA_test'\n test_names << 'Cooling_test'\n test_names << 'Plenum_test'\n\n test_selections = OpenStudio::Ruleset::OSArgument::makeChoiceArgument('test_data',test_numbers,test_names,true)\n\n \n test_selections.setDisplayName(\"Experiment\")\n test_selections.setDefaultValue(\"Test_3\")\n args << test_selections\n\n \n return args\n end", "def arguments\n args = OpenStudio::Ruleset::OSArgumentVector.new\n\n # URL of the DEnCity server that will be posted to\n hostname = OpenStudio::Ruleset::OSArgument::makeStringArgument('hostname', true)\n hostname.setDisplayName('URL of the DEnCity Server')\n hostname.setDefaultValue('http://www.dencity.org')\n args << hostname\n\n # DEnCity server user id at hostname\n user_id = OpenStudio::Ruleset::OSArgument::makeStringArgument('user_id',true)\n user_id.setDisplayName('User ID for DEnCity Server')\n args << user_id\n\n # DEnCIty server user id's password\n auth_code = OpenStudio::Ruleset::OSArgument::makeStringArgument('auth_code', true)\n auth_code.setDisplayName('Authentication code for User ID on DEnCity server')\n args << auth_code\n\n # Building type for DEnCity's metadata\n building_type = OpenStudio::Ruleset::OSArgument::makeStringArgument('building_type', false)\n building_type.setDisplayName('Building type')\n args << building_type\n\n # HVAC system for DEnCity's metadata\n primary_hvac = OpenStudio::Ruleset::OSArgument::makeStringArgument('primary_hvac', false)\n primary_hvac.setDisplayName('Primary HVAC system in building')\n args << primary_hvac\n\n args\n\n end", "def arguments\r\n args = OpenStudio::Ruleset::OSArgumentVector.new\r\n\r\n #make choice argument for facade\r\n choices = OpenStudio::StringVector.new\r\n choices << \"MessagePack\"\r\n choices << \"CSV\"\r\n choices << \"Both\"\r\n output_format = OpenStudio::Ruleset::OSArgument::makeChoiceArgument(\"output_format\", choices)\r\n output_format.setDisplayName(\"Output Format\")\r\n output_format.setDefaultValue(\"Both\")\r\n args << output_format\r\n\r\n args\r\n end", "def arguments(model)\n args = OpenStudio::Measure::OSArgumentVector.new\n\t\n #make an argument for entering furnace installed afue\n afue = OpenStudio::Measure::OSArgument::makeDoubleArgument(\"afue\",true)\n afue.setDisplayName(\"Installed AFUE\")\n afue.setUnits(\"Btu/Btu\")\n afue.setDescription(\"The installed Annual Fuel Utilization Efficiency (AFUE) of the furnace, which can be used to account for performance derating or degradation relative to the rated value.\")\n afue.setDefaultValue(1.0)\n args << afue\n\n #make an argument for entering furnace installed supply fan power\n fanpower = OpenStudio::Measure::OSArgument::makeDoubleArgument(\"fan_power_installed\",true)\n fanpower.setDisplayName(\"Installed Supply Fan Power\")\n fanpower.setUnits(\"W/cfm\")\n fanpower.setDescription(\"Fan power (in W) per delivered airflow rate (in cfm) of the indoor fan for the maximum fan speed under actual operating conditions.\")\n fanpower.setDefaultValue(0.5)\n args << fanpower\t\n\t\n #make a string argument for furnace heating output capacity\n furnacecap = OpenStudio::Measure::OSArgument::makeStringArgument(\"capacity\", true)\n furnacecap.setDisplayName(\"Heating Capacity\")\n furnacecap.setDescription(\"The output heating capacity of the furnace. If using '#{Constants.SizingAuto}', the autosizing algorithm will use ACCA Manual S to set the capacity.\")\n furnacecap.setUnits(\"kBtu/hr\")\n furnacecap.setDefaultValue(Constants.SizingAuto)\n args << furnacecap\n \n return args\n end", "def greeting(args)\r\n greet = args[:greet] || \"Hi\"\r\n title = args[:title] || \"Citizen\"\r\n name = args[:name] \r\n puts \"#{greet} #{title} #{name}\"\r\nend", "def parse_args\n\t\t@args = @args_a.each_slice(2).to_a.inject({}) { |h, k| h[k[0]] = k[1]; h }\n\t\tkeys = @skeys + @lkeys\n\t\t@args.each do |k, v|\n\t\t\tif !keys.include?(k)\n\t\t\t\tputs \"Unknown option `#{k}'\"\n\t\t\t\texit\n\t\t\tend\n\n\t\t\tif keys.include?(v)\n\t\t\t\tputs \"Missing values for `#{k}' and `#{v}'\"\n\t\t\t\texit\n\t\t\tend\n\n\t\t\tif v != nil\n\t\t\t\tif v.start_with?('-')\n\t\t\t\t\tputs \"Warning: Value of `#{k}' appears to be a flag\"\n\t\t\t\tend\n\n\t\t\t\tif @static.has_key?(k)\n\t\t\t\t\tif !@static[k].include?(v)\n\t\t\t\t\t\tputs \"Unknown option `#{v}' for `#{k}'\"\n\t\t\t\t\t\texit\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\t\n\t\tif remove_keys(@no_vals).has_blank?\n\t\t\tputs \"Missing argument(s)\"\n\t\t\texit\n\t\tend\t\t\t\n\tend", "def command_line_arguments(array)\n array.size.times do\n if array.include?('-nc')\n colour_changer(:white)\n array.delete('-nc')\n elsif array.any? { |x| ['-d1', '-d2', '-d3', '-d4'].include? x }\n key = (array[0])[1, 2].to_sym\n @difficulty = DIFFICULTY[key]\n @promptarr = prompt_select(key)\n @intro = false\n end\n end\n end", "def arguments()\n args = OpenStudio::Measure::OSArgumentVector.new\n \n #make an argument for the frequency\n reporting_frequency_chs = OpenStudio::StringVector.new\n reporting_frequency_chs << \"Detailed\"\n reporting_frequency_chs << \"Timestep\"\n reporting_frequency_chs << \"Hourly\"\n reporting_frequency_chs << \"Daily\"\n reporting_frequency_chs << \"Monthly\"\n reporting_frequency_chs << \"Runperiod\"\n reporting_frequency = OpenStudio::Ruleset::OSArgument::makeChoiceArgument('reporting_frequency', reporting_frequency_chs, true)\n reporting_frequency.setDisplayName(\"Reporting Frequency\")\n reporting_frequency.setDefaultValue(\"Hourly\")\n args << reporting_frequency\n \n # TODO: argument for subset of output meters\n \n return args\n end", "def arguments()\n args = OpenStudio::Measure::OSArgumentVector.new\n\n #make an argument for the frequency\n reporting_frequency_chs = OpenStudio::StringVector.new\n reporting_frequency_chs << \"Timestep\"\n reporting_frequency_chs << \"Hourly\"\n reporting_frequency_chs << \"Daily\"\n reporting_frequency_chs << \"Monthly\"\n reporting_frequency_chs << \"RunPeriod\"\n arg = OpenStudio::Measure::OSArgument::makeChoiceArgument('reporting_frequency', reporting_frequency_chs, true)\n arg.setDisplayName(\"Reporting Frequency\")\n arg.setDefaultValue(\"Hourly\")\n args << arg\n\n #make an argument for including optional output variables\n arg = OpenStudio::Measure::OSArgument::makeBoolArgument(\"inc_output_variables\", true)\n arg.setDisplayName(\"Include Output Variables\")\n arg.setDefaultValue(false)\n args << arg\n\n return args\n end", "def arguments(model)\n args = OpenStudio::Ruleset::OSArgumentVector.new\n\n #make an argument for entering furnace installed afue\n userdefined_eff = OpenStudio::Ruleset::OSArgument::makeDoubleArgument(\"userdefinedeff\",true)\n userdefined_eff.setDisplayName(\"Efficiency\")\n\tuserdefined_eff.setUnits(\"Btu/Btu\")\n\tuserdefined_eff.setDescription(\"The efficiency of the electric baseboard.\")\n userdefined_eff.setDefaultValue(1.0)\n args << userdefined_eff\n\n #make a choice argument for furnace heating output capacity\n cap_display_names = OpenStudio::StringVector.new\n cap_display_names << Constants.SizingAuto\n (5..150).step(5) do |kbtu|\n cap_display_names << \"#{kbtu} kBtu/hr\"\n end\n\n #make a string argument for furnace heating output capacity\n selected_baseboardcap = OpenStudio::Ruleset::OSArgument::makeChoiceArgument(\"selectedbaseboardcap\", cap_display_names, true)\n selected_baseboardcap.setDisplayName(\"Heating Output Capacity\")\n selected_baseboardcap.setDefaultValue(Constants.SizingAuto)\n args << selected_baseboardcap\n\t\n return args\n end", "def user_input_command_line_menu\n\tcommand_line_input = gets.strip.to_i\n\tcommand_line_input_logic(command_line_input)\nend", "def arguments(model)\n args = OpenStudio::Measure::OSArgumentVector.new\n\n #make an argument for entering baseboard efficiency\n baseboardeff = OpenStudio::Measure::OSArgument::makeDoubleArgument(\"efficiency\",true)\n baseboardeff.setDisplayName(\"Efficiency\")\n baseboardeff.setUnits(\"Btu/Btu\")\n baseboardeff.setDescription(\"The efficiency of the electric baseboard.\")\n baseboardeff.setDefaultValue(1.0)\n args << baseboardeff\n\n #make a string argument for baseboard heating output capacity\n baseboardcap = OpenStudio::Measure::OSArgument::makeStringArgument(\"capacity\", true)\n baseboardcap.setDisplayName(\"Heating Capacity\")\n baseboardcap.setDescription(\"The output heating capacity of the electric baseboard. If using '#{Constants.SizingAuto}', the autosizing algorithm will use ACCA Manual S to set the capacity.\")\n baseboardcap.setUnits(\"kBtu/hr\")\n baseboardcap.setDefaultValue(Constants.SizingAuto)\n args << baseboardcap\n\t\n return args\n end", "def cmdarg; end", "def cmdarg; end", "def cmdarg; end", "def check_inputs_g(args)\n raise TypeError, Ajaila::Messager.warning(\"Nothing to generate...\") if args == []\n raise TypeError, Ajaila::Messager.warning(\"Only miners, selectors, presenters supported\\n(ex. miner SomeMiner, selector SomeSelector,\\n presenter SomePresenter, table SomeTable)\") if KNOWN_INSTANCES.include?(args[0]) == false\n raise TypeError, Ajaila::Messager.warning(\"Your #{args[0]} needs a name!\") if args[1] == nil\n raise TypeError, Ajaila::Messager.warning(\"Wrong format of the #{args[0]} name (use only A-Z and a-z symbols)\") if args[1][/^[A-Z]+$/i] == nil\n return 0\n end", "def arguments\n parser.arguments\n end", "def valid_args(type)\n case type\n when 'search' then %i[q format addressdetails extratags namedetails viewbox bounded exclude_place_ids limit accept-language email]\n when 'reverse' then %i[format lat lon zoom addressdetails extratags namedetails accept-language email]\n else []\n end\n end", "def madlib_inputs\n print \"Enter a noun: \" \n noun = gets.chomp\n print \"Enter a verb: \" \n verb = gets.chomp\n print \"Enter an adjective: \" \n adjective = gets.chomp\n print \"Enter an adverb: \" \n adverb = gets.chomp\n madlib_line(noun, verb, adjective, adverb)\nend", "def arguments\n args = OpenStudio::Measure::OSArgumentVector.new\n\n id = OpenStudio::Measure::OSArgument.makeStringArgument('feature_id', false)\n id.setDisplayName('Feature unique identifier')\n id.setDefaultValue('1')\n args << id\n\n name = OpenStudio::Measure::OSArgument.makeStringArgument('feature_name', false)\n name.setDisplayName('Feature scenario specific name')\n name.setDefaultValue('name')\n args << name\n\n feature_type = OpenStudio::Measure::OSArgument.makeStringArgument('feature_type', false)\n feature_type.setDisplayName('URBANopt Feature Type')\n feature_type.setDefaultValue('Building')\n args << feature_type\n\n feature_location = OpenStudio::Measure::OSArgument.makeStringArgument('feature_location', false)\n feature_location.setDisplayName('URBANopt Feature Location')\n feature_location.setDefaultValue('0')\n args << feature_location\n\n # make an argument for the frequency\n reporting_frequency_chs = OpenStudio::StringVector.new\n reporting_frequency_chs << 'Detailed'\n reporting_frequency_chs << 'Timestep'\n reporting_frequency_chs << 'Hourly'\n reporting_frequency_chs << 'Daily'\n # reporting_frequency_chs << 'Zone Timestep'\n reporting_frequency_chs << 'BillingPeriod' # match it to utility bill object\n ## Utility report here to report the start and end for each fueltype\n reporting_frequency_chs << 'Monthly'\n reporting_frequency_chs << 'Runperiod'\n\n reporting_frequency = OpenStudio::Measure::OSArgument.makeChoiceArgument('reporting_frequency', reporting_frequency_chs, true)\n reporting_frequency.setDisplayName('Reporting Frequency')\n reporting_frequency.setDescription('The frequency at which to report timeseries output data.')\n reporting_frequency.setDefaultValue('Timestep')\n args << reporting_frequency\n\n return args\n end", "def arguments(model)\n args = OpenStudio::Ruleset::OSArgumentVector.new\n \n #make a start date argument\n start_date = OpenStudio::Ruleset::OSArgument::makeStringArgument(\"start_date\",true)\n start_date.setDisplayName(\"Start date\")\n args << start_date\n \n #make an end date argument\n end_date = OpenStudio::Ruleset::OSArgument::makeStringArgument(\"end_date\",true)\n end_date.setDisplayName(\"End date\")\n args << end_date\n \n return args\n end", "def check_arguments\n convert_boolean_strings\n check_output\n check_log_level\n check_input_entry\n check_input_types\n end", "def process_arguments\n # clean unsupport symbols, e.g. JieFang;\n # or error argument due to option typo, e.g. '-list' will put 'ist' into the array in this src.\n @support_newspapers = Array.new #TODO: move to elsewhere\n @support_newspapers << :XM\n @support_newspapers << :WHB\n @support_newspapers << :YZ\n # ATTENTION: command line input is an array of string, to be consistent, internally I use only symbol when using this symbol\n @options.newspapers = @options.newspapers.collect { | item | item.to_sym } & @support_newspapers\n \n if @options.newspapers.size == 0\n @support_newspapers.each do | sym |\n @options.newspapers << sym\n end\n end\n end", "def args\n raw_args\n end", "def argv; end", "def arguments(model)\n args = OpenStudio::Ruleset::OSArgumentVector.new\n \n #make an argument for your name\n code_choices = OpenStudio::StringVector.new \n code_choices << \"ASHRAE 90.1-2007\" \n code_choices << \"ASHRAE 90.1-2010\" \n energy_code = OpenStudio::Ruleset::OSArgument::makeChoiceArgument('energy_code', code_choices, true)\n energy_code.setDisplayName(\"Code baseline\")\n energy_code.setDefaultValue(\"ASHRAE 90.1-2010\")\n args << energy_code\n \n #make an argument to add new space true/false\n leed_check = OpenStudio::Ruleset::OSArgument::makeBoolArgument(\"leed_check\",true)\n leed_check.setDisplayName(\"Perform typical LEED checks?\")\n leed_check.setDefaultValue(true)\n args << leed_check\n \n return args\n end", "def arguments(model)\n #list of arguments as they will appear in the interface. They are available in the run command as\n @argument_array_of_arrays = [\n [ \"variable_name\", \"type\", \"required\", \"model_dependant\", \"display_name\", \"default_value\", \"min_value\", \"max_value\", \"string_choice_array\", \t\"os_object_type\"\t],\n [ \"weather_file_name\", \"STRING\", true, false, \"Weather File Name\", nil, nil, nil, nil, \t nil\t\t\t\t\t],\n #Default set for server weather folder.\n [ \"weather_directory\", \"STRING\", true, false, \"Weather Directory\", \"../../weather\", nil, nil, nil,\t nil\t\t\t\t\t]\n \n ]\n #set up arguments. \n args = OpenStudio::Ruleset::OSArgumentVector.new\n self.argument_setter(args)\n return args\n end", "def more_options\n puts Rainbow(\"Specify your additional options for your search: 'release date', 'search history', or go back\").yellow.underline\n input = gets.chomp.downcase\n \n if input == \"release date\"\n option_release_date\n \n elsif input == \"search history\"\n game_history\n\n elsif input == \"go back\"\n continue_or_exit\n \n else \n puts \"Input not recognized please try again\"\n more_options\n end\n end", "def inflamed _args\n \"inflamed _args;\" \n end", "def cmd(options={})\n arguments\n end", "def user_input\n\tgets\nend", "def arguments()\n args = OpenStudio::Ruleset::OSArgumentVector.new\n\n # this measure will require arguments, but at this time, they are not known\n geometry_profile = OpenStudio::Ruleset::OSArgument::makeStringArgument('geometry_profile', true)\n geometry_profile.setDefaultValue(\"{}\")\n os_model = OpenStudio::Ruleset::OSArgument::makeStringArgument('os_model', true)\n os_model.setDefaultValue('multi-model mode')\n user_id = OpenStudio::Ruleset::OSArgument::makeStringArgument('user_id', true)\n user_id.setDefaultValue(\"00000000-0000-0000-0000-000000000000\")\n job_id = OpenStudio::Ruleset::OSArgument::makeStringArgument('job_id', true)\n #job_id.setDefaultValue(SecureRandom.uuid.to_s)\n ashrae_climate_zone = OpenStudio::Ruleset::OSArgument::makeStringArgument('ashrae_climate_zone', false)\n ashrae_climate_zone.setDefaultValue(\"-1\")\n building_type = OpenStudio::Ruleset::OSArgument::makeStringArgument('building_type', false)\n building_type.setDefaultValue(\"BadDefaultType\")\n\n args << geometry_profile\n args << os_model\n args << user_id\n args << job_id\n args << ashrae_climate_zone\n args << building_type\n\n return args\n end", "def input\n @input ||= args.dig(:input)\n end", "def parse_args\n require 'optimist'\n opts = Optimist.options do\n opt :source, \"Inventory Source UID\", :type => :string, :required => ENV[\"SOURCE_UID\"].nil?, :default => ENV[\"SOURCE_UID\"]\n opt :ingress_api, \"Hostname of the ingress-api route\", :type => :string, :default => ENV[\"INGRESS_API\"] || \"http://localhost:9292\"\n opt :config, \"Configuration file name\", :type => :string, :default => ENV[\"CONFIG\"] || \"default\"\n opt :data, \"Amount & custom values of generated items\", :type => :string, :default => ENV[\"DATA\"] || \"default\"\n end\n\n opts\nend", "def arguments(model)\n args = OpenStudio::Ruleset::OSArgumentVector.new\n\n # lat arg\n lat = OpenStudio::Ruleset::OSArgument.makeDoubleArgument(\"lat\", true)\n lat.setDisplayName(\"Latitude\")\n lat.setDefaultValue(39.7392000000)\n args << lat\n\n # long arg\n lon = OpenStudio::Ruleset::OSArgument.makeDoubleArgument(\"lon\", true)\n lon.setDisplayName(\"Longitude\")\n lon.setDefaultValue(-104.9903000000)\n args << lon\n\n return args\n end", "def add args\n db = get_db\n if args.empty?\n print \"Enter a short summary: \"\n STDOUT.flush\n text = gets.chomp\n if text.empty?\n exit ERRCODE\n end\n else\n # if you add last arg as P1..P5, I'll update priority automatically\n if args.last =~ /P[1-5]/\n $default_priority = args.pop\n end\n text = args.join \" \"\n end\n # convert actual newline to C-a. slash n's are escapes so echo -e does not muck up.\n #atitle=$( echo \"$atitle\" | tr -cd '\\40-\\176' )\n text.tr! \"\\n\", '\u0001'\n title = text\n desc = nil\n if $prompt_desc\n # choice of vim or this XXX also how to store in case of error or abandon\n # and allow user to edit, so no retyping. This could be for mult fields\n message \"Enter a detailed description (. to exit): \"\n desc = Cmdapp.get_lines\n #message \"You entered #{desc}\"\n end\n type = $default_type || \"bug\"\n severity = $default_severity || \"normal\"\n status = $default_status || \"open\"\n priority = $default_priority || \"P3\"\n if $prompt_type\n type = Cmdapp._choice(\"Select type:\", %w[bug enhancement feature task] )\n #message \"You selected #{type}\"\n end\n if $prompt_priority\n #priority = Cmdapp._choice(\"Select priority:\", %w[normal critical moderate] )\n priority = ask_priority\n #message \"You selected #{severity}\"\n end\n if $prompt_severity\n severity = Cmdapp._choice(\"Select severity:\", %w[normal critical moderate] )\n #message \"You selected #{severity}\"\n end\n if $prompt_status\n status = Cmdapp._choice(\"Select status:\", %w[open started closed stopped canceled] )\n #message \"You selected #{status}\"\n end\n assigned_to = $default_assigned_to\n if $prompt_assigned_to\n message \"Assign to:\"\n #assigned_to = $stdin.gets.chomp\n assigned_to = Cmdapp._gets \"assigned_to\", \"assigned_to\", $default_assigned_to\n #message \"You selected #{assigned_to}\"\n end\n project = component = version = nil\n # project\n if $use_project\n project = Cmdapp.user_input('project', $prompt_project, nil, $valid_project, $default_project)\n end\n if $use_component\n component = Cmdapp.user_input('component', $prompt_component, nil, $valid_component, $default_component)\n end\n if $use_version\n version = Cmdapp.user_input('version', $prompt_version, nil, $valid_version, $default_version)\n end\n\n start_date = @now\n due_date = default_due_date\n comment_count = 0\n priority ||= \"P3\" \n description = desc\n fix = nil #\"Some long text\" \n #date_created = @now\n #date_modified = @now\n body = {}\n body[\"title\"]=title\n body[\"description\"]=description\n body[\"type\"]=type\n body[\"status\"]=status\n body[\"start_date\"]=start_date.to_s\n body[\"due_date\"]=due_date.to_s\n body[\"priority\"]=priority\n body[\"severity\"]=severity\n body[\"assigned_to\"]=assigned_to\n body[\"created_by\"] = $default_user\n # only insert if its wanted by user\n body[\"project\"]=project if $use_project\n body[\"component\"]=component if $use_component\n body[\"version\"]=version if $use_version\n\n rowid = db.table_insert_hash(\"bugs\", body)\n puts \"Issue #{rowid} created\"\n logid = db.sql_logs_insert rowid, \"create\", \"#{rowid} #{type}: #{title}\"\n body[\"id\"] = rowid\n mail_issue nil, body\n \n 0\n end", "def arguments(model)\n #list of arguments as they will appear in the interface. They are available in the run command as\n @argument_array_of_arrays = [\n [ \"variable_name\", \"type\", \"required\", \"model_dependant\", \"display_name\", \"default_value\", \"min_value\", \"max_value\", \"string_choice_array\", \"os_object_type\"\t ],\n [ \"alternativeModel\", \"STRING\", true, false, \"Alternative Model\", 'FullServiceRestaurant.osm', nil, nil, nil, \t nil\t\t\t\t\t],\n [ \"osm_directory\", \"STRING\", true, false, \"OSM Directory\", \"../../lib/btap/resources/models/smart_archetypes\", nil, nil, nil,\t nil\t\t\t\t\t] \n ]\n #set up arguments. \n args = OpenStudio::Ruleset::OSArgumentVector.new\n self.argument_setter(args)\n return args\n end", "def arguments(model)\n #list of arguments as they will appear in the interface. They are available in the run command as\n @argument_array_of_arrays = [\n [ \"variable_name\", \"type\", \"required\", \"model_dependant\", \"display_name\", \"default_value\", \"min_value\", \"max_value\", \"string_choice_array\", \"os_object_type\"\t ],\n [ \"alternativeModel\", \"STRING\", true, false, \"Alternative Model\", 'FullServiceRestaurant.osm', nil, nil, nil, \t nil\t\t\t\t\t],\n [ \"osm_directory\", \"STRING\", true, false, \"OSM Directory\", \"../../lib/btap/resources/models/smart_archetypes\", nil, nil, nil,\t nil\t\t\t\t\t] \n ]\n #set up arguments. \n args = OpenStudio::Ruleset::OSArgumentVector.new\n self.argument_setter(args)\n return args\n end", "def arguments()\r\n args = OpenStudio::Ruleset::OSArgumentVector.new\r\n\r\n # the name of the sql file\r\n csv_name = OpenStudio::Ruleset::OSArgument.makeStringArgument(\"csv_name\", true)\r\n csv_name.setDisplayName(\"CSV file name\")\r\n csv_name.setDescription(\"CSV file name.\")\r\n csv_name.setDefaultValue(\"mtr.csv\")\r\n args << csv_name\r\n \r\n csv_time_header = OpenStudio::Ruleset::OSArgument.makeStringArgument(\"csv_time_header\", true)\r\n csv_time_header.setDisplayName(\"CSV Time Header\")\r\n csv_time_header.setDescription(\"CSV Time Header Value.\")\r\n csv_time_header.setDefaultValue(\"Date/Time\")\r\n args << csv_time_header\r\n \r\n csv_var = OpenStudio::Ruleset::OSArgument.makeStringArgument(\"csv_var\", true)\r\n csv_var.setDisplayName(\"CSV variable name\")\r\n csv_var.setDescription(\"CSV variable name\")\r\n csv_var.setDefaultValue(\"Whole Building:Facility Total Electric Demand Power [W](TimeStep)\")\r\n args << csv_var\r\n \r\n csv_var_dn = OpenStudio::Ruleset::OSArgument.makeStringArgument(\"csv_var_dn\", true)\r\n csv_var_dn.setDisplayName(\"CSV variable display name\")\r\n csv_var_dn.setDescription(\"CSV variable display name\")\r\n csv_var_dn.setDefaultValue(\"\")\r\n args << csv_var_dn\r\n \r\n years = OpenStudio::Ruleset::OSArgument.makeBoolArgument(\"year\", true)\r\n years.setDisplayName(\"Year in csv data\")\r\n years.setDescription(\"Year in csv data => mm:dd:yy or mm:dd\")\r\n years.setDefaultValue(true)\r\n args << years\r\n \r\n seconds = OpenStudio::Ruleset::OSArgument.makeBoolArgument(\"seconds\", true)\r\n seconds.setDisplayName(\"Seconds in csv data\")\r\n seconds.setDescription(\"Seconds in csv data => hh:mm:ss or hh:mm\")\r\n seconds.setDefaultValue(true)\r\n args << seconds\r\n \r\n sql_key = OpenStudio::Ruleset::OSArgument.makeStringArgument(\"sql_key\", true)\r\n sql_key.setDisplayName(\"SQL key\")\r\n sql_key.setDescription(\"SQL key\")\r\n sql_key.setDefaultValue(\"Whole Building\")\r\n args << sql_key \r\n\r\n sql_var = OpenStudio::Ruleset::OSArgument.makeStringArgument(\"sql_var\", true)\r\n sql_var.setDisplayName(\"SQL var\")\r\n sql_var.setDescription(\"SQL var\")\r\n sql_var.setDefaultValue(\"Facility Total Electric Demand Power\")\r\n args << sql_var \r\n \r\n norm = OpenStudio::Ruleset::OSArgument.makeDoubleArgument(\"norm\", true)\r\n norm.setDisplayName(\"norm of the difference of csv and sql\")\r\n norm.setDescription(\"norm of the difference of csv and sql\")\r\n norm.setDefaultValue(1)\r\n args << norm \r\n\r\n find_avail = OpenStudio::Ruleset::OSArgument.makeBoolArgument(\"find_avail\", true)\r\n find_avail.setDisplayName(\"find_avail\")\r\n find_avail.setDescription(\"find_avail\")\r\n find_avail.setDefaultValue(true)\r\n args << find_avail \r\n\r\n compute_diff = OpenStudio::Ruleset::OSArgument.makeBoolArgument(\"compute_diff\", true)\r\n compute_diff.setDisplayName(\"compute_diff\")\r\n compute_diff.setDescription(\"compute_diff\")\r\n compute_diff.setDefaultValue(true)\r\n args << compute_diff\r\n \r\n verbose_messages = OpenStudio::Ruleset::OSArgument.makeBoolArgument(\"verbose_messages\", true)\r\n verbose_messages.setDisplayName(\"verbose_messages\")\r\n verbose_messages.setDescription(\"verbose_messages\")\r\n verbose_messages.setDefaultValue(true)\r\n args << verbose_messages \r\n\r\n return args\r\n end", "def arguments(model)\n args = OpenStudio::Measure::OSArgumentVector.new\t\t\n\n #Make a string argument for occupants (auto or number)\n num_occ = OpenStudio::Measure::OSArgument::makeStringArgument(\"num_occ\", false)\n num_occ.setDisplayName(\"Number of Occupants\")\n num_occ.setDescription(\"Specify the number of occupants. For a multifamily building, specify one value for all units or a comma-separated set of values (in the correct order) for each unit. A value of '#{Constants.Auto}' will calculate the average number of occupants from the number of bedrooms. Used to specify the internal gains from people only.\")\n num_occ.setDefaultValue(Constants.Auto)\n args << num_occ\n\n #Make a string argument for 24 weekday schedule values\n weekday_sch = OpenStudio::Measure::OSArgument::makeStringArgument(\"weekday_sch\", true)\n weekday_sch.setDisplayName(\"Weekday schedule\")\n weekday_sch.setDescription(\"Specify the 24-hour weekday schedule.\")\n weekday_sch.setDefaultValue(\"1.00000, 1.00000, 1.00000, 1.00000, 1.00000, 1.00000, 1.00000, 0.88310, 0.40861, 0.24189, 0.24189, 0.24189, 0.24189, 0.24189, 0.24189, 0.24189, 0.29498, 0.55310, 0.89693, 0.89693, 0.89693, 1.00000, 1.00000, 1.00000\")\n args << weekday_sch\n \n #Make a string argument for 24 weekend schedule values\n weekend_sch = OpenStudio::Measure::OSArgument::makeStringArgument(\"weekend_sch\", true)\n weekend_sch.setDisplayName(\"Weekend schedule\")\n weekend_sch.setDescription(\"Specify the 24-hour weekend schedule.\")\n weekend_sch.setDefaultValue(\"1.00000, 1.00000, 1.00000, 1.00000, 1.00000, 1.00000, 1.00000, 0.88310, 0.40861, 0.24189, 0.24189, 0.24189, 0.24189, 0.24189, 0.24189, 0.24189, 0.29498, 0.55310, 0.89693, 0.89693, 0.89693, 1.00000, 1.00000, 1.00000\")\n args << weekend_sch\n\n #Make a string argument for 12 monthly schedule values\n monthly_sch = OpenStudio::Measure::OSArgument::makeStringArgument(\"monthly_sch\", true)\n monthly_sch.setDisplayName(\"Month schedule\")\n monthly_sch.setDescription(\"Specify the 12-month schedule.\")\n monthly_sch.setDefaultValue(\"1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0\")\n args << monthly_sch\n\n return args\n end", "def validate_arguments()\n usage unless ARGV.count > 0\nend", "def input args\n if args.state.inputlist.length > 5\n args.state.inputlist.pop\n end\n\n should_process_special_move = (args.inputs.keyboard.key_down.j) ||\n (args.inputs.keyboard.key_down.k) ||\n (args.inputs.keyboard.key_down.a) ||\n (args.inputs.keyboard.key_down.d) ||\n (args.inputs.controller_one.key_down.y) ||\n (args.inputs.controller_one.key_down.x) ||\n (args.inputs.controller_one.key_down.left) ||\n (args.inputs.controller_one.key_down.right)\n\n if (should_process_special_move)\n if (args.inputs.keyboard.key_down.j && args.inputs.keyboard.key_down.k) ||\n (args.inputs.controller_one.key_down.x && args.inputs.controller_one.key_down.y)\n args.state.inputlist.unshift(\"shield\")\n elsif (args.inputs.keyboard.key_down.k || args.inputs.controller_one.key_down.y) &&\n (args.state.inputlist[0] == \"forward-attack\") && ((args.state.tick_count - args.state.lastpush) <= 15)\n args.state.inputlist.unshift(\"dash-attack\")\n args.state.player.dx = 20\n elsif (args.inputs.keyboard.key_down.j && args.inputs.keyboard.a) ||\n (args.inputs.controller_one.key_down.x && args.inputs.controller_one.key_down.left)\n args.state.inputlist.unshift(\"back-attack\")\n elsif ( args.inputs.controller_one.key_down.x || args.inputs.keyboard.key_down.j)\n args.state.inputlist.unshift(\"forward-attack\")\n elsif (args.inputs.keyboard.key_down.k || args.inputs.controller_one.key_down.y) &&\n (args.state.player.y > 128)\n args.state.inputlist.unshift(\"dair\")\n elsif (args.inputs.keyboard.key_down.k || args.inputs.controller_one.key_down.y)\n args.state.inputlist.unshift(\"up-attack\")\n elsif (args.inputs.controller_one.key_down.left || args.inputs.keyboard.key_down.a) &&\n (args.state.inputlist[0] == \"<\") &&\n ((args.state.tick_count - args.state.lastpush) <= 10)\n args.state.inputlist.unshift(\"<<\")\n args.state.player.dx = -15\n elsif (args.inputs.controller_one.key_down.left || args.inputs.keyboard.key_down.a)\n args.state.inputlist.unshift(\"<\")\n args.state.timeleft = args.state.tick_count\n elsif (args.inputs.controller_one.key_down.right || args.inputs.keyboard.key_down.d)\n args.state.inputlist.unshift(\">\")\n end\n\n args.state.lastpush = args.state.tick_count\n end\n\n if args.inputs.keyboard.space || args.inputs.controller_one.r2 # if the user presses the space bar\n args.state.player.jumped_at ||= args.state.tick_count # jumped_at is set to current frame\n\n # if the time that has passed since the jump is less than the player's jump duration and\n # the player is not falling\n if args.state.player.jumped_at.elapsed_time < args.state.player_jump_power_duration && !args.state.player.falling\n args.state.player.dy = args.state.player_jump_power # change in y is set to power of player's jump\n end\n end\n\n # if the space bar is in the \"up\" state (or not being pressed down)\n if args.inputs.keyboard.key_up.space || args.inputs.controller_one.key_up.r2\n args.state.player.jumped_at = nil # jumped_at is empty\n args.state.player.falling = true # the player is falling\n end\n\n if args.inputs.left # if left key is pressed\n if args.state.player.dx < -5\n args.state.player.dx = args.state.player.dx\n else\n args.state.player.dx = -5\n end\n\n elsif args.inputs.right # if right key is pressed\n if args.state.player.dx > 5\n args.state.player.dx = args.state.player.dx\n else\n args.state.player.dx = 5\n end\n else\n args.state.player.dx *= args.state.player_speed_slowdown_rate # dx is scaled down\n end\n\n if ((args.state.player.dx).abs > 5) #&& ((args.state.tick_count - args.state.lastpush) <= 10)\n args.state.player.dx *= 0.95\n end\nend", "def arguments(model = nil)\n args = OpenStudio::Ruleset::OSArgumentVector.new\n\n chs = OpenStudio::StringVector.new\n chs << 'Last OSM'\n chs << 'Last IDF'\n file_source = OpenStudio::Ruleset::OSArgument.makeChoiceArgument('file_source', chs, true)\n file_source.setDisplayName('Model Source')\n file_source.setDefaultValue('Last OSM')\n args << file_source\n\n chs = OpenStudio::StringVector.new\n chs << 'Timestep'\n chs << 'Hourly'\n reporting_frequency = OpenStudio::Ruleset::OSArgument.makeChoiceArgument('reporting_frequency', chs, true)\n reporting_frequency.setDisplayName('Reporting Frequency')\n reporting_frequency.setDefaultValue('Hourly')\n args << reporting_frequency\n\n variable1_name = OpenStudio::Ruleset::OSArgument.makeStringArgument('variable1_name', true)\n variable1_name.setDisplayName('Variable 1 Name')\n variable1_name.setDefaultValue('Surface Outside Face Temperature')\n args << variable1_name\n\n variable2_name = OpenStudio::Ruleset::OSArgument.makeStringArgument('variable2_name', true)\n variable2_name.setDisplayName('Variable 2 Name')\n variable2_name.setDefaultValue('Surface Inside Face Temperature')\n args << variable2_name\n\n variable3_name = OpenStudio::Ruleset::OSArgument.makeStringArgument('variable3_name', true)\n variable3_name.setDisplayName('Variable 3 Name')\n variable3_name.setDefaultValue('Zone Mean Radiant Temperature')\n args << variable3_name\n\n return args\n end", "def arguments(model)\n args = OpenStudio::Ruleset::OSArgumentVector.new\n\n # Create a list of the names and handles of space types\n # used in the building.\n used_space_type_handles = OpenStudio::StringVector.new\n used_space_type_names = OpenStudio::StringVector.new\n model.getSpaceTypes.sort.each do |space_type|\n if space_type.spaces.size > 0 # only show space types used in the building\n used_space_type_handles << space_type.handle.to_s\n used_space_type_names << space_type.name.to_s\n end\n end\n\t\n # Make an argument for plenum space type\n ceiling_return_plenum_space_type = OpenStudio::Ruleset::OSArgument::makeChoiceArgument(\"ceiling_return_plenum_space_type\", used_space_type_handles, used_space_type_names,false)\n ceiling_return_plenum_space_type.setDisplayName(\"This space type should be part of a ceiling return air plenum.\")\n args << ceiling_return_plenum_space_type\n\t\n # Make a bool argument to edit/not edit each space type\n\t\tmodel.getSpaceTypes.sort.each do |space_type|\n\t\t\tif space_type.spaces.size > 0 # only show space types used in the building\n\t\t\t\tspace_type_to_edit = OpenStudio::Ruleset::OSArgument::makeBoolArgument(space_type.name.get.to_s,false)\n\t\t\t\t# Make a bool argument for this space type\n\t\t\t\tspace_type_to_edit.setDisplayName(\"Add #{space_type.name.get} space type to GSHP system?\")\n\t\t\t\tspace_type_to_edit.setDefaultValue(false)\t\t\n\t\t\t\targs << space_type_to_edit\n\t\t\tend\n\t\tend\n\t \n\t\t# Heating COP of GSHP\n\t\tgshp_htg_cop = OpenStudio::Ruleset::OSArgument::makeDoubleArgument(\"gshp_htg_cop\",false)\n\t\tgshp_htg_cop.setDisplayName(\"GSHP DX Heating Coil Heating COP\")\n\t\tgshp_htg_cop.setDefaultValue(4.0)\n\t\targs << gshp_htg_cop\n\t\t\n\t\t# Cooling EER of GSHP\n\t\tgshp_clg_eer = OpenStudio::Ruleset::OSArgument::makeDoubleArgument(\"gshp_clg_eer\",false)\n\t\tgshp_clg_eer.setDisplayName(\"GSHP DX Cooling Coil Cooling EER\")\n\t\tgshp_clg_eer.setDefaultValue(14)\n\t\targs << gshp_clg_eer\n\t\t\n\t\t# GSHP Fan Type PSC or ECM\n\t\tfan_choices = OpenStudio::StringVector.new\n\t\tfan_choices << \"PSC\"\n\t\tfan_choices << \"ECM\"\n\t\tgshp_fan_type = OpenStudio::Ruleset::OSArgument::makeChoiceArgument(\"gshp_fan_type\",fan_choices,true) # note ECM fan type may correspond to different set of heat pump performance curves\n\t\tgshp_fan_type.setDisplayName(\"GSHP Fan Type: PSC or ECM?\")\n\t\tgshp_fan_type.setDefaultValue(\"PSC\")\n args << gshp_fan_type\n\t\t\n\t\t# Condenser Loop Cooling Temperature\n\t\t# condLoopCoolingTemp = OpenStudio::Ruleset::OSArgument::makeDoubleArgument(\"condLoopCoolingTemp\",false)\n\t\t# condLoopCoolingTemp.setDisplayName(\"Condenser Loop Cooling Temperature (F)\")\n\t\t# condLoopCoolingTemp.setDefaultValue(90)\n\t\t# args << condLoopCoolingTemp\n\t\t\n\t\t# Condenser Loop Heating Temperature\n\t\t# condLoopHeatingTemp = OpenStudio::Ruleset::OSArgument::makeDoubleArgument(\"condLoopHeatingTemp\",false)\n\t\t# condLoopHeatingTemp.setDisplayName(\"Condenser Loop Heating Temperature (F)\")\n\t\t# condLoopHeatingTemp.setDefaultValue(60)\t\n\t\t# args << condLoopHeatingTemp\n\t\t\n\t\t# Vertical Bore HX\n\t\tbuilding_area = model.getBuilding.floorArea \n\t\tbuilding_cool_ton = building_area*10.7639/500\t\t# 500sf/ton estimated\n\t\tbore_hole_no = OpenStudio::Ruleset::OSArgument::makeIntegerArgument(\"bore_hole_no\",false)\n\t\tbore_hole_no.setDisplayName(\"Number of Bore Holes\")\n\t\tbore_hole_no.setDefaultValue(building_cool_ton.to_i) \n\t\targs << bore_hole_no\n\n\t\t\n\t\tbore_hole_length = OpenStudio::Ruleset::OSArgument::makeDoubleArgument(\"bore_hole_length\",false)\n\t\tbore_hole_length.setDisplayName(\"Bore Hole Length (ft)\")\n\t\tbore_hole_length.setDefaultValue(200)\n\t\targs << bore_hole_length\n\n\t\tbore_hole_radius = OpenStudio::Ruleset::OSArgument::makeDoubleArgument(\"bore_hole_radius\",false)\n\t\tbore_hole_radius.setDisplayName(\"Bore Hole Radius (inch)\")\n\t\tbore_hole_radius.setDefaultValue(6.0)\n\t\targs << bore_hole_radius\n\t\t\n\t\tground_k_value = OpenStudio::Ruleset::OSArgument::makeDoubleArgument(\"ground_k_value\",false)\n\t\tground_k_value.setDisplayName(\"Ground Conductivity (Btu/hr.F.R\")\n\t\tground_k_value.setDefaultValue(0.75)\n\t\targs << ground_k_value\n\t\t\n\t\tgrout_k_value = OpenStudio::Ruleset::OSArgument::makeDoubleArgument(\"grout_k_value\",false)\n\t\tgrout_k_value.setDisplayName(\"Grout Conductivity (Btu/hr.F.R\")\n\t\tgrout_k_value.setDefaultValue(0.75)\n\t\targs << grout_k_value\n\t\t\n\t\tchs = OpenStudio::StringVector.new\n\t\tchs << \"Yes\"\n\t\tchs << \"No\"\n\t\tsupplemental_boiler = OpenStudio::Ruleset::OSArgument::makeChoiceArgument(\"supplemental_boiler\",chs, true)\n\t\tsupplemental_boiler.setDisplayName(\"Supplemental Heating Boiler?\")\n\t\tsupplemental_boiler.setDefaultValue(\"No\")\n\t\targs << supplemental_boiler\n\t\t\n\t\t# Boiler Capacity\n\t\tboiler_cap = OpenStudio::Ruleset::OSArgument::makeDoubleArgument(\"boiler_cap\",false)\n\t\tboiler_cap.setDisplayName(\"boiler normal capacity (MBtuh)\")\n\t\tboiler_cap.setDefaultValue(500.0)\n\t\targs << boiler_cap\n\t\t\t\t\n\t\t# Boiler Efficiency\n\t\tboiler_eff = OpenStudio::Ruleset::OSArgument::makeDoubleArgument(\"boiler_eff\",false)\n\t\tboiler_eff.setDisplayName(\"Boiler Thermal Efficiency\")\n\t\tboiler_eff.setDefaultValue(0.9)\n\t\targs << boiler_eff\n\t\t\n\t\t# Boiler fuel Type\n\t\tfuel_choices = OpenStudio::StringVector.new\n\t\tfuel_choices << \"NaturalGas\"\n\t\tfuel_choices << \"PropaneGas\"\n\t\tfuel_choices << \"FuelOil#1\"\n\t\tfuel_choices << \"FuelOil#2\"\n\t\tfuel_choices << \"Electricity\"\n\t\tboiler_fuel_type = OpenStudio::Ruleset::OSArgument::makeChoiceArgument(\"boiler_fuel_type\",fuel_choices,false) \n\t\tboiler_fuel_type.setDisplayName(\"Boiler Fuel Type\")\n\t\tboiler_fuel_type.setDefaultValue(\"NaturalGas\")\n\t\targs << boiler_fuel_type\n\t\t\n\t\t# boiler Hot water supply temperature\n\t\tboiler_hw_st = OpenStudio::Ruleset::OSArgument::makeDoubleArgument(\"boiler_hw_st\",false)\n\t\tboiler_hw_st.setDisplayName(\"Boiler Design Heating Water Outlet Temperature (F)\")\n\t\tboiler_hw_st.setDefaultValue(120)\t\n\t\targs << boiler_hw_st\n\t\t\n\t\t# DOAS Fan Type\n\t\tdoas_fan_choices = OpenStudio::StringVector.new\n\t\tdoas_fan_choices << \"Constant\"\n\t\tdoas_fan_choices << \"Variable\"\n\t\tdoas_fan_type = OpenStudio::Ruleset::OSArgument::makeChoiceArgument(\"doas_fan_type\",doas_fan_choices,true)\n\t\tdoas_fan_type.setDisplayName(\"DOAS Fan Flow Control - Variable means DCV controls\")\n\t\tdoas_fan_type.setDefaultValue(\"Variable\")\n\t\targs << doas_fan_type\n\t\t\n\t\t# DOAS Energy Recovery\n\t\terv_choices = OpenStudio::StringVector.new\n\t\terv_choices << \"plate w/o economizer lockout\"\n\t\terv_choices << \"plate w/ economizer lockout\"\n\t\terv_choices << \"rotary wheel w/o economizer lockout\"\n\t\terv_choices << \"rotary wheel w/ economizer lockout\"\n\t\terv_choices << \"none\"\n\t\tdoas_erv = OpenStudio::Ruleset::OSArgument::makeChoiceArgument(\"doas_erv\",erv_choices,true)\n\t\tdoas_erv.setDisplayName(\"DOAS Energy Recovery?\")\n\t\tdoas_erv.setDefaultValue(\"none\")\n\t\targs << doas_erv\n\t\t\n\t\t# DOAS Evaporative Cooling\n\t\tevap_choices = OpenStudio::StringVector.new\n\t\tevap_choices << \"Direct Evaporative Cooler\"\n\t\tevap_choices << \"none\"\n\t\tdoas_evap = OpenStudio::Ruleset::OSArgument::makeChoiceArgument(\"doas_evap\",evap_choices,true)\n\t\tdoas_evap.setDisplayName(\"DOAS Direct Evaporative Cooling?\")\n\t\tdoas_evap.setDefaultValue(\"none\")\n\t\targs << doas_evap\n\t\t\n\t\t# DOAS DX Cooling\n\t\tdoas_dx_eer = OpenStudio::Ruleset::OSArgument::makeDoubleArgument(\"doas_dx_eer\",false)\n\t\tdoas_dx_eer.setDisplayName(\"DOAS DX Cooling EER\")\n\t\tdoas_dx_eer.setDefaultValue(10.0)\n\t\targs << doas_dx_eer\n\t\n # make an argument for material and installation cost\n # todo - I would like to split the costing out to the air loops weighted by area of building served vs. just sticking it on the building\n cost_total_hvac_system = OpenStudio::Ruleset::OSArgument::makeDoubleArgument(\"cost_total_hvac_system\",true)\n cost_total_hvac_system.setDisplayName(\"Total Cost for HVAC System ($).\")\n cost_total_hvac_system.setDefaultValue(0.0)\n args << cost_total_hvac_system\n \n #make an argument to remove existing costs\n remake_schedules = OpenStudio::Ruleset::OSArgument::makeBoolArgument(\"remake_schedules\",true)\n remake_schedules.setDisplayName(\"Apply recommended availability and ventilation schedules for air handlers?\")\n remake_schedules.setDefaultValue(true)\n args << remake_schedules\n\n return args\n end", "def arguments()\r\n args = OpenStudio::Ruleset::OSArgumentVector.new\r\n\r\n # the name of the sql file\r\n csv_name = OpenStudio::Ruleset::OSArgument.makeStringArgument(\"csv_name\", true)\r\n csv_name.setDisplayName(\"CSV file name\")\r\n csv_name.setDescription(\"CSV file name.\")\r\n csv_name.setDefaultValue(\"mtr.csv\")\r\n args << csv_name\r\n \r\n csv_time_header = OpenStudio::Ruleset::OSArgument.makeStringArgument(\"csv_time_header\", true)\r\n csv_time_header.setDisplayName(\"CSV Time Header\")\r\n csv_time_header.setDescription(\"CSV Time Header Value.\")\r\n csv_time_header.setDefaultValue(\"Date/Time\")\r\n args << csv_time_header\r\n \r\n csv_var = OpenStudio::Ruleset::OSArgument.makeStringArgument(\"csv_var\", true)\r\n csv_var.setDisplayName(\"CSV variable name\")\r\n csv_var.setDescription(\"CSV variable name\")\r\n csv_var.setDefaultValue(\"Whole Building:Facility Total Electric Demand Power [W](TimeStep)\")\r\n args << csv_var\r\n \r\n csv_var_dn = OpenStudio::Ruleset::OSArgument.makeStringArgument(\"csv_var_dn\", true)\r\n csv_var_dn.setDisplayName(\"CSV variable display name\")\r\n csv_var_dn.setDescription(\"CSV variable display name\")\r\n csv_var_dn.setDefaultValue(\"\")\r\n args << csv_var_dn\r\n \r\n years = OpenStudio::Ruleset::OSArgument.makeBoolArgument(\"year\", true)\r\n years.setDisplayName(\"Year in csv data\")\r\n years.setDescription(\"Year in csv data => mm:dd:yy or mm:dd\")\r\n years.setDefaultValue(true)\r\n args << years\r\n \r\n seconds = OpenStudio::Ruleset::OSArgument.makeBoolArgument(\"seconds\", true)\r\n seconds.setDisplayName(\"Seconds in csv data\")\r\n seconds.setDescription(\"Seconds in csv data => hh:mm:ss or hh:mm\")\r\n seconds.setDefaultValue(true)\r\n args << seconds\r\n \r\n sql_key = OpenStudio::Ruleset::OSArgument.makeStringArgument(\"sql_key\", true)\r\n sql_key.setDisplayName(\"SQL key\")\r\n sql_key.setDescription(\"SQL key\")\r\n sql_key.setDefaultValue(\"\")\r\n args << sql_key \r\n\r\n sql_var = OpenStudio::Ruleset::OSArgument.makeStringArgument(\"sql_var\", true)\r\n sql_var.setDisplayName(\"SQL var\")\r\n sql_var.setDescription(\"SQL var\")\r\n sql_var.setDefaultValue(\"Facility Total Electric Demand Power\")\r\n args << sql_var \r\n \r\n stp = OpenStudio::Ruleset::OSArgument.makeStringArgument(\"stp\", true)\r\n stp.setDisplayName(\"Timeseries Timestep\")\r\n stp.setDescription(\"Timeseries Timestep\")\r\n stp.setDefaultValue(\"Zone Timestep\")\r\n args << stp\r\n \r\n env = OpenStudio::Ruleset::OSArgument.makeStringArgument(\"env\", true)\r\n env.setDisplayName(\"availableEnvPeriods\")\r\n env.setDescription(\"availableEnvPeriods\")\r\n env.setDefaultValue(\"RUN PERIOD 1\")\r\n args << env\r\n \r\n norm = OpenStudio::Ruleset::OSArgument.makeDoubleArgument(\"norm\", true)\r\n norm.setDisplayName(\"norm of the difference of csv and sql\")\r\n norm.setDescription(\"norm of the difference of csv and sql\")\r\n norm.setDefaultValue(1)\r\n args << norm \r\n\r\n scale = OpenStudio::Ruleset::OSArgument.makeDoubleArgument(\"scale\", true)\r\n scale.setDisplayName(\"scale factor to apply to the difference\")\r\n scale.setDescription(\"scale factor to apply to the difference\")\r\n scale.setDefaultValue(1)\r\n args << scale \r\n\r\n find_avail = OpenStudio::Ruleset::OSArgument.makeBoolArgument(\"find_avail\", true)\r\n find_avail.setDisplayName(\"find_avail\")\r\n find_avail.setDescription(\"find_avail\")\r\n find_avail.setDefaultValue(true)\r\n args << find_avail \r\n\r\n compute_diff = OpenStudio::Ruleset::OSArgument.makeBoolArgument(\"compute_diff\", true)\r\n compute_diff.setDisplayName(\"compute_diff\")\r\n compute_diff.setDescription(\"compute_diff\")\r\n compute_diff.setDefaultValue(true)\r\n args << compute_diff\r\n \r\n verbose_messages = OpenStudio::Ruleset::OSArgument.makeBoolArgument(\"verbose_messages\", true)\r\n verbose_messages.setDisplayName(\"verbose_messages\")\r\n verbose_messages.setDescription(\"verbose_messages\")\r\n verbose_messages.setDefaultValue(true)\r\n args << verbose_messages \r\n \r\n algorithm_download = OpenStudio::Ruleset::OSArgument.makeBoolArgument(\"algorithm_download\", true)\r\n algorithm_download.setDisplayName(\"algorithm_download\")\r\n algorithm_download.setDescription(\"algorithm_download\")\r\n algorithm_download.setDefaultValue(false)\r\n args << algorithm_download \r\n \r\n plot_flag = OpenStudio::Ruleset::OSArgument.makeBoolArgument(\"plot_flag\", true)\r\n plot_flag.setDisplayName(\"plot_flag timeseries data\")\r\n plot_flag.setDescription(\"plot_flag timeseries data\")\r\n plot_flag.setDefaultValue(true)\r\n args << plot_flag\r\n \r\n plot_name = OpenStudio::Ruleset::OSArgument.makeStringArgument(\"plot_name\", true)\r\n plot_name.setDisplayName(\"Plot name\")\r\n plot_name.setDescription(\"Plot name\")\r\n plot_name.setDefaultValue(\"\")\r\n args << plot_name\r\n \r\n warning_messages = OpenStudio::Ruleset::OSArgument.makeBoolArgument(\"warning_messages\", true)\r\n warning_messages.setDisplayName(\"warning_messages\")\r\n warning_messages.setDescription(\"warning_messages\")\r\n warning_messages.setDefaultValue(false)\r\n args << warning_messages\r\n\r\n return args\r\n end", "def arguments(model)\n args = OpenStudio::Ruleset::OSArgumentVector.new\n\n # the name of the space to add to the model\n setpoint = OpenStudio::Ruleset::OSArgument.makeDoubleArgument(\"setpoint_temperature\", true)\n setpoint.setUnits(\"Degrees Celsius\")\n setpoint.setDisplayName(\"Ambient Loop Temperature\")\n setpoint.setDefaultValue(20)\n setpoint.setDescription(\"Temperature setpoint for the ambient loop\")\n args << setpoint\n\n delta = OpenStudio::Ruleset::OSArgument.makeDoubleArgument(\"design_delta\", true)\n delta.setUnits(\"Delta Temperature\")\n delta.setDefaultValue(5.55) # 10 Deg F default delta\n delta.setDisplayName(\"Delta Design Loop Temperature\")\n delta.setDescription(\"Delta design temperature for the ambient loop\")\n args << delta\n\n return args\n end", "def arguments\n args = OpenStudio::Ruleset::OSArgumentVector.new\n\n return args\n end", "def print_two_again(arg1, arg2) # Non-variable list of inputs it will accept\n puts \"arg1: #{arg1}, arg2: #{arg2}\"\nend", "def commander _args\n \"commander _args;\" \n end", "def arguments(model)\n args = OpenStudio::Measure::OSArgumentVector.new\n\n # make a string argument for furnace fuel type\n fuel_display_names = OpenStudio::StringVector.new\n fuel_display_names << Constants.FuelTypeGas\n fuel_display_names << Constants.FuelTypeOil\n fuel_display_names << Constants.FuelTypePropane\n fuel_display_names << Constants.FuelTypeElectric\n fuel_type = OpenStudio::Measure::OSArgument::makeChoiceArgument('fuel_type', fuel_display_names, true)\n fuel_type.setDisplayName('Fuel Type')\n fuel_type.setDescription('Type of fuel used for heating.')\n fuel_type.setDefaultValue(Constants.FuelTypeGas)\n args << fuel_type\n\n # make an argument for entering furnace installed afue\n afue = OpenStudio::Measure::OSArgument::makeDoubleArgument('afue', true)\n afue.setDisplayName('Installed AFUE')\n afue.setUnits('Btu/Btu')\n afue.setDescription('The installed Annual Fuel Utilization Efficiency (AFUE) of the furnace, which can be used to account for performance derating or degradation relative to the rated value.')\n afue.setDefaultValue(0.78)\n args << afue\n\n # make an argument for entering furnace installed supply fan power\n fan_power_installed = OpenStudio::Measure::OSArgument::makeDoubleArgument('fan_power_installed', true)\n fan_power_installed.setDisplayName('Installed Supply Fan Power')\n fan_power_installed.setUnits('W/cfm')\n fan_power_installed.setDescription('Fan power (in W) per delivered airflow rate (in cfm) of the indoor fan for the maximum fan speed under actual operating conditions.')\n fan_power_installed.setDefaultValue(0.5)\n args << fan_power_installed\n\n # make a string argument for furnace heating output capacity\n capacity = OpenStudio::Measure::OSArgument::makeStringArgument('capacity', true)\n capacity.setDisplayName('Heating Capacity')\n capacity.setDescription(\"The output heating capacity of the furnace. If using '#{Constants.SizingAuto}', the autosizing algorithm will use ACCA Manual S to set the capacity.\")\n capacity.setUnits('kBtu/hr')\n capacity.setDefaultValue(Constants.SizingAuto)\n args << capacity\n\n # make a string argument for distribution system efficiency\n dse = OpenStudio::Measure::OSArgument::makeStringArgument('dse', true)\n dse.setDisplayName('Distribution System Efficiency')\n dse.setDescription('Defines the energy losses associated with the delivery of energy from the equipment to the source of the load.')\n dse.setDefaultValue('NA')\n args << dse\n\n # make a bool argument for open hvac flue\n has_hvac_flue = OpenStudio::Measure::OSArgument::makeBoolArgument('has_hvac_flue', true)\n has_hvac_flue.setDisplayName('Air Leakage: Has Open HVAC Flue')\n has_hvac_flue.setDescription('Specifies whether the building has an open flue associated with the HVAC system.')\n has_hvac_flue.setDefaultValue(true)\n args << has_hvac_flue\n\n return args\n end", "def args\n @args\n end", "def default_args(a,b,c=1)\n puts \"\\nValues of variables: \",a,b,c\nend", "def arguments\n args = OpenStudio::Measure::OSArgumentVector.new\n\n return args\n end", "def arguments(model)\n args = OpenStudio::Measure::OSArgumentVector.new\n \n \t#Make a string argument for 24 weekday cooling set point values\n clg_wkdy = OpenStudio::Measure::OSArgument::makeStringArgument(\"clg_wkdy\", false)\n clg_wkdy.setDisplayName(\"Weekday Setpoint\")\n clg_wkdy.setDescription(\"Specify a single cooling setpoint or a 24-hour comma-separated cooling schedule for the weekdays.\")\n clg_wkdy.setUnits(\"degrees F\")\n clg_wkdy.setDefaultValue(\"76\")\n args << clg_wkdy \n \n \t#Make a string argument for 24 weekend cooling set point values\n clg_wked = OpenStudio::Measure::OSArgument::makeStringArgument(\"clg_wked\", false)\n clg_wked.setDisplayName(\"Weekend Setpoint\")\n clg_wked.setDescription(\"Specify a single cooling setpoint or a 24-hour comma-separated cooling schedule for the weekend.\")\n clg_wked.setUnits(\"degrees F\")\n clg_wked.setDefaultValue(\"76\")\n args << clg_wked\t\n\t\n return args\n end", "def arguments\n args = OpenStudio::Measure::OSArgumentVector.new\n # this measure does not require any user arguments, return an empty list\n return args\n end" ]
[ "0.7374333", "0.7374333", "0.7374333", "0.70872897", "0.70077103", "0.70077103", "0.70077103", "0.70077103", "0.70077103", "0.70077103", "0.70077103", "0.70077103", "0.70077103", "0.70077103", "0.70077103", "0.70077103", "0.70077103", "0.70077103", "0.70077103", "0.70077103", "0.70077103", "0.70077103", "0.70077103", "0.70077103", "0.68299204", "0.6825695", "0.6758906", "0.6746552", "0.65893596", "0.6578825", "0.65786016", "0.65448135", "0.6501143", "0.6474433", "0.6470304", "0.6469248", "0.6467998", "0.6462636", "0.6409218", "0.6388153", "0.63780683", "0.6372597", "0.6372573", "0.63620925", "0.63583964", "0.6349174", "0.63468903", "0.63464946", "0.6328633", "0.6326973", "0.6293388", "0.6288865", "0.6271469", "0.6256274", "0.62561256", "0.62395", "0.6236416", "0.6235132", "0.6221539", "0.6221539", "0.6221539", "0.6203321", "0.6194016", "0.61802244", "0.61708623", "0.61680543", "0.6167006", "0.6164411", "0.616031", "0.61441773", "0.61280507", "0.6116039", "0.60984373", "0.608958", "0.6089097", "0.6080744", "0.6076165", "0.60739696", "0.6069339", "0.6068856", "0.6052556", "0.6047566", "0.60359526", "0.60359526", "0.6035496", "0.6027753", "0.6026836", "0.60268176", "0.6020298", "0.6006339", "0.60050493", "0.5999392", "0.5996131", "0.5991216", "0.5985286", "0.59820926", "0.5972977", "0.5967885", "0.5967392", "0.5966197", "0.59577847" ]
0.0
-1
define what happens when the measure is run
def run(model, runner, user_arguments) super(model, runner, user_arguments) #use the built-in error checking if not runner.validateUserArguments(arguments(model), user_arguments) return false end ### START INPUTS #assign the user inputs to variables ceilingReturnPlenumSpaceType = runner.getOptionalWorkspaceObjectChoiceValue("ceilingReturnPlenumSpaceType",user_arguments,model) costTotalHVACSystem = runner.getDoubleArgumentValue("costTotalHVACSystem",user_arguments) remake_schedules = runner.getBoolArgumentValue("remake_schedules",user_arguments) # check that spaceType was chosen and exists in model ceilingReturnPlenumSpaceTypeCheck = OsLib_HelperMethods.checkOptionalChoiceArgFromModelObjects(ceilingReturnPlenumSpaceType, "ceilingReturnPlenumSpaceType","to_SpaceType", runner, user_arguments) if ceilingReturnPlenumSpaceTypeCheck == false then return false else ceilingReturnPlenumSpaceType = ceilingReturnPlenumSpaceTypeCheck["modelObject"] end # default building/ secondary space types standardBuildingTypeTest = ["PrimarySchool","SecondarySchool"] #ML Not used yet secondarySpaceTypeTest = ["Cafeteria", "Kitchen", "Gym", "Auditorium"] primarySpaceType = "Classroom" # todo - why aren't all primary space types listed? Maybe only important that not in secondary list primaryHVAC = {"doas" => true, "fan" => "Variable", "heat" => "wahpv", "cool" => "wahpv", "unitary" => true} secondaryHVAC = {"fan" => "Constant", "heat" => "Gas", "cool" => "SingleDX", "unitary" => true} zoneHVAC = "GSHP" chillerType = "AirCooled" #set to none if chiller not used radiantChillerType = "None" #set to none if not radiant system allHVAC = {"primary" => primaryHVAC,"secondary" => secondaryHVAC,"zone" => zoneHVAC} ### END INPUTS ### START SORT ZONES options = {"standardBuildingTypeTest" => standardBuildingTypeTest, #ML Not used yet "secondarySpaceTypeTest" => secondarySpaceTypeTest, "ceilingReturnPlenumSpaceType" => ceilingReturnPlenumSpaceType} zonesSorted = OsLib_HVAC_zedg_gshp.sortZones(model, runner, options) zonesPrimary = zonesSorted["zonesPrimary"] zonesSecondary = zonesSorted["zonesSecondary"] zonesPlenum = zonesSorted["zonesPlenum"] zonesUnconditioned = zonesSorted["zonesUnconditioned"] ### END SORT ZONES ### START REPORT INITIAL CONDITIONS OsLib_HVAC_zedg_gshp.reportConditions(model, runner, "initial") ### END REPORT INITIAL CONDITIONS ### START ASSIGN HVAC SCHEDULES options = {"primarySpaceType" => primarySpaceType, "allHVAC" => allHVAC, "remake_schedules" => remake_schedules} schedulesHVAC = OsLib_HVAC_zedg_gshp.assignHVACSchedules(model, runner, options) # assign schedules primary_SAT_schedule = schedulesHVAC["primary_sat"] building_HVAC_schedule = schedulesHVAC["hvac"] building_ventilation_schedule = schedulesHVAC["ventilation"] make_hot_water_plant = false unless schedulesHVAC["hot_water"].nil? hot_water_setpoint_schedule = schedulesHVAC["hot_water"] make_hot_water_plant = true end make_chilled_water_plant = false unless schedulesHVAC["chilled_water"].nil? chilled_water_setpoint_schedule = schedulesHVAC["chilled_water"] make_chilled_water_plant = true end make_radiant_hot_water_plant = false unless schedulesHVAC["radiant_hot_water"].nil? radiant_hot_water_setpoint_schedule = schedulesHVAC["radiant_hot_water"] make_radiant_hot_water_plant = true end make_radiant_chilled_water_plant = false unless schedulesHVAC["radiant_chilled_water"].nil? radiant_chilled_water_setpoint_schedule = schedulesHVAC["radiant_chilled_water"] make_radiant_chilled_water_plant = true end unless schedulesHVAC["hp_loop"].nil? heat_pump_loop_setpoint_schedule = schedulesHVAC["hp_loop"] end unless schedulesHVAC["hp_loop_cooling"].nil? heat_pump_loop_cooling_setpoint_schedule = schedulesHVAC["hp_loop_cooling"] end unless schedulesHVAC["hp_loop_heating"].nil? heat_pump_loop_heating_setpoint_schedule = schedulesHVAC["hp_loop_heating"] end unless schedulesHVAC["mean_radiant_heating"].nil? mean_radiant_heating_setpoint_schedule = schedulesHVAC["mean_radiant_heating"] end unless schedulesHVAC["mean_radiant_cooling"].nil? mean_radiant_cooling_setpoint_schedule = schedulesHVAC["mean_radiant_cooling"] end ### END ASSIGN HVAC SCHEDULES ### START REMOVE EQUIPMENT OsLib_HVAC_zedg_gshp.removeEquipment(model, runner) ### END REMOVE EQUIPMENT ### START CREATE NEW PLANTS # create new plants # hot water plant if make_hot_water_plant hot_water_plant = OsLib_HVAC_zedg_gshp.createHotWaterPlant(model, runner, hot_water_setpoint_schedule, "Hot Water") end # chilled water plant if make_chilled_water_plant chilled_water_plant = OsLib_HVAC_zedg_gshp.createChilledWaterPlant(model, runner, chilled_water_setpoint_schedule, "Chilled Water", chillerType) end # radiant hot water plant if make_radiant_hot_water_plant radiant_hot_water_plant = OsLib_HVAC_zedg_gshp.createHotWaterPlant(model, runner, radiant_hot_water_setpoint_schedule, "Radiant Hot Water") end # chilled water plant if make_radiant_chilled_water_plant radiant_chilled_water_plant = OsLib_HVAC_zedg_gshp.createChilledWaterPlant(model, runner, radiant_chilled_water_setpoint_schedule, "Radiant Chilled Water", radiantChillerType) end # condenser loop # need condenser loop if there is a water-cooled chiller or if there is a water source heat pump loop options = {} options["zoneHVAC"] = zoneHVAC if zoneHVAC == "WSHP" or zoneHVAC == "GSHP" options["loop_setpoint_schedule"] = heat_pump_loop_setpoint_schedule options["cooling_setpoint_schedule"] = heat_pump_loop_cooling_setpoint_schedule options["heating_setpoint_schedule"] = heat_pump_loop_heating_setpoint_schedule end condenserLoops = OsLib_HVAC_zedg_gshp.createCondenserLoop(model, runner, options) unless condenserLoops["condenser_loop"].nil? condenser_loop = condenserLoops["condenser_loop"] end make_heat_pump_loop = false unless condenserLoops["heat_pump_loop"].nil? heat_pump_loop = condenserLoops["heat_pump_loop"] make_heat_pump_loop = true end ### END CREATE NEW PLANTS ### START CREATE PRIMARY ZONE EQUIPMENT options = {} options["zonesPrimary"] = zonesPrimary options["zoneHVAC"] = zoneHVAC if make_hot_water_plant options["hot_water_plant"] = hot_water_plant end if make_chilled_water_plant options["chilled_water_plant"] = chilled_water_plant end if zoneHVAC == "WSHP" or zoneHVAC == "GSHP" options["heat_pump_loop"] = heat_pump_loop end if zoneHVAC == "DualDuct" options["ventilation_schedule"] = building_ventilation_schedule end if zoneHVAC == "Radiant" options["radiant_hot_water_plant"] = radiant_hot_water_plant options["radiant_chilled_water_plant"] = radiant_chilled_water_plant options["mean_radiant_heating_setpoint_schedule"] = mean_radiant_heating_setpoint_schedule options["mean_radiant_cooling_setpoint_schedule"] = mean_radiant_cooling_setpoint_schedule end OsLib_HVAC_zedg_gshp.createPrimaryZoneEquipment(model, runner, options) ### END CREATE PRIMARY ZONE EQUIPMENT ### START CREATE PRIMARY AIRLOOPS # populate inputs hash for create primary airloops method options = {} options["zonesPrimary"] = zonesPrimary options["primaryHVAC"] = primaryHVAC options["zoneHVAC"] = zoneHVAC if primaryHVAC["doas"] options["hvac_schedule"] = building_ventilation_schedule options["ventilation_schedule"] = building_ventilation_schedule else # primary HVAC is multizone VAV unless zoneHVAC == "DualDuct" # primary system is multizone VAV that cools and ventilates options["hvac_schedule"] = building_HVAC_schedule options["ventilation_schedule"] = building_ventilation_schedule else # primary system is a multizone VAV that cools only (primary system ventilation schedule is set to always off; hvac set to always on) options["hvac_schedule"] = model.alwaysOnDiscreteSchedule() end end options["primary_sat_schedule"] = primary_SAT_schedule if make_hot_water_plant options["hot_water_plant"] = hot_water_plant end if make_chilled_water_plant options["chilled_water_plant"] = chilled_water_plant end if make_heat_pump_loop options["heat_pump_loop"] = heat_pump_loop end primary_airloops = OsLib_HVAC_zedg_gshp.createPrimaryAirLoops(model, runner, options) ### END CREATE PRIMARY AIRLOOPS ### START CREATE SECONDARY AIRLOOPS # populate inputs hash for create primary airloops method # todo - set this up to take unitary system options = {} options["zonesSecondary"] = zonesSecondary options["secondaryHVAC"] = secondaryHVAC options["hvac_schedule"] = building_HVAC_schedule options["ventilation_schedule"] = building_ventilation_schedule if make_hot_water_plant options["hot_water_plant"] = hot_water_plant end if make_chilled_water_plant options["chilled_water_plant"] = chilled_water_plant end if make_heat_pump_loop options["heat_pump_loop"] = heat_pump_loop end secondary_airloops = OsLib_HVAC_zedg_gshp.createSecondaryAirLoops(model, runner, options) ### END CREATE SECONDARY AIRLOOPS ### START ASSIGN PLENUMS options = {"zonesPrimary" => zonesPrimary,"zonesPlenum" => zonesPlenum} zone_plenum_hash = OsLib_HVAC_zedg_gshp.validateAndAddPlenumZonesToSystem(model, runner, options) ### END ASSIGN PLENUMS # START ADD DCV options = {} unless zoneHVAC == "DualDuct" options["primary_airloops"] = primary_airloops end options["secondary_airloops"] = secondary_airloops options["allHVAC"] = allHVAC OsLib_HVAC_zedg_gshp.addDCV(model, runner, options) options = {} options["secondary_airloops"] = secondary_airloops options["allHVAC"] = allHVAC OsLib_HVAC_zedg_gshp.addDCV(model, runner, options) # END ADD DCV # add in lifecycle costs expected_life = 25 years_until_costs_start = 0 costHVAC = costTotalHVACSystem lcc_mat = OpenStudio::Model::LifeCycleCost.createLifeCycleCost("HVAC System", model.getBuilding, costHVAC, "CostPerEach", "Construction", expected_life, years_until_costs_start).get # todo - add EMS # totod - test ems in run before commit plant_component_temperature_source = model.getPlantComponentTemperatureSources.first inlet_port = plant_component_temperature_source.inletModelObject.get # todo - confirm this exists schedule = plant_component_temperature_source.sourceTemperatureSchedule.get # todo - confirm this exists runner.registerInfo("Adding Plant Component Temperature Source EMS code for #{plant_component_temperature_source.name}") # add output variable outputVariable = OpenStudio::Model::OutputVariable.new("System Node Temperature",model) outputVariable.setReportingFrequency("Hourly") outputVariable.setKeyValue(plant_component_temperature_source.name.get) # add sensor sensor = OpenStudio::Model::EnergyManagementSystemSensor.new(model, "System Node Temperature") sensor.setKeyName(inlet_port.name.get) sensor.setName("Ground_HX_Inlet_Temp") # add actuator actuator = OpenStudio::Model::EnergyManagementSystemActuator.new(schedule,"Schedule:Constant","Schedule Value") actuator.setName("Ground_HX_Schedule_Actuator") # add program control_program = OpenStudio::Model::EnergyManagementSystemProgram.new(model) control_program.setName("Ground HX") control_program.addLine("SET Tin = Ground_HX_Inlet_Temp") control_program.addLine("IF Tin < 15.556") control_program.addLine("SET Tout = Tin + 5.556") control_program.addLine("ELSE") control_program.addLine("SET Tout = Tin - 5.556") control_program.addLine("ENDIF") control_program.addLine("SET Ground_HX_Schedule_Actuator = Tout") # add program calling manager pcm = OpenStudio::Model::EnergyManagementSystemProgramCallingManager.new(model) pcm.setName("Ground HX") pcm.setCallingPoint("InsideHVACSystemIterationLoop") pcm.addProgram(control_program) ### START REPORT FINAL CONDITIONS OsLib_HVAC_zedg_gshp.reportConditions(model, runner, "final") ### END REPORT FINAL CONDITIONS return true end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def measure; end", "def measure=(_arg0); end", "def measure\n\t\t1\n\tend", "def measure(*args, &b)\n end", "def communicate_measure_result(_ = nil, _ = nil); end", "def communicate_measure_result(_ = nil, _ = nil); end", "def called\n self.measurement.called\n end", "def measure\n start = Time.now\n yield\n Time.now - start\n end", "def measure\n start = Time.now\n yield\n Time.now - start\n end", "def measure\n Measure.new(1, self)\n end", "def measurement(n)\n @options[:before_hook].call(n)\n measure = measure(n, &@options[:fn])\n @options[:after_hook].call(n)\n measure\n end", "def measure\n Measure.new(@counter+=1)\n end", "def communicate_measure_result(_ = nil, _ = nil)\r\n end", "def benchmark\nend", "def calculated; end", "def setup_metrics\n end", "def setup_metrics\n end", "def setup_metrics\n end", "def run()\n\t\tputs \"#{@name} ran for #{@meters} meters in #{self.getTimeLapse} seconds\"\n\t\t# chiama funzione per stampare quante volte ha respirato\n\t\tself.breathe\n\tend", "def runs; end", "def statistics; end", "def medical_use; end", "def measure\n start_real = System.monotonic_time\n start_cpu = System.cpu_time\n retval = yield\n\n real_time = System.monotonic_time - start_real\n cpu_time = System.cpu_time - start_cpu\n\n @real_time += real_time\n @cpu_time += cpu_time\n @call_count += 1\n\n if call_measurement_enabled? && above_threshold?\n self.class.call_duration_histogram.observe(@transaction.labels.merge(labels), real_time / 1000.0)\n end\n\n retval\n end", "def stats; end", "def stats; end", "def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n\n # use the built-in error checking\n if !runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n\n # Return N/A if not selected to run\n run_measure = runner.getIntegerArgumentValue(\"run_measure\",user_arguments)\n if run_measure == 0\n runner.registerAsNotApplicable(\"Run Measure set to #{run_measure}.\")\n return true \n end \n \n\n percent_runtime_reduction = runner.getDoubleArgumentValue(\"percent_runtime_reduction\",user_arguments)\n\n \n \n # Check arguments for reasonableness\n if percent_runtime_reduction >= 100\n runner.registerError(\"Percent runtime reduction must be less than 100.\")\n return false\n end\n\n # Find all the original schedules (before occ sensors installed)\n original_lts_schedules = []\n model.getLightss.each do |light_fixture|\n if light_fixture.schedule.is_initialized\n original_lts_schedules << light_fixture.schedule.get\n end\n end \n\n # Make copies of all the original lights schedules, reduced to include occ sensor impact\n original_schs_new_schs = {}\n original_lts_schedules.uniq.each do |orig_sch|\n # Copy the original schedule\n new_sch = orig_sch.clone.to_ScheduleRuleset.get\n new_sch.setName(\"#{new_sch.name.get} with occ sensor\")\n # Reduce each value in each profile (except the design days) by the specified amount\n runner.registerInfo(\"Reducing values in '#{orig_sch.name}' schedule by #{percent_runtime_reduction}% to represent occ sensor installation.\")\n day_profiles = []\n day_profiles << new_sch.defaultDaySchedule\n new_sch.scheduleRules.each do |rule|\n day_profiles << rule.daySchedule\n end\n multiplier = (100 - percent_runtime_reduction)/100\n day_profiles.each do |day_profile|\n #runner.registerInfo(\"#{day_profile.name}\")\n times_vals = day_profile.times.zip(day_profile.values)\n #runner.registerInfo(\"original time/values = #{times_vals}\")\n times_vals.each do |time,val|\n day_profile.addValue(time, val * multiplier)\n end\n #runner.registerInfo(\"new time/values = #{day_profile.times.zip(day_profile.values)}\")\n end \n #log the relationship between the old sch and the new, reduced sch\n original_schs_new_schs[orig_sch] = new_sch\n end\n \n # Replace the old schedules with the new, reduced schedules\n spaces_sensors_added_to = []\n model.getLightss.each do |light_fixture|\n next if light_fixture.schedule.empty?\n lights_sch = light_fixture.schedule.get\n new_sch = original_schs_new_schs[lights_sch]\n if new_sch\n runner.registerInfo(\"Added occupancy sensor for '#{light_fixture.name}'\")\n light_fixture.setSchedule(new_sch)\n spaces_sensors_added_to << light_fixture.space\n end\n end\n \n # Report if the measure is not applicable\n num_sensors_added = spaces_sensors_added_to.uniq.size\n if spaces_sensors_added_to.size == 0\n runner.registerAsNotApplicable(\"This measure is not applicable because there were no lights in the building.\")\n return true\n end \n \n # Report final condition\n runner.registerFinalCondition(\"Added occupancy sensors to #{num_sensors_added} spaces in the building.\")\n\n return true\n\n end", "def run\n\t\t\tsummary\n\t\tend", "def quick_stats\n\tend", "def stats\n \n end", "def benchmark(reporter); end", "def stats\n end", "def stats\n end", "def measure(name, &block)\n if self.running? name\n yield\n else\n result = nil\n self.results[name] ||= 0\n self.running << name\n self.results[name] += Benchmark.measure{result = yield}.real\n self.running.delete(name)\n result\n end\n end", "def measure\n start_real = System.monotonic_time\n start_cpu = System.cpu_time\n retval = yield\n\n real_time = System.monotonic_time - start_real\n cpu_time = System.cpu_time - start_cpu\n\n @real_time += real_time\n @cpu_time += cpu_time\n @call_count += 1\n\n if above_threshold?\n self.class.gitlab_method_call_duration_seconds.observe(@transaction.labels.merge(labels), real_time)\n end\n\n retval\n end", "def measure_code(model,runner)\n measure_folder = \"#{File.dirname(__FILE__)}/\"\n baseline_spreadsheet = \"#{File.dirname(__FILE__)}/baseline.csv\"\n #Note: place output folder locally to run faster! (e.g. your C drive)\n output_folder = \"#{File.dirname(__FILE__)}/tests/output\"\n create_models = true\n simulate_models = true\n create_annual_outputs = true\n create_hourly_outputs = true\n #This creates the measures object and collects all the csv information for the\n # measure_id variant.\n csv_measures = BTAP::Measures::CSV_OS_Measures.new(\n baseline_spreadsheet,\n measure_folder#script root folder where all the csv relative paths are used.\n )\n csv_measures.create_cold_lake_vintages(output_folder) unless create_models == false\n BTAP::SimManager::simulate_all_files_in_folder(output_folder) unless simulate_models == false\n BTAP::Reporting::get_all_annual_results_from_runmanger(output_folder) unless create_annual_outputs == false\n #convert eso to csv then create terminus file.\n BTAP::FileIO::convert_all_eso_to_csv(output_folder, output_folder).each {|csvfile| BTAP::FileIO::terminus_hourly_output(csvfile)} unless create_hourly_outputs == false\n\n end", "def cpu_metrics\n super\n end", "def instrument; end", "def profiler; end", "def profiler; end", "def setup\n\t\n # create an instance of the measure\n @measure = VentilationQAQC.new\n \n #create an instance of the runner\n @runner = OpenStudio::Ruleset::OSRunner.new\t\n\t\n # get arguments \n @arguments = @measure.arguments()\n\n # make argument map\n make_argument_map\n\t\n # Make an empty model\n @model = OpenStudio::Model::Model.new\n\t@runner.setLastOpenStudioModel(@model)\n\t\n\t# Create a fake sql file - our measure will crash if @runner has no sql file set.\n\t# We don't get data from this file because we get data from our patched SqlFile class instead (see above)\n\tsqlFile = OpenStudio::SqlFile.new(OpenStudio::Path.new(sqlPath))\n\t@runner.setLastEnergyPlusSqlFilePath(OpenStudio::Path.new(sqlPath))\n\t\n\t$serieses[\"Zone Mechanical Ventilation Mass Flow Rate|ZONE1\"] = OpenStudio::TimeSeries.new(OpenStudio::Date.new, OpenStudio::Time.new(1.0), (0..364).to_a.to_vector, \"m^3/s\")\n end", "def monitor(*args, &bl)\n result = nil\n took = Benchmark.realtime {\n result = bl.call\n }\n Tools.info(args, op_took: took)\n result\n end", "def measure_code(model,runner)\n ################ Start Measure code here ################################\n \n #Check weather directory Weather File\n unless (Pathname.new @lib_directory).absolute?\n @lib_directory = File.expand_path(File.join(File.dirname(__FILE__), @lib_directory))\n end\n lib_file = File.join(@lib_directory, @lib_file_name)\n if File.exists?(lib_file) and @lib_file_name.downcase.include? \".osm\"\n BTAP::runner_register(\"Info\",\"#{@lib_file_name} Found!.\", runner)\n else\n BTAP::runner_register(\"Error\",\"#{lib_file} does not exist or is not an .osm file.\", runner)\n return false\n end\n \n #load model and test.\n construction_set = BTAP::Resources::Envelope::ConstructionSets::get_construction_set_from_library( lib_file, @construction_set_name )\n #Set Construction Set.\n unless model.building.get.setDefaultConstructionSet( construction_set.clone( model ).to_DefaultConstructionSet.get )\n BTAP::runner_register(\"Error\",\"Could not set Default Construction #{@construction_set_name} \", runner)\n return false\n end\n BTAP::runner_register(\"FinalCondition\",\"Default Construction set to #{@construction_set_name} from #{lib_file}\",runner)\n ##########################################################################\n return true\n end", "def run(workspace, runner, user_arguments)\n super(workspace, runner, user_arguments)\n\n # use the built-in error checking \n if !runner.validateUserArguments(arguments(workspace), user_arguments)\n return false\n end\n \n # Report that this is an anti-measure\n runner.registerValue('anti_measure',true) \n \n # Return N/A if not selected to run\n run_measure = runner.getIntegerArgumentValue(\"run_measure\",user_arguments)\n if run_measure == 0\n runner.registerAsNotApplicable(\"Run Measure set to #{run_measure}.\")\n return true \n end\n \n\t# Initialize counter variables\n\tno_economizer = 0\n\tfixed_dry_bulb = 0\n\tdifferential_dry_bulb = 0\t\n\tfixed_enthalpy = 0\n\tdifferential_enthalpy = 0\n\tfixed_dew_point_and_dry_bulb = 0\n\telectronic_enthalpy = 0\n\tdifferential_dry_bulb_and_enthalpy = 0\n\t\n\t# Retrieve all Controller:Outdoor air objects in the idf \t\n\toa_controllers = workspace.getObjectsByType(\"Controller:OutdoorAir\".to_IddObjectType)\n\t\n\t# Get the names of each Controller:Outdoor Air object\n\toa_controllers.each do |oa_controller|\n\n\t\toa_controller_name = oa_controller.getString(0).to_s #(0) is field Name\n\t\toa_controller_economizer_control_type = oa_controller.getString(7).to_s #(7) is field Economizer Control Type\n\t\n\t\t# test for presence No economizer controller setting \n\t\tif oa_controller_economizer_control_type == \"NoEconomizer\" # or empty\n\t\t\trunner.registerInfo(\"The Controller:Outdoor air object named #{oa_controller_name} has a disabled airside economizer. Economizer sensor faults will not be added.\")\n\t\t\tno_economizer = no_economizer + 1\n\t\tend\n\t\t\n\t\t# test for presence of differential dry bulb economizer controller setting \n\t\tif oa_controller_economizer_control_type == \"DifferentialDryBulb\"\n\t\t\t# Initialize array to hold new IDF objects\n\t\t\tstring_object = []\n\t\t\t# Create IDF object text for FaultModel:TemperatureSensorOffset:OutdoorAir \n\t\t\tstring_object = \"\n\t\t\t\tFaultModel:TemperatureSensorOffset:OutdoorAir,\n\t\t\t\t#{oa_controller_name}_Outdoor Air Temp Sensor Bias, !- Name\n\t\t\t\tAlways On Discrete, \t\t\t\t\t\t\t!- Availability Schedule Name\n\t\t\t\t, \t\t\t\t\t\t\t\t\t\t\t\t!- Severity Schedule Name\n\t\t\t\tController:OutdoorAir, \t\t\t\t\t\t\t!- Controller Object Type\n\t\t\t\t#{oa_controller_name}, \t\t\t\t\t\t\t!- Controller Object Name\n\t\t\t\t1.11; \t\t\t\t\t\t\t\t\t\t\t!- Temperature Sensor Offset \n\t\t\t\t\"\n\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t# Add string object to workspace to create idf object\n\t\t\tidfObject = OpenStudio::IdfObject::load(string_object)\n\t\t\tobject = idfObject.get\n\t\t\tworkspace.addObject(object)\n\n\t\t\t# Create IDF object text for FaultModel:TemperatureSensorOffset:ReturnAir\n\t\t\tstring_object = \"\n\t\t\t\tFaultModel:TemperatureSensorOffset:ReturnAir,\n\t\t\t\t#{oa_controller_name}_Return Air Temp Sensor Bias, !- Name\n\t\t\t\tAlways On Discrete, \t\t\t\t\t\t\t!- Availability Schedule Name\n\t\t\t\t, \t\t\t\t\t\t\t\t\t\t\t\t!- Severity Schedule Name\n\t\t\t\tController:OutdoorAir, \t\t\t\t\t\t\t!- Controller Object Type\n\t\t\t\t#{oa_controller_name}, \t\t\t\t\t\t\t!- Controller Object Name\n\t\t\t\t-1.11; \t\t\t\t\t\t\t\t\t\t\t!- Temperature Sensor Offset \n\t\t\t\t\"\n\t\t\t\n\t\t\t# Add string object to workspace to create idf object\n\t\t\tidfObject = OpenStudio::IdfObject::load(string_object)\n\t\t\tobject = idfObject.get\n\t\t\tworkspace.addObject(object)\n\t\t\t\n\t\t\tdifferential_dry_bulb = differential_dry_bulb + 1\n\t\t\t# info message\n\t\t\trunner.registerInfo(\"To model dry bulb sensor drift, a FaultModel:TemperatureSensorOffset:ReturnAir object with an offset of -2 deg F and a FaultModel:TemperatureSensorOffset:OutdoorAir object with an offset of +2 deg F has been added to the #{oa_controller_economizer_control_type} controlled airside economizer associated with the Controller:Outdoor air object named #{oa_controller_name}. The fault availability is scheduled using the 'Always On Discrete' schedule.\")\n\t\t\t\n\n\t\tend # OA Controller Type DifferentialDryBulb\n\n\t\t# test for presence of fixed dry bulb economizer controller setting \n\t\tif oa_controller_economizer_control_type == \"FixedDryBulb\"\n\t\t\t# Initialize array to hold new IDF objects\n\t\t\tstring_object = []\n\t\t\t# Create IDF object text for FaultModel:TemperatureSensorOffset:OutdoorAir\n\t\t\tstring_object = \"\n\t\t\t\tFaultModel:TemperatureSensorOffset:OutdoorAir,\n\t\t\t\t#{oa_controller_name}_Outdoor Air Temp Sensor Bias, !- Name\n\t\t\t\tAlways On Discrete, \t\t\t\t\t\t\t!- Availability Schedule Name\n\t\t\t\t, \t\t\t\t\t\t\t\t\t\t\t\t!- Severity Schedule Name\n\t\t\t\tController:OutdoorAir, \t\t\t\t\t\t\t!- Controller Object Type\n\t\t\t\t#{oa_controller_name}, \t\t\t\t\t\t\t!- Controller Object Name\n\t\t\t\t1.11; \t\t\t\t\t\t\t\t\t\t\t!- Temperature Sensor Offset \n\t\t\t\t\"\n\t\t\t# Add string object to workspace to create idf object\n\t\t\tidfObject = OpenStudio::IdfObject::load(string_object)\n\t\t\tobject = idfObject.get\n\t\t\tworkspace.addObject(object)\n\t\t\t\n\t\t\t# Create IDF object text for FaultModel:TemperatureSensorOffset:ReturnAir\n\t\t\tstring_object = \"\n\t\t\t\tFaultModel:TemperatureSensorOffset:ReturnAir,\n\t\t\t\t#{oa_controller_name}_Return Air Temp Sensor Bias, !- Name\n\t\t\t\tAlways On Discrete, \t\t\t\t\t\t\t!- Availability Schedule Name\n\t\t\t\t, \t\t\t\t\t\t\t\t\t\t\t\t!- Severity Schedule Name\n\t\t\t\tController:OutdoorAir, \t\t\t\t\t\t\t!- Controller Object Type\n\t\t\t\t#{oa_controller_name}, \t\t\t\t\t\t\t!- Controller Object Name\n\t\t\t\t-1.11; \t\t\t\t\t\t\t\t\t\t\t!- Temperature Sensor Offset \n\t\t\t\t\"\n\t\t\t# Add string object to workspace to create idf object\n\t\t\tidfObject = OpenStudio::IdfObject::load(string_object)\n\t\t\tobject = idfObject.get\n\t\t\tworkspace.addObject(object)\n\t\t\t\n\t\t\trunner.registerInfo(\"To model dry bulb sensor drift, a FaultModel:TemperatureSensorOffset:ReturnAir object with an offset of -2 deg F and a FaultModel:TemperatureSensorOffset:OutdoorAir object with an offset of +2 deg F has been added to the #{oa_controller_economizer_control_type} controlled airside economizer associated with the Controller:Outdoor air object named #{oa_controller_name}. The fault availability is scheduled using the 'Always On Discrete' schedule.\")\n\t\t\tfixed_dry_bulb = fixed_dry_bulb + 1\n\t\t\t\n\t\tend # OA Controller Type = FixedDryBulb \t\t\n\t\t\n\t\t# test for presence of fixed enthalpy economizer controller setting \t\t\t\t\n\t\tif oa_controller_economizer_control_type == \"FixedEnthalpy\"\n\t\t\t# Initialze array to hold new IDF objects\n\t\t\tstring_object = []\n\t\t\t# Create IDF object text for FaultModel:EnthalpySensorOffset:OutdoorAir\n\t\t\tstring_object = \"\n\t\t\t\tFaultModel:EnthalpySensorOffset:OutdoorAir,\n\t\t\t\t#{oa_controller_name}_Outdoor Air Enthalpy Sensor Bias, !- Name\n\t\t\t\tAlways On Discrete, \t\t\t\t\t\t\t!- Availability Schedule Name\n\t\t\t\t, \t\t\t\t\t\t\t\t\t\t\t\t!- Severity Schedule Name\n\t\t\t\tController:OutdoorAir, \t\t\t\t\t\t\t!- Controller Object Type\n\t\t\t\t#{oa_controller_name}, \t\t\t\t\t\t\t!- Controller Object Name\n\t\t\t\t5; \t\t\t\t\t\t\t\t\t\t\t!- Temperature Sensor Offset \n\t\t\t\t\"\n\t\t\t# Add string object to workspace to create idf object\n\t\t\tidfObject = OpenStudio::IdfObject::load(string_object)\n\t\t\tobject = idfObject.get\n\t\t\tworkspace.addObject(object)\n\t\t\t\n\t\t\t# Create IDF object text for FaultModel:EnthalpySensorOffset:ReturnAir\n\t\t\tstring_object = \"\n\t\t\t\tFaultModel:EnthalpySensorOffset:ReturnAir,\n\t\t\t\t#{oa_controller_name}_Return Air Enthalpy Sensor Bias, !- Name\n\t\t\t\tAlways On Discrete, \t\t\t\t\t\t\t!- Availability Schedule Name\n\t\t\t\t, \t\t\t\t\t\t\t\t\t\t\t\t!- Severity Schedule Name\n\t\t\t\tController:OutdoorAir, \t\t\t\t\t\t\t!- Controller Object Type\n\t\t\t\t#{oa_controller_name}, \t\t\t\t\t\t\t!- Controller Object Name\n\t\t\t\t-5; \t\t\t\t\t\t\t\t\t\t\t!- Temperature Sensor Offset \n\t\t\t\t\"\n\t\t\t# Add string object to workspace to create idf object\n\t\t\tidfObject = OpenStudio::IdfObject::load(string_object)\n\t\t\tobject = idfObject.get\n\t\t\twworkspace.addObject(object)\n\n\t\t\trunner.registerInfo(\"To model enthalpy sensor drift, a FaultModel:EnthalpySensorOffset:ReturnAir object with an offset of -2 Btu/lb and a FaultModel:EnthalpySensorOffset:OutdoorAir object with an offset of +2 Btu/lb have been added to the #{oa_controller_economizer_control_type} controlled airside economizer associated with the Controller:Outdoor air object named #{oa_controller_name}. The fault availability is scheduled using the 'Always On Discrete' schedule.\")\n\t\t\tfixed_enthalpy = fixed_enthalpy + 1\n\t\tend # OA Controller Type = FixedEnthalpy \n\t\t\n\t\t# test for presence of differential enthalpy economizer controller setting \t\t\n\t\tif oa_controller_economizer_control_type == \"DifferentialEnthalpy\"\n\t\t\t# Initialze array to hold new IDF objects\n\t\t\tstring_object = []\n\t\t\t# Create IDF object text for FaultModel:EnthalpySensorOffset:OutdoorAir\n\t\t\tstring_object = \"\n\t\t\t\tFaultModel:EnthalpySensorOffset:OutdoorAir,\n\t\t\t\t#{oa_controller_name}_Outdoor Air Enthalpy Sensor Bias, !- Name\n\t\t\t\tAlways On Discrete, \t\t\t\t\t\t\t!- Availability Schedule Name\n\t\t\t\t, \t\t\t\t\t\t\t\t\t\t\t\t!- Severity Schedule Name\n\t\t\t\tController:OutdoorAir, \t\t\t\t\t\t\t!- Controller Object Type\n\t\t\t\t#{oa_controller_name}, \t\t\t\t\t\t\t!- Controller Object Name\n\t\t\t\t5; \t\t\t\t\t\t\t\t\t\t\t!- Temperature Sensor Offset \n\t\t\t\t\"\n\t\t\t# Add string object to workspace to create idf object\n\t\t\tidfObject = OpenStudio::IdfObject::load(string_object)\n\t\t\tobject = idfObject.get\n\t\t\tworkspace.addObject(object)\n\t\t\t\n\t\t\t# Create IDF object text for FaultModel:EnthalpySensorOffset:ReturnAir\n\t\t\tstring_object = \"\n\t\t\t\tFaultModel:EnthalpySensorOffset:ReturnAir,\n\t\t\t\t#{oa_controller_name}_Return Air Enthalpy Sensor Bias, !- Name\n\t\t\t\tAlways On Discrete, \t\t\t\t\t\t\t!- Availability Schedule Name\n\t\t\t\t, \t\t\t\t\t\t\t\t\t\t\t\t!- Severity Schedule Name\n\t\t\t\tController:OutdoorAir, \t\t\t\t\t\t\t!- Controller Object Type\n\t\t\t\t#{oa_controller_name}, \t\t\t\t\t\t\t!- Controller Object Name\n\t\t\t\t-5; \t\t\t\t\t\t\t\t\t\t\t!- Temperature Sensor Offset \n\t\t\t\t\"\n\t\t\t# Add string object to workspace to create idf object\n\t\t\tidfObject = OpenStudio::IdfObject::load(string_object)\n\t\t\tobject = idfObject.get\n\t\t\tworkspace.addObject(object)\n\n\t\t\trunner.registerInfo(\"To model enthalpy sensor drift, a FaultModel:EnthalpySensorOffset:ReturnAir object with an offset of -2 Btu/lb and a FaultModel:EnthalpySensorOffset:OutdoorAir object with an offset of +2 Btu/lb have been added to the #{oa_controller_economizer_control_type} controlled airside economizer associated with the Controller:Outdoor air object named #{oa_controller_name}. The fault availability is scheduled using the 'Always On Discrete' schedule.\")\n\t\t\tdifferential_enthalpy = differential_enthalpy + 1\n\t\t\t\n\t\tend # OA Controller Type =\"Differential Enthalpy\"\t\t\n\t\t\n\t\n\t\t# test for presence of electronic enthalpy economizer controller setting \n\t\tif oa_controller_economizer_control_type == \"ElectronicEnthalpy\"\n\t\t\t# Initialze array to hold new IDF objects\n\t\t\tstring_object = []\n\t\t\t# Create IDF object text for FaultModel:EnthalpySensorOffset:OutdoorAir\n\t\t\tstring_object = \"\n\t\t\t\tFaultModel:EnthalpySensorOffset:OutdoorAir,\n\t\t\t\t#{oa_controller_name}_Outdoor Air Enthalpy Sensor Bias, !- Name\n\t\t\t\tAlways On Discrete, \t\t\t\t\t\t\t!- Availability Schedule Name\n\t\t\t\t, \t\t\t\t\t\t\t\t\t\t\t\t!- Severity Schedule Name\n\t\t\t\tController:OutdoorAir, \t\t\t\t\t\t\t!- Controller Object Type\n\t\t\t\t#{oa_controller_name}, \t\t\t\t\t\t\t!- Controller Object Name\n\t\t\t\t5; \t\t\t\t\t\t\t\t\t\t\t\t!- Temperature Sensor Offset \n\t\t\t\t\"\n\t\t\t# Add string object to workspace to create idf object\n\t\t\tidfObject = OpenStudio::IdfObject::load(string_object)\n\t\t\tobject = idfObject.get\n\t\t\tworkspace.addObject(object)\n\t\t\t\n\t\t\t# Create IDF object text for FaultModel:EnthalpySensorOffset:ReturnAir\n\t\t\tstring_object = \"\n\t\t\t\tFaultModel:EnthalpySensorOffset:ReturnAir,\n\t\t\t\t#{oa_controller_name}_Return Air Enthalpy Sensor Bias, !- Name\n\t\t\t\tAlways On Discrete, \t\t\t\t\t\t\t!- Availability Schedule Name\n\t\t\t\t, \t\t\t\t\t\t\t\t\t\t\t\t!- Severity Schedule Name\n\t\t\t\tController:OutdoorAir, \t\t\t\t\t\t\t!- Controller Object Type\n\t\t\t\t#{oa_controller_name}, \t\t\t\t\t\t\t!- Controller Object Name\n\t\t\t\t-5; \t\t\t\t\t\t\t\t\t\t\t!- Temperature Sensor Offset \n\t\t\t\t\"\n\t\t\t# Add string object to workspace to create idf object\n\t\t\tidfObject = OpenStudio::IdfObject::load(string_object)\n\t\t\tobject = idfObject.get\n\t\t\tworkspace.addObject(object)\n\n\t\t\trunner.registerInfo(\"To model enthalpy sensor drift, a FaultModel:EnthalpySensorOffset:ReturnAir object with an offset of -2 Btu/lb and a FaultModel:EnthalpySensorOffset:OutdoorAir object with an offset of +2 Btu/lb have been added to the #{oa_controller_economizer_control_type} controlled airside economizer associated with the Controller:Outdoor air object named #{oa_controller_name}. The fault availability is scheduled using the 'Always On Discrete' schedule.\")\n\t\t\telectronic_enthalpy = electronic_enthalpy + 1\n\n\t\tend # OA Controller Type = \"ElectronicEnthalpy\" \t\t\n\t\t\n\t\t# test for presence of fixed dew point and dry bulb economizer controller setting \n\t\tif oa_controller_economizer_control_type == \"FixedDewPointAndDryBulb\" \n\t\t\t# Initialze array to hold new IDF objects\n\t\t\tstring_object = []\n\t\t\t# Create IDF object text for FaultModel:EnthalpySensorOffset:OutdoorAir\n\t\t\tstring_object = \"\n\t\t\t\tFaultModel:EnthalpySensorOffset:OutdoorAir,\n\t\t\t\t#{oa_controller_name}_Outdoor Air Enthalpy Sensor Bias, !- Name\n\t\t\t\tAlways On Discrete, \t\t\t\t\t\t\t!- Availability Schedule Name\n\t\t\t\t, \t\t\t\t\t\t\t\t\t\t\t\t!- Severity Schedule Name\n\t\t\t\tController:OutdoorAir, \t\t\t\t\t\t\t!- Controller Object Type\n\t\t\t\t#{oa_controller_name}, \t\t\t\t\t\t\t!- Controller Object Name\n\t\t\t\t5; \t\t\t\t\t\t\t\t\t\t\t\t!- Temperature Sensor Offset \n\t\t\t\t\"\n\t\t\t# Add string object to workspace to create idf object\n\t\t\tidfObject = OpenStudio::IdfObject::load(string_object)\n\t\t\tobject = idfObject.get\n\t\t\tworkspace.addObject(object)\n\t\t\t\n\t\t\t# Create IDF object text for FaultModel:EnthalpySensorOffset:ReturnAir\n\t\t\tstring_object = \"\n\t\t\t\tFaultModel:EnthalpySensorOffset:ReturnAir,\n\t\t\t\t#{oa_controller_name}_Return Air Enthalpy Sensor Bias, !- Name\n\t\t\t\tAlways On Discrete, \t\t\t\t\t\t\t!- Availability Schedule Name\n\t\t\t\t, \t\t\t\t\t\t\t\t\t\t\t\t!- Severity Schedule Name\n\t\t\t\tController:OutdoorAir, \t\t\t\t\t\t\t!- Controller Object Type\n\t\t\t\t#{oa_controller_name}, \t\t\t\t\t\t\t!- Controller Object Name\n\t\t\t\t-5; \t\t\t\t\t\t\t\t\t\t\t!- Temperature Sensor Offset \n\t\t\t\t\"\n\t\t\t# Add string object to workspace to create idf object\n\t\t\tidfObject = OpenStudio::IdfObject::load(string_object)\n\t\t\tobject = idfObject.get\n\t\t\tworkspace.addObject(object)\n\t\t\t\n\t\t\t# Initialize array to hold new IDF objects\n\t\t\tstring_object = []\n\t\t\t# Create IDF object text for FaultModel:TemperatureSensorOffset:OutdoorAir\n\t\t\tstring_object = \"\n\t\t\t\tFaultModel:TemperatureSensorOffset:OutdoorAir,\n\t\t\t\t#{oa_controller_name}_Outdoor Air Temp Sensor Bias, !- Name\n\t\t\t\tAlways On Discrete, \t\t\t\t\t\t\t!- Availability Schedule Name\n\t\t\t\t, \t\t\t\t\t\t\t\t\t\t\t\t!- Severity Schedule Name\n\t\t\t\tController:OutdoorAir, \t\t\t\t\t\t\t!- Controller Object Type\n\t\t\t\t#{oa_controller_name}, \t\t\t\t\t\t\t!- Controller Object Name\n\t\t\t\t1.11; \t\t\t\t\t\t\t\t\t\t\t!- Temperature Sensor Offset \n\t\t\t\t\"\n\t\t\t# Add string object to workspace to create idf object\n\t\t\tidfObject = OpenStudio::IdfObject::load(string_object)\n\t\t\tobject = idfObject.get\n\t\t\tworkspace.addObject(object)\n\t\t\t\n\t\t\t# Create IDF object text for FaultModel:TemperatureSensorOffset:ReturnAir\n\t\t\tstring_object = \"\n\t\t\t\tFaultModel:TemperatureSensorOffset:ReturnAir,\n\t\t\t\t#{oa_controller_name}_Return Air Temp Sensor Bias, !- Name\n\t\t\t\tAlways On Discrete, \t\t\t\t\t\t\t!- Availability Schedule Name\n\t\t\t\t, \t\t\t\t\t\t\t\t\t\t\t\t!- Severity Schedule Name\n\t\t\t\tController:OutdoorAir, \t\t\t\t\t\t\t!- Controller Object Type\n\t\t\t\t#{oa_controller_name}, \t\t\t\t\t\t\t!- Controller Object Name\n\t\t\t\t-1.11; \t\t\t\t\t\t\t\t\t\t\t!- Temperature Sensor Offset \n\t\t\t\t\"\n\t\t\t# Add string object to workspace to create idf object\n\t\t\tidfObject = OpenStudio::IdfObject::load(string_object)\n\t\t\tobject = idfObject.get\n\t\t\tworkspace.addObject(object)\n\n\t\t\trunner.registerInfo(\"To model both enthalpy and dry bulb sensor drift, a FaultModel:EnthalpySensorOffset:ReturnAir object with an offset of -2 Btu/lb and a FaultModel:EnthalpySensorOffset:OutdoorAir object with an offset of +2 Btu/lb and a FaultModel:TemperatureSensorOffset:ReturnAir object with an offset of -2 deg F and a FaultModel:TemperatureSensorOffset:OutdoorAir object with an offset of +2 deg have been added to the #{oa_controller_economizer_control_type} controlled airside economizer associated with the Controller:Outdoor air object named #{oa_controller_name}. The fault availability is scheduled using the 'Always On Discrete' schedule.\")\n\t\t\tfixed_dew_point_and_dry_bulb = fixed_dew_point_and_dry_bulb + 1\n\n\t\tend # OA Controller Type = \"FixedDewPointAndDryBulb\" \n\t\n\t\t# test for presence of differential dry bulb and enthalpy economizer controller setting \t\t\n\t\tif oa_controller_economizer_control_type == \"DifferentialDryBulbAndEnthalpy\"\n\t\t\t# Initialze array to hold new IDF objects\n\t\t\tstring_object = []\n\t\t\t# Create IDF object text for FaultModel:EnthalpySensorOffset:OutdoorAir\n\t\t\tstring_object = \"\n\t\t\t\tFaultModel:EnthalpySensorOffset:OutdoorAir,\n\t\t\t\t#{oa_controller_name}_Outdoor Air Enthalpy Sensor Bias, !- Name\n\t\t\t\tAlways On Discrete, \t\t\t\t\t\t\t!- Availability Schedule Name\n\t\t\t\t, \t\t\t\t\t\t\t\t\t\t\t\t!- Severity Schedule Name\n\t\t\t\tController:OutdoorAir, \t\t\t\t\t\t\t!- Controller Object Type\n\t\t\t\t#{oa_controller_name}, \t\t\t\t\t\t\t!- Controller Object Name\n\t\t\t\t5; \t\t\t\t\t\t\t\t\t\t\t\t!- Temperature Sensor Offset \n\t\t\t\t\"\n\t\t\t# Add string object to workspace to create idf object\n\t\t\tidfObject = OpenStudio::IdfObject::load(string_object)\n\t\t\tobject = idfObject.get\n\t\t\tworkspace.addObject(object)\n\t\t\n\t\t\t# Create IDF object text for FaultModel:EnthalpySensorOffset:ReturnAir\n\t\t\tstring_object = \"\n\t\t\t\tFaultModel:EnthalpySensorOffset:ReturnAir,\n\t\t\t\t#{oa_controller_name}_Return Air Enthalpy Sensor Bias, !- Name\n\t\t\t\tAlways On Discrete, \t\t\t\t\t\t\t!- Availability Schedule Name\n\t\t\t\t, \t\t\t\t\t\t\t\t\t\t\t\t!- Severity Schedule Name\n\t\t\t\tController:OutdoorAir, \t\t\t\t\t\t\t!- Controller Object Type\n\t\t\t\t#{oa_controller_name}, \t\t\t\t\t\t\t!- Controller Object Name\n\t\t\t\t-5; \t\t\t\t\t\t\t\t\t\t\t!- Temperature Sensor Offset \n\t\t\t\t\"\n\t\t\t# Add string object to workspace to create idf object\n\t\t\tidfObject = OpenStudio::IdfObject::load(string_object)\n\t\t\tobject = idfObject.get\n\t\t\tworkspace.addObject(object)\n\t\t\t\n\t\t\t# Initialize array to hold new IDF objects\n\t\t\tstring_object = []\n\t\t\t# Create IDF object text for FaultModel:TemperatureSensorOffset:OutdoorAir\n\t\t\tstring_object = \"\n\t\t\t\tFaultModel:TemperatureSensorOffset:OutdoorAir,\n\t\t\t\t#{oa_controller_name}_Outdoor Air Temp Sensor Bias, !- Name\n\t\t\t\tAlways On Discrete, \t\t\t\t\t\t\t!- Availability Schedule Name\n\t\t\t\t, \t\t\t\t\t\t\t\t\t\t\t\t!- Severity Schedule Name\n\t\t\t\tController:OutdoorAir, \t\t\t\t\t\t\t!- Controller Object Type\n\t\t\t\t#{oa_controller_name}, \t\t\t\t\t\t\t!- Controller Object Name\n\t\t\t\t1.11; \t\t\t\t\t\t\t\t\t\t\t!- Temperature Sensor Offset \n\t\t\t\t\"\n\t\t\t# Add string object to workspace to create idf object\n\t\t\tidfObject = OpenStudio::IdfObject::load(string_object)\n\t\t\tobject = idfObject.get\n\t\t\tworkspace.addObject(object)\n\t\t\t\t\t\t\n\t\t\t# Create IDF object text for FaultModel:TemperatureSensorOffset:ReturnAir\n\t\t\tstring_object = \"\n\t\t\t\tFaultModel:TemperatureSensorOffset:ReturnAir,\n\t\t\t\t#{oa_controller_name}_Return Air Temp Sensor Bias, !- Name\n\t\t\t\tAlways On Discrete, \t\t\t\t\t\t\t!- Availability Schedule Name\n\t\t\t\t, \t\t\t\t\t\t\t\t\t\t\t\t!- Severity Schedule Name\n\t\t\t\tController:OutdoorAir, \t\t\t\t\t\t\t!- Controller Object Type\n\t\t\t\t#{oa_controller_name}, \t\t\t\t\t\t\t!- Controller Object Name\n\t\t\t\t-1.11; \t\t\t\t\t\t\t\t\t\t\t!- Temperature Sensor Offset \n\t\t\t\t\"\n\t\t\t# Add string object to workspace to create idf object\n\t\t\tidfObject = OpenStudio::IdfObject::load(string_object)\n\t\t\tobject = idfObject.get\n\t\t\tworkspace.addObject(object)\n\n\t\t\trunner.registerInfo(\"To model both enthalpy and dry bulb sensor drift, a FaultModel:EnthalpySensorOffset:ReturnAir object with an offset of -2 Btu/lb and a FaultModel:EnthalpySensorOffset:OutdoorAir object with an offset of +2 Btu/lb and a FaultModel:TemperatureSensorOffset:ReturnAir object with an offset of -2 deg F and a FaultModel:TemperatureSensorOffset:OutdoorAir object with an offset of +2 deg have been added to the #{oa_controller_economizer_control_type} controlled airside economizer associated with the Controller:Outdoor air object named #{oa_controller_name}. The fault availability is scheduled using the 'Always On Discrete' schedule.\")\n\t\t\tdifferential_dry_bulb_and_enthalpy = differential_dry_bulb_and_enthalpy + 1\n\t\tend # OA Controller Type \"DifferentialDryBulbAndEnthalpy\"\n\t\t\n\t\t\t\t\n\tend # end loop through oa controller objects\n\n\t# reporting when N/A condition is appropriate\n\tif fixed_dry_bulb +\tdifferential_dry_bulb + fixed_enthalpy + differential_enthalpy + fixed_dew_point_and_dry_bulb +\telectronic_enthalpy + differential_dry_bulb_and_enthalpy == 0\n\t\trunner.registerAsNotApplicable(\"Measure not applicable because the model contains no OutdoorAir:Controller objects with operable economizers.\")\n\tend \n\t\n\ttotal = fixed_dry_bulb + differential_dry_bulb + fixed_enthalpy + differential_enthalpy + fixed_dew_point_and_dry_bulb + electronic_enthalpy + differential_dry_bulb_and_enthalpy\n\t\n\t# reporting initial condition of model\n\trunner.registerInitialCondition(\"The measure started with #{total} Outdoor Air Controllers configured for operational airside economizers. #{no_economizer} Outdoor Air Controller had the Economizer Contrrol Type set to 'NoEconomizer'.\")\n\t# reporting final condition of model\n\trunner.registerFinalCondition(\"The measure finished by adding outdoor and return air temperature and enthalpy sensor faults to #{total} economizer configurations.\")\n \n return true\n \n end", "def calculation\n end", "def monitor; end", "def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n\n # Return N/A if not selected to run\n run_measure = runner.getIntegerArgumentValue(\"run_measure\",user_arguments)\n if run_measure == 0\n runner.registerAsNotApplicable(\"Run Measure set to #{run_measure}.\")\n return true \n end \n \n # initialize variables\n affected_space_types = []\n affected_flag = false\n power_tot = 0\n power_tot_new = 0\n control_factor = 0.05 #90.1-2010 Table 9.6.2\n\n # standards space types\n affected_space_types << \"BreakRoom\"\n affected_space_types << \"Conference\"\n affected_space_types << \"Office\"\n affected_space_types << \"Restroom\"\n affected_space_types << \"Stair\"\n\n # get model objects\n space_types = model.getSpaceTypes\n\n # DO STUFF\n #TODO account for zone multipliers?\n space_types.each do |st|\n\n std_spc_typ = st.standardsSpaceType.to_s\n area = st.floorArea\n people = st.getNumberOfPeople(area)\n power = st.getLightingPower(area, people)\n power_tot += power\n\n #calcualte LPD\n lpd_area = power / area\n lpd_people = power / people\n\n affected_space_types.each do |ast|\n\n if ast == std_spc_typ\n\n #calculate adjustment and new power\n power_adj = power * control_factor\n power_new = power - power_adj\n\n lpd_area_new = power_new / area\n lpd_people_new = power_new / people\n\n #set new power\n if st.lightingPowerPerFloorArea.is_initialized\n\n runner.registerInfo(\"Adjusting interior lighting power for space type: #{st.name}\")\n st.setLightingPowerPerFloorArea(lpd_area_new)\n\n lpd_area_ip = OpenStudio.convert(lpd_area,\"ft^2\",\"m^2\").get\n lpd_area_new_ip = OpenStudio.convert(lpd_area_new,\"ft^2\",\"m^2\").get\n lpd_area_change = (1 - (lpd_area_new / lpd_area)) * 100\n\n runner.registerInfo(\"=> Initial interior lighting power = #{lpd_area_ip.round(2)} W/ft2\")\n runner.registerInfo(\"=> Final interior lighting power = #{lpd_area_new_ip.round(2)} W/ft2\")\n runner.registerInfo(\"=> Interior lighting power reduction = #{lpd_area_change.round(0)}%\")\n\n elsif st.lightingPowerPerPerson.is_initialized\n\n runner.registerInfo(\"Adjusting interior lighting power for space type: #{st.name}\")\n st.setLightingPowerPerPerson(lpd_people_new)\n\n lpd_people_change = (1 - (lpd_people_new / lpd_people)) * 100\n\n runner.registerInfo(\"=> Initial interior lighting power = #{lpd_people} W/person\")\n runner.registerInfo(\"=> Final interior lighting power = #{lpd_people_new} W/person\")\n runner.registerInfo(\"=> Interior lighting power reduction = #{lpd_people_change.round(0)}%\")\n\n else\n\n runner.registerWarning(\"Lighting power is specified using Lighting Level (W) for affected space type: #{st.name}\")\n\n end #set new power\n\n affected_flag = true\n\n end\n\n end #affected space types\n\n # calculate new total lighting power\n power = st.getLightingPower(area, people)\n power_tot_new += power\n\n end #space types\n\n # report not applicable\n if affected_flag == false\n runner.registerAsNotApplicable(\"No affected space types found\")\n end\n\n # report initial condition\n runner.registerInitialCondition(\"Total interior lighting power = #{power_tot.round(0)} W\")\n\n # report final condition\n runner.registerFinalCondition(\"Total interior lighting power = #{power_tot_new.round(0)} W\")\n\n return true\n\n end", "def measure key,value\n @context= {}\n @path = \"#{key}\" \n @context[:callcount] = 1\n @context[:firsttimestampoffset] = Time.now.to_f*1000 - value\n @context[:name] = @path\n @context[:responsetime] = value\n @context_list << @context\n end", "def total_time=(_arg0); end", "def run(workspace, runner, user_arguments)\n super(workspace, runner, user_arguments)\n\n #use the built-in error checking \n if not runner.validateUserArguments(arguments(workspace), user_arguments)\n return false\n end\n \n run_measure = runner.getIntegerArgumentValue(\"run_measure\",user_arguments)\n if run_measure == 0\n runner.registerAsNotApplicable(\"Run Measure set to #{run_measure}.\")\n return true \n end\n \n require 'json'\n \n # Get the last openstudio model\n model = runner.lastOpenStudioModel\n if model.empty?\n runner.registerError(\"Could not load last OpenStudio model, cannot apply measure.\")\n return false\n end\n model = model.get\n \n results = {}\n \n #get all DX coils in model\n dx_single = workspace.getObjectsByType(\"Coil:Cooling:DX:SingleSpeed\".to_IddObjectType)\n dx_two = workspace.getObjectsByType(\"Coil:Cooling:DX:TwoSpeed\".to_IddObjectType)\n \n dx_single.each do |dx|\n dx_name = {}\n coil_name = dx.getString(0).get\n runner.registerInfo(\"DX coil: #{coil_name} Initial COP: #{dx.getDouble(4).get}\")\n dx.setDouble(4,7.62)\n runner.registerInfo(\"DX coil: #{coil_name} Final COP: #{dx.getDouble(4).get}\")\n dx_name[:dxname] = \"#{coil_name}\"\n results[\"#{coil_name}\"] = dx_name\n end\n\n dx_two.each do |dx|\n dx_name = {}\n coil_name = dx.getString(0).get\n runner.registerInfo(\"DX coil: #{coil_name} Initial High COP: #{dx.getDouble(4).get}, Initial Low COP: #{dx.getDouble(16).get}\")\n dx.setDouble(4,7.62)\n dx.setDouble(16,7.62)\n runner.registerInfo(\"DX coil: #{coil_name} Final High COP: #{dx.getDouble(4).get}, Final Low COP: #{dx.getDouble(16).get}\")\n dx_name[:dxname] = \"#{coil_name}\"\n results[\"#{coil_name}\"] = dx_name\n end\n \n if results.empty?\n runner.registerWarning(\"No DX coils are appropriate for this measure\")\n runner.registerAsNotApplicable(\"No DX coils are appropriate for this measure\")\n end\n \n #save airloop parsing results to ems_results.json\n runner.registerInfo(\"Saving ems_results.json\")\n FileUtils.mkdir_p(File.dirname(\"ems_results.json\")) unless Dir.exist?(File.dirname(\"ems_results.json\"))\n File.open(\"ems_results.json\", 'w') {|f| f << JSON.pretty_generate(results)}\n \n if results.empty?\n runner.registerWarning(\"No DX coils are appropriate for this measure\")\n runner.registerAsNotApplicable(\"No DX coils are appropriate for this measure\")\n #save blank ems_membrane_heat_pump_cooling_only.ems file so Eplus measure does not crash\n ems_string = \"\"\n runner.registerInfo(\"Saving blank ems_membrane_heat_pump_cooling_only file\")\n FileUtils.mkdir_p(File.dirname(\"ems_membrane_heat_pump_cooling_only.ems\")) unless Dir.exist?(File.dirname(\"ems_membrane_heat_pump_cooling_only.ems\"))\n File.open(\"ems_membrane_heat_pump_cooling_only.ems\", \"w\") do |f|\n f.write(ems_string)\n end\n return true\n end\n \n timeStep = model.getTimestep.numberOfTimestepsPerHour\n \n runner.registerInfo(\"Making EMS string for Membrane Heat Pump Cooling Only\")\n #start making the EMS code\n ems_string = \"\" #clear out the ems_string\n ems_string << \"\\n\" \n ems_string << \"Output:Variable,*,Cooling Coil Sensible Cooling Energy,timestep; !- HVAC Sum [J]\" + \"\\n\"\n ems_string << \"\\n\" \n \n results.each_with_index do |(key, value), i| \n ems_string << \"EnergyManagementSystem:Sensor,\" + \"\\n\"\n ems_string << \" MembraneHP#{i+1}SensibleClgJ,\" + \"\\n\"\n ems_string << \" #{value[:dxname]},\" + \"\\n\"\n ems_string << \" Cooling Coil Sensible Cooling Energy;\" + \"\\n\"\n ems_string << \"\\n\" \n ems_string << \"WaterUse:Equipment,\" + \"\\n\"\n ems_string << \" MembraneHP#{i+1}WaterUse, !- Name\" + \"\\n\"\n ems_string << \" Membrane HP Cooling, !- End-Use Subcategory\" + \"\\n\"\n ems_string << \" 0.003155, !- Peak Flow Rate {m3/s} = 3000 gal/hr\" + \"\\n\"\n ems_string << \" MembraneHP#{i+1}WaterUseSchedule; !- Flow Rate Fraction Schedule Name\" + \"\\n\"\n ems_string << \"\\n\" \n ems_string << \"Schedule:Constant,\" + \"\\n\"\n ems_string << \" MembraneHP#{i+1}WaterUseSchedule, !- Name\" + \"\\n\"\n ems_string << \" , !- Schedule Type Limits Name\" + \"\\n\"\n ems_string << \" 1; !- Hourly Value\" + \"\\n\"\n ems_string << \"\\n\" \n ems_string << \"EnergyManagementSystem:Actuator,\" + \"\\n\"\n ems_string << \" MembraneHP#{i+1}WaterUseCtrl,\" + \"\\n\"\n ems_string << \" MembraneHP#{i+1}WaterUseSchedule,\" + \"\\n\"\n ems_string << \" Schedule:Constant,\" + \"\\n\"\n ems_string << \" Schedule Value;\" + \"\\n\"\n ems_string << \"\\n\" \n end\n ems_string << \"EnergyManagementSystem:ProgramCallingManager,\" + \"\\n\"\n ems_string << \" MembraneHPWaterUseProgramControl, !- Name\" + \"\\n\"\n ems_string << \" AfterPredictorBeforeHVACManagers, !- EnergyPlus Model Calling Point\" + \"\\n\"\n ems_string << \" MembraneHPWaterUseProgram; !- Program Name 1\" + \"\\n\"\n ems_string << \"\\n\"\n ems_string << \"EnergyManagementSystem:Program,\" + \"\\n\"\n ems_string << \" MembraneHPWaterUseProgram, !- Name\" + \"\\n\"\n ems_string << \" SET TimeStepsPerHr = #{timeStep}\" + \"\\n\"\n results.each_with_index do |(key, value), i|\n ems_string << \" SET MembraneHP#{i+1}SensibleClgTonHr = MembraneHP#{i+1}SensibleClgJ * 0.0000007898,\" + \"\\n\"\n ems_string << \" SET MembraneHP#{i+1}SensibleWtrGal = MembraneHP#{i+1}SensibleClgTonHr * 3.0,\" + \"\\n\"\n ems_string << \" SET MembraneHP#{i+1}SensibleWtrGalPerHr = MembraneHP#{i+1}SensibleWtrGal * TimeStepsPerHr,\" + \"\\n\"\n ems_string << \" SET MembraneHP#{i+1}WaterUseCtrl = MembraneHP#{i+1}SensibleWtrGalPerHr / 3000.0,\" + \"\\n\"\n end \n ems_string << \" SET UnusedLine = 0;\" + \"\\n\"\n \n #save EMS snippet\n runner.registerInfo(\"Saving ems_membrane_heat_pump_cooling_only file\")\n FileUtils.mkdir_p(File.dirname(\"ems_membrane_heat_pump_cooling_only.ems\")) unless Dir.exist?(File.dirname(\"ems_membrane_heat_pump_cooling_only.ems\"))\n File.open(\"ems_membrane_heat_pump_cooling_only.ems\", \"w\") do |f|\n f.write(ems_string)\n end\n \n #unique initial conditions based on\n runner.registerInitialCondition(\"The building has #{results.size} DX coils for which this measure is applicable.\")\n\n #reporting final condition of model\n runner.registerFinalCondition(\"The efficiency of the following coils was increased to SEER 26 to reflect the replacement of these coils with membrane heatpumps: #{results.keys}\")\n \n ems_path = '../MembraneHeatPumpCoolingOnly/ems_membrane_heat_pump_cooling_only.ems'\n json_path = '../MembraneHeatPumpCoolingOnly/ems_results.json'\n if File.exist? ems_path\n ems_string = File.read(ems_path)\n if File.exist? json_path\n json = JSON.parse(File.read(json_path))\n end\n else\n ems_path2 = Dir.glob('../../**/ems_membrane_heat_pump_cooling_only.ems')\n ems_path1 = ems_path2[0]\n json_path2 = Dir.glob('../../**/ems_results.json')\n json_path1 = json_path2[0]\n if ems_path2.size > 1\n runner.registerWarning(\"more than one ems_membrane_heat_pump_cooling_only.ems file found. Using first one found.\")\n end\n if !ems_path1.nil? \n if File.exist? ems_path1\n ems_string = File.read(ems_path1)\n if File.exist? json_path1\n json = JSON.parse(File.read(json_path1))\n else\n runner.registerError(\"ems_results.json file not located\") \n end \n else\n runner.registerError(\"ems_membrane_heat_pump_cooling_only.ems file not located\")\n end \n else\n runner.registerError(\"ems_membrane_heat_pump_cooling_only.ems file not located\") \n end\n end\n if json.nil?\n runner.registerError(\"ems_results.json file not located\")\n return false\n end\n \n if json.empty?\n runner.registerWarning(\"No DX coils are appropriate for this measure\")\n return true\n end\n \n idf_file = OpenStudio::IdfFile::load(ems_string, 'EnergyPlus'.to_IddFileType).get\n runner.registerInfo(\"Adding EMS code to workspace\")\n workspace.addObjects(idf_file.objects)\n \n return true\n\n end", "def apply_measure_to_model(test_name, args, model_name = nil, result_value = 'Success', warnings_count = 0, info_count = nil)\n # create an instance of the measure\n measure = ChangeBuildingLocation.new\n\n # create an instance of a runner with OSW\n osw_path = OpenStudio::Path.new(File.dirname(__FILE__) + '/test.osw')\n osw = OpenStudio::WorkflowJSON.load(osw_path).get\n runner = OpenStudio::Measure::OSRunner.new(osw)\n\n # get model\n if model_name.nil?\n # make an empty model\n model = OpenStudio::Model::Model.new\n else\n # load the test model\n translator = OpenStudio::OSVersion::VersionTranslator.new\n path = OpenStudio::Path.new(File.dirname(__FILE__) + '/' + model_name)\n model = translator.loadModel(path)\n assert(!model.empty?)\n model = model.get\n end\n\n # get arguments\n arguments = measure.arguments(model)\n argument_map = OpenStudio::Measure.convertOSArgumentVectorToMap(arguments)\n\n # populate argument with specified hash value if specified\n arguments.each do |arg|\n temp_arg_var = arg.clone\n if args.key?(arg.name)\n assert(temp_arg_var.setValue(args[arg.name]))\n end\n argument_map[arg.name] = temp_arg_var\n end\n\n # temporarily change directory to the run directory and run the measure (because of sizing run)\n start_dir = Dir.pwd\n begin\n unless Dir.exist?(run_dir(test_name))\n Dir.mkdir(run_dir(test_name))\n end\n Dir.chdir(run_dir(test_name))\n\n # run the measure\n measure.run(model, runner, argument_map)\n result = runner.result\n ensure\n Dir.chdir(start_dir)\n\n # delete sizing run dir\n FileUtils.rm_rf(run_dir(test_name))\n end\n\n # show the output\n puts \"measure results for #{test_name}\"\n show_output(result)\n\n # assert that it ran correctly\n if result_value.nil? then result_value = 'Success' end\n assert_equal(result_value, result.value.valueName)\n\n # check count of warning and info messages\n unless info_count.nil? then assert(result.info.size == info_count) end\n unless warnings_count.nil? then assert(result.warnings.size == warnings_count) end\n\n # if 'Fail' passed in make sure at least one error message (while not typical there may be more than one message)\n if result_value == 'Fail' then assert(result.errors.size >= 1) end\n\n # save the model to test output directory\n output_file_path = OpenStudio::Path.new(File.dirname(__FILE__) + \"/output/#{test_name}_test_output.osm\")\n model.save(output_file_path, true)\n end", "def measure_code(model,runner)\n ################ Start Measure code here ################################\n # Argument will be passed as instance variable. So if your argument was height, your can access it using @height. \n\n # report initial condition\n site = model.getSite\n initial_design_days = model.getDesignDays\n if site.weatherFile.is_initialized\n weather = site.weatherFile.get\n runner.registerInitialCondition(\"The initial weather file path was '#{weather.path.get}' and the model had #{initial_design_days.size} design days.\")\n else\n runner.registerInitialCondition(\"The initial weather file has not been set and the model had #{initial_design_days.size} design days.\")\n end\n\n\n #Check form weather directory Weather File\n unless (Pathname.new @weather_directory).absolute?\n @weather_directory = File.expand_path(File.join(File.dirname(__FILE__), @weather_directory))\n end\n weather_file = File.join(@weather_directory, @weather_file_name)\n if File.exists?(weather_file) and @weather_file_name.downcase.include? \".epw\"\n BTAP::runner_register(\"Info\", \"The epw weather file #{weather_file} was found!\", runner)\n else\n BTAP::runner_register(\"Error\",\"'#{weather_file}' does not exist or is not an .epw file.\", runner)\n return false\n end\n\n begin\n weather = BTAP::Environment::WeatherFile.new(weather_file)\n #Set Weather file to model.\n weather.set_weather_file(model)\n #Store information about this run in the runner for output. This will be in the csv and R dumps.\n runner.registerValue( 'city',weather.city )\n runner.registerValue( 'state_province_region ',weather.state_province_region )\n runner.registerValue( 'country',weather.country )\n runner.registerValue( 'hdd18',weather.hdd18 )\n runner.registerValue( 'cdd18',weather.cdd18 )\n runner.registerValue( 'necb_climate_zone',BTAP::Compliance::NECB2011::get_climate_zone_name(weather.hdd18).to_s)\n runner.registerFinalCondition( \"Model ended with weatherfile of #{model.getSite.weatherFile.get.path.get}\" )\n rescue\n BTAP::runner_register(\"Error\",\"'#{weather_file}' could not be loaded into model.\", runner)\n\n return false\n end\n BTAP::runner_register(\"FinalCondition\",\"Weather file set to #{weather_file}\",runner)\n return true\n end", "def run(workspace, runner, user_arguments)\r\n super(workspace, runner, user_arguments)\r\n\r\n #use the built-in error checking \r\n if not runner.validateUserArguments(arguments(workspace), user_arguments)\r\n return false\r\n end\r\n \r\n run_measure = runner.getIntegerArgumentValue(\"run_measure\",user_arguments)\r\n if run_measure == 0\r\n runner.registerAsNotApplicable(\"Run Measure set to #{run_measure}.\")\r\n return true \r\n end\r\n \r\n require 'json'\r\n \r\n # Get the last openstudio model\r\n model = runner.lastOpenStudioModel\r\n if model.empty?\r\n runner.registerError(\"Could not load last OpenStudio model, cannot apply measure.\")\r\n return false\r\n end\r\n model = model.get\r\n \r\n results = {}\r\n #get all DX coils in model\r\n dx_single = model.getCoilCoolingDXSingleSpeeds \r\n dx_two = model.getCoilCoolingDXTwoSpeeds\r\n \r\n if !dx_single.empty?\r\n dx_single.each do |dx|\r\n dx_name = {}\r\n runner.registerInfo(\"DX coil: #{dx.name.get} Initial COP: #{dx.ratedCOP.get}\")\r\n dx.setRatedCOP(OpenStudio::OptionalDouble.new(7.62))\r\n runner.registerInfo(\"DX coil: #{dx.name.get} Final COP: #{dx.ratedCOP.get}\")\r\n dx_name[:dxname] = \"#{dx.name.get}\"\r\n results[\"#{dx.name.get}\"] = dx_name\r\n end\r\n end\r\n if !dx_two.empty?\r\n dx_two.each do |dx|\r\n dx_name = {}\r\n runner.registerInfo(\"DX coil: #{dx.name.get} Initial High COP: #{dx.ratedHighSpeedCOP.get} Low COP: #{dx.ratedLowSpeedCOP.get}\")\r\n dx.setRatedHighSpeedCOP(7.62)\r\n dx.setRatedLowSpeedCOP(7.62)\r\n runner.registerInfo(\"DX coil: #{dx.name.get} Final High COP: #{dx.ratedHighSpeedCOP.get} Final COP: #{dx.ratedLowSpeedCOP.get}\")\r\n dx_name[:dxname] = \"#{dx.name.get}\"\r\n results[\"#{dx.name.get}\"] = dx_name\r\n end\r\n end\r\n \r\n if results.empty?\r\n runner.registerWarning(\"No DX coils are appropriate for this measure\")\r\n runner.registerAsNotApplicable(\"No DX coils are appropriate for this measure\")\r\n end\r\n \r\n #save airloop parsing results to ems_results.json\r\n runner.registerInfo(\"Saving ems_results.json\")\r\n FileUtils.mkdir_p(File.dirname(\"ems_results.json\")) unless Dir.exist?(File.dirname(\"ems_results.json\"))\r\n File.open(\"ems_results.json\", 'w') {|f| f << JSON.pretty_generate(results)}\r\n \r\n if results.empty?\r\n runner.registerWarning(\"No DX coils are appropriate for this measure\")\r\n runner.registerAsNotApplicable(\"No DX coils are appropriate for this measure\")\r\n #save blank ems_membrane_heat_pump_cooling_only.ems file so Eplus measure does not crash\r\n ems_string = \"\"\r\n runner.registerInfo(\"Saving blank ems_membrane_heat_pump_cooling_only file\")\r\n FileUtils.mkdir_p(File.dirname(\"ems_membrane_heat_pump_cooling_only.ems\")) unless Dir.exist?(File.dirname(\"ems_membrane_heat_pump_cooling_only.ems\"))\r\n File.open(\"ems_membrane_heat_pump_cooling_only.ems\", \"w\") do |f|\r\n f.write(ems_string)\r\n end\r\n return true\r\n end\r\n \r\n timeStep = model.getTimestep.numberOfTimestepsPerHour\r\n \r\n runner.registerInfo(\"Making EMS string for Membrane Heat Pump Cooling Only\")\r\n #start making the EMS code\r\n ems_string = \"\" #clear out the ems_string\r\n ems_string << \"\\n\" \r\n ems_string << \"Output:Variable,*,Cooling Coil Sensible Cooling Energy,timestep; !- HVAC Sum [J]\" + \"\\n\"\r\n ems_string << \"\\n\" \r\n \r\n results.each_with_index do |(key, value), i| \r\n ems_string << \"EnergyManagementSystem:Sensor,\" + \"\\n\"\r\n ems_string << \" MembraneHP#{i+1}SensibleClgJ,\" + \"\\n\"\r\n ems_string << \" #{value[:dxname]},\" + \"\\n\"\r\n ems_string << \" Cooling Coil Sensible Cooling Energy;\" + \"\\n\"\r\n ems_string << \"\\n\" \r\n ems_string << \"WaterUse:Equipment,\" + \"\\n\"\r\n ems_string << \" MembraneHP#{i+1}WaterUse, !- Name\" + \"\\n\"\r\n ems_string << \" Membrane HP Cooling, !- End-Use Subcategory\" + \"\\n\"\r\n ems_string << \" 0.003155, !- Peak Flow Rate {m3/s} = 3000 gal/hr\" + \"\\n\"\r\n ems_string << \" MembraneHP#{i+1}WaterUseSchedule; !- Flow Rate Fraction Schedule Name\" + \"\\n\"\r\n ems_string << \"\\n\" \r\n ems_string << \"Schedule:Constant,\" + \"\\n\"\r\n ems_string << \" MembraneHP#{i+1}WaterUseSchedule, !- Name\" + \"\\n\"\r\n ems_string << \" , !- Schedule Type Limits Name\" + \"\\n\"\r\n ems_string << \" 1; !- Hourly Value\" + \"\\n\"\r\n ems_string << \"\\n\" \r\n ems_string << \"EnergyManagementSystem:Actuator,\" + \"\\n\"\r\n ems_string << \" MembraneHP#{i+1}WaterUseCtrl,\" + \"\\n\"\r\n ems_string << \" MembraneHP#{i+1}WaterUseSchedule,\" + \"\\n\"\r\n ems_string << \" Schedule:Constant,\" + \"\\n\"\r\n ems_string << \" Schedule Value;\" + \"\\n\"\r\n ems_string << \"\\n\" \r\n end\r\n ems_string << \"EnergyManagementSystem:ProgramCallingManager,\" + \"\\n\"\r\n ems_string << \" MembraneHPWaterUseProgramControl, !- Name\" + \"\\n\"\r\n ems_string << \" AfterPredictorBeforeHVACManagers, !- EnergyPlus Model Calling Point\" + \"\\n\"\r\n ems_string << \" MembraneHPWaterUseProgram; !- Program Name 1\" + \"\\n\"\r\n ems_string << \"\\n\"\r\n ems_string << \"EnergyManagementSystem:Program,\" + \"\\n\"\r\n ems_string << \" MembraneHPWaterUseProgram, !- Name\" + \"\\n\"\r\n ems_string << \" SET TimeStepsPerHr = #{timeStep}\" + \"\\n\"\r\n results.each_with_index do |(key, value), i|\r\n ems_string << \" SET MembraneHP#{i+1}SensibleClgTonHr = MembraneHP#{i+1}SensibleClgJ * 0.0000007898,\" + \"\\n\"\r\n ems_string << \" SET MembraneHP#{i+1}SensibleWtrGal = MembraneHP#{i+1}SensibleClgTonHr * 3.0,\" + \"\\n\"\r\n ems_string << \" SET MembraneHP#{i+1}SensibleWtrGalPerHr = MembraneHP#{i+1}SensibleWtrGal * TimeStepsPerHr,\" + \"\\n\"\r\n ems_string << \" SET MembraneHP#{i+1}WaterUseCtrl = MembraneHP#{i+1}SensibleWtrGalPerHr / 3000.0,\" + \"\\n\"\r\n end \r\n ems_string << \" SET UnusedLine = 0;\" + \"\\n\"\r\n \r\n #save EMS snippet\r\n runner.registerInfo(\"Saving ems_membrane_heat_pump_cooling_only file\")\r\n FileUtils.mkdir_p(File.dirname(\"ems_membrane_heat_pump_cooling_only.ems\")) unless Dir.exist?(File.dirname(\"ems_membrane_heat_pump_cooling_only.ems\"))\r\n File.open(\"ems_membrane_heat_pump_cooling_only.ems\", \"w\") do |f|\r\n f.write(ems_string)\r\n end\r\n \r\n #unique initial conditions based on\r\n runner.registerInitialCondition(\"The building has #{results.size} DX coils for which this measure is applicable.\")\r\n\r\n #reporting final condition of model\r\n runner.registerFinalCondition(\"The efficiency of the following coils was increased to SEER 26 to reflect the replacement of these coils with membrane heatpumps: #{results.keys}\")\r\n \r\n ems_path = '../MembraneHeatPumpCoolingOnlyEms/ems_membrane_heat_pump_cooling_only.ems'\r\n json_path = '../MembraneHeatPumpCoolingOnlyEms/ems_results.json'\r\n if File.exist? ems_path\r\n ems_string = File.read(ems_path)\r\n if File.exist? json_path\r\n json = JSON.parse(File.read(json_path))\r\n end\r\n else\r\n ems_path2 = Dir.glob('../../**/ems_membrane_heat_pump_cooling_only.ems')\r\n ems_path1 = ems_path2[0]\r\n json_path2 = Dir.glob('../../**/ems_results.json')\r\n json_path1 = json_path2[0]\r\n if ems_path2.size > 1\r\n runner.registerWarning(\"more than one ems_membrane_heat_pump_cooling_only.ems file found. Using first one found.\")\r\n end\r\n if !ems_path1.nil? \r\n if File.exist? ems_path1\r\n ems_string = File.read(ems_path1)\r\n if File.exist? json_path1\r\n json = JSON.parse(File.read(json_path1))\r\n else\r\n runner.registerError(\"ems_results.json file not located\") \r\n end \r\n else\r\n runner.registerError(\"ems_membrane_heat_pump_cooling_only.ems file not located\")\r\n end \r\n else\r\n runner.registerError(\"ems_membrane_heat_pump_cooling_only.ems file not located\") \r\n end\r\n end\r\n if json.nil?\r\n runner.registerError(\"ems_results.json file not located\")\r\n return false\r\n end\r\n \r\n if json.empty?\r\n runner.registerWarning(\"No DX coils are appropriate for this measure\")\r\n return true\r\n end\r\n \r\n idf_file = OpenStudio::IdfFile::load(ems_string, 'EnergyPlus'.to_IddFileType).get\r\n runner.registerInfo(\"Adding EMS code to workspace\")\r\n workspace.addObjects(idf_file.objects)\r\n \r\n return true\r\n\r\n end", "def modeler_description\n return 'The measure performs the following functions: (1) IDs all chillers, (2) Locates their performance curves and outputs the data, (3) Adds reporting variables for chiller-related data.'\n end", "def build_timing; end", "def measure_gc\n return unless enabled?\n\n @raw_data << { fake: true }\n @total_time += 1.1\n\n end", "def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n\n # use the built-in error checking\n if !runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n\n # define if the measure should run to a specific time period or whole day\n apply_to_time = true\n\n # assign the user inputs to variables\n object = runner.getOptionalWorkspaceObjectChoiceValue('space_type', user_arguments, model)\n single_space_type = runner.getDoubleArgumentValue('single_space_type', user_arguments)\n occupied_space_type = runner.getDoubleArgumentValue('occupied_space_type', user_arguments)\n unoccupied_space_type = runner.getDoubleArgumentValue('unoccupied_space_type', user_arguments)\n starttime_winter2 = runner.getStringArgumentValue('starttime_winter2', user_arguments)\n endtime_winter2 = runner.getStringArgumentValue('endtime_winter2', user_arguments)\n starttime_winter1 = runner.getStringArgumentValue('starttime_winter1', user_arguments)\n endtime_winter1 = runner.getStringArgumentValue('endtime_winter1', user_arguments)\n starttime_summer = runner.getStringArgumentValue('starttime_summer', user_arguments)\n endtime_summer = runner.getStringArgumentValue('endtime_summer', user_arguments)\n auto_date = runner.getBoolArgumentValue('auto_date', user_arguments)\n alt_periods = runner.getBoolArgumentValue('alt_periods', user_arguments)\n demo_cost_initial_const=false\n\n winter_start_month1 = 1\n winter_end_month1 = 5\n summer_start_month = 6\n summer_end_month = 9\n winter_start_month2 = 10\n winter_end_month2 = 12\n\n######### GET CLIMATE ZONES ################\n if auto_date\n ashraeClimateZone = ''\n #climateZoneNUmber = ''\n climateZones = model.getClimateZones\n climateZones.climateZones.each do |climateZone|\n if climateZone.institution == 'ASHRAE'\n ashraeClimateZone = climateZone.value\n runner.registerInfo(\"Using ASHRAE Climate zone #{ashraeClimateZone}.\")\n end\n end\n\n if ashraeClimateZone == '' # should this be not applicable or error?\n runner.registerError(\"Please assign an ASHRAE Climate Zone to your model using the site tab in the OpenStudio application. The measure can't make AEDG recommendations without this information.\")\n return false # note - for this to work need to check for false in measure.rb and add return false there as well.\n # else\n # climateZoneNumber = ashraeClimateZone.split(//).first\n end\n # #runner.registerInfo(\"CLIMATE ZONE #{ashraeClimateZone}. Right now does not do anything.\")\n # if !['1', '2', '3', '4', '5', '6', '7', '8'].include? climateZoneNumber\n # runner.registerError('ASHRAE climate zone number is not within expected range of 1 to 8.')\n # return false # note - for this to work need to check for false in measure.rb and add return false there as well.\n # end\n\n if alt_periods\n if ashraeClimateZone == '3A'\n starttime_summer = '18:01:00'\n endtime_summer = '21:59:00'\n starttime_winter1 = '17:01:00'\n endtime_winter1 = '20:59:00'\n starttime_winter2 = '17:01:00'\n endtime_winter2 = '20:59:00'\n elsif ashraeClimateZone == '4A'\n starttime_summer = '18:01:00'\n endtime_summer = '21:59:00'\n starttime_winter1 = '17:01:00'\n endtime_winter1 = '20:59:00'\n starttime_winter2 = '17:01:00'\n endtime_winter2 = '20:59:00'\n elsif ashraeClimateZone == '5A'\n starttime_summer = '14:01:00'\n endtime_summer = '17:59:00'\n starttime_winter1 = '18:01:00'\n endtime_winter1 = '21:59:00'\n starttime_winter2 = '18:01:00'\n endtime_winter2 = '21:59:00'\n elsif ashraeClimateZone == '6A'\n starttime_summer = '13:01:00'\n endtime_summer = '16:59:00'\n starttime_winter1 = '17:01:00'\n endtime_winter1 = '20:59:00'\n starttime_winter2 = '17:01:00'\n endtime_winter2 = '20:59:00'\n end\n else\n if ashraeClimateZone == '2A'\n starttime_summer = '17:01:00'\n endtime_summer = '20:59:00'\n starttime_winter1 = '17:01:00'\n endtime_winter1 = '20:59:00'\n starttime_winter2 = '17:01:00'\n endtime_winter2 = '20:59:00'\n elsif ashraeClimateZone == '2B'\n starttime_summer = '17:01:00'\n endtime_summer = '20:59:00'\n starttime_winter1 = '17:01:00'\n endtime_winter1 = '20:59:00'\n starttime_winter2 = '17:01:00'\n endtime_winter2 = '20:59:00'\n elsif ashraeClimateZone == '3A'\n starttime_summer = '19:01:00'\n endtime_summer = '22:59:00'\n starttime_winter1 = '17:01:00'\n endtime_winter1 = '20:59:00'\n starttime_winter2 = '17:01:00'\n endtime_winter2 = '20:59:00'\n elsif ashraeClimateZone == '3B'\n starttime_summer = '18:01:00'\n endtime_summer = '21:59:00'\n starttime_winter1 = '19:01:00'\n endtime_winter1 = '22:59:00'\n starttime_winter2 = '19:01:00'\n endtime_winter2 = '22:59:00'\n elsif ashraeClimateZone == '3C'\n starttime_summer = '19:01:00'\n endtime_summer = '22:59:00'\n starttime_winter1 = '17:01:00'\n endtime_winter1 = '20:59:00'\n starttime_winter2 = '17:01:00'\n endtime_winter2 = '20:59:00'\n elsif ashraeClimateZone == '4A'\n starttime_summer = '12:01:00'\n endtime_summer = '15:59:00'\n starttime_winter1 = '16:01:00'\n endtime_winter1 = '19:59:00'\n starttime_winter2 = '16:01:00'\n endtime_winter2 = '19:59:00'\n elsif ashraeClimateZone == '4B'\n starttime_summer = '17:01:00'\n endtime_summer = '20:59:00'\n starttime_winter1 = '17:01:00'\n endtime_winter1 = '20:59:00'\n starttime_winter2 = '17:01:00'\n endtime_winter2 = '20:59:00'\n elsif ashraeClimateZone == '4C'\n starttime_summer = '17:01:00'\n endtime_summer = '20:59:00'\n starttime_winter1 = '17:01:00'\n endtime_winter1 = '20:59:00'\n starttime_winter2 = '17:01:00'\n endtime_winter2 = '20:59:00'\n elsif ashraeClimateZone == '5A'\n starttime_summer = '20:01:00'\n endtime_summer = '23:59:00'\n starttime_winter1 = '17:01:00'\n endtime_winter1 = '20:59:00'\n starttime_winter2 = '17:01:00'\n endtime_winter2 = '20:59:00'\n elsif ashraeClimateZone == '5B'\n starttime_summer = '17:01:00'\n endtime_summer = '20:59:00'\n starttime_winter1 = '17:01:00'\n endtime_winter1 = '20:59:00'\n starttime_winter2 = '17:01:00'\n endtime_winter2 = '20:59:00'\n elsif ashraeClimateZone == '5C'\n starttime_summer = '17:01:00'\n endtime_summer = '20:59:00'\n starttime_winter1 = '17:01:00'\n endtime_winter1 = '20:59:00'\n starttime_winter2 = '17:01:00'\n endtime_winter2 = '20:59:00'\n elsif ashraeClimateZone == '6A'\n starttime_summer = '16:01:00'\n endtime_summer = '19:59:00'\n starttime_winter1 = '18:01:00'\n endtime_winter1 = '21:59:00'\n starttime_winter2 = '18:01:00'\n endtime_winter2 = '21:59:00'\n elsif ashraeClimateZone == '6B'\n starttime_summer = '17:01:00'\n endtime_summer = '20:59:00'\n starttime_winter1 = '17:01:00'\n endtime_winter1 = '20:59:00'\n starttime_winter2 = '17:01:00'\n endtime_winter2 = '20:59:00'\n elsif ashraeClimateZone == '7A'\n starttime_summer = '16:01:00'\n endtime_summer = '19:59:00'\n starttime_winter1 = '18:01:00'\n endtime_winter1 = '21:59:00'\n starttime_winter2 = '18:01:00'\n endtime_winter2 = '21:59:00'\n end\n end\n end \n\n # check the lighting power reduction percentages and for reasonableness\n if occupied_space_type > 100\n runner.registerError('Please Enter a Value less than or equal to 100 for the Electric Equipment Power Reduction Percentage.')\n return false\n elsif occupied_space_type == 0\n runner.registerInfo('No Electric Equipment power adjustment requested, but some life cycle costs may still be affected.')\n elsif (occupied_space_type < 1) && (occupied_space_type > -1)\n runner.registerWarning(\"A Electric Equipment Power Reduction Percentage of #{occupied_space_type} percent is abnormally low.\")\n elsif occupied_space_type > 90\n runner.registerWarning(\"A Electric Equipment Power Reduction Percentage of #{occupied_space_type} percent is abnormally high.\")\n elsif occupied_space_type < 0\n runner.registerInfo('The requested value for Electric Equipment power reduction percentage was negative. This will result in an increase in Electric Equipment power.')\n end\n\n # check the equipment_power_reduction_percent and for reasonableness\n if unoccupied_space_type > 100\n runner.registerError('Please Enter a Value less than or equal to 100 for the Electric Equipment Power Reduction Percentage.')\n return false\n elsif unoccupied_space_type == 0\n runner.registerInfo('No Electric Equipment power adjustment requested, but some life cycle costs may still be affected.')\n elsif (unoccupied_space_type < 1) && (unoccupied_space_type > -1)\n runner.registerWarning(\"A Electric Equipment Power Reduction Percentage of #{unoccupied_space_type} percent is abnormally low.\")\n elsif unoccupied_space_type > 90\n runner.registerWarning(\"A Electric Equipment Power Reduction Percentage of #{unoccupied_space_type} percent is abnormally high.\")\n elsif unoccupied_space_type < 0\n runner.registerInfo('The requested value for Electric Equipment power reduction percentage was negative. This will result in an increase in Electric Equipment power.')\n end\n\n # check the equipment_power_reduction_percent and for reasonableness\n if single_space_type > 100\n runner.registerError('Please Enter a Value less than or equal to 100 for the Electric Equipment Power Reduction Percentage.')\n return false\n elsif single_space_type == 0\n runner.registerInfo('No Electric Equipment power adjustment requested, but some life cycle costs may still be affected.')\n elsif (single_space_type < 1) && (single_space_type > -1)\n runner.registerWarning(\"A Electric Equipment Power Reduction Percentage of #{single_space_type} percent is abnormally low.\")\n elsif single_space_type > 90\n runner.registerWarning(\"A Electric Equipment Power Reduction Percentage of #{single_space_type} percent is abnormally high.\")\n elsif single_space_type < 0\n runner.registerInfo('The requested value for Electric Equipment power reduction percentage was negative. This will result in an increase in Electric Equipment power.')\n end\n\n # check the time periods for reasonableness\n if (starttime_winter1.to_f > endtime_winter1.to_f) && (starttime_winter2.to_f > endtime_winter2.to_f) && (starttime_summer.to_f > endtime_summer.to_f)\n runner.registerError('The end time should be larger than the start time.')\n return false\n end\n\n # check the space_type for reasonableness\n space_type = nil\n if object.empty?\n handle = runner.getStringArgumentValue('space_type', user_arguments)\n if handle.empty?\n runner.registerError('No space type was chosen.')\n else\n runner.registerError(\"The selected space type with handle '#{handle}' was not found in the model. It may have been removed by another measure.\")\n end\n return false\n else\n if !object.get.to_SpaceType.empty?\n space_type = object.get.to_SpaceType.get\n elsif !object.get.to_Building.empty?\n apply_to_building = true\n else\n runner.registerError('Script Error - argument not showing up as space type or building.')\n return false\n end\n end\n\n\n ############################################\n\n # assign the time duration when DR strategy is applied, from shift_time1 to shift_time2, only applied when apply_to_time is ture\n shift_time1 = OpenStudio::Time.new(starttime_winter1)\n shift_time2 = OpenStudio::Time.new(endtime_winter1)\n shift_time3 = OpenStudio::Time.new(0, 24, 0, 0)\n shift_time4 = OpenStudio::Time.new(starttime_summer)\n shift_time5 = OpenStudio::Time.new(endtime_summer)\n shift_time6 = OpenStudio::Time.new(starttime_winter2)\n shift_time7 = OpenStudio::Time.new(endtime_winter2)\n \n \n # get space types in model\n if apply_to_building\n space_types = model.getSpaceTypes\n else\n space_types = []\n space_types << space_type # only run on a single space type\n end\n\n # make a hash of old defs and new equipments and luminaire defs\n cloned_equi_defs = {}\n # loop through space types\n space_types.each do |space_type|\n\n equi_set_schs = {}\n if apply_to_building # measure will be applied differently to space types, based on whether the space type is occupied\n if !space_type.people.empty?\n equipment_power_reduction_percent = 1 - (occupied_space_type/100)\n else\n equipment_power_reduction_percent = 1 - (unoccupied_space_type/100)\n end\n runner.registerInitialCondition(\"Equipment power will be reduced by #{occupied_space_type}% in occupied spaces, and reduced by #{unoccupied_space_type}% in unoccupied spaces\")\n\n else\n equipment_power_reduction_percent = 1 - (single_space_type/100) # measure will be applied evenly to all zones\n runner.registerInitialCondition(\"Equipment power will be reduced by #{single_space_type}% to '#{space_type.name}'.\")\n end\n\n space_type_equipments = space_type.electricEquipment\n space_type_equipments.each do |space_type_equipment|\n #clone of not already in hash\n equi_set_sch = space_type_equipment.schedule\n if !equi_set_sch.empty?\n # clone of not already in hash\n if equi_set_schs.key?(equi_set_sch.get.name.to_s)\n new_equi_set_sch = equi_set_schs[equi_set_sch.get.name.to_s]\n else\n new_equi_set_sch = equi_set_sch.get.clone(model)\n new_equi_set_sch = new_equi_set_sch.to_Schedule.get\n new_equi_set_sch_name = new_equi_set_sch.setName(\"#{new_equi_set_sch.name} adjusted #{equipment_power_reduction_percent}\")\n # add to the hash\n equi_set_schs[new_equi_set_sch.name.to_s] = new_equi_set_sch\n end\n # hook up clone to equipment\n \n if space_type_equipment.name.to_s != \"OfficeLarge Data Center Elec Equip\" && space_type_equipment.name.to_s != \"OfficeLarge Main Data Center Elec Equip\"\n space_type_equipment.setSchedule(new_equi_set_sch)\n runner.registerInfo(\"#{space_type_equipment.name} has a new electric equipment schedule\")\n end\n else\n runner.registerWarning(\"#{space_type.equipments.name} doesn't have a schedule.\")\n end\n end\n \n if apply_to_time\n runner.registerFinalCondition(\" equipment power is reduced from #{shift_time1} to #{shift_time2}.\")\n runner.registerFinalCondition(\" equipment power is reduced from #{shift_time4} to #{shift_time5} during special between month #{summer_start_month} and #{summer_end_month}\")\n else\n runner.registerFinalCondition(\" equipment power is reduced all day.\")\n end\n\n \n # make equipment schedule adjustments and rename.\n equi_set_schs.each do |k, v| # old name and new object for schedule\n if !v.to_ScheduleRuleset.empty?\n\n schedule = v.to_ScheduleRuleset.get\n default_rule = schedule.defaultDaySchedule\n rules = schedule.scheduleRules\n\n days_covered = Array.new(7, false)\n\n if rules.length > 0\n rules.each do |rule|\n summerStartMonth = OpenStudio::MonthOfYear.new(summer_start_month)\n summerEndMonth = OpenStudio::MonthOfYear.new(summer_end_month)\n summerStartDate = OpenStudio::Date.new(summerStartMonth, 1)\n summerEndDate = OpenStudio::Date.new(summerEndMonth, 30)\n \n summer_rule = rule.clone(model).to_ScheduleRule.get\n summer_rule.setStartDate(summerStartDate)\n summer_rule.setEndDate(summerEndDate)\n\n allDaysCovered(summer_rule, days_covered)\n\n cloned_day_summer = rule.daySchedule.clone(model)\n cloned_day_summer.setParent(summer_rule)\n\n summer_day = summer_rule.daySchedule\n day_time_vector = summer_day.times\n day_value_vector = summer_day.values\n summer_day.clearValues\n \n summer_day = createDaySchedule(summer_day, day_time_vector, day_value_vector, shift_time4, shift_time5, equipment_power_reduction_percent)\n \n ##############################################\n winterStartMonth1 = OpenStudio::MonthOfYear.new(winter_start_month1)\n winterEndMonth1 = OpenStudio::MonthOfYear.new(winter_end_month1)\n winterStartDate1 = OpenStudio::Date.new(winterStartMonth1, 1)\n winterEndDate1 = OpenStudio::Date.new(winterEndMonth1, 31)\n \n winter_rule1 = rule #rule.clone(model).to_ScheduleRule.get\n winter_rule1.setStartDate(winterStartDate1)\n winter_rule1.setEndDate(winterEndDate1)\n\n\n cloned_day_winter = rule.daySchedule.clone(model)\n cloned_day_winter.setParent(winter_rule1)\n\n winter_day1 = winter_rule1.daySchedule\n day_time_vector = winter_day1.times\n day_value_vector = winter_day1.values\n winter_day1.clearValues\n \n winter_day1 = createDaySchedule(winter_day1, day_time_vector, day_value_vector, shift_time6, shift_time7, equipment_power_reduction_percent)\n if shift_time1 != shift_time6 \n winter_day1 = createDaySchedule(winter_day1, day_time_vector, day_value_vector, shift_time1, shift_time2, equipment_power_reduction_percent)\n end\n ###################################################\n winterStartMonth2 = OpenStudio::MonthOfYear.new(winter_start_month2)\n winterEndMonth2 = OpenStudio::MonthOfYear.new(winter_end_month2)\n winterStartDate2 = OpenStudio::Date.new(winterStartMonth2, 1)\n winterEndDate2 = OpenStudio::Date.new(winterEndMonth2, 31)\n \n winter_rule2 = winter_rule1.clone(model).to_ScheduleRule.get\n winter_rule2.setStartDate(winterStartDate2)\n winter_rule2.setEndDate(winterEndDate2)\n \n cloned_day_winter2 = winter_day1.clone(model)\n cloned_day_winter2.setParent(winter_rule2)\n end\n end\n #runner.registerInfo(\"BEFORE #{days_covered}\")\n if days_covered.include?(false)\n summerStartMonth = OpenStudio::MonthOfYear.new(summer_start_month)\n summerEndMonth = OpenStudio::MonthOfYear.new(summer_end_month)\n summerStartDate = OpenStudio::Date.new(summerStartMonth, 1)\n summerEndDate = OpenStudio::Date.new(summerEndMonth, 30)\n \n summer_rule = OpenStudio::Model::ScheduleRule.new(schedule)\n summer_rule.setStartDate(summerStartDate)\n summer_rule.setEndDate(summerEndDate)\n coverSomeDays(summer_rule, days_covered)\n allDaysCovered(summer_rule, days_covered)\n\n cloned_day_summer = default_rule.clone(model)\n cloned_day_summer.setParent(summer_rule)\n\n summer_day = summer_rule.daySchedule\n day_time_vector = summer_day.times\n day_value_vector = summer_day.values\n summer_day.clearValues\n \n summer_day = createDaySchedule(summer_day, day_time_vector, day_value_vector, shift_time4, shift_time5, equipment_power_reduction_percent)\n \n ##############################################\n winterStartMonth1 = OpenStudio::MonthOfYear.new(winter_start_month1)\n winterEndMonth1 = OpenStudio::MonthOfYear.new(winter_end_month1)\n winterStartDate1 = OpenStudio::Date.new(winterStartMonth1, 1)\n winterEndDate1 = OpenStudio::Date.new(winterEndMonth1, 31)\n \n winter_rule1 = summer_rule.clone(model).to_ScheduleRule.get #OpenStudio::Model::ScheduleRule.new(schedule)\n winter_rule1.setStartDate(winterStartDate1)\n winter_rule1.setEndDate(winterEndDate1)\n\n #coverSomeDays(winter_rule1, days_covered)\n #allDaysCovered(summer_rule, days_covered)\n\n cloned_day_winter = default_rule.clone(model)\n cloned_day_winter.setParent(winter_rule1)\n\n winter_day1 = winter_rule1.daySchedule\n day_time_vector = winter_day1.times\n day_value_vector = winter_day1.values\n winter_day1.clearValues\n \n\n\n winter_day1 = createDaySchedule(winter_day1, day_time_vector, day_value_vector, shift_time6, shift_time7, equipment_power_reduction_percent)\n if shift_time1 != shift_time6 \n winter_day1 = createDaySchedule(winter_day1, day_time_vector, day_value_vector, shift_time1, shift_time2, equipment_power_reduction_percent)\n end\n ###################################################\n winterStartMonth2 = OpenStudio::MonthOfYear.new(winter_start_month2)\n winterEndMonth2 = OpenStudio::MonthOfYear.new(winter_end_month2)\n winterStartDate2 = OpenStudio::Date.new(winterStartMonth2, 1)\n winterEndDate2 = OpenStudio::Date.new(winterEndMonth2, 31)\n \n winter_rule2 = winter_rule1.clone(model).to_ScheduleRule.get #OpenStudio::Model::ScheduleRule.new(schedule)\n winter_rule2.setStartDate(winterStartDate2)\n winter_rule2.setEndDate(winterEndDate2)\n \n cloned_day_winter2 = winter_day1.clone(model)\n cloned_day_winter2.setParent(winter_rule2)\n end\n #runner.registerInfo(\"AFTER Summer #{days_covered}\")\n else\n runner.registerWarning(\"Schedule '#{k}' isn't a ScheduleRuleset object and won't be altered by this measure.\")\n v.remove # remove un-used clone\n end\n end\n\n end\n return true\n end", "def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n\n #use the built-in error checking\n if not runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n\n #assume the occ sensors will last the full analysis\n expected_life = 25\n \n #assign the user inputs to variables\n space_type_object = runner.getOptionalWorkspaceObjectChoiceValue(\"space_type\",user_arguments,model)\n percent_runtime_reduction = runner.getDoubleArgumentValue(\"percent_runtime_reduction\",user_arguments)\n material_and_installation_cost_per_space = runner.getDoubleArgumentValue(\"material_and_installation_cost_per_space\",user_arguments)\n\n #check the space_type for reasonableness and see if measure should run on space type or on the entire building\n apply_to_building = false\n space_type = nil\n if space_type_object.empty?\n handle = runner.getStringArgumentValue(\"space_type\",user_arguments)\n if handle.empty?\n runner.registerError(\"No space type was chosen.\")\n else\n runner.registerError(\"The selected space type with handle '#{handle}' was not found in the model. It may have been removed by another measure.\")\n end\n return false\n else\n if not space_type_object.get.to_SpaceType.empty?\n space_type = space_type_object.get.to_SpaceType.get\n elsif not space_type_object.get.to_Building.empty?\n apply_to_building = true\n else\n runner.registerError(\"Script Error - argument not showing up as space type or building.\")\n return false\n end\n end\n \n #check arguments for reasonableness\n if percent_runtime_reduction >= 100\n runner.registerError(\"Percent runtime reduction must be less than 100.\")\n return false\n end\n\n #find all the original schedules (before occ sensors installed)\n original_lts_schedules = []\n if apply_to_building #apply to the whole building\n \n model.getLightss.each do |light_fixture|\n if light_fixture.schedule.is_initialized\n original_lts_schedules << light_fixture.schedule.get\n end\n end\n else #apply to the a specific space type\n #do the lights assigned to the space type itself\n space_type.lights.each do |light_fixture|\n if light_fixture.schedule.is_initialized\n original_lts_schedules << light_fixture.schedule.get\n end\n end\n #do the lights in each space of the selected space type\n space_type.spaces.each do |space|\n space.lights.each do |light_fixture|\n if light_fixture.schedule.is_initialized\n original_lts_schedules << light_fixture.schedule.get\n end\n end \n end\n end\n \n #make copies of all the original lights schedules, reduced to include occ sensor impact\n original_schs_new_schs = {}\n original_lts_schedules.uniq.each do |orig_sch|\n #TODO skip non-schedule-ruleset schedules\n \n #copy the original schedule\n new_sch = orig_sch.clone.to_ScheduleRuleset.get\n #reduce each value in each profile (except the design days) by the specified amount\n runner.registerInfo(\"Reducing values in '#{orig_sch.name}' schedule by #{percent_runtime_reduction}% to represent occ sensor installation.\")\n day_profiles = []\n day_profiles << new_sch.defaultDaySchedule\n new_sch.scheduleRules.each do |rule|\n day_profiles << rule.daySchedule\n end\n multiplier = (100 - percent_runtime_reduction)/100\n day_profiles.each do |day_profile|\n #runner.registerInfo(\"#{day_profile.name}\")\n times_vals = day_profile.times.zip(day_profile.values)\n #runner.registerInfo(\"original time/values = #{times_vals}\")\n times_vals.each do |time,val|\n day_profile.addValue(time, val * multiplier)\n end\n #runner.registerInfo(\"new time/values = #{day_profile.times.zip(day_profile.values)}\")\n end \n #log the relationship between the old sch and the new, reduced sch\n original_schs_new_schs[orig_sch] = new_sch\n #runner.registerInfo(\"***\")\n end\n \n #replace the old schedules with the new schedules\n spaces_sensors_added_to = []\n if apply_to_building #apply to the whole building\n runner.registerInfo(\"Adding occupancy sensors to whole building\")\n model.getLightss.each do |light_fixture|\n next if light_fixture.schedule.empty?\n lights_sch = light_fixture.schedule.get\n new_sch = original_schs_new_schs[lights_sch]\n if new_sch\n runner.registerInfo(\"Added occupancy sensor for '#{light_fixture.name}'\")\n light_fixture.setSchedule(new_sch)\n spaces_sensors_added_to << light_fixture.space\n end\n end\n else #apply to the a specific space type\n #do the lights assigned to the space type itself\n runner.registerInfo(\"Adding occupancy sensors to space type '#{space_type.name}'\")\n space_type.lights.each do |light_fixture|\n next if light_fixture.schedule.empty?\n lights_sch = light_fixture.schedule.get\n new_sch = original_schs_new_schs[lights_sch]\n if new_sch\n runner.registerInfo(\"Added occupancy sensor for '#{light_fixture.name}'\")\n light_fixture.setSchedule(new_sch)\n spaces_sensors_added_to << light_fixture.space\n end\n end\n #do the lights in each space of the selected space type\n space_type.spaces.each do |space|\n runner.registerInfo(\"Adding occupancy sensors to space '#{space.name}\")\n space.lights.each do |light_fixture|\n next if light_fixture.schedule.empty?\n lights_sch = light_fixture.schedule.get\n new_sch = original_schs_new_schs[lights_sch]\n if new_sch\n runner.registerInfo(\"Added occupancy sensor for '#{light_fixture.name}'\")\n light_fixture.setSchedule(new_sch)\n spaces_sensors_added_to << light_fixture.space\n end\n end \n end\n end \n \n #report if the measure is not applicable\n num_sensors_added = spaces_sensors_added_to.uniq.size\n if spaces_sensors_added_to.size == 0\n runner.registerAsNotApplicable(\"This measure is not applicable because there were no lights in the specified areas of the building.\")\n return true\n end\n \n #report initial condition\n runner.registerInitialCondition(\"The building has several areas where occupancy sensors could be used to reduce lighting energy by turning off the lights while no occupants are present.\") \n \n #add cost of adding occ sensors\n if material_and_installation_cost_per_space != 0\n cost = OpenStudio::Model::LifeCycleCost.createLifeCycleCost(\"Add #{material_and_installation_cost_per_space} Occ Sensors to the Building\", model.getBuilding, material_and_installation_cost_per_space * num_sensors_added, \"CostPerEach\", \"Construction\", expected_life, 0)\n if cost.empty?\n runner.registerError(\"Failed to add costs.\")\n end\n end \n \n #report final condition\n if apply_to_building\n runner.registerFinalCondition(\"Add occupancy sensors to #{num_sensors_added} spaces in the building. The total cost to perform this is $#{material_and_installation_cost_per_space.round} per space, for a total cost of $#{(material_and_installation_cost_per_space * num_sensors_added).round}\")\n else\n runner.registerFinalCondition(\"Add occupancy sensors to #{num_sensors_added} #{space_type.name} spaces in the building. The total cost to perform this is $#{material_and_installation_cost_per_space.round} per space, for a total cost of $#{(material_and_installation_cost_per_space * num_sensors_added).round}\")\n end\n \n return true\n \n end", "def run(model, runner, user_arguments)\r\n super(model, runner, user_arguments)\r\n\r\n #use the built-in error checking \r\n if not runner.validateUserArguments(arguments(model), user_arguments)\r\n return false\r\n end\r\n run_measure = runner.getIntegerArgumentValue(\"run_measure\",user_arguments)\r\n if run_measure == 0\r\n runner.registerAsNotApplicable(\"Run Measure set to #{run_measure}.\")\r\n return true \r\n end\r\n \r\n require 'json'\r\n \r\n results = {}\r\n dx_name = []\r\n #get all DX coils in model\r\n dx_single = model.getCoilCoolingDXSingleSpeeds \r\n dx_two = model.getCoilCoolingDXTwoSpeeds\r\n dx_heat = model.getCoilHeatingDXSingleSpeeds\r\n \r\n if !dx_single.empty?\r\n dx_single.each do |dx|\r\n runner.registerInfo(\"DX coil: #{dx.name.get} Initial COP: #{dx.ratedCOP.get}\")\r\n dx.setRatedCOP(OpenStudio::OptionalDouble.new(6.0))\r\n runner.registerInfo(\"DX coil: #{dx.name.get} Final COP: #{dx.ratedCOP.get}\")\r\n dx_name << dx.name.get\r\n end\r\n end\r\n if !dx_two.empty?\r\n dx_two.each do |dx|\r\n runner.registerInfo(\"DX coil: #{dx.name.get} Initial High COP: #{dx.ratedHighSpeedCOP.get} Low COP: #{dx.ratedLowSpeedCOP.get}\")\r\n dx.setRatedHighSpeedCOP(6.0)\r\n dx.setRatedLowSpeedCOP(6.0)\r\n runner.registerInfo(\"DX coil: #{dx.name.get} Final High COP: #{dx.ratedHighSpeedCOP.get} Final COP: #{dx.ratedLowSpeedCOP.get}\")\r\n dx_name << dx.name.get\r\n end\r\n end\r\n if !dx_heat.empty?\r\n dx_heat.each do |dx|\r\n runner.registerInfo(\"DX coil: #{dx.name.get} Initial COP: #{dx.ratedCOP}\")\r\n dx.setRatedCOP(6.0)\r\n runner.registerInfo(\"DX coil: #{dx.name.get} Final COP: #{dx.ratedCOP}\")\r\n dx_name << dx.name.get\r\n end\r\n end\r\n \r\n if dx_name.empty?\r\n runner.registerWarning(\"No DX coils are appropriate for this measure\")\r\n runner.registerAsNotApplicable(\"No DX coils are appropriate for this measure\")\r\n end\r\n \r\n #unique initial conditions based on\r\n runner.registerInitialCondition(\"The building has #{dx_name.size} DX coils for which this measure is applicable.\")\r\n\r\n #reporting final condition of model\r\n runner.registerFinalCondition(\"The COP of the following coils was increased to 6: #{dx_name}\")\r\n return true\r\n\r\n end", "def around_perform_stats(*args)\n start = Time.now\n yield\n time_taken = Time.now - start\n statsd.timing(\"duration:#{self}\", time_taken)\n statsd.increment(\"total_successful:#{self}\")\n statsd.increment(\"total_successful\")\n run_hooks(:duration, :duration, args) {|key| statsd.timing(key, time_taken)}\n end", "def defMeasurement(name,&block)\n mp = {:mp => name, :fields => []}\n @fields = []\n # call the block with ourserlves to process its 'defMetric' statements\n block.call(self) if block\n @fields.each { |f| mp[:fields] << f }\n define_measurement_point(mp)\n end", "def measure(heading)\n start_time = Time.now\n print heading\n result = yield\n end_time = Time.now - start_time\n puts \" (#{end_time} s)\"\n result\nend", "def measure() @measure ||= (nb_weight == 0.0 ? 0.0 : sum_weight / nb_weight) end", "def record_measure(label)\n $logger.debug(\n tms = Benchmark.measure(label) do\n yield\n end.format(\"%n: %10.6rreal %10.6u user %10.6y sys\")\n )\nend", "def run_examination\n true\n end", "def update\n if @clock1_measure.nil?\n discipline_freq\n else\n elapsed = @clock1.time - @clock1_measure.local_time\n discipline_freq if elapsed > @frequency_discipline_interval\n end\n if @clock2_measure.nil?\n discipline_phase\n else\n elapsed = @clock2.time - @clock2_measure.local_time\n discipline_phase if elapsed > @phase_discipline_interval\n end\n end", "def benchmark!\n @benchmark = true\n end", "def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n\n # use the built-in error checking\n if !runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n\n # Return N/A if not selected to run\n run_measure = runner.getIntegerArgumentValue(\"run_measure\",user_arguments)\n if run_measure == 0\n runner.registerAsNotApplicable(\"Run Measure set to #{run_measure}.\")\n return true \n end \n \n\n pct_red = runner.getDoubleArgumentValue(\"pct_red\",user_arguments)\n start_hr = runner.getDoubleArgumentValue(\"start_hr\",user_arguments)\n end_hr = runner.getDoubleArgumentValue(\"end_hr\",user_arguments)\n \n\n\n #check the fraction for reasonableness\n if not 0 <= pct_red and pct_red <= 100\n runner.registerError(\"Percent reduction value needs to be between 0 and 100.\")\n return false\n end\n\n #check start_hr for reasonableness and round to 15 minutes\n start_red_hr = nil\n start_red_min = nil\n if not 0 <= start_hr and start_hr <= 24\n runner.registerError(\"Time in hours needs to be between or equal to 0 and 24\")\n return false\n else\n rounded_start_hr = ((start_hr*4).round)/4.0\n if not start_hr == rounded_start_hr\n runner.registerInfo(\"Start time rounded to nearest 15 minutes: #{rounded_start_hr}\")\n end\n start_red_hr = rounded_start_hr.truncate\n start_red_min = (rounded_start_hr - start_red_hr)*60\n start_red_min = start_red_min.to_i\n end\n\n #check end_hr for reasonableness and round to 15 minutes\n end_red_hr = nil\n end_red_min = nil \n if not 0 <= end_hr and end_hr <= 24\n runner.registerError(\"Time in hours needs to be between or equal to 0 and 24.\")\n return false\n elsif end_hr > end_hr\n runner.registerError(\"Please enter an end time later in the day than end time.\")\n return false\n else\n rounded_end_hr = ((end_hr*4).round)/4.0\n if not end_hr == rounded_end_hr\n runner.registerInfo(\"End time rounded to nearest 15 minutes: #{rounded_end_hr}\")\n end\n end_red_hr = rounded_end_hr.truncate\n end_red_min = (rounded_end_hr - end_red_hr)*60\n end_red_min = end_red_min.to_i\n end\n\n # Translate the percent reduction into a multiplier\n red_mult = pct_red/100\n\n # Get schedules from all lights.\n original_lights_schs = []\n model.getLightss.each do |lights|\n if lights.schedule.is_initialized\n lights_sch = lights.schedule.get\n original_lights_schs << lights_sch\n end\n end\n\n # loop through the unique list of lights schedules, cloning\n # and reducing schedule fraction during the specified time range.\n original_lights_schs_new_schs = {}\n original_lights_schs.uniq.each do |lights_sch|\n if lights_sch.to_ScheduleRuleset.is_initialized\n new_lights_sch = lights_sch.clone(model).to_ScheduleRuleset.get\n new_lights_sch.setName(\"#{lights_sch.name} with Solar Cogeneration and Daylighting\")\n original_lights_schs_new_schs[lights_sch] = new_lights_sch\n new_lights_sch = new_lights_sch.to_ScheduleRuleset.get\n \n # method to adjust the values in a day schedule by a \n # specified percentage during a range of hours.\n def reduce_schedule(day_sch, red_mult, start_red_hr, start_red_min, end_red_hr, end_red_min)\n start_time = OpenStudio::Time.new(0, start_red_hr, start_red_min, 0)\n end_time = OpenStudio::Time.new(0, end_red_hr, end_red_min, 0)\n\n # Get the original values at the desired start and end times\n # and put points into the schedule at those times.\n day_sch.addValue(start_time, day_sch.getValue(start_time))\n day_sch.addValue(end_time, day_sch.getValue(end_time))\n \n # Store the original time/values then clear the schedule\n times = day_sch.times\n values = day_sch.values\n day_sch.clearValues\n\n # Modify the time/values and add back to the schedule\n for i in 0..(values.length - 1)\n if times[i] > start_time and times[i] <= end_time # Inside range\n day_sch.addValue(times[i], values[i] * red_mult)\n else\n day_sch.addValue(times[i], values[i])\n end\n end\n\n end #end reduce schedule\n\n # Reduce default day schedule\n if new_lights_sch.scheduleRules.size == 0\n runner.registerWarning(\"Schedule '#{new_lights_sch.name}' applies to all days. It has been treated as a Weekday schedule.\")\n end\n reduce_schedule(new_lights_sch.defaultDaySchedule, red_mult, start_red_hr, start_red_min, end_red_hr, end_red_min)\n \n # Reduce all other schedule rules\n new_lights_sch.scheduleRules.each do |sch_rule|\n reduce_schedule(sch_rule.daySchedule, red_mult, start_red_hr, start_red_min, end_red_hr, end_red_min)\n end\n \n end \n end #end of original_lights_schs.uniq.each do\n\n #loop through all lights instances, replacing old lights schedules with the reduced schedules\n model.getLightss.each do |lights|\n if lights.schedule.empty?\n runner.registerWarning(\"There was no schedule assigned for the lights object named '#{lights.name}. No schedule was added.'\")\n else\n old_lights_sch = lights.schedule.get\n lights.setSchedule(original_lights_schs_new_schs[old_lights_sch])\n runner.registerInfo(\"Schedule for the lights object named '#{lights.name}' was reduced to simulate the application of Solar Cogeneration and Daylighting.\")\n end\n end\n\n # NA if the model has no lights\n if model.getLightss.size == 0\n runner.registerNotAsApplicable(\"Not Applicable - There are no lights in the model.\")\n end\n\n # Reporting final condition of model\n runner.registerFinalCondition(\"#{original_lights_schs.uniq.size} schedule(s) were edited to reflect the addition of Solar Cogeneration and Daylighting to the building.\")\n \n return true\n\n end", "def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n\n # use the built-in error checking\n if !runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n \n # Return N/A if not selected to run\n run_measure = runner.getIntegerArgumentValue(\"run_measure\",user_arguments)\n if run_measure == 0\n runner.registerAsNotApplicable(\"Run Measure set to #{run_measure}.\")\n return true \n end\n\n\t#initialize variables\n\ttz_count = 0\n\tclg_tstat_schedule = []\n\tthermal_zone_array = []\n\t\t\n\t# get the thermal zones and loop through them \n\tmodel.getThermalZones.each do |thermal_zone|\n\t\n\t\tthermal_zone_array << thermal_zone\n\t\t\n\t\t# test to see if thermal zone has a thermostat object assigned or is unconditioned. \n\t\tif thermal_zone.thermostatSetpointDualSetpoint.is_initialized\n\t\t\tzone_thermostat = thermal_zone.thermostatSetpointDualSetpoint.get\n\t\t\ttz_count += 1\n\t\t\t\n\t\t\tif zone_thermostat.coolingSetpointTemperatureSchedule.is_initialized\n\t\t\t\tclg_tstat_schedule = zone_thermostat.coolingSetpointTemperatureSchedule.get\n\t\t\t\t\n\t\t\t\t# clone the existing cooling T-stat schedule in case it is used somewhere else in the model\n\t\t\t\tcloned_clg_tstat_schedule = clg_tstat_schedule.clone\n\t\t\t\t@new_clg_tstat_schedule_name = (\"#{clg_tstat_schedule.name}+1.5F\")\n\t\t\t\n\t\t\t\tif cloned_clg_tstat_schedule.to_ScheduleRuleset.is_initialized\n\t\t\t\t\tschedule = cloned_clg_tstat_schedule.to_ScheduleRuleset.get\n\t\t\t\t\t# gather profiles of cloned schedule\n\t\t\t\t\tprofiles = []\n\t\t\t\t\tcooling_thermostat_array = []\n\t\t\t\t\tdefaultProfile = schedule.to_ScheduleRuleset.get.defaultDaySchedule\n\t\t\t\t\n\t\t\t\t\tprofiles << defaultProfile\n\t\t\t\t\trules = schedule.scheduleRules\n\t\t\t\t\n\t\t\t\t\trules.each do |rule|\n\t\t\t\t\t\tprofiles << rule.daySchedule\n\t\t\t\t\tend # end the do loop through the rulesetsdo\n\n\t\t\t\t\t#adjust profiles of temperature schedule of cloned schedule by + 1.5 deg F delta (0.833 C)\n\t\t\t\t\tprofiles.each do |profile|\n\t\t\t\t\t\ttime = profile.times\n\t\t\t\t\t\ti = 0\n\t\t\t\t\t\t#TODO - name new profile\n\t\t\t\t\t\tprofile.values.each do |value|\n\t\t\t\t\t\t\tdelta = 0.8333\n\t\t\t\t\t\t\tnew_value = value + delta # Note this is where the cooling setpoint is raised\n\t\t\t\t\t\t\tprofile.addValue(time[i], new_value)\n\t\t\t\t\t\t\ti += 1\n\t\t\t\t\t\t\tcloned_clg_tstat_schedule.setName(@new_clg_tstat_schedule_name)\n\t\t\t\t\t\t\tcooling_thermostat_array << cloned_clg_tstat_schedule\n\t\t\t\t\t\tend # end loop through each profile values\n\t\t\t\t\tend # end loop through each profile\n\t\t\t\t\t\n\t\t\t\t\tzone_thermostat.setCoolingSetpointTemperatureSchedule(cloned_clg_tstat_schedule.to_ScheduleRuleset.get)\n\t\t\t\t\trunner.registerInfo(\"The existing cooling thermostat '#{clg_tstat_schedule.name}' has been changed to #{cloned_clg_tstat_schedule.name}. Inspect the new schedule values using the OS App.\")\n\t\t\t\tend # end if statement for cloning and modifying cooling tstat schedule object\n\t\t\telse\n\t\t\t\trunner.registerInfo(\"The dual setpoint thermostat object named #{zone_thermostat.name} serving thermal zone #{thermal_zone.name} did not have a cooling setpoint temperature schedule associated with it. The measure will not alter this thermostat object\")\n\t\t\tend # end if statement for cooling Setpoint Temperature is initialized\n\t\t\t\n\t\t\tif zone_thermostat.heatingSetpointTemperatureSchedule.is_initialized\n\t\t\t\thtg_tstat_schedule = zone_thermostat.heatingSetpointTemperatureSchedule.get\n\t\t\t\t\t\t\n\t\t\t\t# clone the existing heating T-stat schedule in case it is used somewhere else\n\t\t\t\tcloned_htg_tstat_schedule = htg_tstat_schedule.clone\n\t\t\t\t\n\t\t\t\t#name cloned heating t-stat schedule\n\t\t\t\tcloned_htg_tstat_schedule.setName(\"#{htg_tstat_schedule.name}-1.5F\")\n\n\t\t\t\tif cloned_htg_tstat_schedule.to_ScheduleRuleset.is_initialized\n\t\t\t\t\tschedule = cloned_htg_tstat_schedule.to_ScheduleRuleset.get\n\t\t\t\t\n\t\t\t\t\t# gather profiles of cloned schedule\n\t\t\t\t\tprofiles_h = []\n\t\t\t\t\tdefaultProfile = schedule.to_ScheduleRuleset.get.defaultDaySchedule\n\t\t\t\t\t\n\t\t\t\t\tprofiles_h << defaultProfile\n\t\t\t\t\trules_h = schedule.scheduleRules\n\t\t\t\t\trules_h.each do |rule_h|\n\t\t\t\t\t\tprofiles_h << rule_h.daySchedule\n\t\t\t\t\tend # end the rule_h do\n\n\t\t\t\t\t#adjust profiles_h of temperature schedule of cloned schedule by + 1.5 deg F delta (0.833 C)\n\t\t\t\t\tprofiles_h.each do |profile_h|\n\t\t\t\t\t\ttime_h = profile_h.times\n\t\t\t\t\t\ti = 0\n\t\t\t\t\t\t#TODO - name new profile\n\t\t\t\t\t\tprofile_h.values.each do |value_h|\n\t\t\t\t\t\t\tdelta_h = 0.8333\n\t\t\t\t\t\t\tnew_value_h = value_h - delta_h # Note this is where the heating setpoint is lowered \n\t\t\t\t\t\t\tprofile_h.addValue(time_h[i], new_value_h)\n\t\t\t\t\t\t\ti += 1\n\t\t\t\t\t\tend # end loop through each profile values\n\t\t\t\t\tend # end loop through each profile_h\n\t\t\t\t\t\n\t\t\t\t\tzone_thermostat.setHeatingSetpointTemperatureSchedule(cloned_htg_tstat_schedule.to_ScheduleRuleset.get)\n\t\t\t\t\trunner.registerInfo(\"The existing heating thermostat '#{htg_tstat_schedule.name}' has been changed to #{cloned_htg_tstat_schedule.name}. Inspect the new schedule values using the OS App.\")\n\t\t\t\tend # end if statement for cloning and modifying heating tstat schedule object\t\n\t\t\telse\n\t\t\t\trunner.registerInfo(\"The dual setpoint thermostat object named #{zone_thermostat.name} serving thermal zone #{thermal_zone.name} did not have a heating setpoint temperature schedule associated with it. The measure will not alter this thermostat object\")\n\t\t\tend # end if statement for heating Setpoint Temperature is initialized\n\t\tend\t# end if statement for zone_thermstat cooling schedule\n\t\t\n\tend # end loop through thermal zones\t\t\t\n\t\t\t\n\t# Add ASHRAE 55 Comfort Warnings are applied to people objects\n\t# get people objects and people definitions in model\n\tpeople_defs = model.getPeopleDefinitions\n\tpeople_instances = model.getPeoples\n\n\t# loop through people objects\n\tpeople_def_counter = 0\n\tpeople_defs.sort.each do |people_def|\n\t next if not people_def.instances.size > 0\n\t people_def_counter += 1\n\t people_def.setEnableASHRAE55ComfortWarnings(true)\n\tend\n\t\t\t\n\treporting_frequency = \"Timestep\"\n\toutputVariable = OpenStudio::Model::OutputVariable.new(\"Zone Thermal Comfort ASHRAE 55 Adaptive Model 90% Acceptability Status []\",model)\n\toutputVariable.setReportingFrequency(reporting_frequency)\n\trunner.registerInfo(\"Adding output variable for 'Zone Thermal Comfort ASHRAE 55 Adaptive Model 90% Acceptability Status' reporting '#{reporting_frequency}'\")\n\n\t# write As Not Applicable message\n\tif tz_count == 0\n\t\trunner.registerAsNotApplicable(\"Measure is not applicable. There are no conditioned thermal zones in the model.\")\n\t\treturn true\n\tend\n\n\t# report initial condition of model\n\trunner.registerInitialCondition(\"The initial model contained #{tz_count} thermal zones with #{thermal_zone_array.length} 'Cooling Thermostat Schedule' and #{thermal_zone_array.length} 'Heating Thermostat Schedule' objects for which this measure is applicable.\")\n\n\t# report final condition of model\n\trunner.registerFinalCondition(\"The #{thermal_zone_array.length} Heating and #{thermal_zone_array.length} Cooling Thermostats schedules for #{thermal_zone_array.length} Thermal Zones were altered to reflect a additional deadband width of 3 Deg F . \")\n\treturn true\n\n end", "def stat(*args)\n @recorder.call(*args) if @recorder\n end", "def measure (n=1)\n cnt=0\nelapsed_time=Time.now\n\nn.times {\n cnt+=1\n yield} \nelapsed_time=(Time.now-elapsed_time)/cnt\n\nend", "def run() end", "def running_test_step; end", "def stat() end", "def measure(msg)\n start = Time.now\n yield\n printf \"%<msg>s in %<elapsed>.2f seconds\\n\", msg: msg, elapsed: Time.now - start\nend", "def measure(msg)\n start = Time.now\n yield\n printf \"%<msg>s in %<elapsed>.2f seconds\\n\", msg: msg, elapsed: Time.now - start\nend", "def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n\n # use the built-in error checking\n if !runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n\n # Return N/A if not selected to run\n run_measure = runner.getIntegerArgumentValue(\"run_measure\",user_arguments)\n if run_measure == 0\n runner.registerAsNotApplicable(\"Run Measure set to #{run_measure}.\")\n return true \n end \n \n #initialize variables\n zone_hvac_count = 0\n pump_count = 0\n air_loop_count = 0\n \n #loop through each air loop in the model\n model.getAirLoopHVACs.sort.each do |air_loop|\n\n # call the method to generate a new occupancy schedule based on a 5% threshold\n occ_sch = air_loop.get_occupancy_schedule(0.15)\n old_sch = air_loop.availabilitySchedule\n next unless compare_eflh(runner, old_sch, occ_sch)\n # set the availability schedule of the airloop to the newly generated schedule\n air_loop.setAvailabilitySchedule(occ_sch)\n runner.registerInfo(\"The availability schedule named #{old_sch.name} for #{air_loop.name} was replaced with a new schedule named #{occ_sch.name} which tracks the occupancy profile of the thermal zones on this airloop.\")\n air_loop_count +=1\n \n end\n\n #loop through each thermal zone\n model.getThermalZones.sort.each do |thermal_zone|\n \n # zone equipments assigned to thermal zones\n thermal_zone_equipment = thermal_zone.equipment \n \n if thermal_zone_equipment.size >= 1\n # run schedule method to create a new schedule ruleset, routines \n occ_sch = thermal_zone.get_occupancy_schedule(0.15)\n \n #loop through Zone HVAC Equipment\n thermal_zone_equipment.each do |equip|\n \n # getting the fan exhaust object & getting relevant information for it. \n if equip.to_FanZoneExhaust.is_initialized\n zone_equip = equip.to_FanZoneExhaust.get\n old_schedule = zone_equip.availabilitySchedule.get\n next unless compare_eflh(runner, old_schedule, occ_sch)\n #assign the 'occ_sch' here as exhaust's availability schedule\n zone_equip.setAvailabilitySchedule(occ_sch)\n runner.registerInfo(\"The availability schedule named #{old_schedule.name} for the OS_Fan_ZoneExhaust named #{zone_equip.name} was replaced with a new schedule named #{occ_sch.name} representing the occupancy profile of the thermal zone named #{thermal_zone.name}.\")\n zone_hvac_count += 1 \t\n elsif equip.to_RefrigerationAirChiller.is_initialized\n zone_equip = equip.to_RefrigerationAirChiller.get\n zone_hvac_count += 1 if set_equip_availability_schedule(runner, thermal_zone, occ_sch, zone_equip)\n elsif equip.to_WaterHeaterHeatPump.is_initialized\n zone_equip = equip.to_WaterHeaterHeatPump.get\n zone_hvac_count += 1 if set_equip_availability_schedule(runner, thermal_zone, occ_sch, zone_equip)\n elsif equip.to_ZoneHVACBaseboardConvectiveElectric.is_initialized\n zone_equip = equip.to_ZoneHVACBaseboardConvectiveElectric.get\n zone_hvac_count += 1 if set_equip_availability_schedule(runner, thermal_zone, occ_sch, zone_equip)\n elsif equip.to_ZoneHVACBaseboardConvectiveWater.is_initialized\n zone_equip = equip.to_ZoneHVACBaseboardConvectiveWater.get\n zone_hvac_count += 1 if set_equip_availability_schedule(runner, thermal_zone, occ_sch, zone_equip)\n elsif equip.to_ZoneHVACBaseboardRadiantConvectiveElectric.is_initialized\n zone_equip = equip.to_ZoneHVACBaseboardRadiantConvectiveElectric.get\n zone_hvac_count += 1 if set_equip_availability_schedule(runner, thermal_zone, occ_sch, zone_equip)\n elsif equip.to_ZoneHVACBaseboardRadiantConvectiveWater.is_initialized\n zone_equip = equip.to_ZoneHVACBaseboardRadiantConvectiveWater.get\n zone_hvac_count += 1 if set_equip_availability_schedule(runner, thermal_zone, occ_sch, zone_equip)\n elsif equip.to_ZoneHVACDehumidifierDX.is_initialized\n zone_equip = equip.to_ZoneHVACDehumidifierDX.get\n zone_hvac_count += 1 if set_equip_availability_schedule(runner, thermal_zone, occ_sch, zone_equip)\n elsif equip.to_ZoneHVACEnergyRecoveryVentilator.is_initialized\n zone_equip = equip.to_ZoneHVACEnergyRecoveryVentilator.get\n zone_hvac_count += 1 if set_equip_availability_schedule(runner, thermal_zone, occ_sch, zone_equip)\t\t\t\t\n elsif equip.to_ZoneHVACFourPipeFanCoil.is_initialized\n zone_equip = equip.to_ZoneHVACFourPipeFanCoil.get\n zone_hvac_count += 1 if set_equip_availability_schedule(runner, thermal_zone, occ_sch, zone_equip)\t\t\t\t\t\n elsif equip.to_ZoneHVACHighTemperatureRadiant.is_initialized\n zone_equip = equip.to_ZoneHVACHighTemperatureRadiant.get\n zone_hvac_count += 1 if set_equip_availability_schedule(runner, thermal_zone, occ_sch, zone_equip)\t\t\t\t\n elsif equip.to_ZoneHVACIdealLoadsAirSystem.is_initialized\n zone_equip = equip.to_ZoneHVACIdealLoadsAirSystem.get\n zone_hvac_count += 1 if set_equip_availability_schedule(runner, thermal_zone, occ_sch, zone_equip)\t\t\t\t \n elsif equip.to_ZoneHVACLowTemperatureRadiantElectric.is_initialized\n zone_equip = equip.to_ZoneHVACLowTemperatureRadiantElectric.get\n zone_hvac_count += 1 if set_equip_availability_schedule(runner, thermal_zone, occ_sch, zone_equip)\t\t\t\t\t\n elsif equip.to_ZoneHVACLowTempRadiantConstFlow.is_initialized\n zone_equip = equip.to_ZoneHVACLowTempRadiantConstFlow.get\n zone_hvac_count += 1 if set_equip_availability_schedule(runner, thermal_zone, occ_sch, zone_equip)\t\t\t\t\t \t\n elsif equip.to_ZoneHVACLowTempRadiantVarFlow.is_initialized\n zone_equip = equip.to_ZoneHVACLowTempRadiantVarFlow.get\n zone_hvac_count += 1 if set_equip_availability_schedule(runner, thermal_zone, occ_sch, zone_equip)\t\t\t\t\t\n elsif equip.to_ZoneHVACPackagedTerminalAirConditioner.is_initialized\n zone_equip = equip.to_ZoneHVACPackagedTerminalAirConditioner.get\n zone_hvac_count += 1 if set_equip_availability_schedule(runner, thermal_zone, occ_sch, zone_equip)\n elsif equip.to_ZoneHVACPackagedTerminalHeatPump.is_initialized\n zone_equip = equip.to_ZoneHVACPackagedTerminalHeatPump.get\n zone_hvac_count += 1 if set_equip_availability_schedule(runner, thermal_zone, occ_sch, zone_equip)\n elsif equip.to_ZoneHVACTerminalUnitVariableRefrigerantFlow.is_initialized\n next unless compare_eflh(runner, old_schedule, occ_sch) \n equip.to_ZoneHVACTerminalUnitVariableRefrigerantFlow.get.setTerminalUnitAvailabilityschedule(occ_sch)\n runner.registerInfo(\"The availability schedule for the Zone HVAC Terminal Unit Variable Refrigerant Flow Object has been replaced with a new schedule named #{occ_sch.name} representing the occupancy profile of the thermal zone named #{thermal_zone.name}.\")\t\t\t\t\t\n zone_hvac_count += 1 \n elsif equip.to_ZoneHVACUnitHeater.is_initialized\n zone_equip = equip.to_ZoneHVACUnitHeater.get\n zone_hvac_count += 1 if set_equip_availability_schedule(runner, thermal_zone, occ_sch, zone_equip)\t\t\t\n elsif equip.to_ZoneHVACUnitVentilator.is_initialized\n zone_equip = equip.to_ZoneHVACUnitVentilator.get\n zone_hvac_count += 1 if set_equip_availability_schedule(runner, thermal_zone, occ_sch, zone_equip)\t\t\t\t\t\n elsif equip.to_ZoneVentilationDesignFlowRate.is_initialized\n runner.registerInfo(\"Thermal Zone named #{thermal_zone.name} has a Zone Ventilation Design Flow Rate object attacjhed as a ZoneHVACEquipment object. No modification were made to this object.\")\t\t\n end \t\n \n end # end loop through Zone HVAC Equipment\n \n else\n runner.registerInfo(\"Thermal Zone named #{thermal_zone.name} has no Zone HVAC Equipment objects attached - therefore no schedule objects have been altered.\")\t\n end # end of if statement\n \n end # end loop through thermal zones\n\n # Change pump control status if any airloops or\n # zone equipment were changed.\n if air_loop_count > 0 || zone_hvac_count > 0\n model.getPlantLoops.each do |plantLoop|\n #Loop through each plant loop demand component\n plantLoop.demandComponents.each do |dc|\n if dc.to_PumpConstantSpeed.is_initialized\n cs_pump = dc.to_PumpConstantSpeed.get\n if cs_pump.pumpControlType == (\"Intermittent\")\n runner.registerInfo(\"Demand side Constant Speed Pump object named #{cs_pump.name} on the plant loop named #{dc.name} had a pump control type attribute already set to intermittent. No changes will be made to this object.\")\n else \n cs_pump.setPumpControlType(\"Intermittent\")\n runner.registerInfo(\"Pump Control Type attribute of Demand side Constant Speed Pump object named #{cs_pump.name} on the plant loop named #{dc.name} was changed from continuous to intermittent.\")\n pump_count +=1\n end\n end\n \n if dc.to_PumpVariableSpeed.is_initialized\n vs_pump = dc.to_PumpVariableSpeed.get\n if vs_pump.pumpControlType == (\"Intermittent\")\n runner.registerInfo(\"Demand side Variable Speed Pump named #{vs_pump.name} on the plant loop named #{dc.name} had a pump control type attribute already set to intermittent. No changes will be made to this object.\")\n else \n cs_pump.setPumpControlType(\"Intermittent\")\n runner.registerInfo(\"Demand side Pump Control Type attribute of Variable Speed Pump named #{vs_pump.name} on the plant loop named #{dc.name} was changed from continuous to intermittent.\")\n pump_count +=1\n end\n end\n end\n \n #Loop through each plant loop supply component\n plantLoop.supplyComponents.each do |sc|\n if sc.to_PumpConstantSpeed.is_initialized\n cs_pump = sc.to_PumpConstantSpeed.get\n if cs_pump.pumpControlType == (\"Intermittent\")\n runner.registerInfo(\"Supply side Constant Speed Pump object named #{cs_pump.name} on the plant loop named #{sc.name} had a pump control type attribute already set to intermittent. No changes will be made to this object.\")\n else \n cs_pump.setPumpControlType(\"Intermittent\")\n runner.registerInfo(\"Supply Side Pump Control Type atteribute of Constant Speed Pump named #{cs_pump.name} on the plant loop named #{sc.name} was changed from continuous to intermittent.\")\n pump_count +=1\n end #end if statement\t\n end #end if statement for changing supply component constant speed pump objects\n \n if sc.to_PumpVariableSpeed.is_initialized\n vs_pump = sc.to_PumpVariableSpeed.get\n if vs_pump.pumpControlType == (\"Intermittent\")\n runner.registerInfo(\"Supply side Variable Speed Pump object named #{vs_pump.name} on the plant loop named #{sc.name} had a pump control type attribute already set to intermittent. No changes will be made to this object.\")\n else \n cs_pump.setPumpControlType(\"Intermittent\")\n runner.registerInfo(\"Pump Control Type attribute of Supply Side Variable Speed Pump named #{vs_pump.name} on the plant loop named #{sc.name} was changed from continuous to intermittent.\")\n pump_count +=1\n end #end if statement\t\n end #end if statement for changing supply component variable speed pump objects\n \n end # end loop throught plant loop supply side components\n \n end # end loop through plant loops\n end\n \n #Write N/A message\n if air_loop_count == 0 && zone_hvac_count == 0 && pump_count == 0 \n runner.registerAsNotApplicable(\"The model did not contain any Airloops, Thermal Zones having ZoneHVACEquipment objects or associated plant loop pump objects to act upon. The measure is not applicable.\")\n return true\n end\t\n \n #report initial condition of model\n runner.registerInitialCondition(\"The model started with #{air_loop_count} AirLoops, #{zone_hvac_count} Zone HVAC Equipment Object and #{pump_count} pump objects subject to modifications.\")\n \n # report final condition of model\n runner.registerFinalCondition(\"The measure modified the availability schedules of #{air_loop_count} AirLoops and #{zone_hvac_count} Zone HVAC Equipment objects. #{pump_count} pump objects had control settings modified.\")\n \n # Add ASHRAE Standard 55 warnings\n reporting_frequency = \"Timestep\"\n outputVariable = OpenStudio::Model::OutputVariable.new(\"Zone Thermal Comfort ASHRAE 55 Adaptive Model 90% Acceptability Status []\",model)\n outputVariable.setReportingFrequency(reporting_frequency)\n runner.registerInfo(\"Adding output variable for 'Zone Thermal Comfort ASHRAE 55 Adaptive Model 90% Acceptability Status' reporting at the model timestep.\")\n \n return true\n\t\n end", "def calc_next_run\n nil\n end", "def calc_next_run\n nil\n end", "def running_test_case; end", "def estimate\n # (native code) \n end", "def run; end", "def run; end", "def run; end", "def run; end", "def run; end", "def run; end", "def run; end", "def run; end", "def run; end", "def tick; end", "def tick; end", "def tick; end", "def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n\n # use the built-in error checking\n if !runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n\n # assign the user inputs to variables\n verbose_info_statements = runner.getBoolArgumentValue(\"verbose_info_statements\",user_arguments)\n fixed_window_subsurface = runner.getOptionalWorkspaceObjectChoiceValue('fixed_window_subsurface', user_arguments, model) # model is passed in because of argument type\n internal_variable_availability_dictionary_reporting = runner.getStringArgumentValue('internal_variable_availability_dictionary_reporting', user_arguments)\n ems_runtime_language_debug_output_level = runner.getStringArgumentValue('ems_runtime_language_debug_output_level', user_arguments) \n actuator_availability_dictionary_reporting = runner.getStringArgumentValue('actuator_availability_dictionary_reporting', user_arguments) \n \n runner.registerInitialCondition(\"Measure began with #{model.getEnergyManagementSystemSensors.count} EMS sensors, #{model.getEnergyManagementSystemActuators.count} EMS Actuators, #{model.getEnergyManagementSystemPrograms.count} EMS Programs, #{model.getEnergyManagementSystemSubroutines.count} EMS Subroutines, #{model.getEnergyManagementSystemProgramCallingManagers.count} EMS Program Calling Manager objects\")\n \n # declare arrys for scope\n array_of_21_sets = []\n material_property_glazing_spectral_data_vector = []\n standard_glazing_layer_array = []\n construction_array = []\n ems_window_construction_array = []\n \n # load idf into workspace\n workspace = OpenStudio::Workspace::load(OpenStudio::Path.new(\"#{File.dirname(__FILE__)}/resources/EMSThermochromicWindow.idf\")).get\n \n # get all MaterialPropertyGlazingSpectralData objects from within the idf\n # material_property_glazing_spectral_datas = source_idf.getObjectsByType(\"MaterialProperty:GlazingSpectralData\".to_IddObjectType)\n material_property_glazing_spectral_datas = workspace.getObjectsByType(\"MaterialProperty:GlazingSpectralData\".to_IddObjectType)\n if verbose_info_statements == true\n runner.registerInfo(\"The model has #{material_property_glazing_spectral_datas.size} material_property_glazing_spectral_datas objects.\")\n end\n \n material_property_glazing_spectral_datas.each do |material_property_glazing_spectral_data|\n \n spectral_data = {\"name\" => \"\",\"properties\" => []}\n spectral_data[\"name\"] = material_property_glazing_spectral_data.getString(0).to_s\n \n # Note: EnergyPlus file MaterialProperty:GlazingSpectralData objects have 1764 /4 = 441 sets of 4 values each \n n = material_property_glazing_spectral_data.numFields\n (1..n).each do |i| \n spectral_data[\"properties\"] << material_property_glazing_spectral_data.getString(i).to_s \n end\n array_of_21_sets << spectral_data\n end\n \n array_of_21_sets.each do |set|\n \n props = set[\"properties\"]\n material_property_glazing_spectral_data = OpenStudio::Model::MaterialPropertyGlazingSpectralData.new(model)\n material_property_glazing_spectral_data.setName(\"#{set[\"name\"]}\")\n \n k = (props.length / 4) - 1\n (0..k).each do |i| # note 440 uniques (a, b, c, d) pairs of attributes for each spectral data field object\n material_property_glazing_spectral_data.addSpectralDataField(props[(i*4)+0].to_f, props[(i*4)+1].to_f, props[(i*4)+2].to_f, props[(i*4)+3].to_f)\t\n end\n \n material_property_glazing_spectral_data_vector << material_property_glazing_spectral_data\n end \n \n # create (2) required new air gas materials to used by all EMS window constructions \n air_gas_3mm_material = OpenStudio::Model::Gas.new(model, \"Air\", 0.003) \n air_gas_3mm_material.setName(\"AIR 3MM\")\n \n air_gas_8mm_material = OpenStudio::Model::Gas.new(model, \"Air\", 0.008) \n air_gas_8mm_material.setName(\"AIR 8MM\")\n \n # loop through array of OS MaterialPropertyGlazingSpectralData objects and create 21 new Standard Glazing objects \n material_property_glazing_spectral_data_vector.each do |spec_data_obj|\n spec_data_obj_name = spec_data_obj.name\n layer_name = spec_data_obj_name.to_s.slice(\"sp\")\n if ((spec_data_obj_name == \"WO18RT25SP\") || (spec_data_obj_name == \"Clear3PPGSP\"))\n layer = OpenStudio::Model::StandardGlazing.new(model, 'Spectral', 0.0075)\n else\n layer = OpenStudio::Model::StandardGlazing.new(model, 'Spectral', 0.003276)\n end\n layer.setName(\"#{layer_name}\")\n layer.setWindowGlassSpectralDataSet(spec_data_obj)\n layer.setInfraredTransmittanceatNormalIncidence(0) # same for all 21 constructions\n layer.setFrontSideInfraredHemisphericalEmissivity(0.84) # same for all 21 constructions\n layer.setBackSideInfraredHemisphericalEmissivity(0.84) # same for all 21 constructions\n if ((spec_data_obj_name == \"WO18RT25SP\") || (spec_data_obj_name == \"Clear3PPGSP\"))\n layer.setConductivity(1.0) \n else\n layer.setConductivity(0.6) \n end\n layer.setDirtCorrectionFactorforSolarandVisibleTransmittance(1) # same for all 21 constructions\n layer.setSolarDiffusing(false)\n standard_glazing_layer_array << layer\n end\n\n # Create (2) unique standard glazing layers not used for Thermochromatic performance \n sb60_clear_3_ppg_layer = standard_glazing_layer_array[0]\n clear_3ppg_layer = standard_glazing_layer_array[1]\n remaining_standard_glazing_layer_array = standard_glazing_layer_array.drop(2)\n \n # create (19) new arrays of layered constructions representing thermochromatic layers\n remaining_standard_glazing_layer_array.each do |remaining_standard_glazing_layer|\n construction = [sb60_clear_3_ppg_layer, air_gas_3mm_material, remaining_standard_glazing_layer, air_gas_8mm_material, sb60_clear_3_ppg_layer]\n construction_array << construction\n end\n \n # create 19 new OS:Construction objects representing EMS thermochromatic windows\n name_index_array = [25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 50, 55, 60, 65, 70, 75, 80, 85]\n index = 0\n \n construction_array.each do |const|\n ems_window_construction = OpenStudio::Model::Construction.new(const)\n ems_window_construction.setName(\"TCwindow_#{name_index_array[index]}\")\n if verbose_info_statements == true\n runner.registerInfo(\"Created a new Construction named #{ems_window_construction.name} representing a thermochromatic window construction.\")\n end\n ems_window_construction_array << ems_window_construction\n index +=1\n end\n\n # check the user argument of the fixed window subsurface for reasonableness\n if fixed_window_subsurface.empty?\n handle = runner.getStringArgumentValue('fixed_window_subsurface', user_arguments)\n if handle.empty?\n runner.registerError('No fixed window subsurface was chosen.')\n else\n runner.registerError(\"The selected fixed window subsurface with handle '#{handle}' was not found in the model. It may have been removed by another measure.\")\n end\n return false\n else\n if !fixed_window_subsurface.get.to_SubSurface.empty?\n fixed_window_subsurface = fixed_window_subsurface.get.to_SubSurface.get\n else\n runner.registerError('Script Error - argument not showing up as construction.')\n return false\n end\n end\n \n # Create a new EnergyManagementSystem:Sensor object representing the Surface Outside Face temp of the EMS thermochromatic window subsurface\n ems_win_Tout_sensor = OpenStudio::Model::EnergyManagementSystemSensor.new(model, \"Surface Outside Face Temperature\")\n ems_win_Tout_sensor.setName(\"Win1_Tout\")\n ems_win_Tout_sensor.setKeyName(\"#{fixed_window_subsurface.name}\")\n if verbose_info_statements == true\n runner.registerInfo(\"An EMS Sensor object named '#{ems_win_Tout_sensor.name}' representing the Surface Outside Face temp of the EMS thermochromatic window subsurface was added to the model.\") \n end\n \n # Create a new EMS Actuator Object representing the construction state of the EMS generated thermochromatic window \n ems_win_construct_actuator = OpenStudio::Model::EnergyManagementSystemActuator.new(fixed_window_subsurface, \"Surface\", \"Construction State\")\n ems_win_construct_actuator.setName(\"Win1_Construct\")\n if verbose_info_statements == true\n runner.registerInfo(\"An EMS Actuator object named '#{ems_win_construct_actuator.name}' representing construction state of the EMS generated thermochromatic window was added to the model.\") \n end\n \n # Create 19 EnergyManagementSystem:ConstructionIndexVariable objects for each unique thermochromatic construction\n ems_window_construction_array.each do |ems_window_construction|\n ems_constr_index_var = OpenStudio::Model::EnergyManagementSystemConstructionIndexVariable.new(model, ems_window_construction ) \n ems_constr_index_var.setName(\"#{ems_window_construction.name}\")\n if verbose_info_statements == true\n runner.registerInfo(\"An EMS SystemConstructionIndexVariable object named '#{ems_constr_index_var.name}' representing the the EMS construction state of the thermochromatic window was added to the model.\") \n end\n end\n \n # Create new EnergyManagementSystem:Program object for assigning different window constructions by dynamically evaluating the exterior surface temp of the fixed window subsurface \n ems_apply_thermochromatic_constructions_prgm = OpenStudio::Model::EnergyManagementSystemProgram.new(model)\n ems_apply_thermochromatic_constructions_prgm.setName(\"#{fixed_window_subsurface.name}_Control\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"IF #{ems_win_Tout_sensor.name} <= 26.0\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"SET #{ems_win_construct_actuator.name} = TCwindow_25\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"ELSEIF #{ems_win_Tout_sensor.name} <= 28.0\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"SET #{ems_win_construct_actuator.name} = TCwindow_27\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"ELSEIF #{ems_win_Tout_sensor.name} <= 30.0\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"SET #{ems_win_construct_actuator.name} = TCwindow_29\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"ELSEIF #{ems_win_Tout_sensor.name} <= 32.0\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"SET #{ems_win_construct_actuator.name} = TCwindow_31\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"ELSEIF #{ems_win_Tout_sensor.name} <= 34.0\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"SET #{ems_win_construct_actuator.name} = TCwindow_33\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"ELSEIF #{ems_win_Tout_sensor.name} <= 36.0\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"SET #{ems_win_construct_actuator.name} = TCwindow_35\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"ELSEIF #{ems_win_Tout_sensor.name} <= 38.0\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"SET #{ems_win_construct_actuator.name} = TCwindow_37\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"ELSEIF #{ems_win_Tout_sensor.name} <= 40.0\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"SET #{ems_win_construct_actuator.name} = TCwindow_39\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"ELSEIF #{ems_win_Tout_sensor.name} <= 42.0\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"SET #{ems_win_construct_actuator.name} = TCwindow_41\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"ELSEIF #{ems_win_Tout_sensor.name} <= 44.0\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"SET #{ems_win_construct_actuator.name} = TCwindow_43\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"ELSEIF #{ems_win_Tout_sensor.name} <= 47.5\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"SET #{ems_win_construct_actuator.name} = TCwindow_45\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"ELSEIF #{ems_win_Tout_sensor.name} <= 52.5\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"SET #{ems_win_construct_actuator.name} = TCwindow_50\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"ELSEIF #{ems_win_Tout_sensor.name} <= 57.5\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"SET #{ems_win_construct_actuator.name} = TCwindow_55\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"ELSEIF #{ems_win_Tout_sensor.name} <= 62.5\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"SET #{ems_win_construct_actuator.name} = TCwindow_60\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"ELSEIF #{ems_win_Tout_sensor.name} <= 67.5\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"SET #{ems_win_construct_actuator.name} = TCwindow_65\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"ELSEIF #{ems_win_Tout_sensor.name} <= 72.5\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"SET #{ems_win_construct_actuator.name} = TCwindow_70\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"ELSEIF #{ems_win_Tout_sensor.name} <= 77.5\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"SET #{ems_win_construct_actuator.name} = TCwindow_75\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"ELSEIF #{ems_win_Tout_sensor.name} <= 82.5\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"SET #{ems_win_construct_actuator.name} = TCwindow_80\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"ELSE\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"SET #{ems_win_construct_actuator.name} = TCwindow_85\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"ENDIF\")\n if verbose_info_statements == true\n runner.registerInfo(\"An EMS Program Object named '#{ems_apply_thermochromatic_constructions_prgm.name}' for dynamically assigning different window constructions based on the exterior surface temp was added to the model.\") \n end\n \n # Create a new EnergyManagementSystem:ProgramCallingManager object configured to call the EMS programs\n ems_prgm_calling_mngr = OpenStudio::Model::EnergyManagementSystemProgramCallingManager.new(model)\n ems_prgm_calling_mngr.setName(\"My thermochromic window emulator\")\n ems_prgm_calling_mngr.setCallingPoint(\"BeginTimestepBeforePredictor\")\n ems_prgm_calling_mngr.addProgram(ems_apply_thermochromatic_constructions_prgm)\n if verbose_info_statements == true\n runner.registerInfo(\"EMS Program Calling Manager object named '#{ems_prgm_calling_mngr.name}' added to call EMS program for dynamically applying a thermochromatic window.\") \n end\n \n # create unique object for OutputEnergyManagementSystems and configure to allow EMS reporting\n outputEMS = model.getOutputEnergyManagementSystem\n outputEMS.setInternalVariableAvailabilityDictionaryReporting(\"internal_variable_availability_dictionary_reporting\")\n outputEMS.setEMSRuntimeLanguageDebugOutputLevel(\"ems_runtime_language_debug_output_level\")\n outputEMS.setActuatorAvailabilityDictionaryReporting(\"actuator_availability_dictionary_reporting\")\n if verbose_info_statements == true\n runner.registerInfo(\"EMS OutputEnergyManagementSystem object configured per user arguments.\") \n end\n \n runner.registerFinalCondition(\"Measure finished with #{model.getEnergyManagementSystemSensors.count} EMS sensors, #{model.getEnergyManagementSystemActuators.count} EMS Actuators, #{model.getEnergyManagementSystemPrograms.count} EMS Programs, #{model.getEnergyManagementSystemSubroutines.count} EMS Subroutines, #{model.getEnergyManagementSystemProgramCallingManagers.count} EMS Program Calling Manager objects\")\n\n end", "def bench(action, msg = nil)\n @t ||= Time.now\n @total ||= 0\n @step ||= 0\n case action\n when :start\n @step = 0\n @total = 0\n @t = Time.now\n when :step\n @step += 1\n int = Time.now - @t\n @total += int\n @t = Time.now\n dbg(\"Benchmark #{msg.nil? ? (\"%02d\" % @step) : msg}: #{\"%8.3fms\" % (int * 1000)} (Total: #{\"%8.3fms\" % (@total * 1000)}).\")\n end\nend", "def apply_measure_and_run(test_name, measure, argument_map, osm_path, epw_path, run_model: false)\n assert(File.exist?(osm_path))\n assert(File.exist?(epw_path))\n\n # create run directory if it does not exist\n if !File.exist?(run_dir(test_name))\n FileUtils.mkdir_p(run_dir(test_name))\n end\n assert(File.exist?(run_dir(test_name)))\n\n # change into run directory for tests\n start_dir = Dir.pwd\n Dir.chdir run_dir(test_name)\n\n # remove prior runs if they exist\n if File.exist?(model_output_path(test_name))\n FileUtils.rm(model_output_path(test_name))\n end\n if File.exist?(report_path(test_name))\n FileUtils.rm(report_path(test_name))\n end\n\n # copy the osm and epw to the test directory\n new_osm_path = \"#{run_dir(test_name)}/#{File.basename(osm_path)}\"\n FileUtils.cp(osm_path, new_osm_path)\n new_epw_path = \"#{run_dir(test_name)}/#{File.basename(epw_path)}\"\n FileUtils.cp(epw_path, new_epw_path)\n # create an instance of a runner\n runner = OpenStudio::Measure::OSRunner.new(OpenStudio::WorkflowJSON.new)\n\n # load the test model\n model = load_model(new_osm_path)\n\n # set model weather file\n epw_file = OpenStudio::EpwFile.new(OpenStudio::Path.new(new_epw_path))\n OpenStudio::Model::WeatherFile.setWeatherFile(model, epw_file)\n assert(model.weatherFile.is_initialized)\n\n # run the measure\n puts \"\\nAPPLYING MEASURE...\"\n measure.run(model, runner, argument_map)\n result = runner.result\n\n # show the output\n show_output(result)\n\n # save model\n model.save(model_output_path(test_name), true)\n\n errs = []\n if run_model && (result.value.valueName == 'Success')\n puts \"\\nRUNNING ANNUAL SIMULATION...\"\n\n std = Standard.build('NREL ZNE Ready 2017')\n std.model_run_simulation_and_log_errors(model, run_dir(test_name))\n\n # check that the model ran successfully and generated a report\n assert(File.exist?(model_output_path(test_name)))\n assert(File.exist?(sql_path(test_name)))\n assert(File.exist?(report_path(test_name)))\n\n # set runner variables\n runner.setLastEpwFilePath(epw_path)\n runner.setLastOpenStudioModelPath(OpenStudio::Path.new(model_output_path(test_name)))\n runner.setLastEnergyPlusSqlFilePath(OpenStudio::Path.new(sql_path(test_name)))\n sql = runner.lastEnergyPlusSqlFile.get\n model.setSqlFile(sql)\n\n # test for unmet hours\n unmet_heating_hrs = std.model_annual_occupied_unmet_heating_hours(model)\n unmet_cooling_hrs = std.model_annual_occupied_unmet_cooling_hours(model)\n unmet_hrs = std.model_annual_occupied_unmet_hours(model)\n max_unmet_hrs = 550\n if unmet_hrs\n if unmet_hrs > 550\n errs << \"For #{test_name} there were #{unmet_heating_hrs.round(1)} unmet occupied heating hours and #{unmet_cooling_hrs.round(1)} unmet occupied cooling hours (total: #{unmet_hrs.round(1)}), more than the limit of #{max_unmet_hrs}.\" if unmet_hrs > max_unmet_hrs\n else\n puts \"There were #{unmet_heating_hrs.round(1)} unmet occupied heating hours and #{unmet_cooling_hrs.round(1)} unmet occupied cooling hours (total: #{unmet_hrs.round(1)}).\"\n end\n else\n errs << \"For #{test_name} could not determine unmet hours; simulation may have failed.\"\n end\n end\n\n # change back directory\n Dir.chdir(start_dir)\n\n assert(errs.empty?, errs.join(\"\\n\"))\n\n return result\n end", "def after_assumption(name); end", "def call\n result = while_measuring_memory_usage { action.call }\n\n Measurement.from_result(result)\n end", "def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n\n # use the built-in error checking\n if !runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n\n # assign the user inputs to variables\n retrofit_month = runner.getStringArgumentValue('retrofit_month', user_arguments).to_i\n retrofit_day = runner.getStringArgumentValue('retrofit_day', user_arguments).to_i\n\n # report initial condition of model\n runner.registerInitialCondition(\"Measure started successfully.\")\n\n # TODO: check the month and day for reasonableness\n runner.registerInfo(\"User entered retrofit month: #{retrofit_month}\")\n runner.registerInfo(\"User entered retrofit day: #{retrofit_day}\")\n\n prog_calling_manager = OpenStudio::Model::EnergyManagementSystemProgramCallingManager.new(model)\n prog_calling_manager.setCallingPoint('BeginTimestepBeforePredictor')\n\n # Remove old and add new equip with EMS by spaces\n hash_space_epd = Hash.new\n v_spaces = model.getSpaces\n v_spaces.each do |space|\n current_space_equip = space.electricEquipment[0]\n unless current_space_equip.nil?\n\n # Get equipment power density for each space type\n new_space_epd = runner.getOptionalDoubleArgumentValue(\"new_#{space.name.to_s}_epd\", user_arguments)\n if new_space_epd.is_initialized\n hash_space_epd[\"new_#{space.name.to_s}_epd\"] = new_space_epd\n runner.registerInfo(\"User entered new electric equipment power density for #{space.name.to_s} is #{new_space_epd} W/m2\")\n # Set ems\n current_space_equip_def = current_space_equip.electricEquipmentDefinition\n equip_sch_name = current_space_equip.schedule.get.nameString\n equip_sch_ems_sensor = OpenStudio::Model::EnergyManagementSystemSensor.new(model, 'Schedule Value')\n equip_sch_ems_sensor.setKeyName(equip_sch_name)\n runner.registerInfo(\"Delete old equip object for #{space.name}\")\n current_space_equip.remove\n\n new_equip = add_equip_space(space, current_space_equip_def)\n equip_level_w = new_space_epd.to_f * space.floorArea.to_f\n ems_equip_program = add_equip_ems(model, new_equip, equip_level_w, equip_sch_ems_sensor, retrofit_month, retrofit_day)\n prog_calling_manager.addProgram(ems_equip_program)\n runner.registerInfo(\"Add ems equipment control for #{space.name} succeeded.\")\n else\n # Get equipment power ratio for each space type\n new_space_ratio = runner.getDoubleArgumentValue(\"new_#{space.name.to_s}_ratio\", user_arguments)\n\n old_equip_sch = current_space_equip.schedule.get\n ems_equip_program = add_equip_ems_w_occ_var(model, current_space_equip, old_equip_sch, new_space_ratio, retrofit_month, retrofit_day)\n prog_calling_manager.addProgram(ems_equip_program)\n runner.registerInfo(\"Add ems equipment control for #{space.name} succeeded.\")\n # runner.registerInfo(\"Delete old equip object for #{space.name}\")\n # current_space_equip.remove\n end\n\n end\n end\n\n # Remove old and add new equip with EMS by space types\n hash_space_type_epd = Hash.new\n v_space_types = model.getSpaceTypes\n v_space_types.each do |space_type|\n current_spaces = space_type.spaces\n current_space_type_equip = space_type.electricEquipment[0]\n unless current_space_type_equip.nil?\n # Get equipment power density for each space type\n current_space_type_epd = runner.getStringArgumentValue(\"new_#{space_type.name.to_s}_epd\", user_arguments)\n hash_space_type_epd[\"new_#{space_type.name.to_s}_epd\"] = current_space_type_epd\n runner.registerInfo(\"User entered new electric equipment power density for #{space_type.name.to_s} is #{current_space_type_epd} W/m2\")\n\n # Set ems\n current_space_type_equip_def = current_space_type_equip.electricEquipmentDefinition\n current_space_type_sch_set = space_type.defaultScheduleSet.get\n current_space_type_equip_sch_set = current_space_type_sch_set.electricEquipmentSchedule.get\n\n equip_sch_name = current_space_type_equip_sch_set.nameString\n equip_sch_ems_sensor = OpenStudio::Model::EnergyManagementSystemSensor.new(model, 'Schedule Value')\n equip_sch_ems_sensor.setKeyName(equip_sch_name)\n\n puts \"Delete old equip object for #{space_type.name}\"\n current_space_type_equip.remove\n\n current_spaces.each do |space|\n # Calculate equipemtn electric power for each space\n new_equip = add_equip_space_type(model, space, space_type, current_space_type_equip_def)\n equip_level_w = current_space_type_epd.to_f * space.floorArea.to_f\n ems_equip_program = add_equip_ems(model, new_equip, equip_level_w, equip_sch_ems_sensor, retrofit_month, retrofit_day)\n prog_calling_manager.addProgram(ems_equip_program)\n runner.registerInfo(\"Add ems equipment control for #{space.name} succeeded.\")\n end\n end\n end\n\n # echo the model updates back to the user\n runner.registerInfo(\"The electric equipment retrofit measure is applied.\")\n\n # report final condition of model\n runner.registerFinalCondition(\"Measure ended successfully.\")\n\n return true\n end", "def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n\n # use the built-in error checking\n if !runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n\n runner.registerInfo(\"Start to create lighting measure from occupant schedule\")\n\n ### Get user selected lighting space assumptions for each space\n v_space_types = model.getSpaceTypes\n i = 1\n lght_space_type_arg_vals = {}\n # Loop through all space types, group spaces by their types\n v_space_types.each do |space_type|\n # Loop through all spaces of current space type\n v_current_spaces = space_type.spaces\n next if not v_current_spaces.size > 0\n v_current_spaces.each do |current_space|\n lght_space_type_val = runner.getStringArgumentValue(@@v_space_args[current_space.nameString], user_arguments)\n lght_space_type_arg_vals[current_space.nameString] = lght_space_type_val\n i += 1\n end\n end\n\n puts lght_space_type_arg_vals\n\n ### Start creating new lighting schedules based on occupancy schedule\n occ_schedule_dir = runner.getStringArgumentValue('occ_schedule_dir', user_arguments)\n model_temp_run_path = Dir.pwd + '/'\n measure_root_path = File.dirname(__FILE__)\n\n puts '=' * 80\n puts measure_root_path\n\n if File.file?(occ_schedule_dir)\n # Check if user provided a occupancy schedule CSV file\n csv_file = occ_schedule_dir\n puts 'Use user provided occupancy schedule file at: ' + csv_file.to_s\n runner.registerInitialCondition('Location check:' + File.expand_path(\"../..\", measure_root_path))\n # runner.registerInitialCondition('Use user provided occupancy schedule file at: ' + csv_file.to_s)\n else\n # Check if schedule file at several places\n # 1. Default fils path when run with OSW in CLI\n csv_path_lookup_1 = File.expand_path(\"../..\", measure_root_path) + \"/files/#{@@default_occupant_schedule_filename}\"\n puts '#' * 80\n puts \"First lookup location: \" + csv_path_lookup_1\n runner.registerInfo(\"First lookup location: \" + csv_path_lookup_1)\n # 2. Default path when run with OpenStudio CLI\n csv_path_lookup_2 = File.expand_path(\"../..\", model_temp_run_path) + \"/files/#{@@default_occupant_schedule_filename}\"\n puts '#' * 80\n puts \"Second lookup location: \" + csv_path_lookup_2\n runner.registerInfo(\"Second lookup location: \" + csv_path_lookup_2)\n # 3. Default path when run with OpenStudio GUI\n csv_path_lookup_3 = File.expand_path(\"../../..\", model_temp_run_path) + \"/resources/files/#{@@default_occupant_schedule_filename}\"\n puts '#' * 80\n puts \"Third lookup location: \" + csv_path_lookup_3\n runner.registerInfo(\"Third lookup location: \" + csv_path_lookup_3)\n # 4. Generated files folder when run with rspec\n csv_path_lookup_4 = File.expand_path(\"..\", model_temp_run_path) + \"/generated_files/#{@@default_occupant_schedule_filename}\"\n puts '#' * 80\n puts \"Forth lookup location: \" + csv_path_lookup_4\n runner.registerInfo(\"Forth lookup location: \" + csv_path_lookup_4)\n # 5. Generated files folder with OpenStudio V2.9.0+\n csv_path_lookup_5 = File.join(File.expand_path(\"../..\", model_temp_run_path), 'generated_files', @@default_occupant_schedule_filename)\n puts '#' * 80\n puts \"Fifth lookup location: \" + csv_path_lookup_5\n runner.registerInfo(\"Fifth lookup location: \" + csv_path_lookup_5)\n\n if File.file?(csv_path_lookup_1)\n csv_file = csv_path_lookup_1\n elsif File.file?(csv_path_lookup_2)\n csv_file = csv_path_lookup_2\n elsif File.file?(csv_path_lookup_3)\n csv_file = csv_path_lookup_3\n elsif File.file?(csv_path_lookup_4)\n csv_file = csv_path_lookup_4 \n elsif File.file?(csv_path_lookup_5)\n csv_file = csv_path_lookup_5\n else\n csv_file = ''\n end\n puts 'Use default occupancy schedule file at: ' + csv_file.to_s\n runner.registerInfo('Use default occupancy schedule file at: ' + csv_file.to_s)\n end\n\n # Get the spaces with occupancy count schedule available\n v_spaces_occ_sch = File.readlines(csv_file)[3].split(',') # Room ID is saved in 4th row of the occ_sch file\n v_headers = Array.new\n v_spaces_occ_sch.each do |space_occ_sch|\n if !['Room ID', 'Outdoor', 'Outside building'].include? space_occ_sch and !space_occ_sch.strip.empty?\n v_headers << space_occ_sch\n end\n end\n v_headers = [\"Time\"] + v_headers\n\n # report initial condition of model\n runner.registerInfo(\"The building has #{v_headers.length - 1} spaces with available occupant schedule file.\")\n\n # Read the occupant count schedule file and clean it\n clean_csv = File.readlines(csv_file).drop(6).join\n csv_table_sch = CSV.parse(clean_csv, headers: true)\n new_csv_table = csv_table_sch.by_col!.delete_if do |column_name, column_values|\n !v_headers.include? column_name\n end\n\n runner.registerInfo(\"Successfully read occupant count schedule from CSV file.\")\n runner.registerInfo(\"Creating new lighting schedules...\")\n\n # Create lighting schedule based on the occupant count schedule\n v_cols = Array.new\n v_ts = new_csv_table.by_col!['Time']\n v_headers.each do |header|\n if header != 'Time'\n space_name = header\n v_occ_n = new_csv_table.by_col![space_name]\n v_light = create_lighting_sch_from_occupancy_count(space_name, v_ts, v_occ_n, @@off_delay)\n v_cols << v_light\n end\n end\n\n runner.registerInfo(\"Writing new lighting schedules to CSV file.\")\n # Write new lighting schedule file to CSV\n file_name_light_sch = \"#{model_temp_run_path}/#{@@lighting_schedule_CSV_name}\"\n vcols_to_csv(v_cols, file_name_light_sch)\n\n # Add new lighting schedule from the CSV file created\n runner.registerInfo(\"Removing old OS:Lights and OS:Lights:Definition for office and conference rooms.\")\n # Remove old lights definition objects for office and conference rooms\n v_space_types.each do |space_type|\n space_type.spaces.each do |space|\n selected_space_type = lght_space_type_arg_vals[space.name.to_s]\n if (@@office_type_names.include? selected_space_type) || (@@conference_room_type_names.include? selected_space_type)\n space_type.lights.each do |lght|\n puts 'Remove old lights definition object: ' + lght.lightsDefinition.name.to_s\n lght.lightsDefinition.remove\n end\n end\n end\n end\n\n # Remove old lights objects for office and conference rooms\n # Caution: the order of deletion matters\n v_space_types.each do |space_type|\n space_type.spaces.each do |space|\n selected_space_type = lght_space_type_arg_vals[space.name.to_s]\n if (@@office_type_names.include? selected_space_type) || (@@conference_room_type_names.include? selected_space_type)\n space_type.lights.each do |lght|\n puts 'Remove old lights object: ' + lght.name.to_s\n lght.remove\n end\n end\n end\n end\n\n puts '---> Create new lighting schedules from CSV.'\n\n runner.registerInfo(\"Adding new OS:Schedule:File objects to the model....\")\n v_spaces = model.getSpaces\n v_spaces.each do |space|\n v_headers.each_with_index do |s_space_name, i|\n if s_space_name == space.name.to_s\n col = i\n temp_file_path = file_name_light_sch\n sch_file_name = space.name.to_s + ' lght sch'\n schedule_file = get_os_schedule_from_csv(model, temp_file_path, sch_file_name, col, skip_row = 1)\n schedule_file.setMinutesperItem(@@minute_per_item.to_s)\n model = add_light(model, space, schedule_file)\n end\n end\n end\n\n # report final condition of model\n runner.registerFinalCondition(\"Finished creating and adding new lighting schedules for #{v_headers.length - 1} spaces.\")\n\n return true\n end", "def span\n measure\n @span\n end", "def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n \n #use the built-in error checking \n if not runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n\n # System Type 2: PTHP, Residential\n # This measure creates:\n # a constant volume packaged terminal heat pump unit with DX heating \n # and cooling for each zone in the building\n \n always_on = model.alwaysOnDiscreteSchedule\n\n # Make a PTHP for each zone\n model.getThermalZones.each do |zone|\n \n fan = OpenStudio::Model::FanConstantVolume.new(model,always_on)\n fan.setPressureRise(300)\n\n supplemental_htg_coil = OpenStudio::Model::CoilHeatingElectric.new(model,always_on)\n\n clg_cap_f_of_temp = OpenStudio::Model::CurveBiquadratic.new(model)\n clg_cap_f_of_temp.setCoefficient1Constant(0.942587793)\n clg_cap_f_of_temp.setCoefficient2x(0.009543347)\n clg_cap_f_of_temp.setCoefficient3xPOW2(0.0018423)\n clg_cap_f_of_temp.setCoefficient4y(-0.011042676)\n clg_cap_f_of_temp.setCoefficient5yPOW2(0.000005249)\n clg_cap_f_of_temp.setCoefficient6xTIMESY(-0.000009720)\n clg_cap_f_of_temp.setMinimumValueofx(17.0)\n clg_cap_f_of_temp.setMaximumValueofx(22.0)\n clg_cap_f_of_temp.setMinimumValueofy(13.0)\n clg_cap_f_of_temp.setMaximumValueofy(46.0)\n\n clg_cap_f_of_flow = OpenStudio::Model::CurveQuadratic.new(model)\n clg_cap_f_of_flow.setCoefficient1Constant(0.718954)\n clg_cap_f_of_flow.setCoefficient2x(0.435436)\n clg_cap_f_of_flow.setCoefficient3xPOW2(-0.154193)\n clg_cap_f_of_flow.setMinimumValueofx(0.75)\n clg_cap_f_of_flow.setMaximumValueofx(1.25)\n\n clg_energy_input_ratio_f_of_temp = OpenStudio::Model::CurveBiquadratic.new(model)\n clg_energy_input_ratio_f_of_temp.setCoefficient1Constant(0.342414409)\n clg_energy_input_ratio_f_of_temp.setCoefficient2x(0.034885008)\n clg_energy_input_ratio_f_of_temp.setCoefficient3xPOW2(-0.000623700)\n clg_energy_input_ratio_f_of_temp.setCoefficient4y(0.004977216)\n clg_energy_input_ratio_f_of_temp.setCoefficient5yPOW2(0.000437951)\n clg_energy_input_ratio_f_of_temp.setCoefficient6xTIMESY(-0.000728028)\n clg_energy_input_ratio_f_of_temp.setMinimumValueofx(17.0)\n clg_energy_input_ratio_f_of_temp.setMaximumValueofx(22.0)\n clg_energy_input_ratio_f_of_temp.setMinimumValueofy(13.0)\n clg_energy_input_ratio_f_of_temp.setMaximumValueofy(46.0)\n\n clg_energy_input_ratio_f_of_flow = OpenStudio::Model::CurveQuadratic.new(model)\n clg_energy_input_ratio_f_of_flow.setCoefficient1Constant(1.1552)\n clg_energy_input_ratio_f_of_flow.setCoefficient2x(-0.1808)\n clg_energy_input_ratio_f_of_flow.setCoefficient3xPOW2(0.0256)\n clg_energy_input_ratio_f_of_flow.setMinimumValueofx(0.5)\n clg_energy_input_ratio_f_of_flow.setMaximumValueofx(1.5)\n\n clg_part_load_fraction = OpenStudio::Model::CurveQuadratic.new(model)\n clg_part_load_fraction.setCoefficient1Constant(0.75)\n clg_part_load_fraction.setCoefficient2x(0.25)\n clg_part_load_fraction.setCoefficient3xPOW2(0.0)\n clg_part_load_fraction.setMinimumValueofx(0.0)\n clg_part_load_fraction.setMaximumValueofx(1.0)\n\n clg_coil = OpenStudio::Model::CoilCoolingDXSingleSpeed.new(model,\n always_on,\n clg_cap_f_of_temp,\n clg_cap_f_of_flow,\n clg_energy_input_ratio_f_of_temp,\n clg_energy_input_ratio_f_of_flow,\n clg_part_load_fraction)\n\n htg_cap_f_of_temp = OpenStudio::Model::CurveCubic.new(model)\n htg_cap_f_of_temp.setCoefficient1Constant(0.758746)\n htg_cap_f_of_temp.setCoefficient2x(0.027626)\n htg_cap_f_of_temp.setCoefficient3xPOW2(0.000148716)\n htg_cap_f_of_temp.setCoefficient4xPOW3(0.0000034992)\n htg_cap_f_of_temp.setMinimumValueofx(-20.0)\n htg_cap_f_of_temp.setMaximumValueofx(20.0)\n\n htg_cap_f_of_flow = OpenStudio::Model::CurveCubic.new(model)\n htg_cap_f_of_flow.setCoefficient1Constant(0.84)\n htg_cap_f_of_flow.setCoefficient2x(0.16)\n htg_cap_f_of_flow.setCoefficient3xPOW2(0.0)\n htg_cap_f_of_flow.setCoefficient4xPOW3(0.0)\n htg_cap_f_of_flow.setMinimumValueofx(0.5)\n htg_cap_f_of_flow.setMaximumValueofx(1.5)\n\n htg_energy_input_ratio_f_of_temp = OpenStudio::Model::CurveCubic.new(model)\n htg_energy_input_ratio_f_of_temp.setCoefficient1Constant(1.19248)\n htg_energy_input_ratio_f_of_temp.setCoefficient2x(-0.0300438)\n htg_energy_input_ratio_f_of_temp.setCoefficient3xPOW2(0.00103745)\n htg_energy_input_ratio_f_of_temp.setCoefficient4xPOW3(-0.000023328)\n htg_energy_input_ratio_f_of_temp.setMinimumValueofx(-20.0)\n htg_energy_input_ratio_f_of_temp.setMaximumValueofx(20.0)\n\n htg_energy_input_ratio_f_of_flow = OpenStudio::Model::CurveQuadratic.new(model)\n htg_energy_input_ratio_f_of_flow.setCoefficient1Constant(1.3824)\n htg_energy_input_ratio_f_of_flow.setCoefficient2x(-0.4336)\n htg_energy_input_ratio_f_of_flow.setCoefficient3xPOW2(0.0512)\n htg_energy_input_ratio_f_of_flow.setMinimumValueofx(0.0)\n htg_energy_input_ratio_f_of_flow.setMaximumValueofx(1.0)\n\n htg_part_load_fraction = OpenStudio::Model::CurveQuadratic.new(model)\n htg_part_load_fraction.setCoefficient1Constant(0.75)\n htg_part_load_fraction.setCoefficient2x(0.25)\n htg_part_load_fraction.setCoefficient3xPOW2(0.0)\n htg_part_load_fraction.setMinimumValueofx(0.0)\n htg_part_load_fraction.setMaximumValueofx(1.0)\n\n htg_coil = OpenStudio::Model::CoilHeatingDXSingleSpeed.new( model,\n always_on,\n htg_cap_f_of_temp,\n htg_cap_f_of_flow,\n htg_energy_input_ratio_f_of_temp,\n htg_energy_input_ratio_f_of_flow,\n htg_part_load_fraction ) \n\n pthp = OpenStudio::Model::ZoneHVACPackagedTerminalHeatPump.new(model,\n always_on, \n fan,\n htg_coil,\n clg_coil,\n supplemental_htg_coil)\n\n pthp.setName(\"#{zone.name} PTHP\")\n pthp.addToThermalZone(zone)\n\n end\n\n \n return true\n \n end" ]
[ "0.79848564", "0.7639647", "0.76355976", "0.7170129", "0.66926914", "0.66926914", "0.66718984", "0.66311747", "0.6599127", "0.65870225", "0.65324444", "0.6481582", "0.6405596", "0.64028287", "0.6333309", "0.6283632", "0.6283632", "0.6283632", "0.6281165", "0.6269874", "0.62425435", "0.62203735", "0.6198304", "0.6196627", "0.6196627", "0.61319697", "0.6107745", "0.60714525", "0.60513526", "0.601827", "0.6008391", "0.6008391", "0.60008335", "0.5976995", "0.59641606", "0.5962238", "0.5958165", "0.59570605", "0.59570605", "0.59439784", "0.5934565", "0.5928137", "0.5920926", "0.5916211", "0.59129107", "0.5911706", "0.59022516", "0.5872101", "0.5865909", "0.58645797", "0.5847354", "0.583844", "0.58373237", "0.57887447", "0.5772885", "0.57687855", "0.5756301", "0.5745138", "0.5740855", "0.5723286", "0.57180965", "0.5713821", "0.5698708", "0.5697907", "0.56978434", "0.56891346", "0.5688938", "0.5685465", "0.56740844", "0.5662743", "0.5649326", "0.56483626", "0.5646554", "0.56390476", "0.56390476", "0.5633756", "0.56218606", "0.56218606", "0.5608723", "0.5608213", "0.55982304", "0.55982304", "0.55982304", "0.55982304", "0.55982304", "0.55982304", "0.55982304", "0.55982304", "0.55982304", "0.559522", "0.559522", "0.559522", "0.55878526", "0.558349", "0.55677843", "0.5567233", "0.5564496", "0.55636495", "0.55590993", "0.5556679", "0.5547891" ]
0.0
-1
used in edit meal view to display ingredient macros in table
def foods_converted foods_result = [] self.foods.each do |food| food_macros_serving = Hash.new serving_size = (food.serving_size / 100.0) food_macros_serving["name"] = self.name food_macros_serving["kcal"] = (serving_size * food.kcal).round food_macros_serving["protein"] = (serving_size * food.protein).round food_macros_serving["carbs"] = (serving_size * food.carbs).round food_macros_serving["fats"] = (serving_size * food.fats).round food_macros_serving["vegan"] = food.vegan food_macros_serving["vegetarian"] = food.vegetarian food_macros_serving["nut_free"] = food.nut_free food_macros_serving["gluten_free"] = food.gluten_free food_macros_serving["soy_free"] = food.soy_free foods_result.push(food_macros_serving) end return foods_result end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n @ingredients = Ingredient.all\n end", "def show\n @ingredient_recettes = @ingredient.recettes\n end", "def ingredient_name\n return ingredient.name\n end", "def show\n @recipe_ingredient_group = RecipeIngredientGroup.new\n @recipe_ingredients = @recipe.recipe_ingredients\n @recipe_ingredient_groups = @recipe.recipe_ingredient_groups\n \n @recipe_ingredient = RecipeIngredient.new\n @ingredient = Ingredient.new\n \n end", "def inline_ingredients\n ingredients.to_a.map(&:name).join(' ')\n end", "def show\n @ingredients = @recipe.ingredients\n @masterpieces = @recipe.masterpieces\n end", "def show\n \n rec_id = params[:id].to_i\n recipe = Recipe.find(rec_id)\n # find user name for recipe\n \n username = recipe.user.username;\n\n # get all ingredients from step ingredients ?\n ingredients = []\n\n recipe_steps = recipe.recipe_steps\n # one to one step ingredients to ingredients when coming from recipe-steps\n \n # recipe ingredients\n \n \n \n step_ingredients = recipe_steps.map{ |rs| \n { \n step_num: rs.step_num,\n step_image: rs.image,\n instruction: rs.instruction,\n step_ingredients: rs.step_ingredients.map{ |si| \n {amount: si.amount, ingredient: {name: si.ingredient.name} }\n } \n \n }\n \n }\n\n \n step_ingredients.each do |si|\n # byebug \n ings = si[:step_ingredients]\n ings.each do |ing|\n if ing[:amount] \n ing_total = ing[:amount] + \" \" + ing[:ingredient][:name] \n if !ingredients.include?(ing_total)\n ingredients.push(ing_total) \n end\n else\n ing_total = ing[:ingredient][:name] \n if !ingredients.include?(ing_total)\n ingredients.push(ing_total) \n end\n end\n end\n end\n \n # fix time to string\n \n render json: {username: username, recipe: recipe, ingredients: ingredients, recipe_steps: step_ingredients }, status: :accepted\n end", "def custom_regimen_ingredients\n arv_extras_concepts = Concept.joins(:concept_names).where(\n concept_name: { name: ['INH', 'CPT', 'Pyridoxine', 'Rifapentine', 'INH / RFP'] }\n )\n Drug.where(concept: arv_extras_concepts) + Drug.arv_drugs.order(name: :desc)\n end", "def ingredient\n if self.respond_to?(ingredient_column)\n self.send(ingredient_column)\n end\n end", "def shopping_list\n self.ingredients.select do |ingred_calor|\n ingred_calor.name\n\n\n binding.pry \n end\n\nend", "def show\n recipe_ingredients = RecipeIngredient.where(recipe_id: @recipe[:id])\n recipe_ingredient_ids = recipe_ingredients.pluck(:ingredient_id)\n @recipe_ingredients = recipe_ingredients.group_by(&:ingredient_id)\n @ingredients_like_ids = []\n fridge_items = FridgeItem.all\n fridge_items.each do |fi|\n @ingredients_like_ids << find_ingredients_like(fi.ingredient_id)\n end\n @ingredients_like_ids.flatten!\n @ingredients = Ingredient.find(recipe_ingredient_ids)\n @fridge_item_ids = []\n @ingredients.each do |ingredient|\n if @ingredients_like_ids.include?(ingredient.id)\n @fridge_item_ids << ingredient.id\n end\n end\n @fridge_item = FridgeItem.new\n end", "def insert_table(ingredients)\n @ingredients = ingredients\n rows = [ingredients].transpose\n table = Terminal::Table.new headings: %w(Ingredients), rows: rows\n puts Paint[table, :red]\n end", "def show\n @meal = @meal_recipe.meal\n @meal_plan = @meal.day.meal_plan\n @leftover = Leftover.meal_recipe(@meal_recipe).first\n @meal_ingredient = MealIngredient.new\n end", "def edit_ingredients\n @prompt.select(\"Do you want to add or delete ingredients?\") do |menu|\n menu.choice \"Add ingredient(s)\", -> {add_ingredients}\n menu.choice \"Delete ingredient(s)\", -> {delete_ingredients}\n menu.choice \"Back to menu\", -> {nav_menu}\n end\n end", "def index\n @ingredientes = Ingrediente.all\n end", "def index\n @ingredientes = Ingrediente.all\n end", "def edit_form\n\t\titem_text = question_items.first.text #in_place_editor_field :question_cell, :items, {}, :rows => 3\n\t\tdiv_item(item_text, \"iteminformation\")\n\tend", "def show \n\n # @recipe.ingredients.build\n @new_ingredient = Ingredient.new\n @new_ingredient.recipe = @recipe\n\n # @flag = @recipe.flags.create\n\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @recipe }\n end\n end", "def print_needed_ingredients\n puts \"\\n\\n\\s\\e[4m#{self.name} Recipe\\e[0m\"\n self.ingredients.each { |ingredient| puts \"\\s- #{ingredient.name}: #{RecipeIngredient.find_by(recipe_id: self.id, ingredient_id: ingredient.id).amount} cl\" }\n if self.recipe_specials.collect{|x| x.special if x.special}.uniq != [nil]\n self.recipe_specials.collect{|x| x.special if x.special}.uniq.each{|y| puts \"\\s- Special: #{y}\"}\n elsif self.recipe_specials.collect{|x| x.garnish if x.garnish}.uniq != [nil]\n puts \"\\s- Garnish: #{self.recipe_specials.collect{|x| x.garnish if x.garnish}.uniq[0]}\"\n end\n puts \"\\s- Preparation: #{self.preparation}\"\n end", "def recipe_ingredients(recipe_id)\n recipe_status_helper(recipe_id)\n @recipe_ingredient_arr = recipe_ingredient.split(\", \")\n puts \" \"\n p user.recipes.where(id: recipe_id)[0].ingredient\n prompt.select(\"Options\") do |menu|\n puts \" \"\n menu.choice \"Choose New Protein\", -> {choose_protein}\n menu.choice \"Update Recipe Rating\", -> {update_recipe_rating(recipe_id)}\n menu.choice \"Add Ingredient\", -> {ingredient_add_helper(recipe_id)}\n menu.choice \"Remove Ingredient\", -> {ingredient_remove_helper(recipe_id)}\n menu.choice \"Exit\", -> {exit_helper}\n end\n end", "def load_comp_cell_aliquots\n show do\n title \"Load competent cell aliquots with 50µl Digested Plasmid, Full Plasmid, or Fragment\"\n \n operations.each do |op|\n if op.input(\"Genetic Material\").object_type.name == \"Plasmid Stock\"\n check \"Make a dilution of 1 µl stock and 49 µl water for aliquot #{op.input(\"Parent\").item.id}\"\n end\n end\n \n table operations.start_table\n .input_item(\"Genetic Material\", heading: \"Plasmid/Fragment ID\")\n .input_item(\"Parent\", heading: \"Yeast Competent Aliquot\", checkable: true)\n .custom_column(heading: \"Dilution\") { |op| op.input(\"Genetic Material\").object_type.name == \"Plasmid Stock\" ? \"Y\" : \"N\"}\n .end_table\n end\n end", "def index\n @measured_ingredients = MeasuredIngredient.all\n end", "def index\n @recipe_ingredients_units = RecipeIngredientsUnit.all\n end", "def set_ingredient\n @ingredient = Ingredient.find(params[:id])\n end", "def show\n @ingredient = Ingredient.find(params[:id])\n @page_title = \"#{@ingredeint.name}\"\n end", "def ingredient(name)\n content = content_by_name(name)\n return nil if content.blank?\n content.ingredient\n end", "def ingredient(name)\n content = content_by_name(name)\n return nil if content.blank?\n content.ingredient\n end", "def recipe_ingredients\n RecipeIngredient.all.select { |ri| ri.ingredient.name == @ing }\n end", "def edit\n\t\t@heating_choices = [ [\"Gas\", \"Gas\"], [\"Electric\", \"Electric\"], [\"Geothermal\", \"Geothermal\"], [\"Other\", \"Other\"]]\n\t\t@cooling_choices = [ [\"Central Air\", \"Central Air\"], [\"Geothermal\", \"Geothermal\"], [\"None\", \"None\"], [\"Other\", \"Other\"]]\n\t\t@property_types = [ [\"Single Family\", \"Single Family\"], [\"Condo\", \"Condo\"], [\"Multi Family\", \"Multi Family\"], [\"Vacant Land\", \"Vacant Land\"], [\"Mobile Home\", \"Mobile Home\"] ]\n\t\t@basement_types = [ [\"Finished\", \"Finished\"], [\"Partially Finished\", \"Partially Finished\"], [\"Unfinished\", \"Unfinished\"], [\"Other\", \"Other\"], [\"None\", \"None\"]]\n\n\t\t@bathroom_col = (1..10).step(0.25)\n\t\t@states = [\n\t [ \"Alabama\", \"AL\" ],\n\t [ \"Alaska\", \"AK\" ],\n\t [ \"Arizona\", \"AZ\" ],\n\t [ \"Arkansas\", \"AR\" ],\n\t [ \"California\", \"CA\" ],\n\t [ \"Colorado\", \"CO\" ],\n\t [ \"Connecticut\", \"CT\" ],\n\t [ \"Delaware\", \"DE\" ],\n\t [ \"Florida\", \"FL\" ],\n\t [ \"Georgia\", \"GA\" ],\n\t [ \"Hawaii\", \"HI\" ],\n\t [ \"Idaho\", \"ID\" ],\n\t [ \"Illinois\", \"IL\" ],\n\t [ \"Indiana\", \"IN\" ],\n\t [ \"Iowa\", \"IA\" ],\n\t [ \"Kansas\", \"KS\" ],\n\t [ \"Kentucky\", \"KY\" ],\n\t [ \"Louisiana\", \"LA\" ],\n\t [ \"Maine\", \"ME\" ],\n\t [ \"Maryland\", \"MD\" ],\n\t [ \"Massachusetts\", \"MA\" ],\n\t [ \"Michigan\", \"MI\" ],\n\t [ \"Minnesota\", \"MN\" ],\n\t [ \"Mississippi\", \"MS\" ],\n\t [ \"Missouri\", \"MO\" ],\n\t [ \"Montana\", \"MT\" ],\n\t [ \"Nebraska\", \"NE\" ],\n\t [ \"Nevada\", \"NV\" ],\n\t [ \"New Hampshire\", \"NH\" ],\n\t [ \"New Jersey\", \"NJ\" ],\n\t [ \"New Mexico\", \"NM\" ],\n\t [ \"New York\", \"NY\" ],\n\t [ \"North Carolina\", \"NC\" ],\n\t [ \"North Dakota\", \"ND\" ],\n\t [ \"Ohio\", \"OH\" ],\n\t [ \"Oklahoma\", \"OK\" ],\n\t [ \"Oregon\", \"OR\" ],\n\t [ \"Pennsylvania\", \"PA\" ],\n\t [ \"Rhode Island\", \"RI\" ],\n\t [ \"South Carolina\", \"SC\" ],\n\t [ \"South Dakota\", \"SD\" ],\n\t [ \"Tennessee\", \"TN\" ],\n\t [ \"Texas\", \"TX\" ],\n\t [ \"Utah\", \"UT\" ],\n\t [ \"Vermont\", \"VT\" ],\n\t [ \"Virginia\", \"VA\" ],\n\t [ \"Washington\", \"WA\" ],\n\t [ \"West Virginia\", \"WV\" ],\n\t [ \"Wisconsin\", \"WI\" ],\n\t [ \"Wyoming\", \"WY\" ]\n\t ].freeze\n\t \n\n\t\t@listing = Listing.find(params[:id])\n\t\t9.times { @listing.images.build }\n\tend", "def ingredient_setter_method\n ingredient_column.to_s + '='\n end", "def set_ingredient\n @ingredient = Ingredient.find(params[:id])\n @ingredient_item = Item.find(@ingredient.item_id)\n end", "def index\n @ingredients = Ingredient.all\n end", "def index\n @ingredients = Ingredient.all\n end", "def edit\n #@genres = Genre.all.map { |c| [c.name, c.id] }\n end", "def show\n puts \"sanjanaaaaaaaa\"\n\n @ingredientArray=Array.new\n @amountArray=Array.new\n @unitArray=Array.new\n @comment = Comment.new(recipe_id: @recipe.id, user_id: current_user.id) if user_signed_in?\n @ingredientrecipe = IngredientRecipe.all.select(\"ingredient_id\").where(\"recipe_id = #{@recipe.id}\")\n @ingredientrecipe.each do |ind|\n @ingredientArray.push(ind.ingredient_id)\n @amountArray.push(ind.amount.to_s)\n puts ind.ingredient_id\n puts ind.amount\n puts ind.measurement_unit\n\n @unitArray.push(ind.measurement_unit)\n end\n puts \"heyyyyyyyyyyyyy\"\n puts @amountArray\n \n @ingredients = Ingredient.all.where(\"id in (:ingredArray)\", ingredArray: @ingredientArray)\n @ingredients.each do |ind|\n puts ind.name\n end\n end", "def edit\n @page_title = \"Edit Ingredeient\"\n @ingredient = Ingredient.find(params[:id])\n @btnText = \"Update Ingredient\"\n @obj = @ingredient\n render 'shared/form'\n end", "def index\n @ingredient_suggestions = IngredientSuggestion.all.order('item ASC')\n @ingredients = @ingredient_suggestions.select(:id, :item)\n end", "def set_ingredient\n @ingredient = Ingredient.find(params[:id])\n end", "def set_ingredient\n @ingredient = Ingredient.find(params[:id])\n end", "def ingredients\n recipe_ingredients.map {|recipe_ingredient| recipe_ingredient.ing}\n end", "def ingredients\n # self.recipe_ingredients\n recipe_ingredients.map do |r_i|\n r_i.ingredient\n end\n end", "def index\n @ingredient_lists = IngredientList.all\n end", "def index\n @recipeingredients = Recipeingredient.all\n end", "def ingredients\n self.dessert_ingredients.map {|di| di.ingredient}\n end", "def show\n if params[:edit_ingredient]\n @ingredient = Ingredient.find(params[:edit_ingredient])\n else\n @ingredient = Ingredient.new\n end\n @country_consumption_name = @recipe.country_consumption.name\n respond_to_format\n end", "def index\n @ingredient_recipes = IngredientRecipe.all\n end", "def index\n @page_title = \"All Ingredeients\"\n @ingredients = Ingredient.all\n end", "def ingredients\n RecipeIngrediant.all.select do |recing|\n recing.recipe == self\n end\n #map to ing\n\n end", "def ingredient\n return nil if essence.nil?\n essence.ingredient\n end", "def preview_ingredient\n @_preview_ingredient ||= ingredients.detect(&:preview_ingredient?) || first_ingredient_by_definition\n end", "def label_and_rehydrate\n show do\n title \"Label and rehydrate\"\n\n check \"Label each fragment tube with the ids shown in the Fragment Stock item ids column.\"\n check \"Rehydrate each fragment with the volume of TE shown in the Rehydrate column.\"\n\n table operations.start_table\n .input_sample(INPUT)\n .custom_column(heading: 'Names of inputs') {|op| op.input(\"Lyophilized Fragment\").sample.name}\n .output_item(STOCK)\n .custom_column(heading: \"Rehydrate (uL of TE)\", checkable: true) {|op| op.temporary[:water_vol]}\n .end_table\n end\n end", "def ingredients_helper\n RecipeIngredient.all.select {|instance| instance.recipe == self}\n end", "def index\n @recipe_ingredients = RecipeIngredient.all\n end", "def form_field_name(essence_column = self.essence.ingredient_column)\n \"contents[content_#{self.id}][#{essence_column}]\"\n end", "def parse_ingredients ingredient_line, recipe \n Rails.logger.debug \"== Blender::parse_ingredients\"\n \n # Removes hifen \"-\"\n ingredient_line.gsub!(\"-\",\"\") \n # Removes Complementary Words\n ingredient_line.gsub!(/\\b(#{STOP_WORDS.join('|')})\\b/mi, ' ')\n \n # Given a ingredient line, extracts the: measure, quantity, ingredient name\n measure, quantity, ingredient = get_measure_quantity_and_ingredient ingredient_line.downcase\n \n Rails.logger.debug \"* Extracted Ingredient: Quant:(#{quantity}) Meas:(#{measure}) Name:(#{ingredient})\"\n \n add_ingredient_to_recipe quantity, measure, ingredient, recipe \n # Returns true if could understand and extract the measure and quantity\n return !measure.nil? && !quantity.nil?\n end", "def index\n @diet_ingredient_types = DietIngredientType.all\n end", "def ingredient_names\n self.ingredients.map do |ing|\n ing.name\n end\n end", "def set_ingredient\n @ingredient = Ingredient.find(params[:id])\n end", "def set_ingredient\n @ingredient = Ingredient.find(params[:id])\n end", "def set_ingredient\n @ingredient = Ingredient.find(params[:id])\n end", "def set_ingredient\n @ingredient = Ingredient.find(params[:id])\n end", "def set_ingredient\n @ingredient = Ingredient.find(params[:id])\n end", "def set_ingredient\n @ingredient = Ingredient.find(params[:id])\n end", "def set_ingredient\n @ingredient = Ingredient.find(params[:id])\n end", "def set_ingredient\n @ingredient = Ingredient.find(params[:id])\n end", "def set_ingredient\n @ingredient = Ingredient.find(params[:id])\n end", "def set_ingredient\n @ingredient = Ingredient.find(params[:id])\n end", "def set_ingredient\n @ingredient = Ingredient.find(params[:id])\n end", "def set_ingredient\n @ingredient = Ingredient.find(params[:id])\n end", "def set_ingredient\n @ingredient = Ingredient.find(params[:id])\n end", "def set_ingredient\n @ingredient = Ingredient.find(params[:id])\n end", "def index\n @ingredients_nutrients = IngredientsNutrient.all\n end", "def ingredients\n recipe_ingredients.map do |r|\n r.ingredient\n end\n end", "def make_primer_aliquots\n show do\n title \"Make fragment stock aliquots\"\n\n check \"Pipette #{operations.running.first.temporary[:dilution_vol] } uL #{STOCK} into each #{DILUTED_STOCK} tube using the following table.\"\n\n table operations.running.start_table\n .output_item(STOCK, heading: \"#{STOCK} (#{operations.running.first.temporary[:dilution_vol]} uL)\")\n .output_item(DILUTED_STOCK, checkable: true)\n .end_table\n \n check \"Vortex each tube after the DNA has been added.\"\n end\n end", "def item_edit\n end", "def show\n @recipe = Recipe.find(params[:id])\n @ingrediences = Ingredience.find(:all, :order => 'title')\n @units = Unit.find(:all, :conditions => ['foods = ?', true], :order => 'name')\n @meals = Meal.find(:all, :conditions => ['recipe_id = ?', @recipe.id])\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @recipe }\n end\n end", "def show\n @material_composition.type_name = ['Material', \"Alvenaria: Parede Simples\",\"Alvenaria: Parede Dupla\" ][@material_composition.mtype]\n @impacts = @material_composition.impacts\n end", "def show\n @ingredient = Ingredient.find(params[:id])\n @alternate_ingredient = @ingredient.to_unit(@ingredient.conversions_to_display) unless @ingredient.conversions_to_display.nil?\n respond_to do |format|\n format.html # show.rhtml\n format.xml { render :xml => @ingredient.to_xml }\n end\n end", "def edit\n params[:extrablank].nil? ? @extrablank = 1 : @extrablank = params[:extrablank].to_i\n @items = Item.all\n @recipe = Recipe.find(params[:id])\n @extrablank.times do\n @recipe.quantities.build\n end\n # @ingredients ? @ingredients << Item.new : @ingredients = [Item.new]\n end", "def current_ingredient\n ingredient = Ingredient.find(params[:id])\n end", "def edit()\n\t\t@fruit = Fruit.find(params[:fruit_id]) || (params[:id])\n\t\t@plantations = Plantation.all\n\tend", "def show\n @recipe = Recipe.find(params[:id])\n @step = @recipe.steps.build #build a new step, this new one does not have sequence_id YET\n @ingredient = @recipe.ingredients.build #build new ingredient\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @recipe }\n end\n end", "def print_meals\n meals.reset\n puts separator_line\n table = TTY::Table.new\n table << [\"Index\", \"Title\", \"Status\", \"On Shopping List?\", \"Rating\", \"Notes\"].map{|item|\n ptext(item)\n }\n meals.each_with_index do |meal, index|\n table << [\n index+1,\n meal.recipe.title,\n meal.active == false ? \"Cooked\" : \"Awaiting Cooking\",\n meal.shopping == true ? \"Yes\" : \"No\",\n !meal.rating.nil? ? meal.rating.to_5_stars : \"[Unrated]\",\n !meal.notes.nil? ? meal.notes.max_line_length(50) : \"None.\"\n ]\n end\n\n putable = table.render(:ascii, multiline: true, padding: [1,1,1,1]) do |renderer|\n renderer.border.separator = TTY::Table::Border::EACH_ROW\n end\n puts putable\n end", "def ingredients\n recipeingredient.map {|ri| ri.ingredient}\n end", "def index\n @barbecue_ingredients = BarbecueIngredient.all\n end", "def show\n # accept the params\n # go to the db and get the correct recipe for that param\n p params[:id]\n @recipe = Recipe.find_by(id: params[:id])\n @ingredients = @recipe.ingredients.split(\", \").map {|ingredient| ingredient.capitalize}\n # send this to the view\n # show that data to the user\n render 'show.json.jb'\n end", "def show\n @breakfast_ingredients_data = {\n 'Fruits' => {},\n 'Vegetables' => {},\n 'Cereals' => {},\n 'Milk Products' => {},\n 'Groceries' => {},\n 'Proteins' => {},\n 'Others' => {}\n }\n @lunch_ingredients_data = {\n 'Fruits' => {},\n 'Vegetables' => {},\n 'Cereals' => {},\n 'Milk Products' => {},\n 'Groceries' => {},\n 'Proteins' => {},\n 'Others' => {}\n }\n @dinner_ingredients_data = {\n 'Fruits' => {},\n 'Vegetables' => {},\n 'Cereals' => {},\n 'Milk Products' => {},\n 'Groceries' => {},\n 'Proteins' => {},\n 'Others' => {}\n }\n\n @menu.breakfast_recipes.each do |recipe|\n recipe.recipe_line_items.each do |rli|\n ing = rli.ingredient\n next if ing.category.nil?\n current_ingredient_quantity = @breakfast_ingredients_data[ing.category][\"#{ing.name}|#{ing.unit_of_measurement}\"]\n added_ingredient_quantity = (BigDecimal.new((rli.quantity || 0).to_s) * @menu.breakfast_head_count).to_s(\"F\")\n if current_ingredient_quantity.nil?\n @breakfast_ingredients_data[ing.category][\"#{ing.name}|#{ing.unit_of_measurement}\"] = added_ingredient_quantity\n else\n new_ingredient_quantity = (BigDecimal.new(current_ingredient_quantity.to_s) + BigDecimal.new(added_ingredient_quantity.to_s)).to_s(\"F\")\n @breakfast_ingredients_data[ing.category][\"#{ing.name}|#{ing.unit_of_measurement}\"] = new_ingredient_quantity\n end\n end\n end\n\n @menu.lunch_recipes.each do |recipe|\n recipe.recipe_line_items.each do |rli|\n ing = rli.ingredient\n next if ing.category.nil?\n current_ingredient_quantity = @lunch_ingredients_data[ing.category][\"#{ing.name}|#{ing.unit_of_measurement}\"]\n added_ingredient_quantity = (BigDecimal.new((rli.quantity || 0).to_s) * @menu.lunch_head_count).to_s(\"F\")\n if current_ingredient_quantity.nil?\n @lunch_ingredients_data[ing.category][\"#{ing.name}|#{ing.unit_of_measurement}\"] = added_ingredient_quantity\n else\n new_ingredient_quantity = (BigDecimal.new(current_ingredient_quantity.to_s) + BigDecimal.new(added_ingredient_quantity.to_s)).to_s(\"F\")\n @lunch_ingredients_data[ing.category][\"#{ing.name}|#{ing.unit_of_measurement}\"] = new_ingredient_quantity\n end\n end\n end\n\n @menu.dinner_recipes.each do |recipe|\n recipe.recipe_line_items.each do |rli|\n ing = rli.ingredient\n next if ing.category.nil?\n current_ingredient_quantity = @dinner_ingredients_data[ing.category][\"#{ing.name}|#{ing.unit_of_measurement}\"]\n added_ingredient_quantity = (BigDecimal.new((rli.quantity || 0).to_s) * @menu.dinner_head_count).to_s(\"F\")\n if current_ingredient_quantity.nil?\n @dinner_ingredients_data[ing.category][\"#{ing.name}|#{ing.unit_of_measurement}\"] = added_ingredient_quantity\n else\n new_ingredient_quantity = (BigDecimal.new(current_ingredient_quantity.to_s) + BigDecimal.new(added_ingredient_quantity.to_s)).to_s(\"F\")\n @dinner_ingredients_data[ing.category][\"#{ing.name}|#{ing.unit_of_measurement}\"] = new_ingredient_quantity\n end\n end\n end\n\n render layout: false\n end", "def show\n @materials = Hash.new(0)\n \n @shopping.shopping_meals.each do |sm|\n next if not sm.selected \n sm.meal.dishes.each do |dish|\n dish.burdens.each do |burden|\n material = burden.material\n @materials[material] += burden.quantity \n end\n end\n end\n end", "def product_row_helper(product,opts={})\n opts[:class] ||= 'row'\n photo_opts={:class=>'product col-image', :content => link_to('Add image..',product_images_path(product))}\n if opts[:image] \n photo_opts[:image] = opts[:image]\n end\n \n # this make inline editing work \n @product = product\n content = column_helper :class => 'col-name', :content => checkbox_helper(opts[:checkbox], {\n :element_id => 'product_ids',\n :element_value => product.id,\n :element_default => true,\n :element_link => link_to(h(product.name),product)\n })\n \n content << column_helper(:class =>'product col-quantity', :content =>pricing_helper(@product))\n content << column_helper(:class =>'product col-quantity', :content =>weight_helper(@product))\n content << column_helper(:class =>'product col-quantity', :content =>in_place_editor_field(@product, :order_code,{}, {}))\n content << column_helper(:class =>'product col-quantity', :content=>link_to(product.categories.size,product_categories_path(product)))\n content << column_helper(:class =>'product col-quantity', :content=>link_to(product.suppliers.size,product_suppliers_path(product)))\n content << column_helper(:class =>'product col-quantity', :content=>link_to(product.images.size,product_images_path(product)))\n content << photo_column_helper(product.images,photo_opts)\n content << column_helper(:class => 'product spacer', :content=>in_place_editor_field(@product, :description,{}, {:rows=>3} ))\n content_tag('dl',content,:class => opts[:class])\nend", "def table_content\n # This makes a call to gift_rows and gets back an array of data that will \n # populate the columns and rows of a table I then included some styling to \n # include a header and make its text bold. I made the row background colors \n # alternate between grey and white Then I set the table column widths\n table gift_rows do\n row(0).font_style = :bold\n self.header = true\n self.row_colors = ['DDDDDD', 'FFFFFF']\n self.column_widths = [180, 180, 180]\n end\n end", "def edit\n @product = Product.find(params[:id])\n all_ubications = Ubication.find :all\n @ubications = Hash.new\n @ubications[\"Ninguna\"] = nil\n for u in all_ubications do\n @ubications[u.name] = u.id\n end\n\n end", "def new\n #@aliments = Aliment.order(\"name ASC\").all\n @repa = Repa.new\n @ingredient = @repa.ingredients.build\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @repa }\n end\n end", "def show_primer_table primer_tab, primers_over_60, primers_over_90\n data = show do\n title \"Create an IDT DNA oligos order\"\n \n warning \"Oligo concentration for primer(s) #{primers_over_60} will have to be set to \\\"100 nmole DNA oligo.\\\"\" if primers_over_60 != \"\"\n warning \"Oligo concentration for primer(s) #{primers_over_90} will have to be set to \\\"250 nmole DNA oligo.\\\"\" if primers_over_90 != \"\"\n \n #check \"Click Custom DNA Oligos, click Bulk Input. Copy paste the following table and then click the Update button.\"\n \n check \"Under \\\"Custom DNA Oligos\\\", click \\\"DNA Oligos\\\", then under \\\"Single-stranded DNA\\\" click \\\"Order now\\\", and click \\\"Bulk input\\\". Copy and paste the following table there.\"\n table primer_tab\n \n check \"Click Add to Order, review the shopping cart to double check that you entered correctly. There should be #{operations.length} primers in the cart.\"\n check \"Click Checkout, then click Continue.\"\n check \"Enter the payment information, click the oligo card tab, select the Card1 in Choose Payment and then click Submit Order.\"\n check \"Go back to the main page, let it sit for 5-10 minutes, return and refresh, and find the order number for the order you just placed.\"\n \n get \"text\", var: \"order_number\", label: \"Enter the IDT order number below\", default: 100\n end\n\n operations.each { |op| op.set_output_data(\"Primer\", :order_number, data[:order_number]) }\n end", "def show_table\n build_html do\n if upd_apar_defs.length == 0\n div.upd_apar_defs do\n span \"Did not find any items matching request\"\n end\n else\n table.upd_apar_defs do\n thead do\n tr do\n th '#'\n [ \"Defect\", \"Apar\", \"PTF\", \"Abstract\",\n \"LPP\", \"VRMF\", \"Version\", \"Service Pack\" ].each do |header_label|\n th class: \"upd_apar_def-#{header_label.gsub(\" \", \"_\").downcase}\" do\n span class: \"upd_apar_defs_header_span\" do\n text header_label\n span class: \"sort sortable\" do\n end\n end\n end\n end\n end\n end\n tbody do\n # upd_apar_defs.each_with_index { |o, i| show_upd_apar_def(o,i) }\n end\n end\n end\n end\n end", "def recipePrintHelper(name)\n myrecipe = @RecipeHash[name]\n puts \"#{myrecipe.name} #{myrecipe.calories}\"\n # Loop through each ingredient and print out the required ingredient name and\n # and the associated calories.\n myrecipe.ingredients.each do |ingredient|\n puts \" #{@BasicHash[ingredient].name} #{@BasicHash[ingredient].calories}\\n\"\n end\n end", "def ingredient_data\n respond_to do |format|\n format.json { render json: helpers.get_ingredient(params[:ingredient_type], params[:ingredient_id]) }\n end\n end", "def show\n @recipe = Recipe.find(params[:id])\n @nutrition_info = NutritionInfo.where( \"recipe_id = ?\", @recipe.id ).first\n @inventory_items = []\n @recipe.inventory_items.each do |inventory_item|\n @inventory_items << inventory_item\n end\n\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @recipe }\n end\n end", "def index\n @dis_ingredients = DisIngredient.all\n end", "def show\n @recipe = Recipe.find(params[:id])\n @recipeIngredients = RecipeIngredient.where(:recipeId => params[:id])\n @ingredients = Ingredient.where(:id => @recipeIngredients.select(:ingredientId))\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @recipe }\n end\n end", "def show\n @recipe = Recipe.find(params[:id])\n @ingredients = @recipe.ingredients\n @instructions_domain = @recipe.instruction_url_split\n @nutrition_info = @recipe.nutrition_informations\n @health_labels = @recipe.health_labels\n end", "def set_formulation\n @formulation = Formulation.includes(formulation_ingredients: [:ingredient]).find(params[:id])\n end" ]
[ "0.6153587", "0.6143423", "0.61109203", "0.60974365", "0.60917294", "0.6018128", "0.59337914", "0.592422", "0.59125805", "0.58612365", "0.585769", "0.58232474", "0.5816479", "0.5815542", "0.5787807", "0.5787807", "0.5771478", "0.5767419", "0.5752202", "0.5751808", "0.5733441", "0.57097685", "0.5690749", "0.5689197", "0.56621724", "0.56511325", "0.56511325", "0.564648", "0.56463057", "0.5629142", "0.5627665", "0.5627625", "0.5627625", "0.56259406", "0.5589845", "0.5582803", "0.55792", "0.5577855", "0.5577855", "0.55628496", "0.55628276", "0.55533665", "0.5539562", "0.5538041", "0.5535742", "0.55196905", "0.551524", "0.55136985", "0.5509052", "0.55038524", "0.550027", "0.5486441", "0.54796034", "0.54676694", "0.543543", "0.5434705", "0.5427542", "0.5427188", "0.5427188", "0.5427188", "0.5427188", "0.5427188", "0.5427188", "0.5427188", "0.5427188", "0.5427188", "0.5427188", "0.5427188", "0.5427188", "0.5427188", "0.5427188", "0.54244626", "0.5412496", "0.5411561", "0.54092366", "0.5406278", "0.54047614", "0.53950924", "0.5390212", "0.5389268", "0.53875273", "0.5383391", "0.53797495", "0.5376967", "0.5372315", "0.5371673", "0.5370144", "0.53652877", "0.53551525", "0.5352756", "0.5336979", "0.53293204", "0.5314396", "0.53128433", "0.5311095", "0.5310734", "0.53062624", "0.53043026", "0.5304012", "0.53003836", "0.52951175" ]
0.0
-1
GET /evaluaciones/1 GET /evaluaciones/1.xml
def show @evaluacione = Evaluacione.find(params[:id]) respond_to do |format| format.html # show.html.erb format.xml { render :xml => @evaluacione } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\r\n @evaluaciones = Evaluacione.all\r\n end", "def index\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @evaluators }\n end\n end", "def show\r\n @evaluation = Evaluation.find(params[:id])\r\n @responses = Response.find_all_by_Evaluation_id params[:id]\r\n\r\n respond_to do |format|\r\n format.html # show.html.erb\r\n format.xml { render :xml => @evaluation }\r\n end\r\n end", "def show\n @evaluacion = Evaluacion.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @evaluacion }\n end\n end", "def new\n @evaluacione = Evaluacione.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @evaluacione }\n end\n end", "def index\n @evaluaciones = Evaluacion.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @evaluaciones }\n end\n end", "def show\n @evaluation = Evaluation.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @evaluation }\n end\n end", "def show\n @evaluacion_servicios = EvaluacionServicio.find(params[:id])\n end", "def index\n @evaluos = Evaluo.all\n end", "def index\n @evaluacion_servicios = EvaluacionServicio.all\n end", "def show\n @estacion = Estacion.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @estacion }\n end\n end", "def show\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @evaluator }\n end\n end", "def index\n @test_subject_evaluations = @test_subject.test_subject_evaluations.find(:all, :order => 'evaluated_on DESC')\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @test_subject_evaluations }\n end\n end", "def show\n @evaluate_course = EvaluateCourse.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @evaluate_course }\n end\n end", "def index\n @solicitudes = Solicitud.all\n \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @solicitudes }\n end\n end", "def index\n @evals = Eval.all\n respond_with(@evals) \n end", "def index\n @predicitions = Predicition.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @predicitions }\n end\n end", "def show\n @test_subject_evaluation = @test_subject.test_subject_evaluations.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @test_subject_evaluation }\n end\n end", "def evaluations(id)\n connection.get do |req|\n req.url \"job/#{id}/evaluations\"\n end\n end", "def show\n @evaluations = Evaluation.find(params[:id])\n end", "def show\n @requisicion = Requisicion.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @requisicion }\n end\n end", "def index\n debugger\n @receitas = Receita.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @receitas }\n end\n end", "def consultar\n @disciplina = Disciplina.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @disciplina }\n end\n end", "def show\n @frequencia_orgao = Frequencia::Orgao.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb.erb\n format.xml { render :xml => @frequencia_orgao }\n end\n end", "def show\n @estagiarios = Estagiario.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @estagiarios }\n end\n end", "def index\n @cuentas = Cuenta.all\n\n @cadena = getcuentasxml\n \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @cadena }\n end\n end", "def index\n @estatus = Estatu.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @estatus }\n end\n end", "def show\n @frequencia_setor = Frequencia::Setor.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb.erb\n format.xml { render :xml => @frequencia_setor }\n end\n end", "def show\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @requisition }\n end\n end", "def index\n @labs = @course.labs.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render xml: @labs }\n end\n end", "def show\n @estagio = Estagio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @estagio }\n end\n end", "def index\n @asistencias = Asistencia.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @asistencias }\n end\n end", "def show\n @analisis = Analisis.find(params[:id])\n\n respond_to do |format|\n format.xml { render :xml => @analisis }\n end\n end", "def index\n @annees = Annee.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @annees }\n end\n end", "def show\n @relatestagiario = Relatestagiario.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @relatestagiario }\n end\n end", "def show\n @requisicao = Requisicao.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @requisicao }\n end\n end", "def index\n @criterions = Criterion.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @criterions }\n end\n end", "def index\n @evaluations = Evaluation.all\n end", "def index\n @evaluations = Evaluation.all\n end", "def index\n @evaluations = Evaluation.all\n end", "def index\n @evaluations = Evaluation.all\n end", "def index\n @evaluations = Evaluation.all\n end", "def index\n @algorithms = Algorithm.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @algorithms }\n end\n end", "def index\n @disciplinas = Disciplina.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @disciplinas }\n end\n end", "def show\n @situacoes_juridica = SituacoesJuridica.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @situacoes_juridica }\n end\n end", "def show\n @exercicio = Exercicio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @exercicio }\n end\n end", "def index\n @evaluations = Evaluation.all\n end", "def xml(id)\n http.get(\"/nfse/#{id}/xml\") do |response|\n response.headers.fetch(\"Location\") { \"\" }\n end\n end", "def download_xml\n\t\turi = URI.parse(\"http://www.esmadrid.com/opendata/tiendas_v1_es.xml\")\n\t\tresponse = Net::HTTP.get_response(uri)\n\t\tcontent = response.body\n\n\t\txml = REXML::Document.new(content)\n\n\t\treturn xml\n\tend", "def index\n @revenus = @foyer.revenus\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @revenus }\n end\n end", "def index\n @retiradas = Retirada.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @retiradas }\n end\n end", "def show\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @formula }\n end\n end", "def index\n @procesos = Proceso.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @procesos }\n end\n end", "def show\n @estatu = Estatu.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @estatu }\n end\n end", "def get_eval\n\t\t@student = Student.find(params[:student_id])\n\t\t@evaluation = @student.evaluations.find(params[:eval_id])\n\t\trender json: @evaluation\n\tend", "def set_evaluacion\n @evaluacions = Evaluacion.find(params[:id])\n end", "def show\n @estudiante = Estudiante.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @estudiante }\n end\n end", "def show\n @estudiante = Estudiante.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @estudiante }\n end\n end", "def index\n @questionnaires = Questionnaire.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @questionnaires }\n end\n end", "def index\n @matriculas = Matricula.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @matriculas }\n end\n end", "def index\n @matriculas = Matricula.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @matriculas }\n end\n end", "def index\n @evaluations = @course.evaluations\n end", "def show\n @tipo_de_exercicio = TipoDeExercicio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @tipo_de_exercicio }\n end\n end", "def show\n @convenio = Convenio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @convenio }\n end\n end", "def index\n @feria2010observaciones = Feria2010observacion.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @feria2010observaciones }\n end\n end", "def index\n @acres = Acre.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @acres }\n end\n end", "def index\n @evaluations = @course.evaluations\n end", "def get_evaluations\n\t\tif current_student.id.to_i == params[:id].to_i\n\t\t\t@student = Student.find(params[:id])\n\t\t\t@evaluations = @student.evaluations\n\t\tend\n\t\trender 'get_evaluations'\n\tend", "def index\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @questionnaires }\n end\n end", "def show\n @valor_sistema = ValorSistema.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @valor_sistema }\n end\n end", "def index\n @facturas = Factura.facturatotal(session[:id])\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @facturas }\n end\n end", "def index\n @exposures = Exposure.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @exposures }\n end\n end", "def index\n @entradas = Entrada.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @entradas }\n end\n end", "def set_evaluacion\n @evaluacion = Evaluacion.find(params[:id])\n end", "def show\n @estoques = Estoque.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @estoques }\n end\n end", "def index\n @corporacion_policiacas = CorporacionPoliciaca.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @corporacion_policiacas }\n end\n end", "def index\n @evaluates = Evaluate.all\n end", "def show\n @relatorios = Relatorio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @relatorios }\n end\n end", "def index\n @feria2009calificaciones = Feria2009calificacion.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @feria2009calificaciones }\n end\n end", "def show\n @periodista = Periodista.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @periodista }\n end\n end", "def index\n @progres = Progre.paginate(:page => params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @progres }\n end\n end", "def index\n @compras = Compra.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @compras }\n end\n end", "def show\n @expression = Expression.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @expression }\n end\n end", "def index\n @lieus = Lieu.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @lieus }\n end\n end", "def show\n @requisition = Requisition.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @requisition }\n format.xml { render xml: @requisitions }\n end\n end", "def set_evaluacion_servicio\n @evaluacion_servicio = EvaluacionServicio.find(params[:id])\n end", "def index\n @rules = Rule.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @rules }\n end\n end", "def index\n @aisles = Aisle.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @aisles }\n end\n end", "def index\r\n @respuesta = Respuestum.all\r\n end", "def index\n @estaciones = Estacion.all(:order => \"posicion ASC\", :joins => :linea, :conditions => [\"lineas.nombre = ?\", \"Linea 8: Garibaldi - Constitución de 1917\"])\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @estaciones }\n end\n end", "def index\n @frequencia_setores = Frequencia::Setor.order('updated_at ASC').paginate :page => params[:page], :per_page => 10\n @total = Frequencia::Setor.all.count\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @frequencia_setores }\n end\n end", "def index\n @personals = Personal.all\n\n cadena = getpersonals(@personals)\n\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => cadena }\n end\n end", "def show\n @exp = Exp.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @exp }\n end\n end", "def index\n @uitgelichts = Uitgelicht.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @uitgelichts }\n end\n end", "def index\n @additions = Addition.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @additions }\n end\n end", "def index\n name = @xml.elements['/name'].text\n @sentence = \"Hello #{name} !\"\n render_xml\n end", "def index\n @pacientes = Paciente.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @pacientes }\n end\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 index\n # @ideias = Ideia.all\n @ideias = Ideia.where(:status => '3')\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @ideias }\n end\n end", "def show\n @criteria = Criteria.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @criteria }\n end\n end" ]
[ "0.65458894", "0.6539789", "0.6520937", "0.6506127", "0.6478041", "0.6476702", "0.643366", "0.6340797", "0.62616915", "0.6201947", "0.61645305", "0.6144908", "0.60656065", "0.6037255", "0.60119736", "0.59711564", "0.59603727", "0.5948803", "0.59164196", "0.58901685", "0.58869344", "0.5881891", "0.58808565", "0.5879692", "0.5873468", "0.586625", "0.58644587", "0.58612406", "0.5843015", "0.58389187", "0.58309853", "0.5824384", "0.5815727", "0.5809523", "0.58084124", "0.5799809", "0.57885414", "0.5787294", "0.5787294", "0.5787294", "0.5787294", "0.5787294", "0.57791245", "0.5776194", "0.57735074", "0.57649964", "0.57527", "0.57466614", "0.5743104", "0.57421714", "0.57390666", "0.57307017", "0.57250744", "0.57223994", "0.5721914", "0.57051945", "0.5700461", "0.5700142", "0.5682173", "0.56741196", "0.56741196", "0.5668412", "0.5666865", "0.5660189", "0.56584626", "0.5657509", "0.5655643", "0.5650435", "0.56373656", "0.5633669", "0.56335557", "0.5632939", "0.5624555", "0.56243664", "0.56238097", "0.56164736", "0.5613644", "0.5604801", "0.5603253", "0.5599418", "0.5597395", "0.5585528", "0.55835956", "0.5583281", "0.5580162", "0.5578287", "0.55748814", "0.5573757", "0.5572323", "0.55718726", "0.55700797", "0.5570053", "0.5566721", "0.55666876", "0.55622333", "0.5558668", "0.555372", "0.55535775", "0.55528593", "0.5550554" ]
0.7179133
0
GET /evaluaciones/new GET /evaluaciones/new.xml
def new @evaluacione = Evaluacione.new respond_to do |format| format.html # new.html.erb format.xml { render :xml => @evaluacione } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @estacion = Estacion.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @estacion }\n end\n end", "def new\n @estagio = Estagio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @estagio }\n end\n end", "def new\n @solicitud = Solicitud.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @solicitud }\n end\n end", "def new\n @recurso = Recurso.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @recurso }\n end\n end", "def new\n @periodista = Periodista.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @periodista }\n end\n end", "def new\n @estagiarios = Estagiario.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @estagiarios }\n end\n end", "def new\n @relatestagiario = Relatestagiario.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @relatestagiario }\n end\n end", "def new\n @aplicacion = Aplicacion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @aplicacion }\n end\n end", "def create\n @evaluacione = Evaluacione.new(params[:evaluacione])\n\n respond_to do |format|\n if @evaluacione.save\n format.html { redirect_to(@evaluacione, :notice => 'Evaluacione was successfully created.') }\n format.xml { render :xml => @evaluacione, :status => :created, :location => @evaluacione }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @evaluacione.errors, :status => :unprocessable_entity }\n end\n end\n end", "def new\n @convenio = Convenio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @convenio }\n end\n end", "def new\n @nostro = Nostro.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @nostro }\n end\n end", "def new\n @precio = Precio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @precio }\n end\n end", "def new\n @estatu = Estatu.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @estatu }\n end\n end", "def new\n @exercicio = Exercicio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @exercicio }\n end\n end", "def new\n @proceso = Proceso.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @proceso }\n end\n end", "def new\n @node = Node.scopied.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @node }\n end\n end", "def new\n @expression = Expression.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @expression }\n end\n end", "def new\n @pessoa = Pessoa.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @pessoa }\n end\n end", "def new\n @pessoa = Pessoa.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @pessoa }\n end\n end", "def new\n @situacoes_juridica = SituacoesJuridica.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @situacoes_juridica }\n end\n end", "def new\n @documentoclasificacion = Documentoclasificacion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @documentoclasificacion }\n end\n end", "def new\n @estudiante = Estudiante.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @estudiante }\n end\n end", "def new\n @lien = Lien.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lien }\n end\n end", "def new\n @noticia = Noticia.new \n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @noticia }\n end\n end", "def new\n @evaluate_course = EvaluateCourse.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @evaluate_course }\n end\n end", "def new\n @tipo_de_exercicio = TipoDeExercicio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @tipo_de_exercicio }\n end\n end", "def new\n @predicition = Predicition.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @predicition }\n end\n end", "def new\n @receita = Receita.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @receita }\n end\n end", "def new\n @regiaos = Regiao.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @regiaos }\n end\n end", "def new\n @relatorios = Relatorio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @relatorios }\n end\n end", "def new\n @puesto = Puesto.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @puesto }\n end\n end", "def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => new_vurl }\n end\n end", "def new\n @questao = Questao.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @questao }\n end\n end", "def new\n @annee = Annee.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @annee }\n end\n end", "def new\n @estoques = Estoque.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @estoques }\n end\n end", "def new\n @asistencia = Asistencia.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @asistencia }\n end\n end", "def new\n @peca = Peca.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @peca }\n end\n end", "def new\n @vestimenta = Vestimenta.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @vestimenta }\n end\n end", "def new\n @periodos = Periodo.all.collect{|p|[\"#{t p.inicio.strftime(\"%B\")} - #{t p.fim.strftime(\"%B\")}\",p.id]}\n @requisicao = Requisicao.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @requisicao }\n end\n end", "def new\n @test_subject_evaluation = TestSubjectEvaluation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @test_subject_evaluation }\n end\n end", "def new\n @nota = Nota.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @nota }\n end\n end", "def new\n @nota = Nota.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @nota }\n end\n end", "def new\n @entrada = Entrada.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @entrada }\n end\n end", "def new\n @frequencia_orgao = Frequencia::Orgao.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @frequencia_orgao }\n end\n end", "def new\n @progre = Progre.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @progre }\n end\n end", "def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @instituto }\n end\n end", "def new\n @compras_documento = ComprasDocumento.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @compras_documento }\n end\n end", "def new\n @factura = Factura.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @factura }\n end\n end", "def new\n @estados_civil = EstadosCivil.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @estados_civil }\n end\n end", "def new\n @modulo = Modulo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @modulo }\n end\n end", "def new\n @visarequest = Visarequest.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @visarequest }\n end\n end", "def new\n @entradas = Entrada.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @entradas }\n end\n end", "def new\n @adjunto = Adjunto.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @adjunto }\n end\n end", "def new\n @norma = Norma.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @norma }\n end\n end", "def new\n @documento = Documento.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @documento }\n end\n end", "def new\n @spiel = Spiel.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @spiel }\n end\n end", "def new\n @formula = Formula.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @formula }\n end\n end", "def new\n @nossos_servico = NossosServico.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @nossos_servico }\n end\n end", "def new\n @coleccionista = Coleccionista.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @coleccionista }\n end\n end", "def new\n @tipo_nota = TipoNota.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @tipo_nota }\n end\n end", "def new\n @elemento = Elemento.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @elemento }\n end\n end", "def new\n @tiposproceso = Tiposproceso.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @tiposproceso }\n end\n end", "def new\n @retirada = Retirada.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @retirada }\n end\n end", "def new\n @competencia = Competencia.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @competencia }\n end\n end", "def new\n @correspondenciasclase = Correspondenciasclase.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @correspondenciasclase }\n end\n end", "def new\n @pizarra = Pizarra.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @pizarra }\n end\n end", "def new\n @inscripcione = Inscripcione.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @inscripcione }\n end\n end", "def new\n @crianca = Crianca.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @crianca }\n end\n end", "def new\n @frequencia_setor = Frequencia::Setor.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @frequencia_setor }\n end\n end", "def new\n @historico = Historico.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @historico }\n end\n end", "def new\n @nom = Nom.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @nom }\n end\n end", "def new\n @numerador = Numerador.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @numerador }\n end\n end", "def new\n @calidadtiposdocumento = Calidadtiposdocumento.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @calidadtiposdocumento }\n end\n end", "def new\n @actividad = Actividad.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @actividad }\n end\n end", "def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @nomina }\n end\n end", "def new\n @convenio_financiamiento = ConvenioFinanciamiento.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @convenio_financiamiento }\n end\n end", "def new\n @curta = Curta.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @curta }\n end\n end", "def new\n @especificacao = Especificacao.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @especificacao }\n end\n end", "def new\n @addition = Addition.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @addition }\n end\n end", "def new\n @iguanasactualizacion = Iguanasactualizacion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @iguanasactualizacion }\n end\n end", "def new\n @curso = Curso.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @curso }\n end\n end", "def new\n @Roc = Roc.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @Roc }\n end\n end", "def new\n @publicacion = Publicacion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @publicacion }\n end\n end", "def new\n @remocao = Remocao.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @remocao }\n end\n end", "def new\n @suministro = Suministro.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @suministro }\n end\n end", "def new_rest\n @question_localized = QuestionLocalized.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @question_localized }\n end\n end", "def new\n @occurence = Occurence.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @occurence }\n end\n end", "def new\n @senhas = Senha.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @senhas }\n end\n end", "def new\n @arrendamientosprorroga = Arrendamientosprorroga.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @arrendamientosprorroga }\n end\n end", "def new\n @contratosinterventoria = Contratosinterventoria.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @contratosinterventoria }\n end\n end", "def new\n @contrato = Contrato.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @contrato }\n end\n end", "def new\n @serie_comparativa = SerieComparativa.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @serie_comparativa }\n end\n end", "def new\n @election = Election.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @election }\n end\n end", "def new\n @valor_sistema = ValorSistema.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @valor_sistema }\n end\n end", "def new\n @requisition = Requisition.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @requisition }\n end\n end", "def new\n @tipo_proy = TipoProy.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @tipo_proy }\n end\n end", "def new\n @tipo_de_documento = TipoDeDocumento.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @tipo_de_documento }\n end\n end", "def new\n @reclamo = Reclamo.new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @reclamo }\n end\n \n end", "def new\n @vocab = Vocab.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @vocab }\n end\n end", "def new\n @projeto = Projeto.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @projeto }\n end\n end" ]
[ "0.73444235", "0.7029901", "0.700799", "0.6965129", "0.69602835", "0.694903", "0.69425124", "0.6895614", "0.6863163", "0.6862484", "0.6858303", "0.6849317", "0.684832", "0.68457526", "0.6836905", "0.6826136", "0.68043894", "0.68008494", "0.68008494", "0.6800445", "0.6791564", "0.6791323", "0.67734003", "0.6750654", "0.6750302", "0.6749944", "0.67498875", "0.67460436", "0.67458105", "0.6737758", "0.6728964", "0.67271274", "0.6726374", "0.6718021", "0.6716503", "0.6710756", "0.67102116", "0.67069995", "0.6695416", "0.668932", "0.6687929", "0.6687929", "0.66875035", "0.6684149", "0.6681843", "0.6680901", "0.666818", "0.66662556", "0.6653057", "0.66508186", "0.66505706", "0.6647745", "0.66437787", "0.6642822", "0.66392034", "0.6637877", "0.66324073", "0.6628317", "0.66272956", "0.6625738", "0.66184866", "0.6618146", "0.6615446", "0.66136783", "0.6611365", "0.6606072", "0.66021764", "0.6601208", "0.65980357", "0.6596146", "0.65943545", "0.6594248", "0.6591229", "0.6590869", "0.65907174", "0.6589421", "0.6587048", "0.6584422", "0.6579511", "0.6576838", "0.65764964", "0.6570167", "0.65691155", "0.6567331", "0.6563317", "0.6562652", "0.6554596", "0.6552592", "0.6552333", "0.6547825", "0.65411454", "0.6538954", "0.6534006", "0.6532211", "0.6531516", "0.6531415", "0.6529763", "0.6528133", "0.6528096", "0.65280026" ]
0.774188
0
POST /evaluaciones POST /evaluaciones.xml
def create @evaluacione = Evaluacione.new(params[:evaluacione]) respond_to do |format| if @evaluacione.save format.html { redirect_to(@evaluacione, :notice => 'Evaluacione was successfully created.') } format.xml { render :xml => @evaluacione, :status => :created, :location => @evaluacione } else format.html { render :action => "new" } format.xml { render :xml => @evaluacione.errors, :status => :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def post_evaluate(excon, body)\n excon.request(\n method: :post,\n path: '/evaluate',\n headers: { 'Content-Type' => 'application/json' },\n body: body\n )\nend", "def evaluacione_params\r\n params.require(:evaluacione).permit(:contestada, :curso_id, :encuesta_id, :nombre)\r\n end", "def evaluacion_params\n params.require(:evaluacion).permit(:pregunta_1, :pregunta_2, :pregunta_3, :pregunta_4, :pregunta_5, :pregunta_6, :pregunta_7, :pregunta_8, :observacion, :fecha_evaluacion, :nota, :nota_informe_practica)\n end", "def create\r\n @evaluacione = Evaluacione.new(evaluacione_params)\r\n\r\n respond_to do |format|\r\n if @evaluacione.save\r\n format.html { redirect_to @evaluacione, notice: 'Evaluacione was successfully created.' }\r\n format.json { render :show, status: :created, location: @evaluacione }\r\n else\r\n format.html { render :new }\r\n format.json { render json: @evaluacione.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end", "def create\n @evaluo = Evaluo.new(evaluo_params)\n\n respond_to do |format|\n if @evaluo.save\n format.html { redirect_to @evaluo, notice: 'Evaluo was successfully created.' }\n format.json { render :show, status: :created, location: @evaluo }\n else\n format.html { render :new }\n format.json { render json: @evaluo.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @evaluacion_servicio = EvaluacionServicio.new(evaluacion_servicio_params)\n \n respond_to do |format|\n if @evaluacion_servicio.save\n format.html { redirect_to servicio_sociales_path, notice: 'Evaluacion servicio was successfully created.' }\n format.json { render :show, status: :created, location: @evaluacion_servicio }\n else\n format.html { render :new }\n format.json { render json: @evaluacion_servicio.errors, status: :unprocessable_entity }\n end\n end\n end", "def evaluo_params\n params.require(:evaluo).permit(:tipo, :Activo, :integer, :descripcion, :montoactual, :fecha)\n end", "def new\n @evaluacione = Evaluacione.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @evaluacione }\n end\n end", "def create\n doc = Nokogiri::XML(request.body.read)\n cvNode = doc.xpath('elwak/checklisten_vorlage')\n cv = ChecklistenVorlage.new({\n objekt_id: cvNode.xpath('objekt_id').text.to_s, \n bezeichner: cvNode.xpath('bezeichner').text.to_s, \n version: cvNode.xpath('version').text.to_s.to_i, \n inaktiv: cvNode.xpath('inaktiv').text.to_s.to_bool \n })\n cv.save\n\n cvNode.xpath('checklisten_eintrags/checklisten_eintrag').each do |ceNode|\n ce = ChecklistenEintrag.new({\n checklisten_vorlage_id: cv.id,\n bezeichner: ceNode.xpath('bezeichner').text.to_s,\n was: ceNode.xpath('was').text.to_s,\n wann: ceNode.xpath('wann').text.to_s,\n typ: ceNode.xpath('typ').text.to_s.to_i,\n position: ceNode.xpath('position').text.to_s.to_i\n })\n ce.save\n end\n\n respond_to do |format|\n format.xml {render :xml => '<?xml version=\"1.0\" encoding=\"UTF-8\"?><success />'}\n end\n end", "def post(xmldoc)\n headers = {'Content-Type' => 'text/xml'}\n check_response( @httpcli.post(@endpoint, xmldoc, headers) )\n end", "def create\n @trabajo = Trabajo.find(params[:trabajo_id])\n @evaluacion = @trabajo.build_evaluacion(params[:evaluacion])\n @evaluacion.proveedor_id = @trabajo.contratado_id\n\n @path = [@trabajo, @evaluacion]\n respond_to do |format|\n if @evaluacion.save\n unless params[:evaluacion][:imagen].nil? or params[:evaluacion][:imagen].blank?\n @imagen = @evaluacion.imagen.create(:archivo => params[:evaluacion][:imagen], :descripcion => params[:evaluacion][:imagen][:descripcion], :proposito => \"evaluacion\")\n end\n # TtpMailer.notificar_trabajo_evaluado(@trabajo)\n flash[:success] = \"¡Trabajo evaluado!. Acabas de contribuir con otros solicitantes.\"\n format.html { redirect_to panel_solicitante_path }\n format.json { render json: @evaluacion, status: :created, location: @evaluacion }\n else\n flash[:error] = \"Ocurrió un error. Revisa el formulario.\"\n format.html { render action: \"new\" }\n format.json { render json: @evaluacion.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @criterio_evalucion_servicio = CriterioEvalucionServicio.new(criterio_evalucion_servicio_params)\n\n respond_to do |format|\n if @criterio_evalucion_servicio.save\n\n format.html { redirect_to @criterio_evalucion_servicio, notice: 'Criterio evalucion servicio was successfully created.' }\n format.json { render :show, status: :created, location: @criterio_evalucion_servicio }\n else\n format.html { render :new }\n format.json { render json: @criterio_evalucion_servicio.errors, status: :unprocessable_entity }\n end\n end\n end", "def evaluation_params\n params.require(:evaluation).permit(:objetivo, :fecha, :course_id)\n end", "def create\r\n @evaluation = Evaluation.new(params[:evaluation])\r\n @answers = @evaluation.responses\r\n\r\n respond_to do |format|\r\n if @evaluation.save && @answers.each{|a| a.save }.all?\r\n format.html { redirect_to(@evaluation, :notice => 'Evaluation was successfully created.') }\r\n format.xml { render :xml => @evaluation, :status => :created, :location => @evaluation }\r\n else\r\n format.html { render :action => \"new\" }\r\n format.xml { render :xml => @evaluation.errors, :status => :unprocessable_entity }\r\n end\r\n end\r\n end", "def create\n @evaluation = Evaluation.new(params[:evaluation])\n\n respond_to do |format|\n if @evaluation.save\n flash[:notice] = 'Evaluation was successfully created.'\n format.html { redirect_to(@evaluation) }\n format.xml { render :xml => @evaluation, :status => :created, :location => @evaluation }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @evaluation.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @evaluation = Evaluation.new(evaluation_params)\n\n respond_to do |format|\n if @evaluation.save\n format.html { redirect_to @evaluation, notice: 'Avaliação criada.' }\n format.json { render :show, status: :created, location: @evaluation }\n else\n format.html { render :new }\n format.json { render json: @evaluation.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n \n \n @evaluation = @course.evaluations.new(evaluation_params)\n respond_to do |format|\n if @evaluation.save\n format.html { redirect_to course_evaluation_path(@course,@evaluation) , notice: 'La evaluación fue creada con éxito.' }\n format.json { render :show, status: :created, location: @evaluation }\n else\n format.html { render :new }\n format.json { render json: @evaluation.errors, status: :unprocessable_entity }\n end\n end\n end", "def POST; end", "def evaluation_params\n params.require(:evaluation).permit(:date_evaluation, :typeevaluation, :cla_id, :matiere_id, :anneeacademique_id, :user_id)\n end", "def evaluation_params\n params.require(:evaluation).permit(:moyenne, :annee_scolaire, :matiere, :periode, :coefficient)\n end", "def create\n @pacient = Pacient.find(params[:pacient_id])\n @evaluare = @pacient.evaluares.create(params[:evaluare])\n\n respond_to do |format|\n if @evaluare.save\n format.html { redirect_to @pacient, notice: 'Evaluare was successfully created.' }\n format.json { render json: @evaluare, status: :created, location: @evaluare }\n else\n format.html { render action: \"new\" }\n format.json { render json: @evaluare.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n puts evaluation_params\n @evaluation = Evaluation.new(evaluation_params)\n #De aca en adelante es para lograr insertar datos en la tabla intermedia \n #La Tabla intermedia se la evaluation_question\n respond_to do |format|\n puts \"Entre al respond\"\n if @evaluation.save\n puts \"Pude guardarlo\"\n evaluation = Evaluation.last\n evaluation.update(course_id: params[:course_id])\n evaluation_id = evaluation.id\n question_ids = params[:questions]\n question_ids.each do |question_id|\n EvaluationQuestion.create(question_id: question_id, evaluation_id: evaluation_id)\n end\n format.html { redirect_to @evaluation, notice: 'La evaluación fue creada con éxito' }\n format.json { render :show, status: :created, location: @evaluation }\n else\n @question = Question.all\n @courses = Course.all\n format.html { render :new }\n format.json { render json: @evaluation.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @resultadoconsultum = Resultadoconsultum.new(resultadoconsultum_params)\n\t\n\n\trequire 'nokogiri'\n\t\n\t@doc = Nokogiri::XML(File.open(\"exemplos/emplo.xml\"))\n\n\tcar_tires = @doc.xpath(\"//firstname\")\n\t\n\tdoc = Nokogiri::XML(File.open(\"emplo.xml\"))\n\tdoc.xpath('firstname').each do\n\t\tcar_tires\n\tend\n\n\t \n respond_to do |format|\n if @resultadoconsultum.save\n format.html { redirect_to @resultadoconsultum, notice: car_tires }\n format.json { render :show, status: :created, location: @resultadoconsultum }\n else\n format.html { render :new }\n format.json { render json: @resultadoconsultum.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @selecciones = Seleccion.where(\"cliente_id = ?\",usuario_actual.id)\n @peso_total = Seleccion.peso_total(usuario_actual.id)\n @precio_total = Seleccion.precio_total(usuario_actual.id)\n @tarjetas = usuario_actual.tdc\n \n #Cobro en el banco\n client = Savon::Client.new(\"http://localhost:3001/servicios/wsdl\")\n tdc = Tarjeta.where(\"id = ? AND cliente_id = ?\",params[:orden][:tarjeta_id],usuario_actual.id)\n total_pagar = params[:orden][:total]\n pago = '<Message>\n <Request>\n <numero_tdc>'+tdc.numero+'</numero_tdc>\n <nombre_tarjetahabiente>'+tdc.tarjetahabiente+'</nombre_tarjetahabiente>\n <fecha_vencimiento>'+tdc.mes_vencimiento+'/'+tdc.ano_vencimiento+'</fecha_vencimiento>\n <codigo_seguridad>'+tdc.codigo+'</codigo_seguridad>\n <tipo_tarjeta>'+tdc.tipo+'</tipo_tarjeta>\n <direccion_cobro>'+tdc.direccion+'</direccion_cobro>\n <total_pagar>'+total_pagar+'</total_pagar>\n <cuenta_receptora>'+cuenta_receptora+'</cuenta_receptora>\n </Request>\n </Message>'\n #response = client.request :verificar_pago, body: { \"value\" => pago } \n #if response.success?\n # data = response.to_hash[:verificar_pago_response][:value][:response].first\n # @respuesta = XmlSimple.xml_in(data)\n #end\n\n #NAMESPACE = 'pagotdc'\n #URL = 'http://localhost:8080/'\n #banco = SOAP::RPC::Driver.new(URL, NAMESPACE)\n #banco.add_method('verificar_pago', 'numero_tdc', 'nombre_tarjetahabiente', 'fecha_vencimiento', 'codigo_seguridad', 'tipo_tarjeta', 'direccion_cobro', 'total_pagar', 'cuenta_receptora')\n #\n \n #respuesta = banco.verificar_pago(tdc.numero, tdc.tarjetahabiente, tdc.mes_vencimiento.to_s+'/'+tdc.ano_vencimiento.to_s, tdc.codigo, tdc.tipo, params[:orden][:total], tdc.direccion)\n \n if true #respuesta.ack.eql?(0)\n params[:orden][:cliente_id] = usuario_actual.id\n params[:orden][:total] = Seleccion.precio_total(usuario_actual.id)\n params[:orden][:fecha_entrega] = \"0000-00-00\"\n @orden = Orden.new(params[:orden])\n \n if @orden.save\n @selecciones = Seleccion.where(\"cliente_id = ?\",usuario_actual.id)\n @selecciones.each do |seleccion|\n p = Producto.find(seleccion.producto_id)\n @venta = Venta.new(:producto_id=>p.id, \n :orden_id=>@orden.id,\n :categoria_id=>p.categoria_id, \n :cantidad=>seleccion.cantidad,\n :costo=>p.precio)\n @venta.save\n end\n \n Seleccion.vaciar_carro(usuario_actual.id)\n respond_to do |format|\n format.html { redirect_to ver_ordenes_path, notice: 'Orden generada correctamente.' }\n end\n else\n respond_to do |format|\n format.html { render action: \"new\" }\n end\n end\n else\n respond_to do |format|\n format.html { render action: \"new\", notice: respuesta.mensaje }\n end\n end\n end", "def create\n @eval = Eval.new(params[:eval])\n @eval.save and flash[:notice] = \"Yay! New Eval Created!\"\n respond_with(@eval)\n end", "def create\n @evaluations = Evaluation.new(evaluation_params)\n\n respond_to do |format|\n if @evaluation.save\n format.html { redirect_to @evaluation, notice: 'evaluation was successfully created.' }\n format.json { render :show, status: :created, location: @evaluation }\n else\n format.html { render :new }\n format.json { render json: @evaluation.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @estagiarios = Estagiario.new(params[:estagiario])\n\n respond_to do |format|\n if @estagiarios.save\n flash[:notice] = 'ESTAGIÁRIO CADASTRADO COM SUCESSO.'\n format.html { redirect_to(@estagiarios) }\n format.xml { render :xml => @estagiarios, :status => :created, :location => @estagiarios }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @estagiarios.errors, :status => :unprocessable_entity }\n end\n end\n end", "def do_submission(path, xml = nil)\n if xml.nil?\n form = create(:form, question_types: %w(integer integer))\n form.publish!\n xml = build_odk_submission(form)\n end\n\n # write xml to file\n require 'fileutils'\n FileUtils.mkpath('test/fixtures')\n fixture_file = Rails.root.join('test/fixtures/', ODK_XML_FILE)\n File.open(fixture_file.to_s, 'w') { |f| f.write(xml) }\n\n # Upload and do request.\n uploaded = fixture_file_upload(fixture_file, 'text/xml')\n post(path, {:xml_submission_file => uploaded, :format => 'xml'}, 'HTTP_AUTHORIZATION' => encode_credentials(@user.login, 'password'))\n assigns(:response)\n end", "def create\n @estatu = Estatu.new(params[:estatu])\n\n respond_to do |format|\n if @estatu.save\n format.html { redirect_to(@estatu, :notice => 'Registro creado correctamente.') }\n format.xml { render :xml => @estatu, :status => :created, :location => @estatu }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @estatu.errors, :status => :unprocessable_entity }\n end\n end\n end", "def index\r\n @evaluaciones = Evaluacione.all\r\n end", "def create\n @estoques = Estoque.new(params[:estoque])\n\n respond_to do |format|\n if @estoques.save\n flash[:notice] = 'ESTOQUE CADASTRADO COM SUCESSO.'\n format.html { redirect_to(@estoques) }\n format.xml { render :xml => @estoques, :status => :created, :location => @estoques }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @estoques.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @anstoeval = Anstoeval.new(anstoeval_params)\n\n respond_to do |format|\n if @anstoeval.save\n format.html { redirect_to @anstoeval, notice: 'anstoeval was successfully created.' }\n format.json { render :show, status: :created, location: @anstoeval }\n else\n format.html { render :new }\n format.json { render json: @anstoeval.errors, status: :unprocessable_entity }\n end\n end\n end", "def test_accueil_et_inscription\n\t\tpost '/accueil', identifiant: '2', date_naiss: '1915-12-19'\n\t\tassert last_response.body.include? 'son inscription'\n\tend", "def index\n @evaluaciones = Evaluacion.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @evaluaciones }\n end\n end", "def post(uri, xml)\r\n req = Net::HTTP::Post.new(uri)\r\n req[\"content-type\"] = \"application/xml\"\r\n req.body = xml\r\n request(req)\r\n end", "def create\n @plan_quirurgico = PlanQuirurgico.new(plan_quirurgico_params)\n @plan_quirurgico.servicios = params[:servicios]\n @plan_quirurgico.estatus = \"En Proceso\"\n puts params\n puts @plan_quirurgico.examen \n respond_to do |format|\n if @plan_quirurgico.save\n format.html { redirect_to @plan_quirurgico, notice: 'El plan quirurgico fue registrado exitosamente.' }\n format.json { render :show, status: :created, location: @plan_quirurgico }\n else\n format.html { render :new }\n format.json { render json: @plan_quirurgico.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @estagio = Estagio.new(params[:estagio])\n\n respond_to do |format|\n if @estagio.save\n flash[:notice] = 'Estagio was successfully created.'\n format.html { redirect_to(@estagio) }\n format.xml { render :xml => @estagio, :status => :created, :location => @estagio }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @estagio.errors, :status => :unprocessable_entity }\n end\n end\n end", "def new\n @trabajo = Trabajo.find(params[:trabajo_id])\n @evaluacion = @trabajo.build_evaluacion\n\n @path = [@trabajo, @evaluacion]\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @evaluacion }\n end\n end", "def post_query( xml )\n url = URI.parse( self.url )\n response = self.http.post_form( url, { \"query\" => xml } )\n return response.body\n end", "def evaluacion_params\n #params.require(:evaluacion).permit(:user_id, :curso_id, :motivacion_pregunta1, :motivacion_pregunta2, :motivacion_pregunta3, :motivacion_pregunta4, :motivacion_pregunta5, :motivacion_pregunta6, :motivacion_pregunta7, :motivacion_pregunta8, :motivacion_pregunta9, :motivacion_pregunta10, :motivacion, :representacion_pregunta11, :representacion_pregunta12, :representacion_pregunta13, :representacion_pregunta14, :representacion_pregunta15, :representacion_pregunta16, :representacion_pregunta17, :representacion_pregunta18, :representacion_pregunta19, :representacion_pregunta20, :representacion_pregunta21, :representacion_pregunta22, :representacion, :expresion_pregunta23, :expresion_pregunta24, :expresion_pregunta25, :expresion_pregunta26, :expresion_pregunta27, :expresion_pregunta28, :expresion_pregunta29, :expresion_pregunta30, :expresion_pregunta31, :expresion, :texto_libre)\n \n params.require(:evaluacion).permit(:user_descripcion, :user_nombre, :user_name, :curso_descripcion, :curso_nombre, :curso_name, :user_id, :curso_id, :motivacion_pregunta1, :motivacion_pregunta2, :motivacion_pregunta3, :motivacion_pregunta4, :motivacion_pregunta5, :motivacion_pregunta6, :motivacion_pregunta7, :motivacion_pregunta8, :motivacion_pregunta9, :motivacion_pregunta10, :motivacion, :representacion_pregunta11, :representacion_pregunta12, :representacion_pregunta13, :representacion_pregunta14, :representacion_pregunta15, :representacion_pregunta16, :representacion_pregunta17, :representacion_pregunta18, :representacion_pregunta19, :representacion_pregunta20, :representacion_pregunta21, :representacion_pregunta22, :representacion, :expresion_pregunta23, :expresion_pregunta24, :expresion_pregunta25, :expresion_pregunta26, :expresion_pregunta27, :expresion_pregunta28, :expresion_pregunta29, :expresion_pregunta30, :expresion_pregunta31, :expresion, :texto_libre, :experiencia, :progreso)\n end", "def set_evaluacion\n @evaluacions = Evaluacion.find(params[:id])\n end", "def evaluation_params\n params.require(:evaluation).permit(:usuario_avaliado_id, :usuario_avaliador_id, :date, :done, :evaluation_model_id)\n end", "def create\n @evaluation = Evaluation.new(evaluation_params)\n\n respond_to do |format|\n if @evaluation.save\n format.html { redirect_to @evaluation, notice: 'Evaluation was successfully created.' }\n format.json { render :show, status: :created, location: @evaluation }\n else\n format.html { render :new }\n format.json { render json: @evaluation.errors, status: :unprocessable_entity }\n end\n end\n end", "def setorden\n @xml = params[:solicitud]\n @arreglo = Orden.validarRemota(@xml)\n if !(@arreglo.nil?)\n # @cliente = Persona.new(@xml[:cliente])\n # @cliente.save\n\n # @tarjeta = @xml[:tarjeta]\n # @tarjeta = TipoPago.new(@tarjeta)\n # @tarjeta.personas_id = @cliente.id\n # @tarjeta.save\n\n # @recoleccion = Direccion.new(@xml[:direccionrecoleccion])\n @entrega = Direccion.new(@xml[:direccionentrega])\n # @recoleccion.save\n @entrega.save\n\n @orden = Orden.new(@xml[:orden])\n @orden.estado = 'Pendiente por recolectar'\n @orden.personas_id= @arreglo[0]\n @orden.save\n\n @paquete = Paquete.new(@xml[:paquete])\n @paquete.ordens_id = @orden.id\n @paquete.personas_id = @arreglo[0]\n @paquete.save\n\n @historico1= Historico.new(:ordens_id => @orden.id, :direccions_id => @arreglo[2], :tipo => 'Recolectada')\n @historico= Historico.new(:ordens_id => @orden.id, :direccions_id => @entrega.id, :tipo => 'Entregada')\n @historico1.save\n @historico.save\n \n @monto = Enviar.montoTotal(@orden.id)\n @iva = (@monto * 0.12).round(2)\n @montototal = @monto + @iva\n Enviar.compania\n @factura = Factura.new(:companias_id => 1, :ordens_id =>@orden.id , :tipo_pagos_id => @arreglo[1] , :costoTotal => @monto ,:iva => @iva)\n @factura.save\n else\n render \"errorxml\"\n end\n end", "def set_evaluacion\n @evaluacion = Evaluacion.find(params[:id])\n end", "def index\n @evaluacion_servicios = EvaluacionServicio.all\n end", "def create\n @entradas = Entrada.new(params[:entrada])\n\n respond_to do |format|\n if @entradas.save\n flash[:notice] = 'LANÇAMENTO ENTRADA EFETUADO'\n format.html { redirect_to(homes_path) }\n format.xml { render :xml => @entradas, :status => :created, :location => @entradas }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @entradas.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @estudiante = Estudiante.new(params[:estudiante])\n\n respond_to do |format|\n if @estudiante.save\n flash[:notice] = 'Creado.'\n format.html { redirect_to(@estudiante) }\n format.xml { render :xml => @estudiante, :status => :created, :location => @estudiante }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @estudiante.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @respuesta = Respuesta.new(params[:respuesta])\n\n if @respuesta.save\n render json: @respuesta, status: :created, location: @respuesta\n else\n render json: @respuesta.errors, status: :unprocessable_entity\n end\n end", "def create\n @estudiante = Estudiante.new(params[:estudiante])\n\n respond_to do |format|\n if @estudiante.save\n format.html { redirect_to(@estudiante, :notice => 'Estudiante was successfully created.') }\n format.xml { render :xml => @estudiante, :status => :created, :location => @estudiante }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @estudiante.errors, :status => :unprocessable_entity }\n end\n end\n end", "def new\n \n @selecciones = Seleccion.where(\"cliente_id = ?\",usuario_actual.id)\n respond_to do |format|\n unless @selecciones.empty?\n @peso_total = Seleccion.peso_total(usuario_actual.id)\n @precio_total = Seleccion.precio_total(usuario_actual.id)\n @tarjetas = usuario_actual.tdc\n @orden = Orden.new(:direccion_entrega=>usuario_actual.direccion)\n t = Time.now\n fecha = t.strftime(\"%Y-%m-%d\")\n client = Savon::Client.new(\"http://192.168.1.121/DistribuidorFIF/webservices/servicio.php?wsdl\")\n preorden = \"<solicitud_pedido>\n <num_orden>001</num_orden>\n <nombre_comercio>Tukiosquito</nombre_comercio>\n <fecha_solicitud>\"+fecha.to_s+\"</fecha_solicitud>\n <nombre_cliente>\"+usuario_actual.nombre+\" \"+usuario_actual.apellido+\"</nombre_cliente>\n <direccion_comercio>\n <avenida>Sucre</avenida>\n <calle>-</calle>\n <edificio_casa>CC Millenium</edificio_casa>\n <local_apt>C1-15</local_apt>\n <parroquia>Leoncio Martinez</parroquia>\n <municipio>Sucre</municipio>\n <ciudad>Caracas</ciudad>\n <estado>Miranda</estado>\n <pais>Venezuela</pais>\n </direccion_comercio>\n <direccion_destino>\n <avenida>Santa Rosa</avenida>\n <calle>Tierras Rojas</calle>\n <edificio_casa>Villa Magica</edificio_casa>\n <local_apt>69</local_apt>\n <parroquia> </parroquia>\n <municipio>Zamora</municipio>\n <ciudad>Cua</ciudad>\n <estado>Miranda</estado>\n <pais>Venezuela</pais>\n </direccion_destino>\"\n @selecciones.each do |seleccion|\n p = Producto.find(seleccion.producto_id)\n preorden = preorden+\"\n <articulo>\n <id>\"+p.id.to_s+\"</id>\n <descripcion>\"+p.descripcion+\"</descripcion>\n <peso>\"+p.peso.to_s+\"</peso>\n <cantidad>\"+seleccion.cantidad.to_s+\"</cantidad>\n <precio>\"+p.precio.to_s+\"</precio>\n </articulo>\"\n end\n preorden = preorden+\"</solicitud_pedido>\"\n response = client.request :ejemplo, body: { \"value\" => preorden } \n if response.success? \n respuesta = response.to_hash[:ejemplo_response][:return]\n datos = XmlSimple.xml_in(respuesta)\n end\n\n @precio_envio = datos[\"num_orden\"][0]\n #@arreglo = XmlSimple.xml_in('')\n #@xml = XmlSimple.xml_out(@arreglo, { 'RootName' => 'solicitud_pedido' })\n #url = 'http://192.168.1.101/Antonio/tukyosquito/proyecto/servicio/servicio.php'\n #cotizacion = SOAP::RPC::Driver.new(url)\n #cotizacion.add_method('obtener','asd')\n #tdc = Tarjeta.where(\"id = ? AND cliente_id = ?\",params[:orden][:tarjeta_id],usuario_actual.id)\n #@respuesta = cotizacion.obtener('123')\n format.html # new.html.erb\n else\n format.html { redirect_to carrito_path, notice: 'No tiene productos agregados al carro de compras para generar una orden.' }\n end\n end\n end", "def destroy\n @evaluacione = Evaluacione.find(params[:id])\n @evaluacione.destroy\n\n respond_to do |format|\n format.html { redirect_to(evaluaciones_url) }\n format.xml { head :ok }\n end\n end", "def create\n @evaluation = Evaluation.new(evaluation_params)\n\n respond_to do |format|\n if @evaluation.save\n format.html { redirect_to @evaluation, notice: 'Evaluation was successfully created.' }\n format.json { render action: 'show', status: :created, location: @evaluation }\n else\n format.html { render action: 'new' }\n format.json { render json: @evaluation.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @evaluation = Evaluation.new(evaluation_params)\n\n respond_to do |format|\n if @evaluation.save\n format.html { redirect_to @evaluation, notice: 'Evaluation was successfully created.' }\n format.json { render action: 'show', status: :created, location: @evaluation }\n else\n format.html { render action: 'new' }\n format.json { render json: @evaluation.errors, status: :unprocessable_entity }\n end\n end\n end", "def presupuesto_params\n params.permit(:fechaPresentacion, :montoTotal, :aprobado, :proyecto_id, :restriccion_id, :usuario_id, :evaluado)\n end", "def new\n @estacion = Estacion.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @estacion }\n end\n end", "def create\n @evaluation = Evaluation.new(evaluation_params)\n @evaluation.course = @course\n respond_to do |format|\n if @evaluation.save\n format.html { redirect_to course_evaluations_url, notice: 'La evaluacion fue creada correctamente!' }\n else\n format.html { render :new }\n end\n end\n end", "def create\n @relatestagiario = Relatestagiario.new(params[:relatestagiario])\n\n respond_to do |format|\n if @relatestagiario.save\n flash[:notice] = 'RELATÓRIO SALVO COM SUCESSO.'\n format.html { redirect_to(@relatestagiario) }\n format.xml { render :xml => @relatestagiario, :status => :created, :location => @relatestagiario }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @relatestagiario.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @psicologic_evaluation = PsicologicEvaluation.new(psicologic_evaluation_params)\n\n respond_to do |format|\n if @psicologic_evaluation.save\n format.html { redirect_to @psicologic_evaluation, notice: 'Psicologic evaluation was successfully created.' }\n format.json { render :show, status: :created, location: @psicologic_evaluation }\n else\n format.html { render :new }\n format.json { render json: @psicologic_evaluation.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_evaluacion_servicio\n @evaluacion_servicio = EvaluacionServicio.find(params[:id])\n end", "def index\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @evaluators }\n end\n end", "def create\n @requisicion = Requisicion.new(params[:requisicion])\n\n respond_to do |format|\n if @requisicion.save\n format.html { redirect_to(@requisicion, :notice => 'Requisicion was successfully created.') }\n format.xml { render :xml => @requisicion, :status => :created, :location => @requisicion }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @requisicion.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @evaluation = Evaluation.new(evaluation_params)\n\n if @evaluation.save\n render :show, status: :created\n else\n render json: @evaluation.errors, status: :unprocessable_entity\n end\n end", "def enviar_factura(factura)\n begin\n logger.debug(\"...Iniciar enviar factura\")\n info = InfoGrupo.where('id_grupo = ?',factura['cliente']).first\n url = 'http://integra'+info[:numero].to_s+'.ing.puc.cl/api/facturas/recibir/'+factura['_id'].to_s\n #url = 'http://localhost:3000/api/facturas/recibir/'+factura['_id'].to_s\n request = Typhoeus::Request.new(\n url,\n method: :get,\n headers: { ContentType: \"application/json\"})\n response = request.run \n logger.debug(\"...Fin enviar factura\")\n return {:validado => true, :factura => factura}\n rescue => ex\n Applog.debug(ex.message,'enviar_factura')\n return {:validado => false, :factura => factura}\n end\nend", "def post_check(excon, body)\n excon.request(\n method: :post,\n path: '/check',\n headers: { 'Content-Type' => 'application/json' },\n body: body\n )\nend", "def create(name=\"Default Name\", age=\"50\")\r\n xml_req =\r\n \"<?xml version='1.0' encoding='UTF-8'?>\r\n <person>\r\n <name>#{name}</name>\r\n <age>#{age}</age>\r\n </person>\"\r\n \r\n request = Net::HTTP::Post.new(@url)\r\n request.add_field \"Content-Type\", \"application/xml\"\r\n request.body = xml_req\r\n \r\n http = Net::HTTP.new(@uri.host, @uri.port)\r\n response = http.request(request)\r\n response.body \r\n end", "def update\n doc = Nokogiri::XML(request.body.read)\n cvNode = doc.xpath('elwak/checklisten_vorlage')\n\n update_params = {inaktiv: cvNode.xpath('inaktiv').text.to_s.to_bool}\n respond_to do |format|\n if @checklisten_vorlage.update(update_params)\n format.xml {render :xml => '<?xml version=\"1.0\" encoding=\"UTF-8\"?><success />'}\n else\n format.xml {render :xml => '<?xml version=\"1.0\" encoding=\"UTF-8\"?><error />'}\n end\n end\n end", "def avanzar_evaluacion(usuario)\n unless self.Estatus.const_id == 'ST0028'\n self.errors.add(:solicitud, I18n.t('Sistema.Body.Modelos.Solicitud.Errores.estatus_no_adecuado'))\n else\n estatus_id_inicial = self.estatus_id\n fecha_evento = Time.now\n configuracion_avance = ConfiguracionAvance.find_by_estatus_origen_id(estatus_id_inicial)\n estatus_id_final = configuracion_avance.estatus_destino_id\n self.estatus_id = estatus_id_final\n self.fecha_actual_estatus = fecha_evento.strftime(\"%Y/%m/%d\")\n self.save\n ControlSolicitud.create_new(self.id, estatus_id_final, usuario, I18n.('Sistema.Body.General.avanzar'), estatus_id_inicial, '')\n end\n end", "def set_evaluacione\r\n @evaluacione = Evaluacione.find(params[:id])\r\n end", "def estaciones\n\n param_estacion = params[:estacion]\n param_fecha = params[:fecha].to_i\n @info_polens = InfoPolen.where({\"ESTACIONES\" => param_estacion, \"FECHA\" => param_fecha}).order_by(:TIPOS_POLINICOS.asc)\n\n respond_to do |format|\n format.html #{ redirect_to info_polens_url }\n format.json { render json: @info_polens }\n end\n end", "def create\n @frequencia_setor = Frequencia::Setor.new(params[:frequencia_setor])\n\n respond_to do |format|\n if @frequencia_setor.save\n format.html { redirect_to(@frequencia_setor, :notice => 'Setor salvo com sucesso.') }\n format.xml { render :xml => @frequencia_setor, :status => :created, :location => @frequencia_setor }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @frequencia_setor.errors, :status => :unprocessable_entity }\n end\n end\n end", "def puntaje #DESC: Ver su reporte de puntajes de una determinada evaluacion.\n @evaluacion = Evaluacion.find params[:evaluacion_id]\n if @evaluacion\n \n if params[:refresh_data] && current_user.tiene_perfil?(\"Administrador\")\n @evaluado = Evaluado.find_all_by_tipo(@evaluacion, @usuario)\n @evaluado.each do |e|\n @evaluacion.completar_evaluacion(e, e.usuario)\n end\n @usuario.asignar_resultado_por_competencia(@evaluacion)\n end\n @usuario_preguntas = @usuario.usuarios_preguntas.por_evaluacion(@evaluacion)\n\n #@porcentaje_competencia_esp = @usuario.porcentaje_competencias(@evaluacion,:especifica)\n #@porcentaje_competencia_gen = @usuario.porcentaje_competencias(@evaluacion,:general)\n\n # especificas=@usuario_preguntas.select{|p| (p.pregunta.competencia_tipo.match('especifica') and p.resultado>0)}\n # generales=@usuario_preguntas.select{|p| (p.pregunta.competencia_tipo.match('general') and p.resultado>0)}\n\n especificas=@usuario_preguntas.select{|p| (p.pregunta.competencia_tipo.match(/especifica/i))}\n generales=@usuario_preguntas.select{|p| (p.pregunta.competencia_tipo.match(/general/i))}\n\n suma=0\n cantidad=especificas.count\n especificas.each{ |e| suma+=e.resultado.to_f}\n @porcentaje_competencia_esp = cantidad > 0 ? (suma/(100*cantidad))*100 : 0\n divisor=cantidad > 0 ? 1 : 0\n suma=0\n cantidad=generales.count\n generales.each{ |g| suma+=g.resultado.to_f}\n @porcentaje_competencia_gen = cantidad > 0 ? (suma/(100*cantidad))*100 : 0\n divisor+=cantidad > 0 ? 1 : 0\n @cuantitativo = divisor > 0 ? (@porcentaje_competencia_gen + @porcentaje_competencia_esp) / divisor : 0\n\n @resultado_competencias=@usuario.resultados_competencias.por_evaluacion(@evaluacion)\n cantidad=@resultado_competencias.count\n suma=0\n @resultado_competencias.each{ |p| suma+=p.pares}\n @porcentaje_par = cantidad > 0 ? (suma/(100*cantidad))*100 : 0\n\n suma=0\n @resultado_competencias.each{ |p| suma+=p.jefes}\n @porcentaje_superior = cantidad > 0 ? (suma/(100*cantidad))*100 : 0\n\n suma=0\n @resultado_competencias.each{ |p| suma+=p.subordinados}\n @porcentaje_subordinado = cantidad > 0 ? (suma/(100*cantidad))*100 : 0\n\n suma=0\n @resultado_competencias.each{ |p| suma+=p.autoevaluacion}\n @porcentaje_autoevaluacion = cantidad > 0 ? (suma/(100*cantidad))*100 : 0\n\n @conclusiones = Evaluado.find_all_conclusiones(@usuario, @evaluacion)\n end\n end", "def post_spoonacular\n # %encode ingredients to url\n encoded_ingr = URI.escape(@translated_recipe[:ingredients_list])\n # post call block :\n url = URI(\"https://spoonacular-recipe-food-nutrition-v1.p.rapidapi.com/recipes/parseIngredients?includeNutrition=true\")\n http = Net::HTTP.new(url.host, url.port)\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n request = Net::HTTP::Post.new(url)\n request[\"content-type\"] = \"application/x-www-form-urlencoded\"\n request[\"x-rapidapi-key\"] = ENV[\"X_RAPIDAPI_KEY\"]\n request[\"x-rapidapi-host\"] = \"spoonacular-recipe-food-nutrition-v1.p.rapidapi.com\"\n # body of the call with ingredients and servings\n request.body = \"ingredientList=#{encoded_ingr}&#{@recipe_hash[:servings]}\"\n # response\n response = http.request(request)\n end", "def create\n @regra_negocio = RegraNegocio.new(regra_negocio_params)\n\n respond_to do |format|\n if @regra_negocio.save\n format.html { redirect_to @regra_negocio, notice: 'Regra negocio was successfully created.' }\n format.json { render :show, status: :created, location: @regra_negocio }\n else\n format.html { render :new }\n format.json { render json: @regra_negocio.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @regiaos = Regiao.new(params[:regiao])\n\n respond_to do |format|\n if @regiaos.save\n flash[:notice] = 'REGIÃO SALVA COM SUCESSO'\n format.html { redirect_to(new_regiao_path)}\n format.xml { render :xml => @regiaos, :status => :created, :location => @regiaos }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @regiaos.errors, :status => :unprocessable_entity }\n end\n end\n end", "def post(body)\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = true if uri.scheme == 'https'\n\n request = Net::HTTP::Post.new(uri)\n request['Content-Type'] = 'text/xml'\n request['Accept-Language'] = locale if locale\n request.body = body\n\n response = http.request(request)\n\n Response.new(response, uri)\n end", "def create\n @movimentode_estoque = MovimentodeEstoque.new(movimentode_estoque_params)\n\n respond_to do |format|\n if @movimentode_estoque.save\n format.html { redirect_to @movimentode_estoque, notice: 'Movimentode estoque was successfully created.' }\n format.json { render :show, status: :created, location: @movimentode_estoque }\n else\n format.html { render :new }\n format.json { render json: @movimentode_estoque.errors, status: :unprocessable_entity }\n end\n end\n end", "def post(url_variables:, body:)\n ensure_service_document\n\n end", "def post_xml_64(xml=:example_response)\n post \"/auth/saml/callback\", {'SAMLResponse' => load_xml_64(xml)}\nend", "def create\n @estadoproceso = Estadoproceso.new(estadoproceso_params)\n\n respond_to do |format|\n if @estadoproceso.save\n format.html { redirect_to @estadoproceso, notice: 'Estadoproceso was successfully created.' }\n format.json { render :show, status: :created, location: @estadoproceso }\n else\n format.html { render :new }\n format.json { render json: @estadoproceso.errors, status: :unprocessable_entity }\n end\n end\n end", "def respuestum_params\r\n params.require(:respuestum).permit( :encuestado_id, :encuestador_id, :evaluacion_id, :grupo_id, :respondida)\r\n end", "def evals_questions evaluation_id\n call_path = \"evals/questions\"\n request = {\"evaluationID\": evaluation_id}.to_json\n data = build_post_data(request)\n perform_post(build_url(call_path), data)\n end", "def create\n @respuesta = Respuesta.new(respuesta_params)\n\n respond_to do |format|\n if @respuesta.save\n format.html { redirect_to @respuesta, notice: 'Respuesta was successfully created.' }\n format.json { render :show, status: :created, location: api_v1_respuesta_url(@respuesta) }\n else\n format.html { render :new }\n format.json { render json: @respuesta.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @tipo_de_exercicio = TipoDeExercicio.new(params[:tipo_de_exercicio])\n\n respond_to do |format|\n if @tipo_de_exercicio.save\n flash[:notice] = 'TipoDeExercicio was successfully created.'\n format.html { redirect_to(@tipo_de_exercicio) }\n format.xml { render :xml => @tipo_de_exercicio, :status => :created, :location => @tipo_de_exercicio }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @tipo_de_exercicio.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @solicitud = Solicitud.new(params[:solicitud])\n \n respond_to do |format|\n if @solicitud.save\n flash[:notice] = 'Solicitud creada correctamente.'\n format.html { params[:oper].nil? ? redirect_to(@solicitud) : render(:text => \"Ok\")}\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @solicitud.errors, :status => :unprocessable_entity }\n end\n end\n end", "def post #:doc:\n end", "def respuesta_params\n params.require(:respuesta).permit(:consulta_id, :pregunta_id, :valor)\n end", "def create\n @situacoes_juridica = SituacoesJuridica.new(params[:situacoes_juridica])\n\n respond_to do |format|\n if @situacoes_juridica.save\n format.html { redirect_to(@situacoes_juridica, :notice => 'Situação jurídica cadastrada com sucesso.') }\n format.xml { render :xml => @situacoes_juridica, :status => :created, :location => @situacoes_juridica }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @situacoes_juridica.errors, :status => :unprocessable_entity }\n end\n end\n end", "def post\n resource.post(request, response)\n end", "def create\n @exura = Exura.new(params[:exura])\n\n respond_to do |format|\n if @exura.save\n format.html { redirect_to @exura, :notice => 'Exura was successfully created.' }\n format.json { render :json => @exura, :status => :created, :location => @exura }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @exura.errors, :status => :unprocessable_entity }\n end\n end\n end", "def post endpoint, data\n do_request :post, endpoint, data\n end", "def send_evaluate_prop\n task = @proposal.evaluate_proposals.create\n task.workbench = Organization.find params[:organization][:organization_id]\n task.save\n redirect_to :action => \"pending\"\n end", "def post_and_run(options)\n options[:eval_response] = true\n\n self.post options\n end", "def evaluation_params\n params.require(:evaluation).permit(:date, :time, :event, :name, :team, :parent, :email, :bodypart, :left, :right, :subjective, :visual, :palpation, :rom, :mmt, :neurological, :specialtests, :functionaltesting, :assessment, :plan, :rice, :taping, :mdreferral, :crutches, :instruction, :screen, :erreferral, :hospitalname, :notifiedparent, :whomnotified, :datetime)\n end", "def criterio_evalucion_servicio_params\n params.require(:criterio_evalucion_servicio).permit(:id_evalucion, :id_cat_criterio_eval, :calificacion_criterio)\n end", "def create\n @annee = Annee.new(params[:annee])\n\n respond_to do |format|\n if @annee.save\n #flash[:notice] = 'Année créée'\n format.html { redirect_to(annees_path) }\n format.xml { render :xml => @annee, :status => :created, :location => @annee }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @annee.errors, :status => :unprocessable_entity }\n end\n end\n end", "def corrigiendo_manualmente\n screen_name(\"#{@task.class.to_s}/corrigiendo_manualmente\")\n\n # Need a document\n check_for_target_document\n\n # Read it so we can display it\n @xml_text = get_dummy_text\n\n @am_result = AmResult.where(\"ot_id = #{@ot.id}\").order(\"run_date DESC\").first\n\n respond_to do |format|\n format.html { render action: \"corrigiendo_manualmente\" }\n format.json { head :ok }\n end\n end", "def evaluation_params\n params.require(:evaluation).permit(:title, :approbation_grade, :date)\n end", "def create\n @evaluation_criterium = EvaluationCriterium.new(params[:evaluation_criterium])\n\n respond_to do |format|\n if @evaluation_criterium.save\n format.html { redirect_to @evaluation_criterium, notice: 'Evaluation criterium was successfully created.' }\n format.json { render json: @evaluation_criterium, status: :created, location: @evaluation_criterium }\n else\n format.html { render action: \"new\" }\n format.json { render json: @evaluation_criterium.errors, status: :unprocessable_entity }\n end\n end\n end", "def post(uri, doc = nil, options = {})\n execute(uri, :post, options, doc)\n end" ]
[ "0.6443393", "0.61755776", "0.60337514", "0.6032301", "0.5985007", "0.5968063", "0.594564", "0.59177965", "0.5874566", "0.5771221", "0.57186526", "0.56468993", "0.564466", "0.5627873", "0.5609866", "0.55782497", "0.5567646", "0.55050796", "0.55003476", "0.5490839", "0.54872173", "0.54605854", "0.5456874", "0.5455567", "0.5443634", "0.54388016", "0.5423977", "0.53961635", "0.5394366", "0.5393835", "0.53535646", "0.5351831", "0.5349933", "0.5340432", "0.532282", "0.5311828", "0.53065944", "0.53049487", "0.5301942", "0.52988416", "0.5294016", "0.5292135", "0.5271671", "0.52575433", "0.52401435", "0.5231682", "0.5230414", "0.5220378", "0.5191291", "0.51898116", "0.5181724", "0.5181418", "0.51802665", "0.51802665", "0.5179594", "0.51706773", "0.51706296", "0.5166976", "0.5165726", "0.5156748", "0.5150492", "0.51497495", "0.51440066", "0.5137192", "0.51008517", "0.5095509", "0.5093785", "0.50740457", "0.5065249", "0.506361", "0.50633264", "0.50606185", "0.50580627", "0.5056821", "0.50541717", "0.50531495", "0.50530076", "0.5052376", "0.504667", "0.5041277", "0.5038183", "0.503621", "0.5032313", "0.50321084", "0.50238466", "0.5016243", "0.5014934", "0.50137275", "0.5012336", "0.49979365", "0.4997528", "0.49946335", "0.49941733", "0.49912956", "0.4990979", "0.4988377", "0.49849376", "0.49845716", "0.49842924", "0.49786636" ]
0.6520938
0
PUT /evaluaciones/1 PUT /evaluaciones/1.xml
def update @evaluacione = Evaluacione.find(params[:id]) respond_to do |format| if @evaluacione.update_attributes(params[:evaluacione]) format.html { redirect_to(@evaluacione, :notice => 'Evaluacione was successfully updated.') } format.xml { head :ok } else format.html { render :action => "edit" } format.xml { render :xml => @evaluacione.errors, :status => :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @evaluacion = Evaluacion.find(params[:id])\n\n respond_to do |format|\n if @evaluacion.update_attributes(params[:evaluacion])\n format.html { redirect_to @evaluacion, notice: 'Evaluacion was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @evaluacion.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @evaluacion_servicio.update(evaluacion_servicio_params)\n format.html { redirect_to @evaluacion_servicio, notice: 'Evaluacion servicio was successfully updated.' }\n format.json { render :show, status: :ok, location: @evaluacion_servicio }\n else\n format.html { render :edit }\n format.json { render json: @evaluacion_servicio.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @evaluo.update(evaluo_params)\n format.html { redirect_to @evaluo, notice: 'Evaluo was successfully updated.' }\n format.json { render :show, status: :ok, location: @evaluo }\n else\n format.html { render :edit }\n format.json { render json: @evaluo.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\r\n respond_to do |format|\r\n if @evaluacione.update(evaluacione_params)\r\n format.html { redirect_to @evaluacione, notice: 'Evaluacione was successfully updated.' }\r\n format.json { render :show, status: :ok, location: @evaluacione }\r\n else\r\n format.html { render :edit }\r\n format.json { render json: @evaluacione.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end", "def update\n @estoques = Estoque.find(params[:id])\n\n respond_to do |format|\n if @estoques.update_attributes(params[:estoque])\n flash[:notice] = 'ESTOQUE SALVO COM SUCESSO.'\n format.html { redirect_to(@estoques) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @estoques.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update opts = {}\n opts[:headers] ||= {}\n opts[:headers]['Content-Type'] ||= 'text/xml'\n post 'update', opts\n end", "def update\n @estagio = Estagio.find(params[:id])\n\n respond_to do |format|\n if @estagio.update_attributes(params[:estagio])\n flash[:notice] = 'Estagio was successfully updated.'\n format.html { redirect_to(@estagio) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @estagio.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @evaluation = Evaluation.find(params[:id])\n\n respond_to do |format|\n if @evaluation.update_attributes(params[:evaluation])\n format.html { redirect_to @evaluation, notice: 'Avaliacao atualizada com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @evaluation.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @evaluare = Evaluare.find(params[:id])\n\n respond_to do |format|\n if @evaluare.update_attributes(params[:evaluare])\n format.html { redirect_to @evaluare, notice: 'Evaluare was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @evaluare.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @frequencia_orgao = Frequencia::Orgao.find(params[:id])\n\n respond_to do |format|\n if @frequencia_orgao.update_attributes(params[:frequencia_orgao])\n format.html { redirect_to(@frequencia_orgao, :notice => 'Orgão atualizado com sucesso.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @frequencia_orgao.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @estagiarios = Estagiario.find(params[:id])\n\n respond_to do |format|\n if @estagiarios.update_attributes(params[:estagiario])\n flash[:notice] = 'ESTAGIÁRIO SALVO COM SUCESSO.'\n format.html { redirect_to(@estagiarios) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @estagiarios.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @evaluation = Evaluation.find(params[:id])\n\n respond_to do |format|\n if @evaluation.update_attributes(params[:evaluation])\n format.html { redirect_to(@evaluation, :notice => 'Evaluation was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @evaluation.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @evaluation = Evaluation.find(params[:id])\n\n respond_to do |format|\n if @evaluation.update_attributes(params[:evaluation])\n flash[:notice] = 'Evaluation was successfully updated.'\n format.html { redirect_to(@evaluation) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @evaluation.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @criterio_evalucion_servicio.update(criterio_evalucion_servicio_params)\n format.html { redirect_to @criterio_evalucion_servicio, notice: 'Criterio evalucion servicio was successfully updated.' }\n format.json { render :show, status: :ok, location: @criterio_evalucion_servicio }\n else\n format.html { render :edit }\n format.json { render json: @criterio_evalucion_servicio.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @estoque = Estoque.find(params[:id])\n\n respond_to do |format|\n if @estoque.update_attributes(params[:estoque])\n format.html { redirect_to @estoque, notice: 'Estoque was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @estoque.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @estatu = Estatu.find(params[:id])\n\n respond_to do |format|\n if @estatu.update_attributes(params[:estatu])\n format.html { redirect_to(@estatu, :notice => 'Registro actualizado correctamente.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @estatu.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @frequencia_setor = Frequencia::Setor.find(params[:id])\n\n respond_to do |format|\n if @frequencia_setor.update_attributes(params[:frequencia_setor])\n format.html { redirect_to(@frequencia_setor, :notice => 'Setor atualizado com sucesso.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @frequencia_setor.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @estudiante = Estudiante.find(params[:id])\n\n respond_to do |format|\n if @estudiante.update_attributes(params[:estudiante])\n flash[:notice] = 'Actualizado.'\n format.html { redirect_to(@estudiante) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @estudiante.errors, :status => :unprocessable_entity }\n end\n end\n end", "def test_put_expenses_1_xml\n @parameters = {:expense => {:description => 'NewDescription'}}\n if ActiveRecord::VERSION::MAJOR < 4\n Redmine::ApiTest::Base.should_allow_api_authentication(:put,\n '/expenses/1.xml',\n {:expense => {:description => 'NewDescription'}},\n {:success_code => :ok})\n end\n\n assert_no_difference('Expense.count') do\n put '/expenses/1.xml', @parameters, credentials('admin')\n end\n\n expense = Expense.find(1)\n assert_equal \"NewDescription\", expense.description\n end", "def set_evaluacion_servicio\n @evaluacion_servicio = EvaluacionServicio.find(params[:id])\n end", "def update\n @supervisor_estagio = SupervisorEstagio.find(params[:id])\n\n respond_to do |format|\n if @supervisor_estagio.update_attributes(params[:supervisor_estagio])\n flash[:notice] = 'Supervisor de Estagio atualizado com sucesso.'\n format.html { redirect_to(@supervisor_estagio) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @supervisor_estagio.errors, :status => :unprocessable_entity }\n end\n end\n end", "def set_evaluacion\n @evaluacion = Evaluacion.find(params[:id])\n end", "def put(uri, xml)\r\n req = Net::HTTP::Put.new(uri)\r\n req[\"content-type\"] = \"application/xml\"\r\n req.body = xml\r\n request(req)\r\n end", "def update\n @exercicio = Exercicio.find(params[:id])\n\n respond_to do |format|\n if @exercicio.update_attributes(params[:exercicio])\n flash[:notice] = 'Exercicio was successfully updated.'\n format.html { redirect_to(@exercicio) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @exercicio.errors, :status => :unprocessable_entity }\n end\n end\n end", "def set_evaluacion\n @evaluacions = Evaluacion.find(params[:id])\n end", "def update\n respond_to do |format|\n if @anstoeval.update(anstoeval_params)\n format.html { redirect_to @anstoeval, notice: 'anstoeval was successfully updated.' }\n format.json { render :show, status: :ok, location: @anstoeval }\n else\n format.html { render :edit }\n format.json { render json: @anstoeval.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @orc_suplementacao = OrcSuplementacao.find(params[:id])\n\n respond_to do |format|\n if @orc_suplementacao.update_attributes(params[:orc_suplementacao])\n flash[:notice] = 'SALVO COM SUCESSO.'\n format.html { redirect_to(@orc_suplementacao) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @orc_suplementacao.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @evaluation.update(evaluation_params)\n format.html { redirect_to @evaluation, notice: 'La evaluación fue actualizada correctamente' }\n format.json { render :show, status: :ok, location: @evaluation }\n else\n format.html { render :edit }\n format.json { render json: @evaluation.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @estatuto = Estatuto.find(params[:id])\n\n respond_to do |format|\n if @estatuto.update_attributes(params[:estatuto])\n format.html { redirect_to @estatuto, notice: 'Estatuto was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @estatuto.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @tipo_de_exercicio = TipoDeExercicio.find(params[:id])\n\n respond_to do |format|\n if @tipo_de_exercicio.update_attributes(params[:tipo_de_exercicio])\n flash[:notice] = 'TipoDeExercicio was successfully updated.'\n format.html { redirect_to(@tipo_de_exercicio) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @tipo_de_exercicio.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @requisicion = Requisicion.find(params[:id])\n\n respond_to do |format|\n if @requisicion.update_attributes(params[:requisicion])\n format.html { redirect_to(@requisicion, :notice => 'Requisicion was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @requisicion.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @estudiante = Estudiante.find(params[:id])\n\n respond_to do |format|\n if @estudiante.update_attributes(params[:estudiante])\n format.html { redirect_to(@estudiante, :notice => 'Estudiante was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @estudiante.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update_rest\n @question_localized = QuestionLocalized.find(params[:id])\n\n respond_to do |format|\n if @question_localized.update_attributes(params[:question_localized])\n flash[:notice] = 'QuestionLocalized was successfully updated.'\n format.html { redirect_to(@question_localized) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @question_localized.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @evaluation.update(evaluation_params)\n format.html { redirect_to @evaluation, notice: 'Avaliação atualizada.' }\n format.json { render :show, status: :ok, location: @evaluation }\n else\n format.html { render :edit }\n format.json { render json: @evaluation.errors, status: :unprocessable_entity }\n end\n end\n end", "def test_put_invoices_1_xml\n @parameters = {:invoice => {:number => 'NewNumber'}}\n \n Redmine::ApiTest::Base.should_allow_api_authentication(:put,\n '/invoices/1.xml',\n {:invoice => {:number => 'NewNumber'}},\n {:success_code => :ok})\n \n assert_no_difference('Invoice.count') do\n put '/invoices/1.xml', @parameters, credentials('admin')\n end\n \n invoice = Invoice.find(1)\n assert_equal \"NewNumber\", invoice.number\n \n end", "def update\n doc = Nokogiri::XML(request.body.read)\n cvNode = doc.xpath('elwak/checklisten_vorlage')\n\n update_params = {inaktiv: cvNode.xpath('inaktiv').text.to_s.to_bool}\n respond_to do |format|\n if @checklisten_vorlage.update(update_params)\n format.xml {render :xml => '<?xml version=\"1.0\" encoding=\"UTF-8\"?><success />'}\n else\n format.xml {render :xml => '<?xml version=\"1.0\" encoding=\"UTF-8\"?><error />'}\n end\n end\n end", "def update\n @estacionamiento = Estacionamiento.find(params[:id])\n\n respond_to do |format|\n if @estacionamiento.update_attributes(params[:estacionamiento])\n format.html { redirect_to @estacionamiento, notice: 'Estacionamiento was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @estacionamiento.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @movimentacao_de_estoque = MovimentacaoDeEstoque.find(params[:id])\n\n respond_to do |format|\n if @movimentacao_de_estoque.update_attributes(params[:movimentacao_de_estoque])\n format.html { redirect_to @movimentacao_de_estoque, notice: 'Movimentacao de estoque was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @movimentacao_de_estoque.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_evaluacione\r\n @evaluacione = Evaluacione.find(params[:id])\r\n end", "def update\n if ENV[\"NEW_EVALUATION\"] == nil\n raise ActionController::RoutingError\n return\n end\n respond_to do |format|\n if @evaluation.update(evaluation_params)\n format.html { redirect_to @evaluation, notice: 'Evaluation was successfully updated.' }\n format.json { render :show, status: :ok, location: @evaluation }\n else\n format.html { render :edit }\n format.json { render json: @evaluation.errors, status: :unprocessable_entity }\n end\n end\n end", "def actualizacion \n fiesta.update (params[:id]) \n render json: fiesta\n end", "def update\n @respuesta = Respuesta.find(params[:id])\n\n if @respuesta.update(params[:respuesta])\n head :no_content\n else\n render json: @respuesta.errors, status: :unprocessable_entity\n end\n end", "def update\n @exura = Exura.find(params[:id])\n\n respond_to do |format|\n if @exura.update_attributes(params[:exura])\n format.html { redirect_to @exura, :notice => 'Exura was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @exura.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @situacoes_juridica = SituacoesJuridica.find(params[:id])\n\n respond_to do |format|\n if @situacoes_juridica.update_attributes(params[:situacoes_juridica])\n format.html { redirect_to(@situacoes_juridica, :notice => 'Situação jurídica atualizada com sucesso.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @situacoes_juridica.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @evaluation.update(evaluation_params)\n format.html { redirect_to course_evaluations_url, notice: 'La evaluación fue modificada correctamente!' }\n else\n format.html { render :edit }\n end\n end\n end", "def update\n @prestamo = Prestamo.find(params[:id])\n\n respond_to do |format|\n if @prestamo.update_attributes(params[:prestamo])\n flash[:notice] = 'Prestamo actualizado correctamente.'\n format.html { redirect_to(@prestamo) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @prestamo.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @relatorios = Relatorio.find(params[:id])\n\n respond_to do |format|\n if @relatorios.update_attributes(params[:relatorio])\n flash[:notice] = 'RELATORIO SALVO COM SUCESSO.'\n format.html { redirect_to(@relatorios) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @relatorios.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @tipo_de_documento = TipoDeDocumento.find(params[:id])\n\n respond_to do |format|\n if @tipo_de_documento.update_attributes(params[:tipo_de_documento])\n format.html { redirect_to(@tipo_de_documento, :notice => 'Tipo de documento atualizado com sucesso.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @tipo_de_documento.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @expression = Expression.find(params[:id])\n\n respond_to do |format|\n if @expression.update_attributes(params[:expression])\n flash[:notice] = 'Expression was successfully updated.'\n format.html { redirect_to(@expression) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @expression.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update_rest\n @answer_localized = AnswerLocalized.find(params[:id])\n\n respond_to do |format|\n if @answer_localized.update_attributes(params[:answer_localized])\n flash[:notice] = 'AnswerLocalized was successfully updated.'\n format.html { redirect_to(@answer_localized) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @answer_localized.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @estadocivil.update(estadocivil_params)\n format.html { redirect_to @estadocivil, notice: 'Estadocivil was successfully updated.' }\n format.json { render :show, status: :ok, location: @estadocivil }\n else\n format.html { render :edit }\n format.json { render json: @estadocivil.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @relatestagiario = Relatestagiario.find(params[:id])\n\n respond_to do |format|\n if @relatestagiario.update_attributes(params[:relatestagiario])\n flash[:notice] = 'RELATÓRIO SALVO COM SUCESSO.'\n format.html { redirect_to(@relatestagiario) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @relatestagiario.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @oferta_academica = OfertaAcademica.find(params[:id])\n\n if @oferta_academica.update(params[:oferta_academica])\n head :no_content\n else\n render json: @oferta_academica.errors, status: :unprocessable_entity\n end\n end", "def update\n @solicitudrecurso = Solicitudrecurso.find(params[:id])\n \n\n respond_to do |format|\n\n \n if @solicitudrecurso.update_attributes(:motivos => params[:motivos])\n \n @solicitudrecursos = Solicitudrecurso.find_all_by_usuario_id(@usuario_actual.id)\n format.html { redirect_to :action => \"index\" }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @solicitudrecurso.errors, :status => :unprocessable_entity }\n end\n \n end\n end", "def update\n respond_to do |format|\n if @predio.update(predio_params)\n format.html { redirect_to @predio, notice: 'Predio foi alterado com sucesso.' }\n format.json { render :show, status: :ok, location: @predio }\n else\n format.html { render :edit }\n format.json { render json: @predio.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @interventoriasfecha = Interventoriasfecha.find(params[:id])\n\n respond_to do |format|\n if @interventoriasfecha.update_attributes(params[:interventoriasfecha])\n format.html { redirect_to(@interventoriasfecha, :notice => 'Interventoriasfecha was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @interventoriasfecha.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update(id, name=\"Updated Name\", age=\"55\")\r\n xml_req =\r\n \"<?xml version='1.0' encoding='UTF-8'?>\r\n <person>\r\n <id type='integer'>#{id}</id>\r\n <name>#{name}</name>\r\n <age>#{age}</age> \r\n </person>\"\r\n request = Net::HTTP::Put.new(\"#{@url}/#{id}.xml\")\r\n request.add_field \"Content-Type\", \"application/xml\"\r\n request.body = xml_req\r\n http = Net::HTTP.new(@uri.host, @uri.port)\r\n response = http.request(request)\r\n # no response body will be returned\r\n case response\r\n when Net::HTTPSuccess\r\n return \"#{response.code} OK\"\r\n else\r\n return \"#{response.code} ERROR\"\r\n end\r\n end", "def update\n @documentoclasificacion = Documentoclasificacion.find(params[:id])\n\n respond_to do |format|\n if @documentoclasificacion.update_attributes(params[:documentoclasificacion])\n format.html { redirect_to(@documentoclasificacion, :notice => 'Documentoclasificacion was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @documentoclasificacion.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @questao = Questao.find(params[:id])\n\n respond_to do |format|\n if @questao.update_attributes(params[:questao])\n format.html { redirect_to(@questao, :notice => 'Questao was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @questao.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @eval = Eval.find(params[:id])\n if @eval.update_attributes(params[:eval])\n flash[:notice] = \"Eval was successfully updated.\"\n respond_with(@eval)\n else\n respond_with(@eval.errors)\n end\n end", "def update\n @convenio = Convenio.find(params[:id])\n\n respond_to do |format|\n if @convenio.update_attributes(params[:convenio])\n format.html { redirect_to(@convenio, :notice => 'Convenio was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @convenio.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @calidadtiposdocumento = Calidadtiposdocumento.find(params[:id])\n\n respond_to do |format|\n if @calidadtiposdocumento.update_attributes(params[:calidadtiposdocumento])\n format.html { redirect_to(@calidadtiposdocumento, :notice => 'Calidadtiposdocumento was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @calidadtiposdocumento.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @escola = Escola.find(params[:id])\n\n respond_to do |format|\n if @escola.update_attributes(params[:escola])\n format.html { redirect_to @escola, :notice => 'Escola was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @escola.errors, :status => :unprocessable_entity }\n end\n end\n end", "def put!\n request! :put\n end", "def update\n @valor_sistema = ValorSistema.find(params[:id])\n\n respond_to do |format|\n if @valor_sistema.update_attributes(params[:valor_sistema])\n flash[:notice] = 'ValorSistema was successfully updated.'\n format.html { redirect_to(@valor_sistema) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @valor_sistema.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @iguanasactualizacion = Iguanasactualizacion.find(params[:id])\n\n respond_to do |format|\n if @iguanasactualizacion.update_attributes(params[:iguanasactualizacion])\n format.html { redirect_to(@iguanasactualizacion, :notice => 'Iguanasactualizacion was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @iguanasactualizacion.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @evaluation.update(evaluation_params)\n format.html { redirect_to @evaluation, notice: 'Evaluation was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @evaluation.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @evaluation.update(evaluation_params)\n format.html { redirect_to @evaluation, notice: 'Evaluation was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @evaluation.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @regiaos = Regiao.find(params[:id])\n\n respond_to do |format|\n if @regiaos.update_attributes(params[:regiao])\n flash[:notice] = 'REGIÃO SALVA COM SUCESSO'\n format.html { redirect_to(@regiaos) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @regiaos.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @servicio = Servicio.find(params[:id])\n\n respond_to do |format|\n if @servicio.update_attributes(params[:servicio])\n format.html { redirect_to @servicio, :notice => 'Servicio was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @servicio.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @ventas_presupuesto = Ventas::Presupuesto.find(params[:id])\n\n respond_to do |format|\n if @ventas_presupuesto.update_attributes(params[:ventas_presupuesto])\n format.html { redirect_to @ventas_presupuesto, notice: 'Presupuesto was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @ventas_presupuesto.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @reputacao_veiculo = ReputacaoVeiculo.find(params[:id])\n\n respond_to do |format|\n if @reputacao_veiculo.update_attributes(params[:reputacao_veiculo])\n format.html { redirect_to(@reputacao_veiculo, :notice => 'A reputacao do veiculo foi atualizada com sucesso.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @reputacao_veiculo.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @nossos_servico = NossosServico.find(params[:id])\n\n respond_to do |format|\n if @nossos_servico.update_attributes(params[:nossos_servico])\n format.html { redirect_to(@nossos_servico, :notice => 'Nossos servico was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @nossos_servico.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @movimentode_estoque.update(movimentode_estoque_params)\n format.html { redirect_to @movimentode_estoque, notice: 'Movimentode estoque was successfully updated.' }\n format.json { render :show, status: :ok, location: @movimentode_estoque }\n else\n format.html { render :edit }\n format.json { render json: @movimentode_estoque.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @visarequest = Visarequest.find(params[:id])\n\n respond_to do |format|\n if @visarequest.update_attributes(params[:visarequest])\n flash[:notice] = 'Visarequest was successfully updated.'\n format.html { redirect_to(@visarequest) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @visarequest.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n if @evaluation.update(evaluation_params)\n flash[:success] = 'Actualizado correctamente'\n redirect_to evaluations_url\n else\n flash[:danger] = 'Ocurrió un error'\n render :edit\n end\n end", "def update\n @requerimiento = Requerimiento.find(params[:id])\n\n respond_to do |format|\n if @requerimiento.update_attributes(params[:requerimiento])\n format.html { redirect_to \"#{requerimientos_path}/#{@requerimiento.numero}\", notice: 'Requerimiento was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @requerimiento.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @respuesta = Respuesta.find(params[:id])\n\n respond_to do |format|\n if @respuesta.update_attributes(params[:respuesta])\n format.html { redirect_to @respuesta, notice: 'Respuesta was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @respuesta.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @solicitud_servicio = SolicitudServicio.find(params[:id])\n\n respond_to do |format|\n if @solicitud_servicio.update_attributes(params[:solicitud_servicio])\n format.html { redirect_to @solicitud_servicio, notice: 'Solicitud servicio was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @solicitud_servicio.errors, status: :unprocessable_entity }\n end\n end\n end", "def update options={}\n client.put(\"/#{id}\", options)\n end", "def update\n @matriz = Matriz.find(params[:id])\n @niveis = NiveisEnsino.order(:nome).collect{|n|[n.nome,n.id]}\n\n respond_to do |format|\n if @matriz.update_attributes(params[:matriz])\n format.html { redirect_to(@matriz, :notice => 'Matriz atualizado com sucesso.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @matriz.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @senhas = Senha.find(params[:id])\n\n respond_to do |format|\n if @senhas.update_attributes(params[:senha])\n flash[:notice] = 'SENHA SALVA COM SUCESSO.'\n format.html { redirect_to(senhas_path) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @senhas.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @coordenador_estagio = CoordenadorEstagio.find(params[:id])\n\n respond_to do |format|\n if @coordenador_estagio.update_attributes(params[:coordenador_estagio])\n format.html { redirect_success(\"Coordenador alterado com sucesso!\",:coordenador_estagio, :index)}\n format.json { head :no_content }\n else\n format.html { redirect_error(\"Erro ao alterar coordenador!\",:coordenador_estagio, :index)}\n format.json { render json: @coordenador_estagio.errors, status: :unprocessable_entity }\n end\n end\n end", "def suscribe\n @estate = Estate.find(params[:id])\n @estate.update_attribute(:status, true)\n respond_to do |format|\n format.html { redirect_to estates_url, notice: 'Propiedad publicada exitosamente.' }\n format.json { head :no_content }\n end\n end", "def update\n @inscripcione = Inscripcione.find(params[:id])\n\n respond_to do |format|\n if @inscripcione.update_attributes(params[:inscripcione])\n format.html { redirect_to(@inscripcione, :notice => 'Inscripcione was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @inscripcione.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @exp = Exp.find(params[:id])\n\n respond_to do |format|\n if @exp.update_attributes(params[:exp])\n flash[:notice] = 'Exp was successfully updated.'\n format.html { redirect_to(@exp) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @exp.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @suministro = Suministro.find(params[:id])\n\n respond_to do |format|\n if @suministro.update_attributes(params[:suministro])\n format.html { redirect_to(@suministro, :notice => 'Suministro was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @suministro.errors, :status => :unprocessable_entity }\n end\n end\n end", "def set_evaluo\n @evaluo = Evaluo.find(params[:id])\n end", "def update\n @articulo = Articulo.find(params[:id])\n\n respond_to do |format|\n if @articulo.update_attributes(params[:articulo])\n flash[:notice] = ''\n format.html { redirect_to(articulos_url) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @articulo.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @voluntario = Voluntario.find(params[:id])\n params[:voluntario].delete :inclusoes\n\n respond_to do |format|\n if @voluntario.update_attributes(params[:voluntario])\n format.html { redirect_to(@voluntario, :notice => 'Voluntário atualizado com sucesso.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @voluntario.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @vigencia = Vigencia.find(params[:id])\n\n respond_to do |format|\n if @vigencia.update_attributes(params[:vigencia])\n format.html { redirect_to(@vigencia, :notice => 'Vigencia was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @vigencia.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @recursorevision = @solicitud.recursosrevision.find(params[:id])\n\n respond_to do |format|\n if @recursorevision.update_attributes(params[:recursorevision])\n format.html { redirect_to([@solicitud,@recursorevision], :notice => 'Recurso revisión actualizado con exito.') }\n format.xml { head :ok }\n else \n format.html { render :action => \"edit\" }\n format.xml { render :xml => @recursorevision.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @peca = Peca.find(params[:id])\n\n respond_to do |format|\n if @peca.update_attributes(params[:peca])\n flash[:notice] = 'Peça atualizada com sucesso.'\n format.html { redirect_to(@peca) }\n format.xml { head :ok }\n else\n flash[:notice] = 'O formulário contém erros. Verifique os campos digitados e tente novamente.'\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @peca.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @sivic_discipulo.update(sivic_discipulo_params_netested)\n format.html { redirect_to @sivic_discipulo, notice: 'Registro alterado com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @sivic_discipulo.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @ejercicio = Ejercicio.find(params[:id])\n\n respond_to do |format|\n if @ejercicio.update_attributes(params[:ejercicio])\n format.html { redirect_to @ejercicio, notice: 'Ejercicio was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @ejercicio.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @recurso = Recurso.find(params[:id])\n\n respond_to do |format|\n if @recurso.update_attributes(params[:recurso])\n format.html { redirect_to @recurso, notice: 'O recurso de auto de infração foi atualizado com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @recurso.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @agronomiaquimica = Agronomiaquimica.find(params[:id])\n\n respond_to do |format|\n if @agronomiaquimica.update_attributes(params[:agronomiaquimica])\n format.html { redirect_to @agronomiaquimica, notice: 'Agronomiaquimica was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @agronomiaquimica.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @seguro = Seguro.find(params[:id])\n\n respond_to do |format|\n if @seguro.update_attributes(params[:seguro])\n format.html { redirect_to @seguro, notice: 'Seguro was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @seguro.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @revenu = @foyer.revenus.find(params[:id])\n\n respond_to do |format|\n if @revenu.update_attributes(params[:revenu])\n flash[:notice] = 'Revenu a bien été mis à jour.'\n format.html { redirect_to foyer_revenus_url(@foyer) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @revenu.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @vocacionada = Vocacionada.find(params[:id])\n\n respond_to do |format|\n if @vocacionada.update_attributes(params[:vocacionada])\n format.html { redirect_to vocacionadas_url}\n flash[:notice] = \"Registro alterado com sucesso!\"\n else\n format.html { render action: \"edit\" }\n format.json { render json: @vocacionada.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.6807242", "0.6507722", "0.6355236", "0.63372445", "0.6139806", "0.6082772", "0.6077134", "0.6025371", "0.6008826", "0.5974862", "0.59637237", "0.5961347", "0.59553313", "0.5954125", "0.5931183", "0.5917951", "0.59129953", "0.59085566", "0.5891922", "0.5878923", "0.5829348", "0.5824295", "0.5810756", "0.58074015", "0.5786751", "0.5780703", "0.5768973", "0.57570636", "0.5750563", "0.5744423", "0.5728171", "0.57068855", "0.56995445", "0.56968474", "0.5690202", "0.56842554", "0.56689775", "0.5666723", "0.5663659", "0.5659028", "0.5651121", "0.56344604", "0.56182873", "0.5615529", "0.56078947", "0.5595029", "0.55925924", "0.5591691", "0.55912983", "0.55878675", "0.55870867", "0.5583324", "0.55767393", "0.5569706", "0.5564378", "0.556429", "0.5549932", "0.5542963", "0.5539645", "0.55359554", "0.55358046", "0.55357695", "0.55297834", "0.5529571", "0.5528795", "0.5527153", "0.5519383", "0.5519383", "0.551757", "0.5511259", "0.5503654", "0.550264", "0.5501514", "0.550143", "0.5500829", "0.5498953", "0.54972637", "0.5495341", "0.5492025", "0.54901326", "0.5485737", "0.5472379", "0.5470559", "0.54701734", "0.54677695", "0.5467744", "0.5466151", "0.546559", "0.5465223", "0.546433", "0.5462749", "0.5462074", "0.545998", "0.5458291", "0.54577464", "0.5456272", "0.54552037", "0.54547954", "0.54446954", "0.54435176" ]
0.6813215
0
DELETE /evaluaciones/1 DELETE /evaluaciones/1.xml
def destroy @evaluacione = Evaluacione.find(params[:id]) @evaluacione.destroy respond_to do |format| format.html { redirect_to(evaluaciones_url) } format.xml { head :ok } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @evaluacion = Evaluacion.find(params[:id])\n @evaluacion.destroy\n\n respond_to do |format|\n format.html { redirect_to evaluaciones_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @estacion = Estacion.find(params[:id])\n @estacion.destroy\n\n respond_to do |format|\n format.html { redirect_to(estaciones_url) }\n format.xml { head :ok }\n end\n end", "def netdev_resxml_delete( xml )\n top = netdev_resxml_top( xml )\n par = top.instance_variable_get(:@parent)\n par['delete'] = 'delete'\n end", "def destroy\n RestClient.delete \"#{REST_API_URI}/contents/#{id}.xml\" \n self\n end", "def destroy\r\n @evaluacione.destroy\r\n respond_to do |format|\r\n format.html { redirect_to evaluaciones_url, notice: 'Evaluacione was successfully destroyed.' }\r\n format.json { head :no_content }\r\n end\r\n end", "def delete()\n response = send_post_request(@xml_api_delete_path)\n response.is_a?(Net::HTTPSuccess) or response.is_a?(Net::HTTPRedirection)\n end", "def destroy\n @evaluation = Evaluation.find(params[:id])\n @evaluation.destroy\n\n respond_to do |format|\n format.html { redirect_to(evaluations_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @evaluation = Evaluation.find(params[:id])\n @evaluation.destroy\n\n respond_to do |format|\n format.html { redirect_to(evaluations_url) }\n format.xml { head :ok }\n end\n end", "def destroy\r\n @evaluation = Evaluation.find(params[:id])\r\n @evaluation.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_to(evaluations_url) }\r\n format.xml { head :ok }\r\n end\r\n end", "def destroy\n @relatestagiario = Relatestagiario.find(params[:id])\n @relatestagiario.destroy\n\n respond_to do |format|\n format.html { redirect_to(relatestagiarios_url) }\n format.xml { head :ok }\n end\n end", "def delete()\n response = send_post_request(@xml_api_delete_path)\n response.is_a?(Net::HTTPSuccess) or response.is_a?(Net::HTTPRedirection)\n end", "def destroy\n @evaluo.destroy\n respond_to do |format|\n format.html { redirect_to evaluos_url, notice: 'Evaluo was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @frequencia_setor = Frequencia::Setor.find(params[:id])\n @frequencia_setor.destroy\n\n respond_to do |format|\n format.html { redirect_to(frequencia_setores_url) }\n format.xml { head :ok }\n end\n end", "def delete_data(index_name)\n uri = @client.make_uri(\"/#{index_name}/update/\")\n req = HTTP::Post.new(uri)\n req.content_type = 'text/xml'\n req.body = '<delete><query>*:*</query></delete>'\n response = @client.send_http(req, true, ['200'])\n end", "def destroy\n @requisicao = Requisicao.find(params[:id])\n @requisicao.destroy\n\n respond_to do |format|\n format.html { redirect_to(requisicoes_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @documentoclasificacion = Documentoclasificacion.find(params[:id])\n @documentoclasificacion.destroy\n\n respond_to do |format|\n format.html { redirect_to(documentoclasificaciones_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @estudiante = Estudiante.find(params[:id])\n @estudiante.destroy\n\n respond_to do |format|\n format.html { redirect_to(estudiantes_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @estudiante = Estudiante.find(params[:id])\n @estudiante.destroy\n\n respond_to do |format|\n format.html { redirect_to(estudiantes_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @convenio = Convenio.find(params[:id])\n @convenio.destroy\n\n respond_to do |format|\n format.html { redirect_to(convenios_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @evaluacion_servicio.destroy\n respond_to do |format|\n format.html { redirect_to evaluacion_servicios_url, notice: 'Evaluacion servicio was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @requisicion = Requisicion.find(params[:id])\n @requisicion.destroy\n\n respond_to do |format|\n format.html { redirect_to(requisicions_url) }\n format.xml { head :ok }\n end\n end", "def destroy\r\n @asignacionexa = Asignacionlabexa.find(params[:id])\r\n @asignacionexa.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_to(asignacionlabexas_url) }\r\n format.xml { head :ok }\r\n end\r\n end", "def destroy\n @recurso = Recurso.find(params[:id])\n @recurso.destroy\n\n respond_to do |format|\n format.html { redirect_to(recursos_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @frequencia_orgao = Frequencia::Orgao.find(params[:id])\n @frequencia_orgao.destroy\n\n respond_to do |format|\n format.html { redirect_to(frequencia_orgaos_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @estatu = Estatu.find(params[:id])\n @estatu.destroy\n\n respond_to do |format|\n format.html { redirect_to(estatus_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @calidadtiposdocumento = Calidadtiposdocumento.find(params[:id])\n @calidadtiposdocumento.destroy\n\n respond_to do |format|\n format.html { redirect_to(calidadtiposdocumentos_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @iguanasactualizacion = Iguanasactualizacion.find(params[:id])\n @iguanasactualizacion.destroy\n\n respond_to do |format|\n format.html { redirect_to(iguanasactualizaciones_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @documento = Documento.find(params[:id])\n @documento.destroy\n\n respond_to do |format|\n format.html { redirect_to(documentos_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @entrada = Entrada.find(params[:id])\n @entrada.destroy\n\n respond_to do |format|\n format.html { redirect_to(mngr_entradas_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @documento = @externo.documentos.find(params[:id])\n @documento.destroy\n\n respond_to do |format|\n format.html { redirect_to(documentos_url(@externo)) }\n format.xml { head :ok }\n end\n end", "def destroy\n @evaluation.destroy\n respond_to do |format|\n format.html { redirect_to evaluations_url, notice: 'La evaluación fue eliminada satisfactoriamente' }\n format.json { head :no_content }\n end\n end", "def destroy\n @exercicio = Exercicio.find(params[:id])\n @exercicio.destroy\n\n respond_to do |format|\n format.html { redirect_to(exercicios_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @config_xml = ConfigXml.find(params[:id])\n @config_xml.destroy\n\n respond_to do |format|\n format.html { redirect_to(config_xmls_url) }\n format.xml { head :ok }\n end\n rescue ActiveRecord::RecordNotFound => e\n prevent_access(e)\n end", "def destroy\n @tipo_de_exercicio = TipoDeExercicio.find(params[:id])\n @tipo_de_exercicio.destroy\n\n respond_to do |format|\n format.html { redirect_to(tipo_de_exercicios_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @expedicao = Expedicao.find(params[:id])\n @expedicao.destroy\n\n respond_to do |format|\n format.html { redirect_to(expedicoes_url) }\n format.xml { head :ok }\n end\n end", "def delete!\n Recliner.delete(uri)\n end", "def destroy\n @evaluare = Evaluare.find(params[:id])\n @evaluare.destroy\n\n respond_to do |format|\n format.html { redirect_to evaluares_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @adjunto = Adjunto.find(params[:id])\n @adjunto.destroy\n\n respond_to do |format|\n format.html { redirect_to(adjuntos_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @correspondenciasasignada = Correspondenciasasignada.find(params[:id])\n @correspondenciasasignada.destroy\n\n respond_to do |format|\n format.html { redirect_to(correspondenciasasignadas_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @docderivacione.destroy\n respond_to do |format|\n format.html { redirect_to docderivaciones_url, notice: 'Docderivacione was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @estagio = Estagio.find(params[:id])\n @estagio.destroy\n\n respond_to do |format|\n format.html { redirect_to(estagios_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @tipo_de_documento = TipoDeDocumento.find(params[:id])\n @tipo_de_documento.destroy\n\n respond_to do |format|\n format.html { redirect_to(tipos_de_documento_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @expression = Expression.find(params[:id])\n @expression.destroy\n\n respond_to do |format|\n format.html { redirect_to(expressions_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @motivo_assistencia = MotivoAssistencia.find(params[:id])\n @motivo_assistencia.destroy\n\n respond_to do |format|\n format.html { redirect_to(motivos_assistencia_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @aplicacion = Aplicacion.find(params[:id])\n @aplicacion.destroy\n\n respond_to do |format|\n format.html { redirect_to(aplicacions_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @reclamo = Reclamo.find(params[:id])\n @reclamo.destroy\n\n respond_to do |format|\n format.html { redirect_to(reclamos_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @configuracion = Configuracion.find(params[:id])\n @configuracion.destroy\n\n respond_to do |format|\n format.html { redirect_to(configuracions_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @reclamacao = Reclamacao.find(params[:id])\n @reclamacao.destroy\n\n respond_to do |format|\n format.html { redirect_to(reclamacaos_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @criterio_evalucion_servicio.destroy\n respond_to do |format|\n format.html { redirect_to criterio_evalucion_servicios_url, notice: 'Criterio evalucion servicio was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def deletepublish\n @question = Publishquiz.find(:all, :conditions=>\"question_id=\"+params[:question]+\" and quiz_id=\"+session[:quizid])\n @question[0].destroy\n\n respond_to do |format|\n format.html { redirect_to(questions_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @certificado = Certificado.find(params[:id])\n @certificado.destroy\n\n respond_to do |format|\n format.html { redirect_to(certificados_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @test_subject_evaluation = @test_subject.test_subject_evaluations.find(params[:id])\n @test_subject_evaluation.destroy\n\n respond_to do |format|\n format.html { redirect_to(test_subject_test_subject_evaluations_url(@test_subject)) }\n format.xml { head :ok }\n end\n end", "def destroy\n @visarequest = Visarequest.find(params[:id])\n @visarequest.destroy\n\n respond_to do |format|\n format.html { redirect_to(visarequests_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @elemento = Elemento.find(params[:id])\n @elemento.destroy\n\n respond_to do |format|\n format.html { redirect_to(elementos_url) }\n format.xml { head :ok }\n end\n end", "def delete\n request(:delete)\n end", "def destroy\n @consulta = Consulta.find(params[:id])\n @consulta.destroy\n\n respond_to do |format|\n format.html { redirect_to(consultas_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @consulta = Consulta.find(params[:id])\n @consulta.destroy\n\n respond_to do |format|\n format.html { redirect_to(consultas_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @texte_accueil = TexteAccueil.find(params[:id])\n @texte_accueil.destroy\n\n respond_to do |format|\n format.html { redirect_to(texte_accueils_url) }\n format.xml { head :ok }\n end\n end", "def destroy\r\n @asignacion = Asignacion.find(params[:id])\r\n @asignacion.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_to(asignacions_url) }\r\n format.xml { head :ok }\r\n end\r\n end", "def destroy\n @estagiarios = Estagiario.find(params[:id])\n @estagiarios.destroy\n\n respond_to do |format|\n format.html { redirect_to(homes_path) }\n format.xml { head :ok }\n end\n end", "def destroy\n @criteria = Criteria.find(params[:id])\n @criteria.destroy\n\n respond_to do |format|\n format.html { redirect_to(criterias_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @asistencia = Asistencia.find(params[:id])\n @asistencia.destroy\n\n respond_to do |format|\n format.html { redirect_to(asistencias_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @evaluation.destroy\n respond_to do |format|\n format.html { redirect_to course_evaluations_url, notice: 'La evaluación fue eliminada correctamente!' }\n end\n end", "def destroy\n @conteudo = Conteudo.find(params[:id])\n @conteudo.destroy\nt=0\n respond_to do |format|\n format.html { redirect_to(exclusao_path) }\n format.xml { head :ok }\n end\n end", "def destroy\n @reputacao_veiculo = ReputacaoVeiculo.find(params[:id])\n @reputacao_veiculo.destroy\n\n respond_to do |format|\n format.html { redirect_to(reputacao_veiculos_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @exp = Exp.find(params[:id])\n @exp.destroy\n\n respond_to do |format|\n format.html { redirect_to(exps_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @suministro = Suministro.find(params[:id])\n @suministro.destroy\n\n respond_to do |format|\n format.html { redirect_to(suministros_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @coleccionista = Coleccionista.find(params[:id])\n @coleccionista.destroy\n\n respond_to do |format|\n format.html { redirect_to(coleccionistas_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @correspondenciasclase = Correspondenciasclase.find(params[:id])\n @correspondenciasclase.destroy\n\n respond_to do |format|\n format.html { redirect_to(correspondenciasclases_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @orc_ficha = OrcFicha.find(params[:id])\n @orc_ficha.destroy\n\n respond_to do |format|\n format.html { redirect_to(orc_fichas_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @valor_sistema = ValorSistema.find(params[:id])\n @valor_sistema.destroy\n\n respond_to do |format|\n format.html { redirect_to(valores_sistema_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @documentacion.destroy\n respond_to do |format|\n format.html { redirect_to @mem, notice: 'Documentación eliminada correctamente.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @evaluator.destroy\n\n respond_to do |format|\n format.html { redirect_to(evaluators_url) }\n format.xml { head :ok }\n end\n end", "def delete\n client.delete(\"/#{id}\")\n end", "def destroy\n @receita = Receita.find(params[:id])\n @receita.destroy\n\n respond_to do |format|\n format.html { redirect_to(receitas_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @regiaos = Regiao.find(params[:id])\n @regiaos.destroy\n\n respond_to do |format|\n format.html { redirect_to(homes_path) }\n format.xml { head :ok }\n end\n end", "def destroy\n @relatorios = Relatorio.find(params[:id])\n @relatorios.destroy\n\n respond_to do |format|\n format.html { redirect_to(homes_path) }\n format.xml { head :ok }\n end\n end", "def destroy\n @constancia_documento.destroy\n respond_to do |format|\n format.html { redirect_to constancia_documentos_url, notice: 'La constancia fue eliminada correctamente.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @documento = Documento.find(params[:id])\n # Eliminar los registros asociativos de las tablas JOIN \n # para las asociaciones HBTM (has_and_belongs_to_many)\n #\n @documento.reconocimientos.destroy_all\n @documento.areas.destroy_all\n\n @documento.destroy\n\n respond_to do |format|\n format.html { redirect_to documentos_url, :notice => \"#{@documento.titulo} eliminado\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @acre = Acre.find(params[:id])\n @acre.destroy\n\n respond_to do |format|\n format.html { redirect_to(acres_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @factura = Factura.find(params[:id])\n @factura.destroy\n\n respond_to do |format|\n format.html { redirect_to(facturas_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @evaluation.destroy\n respond_to do |format|\n format.html { redirect_to evaluations_url, notice: 'Avaliação deletada.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @vigencia = Vigencia.find(params[:id])\n @vigencia.destroy\n\n respond_to do |format|\n format.html { redirect_to(vigencias_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @requisition.destroy\n\n respond_to do |format|\n format.html { redirect_to(requisitions_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @prestamo = Prestamo.find(params[:id])\n @prestamo.destroy\n\n respond_to do |format|\n format.html { redirect_to(prestamos_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @proceso = Proceso.find(params[:id])\n @proceso.destroy\n\n respond_to do |format|\n format.html { redirect_to(procesos_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @recursorevision = @solicitud.recursosrevision.find(params[:id])\n @recursorevision.destroy\n\n respond_to do |format|\n format.html { redirect_to(solicitud_recursosrevision_url(@solicitud), :notice => \"Recurso de revisión eliminado con exito.\") }\n format.xml { head :ok }\n end\n end", "def destroy\n @certidao = Certidao.find(params[:id])\n @certidao.destroy\n\n respond_to do |format|\n format.html { redirect_to(certidaos_url) }\n format.xml { head :ok }\n end\n end", "def delete(slide)\n # ./_rels/presentation.xml.rels\n # Update Relationship ids\n # Insert a new one slideRef\n @doc.edit_xml @doc.presentation.rels.path do |xml|\n # Calucate the next id\n # next_id = xml.xpath('//xmlns:Relationship[@Id]').map{ |n| n['Id'] }.sort.last.succ\n # TODO - Figure out how to make this more MS idiomatic up 9->10 instead of incrementing\n # the character....\n # Insert that into the slide and crakc open the presentation.xml file\n\n target = slide.path.relative_path_from(@doc.presentation.path.dirname)\n relationship = xml.at_xpath(\"/xmlns:Relationships/xmlns:Relationship[@Type='#{Slide::REL_TYPE}' and @Target='#{target}']\")\n # ./presentation.xml\n # Update attr\n # p:notesMasterId\n # Insert attr\n # p:sldId, increment, etc.\n @doc.edit_xml '/ppt/presentation.xml' do |xml|\n xml.at_xpath(\"/p:presentation/p:sldIdLst/p:sldId[@r:id='#{relationship['Id']}']\").remove\n end\n relationship.remove\n end\n\n # Delete slide link and slideNotes link from ./[Content-Types].xml \n @doc.edit_xml @doc.content_types.path do |xml|\n xml.at_xpath(\"/xmlns:Types/xmlns:Override[@ContentType='#{Slide::CONTENT_TYPE}' and @PartName='#{slide.path}']\").remove\n xml.at_xpath(\"/xmlns:Types/xmlns:Override[@ContentType='#{Notes::CONTENT_TYPE}' and @PartName='#{slide.notes.path}']\").remove\n end\n\n # Update ./ppt\n # !!! DESTROY !!!\n # ./slides\n # Delete files\n # ./_rels/notesSlide(\\d+).xml.rels\n @doc.delete slide.notes.rels.path\n # ./notesSlide(\\d+).xml file\n @doc.delete slide.notes.path\n # ./_rels/slide(\\d+).xml.rels\n @doc.delete slide.rels.path\n # ./slide(\\d+).xml file\n @doc.delete slide.path\n # ./notesSlides\n # Delete files\n\n # Hooray! We're done! Ummm, what should we return though? can't be the slide since\n # its destroyed and there's no practical way to keep it around in memory.\n end", "def destroy\n @convenio_financiamiento = ConvenioFinanciamiento.find(params[:id])\n @convenio_financiamiento.destroy\n\n respond_to do |format|\n format.html { redirect_to(convenio_financiamientos_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @remocao = Remocao.find(params[:id])\n @remocao.destroy\n\n respond_to do |format|\n format.html { redirect_to(remocaos_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @inscripcione = Inscripcione.find(params[:id])\n @inscripcione.destroy\n\n respond_to do |format|\n format.html { redirect_to(inscripciones_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @exalumno = @alumno.exalumno\n @exalumno.destroy\n\n respond_to do |format|\n format.html { redirect_to(alumno_path(@alumno)) }\n format.xml { head :ok }\n end\n end", "def destroy\n @ficha_tematica = FichaTematica.find(params[:id])\n @ficha_tematica.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_ficha_tematicas_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @competencia = Competencia.find(params[:id])\n @competencia.destroy\n\n respond_to do |format|\n format.html { redirect_to(competencias_url) }\n format.xml { head :ok }\n end\n end", "def delete_all(xpath); end", "def delete\n Iterable.request(conf, base_path).delete\n end", "def destroy\n @tiposproceso = Tiposproceso.find(params[:id])\n @tiposproceso.destroy\n\n respond_to do |format|\n format.html { redirect_to(tiposprocesos_url) }\n format.xml { head :ok }\n end\n end", "def delete(id)\n request = Net::HTTP::Delete.new(\"#{@url}/#{id}.xml\")\n http = Net::HTTP.new(@uri.host, @uri.port)\n response = http.request(request)\n\n # no response body will be returned\n case response\n when Net::HTTPSuccess\n return \"#{response.code} OK\"\n else\n return \"#{response.code} ERROR\"\n end\n end", "def destroy\n @respuesta = Respuesta.find(params[:id])\n @respuesta.destroy\n\n head :no_content\n end" ]
[ "0.68952584", "0.67754596", "0.66590357", "0.66368866", "0.6585356", "0.65540206", "0.6540472", "0.6540472", "0.6505618", "0.6480637", "0.6465142", "0.6417233", "0.6404615", "0.6403051", "0.6400472", "0.6393812", "0.63901806", "0.6389374", "0.637874", "0.63649964", "0.6354835", "0.6348731", "0.63454115", "0.63423467", "0.63414615", "0.6333323", "0.63234884", "0.6321208", "0.63138187", "0.6312377", "0.62974775", "0.62947166", "0.62941325", "0.6291541", "0.628966", "0.6288139", "0.6287329", "0.62813073", "0.6277372", "0.62741035", "0.62658584", "0.6263966", "0.62601215", "0.6257252", "0.6255128", "0.624629", "0.6244805", "0.622195", "0.6220461", "0.6219573", "0.6214433", "0.6212964", "0.62122875", "0.62091947", "0.6203018", "0.6201434", "0.6201434", "0.62010044", "0.6197249", "0.6196669", "0.61884844", "0.6186915", "0.6186387", "0.61813647", "0.6178834", "0.61764115", "0.6171293", "0.61683327", "0.6167706", "0.6167066", "0.6166002", "0.61615044", "0.61613077", "0.61588293", "0.61546814", "0.6151613", "0.61513364", "0.6148377", "0.6148144", "0.61465174", "0.6144376", "0.61418414", "0.61406815", "0.613926", "0.6133739", "0.61327624", "0.6128996", "0.6126495", "0.6123707", "0.6119612", "0.6117683", "0.6117404", "0.61174035", "0.61164975", "0.6115117", "0.6112244", "0.61040014", "0.6099097", "0.6089973", "0.60860026" ]
0.733809
0
All the graph statements except hasModel and those with missing objects
def statements graph.statements.reject { |stmt| predicate_blacklist.include?(stmt.predicate) || missing_object?(stmt) } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def relation_none(model)\n validate_model(model)\n model.none\n end", "def graph?\n false\n end", "def graph?\n true\n end", "def generate_graph\n end", "def dangling_relationships\n relationships.select do |relationship|\n relationship.subject.nil? || relationship.objekt.nil?\n end\n end", "def check_unused_preload_associations; end", "def neo_graphs\n @neo_graphs ||= {}\n end", "def exclude_from_model\n []\n end", "def use_dependency_graph?(objects)\n objects.each do |id,object|\n object.foreign_objects.each do |property|\n if object[property].present?\n return false\n end\n end\n end\n true\n end", "def create_default_graphs\r\n fields.each do |field|\r\n graphs.create(field: field) if field.graphable?\r\n end\r\n end", "def inject_graph_values!\n end", "def test_has_edges_when_empty\n graph = Graph.new\n\n assert(graph.has_edges() == false)\n end", "def test_has_edges_vertices_only\n vertex_a = Vertex.new('a')\n vertex_b = Vertex.new('b')\n vertex_c = Vertex.new('c')\n graph = Graph.new\n graph.add_vertex(vertex_a).add_vertex(vertex_b).add_vertex(vertex_c)\n\n assert(graph.has_edges() == false)\n end", "def remove_predicate_and_its_object_statements(predicate)\n predicate_stmts = @graph.query([nil, predicate, nil])\n predicate_stmts.each { |pstmt|\n pred_obj = pstmt.object\n OA::Graph.subject_statements(pred_obj, @graph).each { |s|\n @graph.delete s\n } if OA::Graph.subject_statements(pred_obj, @graph)\n @graph.delete pstmt\n }\n end", "def graph?\n show?\n end", "def graph?\n show?\n end", "def has_any_model_relationship?\n !model_relationship.eql?(NONE)\n end", "def eager_graph(*associations)\n eager_graph_with_options(associations)\n end", "def fill_destroy_graph( graph )\n fill_save_graph( graph )\n end", "def init_graph\n Graph.new(self, skip_track: :broad)\n end", "def unreferenced_elements\n model\n .elements\n .select { |el| el.references.none?(&ref_is_relationship_or_diagram) }\n end", "def ungraphed\n ds = super.clone(:eager_graph=>nil)\n if (eg = @opts[:eager_graph]) && (rp = eg[:row_proc])\n ds = ds.with_row_proc(rp)\n end\n ds\n end", "def initialize(dataset)\n opts = dataset.opts\n eager_graph = opts[:eager_graph]\n @master = eager_graph[:master]\n requirements = eager_graph[:requirements]\n reflection_map = @reflection_map = eager_graph[:reflections]\n reciprocal_map = @reciprocal_map = eager_graph[:reciprocals]\n limit_map = @limit_map = eager_graph[:limits]\n @unique = eager_graph[:cartesian_product_number] > 1\n \n alias_map = @alias_map = {}\n type_map = @type_map = {}\n after_load_map = @after_load_map = {}\n reflection_map.each do |k, v|\n alias_map[k] = v[:name]\n after_load_map[k] = v[:after_load] unless v[:after_load].empty?\n type_map[k] = if v.returns_array?\n true\n elsif (limit_and_offset = limit_map[k]) && !limit_and_offset.last.nil?\n :offset\n end\n end\n\n # Make dependency map hash out of requirements array for each association.\n # This builds a tree of dependencies that will be used for recursion\n # to ensure that all parts of the object graph are loaded into the\n # appropriate subordinate association.\n @dependency_map = {}\n # Sort the associations by requirements length, so that\n # requirements are added to the dependency hash before their\n # dependencies.\n requirements.sort_by{|a| a[1].length}.each do |ta, deps|\n if deps.empty?\n dependency_map[ta] = {}\n else\n deps = deps.dup\n hash = dependency_map[deps.shift]\n deps.each do |dep|\n hash = hash[dep]\n end\n hash[ta] = {}\n end\n end\n \n # This mapping is used to make sure that duplicate entries in the\n # result set are mapped to a single record. For example, using a\n # single one_to_many association with 10 associated records,\n # the main object column values appear in the object graph 10 times.\n # We map by primary key, if available, or by the object's entire values,\n # if not. The mapping must be per table, so create sub maps for each table\n # alias.\n records_map = {@master=>{}}\n alias_map.keys.each{|ta| records_map[ta] = {}}\n @records_map = records_map\n\n datasets = opts[:graph][:table_aliases].to_a.reject{|ta,ds| ds.nil?}\n column_aliases = opts[:graph_aliases] || opts[:graph][:column_aliases] # SEQUEL5: Remove :graph_aliases support\n primary_keys = {}\n column_maps = {}\n models = {}\n row_procs = {}\n datasets.each do |ta, ds|\n models[ta] = ds.model\n primary_keys[ta] = []\n column_maps[ta] = {}\n row_procs[ta] = ds.row_proc\n end\n column_aliases.each do |col_alias, tc|\n ta, column = tc\n column_maps[ta][col_alias] = column\n end\n column_maps.each do |ta, h|\n pk = models[ta].primary_key\n if pk.is_a?(Array)\n primary_keys[ta] = []\n h.select{|ca, c| primary_keys[ta] << ca if pk.include?(c)}\n else\n h.select{|ca, c| primary_keys[ta] = ca if pk == c}\n end\n end\n @column_maps = column_maps\n @primary_keys = primary_keys\n @row_procs = row_procs\n\n # For performance, create two special maps for the master table,\n # so you can skip a hash lookup.\n @master_column_map = column_maps[master]\n @master_primary_keys = primary_keys[master]\n\n # Add a special hash mapping table alias symbols to 5 element arrays that just\n # contain the data in other data structures for that table alias. This is\n # used for performance, to get all values in one hash lookup instead of\n # separate hash lookups for each data structure.\n ta_map = {}\n alias_map.keys.each do |ta|\n ta_map[ta] = [records_map[ta], row_procs[ta], alias_map[ta], type_map[ta], reciprocal_map[ta]]\n end\n @ta_map = ta_map\n end", "def conditions_met?(object, associations); end", "def don_bobfather\n #traversal = self.outgoing(:bobfather).depth(:all).unique(:node_path).eval_paths { |path| (path.end_node[:fbid] == user[:fbid]) ? :include_and_continue : :exclude_and_continue }\n traversal = self.outgoing(:bobfather).depth(:all).to_a.last #. #filter{|path| path.end_node.has_bobfather?}.\n # each{|node| puts node[:name]}\n end", "def strict(name, options = {}, &block)\n GraphViz::DSL.new(name, options.merge( { :type => \"strict digraph\" } ), &block).graph\nend", "def post_processing! (edges)\n # 'and' coordination\n edges.reject!{|e| e[:text] == 'and'}\n end", "def graphable?\n #(self.name =~ /ricc|lag/i || self.virtual ) rescue false \n (! self.virtual) rescue false # PRODUCTION\n end", "def model_relationships; end", "def remove_from_graph\n # Ignores trying to delete nonexistent records\n connection.execute <<-EOS\n DELETE IGNORE FROM #{oqgraph_table_name} WHERE origid = #{self.send(self.class.from_key)} AND destid = #{self.send(self.class.to_key)};\n EOS\n end", "def finalize\n # Apply styles before pruning because some relations may be destroyed while pruning\n puts \"Applying styles\"\n @graph.apply_styles\n\n # Prune the graph according to ignore rules.\n # We keep pruning until there are no more changes because some rules don't apply the first time (for example: &:island?)\n puts \"Pruning nodes\"\n i = 1\n while (x = @graph.prune) > 0\n puts \" #{x} nodes pruned on #{i.ordinalize} pass\"\n i += 1\n end\n self\n end", "def unnamed?\n @graph_name.nil?\n end", "def calculate_edges\n es = [{:left_table=>self[:model].table_name, :left_key=>self[:left_primary_key_column]}]\n self[:through].each do |t|\n es.last.merge!(:right_key=>t[:left], :right_table=>t[:table], :join_type=>t[:join_type]||self[:graph_join_type], :conditions=>(t[:conditions]||[]).to_a, :block=>t[:block])\n es.last[:only_conditions] = t[:only_conditions] if t.include?(:only_conditions)\n es << {:left_table=>t[:table], :left_key=>t[:right]}\n end\n es.last.merge!(:right_key=>right_primary_key, :right_table=>associated_class.table_name)\n edges = es.map do |e| \n h = {:table=>e[:right_table], :left=>e[:left_key], :right=>e[:right_key], :conditions=>e[:conditions], :join_type=>e[:join_type], :block=>e[:block]}\n h[:only_conditions] = e[:only_conditions] if e.include?(:only_conditions)\n h\n end\n reverse_edges = es.reverse.map{|e| {:table=>e[:left_table], :left=>e[:left_key], :right=>e[:right_key]}}\n reverse_edges.pop\n calculate_reverse_edge_aliases(reverse_edges)\n final_reverse_edge = reverse_edges.pop\n final_reverse_alias = final_reverse_edge[:alias]\n\n h = {:final_edge=>edges.pop,\n :final_reverse_edge=>final_reverse_edge,\n :edges=>edges,\n :reverse_edges=>reverse_edges,\n :predicate_key=>qualify(final_reverse_alias, edges.first[:right]),\n :associated_key_table=>final_reverse_edge[:alias],\n }\n h.each{|k, v| cached_set(k, v)}\n h\n end", "def eager_graph_limit_strategy(_)\n nil\n end", "def gv_object\n return @gv_object if @gv_object\n return unless defined? GraphViz\n @gv_object = GraphViz.new gv_graph_name, :type => :digraph\n @gv_object.node_attrs[:style] = 'filled, solid'\n\n each_task do |task|\n next unless task.node == gv_filter_node if gv_filter_node\n gv_node = @gv_object.add_node task.to_s\n gv_node.fillcolor = gv_task_color(task)\n end\n\n each_task do |task|\n task.each_dependency do |dep_task|\n next unless dep_task.node == gv_filter_node if gv_filter_node\n next unless @gv_object.find_node dep_task.to_s and @gv_object.find_node task.to_s\n @gv_object.add_edges dep_task.to_s, task.to_s\n end\n end\n @gv_object\n end", "def required_nonpath_params\n self.associations.reject { |k,v| v[:type] != :belongs_to }.keys.reject {|x| self.resource_tuple.map { |y| y.to_s.singularize }.member?(x) }\n end", "def print_graph\n @items.each do |item|\n puts \"#{item.inspect} depends on:\"\n\n predecessors = direct_predecessors_of(item)\n predecessors.each do |pred|\n puts \" #{pred.inspect}\"\n end\n puts \" (nothing!)\" if predecessors.empty?\n puts\n end\n end", "def interested?(model)\n !model.nil?\nend", "def test_has_edge_no_vertices\n assert(@graph.has_edge('vertex1', 'vertex2') == false)\n end", "def works_with_missing_metadata\n GenericWork.all.select do |gw|\n gw.description == [] && gw.creator == []\n end\n end", "def get_nothing(nodes, metadata)\n record_call(:get_nothing, nodes, metadata)\n # Here we return something to test that if the first one fails we have the second CMDB\n nodes.map { |node| [node, \"#{node} has nothing\"] }.to_h\n end", "def predicates\n @graphs.inject([]) {|memo, g| memo += g.predicates}\n end", "def create_dot_graph\r\n\r\n \t# Create the base object, then add edges/nodes later etc\r\n \tmy_graph = Graph.new\r\n \tmy_graph.name= \"State_Model\"\r\n \tmy_graph.node_style= :ellipse\r\n \tmy_graph.type = :digraph\r\n\r\n \t# For each entry in the Adjacency matrix extract the relationships and add the graph edges.\r\n \tself.adjacency_matrix.each_key do |table_key|\r\n \t\ttransition_list=self.adjacency_matrix[table_key]\r\n \t\ttransition_list.each do |transition|\r\n \t\t # is the action guarded?\r\n \t\t if self.guarded_actions !=nil\r\n \t\t guarded=self.guarded_actions.include? transition.action\r\n \t\t\tend # end if \r\n \t\t\t# add the edge...\r\n \t\t\tmy_graph.add_edge(transition.start_state, transition.end_state, \" #{transition.action} \", guarded)\r\n \t\tend # end add transitions\r\n \tend # end add nodes\r\n\r\n \treturn my_graph\r\n end", "def generate_all_objects(graph, base_name, kind, extra)\n graph.map do |object|\n if object.object.name == base_name\n generate_object(object.object, \"title#{object.seed}\", kind,\n object.seed, extra)\n else\n generate_ref(object.object, object.seed)\n end\n end\n end", "def show\n puts '* database name, @dbname = ' + @dbname\n puts '* which belongs to database set name, @dsname = ' + @ds.dsname\n puts '* Now calling all entity sets to display themselves.....'\n if @hes\n @hes.each_value{|x| x.show}\n else\n puts 'No entity set to show'\n end # if\n \n if @hrs.size > 0\n puts '***** Now calling all relationship sets to display themselves.....'\n @hrs.each_value{|y| y.show}\n else\n puts 'RELATIONSHIP SETS? No relationship set exists in this database.'\n end # if\n end", "def ungraphed\n clone(:graph=>nil, :graph_aliases=>nil) # SEQUEL5: Remove :graph_aliases\n end", "def test_empty_branch\n #puts \"---------------test_branch-----------------\"\n t1 = t2 = nil\n GraphBuilder::Builder.build do |b|\n t1 = b.add(Thing1.new)\n b.branch do \n end\n t2 = b.add(Thing2.new)\n end\n\n r = Thing.links([t1,t2])\n assert_equal 1, r.size\n assert r.include? [t1,t2]\n end", "def with_graph(graph_name)\n old_lists, @lists = @lists, {}\n old_references, @references = @references, {}\n old_serialized, @serialized = @serialized, {}\n old_subjects, @subjects = @subjects, {}\n old_graph, @graph = @graph, repo.project_graph(graph_name)\n old_formulae, @formulae = @formulae, {}\n\n graph_done(graph_name)\n\n lists = {}\n graph.each do |statement|\n preprocess_graph_statement(statement)\n [statement.subject, statement.object].each do |resource|\n @formulae[resource] = true if\n resource.node? &&\n (formula_names.include?(resource) || resource.id.start_with?('_form_'))\n\n # First-class list may have members which are formulae, and need reference counts\n if resource.list?\n resource.each_descendant do |term|\n bump_reference(term)\n @formulae[term] = true if\n term.node? &&\n (formula_names.include?(term) || term.id.start_with?('_form_'))\n end\n end\n end\n\n # Collect list elements\n if [RDF.first, RDF.rest].include?(statement.predicate) && statement.subject.node?\n lists[statement.subject] ||= {}\n lists[statement.subject][statement.predicate] = statement.object\n end\n end\n\n # Remove list entries after head with more than two properties (other than rdf:type)\n rests = lists.values.map {|props| props[RDF.rest]}\n\n # Remove non-head lists that have too many properties\n rests.select do |bn|\n pc = 0\n @subjects.fetch(bn, {}).each do |pred, count|\n next if pred == RDF.type\n pc += count\n end\n lists.delete(bn) if pc > 2\n end\n\n # Values for this list element, recursive\n def list_values(bn, lists)\n raise \"no list\" unless lists.has_key?(bn)\n first, rest = lists[bn][RDF.first], lists[bn][RDF.rest]\n (rest == RDF.nil ? [] : list_values(rest, lists)).unshift(first)\n rescue\n lists.delete(bn)\n raise $!\n end\n\n # Create value arrays for each entry\n lists.each do |bn, props|\n begin\n @lists[bn] = list_values(bn, lists)\n rescue\n # Skip this list element, if it raises an exception\n lists.delete(bn)\n end\n end\n\n # Mark all remaining rests done\n rests.each {|bn| subject_done(bn) if lists.include?(bn)}\n\n # Remove entries that are referenced as rdf:rest of some entry\n lists.each do |bn, props|\n @lists.delete(props[RDF.rest])\n end\n\n # Record nodes in subject or object\n yield\n ensure\n @graph, @lists, @references, @serialized, @subjects, @formulae = old_graph, old_lists, old_references, old_serialized, old_subjects, old_formulae\n end", "def show\n @user = User.find(params[:id])\n session['user_name'] = @user.name\n session['user_id'] = params[:id]\n session['user_gender'] = @user.gender\n unless @user.uuid == current_user.uuid\n unless current_user.rels(dir: :outgoing, type: :visits, between: @user).blank?\n rel = current_user.rels(dir: :outgoing, type: :visits, between: @user)\n rel[0].count = rel[0].count + 1\n rel[0].save!\n else\n rel = Visit.new\n rel.from_node = current_user\n rel.to_node = @user\n rel.count = 1\n rel.save!\n end\n current_user.save!\n end\n @my_badges = []\n\n #@req_badges = Neo4j::Session.query.match(\"(me { uuid: '#{current_user.uuid}' })-[:giveBadges]->(myBadge)<-[:getBadges]-(user { uuid: '#{@user.uuid}' })\").where(\" myBadge.status = false \").pluck(:myBadge)\n #@badges = Neo4j::Session.query.match(\"(me { uuid: '#{@user.uuid}' })-[:getBadges]->(myBadge)\").where(\"myBadge.status = true\").pluck('DISTINCT myBadge.badgeType, count(myBadge.badgeType)')\n @badges = Neo4j::Session.query.match(\"(me { uuid: '#{@user.uuid}' })-[:getBadges]->(myBadge)\").pluck('DISTINCT myBadge.badgeType, count(myBadge.badgeType)')\n @badges_count = @user.getBadges.where(status: true).count\n\n @pictures = @user.pictures.where(visible: true)\n @testimonials = @user.testimonials\n \n unless @user == current_user\n t = []\n @testimonials.each do |testimonial|\n if testimonial.liked\n t << testimonial\n next\n end\n if testimonial.write_testimonials[0] == current_user\n t << testimonial\n end\n end\n @testimonials = t\n \n end\n unless @user.uuid == current_user.uuid\n @like = current_user.rels(dir: :outgoing, type: :likes, between: @user).blank? ? true : false\n \n end\n unless @user.uuid == current_user.uuid\n place_ids = current_user.places.map { |p| p.place_id }\n @locations = @user.places.where(place_id: place_ids)\n else\n @locations = @user.places\n end\n \n @likes_count = @user.rels(dir: :incoming, type: \"likes\").count\n\n @interests = @user.userInterests\n @interests_count = @interests.count\n\n # ip_loc = Geocoder.search(remote_ip)[0]\n\n # @address = ip_loc.address\n # @latitude = ip_loc.latitude\n # @longitude = ip_loc.longitude\n end", "def discard_transaction\n\t clear_relations\n\tend", "def clean_neo4j\n neo_connection.execute_query(\"START n0=node(0),nx=node(*) MATCH n0-[r0?]-(),nx-[rx?]-() WHERE nx <> n0 DELETE r0,rx,nx\")\nend", "def calculate_graph_diffs(graphname1, graphname2, diffgraphname)\n update(\"INSERT { GRAPH <#{diffgraphname}> { ?s ?p ?o . }} WHERE { GRAPH <#{graphname1}> { ?s ?p ?o } FILTER NOT EXISTS { GRAPH <#{graphname2}> { ?s ?p ?o }}}\")\nend", "def clear_relations(remove_internal: false, remove_strong: true)\n modified_plan = false\n if remove_internal\n each_event do |ev|\n if ev.clear_relations(remove_strong: remove_strong)\n modified_plan = true\n end\n end\n else\n modified_plan =\n clear_events_external_relations(remove_strong: remove_strong)\n end\n super(remove_strong: remove_strong) || modified_plan\n end", "def relation_all(model)\n validate_model(model)\n model.all\n end", "def remove_nonsense_nodes\n _clear_cache\n hash = {}\n self.each_node do |node|\n hash[node] = true if @pathway.graph[node].size == 2\n end\n hash.each_key do |node|\n adjs = @pathway.graph[node].keys\n edges = @pathway.graph[node].values\n new_edge = get_edge_merged(edges[0], edges[1])\n @pathway.graph[adjs[0]].delete(node)\n @pathway.graph[adjs[1]].delete(node)\n @pathway.graph.delete(node)\n @pathway.append(Bio::Relation.new(adjs[0], adjs[1], new_edge))\n end\n #@pathway.to_relations\n @pathway.relations.reject! do |rel|\n hash[rel.node[0]] or hash[rel.node[1]]\n end\n return hash.keys\n end", "def additional_triples(rdf_graph)\n if is_a?(Model) && contains_sbml?\n rdf_graph << [rdf_resource, JERMVocab.hasFormat, JERMVocab.SBML_format]\n end\n rdf_graph\n end", "def eager_graph_build_associations(rows)\n objects = super\n\n if eager_data = @opts[:eager_graph_eager]\n eager_data.each do |deps, assocs|\n current = objects\n\n last_class, *deps = deps\n deps.each do |dep, is_multiple|\n current_assocs = current.map(&:associations)\n\n if is_multiple\n current = current_assocs.flat_map{|a| a[dep]}\n else\n current = current_assocs.map{|a| a[dep]}\n current.compact!\n end\n\n current.uniq!(&:object_id)\n end\n\n last_class.dataset.send(:eager_load, current, assocs)\n end\n end\n\n objects\n end", "def skip_schema_queries; end", "def has_vertex?(vertex)\n\tend", "def process_class(current_class)\n\n STDERR.print \"\\tProcessing #{current_class}\\n\" if @options.verbose\n\n generated = false\n \n # Is current_clas derived from ActiveRecord::Base?\n if current_class.respond_to?'reflect_on_all_associations'\n\n\n node_attribs = []\n if @options.brief || current_class.abstract_class?\n node_type = 'model-brief'\n else \n node_type = 'model'\n\n # Collect model's content columns\n\n\tcontent_columns = current_class.content_columns\n\t\n\tif @options.hide_magic \n # From patch #13351\n # http://wiki.rubyonrails.org/rails/pages/MagicFieldNames\n magic_fields = [\n \"created_at\", \"created_on\", \"updated_at\", \"updated_on\",\n \"lock_version\", \"type\", \"id\", \"position\", \"parent_id\", \"lft\", \n \"rgt\", \"quote\", \"template\"\n ]\n magic_fields << current_class.table_name + \"_count\" if current_class.respond_to? 'table_name' \n content_columns = current_class.content_columns.select {|c| ! magic_fields.include? c.name}\n else\n content_columns = current_class.content_columns\n end\n \n content_columns.each do |a|\n content_column = a.name\n content_column += ' :' + a.type.to_s unless @options.hide_types\n node_attribs << content_column\n end\n end\n @graph.add_node [node_type, current_class.name, node_attribs]\n generated = true\n # Process class associations\n associations = current_class.reflect_on_all_associations\n if @options.inheritance && ! @options.transitive\n superclass_associations = current_class.superclass.reflect_on_all_associations\n \n associations = associations.select{|a| ! superclass_associations.include? a} \n # This doesn't works!\n # associations -= current_class.superclass.reflect_on_all_associations\n end\n associations.each do |a|\n process_association current_class.name, a\n end\n elsif @options.all && (current_class.is_a? Class)\n # Not ActiveRecord::Base model\n node_type = @options.brief ? 'class-brief' : 'class'\n @graph.add_node [node_type, current_class.name]\n generated = true\n elsif @options.modules && (current_class.is_a? Module)\n @graph.add_node ['module', current_class.name]\n end\n\n # Only consider meaningful inheritance relations for generated classes\n if @options.inheritance && generated && \n (current_class.superclass != ActiveRecord::Base) &&\n (current_class.superclass != Object)\n @graph.add_edge ['is-a', current_class.superclass.name, current_class.name]\n end \n\n end", "def is_get_result_on_active_object?\n (node_type == :lasgn and\n not sons.empty? and\n not ((expl_dependencies.map { |n| n.name } + non_expl_dependencies.map { |n| n.name }) & grid_objects.map { |n| n.name }).empty? and\n (sons.first.name.start_with? \"get_result\" or (not sons.first.sons.empty? and sons.first.sons.first.name.start_with? \"get_result\"))) # x.get_result and x.get_result.foo()\n end", "def replace_blank_nodes(obj, graph)\n # Remove \"@id\" attribute of JobPosting instance if it contains blank node\n filtered_obj = obj.select { |k, v| !((k == \"@id\") && blank?(v)) }\n Hash[filtered_obj.map { |k, v| [k, embed(v, graph)] }]\n end", "def eager_graph_lazy_dataset?\n true\n end", "def graph(kind)\n res = orchio_get_graph(kind)\n (res.success?) ? res.results.map { |odoc| odoc.to_rails } : false\n end", "def objects\n @graphs.inject([]) {|memo, g| memo += g.objects}\n end", "def eager_graph_association(ds, model, ta, requirements, r, *associations)\n if r.is_a?(SQL::AliasedExpression)\n alias_base = r.alias\n r = r.expression\n else\n alias_base = r[:graph_alias_base]\n end\n assoc_table_alias = ds.unused_table_alias(alias_base)\n loader = r[:eager_grapher]\n if !associations.empty?\n if associations.first.respond_to?(:call)\n callback = associations.first\n associations = {}\n elsif associations.length == 1 && (assocs = associations.first).is_a?(Hash) && assocs.length == 1 && (pr_assoc = assocs.to_a.first) && pr_assoc.first.respond_to?(:call)\n callback, assoc = pr_assoc\n associations = assoc.is_a?(Array) ? assoc : [assoc]\n end\n end\n local_opts = ds.opts[:eager_graph][:local]\n limit_strategy = r.eager_graph_limit_strategy(local_opts[:limit_strategy])\n\n if r[:conditions] && !Sequel.condition_specifier?(r[:conditions]) && !r[:orig_opts].has_key?(:graph_conditions) && !r[:orig_opts].has_key?(:graph_only_conditions) && !r.has_key?(:graph_block)\n Sequel::Deprecation.deprecate(\"Ignoring :conditions for #{r[:model]} #{r[:name]} association during eager_graph/association_join, consider specifying :graph_block\") unless r[:ignore_conditions_warning]\n end\n\n ds = loader.call(:self=>ds, :table_alias=>assoc_table_alias, :implicit_qualifier=>(ta == ds.opts[:eager_graph][:master]) ? first_source : qualifier_from_alias_symbol(ta, first_source), :callback=>callback, :join_type=>local_opts[:join_type], :join_only=>local_opts[:join_only], :limit_strategy=>limit_strategy, :from_self_alias=>ds.opts[:eager_graph][:master])\n if r[:order_eager_graph] && (order = r.fetch(:graph_order, r[:order]))\n ds = ds.order_append(*qualified_expression(order, assoc_table_alias))\n end\n eager_graph = ds.opts[:eager_graph]\n eager_graph[:requirements][assoc_table_alias] = requirements.dup\n eager_graph[:reflections][assoc_table_alias] = r\n if limit_strategy == :ruby\n eager_graph[:limits][assoc_table_alias] = r.limit_and_offset \n end\n eager_graph[:cartesian_product_number] += r[:cartesian_product_number] || 2\n ds = ds.eager_graph_associations(ds, r.associated_class, assoc_table_alias, requirements + [assoc_table_alias], *associations) unless associations.empty?\n ds\n end", "def graph_for_entity(entity)\n entity.minor? ? @mine_graph : @graph\n end", "def show_all\n begin\n @model.start_operation \"Show all layers and entities\"\n puts \"Showing all layers and entities...\" if @debug\n @layers.each { |l|\n puts \"\\tMaking layer '#{l}' visible...\" if @debug\n l.visible = true\n }\n @entities.each { |e|\n # If the entity is a Group or Component, test if it is frozen.\n if e.is_a? Sketchup::Group or e.is_a? Sketchup::ComponentInstance\n if not e.visible? and e.locked?\n puts \"\\t'#{e}' is hidden and locked, do no show it...\" if @debug\n else\n puts \"\\tMaking '#{e}' entity visible...\" if @debug\n e.visible = true\n end\n else\n puts \"\\tMaking '#{e}' entity visible...\" if @debug\n e.visible = true\n end\n }\n @model.commit_operation\n rescue Exception => e\n puts \"Error encountered: #{e}\" # Show even if debuggnig is off.\n @model.abort_operation\n end\n end", "def empty?\n @vertices.empty?\n end", "def empty?\n @vertices.empty?\n end", "def generate\n instance_eval(&callbacks[:setup])\n if options.only_recursion_depth.present?\n depth = options.only_recursion_depth.to_s.to_i\n options[:only].dup.each do |class_name|\n options[:only]+= recurse_into_relationships(@domain.entity_by_name(class_name), depth)\n end\n options[:only].uniq!\n end\n\n filtered_entities.each do |entity|\n instance_exec entity, filtered_attributes(entity), &callbacks[:each_entity]\n end\n\n filtered_specializations.each do |specialization|\n instance_exec specialization, &callbacks[:each_specialization]\n end\n\n filtered_relationships.each do |relationship|\n instance_exec relationship, &callbacks[:each_relationship]\n end\n end", "def graph_obj?(o)\n point?(o) or shape?(o)\nend", "def eager_graph_associations(ds, model, ta, requirements, *associations)\n return ds if associations.empty?\n associations.flatten.each do |association|\n ds = case association\n when Symbol, SQL::AliasedExpression\n ds.eager_graph_association(ds, model, ta, requirements, eager_graph_check_association(model, association))\n when Hash\n association.each do |assoc, assoc_assocs|\n ds = ds.eager_graph_association(ds, model, ta, requirements, eager_graph_check_association(model, assoc), assoc_assocs)\n end\n ds\n else\n raise(Sequel::Error, 'Associations must be in the form of a symbol or hash')\n end\n end\n ds\n end", "def annotate_edges(graph)\n graph.edges.each do |edge|\n if edge.to.props.dig(:node_class, :node_class) == 'org.graalvm.compiler.nodes.ValuePhiNode' && edge.props[:name] == 'values'\n merge_node = edge.to.edges.find { |e| e.props[:name] == 'merge' }.from\n control_into_merge = %w[ends loopBegin]\n merge_node_control_edges_in = merge_node.edges.select { |e| control_into_merge.include?(e.props[:name]) && e.to.props.dig(:node_class, :node_class) != 'org.graalvm.compiler.nodes.LoopExitNode' }\n matching_control_edge = merge_node_control_edges_in[edge.props[:index]]\n control_in_node = matching_control_edge.nodes.find { |n| n != merge_node }\n edge.props[:label] = \"from #{control_in_node.id}\"\n edge.props[:kind] = 'data'\n next\n end\n\n # Look at the name of the edge to decide how to treat them.\n case edge.props[:name]\n\n # Control edges.\n when 'ends', 'next', 'trueSuccessor', 'falseSuccessor', 'exceptionEdge'\n edge.props[:kind] = 'control'\n case edge.props[:name]\n when 'trueSuccessor'\n # Simplify trueSuccessor to T\n edge.props[:label] = 'T'\n when 'falseSuccessor'\n # Simplify falseSuccessor to F\n edge.props[:label] = 'F'\n when 'exceptionEdge'\n # Simplify exceptionEdge to unwind\n edge.props[:label] = 'unwind'\n end\n\n # Info edges, which are drawn reversed as they point from the user\n # to the info.\n when 'frameState', 'callTarget', 'stateAfter'\n edge.props[:label] = nil\n edge.props[:kind] = 'info'\n edge.props[:reverse] = true\n\n # Condition for branches, which we label as ?.\n when 'condition'\n edge.props[:kind] = 'data'\n edge.props[:label] = '?'\n\n # loopBegin edges point from LoopEndNode (continue) and LoopExitNode\n # (break) to the LoopBeginNode. Both are drawn reversed.\n when 'loopBegin'\n edge.props[:hidden] = true\n\n case edge.to.props.dig(:node_class, :node_class)\n when 'org.graalvm.compiler.nodes.LoopEndNode'\n # If it's from the LoopEnd then it's the control edge to follow.\n edge.props[:kind] = 'loop'\n edge.props[:reverse] = true\n when 'org.graalvm.compiler.nodes.LoopExitNode'\n # If it's from the LoopExit then it's just for information - it's\n # not control flow to follow.\n edge.props[:kind] = 'info'\n edge.props[:reverse] = true\n else\n raise EncodingError, 'loopBegin edge not to LoopEnd or LoopExit'\n end\n\n # Merges are info.\n when 'merge'\n edge.props[:kind] = 'info'\n edge.props[:reverse] = true\n\n # Successors are control from a switch.\n when 'successors'\n # We want to label the edges with the corresponding index of the key.\n if edge.props[:index] == edge.from.props['keys'].size\n label = 'default'\n else\n label = \"k[#{edge.props[:index]}]\"\n end\n edge.props[:label] = label\n edge.props[:kind] = 'control'\n\n # Successors are control from a switch.\n when 'arguments'\n # We want to label the edges with their corresponding argument index.\n edge.props[:label] = \"arg[#{edge.props[:index]}]\"\n edge.props[:kind] = 'data'\n\n # Everything else is data.\n else\n edge.props[:kind] = 'data'\n edge.props[:label] = edge.props[:name]\n\n end\n end\n end", "def before_graph_recalculation\n each_adapter(&:before_graph_recalculation!)\n end", "def is_vertex(id)\n # YOUR WORK HERE\n end", "def related_models\n via_assay = assays.collect(&:models).flatten.uniq.compact\n via_assay | models\n end", "def graph_name\n nil\n end", "def remove_has_target_statements\n remove_predicate_and_its_object_statements RDF::Vocab::OA.hasTarget\n end", "def eager_graph_with_options(associations, opts=OPTS)\n associations = [associations] unless associations.is_a?(Array)\n if eg = @opts[:eager_graph]\n eg = eg.dup\n [:requirements, :reflections, :reciprocals, :limits].each{|k| eg[k] = eg[k].dup}\n eg[:local] = opts\n ds = clone(:eager_graph=>eg)\n ds.eager_graph_associations(ds, model, ds.opts[:eager_graph][:master], [], *associations)\n else\n # Each of the following have a symbol key for the table alias, with the following values: \n # :reciprocals :: the reciprocal value to use for this association\n # :reflections :: AssociationReflection instance related to this association\n # :requirements :: array of requirements for this association\n # :limits :: Any limit/offset array slicing that need to be handled in ruby land after loading\n opts = {:requirements=>{}, :master=>alias_symbol(first_source), :reflections=>{}, :reciprocals=>{}, :limits=>{}, :local=>opts, :cartesian_product_number=>0, :row_proc=>row_proc}\n ds = clone(:eager_graph=>opts)\n ds.eager_graph_associations(ds, model, ds.opts[:eager_graph][:master], [], *associations).naked\n end\n end", "def statements\n @statements ||= statements_as_subject + statements_as_predicate + statements_as_object\n end", "def test_delete_if\n graph = Rgraphum::Graph.new\n (0..9).each do |i|\n graph.vertices << { label: \"v#{i}\" }\n end\n (0..9).each do |i|\n graph.edges << {\n source: graph.vertices[i],\n target: graph.vertices[(i+1) % 10],\n weight: i,\n }\n end\n\n # v0 -> v1 -> v2 -> v3 -> v4 -> v5 -> v6 -> v7 -> v8 -> v9\n # ^ |\n # +-----------------------------------------------------+\n assert_equal 10, graph.vertices.size\n assert_equal 10, graph.edges.size\n graph.vertices do |vertex|\n assert_equal 2, vertex.edges.size\n end\n\n graph.edges.delete_if { |edge| edge.weight.odd? }\n # graph.edges.reject! { |edge| edge.weight.odd? }\n\n # v0 -> v1 v2 -> v3 v4 -> v5 v6 -> v7 v8 -> v9\n assert_equal 10, graph.vertices.size\n assert_equal 5, graph.edges.size, \"edges.size was 10 but deleted 5 edges\"\n\n assert_equal 0, graph.edges[0].weight\n assert_equal 2, graph.edges[1].weight\n assert_equal 4, graph.edges[2].weight\n assert_equal 6, graph.edges[3].weight\n assert_equal 8, graph.edges[4].weight\n\n graph.vertices do |vertex|\n assert_equal 1, vertex.edges.size\n end\n end", "def test_has_node_dummy_with_obj\n nonexistent_node = Node.new(1, [2])\n refute @graph.node?(nonexistent_node)\n end", "def discard_transaction\n\t clear_vertex\n\t super if defined? super\n\tend", "def initialize(scenario)\n @graph = scenario.gql.future.graph\n end", "def index\n @graphs = Graph.all\n end", "def build_graph\n \n RDF::Graph.load(@options.file).each do |statement|\n subject = statement.subject\n predicate = statement.predicate\n object = statement.object\n \n edge(predicate,node(subject),node(object))\n end\n end", "def test_lists\r\n nodelist = @mymodel.node_list\r\n linklist = @mymodel.link_list\r\n \r\n assert(nodelist.size == 0)\r\n assert(linklist.size == 0)\r\n end", "def clear_relations\n each_event { |ev| ev.clear_relations }\n\t super()\n self\n\tend", "def destroy_constraints_statements(repository_name, model)\n model.many_to_one_relationships.map do |relationship|\n table_name = model.storage_name(repository_name)\n constraint_name = constraint_name(table_name, relationship.name)\n next unless constraint_exists?(table_name, constraint_name)\n\n destroy_constraints_statement(table_name, constraint_name)\n\n end.compact\n end", "def generate_objects!\n if custom_query?\n results = eval(custom_query)\n else\n objects = any? ? [] : starting_objects.clone\n objects_to_delete = []\n puts \"Evaluating #{starting_objects.size} objects and #{conditions.size} condition(s)...\"\n for obj in starting_objects\n # print \"\\n #{obj.id}: \"\n for condition in conditions\n # print \" [C#{condition.id}:\"\n if condition.passes?(obj)\n # print \"PASS]\"\n objects << obj and break if any?\n else\n # print \"FAIL]\"\n objects_to_delete << obj and break if all?\n end\n end\n end\n results = objects - objects_to_delete\n unless result_variant.blank?\n results = results.collect{|r| r.instance_eval(result_variant)}.flatten\n end\n end\n update_object_ids(results)\n update_attribute(:objects_generated_at, Time.now)\n update_attribute(:objects_count, self.object_ids.values.flatten.uniq.size)\n results\n end", "def fill_save_graph( graph )\n raise \"#{self.to_s}.fill_save_graph should fill the supplied graph with the data from the object.\"\n end", "def all(options = {})\n unlinked = options[:unlinked] || false\n\n results = run\n nodes = QL.from_bindings_to_nodes(results, @last_query_context, :unlinked => unlinked)\n nodes\n #sets = @last_query_context.query_keys\n #nodes.select do |node|\n # valid = false\n # c = 0\n # while(!valid && c<sets.length)\n # sets_keys, sets_query = sets[c]\n # valid = (sets_keys.empty?) || sets_keys.inject(true) do |ac,k|\n # value = nil\n # if (sets_query[k].is_a?(Hash) || (sets_query[k].is_a?(Symbol)))\n # value = ac && node[k]\n # end\n # if(value.nil? && @reasoning == true)\n # value = ac && node.values.include?(sets_query[k])\n # end\n # if (value.nil? && sets_query[k].is_a?(String) && sets_query[k].index(\"@id(\"))\n # value = ac && node[k]\n # end\n # if(value.nil?)\n # ac && node[k] == sets_query[k]\n # else\n # value\n # end\n # end\n # c += 1\n # end\n # valid\n #end\n end", "def test_empty_chain\n #puts \"---------------test_chain-----------------\"\n\n t1 = t2 = t3 = t4 = nil\n GraphBuilder::Builder.build do |b|\n t1 = b.add(Thing1.new)\n b.chain do\n end\n t4 = b.add(Thing4.new)\n end\n\n r = Thing.links([t1,t4])\n assert_equal 1, r.size\n assert r.include? [t1,t4]\n end", "def test_has_edge_no_edge\n assert(@graph.has_edge('b', 'd') == false)\n end", "def provided_models\n if model = explicit_fullfilled_model\n [model[0]] + model[1]\n else\n models = self.model.fullfilled_model\n if (task_class = models.find { |m| m.kind_of?(Class) })\n [task_class] + models.find_all { |m| !task_class.has_ancestor?(m) }\n else\n models\n end\n end\n end", "def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n\n # use the built-in error checking\n if !runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n\n # assign the user inputs to variables\n remove_unused_space_types = runner.getBoolArgumentValue(\"remove_unused_space_types\",user_arguments)\n remove_unused_load_defs = runner.getBoolArgumentValue(\"remove_unused_load_defs\",user_arguments)\n remove_unused_schedules = runner.getBoolArgumentValue(\"remove_unused_schedules\",user_arguments)\n remove_unused_constructions = runner.getBoolArgumentValue(\"remove_unused_constructions\",user_arguments)\n\n # report initial condition of model\n runner.registerInitialCondition(\"The model started with #{model.numObjects.to_s} objects.\")\n\n # remove orphan space infiltration objects\n orphan_flag = false\n model.getSpaceInfiltrationDesignFlowRates.sort.each do |instance|\n if instance.spaceType.is_initialized == false and instance.space.is_initialized == false\n runner.registerInfo(\"Removing orphan space infiltration object named #{instance.name}\")\n instance.remove\n orphan_flag = true\n end\n end\n if not orphan_flag\n runner.registerInfo(\"No orphan space infiltration objects were found\")\n end\n\n # todo - add section to remove orphan effective leakage\n\n # remove orphan design spec oa objects\n orphan_flag = false\n model.getDesignSpecificationOutdoorAirs.sort.each do |instance|\n if instance.directUseCount == 0\n runner.registerInfo(\"Removing orphan design specification outdoor air object named #{instance.name}\")\n instance.remove\n orphan_flag = true\n end\n end\n if not orphan_flag\n runner.registerInfo(\"No orphan design specification outdoor air objects were found\")\n end\n\n # remove orphan load instances\n orphan_flag = false\n model.getSpaceLoadInstances.sort.each do |instance|\n if instance.spaceType.is_initialized == false and instance.space.is_initialized == false\n\n # extra check for water use equipment. They may or may not have space. But they should have a water use connection\n if instance.to_WaterUseEquipment.is_initialized and instance.to_WaterUseEquipment.get.waterUseConnections.is_initialized\n next\n end\n\n runner.registerInfo(\"Removing orphan load instance object named #{instance.name}\")\n instance.remove\n orphan_flag = true\n end\n end\n if not orphan_flag\n runner.registerInfo(\"No orphan load instance objects were found\")\n end\n\n # remove orphan surfaces\n orphan_flag = false\n model.getSurfaces.sort.each do |surface|\n if not surface.space.is_initialized\n runner.registerInfo(\"Removing orphan base surface named #{surface.name}\")\n surface.remove\n orphan_flag = true\n end\n end\n if not orphan_flag\n runner.registerInfo(\"No orphan base surfaces were found\")\n end\n\n # remove orphan subsurfaces\n orphan_flag = false\n model.getSubSurfaces.sort.each do |subsurface|\n if not subsurface.surface.is_initialized\n runner.registerInfo(\"Removing orphan sub surface named #{subsurface.name}\")\n subsurface.remove\n orphan_flag = true\n end\n end\n if not orphan_flag\n runner.registerInfo(\"No orphan sub surfaces were found\")\n end\n\n # remove orphan shading surfaces\n orphan_flag = false\n model.getShadingSurfaces.sort.each do |surface|\n if not surface.shadingSurfaceGroup.is_initialized\n runner.registerInfo(\"Removing orphan shading surface named #{surface.name}\")\n surface.remove\n orphan_flag = true\n end\n end\n if not orphan_flag\n runner.registerInfo(\"No orphan shading surfaces were found\")\n end\n\n # remove orphan interior partition surfaces\n orphan_flag = false\n model.getInteriorPartitionSurfaces.sort.each do |surface|\n if not surface.interiorPartitionSurfaceGroup.is_initialized\n runner.registerInfo(\"Removing orphan interior partition surface named #{surface.name}\")\n surface.remove\n orphan_flag = true\n end\n end\n if not orphan_flag\n runner.registerInfo(\"No orphan interior partition surfaces were found\")\n end\n\n # find and remove orphan LifeCycleCost objects\n lcc_objects = model.getObjectsByType(\"OS:LifeCycleCost\".to_IddObjectType)\n #make an array to store the names of the orphan LifeCycleCost objects\n orphaned_lcc_objects = Array.new\n #loop through all LifeCycleCost objects, checking for missing Item Name\n lcc_objects.each do |lcc_object|\n if lcc_object.isEmpty(4)\n orphaned_lcc_objects << lcc_object.handle\n puts \"**(removing object)#{lcc_object.name} is not connected to any model object\"\n runner.registerInfo(\"Removing orphan lifecycle cost named #{lcc_object.name}\")\n lcc_object.remove\n end\n end\n #summarize the results\n if not orphaned_lcc_objects.length > 0\n runner.registerInfo(\"no orphaned LifeCycleCost objects were found\")\n end\n\n # todo - remove surfaces that would trigger error in E+ (less than 3 vertices or too small.)\n\n\n # todo - remove empty shading and interior partition groups. Don't think we would want to do this to spaces, since they may contain space types or loads\n\n\n # remove unused space types\n if remove_unused_space_types\n unused_flag_counter = 0\n model.getSpaceTypes.sort.each do |resource|\n if resource.spaces.size == 0\n unused_flag_counter += 1\n resource.remove\n end\n end\n runner.registerInfo(\"Removed #{unused_flag_counter} unused space types\")\n end\n\n # remove unused load defs\n if remove_unused_load_defs\n unused_flag_counter = 0\n model.getSpaceLoadDefinitions.sort.each do |resource|\n if resource.directUseCount == 0\n unused_flag_counter += 1\n resource.remove\n end\n end\n runner.registerInfo(\"Removed #{unused_flag_counter} unused load definitions\")\n end\n\n # remove unused default schedule sets\n if remove_unused_schedules\n unused_flag_counter = 0\n model.getDefaultScheduleSets.sort.each do |resource|\n if resource.directUseCount == 0\n unused_flag_counter += 1\n resource.remove\n end\n end\n runner.registerInfo(\"Removed #{unused_flag_counter} unused default schedules sets\")\n end\n\n # remove unused default schedules\n if remove_unused_schedules\n unused_flag_counter = 0\n model.getSchedules.sort.each do |resource|\n if resource.directUseCount == 0\n unused_flag_counter += 1\n resource.remove\n end\n end\n runner.registerInfo(\"Removed #{unused_flag_counter} unused schedules\")\n end\n\n # remove unused default schedule sets\n if remove_unused_constructions\n\n unused_flag_counter = 0\n model.getDefaultConstructionSets.sort.each do |resource|\n if resource.directUseCount == 0\n unused_flag_counter += 1\n resource.remove\n end\n end\n runner.registerInfo(\"Removed #{unused_flag_counter} unused default construction sets\")\n\n # remove default surface and sub surface constructions, but dont' report\n # these are typically hidden from users and reporting it may be more confusing that helpful\n unused_flag_counter = 0\n model.getDefaultSurfaceConstructionss.sort.each do |resource|\n if resource.directUseCount == 0\n unused_flag_counter += 1\n resource.remove\n end\n end\n #runner.registerInfo(\"Removed #{unused_flag_counter} unused default surface constructions\")\n\n unused_flag_counter = 0\n model.getDefaultSubSurfaceConstructionss.sort.each do |resource|\n if resource.directUseCount == 0\n unused_flag_counter += 1\n resource.remove\n end\n end\n #runner.registerInfo(\"Removed #{unused_flag_counter} unused default sub surface constructions\")\n\n # remove default constructions\n unused_flag_counter = 0\n model.getConstructions.sort.each do |resource|\n if resource.directUseCount == 1 # still don't understand why this is 1 not 0\n unused_flag_counter += 1\n resource.remove\n else # this was just put in for testing ot understand why directUseCount isn't 0\n #puts \"\"\n #puts \"Name #{resource.name}\"\n #puts \"directUseCount = #{resource.nonResourceObjectUseCount}\"\n #puts \"nonResourceObjectUseCount = #{resource.nonResourceObjectUseCount}\"\n #puts \"targets.size = #{resource.targets.size}\"\n #puts \"sources.size = #{resource.sources.size}\"\n\n end\n end\n runner.registerInfo(\"Removed #{unused_flag_counter} unused constructions\")\n\n # remove unused materials\n unused_flag_counter = 0\n model.getMaterials.sort.each do |resource|\n if resource.directUseCount == 0\n unused_flag_counter += 1\n resource.remove\n end\n end\n runner.registerInfo(\"Removed #{unused_flag_counter} unused materials\")\n\n end\n\n # report final condition of model\n runner.registerFinalCondition(\"The model finished with #{model.numObjects.to_s} objects.\")\n\n return true\n\n end", "def all_related_models\n via_assay = related_assays.collect do |assay|\n assay.model_masters\n end.flatten.uniq.compact\n via_assay | related_models\n end", "def explicit_fullfilled_model?\n !!explicit_fullfilled_model\n end", "def includes\n @includes ||= remove_through_model(full_includes)\n end" ]
[ "0.5597195", "0.55133337", "0.5406379", "0.530991", "0.5297998", "0.5282695", "0.525528", "0.5249848", "0.5246992", "0.51800144", "0.51720977", "0.5172053", "0.5152756", "0.5147899", "0.51356155", "0.51356155", "0.51038206", "0.50939673", "0.5085285", "0.5081328", "0.5078451", "0.50643486", "0.5057599", "0.503536", "0.5020005", "0.5018004", "0.49729326", "0.49696112", "0.4950971", "0.4949689", "0.49359617", "0.49002436", "0.4892896", "0.48752347", "0.48723415", "0.48697105", "0.48487717", "0.484389", "0.48389348", "0.4838304", "0.483256", "0.4830314", "0.48216113", "0.48153597", "0.47950917", "0.47921228", "0.47887123", "0.47884822", "0.4779021", "0.47647086", "0.4759277", "0.47568718", "0.4755289", "0.4753614", "0.47505206", "0.47484443", "0.474327", "0.47411084", "0.473881", "0.47303733", "0.47301376", "0.47234964", "0.47229806", "0.47204164", "0.47039893", "0.47025937", "0.46954358", "0.46906173", "0.46843207", "0.46843207", "0.4680594", "0.4672957", "0.4671632", "0.4670101", "0.46697387", "0.4669089", "0.4662836", "0.46620357", "0.4656138", "0.46507356", "0.46505532", "0.4647213", "0.4643685", "0.46433142", "0.46367243", "0.4635497", "0.4635491", "0.46339086", "0.46305817", "0.46274623", "0.46251684", "0.46250564", "0.4622967", "0.46197215", "0.461732", "0.46162564", "0.46147624", "0.46108803", "0.46104234", "0.46006644" ]
0.5764731
0
returns the number of items within the entire collection
def item_count @collection.length end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def item_count\n @collection.size\n end", "def item_count\n collection.length\n end", "def item_count\n @collection.count\n end", "def count\n collection.count\n end", "def number_of_elements_in_collection\n # collection here refers to the collection that is set with the initialize method\n # collection() is a private accessor method at the bottom of this class that accesses @collection\n collection.count\n end", "def size\n @collection.size\n end", "def length\n collection.size\n end", "def count\r\n items.size\r\n end", "def count\n @collection.count(Scope.new(@collection, @selector, @opts))\n end", "def count_items\n @items.size\n end", "def size\n @collection.size\n end", "def total_entries\n collection.total_count\n end", "def count\n @item_list.size\n end", "def size\n @items.count\n end", "def size\n @items.count\n end", "def item_count\n @items.length \n end", "def item_count\n @items.length\n end", "def count\n each.size\n end", "def count\n items.compact.count.to_d\n end", "def count\n Driver.client[coll_name].find.count\n end", "def size\n items.size\n end", "def size\n items.size\n end", "def size\n return @items.size\n end", "def size\n return @items.size\n end", "def size\n\n @items.size\n end", "def count\n each.count\n end", "def items_count\n @items_count ||= @relation.count\n end", "def size\n return @items.length\n end", "def size\n return @items.length\n end", "def size\n return @items.length\n end", "def size\n return @items.length\n end", "def size\n return @items.length\n end", "def size\n return @items.length\n end", "def size\n return @items.length\n end", "def all_items_count\n all_items.count\n end", "def total_count\n @all.size\n end", "def size\n return @items.length\n end", "def size\n\t\treturn @items.size\n end", "def size\n @items.size\n end", "def size\n @items.size\n end", "def size\n @items.size\n end", "def size\n @items.size\n end", "def size\n @items.size\n end", "def size\n @items.size\n end", "def size\n @items.size\n end", "def size\n @items.size\n end", "def size\n @items.size\n end", "def size\n @items.size\n end", "def size\n @items.size\n end", "def size\n @items.size\n end", "def size\n @items.size\n end", "def size\n @items.length\n end", "def item_count\n return @item_count\n end", "def size\n @items.length\n end", "def size\n @items.length\n end", "def size\n @items.length\n end", "def size\n @items.length\n end", "def size\n @items.length\n end", "def size\n @items.length\n end", "def size\n @items.length\n end", "def size\n @items.length\n end", "def size\n @items.length\n end", "def size\n @items.length\n end", "def size\n @items.length\n end", "def size\n @items.length\n end", "def size\n @items.length\n end", "def size\n @items.length\n end", "def size\n @items.length\n end", "def size\n @items.length\n end", "def size\n @items.length\n end", "def size\n @items.length\n end", "def size\n @items.length\n end", "def size\n @items.length\n end", "def size\n @items.length\n end", "def size\n @items.length\n end", "def size\n @items.length\n end", "def size\n @items.length\n end", "def size\n @items.length\n end", "def size\n @items.length\n end", "def size\n @items.length\n end", "def size\n @items.length\n end", "def size\n @items.length\n end", "def size\n @items.length\n end", "def size\n @items.length\n end", "def size\n @items.length\n end", "def size\n @items.length\n end", "def size\n @items.length\n end", "def size\n @items.length\n end", "def size\n @items.length\n end", "def item_count\n @item_count ||= except(:includes, :limit, :offset).count\n end", "def size\n\t\t@items.size\n\tend", "def count\n @all.size\n end", "def records_count\n cached_collection.count\n end", "def count\n @documents.count\n end", "def size\n @items.length \n end", "def item_count\n titles.size\n end", "def size\n @items_set.size\n end", "def num_items()\n items ? items.length : 0\n end", "def page_count\n if collection.length < page_size\n 1\n else\n (collection.length / page_size) + 1\n end\n end", "def size\n @items.size\n end" ]
[ "0.8950768", "0.8918706", "0.881112", "0.8568127", "0.8565642", "0.82640946", "0.8262284", "0.822973", "0.8160236", "0.8156021", "0.8138456", "0.805573", "0.79227865", "0.7866197", "0.7866197", "0.78629667", "0.7862662", "0.7845518", "0.7803834", "0.7803348", "0.7711624", "0.7711624", "0.7704124", "0.7660036", "0.7650459", "0.7618048", "0.76170266", "0.7614156", "0.7614156", "0.7614156", "0.7614156", "0.7614156", "0.7614156", "0.7614156", "0.7605205", "0.75980073", "0.75878066", "0.75689584", "0.7564309", "0.7564309", "0.7564309", "0.7564309", "0.7564309", "0.7564309", "0.7564309", "0.7564309", "0.7564309", "0.7564309", "0.7564309", "0.7564309", "0.75443333", "0.75011194", "0.75002265", "0.74983597", "0.74983597", "0.74983597", "0.74983597", "0.74983597", "0.74983597", "0.74983597", "0.74983597", "0.74983597", "0.74983597", "0.74983597", "0.74983597", "0.74983597", "0.74983597", "0.74983597", "0.74983597", "0.74983597", "0.74983597", "0.74983597", "0.74983597", "0.74983597", "0.74983597", "0.74983597", "0.74983597", "0.74983597", "0.74983597", "0.74983597", "0.74983597", "0.74983597", "0.74983597", "0.74983597", "0.74983597", "0.74983597", "0.74983597", "0.74983597", "0.74940944", "0.7488854", "0.74883354", "0.7467526", "0.7466452", "0.746622", "0.74577206", "0.7451262", "0.7439315", "0.7434879", "0.7424756", "0.7421028" ]
0.8898303
2
returns the number of pages
def page_count @collection.max + 1 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def page_count; pages.count; end", "def number_of_pages\n return @number_of_pages\n end", "def page_count\n @total_pages\n end", "def num_pages\n n, rest = @num_entries.divmod(@entries_per_page)\n if rest > 0 then n + 1 else n end\n end", "def total_pages\n pages.size\n end", "def getPageCount()\n return @helper.getPageCount()\n end", "def getPageCount()\n return @helper.getPageCount()\n end", "def getPageCount()\n return @helper.getPageCount()\n end", "def getPageCount()\n return @helper.getPageCount()\n end", "def page_count\n @page_counter\n end", "def page_count\n @pages.count\n end", "def total_pages; end", "def page_count\n page_size.zero? ? 1 : (count.to_f / page_size).ceil\n end", "def num_pages\n if order_bw_pages && order_color_pages\n return 2 + order_bw_pages + order_color_pages\n end\n end", "def page_count\n load_page(1) if @num_records.nil? # load pagination metadata\n @num_pages\n end", "def page_count\n @page_count ||= get_page_count\n end", "def pages_count\n @pages_count ||= (items_count / @per_page.to_f).ceil\n end", "def num_pages\n (total_count.to_f / per_page).ceil\n end", "def num_pages\n (except(:offset, :limit).count.to_f / limit_value).ceil\n end", "def num_pages\n (@total_entries.to_i / per_page.to_f).ceil\n end", "def num_pages\n 26\n end", "def number_of_pages\n (total / page_size.to_f).ceil\n end", "def num_pages\n (count.to_f / options[:limit]).ceil\n end", "def page_count\n @page_count\n end", "def number_of_pages\n document.at(\"[@itemprop='numberOfPages']\").innerHTML.scan(/\\d+/).first.to_i rescue nil\n end", "def pages(board)\n get(board, 1)[:pages].size\n end", "def num_pages\n (total_count.to_f / limit_value).ceil\n end", "def num_pages\n (total_count.to_f / limit_value).ceil\n end", "def page_count(arg)\n @pages = arg\n end", "def num_pages\n (@limit / 10.0).ceil\n end", "def page_count\n # Integer arithmetic is simpler and faster.\n @page_count ||= item_count > 0 ? (item_count - 1) / items_per_page + 1 : 1\n end", "def total_pages\n -1\n end", "def page_count\n @page_count ||= ( @total_results / @query.page_size.to_f ).ceil\n end", "def page_count\n (unpaged_count.to_f / @entries_per_page).ceil\n end", "def page_count\n if collection.length < page_size\n 1\n else\n (collection.length / page_size) + 1\n end\n end", "def page_count\n 1\n end", "def show_total_pages\n pages = show_total_hits / show_results_per_page\n return pages + 1\n end", "def total_pages\n (items.size - 1) / max_items + 1\n end", "def get_num_pages\n record_count = @model_class.count\n if record_count % @items_per_page == 0\n (record_count / @items_per_page)\n else\n (record_count / @items_per_page) + 1\n end\n end", "def total_pages\n @total_pages\n end", "def page_count\n @page_count = notices_count/30 + 1\n @page_count = max_pages if @page_count > max_pages\n @page_count\n end", "def page_count(input)\n info = info(input)\n return nil if info.nil?\n info['Pages'].to_i\n end", "def page_count\n pages.last\n end", "def current_page_number\n @pageset.size\n end", "def extract_total_pages\n pag = setup.fetch_page.css('.Ver12C')[70].text\n pag.scan(/\\d+/)[2].to_i\n end", "def num_pages \n if source_record['300'] && (source_record['300']['a'] =~ /(\\d{1,6}) ?pp?(?:[\\. ]|\\Z)(?!.*\\d+ pp?(?:[\\. ]|\\Z))/)\n return $1\n end\n\n return nil\n end", "def count\n @document.page_count\n end", "def get_number_of_pages(numrec)\n return ((numrec + 50) / 50 * 50) / 50\nend", "def page_count\n if item_count % @items_per_page == 0\n item_count / @items_per_page\n else\n 1 + (item_count / @items_per_page)\n end\n end", "def getTotalPageCount()\n return @helper.getTotalPageCount()\n end", "def total_pages\n total = total_items / page_size\n if total_items % page_size != 0\n total += 1\n end\n total\n end", "def page_count\n file_groups\n @highest_page_count\n end", "def total_pages(games_count)\n (games_count % GAMES_PER_PAGE == 0 ? games_count / GAMES_PER_PAGE : games_count / GAMES_PER_PAGE + 1).to_i\n end", "def get_page_count(response)\n page_links = response.headers['link'].scan(/<(\\S+)>/).flatten\n /\\?page\\=(\\d+)\\&/.match(page_links.last)[1].to_i\n end", "def page_item_count(page_index)\n return -1 if page_index < 0 || page_index >= self.page_count\n @pages[page_index].count\n end", "def total_pages\n nil\n end", "def total_pages\n nil\n end", "def total_pages\n self.search.results.total_pages\n end", "def num_pages(url)\n url = ensure_max_per_page(url)\n data = api_request_raw(url)\n\n if data.nil? or data.meta.nil? or data.meta['link'].nil?\n return 1\n end\n\n links = parse_links(data.meta['link'])\n\n if links.nil? or links['last'].nil?\n return 1\n end\n\n params = CGI::parse(URI::parse(links['last']).query)\n params['page'][0].to_i\n end", "def page_count(doc)\n doc.at_css('.pagination') && doc.at_css('.pagination')\n .css('b')\n .map(&:text)\n .map(&:to_i)\n .max\n end", "def item_count\n @pages.inject(0){|item_count, page| item_count + page.count}\n end", "def page_count\n (item_count / @items_per_page.to_f).ceil\n end", "def number_of_pages=(value)\n @number_of_pages = value\n end", "def page_size\n @raw_page['records'].size\n end", "def total_pages\n pagination_adapter.total_pages\n end", "def page_count()\n if @pages >= 500\n return true\n end\n else\n return false\n end", "def number_pages\n pagenum = 1\n @sequence.each do |entry|\n entry.pagenum = pagenum\n next if (is_page? entry and entry.valid_repeat)\n pagenum += 1 if is_page?(entry)\n end\n end", "def page_count \n (item_count / @per_page.to_f).ceil \n end", "def total_pages\n collection.total_pages\n end", "def page_count\n bib_page_count\n end", "def total_pages\n ( total_results.to_f / limit ).ceil\n end", "def page_length\n return 0 if self.elements[:results].nil?\n self.elements[:results].length\n end", "def total_pages\n f = total_results.to_f / RESULTS_PER_PAGE\n f.ceil\n end", "def total_pages\n (posts.count + PER_PAGE - 1) / PER_PAGE # Taking advantage from integer division\n end", "def actual_page_count\n warn \"WARNING: actual_page_count is not yet implemented properly.\"\n warn \" Please send patches.\"\n @pages.count\n end", "def count\n load_page(1) if @num_records.nil? # load pagination metadata\n @num_records\n end", "def page_num_getter\n\t\t##Nokogiri\n\t\t# doc = Nokogiri::HTML(open(@page_name))\n\t\t# puts doc.css('result custom-right-inner')\n\t\t##Mechanize\n\t\t##new agent\n\t\t@agent = Mechanize.new\n\t\tstr = @agent.get(@page_name).search('span.custom-right-inner')[0].text\n\t\t@total_page = str.scan(/\\d+/)[0].to_i\n\tend", "def total_pages\n\t\t\t\treturn 0 if @total_results == 0\n\t\t\t\t(@total_results.to_f / BATCH_SIZE).ceil\n\t\t\tend", "def get_total_pages\n\t\turl = \"#{@base_url}partners?city=#{@city}\"\n\t\tpage = @mechanize.get(url)\n\t\ttotal_pages = page.search('.pagination li:last a')[0]['href'].split('=')[2].to_i\n\tend", "def number_of_pages job\n count = 0\n pages = job.client_images_to_jobs.length\n if (@facility.image_type == 1) && (pages < 2)\n job.images_for_jobs.each do |image|\n path = Dir.glob(\"#{@location}/Parser/Images/#{image.filename}\").first\n count += %x[identify \"#{path}\"].split(image.filename).length-1 #command for retrieve number of pages in a tiff file (multi/single)\n end\n pages = count\n end\n pages\n end", "def total_pages\n (count / per_page.to_f).ceil\n end", "def number_of_pages job\n count = 0\n pages = job.client_images_to_jobs.length\n if (@facility.image_type == 1) && (pages < 2)\n job.images_for_jobs.each do |image|\n path = Dir.glob(\"#{@location}/**/#{image.filename}\").first\n count += %x[identify #{path}].split(image.filename).length-1 rescue nil #command for retrieve number of pages in a tiff file (multi/single)\n end\n pages = count\n end\n pages\n end", "def number_of_pages job\n count = 0\n pages = job.client_images_to_jobs.length\n if (@facility.image_type == 1) && (pages < 2)\n job.images_for_jobs.each do |image|\n path = Dir.glob(\"#{@location}/**/#{image.filename}\").first\n count += %x[identify #{path}].split(image.filename).length-1 rescue nil #command for retrieve number of pages in a tiff file (multi/single)\n end\n pages = count\n end\n pages\n end", "def number_of_pages job\r\n count = 0\r\n pages = job.client_images_to_jobs.length\r\n if (@facility.image_type == 1) && (pages < 2)\r\n job.images_for_jobs.each do |image|\r\n path = Dir.glob(\"#{@location}/**/#{image.filename}\").first\r\n count += %x[identify \"#{path}\"].split(image.filename).length-1 #command for retrieve number of pages in a tiff file (multi/single)\r\n end\r\n pages = count\r\n end\r\n pages\r\n end", "def max_pages() 1 end", "def number_of_pages job\n count = 0\n pages = job.client_images_to_jobs.length\n if (@facility.image_type == 1) && (pages < 2)\n job.images_for_jobs.each do |image|\n path = Dir.glob(\"#{@location}/**/#{image.filename}\").first\n count += %x[identify #{path}].split(image.filename).length-1 #command for retrieve number of pages in a tiff file (multi/single)\n end\n pages = count\n end\n pages\n end", "def get_total_pages(page)\n\t\t\tsource = getHtml(page).split(\";\")\n\t\t\ttotal_pages = 0 \n\t\t\tsource.each do |pos|\n\t\t\t\tif pos.include? \"total_pages\" \n\t\t\t\t\treturn pos[pos.index(\"=\") + 1, pos.length].to_i \n\t\t\t\tend\n\t\t\tend\n\t\tend", "def number_of_pages job\n count = 0\n pages = job.client_images_to_jobs.length\n if (@facility.image_type == 1) && (pages < 2)\n job.images_for_jobs.each do |image|\n path = Dir.glob(\"#{@location}/**/#{image.filename}\").first\n count += %x[identify \"#{path}\"].split(image.filename).length-1 #command for retrieve number of pages in a tiff file (multi/single)\n end\n pages = count\n end\n pages\n end", "def total_pages\n @total_pages ||= (@data.rows.length / per_page.to_f).ceil\n end", "def getNumberOfPages(doc)\n numberOfPages = 1\n\n doc.search(\"Document > View > ScrollView > VBoxView > View > MatrixView > VBoxView:nth(0) > HBoxView > TextView > SetFontStyle > b\").each do |e|\n # Parse the last number in the string, e.g. the 99 in \"Page 3 of 99\"\n numberOfPages = e.inner_html[/[0-9]+$/].to_i\n end\n\n return numberOfPages\nend", "def number_of_pages job\n count = 0\n pages = job.client_images_to_jobs.length\n if (@facility.image_type == 1) && (pages < 2)\n job.images_for_jobs.each do |image|\n image_path = @image_folder.detect{|image_string| image_string.downcase == \"#{@image_path}/#{image.image_file_name}\".downcase}\n count += %x[identify #{image_path}].split(image.image_file_name).length-1 rescue nil #command for retrieve number of pages in a tiff file (multi/single)\n end\n pages = count\n end\n pages\n end", "def total_pages\n @total_pages ||= (count.to_f / per_page).ceil\n end", "def last_page_number\n number_of_pages\n end", "def num_pages\n groups = self.groups.includes(:descriptions)\n groups.map {|g| g.descriptions.length > 0 ? 1 : 0}.sum\n end", "def page_number\n\t\t\t\treturn 0 if @total_results == 0\n\t\t\t\t@offset + 1\n\t\t\tend", "def page_item_count(page_index)\n if (page_index + 1 < page_count)\n page_size\n elsif page_index + 1 > page_count\n -1\n else\n item_count % page_size\n end\n end", "def pages_per_bookkeeping_page\n page_size\n end", "def number_of_json_pages(state) #this will return an integer representing number of pages, use this to refactor\n state_locations(state)[\"numberOfPages\"]\n end", "def get_links_count page_number\n begin\n \n if @filename == ''\n raise 'filename not specified'\n end\n \n if page_number == ''\n raise 'page number not specified'\n end\n \n \n str_uri = $product_uri + '/pdf/' + @filename + '/pages/' + page_number.to_s + '/links'\n str_signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri) \n response_stream = RestClient.get(str_signed_uri, {:accept=>'application/json'})\n \n stream_hash = JSON.parse(response_stream)\n \n return stream_hash['Links']['List'].length\n \n \n rescue Exception=>e\n print e\n end\n end", "def max_pages() Pages.keys.size end" ]
[ "0.8871328", "0.8835811", "0.87635493", "0.86556756", "0.8639673", "0.8625077", "0.8625077", "0.8625077", "0.8625077", "0.8606896", "0.84872305", "0.8312499", "0.8308352", "0.82833606", "0.82538044", "0.8244665", "0.82341814", "0.82276404", "0.8223418", "0.81749964", "0.81725395", "0.8171214", "0.81569517", "0.81421524", "0.81361306", "0.8118509", "0.81129956", "0.81129956", "0.8105327", "0.806335", "0.80427974", "0.8004959", "0.79954755", "0.79752123", "0.79697645", "0.79679275", "0.79458386", "0.78955066", "0.78877705", "0.7879689", "0.7868856", "0.7855552", "0.7834736", "0.78298193", "0.78200394", "0.78182083", "0.7817464", "0.78121716", "0.77955943", "0.77933246", "0.77929026", "0.7771359", "0.7769288", "0.7756102", "0.77289796", "0.77132773", "0.77132773", "0.7686333", "0.76822364", "0.76715684", "0.7670368", "0.7667015", "0.7651537", "0.7651143", "0.7629971", "0.7606548", "0.7604786", "0.75837654", "0.7583268", "0.75568885", "0.75433594", "0.7535463", "0.7534336", "0.75295067", "0.7521924", "0.7517745", "0.75146353", "0.7511965", "0.75111187", "0.75098306", "0.7496658", "0.7493119", "0.7493119", "0.7483175", "0.747945", "0.7473536", "0.7472861", "0.7467843", "0.74641913", "0.74602735", "0.7454101", "0.74533355", "0.74415267", "0.74331325", "0.7432761", "0.74251187", "0.7417616", "0.7395888", "0.7390414", "0.73768234" ]
0.7386953
99
returns the number of items on the current page. page_index is zero based. this method should return 1 for page_index values that are out of range
def page_item_count(page_index) return -1 if page_index > @collection[-1] || page_index < 0 @collection.count {|v| v == page_index} end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def page_item_count(page_index)\n return -1 if page_index < 0 || page_index >= self.page_count\n @pages[page_index].count\n end", "def page_item_count(page_index)\n if (page_index + 1 < page_count)\n page_size\n elsif page_index + 1 > page_count\n -1\n else\n item_count % page_size\n end\n end", "def page_item_count(page_index)\n return -1 if page_index < 0\n return -1 if page_index >= page_count\n if page_index < (page_count-1)\n @items_per_page\n else\n this_page = item_count % @items_per_page\n this_page == 0 ? @items_per_page : this_page\n end\n end", "def page_item_count(page_index)\n return -1 if page_index < 0 || page_index > page_count-1 \n return @per_page if page_index < page_count-1 \n return item_count - ((page_count-1) * @per_page) \n end", "def page_count\n # Integer arithmetic is simpler and faster.\n @page_count ||= item_count > 0 ? (item_count - 1) / items_per_page + 1 : 1\n end", "def page_item_count(page_index)\n # input page index\n # array of pages : transform page_count to array of page_count elements\n pages_array = Array.new(page_count) { |i| i }\n # return the number of item on page_index if page_index in the range else return -1\n return -1 unless (0...page_count).include?(page_index)\n\n if pages_array[page_index] != pages_array[-1]\n @items_per_page\n else\n item_count % @items_per_page\n end\n end", "def page_count\n if item_count % @items_per_page == 0\n item_count / @items_per_page\n else\n 1 + (item_count / @items_per_page)\n end\n end", "def item_count\n @pages.inject(0){|item_count, page| item_count + page.count}\n end", "def page_count\n (item_count / @items_per_page.to_f).ceil\n end", "def total_pages\n (items.size - 1) / max_items + 1\n end", "def page_count\n if collection.length < page_size\n 1\n else\n (collection.length / page_size) + 1\n end\n end", "def pages_count\n @pages_count ||= (items_count / @per_page.to_f).ceil\n end", "def page_count\n @page_counter\n end", "def page_count; pages.count; end", "def page_count\n @total_pages\n end", "def page_index(item_index)\n if (item_index >= item_count || item_index < 0)\n -1\n elsif item_count == item_index - 1\n page_count - 1\n else\n (item_index / page_size)\n end\n end", "def getPageCount()\n return @helper.getPageCount()\n end", "def getPageCount()\n return @helper.getPageCount()\n end", "def getPageCount()\n return @helper.getPageCount()\n end", "def getPageCount()\n return @helper.getPageCount()\n end", "def num_pages\n n, rest = @num_entries.divmod(@entries_per_page)\n if rest > 0 then n + 1 else n end\n end", "def number_of_pages\n return @number_of_pages\n end", "def page_index(item_index)\n return -1 if item_index < 0 || item_index > item_count-1 \n item_index/@per_page \n end", "def page_count \n (item_count / @per_page.to_f).ceil \n end", "def page_count\n page_size.zero? ? 1 : (count.to_f / page_size).ceil\n end", "def total_pages\n total = total_items / page_size\n if total_items % page_size != 0\n total += 1\n end\n total\n end", "def page_count\n (unpaged_count.to_f / @entries_per_page).ceil\n end", "def page_count\n @collection.max + 1\n end", "def page_count\n @pages.count\n end", "def page_count\n @page_count ||= get_page_count\n end", "def get_num_pages\n record_count = @model_class.count\n if record_count % @items_per_page == 0\n (record_count / @items_per_page)\n else\n (record_count / @items_per_page) + 1\n end\n end", "def current_page_number\n @pageset.size\n end", "def page_index(item_index)\n return -1 if item_index < 0\n return -1 if item_index >= item_count\n item_index / @items_per_page\n end", "def page_count\n 1\n end", "def num_pages\n (@total_entries.to_i / per_page.to_f).ceil\n end", "def total_pages\n pages.size\n end", "def page_count\n @page_count\n end", "def page_number\n\t\t\t\treturn 0 if @total_results == 0\n\t\t\t\t@offset + 1\n\t\t\tend", "def num_pages\n (except(:offset, :limit).count.to_f / limit_value).ceil\n end", "def total_pages\n -1\n end", "def page_count\n @page_count ||= ( @total_results / @query.page_size.to_f ).ceil\n end", "def num_pages\n (count.to_f / options[:limit]).ceil\n end", "def page_count\n pages.last\n end", "def num_pages\n (total_count.to_f / per_page).ceil\n end", "def num_pages\n (total_count.to_f / limit_value).ceil\n end", "def num_pages\n (total_count.to_f / limit_value).ceil\n end", "def getTotalPageCount()\n return @helper.getTotalPageCount()\n end", "def page_count\n load_page(1) if @num_records.nil? # load pagination metadata\n @num_pages\n end", "def page_index(item_index)\n # input item index\n # guard clause to check item in is the range\n return -1 unless (0...item_count).include?(item_index)\n\n # return the page index if item in the range else return -1\n item_index / @items_per_page\n end", "def num_pages\n (@limit / 10.0).ceil\n end", "def total_pages\n collection.total_pages\n end", "def total_pages\n pagination_adapter.total_pages\n end", "def number_of_pages\n document.at(\"[@itemprop='numberOfPages']\").innerHTML.scan(/\\d+/).first.to_i rescue nil\n end", "def page_index(item_index) \n return -1 if !(item_index < item_count) || item_index < 0\n @collection[item_index]\n end", "def count\n @document.page_count\n end", "def item_count\n return @item_count\n end", "def page_count\n @page_count = notices_count/30 + 1\n @page_count = max_pages if @page_count > max_pages\n @page_count\n end", "def page_size\n @raw_page['records'].size\n end", "def total_pages\n self.search.results.total_pages\n end", "def page_count_from_end(current_page, total_pages)\n (total_pages.to_i - current_page.to_i) + 1\n end", "def item_count\n @items.length\n end", "def page_index(item_index)\n return -1 if item_index < 0 || item_index >= self.item_count\n location = item_index.divmod @items_per_page\n location[0]\n end", "def item_count\n @item_count ||= except(:includes, :limit, :offset).count\n end", "def number_of_pages\n (total / page_size.to_f).ceil\n end", "def item_count\n @collection.size\n end", "def page_length\n return 0 if self.elements[:results].nil?\n self.elements[:results].length\n end", "def items\n if ( @paginator.items_per_page.kind_of?(Array) )\n @number <= @paginator.items_per_page.size ? @paginator.items_per_page[@number-1] : @paginator.items_per_page.last\n else\n @paginator.items_per_page\n end\n end", "def item_count\n @collection.length\n end", "def num_pages\n if order_bw_pages && order_color_pages\n return 2 + order_bw_pages + order_color_pages\n end\n end", "def page_count(arg)\n @pages = arg\n end", "def page_count\n file_groups\n @highest_page_count\n end", "def get_page_count\n first_page = Habr::open_page(Habr::Links.favorites(@userslug))\n count = 1\n\n last_page_link = first_page.xpath(\".//*[@id='nav-pages']/li/noindex/a\").first\n\n if last_page_link\n count = get_page_number_from_url(last_page_link[:href])\n else # no last page link found (that means fav pages count <= 6)\n page_urls = first_page.css(\"#nav-pages>li>a\").map { |link| link[:href] }\n page_numbers = page_urls.map { |url| get_page_number_from_url(url) }\n count = page_numbers.max unless page_numbers.empty?\n end\n\n count\n end", "def current_page_record_count\n return 0 if @current_page > @page_count\n \n a = 1 + (@current_page - 1) * @page_size\n b = a + @page_size - 1\n b = @pagination_record_count if b > @pagination_record_count\n b - a + 1\n end", "def item_count\n collection.length\n end", "def page_count(doc)\n doc.at_css('.pagination') && doc.at_css('.pagination')\n .css('b')\n .map(&:text)\n .map(&:to_i)\n .max\n end", "def show_total_pages\n pages = show_total_hits / show_results_per_page\n return pages + 1\n end", "def total_pages\n ( total_results.to_f / limit ).ceil\n end", "def total_pages\n (posts.count + PER_PAGE - 1) / PER_PAGE # Taking advantage from integer division\n end", "def total_pages\n @total_pages\n end", "def actual_page_count\n warn \"WARNING: actual_page_count is not yet implemented properly.\"\n warn \" Please send patches.\"\n @pages.count\n end", "def total_pages; end", "def nbpages\n attachments.order(position: 'asc').first.nbpages\n rescue StandardError => exc\n logger.error(\"Message for the log file #{exc.message}\")\n 0\n end", "def next_page_number\n self.pages.count + 1\n end", "def total_pages(games_count)\n (games_count % GAMES_PER_PAGE == 0 ? games_count / GAMES_PER_PAGE : games_count / GAMES_PER_PAGE + 1).to_i\n end", "def item_count\n @collection.count\n end", "def count\n if paginated?\n to_hash['results'].nil? ? 0 : to_hash['results'].size\n else\n to_hash['count']\n end\n end", "def count\n load_page(1) if @num_records.nil? # load pagination metadata\n @num_records\n end", "def total_pages\n current_page+4\n # hack to remove this count dependency\n #(total_count.to_f / limit_value).ceil\n end", "def get_total_pages\n list = @parsed_response[\"#{@collection}List\"]\n @total_pages = (list['total_results'].to_f/list['page_size'].to_f).ceil\n end", "def last_page_number\n number_of_pages\n end", "def total_entries\n pagination_adapter.total_entries\n end", "def number_pages\n pagenum = 1\n @sequence.each do |entry|\n entry.pagenum = pagenum\n next if (is_page? entry and entry.valid_repeat)\n pagenum += 1 if is_page?(entry)\n end\n end", "def item_count\n @items.length \n end", "def page_count\n bib_page_count\n end", "def num_pages\n 26\n end", "def total_pages\n (count / per_page.to_f).ceil\n end", "def total_pages\n @total_pages ||= (@data.rows.length / per_page.to_f).ceil\n end", "def total_pages\n sql = <<-EOS.squish\n SELECT\n COUNT(RES.*)\n FROM\n (\n SELECT\n shop_category_rels.item_id AS item_id,\n shop_category_rels.item_type AS item_type\n FROM\n \"shop_category_rels\"\n WHERE\n (\n \"shop_category_rels\".\"item_amount\" != 0\n )\n AND \"shop_category_rels\".\"item_state\" = 'published'\n GROUP BY\n item_id,\n item_type\n ) AS RES\n ;\n EOS\n\n records = @conn.execute(sql).getvalue(0,0)\n (records.to_f / @limit.to_f).ceil\n end", "def count_page\n num_pages = current_cookbook.num_pages\n render json: {num_pages: num_pages}\n end", "def pages_left\n self.page_count - self.current_page\n end" ]
[ "0.90772384", "0.8794858", "0.86657184", "0.84735316", "0.84356713", "0.8316049", "0.82967085", "0.7996766", "0.7991153", "0.79892004", "0.78802973", "0.78521496", "0.7756084", "0.77449316", "0.77258366", "0.76960295", "0.7683067", "0.7683067", "0.7683067", "0.7683067", "0.767151", "0.76691747", "0.75837487", "0.75760585", "0.7567262", "0.75616366", "0.75598127", "0.75202566", "0.7510337", "0.75063765", "0.7471527", "0.7464462", "0.74511385", "0.7392492", "0.73875296", "0.73735845", "0.7366857", "0.7346363", "0.73395544", "0.7314019", "0.73127925", "0.73046184", "0.730067", "0.7254807", "0.72072536", "0.72072536", "0.71738535", "0.7160417", "0.71445704", "0.7076193", "0.7071258", "0.70636505", "0.7049874", "0.70440066", "0.7010866", "0.6996416", "0.6969414", "0.69441414", "0.69285375", "0.69265187", "0.692574", "0.69195575", "0.69132406", "0.6899519", "0.68732756", "0.68456227", "0.6842612", "0.6837197", "0.6820297", "0.68037546", "0.67937136", "0.67880946", "0.6785824", "0.6779576", "0.67792046", "0.67720944", "0.676358", "0.6753045", "0.6751063", "0.67477083", "0.67473716", "0.6742518", "0.67333204", "0.6731358", "0.67300427", "0.6729647", "0.67149675", "0.6712397", "0.6686259", "0.6681456", "0.6648191", "0.6647206", "0.6630359", "0.6628819", "0.6622877", "0.6620957", "0.661935", "0.66185963", "0.6613156", "0.6611203" ]
0.88058585
1
determines what page an item is on. Zero based indexes. this method should return 1 for item_index values that are out of range
def page_index(item_index) return -1 if !(item_index < item_count) || item_index < 0 @collection[item_index] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def page_index(item_index)\n return -1 if item_index < 0 || item_index >= self.item_count\n location = item_index.divmod @items_per_page\n location[0]\n end", "def page_index(item_index)\n if (item_index >= item_count || item_index < 0)\n -1\n elsif item_count == item_index - 1\n page_count - 1\n else\n (item_index / page_size)\n end\n end", "def page_index(item_index)\n return -1 if item_index < 0 || item_index > item_count-1 \n item_index/@per_page \n end", "def page_index(item_index)\n # input item index\n # guard clause to check item in is the range\n return -1 unless (0...item_count).include?(item_index)\n\n # return the page index if item in the range else return -1\n item_index / @items_per_page\n end", "def page_index(item_index)\n return -1 if item_index < 0\n return -1 if item_index >= item_count\n item_index / @items_per_page\n end", "def page_item_count(page_index)\n if (page_index + 1 < page_count)\n page_size\n elsif page_index + 1 > page_count\n -1\n else\n item_count % page_size\n end\n end", "def page_item_count(page_index)\n return -1 if page_index < 0 || page_index > page_count-1 \n return @per_page if page_index < page_count-1 \n return item_count - ((page_count-1) * @per_page) \n end", "def page_item_count(page_index)\n return -1 if page_index < 0\n return -1 if page_index >= page_count\n if page_index < (page_count-1)\n @items_per_page\n else\n this_page = item_count % @items_per_page\n this_page == 0 ? @items_per_page : this_page\n end\n end", "def item_page\n @item_page ||= ApiBucket::Base::Element.get(@doc, \"//ItemPage\").to_i\n end", "def page_item_count(page_index)\n return -1 if page_index > @collection[-1] || page_index < 0\n @collection.count {|v| v == page_index}\n end", "def start_index(page)\n (page - 1) * @count + 1\n end", "def page_item_count(page_index)\n # input page index\n # array of pages : transform page_count to array of page_count elements\n pages_array = Array.new(page_count) { |i| i }\n # return the number of item on page_index if page_index in the range else return -1\n return -1 unless (0...page_count).include?(page_index)\n\n if pages_array[page_index] != pages_array[-1]\n @items_per_page\n else\n item_count % @items_per_page\n end\n end", "def page_item_count(page_index)\n return -1 if page_index < 0 || page_index >= self.page_count\n @pages[page_index].count\n end", "def current_start_index\n @current_page * @entries_per_page \n end", "def index_of( item )\n max = self.get_length\n counter = 1\n while( counter <= max )\n if( get(counter) == item)\n return counter\n end\n counter = counter + 1\n end\n return nil\n end", "def start_index\n return 0 if self.total_results == 0\n si = ((self.current_page - 1) * self.results_per_page)\n return (si >= 0 ? si + 1 : 0)\n end", "def page\r\n @page || 1\r\n end", "def last_item\n if @paginator.items_per_page.kind_of?(Array) \n [offset + (@number <= @paginator.items_per_page.size ? @paginator.items_per_page[@number-1] : @paginator.items_per_page.last),@paginator.item_count].min\n else\n [@paginator.items_per_page * @number, @paginator.item_count].min\n end\n end", "def page_count\n if item_count % @items_per_page == 0\n item_count / @items_per_page\n else\n 1 + (item_count / @items_per_page)\n end\n end", "def page_number\n\t\t\t\treturn 0 if @total_results == 0\n\t\t\t\t@offset + 1\n\t\t\tend", "def create_apparent_index(apparent_page)\n page = apparent_page - 1\n if page == 0\n from = 1\n to = apparent_page == self.max_page ? self.selected_restaurant_ids.length : 9\n else\n from = page * 9 + 1\n to = apparent_page == self.max_page ? self.selected_restaurant_ids.length : apparent_page * 9\n end\n\n return from, to\n end", "def items\n if ( @paginator.items_per_page.kind_of?(Array) )\n @number <= @paginator.items_per_page.size ? @paginator.items_per_page[@number-1] : @paginator.items_per_page.last\n else\n @paginator.items_per_page\n end\n end", "def item index\n @items[index-1]\n end", "def __page\n @_page || 1\n end", "def page\n if !@page || @page < 1\n 1\n elsif @page > total_pages\n total_pages\n else\n @page\n end\n end", "def page\n [[params[:page].to_i, 1].max, total_pages].min\n end", "def get_index(i)\n i/BITS_PER_ITEM\n end", "def get_position (item)\r\n position = 0\r\n self.items.each_with_index {|val, index|\r\n if (val.get_name == item.get_name)\r\n position = index\r\n end\r\n }\r\n return position\r\n end", "def total_pages\n (items.size - 1) / max_items + 1\n end", "def create_mongo_index(apparent_page)\n page = apparent_page - 1\n if page == 0\n from = 0\n to = apparent_page == self.max_page ? self.selected_restaurant_ids.length-1 : 8\n else\n from = page * 9\n to = apparent_page == self.max_page ? self.selected_restaurant_ids.length-1 : apparent_page * 9 -1\n end\n\n return from, to\n end", "def page_count\n # Integer arithmetic is simpler and faster.\n @page_count ||= item_count > 0 ? (item_count - 1) / items_per_page + 1 : 1\n end", "def last_page_index\n num_pages() - 1\n end", "def selected_page; @pages[index]; end", "def page\n _page = params[:page].to_i\n return (_page == 0) ? 1 : _page\n end", "def page\n Integer(parsed_body['Meta']['Parameters']['page'] || 1)\n end", "def is_first_page?\n p_index.to_i == 1\n end", "def return_index_or_default(items, index, default_value)\n\t\tif index < 0 && items.length < index.abs\n\t\t\treturn default_value\n\t\telsif index >= 0 && items.length-1 < index\n\t\t\treturn default_value\n\t\telse\n\t\t\treturn items[index] \n\t\tend\n\tend", "def page_number\n raise NotImplemented\n end", "def first_in_page\n ((current_page - 1) * per_page) + 1\n end", "def current_page\n [(params[:page] || @default_page || 1).to_i, 1].max # ensure positive integer\n end", "def leading\n (@total_pages > 0) ? 1 : nil\n end", "def first_page_number\n 1\n end", "def PageNo()\n\t\t#Get current page number\n\t\treturn @page;\n\tend", "def item_endpoint?(page)\n page == :item\n end", "def current_page\n @options[:page].blank? ? 1 : @options[:page].to_i\n end", "def current_page\n return 0 if current_limit.blank? || current_limit.zero?\n (current_offset / current_limit) + 1\n end", "def total_pages\n -1\n end", "def index_from_start(index); end", "def get_current_position_in_page_list(pagelist)\n\n pagelist.each_with_index do |page_path, index|\n if page_path == \"/\" + current_page.path\n return index\n end\n end\n\n # If we reach this line, the current page path wasn't in our page list and we'll return false so the link generation is skipped.\n return FALSE\n end", "def next\n return @page + 1\n end", "def parse_page_param\n if params[:page].present?\n begin\n page_number = params[:page].to_i\n raise StandardError if page_number <= 0\n return page_number - 1\n rescue Exception\n render 'api/v1/shared/failure', locals: {errors: [{page: 'parameter is wrong'}]}, status: :unprocessable_entity\n return\n end\n else\n return 0\n end\n end", "def current_page\n per_page.zero? ? 0 : (@solr_data[:start].to_i / per_page) + 1\n end", "def current_page_number\n @pageset.size\n end", "def page\r\n\t\t\t\tparams[:page].to_i || 1\r\n\t\t\tend", "def start_result_number\n ((page - 1) * per_page) + 1\n end", "def visible_line_number\r\n item_max\r\n end", "def get_item(index)\n # TODO\n end", "def current_idx\n return @idx >= 0 ? @idx : nil\n end", "def current_page\n [results.current_page, results.total_pages].min\n end", "def page_count\n 1\n end", "def item_number(item)\n return nil if item.nil?\n container = item_container(item.class)\n container ? container[item.id] || 0 : 0\n end", "def page_count\n (item_count / @items_per_page.to_f).ceil\n end", "def get_index(i)\n\t\tif (!@head || @size < i+1)then return false end\n\t\tcurrent = this.head\n\t\tcount = 0\n\t\twhile (count < i) #go to the index\n\t\t\tcurrent = current.get_next()\n\t\t\tcount+=1\n\t\tend\n\t\treturn current.get_item()\n\tend", "def next_page\n current_page + 1 unless last_page? || out_of_range?\n end", "def page\n Integer(params[:page] || 1)\n end", "def current_page\n first(@raw_page['records'].size)\n end", "def current_page\n return 1 if start < 1\n per_page_normalized = per_page < 1 ? 1 : per_page\n @current_page ||= (start / per_page_normalized).ceil + 1\n end", "def next_page_number\n [page_number + 1, last_page_number].min\n end", "def pagination_from(collection)\n collection.offset_value + 1\n end", "def current_page\n self.page ||= 0\n self.page + 1\n end", "def icon_index(item)\n return $data_items[item.item_id].icon_index if item.item?\n return ($data_items.find { |i| !i.nil? && i.subtype_id == item.category_id}).icon_index if item.category?\n end", "def page\n @request.params[:page] ? @request.params[:page].to_i : 1\n end", "def visible_line_number\n item_max\n end", "def visible_line_number\n item_max\n end", "def visible_line_number\n item_max\n end", "def visible_line_number\n item_max\n end", "def first_page\n return nil if total_pages < 1\n return 1\n end", "def presentation_page n\n pages[n-1][:resource]\n end", "def calculate_next\n n = @current_page + 1\n n > @total_pages || n <= 0 ? nil : n\n end", "def page num\n raise ArgumentError.new 'Survey pages are one-indexed' if num < 1\n pages[num - 1]\n end", "def index_for_item(item)\n for x in INVENTORY\n if x.has_value?(item)\n return index = INVENTORY.index(x)\n end\n end\n return index\nend", "def serial_number(index)\n if not params[:page].blank?\n if params[:page].to_i >= 1\n (index + 1) + (params[:page].to_i - 1) * Account.per_page\n end\n else\n index + 1\n end\n end", "def next_item(item, options = {})\n options ||= {}\n items = filter_items(Items.new, opt: options)\n\n idx = items.index(item)\n\n idx.positive? ? items[idx - 1] : nil\n end", "def next_page\n return if page >= total_pages\n page + 1\n end", "def getCurrentPage(doc)\n currentPage = 1\n\n doc.search(\"Document > View > ScrollView > VBoxView > View > MatrixView > VBoxView:nth(0) > HBoxView > TextView > SetFontStyle > b\").each do |e|\n # Parse the first number in the string, e.g. the 3 in \"Page 3 of 99\"\n currentPage = e.inner_html[/[0-9]+/].to_i\n end\n\n return currentPage\nend", "def pbItemMenu(index)\n pbDisplayMessage(\"Items can't be used here.\")\n return -1\n end", "def index(list, item, &block)\r\n\t\ti = bisect_left(list, item, &block)\r\n\t\treturn list[i] == item ? i : nil\r\n\tend", "def out_of_range?\n current_page > total_pages\n end", "def page_count\n @collection.max + 1\n end", "def offset\n if page <= 1\n # We want first page of results\n 0\n else\n # Max offset for search API is 999\n # If there are 20 results and the user requests page 3, there will be an empty result set\n [((page - 1) * limit), 999].min\n end\n end", "def page_number\n (params[:page] || 1).to_i\n end", "def paginate_items(items)\n paginated_items = items.paginate(paginate_options)\n next_page_exists = paginated_items.length > @limit || paginated_items.next_page\n add_link_header(offset: (offset + 1)) if next_page_exists\n paginated_items[0..(@limit - 1)] # get paginated_collection of length 'limit'\n end", "def page\n params[:iDisplayStart].to_i/per_page + 1\n end", "def show_current_page\n if params[:eds_action].present?\n if params[:eds_action].scan(/GoToPage/).length > 0\n pagenum = params[:eds_action].to_s\n newpagenum = pagenum.gsub(\"GoToPage(\", \"\")\n newpagenum = newpagenum.gsub(\")\", \"\")\n return newpagenum.to_i\n elsif params[:eds_action].scan(/SetResultsPerPage/).length > 0\n if params[:pagenumber].present?\n return params[:pagenumber].to_i\n else\n return 1\n end\n else\n return 1\n end\n end\n if params[:pagenumber].present?\n return params[:pagenumber].to_i\n end\n return 1\n end", "def next_page\n return nil if total_pages == -1\n return nil if page == total_pages\n return page + 1\n end", "def pagy_get_items(collection, pagy)\n # handle arrays\n return collection[pagy.offset, pagy.items] if collection.is_a? Array\n # this should work with ActiveRecord, Sequel, Mongoid...\n collection.offset(pagy.offset).limit(pagy.items)\nend", "def begin; pager.offset page; end", "def get_page_number\n # this is the normal case; masterfile and unit share same metadata record\n # so page number will match the numbering sequence of the filename\n page = filename.split(\"_\")[1].split(\".\")[0].to_i\n # if metadata_id == unit.metadata_id\n if is_clone?\n mf_id = original_mf_id\n page = MasterFile.find(mf_id).filename.split(\"_\")[1].split(\".\")[0].to_i\n end\n # else\n # # this master file has been assigned to a separate metadata record. the\n # # page number in the filename does not reflect the actual page num. Count\n # # masterfiles owned by metadata record to determine\n # page = 1\n # metadata.master_files.each do |mf|\n # if mf.id == id\n # break\n # else\n # page += 1\n # end\n # end\n # end\n return page\n end", "def end_index\n ei = self.current_page * self.results_per_page\n return (ei < self.total_results ? ei : self.total_results)\n end", "def page\n params[:iDisplayStart].to_i / per_page + 1\n end" ]
[ "0.8317278", "0.82632387", "0.80230683", "0.8019768", "0.7967099", "0.72548354", "0.69349074", "0.6880199", "0.68635756", "0.68510646", "0.6838713", "0.67769283", "0.6733125", "0.6696102", "0.65258515", "0.6493964", "0.6490064", "0.64006805", "0.6397563", "0.6358977", "0.6250773", "0.6218902", "0.61952907", "0.6175079", "0.61421245", "0.6123443", "0.6120355", "0.6118894", "0.6113016", "0.6082117", "0.60579044", "0.60308695", "0.60269135", "0.6013349", "0.60079616", "0.59985733", "0.59866726", "0.59719974", "0.593497", "0.5934821", "0.59316355", "0.5905257", "0.5904494", "0.58982074", "0.5876564", "0.5842969", "0.5840703", "0.5837425", "0.5826285", "0.5814553", "0.5793669", "0.57838815", "0.57754534", "0.57623005", "0.5757249", "0.5748468", "0.5745379", "0.5745112", "0.5736221", "0.5734287", "0.5717025", "0.571669", "0.5716246", "0.57089627", "0.5701431", "0.5688737", "0.56782824", "0.56768703", "0.5676762", "0.56705654", "0.5667272", "0.56633145", "0.56632644", "0.56632644", "0.56632644", "0.56632644", "0.5649709", "0.5640698", "0.5635709", "0.5634768", "0.5631944", "0.56201345", "0.5616947", "0.5614857", "0.56127423", "0.5611421", "0.5609766", "0.56001174", "0.55968064", "0.55967706", "0.55938053", "0.5589509", "0.5570315", "0.5565631", "0.5565037", "0.5562395", "0.5556058", "0.5543204", "0.55426335", "0.5539218" ]
0.82983905
1
Implements the ids reader method, e.g. foo.item_ids for Foo.indirectly_contains :items, ...
def ids_reader predicate = reflection.options.fetch(:has_member_relation) if loaded? target.map(&:id) else owner.resource.query({ predicate: predicate }) .map { |s| ActiveFedora::Base.uri_to_id(s.object) } | target.map(&:id) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ids_getter(name, metadata)\n ids_method = \"#{name.to_s.singularize}_ids\"\n re_define_method(ids_method) do\n send(name).only(:id).map(&:id)\n end\n self\n end", "def ids\n (1..get_item_count).map do |index|\n get_item_identifier index\n end\n end", "def extract_ids\n # no-op\n end", "def ids\n @ids ||= []\n end", "def ids_reader\n if loaded?\n target.pluck(reflection.association_primary_key)\n elsif !target.empty?\n load_target.pluck(reflection.association_primary_key)\n else\n @association_ids ||= scope.pluck(reflection.association_primary_key)\n end\n end", "def for_ids(*ids)\n field = klass.fields[\"_id\"]\n ids.flatten!\n if ids.size > 1\n any_in(:_id => ids.map{ |id| field.serialize(id) })\n else\n where(:_id => field.serialize(ids.first))\n end\n end", "def eager_loaded_ids(docs, metadata)\n if metadata.stores_foreign_key?\n docs.flat_map{ |doc| doc.send(metadata.foreign_key) }\n else\n docs.map(&:id)\n end\n end", "def ids\n root.ids\n end", "def related_concept_ids(db, *ids)\n ids\n end", "def ids\n self.is_leaf? ? [@ids].flatten : self.children.inject([]) {|result, item| result += item.ids}\n end", "def ids\n pluck(:id)\n end", "def ids(*values)\n values.inject(self) { |res, val| res._ids(val) }\n end", "def ids(*values)\n values.inject(self) { |res, val| res._ids(val) }\n end", "def ids(*values)\n values.inject(self) { |res, val| res._ids(val) }\n end", "def map_raw_ids( ids )\n ids ||= []\n ids = ids.values if ( ids.class == Hash or ids.class == HashWithIndifferentAccess )\n ids.map { | str | str.to_i }\n end", "def find_ids(uris)\n uris.map { |uri| find_id(uri) }\n end", "def ids\n @ids ||= term.list_ids.sort\n end", "def identifiers\n request[:ids]\n end", "def record_ids(opts = {})\n opts = opts.merge(@opts)\n client.list_identifiers(opts).full.lazy.flat_map(&:identifier)\n end", "def all_ids(_context)\n raise NotImplementedError\n end", "def ids(things)\n things.map(&:id).join(\",\")\n end", "def ids; @docs.keys end", "def find_ids(ids)\n ids.inject([]) { |x, id| x << all.find { |y| y.id == id }}\n end", "def fetch_ids(model, ids)\n mapping = {}\n\n # find the matching records\n matches = model.any_in(:_id => ids.to_a)\n\n # add in conditions that are defined in the block\n matches = yield(matches) if block_given?\n\n # reorder\n matches.each{|record| mapping[record.id.to_s] = record }\n\n # restore the order of the tiles\n ids.map{|id| mapping[id.to_s]}.compact\n end", "def identifier_list(*ids, separator: /\\s*,\\s*/, **)\n ids = ids.flat_map { |v| v.is_a?(String) ? v.strip.split(separator) : v }\n ids.map! { |v| v.is_a?(ApplicationRecord) ? v.id : v }\n ids.map! { |v| positive(v) || v }.compact_blank!\n end", "def for_ids(ids)\n ids = mongoize_ids(ids)\n if ids.size > 1\n send(id_finder, { _id: { \"$in\" => ids }})\n else\n send(id_finder, { _id: ids.first })\n end\n end", "def all_item_ids\n [id] + item_ids\n end", "def related_concept_ids(db, *ids)\n ids = ids.flatten\n other_ids = db[:mappings].where(concept_2_id: ids).where{Sequel.function(:lower, :relationship_id) =~ 'is_a'}.select_map(:concept_1_id)\n other_ids + ids\n end", "def load_by_ids(ids, context)\n ids.map { |id| load_by_id(id, context) }\n end", "def identifier_list(*ids, **opt)\n cid = current_id.presence\n ids = params.values_at(*id_param_keys) if ids.blank?\n super(ids, **opt).tap do |result|\n result.map! { |v| CURRENT_ID.casecmp?(v) ? cid : v } if cid\n end\n end", "def ids\n @keys ||= []\n end", "def disgemd_ids_for(klass)\n ids = Recommendable.redis.smembers(Recommendable::Helpers::RedisKeyMapper.disgemd_set_for(klass, id))\n ids.map!(&:to_i) if [:active_record, :data_mapper, :sequel].include?(Recommendable.config.orm)\n ids\n end", "def ids\n @store.transaction do\n @store.roots\n end\n end", "def mongoize_ids(ids)\n ids.map do |id|\n id = id[:_id] if id.respond_to?(:keys) && id[:_id]\n klass.fields[\"_id\"].mongoize(id)\n end\n end", "def find_many(ids, options = {})\n ids = ids.map do |id|\n id.to_s.include?('#') ? id : \"#{node_type}##{id}\"\n end\n\n super ids, options\n end", "def datastore_ids\n array = Array.new\n\n self.each(\"DATASTORES/ID\") do |id|\n array << id.text.to_i\n end\n\n return array\n end", "def get_ids\r\n case id\r\n when 1 then [1,2,3,4,5] # superadmin\r\n when 2 then [2] # data\r\n when 3 then [3,4,5] # centeradmin\r\n when 4 then [4,5] # teamadmin\r\n when 5 then [5] # behandler\r\n when 10 then [10,11,12,13,14,15] # login_bruger\r\n when 11 then [11] # parent\r\n when 12 then [12] # teacher\r\n when 13 then [13] # pedagogue\r\n when 14 then [14] # youth\r\n else []\r\n end\r\n end", "def ids\n @nodes.map(&:id)\n end", "def associated_records(ids)\n max_ids_in_a_list = connection.ids_in_list_limit || ids.size\n records = []\n ids.each_slice(max_ids_in_a_list) do |some_ids|\n records += yield(some_ids)\n end\n records\n end", "def load_by_ids ids\n items = @api.fetch_multiple_items ids\n create_by_api_items(items)\n end", "def ids\n options[:id][1..-2].split(\",\").map(&:to_i)\n end", "def ids\n primary_key_array = Array(primary_key)\n\n if loaded?\n result = records.map do |record|\n if primary_key_array.one?\n record._read_attribute(primary_key_array.first)\n else\n primary_key_array.map { |column| record._read_attribute(column) }\n end\n end\n return @async ? Promise::Complete.new(result) : result\n end\n\n if has_include?(primary_key)\n relation = apply_join_dependency.group(*primary_key_array)\n return relation.ids\n end\n\n columns = arel_columns(primary_key_array)\n relation = spawn\n relation.select_values = columns\n\n result = if relation.where_clause.contradiction?\n ActiveRecord::Result.empty\n else\n skip_query_cache_if_necessary do\n klass.connection.select_all(relation, \"#{klass.name} Ids\", async: @async)\n end\n end\n\n result.then { |result| type_cast_pluck_values(result, columns) }\n end", "def gemd_ids_for(klass)\n ids = Recommendable.redis.smembers(Recommendable::Helpers::RedisKeyMapper.gemd_set_for(klass, id))\n ids.map!(&:to_i) if [:active_record, :data_mapper, :sequel].include?(Recommendable.config.orm)\n ids\n end", "def get_ids(table)\r\n valid_ids = []\r\n table_info = @db.execute(\"SELECT * FROM #{table}\")\r\n table_info.each do |line|\r\n line_info = []\r\n line.each do |name, value|\r\n if name == 'id'\r\n valid_ids << value\r\n end\r\n end\r\n end\r\n valid_ids\r\n end", "def include_ids?(item_ids)\n all_item_ids == item_ids\n end", "def element_ids\n chain_route :element_type => :object, :pipe_class => Pacer::Pipes::IdPipe\n end", "def element_ids\n chain_route :element_type => :object, :pipe_class => Pacer::Pipes::IdPipe\n end", "def get_ids_for_query\n if param.field.options[:definition]\n definition = param.field.options[:definition]\n else\n # Set up a definition\n definition = Definition.new\n definition.base = param.field.options[:base].is_a?(Proc) ? param.field.options[:base].call : param.field.options[:base]\n\n # Get the fields which we should search for\n fields = @field.is_a?(Array) ? @field : [@field]\n fields.each do |field|\n definition.fields << DefinitionField.new(field, :condition => Local, :value_transmogrification => param.field.options[:value_transmogrification])\n end\n end\n\n # Set up a query\n query = Query.new(definition)\n\n # Add all the fields\n query.group(:any) do |params|\n fields.each do |field|\n params << query.param(field, @operator, @value)\n end\n end\n\n ids = query.results.pluck(param.field.options[:foreign_key])\n\n if @operator == :blank\n all_ids = param.query.definition.base.pluck(:id)\n present_ids = definition.base.pluck(param.field.options[:foreign_key])\n ids = (all_ids - present_ids) + ids\n end\n\n ids\n\n end", "def items_from_ids(ids_array)\n id_strs = ids_array.collect do |id|\n id = if id.is_a? Google::Reader::ItemRef\n id.id\n elsif id.is_a?(Fixnum) || id.is_a?(Bignum)\n id\n else\n raise \"invalid item id type: #{id} (class: #{id.class})\"\n end\n \"i=#{id}\"\n end\n\n resp = @client.access_token.post(\"/reader/api/0/stream/items/contents\", id_strs.join(\"&\"))\n raise \"unable to retrieve the item contents for user \\\"#{user_id}\\\": #{resp.inspect}\" unless resp.code_type == Net::HTTPOK\n Google::Reader::ItemList.new(@client, resp.body)\n end", "def id_list(item, **opt)\n id_split(item).map! { |v| id_obj(v, **opt) }.compact\n end", "def article_ids\n query('SELECT Id FROM KnowledgeArticle').map(&:Id)\n end", "def identifiers\n return [] if __getobj__.blank?\n\n __getobj__.identifier if __getobj__.respond_to?(:identifier)\n end", "def richtext_contents_ids\n descendent_contents\n .where(Element.table_name => {folded: false})\n .essence_richtexts\n .pluck(\"#{Content.table_name}.id\")\n end", "def ids_writer(ids)\n primary_key = reflection.association_primary_key\n pk_type = klass.type_for_attribute(primary_key)\n ids = Array(ids).compact_blank\n ids.map! { |id| pk_type.cast(id) }\n\n records = if klass.composite_primary_key?\n query_records = ids.map { |values_set| klass.where(primary_key.zip(values_set).to_h) }.inject(&:or)\n\n query_records.index_by do |record|\n primary_key.map { |primary_key| record._read_attribute(primary_key) }\n end\n else\n klass.where(primary_key => ids).index_by do |record|\n record._read_attribute(primary_key)\n end\n end.values_at(*ids).compact\n\n if records.size != ids.size\n found_ids = records.map { |record| record._read_attribute(primary_key) }\n not_found_ids = ids - found_ids\n klass.all.raise_record_not_found_exception!(ids, records.size, ids.size, primary_key, not_found_ids)\n else\n replace(records)\n end\n end", "def ids_in\n \"p.id IN :ids\" if options[:id].present?\n end", "def get_ids(array)\n ids = \"(\"\n array.each do |me|\n ids << me.id.to_s + \",\"\n end\n ids = ids.chomp(\",\")\n ids = ids + \")\"\n return ids\n\n end", "def fill_ids(_in_stream)\n end", "def invoice_items_by_id_collection(collection)\n FinderClass.match_by_data(@invoice_items.all, collection, :id)\n end", "def _referenced_object_ids\n @data.each.select do |v|\n v&.respond_to?(:is_poxreference?)\n end.map(&:id)\n end", "def _getIDVals(ids = nil)\n if ids.nil?\n doc = ownerDocument\n return [] if doc.nil?\n ids = doc._getIDAttrs\n end\n\n idelem = []\n if !ids[nodeName].nil?\n return attributes._getValues(ids[nodeName])\n elsif !ids['*'].nil?\n return attributes._getValues(ids['*'])\n end\n return []\n end", "def existing_ids\n @existing_ids ||= Set.new(mapper.select(nil, :id).map{ |row| row[:id] })\n end", "def ids_setter(name, metadata)\n ids_method = \"#{name.to_s.singularize}_ids=\"\n re_define_method(ids_method) do |ids|\n send(metadata.setter, metadata.klass.find(ids.reject(&:blank?)))\n end\n self\n end", "def identifier_uris\n return @identifier_uris\n end", "def filtered_item_ids(filter, params = {})\n resp = @client.access_token.get(ItemList.merge_query_string(\"/reader/api/0/stream/items/ids?output=json&s=user/#{user_id}/state/com.google/#{filter}&n=20\", params))\n raise \"unable to retrieve the list of #{filter} item ids for user \\\"#{user_id}\\\": #{resp.inspect}\" unless resp.code_type == Net::HTTPOK\n JSON.parse(resp.body)['itemRefs'].collect do |hash|\n Google::Reader::ItemRef.new(hash)\n end\n end", "def find_by_ids(ids)\n rows = data_store.get(ids)\n results = []\n rows = [] << rows unless rows.instance_of?(Array)\n\n rows.each do |row|\n results << _deserialize(row[:key], row[:data])\n end\n\n results\n end", "def get_self_and_children_ids\n ids = [self.id]\n ids += get_children_ids_recursive\n return ids\n\t\tend", "def list_ids\n @documents.keys\n end", "def liked_ids_for(klass)\n ids = Recommendable.redis.smembers(Recommendable::Helpers::RedisKeyMapper.liked_set_for(klass, id))\n ids.map!(&:to_i) if [:active_record, :data_mapper, :sequel].include?(Recommendable.config.orm)\n ids\n end", "def reader_ids\n group_user_ids(readers_join_table)\n end", "def ids_permitting( priv, keyword_args = {} )\n priv, association = disassemble_priv( priv )\n if association.nil?\n return self.ids_permitting_internal( priv, keyword_args.merge( :distinct => true ))\n else\n klass = self.class_for_associate(association)\n fk = self.reflect_on_association(association).foreign_key.to_s\n return <<-END_SQL\n (select id from #{table_name} where #{table_name}.#{fk} in\n #{klass.ids_permitting_internal( priv, keyword_args )})\n END_SQL\n end\n end", "def lookup( *ids )\n cache = attribute_cache( :id )\n matching = ids.map do |id|\n entity = cache.fetch( id ) do\n entities.find { |e| e.id == id }\n end\n\n entity || missing_entity_class.new\n end\n\n List.new matching\n end", "def schema_article_ids\n ids = []\n if self.schema.respond_to?(:each_key)\n self.schema.each_key do |item|\n ids += self.schema[item]['ids']\n end\n end\n ids\n end", "def ids(id)\n # Android auto resolves strings.xml ids\n find_elements :id, id\n end", "def path_ids\n ancestor_ids + [id]\n end", "def path_ids\n ancestor_ids + [id]\n end", "def child_ids\n ids = [self.id]\n self.children.each do |child|\n ids += child.child_ids\n end\n ids\n end", "def get_relation_ids(project_id = nil, base_ids = nil)\n\t\treturn [] if base_ids == []\n\t\tsubcatrels.in_project(project_id).among_denotations(base_ids).pluck(:id)\n\tend", "def extract_by_ids(ids, columns, context)\n records = load_by_ids(ids, context).index_by(&:id)\n ids.map do |id|\n rec = records[id]\n next nil unless rec\n columns.map { |col| [col, rec.send(col)] }.to_h\n end\n end", "def list_ids params={}\n @nimble.get \"contacts/ids\", params\n end", "def get_user_ids(fname=\"../id_list\")\n file = File.open(fname, \"r\")\n ids = []\n file.each do |line|\n ids += [Integer(line.split(\":\")[1].strip())]\n end\n file.close() \n return ids\nend", "def descendant_ids\n descendants.map(&:id)\n end", "def account_ids()\n return [1, 2]\n end", "def invoice_items\n invoice_items = engine.invoice_item_repository.parse\n invoice_items.select {|invoice_item| invoice_item.item_id == id}\n end", "def do_id_query(ids)\n responses = []\n ids.each do |k, v|\n new_key_value = map_key(k, v)\n next if new_key_value.blank? #we probably have bad ISBN, could be bad key though\n responses << get_thing(new_key_value)\n end\n selected = responses.map { |r| r['result'] }.flatten.compact.uniq\n return selected\n end", "def liked_ids_for(klass)\n ids = Recommendations.redis.smembers(Recommendations::Helpers::RedisKeyMapper.liked_set_for(klass, id))\n ids.map!(&:to_i)\n ids\n end", "def get_denotation_ids(project_id = nil, span = nil)\n\t\tdenotations.in_project(project_id).in_span(span).pluck(:id)\n\tend", "def identifiers; end", "def path_ids\n @objects.map{|e| e.path_id}\n end", "def find_from_ids(conn_id, ids, options)\n subfolders = nil\n \n folder_list = ids.collect { |path|\n path = resolve_folderpath_option(conn_id, path)\n options[:command] = generate_list_command(conn_id, path, subfolders)\n \n list_folders(conn_id, options)\n }.flatten.compact\n \n MailboxListParser.read(folder_list, conn_id, self)\n end", "def input_item_id_array(input_names:, op:)\n input_names.map { |n| op.input(n).child_item_id }\n end", "def async_ids\n async.ids\n end", "def record_ids\n @records.keys\n end", "def person_ids\n persons = Person.find_all_from_identifier(source: 'xkonto', identifier: username)\n return nil if persons.blank?\n return persons.map(&:id)\n end", "def image_ids; (images.map(&:id) rescue []); end", "def image_ids; (images.map(&:id) rescue []); end", "def asset_ids(id)\n monograph = Hyrax::PresenterFactory.build_for(ids: [id], presenter_class: Hyrax::MonographPresenter, presenter_args: nil).first\n return if monograph.blank?\n\n docs = monograph.ordered_member_docs\n return if docs.blank?\n\n ids = []\n docs.each do |doc|\n fp = Hyrax::FileSetPresenter.new(doc, nil)\n next if fp.featured_representative?\n next if fp.id == monograph.representative_id\n next if Sighrax.tombstone?(Sighrax.from_presenter(fp))\n ids << fp.id\n end\n\n ids.join(\",\")\n end", "def ingested_ids\n ingested_ids_by_type.flatten\n end", "def ingested_ids\n ingested_ids_by_type.flatten\n end", "def read ids, options = {}\n fields = if options[:fields].present?\n options[:fields] & attribute_names\n else\n attribute_names\n end\n \n context = options[:context]\n ids = ids.reverse if options[:reverse_flag]\n\n [].tap do |result|\n remote.read(ids, fields, context).each do |attributes|\n position = ids.index(attributes[:id].to_i)\n result[position] = instantiate(attributes, context).tap do |record|\n record.attribute_names = fields.map &:to_s\n end\n end\n end\n end", "def direct_children_by_id(*args)\n scope = args.last.is_a?(Hash) ? args.pop : {}\n ids = args.flatten.compact.uniq\n self.class.find_in_nested_set(:all, { \n :conditions => [\"#{scope_condition} AND #{prefixed_parent_col_name} = #{self.id} AND #{self.class.table_name}.#{self.class.primary_key} IN (?)\", ids]\n }, scope) \n end" ]
[ "0.7071506", "0.6968297", "0.6785989", "0.65630686", "0.6425952", "0.64023226", "0.6367779", "0.63203144", "0.6312439", "0.6233021", "0.6220249", "0.6191885", "0.6191885", "0.6191885", "0.6147744", "0.6124463", "0.61093843", "0.60776937", "0.60561687", "0.6050675", "0.6018001", "0.6011923", "0.5973202", "0.59621084", "0.5934156", "0.5932884", "0.59274685", "0.59056616", "0.5884853", "0.5882203", "0.5876652", "0.58751875", "0.5853494", "0.5853466", "0.5848014", "0.5840022", "0.58283746", "0.5817545", "0.5794778", "0.5769157", "0.5762447", "0.5759933", "0.57535255", "0.57529736", "0.5746058", "0.5739497", "0.5739497", "0.5729647", "0.571929", "0.5710017", "0.57072383", "0.57041365", "0.56966984", "0.56932604", "0.5658121", "0.56391424", "0.56354725", "0.56289726", "0.56203395", "0.5616634", "0.56131536", "0.5602682", "0.56003696", "0.559934", "0.55933267", "0.5583637", "0.55749315", "0.5571294", "0.55693084", "0.5560764", "0.5557025", "0.5554916", "0.5549524", "0.5546967", "0.5546967", "0.5527931", "0.5517201", "0.55084443", "0.5502645", "0.54997", "0.54987854", "0.5497504", "0.54967135", "0.5492512", "0.5487212", "0.54834044", "0.5449618", "0.5447435", "0.5442892", "0.54207563", "0.54150635", "0.54117876", "0.5409234", "0.54079485", "0.54079485", "0.5406709", "0.5402607", "0.5402607", "0.539464", "0.53912383" ]
0.70116866
1
use to_f if you convert unexact values
def converts(option) if option == "a" puts "Insert the value in mm :" millimeters = gets.chomp.to_i centimeters = Conversions.convert_millimeters_to_centimeters millimeters puts "#{millimeters} mm represent #{centimeters} cm" elsif option == "b" puts "Insert the value in cm :" centimeters = gets.chomp.to_i meters = Conversions.convert_centimeters_to_meters centimeters puts "#{centimeters} cm represent #{meters} mt" elsif option == "c" puts "Insert the value in mt :" meters = gets.chomp.to_i kilometers = Conversions.convert_meters_to_kilometers meters puts "#{meters} mt represent #{kilometers} km" else puts "Unsupported option" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_f() end", "def to_f() end", "def to_f() end", "def to_f() end", "def to_f; end", "def to_f\n end", "def to_f\n end", "def to_f\n end", "def to_f\n case @kind\n when :float_lit, :float_exp_lit,\n :integer_lit, :integer_exp_lit,\n :single_string_lit, :double_string_lit\n @value.to_f\n else\n self.to_i.to_f\n end\n end", "def to_f\n self.class.new(@value.to_f)\n end", "def to_f\n Float(value)\n end", "def to_f\n @value.to_f\n end", "def to_f\n (self.v || self.d).to_f\n end", "def to_f\n return nil if value.nil?\n value.to_f.with_decimals decimals\n end", "def __s2f(other)\n return other if other.is_a? Numeric\n if /^0[Xx][0-9a-fA-F]+$/ =~ other\n other.to_i(0).to_f\n else\n other.to_f\n end\n end", "def to_f\n @value.to_f\n end", "def to_f\n @value.to_f\n end", "def to_f\n @value.to_f\n end", "def to_f\n @value.to_f\n end", "def to_f\n to_r.to_f\n end", "def to_f \n return self.value\n end", "def to_f\n self.map {|e| e.to_f}\n end", "def to_f_with_method\n to_x_with_method.to_f\n end", "def to_f\n in_native.to_f\n end", "def farenheit\n self.to_f\n end", "def to_rep(val)\n val.to_f\n end", "def to_f(pattern)\n get_numeric_value(pattern){ |value| value.to_f(pattern) }\n end", "def to_f\n @object.to_f\n end", "def to_f\n @object.to_f\n end", "def to_f\n @object.to_f\n end", "def to_f\n @object.to_f\n end", "def coerce(value)\n return 0.0 unless value.respond_to?(:to_f)\n\n value.to_f\n end", "def to_f(pattern)\n if @value\n result = @value.to_f(pattern)\n result += @variation if @variation\n result\n end\n end", "def to_f(aNum)\r\n# - - - - - - - - - - - - - - - - - -\r\n return 0.0 + aNum\r\nend", "def massage(value)\n value.to_f\n end", "def to_f\n gsub(SCRUB_NUMBER_REGEX, EMPTY_STRING).core_to_f\n end", "def post_process_float( val )\n\t\t\treturn Float( val.to_s )\n\t\tend", "def typecast_value_float(value)\n Float(value)\n end", "def to_f(general_votes_cell)\n general_votes_cell.gsub(/[^0-9]/, '').to_f\n end", "def to_sf\n ONE_FLOAT_RE.match(self)[1].to_f\n end", "def from_german_to_f\n self.gsub(',', '.').to_f\n end", "def format_value_to_float(value)\n value.to_s\n end", "def to_f\n amount.to_f\n end", "def convert_int_to_f(num)\n if num.class == Integer || num.class == Float\n return num.to_f/100.to_f\n end\n end", "def to_f\n @amount.to_f\n end", "def number_f\n return @number_f\n end", "def to_float(value)\n return value.to_f if value.is_a?(Numeric)\n value = value.to_s if value.is_a?(Symbol)\n value.to_f if value.is_a?(String) && value.match?(NUMBER_PATTERN)\n end", "def to_stringified_float(int)\n # your code goes here\n return (int.to_f).to_s\nend", "def typecast_to_float(value)\n typecast_to_numeric(value, :to_f)\n end", "def to_f\n to_time.to_f\n end", "def to_f\n @bits.to_f\n end", "def value; super.to_f; end", "def toF\n if @unit == 'C' then\n @unit = 'F'\n @value = 1.8 * @value + 32.0\n elsif @unit == 'R' then\n @unit = 'F'\n @value -= 459.67\n elsif @unit == 'K' then\n @unit = 'F'\n @value = 1.8 * @value - 459.67\n end\n self\n end", "def to_stringified_float(int)\r\n # your code goes here\r\n # use of methods\r\n\r\n int.to_f.to_s\r\nend", "def convert_i_f(value)\n if (value =~ /\\./)\n value = value.to_f\n elsif\n value = value.to_i\n end\n return value\nend", "def to_f\n if isFloat? then\n value = exp.to_f\n return value\n elsif exp == \"Infinity\" then return @@MAX_VALUE\n elsif exp == \"-Infinity\" then return @@MIN_VALUE\n else\n raise \"Non-float conversion in expression: \" + exp\n end\n end", "def convert_float( text_value )\r\n (!text_value.empty?) ? text_value.to_f : 0.0\r\nend", "def to_f\n @val / @div.to_f\n end", "def test_NilClass_InstanceMethod_to_f\n\t\tassert_equal(0.0, nil.to_f)\n\tend", "def to_f()\n @sec.to_f ;\n end", "def to_f\n @amount.to_f\n end", "def numericize\n\t\tcollect(&:to_f)\n\tend", "def to_f(metric=nil)\n (metric || (metric.nil? && self.metric?)) ? self.km(false) : self.m(false)\n end", "def time_to_float(input)\n return input.respond_to?(:to_time) ? input.to_time.to_f : input.to_f\n end", "def convert(f)\n (f - 32.0) * 5 / 9\nend", "def value_to_float(value)\n if @slop.strict?\n begin\n Float(value.to_s)\n rescue ArgumentError\n raise InvalidArgumentError, \"#{value} could not be coerced into Float\"\n end\n else\n value.to_s.to_f\n end\n end", "def like_f?\n return false unless self.to_f?\n\n num = self.without_leading_zeros\n (num.to_i != num.to_f) || num.include?(\".\")\n end", "def unpack_float(value)\n value.to_f\n end", "def to_Float\n begin\n fl = Float stripn\n return fl\n rescue ArgumentError\n return false\n end\n end", "def to_f\n if @last == 0\n raise ZeroDivisionError\n else\n @first.to_f / @last\n end\n end", "def to_stringified_float(int)\n x = int.to_f\n return puts x.to_s\n # your code goes here\nend", "def to_f\n return @amount.to_f\n end", "def test_002_convert_float2\r\n\tresult = convert_float( '')\r\n\tassert close_enough( 0.0, result )\r\n end", "def value\n @value.to_f\n end", "def to_f\n (BigDecimal.new(cents.to_s) / currency.subunit_to_unit).to_f\n end", "def to_f\n (BigDecimal.new(cents.to_s) / currency.subunit_to_unit).to_f\n end", "def int_or_f(number)\n if number.to_f - number.to_i == 0.0\n number = number.to_i\n else\n number = number.to_f\n end\nend", "def at_to_f (at)\n\n at = Rufus::to_ruby_time(at) if at.kind_of?(String)\n at = Rufus::to_gm_time(at) if at.kind_of?(DateTime)\n at = at.to_f if at.kind_of?(Time)\n\n raise \"cannot schedule at : #{at.inspect}\" unless at.is_a?(Float)\n\n at\n end", "def to_s\n \"#{( \"%.f\" % @value )}#{'%'} \"\n end", "def test_Rational_InstanceMethods_to_f\n\t\tassert_equal(9.25, Rational(\"37/4\").to_f)\n\tend", "def to_f\n p = FFI::MemoryPointer.new(:double)\n if CF.CFNumberGetValue(self, :kCFNumberDoubleType, p) != 0\n p.read_double\n else\n raise \"CF.CFNumberGetValue failed to convert #{self.inspect} to kCFNumberDoubleType\"\n end\n end", "def convert(temperature_fahrenheit)\n (temperature_fahrenheit.to_f - 32) * 5 / 9\nend", "def to_float(num)\n return num unless num.is_a? Numeric\n num.to_f\n end", "def to_s\n @value.to_f.to_s\n end", "def float\n Util.from_bytes :float, value\n end", "def to_femto\n big_self / FEMTO\n end", "def to_f\n # TODO: This calculation can result in floating point errors when the duration\n # is converted to and from a float value\n (@hours * 3600) + (@minutes * 60) + @seconds + (@nano_seconds.to_f / 10**9)\n end", "def latlng_to_f(coord, negative = false)\n decimal = nil\n\n if coord =~ /^([0-9]*?)([0-9]{2,2}\\.[0-9]*)$/\n deg = $1.to_i # degrees\n min = $2.to_f # minutes & seconds\n\n # Calculate\n decimal = deg + (min / 60)\n if negative\n decimal *= -1\n end\n end\n\n decimal\n end", "def test_Complex_InstanceMethods_to_f\n\t\tassert_equal(2.0, Complex(2, 0).to_f)\n\tend", "def to_f\n return self.time.to_f\n end", "def convert( fahrenheit )\n puts format( \"%.2f\", ( fahrenheit.to_f - 32 )/ 1.8000 )\nend", "def represents_f?\n f_value = self.to_f\n # is this not equal to zero and also not actually an integer?\n if (f_value != 0) && (f_value.to_s == self)\n true\n else\n false\n end\n end", "def to_f\n\t\tnum.to_f/denom\n\tend", "def to_float_or_int(v)\n v.match('\\.').nil? ? Integer(v) : Float(v)\n end", "def is_float?\n self.to_f.to_s == self\n end", "def convert(_Fahrenheit)\n (_Fahrenheit.to_f - 32) * 5 / 9\n end", "def hash_values_to_float(original_hash)\n float_values = {}\n original_hash.each { |k, v| float_values[k] = v.to_f }\n float_values\n end", "def test_to_f\n x = Torch.tensor([1.5])\n assert_equal 1.5, x.to_f\n end", "def convert_inches_to_feet( inches )\r\n inches.valid_float? ? (inches.to_f/12.0) : 0.0\r\nend", "def convert(temp_in_fahrenheit)\n (temp_in_fahrenheit.to_f - 32) * 5/9\nend", "def type_cast(v)\n ((float = Float(v)) && (float % 1.0 == 0) ? float.to_i : float) rescue v\n end" ]
[ "0.837901", "0.837901", "0.837901", "0.837901", "0.80831075", "0.77847016", "0.77847016", "0.77847016", "0.7709833", "0.76996845", "0.76516867", "0.7643432", "0.76333004", "0.76147074", "0.75944954", "0.75668126", "0.75668126", "0.75668126", "0.75668126", "0.7400291", "0.7339389", "0.7310711", "0.72183216", "0.7216612", "0.7139698", "0.71348417", "0.71186924", "0.7065663", "0.7065663", "0.7065663", "0.7065663", "0.69842225", "0.6882077", "0.68700445", "0.68309027", "0.6753194", "0.669322", "0.66815686", "0.6680117", "0.66664064", "0.6653619", "0.6621161", "0.6583009", "0.6572406", "0.65716165", "0.6571203", "0.656215", "0.6558558", "0.65489525", "0.65456647", "0.6498752", "0.6494393", "0.64904183", "0.6483597", "0.6463728", "0.6417031", "0.6416189", "0.6412725", "0.640249", "0.6386378", "0.6385666", "0.63794655", "0.636301", "0.6345994", "0.63289756", "0.6271439", "0.62189853", "0.6201991", "0.61967564", "0.61960834", "0.6190141", "0.6162979", "0.6142313", "0.6134193", "0.6130928", "0.6130928", "0.6121336", "0.6105107", "0.60991085", "0.6087309", "0.60869706", "0.6073564", "0.6072571", "0.6069619", "0.60677725", "0.6065297", "0.6060783", "0.60570085", "0.60555536", "0.6047999", "0.6017172", "0.59945995", "0.5987452", "0.59773946", "0.5977013", "0.597312", "0.59629625", "0.5952072", "0.59482974", "0.5943132", "0.5940579" ]
0.0
-1
return the name of the role
def role_str case name when ROLE_ADMIN then I18n.t("model.role.admin") when ROLE_COMPANY then I18n.t("model.role.company") when ROLE_ENGINEER then I18n.t("model.role.engineer") when ROLE_NORMAL then I18n.t("model.role.normal") end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def role_name\n @role_name ||= object.meta[:role].try(:capitalize)\n end", "def role_name\r\n Role.find(object.role_id).role_name\r\n end", "def role_name\n object.role_name\n end", "def role\r\n r = read_attribute(:role)\r\n r.capitalize unless r.nil?\r\n end", "def name_with_role\n \"#{self.name} (#{self.organization.name} - #{self.role.name})\"\n end", "def get_role_name(key)\n key = Access::Validate.role(key)\n get_hash_value(Access::Core.roles_hash, key, :name)\n end", "def get_role_name(role_type, role)\n method_symbol = ROLES[role_type]\n\n return nil if method_symbol.nil?\n\n role_object = role.send(method_symbol)\n\n return nil if role_object.name.empty?\n\n role_object.name\n end", "def resource_name\n\t\t\"role\"\n\tend", "def role\n @role\n end", "def get_user_name(role)\n get_user(role).full_name\n end", "def name\n \"#{role_name} #{user&.email}\"\n end", "def role_name\n @values.fetch('ai.device.roleName') { \n @values['ai.device.roleName'] = nil\n }\n end", "def role\n return @role\n end", "def get_role\n return case self.role_id\n when 2\n \"User\"\n else\n \"N/A\"\n end\n end", "def display_role\n ROLE_LIST[self.role]\n end", "def get_full_role\n if role == \"admin\"\n return \"Administrator\"\n elsif role == \"lead\"\n return \"Organization Lead\"\n end\n end", "def role_selection\n \"#{name}\"\n end", "def oo_default_role_name\n name.words.snakecase\n end", "def role_arn\n data.role_arn\n end", "def role_arn\n data[:role_arn]\n end", "def role\n return self.position.name\n end", "def role(user)\n if user.admin\n return \"Admin\"\n else return \"User\"\n end\n end", "def get_full_role\n\t\tif role == \"lead\"\n\t\t\treturn \"Project Lead\"\n\t\telsif role == \"editor\"\n\t\t\treturn \"editor\"\n\t\tend\n\tend", "def human_name\n I18n.t(@name, :scope => [:role], :default => @name.to_s.humanize)\n end", "def role_str\n if (role == nil)\n role_result = \"participant\"\n else\n role_result = role\n end\n role_result\n end", "def role(req)\n \"admin:#{dealership(req).id}\"\n end", "def get_role(role_name)\n self.class.get_role(role_name)\n end", "def user_role\n USER_ROLE[role]\n end", "def role(role_name)\n context.send(role_name)\n end", "def get_role\n\t\tself.role\n\tend", "def role_names\n roles.map { |role| role.name.capitalize }\n end", "def role\n admin ? \"admin\" : \"user\"\n end", "def arn\n cloud_desc.role_arn\n end", "def title_for(role)\n role_titles[role]\n end", "def role; end", "def role; end", "def roleid\n [ account, kind, identifier ].join(':')\n end", "def role\n if self.admin || (Setting.no_security == \"true\")\n return :admin\n elsif self.reviewer\n return :reviewer\n else\n return :default\n end\n end", "def role?\n role.name.to_sym\n end", "def name(role_name = nil)\n if role_name\n @name = \"#{role_name}.#{index}\"\n end\n @name || \"##{index}\"\n end", "def find_role(name)\n self.roles.find {|a| a.name == name}\n end", "def role_for(name)\n role_name = name.to_s.gsub(/(?:^|_)([a-z])/) { $1.upcase }\n self.class.const_get(role_name)\n rescue NameError\n Module.new\n end", "def downcase_role\n self.role.downcase\n end", "def role\n @role ||=\n if is_admin?\n :admin\n else\n :customer\n end\n end", "def role\n @pool.role\n end", "def nice_role(role_id)\n if role_id != GlobalConstants::TOURNAMENT_ROLES[:tab_room]\n return GlobalConstants::TOURNAMENT_ROLES_STR[role_id].to_s.upcase;\n else\n return GlobalConstants::TOURNAMENT_ROLES_STR[role_id].to_s.titleize;\n end\n return nil;\n end", "def role?(role_name)\n role == role_name\n \n end", "def role_label\n if user.is_admin?\n colored_label('Admin', :success)\n elsif user.has_role?(:manager)\n colored_label('Manager', :info)\n elsif user.has_role?(:content_manager) || user.has_role?(:event_manager) || user.has_role?(:forum_manager)\n colored_label('Submanager', :warning)\n elsif user.has_role?(:reviewer)\n colored_label('Reviewer', :default)\n elsif user.has_role?(:beta)\n colored_label('Beta', :danger)\n else\n 'User'\n end\n end", "def get_role\n\t\tif self.roles[0]\t\n\t\t\tself.roles[0].role_type \n\t\telse\n\t\t\t0\n\t\tend\n\tend", "def get_role_arn(name)\n @@client.get_role({\n role_name: name\n }).role.arn\n rescue Aws::IAM::Errors::NoSuchEntity\n nil\n end", "def role_type\n return User.role_type_from_string(self.role)\n end", "def role\n return :admin unless organization\n if has_role?(:admin, organization)\n return :admin\n elsif organization.owner_id == self.id\n return :owner\n else\n return :member\n end\n end", "def role? role_name\n self.roles.exists? name: role_name.to_s\n end", "def checkrole\n if roles_mask == 4\n 'User'\n elsif roles_mask == 6\n 'Administrator'\n end\n end", "def role?(role)\n self.role.to_s == role.to_s\n end", "def get_role_arn(name)\n sib_role = @deploy.findLitterMate(name: name, type: \"roles\")\n return sib_role.cloudobj.arn if sib_role\n\n begin\n role = MU::Cloud::AWS.iam(credentials: @config['credentials']).get_role({\n role_name: name.to_s\n })\n return role['role']['arn']\n rescue Exception => e\n MU.log \"#{e}\", MU::ERR\n end\n nil\n end", "def role?(r)\n self.role == r.to_s\n end", "def to_s\n \"#{label || role} in #{organization_id}\"\n end", "def role_definition\n return @role_definition\n end", "def role_definition\n return @role_definition\n end", "def current_user_role\n current_user.try(:role).try(:to_sym) || :normal\n end", "def role?(role)\n self.role == role.to_s\n end", "def role?(role)\n self.role == role.to_s\n end", "def society_role_str\n raw_str = GlobalConstants::SOCIETY_ROLES_STR[self.status];\n return raw_str.capitalize();\n end", "def current_role\n if user_signed_in?\n @current_role ||= current_user.roles.pluck(:name)\n end\n end", "def role\n permission_type\n end", "def role\n @manifest_options[:role] || \"\"\n end", "def server_name_for_role role\n role = role.to_sym\n if servers_by_role[role]\n existing_numbers = servers_by_role[role].collect { |s| s.tags['Name'].split(\"-\").last.to_i }\n next_number = ((1..existing_numbers.count+1).to_a - existing_numbers).first\n else\n next_number = 1\n end\n server_name = \"#{role}-#{next_number}\"\n end", "def name\n [roleinjobposition.name, (jobpositionlevel.nil? ? nil : jobpositionlevel.name) ].compact.join(' ')\n end", "def description_for(role)\n role_descriptions[role]\n end", "def role?(role)\n roles.pluck(:name).include? role.to_s\n end", "def role(name)\n json = client.get(\"/v1/auth/approle/role/#{encode_path(name)}\")\n return Secret.decode(json)\n rescue HTTPError => e\n return nil if e.code == 404\n raise\n end", "def has_role? (role_name)\n self.role ? self.role.name==(role_name.to_s) : false\n end", "def has_role? (role_name)\n self.role ? self.role.name==(role_name.to_s) : false\n end", "def role?(role)\n self.role == role.to_s ? true : false\n end", "def getRole (user)\n case user.role\n when 0\n return 'user'\n when 1\n return 'operator'\n when 2\n return 'cto_user'\n when 3\n return 'owner'\n when 4\n return 'anonymous'\n else\n raise ('invalid user' + user.role)\n end\n end", "def role_id\n data.role_id\n end", "def role?(role)\n\t self.role.name == role\n end", "def role?(role)\n self.role&.name == role\n end", "def has_role?(role_name) # rubocop:disable Naming/PredicateName\n role&.name == role_name.to_s\n end", "def get_role user\n project_role_user = ProjectRoleUser.where(:project_id => self, :user_id => user).first\n if project_role_user\n project_role_user.role.name\n else\n nil\n end\n end", "def user_role\n current_user.role if current_user\n end", "def get_role_or_nil\n if user_type == \"UserControl\"\n \"UserControl\"\n elsif user_signed_in?\n current_user.role.name\n else\n nil\n end\n end", "def get_role(role_name)\n request(\n 'Action' => 'GetRole',\n 'RoleName' => role_name,\n :parser => Fog::Parsers::AWS::IAM::SingleRole.new\n )\n end", "def has_role?( role )\n\t\treturn self.role.title.to_sym == role if self.role\n\t\tfalse\n\tend", "def fetch_metadata_role_name\n unless @credential_verification_url\n raise \"Unable to determine the AWS metadata server security credentials endpoint\"\n end\n\n get_aws_resource(@credential_verification_url, \"IAM Role\").body\n end", "def options_for_role\n Member::AVAILABLE_ROLES.map { |role| [role.capitalize, role] }\n end", "def function_name_role\n {\n 'Type' => 'AWS::IAM::Role',\n 'Properties' => {\n 'ManagedPolicyArns' => [\n 'arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole'\n ],\n 'AssumeRolePolicyDocument' => lambda_service_can_assume_role\n }\n }\n end", "def role\n @path = \"/services/Admin\"\n @role ||= Nephophobia::Resource::Role.new self\n end", "def role=(value)\n @role = value\n end", "def role_name=(value)\n if value == @defaults['ai.device.roleName']\n @values.delete 'ai.device.roleName' if @values.key? 'ai.device.roleName'\n else\n @values['ai.device.roleName'] = value\n end\n end", "def role?(role_to_compare)\n self.role.to_s == role_to_compare.to_s\n end", "def member_label\n @member_label ||= if member.role.present?\n t(member.role, scope: \"asset_role_label\", default: member.role.humanize )\n else\n member.title\n end\n end", "def role_cls\n User\n end", "def account_type\n self.role.name\n end", "def account_type\n self.role.name\n end", "def has_role?(name)\n !roles.find_by('lower(name) = ?', name.downcase).nil?\n end", "def guild_role\n\t\t@guild_role\n\tend", "def type\n TYPES[roletype_id]\n end", "def role_symbols\n [:user]\n end" ]
[ "0.8877166", "0.8833476", "0.87497485", "0.8400174", "0.83137137", "0.81513506", "0.8113835", "0.7994746", "0.78880656", "0.78487027", "0.7735582", "0.77353096", "0.7721731", "0.7701005", "0.76615936", "0.76540244", "0.7581208", "0.755716", "0.7501846", "0.7480339", "0.747146", "0.7453066", "0.7410673", "0.740115", "0.7386449", "0.7362999", "0.7357906", "0.7355751", "0.73513716", "0.7324759", "0.73202103", "0.7280191", "0.72478414", "0.72419524", "0.7217848", "0.7217848", "0.7210148", "0.71911633", "0.7161671", "0.71587735", "0.7141038", "0.7134013", "0.7077275", "0.7052819", "0.7048432", "0.7008224", "0.6997877", "0.69858897", "0.6972547", "0.6951681", "0.6938302", "0.6885312", "0.6878582", "0.6841995", "0.6841191", "0.68302596", "0.6814906", "0.68135136", "0.6808792", "0.6808792", "0.6795269", "0.6788275", "0.6788275", "0.6783297", "0.6779554", "0.6770527", "0.6768323", "0.6754022", "0.6752026", "0.67365515", "0.6723179", "0.67067266", "0.67017716", "0.67017716", "0.66941196", "0.66933423", "0.6690686", "0.6690023", "0.6653046", "0.6646106", "0.6625766", "0.66237146", "0.66229093", "0.65955746", "0.6570126", "0.65617245", "0.6561352", "0.65603566", "0.6555689", "0.65556026", "0.6553923", "0.6550818", "0.65375733", "0.6501568", "0.64934814", "0.64934814", "0.6480508", "0.6475546", "0.64652205", "0.64621323" ]
0.7570399
17
Locale in xx_XX format
def full_locale(lang=I18n.locale.to_s) if lang == "en" "en_US" else "#{lang.downcase}_#{lang.upcase}" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def format_locale\n self.locale = self.locale.gsub('_', '-').split(',').first.split('-').first if self.locale.present?\n end", "def apply_locale; end", "def to_deepl_compatible_locale(locale)\n locale.to_s.split('-', 2).first.upcase\n end", "def _calc_locale(_l)\n _l = (_l || @_deco_locale || (h.cama_get_i18n_frontend rescue nil) || I18n.locale).to_s\n \"_#{_l}\"\n end", "def normalize_locale(locale)\n locale = locale.to_s\n\n locale.tr('-','_')\n end", "def locale; end", "def locale; end", "def locale; end", "def locale; end", "def locale; end", "def locale; end", "def locale; end", "def full_locale(lang = I18n.locale)\n case lang\n when :en\n \"en_US\"\n else\n \"#{lang.downcase}_#{lang.upcase}\"\n end\n end", "def locale_to_name\n \t\t{'fr' => 'Français',\n 'en' => 'English',\n 'po' => 'portugues',\n 'sp' => 'Spanish',\n 'de' => 'Deutsch',\n 'it' => 'Italiano'}\n\tend", "def to_deepl_source_locale(locale)\n locale.to_s.split('-', 2).first.upcase\n end", "def formatta_locale(format)\n if defined? I18n\n I18n.l self, format: format\n else\n formattazione = strftime format\n formattazione\n .gsub(/January/i, \"Gennaio\")\n .gsub(/February/i, \"Febbraio\")\n .gsub(/March/i, \"Marzo\")\n .gsub(/April/i, \"Aprile\")\n .gsub(/May/i, \"Maggio\")\n .gsub(/June/i, \"Giugno\")\n .gsub(/July/i, \"Luglio\")\n .gsub(/August/i, \"Agosto\")\n .gsub(/September/i, \"Settembre\")\n .gsub(/October/i, \"Ottobre\")\n .gsub(/November/i, \"Novembre\")\n .gsub(/December/i, \"Dicembre\")\n end\n end", "def locale=(_arg0); end", "def locale(locale)\n if default?\n locale.to_s\n else\n \"#{self.name}_#{locale.to_s}\"\n end\n end", "def locale\n I18n.locale.to_s\n end", "def locale\n I18n.locale.to_s\n end", "def to_international\n if extension?\n \"+49 #{@prefix} #{number}/#{extension}\"\n else\n \"+49 #{@prefix} #{number}\"\n end\n end", "def locale\r\n read_attribute(:locale).to_sym\r\n end", "def default_locale; end", "def locale_of(filename)\n locale = (filename =~ extension_regex ? $1 : nil)\n locale ? locale.gsub(/^\\./, '').to_sym : nil\n end", "def lang locale\n if translations.find_by(locale: locale).try(:automated?)\n \"#{locale}-x-mtfrom-de\"\n else\n locale.to_s\n end\n end", "def locale_language(locale=nil)\n \"#{locale || I18n.locale}\"[0, 2].to_sym\n end", "def translate(lang)\n lang.tr('-', '_')\n end", "def localize\n helpers.localize\n end", "def format_fecha_conversion(fecha)\n unless fecha.to_s ==''\n\n if I18n.locale.to_s==\"es\" || I18n.locale.to_s==\"fr\" || I18n.locale.to_s==\"ar\" || I18n.locale.to_s==\"cs\" || I18n.locale.to_s==\"da\" || I18n.locale.to_s==\"de\" || I18n.locale.to_s==\"fi\" || I18n.locale.to_s==\"hu\" || I18n.locale.to_s==\"it\" || I18n.locale.to_s==\"ru\" || I18n.locale.to_s==\"nl\" || I18n.locale.to_s==\"pl\" || I18n.locale.to_s==\"pt\" || I18n.locale.to_s==\"sl\" || I18n.locale.to_s==\"sv\"\n fecha_busqueda = fecha[6,4].to_s + '-' + fecha[3,2].to_s + '-' + fecha[0,2].to_s\n elsif I18n.locale.to_s==\"ja\"\n fecha_busqueda = fecha[0,4].to_s + '-' + fecha[5,2].to_s + '-' + fecha[8,2].to_s\n else\n fecha_busqueda = fecha[6,4].to_s + '-' + fecha[0,2].to_s + '-' + fecha[3,2].to_s\n end\n\n else\n fecha_busqueda = \"\"\n end\n end", "def locale=(value); end", "def locale_backend; end", "def set_locale\n end", "def path_format_locale(path, arg_base_url = \"\")\r\n if arg_base_url == \"\"\r\n url = $base_url\r\n else\r\n url = arg_base_url\r\n end\r\n url.to_s + path + \"?locale=\" + $lang.to_s\r\n end", "def payment_compatible_locale(locale)\n locale = locale.to_s.split(\"-\").first\n if [\"fr\", \"en\", \"es\", \"it\", \"pt\", \"de\", \"nl\", \"fi\"].include?(locale)\n return locale\n else\n return \"en\"\n end\n end", "def currency_to_locale number\n if params[:locale] == 'es'\n number = number*1.3\n end\n number_to_currency number\n end", "def locale_country(locale = nil)\n (locale || I18n.locale).to_s.match(/[_-](\\w{2})$/) ? $1.to_sym : nil\n end", "def strftime_to_ms_format numberformat\n return nil if numberformat.nil?\n numberformat.gsub(\"%Y\", \"yyyy\").gsub(\"%A\", \"dddd\").gsub(\"%B\", \"mmmm\").gsub(\"%a\", \"ddd\").gsub(\"%b\", \"mmm\").gsub(\"%y\", \"yy\").gsub(\"%d\", \"dd\").gsub(\"%m\", \"mm\").gsub(\"%y\", \"y\").gsub(\"%y\", \"%%y\").gsub(\"%e\", \"d\")\n end", "def locale=(locale); end", "def locale_country(locale=nil)\n \"#{locale || I18n.locale}\".match(/-([a-zA-Z]{2})/) ? $1.to_sym : nil\n end", "def locale\n (self.country.blank? or self.country.indonesia?) ? :id : :en\n end", "def default_locale\n (self.locales.first || Locomotive::Mounter.locale).to_sym\n end", "def system\n locale_from_env || default_locale\n end", "def get_locale(host)\r\n host.gsub(I18n.config.host_locale_regex, '\\1') || I18n.default_locale\r\n end", "def locale\n favored_locale\n end", "def with_locale(tmp_locale = T.unsafe(nil)); end", "def locale\n @locale || YodleeApi.locale\n end", "def mission_id_to_locale_id(id)\n \"m_#{id}\"\nend", "def to_gettext(locale:)\n join_char = Rails.configuration.x.locales.gettext_join_character\n locale = default_locale if locale.blank?\n convert(string: locale, join_char: join_char)\n end", "def locale\n @grpc.locale\n end", "def locale\n @grpc.locale\n end", "def international\n return \"+#{sanitized}\" unless valid?\n\n format = @data[country][:format]\n if matches = @national_number.match(/#{format[Core::PATTERN]}/)\n fmt = format[:intl_format] || format[:format]\n national = fmt.gsub(/\\$\\d/) { |el| matches[el[1].to_i] }\n else\n national = @national_number\n end\n\n \"+#{@data[country][Core::COUNTRY_CODE]} #{national}\"\n end", "def locale\n @values.fetch('ai.device.locale') { \n @values['ai.device.locale'] = nil\n }\n end", "def currency_format(locale)\n {\n separator: I18n.t(\"number.currency.format.separator\", locale: locale) || \".\",\n delimiter: I18n.t(\"number.currency.format.delimiter\", locale: locale) || \",\",\n format: I18n.t(\"number.currency.format.format\", locale: locale) || \"%u%n\"\n }\n end", "def locale(force = true)\n @locale || negotiate_locale(force)\n end", "def strftime_ordinalized(fmt, format=nil)\n strftime(fmt.gsub(/(^|[^-])%d/, '\\1_%d_')).gsub(/_(\\d+)_/) { |s| s.to_i.ordinalize }\n end", "def num_fmt_id_to_ms_formatting num_fmt_id\n # from: https://stackoverflow.com/questions/4730152/what-indicates-an-office-open-xml-cell-contains-a-date-time-value\n {\"0\" => nil, \"1\" => \"0\", \"2\" => \"0.00\", \"3\" => \"#,##0\", \"4\" => \"#,##0.00\",\n \"9\" => \"0%\", \"10\" => \"0.00%\", \"11\" => \"0.00E+00\", \"12\" => \"# ?/?\",\n \"13\" => \"# ??/??\", \"14\" => \"mm-dd-yy\", \"15\" => \"d-mmm-yy\", \"16\" => \"d-mmm\",\n \"17\" => \"mmm-yy\", \"18\" => \"h:mm AM/PM\", \"19\" => \"h:mm:ss AM/PM\",\n \"20\" => \"h:mm\", \"21\" => \"h:mm:ss\", \"22\" => \"m/d/yy h:mm\",\n \"37\" => \"#,##0 ;(#,##0)\", \"38\" => \"#,##0 ;[Red](#,##0)\",\n \"39\" => \"#,##0.00;(#,##0.00)\", \"40\" => \"#,##0.00;[Red](#,##0.00)\",\n \"44\" => '_(\"$\"* #,##0.00_);_(\"$\"* \\(#,##0.00\\);_(\"$\"* \"-\"??_);_(@_)',\n \"45\" => \"mm:ss\", \"46\" => \"[h]:mm:ss\", \"47\" => \"mmss.0\", \"48\" => \"##0.0E+0\",\n \"49\" => \"@\", \"27\" => \"[$-404]e/m/d\", \"30\" => \"m/d/yy\", \"36\" => \"[$-404]e/m/d\",\n \"50\" => \"[$-404]e/m/d\", \"57\" => \"[$-404]e/m/d\", \"59\" => \"t0\", \"60\" => \"t0.00\",\n \"61\" => \"t#,##0\", \"62\" => \"t#,##0.00\", \"67\" => \"t0%\", \"68\" => \"t0.00%\",\n \"69\" => \"t# ?/?\", \"70\" => \"t# ??/??\",}[num_fmt_id.to_s]\n end", "def translation\r\n translation_for(Mongoid::Globalize.locale)\r\n end", "def verificar_locale\n \n end", "def locale\n return nil if errors\n\n locale = YAML.safe_load(@text).keys.first\n locale.to_sym\n end", "def to_i18n(locale:)\n join_char = Rails.configuration.x.locales.i18n_join_character\n locale = default_locale if locale.blank?\n convert(string: locale, join_char: join_char)\n end", "def translate_lang_code(val)\n t(val.upcase)\n end", "def langtag(locale)\n\t\tcase locale.to_s\n\t\twhen 'se' then 'se'\n\t\twhen 'us' then 'en'\n\t\twhen 'uk' then 'en'\n\t\twhen 'cn' then 'zh'\n\t\telse locale\n\t\tend\n\tend", "def locale\n if !language.nil?\n language.abbreviation\n elsif !org.nil?\n org.locale\n end\n end", "def locale\n self.padma.try :locale\n end", "def default_locale=(locale); end", "def locale_language(locale = nil)\n (locale || I18n.locale).to_s.match(/^(\\w{2})/) ? $1.to_sym : nil\n end", "def current_locale\n Thread.current[:\"localite:locale\"] || base\n end", "def with_locale(tmp_locale = T.unsafe(nil), &block); end", "def locale\n return @locale\n end", "def locale\n return @locale\n end", "def po_locale\n @po_locale\n end", "def localize(time, opts)\n time.strftime(opts[:format])\n end", "def language_name(code)\n if configatron.locales.include?(code)\n t(:locale_name, :locale => code)\n else\n (entry = ISO_639.find(code.to_s)) ? entry.english_name : code.to_s\n end\n end", "def locale_name\n YAML.load(translation || \"{}\").with_indifferent_access[locale] || survey.default_locale_name\n end", "def locale\n if self.language\n LANGUAGE_CODE[self.language]\n end\n end", "def locale_idx; end", "def set_locale\n I18n.locale = params[:locale] \n end", "def format_ordinal(number)\n number.to_s + ORDINALS.fetch(number.to_s[-1].to_sym, 'th')\nend", "def default_locale\n FastGettext.available_locales.first\n end", "def suffixize(lang)\n lang.blank? ? \"\" : \"_#{lang}\"\n end", "def whatsapp_format(phone)\n Phonelib.parse(phone).international(false).tr('+', '')\n end", "def get_locale\n if !self.language.nil?\n return self.language.abbreviation\n else\n return nil\n end\n end", "def domain_to_locale code\n\t\t\tdomain_locale_map[code.to_sym] || flag_locale_map[code.to_sym] || code\n\t\tend", "def set_locale\n I18n.locale = extract_locale_from_tld\n end", "def first_data_language\n I18n.locale.to_s.sub('-','_').downcase\n end", "def use_i18n; end", "def user_locale(user = current_user)\n locale = if user && user.language != 'default'\n user.language\n else\n http_accept_language.language_region_compatible_from(I18n.available_locales)\n end\n\n begin\n I18n.locale = locale.tr('-', '_') unless locale.nil?\n rescue\n # Default to English if there are any issues in language\n logger.error(\"Support: User locale is not supported (#{locale}\")\n I18n.locale = \"en\"\n end\n end", "def locale\n configatron.ramazon.locale || :us\n end", "def format_order_number(number)\n number.to_s.gsub(/[^\\w_]/, '').rjust(4, \"0\")[0...20]\n end", "def number_to_ordinal(num)\n if params[:locale] == \"en\"\n num = num.to_i\n if (10...20)===num\n \"#{num}th\"\n else\n g = %w{ th st nd rd th th th th th th }\n a = num.to_s\n c=a[-1..-1].to_i\n a + g[c]\n end\n else\n num = num.to_i\n raw \"#{num}&ordf;\"\n end\n end", "def locale\n @locale || { :country => \"US\", :language => \"en\", :variant => nil }\n end", "def set_locale\n I18n.locale = params[:locale]\n end", "def set_locale\n I18n.locale = params[:locale]\n end", "def preferred_locales_str\n (preferred_locales || []).join(\",\")\n end", "def default_locale\n AppConfig.default_locale\n end", "def getLocaleCode\n # first default locale to default locale\n @locale_code = Rails.application.config.i18n.default_locale\n # next set locale to the locale in user record\n @locale_code = current_user.try(:locale) || @locale_code\n # next set locale to the locale passed as the locale param\n if (params.present? &&\n params['locale'].present? &&\n BaseRec::VALID_LOCALES.include?(params['locale'].to_s)\n )\n @locale_code = params['locale']\n end\n # set the locale in I18n\n I18n.locale = @locale_code\n Rails.logger.debug \"@locale_code: #{@locale_code.inspect}\"\n end", "def set_locale\n # This requires a user model to work. I'm assuming there will be a \"current_user\" helper.\n # If we decide to use Devise, that will be default.\n # I18n.locale = current_user.language || I18n.default_locale\n end", "def locale_from_http_header\n language = request.env['HTTP_ACCEPT_LANGUAGE']\n unless language.blank?\n http_locale = language.scan(/^[a-z]{2}-[A-Z]{2}/)\n unless http_locale.blank?\n http_locale = http_locale.first\n else\n http_locale = language.scan(/^[a-z]{2}/).first\n end\n end\n end", "def hecho_en\n 'china'\n end", "def humanize(lang = :en)\n to_s\n end" ]
[ "0.7725891", "0.7055182", "0.6987029", "0.6929199", "0.6824065", "0.6806571", "0.6806571", "0.6806571", "0.6806571", "0.6806571", "0.6806571", "0.6806571", "0.67514277", "0.6677381", "0.6646012", "0.6639206", "0.65349495", "0.645439", "0.63492495", "0.63492495", "0.6312461", "0.6289676", "0.6286102", "0.6283459", "0.6255257", "0.6208644", "0.6128746", "0.6127341", "0.61001086", "0.60990345", "0.6094941", "0.60645586", "0.60402656", "0.60349363", "0.6025491", "0.6012041", "0.6003182", "0.600291", "0.5981945", "0.5979253", "0.59779257", "0.5954241", "0.59510297", "0.5939831", "0.5936118", "0.59217185", "0.59163594", "0.5910343", "0.5844846", "0.5844846", "0.58419967", "0.584074", "0.58143413", "0.58058363", "0.5802637", "0.5782573", "0.57622164", "0.57507277", "0.5750217", "0.57396275", "0.5739036", "0.5730807", "0.5706342", "0.56984943", "0.5690808", "0.56799626", "0.56742144", "0.567107", "0.5667482", "0.5667482", "0.5667177", "0.56460994", "0.5612582", "0.5606637", "0.5597139", "0.55957377", "0.557334", "0.5573215", "0.557108", "0.55648357", "0.5563183", "0.5541984", "0.5524378", "0.5509932", "0.55093735", "0.5487572", "0.54820836", "0.5477042", "0.5473147", "0.54696333", "0.5463247", "0.54584044", "0.54584044", "0.54566675", "0.5456178", "0.54491127", "0.5443567", "0.54401845", "0.5438552", "0.5432209" ]
0.6825189
4
Link_to with active class if current_page
def nav_link_to(text, url, options = {}) is_active = url_for(url.split("#")[0], relative: false) == url_for(current_page.url, relative: false) options[:class] ||= "" options[:class] << " active" if is_active link_to(text, url, options) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def link_to_if_current(text, page, active_class: \"active\")\n if page == current_page\n link_to text, page.request_path, class: active_class\n else\n link_to text, page.request_path\n end\n end", "def nav_link_to(link, url, opts={})\n if current_resource.url == url_for(url)\n opts[:class] << \" active\"\n end\n link_to(link, url, opts)\n end", "def active_class(link_path)\n current_page?(link_path) ? 'active' : ''\n end", "def active_class(link_path)\n current_page?(link_path) ? \"active\" : \"\"\n end", "def active_class(link_path)\n active = current_page?(link_path) ? \"active\" : \"no-active\"\n end", "def active_class(link_path)\n active = current_page?(link_path) ? \"active\" : \"no-active\"\n end", "def active_link_to(*args, &block)\n if block_given?\n active_link_to(capture(&block), args.first || {}, args.second)\n else\n active = false\n html_options = args.third || {}\n active_paths = html_options.delete(:active_paths)\n active_controllers = html_options.delete(:active_controllers)\n if active_paths.nil? && active_controllers.nil?\n active = true if request.fullpath == args.second\n else\n active_paths.to_a.each do |url_object|\n next if url_object.nil?\n next if url_object.respond_to?(:second) && !url_object.try(:second).try(:persisted?)\n active = request.path == url_for(url_object)\n break if active\n end\n active_controllers.to_a.each do |controller|\n active = params[:controller] == controller.to_s\n break if active\n end\n end\n content_tag :li, active ? { class: 'active' } : nil do\n link_to(*args)\n end\n end\n end", "def link_class(url)\n return 'nav-item' unless current_page?(url)\n\n 'nav-item current'\n end", "def active_link_to(text = nil, path = nil, **opts, &block)\n link = block ? text : path # because positional\n content = block ? capture(&block) : text\n opts[:class] = class_names(opts[:class], { active: current_page?(link) })\n\n link_to(link, opts) { content }\n end", "def nav_link_to(link_text, link)\n if current_page?(link)\n link_to link_text, link, class: \"active\"\n else\n link_to link_text, link\n end\n end", "def css_class\n (page.link_to.split('/')[1] == @href.split('/')[1] || page.link_to?(@href)) && \"active\"\n end", "def nav_link(text, route)\n content_tag(:li, class: current_page?(route) ? \"active\" : \"\") do\n link_to text, route\n end\n end", "def current_page_link(path)\n \"current-page\" if current_page?(path)\n end", "def link_to_with_current name, options = {}, html_options={}\n dup_options = html_options.dup\n \n if current_page?(options)\n dup_options[:class] = \"current\"\n end\n\n link_to name, options, dup_options\n end", "def link_actived?(link_path)\n \"active\" if current_page?(link_path)\n end", "def is_active?(link_path)\n current_page?(link_path) ? \"active\" : \"\"\n end", "def is_active?(link_path)\n if current_page?(link_path)\n 'active'\n else\n ''\n end\n end", "def active_link_to_class(url, options = {})\n if is_active_link?(url, options[:active])\n options[:class_active] || 'active'\n else\n options[:class_inactive] || ''\n end\n end", "def active? path \n \"active\" if current_page? path\n end", "def nav_link(text, link)\n recognized = Rails.application.routes.recognize_path(link)\n if recognized[:controller] == params[:controller] && recognized[:action] == params[:action]\n content_tag(:li, :class => \"active\") { link_to( text, link ) }\n else\n content_tag(:li) { link_to( text, link ) }\n end\n end", "def active? path\n \"active\" if current_page? path\n end", "def active? path\n \"active\" if current_page? path\n end", "def active_navbar_class(page_path)\n current_page?(page_path) ? \"active\" : \"\"\n end", "def menu_link_to(text, options = {}, html_options = {})\n if (options[:controller] == controller.controller_name && options[:action] == controller.action_name)\n html_options['class'] = 'UbcCurrent'\n end\n link_to(text, options, html_options)\n end", "def menu_link_to(name,path,options={})\n style = \"page_item\"\n style = \"current_page_item\" if current_page?(path)\n options.merge!( { :class => \"#{style} btn btn-small\" } )\n link_to( name, path, options )\n end", "def active_in_page(path)\n \"active\" if current_page?(path)\n end", "def active_navigation(link_path)\n\t current_page?(link_path) ? 'active' : ''\n\tend", "def top_link_for(label, page)\n if page && page.root.slug == label.parameterize\n link_to label, page_path(label.parameterize), class: \"top-active\"\n else\n link_to_unless_current label, page_path(label.parameterize) do\n link_to label, \"#\", class: \"top-active\"\n end\n end\n end", "def link_with_active(text, url)\n if url == \"/\" then\n if request.fullpath == \"/\" then\n return link_to text, url, :id => \"selected_main_tab\"\n else\n return link_to text, url\n end\n else\n if request.fullpath.include? url then\n return link_to text, url, :id => \"selected_main_tab\"\n else\n return link_to text, url\n end\n end\n end", "def nav_link(text, path)\n if current_page? path\n content_tag :li, class: 'active' do\n\n # <span class=\"sr-only\">(current)</span> required for Screen Readers\n link_to path do\n concat text\n concat content_tag :span, '(current)', class: 'sr-only'\n end\n end\n else\n content_tag :li do\n link_to text, path\n end\n end\n end", "def tab(body, url_options, html_options = {})\n if current_page?(url_options)\n html_options[:class] ||= ''\n html_options[:class] << ' active'\n end\n link_to body, url_options, html_options\n end", "def is_active?(link_path)\n\t if current_page?(link_path)\n\t \"active\"\n\t else\n\t \"\"\n\t end\n end", "def navigation_link_to(txt, url)\n\t\tpage_index = request[\"path\"].gsub(\"index.html\",\"\")\n\t\t\n\t\tif url == \"/#{page_index}\"\n\t\t\treturn link_to(txt, url, :class => \"active\")\n\t\tend\n\t\tlink_to(txt,url)\n\tend", "def nav_link_class(controller_name)\n controller?(controller_name) ? 'active' : 'passive'\n end", "def active_link_to(name = nil, options = nil, html_options = nil, &block)\n # this is from Rails source - ignore rubocop\n # rubocop:disable Style/ParallelAssignment\n html_options, options, name = options, name, block if block_given?\n options ||= {}\n # rubocop:enable Style/ParallelAssignment\n\n html_options = convert_options_to_data_attributes(options, html_options)\n\n url = url_for(options)\n html_options[\"href\".freeze] ||= url\n\n # Begin custom\n active_children = html_options.delete('active_children')\n active_children = true if active_children.nil?\n current_url = request.env['PATH_INFO']\n if current_page?(url) || (active_children && current_url.include?(url))\n active_class = html_options.delete('active_class') || 'active'\n existing_class = html_options['class'] || ''\n html_options['class'] = existing_class + ' ' + active_class\n end\n # End custom\n\n content_tag(\"a\".freeze, name || url, html_options, &block)\n end", "def nav_link(text, *paths)\n attrs = paths.any? { |p| current_page?(p) } ? { :class => \"active\" } : {}\n content_tag(:li, attrs) { link_to text, paths.first }\n end", "def nav_active(path)\n (current_page.path.start_with? path) ? \"active\" : \"\"\n end", "def nav_link(link_text, link_path)\n class_name = current_page?(link_path) ? 'active' : ''\n\n content_tag(:li, :class => class_name) do\n link_to link_text, link_path\n end\n end", "def nav_link(link_text, link_path)\n recognized = Rails.application.routes.recognize_path(link_path)\n class_name = recognized[:controller] == params[:controller] ? 'active' : ''\n content_tag(:li, class: class_name) do\n link_to link_text, link_path\n end\n end", "def nav_link(section, href, content)\n attributes = {\n :class => ['nav-link'],\n :href => site_url(href),\n }\n attributes[:class].push('active') if (attr 'site-section') == section\n html_tag('a', attributes, content)\n end", "def admin_nav_link(controller, url = false, selected_url = false)\n controller_name = controller.gsub(/ /, \"_\").downcase.pluralize\n url = \"/admin/#{controller_name}\" unless url\n\n css = nil\n if selected_url && request.env['REQUEST_URI'] =~ /#{selected_url}/\n css = \"active\"\n elsif request.env['REQUEST_URI'] =~ /#{url}/\n css = \"active\"\n end\n content_tag(:li, link_to(controller, url), class: css, id: \"admin-nav-#{controller_name.dasherize}\")\n end", "def nav_link_to(text, path)\n\t\t\tlink_to_unless_current text, path do\n\t\t\t\tlink_to text, '#', :class => 'current'\n\t\t\tend\n\t\tend", "def nav_active(url)\n active_nav_class = \"current\"\n\n if (url.instance_of? String)\n current_resource.url == url_for(url) ? {class: active_nav_class} : {}\n elsif (url.instance_of? Array)\n url.map { |url| url_for(url) }.include?(current_resource.url) ? {class: active_nav_class} : {}\n else\n {}\n end\n end", "def menu_link_to(text, url, options={}, current=nil)\n content_tag :li, link_to(text, url, options), :class => (current.nil? ? part_of_current_url?(url) : current) ? 'current' : nil\n end", "def site_page_navigation_item(text, path, link_html_opts={}, li_html_opts={})\n li_class = current_page?(path) ? \"active\" : \"\"\n content_tag :li, li_html_opts.merge(:class=>li_class) do\n link_to text.html_safe, path, link_html_opts\n end\n end", "def is_active?(current_page)\n return \"is-active\" if params[:controller] == current_page.to_s\n end", "def active_link(text,link)\n content_tag(:li) do\n link_to text, link, :class => 'active', remote: true\n end\n end", "def is_active?(current_page)\n return \"is-active is-primary\" if params[:controller] == current_page.to_s\n end", "def active_class(link_path)\n if request_path_active?(link_path)\n \"active\"\n else\n \"\"\n end\n rescue ActionController::UrlGenerationError\n \"\"\n end", "def nav_link(text, link, options = {})\n #controller, action=\"index\", show_link=true , css_class='')\n options.reverse_merge! :li_class => '', :show_link => true, :a_class => ''\n if current_page?(link)\n if options[:show_link]\n \"<li class=\\\"current #{options[:li_class]}\\\">#{link_to text, link, :class => options[:a_class]}</li>\"\n else\n \"<li class=\\\"current #{options[:li_class]}\\\">#{text}</li>\"\n end\n else\n \"<li class=\\\"#{options[:li_class]}\\\">#{link_to text, link, :class => options[:a_class]}</li>\"\n end\n end", "def active_path?(href, current_path = \"\")\n href == get_path(current_path)\n end", "def nav_link(*args)\n class_names = \"button\"\n class_names = \"#{class_names} #{args[2][:class]}\" if args.length >= 3\n content_tag(:li, active_link_to(args[0] , args[1] , :title => args[0]), :class => class_names)\n end", "def activepage?(path)\n \t\t\"active\" if current_page?(path)\n \tend", "def nav_link(text, path, link_args={})\n if path.kind_of? Array\n current = path.any? do |p|\n current_page?(p)\n end\n path = path[0]\n else\n current = current_page?(path)\n end\n\n link_args[:class] = \"#{current ? 'active' : ''} nav-link #{link_args[:class] || ''}\"\n\n content_tag(:li, link_to(text, path, link_args), class: \"nav-item\")\n end", "def tab_link_to(name, options = {}, html_options = {})\n html_options.merge!({ :class => 'current_tab' }) if current_page?(options)\n link_to name, options, html_options\n end", "def active_class(url, options = {})\n if is_active_link?(url, options)\n options[:active_class] || 'active'\n else\n options[:inactive_class] || ''\n end\n end", "def is_active?(link_path)\n link_path.include?(request.path) ? \"active\" : \"\"\n end", "def is_active?(link_path)\n link_path.include?(request.path) ? \"active\" : \"\"\n end", "def nav_link(link_text, link_path)\n class_name = current_page?(link_path) ? 'current' : ''\n\n # Playlists and Tags routes should also trigger highlighting of the Watch Ignite Videos menu item\n current_uri = request.env['PATH_INFO']\n if ['/tags','/playlists'].include? current_uri and link_path == '/videos'\n class_name = 'current'\n end\n\n content_tag(:li, :class => class_name) do\n link_to link_text, link_path\n end\n end", "def nav(name=\"\", path=root_path, active='')\n active_class = active == controller.controller_name ? 'activelink' : ''\n markaby do #=> Markaby template.\n li :class => active_class do\n link_to(name, path)\n end\n end\n end", "def item title, link\n unless current_page? link\n content_tag :li, link_to(title, link)\n else\n content_tag(:li, :class => :active){\n content_tag :strong, title\n }\n end\n end", "def nav_link_to(label, path, opts = {})\n if @_nav_mode == :dropdown # We insert dropdown-items\n return link_to(label, path, merge_class_key(opts, 'dropdown-item'))\n end\n\n strict = opts.delete(:strict)\n active = (strict ? (request.fullpath == path) : request.fullpath.include?(path))\n\n # Regular nav link item\n content_tag(:li, class: (active ? 'nav-item active' : 'nav-item')) do\n link_to(label, path, merge_class_key(opts, 'nav-link'))\n end\n end", "def link_selected(link_path)\n current_controller = params[:controller]\n if current_controller == \"pages\"\n current_page?(link_path)\n else\n link_controller = \"\"\n begin\n link_controller = Rails.application.routes.recognize_path(link_path)[:controller]\n rescue ActionController::RoutingError\n end\n current_controller == link_controller\n end\n end", "def is_page_active(page)\n current_page.url == page\n end", "def top_nav_item(link_text, link_opts, html_opts={})\n css_class = html_opts[:class] || \"\"\n css_class = (css_class.split(/\\s+/)+[\"active\"]).join(\" \") if current_page?(link_opts)\n html_opts[:class] = css_class\n content_tag :li, html_opts do\n link_to(link_text, link_opts)\n end\n end", "def navigation_menu(i18n_path, controller_paths, link_to_path, options={})\n code = '<li class=\"'\n code += 'active ' if is_menu_active? controller_paths\n code += 'first ' if options[:first]\n code += \"\\\">\\n\"\n code += link_to(I18n::t(i18n_path), link_to_path) + \"\\n\"\n code += \"</li>\\n\"\n\n code\n end", "def nav_class_for_controller(*controller)\n is_active = controller.include?(params[:controller])\n is_active ? \"active\" : \"\"\n end", "def is_current(page)\n if controller.controller_name == page\n 'class=current'\n end\n end", "def active_link_class(item)\n active_class = 'active_menu_link'\n found = false\n case item.class.to_s\n when 'Project'\n found = true if (@project && @project == item) && (@stage.blank?)\n when 'Host'\n found = true if @host && @host == item\n when 'Recipe'\n found = true if @recipe && @recipe == item\n when 'User'\n found = true if @user && @user == item\n when 'Stage'\n found = true if @stage && @stage == item\n end\n \n if found\n active_class\n else\n ''\n end\n end", "def navigation_link_to(name, options = {}, html_options = {})\n if current_page?(options)\n content_tag(\"span\", name)\n else\n link_to name, options, html_options\n end\n end", "def link_to_nav(name, url)\n path = request.path\n current = false\n\n # path - url\n # docs/index.html - /docs/index.html\n # docs/index.html - /docs\n # docs/quickstart/dashboard - /docs\n\n # Strip leading / from the url\n testUrl = url[1..-1]\n\n\n if testUrl == path\n # Exact match\n current = true\n elsif path.start_with? testUrl\n # starts with match\n current = true\n end\n\n if current\n link_to name, url, :class => \"active\"\n else\n link_to name, url\n end\n end", "def active_page(active_page)\n @active == active_page ? \"active\" : \"\"\n end", "def active_page(active_page)\n @active == active_page ? \"active\" : \"\"\n end", "def active_page(active_page)\n @active == active_page ? \"active\" : \"\"\n end", "def nav_link(text,controller,action=\"index\")\n link_to_unless_current text,:id=>nil,:controller=>controller,:action=>action\n end", "def section_link(name,options)\n if options[:action].include?(@current_action) && options[:controller] == @current_controller\n link_to(name, \"/\"+ options[:url], :class => 'current')\n else\n link_to(name, \"/\"+ options[:url])\n end\n end", "def nav_link_controller(text, controller)\n return link_to_unless_current(text, {:controller => controller})\n end", "def draw_link(href, label, current_path = \"\")\n active = active_path?(href, current_path)\n\n l = \"<li\"\n l += active ? ' class=\"active\">' : \">\"\n l += %Q(<a href=\"#{href}\">#{label})\n l += active ? ' <span class=\"sr-only\">(current)</span>' : \"\"\n l += \"</a></li>\"\n end", "def nav_link(text,controller,action=\"index\")\n\t\t\tlink_to_unless_current text,:controller=>controller,:action=>action\n\t\tend", "def active_class(rendered_page, current_page)\n if rendered_page[:shortname] == current_page[:shortname]\n return 'active'\n elsif (current_page.page_type == \"country\" && !current_page.parent.nil? && rendered_page[:shortname] == current_page.parent[:shortname])\n return 'active'\n end\n return '' \n end", "def tab_to(name, all_options = nil)\n url = all_options.is_a?(Array) ? all_options[0].merge({:only_path => false}) : \"#\"\n\n current_url = url_for(:action => @current_action, :only_path => false)\n html_options = {}\n\n if all_options.is_a?(Array)\n all_options.each do |o|\n if url_for(o.merge({:only_path => false})) == current_url\n html_options = {:class => \"current\"}\n break\n end\n end \n end\n\n link_to(name, url, html_options)\n end", "def nav_link(text, controller, action=\"index\")\n return link_to_unless_current(text, {:controller => controller,\n :action => action} )\n end", "def active?(controller_name)\n if params[:controller] == controller_name\n ' class=\"active\" '\n end\n end", "def nav_link(link_text, icon_text, link_path)\n\t\tclass_name = current_page?(link_path) ? 'current' : ''\n\n\t\tcontent_tag(:li, :class => class_name) do\n\t\t\tlink_to \"#{icon(icon_text)} <span>#{link_text}</span>\".html_safe, link_path\n\t\tend\n\tend", "def tab_to(name, all_options = nil)\n url = all_options.is_a?(Array) ? all_options[0].merge({:only_path => false}) : \"#\"\n\n current_url = url_for(:action => @current_action, :only_path => false)\n html_options = {}\n\n if all_options.is_a?(Array)\n all_options.each do |o|\n if url_for(o.merge({:only_path => false})) == current_url\n html_options = {:class => \"current\"}\n break\n end\n end\n end\n link_to(name, url, html_options)\n end", "def tab_to(name, all_options = nil)\n url = all_options.is_a?(Array) ? all_options[0].merge({:only_path => false}) : \"#\"\n current_url = url_for(:action => @current_action, :only_path => false)\n html_options = {}\n\n if all_options.is_a?(Array)\n all_options.each do |o|\n if url_for(o.merge({:only_path => false})) == current_url\n #html_options = {:class => \"current\"}\n name = \"<span class = 'current'> #{name} </span>\"\n break\n end\n end\n end\n link_to(name, url, html_options)\n end", "def nav_link(text, action=\"index\", controller)\n\t\treturn link_to_unless_current text, :id => nil, :controller => controller, :action => action\n\tend", "def tab_to(name, all_options = nil)\n url = all_options.is_a?(Array) ? all_options[0].merge({:only_path => false}) : \"#\"\n\n current_url = url_for(:action => @current_action, :only_path => false)\n html_options = {}\n\n if all_options.is_a?(Array)\n all_options.each do |o|\n if url_for(o.merge({:only_path => false})) == current_url\n html_options = {:class => \"current\"}\n break\n end\n end\n end\n\n link_to(name, url, html_options)\n end", "def nav(name, url, pages = nil, active = false)\n content_tag :li, link_to(name, url), :class => (active || (pages && active_page?(pages)) ? 'act' : nil)\n end", "def current_class?(test_path)\n if request.path == test_path\n return \"nav-button-active\"\n else \n return \"nav-button\"\n end\n end", "def active(basename)\n basename == Pathname.new(current_page.destination_path).basename.to_s.sub(/\\..*/, '') ? {'class' => 'ui-btn-active'} : {}\n end", "def nav_link(text, controller, action=\"index\", id=nil)\n link_to_unless_current text, :id => nil, :controller => controller, :action => action, :id => id\n end", "def active_tag(name, url, content = nil, options = nil, &block)\n if block_given?\n options = content if content.is_a?(Hash)\n content = capture_html(&block)\n end\n\n if is_active_page?(url)\n options ||= {}\n active_class = 'active'\n\n if options[:class].nil?\n options[:class] = active_class\n else\n options[:class] += \" #{active_class}\"\n end\n end\n\n content_tag(name, content, options, &block)\n end", "def main_nav_link_helper(role,link_id,link_text,link_title,link_details)\n if has_role?(role)\n (\"<li id='#{link_id}'#{\" class='active'\" if main_nav_guess_current == link_id}>\" +\n link_to(link_text, link_details, :title => link_title) +\n \"</li>\").html_safe\n else\n \"\"\n end\n end", "def active_nav\n @active = \"user\"\n end", "def navigation_helper(label, link_path, link_opts={})\n li_opts = {}\n li_opts = request.path.eql?(link_path) ? { class: \"selected\" } : {}\n content_tag(:li, link_to(label, link_path, link_opts), li_opts)\n end", "def active_tab_class(*paths)\n active = false\n # originally used current_page? but it did not work when update button was called.\n paths.each { |path| active ||= path == request.path }\n active ? 'active' : ''\n end", "def current_path(path)\n \"green\" if current_page?(path)\n end", "def aboutusActive?(page_title)\n 'class=\"active\"' if page_title == \"About Us\"\n end", "def nav_link(text, options)\n link_to_unless_current text, options\n end" ]
[ "0.86151206", "0.8035615", "0.7871288", "0.77930945", "0.7607686", "0.7607686", "0.7537126", "0.7535651", "0.75335747", "0.7404182", "0.73309106", "0.7302635", "0.7293621", "0.72701323", "0.7182329", "0.7123731", "0.7111835", "0.7102652", "0.7099457", "0.70991486", "0.70869106", "0.70869106", "0.7085722", "0.7036481", "0.7008154", "0.70035344", "0.6982781", "0.69810677", "0.69311357", "0.6925084", "0.69017065", "0.6876681", "0.68623793", "0.6848956", "0.68440276", "0.68266606", "0.68068284", "0.6794879", "0.67189693", "0.67179817", "0.6672583", "0.66707826", "0.66523254", "0.6625801", "0.66093457", "0.6594164", "0.65823925", "0.6580334", "0.65792435", "0.656058", "0.6548427", "0.6546283", "0.6534614", "0.6534214", "0.649319", "0.6478961", "0.64636874", "0.64636874", "0.6458675", "0.64472044", "0.64368105", "0.6423779", "0.6394004", "0.638237", "0.637817", "0.63576347", "0.63210654", "0.6300363", "0.6271044", "0.6233757", "0.62259793", "0.6222329", "0.6222329", "0.6222329", "0.6216114", "0.6210901", "0.619133", "0.61689633", "0.6156342", "0.6134455", "0.61099225", "0.6100052", "0.60805386", "0.6078897", "0.60376304", "0.60320336", "0.6015796", "0.6007633", "0.59890777", "0.5987246", "0.59628516", "0.59577346", "0.5955723", "0.5946547", "0.5936393", "0.58827734", "0.5863074", "0.5842228", "0.5840283", "0.583145" ]
0.74980676
9
Use callbacks to share common setup or constraints between actions.
def set_article @article = Article.find(params[:article_id]) render json: { error: 'not found' }, status: 404 if @article.nil? 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
extended data janitor model validations that apply data_janitor audit purposes
def dj_audit_validations(&block) with_options(on: [:dj_audit], &block) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def validation; end", "def validation; end", "def extra_validations\n success\n end", "def pre_validation\n\n\n end", "def validate\n \n \n end", "def validate; end", "def validate; end", "def validate; end", "def validate; end", "def pre_validation\n\n end", "def validator; end", "def subclass_validations ; true ; end", "def validated; end", "def validate\n\n end", "def validate\r\n\r\n end", "def custom_validations\n self.validate_baseline && validate_baseline_date && \n self.validate_trial_days && self.validates_goal_name && self.validation_due_date\n end", "def validate_on_create; end", "def validate\n end", "def validate\n end", "def validate\n end", "def validate\n # add errors if not validate\n end", "def validate!; end", "def validate!; end", "def validate!; end", "def validated_data\n @schema.validate(@data)\n end", "def validate_event; end", "def validate\n end", "def validate\n end", "def validate\n end", "def validate\n end", "def validate_data\n #first remove any old errors from the table\n self.dataerrors.clear\n \n @s = [] \n # check the necessary fields in the table\n # use the build method so the polymorphic reference is generated cleanly\n # check for the relationships t other tables\n if self.rate_id.blank? && self.rate_override.blank?\n @s.push self.dataerrors.build(:message => \"A rate or override rate must be entered\", :created_user => self.created_user) \n end\n \n #if there are errors, save them to the dataerrors table and return false\n if @s.count > 0\n Dataerror.store(@s) \n return false\n end\n #everything is good, return true\n return true\n end", "def validate\n super \n end", "def validate(vmode=nil)\n # Holding pattern. All models should use super, in principal\n end", "def validated?; end", "def valid_before; end", "def validate_on_create=(_arg0); end", "def is_valid; end", "def validate_data\n @state = true\n #store the original error count, if there is a chnage to the count, then we want to update all associated insurance_billings and balance_bills\n @original_count = self.dataerrors.count\n #first remove any old errors from the table\n self.dataerrors.clear\n\n @s = []\n # check the necessary fields in the table\n # use the build method so the polymorphic reference is generated cleanly\n @s.push self.dataerrors.build(:message => \"Provider first name is blank\", :created_user => self.created_user) if self.first_name.blank?\n @s.push self.dataerrors.build(:message => \"Provider last name is blank\", :created_user => self.created_user) if self.last_name.blank?\n @s.push self.dataerrors.build(:message => \"Provider NPI is required\", :created_user => self.created_user) if self.npi.blank?\n #either the ein or ssn is required\n @s.push self.dataerrors.build(:message => \"EIN or SSN is required\", :created_user => self.created_user) if self.ssn_number.blank? && self.ein_number.blank?\n @s.push self.dataerrors.build(:message => \"Office phone is required\", :created_user => self.created_user) if self.office_phone.blank?\n\n #if there are errors, save them to the dataerrors table and return false\n if @s.count > 0\n Dataerror.store(@s)\n @state = false\n end\n #if the error counts changed, then update all insurance_bill & balance bills\n if @original_count != @s.count\n self.insurance_billings.each { |billing| billing.validate_claim }\n # need to rethink the validate\n # self.balance_bill_sessions.each { |balance| balance.validate_balance_bill }\n end\n return @state\n end", "def run_validations\n true\n end", "def validate_data\n @state = true\n #store the original error count, if there is a chnage to the count, then we want to update all associated insurance_billings and balance_bills\n @original_count = self.dataerrors.count\n #first remove any old errors from the table\n self.dataerrors.clear\n\n @s = []\n # check the necessary fields in the table\n # use the build method so the polymorphic reference is generated cleanly\n @s.push self.dataerrors.build(:message => \"Group name is blank\", :created_user => self.created_user) if self.group_name.blank?\n @s.push self.dataerrors.build(:message => \"Office phone number is required\", :created_user => self.created_user) if self.office_phone.blank?\n @s.push self.dataerrors.build(:message => \"EIN number is required\", :created_user => self.created_user) if self.ein_number.blank?\n @s.push self.dataerrors.build(:message => \"NPI is required for group\", :created_user => self.created_user) if self.npi.blank?\n\n #if there are errors, save them to the dataerrors table and return false\n if @s.count > 0\n Dataerror.store(@s)\n @state = false\n end\n #if the error counts changed, then update all insurance_bill & balance bills\n if @original_count != @s.count\n self.insurance_billings.each { |billing| billing.validate_claim }\n #self.balance_bills.each { |balance| balance.validate_balance_bill }\n end\n return @state\n end", "def _before_validation\n end", "def validate_on_create #:doc:\n end", "def validate_essential_attributes #:nodoc:\n if @month.to_i.zero? || @year.to_i.zero?\n errors.add :month, \"is required\" if @month.to_i.zero?\n errors.add :year, \"is required\" if @year.to_i.zero?\n else\n errors.add :month, \"is not a valid month\" unless valid_month?(@month)\n errors.add 'card', \"has expired\" if expired?\n errors.add :year, \"is not a valid year\" unless valid_expiry_year?(@year)\n end\n end", "def validate!\n validator.validate(data: data, schema: schema, logger: validation_logger)\n end", "def validate\n super\n end", "def run_validations!\n run_callbacks(:validation) do\n super\n end\n end", "def model_valid?\n true\n end", "def model_valid?\n true\n end", "def after_validate\n end", "def validate_on_update # :doc:\n end", "def extended_validator\n notify_observers(:validate_application)\n end", "def set_validations_and_filters\n validates_length_of :numero_publicacion, :in => 6..12, :allow_nil => true, :allow_blank => true\n validates_presence_of :fecha_solicitud, :numero_gaceta\n validates_format_of :numero_solicitud, :with => /^\\d+-\\d{4}/\n validates_uniqueness_of :numero_solicitud#, :scope => :parent_id\n #validates_presence_of :numero_publicacion, :numero_gaceta\n end", "def should_validate\n validation_trigger\n end", "def validatable?\n true\n end", "def validate\n begin\n validatable_rules.map{ |k, v| self.send(\"validate_\" + k.to_s) }\n rescue Errors::ValidationError => e\n raise decorate_error e\n end\n end", "def add_validation_errors(value); end", "def validate\n validate_summary\n validate_duration\n validate_kind\n validate_state\n validate_created_at\n\n super\n end", "def validations_for_diff\n []\n end", "def validate\r\n @invalid=false\r\n end", "def validate_data\n @state = true\n #store the original error count, if there is a chnage to the count, then we want to update all associated insurance_billings and balance_bills\n @original_count = self.dataerrors.count\n #first remove any old errors from the table\n self.dataerrors.clear\n\n @s = []\n # check the necessary fields in the table\n # use the build method so the polymorphic reference is generated cleanly\n @s.push self.dataerrors.build(:message => \"Insurance Company name is required\", :created_user => self.created_user) if self.name.blank?\n @s.push self.dataerrors.build(:message => \"Payor ID is required\", :created_user => self.created_user) if self.insurance_co_id.blank?\n @s.push self.dataerrors.build(:message => \"An Address is required\", :created_user => self.created_user) if self.address1.blank?\n @s.push self.dataerrors.build(:message => \"A city is required as part of the address\", :created_user => self.created_user) if self.city.blank?\n @s.push self.dataerrors.build(:message => \"The state is required as part of the address\", :created_user => self.created_user) if self.state.blank?\n @s.push self.dataerrors.build(:message => \"The zip code is required\", :created_user => self.created_user) if self.zip.blank?\n\n #if there are errors, save them to the dataerrors table and return false\n if @s.count > 0\n Dataerror.store(@s)\n @state = false\n end\n # if the error counts changed, then update all subsciber and provider_insurance records\n # they will in turn re-validate and update insurance_billing && balance_bill records\n if @original_count != @s.count\n self.subscribers.each { |subscribe| subscribe.validate_data }\n self.provider_insurances.each { |provide| provide.validate_data }\n end\n return @state\n end", "def check_updated_course_data_validity(course_data)\n schema = {\n 'type' => 'object',\n 'required' => %w(Name Code StartDate EndDate IsActive),\n 'properties' => {\n 'Name' => { 'type' => 'string' },\n 'Code' => { 'type' => 'string' },\n 'StartDate' => { 'type' => %w(string null) },\n 'EndDate' => { 'type' => %w(string null) },\n 'IsActive' => { 'type' => 'boolean' }\n }\n }\n JSON::Validator.validate!(schema, course_data, validate_schema: true)\nend", "def validate\n @invalid=false\n end", "def valid; end", "def validate!\n # pass\n end", "def validate_build\n end", "def before_validation() \n #logger.info \"Tend: #{tend} // class: #{tend.class}\"\n self.published = true unless attribute_present?(\"published\") # pubblicato: yes\n self.starred = false unless attribute_present?(\"starred\") # starred: no\n #ric_change_parameter('starred',false)\n #self.birthday = Date.civil(1901,1,1) unless attribute_present?(\"birthday\") # compleanno 1gen1901\n self.nickname = _fake_nickname unless attribute_present?(\"nickname\") # i.e. 'rcarlesso'\n self.created_by ||= current_user.name rescue \"ModelCreatedBy: #{$!}\"\n self.updated_by = current_user.name rescue \"Probably Updated from shell and not from web: ''#{$!}''\"\n if (attribute_present?(\"organisation\") && ! attribute_present?(\"work_venue_id\") ) # --> autocreate workplace obj from string! Cool!\n self.work_venue = Venue.find_or_create_by_name(organisation.strip) rescue nil\n end\n if (attribute_present?(\"location\") && ! attribute_present?(\"venue_id\") ) # --> autocreate workplace obj from string! Cool!\n self.venue = Venue.find_or_create_by_name(location.strip) rescue nil\n end\n self.relevance = 42 unless attribute_present?(\"relevance\") # rilevanza 42\n # NON HO ACCESSO AL CURRENTUSER DA QUI! SOLO VIEW E CONTROLLER!!!\n #self.feed = \"Person:_:BeforeValidation(): person changed by ''#{@current_user rescue 'BOH'}'' on #{Time.now}\" unless attribute_present?(\"feed\") \n #self.nickname = self.nickname.nicknamize rescue nil # minuscolizza e toglie spazi\n self.email = self.email.strip if attribute_present?(\"email\")\n end", "def valid_after; end", "def validate_associated_records_for_notifications; end", "def apply_validations_for_date\n flex_column_class.validates_each field_name do |record, attr, value|\n record.errors.add(attr, \"must be a Date\") if value && (! value.kind_of?(Date))\n end\n end", "def valid_data_on_creation?\n valid_data_on_creation\n end", "def validate\n validate_amount\n validate_game\n validate_period\n end", "def validator=(_); end", "def before_validation_callback\n end", "def accounting_validation_state\n super\n end", "def validate_field_without_promotion\n return unless @designation_history.prev_designation_id.nil?\n begin\n if (@designation_history.new_designation_id != params[:designation_id].to_i) and (@designation_history.applicable_from == params[:designation_history][:applicable_from].to_date)\n flash.now[:error]= l(:designation_not_update_error)\n elsif (@designation_history.applicable_from != params[:designation_history][:applicable_from].to_date) and (@designation_history.new_designation_id == params[:designation_id].to_i)\n flash.now[:error] = l(:desgination_applicable_from_error)\n end\n rescue\n flash.now[:error] = l(:proper_date_error_message)\n end \n render 'systango_hrm_employees/edit' unless flash.now[:error].blank?\n end", "def validations\n {}\n end", "def validate \n#\tfirst check whether combo fields have been selected\n\t is_valid = true\n\t if is_valid\n\t\t is_valid = ModelHelper::Validations.validate_combos([{:mark_code => self.mark_code}],self) \n\tend\n\t#now check whether fk combos combine to form valid foreign keys\n\t if is_valid\n\t\t is_valid = set_mark\n\t end\n\t if is_valid\n\t\t is_valid = ModelHelper::Validations.validate_combos([{:short_description => self.short_description}],self) \n\tend\n\t#now check whether fk combos combine to form valid foreign keys\n\t if is_valid\n\t\t is_valid = set_organization\n\t end\n\t#validates uniqueness for this record\n\t if self.new_record? && is_valid\n\t\t validate_uniqueness\n\t end\nend", "def validate\n true\n end", "def validate\n raise NoMethodError, \"must define method 'validate'\"\n end", "def validate_data\n @state = true\n #store the original error count, if there is a chnage to the count, then we want to update all associated insurance_billings and balance_bills\n @original_count = self.dataerrors.count\n #first remove any old errors from the table\n self.dataerrors.clear\n\n @s = []\n # check the necessary fields in the table\n # use the build method so the polymorphic reference is generated cleanly\n @s.push self.dataerrors.build(:message => \"An Address is required\", :created_user => self.created_user) if self.address1.blank?\n @s.push self.dataerrors.build(:message => \"A city is required as part of the address\", :created_user => self.created_user) if self.city.blank?\n @s.push self.dataerrors.build(:message => \"The state is reuqired as part oof the address\", :created_user => self.created_user) if self.state.blank?\n @s.push self.dataerrors.build(:message => \"The zip code is required\", :created_user => self.created_user) if self.zip.blank?\n @s.push self.dataerrors.build(:message => \"Office phone number is required\", :created_user => self.created_user) if self.office_phone.blank?\n\n #if there are errors, save them to the dataerrors table and return false\n if @s.count > 0\n Dataerror.store(@s)\n @state = false\n end\n\n #if the error counts changed, then update all insurance_bill & balance bills\n if @original_count != @s.count\n self.insurance_sessions.each { |session| session.validate_data }\n end\n return @state\n end", "def timeliness_validation_for(attr_names, type)\n super\n attr_names.each { |attr_name| define_timeliness_write_method(attr_name) }\n end", "def valid_attributes\n {\n :name => \"my dashboard\",\n :data => 'new data',\n :scale => false,\n :is_public => false\n }\n end", "def validates_allowed_transitions(field, alloweds)\n validates_each(field) do |record, attr, value|\n if !record.new_record? && record.send(\"#{attr}_changed?\")\n\n# PB SAFE just does field validation\ncanvas-lms validates_each canvas-lms/lib/custom_validations.rb:36\n def validates_as_readonly(*fields)\n validates_each(fields) do |record, attr, value|\n if !record.new_record? && record.send(\"#{attr}_changed?\")\n record.errors.add attr, \"cannot be changed\"\n end\n end\n end\n\n # alloweds is a hash of old_value => [new_value]\n # on update, only those transitions will be allowed for the given field\n def validates_allowed_transitions(field, alloweds)\n validates_each(field) do |record, attr, value|\n if !record.new_record? && record.send(\"#{attr}_changed?\")\n old_val = record.send(\"#{attr}_was\")\n unless alloweds.any? { |old,news| old_val == old && Array(news).include?(value) }\n record.errors.add attr, \"cannot be changed to that value\"\n end\n end\n end\n end\n end\n\n def self.included(klass)\n if klass < ActiveRecord::Base\n klass.send :extend, ClassMethods\n\n# PB SAFE just does field validation\ncanvas-lms validates_each canvas-lms/lib/custom_validations.rb:46\n def validates_allowed_transitions(field, alloweds)\n validates_each(field) do |record, attr, value|\n if !record.new_record? && record.send(\"#{attr}_changed?\")\n old_val = record.send(\"#{attr}_was\")\n unless alloweds.any? { |old,news| old_val == old && Array(news).include?(value) }\n record.errors.add attr, \"cannot be changed to that value\"\n end\n end\n end\n end\n end\n\n def self.included(klass)\n if klass < ActiveRecord::Base\n klass.send :extend, ClassMethods\n end\n end\n\nend\n\n\n# PB SAFE \ncanvas-lms validates_each canvas-lms/app/models/pseudonym.rb:42\n # allows us to validate the user and pseudonym together, before saving either\n validates_each :user_id do |record, attr, value|\n record.errors.add(attr, \"blank?\") unless value || record.user\n end\n before_validation :validate_unique_id\n before_destroy :retire_channels\n\n before_save :set_password_changed\n before_validation :infer_defaults, :verify_unique_sis_user_id\n after_save :update_passwords_on_related_pseudonyms\n after_save :update_account_associations_if_account_changed\n has_a_broadcast_policy\n\n alias_method :context, :account\n\n include StickySisFields\n are_sis_sticky :unique_id\n\n validates_each :password, {:if => :require_password?}, &Canvas::PasswordPolicy.method(\"validate\")\n acts_as_authentic do |config|\n config.validates_format_of_login_field_options = {:with => /\\A\\w[\\w\\.\\+\\-_'@ =]*\\z/}\n config.login_field :unique_id\n config.validations_scope = [:account_id, :workflow_state]\n config.perishable_token_valid_for = 30.minutes\n config.validates_length_of_login_field_options = {:within => 1..MAX_UNIQUE_ID_LENGTH}\n\n# PB SAFE just checking format\ncanvas-lms validates_each canvas-lms/app/models/pseudonym.rb:59\n\n validates_each :password, {:if => :require_password?}, &Canvas::PasswordPolicy.method(\"validate\")\n acts_as_authentic do |config|\n config.validates_format_of_login_field_options = {:with => /\\A\\w[\\w\\.\\+\\-_'@ =]*\\z/}\n config.login_field :unique_id\n config.validations_scope = [:account_id, :workflow_state]\n config.perishable_token_valid_for = 30.minutes\n config.validates_length_of_login_field_options = {:within => 1..MAX_UNIQUE_ID_LENGTH}\n config.validates_uniqueness_of_login_field_options = { :case_sensitive => false, :scope => [:account_id, :workflow_state], :if => lambda { |p| (p.unique_id_changed? || p.workflow_state_changed?) && p.active? } }\n end\n\n attr_writer :require_password\n def require_password?\n # Change from auth_logic: don't require a password just because new_record?\n # is true. just check if the pw has changed or crypted_password_field is\n # blank.\n password_changed? || (send(crypted_password_field).blank? && sis_ssha.blank?) || @require_password\n end\n\n acts_as_list :scope => :user\n\n set_broadcast_policy do |p|\n p.dispatch :confirm_registration\n p.to { self.communication_channel || self.user.communication_channel }\n p.whenever { |record|\n\n# PB SAFE just checking format\ncanvas-lms validates_each canvas-lms/app/models/wiki_page.rb:154\n\n validates_each :title do |record, attr, value|\n if value.blank?\n record.errors.add(attr, t('errors.blank_title', \"Title can't be blank\"))\n elsif value.size > maximum_string_length\n record.errors.add(attr, t('errors.title_too_long', \"Title can't exceed %{max_characters} characters\", :max_characters => maximum_string_length))\n elsif value.to_url.blank?\n record.errors.add(attr, t('errors.title_characters', \"Title must contain at least one letter or number\")) # it's a bit more liberal than this, but let's not complicate things\n end\n end\n\n has_a_broadcast_policy\n simply_versioned :exclude => SIMPLY_VERSIONED_EXCLUDE_FIELDS, :when => Proc.new { |wp|\n # :user_id and :updated_at do not merit creating a version, but should be saved\n exclude_fields = [:user_id, :updated_at].concat(SIMPLY_VERSIONED_EXCLUDE_FIELDS).map(&:to_s)\n (wp.changes.keys.map(&:to_s) - exclude_fields).present?\n }\n after_save :remove_changed_flag\n\n\n workflow do\n state :active do\n event :unpublish, :transitions_to => :unpublished\n end\n state :unpublished do\n\n# PB NOT_SAFE race if/when name may already be in use!\ncanvas-lms validates_each canvas-lms/app/models/group_category.rb:41\n\n validates_each :name do |record, attr, value|\n next unless record.name_changed? || value.blank?\n max_len = maximum_string_length\n max_len -= record.create_group_count.to_s.length + 1 if record.create_group_count\n\n if value.blank?\n record.errors.add attr, t(:name_required, \"Name is required\")\n elsif GroupCategory.protected_name_for_context?(value, record.context)\n record.errors.add attr, t(:name_reserved, \"%{name} is a reserved name.\", name: value)\n elsif record.context && record.context.group_categories.other_than(record).where(name: value).exists?\n record.errors.add attr, t(:name_unavailable, \"%{name} is already in use.\", name: value)\n elsif value.length > max_len\n record.errors.add attr, t(:name_too_long, \"Enter a shorter category name\")\n end\n end\n\n validates_each :group_limit do |record, attr, value|\n next if value.nil?\n record.errors.add attr, t(:greater_than_1, \"Must be greater than 1\") unless value.to_i > 1\n end\n\n validates_each :self_signup do |record, attr, value|\n next unless record.self_signup_changed?\n next if value.blank?\n\n\n# PB SAFE value checking\ncanvas-lms validates_each canvas-lms/app/models/group_category.rb:57\n\n validates_each :group_limit do |record, attr, value|\n next if value.nil?\n record.errors.add attr, t(:greater_than_1, \"Must be greater than 1\") unless value.to_i > 1\n end\n\n validates_each :self_signup do |record, attr, value|\n next unless record.self_signup_changed?\n next if value.blank?\n if !record.context.is_a?(Course) && record != communities_for(record.context)\n record.errors.add :enable_self_signup, t(:self_signup_for_courses, \"Self-signup may only be enabled for course groups or communities\")\n elsif value != 'enabled' && value != 'restricted'\n record.errors.add attr, t(:invalid_self_signup, \"Self-signup needs to be one of the following values: %{values}\", values: \"null, 'enabled', 'restricted'\")\n elsif record.restricted_self_signup? && record.has_heterogenous_group?\n record.errors.add :restrict_self_signup, t(:cant_restrict_self_signup, \"Can't restrict self-signup while a mixed-section group exists in the category\")\n end\n end\n\n validates_each :auto_leader do |record, attr, value|\n next unless record.auto_leader_changed?\n next if value.blank?\n unless ['first', 'random'].include?(value)\n record.errors.add attr, t(:invalid_auto_leader, \"AutoLeader type needs to be one of the following values: %{values}\", values: \"null, 'first', 'random'\")\n end\n end\n\n# PB NOT_SAFE conditional evaluation depends on current DB state; e.g., group_categories\ncanvas-lms validates_each canvas-lms/app/models/group_category.rb:62\n\n validates_each :self_signup do |record, attr, value|\n next unless record.self_signup_changed?\n next if value.blank?\n if !record.context.is_a?(Course) && record != communities_for(record.context)\n record.errors.add :enable_self_signup, t(:self_signup_for_courses, \"Self-signup may only be enabled for course groups or communities\")\n elsif value != 'enabled' && value != 'restricted'\n record.errors.add attr, t(:invalid_self_signup, \"Self-signup needs to be one of the following values: %{values}\", values: \"null, 'enabled', 'restricted'\")\n elsif record.restricted_self_signup? && record.has_heterogenous_group?\n record.errors.add :restrict_self_signup, t(:cant_restrict_self_signup, \"Can't restrict self-signup while a mixed-section group exists in the category\")\n end\n end\n\n validates_each :auto_leader do |record, attr, value|\n next unless record.auto_leader_changed?\n next if value.blank?\n unless ['first', 'random'].include?(value)\n record.errors.add attr, t(:invalid_auto_leader, \"AutoLeader type needs to be one of the following values: %{values}\", values: \"null, 'first', 'random'\")\n end\n end\n\n scope :active, -> { where(:deleted_at => nil) }\n\n scope :other_than, lambda { |cat| where(\"group_categories.id<>?\", cat.id || 0) }\n\n\n# PB SAFE -- if we don't hit the 'next's, we just do a local format check\ncanvas-lms validates_each canvas-lms/app/models/group_category.rb:74\n\n validates_each :auto_leader do |record, attr, value|\n next unless record.auto_leader_changed?\n next if value.blank?\n unless ['first', 'random'].include?(value)\n record.errors.add attr, t(:invalid_auto_leader, \"AutoLeader type needs to be one of the following values: %{values}\", values: \"null, 'first', 'random'\")\n end\n end\n\n scope :active, -> { where(:deleted_at => nil) }\n\n scope :other_than, lambda { |cat| where(\"group_categories.id<>?\", cat.id || 0) }\n\n class << self\n def protected_name_for_context?(name, context)\n protected_names_for_context(context).include?(name)\n end\n\n def student_organized_for(context)\n role_category_for_context('student_organized', context)\n end\n\n def imported_for(context)\n role_category_for_context('imported', context)\n end\n\n# PB NOT_SAFE ; may delete the appointment_group.contexts concurrently\ncanvas-lms validates_each canvas-lms/app/models/appointment_group_sub_context.rb:28\n\n validates_each :sub_context do |record, attr, value|\n if record.participant_type == 'User'\n record.errors.add(attr, t('errors.invalid_course_section', 'Invalid course section')) unless value.blank? || value.is_a?(CourseSection) && record.appointment_group.contexts.any? { |c| c == value.course }\n else\n record.errors.add(attr, t('errors.missing_group_category', 'Group appointments must have a group category')) unless value.present? && value.is_a?(GroupCategory)\n record.errors.add(attr, t('errors.invalid_group_category', 'Invalid group category')) unless value && record.appointment_group.contexts.any? { |c| c == value.context }\n end\n end\n\n def participant_type\n sub_context_type == 'GroupCategory' ? 'Group' : 'User'\n end\nend\n\n\n# PB NOT_SAFE e.g., enrollment limit might change depending on concurrent saves!\ncanvas-lms validates_each canvas-lms/app/models/user.rb:279\n validates_acceptance_of :terms_of_use, :if => :require_acceptance_of_terms, :allow_nil => false\n validates_each :self_enrollment_code do |record, attr, value|\n next unless record.require_self_enrollment_code\n if value.blank?\n record.errors.add(attr, \"blank\")\n elsif record.validation_root_account\n course = record.validation_root_account.self_enrollment_course_for(value)\n record.self_enrollment_course = course\n if course && course.self_enrollment_enabled?\n record.errors.add(attr, \"full\") if course.self_enrollment_limit_met?\n record.errors.add(attr, \"already_enrolled\") if course.user_is_student?(record, :include_future => true)\n else\n record.errors.add(attr, \"invalid\")\n end\n else\n record.errors.add(attr, \"account_required\")\n end\n end\n\n before_save :assign_uuid\n before_save :update_avatar_image\n before_save :record_acceptance_of_terms\n after_save :update_account_associations_if_necessary\n after_save :self_enroll_if_necessary\n\n\n# PB NOT_SAFE ; duplicates, etc.\ncanvas-lms validates_each canvas-lms/app/models/calendar_event.rb:70\n\n validates_each :child_event_data do |record, attr, events|\n next unless events || Canvas::Plugin.value_to_boolean(record.remove_child_events)\n events ||= []\n events = events.values if events.is_a?(Hash)\n next record.errors.add(attr, t('errors.no_updating_user', \"Can't update child events unless an updating_user is set\")) if events.present? && !record.updating_user\n context_codes = events.map{ |e| e[:context_code] }\n next record.errors.add(attr, t('errors.duplicate_child_event_contexts', \"Duplicate child event contexts\")) if context_codes != context_codes.uniq\n contexts = find_all_by_asset_string(context_codes).group_by(&:asset_string)\n context_codes.each do |code|\n context = contexts[code] && contexts[code][0]\n next if context && context.grants_right?(record.updating_user, :manage_calendar) && context.try(:parent_event_context) == record.context\n break record.errors.add(attr, t('errors.invalid_child_event_context', \"Invalid child event context\"))\n end\n record.child_event_contexts = contexts\n record.child_event_data = events\n end\n\n def replace_child_events\n return unless @child_event_data\n current_events = child_events.group_by{ |e| e[:context_code] }\n @child_event_data.each do |data|\n if event = current_events.delete(data[:context_code]) and event = event[0]\n event.updating_user = @updating_user\n event.update_attributes(:start_at => data[:start_at], :end_at => data[:end_at])\n\n# PB SAFE ; simple formatting\ncanvas-lms validates_each canvas-lms/app/models/group.rb:87\n\n validates_each :name do |record, attr, value|\n if value.blank?\n record.errors.add attr, t(:name_required, \"Name is required\")\n elsif value.length > maximum_string_length\n record.errors.add attr, t(:name_too_long, \"Enter a shorter group name\")\n end\n end\n\n validates_each :max_membership do |record, attr, value|\n next if value.nil?\n record.errors.add attr, t(:greater_than_1, \"Must be greater than 1\") unless value.to_i > 1\n end\n\n alias_method :participating_users_association, :participating_users\n\n def participating_users(user_ids = nil)\n user_ids ?\n participating_users_association.where(:id =>user_ids) :\n participating_users_association\n end\n\n def wiki_with_create\n Wiki.wiki_for_context(self)\n end\n\n# PB SAFE ; formatting\ncanvas-lms validates_each canvas-lms/app/models/group.rb:95\n\n validates_each :max_membership do |record, attr, value|\n next if value.nil?\n record.errors.add attr, t(:greater_than_1, \"Must be greater than 1\") unless value.to_i > 1\n end\n\n alias_method :participating_users_association, :participating_users\n\n def participating_users(user_ids = nil)\n user_ids ?\n participating_users_association.where(:id =>user_ids) :\n participating_users_association\n end\n\n def wiki_with_create\n Wiki.wiki_for_context(self)\n end\n alias_method_chain :wiki, :create\n\n def auto_accept?\n self.group_category &&\n self.group_category.allows_multiple_memberships? &&\n self.join_level == 'parent_context_auto_join'\n end\n\n\n# PB NOT_SAFE concurrent overlapping appointments\ncanvas-lms validates_each canvas-lms/app/models/appointment_group.rb:65\n validates_inclusion_of :participant_visibility, :in => ['private', 'protected'] # presumably we might add public if we decide to show appointments on the public calendar feed\n validates_each :appointments do |record, attr, value|\n next unless record.new_appointments.present? || record.validation_event_override\n appointments = value\n if record.validation_event_override\n appointments = appointments.select{ |a| a.new_record? || a.id != record.validation_event_override.id} << record.validation_event_override\n end\n appointments.sort_by(&:start_at).inject(nil) do |prev, appointment|\n record.errors.add(attr, t('errors.invalid_end_at', \"Appointment end time precedes start time\")) if appointment.end_at < appointment.start_at\n record.errors.add(attr, t('errors.overlapping_appointments', \"Appointments overlap\")) if prev && appointment.start_at < prev.end_at\n appointment\n end\n end\n\n def validate\n if appointment_group_contexts.empty?\n errors.add :appointment_group_contexts,\n t('errors.needs_contexts', 'Must have at least one context')\n end\n end\n\n attr_accessible :title, :description, :location_name, :location_address, :contexts, :sub_context_codes, :participants_per_appointment, :min_appointments_per_participant, :max_appointments_per_participant, :new_appointments, :participant_visibility, :cancel_reason\n\n # when creating/updating an appointment, you can give it a list of (new)\n # appointment times. these will be added to the existing appointment times\n\n\n# PB SAFE ; Resources set by conf\nrefinerycms FileSizeValidator refinerycms/resources/lib/refinery/resources/validators/file_size_validator.rb:3\n module Validators\n class FileSizeValidator < ActiveModel::Validator\n\n def validate(record)\n file = record.file\n\n if file.respond_to?(:length) && file.length > Resources.max_file_size\n record.errors[:file] << ::I18n.t('too_big',\n :scope => 'activerecord.errors.models.refinery/resource',\n :size => Resources.max_file_size)\n end\n end\n\n end\n end\n end\nend\n\n\n# PB SAFE: changed? => whether this actual image has changed.\nrefinerycms ImageUpdateValidator refinerycms/images/lib/refinery/images/validators/image_update_validator.rb:3\n module Validators\n class ImageUpdateValidator < ActiveModel::Validator\n\n def validate(record)\n if record.image_name_changed?\n record.errors.add :image_name,\n ::I18n.t(\"different_file_name\",\n :scope => \"activerecord.errors.models.refinery/image\")\n end\n end\n\n end\n end\n end\nend\n\n\n# PB SAFE static configuration\nrefinerycms ImageSizeValidator refinerycms/images/lib/refinery/images/validators/image_size_validator.rb:3\n module Validators\n class ImageSizeValidator < ActiveModel::Validator\n\n def validate(record)\n image = record.image\n\n if image.respond_to?(:length) && image.length > Images.max_image_size\n record.errors[:image] << ::I18n.t('too_big',\n :scope => 'activerecord.errors.models.refinery/image',\n :size => Images.max_image_size)\n end\n end\n\n end\n end\n end\nend\n\n\n# PB SAFE formatting only\nskyline validates_each skyline/vendor/weppos/url_validation.rb:57\n\n validates_each(attr_names, configuration) do |record, attr_name, value|\n begin\n uri = URI.parse(value)\n\n if !allowed_schemes.include?(uri.scheme)\n raise(URI::InvalidURIError)\n end\n\n if [:scheme, :host].any? { |i| uri.send(i).blank? }\n raise(URI::InvalidURIError)\n end\n\n rescue URI::InvalidURIError => e\n record.errors.add(attr_name, :invalid, :default => configuration[:message], :value => value)\n next\n end\n end\n end\nend\n\n# PB SAFE formatting\ncommunityengine validates_each communityengine/app/models/invitation.rb:12\n\n validates_each :email_addresses do |record, attr, email_addresses |\n invalid_emails = []\n email_addresses = email_addresses || ''\n emails = email_addresses.split(\",\").collect{|email| email.strip }.uniq\n \n emails.each{ |email|\n unless email =~ /[\\w._%-]+@[\\w.-]+.[a-zA-Z]{2,4}/\n invalid_emails << email\n end \n }\n unless invalid_emails.empty?\n record.errors.add(:email_addresses, \" included invalid addresses: <ul>\"+invalid_emails.collect{|email| '<li>'+email+'</li>' }.join+\"</ul>\")\n record.email_addresses = (emails - invalid_emails).join(', ')\n end\n end\n\n attr_accessible :email_addresses, :message\n\n def send_invite\n emails = self.email_addresses.split(\",\").collect{|email| email.strip }.uniq \n emails.each{|email|\n UserNotifier.signup_invitation(email, self.user, self.message).deliver\n }\n end\n\n# PB SAFE formatting\ncommunityengine validates_each communityengine/app/models/friendship.rb:14\n validate :cannot_request_if_daily_limit_reached\n validates_each :user_id do |record, attr, value|\n record.errors.add attr, 'can not be same as friend' if record.user_id.eql?(record.friend_id)\n end\n \n # named scopes\n scope :accepted, lambda {\n #hack: prevents FriendshipStatus[:accepted] from getting called before the friendship_status records are in the db (only matters in testing ENV)\n {:conditions => [\"friendship_status_id = ?\", FriendshipStatus[:accepted].id] }\n }\n \n def cannot_request_if_daily_limit_reached \n if new_record? && initiator && user.has_reached_daily_friend_request_limit?\n errors.add(:base, \"Sorry, you'll have to wait a little while before requesting any more friendships.\") \n end\n end \n \n before_validation(:on => :create){:set_pending}\n after_save :notify_requester, :if => Proc.new{|fr| fr.accepted? && fr.initiator }\n\n attr_protected :friendship_status_id\n \n def reverse\n Friendship.find(:first, :conditions => ['user_id = ? and friend_id = ?', self.friend_id, self.user_id])\n end\n\n# PB SAFE ; validates against external URLs, but fine from DB \npublify validates_each publify/lib/spam_protection.rb:103\n\n validates_each(attr_names, configuration) do |record, attr_name, value|\n record.errors.add(attr_name, configuration[:message]) if SpamProtection.new(record.blog).is_spam?(value)\n end\n end\n end", "def your_attributes_valid\n do_validate_attributes('your')\n end", "def validate_data\n @state = true\n #store the original error count, if there is a chnage to the count, then we want to update all associated insurance_billings and balance_bills\n @original_count = self.dataerrors.count \n #first remove any old errors from the table\n self.dataerrors.clear \n \n @s = [] \n # check the necessary fields in the table\n # use the build method so the polymorphic reference is generated cleanly\n @s.push self.dataerrors.build(:message => \"Patient first name is blank\", :created_user => self.created_user) if self.first_name.blank? \n @s.push self.dataerrors.build(:message => \"Patient last name is blank\", :created_user => self.created_user) if self.last_name.blank?\n @s.push self.dataerrors.build(:message => \"Patient address is required\", :created_user => self.created_user) if self.address1.blank?\n @s.push self.dataerrors.build(:message => \"Patient city is blank\", :created_user => self.created_user) if self.city.blank?\n @s.push self.dataerrors.build(:message => \"Patient state is blank\", :created_user => self.created_user) if self.state.blank?\n @s.push self.dataerrors.build(:message => \"Patient zip is blank\", :created_user => self.created_user) if self.zip.blank?\n @s.push self.dataerrors.build(:message => \"Patient gender is blank\", :created_user => self.created_user) if self.gender.blank?\n @s.push self.dataerrors.build(:message => \"Patient dob is blank\", :created_user => self.created_user) if self.dob.blank?\n \n referred_type = ReferredType.all \n if self.referred_from_type == referred_type[0][:referred_type] or self.referred_from_type == referred_type[2][:referred_type]\n @s.push self.dataerrors.build(:message => \"NPI for 'referred from' field in patient's record is blank\", :created_user => self.created_user) if self.referred_from_npi.blank? \n end\n \n #if there are errors, save them to the dataerrors table and return false\n if @s.count > 0\n Dataerror.store(@s) \n @state = false\n end\n #if the error counts changed, then update all insurance_bill & balance bills\n if @original_count != @s.count\n self.insurance_billings.each { |billing| billing.validate_claim }\n self.balance_bills.each { |balance| balance.validate_balance_bill }\n end \n return @state\n end", "def valid_validation_parameter\n %i[\n validate\n criteria\n value\n source\n minimum\n maximum\n ignore_blank\n dropdown\n show_input\n input_title\n input_message\n show_error\n error_title\n error_message\n error_type\n other_cells\n ]\n end", "def validate_event=(_arg0); end", "def validate \n#\tfirst check whether combo fields have been selected\n\t is_valid = true\n\t if is_valid\n\t\t is_valid = ModelHelper::Validations.validate_combos([{:short_description => self.short_description}],self) \n\tend\n\t#now check whether fk combos combine to form valid foreign keys\n\t if is_valid\n\t\t is_valid = set_organization\n\t end\n\t if is_valid\n\t\t is_valid = ModelHelper::Validations.validate_combos([{:target_market_name => self.target_market_name}],self) \n\tend\n\t#now check whether fk combos combine to form valid foreign keys\n\t if is_valid\n\t\t is_valid = set_target_market\n\t end\n\t#validates uniqueness for this record\n\t if self.new_record? && is_valid\n\t\t validate_uniqueness\n\t end\nend", "def validate!\n true\n end", "def before_validation_on_update\n before_validation_on_create\n end", "def validate\n fail 'sub class to implement'\n end", "def validate!\n super()\n self\n end", "def validate!\n validate_patches!\n validate_new_branch_name! if new_branch?\n validate_permissions!\n end", "def valid?(_) true end", "def valid?(_) true end", "def store_validations #:nodoc:\n return if @validations.size == 0\n\n @validations.each do |param|\n store_dv(\n param[:cells],\n param[:validate],\n param[:criteria],\n param[:value],\n param[:maximum],\n param[:input_title],\n param[:input_message],\n param[:error_title],\n param[:error_message],\n param[:error_type],\n param[:ignore_blank],\n param[:dropdown],\n param[:show_input],\n param[:show_error]\n )\n end\n end", "def is_valid\n\tend", "def is_valid\n\tend", "def validate \n#\tfirst check whether combo fields have been selected\n\t is_valid = true\n\t if is_valid\n\t\t is_valid = ModelHelper::Validations.validate_combos([{:commodity_code => self.commodity_code},{:rmt_variety_code => self.rmt_variety_code}],self) \n\tend\n\t#now check whether fk combos combine to form valid foreign keys\n\t if is_valid\n\t\t is_valid = set_rmt_variety\n\t end\n\t if is_valid\n\t\t is_valid = ModelHelper::Validations.validate_combos([{:season_code => self.season_code},{:id => self.id}],self) \n\tend\n\t#now check whether fk combos combine to form valid foreign keys\n\t if is_valid\n\t\t is_valid = set_season\n\t end\n\t#validates uniqueness for this record\n\t if self.new_record? && is_valid\n\t\t validate_uniqueness\n\t end\nend", "def validate\n validate_resources_defined\n validates_unique(:resource_id, :message => \"ARK must point to a unique Resource\")\n validates_unique(:archival_object_id, :message => \"ARK must point to a unique Archival Object\")\n super\n end" ]
[ "0.6437803", "0.6437803", "0.63117343", "0.6299481", "0.6273503", "0.6260488", "0.6260488", "0.6260488", "0.6260488", "0.62549055", "0.6194469", "0.6141859", "0.61279804", "0.61114573", "0.61035025", "0.60986215", "0.6083659", "0.60651106", "0.60651106", "0.60651106", "0.60581714", "0.60506195", "0.60506195", "0.60506195", "0.60318583", "0.60202444", "0.6013516", "0.6009644", "0.6009644", "0.6009644", "0.59866524", "0.59367293", "0.5923676", "0.5907155", "0.59053546", "0.59053063", "0.58988476", "0.5869999", "0.5859558", "0.5852397", "0.584426", "0.58323014", "0.58153236", "0.58109134", "0.5777217", "0.57747316", "0.57591635", "0.57591635", "0.5756062", "0.5738873", "0.57385385", "0.57163024", "0.57017076", "0.5692927", "0.56897604", "0.5683055", "0.56815124", "0.56575966", "0.56536156", "0.56478554", "0.5645052", "0.5639924", "0.56383455", "0.56324726", "0.5622773", "0.5621968", "0.56119734", "0.56053984", "0.5600456", "0.5590806", "0.5587166", "0.5583443", "0.5576976", "0.5568694", "0.55627954", "0.5554582", "0.5550176", "0.5549523", "0.55408967", "0.55353165", "0.5527922", "0.55242014", "0.5510167", "0.550745", "0.5500234", "0.54904836", "0.5479979", "0.5478001", "0.5474148", "0.54634994", "0.54563534", "0.54538727", "0.5438413", "0.54168504", "0.54168504", "0.5415067", "0.5413585", "0.5413585", "0.5410292", "0.5409672" ]
0.60993713
15
Add a white list of extensions which are allowed to be uploaded.
def extension_white_list %w(jpg jpeg gif png JPG JPEG GIF PNG) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def extension_whitelist\n Spotlight::Engine.config.allowed_upload_extensions\n end", "def extension_whitelist\n %w(jpg jpeg gif png tif tiff avi m4v mov mp4 mpg mpeg mpeg wmv qt)\n end", "def extension_whitelist\n %w(jpg jpeg gif png)\n end", "def extension_whitelist\n %w(jpg jpeg gif png)\n end", "def extension_whitelist\n %w(jpg jpeg gif png)\n end", "def extension_whitelist\n %w(jpg jpeg gif png)\n end", "def extension_whitelist\n %w(jpg jpeg gif png)\n end", "def extension_whitelist\n %w(jpg jpeg gif png)\n end", "def extension_whitelist\n %w(jpg jpeg gif png)\n end", "def extension_whitelist\n %w(jpg jpeg gif png)\n end", "def extension_whitelist\n %w(jpg jpeg gif png)\n end", "def extension_whitelist\n %w(jpg jpeg gif png)\n end", "def extension_whitelist\n %w(jpg jpeg gif png)\n end", "def extension_whitelist\n %w(jpg jpeg gif png)\n end", "def extension_whitelist\n %w(jpg jpeg gif png)\n end", "def extension_whitelist\n %w(jpg jpeg gif png)\n end", "def extension_white_list\n if Rails.application.config.respond_to? :extension_allowed_list\n Rails.application.config.extension_allowed_list\n else\n %w( pdf doc docx xls xlsx ppt )\n end\n end", "def extension_whitelist\n %w[jpg jpeg gif png]\n end", "def extension_whitelist\n %w[jpg jpeg gif png]\n end", "def extension_whitelist\n %w[jpg jpeg gif png]\n end", "def extension_whitelist\n %w[jpg jpeg png]\n end", "def extension_whitelist\n %w(jpg jpeg png)\n end", "def extension_whitelist\n %w(jpg jpeg png)\n end", "def extension_whitelist\n %w(jpg jpeg png)\n end", "def extension_whitelist\n %w(jpg jpeg gif png pdf)\n end", "def extension_whitelist\n %w[txt csv xls xlsx doc docx gif jpg jpeg png bmp svg pdf ppt pptx]\n end", "def extension_white_list\n EXTENSIONS\n end", "def extension_white_list\n EXTENSIONS\n end", "def extension_whitelist\n %w(mp4 mp3 jpg jpeg gif png pdf docx)\n end", "def extension_whitelist\n %w[png jpg jpeg]\n end", "def extension_whitelist\n %w[png jpg jpeg]\n end", "def extension_whitelist\n %w(mp4 ogv avi)\n end", "def extension_allowlist\n %w(jpg jpeg png)\n end", "def extension_whitelist; end", "def extensions_white_list\n %w(jpg jpeg gif png)\n end", "def extension_allowlist\n end", "def extension_white_list\n %w(jpg JPG jpeg JPEG gif GIF png PNG)\n end", "def valid_extensions\n %w[.rb .js]\n end", "def extension_white_list\n ExtensionWhiteList.new %w(jpg jpeg png)\n end", "def extension_white_list\n ExtensionWhiteList.new %w(jpg jpeg png)\n end", "def extension_white_list\n %w(jpg jpeg gif png)\n end", "def extension_white_list\n %w(jpg jpeg gif png)\n end", "def extension_white_list\n %w(jpg jpeg png)\n end", "def extension_white_list\n %w(jpg jpeg gif png pdf)\n end", "def extension_white_list\n %w(jpg jpeg gif png)\n end", "def extension_whitelist\n %w[mp3]\n end", "def extension_white_list\n %w(jpg jpeg gif png swf)\n end", "def extension_white_list\n %w(jpg jpeg gif png)\n end", "def extension_white_list\n %w(jpg jpeg gif png)\n end", "def extension_white_list\n %w(jpg jpeg gif png)\n end", "def extension_white_list\n %w(jpg jpeg gif png)\n end", "def extension_white_list\n %w(jpg jpeg gif png)\n end", "def extension_white_list\n %w(jpg jpeg gif png)\n end", "def extension_white_list\n %w(jpg jpeg gif png)\n end", "def extension_white_list\n %w(jpg jpeg gif png)\n end", "def extension_white_list\n %w(jpg jpeg gif png)\n end", "def extension_white_list\n %w(jpg jpeg gif png)\n end", "def extension_white_list\n %w(jpg jpeg gif png)\n end", "def extension_white_list\n %w(jpg jpeg gif png)\n end", "def extension_white_list\n %w(jpg jpeg gif png)\n end", "def extension_white_list\n %w(jpg jpeg gif png)\n end", "def extension_white_list\n %w(jpg jpeg gif png)\n end", "def extension_white_list\n %w(jpg jpeg gif png)\n end", "def extension_white_list\n %w(jpg jpeg gif png)\n end", "def extension_white_list\n %w(jpg jpeg gif png)\n end", "def extension_white_list\n %w(jpg jpeg gif png)\n end", "def extension_white_list\n %w(jpg jpeg gif png)\n end", "def extension_white_list\n %w(jpg jpeg gif png)\n end", "def extension_white_list\n %w(jpg jpeg gif png)\n end", "def extension_white_list\n %w(jpg jpeg gif png)\n end", "def extension_white_list\n %w(jpg jpeg gif png)\n end", "def extension_white_list\n %w(jpg jpeg gif png)\n end", "def extension_white_list\n %w(jpg jpeg gif png)\n end", "def extension_white_list\n %w(jpg jpeg gif png)\n end", "def extension_white_list\n %w(jpg jpeg gif png)\n end", "def extension_white_list\n %w(jpg jpeg gif png)\n end", "def extension_white_list\n %w(jpg jpeg gif png)\n end", "def extension_white_list\n %w(jpg jpeg gif png)\n end", "def extension_white_list\n %w(jpg jpeg gif png)\n end", "def extension_white_list\n %w(jpg jpeg gif png)\n end", "def extension_white_list\n %w(jpg jpeg gif png)\n end", "def extension_white_list\n %w(jpg jpeg gif png)\n end", "def extension_white_list\n %w(jpg jpeg gif png)\n end", "def extension_white_list\n %w(jpg jpeg gif png)\n end", "def extension_white_list\n %w(jpg jpeg gif png)\n end", "def extension_white_list\n %w(jpg jpeg gif png)\n end", "def extension_white_list\n %w(jpg jpeg gif png)\n end", "def extension_white_list\n %w(jpg jpeg gif png)\n end", "def extension_white_list\n %w(jpg jpeg gif png)\n end", "def extension_white_list\n %w(jpg jpeg gif png)\n end", "def extension_white_list\n %w(jpg jpeg gif png)\n end", "def extension_white_list\n %w(jpg jpeg gif png)\n end", "def extension_white_list\n %w(jpg jpeg gif png)\n end", "def extension_white_list\n %w(jpg jpeg gif png)\n end", "def extension_white_list\n %w(jpg jpeg gif png)\n end", "def extension_white_list\n %w(jpg jpeg gif png)\n end", "def extension_white_list\n %w(jpg jpeg gif png)\n end", "def extension_white_list\n %w(jpg jpeg gif png)\n end", "def extension_white_list\n %w(jpg jpeg gif png)\n end", "def extension_white_list\n %w(jpg jpeg gif png)\n end" ]
[ "0.8075808", "0.75609756", "0.7526584", "0.74878633", "0.74878633", "0.74878633", "0.74878633", "0.74878633", "0.74878633", "0.74878633", "0.74878633", "0.74878633", "0.74878633", "0.74878633", "0.74878633", "0.74878633", "0.74864304", "0.7485972", "0.7485972", "0.7485972", "0.7457249", "0.74480677", "0.74480677", "0.74480677", "0.742988", "0.7387422", "0.73568976", "0.73568976", "0.7322633", "0.72903705", "0.72903705", "0.72647786", "0.72437215", "0.7221138", "0.7211211", "0.719847", "0.7186555", "0.71805245", "0.7174579", "0.71736795", "0.71472675", "0.71472675", "0.7136267", "0.71339214", "0.71304995", "0.7111348", "0.70669365", "0.7047301", "0.7047301", "0.70422846", "0.70422846", "0.70422846", "0.70422846", "0.70422846", "0.70422846", "0.70422846", "0.70422846", "0.70422846", "0.70422846", "0.70422846", "0.70422846", "0.70422846", "0.70422846", "0.70422846", "0.70422846", "0.70422846", "0.70422846", "0.70422846", "0.70422846", "0.70422846", "0.70422846", "0.70422846", "0.70422846", "0.70422846", "0.70422846", "0.70422846", "0.70422846", "0.70422846", "0.70422846", "0.70422846", "0.70422846", "0.70422846", "0.70422846", "0.70422846", "0.70422846", "0.70422846", "0.70422846", "0.70422846", "0.70422846", "0.70422846", "0.70422846", "0.70422846", "0.70422846", "0.70422846", "0.70422846", "0.70422846", "0.70422846", "0.70422846", "0.70422846", "0.70422846" ]
0.71089274
46
Override the filename of the uploaded files: Avoid using model.id or version_name here, see uploader/store.rb for details.
def filename if super.present? @name ||= Digest::MD5.hexdigest(File.dirname(current_path)) "#{@name}#{File.extname(original_filename).downcase}" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def filename\n if super.present?\n @name ||=\"#{SecureRandom.hex}.#{file.extension.downcase}\" if original_filename\n Rails.logger.debug(\"(BaseUploader.filename) #{@name}\")\n @name\n end\n end", "def filename\n if original_filename\n \"#{model.name.parameterize}-#{secure_token(8)}.#{file.extension}\"\n end\n end", "def filename\n \"#{original_filename_without_extension.parameterize}_#{model.filename_token}#{original_extension}\" if original_filename\n end", "def filename\n if original_filename\n # This is pretty gross. We only want to reuse the existing filename if\n # a new avatar isn't being uploaded, we look at the *_change attribute to\n # determine if that happened.\n if model && model.read_attribute(mounted_as).present? && !model.send(:\"#{mounted_as}_change\")\n model.read_attribute(mounted_as)\n else\n # new filename\n @name ||= \"#{timestamp}.#{model.send(mounted_as).file.extension}\" if original_filename\n end\n end\n end", "def filename\n if super.present?\n # current_path 是 Carrierwave 上传过程临时创建的一个文件,有时间标记,所以它将是唯一的\n @name ||= Digest::MD5.hexdigest(File.dirname(current_path))\n \"#{@name}.#{ext}\"\n end\n end", "def filename\n \"#{model.name.parameterize}.#{file.extension}\" if original_filename.present?\n end", "def filename\n if original_filename\n if model && model.read_attribute(mounted_as).present?\n model.read_attribute(mounted_as)\n else\n @name ||= \"#{mounted_as}-#{uuid}.#{file.extension}\"\n end\n end\n end", "def filename\n \"#{mounted_as}1.#{model.image.file.extension}\" if original_filename\n end", "def filename\n if original_filename\n var = :\"@#{mounted_as}_unique_file_name\"\n model.instance_variable_get(var) or model.instance_variable_set(var, unique_file_name)\n end\n end", "def filename\n @name ||= \"#{model.firstname.parameterize}-#{model.lastname.parameterize}.#{model.image.file.extension}\"\n end", "def filename\n \"application_#{model.hash}.#{file.extension}\" if original_filename.present?\n end", "def filename\n puts model.name\n puts original_filename\n model.name + File.extname(original_filename)\n end", "def filename\n filename = (model.name + '_' + model.artist.name + '_' + model.release.name).downcase.gsub(/\\s/, '-')\n \"#{filename}\" if original_filename \n end", "def filename(record, file)\n original = \"#{file.basename}.#{file.extension}\"\n write_attribute(:original_filename, original)\n ext = file.suffix.nil? || file.suffix == :original ? file.extension : file.suffix\n \"#{application_for_offering.id.to_s}-#{title.gsub(/[\\s,\\.\\\\\\/\\*\\?\\%\\:\\|\\\"\\'\\<\\>]?/,'')}.#{ext}\"\n end", "def filename\n \"#{model.original_name}\"\n end", "def filename\n if original_filename\n md5 = Digest::MD5.hexdigest(\"#{model.imagenable.friendly_id}_#{Time.now}\")\n \"#{md5}.#{file.extension}\"\n end\n end", "def filename\n model.respond_to?(:filename) ? model.filename : super\n end", "def filename\n @name ||= \"#{timestamp}-#{secure_token(8)}.#{file.extension}\" if original_filename.present?\n end", "def filename\n @filename = \"#{secure_token}_#{split_extension(original_filename)}.#{file.extension}\" if original_filename.present?\n end", "def filename\n if original_filename\n return \"#{model.id.to_s}.jpg\"\n else\n return model.portrait_filename\n end\n end", "def filename\n @name ||= \"#{md5}.#{file.extension}\" if original_filename.present?\n end", "def filename\n if original_filename.present?\n \"#{model.story.slug}-#{secure_token}.#{file.extension}\"\n end\n end", "def set_file_name\n update(name: (file.filename rescue \"Untitled File\"))\n end", "def set_file_name\n update(name: (file.filename rescue \"Untitled File\"))\n end", "def file_name\n uploaded_file_file_name\n end", "def file_name\n \"#{@file_name}.#{extension}\"\n end", "def filename\r\n \"#{model.user_id.to_s}_#{model.id.to_s}.mov\" if original_filename\r\n end", "def set_filename_from_parent\n components = parent.filename.split('.')\n if components.size > 1\n ext = components.last\n name = components[0, components.size - 1].join('.')\n else\n ext = 'mp3'\n name = parent.filename\n end\n name = Digest::SHA1.hexdigest(\"KroogiFileDownload-#{id}-#{name}\")\n \n self.filename = \"#{name}.#{ext}\"\n end", "def original_filename\n fake_file_name || super\n end", "def filename\n \"#{resize_prefix}_#{original_filename}\"\n end", "def filename\n if original_filename.present? && model.photoable.present?\n \"#{model.photoable.display_name.parameterize}-#{secure_token}.#{file.extension}\"\n elsif original_filename.present? && model.photoable.blank?\n \"mydiscoveries-#{secure_token}.#{file.extension}\"\n end\n end", "def filename(version)\n @file_id.sub(/\\.#{file_type}\\Z/, \".#{version}.#{file_type}\")\n end", "def generate_file_name\n file_name = attachment.instance_read(:file_name).slugged_filename\n attachment.instance_write :file_name, file_name\n end", "def custom_filename(file, opts = {})\n file = CarrierWave::SanitizedFile.new(file) if file.is_a?(String)\n base_name = model.respond_to?(\"#{mounted_as}_token\") ? model.send(\"#{mounted_as}_token\") : file.basename\n base_name = \"#{base_name}_cropped_#{crop_args.join('_')}\" if croppable? && opts[:cropping]\n base_name = [opts[:version], base_name].compact.join('_')\n [base_name, file.extension].join('.')\n end", "def set_name\n self.name = self.asset.original_filename\n end", "def filename\n original_filename\n end", "def filename\n return unless original_filename\n if model.instance_variable_get('@_temporal_filename')\n model.instance_variable_get('@_temporal_filename')\n else\n timestamp = DateTime.now.strftime(\"%d-%m-%Y-%H-%M\")\n random_id = SecureRandom.hex\n temporal_filename = \"#{timestamp}-#{random_id}-#{original_filename}\"\n model.instance_variable_set('@_temporal_filename', temporal_filename)\n end\n end", "def original_filename\n @file_representation[:filename]\n end", "def filename\n \"#{folder_id}#{File.extname(super)}\"\n end", "def full_filename( for_file )\n super.downcase\n # super.chomp( File.extname( super ) ) + '.jpg'\n end", "def original_filename\n @file_representation.original_filename\n end", "def filename(upload = file)\n @@_filename ||= lambda {\n if upload.present?\n current_filename = upload.filename.match(/(.+)\\.csv$/).captures.first\n \"#{model.uuid}-#{current_filename}.csv\"\n end\n }.call\n end", "def file_name\n \"#{Time.current.to_i}-#{@file.original_filename}\"\n end", "def filename\n raise SitemapGenerator::SitemapError, \"No filename or namer set\" unless self[:filename] || self[:namer]\n unless self[:filename]\n self.send(:[]=, :filename, self[:namer].to_s, :super => true)\n\n # Post-process the filename for our compression settings.\n # Strip the `.gz` from the extension if we aren't compressing this file.\n # If you're setting the filename manually, :all_but_first won't work as\n # expected. Ultimately I should force using a namer in all circumstances.\n # Changing the filename here will affect how the FileAdapter writes out the file.\n if self[:compress] == false ||\n (self[:namer] && self[:namer].start? && self[:compress] == :all_but_first)\n self[:filename].gsub!(/\\.gz$/, '')\n end\n end\n self[:filename]\n end", "def filename\n \"#{secure_token(10)+File.extname(original_filename)}\" if original_filename.present?\n end", "def default_file_name\n \"#{klass_name.underscore}_#{id}\"\n end", "def filename\n @file.basename.to_s\n end", "def filename\n @name ||= ActiveSupport::SecureRandom.hex\n\t\"#{@name}#{File.extname(original_filename).downcase}\" if original_filename\n end", "def file_name=(value)\n @file_name = value\n end", "def file_name=(value)\n @file_name = value\n end", "def filename\n return @filename unless @filename.nil?\n generate_file_name()\n @filename\n end", "def filename(model_name); end", "def filename(model_name); end", "def filename\n \"#{original_filename}+#{secure_token}.#{file.extension}\" if original_filename.present?\n end", "def file_name\n self.file_file_name\n end", "def filename\n \"#{options.filename}.#{options.filetype}\"\n end", "def filename\n unless @filename\n @filename = @path.basename.to_s\n end\n\n @filename\n end", "def filename= name\n #This is a stub, used for indexing\n end", "def filename\n DateTime.now.strftime('%Q') + Digest::MD5.hexdigest(original_filename) + original_filename if original_filename\n end", "def public_filename(record, file)\n filename = [application_for_offering.id.to_s] \n filename << application_for_offering.person.fullname\n filename << title\n ext = file.suffix.nil? || file.suffix == :original ? file.extension : file.suffix\n filename.join(' ').gsub(/[^a-z0-9 \\(\\)]+/i,'') + \".#{ext}\"\n end", "def filename\n @original_filename\n end", "def filename=(value)\n @old_filename = full_filename unless filename.nil? or @old_filename\n write_attribute :filename, sanitize_filename(value)\n end", "def original_file_name\n object.original_file_name.nil? ? \"\" : object.original_file_name\n end", "def original_file_name\n object.original_file_name.nil? ? \"\" : object.original_file_name\n end", "def filename\n return unless original_filename\n\n extension = File.extname(original_filename)\n name = File.basename(original_filename, extension)\n\n \"#{Time.current.to_i.to_s}-#{name.parameterize}#{extension}\"\n end", "def filename\n \"#{secure_token(10)}.#{file.extension}\" if original_filename.present?\n end", "def original_filename\n metadata[\"filename\"]\n end", "def filename=(value)\n @old_filename = filename unless filename.nil? || @old_filename\n write_attribute :filename, sanitize_filename(value)\n end", "def default_name\n self.name ||= File.basename(data_file.filename, '.*').titleize if data_file.filename && !self.name\n end", "def filename_for_image_upload\n random_token = Digest::SHA2.hexdigest(\"#{Time.now.utc}--#{current_user.id.to_s}\").first(15)\n \"temp_upload_#{random_token}\"\n end", "def filename_for_image_upload\n random_token = Digest::SHA2.hexdigest(\"#{Time.now.utc}--#{current_user.id.to_s}\").first(15)\n \"temp_upload_#{random_token}\"\n end", "def full_filename (for_file = model.source.file)\n super.chomp(File.extname(super)) + '.png'\n end", "def filename(name)\n @filename = name.downcase.strip.gsub(' ', '-')\n end", "def filename\n super\n end", "def full_filename(for_file)\n # 兼容 #{mounted_as}_fingerprint\n if version_name.present? && model.try(:\"#{mounted_as}_fingerprint\")\n [version_name, model.send(:\"#{mounted_as}_fingerprint\"), for_file].compact.join('_')\n elsif version_name.present?\n [version_name, model.send(:\"#{mounted_as}_identifier\")].compact.join('_')\n else\n super\n end\n end", "def filename\n \"#{mounted_as}_#{Time.zone.now.to_s :number}.pdf\" if original_filename\n end", "def original_filename\n File.basename(self.path)\n end", "def original_filename\n File.basename(self.path)\n end", "def original_filename\n File.basename(self.path)\n end", "def file_name\n if source\n source.is_a?(File) ? File.basename(source.path) : File.basename(source)\n else\n object.original_name.nil? ? \"original_file\" : object.original_name\n end\n end", "def photo_filename\n\tFile.join PHOTO_STORE, \"#{id}.#{extension}\"\n end", "def filename\n if @filename\n ext_name = File.extname(@filename)\n unless %w(jpg jpeg png gif).include?(ext_name)\n model.random_string + \".jpg\"\n else\n model.random_string + ext_name\n end\n end\n end", "def photo_filename\n \tFile.join PHOTO_STORE, \"#{id}.#{extension}\"\n end", "def set_new_filename\n\t\t\tupdate_attribute(:video_file_name_mobile, \"#{self.video_file_name}.mp4\")\n\t\t\tupdate_attribute(:video_file_name, \"#{self.video_file_name}.flv\")\n\t\t\tupdate_attribute(:video_content_type, \"application/x-flash-video\")\n\t\tend", "def filename\n return _meta_data['filename'] if _meta_data.has_key? 'filename'\n name\n end", "def filename=(name)\n @filename = File.basename(name)\n end", "def filename\n \"#{secure_token}.#{file.extension}\" if original_filename\n end", "def photo_filename\n File.join PHOTO_STORE, \"#{id}.#{extension}\"\n end", "def photo_filename\n File.join PHOTO_STORE, \"#{id}.#{extension}\"\n end", "def file_name\n case variant\n when :sample\n \"sample-#{md5}.#{file_ext}\"\n else\n \"#{md5}.#{file_ext}\"\n end\n end", "def file_name\n name.underscore\n end", "def filename(version=nil)\n if version.blank?\n return \"#{unique_name}.#{file_ext}\"\n else\n return nil unless (workflow_version = self.find_version(version))\n return \"#{workflow_version.unique_name}.#{workflow_version.file_ext}\"\n end\n end", "def name\n # Note that we have to be clever here and use \"direct access\"\n # to avoid a stack overflow from recursion.\n\n # Alternative would be to have this \"virtual attribute\" named\n # something other than name, or change the database column name.\n self[:name].blank? ? self[:upload_file_name] : self[:name]\n end", "def original_filename\n @original_filename ||= path.basename.to_s\n end", "def generate_name\n self.name = \"#{album.name}-#{self.image_file_file_name}\"\n end", "def filename\n @filename ||= File.join(tmpdir, \"#{File.basename(destination)}.#{compression.extension}\")\n end", "def filename\n unless @filename\n load_file_params\n end\n @filename\n end", "def filename\n #\"#{original_filename.split('.').first}.png\" if original_filename\n \"img.#{original_filename.split('.').last}\" if original_filename\n #original_filename if original_filename\n end", "def filename\n \"#{secure_token}.#{file.extension}\" if original_filename.present?\n end" ]
[ "0.8077653", "0.8019424", "0.7978584", "0.79266495", "0.7855941", "0.78141326", "0.7767793", "0.77503246", "0.7706582", "0.7576993", "0.75461215", "0.7528873", "0.7521613", "0.7504146", "0.7487593", "0.7486038", "0.7444368", "0.7435015", "0.7411776", "0.73934406", "0.7320671", "0.7203797", "0.72019535", "0.72019535", "0.71999645", "0.71767616", "0.715123", "0.71237314", "0.7120757", "0.71170044", "0.7115012", "0.71096295", "0.7097621", "0.7068395", "0.7050238", "0.70401895", "0.70092857", "0.7003144", "0.7002101", "0.6996328", "0.6988862", "0.6985494", "0.69732106", "0.6969794", "0.69259185", "0.69118947", "0.6908035", "0.6907446", "0.6904218", "0.6904218", "0.68852156", "0.6855972", "0.6855972", "0.68507135", "0.68357635", "0.68319523", "0.6831267", "0.6820803", "0.6794286", "0.6786247", "0.6786156", "0.6772981", "0.67580366", "0.67580366", "0.67524797", "0.67487085", "0.673551", "0.6733947", "0.6731057", "0.67293596", "0.67293596", "0.6720414", "0.6696546", "0.66873664", "0.66853535", "0.66792786", "0.6678901", "0.6678901", "0.6678901", "0.6670344", "0.6657057", "0.6655454", "0.6627728", "0.6623303", "0.6623143", "0.66189843", "0.6616956", "0.6608443", "0.6608443", "0.6607475", "0.66036457", "0.6597528", "0.65796494", "0.6576998", "0.657224", "0.6568793", "0.6553014", "0.6547264", "0.65434545" ]
0.7305732
22
Provide a default URL as a default if there hasn't been a file uploaded
def default_url ActionController::Base.helpers.asset_path('mails/bigimage.jpg', type: :image).to_s end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def url_with_default *args\n unless file_name.nil?\n url_without_default *args\n else\n nil\n end\n end", "def default_url\n nil\n end", "def default_url\n end", "def default_url\n url 'default'\n end", "def default_url\n file_path = [\n 'fallbacks',\n ([model.class.to_s.underscore, mounted_as, version_name].compact.join('_') + '.png')\n ].join '/'\n\n 'http://' + ENV['HOST'] + ActionController::Base.helpers.image_path(file_path)\n end", "def default_url\n \"http://placehold.it/330&text=pic\"\n end", "def default_url\n # For Rails 3.1+ asset pipeline compatibility:\n # ActionController::Base.helpers.asset_path(\"fallback/\" + [version_name, \"default.png\"].compact.join('_'))\n\n \"http://res.cloudinary.com/djjs4pnpf/image/upload/v1528878490/jpsez3ep8okeusjdqinz.jpg\"\n end", "def default_url\n ActionController::Base.helpers.asset_path(\"fallback/#{model.class.to_s.underscore}_#{mounted_as}/\" + [version_name, \"default.jpg\"].compact.join('_'))\n end", "def url(**options)\n if uploaded_file = get\n uploaded_file.url(**options)\n else\n default_url(**options)\n end\n end", "def default_path; end", "def default_url\n #\"/assets/fallback/\" + [version_name, \"default.jpg\"].compact.join('_')\n ActionController::Base.helpers.asset_path(\"fallback/\" + [version_name, \"default.jpg\"].compact.join('_'))\n #\"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}\"\n end", "def default_url\n \"/images/fallback/\" + [thumb, \"images.jpeg\"].compact.join('_')\n end", "def default_url\n \"photo/#{version_name}.jpg\"\n end", "def default_url\n Settings.image.default_avatar\n end", "def default_url\n Settings.image.default_avatar\n end", "def default_url\n Settings.image.default_avatar\n end", "def default_url\n version = version_name.downcase if version_name\n du = \"/images/fallback/\" + [version, \"empty_deal_image.png\"].compact.join('_')\n # puts \"default_url=>#{du}\"\n du\n end", "def set_url\n @url = DEFAULT_URL\n end", "def default_url\n \"/images/user/avatar/\" + [version_name, \"default.png\"].compact.join('_')\n end", "def default_url\n ActionController::Base.helpers.asset_path(\"integral/defaults/post_image.jpg\")\n end", "def default_url\n PLACEHOLDER_URL\n end", "def default_url(context)\n end", "def default_url\n asset_path(\"fallback/\" + [version_name, \"default-photo.png\"].compact.join('_'))\n end", "def default_url\n asset_path(\"fallback/\" + [version_name, \"default-photo.png\"].compact.join('_'))\n end", "def default_url\n asset_path(\"fallback/\" + [version_name, \"default-photo.png\"].compact.join('_'))\n end", "def default_path\n nil\n end", "def default_url\n \"https://s3.amazonaws.com/whisprdev/uploads/default_avatar.png\"\n end", "def default_url\n # For Rails 3.1+ asset pipeline compatibility:\n # ActionController::Base.helpers.asset_path(\"fallback/\" + [version_name, \"default.png\"].compact.join('_'))\n \"fallback/\"+[version_name, \"default_#{mounted_as}.jpg\"].compact.join('_')\n end", "def default\n path\n end", "def default_url\n # ActionController::Base.helpers.asset_path(\"fallback/\" + [version_name, \"anonymous_avatar.gif\"].compact.join('_'))\n\n 'anonymous_avatar.gif'\n #\"/images/\" + [version_name, \"anonymous.jpg\"].compact.join('_')\n end", "def file_url\n file.attached? ? url_for(file) : ''\n end", "def url() processed_image.try(:url) || fallback_url end", "def default_url\n \"/images/fallback/\" + [version_name, \"default.png\"].compact.join('_')\n end", "def defaults!\n self.url = nil\n end", "def default_url\n \"/images/fallback/\" + [version_name, \"default.png\"].compact.join('_')\n end", "def default_url\n ActionController::Base.helpers.asset_path(\"missing_avatar_thumb.png\")\n end", "def default_url\n ActionController::Base.helpers.asset_path(\"logos/\" + [version_name, \"missing.png\"].compact.join('/'))\n end", "def default_url\n return @resource.value(:source) unless @resource.value(:source).is_a?(Hash)\n return @resource.value(:source)[@resource.value(:remote)] if @resource.value(:source).key?(@resource.value(:remote))\n raise(\"You must specify the URL for remote '#{@resource.value(:remote)}' in the :source hash\")\n end", "def default_url\n # For Rails 3.1+ asset pipeline compatibility:\n \"/assets/\" + [version_name, \"default.gif\"].compact.join('_')\n end", "def default_url\n # # For Rails 3.1+ asset pipeline compatibility:\n #asset_path([version_name, \"default.png\"].compact.join('_'))\n #\n [version_name, \"logono.gif\"].compact.join('_')\n end", "def default_url\n ActionController::Base.helpers.asset_path(\"default/\" + [version_name, \"standard.jpg\"].compact.join('_'))\n end", "def default_url\n ActionController::Base.helpers.image_path('user.png')\n end", "def default_url\n \"/images/fallback/\" + [version_name, \"base-default.png\"].compact.join(\"_\")\n end", "def default_url\n # For Rails 3.1+ asset pipeline compatibility:\n # ActionController::Base.helpers.asset_path(\"fallback/\" + [version_name, \"default.png\"].compact.join('_'))\n\n ActionController::Base.helpers.asset_path(super)\n end", "def default_url\n return '' #ActionController::Base.helpers.asset_path('common/no-image.png')\n end", "def default_path\n @default_path ||= h.can?(:update, object) ? h.edit_form_path(object) : h.form_path(object)\n end", "def default_url(*args); end", "def default_url\n \"http://placehold.it/450x300&text=BandPhoto\"\n end", "def default_url(*_args)\n ActionController::Base\n .helpers\n .asset_path('fallback/' + [version_name, 'missing_avatar1.png'].compact.join('_'))\n end", "def default_url\n # For Rails 3.1+ asset pipeline compatibility:\n # asset_path(\"fallback/\" + [version_name, \"default.png\"].compact.join('_'))\n\n \"/images/fallback/\" + [version_name, \"default.png\"].compact.join('_')\n end", "def default_url(version_name = \"\")\n end", "def default_url\n # For Rails 3.1+ asset pipeline compatibility:\n # asset_path(\"fallback/\" + [version_name, \"default.png\"].compact.join('_'))\n asset_path \"#{DEFAULT_AVATAR_NAME}.png\"\n end", "def default_url\n # For Rails 3.1+ asset pipeline compatibility:\n ([version_name, \"default.png\"].compact.join('_'))\n \n #\"/images/fallback/\" + [version_name, \"default.png\"].compact.join('_')\n end", "def default_url\n \"/images/fallback/\" + [version_name, \"network-thumb-default.png\"].compact.join(\"_\")\n end", "def default_url\n ActionController::Base.helpers.asset_path(\"images/\" + [version_name, \"missing.png\"].compact.join('/'))\n end", "def default_url\n # # For Rails 3.1+ asset pipeline compatibility:\n # # ActionController::Base.helpers.asset_path(\"fallback/\" + [version_name, \"default.png\"].compact.join('_'))\n #\n # \"/images/fallback/\" + [version_name, \"default.png\"].compact.join('_')\n \"/placeholder.png\"\n end", "def default_file_name\n ''\n end", "def default_url(*args)\n \"/site_assets/_shared/avatars/\" + [\"empty_avatar\", version_name].compact.join('_') + '.png'\n end", "def file_url\n end", "def default_url\n # For Rails 3.1+ asset pipeline compatibility: ActionController::Base.helpers.asset_path(\"fallback/\" + [version_name, \"default.png\"].compact.join('_'))\n \"/assets/fallback/\" + [version_name, \"default.png\"].compact.join('_')\n end", "def safe_default_image\n if default_image.try(:filename).present? \n default_image\n elsif self.images.present?\n self.images.first\n else\n Product::generic_default_image\n end\n\n # To populate run task: assets::populate_default_image\n #default_image.presence || Product::generic_default_image\n end", "def default_url\n '/images/blank_card.png'\n end", "def default_url\n # For Rails 3.1+ asset pipeline compatibility:\n # ActionController::Base.helpers.asset_path(\"fallback/\" + [version_name, \"default.png\"].compact.join('_'))\n asset_path('gray_blank.gif')\n # Settings.assets.gray_image\n end", "def default_url\n # For Rails 3.1+ asset pipeline compatibility:\n # ActionController::Base.helpers.asset_path(\"fallback/\" + [version_name, \"default.png\"].compact.join('_'))\n\n # \"/images/fallback/\" + [version_name, \"default.png\"].compact.join('_')\n # 'default_avatar.png' #rails will look at 'app/assets/images/default_avatar.png'\n end", "def file # :nodoc:\n return @file if @file\n\n if default_file && File.exist?(default_file)\n @file = default_file\n end\n end", "def file # :nodoc:\n return @file if @file\n\n if default_file && File.exist?(default_file)\n @file = default_file\n end\n end", "def default_url\n # # For Rails 3.1+ asset pipeline compatibility:\n ActionController::Base.helpers.asset_path('fallback/' + [version_name, 'default.png'].compact.join('_'))\n #\n # \"/images/fallback/\" + [version_name, \"default.png\"].compact.join('_')\n end", "def upload_file_url\n \"file://#{upload_full_path}\"\n end", "def default_url\r\n ActionController::Base.helpers.asset_path(\"fallback/\" + [version_name, \"default.png\"].compact.join('_'))\r\n #ActionController::Base.helpers.asset_path(\"fallback/\" + \"default.gif\")\r\n end", "def default_url(*args)\n \"default_document_icon.png\"\n end", "def default_url(object, view = \"index\")\n #url_for Util.default_url_for_object( object, view )\n url_for object.default_url( view )\n end", "def blank_url\n asset_host = Rails.configuration.action_controller[:asset_host]\n if asset_host\n \"http://#{asset_host}/assets/default/#{blank_image}\"\n else\n \"/assets/default/#{blank_image}\"\n end\n end", "def upload_url\n return unless @data['image']\n # Isn't actually displayed in-app without this set\n return unless image['property'] == 'image'\n file(@data['image'])\n end", "def upload_default(job, pathname)\n full_file_name = archive_file(job, pathname)\n if job.respond_to?(:upload_file_name=)\n job.upload_file_name = full_file_name\n elsif job.respond_to?(:full_file_name=)\n job.full_file_name = full_file_name\n else\n raise(ArgumentError, \"#{job_class_name} must either have attribute 'upload_file_name' or 'full_file_name'\")\n end\n end", "def default_url_options; end", "def default_url\n size = AttachUploader.versions[version_name||:medium][:uploader].processors[0][1].join(\"x\")\n # \"holder.js/#{size}/industrial\"\n \"\"\n end", "def upload_url=(value)\n @upload_url = value\n end", "def default_to_http_if_missing(blob_params)\n url = blob_params[:data_url]\n unless url.blank?\n begin\n blob_params[:data_url] = Addressable::URI.heuristic_parse(url).to_s\n rescue Addressable::URI::InvalidURIError\n blob_params[:data_url] = url\n end\n end\n end", "def default_url\n # # For Rails 3.1+ asset pipeline compatibility:\n ActionController::Base.helpers.asset_path(\"fallback/\" + [version_name, \"default.png\"].compact.join('_'))\n \"/assets/fallback/\" + [version_name, \"default.png\"].compact.join('_')\n end", "def default_photo_url\n self.dig_for_string(\"agentSummary\", \"defaultPhotoURL\")\n end", "def default_image\n end", "def file_url= val\n return if val.blank?\n\n self.state = :pending\n self.server_data = val\n @file_last_action = __method__.to_sym\n end", "def default_uri\n URI.parse('//' + @default_host + '/')\n end", "def default_files; end", "def default_url\n # For Rails 3.1+ asset pipeline compatibility:\n # asset_path(\"fallback/\" + [version_name, \"default.png\"].compact.join('_'))\n puts YAML::dump(model)\n puts YAML::dump(model.respond_to?('imageable_type'))\n #raise \"very confusing ... model.class = \" + model.class.to_s + \" version = \" + version_name\n if model.respond_to?('imageable_type')\n \"/images/fallback/#{model.imageable_type.to_s}_\" + [version_name, \"default.png\"].compact.join('_')\n else\n \"/images/fallback/#{model.class.to_s}_\" + [version_name, \"default.png\"].compact.join('_')\n end\n end", "def get_attachment_url\n return self.attachment.url unless self.attachment.blank?\n end", "def default_url\n ActionController::Base.helpers.asset_path(\"placeholders/\" + [\"default\", version_name].compact.join('_')) + \".png\"\n return \"/images/placeholders/\" + [\"default\", version_name].compact.join('_') + \".png\"\n end", "def url\n if self.empty?\n \"/img/blank.gif\"\n else\n @url\n end\n end", "def file_url\n return nil if target_item.files.empty?\n target_item.files.last.uri.to_s\n end", "def default_url_options=(_arg0); end", "def file_not_found\n redirect settings.root_url.is_a?(Array) ? send(*settings.root_url) : settings.root_url\n end", "def url\n SETTINGS[:url] || raise(\"Must provide URL - please edit file\")\nend", "def url\n SETTINGS[:url] || raise(\"Must provide URL - please edit file\")\nend", "def url\n SETTINGS[:url] || raise(\"Must provide URL - please edit file\")\nend", "def url(*args)\n super_url = super\n File.exists?(\"#{root}#{super_url}\") ? super_url : default_url\n end", "def default_url\n ActionController::Base.helpers.asset_path(\"videos/\" + [version_name, \"capture.png\"].compact.join('_'))\n end", "def preview_image_url\n nil\n end", "def original_url; end", "def default_url\n \"\" + [version_name, \"default_cat_icon.png\"].compact.join('_')\n end", "def url\n self[:url].blank? ? \"/\" : self[:url]\n end" ]
[ "0.78345007", "0.76724994", "0.7374204", "0.70699346", "0.704846", "0.70038724", "0.6925955", "0.69040054", "0.6878755", "0.6872561", "0.6865552", "0.68286866", "0.6819201", "0.68122137", "0.68122137", "0.68122137", "0.677967", "0.6777166", "0.676122", "0.67448753", "0.6733823", "0.6696634", "0.66724044", "0.66724044", "0.66724044", "0.6667578", "0.6653214", "0.6649621", "0.66268337", "0.6614085", "0.66049695", "0.66002077", "0.65900207", "0.6581446", "0.6575753", "0.6556188", "0.65186584", "0.65185297", "0.6507548", "0.6496376", "0.64835685", "0.647246", "0.6469838", "0.6467001", "0.6466269", "0.64545834", "0.64508283", "0.64295936", "0.64203835", "0.64176905", "0.64107907", "0.64103967", "0.6399444", "0.63938624", "0.6385638", "0.63844866", "0.63827163", "0.63569224", "0.63474107", "0.633124", "0.6318502", "0.63063157", "0.63037246", "0.6300347", "0.62591004", "0.62591004", "0.6258158", "0.624925", "0.6229358", "0.62120616", "0.62043804", "0.6193716", "0.6173458", "0.61665034", "0.6164775", "0.61563236", "0.6151151", "0.61243176", "0.6080535", "0.606687", "0.6061459", "0.60419023", "0.6041879", "0.60284775", "0.6028129", "0.60178334", "0.601308", "0.60112834", "0.6010622", "0.59853184", "0.5982742", "0.5982364", "0.5982364", "0.5982364", "0.59600526", "0.5959866", "0.59385735", "0.59371346", "0.5924906", "0.5920387" ]
0.6416765
50
Constructor Returns an instance of a TLV.
def initialize(type, value = nil, compress=false) @type = type @compress = compress if (value != nil) if (type & TLV_META_TYPE_STRING == TLV_META_TYPE_STRING) if (value.kind_of?(Fixnum)) @value = value.to_s else @value = value.dup end else @value = value end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initialize(type, value = nil)\n\t\t@type = type\n\t\t\n\t\tif (value != nil)\n\t\t\tif (type & TLV_META_TYPE_STRING == TLV_META_TYPE_STRING)\n\t\t\t\tif (value.kind_of?(Fixnum))\n\t\t\t\t\t@value = value.to_s\n\t\t\t\telse\n\t\t\t\t\t@value = value.dup\n\t\t\t\tend\n\t\t\telse\n\t\t\t\t@value = value\n\t\t\tend\n\t\tend\n\tend", "def from_r(raw)\n\t\tself.value = nil\n\n\t\tlength, self.type = raw.unpack(\"NN\");\n\n\t\t# check if the tlv value has been compressed...\n\t\tif( self.type & TLV_META_TYPE_COMPRESSED == TLV_META_TYPE_COMPRESSED )\n\t\t\t# set this TLV as using compression\n\t\t\t@compress = true\n\t\t\t# remove the TLV_META_TYPE_COMPRESSED flag from the tlv type to restore the \n\t\t\t# tlv type to its origional, allowing for transparent data compression.\n\t\t\tself.type = self.type ^ TLV_META_TYPE_COMPRESSED\n\t\t\t# decompress the compressed data (skipping the length and type DWORD's)\n\t\t\traw_decompressed = Rex::Text.zlib_inflate( raw[8..length-1] )\n\t\t\t# update the length to reflect the decompressed data length (+8 for the length and type DWORD's)\n\t\t\tlength = raw_decompressed.length + 8\n\t\t\t# update the raw buffer with the new length, decompressed data and updated type.\n\t\t\traw = [length, self.type].pack(\"NN\") + raw_decompressed\n\t\tend\n\t\t\n\t\tif (self.type & TLV_META_TYPE_STRING == TLV_META_TYPE_STRING)\n\t\t\tif (raw.length > 0)\n\t\t\t\tself.value = raw[8..length-2]\n\t\t\telse\n\t\t\t\tself.value = nil\n\t\t\tend\n\t\telsif (self.type & TLV_META_TYPE_UINT == TLV_META_TYPE_UINT)\n\t\t\tself.value = raw.unpack(\"NNN\")[2]\n\t\telsif (self.type & TLV_META_TYPE_BOOL == TLV_META_TYPE_BOOL)\n\t\t\tself.value = raw.unpack(\"NNc\")[2]\n\n\t\t\tif (self.value == 1)\n\t\t\t\tself.value = true\n\t\t\telse\n\t\t\t\tself.value = false\n\t\t\tend\n\t\telse\n\t\t\tself.value = raw[8..length-1]\n\t\tend\n\n\t\treturn length;\n\tend", "def from_r(raw)\n\t\toffset = 8\n\n\t\t# Reset the TLVs array\n\t\tself.tlvs = []\n\t\tself.type = raw.unpack(\"NN\")[1]\n\n\t\t# Enumerate all of the TLVs\n\t\twhile (offset < raw.length-1)\n\n\t\t\ttlv = nil\n\n\t\t\t# Get the length and type\n\t\t\tlength, type = raw[offset..offset+8].unpack(\"NN\")\n\n\t\t\tif (type & TLV_META_TYPE_GROUP == TLV_META_TYPE_GROUP)\n\t\t\t\ttlv = GroupTlv.new(type)\n\t\t\telse\n\t\t\t\ttlv = Tlv.new(type)\n\t\t\tend\n\n\t\t\ttlv.from_r(raw[offset..offset+length])\n\n\t\t\t# Insert it into the list of TLVs\n\t\t\ttlvs << tlv\n\n\t\t\t# Move up\n\t\t\toffset += length\n\t\tend\n\tend", "def from_r(raw)\n\t\toffset = 8\n\n\t\t# Reset the TLVs array\n\t\tself.tlvs = []\n\t\tself.type = raw.unpack(\"NN\")[1]\n\n\t\t# Enumerate all of the TLVs\n\t\twhile (offset < raw.length-1)\n\n\t\t\ttlv = nil\n\n\t\t\t# Get the length and type\n\t\t\tlength, type = raw[offset..offset+8].unpack(\"NN\")\n\n\t\t\tif (type & TLV_META_TYPE_GROUP == TLV_META_TYPE_GROUP)\n\t\t\t\ttlv = GroupTlv.new(type)\n\t\t\telse\n\t\t\t\ttlv = Tlv.new(type)\n\t\t\tend\n\n\t\t\ttlv.from_r(raw[offset..offset+length])\n\n\t\t\t# Insert it into the list of TLVs\n\t\t\ttlvs << tlv\n\n\t\t\t# Move up\n\t\t\toffset += length\n\t\tend\n\tend", "def initialize(label, bit, type)\n fail 'Label has to be a String' unless label.is_a?(String)\n fail 'Bit has to be a String' unless bit.is_a?(String)\n\n @label = label\n @bit = bit\n @type = type\n end", "def initialize(type = nil, method = nil)\n\t\tsuper(type)\n\n\t\tif (method)\n\t\t\tself.method = method\n\t\tend\n\n\t\tself.created_at = ::Time.now\n\n\t\t# If it's a request, generate a random request identifier\n\t\tif ((type == PACKET_TYPE_REQUEST) ||\n\t\t (type == PACKET_TYPE_PLAIN_REQUEST))\n\t\t\trid = ''\n\n\t\t\t32.times { |val| rid << rand(10).to_s }\n\n\t\t\tadd_tlv(TLV_TYPE_REQUEST_ID, rid)\n\t\tend\n\tend", "def from_r(raw)\n\t\tself.value = nil\n\n\t\tlength, self.type = raw.unpack(\"NN\");\n\n\t\tif (self.type & TLV_META_TYPE_STRING == TLV_META_TYPE_STRING)\n\t\t\tif (raw.length > 0)\n\t\t\t\tself.value = raw[8..length-2]\n\t\t\telse\n\t\t\t\tself.value = nil\n\t\t\tend\n\t\telsif (self.type & TLV_META_TYPE_UINT == TLV_META_TYPE_UINT)\n\t\t\tself.value = raw.unpack(\"NNN\")[2]\n\t\telsif (self.type & TLV_META_TYPE_BOOL == TLV_META_TYPE_BOOL)\n\t\t\tself.value = raw.unpack(\"NNc\")[2]\n\n\t\t\tif (self.value == 1)\n\t\t\t\tself.value = true\n\t\t\telse\n\t\t\t\tself.value = false\n\t\t\tend\n\t\telse\n\t\t\tself.value = raw[8..length-1]\n\t\tend\n\n\t\treturn length;\n\tend", "def initialize(type = nil, method = nil)\n\t\tsuper(type)\n\n\t\tif (method)\n\t\t\tself.method = method\n\t\tend\n\n\t\t# If it's a request, generate a random request identifier\n\t\tif ((type == PACKET_TYPE_REQUEST) ||\n\t\t (type == PACKET_TYPE_PLAINTEXT_REQUEST))\n\t\t\trid = ''\n\n\t\t\t32.times { |val| rid << rand(10).to_s }\n\n\t\t\tadd_tlv(TLV_TYPE_REQUEST_ID, rid)\n\t\tend\n\tend", "def initialize(packet_type, length = 0, payload = '') \n @codec_id = CODEC_ID\n @packet_type = packet_type\n @length = length\n\n case @packet_type\n when 'response'\n @data_length = length - 1 # codec id not included here - skip 1 byte\n @data_to_read = @data_length + SIZE_CRC # size from \"number of data 1\" to crc\n @data = [] # binary data\n when 'command'\n @payload = payload\n end\n\n @records = [] # parsed records\n @status = 'pending' # status of packet\n end", "def initialize(name, type, ast_class: nil, **options)\n # Set basic params converting some args to symbols for consistency\n @name = name.to_sym\n @type = type.to_sym\n @ast_class = nil\n # use self.ast_class to trigger setter method\n self.ast_class = ast_class if ast_class\n\n # Ensure block level tags have an AST class\n if @type == :block && @ast_class.nil?\n raise ArgumentError, \"Block level tag #{name} must have an AST class.\"\n end\n\n # Set attributes from optinos hash, currently unused during AST generation\n @attributes = options.fetch(:attributes, {})\n # WordML properties defined by the tag, i.e. <w:b /> for the <b> tag,\n # etc. All the keys need to be symbols to avoid getting reparsed\n # with the element's CSS attributes.\n @properties = options.fetch(:properties, {})\n @properties = Hash[@properties.map { |k, v| [k.to_sym, v] }]\n # Set permitted child tags or tag groups\n self.allowed_children = options[:allowed_children]\n end", "def initialize(type)\n\t\tsuper(type)\n\n\t\tself.tlvs = [ ]\n\tend", "def initialize(type)\n\t\tsuper(type)\n\n\t\tself.tlvs = [ ]\n\tend", "def new\n @tag = Tag.new\n end", "def initialize(tag, value = \"\")\n @tag = tag\n @value = value\n end", "def initialize(machine, name, options = T.unsafe(nil)); end", "def initialize(element)\n @html_string = element\n element = valid_tag(element) unless element.is_a? Array\n case element[0]\n when :start_element\n @name = element[2]\n @attributes = element[3]\n @children = (Array(element[4..-1]) || []).map {|c | TestTag.new c}\n when :text\n @text = element[1]\n @name = \"text\"\n @attributes = []\n @children = []\n end\n\n end", "def constructor; end", "def new(string_or_io, options = T.unsafe(nil)); end", "def new(string_or_io, options = T.unsafe(nil)); end", "def initialize\n @type = LENGTH\n @value = UNSET\n @value_list = [SHORT, LONG].freeze\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(type,text)\n\t\t@type = type\n\t\t@text = text\n\tend", "def initialize(arg, encoding = T.unsafe(nil)); end", "def new\n @theory = Theory.new\n end", "def initialize(machine, options = T.unsafe(nil)); end", "def initialize(datatype, lngth, array=nil)\n @struct = Numrb::Vec.const_get(\"Struct_#{datatype}\").new\n @struct[:dtype] = TYPES_AR.index(datatype)\n @struct[:size] = lngth\n @struct[:ptr] = Numrb::Vec::Data.new(lngth, STRIDES[datatype])\n if array\n @struct[:ptr].send(\"put_array_of_#{datatype}\", 0, array)\n end\n end", "def initialize(type,text)\n @type = type\n @text = text\n end", "def initialize(has_fields_of_type=nil)\n super(NAME, {}, VapiStruct)\n\n self.has_fields_of_type = has_fields_of_type\n end", "def initialize(type,template,version)\n self.type = type\n self.template = template\n self.version = version\n end", "def initialize( name, typus)\n\t\t@name, @typus = name, typus\n\tend", "def decode_tlv(data)\n raise OutOfData if (data.length == 2 && data[1].ord != 0) || data.length < 2\n tag = data[0].ord\n length = data[1].ord\n if length < 0x80\n value = data[2, length]\n remainder = data[length+2..-1]\n else\n # ASN.1 says this octet can't be 0xff\n raise InvalidLength, length.to_s if length == 0xff\n num_octets = length & 0x7f\n length = build_integer(data, 2, num_octets)\n value = data[num_octets+2, length]\n remainder = data[num_octets+2+length..-1]\n end\n return tag, value, remainder\n end", "def new(options=nil)\n Tidyobj.new(options)\n end", "def initialize(name, substring = T.unsafe(nil)); end", "def initialize(_name, options = {})\n @name = _name\n @type = options[:type] || :binary\n end", "def initialize(type,text)\r\n\t\t@type = type\r\n\t\t@text = text\r\n\tend", "def initialize(attributes = {})\n requires!(attributes, :tag, :password, :server)\n \n @tag = attributes[:tag]\n @password = attributes[:password]\n @server = attributes[:server]\n @port = attributes[:port] || 700\n @clTRID = attributes[:clTRID] || \"ABC-12345\"\n @old_server = attributes[:old_server] || false\n @lang = attributes[:lang] || 'en'\n end", "def initialize(options=nil)\n\n $test_logger.log(\"Initialize message with #{options}\")\n\n #Options available\n #\n #Eg: \"enroll.xml\"\n @xml_file_name = nil\n #\n #Eg: \"<Ping><Identifier>0x8</Identifier></Ping>\"\n @xml_str = nil\n #\n #Eg: \"Root/Request\", \"Root/Reply\", etc..\n @xml_ilv_tag = nil\n #\n #Eg: Response from device in raw format\n @ilv_raw_str = nil\n #\n #Eg: Response from device in hex format\n @ilv_hex_str = nil\n\n #Initial values\n @xml_doc = nil\n @xml_ilv_node = nil\n @is_parse_error = false\n @parse_error_message = \"\"\n @chk_serial_comm = false\n @is_reply_ilv = false\n\n #intialize default packet type and terminal identifier\n @pkt_type = PacketType::Data_PKT\n @ter_id = TERMINAL_ID\n @s_mode = SERIAL_MODE\n\n #Assign specified options to class varilables\n if options\n @xml_file_name = options[:xml_file_name] if options[:xml_file_name] != nil\n @xml_ilv_tag = options[:xml_ilv_tag] if options[:xml_ilv_tag] != nil\n @ilv_raw_str = options[:ilv_raw_str] if options[:ilv_raw_str] != nil\n @ilv_hex_str = options[:ilv_hex_str] if options[:ilv_hex_str] != nil\n @xml_str = options[:xml_str] if options[:xml_str] != nil\n end\n\n #Raise exceptions, if req\n #raise \"Option :xml_ilv_tag not specified\" if !@xml_ilv_tag\n #raise \"Option :xml_file_name not specified\" if !@xml_file_name\n raise \"Both options :ilv_raw_str and :ilv_hex_str cannot be specified at the same time!\" if @ilv_raw_str && @ilv_hex_str\n raise \"Both options :xml_file_name and :xml_str cannot be specified at the same time!\" if @xml_file_name && @xml_str\n\n #Process XML template/data\n if @xml_file_name\n #Raise error if xml file not found\n xml_file_path = File.join(FWConfig::DATA_FOLDER_PATH, FWConfig::XML_FOLDER,@xml_file_name)\n raise \"XML file does not exist in data folder!\\n#{xml_file_path}\" if !File.exist?(xml_file_path)\n\n #XML data from specified file\n xml_data = File.new xml_file_path\n else\n #Specified XML string\n if @xml_str\n xml_data = @xml_str\n #Default XML document\n else\n xml_data = DEF_XML_DOC\n end\n\n #Replace ruby string null character to XML null character\n if xml_data.include? \"\\x0\"\n xml_data.gsub!(\"\\x0\", NULL)\n null_replaced = true\n $test_logger.log(\"Ruby NULL character replaced with XML NULL char!\")\n end\n end\n\n begin\n #Initialize ILV tag\n @xml_doc = Document.new xml_data\n\n if @xml_ilv_tag\n xml_ilv_node = @xml_doc.elements[@xml_ilv_tag]\n #If specified ILV tag is not found in xml then create default reply\n if xml_ilv_node == nil\n @xml_doc = Document.new DEF_XML_DOC\n xml_ilv_node = @xml_doc.root\n end\n else\n\n xml_ilv_node = @xml_doc.elements[REQ_TAG] if !xml_ilv_node\n xml_ilv_node = @xml_doc.elements[REP_TAG] if !xml_ilv_node\n xml_ilv_node = @xml_doc.root if xml_ilv_node == nil\n end\n\n #Check if current ILV is reply ILV\n @is_reply_ilv = true if REP_TAG[/#{xml_ilv_node.name}/]\n\n #Update @xml_ilv_node to store only data from ilv node, i.e. discard parent nodes\n @xml_ilv_node = Document.new xml_ilv_node.to_s\n rescue Exception => ex\n $test_logger.log \"\\nError while parsing input XML data:\\n@@@@@@@@@@\\n#{xml_data}\\n@@@@@@@@@@\\n\", true\n raise\n end\n\n #If null character was replaced then replace back the original character\n if null_replaced\n replace_xml_str @xml_ilv_node, NULL, \"\\x0\"\n $test_logger.log(\"XML NULL character replaced back with ruby NULL char!\")\n end\n\n #Load data for specified input channel\n #RAW ILV str\n if @ilv_raw_str\n notify_change(InputChannel::RAW)\n #HEX ILV str\n elsif @ilv_hex_str\n notify_change(InputChannel::HEX)\n #Data from XML\n else\n notify_change(InputChannel::XML)\n end\n end", "def initialize(payload)\n @named_elements = {}\n super\n @type = read_byte\n instantiate!\n end", "def initialize(n='', i='voice', v='')\n @name = n\n @instrument = i\n @vice = v\n end", "def initialize(id, length, payload)\n\n # This field is parsed\n @id = id\n\n # This field is parsed\n @length = length\n\n # This field is not parsed (literally the bytes we were sent)\n @payload = payload\n end", "def from data\n obj = new\n obj.decode data\n obj\n end", "def initialize(data={})\n data = CXML.parse(data) if data.kind_of?(String)\n\n if data.kind_of?(Hash) && !data.empty?\n @code = data['code'].to_i\n @text = data['text']\n @xml_lang = data['xml:lang']\n end\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(tag)\n @tag = tag\n end", "def new\n \n end", "def initialize(attrs = {})\n # Tipo de Arma\n @kind = attrs[:tpArma]\n # Serie\n @serie = attrs[:nSerie]\n # Cano\n @barrel = attrs[:nCano]\n # Descricao\n @description = attrs[:descr]\n end", "def initialize(tag_name, text, types = nil, name = nil)\n @tag_name, @text, @name, @types = tag_name.to_s, text, name, (types ? [types].flatten.compact : nil)\n end", "def new\n @unit = Unit.new\n\n @unit.libe = :seigneur\n @unit.weapon = '-'\n @unit.amount = 1\n @unit.points = 0\n\n set_units_rules_data\n\n @edition_disabled = false\n\n set_hash_for_vue(false )\n end", "def new(*args)\n self.class.new(*args)\n end", "def initialize(data=\"\", subtype=:generic)\n @data = data\n @type = subtype\n puts \"subtype is #{subtype} and type is #{type}\"\n end", "def initialize(value)\n @value = value\n @type = self.class.type\n end", "def initialize(id, length, payload)\n @id = id\n @length = length\n @payload = payload\n end", "def initialize(literal)\n @literal = literal\n @lemmata = []\n end", "def initialize(attributes={})\n super\n attributes[:type] ||= T_REGULAR\n end", "def initialize(options = {})\n @tag_prefix = :str\n @type = StrVal\n @pt = SimpleTypedList.new(@type)\n parse_options options\n end", "def initialize(type = TYPES[:empty])\n @type = type\n end", "def initialize length\n self.length = length\n end", "def add_tlv(t,l,v=nil)\n tlv = [(t << 9) + l, v]\n self.payload += tlv.flatten.pack(\"na*\")\n end", "def initialize(type, content='', attr=nil)\n @type, @content, @attr = type, content, attr||OPTS\n end", "def initialize(v,c)\n # Su c ́odigo aqu ́ı\n end", "def initialize(data)\n self.class.get(data)\n end", "def new(*args)\n self.class.new(*args)\n end", "def init_parser(connection)\n version = connection.discover_aicc.first.appliance['version'] # getting the appliance version\n ManageIQ::Providers::Lenovo::Parser.get_instance(version)\n end", "def new #:nodoc:\n end", "def initialize(type, text)\n @type, @text = type, text\n end", "def initialize(type, text)\n @type, @text = type, text\n end", "def initialize(length)\n @length = length\n end", "def initialize(options = T.unsafe(nil)); end", "def initialize(options = T.unsafe(nil)); end", "def initialize(options = T.unsafe(nil)); end", "def initialize(options = T.unsafe(nil)); end", "def initialize(options = T.unsafe(nil)); end", "def initialize(options = T.unsafe(nil)); end", "def new\n # Create a new member_type instance that will be used in the form:\n @member_type = MemberType.new;\n end", "def initialize(machine, attrs = {})\n self.attrs = attrs\n self.machine = machine\n end", "def initialize bit_string_or_hash\n if bit_string_or_hash.kind_of?(Hash)\n @attributes = bit_string_or_hash\n pack_bit_fields\n else\n parse_bit_fields(bit_string_or_hash) #.dup.freeze REMOVED: seems useless\n end\n end", "def initialize string\n self.data = string\n end", "def initialize(an, tn, data=nil)\n @tn = tn.collect { |s| s.to_s }\n @an = an.collect { |s| s.to_s }\n @data = data || initdata\n end", "def add_field(type, value)# {{{\n t = TLV.new(2,2)\n t.type = type\n t.value = value\n t.length = 4 + value.length\n self.payload += t.encode \n end", "def initialize(arg1 = \"plum\\x00\\x00\\x00\\x00\".b, arg2 = nil)\n if !arg2\n raise ArgumentError.new(\"data must be 8 octets\") if arg1.bytesize != 8\n arg1 = arg1.b if arg1.encoding != Encoding::BINARY\n initialize_base(type: :ping, stream_id: 0, payload: arg1)\n else\n initialize_base(type: :ping, stream_id: 0, flags: [:ack], payload: arg2)\n end\n end", "def initialize(opts={})\n @value = nil\n @endian = opts[:endian] || NATIVE\n @opt_if = opts[:if]\n @parent = opts[:parent]\n end", "def new()\n #This is a stub, used for indexing\n end", "def initialize(type, content=nil)\n @type = type\n @content = content\n end", "def new_with_value(value, type = nil)\n BikeObject.new(self, value, type || @type)\n end", "def initialize(type,value)\n @type, @value = type, value\n\n end", "def new\n @bond = Bond.new\n end", "def new\n @element = Element.new\n end", "def initialize(vm, type, lt = nil, outer = nil, instructions = nil)\n hash = nil\n if type.is_a?(String)\n hash = JSON.parse(type)\n elsif type.is_a?(Hash)\n hash = type\n end\n\n if hash\n type = hash[:type]\n lt = hash[:local_table]\n outer = hash[:outer_scope]\n instructions = hash[:instructions]\n end\n\n self.vm = vm\n self.name = \"\\##{type}:#{Random.rand(0xFFFFFFFF).to_s(16)}\"\n self.type = type\n case type\n when :top\n clazz = Class.new(vm, 'Object', self, nil, true)\n vm.constant_table['Object'] = clazz\n self.entity = clazz\n self.constant_full_name = ''\n when :class\n self.entity = vm.define_class('a')\n self.constant_full_name = entity.name\n when :method\n when :block\n else\n raise Errors::TypeError\n end\n self.local_table = lt || {}\n self.outer_scope = outer || nil\n self.clazz = get_current_class\n self.instructions = instructions || []\n end" ]
[ "0.6402868", "0.6103011", "0.5926326", "0.5926326", "0.5908427", "0.5730844", "0.570433", "0.56687784", "0.5597977", "0.557782", "0.5570558", "0.5570558", "0.5564883", "0.54935753", "0.5487293", "0.54816663", "0.54783285", "0.5473276", "0.5473276", "0.5438282", "0.5424904", "0.5424904", "0.5424904", "0.5424904", "0.5424904", "0.54106784", "0.5410292", "0.5399879", "0.5399699", "0.53972095", "0.5393318", "0.5388155", "0.53840333", "0.5366311", "0.5360697", "0.5359696", "0.53498286", "0.5344244", "0.5340327", "0.53394926", "0.5339073", "0.5322989", "0.53170156", "0.5300455", "0.528622", "0.52793515", "0.52723503", "0.52723503", "0.52723503", "0.52723503", "0.52723503", "0.52723503", "0.52723503", "0.52723503", "0.52723503", "0.5265477", "0.52644396", "0.5252647", "0.5245952", "0.52402323", "0.52366424", "0.52347285", "0.5232913", "0.5231507", "0.5225871", "0.5224027", "0.52228266", "0.52173084", "0.52150476", "0.521284", "0.5202239", "0.5190229", "0.5183513", "0.51791155", "0.51727366", "0.51659983", "0.51628757", "0.51628757", "0.5160284", "0.5158493", "0.5158493", "0.5158493", "0.5158493", "0.5158493", "0.5158493", "0.5157186", "0.5156839", "0.51473546", "0.51428103", "0.5137627", "0.51337856", "0.5131769", "0.51309264", "0.5129861", "0.5118781", "0.510664", "0.51054484", "0.5101405", "0.5093712", "0.5093396" ]
0.57649475
5
Conditionals Checks to see if a TLVs meta type is equivalent to the meta type passed.
def meta_type?(meta) return (self.type & meta == meta) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def has_tlv?(type)\n\t\treturn get_tlv(type) != nil\n\tend", "def has_tlv?(type)\n\t\treturn get_tlv(type) != nil\n\tend", "def term?\n type.in?(%i[tag metatag wildcard all none])\n end", "def meta?\n @meta\n end", "def type?( in_type )\n type == in_type\n end", "def is_multi?\n return false if metadata[:type].nil? or @@KNOWN_TYPES[type].nil?\n @@KNOWN_TYPES[type][:multi]\n end", "def is_tipo_v?\n self.tipo.eql?('V')\n end", "def check_and_set_string_type\n key = self.key.to_sym\n if KEY_TO_STRING_OPTIONS.key?(key)\n # If there are explicit string options, match the value to one of them.\n matched = false\n options = KEY_TO_STRING_OPTIONS[key]\n options.each do |opt|\n if Metadatum.str_to_basic_chars(text_raw_value) == Metadatum.str_to_basic_chars(opt)\n # Ex: Match 'neb ultra-iifs dna' to 'NEB Ultra II FS DNA'\n # Ex: Match '30-day mortality' to \"30 Day Mortality\"\n self.text_validated_value = opt\n matched = true\n break\n end\n end\n unless matched\n errors.add(:text_raw_value, \"#{text_raw_value} did not match options #{options.join(', ')}\")\n end\n else\n self.text_validated_value = text_raw_value\n end\n end", "def custom?\n self.type.blank?\n end", "def is_nonmulti?\n return false if metadata[:type].nil? or @@KNOWN_TYPES[type].nil?\n !@@KNOWN_TYPES[type][:multi]\n end", "def taxonomic_enforced\n if type_of_tag == 'common_name' || type_of_tag == 'species_name'\n errors.add(:is_taxonomic, \"must be true for #{type_of_tag}\") unless is_taxonomic\n elsif is_taxonomic\n errors.add(:is_taxonomic, \"must be false for #{type_of_tag}\")\n end\n end", "def meta?\r\n self.class.meta?\r\n end", "def test? value\n value.nil? || @type.test?( value )\n end", "def multiple_type?(node)\n node.name == 'content' && !node.attributes['type'].nil?\n end", "def check_type(type)\n %w{galera mysql}.each do |t|\n return true if t == type\n end\n false\n end", "def field_is_correct_type?(field)\n return type == :general if field.key.to_sym == :exhibit_tags\n\n field.section == type\n end", "def mix_type_ok?(item)\n Bubs::Mix::MIX_TYPES.include?(item.mix_type)\n end", "def loose_match?(unit)\n return false if @type != unit.type\n return false if custom? && @custom_name.casecmp(unit.custom_name) != 0\n true\n end", "def method_missing(name, *args, &block)\n if name.to_s =~ /\\?$/ && args.empty?\n if @field_variants.any? { |variant| \"#{variant.attribute}?\" == name.to_s }\n 'true'\n else\n 'false'\n end\n else\n super(name.to_sym, *args, &block)\n end\n end", "def is?(term, type_sym)\n return term[:type] == type_sym\n end", "def type_of?(type)\n type.raw_type == raw_type\n end", "def correct_type?(object)\n object.type == type\n end", "def same_type_guard?\n @type_guard == true\n end", "def type?(type)\n return (type1 == type || type2 == type || type3 == type)\n end", "def member_uses_custom_type?(field)\n field.type.schemas.any? do |klass|\n Avromatic.type_registry.fetch(klass) != NullCustomType\n end\n end", "def custom?(type)\n !primitive?(type) &&\n !structure?(type) &&\n !multiple?(type) &&\n type.respond_to?(:parse) &&\n type.method(:parse).arity == 1\n end", "def type_guard?\n same_type_guard? || specific_type_guard?\n end", "def is_datatype?(); @type == GRT_DATATYPE; end", "def homogeneous?\n asset_type_ids.length == 1\n end", "def most_specific_type(from_magic_type, fallback_type); end", "def most_specific_type(from_magic_type, fallback_type); end", "def check_type\n \t self.type = TYPES[0] if !TYPES.include?(self.type)\n\t end", "def alien?() is_type?( 'Alien'); end", "def translatable?\n [16, 24, 25].include? f_type\n end", "def check_box_type?\n self[:value][:type].to_s\n end", "def builtin_type?\n\t\ttrue\n\tend", "def type?(type)\n\t\treturn self.type == type\n\tend", "def type?(type)\n\t\treturn self.type == type\n\tend", "def builtin_type?\n\t\tfalse\n\tend", "def ltype?\n return true\n end", "def plain_string?\n (type == :string || type == :text) && # String typed\n !value.nil? &&\n !value.empty? &&\n !is_text_run? && # No inline styles\n !is_formula? &&\n !is_array_formula?\n end", "def match?(attribute, type = nil, **options)\n if @attribute != attribute || (type && @type != type)\n return false\n end\n\n options.each do |key, value|\n if @options[key] != value\n return false\n end\n end\n\n true\n end", "def match?(attribute, type = nil, **options)\n if @attribute != attribute || (type && @type != type)\n return false\n end\n\n options.each do |key, value|\n if @options[key] != value\n return false\n end\n end\n\n true\n end", "def compatible?(other_definition)\n return true if meta_data.nil? && other_definition.meta_data.nil?\n return true if meta_data && meta_data.same_keys?(other_definition.meta_data)\n false\n end", "def valid_type?(key, value)\n if [TrueClass, FalseClass].include? @defaults[key].class\n return [TrueClass, FalseClass].include? value.class\n end\n value.is_a? @defaults[key].class\n end", "def tt? tag\n tag.bit == @tt_bit\n end", "def is_meta_tuple? tuple\n if meta_subspace\n meta_subspace === tuple\n else\n # meta_subspace hasn't arrived yet, so use approximation\n tuple.kind_of? Hash and tuple.key? client.tupelo_meta_key and\n tuple[client.tupelo_meta_key] == \"subspace\"\n end\n end", "def is_tipo_a?\n self.tipo.eql?('A')\n end", "def value_type?\n VALUE_TYPES.include?(expected_type)\n end", "def plain?\n language.nil? && datatype.nil?\n end", "def include?(item, kind)\n case kind\n when :item\n item.is_a?(RPG::Item) && !item.key_item?\n when :weapon\n item.is_a?(RPG::Weapon)\n when :armor\n item.is_a?(RPG::Armor) && item.etype_id == 3\n when :shield\n item.is_a?(RPG::Armor) && item.etype_id == 1\n when :helmet\n item.is_a?(RPG::Armor) && item.etype_id == 2\n when :boot\n item.is_a?(RPG::Armor) && item.etype_id == 4\n when :key_item\n item.is_a?(RPG::Item) && item.key_item?\n else\n false\n end\n end", "def has_type?(type_sym)\n each_term do |term|\n if is?(term, type_sym)\n return true\n end\n end\n \n false\n end", "def match_and_type?(expected)\n match?(expected) ? @lookahead.type : nil\n end", "def needs_word?\n if has_type? :reference\n return true\n end\n \n if has_type? :literal\n return true\n end\n \n #otherwise it is only a register or raw special value\n return false\n end", "def is_met?(response)\n klass = response.answer.response_class\n return case self.operator\n when \"==\", \"<\", \">\", \"<=\", \">=\"\n response.as(klass).send(self.operator, self.as(klass))\n when \"!=\"\n !(response.as(klass) == self.as(klass))\n else\n false\n end\n end", "def type_normal?\n return type?(GameData::Types::NORMAL)\n end", "def is_texttype?(); @type == GRT_TEXTTYPE; end", "def tt?(tag)\n tag.bit == @tt_bit\n end", "def generated_unity3d_meta?\n return false unless extname == '.meta'\n return false unless lines.count > 1\n return lines[0].include?(\"fileFormatVersion: \")\n end", "def is_of_same_type_as?(other_ke)\n type == other_ke.type &&\n attr.reject { |k,v| 'id' == k } == other_ke.attr.reject { |k,v| 'id' == k } &&\n options.reject { |k,v| :location == k } == other_ke.options.reject { |k,v| :location == k }\n end", "def is_kind? k, itm\n itm.attributes[:kind] == k\nend", "def has_type?\n ! get_internal_word(TYPE_INDEX).nil?\n end", "def is_type_diff?(left, right)\n l_class = left.class\n r_class = right.class\n\n if left.nil? && r_class == String && right.empty? || right.nil? && l_class == String && left.empty?\n # undef vs. ''\n true\n elsif l_class <= Puppet::Pops::Types::PAnyType && r_class <= String || r_class <= Puppet::Pops::Types::PAnyType && l_class <= String\n # Type vs. Numeric (caused by uc bare word being a type and not a string)\n true\n elsif l_class <= Numeric && r_class <= String || r_class <= Numeric && l_class <= String\n # String vs. Numeric\n true\n else\n # hash, array, booleans and regexp, etc are only true if compared against same type - no difference between 3x. and 4.x\n # or this is a same type comparison (also the same in 3.x. and 4.x)\n false\n end\n end", "def valid?(type, value, type_name = nil)\n if value.is_a? type\n return true\n elsif !!value == value && type == TrueClass #check for boolean\n return true\n else\n raise \"Error: #{type_name || type.name} was excepted. #{value.class.name} was recieved\"\n end\n end", "def guard(ot)\n self.class.typecasts.each do |fld, tc|\n type = tc[:ot_as] || tc[:as]\n set_guard(ot, fld, type) if type\n end\n end", "def applyKind(x)\n if x.kind == @value\n return true\n else\n return false\n end\n end", "def categorical?\n value_type == \"Category\"\nend", "def string?\n type == \"STRING\"\n end", "def is_met?(response)\n klass = response.answer.response_class\n return case self.operator\n when \"==\", \"<\", \">\", \"<=\", \">=\"\n response.as(klass).send(self.operator, self.as(klass))\n when \"!=\"\n !(response.as(klass) == self.as(klass))\n else\n false\n end\n end", "def kind_of\n <<-CODE\n t1 = stack_pop();\n t2 = stack_pop();\n if(ISA(t1, t2)) {\n stack_push(Qtrue);\n } else {\n stack_push(Qfalse);\n }\n CODE\n end", "def object_type?\n !value_type?\n end", "def type?\n !@type.nil? && @type != :any\n end", "def alternative?(part)\n part.sub_type.downcase == 'alternative'\n end", "def treatable?\n @is_treatable ||= real_mot?\n end", "def dual_wield?\r\n slot_type == 1\r\n end", "def needs_encoding?\n ![ :binary, :date, :datetime, :boolean, :float, :integer ].include?(type)\n end", "def is_string?(); @type == GRT_STRING; end", "def needs_encoding?\n ![ :binary, :date, :datetime, :boolean, :float, :integer ].include?(type)\n end", "def has_type?\n ! type.nil?\n end", "def flag?\n return @type == 'x' || @type.nil?\n end", "def get_type(value) #method\n if value == 'verdadero'\n true\n elsif value == 'falso'\n false\n elsif value.include? '.'\n value.to_f\n elsif value.scan(/\\D/).empty?\n value.to_i\n else\n value\n end\n end", "def valid_type?(type)\n super || extended_types.include?(type)\n end", "def dummy?\n @type.nil?\n end", "def matches?(actual)\n matches_type?(actual)\n end", "def html_meta_if(name, content)\n %(<meta name=\"#{name}\" content=\"#{content}\">) if content\n end", "def ambiguous_reciprocal_type?\n true\n end", "def unknown?\n @type == 'TYPE_UNSPECIFIED'\n end", "def type?\n @data[:type].empty? ? false : true\n end", "def is_propvalue?(); @type == GRT_PROPVALUE; end", "def will_be?(type)\n single_class <= type\n end", "def same_types?(other)\n types == other.types\n end", "def meta_content_type(body); end", "def meta_uri?\n return components.size == 1 && components[0] == 'cloudkit-meta'\n end", "def has_meta_tag?(name, content)\n has_selector?(:xpath, \"/html/head/meta#{meta_tag_locator(name, content)}\", visible: false)\n end", "def homogeneous?(other)\n return false if self == other\n return nil if [self, other].any? { |e| e.date.nil? }\n self.date == other.date &&\n title_similar?(self.title, other.title)\n end", "def has_loan_type_conditions?\n loan_type_uids != LOAN_TYPE_UIDS\n end", "def is_metro_cuadrado_type?\n tag_name.eql?(METRO_CUADRADO)\n end", "def test? value\n ! type.test( value )\n end", "def value_type?\n @property.value_type?\n end" ]
[ "0.59200716", "0.59200716", "0.55792856", "0.55123144", "0.54043", "0.53813577", "0.535251", "0.53254145", "0.53163666", "0.5311763", "0.5309913", "0.52808046", "0.5193332", "0.51906294", "0.51764625", "0.5174394", "0.51338243", "0.5090406", "0.5084725", "0.5083678", "0.5075926", "0.50750965", "0.50742966", "0.5069398", "0.50538164", "0.5048615", "0.50467676", "0.5045272", "0.5043249", "0.50322115", "0.50322115", "0.5022025", "0.5015861", "0.5015772", "0.5013989", "0.5008613", "0.49705246", "0.49705246", "0.4961819", "0.49521106", "0.49478394", "0.49450397", "0.49450397", "0.4942661", "0.49340883", "0.49260494", "0.49220622", "0.49184877", "0.49055985", "0.48960245", "0.4870875", "0.48642954", "0.48623523", "0.48533836", "0.48314598", "0.48263952", "0.48217645", "0.4815683", "0.48145398", "0.48082632", "0.4805117", "0.48027873", "0.48023814", "0.47997105", "0.47981822", "0.4795373", "0.47943047", "0.47900033", "0.4789142", "0.4782088", "0.47743034", "0.4765502", "0.47626013", "0.47617242", "0.4754356", "0.47514322", "0.47499087", "0.47497633", "0.47409475", "0.4740443", "0.47360867", "0.4734037", "0.4731697", "0.47301432", "0.4727118", "0.47208452", "0.4720776", "0.4713465", "0.47124127", "0.4708869", "0.47071794", "0.47038472", "0.4703741", "0.47030917", "0.46990937", "0.46988818", "0.46985972", "0.46930164", "0.46900636" ]
0.70168734
1
Checks to see if the TLVs type is equivalent to the type passed.
def type?(type) return self.type == type end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def type_of?(type)\n type.raw_type == raw_type\n end", "def type?( in_type )\n type == in_type\n end", "def has_tlv?(type)\n\t\treturn get_tlv(type) != nil\n\tend", "def has_tlv?(type)\n\t\treturn get_tlv(type) != nil\n\tend", "def check_type(type)\n %w{galera mysql}.each do |t|\n return true if t == type\n end\n false\n end", "def type?(type)\n type = type.to_str\n\n types = param('TYPE')\n\n if types\n types = types.detect { |t| Vpim::Methods.casecmp?(t, type) }\n end\n end", "def correct_type?(object)\n object.type == type\n end", "def type?(type)\n return (type1 == type || type2 == type || type3 == type)\n end", "def matches_type? value, expected_type: type\n case expected_type\n # Raw class types\n when Array\n case expected_type.length\n when 0\n return value.is_a?(Array)\n when 1\n return value.all?{ |v| matches_type?(v, expected_type: expected_type[0]) }\n else\n return expected_type.zip([value].flatten(1)).all?{ |t, v| matches_type?(v, expected_type: t) }\n end\n else\n value.is_a?(expected_type)\n end\n end", "def check_type\n \t self.type = TYPES[0] if !TYPES.include?(self.type)\n\t end", "def is_type_diff?(left, right)\n l_class = left.class\n r_class = right.class\n\n if left.nil? && r_class == String && right.empty? || right.nil? && l_class == String && left.empty?\n # undef vs. ''\n true\n elsif l_class <= Puppet::Pops::Types::PAnyType && r_class <= String || r_class <= Puppet::Pops::Types::PAnyType && l_class <= String\n # Type vs. Numeric (caused by uc bare word being a type and not a string)\n true\n elsif l_class <= Numeric && r_class <= String || r_class <= Numeric && l_class <= String\n # String vs. Numeric\n true\n else\n # hash, array, booleans and regexp, etc are only true if compared against same type - no difference between 3x. and 4.x\n # or this is a same type comparison (also the same in 3.x. and 4.x)\n false\n end\n end", "def __typedeaf_valid_type?(value, type)\n return value.is_a? type\n end", "def valid_type?(type)\n !native_database_types[type].nil?\n end", "def same_types?(other)\n types == other.types\n end", "def check_type(type, value)\n return unless type && value && !value.is_a?(type)\n\n \"should be of type #{type} but is of type #{value.class}\"\n end", "def valid_type?(type)\n super || extended_types.include?(type)\n end", "def will_be?(type)\n single_class <= type\n end", "def is?(btype)\n type == btype\n end", "def has_etype?(etype)\n mask_for_etype = self.class.mask_from_etype(etype)\n return (self.mask & mask_for_etype).eql?(mask_for_etype)\n end", "def has_type?\n ! get_internal_word(TYPE_INDEX).nil?\n end", "def eql?(other)\n type == other.to_s\n end", "def same_type_guard?\n @type_guard == true\n end", "def matches?(actual)\n matches_type?(actual)\n end", "def valid?(type, value, type_name = nil)\n if value.is_a? type\n return true\n elsif !!value == value && type == TrueClass #check for boolean\n return true\n else\n raise \"Error: #{type_name || type.name} was excepted. #{value.class.name} was recieved\"\n end\n end", "def check_for_label_type_mismatch(r, label, type)\n prev_label_pair = r.attr_label_name_space.get(label.get_text)\n if (!(prev_label_pair).nil?)\n # label already defined; if same type, no problem\n if (!(prev_label_pair.attr_type).equal?(type))\n type_mismatch_expr = RJava.cast_to_string(Grammar::LabelTypeToString[type]) + \"!=\" + RJava.cast_to_string(Grammar::LabelTypeToString[prev_label_pair.attr_type])\n ErrorManager.grammar_error(ErrorManager::MSG_LABEL_TYPE_CONFLICT, @grammar, label, label.get_text, type_mismatch_expr)\n return true\n end\n end\n return false\n end", "def has_type?\n ! type.nil?\n end", "def valid_type?(data_type)\n object_type = @plural_form ||\n @object_instance.class.name.pluralize.underscore.dasherize\n unless data_type == object_type\n return set_failure_message(\n format(FailureMessages::DATA_TYPE_MISMATCH, data_type, object_type)\n )\n end\n true\n end", "def valid_ape_type?(type)\n ITEM_TYPES.include?(type)\n end", "def valid_type?\n %w[ip domain cert].include? type\n end", "def conforms(type1, type2)\n\twhile true\n\t\tif type1 == type2\n\t\t\treturn true\n\t\tend\n\n\t\tif (type1 == \"Object\")\n\t\t\tbreak\n\t\telse\n\t\t\ttype1 = $p_map[type1]\n\t\tend\n\tend\n\n\treturn false\nend", "def can_convert?(type)\n get_entry(type) ? true : false\n end", "def valid?\n ENUM.include? @type.downcase.to_sym\n end", "def type?\n !@type.nil? && @type != :any\n end", "def valid_type?\n %w[ip domain].include? type\n end", "def valid?\n !type.nil?\n end", "def valid?\n !type.nil?\n end", "def check_typecode(v)\n if TYPECODE.include?(v)\n return true\n else\n raise InvalidComponentError,\n \"bad typecode(expected #{TYPECODE.join(', ')}): #{v}\"\n end\n end", "def has_type?(type_sym)\n each_term do |term|\n if is?(term, type_sym)\n return true\n end\n end\n \n false\n end", "def subtype?(t1, t2)\n return true if t1 == t2\n fclass(t2) # Check existance of class t2\n return fclass(t1).descendant_of?(t2)\n end", "def check_type(val, type)\n if val.class != type\n raise TypeError\n end\nend", "def compare_fstype(type1, type2)\n type1 == type2 || _normalize_type(type1) == _normalize_type(type2)\n end", "def is(type)\n @value.include?(type)\n end", "def is_typed?(key, type)\n return (!datas.has_key?(key) or datas[key].kind_of?(type))\n end", "def is_datatype?(); @type == GRT_DATATYPE; end", "def pbHasType?(type)\n if type.is_a?(String) || type.is_a?(Symbol)\n type = getID(PBTypes,type)\n end\n for pokemon in $Trainer.pokemonParty\n return true if pokemon.hasType?(type)\n end\n return false\nend", "def ltype?\n return true\n end", "def is?(term, type_sym)\n return term[:type] == type_sym\n end", "def kind_of?(p0) end", "def is_tipo_v?\n self.tipo.eql?('V')\n end", "def conforms(type1, type2)\n\tif type1 == \"SELF_TYPE\" and type2 == \"SELF_TYPE\"\n\t\treturn true\n\tend\n\n\tif type1 == \"SELF_TYPE\" and type2 != \"SELF_TYPE\"\n\t\treturn conforms(get_class_context(), type2)\n\tend\n\n\tif type1 != \"SELF_TYPE\" and type2 == \"SELF_TYPE\"\n\t\treturn false\n\tend\n\n\tif type1 != \"SELF_TYPE\" and type2 != \"SELF_TYPE\"\n\t\t# (T, T')\n\t\twhile true\n\t\t\tif type1 == type2\n\t\t\t\treturn true\n\t\t\tend\n\n\t\t\tif (type1 == \"Object\")\n\t\t\t\tbreak\n\t\t\telse\n\t\t\t\ttype1 = $p_map[type1]\n\t\t\tend\n\t\tend\n\n\t\treturn false\n\tend\nend", "def valid?(value)\n @type_checker.valid?(value)\n end", "def current_is_a?(type)\n assit_kind_of(Class, type)\n @current.attributes['type'] && (\"TaliaCore::#{@current.attributes['type']}\".constantize <= type)\n end", "def match_and_type?(expected)\n match?(expected) ? @lookahead.type : nil\n end", "def value_type?\n VALUE_TYPES.include?(expected_type)\n end", "def type_allowed? type # Will check if the type is included in the list_types hash\n return @@list_types.keys.include?(type.to_sym)\n end", "def valid_itemtype?(valid_types, itemtype)\n return true if valid_types.include?(:any)\n vocabulary = Vocabulary.find(itemtype)\n valid_types.find {|type| vocabulary.kind_of?(type) }\n end", "def assignable_PRubyType(t1, t2)\n return false unless t2.is_a?(Types::PRubyType)\n c1 = class_from_string(t1.ruby_class)\n c2 = class_from_string(t2.ruby_class)\n return false unless c1.is_a?(Class) && c2.is_a?(Class)\n !!(c2 <= c1)\n end", "def alien?() is_type?( 'Alien'); end", "def type_check(type = nil)\n children {|child| type = child.type_check(nil)}\n return type\n end", "def string?\n type == \"STRING\"\n end", "def field_is_correct_type?(field)\n return type == :general if field.key.to_sym == :exhibit_tags\n\n field.section == type\n end", "def type_guard?\n same_type_guard? || specific_type_guard?\n end", "def valid?\n return false if @type.nil?\n return true\n end", "def validate_type(type, context:); end", "def has_type?(type_)\n @mutex.synchronize do\n @types.has_key?(type_)\n end\n end", "def is_boxtype?(); @type == GRT_BOXTYPE; end", "def match?(attribute, type = nil, **options)\n if @attribute != attribute || (type && @type != type)\n return false\n end\n\n options.each do |key, value|\n if @options[key] != value\n return false\n end\n end\n\n true\n end", "def match?(attribute, type = nil, **options)\n if @attribute != attribute || (type && @type != type)\n return false\n end\n\n options.each do |key, value|\n if @options[key] != value\n return false\n end\n end\n\n true\n end", "def of_kind?(attribute, type = :invalid)\n attribute, type = normalize_arguments(attribute, type)\n\n if type.is_a? Symbol\n !where(attribute, type).empty?\n else\n messages_for(attribute).include?(type)\n end\n end", "def supports_type? type\n if type.is_a? Class\n type.to_packed\n elsif type.is_a? Array\n return type.detect{|obj| not supports_type? obj }.nil?\n else\n type.class.to_packed\n end\n return true\n rescue NoMethodError\n return false\n end", "def is_ustring?(); @type == GRT_USTRING; end", "def datatype?(elora, die=nil)\n die = @proofsheet.die(elora.inherited_namespace, elora.absolute_xpath) if not die\n validity = true # default cdata, so valid\n if die\n if die.datatype\n dts = Datatypes.new\n if not dts.valid?(die.datatype, content(elora))\n validity = false\n error = \"DATATYPE '#{content(elora)}' :#{die.datatype}:\"\n @errors << [die.namespace, die.xpath, error]\n end\n end\n end\n return validity\n end", "def needs_encoding?\n ![ :binary, :date, :datetime, :boolean, :float, :integer ].include?(type)\n end", "def checkDom(type)\n @dom == type\n end", "def test? value\n value.nil? || @type.test?( value )\n end", "def is_strtype?(); @type == GRT_STRTYPE; end", "def check_rsvp_type(rsvp)\n raise \"Incompatible RSVP, should be #{rsvp_type}\" unless rsvp.class.to_s == rsvp_type\n end", "def type_supported?(type)\n Sequel.synchronize{return @supported_types[type] if @supported_types.has_key?(type)}\n supported = from(:pg_type).where(:typtype=>'b', :typname=>type.to_s).count > 0\n Sequel.synchronize{return @supported_types[type] = supported}\n end", "def does_not_match?(actual)\n !matches_type?(actual)\n end", "def does_not_match?(actual)\n !matches_type?(actual)\n end", "def is_valid?(types, item)\n types.each do |type|\n if type == :ipv4\n return true if ipv4?(item)\n elsif type == :domain\n return true if domain?(item)\n elsif type == :hash\n return true if hash?(item)\n elsif type == :classification\n return true if classification?(item)\n elsif type == :tag\n return true if tag?(item)\n elsif type == :bool\n return true if bool?(item)\n elsif type == :ssl_field\n return true if ssl_field?(item)\n elsif type == :whois_field\n return true if whois_field?(item)\n elsif type == :tracker_type\n return true if tracker_type?(item)\n end\n end\n return false\n end", "def conforms_to?(type1, type2)\n get_cls = ->(type){\n if type.is_a?(TyParam)\n find_class('Object')\n else\n find_class(type.name)\n end\n }\n cls1, cls2 = get_cls[type1], get_cls[type2]\n return cls1 == cls2 || cls1.subclass_of?(cls2, self)\n end", "def is_of_same_type_as?(other_ke)\n type == other_ke.type &&\n attr.reject { |k,v| 'id' == k } == other_ke.attr.reject { |k,v| 'id' == k } &&\n options.reject { |k,v| :location == k } == other_ke.options.reject { |k,v| :location == k }\n end", "def valid_input_type?\n case @search_type\n when \"Pokemon Name\", \"Type\"\n !@search_menu_input.match?(/\\d/) \n when \"Pokedex Number\"\n !@search_menu_input.match?(/\\D/)\n end\n end", "def type?\n @data[:type].empty? ? false : true\n end", "def include?(singleton_type)\n if singleton_type.is_union_type?\n raise AssertionError.new(\"Union type can never be included in union type\")\n end\n\n @types.include?(singleton_type)\n end", "def needs_encoding?\n ![ :binary, :date, :datetime, :boolean, :float, :integer ].include?(type)\n end", "def typed?\n type != :object\n end", "def is_type? sym\n self.class == Content::TYPES[sym]\n end", "def is_string?(); @type == GRT_STRING; end", "def eql?(other)\n other.is_a?(MIME::Type) && (self == other)\n end", "def check?(token_type)\n return false if at_end?\n return peek.type == token_type\n end", "def sc_kind_of?(type)\n if not (type.kind_of?(Class) or type.kind_of?(String))\n raise ArgumentInvalidTypeError.new \"type\", type, 'class < SCObject', String\n end\n \n if type.kind_of?(Class) and type.ancestors.member?(SCObject)\n type = type.represented_sc_class\n end\n \n type = type.downcase\n result = sc_all_classes.detect do |val| \n val.downcase == type\n end\n return (not result.nil?)\n end", "def check_box_type?\n self[:value][:type].to_s\n end", "def multiple_type?(node)\n node.name == 'content' && !node.attributes['type'].nil?\n end", "def meta_type?(meta)\n\t\treturn (self.type & meta == meta)\n\tend", "def meta_type?(meta)\n\t\treturn (self.type & meta == meta)\n\tend", "def test? value\n ! type.test( value )\n end", "def type?(*types)\n types.each &method(:assert_simple_type)\n existing = get('type', nil)\n if existing.is_a? Json::Array\n (existing.to_a & types).any?\n else\n types.include? existing\n end\n end" ]
[ "0.68759", "0.6807026", "0.67534614", "0.67534614", "0.6587615", "0.64330775", "0.64236933", "0.6405375", "0.6294758", "0.6284693", "0.6276997", "0.6261629", "0.6256036", "0.6227613", "0.6180734", "0.61251134", "0.60295665", "0.5990569", "0.5987478", "0.59523165", "0.59264225", "0.5902883", "0.5896596", "0.58806264", "0.5853088", "0.5828181", "0.5823948", "0.5792446", "0.57531005", "0.57325", "0.57324", "0.572602", "0.5724663", "0.5689997", "0.5667905", "0.5667905", "0.5661657", "0.5659891", "0.5649513", "0.5637449", "0.56149834", "0.5610324", "0.5602077", "0.5596802", "0.5572206", "0.5566182", "0.5551616", "0.5549723", "0.5544701", "0.5541656", "0.5537752", "0.55286187", "0.5528442", "0.5527842", "0.5523162", "0.5518638", "0.55161494", "0.5497704", "0.54880065", "0.5483619", "0.5472892", "0.5445882", "0.54453087", "0.5437196", "0.5428162", "0.5417369", "0.54088235", "0.54088235", "0.53939456", "0.53905666", "0.5381517", "0.5374464", "0.53648406", "0.53615284", "0.53586715", "0.5351528", "0.5350472", "0.5339717", "0.5337869", "0.5337869", "0.53354996", "0.5330601", "0.53244954", "0.53111625", "0.53080887", "0.5307429", "0.53027314", "0.52937245", "0.5291707", "0.52889854", "0.52809453", "0.52725804", "0.5267036", "0.5266272", "0.5260477", "0.5259009", "0.5259009", "0.5249569", "0.52483314" ]
0.63684654
9
Checks to see if the TLVs value is equivalent to the value passed.
def value?(value) return self.value == value end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_raw_value(value)\n check(value, {\n :type => :uint8,\n :count => (size < 1 ? 1 : size),\n :length => 1,\n :bit_length => 8,\n :sign => :unsigned,\n :default_value => 0,\n })\n end", "def valid_value?\n if ape_type == 'utf8' || ape_type == 'external'\n # :nocov:\n if RUBY_VERSION >= '1.9'\n # :nocov:\n begin\n map!{|v| v.to_s.encode('UTF-8')}\n rescue EncodingError\n return false\n end\n end\n string_value.unpack('U*')\n end\n rescue ArgumentError\n false\n else\n true\n end", "def value?(value)\n Vpim::Methods.casecmp?(@value, value.to_str)\n end", "def value?(value) true end", "def ace_value?(value)\n value.size == 2\n end", "def value?(value)\n wrap(value, ->(a, b) { a == b })\n end", "def validate_value(v)\n Card::VALID_VALUES.include?(v)\n end", "def ==(value)\n #\n # Bitstring/bitstring comparison\n #\n unless (value.class == self.class)\n value = _arg2int(value)\n if (self.bounded?)\n bits = [self.length, value.to_s(2).length].max\n value = self.class.new(value, bits)\n else\n value = self.class.new(value)\n end\n end\n ((self.class == value.class) &&\n (self.bounded? == value.bounded?) &&\n (self.length == value.length) &&\n (@value == value.to_i))\n end", "def valid?(v)\n values.include?(normalize(v))\n end", "def check(value)\n # We have to invert the values.\n if value == :true\n false\n else\n true\n end\n end", "def test? value\n begin\n @pairs.all? { |k, v| v === value[k] }\n rescue\n false\n end\n end", "def value?(value); end", "def value?(value); end", "def check(value)\n # We have to invert the values.\n if value == :true\n false\n else\n true\n end\n end", "def has_value?(p0) end", "def valid_value?(value)\n check_validation(value)\n end", "def check_for_valid_comparison(property, value)\r\n #We want to ignore certain things for translation as defined here.\r\n status = !(check_for_hyperlink(value) or check_for_number(value) or check_for_hex(value) or check_for_embed(value) or check_for_ignore(property))\r\n end", "def rebus_value?(v)\n v && v.size > 1\n end", "def changed_in_place?(raw_old_value, new_value)\n deserialize(raw_old_value) != new_value\n end", "def changed_in_place?(raw_old_value, new_value)\n deserialize(raw_old_value) != new_value\n end", "def check_value(v, options = {:length => 0x1})\n array :initial_length => options[:length] do\n uint32 :check_value => lambda { value == v }\n end\n end", "def check_value(value)\n case value\n when 'true'\n true\n when 'false'\n false\n else\n value\n end\n end", "def values_sndiff_equal?(bav, pav)\n bav == pav || string_numeric_diff_ignored? && bav.is_a?(String) && pav.is_a?(Numeric) && to_number_or_nil(bav) == pav\n end", "def test? value\n ! type.test( value )\n end", "def value?(p0) end", "def has_value?(value); end", "def bt_same_value?(other)\n bt_value_attributes == other.bt_value_attributes\n end", "def value?\n !element_value.nil? && element_value != ''\n end", "def value?(value) value.is_a?(String) end", "def valid?(v)\n normalize(v).present?\n end", "def valid?(v)\n normalize(v).present?\n end", "def equivalent?(field)\n return true if eql?(field) # Might be faster, so testing this first\n\n if field.respond_to?(native_fun)\n if field.is_a?(GFA::Field) && native_fun == :to_s\n field.to_s(false) == to_native\n else\n field.send(native_fun) == to_native\n end\n else\n field == value\n end\n end", "def is?(val)\n return true if @val == val\n end", "def has_value?(value)\n super(convert_value(value))\n end", "def changed?(old_value, new_value, _new_value_before_type_cast)\n old_value != new_value\n end", "def eql?(other)\n\t if other.respond_to?(:units)\n\t\t(@units == other.units) and (@value == other.value)\n\t elsif other == 0\n\t\t@value == other\n\t else\n\t\t(@units == nil) and (@value == other)\n\t end\n\tend", "def is_value?(value)\n\t\tvalue.to_i < 10\n\tend", "def ==(other)\n case other\n when Literal\n self.value.eql?(other.value) &&\n self.language.eql?(other.language) &&\n self.datatype.eql?(other.datatype)\n when String\n self.plain? && self.value.eql?(other)\n else false\n end\n end", "def has_value? value; value? value; end", "def matches?(value)\n value.kind_of?(primitive)\n end", "def acceptable?(value)\n true\n end", "def check\n if @value1 == @value2\n @message = \"#{@value1} == #{@value2}\"\n true\n else\n @message = \"#{@value1} != #{@value2}\"\n false\n end\n end", "def check_value!(value)\n # Allow nil and Strings to fall back on the validations for typecasting\n case value\n when nil, String, expected_type\n value\n else\n raise TypeError, \"#{@name} expected #{expected_type.inspect} but got #{value.inspect}\"\n end\n end", "def value_ok(unit, value_to_convert)\n is_ok = case unit\n when :celsius then\n begin\n celsius_min = -273.15\n value_to_convert > celsius_min\n end\n when :fahrenheit then\n begin\n fahrenheit_min = -459.67\n value_to_convert > fahrenheit_min\n end\n when :kelvin then\n begin\n kelvin_min = 0\n value_to_convert > kelvin_min\n end\n else false\n end\n is_ok\nend", "def value_type?\n VALUE_TYPES.include?(expected_type)\n end", "def test_not_same_value_as\n #G\n white_pair = PAIR_OF_4\n black_value = VALUE_2\n\n #W\n result = white_pair.same_value? black_value\n\n #T\n assert_false result\n end", "def has_value?(value)\n each_value.include?(convert_value_to_parameters(value))\n end", "def correct_tag_values?\n validate_tags(info.our_tags)\n validate_album_disc(info.album, file.dirname.basename.to_s)\n end", "def is_equal_value?\n return true unless value_to_compare?\n assigns[@name] == @options[:with]\n end", "def valid_value?(value)\n valid_or_optional?(value) { valid_primitive?(value) }\n end", "def just_u_value?()\n @construction.check_keyword?(\"U-VALUE\")\n end", "def eql?(other)\n\t\tother = other.value if other.is_a? self.class\n\t\treturn value.eql?(other)\n\tend", "def eql?(other)\n\t if other.zero?\n\t\t@value.zero?\n\t elsif other.respond_to?(:units)\n\t\tif other.respond_to? :value\n\t\t @units.eql?(other.units) and @value.eql?(other.value)\n\t\telse\n\t\t other == self\n\t\tend\n\t else\n\t\t@units.nil? and @value.eql?(other)\n\t end\n\tend", "def is_value?\n true\n end", "def eql?(other)\n self.class == other.class && value == other.value\n end", "def eql?(other)\n self.class == other.class && value == other.value\n end", "def just_u_value?()\n @construction.check_keyword?(\"U-VALUE\")\n end", "def secure_compare(value)\n a = self.secret\n b = value\n\n return false if a.blank? || b.blank? || a.bytesize != b.bytesize\n l = a.unpack \"C#{a.bytesize}\"\n\n res = 0\n b.each_byte { |byte| res |= byte ^ l.shift }\n res == 0\n end", "def assert_valid_value(value)\n # TODO: Implement!\n end", "def true?\n self.value == '1'\n end", "def changed?(old_value, new_value, _new_value_before_type_cast) # :nodoc:\n old_value != new_value\n end", "def has_value?(value)\n each do | k, v |\n return true if v == value\n end\n return false\n end", "def eql?(other)\n self.class.equal?(other.class) && value == other.value\n end", "def eql?(other)\n self.class.equal?(other.class) && value == other.value\n end", "def check_and_set_string_type\n key = self.key.to_sym\n if KEY_TO_STRING_OPTIONS.key?(key)\n # If there are explicit string options, match the value to one of them.\n matched = false\n options = KEY_TO_STRING_OPTIONS[key]\n options.each do |opt|\n if Metadatum.str_to_basic_chars(text_raw_value) == Metadatum.str_to_basic_chars(opt)\n # Ex: Match 'neb ultra-iifs dna' to 'NEB Ultra II FS DNA'\n # Ex: Match '30-day mortality' to \"30 Day Mortality\"\n self.text_validated_value = opt\n matched = true\n break\n end\n end\n unless matched\n errors.add(:text_raw_value, \"#{text_raw_value} did not match options #{options.join(', ')}\")\n end\n else\n self.text_validated_value = text_raw_value\n end\n end", "def value_conforms?(value, field, errors = [])\n true\n end", "def valid?\n value\n end", "def valid_n3_value?(element)\n return !element.nil? && !element.match(/^[^\"'\\\\]*$/).nil? ? true : false\n end", "def eql?(obj_)\n if obj_.kind_of?(::String)\n obj_ = @_format.parse(obj_) rescue nil\n end\n return false unless obj_.kind_of?(Value)\n index_ = 0\n obj_.each_field_object do |field_, value_|\n return false if field_ != @_field_path[index_] || value_ != @_values[field_.name]\n index_ += 1\n end\n true\n end", "def valid?(val)\n vals.include? val\n end", "def value?\n Array.wrap(element_value).reject(&:empty?).any?\n end", "def can_have_value?\n return false\n end", "def vash_valid_value?(x); self.class.option_value?(x); end", "def ==(other)\n self.class == other.class && value == other.value\n end", "def valid?(value)\n return false if self == Enum\n return true if value.equal?(LAZY_VALUE)\n self.values.include?(value.to_s)\n end", "def value? value\n include? value\n end", "def eql?(field)\n if field.is_a?(GFA::Field)\n type == field.type && value == field.value\n else\n field.is_a?(value.class) && value == field\n end\n end", "def satisfies_values?(value, depth: 0)\n values = operands.select {|op| op.is_a?(Value)}\n return true if values.empty?\n matched_value = values.detect {|v| v.match?(value, depth: depth + 1)}\n not_satisfied \"Value #{value.to_sxp} not expected, wanted #{values.to_sxp}\", depth: depth unless matched_value\n status \"right value: #{value}\", depth: depth\n true\n end", "def check_integer_box_value(id, value, timeout=nil)\r\n element = find_by_id_and_tag(id, \"input\", timeout)\r\n if element.value != value\r\n raise \"Integer box \\\"\" + id + \"\\\" does not have expected content, expected [\" + value + \"], got [\" + element.value + \"]\"\r\n end\r\n end", "def matches?(actual)\n expected_value == actual\n end", "def value?(value)\n values.include? value\n end", "def single_value?\n return false\n end", "def has_value?(value)\n field(with: value)\n end", "def eql?(obj)\n return false unless obj.is_a?(self.class)\n fields.each do |tag, _|\n if value_for_tag?(tag)\n return false unless (obj.value_for_tag?(tag) && value_for_tag(tag).eql?(obj.value_for_tag(tag)))\n else\n return false if obj.value_for_tag?(tag)\n end\n end\n return true\n end", "def check_utc_time_box_value(id, value, timeout=nil)\r\n element = find_by_id_and_class(id, \"gwt-TimeBox\", timeout)\r\n if element.value != value\r\n raise \"Time box \\\"\" + id + \"\\\" does not have expected content, expected [\" + value + \"], got: [\" + element.value + \"]\"\r\n end\r\n end", "def match?(value, depth: 0)\n status \"\", depth: depth\n if case expr = operands.first\n when RDF::Value then value.eql?(expr)\n when Language, Stem, StemRange then expr.match?(value, depth: depth + 1)\n else false\n end\n status \"matched #{value}\", depth: depth\n true\n else\n status \"not matched #{value}\", depth: depth\n false\n end\n end", "def has_value?\n false\n end", "def value?(value)\n !@children.find { |c| c == value }.nil?\n end", "def true?\n self.value == '1'\n end", "def validate_value value\n true\n end", "def check_label_value(id, value, timeout=nil)\r\n element = find_by_id_and_class(id, \"gwt-Label\", timeout)\r\n if element.text != value\r\n raise \"Label \\\"\" + id + \"\\\" does not have expected content, expected [\" + value + \"], got [\" + element.text + \"]\"\r\n end\r\n end", "def ==(o)\n return true if self.equal?(o)\n self.class == o.class && value == o.value\n end", "def ==(o)\n return true if self.equal?(o)\n self.class == o.class && value == o.value\n end", "def literal?\n @value.is_a?(String) || @value.is_a?(Integer)\n end", "def valid_value?(value)\n @params.each_pair do |key, param|\n return false if key == :minimum && (value.nil? || value.length < param)\n return false if key == :maximum && !value.nil? && value.length > param\n return false if key == :exact && (value.nil? || value.length != param)\n end\n\n true\n end", "def good?(value)\n value\n end", "def ==(other)\n @value == other.value\n end", "def unique_val?\n @lower == @upper\n end", "def ==(val)\n return true if @val == val\n end" ]
[ "0.6237748", "0.619103", "0.6182821", "0.61303514", "0.6072317", "0.6013846", "0.6007214", "0.5981066", "0.59719974", "0.5948616", "0.5939308", "0.59384906", "0.59384906", "0.5905601", "0.5819519", "0.5819146", "0.5808179", "0.58048415", "0.578565", "0.578565", "0.577681", "0.5775027", "0.57697874", "0.57297266", "0.57221913", "0.5718002", "0.5696174", "0.56715643", "0.5642667", "0.563632", "0.563632", "0.5628409", "0.5614522", "0.56142044", "0.5582722", "0.55817634", "0.5574449", "0.5564123", "0.5555529", "0.5538593", "0.5537067", "0.5521689", "0.5504099", "0.55037713", "0.5498376", "0.5483387", "0.5479369", "0.5471524", "0.54604155", "0.5447181", "0.54471713", "0.5420657", "0.54185027", "0.5417821", "0.5412342", "0.5412342", "0.540031", "0.5398934", "0.53865784", "0.53781414", "0.5374071", "0.5368009", "0.5367734", "0.5367734", "0.53650343", "0.5363943", "0.53625935", "0.53624743", "0.5354502", "0.53525037", "0.534334", "0.53397936", "0.5335576", "0.5319327", "0.53185856", "0.5318119", "0.53111494", "0.5288992", "0.52851444", "0.5282547", "0.5280487", "0.52793825", "0.5275464", "0.5273911", "0.5267037", "0.5260999", "0.52503914", "0.5248554", "0.5239086", "0.5235269", "0.5232178", "0.52238584", "0.52238584", "0.5216654", "0.52136195", "0.5213335", "0.5213295", "0.5208574", "0.5208511" ]
0.62886584
1
Serializers Converts the TLV to raw.
def to_r raw = value.to_s; if (self.type & TLV_META_TYPE_STRING == TLV_META_TYPE_STRING) raw += "\x00" elsif (self.type & TLV_META_TYPE_UINT == TLV_META_TYPE_UINT) raw = [value].pack("N") elsif (self.type & TLV_META_TYPE_BOOL == TLV_META_TYPE_BOOL) if (value == true) raw = [1].pack("c") else raw = [0].pack("c") end end # check if the tlv is to be compressed... if( @compress ) raw_uncompressed = raw # compress the raw data raw_compressed = Rex::Text.zlib_deflate( raw_uncompressed ) # check we have actually made the raw data smaller... # (small blobs often compress slightly larger then the origional) # if the compressed data is not smaller, we dont use the compressed data if( raw_compressed.length < raw_uncompressed.length ) # if so, set the TLV's type to indicate compression is used self.type = self.type | TLV_META_TYPE_COMPRESSED # update the raw data with the uncompressed data length + compressed data # (we include the uncompressed data length as the C side will need to know this for decompression) raw = [ raw_uncompressed.length ].pack("N") + raw_compressed end end return [raw.length + 8, self.type].pack("NN") + raw end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_r\n\t\traw = value.to_s;\n\n\t\tif (self.type & TLV_META_TYPE_STRING == TLV_META_TYPE_STRING)\n\t\t\traw += \"\\x00\"\n\t\telsif (self.type & TLV_META_TYPE_UINT == TLV_META_TYPE_UINT)\n\t\t\traw = [value].pack(\"N\")\n\t\telsif (self.type & TLV_META_TYPE_BOOL == TLV_META_TYPE_BOOL)\n\t\t\tif (value == true)\n\t\t\t\traw = [1].pack(\"c\")\n\t\t\telse\n\t\t\t\traw = [0].pack(\"c\")\n\t\t\tend\n\t\tend\n\n\t\treturn [raw.length + 8, self.type].pack(\"NN\") + raw\n\tend", "def to_raw; end", "def to_r\n\t\traw = ''\n\n\t\tself.each() { |tlv|\n\t\t\traw << tlv.to_r\n\t\t}\n\n\t\treturn [raw.length + 8, self.type].pack(\"NN\") + raw\n\tend", "def to_r\n\t\traw = ''\n\n\t\tself.each() { |tlv|\n\t\t\traw << tlv.to_r\n\t\t}\n\n\t\treturn [raw.length + 8, self.type].pack(\"NN\") + raw\n\tend", "def serialize\n @raw_data\n end", "def from_r(raw)\n\t\tself.value = nil\n\n\t\tlength, self.type = raw.unpack(\"NN\");\n\n\t\t# check if the tlv value has been compressed...\n\t\tif( self.type & TLV_META_TYPE_COMPRESSED == TLV_META_TYPE_COMPRESSED )\n\t\t\t# set this TLV as using compression\n\t\t\t@compress = true\n\t\t\t# remove the TLV_META_TYPE_COMPRESSED flag from the tlv type to restore the \n\t\t\t# tlv type to its origional, allowing for transparent data compression.\n\t\t\tself.type = self.type ^ TLV_META_TYPE_COMPRESSED\n\t\t\t# decompress the compressed data (skipping the length and type DWORD's)\n\t\t\traw_decompressed = Rex::Text.zlib_inflate( raw[8..length-1] )\n\t\t\t# update the length to reflect the decompressed data length (+8 for the length and type DWORD's)\n\t\t\tlength = raw_decompressed.length + 8\n\t\t\t# update the raw buffer with the new length, decompressed data and updated type.\n\t\t\traw = [length, self.type].pack(\"NN\") + raw_decompressed\n\t\tend\n\t\t\n\t\tif (self.type & TLV_META_TYPE_STRING == TLV_META_TYPE_STRING)\n\t\t\tif (raw.length > 0)\n\t\t\t\tself.value = raw[8..length-2]\n\t\t\telse\n\t\t\t\tself.value = nil\n\t\t\tend\n\t\telsif (self.type & TLV_META_TYPE_UINT == TLV_META_TYPE_UINT)\n\t\t\tself.value = raw.unpack(\"NNN\")[2]\n\t\telsif (self.type & TLV_META_TYPE_BOOL == TLV_META_TYPE_BOOL)\n\t\t\tself.value = raw.unpack(\"NNc\")[2]\n\n\t\t\tif (self.value == 1)\n\t\t\t\tself.value = true\n\t\t\telse\n\t\t\t\tself.value = false\n\t\t\tend\n\t\telse\n\t\t\tself.value = raw[8..length-1]\n\t\tend\n\n\t\treturn length;\n\tend", "def raw\n repr.raw\n end", "def from_r(raw)\n\t\tself.value = nil\n\n\t\tlength, self.type = raw.unpack(\"NN\");\n\n\t\tif (self.type & TLV_META_TYPE_STRING == TLV_META_TYPE_STRING)\n\t\t\tif (raw.length > 0)\n\t\t\t\tself.value = raw[8..length-2]\n\t\t\telse\n\t\t\t\tself.value = nil\n\t\t\tend\n\t\telsif (self.type & TLV_META_TYPE_UINT == TLV_META_TYPE_UINT)\n\t\t\tself.value = raw.unpack(\"NNN\")[2]\n\t\telsif (self.type & TLV_META_TYPE_BOOL == TLV_META_TYPE_BOOL)\n\t\t\tself.value = raw.unpack(\"NNc\")[2]\n\n\t\t\tif (self.value == 1)\n\t\t\t\tself.value = true\n\t\t\telse\n\t\t\t\tself.value = false\n\t\t\tend\n\t\telse\n\t\t\tself.value = raw[8..length-1]\n\t\tend\n\n\t\treturn length;\n\tend", "def raw\n\n @raw\n\n end", "def raw(value)\n RawString.new(value.to_s)\n end", "def raw(value)\n RawString.new(value.to_s)\n end", "def to_s\n raw\n end", "def raw_value\n to_s\n end", "def from_r(raw)\n\t\toffset = 8\n\n\t\t# Reset the TLVs array\n\t\tself.tlvs = []\n\t\tself.type = raw.unpack(\"NN\")[1]\n\n\t\t# Enumerate all of the TLVs\n\t\twhile (offset < raw.length-1)\n\n\t\t\ttlv = nil\n\n\t\t\t# Get the length and type\n\t\t\tlength, type = raw[offset..offset+8].unpack(\"NN\")\n\n\t\t\tif (type & TLV_META_TYPE_GROUP == TLV_META_TYPE_GROUP)\n\t\t\t\ttlv = GroupTlv.new(type)\n\t\t\telse\n\t\t\t\ttlv = Tlv.new(type)\n\t\t\tend\n\n\t\t\ttlv.from_r(raw[offset..offset+length])\n\n\t\t\t# Insert it into the list of TLVs\n\t\t\ttlvs << tlv\n\n\t\t\t# Move up\n\t\t\toffset += length\n\t\tend\n\tend", "def from_r(raw)\n\t\toffset = 8\n\n\t\t# Reset the TLVs array\n\t\tself.tlvs = []\n\t\tself.type = raw.unpack(\"NN\")[1]\n\n\t\t# Enumerate all of the TLVs\n\t\twhile (offset < raw.length-1)\n\n\t\t\ttlv = nil\n\n\t\t\t# Get the length and type\n\t\t\tlength, type = raw[offset..offset+8].unpack(\"NN\")\n\n\t\t\tif (type & TLV_META_TYPE_GROUP == TLV_META_TYPE_GROUP)\n\t\t\t\ttlv = GroupTlv.new(type)\n\t\t\telse\n\t\t\t\ttlv = Tlv.new(type)\n\t\t\tend\n\n\t\t\ttlv.from_r(raw[offset..offset+length])\n\n\t\t\t# Insert it into the list of TLVs\n\t\t\ttlvs << tlv\n\n\t\t\t# Move up\n\t\t\toffset += length\n\t\tend\n\tend", "def _raw\n @_raw\n end", "def raw\n @raw ||= ''\n end", "def raw; end", "def raw; end", "def raw; end", "def raw; end", "def raw\n #\n end", "def raw\n @raw = true\n self\n end", "def raw_plain\n @raw_plain\n end", "def raw\n @raw ||= Hashie::Mash.new(@raw_plain)\n end", "def raw\n @raw ||= []\n end", "def to_binary\n Formatters::Binary.new.serialize self\n end", "def value_raw\n @value\n end", "def load(raw)\n raw\n end", "def to_s\n '<Twilio::REST::Voice::V1>';\n end", "def raw_value; end", "def read\n Typelib.to_ruby(raw_read)\n end", "def raw(s)\n RawString.new(s)\n end", "def build_raw_data(data)\r\n data.kind_of?(String) ? data : data.inspect\r\n end", "def raws\n @raws = {} unless defined? @raws\n @raws\n end", "def [](name)\n field(name).convert(@raw)\n end", "def to_raw_data\n [@pao_type, @letter_pair.to_raw_data].join(SEPARATOR)\n end", "def raw(s)\n RawString.new(s)\n end", "def set_raw!(value)\n value = value.to_s\n\n @objects = nil\n @memory = FFI::MemoryPointer.new(:uchar, value.length) \n @memory.write_bytes(value)\n\n self[:type] = :raw\n\n raw = self[:values][:raw]\n raw[:size] = value.length\n raw[:ptr] = @memory\n end", "def raw_value\n @value\n end", "def serialize(value)\n value\n end", "def set_raw\n @raw = Raw.find(params[:id])\n end", "def force_convert_to_tnetstring\n ::TNetstring.dump(self.to_hash)\n end", "def to_s\n pad_field :data\n recalc_block_len\n super\n end", "def raw(name = nil)\n if name.nil?\n @raw\n else\n field(name).extract(@raw)\n end\n end", "def to_s\n '#<Twilio::REST::Voice>'\n end", "def get_field_deserializers()\n return super.merge({\n \"self\" => lambda {|n| @self_escaped = n.get_string_value() },\n })\n end", "def raw\n out = \"\"\n @lfn_ents.each {|ent| out += BinaryStruct.encode(ent, DIR_ENT_LFN)} if @lfn_ents\n out += BinaryStruct.encode(@dir_ent, DIR_ENT_SFN)\n end", "def to_s()\n serialize.to_s()\n end", "def to_s()\n serialize.to_s()\n end", "def serialize(value)\n Serializer.parse(value)\n end", "def serialize\n end", "def raw_value(obj)\n GraphQL::Execution::Interpreter::RawValue.new(obj)\n end", "def serialize(value)\n value\n end", "def to_raw()\n self.headers ||= default_headers_obj()\n self.body ||= default_body_obj()\n\n if len=@opts[:static_length]\n @body = Body.new(@body, @body.opts) {|x| x.base = self}\n @headers.set_header(\"Content-Length\", len.to_i)\n elsif @opts[:ignore_content_length]\n @headers.delete_header(\"Content-Length\")\n end\n\n bstr = @body.to_raw\n hdrs = @headers.to_raw_array.unshift(first_entity.to_raw)\n return \"#{hdrs.join(\"\\r\\n\")}\\r\\n\\r\\n#{bstr}\"\n end", "def to_s # :nodoc:\n return @vbits.clone\n end", "def serialize(value)\n value\n end", "def to_s\n JSON.pretty_generate(raw)\n end", "def to_s\n pad_field :data, :options\n recalc_block_len\n super\n end", "def serialized\n @value\n end", "def type_specific_part_raw\n return @type_specific_part_raw unless @type_specific_part_raw.nil?\n @type_specific_part_raw = type_specific_part_raw_with_io.data\n @type_specific_part_raw\n end", "def serialize_to_string\n sio = ProtocolBuffers.bin_sio\n serialize(sio)\n return sio.string\n end", "def to_s\n Forme.transform(:serializer, @opts, @form.opts, self)\n end", "def to_s\n serialize.to_s\n end", "def to_s\n serialize.to_s\n end", "def to_s\n serialize.to_s\n end", "def to_s\n return serialize.to_s\n end", "def dump\n zeroes = ZEROBYTE * 32\n raw = ZEROBYTE * ID3::ID3v1tagSize\n raw[0..2] = 'TAG'\n\n self.each{ |key,value|\n\n range = ID3::Symbol2framename['1.1'][key]\n\n if range.class == Range \n length = range.last - range.first + 1\n paddedstring = value + zeroes\n raw[range] = paddedstring[0..length-1]\n elsif range.class == Fixnum\n raw[range] = value.to_i.chr # supposedly assigning a binary integer value to the location in the string\n else\n # this can't happen the way we defined the hash..\n next\n end\n }\n\n return raw\n end", "def json\n value.sub(/^serialized-/, '')\n end", "def raw(s)\n Forme.raw(s)\n end", "def inspect\n \"<BSON::Binary:0x#{object_id} type=#{type} data=0x#{data[0, 8].unpack1('H*')}...>\"\n end", "def serialize(value)\n value.to_s\n end", "def to_primitive\n data\n end", "def body\n @raw\n end", "def marshal_load(serialised); end", "def tags_raw\n self.tags.join(\"\\n\") unless self.tags.nil?\n end", "def raw_tags_plist=(value)\n obj = value.to_s.from_plist\n self.raw_tags = obj\n end", "def accept_raw raw\n @res << raw.parts.join(\"\\n\")\n end", "def accept_raw raw\n @res << raw.parts.join(\"\\n\")\n end", "def to_raw_object(opener = nil)\n RawObject.construct(hash_id, opener, PREFIX_NAME_LOOKUP[type], content)\n end", "def serialize; end", "def serialize; end", "def serialize_value(v)\n case v\n when TZOffset, Geo::Coord, Reality::Link, Reality::Measure, Money::Currency\n v.inspect\n when Array\n v.map(&method(:serialize_value))\n when String, Numeric, Date, Time\n v\n else\n fail ArgumentError, \"Not a basic value in the entity: #{v.inspect}\"\n end\n end", "def raw_body\n @attributes[:raw_body]\n end", "def get_field_deserializers()\n return super.merge({\n \"audiences\" => lambda {|n| @audiences = n.get_collection_of_primitive_values(String) },\n \"description\" => lambda {|n| @description = n.get_string_value() },\n \"issuer\" => lambda {|n| @issuer = n.get_string_value() },\n \"name\" => lambda {|n| @name = n.get_string_value() },\n \"subject\" => lambda {|n| @subject = n.get_string_value() },\n })\n end", "def raw_node; end", "def to_base\n RDF::NTriples.serialize(self).freeze\n end", "def to_text\n Vpim.decode_text(value)\n end", "def serialize\n \n end", "def to_s\n \"#<#{self.class}:0x%016x index=%d, id=%d, codec_type=:%s>\" %\n [ object_id, self[:index], self[:id], self[:codec][:codec_type] ]\n end", "def raw_bytes\n @raw_bytes ||= read_raw_bytes\n end", "def get_raw_information\n @infos[RAW]\n end", "def raw\n @buffer\n end", "def to_data\n to_s\n end", "def inspect\n serialize.to_s\n end", "def serialize( att, val=send(att) )\n serializer = _serializer(att)\n serializer ? serializer.to_str(val) || val : super\n end", "def serialize(val)\n val.to_s\n end", "def serialize(val)\n val.to_s\n end", "def serialize(object) end", "def to_s\n data\n end" ]
[ "0.6859719", "0.63497025", "0.6252269", "0.6252269", "0.62424344", "0.6140392", "0.5937109", "0.59352195", "0.5920375", "0.58088326", "0.58088326", "0.5777562", "0.57747245", "0.57376057", "0.57376057", "0.56898165", "0.5672061", "0.55899584", "0.55899584", "0.55899584", "0.55899584", "0.5583675", "0.5546567", "0.54524225", "0.5304019", "0.5295119", "0.52863187", "0.52427506", "0.5241492", "0.51994324", "0.51838803", "0.5178277", "0.5142701", "0.5135152", "0.51326346", "0.51309705", "0.51286113", "0.51200265", "0.5095547", "0.5060048", "0.50365365", "0.50336426", "0.5029016", "0.50269955", "0.5026565", "0.5024763", "0.50169426", "0.50128967", "0.5001305", "0.5001305", "0.4994944", "0.49909487", "0.49854857", "0.49767464", "0.49764526", "0.49744976", "0.4972312", "0.49679387", "0.49653137", "0.49513474", "0.4948007", "0.49467844", "0.49464685", "0.49426126", "0.49426126", "0.49426126", "0.49341324", "0.49319646", "0.49240324", "0.4913801", "0.49114054", "0.49107403", "0.49029085", "0.48993766", "0.4895887", "0.48932227", "0.4887974", "0.4886393", "0.4886393", "0.4884488", "0.48806375", "0.48806375", "0.48770773", "0.4860461", "0.48563468", "0.48522142", "0.48443702", "0.4834005", "0.48240745", "0.48193562", "0.4815414", "0.48149464", "0.480473", "0.4797217", "0.47843435", "0.47711372", "0.47631836", "0.47631836", "0.47537234", "0.475176" ]
0.7012267
0
Translates the raw format of the TLV into a sanitize version.
def from_r(raw) self.value = nil length, self.type = raw.unpack("NN"); # check if the tlv value has been compressed... if( self.type & TLV_META_TYPE_COMPRESSED == TLV_META_TYPE_COMPRESSED ) # set this TLV as using compression @compress = true # remove the TLV_META_TYPE_COMPRESSED flag from the tlv type to restore the # tlv type to its origional, allowing for transparent data compression. self.type = self.type ^ TLV_META_TYPE_COMPRESSED # decompress the compressed data (skipping the length and type DWORD's) raw_decompressed = Rex::Text.zlib_inflate( raw[8..length-1] ) # update the length to reflect the decompressed data length (+8 for the length and type DWORD's) length = raw_decompressed.length + 8 # update the raw buffer with the new length, decompressed data and updated type. raw = [length, self.type].pack("NN") + raw_decompressed end if (self.type & TLV_META_TYPE_STRING == TLV_META_TYPE_STRING) if (raw.length > 0) self.value = raw[8..length-2] else self.value = nil end elsif (self.type & TLV_META_TYPE_UINT == TLV_META_TYPE_UINT) self.value = raw.unpack("NNN")[2] elsif (self.type & TLV_META_TYPE_BOOL == TLV_META_TYPE_BOOL) self.value = raw.unpack("NNc")[2] if (self.value == 1) self.value = true else self.value = false end else self.value = raw[8..length-1] end return length; end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def unnormalize(string, doctype = T.unsafe(nil), filter = T.unsafe(nil), illegal = T.unsafe(nil)); end", "def from_r(raw)\n\t\tself.value = nil\n\n\t\tlength, self.type = raw.unpack(\"NN\");\n\n\t\tif (self.type & TLV_META_TYPE_STRING == TLV_META_TYPE_STRING)\n\t\t\tif (raw.length > 0)\n\t\t\t\tself.value = raw[8..length-2]\n\t\t\telse\n\t\t\t\tself.value = nil\n\t\t\tend\n\t\telsif (self.type & TLV_META_TYPE_UINT == TLV_META_TYPE_UINT)\n\t\t\tself.value = raw.unpack(\"NNN\")[2]\n\t\telsif (self.type & TLV_META_TYPE_BOOL == TLV_META_TYPE_BOOL)\n\t\t\tself.value = raw.unpack(\"NNc\")[2]\n\n\t\t\tif (self.value == 1)\n\t\t\t\tself.value = true\n\t\t\telse\n\t\t\t\tself.value = false\n\t\t\tend\n\t\telse\n\t\t\tself.value = raw[8..length-1]\n\t\tend\n\n\t\treturn length;\n\tend", "def normalize(input, doctype = T.unsafe(nil), entity_filter = T.unsafe(nil)); end", "def sanitize_data(data)\n data\n end", "def cleanse_data!\n self.tag = tag.to_s&.strip&.upcase\n self.shl_case_number = shl_case_number.to_s&.strip&.upcase\n end", "def sanitize!; end", "def from_r(raw)\n\t\toffset = 8\n\n\t\t# Reset the TLVs array\n\t\tself.tlvs = []\n\t\tself.type = raw.unpack(\"NN\")[1]\n\n\t\t# Enumerate all of the TLVs\n\t\twhile (offset < raw.length-1)\n\n\t\t\ttlv = nil\n\n\t\t\t# Get the length and type\n\t\t\tlength, type = raw[offset..offset+8].unpack(\"NN\")\n\n\t\t\tif (type & TLV_META_TYPE_GROUP == TLV_META_TYPE_GROUP)\n\t\t\t\ttlv = GroupTlv.new(type)\n\t\t\telse\n\t\t\t\ttlv = Tlv.new(type)\n\t\t\tend\n\n\t\t\ttlv.from_r(raw[offset..offset+length])\n\n\t\t\t# Insert it into the list of TLVs\n\t\t\ttlvs << tlv\n\n\t\t\t# Move up\n\t\t\toffset += length\n\t\tend\n\tend", "def from_r(raw)\n\t\toffset = 8\n\n\t\t# Reset the TLVs array\n\t\tself.tlvs = []\n\t\tself.type = raw.unpack(\"NN\")[1]\n\n\t\t# Enumerate all of the TLVs\n\t\twhile (offset < raw.length-1)\n\n\t\t\ttlv = nil\n\n\t\t\t# Get the length and type\n\t\t\tlength, type = raw[offset..offset+8].unpack(\"NN\")\n\n\t\t\tif (type & TLV_META_TYPE_GROUP == TLV_META_TYPE_GROUP)\n\t\t\t\ttlv = GroupTlv.new(type)\n\t\t\telse\n\t\t\t\ttlv = Tlv.new(type)\n\t\t\tend\n\n\t\t\ttlv.from_r(raw[offset..offset+length])\n\n\t\t\t# Insert it into the list of TLVs\n\t\t\ttlvs << tlv\n\n\t\t\t# Move up\n\t\t\toffset += length\n\t\tend\n\tend", "def modify_raw(data, decrypted)\n data.sub(/\\+OK \\S+(\\s+\\S+)?/, decrypted)\n end", "def sanitize!\n begin\n\n # Sanitize newly read Tags\n @@settings[:tag_fields].each do |tag_field|\n field = tag_field.to_s\n field_value = send(\"#{field}\")\n send(\"#{field}=\", ModelUtils::id3_sanitize(field_value))\n end\n\n # Rescue any exceptions\n rescue Exception => e\n log.error e\n end\n end", "def to_r\n\t\traw = value.to_s;\n\n\t\tif (self.type & TLV_META_TYPE_STRING == TLV_META_TYPE_STRING)\n\t\t\traw += \"\\x00\"\n\t\telsif (self.type & TLV_META_TYPE_UINT == TLV_META_TYPE_UINT)\n\t\t\traw = [value].pack(\"N\")\n\t\telsif (self.type & TLV_META_TYPE_BOOL == TLV_META_TYPE_BOOL)\n\t\t\tif (value == true)\n\t\t\t\traw = [1].pack(\"c\")\n\t\t\telse\n\t\t\t\traw = [0].pack(\"c\")\n\t\t\tend\n\t\tend\n\t\t\n\t\t# check if the tlv is to be compressed...\n\t\tif( @compress )\n\t\t\traw_uncompressed = raw\n\t\t\t# compress the raw data\n\t\t\traw_compressed = Rex::Text.zlib_deflate( raw_uncompressed )\n\t\t\t# check we have actually made the raw data smaller...\n\t\t\t# (small blobs often compress slightly larger then the origional) \n\t\t\t# if the compressed data is not smaller, we dont use the compressed data\n\t\t\tif( raw_compressed.length < raw_uncompressed.length )\n\t\t\t\t# if so, set the TLV's type to indicate compression is used\n\t\t\t\tself.type = self.type | TLV_META_TYPE_COMPRESSED\n\t\t\t\t# update the raw data with the uncompressed data length + compressed data\n\t\t\t\t# (we include the uncompressed data length as the C side will need to know this for decompression)\n\t\t\t\traw = [ raw_uncompressed.length ].pack(\"N\") + raw_compressed\n\t\t\tend\n\t\tend\n\t\t\n\t\treturn [raw.length + 8, self.type].pack(\"NN\") + raw\n\tend", "def to_sanitize\n Sanitize.new(to_hash)\n end", "def unnormalize(string, entities = T.unsafe(nil), filter = T.unsafe(nil)); end", "def sanitize string, compact: true\n string = string.gsub SanitizeXMLRx, '' if string.include? '<'\n string = string.gsub(CharRefRx) { $1 ? BuiltInNamedEntities[$1] : ([$2 ? $2.to_i : ($3.to_i 16)].pack 'U1') } if string.include? '&'\n compact ? (string.strip.tr_s ' ', ' ') : string\n end", "def clean_utf8 raw_s, *opts\n\n fail(\"Not a string: #{raw_s.inspect}\") unless raw_s.is_a?(String)\n\n # === Check options. ==================================================================\n @plaintext_allowed_options ||= [ :spaces, :tabs ]\n invalid_opts = opts - @plaintext_allowed_options\n fail(ArgumentError, \"INVALID OPTION: #{invalid_opts.inspect}\" ) if !invalid_opts.empty?\n # =====================================================================================\n\n raw_s = raw_s.dup\n\n # === Save tabs if requested.\n raw_s.gsub!(TAB, HTML_TAB) if opts.include?(:tabs)\n\n raw_s.encode!(Encoding.find('utf-8') , ENCODING_OPTIONS_CLEAN_UTF8)\n raw_s.scrub!\n raw_s.gsub!(TAB , TWO_SPACES)\n raw_s.gsub!(MULTI_CONTROL_AND_UNPRINTABLE , BLANK)\n raw_s.gsub!(REGEX_UNSUITABLE_CHARS , ' ')\n\n clean = raw_s.to_nfkc\n\n # Save whitespace or strip.\n if !opts.include?(:spaces)\n clean.strip!\n end\n\n # Put back tabs by request.\n if opts.include?(:tabs)\n clean.gsub!(HTML_TAB, TAB)\n end\n\n clean\n end", "def normalizer; end", "def sanitize(template)\n begin\n if template =~ /\\A\".+\"\\Z/m\n # Case 1\n sanitize_with_json(template)\n else\n # Case 2\n sanitize_with_regexp(template)\n end\n rescue JSON::ParserError\n # Case 3\n template\n end\n end", "def sanitize(s, level=:relaxed)\n Sanitize.clean(s, DC::Sanitizer::LEVELS[ level ] )\n end", "def fix(v)\n v.force_encoding('CP1251').encode('UTF-8')\nend", "def prepare_data data\n Iconv.new('UTF-8//IGNORE', 'UTF-8').iconv(data)\n end", "def validate_and_sanitize\n\n r = validate\n return r unless r.success?\n\n @name = @name.to_s.strip\n @symbol = @symbol.to_s.strip.upcase\n @stake_currency_symbol = @stake_currency_symbol.to_s.strip.upcase\n\n validation_errors = validate_token_creation_params\n\n if validation_errors.present?\n return validation_error(\n 'a_tm_itd_1',\n 'invalid_api_params',\n validation_errors,\n GlobalConstant::ErrorAction.default\n )\n end\n\n success\n\n end", "def convert(raw)\n return build_fault(raw) if raw.key?('code')\n\n {\n address: format_address(raw.dig('target', 'address')),\n country_code: raw.dig('target', 'address', 'countryCode'),\n name: raw.dig('target', 'name'),\n vat_number: raw.dig('target', 'vatNumber'), valid: true\n }.tap do |hash|\n hash[:request_date] = Time.parse(raw['processingDate']) if raw.key?('processingDate')\n hash[:request_identifier] = raw['consultationNumber'] if raw.key?('consultationNumber')\n end\n end", "def bad_utf8_fix(record)\n record.fields.each do |field|\n if field.class == MARC::DataField\n field.subfields.each do |subfield|\n subfield.value.force_encoding('UTF-8')\n subfield.value.scrub!('')\n end\n else\n field.value.force_encoding('UTF-8')\n field.value.scrub!('')\n end\n end\n record\nend", "def sanitize_attributes!\n remove_invalid_subjects!\n remove_invalid_audiences!\n remove_invalid_levels!\n set_prices!\n nil\n end", "def validate_and_sanitize\n super\n end", "def normalize(code); end", "def normalize(string); end", "def sanitize_details\n self.details = ActionController::Base.helpers.sanitize(details, { :tags => ALLOWED_HTML_TAGS_IN_DETAILS } )\n end", "def sanitize(text)\n text.gsub('<', '&lt;').gsub('>', '&gt;')\n end", "def untaint() end", "def sanitize!\n return self if @sanitized\n replace(HTMLEntities.new.encode(self))\n @sanitized = true\n return self\n end", "def sanitize_id_format_raw_xml(original_input)\n return nil if original_input.nil? || original_input.raw_content.blank?\n format_sanitizer = Stix::Stix111::SanitizerValidFormat.new(Setting.XML_PARSING_LIBRARY.to_s.to_sym)\n format_sanitizer.sanitize_xml(original_input.raw_content)\n @warnings = format_sanitizer.warnings\n if format_sanitizer.valid?\n original_input.raw_content = format_sanitizer.xml\n else\n @errors = format_sanitizer.errors\n nil\n end\n end", "def validate_and_sanitize\n validate\n end", "def from_human(data)\n read(data)\n end", "def sanitize_attributes\n if self.sanitize_level\n self.description = Sanitize.clean(self.description, self.sanitize_level)\n self.name = Sanitize.clean(self.name, self.sanitize_level)\n end\n end", "def clean\n self.short_msg = sanitize(short_msg)\n self.long_msg = sanitize(long_msg)\n end", "def parse!(raw)\n\n return false if raw.size != ID3::ID3v1tagSize\n\n if (raw[ID3v1versionbyte] == 0) \n @version = \"1.0\"\n else\n @version = \"1.1\"\n end\n\n self.clear # remove all entries from Hash, we don't want left-overs..\n\n ID3::SUPPORTED_SYMBOLS[@version].each{ |key,val|\n if val.class == Range\n # self[key] = raw[val].squeeze(\" \\000\").chomp(\" \").chomp(\"\\000\")\n self[key] = raw[val].strip\n elsif val.class == Fixnum\n self[key] = raw[val].to_s\n else \n # this can't happen the way we defined the hash..\n # printf \"unknown key/val : #{key} / #{val} ; val-type: %s\\n\", val.class\n end \n }\n @raw = raw\n return true\n end", "def read_with_substitution(input, illegal = T.unsafe(nil)); end", "def raw(s)\n RawString.new(s)\n end", "def standardize_input\n valid_characters = Regexp.new(/\\A[A-Zvx\\^\\&\\!\\~\\|\\-\\>\\<\\(\\)\\ \\[\\]\\{\\}\\,\\+]*\\z/)\n if @user_input =~ valid_characters\n @user_input = @user_input.dup\n @user_input.gsub!(/v/, \"|\")\n @user_input.gsub!(/\\^/, \"&\")\n @user_input.gsub!(/\\~/, \"!\")\n @user_input.gsub!(/\\-\\>/, \">\")\n @user_input.gsub!(/\\<\\-/, \"<\")\n @user_input.gsub!(/\\[\\{/, \"(\")\n @user_input.gsub!(/\\]\\}/, \")\")\n @user_input.gsub!(/\\<\\-\\>/, \"+\")\n @user_input.gsub!(/\\<\\>/, \"+\")\n @user_input\n else\n raise \"Invalid characters in input\"\n end\n end", "def raws_to_handle\n [\"422\", \"376\", \"433\"]\n end", "def raw(s)\n Forme.raw(s)\n end", "def normalize(v)\n v.to_s.strip\n end", "def fix_encoding!(thing)\n case thing\n when Net::LDAP::Entry\n thing.each_attribute do |k|\n fix_encoding!(thing[k])\n end\n when Hash\n thing.each_pair do |k, v|\n thing[k] = fix_encoding!(v)\n end\n when Array\n thing.collect! do |v|\n fix_encoding!(v)\n end\n when String\n sanitize_utf8(thing)\n end\n end", "def sanitize(string_or_io)\n Loofah.scrub_fragment(string_or_io, :escape).to_s\n end", "def sanitize(tainted)\n untainted = tainted\n \n untainted = rule1_sanitize(tainted)\n \n # Start - RULE #2 - Attribute Escape Before Inserting Untrusted Data into HTML Common Attributes\n # End - RULE #2 - Attribute Escape Before Inserting Untrusted Data into HTML Common Attributes\n \n # Start - RULE #3 - JavaScript Escape Before Inserting Untrusted Data into HTML JavaScript Data Values\n # End - RULE #3 - JavaScript Escape Before Inserting Untrusted Data into HTML JavaScript Data Values\n \n # Start - RULE #4 - CSS Escape Before Inserting Untrusted Data into HTML Style Property Values\n # End - RULE #4 - CSS Escape Before Inserting Untrusted Data into HTML Style Property Values\n \n untainted\n end", "def sanitize_attributes\n %w(author title description keyword).each do |field|\n self.send(\"#{field}=\",HTMLEntities.new.decode(self.send(field)))\n end\n end", "def raw(value)\n RawString.new(value.to_s)\n end", "def raw(value)\n RawString.new(value.to_s)\n end", "def decode_tlv(data)\n raise OutOfData if (data.length == 2 && data[1].ord != 0) || data.length < 2\n tag = data[0].ord\n length = data[1].ord\n if length < 0x80\n value = data[2, length]\n remainder = data[length+2..-1]\n else\n # ASN.1 says this octet can't be 0xff\n raise InvalidLength, length.to_s if length == 0xff\n num_octets = length & 0x7f\n length = build_integer(data, 2, num_octets)\n value = data[num_octets+2, length]\n remainder = data[num_octets+2+length..-1]\n end\n return tag, value, remainder\n end", "def process_text(raw, preserve = T.unsafe(nil)); end", "def normalize(type); end", "def validate_and_sanitize\n\n r = validate\n return r unless r.success?\n\n return invalid_url_error('dm_sdav_1') if @a_t.blank?\n\n return invalid_url_error('dm_sdav_2') unless Util::CommonValidator.is_valid_token?(@a_t)\n\n decryptor_obj = EmailTokenEncryptor.new(GlobalConstant::SecretEncryptor.email_tokens_key)\n r = decryptor_obj.decrypt(@a_t, GlobalConstant::ManagerValidationHash::secure_data_access_kind)\n return r unless r.success?\n\n decrypted_t = r.data[:plaintext]\n\n splited_reset_token = decrypted_t.split(':')\n\n return invalid_url_error('dm_sdav_3') if splited_reset_token.length != 3\n\n @manager_validation_hash_id = splited_reset_token[0].to_i\n\n @c_at_timestamp = splited_reset_token[1]\n\n @sda_token = splited_reset_token[2]\n\n success\n\n end", "def to_r\n\t\traw = value.to_s;\n\n\t\tif (self.type & TLV_META_TYPE_STRING == TLV_META_TYPE_STRING)\n\t\t\traw += \"\\x00\"\n\t\telsif (self.type & TLV_META_TYPE_UINT == TLV_META_TYPE_UINT)\n\t\t\traw = [value].pack(\"N\")\n\t\telsif (self.type & TLV_META_TYPE_BOOL == TLV_META_TYPE_BOOL)\n\t\t\tif (value == true)\n\t\t\t\traw = [1].pack(\"c\")\n\t\t\telse\n\t\t\t\traw = [0].pack(\"c\")\n\t\t\tend\n\t\tend\n\n\t\treturn [raw.length + 8, self.type].pack(\"NN\") + raw\n\tend", "def translate_data(data)\n if data[0..3] == \"\\x4c\\x6f\\xa7\\x94\"\n # EBCDIC\n data = _ebcdic_to_ascii(data)\n elsif data[0..3] == \"\\x00\\x3c\\x00\\x3f\"\n # UTF-16BE\n data = uconvert(data, 'utf-16be', 'utf-8')\n elsif data.size >= 4 and data[0..1] == \"\\xfe\\xff\" and data[2..3] != \"\\x00\\x00\"\n # UTF-16BE with BOM\n data = uconvert(data[2..-1], 'utf-16be', 'utf-8')\n elsif data[0..3] == \"\\x3c\\x00\\x3f\\x00\"\n # UTF-16LE\n data = uconvert(data, 'utf-16le', 'utf-8')\n elsif data.size >=4 and data[0..1] == \"\\xff\\xfe\" and data[2..3] != \"\\x00\\x00\"\n # UTF-16LE with BOM\n data = uconvert(data[2..-1], 'utf-16le', 'utf-8')\n elsif data[0..3] == \"\\x00\\x00\\x00\\x3c\"\n # UTF-32BE\n data = uconvert(data, 'utf-32be', 'utf-8')\n elsif data[0..3] == \"\\x3c\\x00\\x00\\x00\"\n # UTF-32LE\n data = uconvert(data, 'utf-32le', 'utf-8')\n elsif data[0..3] == \"\\x00\\x00\\xfe\\xff\"\n # UTF-32BE with BOM\n data = uconvert(data[4..-1], 'utf-32BE', 'utf-8')\n elsif data[0..3] == \"\\xff\\xfe\\x00\\x00\"\n # UTF-32LE with BOM\n data = uconvert(data[4..-1], 'utf-32LE', 'utf-8')\n elsif data[0..2] == \"\\xef\\xbb\\xbf\"\n # UTF-8 with BOM\n data = data[3..-1]\n else\n # ASCII-compatible\n end\n return data\nend", "def load(raw)\n raw\n end", "def unwrap\n data.gsub(/({{)|(}})/, '')\n end", "def smartify(input); end", "def normalize(v)\n find(v)&.alpha3 || super(v)\n end", "def sanitize_description\n self.description = Sanitize.fragment(self.description, Sanitize::Config::BASIC)\n end", "def sanitize_data\n sanitize_name\n sanitize_city\n sanitize_zip_code\n sanitize_address\n end", "def sanitize_data\n sanitize_name\n sanitize_city\n sanitize_zip_code\n sanitize_address\n end", "def fix_raw!\n raw['created_at'] = ModelCommon.flatten_date(raw['created_at'])\n raw['id'] = ModelCommon.zeropad_id(raw['id'])\n raw['protected'] = ModelCommon.unbooleanize(raw['protected'])\n Wukong.encode_components raw, 'name', 'location', 'description', 'url'\n # There are several users with bogus screen names\n # These we need to **URL encode** -- not XML-encode.\n if raw['screen_name'] !~ /\\A\\w+\\z/\n raw['screen_name'] = Wukong.encode_str(raw['screen_name'], :url)\n end\n end", "def sanitize(str)\n DescriptionSanitizer.new.sanitize(str)\n end", "def normalize_encrypted(_value)\n nil\n end", "def tag_value(v)\n v.to_s.downcase. # make lowercase\n gsub(/\\s+/, ' '). # elide consecutive spaces\n strip\n end", "def _string_parse!(klass, v)\n klass.parse(v)\n end", "def full_sanitizer=(_arg0); end", "def full_sanitizer=(_arg0); end", "def full_sanitizer=(_arg0); end", "def sanitize(options={})\n coder = HTMLEntities.new()\n \n #lowercase it\n encoded = self.downcase()\n \n #convert special chars to html entities\n encoded = coder.encode(encoded, :named)\n \n #replace spaces by _ (underscore)\n encoded = encoded.gsub(/\\s+/i, '_')\n \n while ((found = encoded.match(/&([^&;]+);/i)))\n #char without accent, is the first in the html entity definition\n char = found[1][0]\n \n char_ord = coder.decode(found[0]).ord()\n if ( (char_ord >= 192 && char_ord <= 214) ||\n (char_ord >= 216 && char_ord <= 223) ||\n (char_ord >= 224 && char_ord <= 246) ||\n (char_ord >= 248 && char_ord <= 255)\n )\n #valid character\n else\n char = \"_\"\n end\n \n #replace encoded\n encoded = encoded.gsub(/#{ Regexp.escape(found[0]) }/, char)\n end\n \n return encoded\n end", "def sanitize\n scrub_payload_emails\n scrub_actor_attributes\n end", "def raw(s)\n RawString.new(s)\n end", "def validate_and_sanitize\n r = validate\n return r unless r.success?\n\n @ethereum_address = @ethereum_address.to_s\n\n @ethereum_address = Util::CommonValidator.sanitize_ethereum_address(@ethereum_address)\n\n return error_with_identifier('invalid_api_params',\n 'um_cea_1',\n ['invalid_ethereum_address']\n ) unless Util::CommonValidator.is_ethereum_address?(@ethereum_address)\n\n success\n end", "def build_raw_data(data)\r\n data.kind_of?(String) ? data : data.inspect\r\n end", "def sanitize_input(params)\n params[\"etd\"][\"abstract\"] = ::InputSanitizer.sanitize(params[\"etd\"][\"abstract\"])\n params[\"etd\"][\"table_of_contents\"] = ::InputSanitizer.sanitize(params[\"etd\"][\"table_of_contents\"])\n end", "def sanitize\n self.summary = sanitize_string(summary)\n self.description = sanitize_string(description)\n self.post_install_message = sanitize_string(post_install_message)\n self.authors = authors.collect {|a| sanitize_string(a) }\n end", "def sanitize_instructions\n self.instructions = Sanitize.fragment(self.instructions, Sanitize::Config::BASIC)\n end", "def parse(rawdata)\n end", "def normalize\n \tif !self.phone.nil?\n\t \tself.phone = self.phone.gsub(/[^a-z0-9]/i, '')\n\t \tif self.phone.length == 8\n\t \t\tarea_code = \"\"\n\t \t\tfirst = self.phone[0]\n\t \t\tif first == \"6\"\n\t \t\t\tarea_code = \"619\"\n\t \t\telsif first == \"8\"\n\t \t\t\tarea_code = \"858\"\n\t \t\tend\n\t \t\tself.phone = area_code + self.phone[1..-1]\n\t \t elsif self.phone.length == 10\n\t \t\t # do nothing for now\n\t \t else\n\t \t\t # do nothing for now\n\t \t end\n\t end\n end", "def clean_client_field(data)\n data = data.to_s\n data.gsub!(/[\\^`|~\\\"']/, '')\n data.gsub!(/[{<]/, '(')\n data.gsub!(/[}>]/, ')')\n data.gsub!(/&/, 'and')\n data[0...100]\n end", "def sanitize(context,input)\n whitelist(input,Owasp::Esapi::Ecnoder::CHAR_ALPHANUMERIC)\n end", "def standardize\n strip_and_squeeze.\n ampersands_into_text.\n into_ampersand_if_second_to_last.\n remove_indian_languages.\n remove_screening_details.\n replace_non_film_prefix.\n remove_newlines.\n remove_dates.\n title_case\n to_s\n end", "def decode_quoted_printable!\n self.replace(self.decode_quoted_printable)\n end", "def sanitize_data!\n convert_datetimes_intelligently!\n end", "def sanitize_data\n data + \"datacite: #{create_xml.to_xml.gsub(\"%\", \"%25\").gsub(\":\", \"%3A\").gsub(\"\\n\", \"%0D%0A\").gsub(\"\\r\", \"\")}\\n\"\n end", "def normalized\n @address.downcase.gsub(/[^A-Fa-f0-9]/, '')\n end", "def pre_normalize(text); end", "def sanitize_label(label); end", "def deserialize(value)\n # expects same behavior as ActiveRecord::Type::String other than decryption\n # https://github.com/rails/rails/blob/5-0-stable/activemodel/lib/active_model/type/value.rb#L21-L23\n v = super(value)\n v.present? ? encryptor.decrypt_and_verify(v) : v\n end", "def sanitized_message\n message.to_s[0,140]\n end", "def normalize(v)\n case v\n when ActiveSupport::Duration then return from_duration(v)\n when IsoDuration then return v.to_s\n else v = v.to_s\n end\n MATCH_PATTERN.any? { |_, pattern| v.match?(pattern) } ? v : ''\n end", "def make_string raw_string\n ParsedString.new raw_string\n end", "def transform_String(o, scope)\n assert_catalog_type(Types::TypeParser.singleton.parse(o), scope)\n end", "def canonize str\n\n case support(\"CASEMAPPING\", \"rfc1459\").downcase\n\n when \"ascii\"\n str.upcase\n\n when \"rfc1459\", nil\n str.upcase.tr(\"|{}^\", \"\\\\\\\\[]~\")\n\n when \"strict-rfc1459\"\n str.upcase.tr(\"|{}\", \"\\\\\\\\[]\")\n\n else\n str.upcase.tr(\"|{}^\", \"\\\\\\\\[]~\")\n\n end\n\n end", "def normalize(v)\n v = strip_copyright(v) if v.is_a?(String)\n day_convert(v)\n end", "def clean_data( field )\n\tfield.to_s.strip\nend", "def fix_utf8(s=nil)\n s=self if s.nil? #if we are included\n if String.method_defined?(:scrub)\n #Ruby 2.1\n #cf http://ruby-doc.org/core-2.1.0/String.html#method-i-scrub\n return s.scrub {|bytes| '<'+bytes.unpack('H*')[0]+'>' }\n else\n return DR::Encoding.to_utf8(s)\n end\n end", "def data_strip_downcase\n self.original_text = original_text.mb_chars.strip.downcase\n self.translated_text = translated_text.mb_chars.strip.downcase\n end", "def sanitize_attributes\n if self.sanitize_level\n self.body = Sanitize.clean(self.body_raw, self.sanitize_level)\n self.title = Sanitize.clean(self.title, self.sanitize_level)\n else\n self.body = self.body_raw\n end\n end" ]
[ "0.6193213", "0.57636374", "0.55234313", "0.5228051", "0.5213243", "0.518444", "0.51834846", "0.51834846", "0.5154971", "0.5140968", "0.5122174", "0.51009953", "0.50373274", "0.5011793", "0.50004846", "0.49918544", "0.49756673", "0.4962281", "0.49432832", "0.49171636", "0.49090734", "0.4893354", "0.48920682", "0.48817638", "0.48780617", "0.48617557", "0.48520216", "0.48489887", "0.4847548", "0.48422837", "0.4830781", "0.48233983", "0.48100108", "0.48023003", "0.47945338", "0.4779235", "0.4755836", "0.47531092", "0.47492558", "0.47470716", "0.47421226", "0.47354585", "0.47331896", "0.47288254", "0.47270036", "0.4722698", "0.47215593", "0.471887", "0.471887", "0.47133264", "0.4712919", "0.47104836", "0.47034428", "0.4696341", "0.46727508", "0.46609503", "0.4649365", "0.46489432", "0.46407628", "0.46369368", "0.46334913", "0.46334913", "0.4624907", "0.4617081", "0.46024114", "0.4600896", "0.4600801", "0.45976928", "0.45976928", "0.45976928", "0.4596629", "0.4593606", "0.45912462", "0.45839494", "0.4574151", "0.45735195", "0.4573299", "0.4570308", "0.45653775", "0.45650485", "0.45637512", "0.45631158", "0.4555756", "0.45470226", "0.4538018", "0.45286486", "0.4519602", "0.4518346", "0.45176315", "0.45148826", "0.45106918", "0.4502924", "0.4499751", "0.44983357", "0.44886398", "0.4486038", "0.4482838", "0.44807553", "0.44806966", "0.4479953" ]
0.55871564
2
Constructor Initializes the group TLV container to the supplied type and creates an empty TLV array.
def initialize(type) super(type) self.tlvs = [ ] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initialize groupSize\n\t\t@groupSize=groupSize\n\t\t@arrayChromosomes=Array.new\n\tend", "def group_type=(value)\n @group_type = value\n end", "def initialize(type)\n @items = []\n @type = type\n end", "def initialize(type = TYPES[:empty])\n @type = type\n end", "def add_tlv(type, value = nil, replace = false)\n\t\ttlv = nil\n\n\t\t# If we should replace any TLVs with the same type...remove them first\n\t\tif (replace)\n\t\t\teach(type) { |tlv|\n\t\t\t\tif (tlv.type == type)\n\t\t\t\t\tself.tlvs.delete(tlv)\n\t\t\t\tend\n\t\t\t}\n\t\tend\n\n\t\tif (type & TLV_META_TYPE_GROUP == TLV_META_TYPE_GROUP)\n\t\t\ttlv = GroupTlv.new(type)\n\t\telse\n\t\t\ttlv = Tlv.new(type, value)\n\t\tend\n\n\t\tself.tlvs << tlv\n\n\t\treturn tlv\n\tend", "def add_tlv(type, value = nil, replace = false, compress=false)\n\n\t\t# If we should replace any TLVs with the same type...remove them first\n\t\tif (replace)\n\t\t\teach(type) { |tlv|\n\t\t\t\tif (tlv.type == type)\n\t\t\t\t\tself.tlvs.delete(tlv)\n\t\t\t\tend\n\t\t\t}\n\t\tend\n\n\t\tif (type & TLV_META_TYPE_GROUP == TLV_META_TYPE_GROUP)\n\t\t\ttlv = GroupTlv.new(type)\n\t\telse\n\t\t\ttlv = Tlv.new(type, value, compress)\n\t\tend\n\n\t\tself.tlvs << tlv\n\n\t\treturn tlv\n\tend", "def initialize(type)\n @type = type\n @word_array = []\n end", "def initialize!(group = T.unsafe(nil)); end", "def initialize!(group = T.unsafe(nil)); end", "def create_array_tc(length, element_type)\n return CORBA::TypeCode::Array.new(element_type, length)\n end", "def initialize(datatype, lngth, array=nil)\n @struct = Numrb::Vec.const_get(\"Struct_#{datatype}\").new\n @struct[:dtype] = TYPES_AR.index(datatype)\n @struct[:size] = lngth\n @struct[:ptr] = Numrb::Vec::Data.new(lngth, STRIDES[datatype])\n if array\n @struct[:ptr].send(\"put_array_of_#{datatype}\", 0, array)\n end\n end", "def from_r(raw)\n\t\toffset = 8\n\n\t\t# Reset the TLVs array\n\t\tself.tlvs = []\n\t\tself.type = raw.unpack(\"NN\")[1]\n\n\t\t# Enumerate all of the TLVs\n\t\twhile (offset < raw.length-1)\n\n\t\t\ttlv = nil\n\n\t\t\t# Get the length and type\n\t\t\tlength, type = raw[offset..offset+8].unpack(\"NN\")\n\n\t\t\tif (type & TLV_META_TYPE_GROUP == TLV_META_TYPE_GROUP)\n\t\t\t\ttlv = GroupTlv.new(type)\n\t\t\telse\n\t\t\t\ttlv = Tlv.new(type)\n\t\t\tend\n\n\t\t\ttlv.from_r(raw[offset..offset+length])\n\n\t\t\t# Insert it into the list of TLVs\n\t\t\ttlvs << tlv\n\n\t\t\t# Move up\n\t\t\toffset += length\n\t\tend\n\tend", "def from_r(raw)\n\t\toffset = 8\n\n\t\t# Reset the TLVs array\n\t\tself.tlvs = []\n\t\tself.type = raw.unpack(\"NN\")[1]\n\n\t\t# Enumerate all of the TLVs\n\t\twhile (offset < raw.length-1)\n\n\t\t\ttlv = nil\n\n\t\t\t# Get the length and type\n\t\t\tlength, type = raw[offset..offset+8].unpack(\"NN\")\n\n\t\t\tif (type & TLV_META_TYPE_GROUP == TLV_META_TYPE_GROUP)\n\t\t\t\ttlv = GroupTlv.new(type)\n\t\t\telse\n\t\t\t\ttlv = Tlv.new(type)\n\t\t\tend\n\n\t\t\ttlv.from_r(raw[offset..offset+length])\n\n\t\t\t# Insert it into the list of TLVs\n\t\t\ttlvs << tlv\n\n\t\t\t# Move up\n\t\t\toffset += length\n\t\tend\n\tend", "def set_tag_type_group\n @tag_type_group = TagTypeGroup.find(params[:id])\n end", "def create\n @tag_type_group = TagTypeGroup.new(tag_type_group_params)\n \n if @tag_type_group.save\n @tag_types = TagType.includes(:tag_type_group).all.group_by(&:tag_type_group)\n else\n render :action => 'new'\n end\n end", "def initialize(type)\n @type = type\n end", "def initialize(type)\n @type = type\n end", "def initialize(data=[], subtype=SUBTYPE_SIMPLE)\n super(data)\n @subtype = subtype\n end", "def set_typegroup\n @typegroup = Typegroup.find(params[:id])\n end", "def create_array(element_type, length = 0, size: nil, typename: nil, **options)\n element_type = validate_type_argument(element_type)\n typename ||= \"#{element_type.name}[#{length}]\"\n if !size && element_type.size\n size = element_type.size * length\n end\n ModelKit::Types.validate_typename(typename)\n array_t = ArrayType.new_submodel(deference: element_type, typename: typename, registry: self,\n length: length, size: size, **options)\n register(array_t)\n end", "def initialize(type=nil)\n @type = type\n end", "def initialize(group,name,protein,glucids,lipids)\n super(name,protein,glucids,lipids)\n @grupo = group\n end", "def new_group(key)\n []\n end", "def initialize(type, value = nil)\n\t\t@type = type\n\t\t\n\t\tif (value != nil)\n\t\t\tif (type & TLV_META_TYPE_STRING == TLV_META_TYPE_STRING)\n\t\t\t\tif (value.kind_of?(Fixnum))\n\t\t\t\t\t@value = value.to_s\n\t\t\t\telse\n\t\t\t\t\t@value = value.dup\n\t\t\t\tend\n\t\t\telse\n\t\t\t\t@value = value\n\t\t\tend\n\t\tend\n\tend", "def genomic_align_group_by_type(type)\n return self.genomic_align_groups.find_by_type(type)\n end", "def initialize(type:, data: nil)\n @type = type\n data = @type.default_data if data.nil?\n @entries = @type.parse(read_data(data))\n end", "def generate_groups(groups, type)\r\n [].tap do |results|\r\n groups.each do |n, obj|\r\n group = {}\r\n group[\"name\"] = obj['name']\r\n group[\"code\"] = n\r\n group[\"risk_category\"] = \"AUTO\"\r\n group[type] = obj[type]\r\n results << group\r\n end\r\n end\r\nend", "def group_type\n return @group_type\n end", "def group(group: T.unsafe(nil)); end", "def initialize_groups\n @groups = []\n @edges.each do |e|\n @groups.push([e[0]]) # single-element group\n @groups.push([e[1]]) # single-element group\n end\n @groups.uniq!\n end", "def new\n @group = Group.new\n end", "def initialize(type)\n @type = type\n end", "def initialize(type)\n @type = type\n end", "def initialize(type)\n @type = type\n end", "def new group_identifier, object_identifier_or_array = []\n groups.store self.class.identifierize(group_identifier), self.class.identifier_collect(object_identifier_or_array)\n end", "def set_group_type\n @group_type = GroupType.find(params[:id])\n end", "def initialize(type, data=nil)\n # Verify then set the record type\n @type = type\n ensure_valid_type\n self.data = data\n end", "def specimen_array_type=(type)\n setSpecimenArrayType(type)\n unless type.nil? then\n copy_container_type_capacity\n end\n type\n end", "def instantiate!\n (@@types[type] || []).each do |name, datatype|\n @named_elements[name.to_sym] = if datatype == :buffer\n remainder_as_buffer\n else\n send(\"read_#{datatype}\")\n end\n end\n end", "def initialize(name, type)\n @name = name\n @type = type\n @stomach = []\n end", "def groups\n @groups = init_groups\n end", "def new\n @group = Group.new\n end", "def new\n @group = Group.new\n end", "def new\n @group = Group.new\n end", "def new\n @group = Group.new\n end", "def new\n @group = Group.new\n end", "def initialize type = nil, *items\n @type = type\n @items = []\n @items.concat items\n end", "def create\n @typegroup = Typegroup.new(typegroup_params)\n\n respond_to do |format|\n if @typegroup.save\n format.html { redirect_to @typegroup, notice: 'Typegroup was successfully created.' }\n format.json { render action: 'show', status: :created, location: @typegroup }\n else\n format.html { render action: 'new' }\n format.json { render json: @typegroup.errors, status: :unprocessable_entity }\n end\n end\n end", "def initialize(type,data=nil)\n self.class.check_msg_type(type)\n self.type = type\n @data = data\n @bytes_per_record = 0\n @bytes_expected = 5\n @keysize = @valuesize = 0\n @parsed = false\n @buffer = String.new\n @parse_phase = PARSE_PHASES.first\n end", "def new\n \t@group = Group.new\n end", "def groups_by_asset_type(type)\n arr = []\n groups.each do |group|\n arr << group if !@bundles[group.to_s].assets(type.to_sym).empty?\n end\n return arr\n end", "def initialize()\n super\n @odata_type = \"#microsoft.graph.sectionGroup\"\n end", "def initialize(type, clean = true)\n\t\t\t@type = type\n\t\t\t@clean = clean\n\t\tend", "def create_types\n\t\t[]\n\tend", "def create_types\n\t\t[]\n\tend", "def initialize(type, array=false, comment=nil)\n @basetype = Fortran.standardize_type type\n @array = array\n @comment = comment\n end", "def new_group(group_data)\n [:id, :name].each { |attr| raise(ArgumentError, \"Missing or Invalid Parameter(s)\") unless group_data.key?(attr) }\n set_values group_data\n end", "def initialize(type, clean = true)\n @type = type\n @clean = clean\n end", "def typegroup_params\n params[:typegroup]\n end", "def initialize(type, clean = true)\n\t\t@type = type\n\t\t@clean = clean\n\tend", "def initialize(type, clean = true)\n\t\t@type = type\n\t\t@clean = clean\n\tend", "def initialize(type, clean = true)\n\t\t@type = type\n\t\t@clean = clean\n\tend", "def initialize(type, clean = true)\n\t\t@type = type\n\t\t@clean = clean\n\tend", "def initialize(type, clean = true)\n\t\t@type = type\n\t\t@clean = clean\n\tend", "def initialize(type, clean = true)\n\t\t@type = type\n\t\t@clean = clean\n\tend", "def initialize(type, clean = true)\n\t\t@type = type\n\t\t@clean = clean\n\tend", "def initialize(type, clean = true)\n\t\t@type = type\n\t\t@clean = clean\n\tend", "def initialize(type, clean = true)\n\t\t@type = type\n\t\t@clean = clean\n\tend", "def initialize(type, clean = true)\n\t\t@type = type\n\t\t@clean = clean\n\tend", "def initialize(type, clean = true)\n\t\t@type = type\n\t\t@clean = clean\n\tend", "def initialize(type, clean = true)\n\t\t@type = type\n\t\t@clean = clean\n\tend", "def initialize(type, clean = true)\n\t\t@type = type\n\t\t@clean = clean\n\tend", "def initialize(type, clean = true)\n\t\t@type = type\n\t\t@clean = clean\n\tend", "def initialize(type, size)\n @type = type\n @size = size\n end", "def initialize\n @type_variants = Container.new\n @extension_index = Container.new\n @data_version = VERSION.dup.freeze\n end", "def initialize(packet_type, length = 0, payload = '') \n @codec_id = CODEC_ID\n @packet_type = packet_type\n @length = length\n\n case @packet_type\n when 'response'\n @data_length = length - 1 # codec id not included here - skip 1 byte\n @data_to_read = @data_length + SIZE_CRC # size from \"number of data 1\" to crc\n @data = [] # binary data\n when 'command'\n @payload = payload\n end\n\n @records = [] # parsed records\n @status = 'pending' # status of packet\n end", "def create_group(group_node)\n name_ru = group_node.text.delete(\"0-9\")\n Group.create(name_ru: name_ru)\n end", "def initialize(type = nil, method = nil)\n\t\tsuper(type)\n\n\t\tif (method)\n\t\t\tself.method = method\n\t\tend\n\n\t\t# If it's a request, generate a random request identifier\n\t\tif ((type == PACKET_TYPE_REQUEST) ||\n\t\t (type == PACKET_TYPE_PLAINTEXT_REQUEST))\n\t\t\trid = ''\n\n\t\t\t32.times { |val| rid << rand(10).to_s }\n\n\t\t\tadd_tlv(TLV_TYPE_REQUEST_ID, rid)\n\t\tend\n\tend", "def initialize(type)\n super\n end", "def group_tag=(value)\n @group_tag = value\n end", "def new\n @group = Group.new \n end", "def create_groups_ui\n @groups_ui = Groups.new(@viewport, @stack)\n end", "def initialize(type, clean = true)\n\t@type = type\n\t@clean = clean\n\tend", "def initialize(type, clean = true)\n\t@type = type\n\t@clean = clean\n\tend", "def initialize(type, clean = true)\n\t@type = type\n\t@clean = clean\n\tend", "def group\n return nil if item_type != 'group'\n direct_group\n end", "def initialize(type = nil, method = nil)\n\t\tsuper(type)\n\n\t\tif (method)\n\t\t\tself.method = method\n\t\tend\n\n\t\tself.created_at = ::Time.now\n\n\t\t# If it's a request, generate a random request identifier\n\t\tif ((type == PACKET_TYPE_REQUEST) ||\n\t\t (type == PACKET_TYPE_PLAIN_REQUEST))\n\t\t\trid = ''\n\n\t\t\t32.times { |val| rid << rand(10).to_s }\n\n\t\t\tadd_tlv(TLV_TYPE_REQUEST_ID, rid)\n\t\tend\n\tend", "def __mk_group(gdoc)\n @disp_dic.ext_grp unless @disp_dic.is_a? Disp::Grouping\n gatt = gdoc.to_h\n return if gatt[:enable] == 'false'\n sub = @disp_dic.add_grp(gatt.delete(:id), gatt.delete(:label))\n gdoc.each { |e| __mk_sub_db(e, sub, gatt.dup) }\n end", "def initialize(type)\n @type = type\n @ready = false\n @instance_name = \"#{@type}#{1 + rand(20)}\"\n @options = Hash.new\n @notes = Hash.new\n end", "def initialize( nodes=[], name: nil, group: nil )\n super( nodes )\n\n @name = name\n @group = group\n\n @count = nil\n end", "def kind\n @kind || :group\n end", "def initialize(type, clean = true)\n\t@type = type\n\t@clean = clean\n end", "def initialize(type, clean = true)\n\t@type = type\n\t@clean = clean\n end", "def initialize(type)\n @type = type\n @mediatype, @subtype = type.split('/', 2)\n end", "def index\n @tag_type_groups = TagTypeGroup.all\n end", "def initialize(element_type)\n @element_type = element_type\n end", "def initialize( name, group=nil )\n @name = name\n @group = group\n\n @count = nil\n end", "def initialize(type = LABEL_DETECTION)\n @type = type\n end", "def initialize(type, clean = true)\n @type = type\n @clean = clean\n end" ]
[ "0.5959835", "0.58469665", "0.5821178", "0.5817117", "0.57417417", "0.5656058", "0.5633167", "0.5556355", "0.5556355", "0.5307821", "0.5232313", "0.52197134", "0.52197134", "0.52070105", "0.52035844", "0.51866245", "0.51866245", "0.5176312", "0.5162468", "0.51504487", "0.5144358", "0.5106941", "0.5100409", "0.50909036", "0.5083495", "0.50775564", "0.50709313", "0.5061307", "0.5054973", "0.5033375", "0.5025626", "0.5019712", "0.5019712", "0.5019712", "0.49868897", "0.4976258", "0.49668804", "0.493905", "0.49297324", "0.4905991", "0.4874078", "0.48690954", "0.48690954", "0.48690954", "0.48690954", "0.48690954", "0.48551968", "0.48528874", "0.4839058", "0.4835612", "0.4819755", "0.48149553", "0.48093635", "0.48068255", "0.48068255", "0.4797916", "0.47957805", "0.4779247", "0.47718436", "0.47639924", "0.47639924", "0.47639924", "0.47639924", "0.47639924", "0.47639924", "0.47639924", "0.47639924", "0.47639924", "0.47639924", "0.47639924", "0.47639924", "0.47639924", "0.47639924", "0.4758069", "0.4757814", "0.47547066", "0.47493735", "0.47442707", "0.4729898", "0.4722503", "0.47191125", "0.4698876", "0.46825594", "0.46825594", "0.46819165", "0.46767053", "0.46754912", "0.4672758", "0.4668136", "0.46646053", "0.46628952", "0.46626252", "0.46626252", "0.46615043", "0.4660771", "0.4658053", "0.46537822", "0.46517178", "0.4648646" ]
0.5399001
10
Groupbased TLV accessors Enumerates TLVs of the supplied type.
def each(type = TLV_TYPE_ANY, &block) get_tlvs(type).each(&block) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def each_with_index(type = TLV_TYPE_ANY, &block)\n\t\tget_tlvs(type).each_with_index(&block)\n\tend", "def each_with_index(type = TLV_TYPE_ANY, &block)\n\t\tget_tlvs(type).each_with_index(&block)\n\tend", "def get_tlv_values(type)\n\t\tget_tlvs(type).collect { |a| a.value }\n\tend", "def get_tlv_values(type)\n\t\tget_tlvs(type).collect { |a| a.value }\n\tend", "def get_tlv(type, index = 0)\n\t\ttype_tlvs = get_tlvs(type)\n\n\t\tif (type_tlvs.length > index)\n\t\t\treturn type_tlvs[index]\n\t\tend\n\n\t\treturn nil\n\tend", "def get_tlv(type, index = 0)\n\t\ttype_tlvs = get_tlvs(type)\n\n\t\tif (type_tlvs.length > index)\n\t\t\treturn type_tlvs[index]\n\t\tend\n\n\t\treturn nil\n\tend", "def get_tlvs(type)\n\t\tif (type == TLV_TYPE_ANY)\n\t\t\treturn self.tlvs\n\t\telse\n\t\t\ttype_tlvs = []\n\n\t\t\tself.tlvs.each() { |tlv|\n\t\t\t\tif (tlv.type?(type))\n\t\t\t\t\ttype_tlvs << tlv\n\t\t\t\tend\n\t\t\t}\n\n\t\t\treturn type_tlvs\n\t\tend\n\tend", "def get_tlvs(type)\n\t\tif (type == TLV_TYPE_ANY)\n\t\t\treturn self.tlvs\n\t\telse\n\t\t\ttype_tlvs = []\n\n\t\t\tself.tlvs.each() { |tlv|\n\t\t\t\tif (tlv.type?(type))\n\t\t\t\t\ttype_tlvs << tlv\n\t\t\t\tend\n\t\t\t}\n\n\t\t\treturn type_tlvs\n\t\tend\n\tend", "def add_tlv(type, value = nil, replace = false)\n\t\ttlv = nil\n\n\t\t# If we should replace any TLVs with the same type...remove them first\n\t\tif (replace)\n\t\t\teach(type) { |tlv|\n\t\t\t\tif (tlv.type == type)\n\t\t\t\t\tself.tlvs.delete(tlv)\n\t\t\t\tend\n\t\t\t}\n\t\tend\n\n\t\tif (type & TLV_META_TYPE_GROUP == TLV_META_TYPE_GROUP)\n\t\t\ttlv = GroupTlv.new(type)\n\t\telse\n\t\t\ttlv = Tlv.new(type, value)\n\t\tend\n\n\t\tself.tlvs << tlv\n\n\t\treturn tlv\n\tend", "def add_tlv(type, value = nil, replace = false, compress=false)\n\n\t\t# If we should replace any TLVs with the same type...remove them first\n\t\tif (replace)\n\t\t\teach(type) { |tlv|\n\t\t\t\tif (tlv.type == type)\n\t\t\t\t\tself.tlvs.delete(tlv)\n\t\t\t\tend\n\t\t\t}\n\t\tend\n\n\t\tif (type & TLV_META_TYPE_GROUP == TLV_META_TYPE_GROUP)\n\t\t\ttlv = GroupTlv.new(type)\n\t\telse\n\t\t\ttlv = Tlv.new(type, value, compress)\n\t\tend\n\n\t\tself.tlvs << tlv\n\n\t\treturn tlv\n\tend", "def fields_of_type(type, &block)\n selected = @fields.select {|f| type == f.type }\n if block\n selected.each {|f| f.instance_eval &block }\n end\n selected\n end", "def get_tlv_value(type, index = 0)\n\t\ttlv = get_tlv(type, index)\n\n\t\treturn (tlv != nil) ? tlv.value : nil\n\tend", "def get_tlv_value(type, index = 0)\n\t\ttlv = get_tlv(type, index)\n\n\t\treturn (tlv != nil) ? tlv.value : nil\n\tend", "def each_type(&block)\n if block_given?\n @types.each_value(&block)\n self\n else\n @types.values\n end\n end", "def tlv_select\n info 'os10_lldp_interface::tlv select'\n begin\n lldp_interface_data = @tlv_ret[:stdout].split(\"\\n\")\n temp_data = {}\n\n lldp_interface_data.each do |data|\n if data.include? 'lldp tlv-select'\n tlv_data = data.split(' ')\n if tlv_data.length == 4\n temp_data[tlv_data[3]] = [' ']\n elsif temp_data[tlv_data[3]].nil? && tlv_data.length >= 4\n temp_data[tlv_data[3]] = [tlv_data[4]]\n elsif tlv_data[4]\n temp_data[tlv_data[3]] = temp_data[tlv_data[3]] << tlv_data[4]\n temp_data[tlv_data[3]] = temp_data[tlv_data[3]].sort\n end\n end\n end\n return temp_data\n rescue Exception => e\n err 'Exception in tlv select'\n err e.message\n err e.backtrace[0]\n raise\n end\n end", "def enumerate(type, opts)\n raise Error::SubclassResponsibility\n end", "def each\n @type_variants.values.each { |tv| tv.each { |t| yield t } }\n end", "def each_type\n types.values.each do |type|\n yield(type)\n end\n end", "def has_tlv?(type)\n\t\treturn get_tlv(type) != nil\n\tend", "def has_tlv?(type)\n\t\treturn get_tlv(type) != nil\n\tend", "def decode_tlv(data)\n raise OutOfData if (data.length == 2 && data[1].ord != 0) || data.length < 2\n tag = data[0].ord\n length = data[1].ord\n if length < 0x80\n value = data[2, length]\n remainder = data[length+2..-1]\n else\n # ASN.1 says this octet can't be 0xff\n raise InvalidLength, length.to_s if length == 0xff\n num_octets = length & 0x7f\n length = build_integer(data, 2, num_octets)\n value = data[num_octets+2, length]\n remainder = data[num_octets+2+length..-1]\n end\n return tag, value, remainder\n end", "def all_group_or_elems(type)\n if type == :group\n self.elements_groups\n elsif type == :elem\n self.elements\n end\n end", "def type_select object, method, label_text, options\n content_tag :div, :class => :\"type-select\" do\n attr_id = \"#{object.class.to_s.downcase}[#{method}]\".to_sym\n output = String.new\n output << content_tag(:label, label_text, :for => attr_id) unless label_text.blank?\n output << select_tag(attr_id, options)\n end\n end", "def type(type)\n select { |node| node.type == type }\n end", "def get_data_elements_by_type(patient, type)\n matches = []\n patient.dataElements.each do |data_element|\n matches << data_element if data_element[:_type] == type\n end\n matches\n end", "def [](type)\r\n @types.fetch type, nil\r\n end", "def [](type_id, flags = {})\n __types__[type_id, flags]\n end", "def volume_type=(value)\n @volume_type = value\n end", "def type(type)\n select { |node| node.type.equal?(type) }\n end", "def type\n @attributes[:type]\n end", "def index\n @tag_type_groups = TagTypeGroup.all\n end", "def gender_types\n @gender_types.each\n end", "def find_all_members type = :all\n case type\n when :all\n\n when :users\n\n when :groups\n\n else\n throw \"Invalid argument\"\n end\n end", "def level_items_list(type, levels)\n levels = levels.join(',') if levels.is_a?(Array)\n response = api_response(type, levels)\n\n # The vocabulary API call without specifying levels returns a Hash instead\n # of an Array, so this is a hacky way of dealing with it.\n if response[\"requested_information\"].is_a?(Hash)\n return response[\"requested_information\"][\"general\"]\n else\n return response[\"requested_information\"]\n end\n end", "def type\n self['type']['type']\n end", "def group_type(name)\n self.span(:class=>\"s3d-search-result-name\",:text=>name).parent.parent.span(:class=>\"mymemberships_item_grouptype\").text\n end", "def add_field(type, value)# {{{\n t = TLV.new(2,2)\n t.type = type\n t.value = value\n t.length = 4 + value.length\n self.payload += t.encode \n end", "def type=(new_type)\n self[:type_flags] = (flags | TYPES[new_type])\n end", "def tag(type, attr={}, children=[], &block)\n tag = _tag(type, attr, children)\n if block\n capture(block) do\n emit(serialize_open(tag))\n Array(tag.children).each{|c| emit(c)}\n yield self\n emit(serialize_close(tag))\n end\n else\n tag\n end\n end", "def index_get(type, name, &blk)\n index = send(\"#{type}_index\")\n\n # we *could* let the index handle get-or-set,\n # but we need to yield the object before the\n # index gets it.\n if index.has_key? name\n yield(index[name]) if block_given?\n index[name]\n else\n initializer = self.class.type_initializers[type]\n inst = initializer.call(name, self) if initializer\n\n #HACK: this goes somewhere else\n inst.dsl_eval { template :default }\n\n yield(inst) if block_given?\n index << inst\n inst\n end\n end", "def get_by_type(type)\r\n facts2typerule = {:methodcall => [:cant_access, :can_access],\r\n :inheritance => [:cant_extend, :can_extend],\r\n :objcreation => [:cant_create, :can_create]}\r\n\r\n find_all { |x| facts2typerule[type].index(x.type_interaction) != nil }\r\n end", "def method\n\t\treturn get_tlv_value(TLV_TYPE_METHOD)\n\tend", "def method\n\t\treturn get_tlv_value(TLV_TYPE_METHOD)\n\tend", "def type\n @attributes[:type]\n end", "def type\n @attributes[:type]\n end", "def type\n @attributes[:type]\n end", "def tag_value(type)\n pattern = reserved_patterns[type]\n tag = tags.detect { |t| t.match?(pattern) }\n return unless tag\n\n tag.match(pattern)[type]\n end", "def types\n @title = 'Resource Type Listing A-Z'\n @objects_by_letter = objects_by_letter(:puppet_type)\n erb(:objects)\nend", "def each\n if @abstract_type\n yield(@type)\n else\n @types.each { |t| yield(t) }\n end\n end", "def by_t(type)\n return self.find_all{|slot| slot.type == type}[0]\n end", "def type\n self.attributes[:type]\n end", "def type_name_enum\r\n [ [ '数字字段1', 'int1' ] ,[ '数字字段2', 'int2' ] ,[ '数字字段3', 'int3' ] ,[ '数字字段4', 'int4' ],[ '数字字段5', 'int5' ],\r\n [ '文本字段1', 'text1' ],[ '文本字段2', 'text2' ],[ '文本字段3', 'text3' ],[ '文本字段4', 'text4' ],[ '文本字段5', 'text5' ],\r\n [ '文本字段6', 'text6' ],[ '文本字段7', 'text7' ],[ '文本字段8', 'text8' ],[ '文本字段9', 'text9' ],[ '文本字段10', 'text10' ]]\r\n end", "def type\n\t\t@type\n\tend", "def index\n @group_types = GroupType.all.page().per(10)\n end", "def elements_by_type(type)\n\t\treturn xpath('//' + type)\n\tend", "def select_type\n\t\t\t@select_all_type = TypeEquipament.all\n\t\tend", "def genomic_align_group_by_type(type)\n return self.genomic_align_groups.find_by_type(type)\n end", "def query_type_enum\n return {\n 0=>'empty',\n 1=>'iso',\n 2=>'multi'\n }\n end", "def html_tag_options_for_type(type)\n case type\n when :content_tag\n HTML_CONTENT_TAG_OPTIONS\n when :empty_tag\n HTML_EMPTY_TAG_OPTIONS\n else\n HTML_TAG_OPTIONS\n end\n end", "def group_type=(value)\n @group_type = value\n end", "def type=(type)\n validator = EnumAttributeValidator.new('String', [\"NFS\", \"SMB\", \"iSCSI\"])\n unless validator.valid?(type)\n fail ArgumentError, \"invalid value for \\\"type\\\", must be one of #{validator.allowable_values}.\"\n end\n @type = type\n end", "def type=(type)\n validator = EnumAttributeValidator.new('String', [\"ITEM\", \"CATEGORY\", \"ITEM_VARIATION\", \"TAX\", \"DISCOUNT\", \"MODIFIER_LIST\", \"MODIFIER\"])\n unless validator.valid?(type)\n fail ArgumentError, \"invalid value for 'type', must be one of #{validator.allowable_values}.\"\n end\n @type = type\n end", "def custom_fields_getters_for(name, type)\n case type.to_sym\n when :select then [name, \"#{name}_id\"]\n when :date, :date_time, :money then \"formatted_#{name}\"\n when :file then \"#{name}_url\"\n when :belongs_to then \"#{name}_id\"\n else\n name\n end\n end", "def items_for_type(type)\n all_ids = []\n valid_ids = []\n AllItems.get.each do |item_code, values|\n _item_name, item_type, item_valid = values\n next unless item_type == type\n all_ids << item_code\n valid_ids << item_code if item_valid\n end\n\n [all_ids, valid_ids]\n end", "def type\n @type\n end", "def add_tlv(t,l,v=nil)\n tlv = [(t << 9) + l, v]\n self.payload += tlv.flatten.pack(\"na*\")\n end", "def custom_fields_getters_for(name, type)\n case type.to_sym\n when :select then [name, \"#{name}_id\"]\n when :date then \"formatted_#{name}\"\n when :file then \"#{name}_url\"\n when :belongs_to then \"#{name}_id\"\n else\n name\n end\n end", "def type\n\t\t\t@data[\"type\"]\n\t\tend", "def instances(type)\n @instances[type]\n end", "def item\n case item_type\n when 'group'\n group\n end\n end", "def item\n case item_type\n when 'group'\n group\n end\n end", "def each\n __types__.each {|t| yield t }\n end", "def type\n attr_val('./@typeCode')\n end", "def volume_type\n return @volume_type\n end", "def type\n field[:type]\n end", "def type\n self[:type]\n end", "def type\n @data['type']\n end", "def all_of_type\n Resource::AllOfType.new(type)\n end", "def type_to_meth(type)\n public_send(type + \"_type\")\n end", "def get_types(pokemon)\n pokemon_types = {}\n case pokemon['types'].size\n when 1\n pokemon_types[:type1] = pokemon['types'][0]['type']['name']\n when 2\n pokemon_types[:type1] = pokemon['types'][0]['type']['name']\n pokemon_types[:type2] = pokemon['types'][1]['type']['name']\n end\n pokemon_types\nend", "def children_by_type(type)\n children = YARD::Registry.all(type)\n children.select { |child| child.parent == self }\n end", "def group_type\n return @group_type\n end", "def type=(type)\n @type = type\n end", "def list_find_by_type(type, options = {})\n list_find({\n :type => subject,\n }.merge(options))\n end", "def describe_types\n [@options[:type]].flatten.join('/')\n end", "def data_types\n @title = 'Data Type Listing A-Z'\n @objects_by_letter = objects_by_letter(:puppet_data_type, :puppet_data_type_alias)\n erb(:objects)\nend", "def field_type\n if self.type == 'Button'\n if push_button?\n 'push_button'\n elsif radio_button?\n 'radio_button'\n else\n 'check_box'\n end\n elsif self.type == 'Text'\n if file?\n 'file_field'\n elsif password?\n 'password_field'\n elsif multiline?\n 'text_area'\n else\n 'text_field'\n end\n elsif self.type == 'Choice'\n 'select'\n else\n self.type.downcase\n end\n end", "def enumeration_types\n @enumeration_types ||= Search::ENUMERATION_TYPES\n end", "def type \n\t\n\t$cst.add_branch(\"type\")\n\t\n\tmatch_token(\"T_TYPE\", $tokens[$index])\n\t\n\t$cst.ascend\nend", "def type\n self['type']\n end", "def type()\n\t\t@db.hget('sgt-structure:' + @id, 'type')\n\tend", "def type\n @type\n end", "def type\n self[:type]\n end", "def from_r(raw)\n\t\tself.value = nil\n\n\t\tlength, self.type = raw.unpack(\"NN\");\n\n\t\t# check if the tlv value has been compressed...\n\t\tif( self.type & TLV_META_TYPE_COMPRESSED == TLV_META_TYPE_COMPRESSED )\n\t\t\t# set this TLV as using compression\n\t\t\t@compress = true\n\t\t\t# remove the TLV_META_TYPE_COMPRESSED flag from the tlv type to restore the \n\t\t\t# tlv type to its origional, allowing for transparent data compression.\n\t\t\tself.type = self.type ^ TLV_META_TYPE_COMPRESSED\n\t\t\t# decompress the compressed data (skipping the length and type DWORD's)\n\t\t\traw_decompressed = Rex::Text.zlib_inflate( raw[8..length-1] )\n\t\t\t# update the length to reflect the decompressed data length (+8 for the length and type DWORD's)\n\t\t\tlength = raw_decompressed.length + 8\n\t\t\t# update the raw buffer with the new length, decompressed data and updated type.\n\t\t\traw = [length, self.type].pack(\"NN\") + raw_decompressed\n\t\tend\n\t\t\n\t\tif (self.type & TLV_META_TYPE_STRING == TLV_META_TYPE_STRING)\n\t\t\tif (raw.length > 0)\n\t\t\t\tself.value = raw[8..length-2]\n\t\t\telse\n\t\t\t\tself.value = nil\n\t\t\tend\n\t\telsif (self.type & TLV_META_TYPE_UINT == TLV_META_TYPE_UINT)\n\t\t\tself.value = raw.unpack(\"NNN\")[2]\n\t\telsif (self.type & TLV_META_TYPE_BOOL == TLV_META_TYPE_BOOL)\n\t\t\tself.value = raw.unpack(\"NNc\")[2]\n\n\t\t\tif (self.value == 1)\n\t\t\t\tself.value = true\n\t\t\telse\n\t\t\t\tself.value = false\n\t\t\tend\n\t\telse\n\t\t\tself.value = raw[8..length-1]\n\t\tend\n\n\t\treturn length;\n\tend", "def member_types; MEMBER_TYPES.select { |type| send \"number_of_#{type}?\" }; end", "def get_fields(type)\n @instrumented_field_map[type.name]\n end", "def type\n @activities = Activity.tagged_with_on(:types,params[:type_name]).page params[:page]\n respond_with @activities\n end", "def get_records_of_type requested_record_type\n ui2 = @records_unpacked\n records = []\n\n ui2_size = ui2.size\n offset = 0\n ptr = ui2\n record_byte_offset = 0\n record_type_array = Array(requested_record_type)\n\n while(offset < ui2_size) do\n curr_record_type = ptr[offset]\n record_size = ptr[offset+1]\n\n offset += (record_size/2)\n\n #yield records, curr_record_type, offset, ptr\n #do |records, record_type, offset, ptr|\n if record_type_array.include? curr_record_type\n #records.push(ptr[record_byte_offset...record_byte_offset+record_size].pack('S>*'))\n records.push(@records_packed[record_byte_offset...record_byte_offset+record_size])\n end\n #end\n\n record_byte_offset += record_size\n #ptr = ptr[(record_size/2)..-1]\n end\n\n records\n end", "def tag_type=(value)\n @tag_type = value\n end" ]
[ "0.6970296", "0.6970296", "0.65281516", "0.65281516", "0.637367", "0.637367", "0.6174964", "0.6174964", "0.61379886", "0.61072034", "0.55152637", "0.54214716", "0.54214716", "0.53846", "0.52289146", "0.5179602", "0.51663953", "0.508196", "0.5049436", "0.5049436", "0.5046244", "0.50200284", "0.48712593", "0.4811398", "0.478832", "0.47867805", "0.4754986", "0.47498354", "0.47482693", "0.4708246", "0.47040266", "0.47019902", "0.46793506", "0.4669522", "0.46543732", "0.46512464", "0.46458867", "0.4641346", "0.46391967", "0.4632438", "0.4628099", "0.46260086", "0.46260086", "0.4621437", "0.4621437", "0.4621437", "0.46188584", "0.4613447", "0.46130824", "0.46111405", "0.4608643", "0.46043354", "0.45777026", "0.45484927", "0.4543096", "0.45349234", "0.4532229", "0.4531303", "0.45235652", "0.45226055", "0.4516614", "0.4497569", "0.4494487", "0.44938844", "0.4492079", "0.4488609", "0.44736552", "0.4471442", "0.44710895", "0.44597572", "0.44597572", "0.4449818", "0.44436234", "0.4439915", "0.44285145", "0.4425746", "0.44253948", "0.4415948", "0.440771", "0.44056678", "0.4401132", "0.43992597", "0.43935055", "0.4388345", "0.4386984", "0.43848193", "0.4383671", "0.43811002", "0.43808585", "0.43801934", "0.43790498", "0.43759072", "0.43755546", "0.43751714", "0.43738654", "0.43717697", "0.43691736", "0.43676588", "0.4365644" ]
0.70094895
1
Enumerates TLVs of a supplied type with indexes.
def each_with_index(type = TLV_TYPE_ANY, &block) get_tlvs(type).each_with_index(&block) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def each(type = TLV_TYPE_ANY, &block)\n\t\tget_tlvs(type).each(&block)\n\tend", "def each(type = TLV_TYPE_ANY, &block)\n\t\tget_tlvs(type).each(&block)\n\tend", "def enumerate(type, opts)\n raise Error::SubclassResponsibility\n end", "def get_tlv(type, index = 0)\n\t\ttype_tlvs = get_tlvs(type)\n\n\t\tif (type_tlvs.length > index)\n\t\t\treturn type_tlvs[index]\n\t\tend\n\n\t\treturn nil\n\tend", "def get_tlv(type, index = 0)\n\t\ttype_tlvs = get_tlvs(type)\n\n\t\tif (type_tlvs.length > index)\n\t\t\treturn type_tlvs[index]\n\t\tend\n\n\t\treturn nil\n\tend", "def get_tlv_values(type)\n\t\tget_tlvs(type).collect { |a| a.value }\n\tend", "def get_tlv_values(type)\n\t\tget_tlvs(type).collect { |a| a.value }\n\tend", "def each_type\n types.values.each do |type|\n yield(type)\n end\n end", "def index(type, options={}, &blk)\n type = to_key(type)\n\n define_method(\"#{type}_index\") do\n indices[type] ||= Index.new(options)\n end\n\n if options[:plural]\n alias_method options[:plural], :\"#{type}_index\"\n end\n\n type_initializers[type] = blk\n\n define_method type do |name, &block_for_index|\n index_get(type, name, &block_for_index)\n end\n end", "def each(&block)\n return to_enum unless block_given?\n @index.each(&block)\n self\n end", "def each(&block)\n return to_enum unless block_given?\n index.each(&block)\n self\n end", "def each_type(&block)\n if block_given?\n @types.each_value(&block)\n self\n else\n @types.values\n end\n end", "def get_tlvs(type)\n\t\tif (type == TLV_TYPE_ANY)\n\t\t\treturn self.tlvs\n\t\telse\n\t\t\ttype_tlvs = []\n\n\t\t\tself.tlvs.each() { |tlv|\n\t\t\t\tif (tlv.type?(type))\n\t\t\t\t\ttype_tlvs << tlv\n\t\t\t\tend\n\t\t\t}\n\n\t\t\treturn type_tlvs\n\t\tend\n\tend", "def get_tlvs(type)\n\t\tif (type == TLV_TYPE_ANY)\n\t\t\treturn self.tlvs\n\t\telse\n\t\t\ttype_tlvs = []\n\n\t\t\tself.tlvs.each() { |tlv|\n\t\t\t\tif (tlv.type?(type))\n\t\t\t\t\ttype_tlvs << tlv\n\t\t\t\tend\n\t\t\t}\n\n\t\t\treturn type_tlvs\n\t\tend\n\tend", "def my_each_with_index\n return to_enum unless block_given?\n\n i = 0\n while i < length\n yield(self[i], i)\n i += 1\n end\n end", "def handle_o\n @number = @tokens[@index].get_tag(Ordinal).type\n @count = @number\n @index += 1\n end", "def index\n @types = Type.all\n end", "def index_of(kind)\n case kind\n when 'static'\n inc_static\n (@static_count - 1).to_s\n when 'field'\n inc_field\n (@field_count - 1).to_s\n when 'argument'\n inc_arg\n (@arg_count - 1).to_s\n when 'var'\n inc_var\n (@var_count - 1).to_s\n end\n end", "def index\n @types = ItemType.all\n end", "def each\n @type_variants.values.each { |tv| tv.each { |t| yield t } }\n end", "def my_each_with_index\n return to_enum unless block_given?\n\n index = 0\n my_each do |value|\n yield(value, index)\n index += 1\n end\n end", "def type \n\t\n\t$cst.add_branch(\"type\")\n\t\n\tmatch_token(\"T_TYPE\", $tokens[$index])\n\t\n\t$cst.ascend\nend", "def my_each_with_index\n if block_given?\n for i in 0.upto(self.length-1)\n yield self[i], i\n end\n else\n self.to_enum\n end\n end", "def index\n @typeconges = Typeconge.all\n end", "def each_with_index(&block)\n return to_enum :each_with_index unless block\n\n i = 0\n self.each{|*val|\n block.call(val.__svalue, i)\n i += 1\n }\n self\n end", "def index_get(type, name, &blk)\n index = send(\"#{type}_index\")\n\n # we *could* let the index handle get-or-set,\n # but we need to yield the object before the\n # index gets it.\n if index.has_key? name\n yield(index[name]) if block_given?\n index[name]\n else\n initializer = self.class.type_initializers[type]\n inst = initializer.call(name, self) if initializer\n\n #HACK: this goes somewhere else\n inst.dsl_eval { template :default }\n\n yield(inst) if block_given?\n index << inst\n inst\n end\n end", "def test_0655_each_with_index\n @@log.debug \"test_0655_each_with_index starts\" if @@log.debug?\n assert_respond_to(@list, :each_with_index, \"test_0655_each_with_index_respond\")\n # Type check\n enum = @list.each_with_index\n result = enum.is_a? Enumerator\n assert(result,\"test_0655_each_with_index_class\") \n # Check each index number\n @list.each_with_index {|item, index|\n case\n when item == @aen\n assert(index == 0, \"test_0655_each_with_index_i0\")\n when item == @bsb\n assert(index == 1, \"test_0655_each_with_index_i1\")\n when item == @cab\n assert(index == 2, \"test_0655_each_with_index_i2\")\n when item == @dad\n assert(index == 3, \"test_0655_each_with_index_i3\")\n else\n flunk(\"test_0655_each_with_index_invalid\")\n end\n }\n#\n# The author's paper copy of the 1.9 Pickaxe implies that each_with_index\n# can be invoked with one or more arguments as shown below.\n#\n# This appears to be incorrect, which can be confirmed by either:\n#\n# * Attempting to run the code shown\n# * Documentation at http://ruby-doc.org/core-1.9/classes/Enumerable.html\n#\n=begin\n # Invoke with argument(s)\n myarg = \"-tag\"\n accum = \"\"\n @list.each_with_index(myarg) {|item, index|\n case\n when item == @aen\n assert(index == 0, \"test_0655_each_with_index_i0a\")\n assert(myarg == \"-tag\", \"test_0655_each_with_index_tag0\")\n when item == @bsb\n assert(index == 1, \"test_0655_each_with_index_i1a\")\n assert(myarg == \"-tag\", \"test_0655_each_with_index_tag1\")\n when item == @cab\n assert(index == 2, \"test_0655_each_with_index_i2a\")\n assert(myarg == \"-tag\", \"test_0655_each_with_index_tag2\")\n when item == @dad\n assert(index == 3, \"test_0655_each_with_index_i3a\")\n assert(myarg == \"-tag\", \"test_0655_each_with_index_tag3\")\n else\n flunk(\"test_0655_each_with_index_invalid\")\n end\n }\n=end\n @@log.debug \"test_0655_each_with_index ends\" if @@log.debug?\n end", "def index\n @type_searches = TypeSearch.all\n end", "def get_tlv_value(type, index = 0)\n\t\ttlv = get_tlv(type, index)\n\n\t\treturn (tlv != nil) ? tlv.value : nil\n\tend", "def get_tlv_value(type, index = 0)\n\t\ttlv = get_tlv(type, index)\n\n\t\treturn (tlv != nil) ? tlv.value : nil\n\tend", "def add_tlv(type, value = nil, replace = false, compress=false)\n\n\t\t# If we should replace any TLVs with the same type...remove them first\n\t\tif (replace)\n\t\t\teach(type) { |tlv|\n\t\t\t\tif (tlv.type == type)\n\t\t\t\t\tself.tlvs.delete(tlv)\n\t\t\t\tend\n\t\t\t}\n\t\tend\n\n\t\tif (type & TLV_META_TYPE_GROUP == TLV_META_TYPE_GROUP)\n\t\t\ttlv = GroupTlv.new(type)\n\t\telse\n\t\t\ttlv = Tlv.new(type, value, compress)\n\t\tend\n\n\t\tself.tlvs << tlv\n\n\t\treturn tlv\n\tend", "def index\n @block_types = BlockTyp.all\n end", "def index_for(type, value)\n order = Kubes.config.kubectl.order.send(type) # kinds or roles\n index = order.index(value.to_s) || 999\n i = index.to_s.rjust(3, \"0\") # pad with 0\n \"#{i}-#{value}\" # append name so that terms with same index get order alphabetically\n end", "def my_each_with_index\n return to_enum unless block_given?\n\n i = 0\n while i < size\n yield(self[i], i)\n i += 1\n end\n self\n end", "def each\n if @abstract_type\n yield(@type)\n else\n @types.each { |t| yield(t) }\n end\n end", "def type_name_enum\r\n [ [ '数字字段1', 'int1' ] ,[ '数字字段2', 'int2' ] ,[ '数字字段3', 'int3' ] ,[ '数字字段4', 'int4' ],[ '数字字段5', 'int5' ],\r\n [ '文本字段1', 'text1' ],[ '文本字段2', 'text2' ],[ '文本字段3', 'text3' ],[ '文本字段4', 'text4' ],[ '文本字段5', 'text5' ],\r\n [ '文本字段6', 'text6' ],[ '文本字段7', 'text7' ],[ '文本字段8', 'text8' ],[ '文本字段9', 'text9' ],[ '文本字段10', 'text10' ]]\r\n end", "def _addIndexes ( type, *list )\n type = type.to_s\n type.upcase!.gsub! /_/, ' '\n @attr_index_hints ||= [ ]\n # set the attr_index_hints for the last object in for_vals\n last_ind = @attr_from.val.length - 1\n @attr_index_hints[last_ind] = { :type => type, :list => SQLObject.get( list ) }\n @string = nil\n return self\n end", "def index\n @tag_types = TagType.all\n end", "def index\n @block_types = BlockType.all\n end", "def my_each_with_index(&block)\n return to_enum(:my_each_with_index) unless block_given?\n n = 0\n while n < length\n block.call(self[n], n) if is_a?(Array)\n block.call(keys[n], self[keys[n]]) if is_a?(Hash)\n block.call(self[n]) if is_a?(Range)\n n += 1\n end\n self\n end", "def enumerate\n ray = []\n new_element = lambda do |element|\n yield ray.last if block_given? unless ray.empty?\n ray << element\n end\n \n self.scan(/./um) do |char|\n if Delimiter::Characters.include? char\n new_element[Delimiter.new(char)]\n \n elsif Whitespace::Characters.include? char\n if ray.last.is_a? Whitespace\n ray.last << char\n else\n new_element[Whitespace.new(char)]\n end\n \n else\n if ray.last.is_a? Word\n ray.last << char\n else\n new_element[Word.new(char)]\n end\n \n end\n end\n \n if block_given?\n yield ray.last\n self\n else\n ray\n end\n end", "def get_records_of_type requested_record_type\n ui2 = @records_unpacked\n records = []\n\n ui2_size = ui2.size\n offset = 0\n ptr = ui2\n record_byte_offset = 0\n record_type_array = Array(requested_record_type)\n\n while(offset < ui2_size) do\n curr_record_type = ptr[offset]\n record_size = ptr[offset+1]\n\n offset += (record_size/2)\n\n #yield records, curr_record_type, offset, ptr\n #do |records, record_type, offset, ptr|\n if record_type_array.include? curr_record_type\n #records.push(ptr[record_byte_offset...record_byte_offset+record_size].pack('S>*'))\n records.push(@records_packed[record_byte_offset...record_byte_offset+record_size])\n end\n #end\n\n record_byte_offset += record_size\n #ptr = ptr[(record_size/2)..-1]\n end\n\n records\n end", "def decode_tlv(data)\n raise OutOfData if (data.length == 2 && data[1].ord != 0) || data.length < 2\n tag = data[0].ord\n length = data[1].ord\n if length < 0x80\n value = data[2, length]\n remainder = data[length+2..-1]\n else\n # ASN.1 says this octet can't be 0xff\n raise InvalidLength, length.to_s if length == 0xff\n num_octets = length & 0x7f\n length = build_integer(data, 2, num_octets)\n value = data[num_octets+2, length]\n remainder = data[num_octets+2+length..-1]\n end\n return tag, value, remainder\n end", "def each\n __types__.each {|t| yield t }\n end", "def enumeration_type_search_statement(enumeration_type) # rubocop:disable Metrics/AbcSize\n all_type_ids = Enumeration.send(enumeration_type).map { |s| s.id.to_s }\n\n # Get the ids in the params that are in the enumeration type\n ids_for_search = all_type_ids & params[:search][:enumerations]\n\n return if ids_for_search.empty?\n\n table_name = Prospect.reflect_on_association('enumerations').table_name\n table_class = table_name.classify.constantize\n arel = table_class.arel_table\n\n arel[:id].in(ids_for_search)\n end", "def index\n @type_identifications = TypeIdentification.all\n end", "def each_indexvalue &_block\n return enum_for(:each_indexvalue) unless block_given?\n if multiple?\n @value.each {|v| yield single_indexvalue(v) }\n else\n yield single_indexvalue(@value)\n end\n end", "def set_incremental_index_on_field_types\n field_types.each_with_index do |field_type, index|\n field_type.index = index\n end\n end", "def index\n @itemtypes = Itemtype.all\n end", "def index\n @spec_types = SpecType.all\n end", "def index\n @api_v1_user_types = Api::V1::UserType.all\n end", "def add_tlv(t,l,v=nil)\n tlv = [(t << 9) + l, v]\n self.payload += tlv.flatten.pack(\"na*\")\n end", "def enumeration_types\n @enumeration_types ||= Search::ENUMERATION_TYPES\n end", "def type index\n @order[index][1]\n end", "def index\n @flat_types = FlatType.all\n end", "def each_type\n @mappings.each do |mapping|\n yield mapping.type\n end\n end", "def index\n @codetypes = Codetype.all\n end", "def add_tlv(type, value = nil, replace = false)\n\t\ttlv = nil\n\n\t\t# If we should replace any TLVs with the same type...remove them first\n\t\tif (replace)\n\t\t\teach(type) { |tlv|\n\t\t\t\tif (tlv.type == type)\n\t\t\t\t\tself.tlvs.delete(tlv)\n\t\t\t\tend\n\t\t\t}\n\t\tend\n\n\t\tif (type & TLV_META_TYPE_GROUP == TLV_META_TYPE_GROUP)\n\t\t\ttlv = GroupTlv.new(type)\n\t\telse\n\t\t\ttlv = Tlv.new(type, value)\n\t\tend\n\n\t\tself.tlvs << tlv\n\n\t\treturn tlv\n\tend", "def each\n @timevec.each_with_index { |time,i | v = values_at(i, *enum_attrs); yield v }\n end", "def get_type_index(item)\n (TYPE_INDICES[item && item.attrs['fields']['issuetype']['name']] || 0)\n end", "def my_each_with_index\n return to_enum unless block_given?\n i = 0\n array = []\n while i < size\n yield to_a[i], i\n array << to_a[i]\n i += 1\n end\n array\n end", "def index\n @bet_types = Bet::Type.all\n end", "def find_type_elements(type, nested = T.unsafe(nil), elements = T.unsafe(nil)); end", "def index\n @typeofstatuses = Typeofstatus.all.page params[:page]\n end", "def index\n @identifier_types = IdentifierType.all\n end", "def index_params\n params.permit(:type)\n end", "def type\n @activities = Activity.tagged_with_on(:types,params[:type_name]).page params[:page]\n respond_with @activities\n end", "def index\n @option_types = OptionType.page params[:page]\n end", "def each_index(&block)\n enum = Enumerator.new do |yielder|\n begin\n @each_index = {}\n\n count = 0\n self.each do |ele|\n # Remove previous element to not take up memory.\n count_before = count - 1\n @each_index.delete(count_before) if @each_index.key?(count_before)\n\n # Add current element to cache.\n @each_index[count] = ele\n yield(count)\n\n # Increase count for next run.\n count += 1\n end\n ensure\n @each_index = nil\n end\n end\n\n if block\n enum.each(&block)\n return nil\n else\n return enum\n end\n end", "def index\n @os_types = OsType.all\n end", "def [](type_id, flags = {})\n __types__[type_id, flags]\n end", "def each_pair(&block)\n block or return enum_for __method__\n each {|index| block.call([index.name, index]) }\n end", "def stat_hash(*type)\n\n if type === []\n type = @type \n end \n\n return type.map {|t| @raw[t]}\n\n end", "def index\n @inventory_types = InventoryType.all.sort_by(&:name)\n end", "def instrument_to_index(instrument_type)\n case instrument_type\n when \"guitars\"\n 0\n when \"microphones\"\n 1\n when \"amps\"\n 2\n when \"drumkit\"\n 3\n when \"keyboard\"\n 4\n else\n puts \"next time, please choose one in this list: (guitars,microphones,amps,drumkit,keyboard)\"\n puts\n exit\n end\nend", "def set_index_type(type)\n @index_type = type\n end", "def emit_list(name, type) #:yields:\n emit_token(TAG_List[name, type])\n begin\n yield\n ensure\n emit_token(TAG_End[nil, nil])\n end\n end", "def index\n if params[:type]\n case params[:type]\n when 'plan' then @debts = Debt.where(:debttype => 0).page(params[:page]).per(10)\n when 'inst' then @debts = Debt.where(:debttype => 1).page(params[:page]).per(10)\n when 'debt' then @debts = Debt.where(:debttype => 2).page(params[:page]).per(10)\n end\n else\n @debts = Debt.all.page(params[:page]).per(10)\n end\n end", "def each(node, &block)\n return to_enum(__method__, node) unless block_given?\n visit(node, &block)\n end", "def index\n @item_attribute_types = ItemAttributeType.all\n end", "def index\n @typeios = bulletin_board.typeios\n end", "def each_index\n return to_enum(__callee__) unless block_given?\n \n each_with_index{ |_, idx| yield(idx) }\n end", "def index\n @type_of_values = TypeOfValue.all\n end", "def enumerator ; end", "def enumerator ; end", "def type_params\n params.require(:type).permit(:name, :index)\n end", "def index\n @count_types = CountType.all\n end", "def get_dictionary_index types, line, indexes=nil\n indexes ||= []\n if types.is_a? Symbol\n types = [types]\n end\n kanji_id = @kanji_lookup[get_element(:kanji, line)]\n out=[]\n types.each do |type|\n dictionary_index_value = get_element(type, line)\n unless dictionary_index_value.nil?\n dictionary_id = @dictionary_lookup[type]\n values = [kanji_id, dictionary_id, dictionary_index_value]\n #puts \"values:#{values}\"\n indexes << values\n else \n #puts \"#{type} not found on this line\"\n end\n end\n return indexes\n end", "def index\n @loot_types = LootType.all\n end", "def index\n @let_types = LetType.all\n end", "def extra_type(index)\r\n return nil if index < 1 || index > 5\r\n send \"extra_#{index}_type\"\r\n end", "def each\n return to_enum(:each) unless block_given?\n @size.times { |position| yield self[position] }\n end", "def index\n @modtypes = Modtype.all\n end", "def eachio_index(&block) # :yield: index\n 0.upto(length-1, &block)\n self\n end", "def index\n @method_types = MethodType.all\n end", "def add_field(type, value)# {{{\n t = TLV.new(2,2)\n t.type = type\n t.value = value\n t.length = 4 + value.length\n self.payload += t.encode \n end", "def fields_of_type(type, &block)\n selected = @fields.select {|f| type == f.type }\n if block\n selected.each {|f| f.instance_eval &block }\n end\n selected\n end", "def index\n @type_tests = TypeTest.all\n end", "def index\n @typebourses = Typebourse.all\n end" ]
[ "0.6651781", "0.6651781", "0.6077107", "0.59453034", "0.59453034", "0.59292334", "0.59292334", "0.5442824", "0.5428451", "0.5387065", "0.53594124", "0.5347856", "0.5347715", "0.5347715", "0.5302907", "0.5184244", "0.51747185", "0.51728725", "0.5158427", "0.51135314", "0.50870466", "0.5076759", "0.50604314", "0.5035476", "0.50334245", "0.50290823", "0.4987524", "0.49672648", "0.49473423", "0.49473423", "0.49345225", "0.4928223", "0.49229217", "0.4922177", "0.4881845", "0.48814496", "0.48471597", "0.48449993", "0.48310593", "0.4826026", "0.48213473", "0.4819216", "0.4810961", "0.48067844", "0.47866732", "0.47748324", "0.47724113", "0.47655207", "0.47611353", "0.47609496", "0.4757395", "0.47275805", "0.47207823", "0.47204325", "0.47159427", "0.47147074", "0.4703404", "0.47022662", "0.46997336", "0.46915537", "0.4688784", "0.46882328", "0.46679497", "0.4632701", "0.46249416", "0.4611602", "0.46092224", "0.46069252", "0.4588882", "0.4578303", "0.45535147", "0.45470744", "0.45465997", "0.4545741", "0.45439062", "0.45433363", "0.45419085", "0.45308033", "0.45306563", "0.452895", "0.4528619", "0.45251918", "0.45203358", "0.4513623", "0.4513623", "0.45080104", "0.45078108", "0.4502643", "0.45017043", "0.44944215", "0.44924977", "0.44894356", "0.448082", "0.4479698", "0.44784376", "0.44730136", "0.44725972", "0.44662535", "0.44630516" ]
0.7803846
1
Returns an array of TLVs for the given type.
def get_tlvs(type) if (type == TLV_TYPE_ANY) return self.tlvs else type_tlvs = [] self.tlvs.each() { |tlv| if (tlv.type?(type)) type_tlvs << tlv end } return type_tlvs end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_tlv_values(type)\n\t\tget_tlvs(type).collect { |a| a.value }\n\tend", "def get_tlv_values(type)\n\t\tget_tlvs(type).collect { |a| a.value }\n\tend", "def get_tlv(type, index = 0)\n\t\ttype_tlvs = get_tlvs(type)\n\n\t\tif (type_tlvs.length > index)\n\t\t\treturn type_tlvs[index]\n\t\tend\n\n\t\treturn nil\n\tend", "def get_tlv(type, index = 0)\n\t\ttype_tlvs = get_tlvs(type)\n\n\t\tif (type_tlvs.length > index)\n\t\t\treturn type_tlvs[index]\n\t\tend\n\n\t\treturn nil\n\tend", "def each(type = TLV_TYPE_ANY, &block)\n\t\tget_tlvs(type).each(&block)\n\tend", "def each(type = TLV_TYPE_ANY, &block)\n\t\tget_tlvs(type).each(&block)\n\tend", "def get_data_elements_by_type(patient, type)\n matches = []\n patient.dataElements.each do |data_element|\n matches << data_element if data_element[:_type] == type\n end\n matches\n end", "def Array(type)\n Strict(::Array).of(type)\n end", "def get_types(type)\n result = []\n types = TYPE_CONVERSION_TREE[type]\n if types\n result += types\n types.each do |t|\n result |= get_types(t)\n end\n end\n result\n end", "def components_with_type(type)\n array = []\n @components.each_value do |c|\n array << c.proxy.name if c.proxy.respond_to?(:has_type?) &&\n c.proxy.has_type?(type)\n end\n array\n end", "def items_for_type(type)\n all_ids = []\n valid_ids = []\n AllItems.get.each do |item_code, values|\n _item_name, item_type, item_valid = values\n next unless item_type == type\n all_ids << item_code\n valid_ids << item_code if item_valid\n end\n\n [all_ids, valid_ids]\n end", "def create_array_tc(length, element_type)\n return CORBA::TypeCode::Array.new(element_type, length)\n end", "def all_by_name_and_type(name, type)\n where(name: name, array_type: type).order_by(&:array_index).to_a\n end", "def add_tlv(type, value = nil, replace = false)\n\t\ttlv = nil\n\n\t\t# If we should replace any TLVs with the same type...remove them first\n\t\tif (replace)\n\t\t\teach(type) { |tlv|\n\t\t\t\tif (tlv.type == type)\n\t\t\t\t\tself.tlvs.delete(tlv)\n\t\t\t\tend\n\t\t\t}\n\t\tend\n\n\t\tif (type & TLV_META_TYPE_GROUP == TLV_META_TYPE_GROUP)\n\t\t\ttlv = GroupTlv.new(type)\n\t\telse\n\t\t\ttlv = Tlv.new(type, value)\n\t\tend\n\n\t\tself.tlvs << tlv\n\n\t\treturn tlv\n\tend", "def each_with_index(type = TLV_TYPE_ANY, &block)\n\t\tget_tlvs(type).each_with_index(&block)\n\tend", "def each_with_index(type = TLV_TYPE_ANY, &block)\n\t\tget_tlvs(type).each_with_index(&block)\n\tend", "def elements_by_type(type)\n\t\treturn xpath('//' + type)\n\tend", "def patterns_for_type(type_)\n @mutex.synchronize do\n typedata_ = @types[type_]\n typedata_ ? typedata_.dup : []\n end\n end", "def types()\n\t\t@pokemon_types = []\n\t\t@pokemon_api[\"types\"].each do |i|\n\t\t\t@pokemon_types.push(i[\"type\"][\"name\"].capitalize)\n\t\tend\n\t\treturn @pokemon_types\n\tend", "def tags\n match = /(.*?)[\\s\\u00A0]+\\[(?<tags>.*)\\]/\n .match(@type_node.inner_text)\n return [] unless match\n match[:tags].split(' ')\n end", "def create_types\n\t\t[]\n\tend", "def create_types\n\t\t[]\n\tend", "def add_tlv(type, value = nil, replace = false, compress=false)\n\n\t\t# If we should replace any TLVs with the same type...remove them first\n\t\tif (replace)\n\t\t\teach(type) { |tlv|\n\t\t\t\tif (tlv.type == type)\n\t\t\t\t\tself.tlvs.delete(tlv)\n\t\t\t\tend\n\t\t\t}\n\t\tend\n\n\t\tif (type & TLV_META_TYPE_GROUP == TLV_META_TYPE_GROUP)\n\t\t\ttlv = GroupTlv.new(type)\n\t\telse\n\t\t\ttlv = Tlv.new(type, value, compress)\n\t\tend\n\n\t\tself.tlvs << tlv\n\n\t\treturn tlv\n\tend", "def types\n @types ||= []\n end", "def types\n [\n { value: 'bus', name: 'Bus' },\n { value: 'coach', name: 'Coach' },\n { value: 'hgv', name: 'Heavy goods vehicle' },\n { value: 'van', name: 'Van' },\n { value: 'minibus', name: 'Minibus' },\n { value: 'private_car', name: 'Car' },\n { value: 'motorcycle', name: 'Motorcycle' }\n ]\n end", "def volume_type_report\n @volume_type_csv_array = []\n get_resource_list('volume', 'types', 'volume_types')\n @resource_id_list.each do |voltypeid|\n volume_type = rest_get(\"#{@resource_url}/types/#{voltypeid}\", @token_id)\n volume_type_array = JSON.parse(volume_type)['volume_type']\n volume_type_name = volume_type_array['name']\n volume_type_drivers = volume_type_array['extra_specs']\n volume_type_unit_type = volume_type_drivers['drivers:logical_unit_type']\n volume_type_prov_type = volume_type_drivers['drivers:provision_type']\n @volume_type_csv_headers = %w(Storage_Template_Name Storage_Template_Type Storage_Template_Prov_Type)\n @volume_type_csv_array << [volume_type_name, volume_type_unit_type, volume_type_prov_type+'-provisioning']\n end\n end", "def tlv_select\n info 'os10_lldp_interface::tlv select'\n begin\n lldp_interface_data = @tlv_ret[:stdout].split(\"\\n\")\n temp_data = {}\n\n lldp_interface_data.each do |data|\n if data.include? 'lldp tlv-select'\n tlv_data = data.split(' ')\n if tlv_data.length == 4\n temp_data[tlv_data[3]] = [' ']\n elsif temp_data[tlv_data[3]].nil? && tlv_data.length >= 4\n temp_data[tlv_data[3]] = [tlv_data[4]]\n elsif tlv_data[4]\n temp_data[tlv_data[3]] = temp_data[tlv_data[3]] << tlv_data[4]\n temp_data[tlv_data[3]] = temp_data[tlv_data[3]].sort\n end\n end\n end\n return temp_data\n rescue Exception => e\n err 'Exception in tlv select'\n err e.message\n err e.backtrace[0]\n raise\n end\n end", "def get_records_of_type requested_record_type\n ui2 = @records_unpacked\n records = []\n\n ui2_size = ui2.size\n offset = 0\n ptr = ui2\n record_byte_offset = 0\n record_type_array = Array(requested_record_type)\n\n while(offset < ui2_size) do\n curr_record_type = ptr[offset]\n record_size = ptr[offset+1]\n\n offset += (record_size/2)\n\n #yield records, curr_record_type, offset, ptr\n #do |records, record_type, offset, ptr|\n if record_type_array.include? curr_record_type\n #records.push(ptr[record_byte_offset...record_byte_offset+record_size].pack('S>*'))\n records.push(@records_packed[record_byte_offset...record_byte_offset+record_size])\n end\n #end\n\n record_byte_offset += record_size\n #ptr = ptr[(record_size/2)..-1]\n end\n\n records\n end", "def elements\n return @types.dup\n end", "def level_items_list(type, levels)\n levels = levels.join(',') if levels.is_a?(Array)\n response = api_response(type, levels)\n\n # The vocabulary API call without specifying levels returns a Hash instead\n # of an Array, so this is a hacky way of dealing with it.\n if response[\"requested_information\"].is_a?(Hash)\n return response[\"requested_information\"][\"general\"]\n else\n return response[\"requested_information\"]\n end\n end", "def find_type_elements(type, nested = T.unsafe(nil), elements = T.unsafe(nil)); end", "def proficiencies_by_type(type)\n\t\t\t\tself.proficiencies.find_by_taggable_type(type).to_a\n\t\tend", "def extract_types(doc)\n types = []\n @raw_types.each do |raw_type|\n doc.each_element_with_attribute('name', raw_type, 0,\n '//schema/complexType') do |type_node|\n type = {:name => raw_type, :fields => []}\n ext_node = REXML::XPath.first(type_node, 'complexContent/extension')\n if ext_node\n base_type = ext_node.attribute('base').to_s.gsub(/^.+:/, '')\n type[:base] = base_type\n @raw_types << base_type unless @raw_types.include?(base_type)\n seq_node = REXML::XPath.first(ext_node, 'sequence')\n fields = get_element_fields(seq_node)\n process_method_field_types(fields)\n type[:fields] += fields\n end\n seq_node = REXML::XPath.first(type_node, 'sequence')\n if seq_node\n fields = get_element_fields(seq_node)\n process_method_field_types(fields)\n type[:fields] += fields\n end\n types << type\n end\n end\n return types\n end", "def options(rental)\n options_raw = @options.select{ |option| option[\"rental_id\"] == rental[\"id\"] }\n options_array = []\n options_raw.each do |hash|\n options_array << hash[\"type\"]\n end\n return options_array\nend", "def list(type)\n get(resource_path_for_entity_type(type) + \"?rows=all\")\n end", "def array_of(type)\n new_class = Class.new(TypedArray)\n new_class.set_element_type(type)\n new_class\n end", "def get_by_type(type)\r\n facts2typerule = {:methodcall => [:cant_access, :can_access],\r\n :inheritance => [:cant_extend, :can_extend],\r\n :objcreation => [:cant_create, :can_create]}\r\n\r\n find_all { |x| facts2typerule[type].index(x.type_interaction) != nil }\r\n end", "def puppet_type_to_ruby(type)\n array = false\n\n type = $1 if type =~ /Optional\\[(.+)/\n\n if type =~ /Array\\[(.+)/\n type = $1\n array = true\n end\n\n return [Numeric, array] if type =~ /Integer/\n return [Numeric, array] if type =~ /Float/\n return [Hash, array] if type =~ /Hash/\n return [:boolean, array] if type =~ /Boolean/\n\n [String, array]\n end", "def types\n list = Array.new\n\n if @db != nil\n is_ok = false\n\n begin\n stm = @db.prepare( 'SELECT qType FROM qryResults GROUP BY qType ORDER BY qType')\n rs = stm.execute\n\n rs.each do |row|\n list.push row['qType']\n end\n\n stm.close\n is_ok = true\n rescue ::SQLite3::Exception => e\n Maadi::post_message(:Warn, \"Repository (#{@type}:#{@instance_name}) encountered an SELECT Types error (#{e.message}).\")\n end\n end\n\n return list\n end", "def list_templates(type)\n res = http_get(:uri=>\"/editor/#{type}/templates\", :fields=>x_cookie)\n end", "def read_array(type, length, bufptr, buffer = nil)\n if length <= 0\n return []\n end\n\n size = sizeof_type(type)\n # Grab the bytes that the array consists of\n buffer = memread(bufptr, size * length, buffer)\n\n offset = 0\n\n 1.upto(length).map do |n|\n data = read_data(type, offset, buffer)\n\n offset = offset + size\n\n data\n end\n end", "def create_types\n\t[]\nend", "def create_types\n\t[]\nend", "def describe_types\n [@options[:type]].flatten.join('/')\n end", "def has_tlv?(type)\n\t\treturn get_tlv(type) != nil\n\tend", "def has_tlv?(type)\n\t\treturn get_tlv(type) != nil\n\tend", "def return_trains_by_type(type)\n (@trains_list.map { |a| a if a.type == type }).compact\n end", "def get_list(type)\n allowed_tables = A_LISTS\n\n if allowed_tables.include? type\n sql = 'SELECT '\n\n # Field names\n sql += get_fields(type)\n\n # Table names\n sql += get_tables(type)\n\n # Conditions\n sql += get_conditions(type)\n\n if sql.include? 'ERROR'\n 'ERROR'\n else\n PType.find_by_sql(sql)\n end\n else\n # TODO: Log error\n end\n end", "def get_tlv_value(type, index = 0)\n\t\ttlv = get_tlv(type, index)\n\n\t\treturn (tlv != nil) ? tlv.value : nil\n\tend", "def get_tlv_value(type, index = 0)\n\t\ttlv = get_tlv(type, index)\n\n\t\treturn (tlv != nil) ? tlv.value : nil\n\tend", "def get_array_values(init,type)\n if type == \"fecha\"\n final = Time.new.year\n unidad = \"\"\n elsif type == \"rango\"\n final = 5000\n unidad = \"m2\"\n elsif type == \"aforo\"\n final = 500\n unidad = \"\"\n end\n array_ = []\n\n #((final.to_i).downto(Integer(init))).each do |n|\n (Integer(init)..(final.to_i)).each do |n|\n array_ << \"#{n}#{unidad}\"\n end\n return array_\n end", "def tags_for type\n tag_ids = ActsAsTaggableOn::Tagging\n .where(taggable_type: type.camelize, context: :tags)\n .collect(&:tag_id)\n .uniq\n ActsAsTaggableOn::Tag\n .where(id: tag_ids)\n end", "def unit_types\n [\"Subject\", \"Fragment\", \"Chapter\", \"Lesson\", \"Lab\"]\n end", "def type_name_enum\r\n [ [ '数字字段1', 'int1' ] ,[ '数字字段2', 'int2' ] ,[ '数字字段3', 'int3' ] ,[ '数字字段4', 'int4' ],[ '数字字段5', 'int5' ],\r\n [ '文本字段1', 'text1' ],[ '文本字段2', 'text2' ],[ '文本字段3', 'text3' ],[ '文本字段4', 'text4' ],[ '文本字段5', 'text5' ],\r\n [ '文本字段6', 'text6' ],[ '文本字段7', 'text7' ],[ '文本字段8', 'text8' ],[ '文本字段9', 'text9' ],[ '文本字段10', 'text10' ]]\r\n end", "def get_record_types\n get_records_with_filter {|records, record_type, offset, ptr| records.push(ptr[0])}\n end", "def type_names\n\t\ttypes_names = DATABASE.execute(\"SELECT name FROM types WHERE id='#{self.type_id[0]}' OR id='#{self.type_id[1]}';\") \t\n\t\treturn types_names\n\tend", "def find_command_with_utype (utype)\n array = Array.new()\n @commands.each do |command|\n if (command.utype == utype)\n array.push(command)\n end\n end\n return array\n end", "def split_array_type(type)\n if type =~ /^(\\w+)\\[(\\w+)\\]$/\n element_type = $1\n length = $2\n unless length =~ /^\\d+$/\n length = railgun.const(length)\n end\n\n return element_type.to_sym, length.to_i\n else\n raise \"Can not split non-array type #{type}\"\n end\n end", "def return_sub_types\n main_type = type_status\n if main_type\n return self.beer_subtypes.map{|type| {id: type.id, name: type.name}}\n else\n return types_for_subtype\n end\n end", "def getPokemonTypeFromTypesObject(types)\n return types.map {|x| x['type']['name']}.compact\nend", "def get_type_trophies(type)\n trophies = []\n @knights.each do |knight|\n knight.trophies.each do |trophy|\n packet = [knight.id, trophy] \n trophies << packet if trophy.type == type\n end\n end\n return trophies\n end", "def mechanisms(type)\n out = FFI::MemoryPointer.new :pointer\n result = Gsasl.send(\"gsasl_#{type}_mechlist\", @context, out)\n Gsasl.raise_error!(result)\n data = out.get_pointer(0)\n list = data.read_string.split(/\\s/)\n list\n ensure\n Gsasl.gsasl_free(data)\n end", "def all_of_type\n Resource::AllOfType.new(type)\n end", "def pet_types\r\n BnetApi::make_request('/wow/data/pet/types')\r\n end", "def children_by_type(type)\n children = YARD::Registry.all(type)\n children.select { |child| child.parent == self }\n end", "def microform_types\n return [] unless record['008']\n types = ['WM']\n f8_23 = record['008'].value[23]\n return types if %w[BK MU SE MX].include?(bib_format) && %w[a b c].include?(f8_23)\n\n f8_29 = record['008'].value[29]\n return types if %w[MP VM].include?(bib_format) && %w[a b c].include?(f8_29)\n\n return types if record['245'] && (record['245']['h'] =~ /micro/i)\n\n # Nope. Not microform\n return []\n end", "def lookup(type)\n @resource_types[type] || []\n end", "def find_command_with_utype (utype)\n array = DOECommands.new()\n self.each do |command|\n if (command.utype == utype)\n array.push(command)\n end\n end\n return array\n end", "def extensions\n TYPE_EXTS[type] || []\n end", "def get_all_org_units_by_type_id(outype_id)\n path = \"/d2l/api/lp/#{$lp_ver}/orgstructure/6606/children/?ouTypeId=#{outype_id}\"\n _get(path)\nend", "def address_components_of_type(type)\n address_components.select{ |c| c['types'].include?(type.to_s) }\n end", "def address_components_of_type(type)\n address_components.select{ |k, v| k == type.to_s }\n end", "def instances(type)\n @instances[type]\n end", "def contentByType( type )\n\t\tcontent = nil\n\t\t@content.each_index { |i|\n\t\t\tif @content[i].type == type\n\t\t\t\tcontent = @content[i]\n\t\t\tend\n\t\t}\n\t\tcontent\n\tend", "def service_types_generated \n types = [ ServiceTypeValue[:fulltext], ServiceTypeValue[:holding], ServiceTypeValue[:table_of_contents], ServiceTypeValue[:relevant_link] ]\n \n return types\n end", "def types(options={})\n select_from_hash_array(TRANSACTION_METHODS, :type, {}, options)\n end", "def types(options={})\n select_from_hash_array(TRANSACTION_METHODS, :type, {}, options)\n end", "def all_items(type = nil)\n if type\n @api_items.select {|k, v| v.kind_of?(TYPE_MAP[type])}.keys\n else\n @api_items.keys\n end\n end", "def index\n @typeconges = Typeconge.all\n end", "def find_by_type(types)\n matches = []\n matches << self if to_type == types\n @value.each do |v|\n matches += v.find_by_type(types) if v.respond_to?(:find_by_type)\n end\n matches\n end", "def read_service_types()\n types = []\n @client.services.each do |type|\n types << type.label\n end\n\n types\n end", "def read_array(getter, counter, type)\n count_max = FFI::Libvirt.send(counter, interface)\n output_ptr = FFI::MemoryPointer.new(:pointer, count_max)\n count_returned = FFI::Libvirt.send(getter, interface, output_ptr, count_max)\n output_ptr.send(\"get_array_of_#{type}\", 0, count_returned)\n end", "def index\n @loot_types = LootType.all\n end", "def all\n all_by_type.values.flatten\n end", "def get_all_outypes\n path = \"/d2l/api/lp/#{$lp_ver}/outypes/\"\n _get(path)\nend", "def fields_for_type(type)\n return @field_mapping[type] || Set.new\n end", "def collect_types_of_lesson\n [ [\"Обязательное занятие\", \"Primary lesson\"], [\"Электив\", \"Extra\"] ]\n end", "def fields_of_type(type, &block)\n selected = @fields.select {|f| type == f.type }\n if block\n selected.each {|f| f.instance_eval &block }\n end\n selected\n end", "def get_all_sobjects(type)\n case type\n when 'Account'\n records = @client.materialize(type).query(\"Agents__c != ''\")\n when 'ccrmbasic__Email__c'\n records = @client.materialize(type).query(\"ccrmbasic__Contact__c != ''\")\n else\n records = @client.materialize(type).all\n end\n sobjects = records.dup.to_a\n while records.next_page?\n sobjects += records.next_page\n records = records.next_page\n end\n sobjects\n end", "def payment_data_types\n []\n end", "def get_all_methods\n methods = []\n each_type do | type |\n type.each_method do |meth|\n methods << meth\n end\n end\n methods\n end", "def stat_hash(*type)\n\n if type === []\n type = @type \n end \n\n return type.map {|t| @raw[t]}\n\n end", "def getDiscs(types)\n\tdiscs = Array.new\n\n\t@discs_doc.elements.each('acda-discs/disc') { |elem|\n\t\tdisc = parseDisc(elem, types)\n\t\tdiscs.push disc\n\t}\n\n\tdiscs\nend", "def get_context_types_list\n [\n context_type_meeting_header,\n context_type_category_header,\n context_type_relay_header,\n context_type_team_ranking,\n context_type_team_stats,\n context_type_stats,\n context_type_result_row,\n context_type_relay_row,\n context_type_ranking_row,\n context_type_stats_details\n ]\n end", "def category_types\n @category_types.each\n end", "def each_type(&block)\n if block_given?\n @types.each_value(&block)\n self\n else\n @types.values\n end\n end", "def type(type)\n select { |node| node.type.equal?(type) }\n end", "def possible_types\n @data.flat_map { |iso2, data| data[:possible] }.uniq\n end", "def get_array_type(array)\r\n\t\t\r\n\t\tif @l_identificadores != nil\r\n\t\t\tarray << @tipo1\r\n\t\t\t@l_identificadores.get_array_type(array)\r\n\t\telse\r\n\t\t\tarray << @tipo2\r\n\t\t\tarray << @tipo1\t\r\n\t\t\treturn array\r\n\t\tend\r\n\r\n\tend" ]
[ "0.74816453", "0.74816453", "0.67054456", "0.67054456", "0.6422999", "0.6422999", "0.6100501", "0.58411473", "0.5706038", "0.5645888", "0.55949676", "0.5576011", "0.55497086", "0.5510361", "0.5505722", "0.5505722", "0.54669064", "0.54653496", "0.54378575", "0.5436767", "0.5354153", "0.5354153", "0.5351562", "0.53500646", "0.5349586", "0.5334861", "0.5300004", "0.52565753", "0.5253083", "0.5239278", "0.5232005", "0.52171725", "0.51865035", "0.5166431", "0.5152739", "0.5139456", "0.5135276", "0.5128489", "0.5125972", "0.5104745", "0.51007026", "0.50902635", "0.50902635", "0.50590104", "0.5040582", "0.5040582", "0.5024504", "0.5023617", "0.5016416", "0.5016416", "0.4985746", "0.49845406", "0.49832696", "0.49735743", "0.49550375", "0.49541733", "0.49498448", "0.49438462", "0.49270216", "0.49234238", "0.49080208", "0.48958054", "0.48921633", "0.48909912", "0.4866931", "0.48520854", "0.48504204", "0.4847833", "0.48422173", "0.48354176", "0.48348472", "0.48270744", "0.48251683", "0.48213583", "0.48156688", "0.48141655", "0.48141655", "0.4813595", "0.48032564", "0.48007816", "0.47904062", "0.4783216", "0.47829866", "0.4782649", "0.47722396", "0.47710574", "0.4769384", "0.4757358", "0.4756682", "0.4748347", "0.4746196", "0.4740297", "0.47356477", "0.47276542", "0.472734", "0.47087923", "0.47080138", "0.47076526", "0.47043943" ]
0.7621979
1
TLV management Adds a TLV of a given type and value.
def add_tlv(type, value = nil, replace = false, compress=false) # If we should replace any TLVs with the same type...remove them first if (replace) each(type) { |tlv| if (tlv.type == type) self.tlvs.delete(tlv) end } end if (type & TLV_META_TYPE_GROUP == TLV_META_TYPE_GROUP) tlv = GroupTlv.new(type) else tlv = Tlv.new(type, value, compress) end self.tlvs << tlv return tlv end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_field(type, value)# {{{\n t = TLV.new(2,2)\n t.type = type\n t.value = value\n t.length = 4 + value.length\n self.payload += t.encode \n end", "def add_tlv(t,l,v=nil)\n tlv = [(t << 9) + l, v]\n self.payload += tlv.flatten.pack(\"na*\")\n end", "def add_tlv(type, value = nil, replace = false)\n\t\ttlv = nil\n\n\t\t# If we should replace any TLVs with the same type...remove them first\n\t\tif (replace)\n\t\t\teach(type) { |tlv|\n\t\t\t\tif (tlv.type == type)\n\t\t\t\t\tself.tlvs.delete(tlv)\n\t\t\t\tend\n\t\t\t}\n\t\tend\n\n\t\tif (type & TLV_META_TYPE_GROUP == TLV_META_TYPE_GROUP)\n\t\t\ttlv = GroupTlv.new(type)\n\t\telse\n\t\t\ttlv = Tlv.new(type, value)\n\t\tend\n\n\t\tself.tlvs << tlv\n\n\t\treturn tlv\n\tend", "def add_tlvs(tlvs)\n\t\tif (tlvs != nil)\n\t\t\ttlvs.each { |tlv|\n\t\t\t\tadd_tlv(tlv['type'], tlv['value'])\n\t\t\t}\n\t\tend\n\tend", "def add_tlvs(tlvs)\n\t\tif (tlvs != nil)\n\t\t\ttlvs.each { |tlv|\n\t\t\t\tadd_tlv(tlv['type'], tlv['value'])\n\t\t\t}\n\t\tend\n\tend", "def initialize(type, value = nil)\n\t\t@type = type\n\t\t\n\t\tif (value != nil)\n\t\t\tif (type & TLV_META_TYPE_STRING == TLV_META_TYPE_STRING)\n\t\t\t\tif (value.kind_of?(Fixnum))\n\t\t\t\t\t@value = value.to_s\n\t\t\t\telse\n\t\t\t\t\t@value = value.dup\n\t\t\t\tend\n\t\t\telse\n\t\t\t\t@value = value\n\t\t\tend\n\t\tend\n\tend", "def add_option(number, value)\n t = Misc::TLV.new(1,1)\n t.type = number\n t.value = value\n t.length = value.length + 2\n @options << t.encode\n end", "def get_tlv_values(type)\n\t\tget_tlvs(type).collect { |a| a.value }\n\tend", "def get_tlv_values(type)\n\t\tget_tlvs(type).collect { |a| a.value }\n\tend", "def add_value(name, type, subtype = nil)\n if type.class == RustyJson::RustStruct || subtype.class == RustyJson::RustStruct\n if type.class == RustyJson::RustStruct\n t = type\n type = type.name\n struct = t\n elsif subtype.class == RustyJson::RustStruct\n s = subtype\n subtype = subtype.name\n struct = s\n end\n @structs << struct\n RustStruct.add_type(struct.name, struct.name)\n end\n @values[name] = [type, subtype]\n true\n end", "def get_tlv(type, index = 0)\n\t\ttype_tlvs = get_tlvs(type)\n\n\t\tif (type_tlvs.length > index)\n\t\t\treturn type_tlvs[index]\n\t\tend\n\n\t\treturn nil\n\tend", "def get_tlv(type, index = 0)\n\t\ttype_tlvs = get_tlvs(type)\n\n\t\tif (type_tlvs.length > index)\n\t\t\treturn type_tlvs[index]\n\t\tend\n\n\t\treturn nil\n\tend", "def add_field(var_name, type, xml_tag, value=nil)\n @fields[var_name] = Field.new(var_name, type, xml_tag, value)\n end", "def add(tag, value)\n @fields[tag.to_sym] = value\n end", "def add(type)\n @value << type\n @value = @value.uniq\n end", "def get_tlv_value(type, index = 0)\n\t\ttlv = get_tlv(type, index)\n\n\t\treturn (tlv != nil) ? tlv.value : nil\n\tend", "def get_tlv_value(type, index = 0)\n\t\ttlv = get_tlv(type, index)\n\n\t\treturn (tlv != nil) ? tlv.value : nil\n\tend", "def <<(value)\n self[\"m:type\"] = Azure::Tables::Types.type_of(value)\n super(value)\n end", "def initialize(type, value = nil, compress=false)\n\t\t@type = type\n\t\t@compress = compress\n\t\t\n\t\tif (value != nil)\n\t\t\tif (type & TLV_META_TYPE_STRING == TLV_META_TYPE_STRING)\n\t\t\t\tif (value.kind_of?(Fixnum))\n\t\t\t\t\t@value = value.to_s\n\t\t\t\telse\n\t\t\t\t\t@value = value.dup\n\t\t\t\tend\n\t\t\telse\n\t\t\t\t@value = value\n\t\t\tend\n\t\tend\n\tend", "def from_r(raw)\n\t\tself.value = nil\n\n\t\tlength, self.type = raw.unpack(\"NN\");\n\n\t\t# check if the tlv value has been compressed...\n\t\tif( self.type & TLV_META_TYPE_COMPRESSED == TLV_META_TYPE_COMPRESSED )\n\t\t\t# set this TLV as using compression\n\t\t\t@compress = true\n\t\t\t# remove the TLV_META_TYPE_COMPRESSED flag from the tlv type to restore the \n\t\t\t# tlv type to its origional, allowing for transparent data compression.\n\t\t\tself.type = self.type ^ TLV_META_TYPE_COMPRESSED\n\t\t\t# decompress the compressed data (skipping the length and type DWORD's)\n\t\t\traw_decompressed = Rex::Text.zlib_inflate( raw[8..length-1] )\n\t\t\t# update the length to reflect the decompressed data length (+8 for the length and type DWORD's)\n\t\t\tlength = raw_decompressed.length + 8\n\t\t\t# update the raw buffer with the new length, decompressed data and updated type.\n\t\t\traw = [length, self.type].pack(\"NN\") + raw_decompressed\n\t\tend\n\t\t\n\t\tif (self.type & TLV_META_TYPE_STRING == TLV_META_TYPE_STRING)\n\t\t\tif (raw.length > 0)\n\t\t\t\tself.value = raw[8..length-2]\n\t\t\telse\n\t\t\t\tself.value = nil\n\t\t\tend\n\t\telsif (self.type & TLV_META_TYPE_UINT == TLV_META_TYPE_UINT)\n\t\t\tself.value = raw.unpack(\"NNN\")[2]\n\t\telsif (self.type & TLV_META_TYPE_BOOL == TLV_META_TYPE_BOOL)\n\t\t\tself.value = raw.unpack(\"NNc\")[2]\n\n\t\t\tif (self.value == 1)\n\t\t\t\tself.value = true\n\t\t\telse\n\t\t\t\tself.value = false\n\t\t\tend\n\t\telse\n\t\t\tself.value = raw[8..length-1]\n\t\tend\n\n\t\treturn length;\n\tend", "def add_type(type)\n end", "def initialize(type, value)\n @type = type\n @value = value\n end", "def add_option(size, value)\n struct = PacketWriter.TypeValueStruct.new 1, 1\n struct.type = size\n struct.value = value\n struct.length = value.length + 2\n self.options << struct.encode\n end", "def has_tlv?(type)\n\t\treturn get_tlv(type) != nil\n\tend", "def has_tlv?(type)\n\t\treturn get_tlv(type) != nil\n\tend", "def to_r\n\t\traw = value.to_s;\n\n\t\tif (self.type & TLV_META_TYPE_STRING == TLV_META_TYPE_STRING)\n\t\t\traw += \"\\x00\"\n\t\telsif (self.type & TLV_META_TYPE_UINT == TLV_META_TYPE_UINT)\n\t\t\traw = [value].pack(\"N\")\n\t\telsif (self.type & TLV_META_TYPE_BOOL == TLV_META_TYPE_BOOL)\n\t\t\tif (value == true)\n\t\t\t\traw = [1].pack(\"c\")\n\t\t\telse\n\t\t\t\traw = [0].pack(\"c\")\n\t\t\tend\n\t\tend\n\t\t\n\t\t# check if the tlv is to be compressed...\n\t\tif( @compress )\n\t\t\traw_uncompressed = raw\n\t\t\t# compress the raw data\n\t\t\traw_compressed = Rex::Text.zlib_deflate( raw_uncompressed )\n\t\t\t# check we have actually made the raw data smaller...\n\t\t\t# (small blobs often compress slightly larger then the origional) \n\t\t\t# if the compressed data is not smaller, we dont use the compressed data\n\t\t\tif( raw_compressed.length < raw_uncompressed.length )\n\t\t\t\t# if so, set the TLV's type to indicate compression is used\n\t\t\t\tself.type = self.type | TLV_META_TYPE_COMPRESSED\n\t\t\t\t# update the raw data with the uncompressed data length + compressed data\n\t\t\t\t# (we include the uncompressed data length as the C side will need to know this for decompression)\n\t\t\t\traw = [ raw_uncompressed.length ].pack(\"N\") + raw_compressed\n\t\t\tend\n\t\tend\n\t\t\n\t\treturn [raw.length + 8, self.type].pack(\"NN\") + raw\n\tend", "def add_binary(_tag, _val)\n raise NotImplementedError\n end", "def decode_tlv(data)\n raise OutOfData if (data.length == 2 && data[1].ord != 0) || data.length < 2\n tag = data[0].ord\n length = data[1].ord\n if length < 0x80\n value = data[2, length]\n remainder = data[length+2..-1]\n else\n # ASN.1 says this octet can't be 0xff\n raise InvalidLength, length.to_s if length == 0xff\n num_octets = length & 0x7f\n length = build_integer(data, 2, num_octets)\n value = data[num_octets+2, length]\n remainder = data[num_octets+2+length..-1]\n end\n return tag, value, remainder\n end", "def value_helper_text(type, text)\n value_el = Ox::Element.new(:value)\n value_el['xsi:type'] = type\n value_el << text\n value_el\n end", "def add_value(value)\n @children['value'][:value] << value\n end", "def add(type, description, options={})\n type = type.downcase\n add_item construct_item(type, description, options)\n end", "def create_variant(type, value)\n value_type = Spree::OptionType.find_or_initialize_by name: type\n value_type.update! presentation: type.capitalize unless value_type.id\n\n # ensure we have propper variant\n option_value = Spree::OptionValue.find_or_create_by! name: value, presentation: value, option_type_id: value_type.id\n\n # this will link variant to size\n Spree::OptionValuesVariant.find_or_create_by! variant_id: @variant.id, option_value_id: option_value.id\n end", "def add(value)\n \n end", "def initialize(type:, value:)\n @type = type\n @value = value\n end", "def initialize\n @type = LENGTH\n @value = UNSET\n @value_list = [SHORT, LONG].freeze\n end", "def get_tlvs(type)\n\t\tif (type == TLV_TYPE_ANY)\n\t\t\treturn self.tlvs\n\t\telse\n\t\t\ttype_tlvs = []\n\n\t\t\tself.tlvs.each() { |tlv|\n\t\t\t\tif (tlv.type?(type))\n\t\t\t\t\ttype_tlvs << tlv\n\t\t\t\tend\n\t\t\t}\n\n\t\t\treturn type_tlvs\n\t\tend\n\tend", "def get_tlvs(type)\n\t\tif (type == TLV_TYPE_ANY)\n\t\t\treturn self.tlvs\n\t\telse\n\t\t\ttype_tlvs = []\n\n\t\t\tself.tlvs.each() { |tlv|\n\t\t\t\tif (tlv.type?(type))\n\t\t\t\t\ttype_tlvs << tlv\n\t\t\t\tend\n\t\t\t}\n\n\t\t\treturn type_tlvs\n\t\tend\n\tend", "def add_type(type)\n\n # nothing to be done\n end", "def add_type(type)\n\n # nothing to be done\n end", "def add(name, type, offset = nil)\n if type.respond_to?(:to_str) || type.respond_to?(:to_sym)\n type = registry.build(type.to_s)\n end\n @fields << [name.to_s, type, offset]\n end", "def add(value)\n\tend", "def initialize(type,value)\n @type, @value = type, value\n\n end", "def type(val); @type = val; self; end", "def addMetadataType\n begin\n # Name of the metadatatype to be added\n name = params[:metadatatypename].to_s.strip.downcase\n value_type = params[:value_type].to_s.strip.downcase\n\n if value_type == \"\"\n value_type = \"string\"\n elsif value_type != \"string\" && value_type != \"float\" && value_type != \"date\" && value_type != \"datetime\"\n render :text => \"Invalid value_type\", :status => 404\n return\n end\n\n # Check that type doesn't exist already\n # @@existing_metadata_types listed in the beginning of file\n if MetadataType.find_by_name(name) or @@existing_metadata_types.include?(name)\n render :text => \"Metadatatype already exists\", :status => 200\n return\n end\n\n # Create new type\n @newtype = MetadataType.create(:name => name, :value_type => value_type)\n render :text => \"Metadatatype created\", :status => 201\n return\n rescue => e\n puts \"Error in adding metadatatype: #{e.to_s}\".background(:red)\n render :text => \"Conflict\", :status => 409\n return\n end\n end", "def add_type\n @item.type = bibtex_type\n end", "def add_record type, data, ttl = 0, flags = 0\n @records << _add_record(flags.to_i, type, data, ttl)\n end", "def add_enum_value(type, value, before: nil, after: nil)\n cmd = \"ALTER TYPE #{type} ADD VALUE '#{value}'\"\n\n if before && after\n raise ArgumentError, \"Cannot have both :before and :after at the same time\"\n elsif before\n cmd << \" BEFORE '#{before}'\"\n elsif after\n cmd << \" AFTER '#{after}'\"\n end\n\n execute(cmd).tap { reload_type_map }\n end", "def add(type)\n @list << type\n self\n end", "def add_value_by_value_type(str, value_type, result_init=nil, result_init_currency=nil, logtag=nil)\n logger.debug(\"#{File.basename(__FILE__)}:#{self.class}:#{Time.now}:add_value_by_value_type, str:#{str}, result_init:#{result_init}, result_init_currency:#{result_init_currency}, value_type:#{value_type}\")\n result = nil\n if value_type == ValueTypeValidator::VALUE_TYPE_VALUE_UNIQ or value_type == ValueTypeValidator::VALUE_TYPE_VALUE\n # Add value\n if result_init.nil?\n sum_str = \"#{str}\"\n else\n sum_str = \"#{str} #{result_init_currency}#{result_init}\"\n end # end if result_init.nil?\n result = ControllerHelper.sum_currency_in_str(sum_str, 0)\n else\n # Add count\n if result_init.nil?\n result = 1\n else\n result = result_init + 1\n end # end if result_init.nil?\n end # end if value_type == ValueTypeValidator::VALUE_TYPE_VALUE_UNIQ or value_type == ValueTypeValidator::VALUE_TYPE_VALUE\n result\n end", "def to_r\n\t\traw = value.to_s;\n\n\t\tif (self.type & TLV_META_TYPE_STRING == TLV_META_TYPE_STRING)\n\t\t\traw += \"\\x00\"\n\t\telsif (self.type & TLV_META_TYPE_UINT == TLV_META_TYPE_UINT)\n\t\t\traw = [value].pack(\"N\")\n\t\telsif (self.type & TLV_META_TYPE_BOOL == TLV_META_TYPE_BOOL)\n\t\t\tif (value == true)\n\t\t\t\traw = [1].pack(\"c\")\n\t\t\telse\n\t\t\t\traw = [0].pack(\"c\")\n\t\t\tend\n\t\tend\n\n\t\treturn [raw.length + 8, self.type].pack(\"NN\") + raw\n\tend", "def each(type = TLV_TYPE_ANY, &block)\n\t\tget_tlvs(type).each(&block)\n\tend", "def each(type = TLV_TYPE_ANY, &block)\n\t\tget_tlvs(type).each(&block)\n\tend", "def volume_type=(value)\n @volume_type = value\n end", "def add(value)\n end", "def add(val, options = {})\n field = (options[:as] || val).to_sym\n\n self[field] = val\n\n @options[field] = options\n end", "def << value\n add(value)\n end", "def add(tag, value)\n datastore.zadd(tag, 0, value)\n end", "def add_text(text, tree = T.unsafe(nil), type = T.unsafe(nil)); end", "def initialize(type, value)\n @value = Hash[type: type, value: value]\n end", "def add(val)\n \n end", "def create\n @value_type = ValueType.new(params[:value_type])\n\n respond_to do |format|\n if @value_type.save\n format.html { redirect_to @value_type, notice: 'Value type was successfully created.' }\n format.json { render json: @value_type, status: :created, location: @value_type }\n else\n format.html { render action: \"new\" }\n format.json { render json: @value_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def add_value_in_view rtype, value, view\n self.check_rtype rtype\n if Enumerable === value\n # unwrap values with only one element\n value = value.count == 0 ? nil : value.count == 1 ? value[0] : value\n end\n @views[view][rtype] ||= []\n @views[view][rtype] << value\n end", "def value=(val)\n if(val.nil?)\n self[:length] = 0\n self[:value] = val\n elsif(val.is_a?(String))\n buff = FFI::MemoryPointer.from_string(val)\n self[:length] = val.length\n self[:value] = buff\n elsif(val.is_a?(Fixnum))\n buff = FFI::MemoryPointer.new :OM_uint32\n buff.write_int val\n self[:length] = FFI::type_size :OM_uint32\n self[:value] = buff\n else\n raise StandardError, \"Can't handle type #{val.class.name}\"\n end\n end", "def <<(value)\n add(value)\n end", "def add_type(type)\n\n # does nothing, types are differentiated by the 'typ' column\n end", "def add_type(type)\n\n # does nothing, types are differentiated by the 'typ' column\n end", "def type=(new_type)\n self[:type_flags] = (flags | TYPES[new_type])\n end", "def from_r(raw)\n\t\toffset = 8\n\n\t\t# Reset the TLVs array\n\t\tself.tlvs = []\n\t\tself.type = raw.unpack(\"NN\")[1]\n\n\t\t# Enumerate all of the TLVs\n\t\twhile (offset < raw.length-1)\n\n\t\t\ttlv = nil\n\n\t\t\t# Get the length and type\n\t\t\tlength, type = raw[offset..offset+8].unpack(\"NN\")\n\n\t\t\tif (type & TLV_META_TYPE_GROUP == TLV_META_TYPE_GROUP)\n\t\t\t\ttlv = GroupTlv.new(type)\n\t\t\telse\n\t\t\t\ttlv = Tlv.new(type)\n\t\t\tend\n\n\t\t\ttlv.from_r(raw[offset..offset+length])\n\n\t\t\t# Insert it into the list of TLVs\n\t\t\ttlvs << tlv\n\n\t\t\t# Move up\n\t\t\toffset += length\n\t\tend\n\tend", "def from_r(raw)\n\t\toffset = 8\n\n\t\t# Reset the TLVs array\n\t\tself.tlvs = []\n\t\tself.type = raw.unpack(\"NN\")[1]\n\n\t\t# Enumerate all of the TLVs\n\t\twhile (offset < raw.length-1)\n\n\t\t\ttlv = nil\n\n\t\t\t# Get the length and type\n\t\t\tlength, type = raw[offset..offset+8].unpack(\"NN\")\n\n\t\t\tif (type & TLV_META_TYPE_GROUP == TLV_META_TYPE_GROUP)\n\t\t\t\ttlv = GroupTlv.new(type)\n\t\t\telse\n\t\t\t\ttlv = Tlv.new(type)\n\t\t\tend\n\n\t\t\ttlv.from_r(raw[offset..offset+length])\n\n\t\t\t# Insert it into the list of TLVs\n\t\t\ttlvs << tlv\n\n\t\t\t# Move up\n\t\t\toffset += length\n\t\tend\n\tend", "def update_value_type\n write_attribute :value_type, EavEntry.get_value_type(@value)\n end", "def add_param(type, val)\n type = type.chr if type.kind_of?(Fixnum)\n @signature += type.to_s\n @params << [type, val]\n end", "def append(value)\n case value\n when NilClass\n append_null\n when Float\n append_double(value)\n when Integer\n case value\n when RANGE_INT16\n append_int16(value)\n when RANGE_INT32\n append_int32(value)\n when RANGE_INT64\n append_int64(value)\n else\n append_hugeint(value)\n end\n when String\n blob?(value) ? append_blob(value) : append_varchar(value)\n when TrueClass, FalseClass\n append_bool(value)\n when Time\n append_timestamp(value)\n when Date\n append_date(value)\n else\n raise(DuckDB::Error, \"not supported type #{value} (#{value.class})\")\n end\n end", "def control_add key, val\n if ov = @dbs[:control][key.to_s]\n fmt = case ov.length\n when 4 then ?N\n when 8 then 'Q>'\n else\n raise RuntimeError, \"#{key} must be 4 or 8 bytes long\"\n end\n ov = ov.unpack1 fmt\n else\n ov = 0\n end\n\n nv = ov + val\n\n @dbs[:control][key.to_s] = [nv].pack 'Q>'\n\n nv\n end", "def initialize(value)\n @value = value\n @type = self.class.type\n end", "def tag_type=(value)\n @tag_type = value\n end", "def _addElement( key, value )\n @token.addElement( key, value )\n end", "def add_field(name, value)\n raise ArgumentError.new(\"Found invalid XML 1.0 unicode character(s)\") if value.is_a? String and value =~ INVALID_CHAR_XML10\n @fields[name] = value\n end", "def initialize(*args)\n @lengths = args\n @types = []\n @value = \"\"\n end", "def create_and_add(tag, attributes, value)\n self.class.create_tag(tag, attributes, value).tap do | tag |\n tag.playlist = @playlist if tag.kind_of? MediaSegment\n add(tag)\n end\n\n end", "def add_string(tag, value)\n value = value.to_s\n write_tag(tag, Type::STRING)\n Varint.serialize(@io, value.bytesize)\n @io << value\n\n self\n end", "def add_vault_member(vault_id, user_id, status)\n request_post(\"/vault/#{vault_id}/member/#{user_id}\", status: status)\n end", "def set_Type(value)\n set_input(\"Type\", value)\n end", "def set_Type(value)\n set_input(\"Type\", value)\n end", "def value_type=(value)\n @value_type = value\n end", "def volumen(numero, opciones = {})\n volumen = numero\n volumenes << volumen\n end", "def type=(value)\n @type = value\n end", "def type=(value)\n @type = value\n end", "def type=(value)\n @type = value\n end", "def type=(value)\n @type = value\n end", "def type=(value)\n @type = value\n end", "def type=(value)\n @type = value\n end", "def type=(value)\n @type = value\n end", "def tlv_select=(should_tlv_select)\n info \"os10_lldp_interface::tlv_select=#{should_tlv_select}\"\n begin\n # if both the current and new inputs are not empty,\n if !tlv_select.empty? && !should_tlv_select.empty?\n conf_lines = []\n conf_lines << \"interface #{@interface_name}\"\n # loop through the new configuration values and check if\n # the keys are already present in the configuration,\n should_tlv_select.each do |key, _value|\n if tlv_select.include? key\n enable = tlv_select[key] - should_tlv_select[key]\n enable.each do |tlvs|\n # enable the tlv-select that is not present in the new config\n conf_lines << \"lldp tlv-select #{key} #{tlvs}\"\n end\n # disable the tlv-select that needs to be configured\n else\n disable = should_tlv_select[key]\n if key == 'dcbxp'\n conf_lines << \"no lldp tlv-select #{key}\"\n else\n disable.each do |tlvs|\n conf_lines << \"no lldp tlv-select #{key} #{tlvs}\"\n end\n end\n end\n end\n # loop through the configuration values already present in the device\n # and check if the keys match with new configs\n tlv_select.each do |k, _v|\n if should_tlv_select.include? k\n disable = should_tlv_select[k] - tlv_select[k]\n disable.each do |tlvs|\n # disable the tlv-select that is not present in config\n # and needs to be configured newly\n conf_lines << \"no lldp tlv-select #{k} #{tlvs}\"\n end\n # enable the tlv-select that does not match with new configuration\n else\n enable = tlv_select[k]\n enable.each do |tlvs|\n conf_lines << \"lldp tlv-select #{k} #{tlvs}\"\n end\n end\n end\n conf_lines.each { |val| info val }\n ecc conf_lines\n\n # if the new configuration is empty and there are config already present\n # in the device, enable them\n elsif should_tlv_select.empty? && !tlv_select.empty?\n tlv_select.each do |key, _value|\n enable = tlv_select[key]\n conf_lines = []\n conf_lines << \"interface #{@interface_name}\"\n enable.each do |tlvs|\n conf_lines << \"lldp tlv-select #{key} #{tlvs}\"\n end\n conf_lines.each { |val| info val }\n ecc conf_lines\n end\n\n # if there are no configuration present in the device, disable all\n # the new tlv-select\n else\n should_tlv_select.each do |key, _value|\n disable = should_tlv_select[key]\n conf_lines = []\n conf_lines << \"interface #{@interface_name}\"\n disable.each do |tlvs|\n conf_lines << \"no lldp tlv-select #{key} #{tlvs}\"\n end\n conf_lines.each { |val| info val }\n ecc conf_lines\n end\n return\n end\n rescue Exception => e\n err 'Exception in tlv select'\n err e.message\n err e.backtrace[0]\n raise\n end\n end", "def add value\n if !@root\n @root = Node.new value, nil, @cmp\n @length = 1\n else\n @root.add value\n @length += 1\n end\n value\n end", "def create_vault(**args)\n request_post('/vault', **args)\n end", "def set_type(v)\n self.type = v\n self\n end", "def attr_set_ub8(attr_type, attr_value)\n #This is a stub, used for indexing\n end", "def create\n @dl_type = DlType.new(params[:dl_type])\n\tif @dl_type.dl_type\n\t\t@dl_type.type_lv = @dl_type.dl_type.type_lv + 1\n\tend\n\n respond_to do |format|\n if @dl_type.save\n format.html { redirect_to(downloads_admin_dl_types_url, :notice => 'Dl type was successfully created.') }\n format.xml { render :xml => @dl_type, :status => :created, :location => @dl_type }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @dl_type.errors, :status => :unprocessable_entity }\n end\n end\n end", "def tlv_select\n info 'os10_lldp_interface::tlv select'\n begin\n lldp_interface_data = @tlv_ret[:stdout].split(\"\\n\")\n temp_data = {}\n\n lldp_interface_data.each do |data|\n if data.include? 'lldp tlv-select'\n tlv_data = data.split(' ')\n if tlv_data.length == 4\n temp_data[tlv_data[3]] = [' ']\n elsif temp_data[tlv_data[3]].nil? && tlv_data.length >= 4\n temp_data[tlv_data[3]] = [tlv_data[4]]\n elsif tlv_data[4]\n temp_data[tlv_data[3]] = temp_data[tlv_data[3]] << tlv_data[4]\n temp_data[tlv_data[3]] = temp_data[tlv_data[3]].sort\n end\n end\n end\n return temp_data\n rescue Exception => e\n err 'Exception in tlv select'\n err e.message\n err e.backtrace[0]\n raise\n end\n end", "def add_attribute_to_type\n check_type_exists\n type_content = File.read(type_path)\n unless parameter_in_type?(type_content)\n type_content.sub!(END_PARAMETER_BLOCK,\"\\t\\t#{@attribute_type} :#{@attribute_name}\\n#{END_PARAMETER_TEXT}\")\n save_file(type_path, type_content)\n Puppet.notice \"#{@attribute_type.capitalize} #{@attribute_name} added to #{type_path}\"\n else\n Puppet.notice \"#{@attribute_type.capitalize} #{@attribute_name} already in #{type_path}\"\n end\n end" ]
[ "0.78159946", "0.7622521", "0.7575506", "0.65320927", "0.65320927", "0.6370173", "0.6156051", "0.5919875", "0.5919875", "0.56553566", "0.5556474", "0.5556474", "0.5506013", "0.54831356", "0.54609066", "0.54539067", "0.54539067", "0.53963107", "0.53696126", "0.53538275", "0.53114897", "0.52786416", "0.5262169", "0.520931", "0.520931", "0.51863295", "0.5167052", "0.51315635", "0.5118846", "0.5110505", "0.51081866", "0.5085691", "0.506597", "0.50223124", "0.5022157", "0.50220454", "0.50220454", "0.50076437", "0.50076437", "0.49931875", "0.49857938", "0.49622387", "0.4959957", "0.49487394", "0.49359143", "0.49207112", "0.49043658", "0.4900136", "0.4891832", "0.48805234", "0.48654333", "0.48654333", "0.48543924", "0.48466176", "0.48179975", "0.48172373", "0.48087722", "0.47951669", "0.47809258", "0.4765213", "0.47619092", "0.47481444", "0.47469008", "0.47423875", "0.4740672", "0.47313386", "0.47279882", "0.4723559", "0.4723559", "0.4719506", "0.47173336", "0.47115412", "0.46923348", "0.46909362", "0.46820056", "0.46662953", "0.46662623", "0.46626055", "0.4660692", "0.46598792", "0.46553704", "0.4646714", "0.4646714", "0.46457878", "0.46360037", "0.46255067", "0.46255067", "0.46255067", "0.46255067", "0.46255067", "0.46255067", "0.46255067", "0.46032414", "0.45899874", "0.45895317", "0.4588198", "0.4578907", "0.45755592", "0.4573496", "0.4563079" ]
0.7435301
3
Adds zero or more TLVs to the packet.
def add_tlvs(tlvs) if (tlvs != nil) tlvs.each { |tlv| add_tlv(tlv['type'], tlv['value']) } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_tlv(t,l,v=nil)\n tlv = [(t << 9) + l, v]\n self.payload += tlv.flatten.pack(\"na*\")\n end", "def add_field(type, value)# {{{\n t = TLV.new(2,2)\n t.type = type\n t.value = value\n t.length = 4 + value.length\n self.payload += t.encode \n end", "def add_tlv(type, value = nil, replace = false, compress=false)\n\n\t\t# If we should replace any TLVs with the same type...remove them first\n\t\tif (replace)\n\t\t\teach(type) { |tlv|\n\t\t\t\tif (tlv.type == type)\n\t\t\t\t\tself.tlvs.delete(tlv)\n\t\t\t\tend\n\t\t\t}\n\t\tend\n\n\t\tif (type & TLV_META_TYPE_GROUP == TLV_META_TYPE_GROUP)\n\t\t\ttlv = GroupTlv.new(type)\n\t\telse\n\t\t\ttlv = Tlv.new(type, value, compress)\n\t\tend\n\n\t\tself.tlvs << tlv\n\n\t\treturn tlv\n\tend", "def add_tlv(type, value = nil, replace = false)\n\t\ttlv = nil\n\n\t\t# If we should replace any TLVs with the same type...remove them first\n\t\tif (replace)\n\t\t\teach(type) { |tlv|\n\t\t\t\tif (tlv.type == type)\n\t\t\t\t\tself.tlvs.delete(tlv)\n\t\t\t\tend\n\t\t\t}\n\t\tend\n\n\t\tif (type & TLV_META_TYPE_GROUP == TLV_META_TYPE_GROUP)\n\t\t\ttlv = GroupTlv.new(type)\n\t\telse\n\t\t\ttlv = Tlv.new(type, value)\n\t\tend\n\n\t\tself.tlvs << tlv\n\n\t\treturn tlv\n\tend", "def add_data(packets)\n @buffer.keys.each { |k| @buffer[k].concat extract_packets(packets, k) }\n trim_data\n end", "def push(packet); end", "def add(words, value = T.unsafe(nil)); end", "def add_bytes(tag, value)\n value = value.to_s\n write_tag(tag, Type::BYTE_ARRAY)\n Varint.serialize(@io, value.bytesize)\n @io << value\n\n self\n end", "def add(args)\n add_dn = args[:dn] or raise Net::LDAP::EmptyDNError, \"Unable to add empty DN\"\n add_attrs = []\n a = args[:attributes] and a.each { |k, v|\n add_attrs << [ k.to_s.to_ber, Array(v).map { |m| m.to_ber}.to_ber_set ].to_ber_sequence\n }\n\n message_id = next_msgid\n request = [add_dn.to_ber, add_attrs.to_ber_sequence].to_ber_appsequence(Net::LDAP::PDU::AddRequest)\n\n write(request, nil, message_id)\n pdu = queued_read(message_id)\n\n if !pdu || pdu.app_tag != Net::LDAP::PDU::AddResponse\n raise Net::LDAP::ResponseMissingOrInvalidError, \"response missing or invalid\"\n end\n\n pdu\n end", "def add(data)\n case data\n when Buffer\n @data.concat(data.data)\n else\n data = data.to_s.dup\n return if data.empty?\n\n @data << data\n end\n @size += data.size\n self\n end", "def from_r(raw)\n\t\toffset = 8\n\n\t\t# Reset the TLVs array\n\t\tself.tlvs = []\n\t\tself.type = raw.unpack(\"NN\")[1]\n\n\t\t# Enumerate all of the TLVs\n\t\twhile (offset < raw.length-1)\n\n\t\t\ttlv = nil\n\n\t\t\t# Get the length and type\n\t\t\tlength, type = raw[offset..offset+8].unpack(\"NN\")\n\n\t\t\tif (type & TLV_META_TYPE_GROUP == TLV_META_TYPE_GROUP)\n\t\t\t\ttlv = GroupTlv.new(type)\n\t\t\telse\n\t\t\t\ttlv = Tlv.new(type)\n\t\t\tend\n\n\t\t\ttlv.from_r(raw[offset..offset+length])\n\n\t\t\t# Insert it into the list of TLVs\n\t\t\ttlvs << tlv\n\n\t\t\t# Move up\n\t\t\toffset += length\n\t\tend\n\tend", "def from_r(raw)\n\t\toffset = 8\n\n\t\t# Reset the TLVs array\n\t\tself.tlvs = []\n\t\tself.type = raw.unpack(\"NN\")[1]\n\n\t\t# Enumerate all of the TLVs\n\t\twhile (offset < raw.length-1)\n\n\t\t\ttlv = nil\n\n\t\t\t# Get the length and type\n\t\t\tlength, type = raw[offset..offset+8].unpack(\"NN\")\n\n\t\t\tif (type & TLV_META_TYPE_GROUP == TLV_META_TYPE_GROUP)\n\t\t\t\ttlv = GroupTlv.new(type)\n\t\t\telse\n\t\t\t\ttlv = Tlv.new(type)\n\t\t\tend\n\n\t\t\ttlv.from_r(raw[offset..offset+length])\n\n\t\t\t# Insert it into the list of TLVs\n\t\t\ttlvs << tlv\n\n\t\t\t# Move up\n\t\t\toffset += length\n\t\tend\n\tend", "def add_option(number, value)\n t = Misc::TLV.new(1,1)\n t.type = number\n t.value = value\n t.length = value.length + 2\n @options << t.encode\n end", "def add(data)\n @parser << data\n end", "def add_option(size, value)\n struct = PacketWriter.TypeValueStruct.new 1, 1\n struct.type = size\n struct.value = value\n struct.length = value.length + 2\n self.options << struct.encode\n end", "def append_opt(opt)\n if opt.name == :dhcp_message_type\n unless @type.nil?\n raise \"DHCP message type ALREADY SET in packet\"\n end\n set_type(opt)\n end\n @optlist << opt\n end", "def add(el)\n # System.out.println(\"add(\"+el+\")\");\n n = word_number(el)\n # System.out.println(\"word number is \"+n);\n # System.out.println(\"bits.length \"+bits.length);\n if (n >= @bits.attr_length)\n grow_to_include(el)\n end\n @bits[n] |= bit_mask(el)\n end", "def addnew(options = {})\n\n options[:initial] = [*(options[:initial] || [])].join('|') if options[:initial]\n options[:archive] = [*(options[:archive] || [])].join('|') if options[:archive]\n\n options = { tvdbid: @tvdbid }.merge(options)\n\n @server.make_json_request('show.addnew', options)['message']\n end", "def add(opt)\n @rtsocket.link.add(vlan_options(opt))\n end", "def build_packet\n return [@request_id, @command_type, @string1, @string2].pack(\"VVa#{@string1.length}a2\")\n end", "def add_template(id)\r\n\t\tbuf = ''\r\n\t\tbuf << \"\\x9b\\x00\" #Packet size\r\n\t\tbuf << \"\\x01\\x00\\x34\\x12\"\r\n\t\tbuf << \"\\x07\" #Opcode\r\n\t\tbuf << \"\\x00\\x00\\x00\\x00\\x00\\x00\\x00\"\r\n\t\tbuf << \"\\x01\" #Flag\r\n\t\tbuf << \"\\x00\\x00\\x00\"\r\n\t\tbuf << \"\\x04\" #Command (add)\r\n\t\tbuf << \"\\x00\\x00\\x00\"\r\n\t\tbuf << id\r\n\t\tbuf << \"\\x00\"\r\n\t\tbuf << \"\\x00\"*31\r\n\t\tbuf << \"\\x78\"\r\n\t\tbuf << \"\\x00\"*63\r\n\t\tbuf << \"\\x78\"\r\n\t\tbuf << \"\\x00\"*28\r\n\r\n\t\tconnect\r\n\r\n\t\tsock.put(buf)\r\n\r\n\t\tprint_status(\"Sending ADD command to #{datastore['RHOST']}\")\r\n\t\tres = sock.recv(1024)\r\n\r\n\t\tdisconnect\r\n\r\n\t\treturn res\r\n\tend", "def <<(xpb)\n @packets << xpb\n end", "def add_raw(raw)\n @fields << Field.new(raw)\n self\n end", "def add_binary(_tag, _val)\n raise NotImplementedError\n end", "def add_veth veth\n cmd = \"#{@vzctl} set #{@ctid} --netif_add #{veth[:ifname]},#{veth[:mac]},#{veth[:host_ifname]},\" \\\n \"#{veth[:host_mac]}, #{veth[:bridge]}\"\n execute(cmd)\n end", "def add_field!(field_name, value = T.unsafe(nil)); end", "def build_options_pack (*options)\n getr = lambda{|value| value = DHCPOP_CONSTANTS[value].nil? ? value : DHCPOP_CONSTANTS[value]; DHCPOP_MESSAGETYPES[value].nil? ? value : DHCPOP_MESSAGETYPES[value] }\n # Build the tree\n packets = options.map do |x|\n packet = []\n if x.class == Array\n x.each {|y| (y.class == Array ? y.each{|z| packet << getr.call(z)} : packet << getr.call(y))}\n else; raise \"Packet option should be an array.\"; end\n packet\n end\n # Work out the lengths, out = length-(op+1)\n ret = []\n packets.each {|packet| packet.each {|obj| ret << (obj == :len ? packet.length-2 : obj)}}\n ret\nend", "def parse(bytes)\n # tack new bytes on to partial packet\n @packet.concat(bytes.force_encoding('BINARY'))\n # find START_BYTE\n until (startPos = @packet.index(START_BYTE)).nil?\n after = @packet.slice(startPos+1 .. -1)\n nread = case after[0]\n when ID_ADC_STATUS\n parseADCStatus(after)\n when ID_DATA\n parseDataPacket(after)\n when ID_IO_STATUS\n parseIOStatus(after)\n when nil # no more bytes\n 0\n else\n # consume up to next START_BYTE\n after.index(START_BYTE) || 0\n end\n @packet = after.slice(nread .. -1)\n end\n end", "def from_r(raw)\n\t\tself.value = nil\n\n\t\tlength, self.type = raw.unpack(\"NN\");\n\n\t\t# check if the tlv value has been compressed...\n\t\tif( self.type & TLV_META_TYPE_COMPRESSED == TLV_META_TYPE_COMPRESSED )\n\t\t\t# set this TLV as using compression\n\t\t\t@compress = true\n\t\t\t# remove the TLV_META_TYPE_COMPRESSED flag from the tlv type to restore the \n\t\t\t# tlv type to its origional, allowing for transparent data compression.\n\t\t\tself.type = self.type ^ TLV_META_TYPE_COMPRESSED\n\t\t\t# decompress the compressed data (skipping the length and type DWORD's)\n\t\t\traw_decompressed = Rex::Text.zlib_inflate( raw[8..length-1] )\n\t\t\t# update the length to reflect the decompressed data length (+8 for the length and type DWORD's)\n\t\t\tlength = raw_decompressed.length + 8\n\t\t\t# update the raw buffer with the new length, decompressed data and updated type.\n\t\t\traw = [length, self.type].pack(\"NN\") + raw_decompressed\n\t\tend\n\t\t\n\t\tif (self.type & TLV_META_TYPE_STRING == TLV_META_TYPE_STRING)\n\t\t\tif (raw.length > 0)\n\t\t\t\tself.value = raw[8..length-2]\n\t\t\telse\n\t\t\t\tself.value = nil\n\t\t\tend\n\t\telsif (self.type & TLV_META_TYPE_UINT == TLV_META_TYPE_UINT)\n\t\t\tself.value = raw.unpack(\"NNN\")[2]\n\t\telsif (self.type & TLV_META_TYPE_BOOL == TLV_META_TYPE_BOOL)\n\t\t\tself.value = raw.unpack(\"NNc\")[2]\n\n\t\t\tif (self.value == 1)\n\t\t\t\tself.value = true\n\t\t\telse\n\t\t\t\tself.value = false\n\t\t\tend\n\t\telse\n\t\t\tself.value = raw[8..length-1]\n\t\tend\n\n\t\treturn length;\n\tend", "def append(key, length, data)\n end", "def add_record type, data, ttl = 0, flags = 0\n @records << _add_record(flags.to_i, type, data, ttl)\n end", "def decode_tlv(data)\n raise OutOfData if (data.length == 2 && data[1].ord != 0) || data.length < 2\n tag = data[0].ord\n length = data[1].ord\n if length < 0x80\n value = data[2, length]\n remainder = data[length+2..-1]\n else\n # ASN.1 says this octet can't be 0xff\n raise InvalidLength, length.to_s if length == 0xff\n num_octets = length & 0x7f\n length = build_integer(data, 2, num_octets)\n value = data[num_octets+2, length]\n remainder = data[num_octets+2+length..-1]\n end\n return tag, value, remainder\n end", "def put_trans_data(pkt, len: 0, param: '', data: '', noPad: false)\n pkt['Payload'].v['ParamOffset'] = 0\n pkt['Payload'].v['DataOffset'] = 0\n\n # SMB header: 32 bytes\n # WordCount: 1 bytes\n # ByteCount: 2 bytes\n #offset = 32 + 1 + len + 2 #len(pkt['Parameters']) + 2\n len = pkt.to_s.length - 4\n param = param.b\n data = data.b\n offset = len\n\n transData = ''\n if param != ''\n padLen = if noPad then 0 else (4 - offset % 4 ) % 4 end\n pkt['Payload'].v['ParamOffset'] = offset + padLen\n transData = (\"\\x00\" * padLen) + param\n offset += padLen + param.length\n end\n\n if data != ''\n padLen = if noPad then 0 else (4 - offset % 4 ) % 4 end\n pkt['Payload'].v['DataOffset'] = offset + padLen\n transData += (\"\\x00\" * padLen) + data\n end\n\n pkt['Payload'].v['Payload'] = transData\n pkt\n end", "def prepend(*parameters)\n @faraday.builder.insert(0, *parameters)\n end", "def add(*types)\n __types__.add(*types)\n end", "def tlv_select\n info 'os10_lldp_interface::tlv select'\n begin\n lldp_interface_data = @tlv_ret[:stdout].split(\"\\n\")\n temp_data = {}\n\n lldp_interface_data.each do |data|\n if data.include? 'lldp tlv-select'\n tlv_data = data.split(' ')\n if tlv_data.length == 4\n temp_data[tlv_data[3]] = [' ']\n elsif temp_data[tlv_data[3]].nil? && tlv_data.length >= 4\n temp_data[tlv_data[3]] = [tlv_data[4]]\n elsif tlv_data[4]\n temp_data[tlv_data[3]] = temp_data[tlv_data[3]] << tlv_data[4]\n temp_data[tlv_data[3]] = temp_data[tlv_data[3]].sort\n end\n end\n end\n return temp_data\n rescue Exception => e\n err 'Exception in tlv select'\n err e.message\n err e.backtrace[0]\n raise\n end\n end", "def add(*types)\n @__types__.add(*types)\n end", "def add (vector, label = 0)\n @fvs.push([vector, label])\n end", "def add(tag)\n return nil if tag.nil?\n get_list(tag) << tag\n end", "def add(*types)\n quiet = ((types.last == :silent) or (types.last == true))\n\n types.each do |mime_type|\n case mime_type\n when true, false, nil, Symbol\n nil\n when MIME::Types\n variants = mime_type.instance_variable_get(:@type_variants)\n add(*variants.values.flatten, quiet)\n when Array\n add(*mime_type, quiet)\n else\n add_type(mime_type, quiet)\n end\n end\n end", "def << bytes\n @body << bytes\n end", "def to_r\n\t\traw = value.to_s;\n\n\t\tif (self.type & TLV_META_TYPE_STRING == TLV_META_TYPE_STRING)\n\t\t\traw += \"\\x00\"\n\t\telsif (self.type & TLV_META_TYPE_UINT == TLV_META_TYPE_UINT)\n\t\t\traw = [value].pack(\"N\")\n\t\telsif (self.type & TLV_META_TYPE_BOOL == TLV_META_TYPE_BOOL)\n\t\t\tif (value == true)\n\t\t\t\traw = [1].pack(\"c\")\n\t\t\telse\n\t\t\t\traw = [0].pack(\"c\")\n\t\t\tend\n\t\tend\n\t\t\n\t\t# check if the tlv is to be compressed...\n\t\tif( @compress )\n\t\t\traw_uncompressed = raw\n\t\t\t# compress the raw data\n\t\t\traw_compressed = Rex::Text.zlib_deflate( raw_uncompressed )\n\t\t\t# check we have actually made the raw data smaller...\n\t\t\t# (small blobs often compress slightly larger then the origional) \n\t\t\t# if the compressed data is not smaller, we dont use the compressed data\n\t\t\tif( raw_compressed.length < raw_uncompressed.length )\n\t\t\t\t# if so, set the TLV's type to indicate compression is used\n\t\t\t\tself.type = self.type | TLV_META_TYPE_COMPRESSED\n\t\t\t\t# update the raw data with the uncompressed data length + compressed data\n\t\t\t\t# (we include the uncompressed data length as the C side will need to know this for decompression)\n\t\t\t\traw = [ raw_uncompressed.length ].pack(\"N\") + raw_compressed\n\t\t\tend\n\t\tend\n\t\t\n\t\treturn [raw.length + 8, self.type].pack(\"NN\") + raw\n\tend", "def add(*elmts)\n elmts.each do |elmt|\n @components.add(elmt)\n end\n end", "def peers_add( *peers )\r\n\t\t\t@peers = @peers.union(peers.flatten)\r\n\t\tend", "def add(data)\n if (@header == nil)\n @header = Node.new(data)\n else\n current = @header\n # go to end of the linked list\n while (current.next) do\n current = current.next\n end\n current.next = Node.new(data)\n end\n @number_of_nodes += 1\n end", "def gtal(packet, params)\n event = Event.all\n if event.nil?\n\t\tpacket.data = \"\"\n \t log_error(\"[gtal] no events in the Data Base\")\n else\n\t packet.data = \"\"\n\t\tevent.each do | elem |\n \t packet.data += \"#{elem.name}\\n\"\n \t end\n end\n packet\n end", "def add(data)\n params = self.params\n data['add']['parameters'].each { |k,v|\n params[k] = v\n }\n write(params)\n data['add']['parameters']\n end", "def add!(data, data_format=DATA_TYPES[:Turtle])\n easy = Curl::Easy.new\n easy.headers[\"Content-Type\"] = data_format\n\n easy.url = self.uri + \"/statements\"\n easy.http_post(data)\n raise(SesameException.new(easy.body_str)) unless easy.response_code == 204\n end", "def add_element(arg = T.unsafe(nil), arg2 = T.unsafe(nil)); end", "def add( item)\n\t\titem.addtag self.gettag\n\tend", "def add(*nodes)\n @nodes.push(*nodes)\n end", "def add(*); end", "def test_add_values\n ogg = dummy()\n\n assert !ogg.has_tag?(\"A\")\n\n ogg.add_values(\"A\", \"B\")\n assert_equal Set[\"B\"], ogg['A']\n\n ogg.add_values(\"A\", \"C\", \"D\")\n assert_equal Set[\"B\", \"C\", \"D\"], ogg['A']\n\n ogg.add_values(\"A\", *[])\n assert_equal Set[\"B\", \"C\", \"D\"], ogg['A']\n end", "def append_0 v\n baos = java.io.ByteArrayOutputStream.new\n baos.write v, 0, v.length\n baos.write 0\n baos.toByteArray\n end", "def fill_xml(xml_node, raw_ilv, ilv_len=nil)\n\n @stack_counter = 0 if !@stack_counter\n\n #Get Element text\n tag_name = xml_node.name\n tag_value = xml_node.get_text\n tag_value = tag_value != nil ? tag_value.value : \"\"\n xml_node.text = \"\"\n\n $test_logger.log(\"Fill XML #{tag_name}\")\n\n #If data is unknown initialize length as calc from packet\n if tag_value == CmdManager::DONT_CARE\n attr_str_len = ilv_len\n else\n #if attr_str_len == nil\n attr_str_len = 1\n end\n\n data_type = nil\n if xml_node.has_attributes?\n\n #Get element attribute \"data type\"\n data_type = xml_node.attributes.get_attribute(TYPE_ATTR).value if xml_node.attributes.get_attribute(TYPE_ATTR)\n\n #Get element attribute \"size\"\n attr_str_len = xml_node.attributes.get_attribute(SIZE_ATTR).value if xml_node.attributes.get_attribute(SIZE_ATTR)\n\n if attr_str_len == CmdManager::DONT_CARE\n if data_type == DataType::STR_WITH_NULL && raw_ilv.index(/\\x00/)\n null_char_pos = raw_ilv.index(/\\x00/) + 1\n xml_node.attributes[SIZE_ATTR] = null_char_pos\n attr_str_len = null_char_pos\n else\n xml_node.attributes[SIZE_ATTR] = ilv_len\n attr_str_len = ilv_len\n end\n else\n attr_str_len = attr_str_len.to_i\n end\n\n end\n\n if raw_ilv.length <= 0\n\n @nodes_to_delete = Array.new if !@nodes_to_delete\n @nodes_to_delete << xml_node\n\n if !@is_parse_error\n @is_parse_error = true\n @parse_error_message = \"Not enough data received for filling XML tag '#{tag_name}' and onwards!\"\n end\n\n else\n\n if xml_node.has_elements?\n old_ilv_len = ilv_len\n xml_node.elements.each do | next_node |\n @stack_counter += 1\n old_ilv_len = fill_xml(next_node, raw_ilv, old_ilv_len)\n @stack_counter -= 1\n end\n\n #Delete unfilled nodes in XML\n if @nodes_to_delete\n @nodes_to_delete.each{|ele|\n xml_node.delete ele\n #ele.elements.delete_all '*'\n }\n @nodes_to_delete.clear\n #!xml_node.elements.each {|ele| xml_node.delete ele if ele.get_text!=nil && ele.get_text.value.to_s.empty? }\n end\n\n #Add Unknown Data, if present\n if @stack_counter == 0 && raw_ilv.length > 0\n unknown_ele = xml_node.root.add_element UNKNOWN_TAG\n unknown_ele.text = get_byte_str(raw_ilv)\n @unknown_flag = true\n raw_ilv = \"\"\n old_ilv_len = 0\n end\n\n else\n\n if (tag_name == ID_TAG)\n\n actual_id = raw_ilv.slice!(0, 1)\n\n ilv_len -= 1 if ilv_len != nil\n\n xml_node.text = get_byte_str(actual_id,1)\n\n elsif tag_name == LEN_TAG && xml_node.previous_element.name == ID_TAG\n #Get length from specified ilv\n len_bytes = 2\n pkt_len_raw = raw_ilv.slice!(0, len_bytes)\n pkt_len = pkt_len_raw.unpack(\"v\").first\n ilv_len -= 2 if ilv_len != nil\n\n #Check if length is greater than 2 bytes\n if pkt_len == 0xffff\n len_bytes += 2\n\n pkt_len_raw = raw_ilv.slice!(0, len_bytes)\n pkt_len = pkt_len_raw.unpack(\"n\").first\n\n ilv_len -= 4 if ilv_len != nil\n end\n\n ilv_len = pkt_len\n\n if tag_value.include?(HEX_PREFIX) || data_type == DataType::HEX\n xml_node.text = get_byte_str(pkt_len_raw, 2)\n else\n xml_node.text = pkt_len\n end\n\n else\n ilv_bytes_count = raw_ilv.bytes.count\n if attr_str_len > ilv_bytes_count\n @is_parse_error = true\n @parse_error_message = \"Not enough ILV data received for filling XML tag '#{tag_name}'!\\nExpected size=#{attr_str_len}\\nActual size=#{ilv_bytes_count}\"\n end\n\n ilv_len -= attr_str_len if ilv_len != nil\n data_str = raw_ilv.slice!(0, attr_str_len)\n\n #if data_type attribute is not present\n #identify data type based on value\n data_type = ILVMessage.get_type_for_data(tag_value) if data_type == nil\n\n #Parse data based on data type\n xml_node.text = parse_data(data_str, data_type, attr_str_len)\n\n end\n\n end\n end\n # return of actual reply element\n ilv_len\n end", "def additional_packet_params\n params.require(:additional_packet).permit(:content, :price)\n end", "def << bindata\n count = @data.size < bindata.size ? @data.size : bindata.size\n (0...count).each do |i|\n Utils.string_setbyte @data,i,Utils.string_getbyte(bindata,i)\n end\n end", "def append_data(data)\n data = Encoding::ASCII_8BIT == data.encoding ? data : data.htb\n chunks << Tapyrus::Script.pack_pushdata(data)\n self\n end", "def protocols_add( *protos )\r\n\t\t\t@protocols = @protocols.union(protos.flatten)\r\n\t\tend", "def << tagspec\n @marcfieldspecs << tagspec\n end", "def add(words) \n @mc.add_elems(words)\n end", "def increment(packet_length); end", "def add_data_elements\n \n end", "def init_fields(args={})\n args[:type] = @int32.new(args[:type] || PcapNG::EPB_TYPE.to_i)\n args[:block_len] = @int32.new(args[:block_len] || MIN_SIZE)\n args[:interface_id] = @int32.new(args[:interface_id] || 0)\n args[:tsh] = @int32.new(args[:tsh] || 0)\n args[:tsl] = @int32.new(args[:tsl] || 0)\n args[:cap_len] = @int32.new(args[:cap_len] || 0)\n args[:orig_len] = @int32.new(args[:orig_len] || 0)\n args[:data] = StructFu::String.new(args[:data] || '')\n args[:options] = StructFu::String.new(args[:options] || '')\n args[:block_len2] = @int32.new(args[:block_len2] || MIN_SIZE)\n args\n end", "def add(tag, value)\n datastore.zadd(tag, 0, value)\n end", "def add_tag(t)\n self.push(t)\n return self\n end", "def addNewData(data)\n\t\tif(data.is_a?(Array))\n\t\t\t@availProofs = @availProofs + data\n\t\telse\n\t\t\t@availProofs.push(data)\n\t\tend\n\tend", "def put_string(*strings)\n strings.each { |s| @request << [s.length].pack('N') + s }\n self\n end", "def _add(params)\n \n vlans = _v_to_l(params[\"v\"])\n \n _check_svi(params[\"b\"]) \n for v in vlans do\n _create_svis(v)\n _set_addr(v, params[\"a\"], params[\"g\"])\n end\n\nend", "def add_tags(*tags)\n @hash_tags.concat(tags.flatten)\n end", "def add(*values)\n if values.length == 1\n @client.execute_udf(@key, @PACKAGE_NAME, 'add', [@bin_name, values[0], @user_module], @policy)\n else\n @client.execute_udf(@key, @PACKAGE_NAME, 'add_all', [@bin_name, values, @user_module], @policy)\n end\n end", "def add(*words)\n words.flatten.each do |word|\n add_word(word)\n end\n nil\n end", "def add(*args); elements.add(*args); end", "def add_tag(tag)\n\n (h.fields['__tags__'] ||= []) << tag\n end", "def initialize(*values)\n @length = 0\n values.each do |value|\n add(value)\n end\n end", "def parse!(data)\n @buffer += data\n overhang = nil\n\n if @size.nil?\n # parse the length field of the \n # extract 4 bytes length header\n @size = @buffer.slice!(0...4).unpack(\"N\").first if @buffer.size >= 4 \n else\n # envelope is complete and contains overhang\n overhang = @buffer.slice!(@size, @buffer.size) if @buffer.size > @size\n end\n \n overhang\n end", "def add_quests(*elems)\r\n @quests.push(*elems)\r\n end", "def add(att, msg)\n fetch(att){self[att] = []} << msg\n end", "def add_subtypes_to_definitions\n # to augment all types definitions\n lolsoap_parser.types.each_value do |content|\n add_subtypes(content[:elements])\n end\n # we have to augment operations because some Requests are abstract, for instance:\n # ReportRequest which can be AccountPerformanceReportRequest etc...\n lolsoap_parser.operations.each_value do |content|\n content[:input][:body].each do |full_name|\n add_subtypes(lolsoap_parser.elements[full_name][:type][:elements])\n end\n end\n @grouped_subtypes = nil # we can reset this as its not needed anymore\n end", "def has_tlv?(type)\n\t\treturn get_tlv(type) != nil\n\tend", "def has_tlv?(type)\n\t\treturn get_tlv(type) != nil\n\tend", "def add_tags\n if @tags.nil?\n @tags = IFFID3.new\n else\n raise AIFFError, 'an ID3 tag already exists'\n end\n end", "def to_r\n\t\traw = ''\n\n\t\tself.each() { |tlv|\n\t\t\traw << tlv.to_r\n\t\t}\n\n\t\treturn [raw.length + 8, self.type].pack(\"NN\") + raw\n\tend", "def to_r\n\t\traw = ''\n\n\t\tself.each() { |tlv|\n\t\t\traw << tlv.to_r\n\t\t}\n\n\t\treturn [raw.length + 8, self.type].pack(\"NN\") + raw\n\tend", "def add(tag, value)\n @fields[tag.to_sym] = value\n end", "def add_tag(*tags)\n tags.each_with_index do |tag, i|\n case tag\n when Tags::Tag\n @tags << tag\n when Tags::RefTag\n @ref_tags << tag\n else\n raise ArgumentError, \"expected Tag or RefTag, got #{tag.class} (at index #{i})\"\n end\n end\n end", "def send_packet(type, *args); end", "def append(data)\r\n return Knj::Gtk2::Tv.append(self, data)\r\n end", "def add_all(words)\n end", "def initialize(packet_type, length = 0, payload = '') \n @codec_id = CODEC_ID\n @packet_type = packet_type\n @length = length\n\n case @packet_type\n when 'response'\n @data_length = length - 1 # codec id not included here - skip 1 byte\n @data_to_read = @data_length + SIZE_CRC # size from \"number of data 1\" to crc\n @data = [] # binary data\n when 'command'\n @payload = payload\n end\n\n @records = [] # parsed records\n @status = 'pending' # status of packet\n end", "def packets; end", "def add(chars)\n result = chars[0]\n \n for i in 1...chars.length\n result = binaryAdd(result, chars[i])\n end\n \n result\n end", "def add_fields(fields)\n\t\tend", "def add_text(text, tree = T.unsafe(nil), type = T.unsafe(nil)); end", "def update_ape\n entries = fields.values.collect{|value| value.raw}.sort{|a,b| x = a.length <=> b.length; x != 0 ? x : a <=> b}\n @tag_data = entries.join\n @tag_item_count = entries.length\n @tag_size = tag_data.length + 64\n base_start = \"#{PREAMBLE}#{[tag_size-32, tag_item_count].pack('VV')}\"\n base_end = \"\\0\"*8\n @tag_header = \"#{base_start}\\x00#{HEADER_FLAGS}#{base_end}\"\n @tag_footer = \"#{base_start}\\x00#{FOOTER_FLAGS}#{base_end}\"\n raise ApeTagError, \"Updated tag has too many items (#{tag_item_count})\" if tag_item_count > MAX_ITEM_COUNT\n raise ApeTagError, \"Updated tag too large (#{tag_size})\" if tag_size > MAX_SIZE\n end", "def +(other)\n self if other.length == 0\n union = Grammar.new(to_hash)\n other.each do |r|\n union.push(r)\n end\n\n union\n end", "def add(data)\n node = Node.new(data: data)\n if head\n tail.next_node = node\n else\n @head = node\n end\n\n @tail = node\n self\n end", "def append_literal(data, ts, te)\n self.literal = literal || []\n literal << text(data, ts, te)\n end", "def append_literal(data, ts, te)\n self.literal = literal || []\n literal << text(data, ts, te)\n end" ]
[ "0.7512073", "0.6452581", "0.5446231", "0.5387242", "0.50093186", "0.4855799", "0.4843963", "0.48399767", "0.4839363", "0.48284498", "0.48074946", "0.48074946", "0.4796561", "0.4761504", "0.4731864", "0.47066212", "0.46885264", "0.4682039", "0.46717402", "0.46441925", "0.4643352", "0.4627707", "0.46267065", "0.46171242", "0.4613528", "0.45901048", "0.45557758", "0.4535989", "0.45279688", "0.45201933", "0.45158392", "0.4513358", "0.45007047", "0.4492784", "0.4492631", "0.44774082", "0.44724697", "0.44597003", "0.44458124", "0.44449702", "0.44397298", "0.44337848", "0.44157985", "0.4402385", "0.43968654", "0.4387202", "0.43783134", "0.43780828", "0.43777984", "0.43712792", "0.43517053", "0.43511453", "0.4349848", "0.4349464", "0.4348991", "0.43454185", "0.43384874", "0.43371943", "0.43350428", "0.43203375", "0.43144462", "0.43138608", "0.4312592", "0.43056175", "0.4304951", "0.42996952", "0.42833525", "0.4280741", "0.42719775", "0.42661586", "0.42644215", "0.42620108", "0.42553705", "0.42514732", "0.4249135", "0.42428717", "0.42385098", "0.42383158", "0.423345", "0.42328414", "0.42328414", "0.42306527", "0.422572", "0.422572", "0.42159492", "0.42105642", "0.42105174", "0.4209275", "0.42008367", "0.41979414", "0.41971093", "0.41955864", "0.4189798", "0.41883138", "0.41878247", "0.4185388", "0.41828552", "0.41807944", "0.41807944" ]
0.6175277
3
Gets the first TLV of a given type.
def get_tlv(type, index = 0) type_tlvs = get_tlvs(type) if (type_tlvs.length > index) return type_tlvs[index] end return nil end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_tlv_value(type, index = 0)\n\t\ttlv = get_tlv(type, index)\n\n\t\treturn (tlv != nil) ? tlv.value : nil\n\tend", "def get_tlv_value(type, index = 0)\n\t\ttlv = get_tlv(type, index)\n\n\t\treturn (tlv != nil) ? tlv.value : nil\n\tend", "def by_t(type)\n return self.find_all{|slot| slot.type == type}[0]\n end", "def type\n types.first\n end", "def type\n types.first\n end", "def type(type)\n types.each { |t| return t if t.id =~ /^#{Regexp.escape(type)}$/}\n nil\n end", "def get_tlv_values(type)\n\t\tget_tlvs(type).collect { |a| a.value }\n\tend", "def get_tlv_values(type)\n\t\tget_tlvs(type).collect { |a| a.value }\n\tend", "def first_stream_of( type )\n streams.each do |stream| return stream if stream.type == type end\n return nil\n end", "def has_tlv?(type)\n\t\treturn get_tlv(type) != nil\n\tend", "def has_tlv?(type)\n\t\treturn get_tlv(type) != nil\n\tend", "def add_tlv(type, value = nil, replace = false)\n\t\ttlv = nil\n\n\t\t# If we should replace any TLVs with the same type...remove them first\n\t\tif (replace)\n\t\t\teach(type) { |tlv|\n\t\t\t\tif (tlv.type == type)\n\t\t\t\t\tself.tlvs.delete(tlv)\n\t\t\t\tend\n\t\t\t}\n\t\tend\n\n\t\tif (type & TLV_META_TYPE_GROUP == TLV_META_TYPE_GROUP)\n\t\t\ttlv = GroupTlv.new(type)\n\t\telse\n\t\t\ttlv = Tlv.new(type, value)\n\t\tend\n\n\t\tself.tlvs << tlv\n\n\t\treturn tlv\n\tend", "def pluck_sir_trevor_type(json, type) \n hash = JSON.parse(json)\n if hash.has_key?(\"data\")\n item = hash[\"data\"].select { |item| item[\"type\"] == type }\n item.first\n end\n end", "def get_type(type)\n TYPES[type.downcase]\n end", "def get_tlvs(type)\n\t\tif (type == TLV_TYPE_ANY)\n\t\t\treturn self.tlvs\n\t\telse\n\t\t\ttype_tlvs = []\n\n\t\t\tself.tlvs.each() { |tlv|\n\t\t\t\tif (tlv.type?(type))\n\t\t\t\t\ttype_tlvs << tlv\n\t\t\t\tend\n\t\t\t}\n\n\t\t\treturn type_tlvs\n\t\tend\n\tend", "def get_tlvs(type)\n\t\tif (type == TLV_TYPE_ANY)\n\t\t\treturn self.tlvs\n\t\telse\n\t\t\ttype_tlvs = []\n\n\t\t\tself.tlvs.each() { |tlv|\n\t\t\t\tif (tlv.type?(type))\n\t\t\t\t\ttype_tlvs << tlv\n\t\t\t\tend\n\t\t\t}\n\n\t\t\treturn type_tlvs\n\t\tend\n\tend", "def add_tlv(type, value = nil, replace = false, compress=false)\n\n\t\t# If we should replace any TLVs with the same type...remove them first\n\t\tif (replace)\n\t\t\teach(type) { |tlv|\n\t\t\t\tif (tlv.type == type)\n\t\t\t\t\tself.tlvs.delete(tlv)\n\t\t\t\tend\n\t\t\t}\n\t\tend\n\n\t\tif (type & TLV_META_TYPE_GROUP == TLV_META_TYPE_GROUP)\n\t\t\ttlv = GroupTlv.new(type)\n\t\telse\n\t\t\ttlv = Tlv.new(type, value, compress)\n\t\tend\n\n\t\tself.tlvs << tlv\n\n\t\treturn tlv\n\tend", "def get_type(addr_results, type)\n addr_results.select { |comp| comp[\"types\"].index(type) != nil }.map { |comp| comp[\"long_name\"] }.first\n end", "def decode_tlv(data)\n raise OutOfData if (data.length == 2 && data[1].ord != 0) || data.length < 2\n tag = data[0].ord\n length = data[1].ord\n if length < 0x80\n value = data[2, length]\n remainder = data[length+2..-1]\n else\n # ASN.1 says this octet can't be 0xff\n raise InvalidLength, length.to_s if length == 0xff\n num_octets = length & 0x7f\n length = build_integer(data, 2, num_octets)\n value = data[num_octets+2, length]\n remainder = data[num_octets+2+length..-1]\n end\n return tag, value, remainder\n end", "def [](type)\r\n @types.fetch type, nil\r\n end", "def singleton_type\n if !is_singleton?\n raise AssertionError.new(\n \"Union type is not singleton (found #{@types.size} types)\")\n end\n\n return @types.first\n end", "def container_element(type)\n val = text(data.at_xpath(\"/c/did/container[@type='#{type}']\"))\n \"#{type.capitalize} #{val.first}\" if val\n end", "def type_name_by_id(type_id)\n unless where(:id => type_id).empty?\n where(:id => type_id).first.name\n end\n end", "def get_response_of_type(type)\n type = type.split('_').map(&:capitalize).join\n\n loop do\n response = get_message\n return response if response.class.name.demodulize == type\n end\n end", "def type(type)\n select { |node| node.type == type }\n end", "def find_by_type(type)\n find{|contact_detail|\n contact_detail[:type] == type\n }.try{|contact_detail|\n contact_detail[:value]\n }\n end", "def type\n response[\"type\"]\n end", "def type\n response[\"type\"]\n end", "def first\n @first ||= VcfGenotypeField.new(@fields[9],format,@header,ref,alt)\n end", "def type(type)\n select { |node| node.type.equal?(type) }\n end", "def getCSharpType( type )\n\n entry = $typeTable.select{ |a| a.first == type }\n if( entry.empty? )\n return nil\n end\n return entry[0]\nend", "def type\n self['type']['type']\n end", "def get(typename)\n if type = types[typename.to_str]\n type\n else\n raise NotFound, \"no type #{typename} in #{self}\"\n end\n end", "def type\n return @type if @type != \"unknown\"\n info\n @type\n end", "def tag_value(type)\n pattern = reserved_patterns[type]\n tag = tags.detect { |t| t.match?(pattern) }\n return unless tag\n\n tag.match(pattern)[type]\n end", "def type\n content.split(' ', 2).first\n end", "def find_first_ancestor(type)\n ancestors.find{|a| a.is_a?(type) }\n end", "def _read_type(length, typename)\n bytes = @io.read(length)\n\n raise EOFError, \"Unexpected EOF reading #{typename}\" \\\n if bytes.nil? || bytes.length != length\n\n bytes\n end", "def type\n _type rescue nil\n end", "def find_by_type( type )\n\t\t\treturn @messages[ type ]\n\t\tend", "def type_code\n type.try(:code)\n end", "def first()\n @tiers.each do |tier|\n unless tier.empty?()\n return tier[0]\n end\n end\n \n return nil\n end", "def type\n self.attributes[:type]\n end", "def find_type(type_spec)\n if type_spec.is_a?(TyRaw) && (typaram = @data[:typarams][type_spec.name])\n typaram\n else\n check_type_exists(type_spec)\n type_spec\n end\n end", "def get_vehicle(type)\n vehicle = @list_vehicles[type]\n #raise exception if vehicle is not in the list\n if vehicle == nil\n raise Exception.new(\"Vehicle is Nil ,We cannot found it\")\n end\n return vehicle\n end", "def get_by_type(type, cookie_or_cookies = nil)\n add_cookie_to_http_header(cookie_or_cookies)\n return @client.get(\"#{@resource_uri}/type/#{type}\")\n end", "def type()\n\t\t@db.hget('sgt-structure:' + @id, 'type')\n\tend", "def type\n TYPES[self[:type_flags] & 0x3]\n end", "def child(type=nil)\n c = children(type)[0]\n end", "def type\n @attributes[:type]\n end", "def type_for(type)\n case\n when type.nil?\n Spira::Types::Any\n when type.is_a?(Symbol) || type.is_a?(String)\n type\n when Spira.types[type]\n Spira.types[type]\n else\n raise TypeError, \"Unrecognized type: #{type}\"\n end\n end", "def type_for(type) \n case\n when type.nil?\n Spira::Types::Any\n when type.is_a?(Symbol) || type.is_a?(String)\n type\n when !(Spira.types[type].nil?)\n Spira.types[type]\n else\n raise TypeError, \"Unrecognized type: #{type}\"\n end\n end", "def sub_type\n @sub_type || parse_and_return(:@sub_type)\n end", "def type\n @attributes[:type]\n end", "def type\n @attributes[:type]\n end", "def type\n @attributes[:type]\n end", "def content_by_type(essence_type)\n contents_by_type(essence_type).first\n end", "def type\n raw_data['type']\n end", "def extract_base_type(type)\n if type.base_type\n extract_base_type(type.base_type)\n else\n type\n end\n end", "def get(type_name)\n @types ||= {}\n register_default unless @types['document']\n\n type = @types[type_name]\n raise RuntimeError, \"Unknown Type #{type} (know #{@types.keys.join(',')})\" unless type\n\n type\n end", "def my_type(type)\n case type\n when /bond/i\n \"Bonds\"\n when /stock/i\n \"Stocks\"\n when /alternative/i\n \"Alternatives\"\n else\n \"Unclassified\"\n end\n end", "def type\r\n\t\t\t`#{BITS::BITSADMIN} /gettype {#{@id}}`\r\n\t\tend", "def describe(type)\n @doc.xpath(\"//#{type}\").first\n end", "def describe(type)\n @doc.xpath(\"//#{type}\").first\n end", "def type\n attr_val('./@typeCode')\n end", "def type\n @payload['type']\n end", "def first_subfield_value(tag)\n sf = @field.subfields.select { |sf| sf.code == tag}\n return '' if sf.empty?\n sf.first.value\n end", "def each(type = TLV_TYPE_ANY, &block)\n\t\tget_tlvs(type).each(&block)\n\tend", "def each(type = TLV_TYPE_ANY, &block)\n\t\tget_tlvs(type).each(&block)\n\tend", "def type\n\t\t\t@data[\"type\"]\n\t\tend", "def type\n @type ||= IDS_TYPES[type_id]\n end", "def find_first(selector, data)\n data = @data unless data\n results = (data/selector)\n if results and results.first\n results.first.inner_html.strip\n else\n nil\n end\n end", "def tlv_select\n info 'os10_lldp_interface::tlv select'\n begin\n lldp_interface_data = @tlv_ret[:stdout].split(\"\\n\")\n temp_data = {}\n\n lldp_interface_data.each do |data|\n if data.include? 'lldp tlv-select'\n tlv_data = data.split(' ')\n if tlv_data.length == 4\n temp_data[tlv_data[3]] = [' ']\n elsif temp_data[tlv_data[3]].nil? && tlv_data.length >= 4\n temp_data[tlv_data[3]] = [tlv_data[4]]\n elsif tlv_data[4]\n temp_data[tlv_data[3]] = temp_data[tlv_data[3]] << tlv_data[4]\n temp_data[tlv_data[3]] = temp_data[tlv_data[3]].sort\n end\n end\n end\n return temp_data\n rescue Exception => e\n err 'Exception in tlv select'\n err e.message\n err e.backtrace[0]\n raise\n end\n end", "def initialize(type, value = nil)\n\t\t@type = type\n\t\t\n\t\tif (value != nil)\n\t\t\tif (type & TLV_META_TYPE_STRING == TLV_META_TYPE_STRING)\n\t\t\t\tif (value.kind_of?(Fixnum))\n\t\t\t\t\t@value = value.to_s\n\t\t\t\telse\n\t\t\t\t\t@value = value.dup\n\t\t\t\tend\n\t\t\telse\n\t\t\t\t@value = value\n\t\t\tend\n\t\tend\n\tend", "def find_basic_type(key)\n only_basic_type(key) || key\n end", "def type\n read_attribute(:type) || Figaro.env.meal_types.split.first\n end", "def type\n @node[\"type\"] || \"text\"\n end", "def type\n type_and_version[0]\n end", "def get_first\n return nil if head.nil?\n return head.data\n end", "def type\n @json['type']\n end", "def type\n TYPES[@type_id]\n end", "def read(type = :byte, opt = { signed: false, mutation: :STD, order: :BIG })\n return unless RuneRb::Network::Message.validate(self, :read, opt)\n\n case type\n when *RW_TYPES[:byte] then read_byte(opt[:signed] || false, opt[:mutation] || :STD)\n when *RW_TYPES[:short] then read_short(opt[:signed] || false, opt[:mutation] || :STD, opt[:order] || :BIG)\n when *RW_TYPES[:medium] then read_medium(opt[:signed] || false, opt[:mutation] || :STD, opt[:order] || :BIG)\n when *RW_TYPES[:int] then read_int(opt[:signed] || false, opt[:mutation] || :STD, opt[:order] || :BIG)\n when *RW_TYPES[:long] then read_long(opt[:signed] || false, opt[:mutation] || :STD, opt[:order] || :BIG)\n when *RW_TYPES[:string] then read_string\n when :bytes then read_bytes(opt[:amount], opt[:mutation])\n when :reverse_bytes, :negative_bytes, :reverse, :negatives then read_bytes_reverse(opt[:amount] || opt[:length], opt[:mutation])\n when :io, :socket then read_from(opt[:io] || opt[:source] || opt[:socket], opt[:length])\n when :header then read_header(opt[:source])\n else raise \"Unrecognized read type! #{type}\"\n end\n end", "def peek_next_type\n peek_next.type\n end", "def type\n @data['type']\n end", "def first(c)\n if c and c.class == String\n return c\n elsif c and c.length > 0 \n return c[0]\n else\n return nil\n end\nend", "def label(type = N::RDFS::label)\n labels(type)[0]\n end", "def label(type = N::RDFS::label)\n labels(type)[0]\n end", "def type\n @attributes.fetch('type', nil)\n end", "def itemtype\n types = resource_type || []\n ResourceTypesService.microdata_type(types.first)\n end", "def get_type\n\n end", "def get_first\n return head ? head.data : nil\n end", "def peektype\n (peek || '')[0]\n end", "def type\n @type.name\n end", "def type\n @data['type']\n end", "def type\n @types ||= strip(:type)\n end", "def get(type, id)\n case type.to_sym\n when :blob then grit.blob(id)\n when :tree then grit.tree(id)\n when :commit then grit.commit(id)\n when :tag\n \n object = grit.git.ruby_git.get_object_by_sha1(id)\n if object.type == :tag \n Grit::Tag.new(object.tag, grit.commit(object.object))\n else\n nil\n end\n \n else raise \"unknown type: #{type}\"\n end\n end", "def type\n return @type\n end", "def sub_type\n has_content_type? ? header[:content_type].sub_type : nil rescue nil\n end", "def fuel_type\n fetch('vehicle.fuel_types')\n end" ]
[ "0.6748661", "0.6748661", "0.6053849", "0.5868394", "0.5867666", "0.5590036", "0.5545002", "0.5545002", "0.55343395", "0.551295", "0.551295", "0.5489713", "0.54462934", "0.5434431", "0.5429876", "0.5429876", "0.5332865", "0.5319422", "0.52711165", "0.52538824", "0.52532554", "0.52283746", "0.5222703", "0.52114064", "0.51710224", "0.513919", "0.5134878", "0.5134878", "0.51339024", "0.5101799", "0.5094826", "0.5088475", "0.506922", "0.5056327", "0.5054348", "0.50532544", "0.5014305", "0.5006988", "0.50026727", "0.49568775", "0.4953312", "0.49351725", "0.4928994", "0.49284762", "0.49263978", "0.49221182", "0.49048766", "0.48988914", "0.48835066", "0.48715177", "0.48681456", "0.485205", "0.48486084", "0.48479536", "0.48479536", "0.48479536", "0.48466188", "0.48392332", "0.48358893", "0.48343828", "0.48265478", "0.48262766", "0.48242742", "0.4823827", "0.48074114", "0.48045963", "0.48039803", "0.47971606", "0.47971606", "0.4787879", "0.47738537", "0.47732064", "0.47680578", "0.47600117", "0.47579318", "0.4744272", "0.47418806", "0.4739456", "0.4738693", "0.47375527", "0.47365814", "0.47332713", "0.4732356", "0.47274038", "0.4725995", "0.47243983", "0.47104284", "0.47068378", "0.4704181", "0.47041726", "0.4701224", "0.46939278", "0.46930537", "0.46795714", "0.46777257", "0.46749312", "0.46655273", "0.466222", "0.4657288" ]
0.7892362
1
Returns the value of a TLV if it exists, otherwise nil.
def get_tlv_value(type, index = 0) tlv = get_tlv(type, index) return (tlv != nil) ? tlv.value : nil end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_tlv(type, index = 0)\n\t\ttype_tlvs = get_tlvs(type)\n\n\t\tif (type_tlvs.length > index)\n\t\t\treturn type_tlvs[index]\n\t\tend\n\n\t\treturn nil\n\tend", "def get_tlv(type, index = 0)\n\t\ttype_tlvs = get_tlvs(type)\n\n\t\tif (type_tlvs.length > index)\n\t\t\treturn type_tlvs[index]\n\t\tend\n\n\t\treturn nil\n\tend", "def try_read\n v = @tvar.value\n v == EMPTY ? nil : v\n end", "def has_tlv?(type)\n\t\treturn get_tlv(type) != nil\n\tend", "def has_tlv?(type)\n\t\treturn get_tlv(type) != nil\n\tend", "def decode_tlv(data)\n raise OutOfData if (data.length == 2 && data[1].ord != 0) || data.length < 2\n tag = data[0].ord\n length = data[1].ord\n if length < 0x80\n value = data[2, length]\n remainder = data[length+2..-1]\n else\n # ASN.1 says this octet can't be 0xff\n raise InvalidLength, length.to_s if length == 0xff\n num_octets = length & 0x7f\n length = build_integer(data, 2, num_octets)\n value = data[num_octets+2, length]\n remainder = data[num_octets+2+length..-1]\n end\n return tag, value, remainder\n end", "def get_tag_value(key)\n get_tag(key).try(:tag_value).try(:value)\n end", "def get_tag_value (tag_path, fetch_datatype=false)\n\n $test_logger.log(\"Get tag value #{tag_path}\")\n\n raise \"XML doc not loaded\" if @xml_ilv_node == nil\n\n #Get target tag\n target_tag = @xml_ilv_node.root.elements[tag_path]\n\n #Fetch target value\n val = \"\"\n val = target_tag.get_text.value if target_tag && target_tag.get_text\n\n #Get data type for element\n if fetch_datatype\n data_type = ILVMessage.get_type_for_ele(target_tag)\n return val, data_type\n else\n return val\n end\n end", "def first_subfield_value(tag)\n sf = @field.subfields.select { |sf| sf.code == tag}\n return '' if sf.empty?\n sf.first.value\n end", "def get_variant_value(identifier)\n data = Gxapi.with_error_handling do\n Timeout::timeout(2.0) do\n Gxapi.cache.fetch(self.cache_key(identifier)) do\n @interface.get_variant(identifier).to_hash\n end\n end\n end\n Ostruct.new(\n data.is_a?(Hash) ? data : self.default_values\n )\n end", "def get_value name=nil\n @value\n end", "def value\n case object_type\n when Constants::ASN_OCTET_STR, Constants::ASN_OPAQUE\n struct.val[:string].read_string(struct.val_len)\n when Constants::ASN_INTEGER\n struct.val[:integer].read_long\n when Constants::ASN_UINTEGER, Constants::ASN_TIMETICKS, Constants::ASN_COUNTER, Constants::ASN_GAUGE\n struct.val[:integer].read_ulong\n when Constants::ASN_IPADDRESS\n struct.val[:objid].read_string(struct.val_len).unpack('CCCC').join(\".\")\n when Constants::ASN_NULL\n nil\n when Constants::ASN_OBJECT_ID\n Net::SNMP::OID.from_pointer(struct.val[:objid], struct.val_len / OID.oid_size)\n when Constants::ASN_COUNTER64\n counter = Wrapper::Counter64.new(struct.val[:counter64])\n counter.high * 2^32 + counter.low\n when Constants::ASN_BIT_STR\n # XXX not sure what to do here. Is this obsolete?\n when Constants::SNMP_ENDOFMIBVIEW\n :endofmibview\n when Constants::SNMP_NOSUCHOBJECT\n :nosuchobject\n when Constants::SNMP_NOSUCHINSTANCE\n :nosuchinstance\n else\n raise Net::SNMP::Error.new, \"Unknown value type #{object_type}\"\n end\n end", "def method_missing(m, *args, &block)\n return nil if @is_empty\n if m =~ /\\?$/\n # query if a value exists, e.g., r.info.dp? or s.dp?\n v = values[fetch(m.to_s.upcase.chop)]\n return (not VcfValue::empty?(v))\n else\n v = values[fetch(m.to_s.upcase)]\n return nil if VcfValue::empty?(v)\n v = v.to_i if v =~ /^\\d+$/\n v = v.to_f if v =~ /^\\d+\\.\\d+$/\n v\n end\n end", "def value\n return nil if @value.is_a? NilPlaceholder\n @value.nil? ? deserialize_value : @value\n end", "def get_value(value_type)\n data = @form.get_data(value_type)\n if data == nil\n return nil\n end\n\n if get_data_type == TYPE_SEPARATOR\n return nil\n end\n\n result = nil\n\n if value_type == GenericForm::VALUE_TYPE_LIVE || value_type == GenericForm::VALUE_TYPE_SAVED || value_type == GenericForm::VALUE_TYPE_VOLATILE\n begin\n field_config = get_field_config[\"yml_key\"]\n if field_config.kind_of?(Array)\n value = eval(\"data\" + field_config[0])\n else\n value = eval(\"data\" + field_config)\n end\n rescue => ex\n $logger.error(\"Error evaluating field '#{html_form_id}' - #{ex.message}: #{ex.backtrace}\")\n raise \"Error evaluating field '#{html_form_id}'\"\n end\n exotic_value = get_exotic_value(value, value_type)\n result = exotic_value != nil ? exotic_value : value\n elsif value_type == GenericForm::VALUE_TYPE_FORM\n value = data[html_form_id]\n if get_data_type == TYPE_BOOLEAN\n value = value == nil ? false : true\n elsif get_data_type == TYPE_NUMERIC\n value = value.to_i\n end\n result = value\n else\n raise \"Unknown value type '#{value_type}'\"\n end\n\n result = '' if result == nil\n\n if result.is_a? String\n result.strip!\n end\n\n result\n end", "def get(*args)\n val = args.empty? ? self : retrieve(*args)\n val == NO_VALUE ? nil : val\n end", "def value\n virtual? ? content : value_card&.value\nend", "def value_type\n value_type_card&.first_name || default_value_type_code.cardname\nend", "def get_if_kind value, kind\n value.kind_of?(kind) && value || nil\n end", "def get_if_kind value, kind\n value.kind_of?(kind) && value || nil\n end", "def method_missing(name, *args)\n obj = find(name.to_s)\n if obj\n return obj.value\n else\n return nil\n end\n end", "def get_tlv_values(type)\n\t\tget_tlvs(type).collect { |a| a.value }\n\tend", "def get_tlv_values(type)\n\t\tget_tlvs(type).collect { |a| a.value }\n\tend", "def getValue(value)\n return nil if value==nil \n return value\nend", "def get_value val=nil\n if @klass == 'String'\n return @value\n elsif @klass == 'Hash'\n return @value[val]\n elsif @klass == 'Array'\n return @value[val]\n else\n return @value\n end\n end", "def get(key)\n self.data[key] && self.data[key][:value]\n end", "def result\n\t\treturn get_tlv_value(TLV_TYPE_RESULT)\n\tend", "def result\n\t\treturn get_tlv_value(TLV_TYPE_RESULT)\n\tend", "def get_value(name)\n val_arr = @ldap_entry[name]\n return val_arr if val_arr.empty?\n #\n val_arr.size == 1 ? val_arr.first : val_arr\n end", "def tag_value(type)\n pattern = reserved_patterns[type]\n tag = tags.detect { |t| t.match?(pattern) }\n return unless tag\n\n tag.match(pattern)[type]\n end", "def get_value(item, key, default: nil, **)\n return if key.blank?\n if key.is_a?(Array)\n key.find { |k| (v = get_value(item, k)) and break v }\n elsif item.respond_to?(key)\n item.send(key)\n elsif item.respond_to?(:emma_metadata) # Upload, etc.\n item.emma_metadata&.dig(key.to_sym)\n elsif item.is_a?(Hash)\n item[key.to_sym] || item[key.to_s]\n end.presence || default\n end", "def parse_value(hash)\n case hash['type']\n when 'literal'\n parse_literal(hash)\n when 'uri'\n parse_uri(hash)\n when 'bnode'\n nil\n else\n fail ArgumentError, \"Unidentifieble datatype: #{hash['type']} in #{hash}\"\n end\n end", "def get\n data[\"_value\"]\n end", "def try_take\n v = @tvar.value\n return nil if v == EMPTY\n\n @tvar.value = EMPTY\n v\n end", "def get_value name\n get name\n end", "def get_value(property_path)\n element = @tree.select(property_path)[0]\n element.nil? ? nil : element.value\n end", "def getvalue\n @variable.get_value @name\n end", "def get(key)\n node = get_rec(@root, key, 0)\n return nil if node.nil?\n return node.value\n end", "def from_r(raw)\n\t\tself.value = nil\n\n\t\tlength, self.type = raw.unpack(\"NN\");\n\n\t\t# check if the tlv value has been compressed...\n\t\tif( self.type & TLV_META_TYPE_COMPRESSED == TLV_META_TYPE_COMPRESSED )\n\t\t\t# set this TLV as using compression\n\t\t\t@compress = true\n\t\t\t# remove the TLV_META_TYPE_COMPRESSED flag from the tlv type to restore the \n\t\t\t# tlv type to its origional, allowing for transparent data compression.\n\t\t\tself.type = self.type ^ TLV_META_TYPE_COMPRESSED\n\t\t\t# decompress the compressed data (skipping the length and type DWORD's)\n\t\t\traw_decompressed = Rex::Text.zlib_inflate( raw[8..length-1] )\n\t\t\t# update the length to reflect the decompressed data length (+8 for the length and type DWORD's)\n\t\t\tlength = raw_decompressed.length + 8\n\t\t\t# update the raw buffer with the new length, decompressed data and updated type.\n\t\t\traw = [length, self.type].pack(\"NN\") + raw_decompressed\n\t\tend\n\t\t\n\t\tif (self.type & TLV_META_TYPE_STRING == TLV_META_TYPE_STRING)\n\t\t\tif (raw.length > 0)\n\t\t\t\tself.value = raw[8..length-2]\n\t\t\telse\n\t\t\t\tself.value = nil\n\t\t\tend\n\t\telsif (self.type & TLV_META_TYPE_UINT == TLV_META_TYPE_UINT)\n\t\t\tself.value = raw.unpack(\"NNN\")[2]\n\t\telsif (self.type & TLV_META_TYPE_BOOL == TLV_META_TYPE_BOOL)\n\t\t\tself.value = raw.unpack(\"NNc\")[2]\n\n\t\t\tif (self.value == 1)\n\t\t\t\tself.value = true\n\t\t\telse\n\t\t\t\tself.value = false\n\t\t\tend\n\t\telse\n\t\t\tself.value = raw[8..length-1]\n\t\tend\n\n\t\treturn length;\n\tend", "def get(key)\n position = find(key)\n if position != nil\n @values[position]\n else\n nil\n end\n end", "def med_tlv_select_inventory\n info 'os10_lldp_interface::med tlv select inventory'\n begin\n @lldp_interface_med_cfg = @lldp_intf[:'lldp-med-cfg'] || {}\n @lldp_interface_med_tlv = @lldp_interface_med_cfg[:'tlvs-tx-enable'] || {}\n return @lldp_interface_med_tlv[:inventory] || ''\n rescue Exception => e\n err 'Exception in med tlv select inventory'\n err e.message\n err e.backtrace[0]\n raise\n end\n end", "def get_tagvalue(object, tagkey)\n value = \"\"\n if object[:tag_set]\n object[:tag_set].each do |tag|\n if tag[:key] == tagkey\n value = tag[:value]\n break\n end\n end\n end\n \n value\n end", "def value\n nil\n end", "def value\n nil\n end", "def getvalue\n #@text_variable && @text_variable.value || @text\n @text\n end", "def getvalue\n #@text_variable && @text_variable.value || @text\n @text\n end", "def read(key)\n exists?(key) ? @data[key] : nil\n end", "def get_tag_value tag_key_name\n tag = self.tags.joins(:tag_key).where('tagging_tag_keys.name = ?', tag_key_name).includes(:tag_value).first\n tag.try(:tag_value).try(:value)\n end", "def value\n ptr = ffi_delegate.value\n return '' if ptr.null? # NOTE: for root elements\n\n ptr.read_string\n end", "def value\n nil\n end", "def value\n nil\n end", "def value\n case tag_name\n when \"select\"\n if self[:multiple]\n selected_options.map { |option| option.value }\n else\n selected_option = @_node.selected_options.first\n selected_option ? Node.new(selected_option).value : nil\n end\n when \"option\"\n self[:value] || text\n when \"textarea\"\n @_node.getText\n else\n self[:value]\n end\n end", "def variant\n return nil if variants?\n variants.first\n end", "def get_value\r\n @bitstring\r\n end", "def get_value(section, key)\n if section.nil?\n raise TypeError.new('nil not allowed')\n end\n section = 'default' if section.empty?\n get_key_string(section, key)\n end", "def get_erb_value(provision, value)\n template = ERB.new value\n ret = template.result(provision._binding)\n\n raise \"#{value} not found.\" if ret.empty?\n\n ret\n end", "def tlv_select\n info 'os10_lldp_interface::tlv select'\n begin\n lldp_interface_data = @tlv_ret[:stdout].split(\"\\n\")\n temp_data = {}\n\n lldp_interface_data.each do |data|\n if data.include? 'lldp tlv-select'\n tlv_data = data.split(' ')\n if tlv_data.length == 4\n temp_data[tlv_data[3]] = [' ']\n elsif temp_data[tlv_data[3]].nil? && tlv_data.length >= 4\n temp_data[tlv_data[3]] = [tlv_data[4]]\n elsif tlv_data[4]\n temp_data[tlv_data[3]] = temp_data[tlv_data[3]] << tlv_data[4]\n temp_data[tlv_data[3]] = temp_data[tlv_data[3]].sort\n end\n end\n end\n return temp_data\n rescue Exception => e\n err 'Exception in tlv select'\n err e.message\n err e.backtrace[0]\n raise\n end\n end", "def read\n v = @tvar.value\n raise Ractor::RetryTransaction if v == EMPTY\n\n v\n end", "def variant\r\n return nil if variants?\r\n variants.first\r\n end", "def value\n return @value unless @value.nil?\n @value = string.data\n @value\n end", "def subfield_value(field, subfield)\n sub = field.subfields.find {|s| s.code == subfield}\n if sub.nil?\n return nil\n end\n sub.value\nend", "def find(key)\n node = find_node(key)\n (node == nil ? nil : node.value)\n end", "def get(key)\n node = _get(@root, key)\n return nil unless node\n node.value\n end", "def value\n json[\"value\"] || json[\"$t\"]\n end", "def value\r\n \tbase_value = read_attribute('value')\r\n \t#\r\n \tif ! base_value.nil?\r\n \treturn YAML::load(base_value)\r\n end\r\n return nil\r\n\tend", "def presence\n blank? ? nil : @value\n end", "def get_value\n send_request(FUNCTION_GET_VALUE, [], '', 2, 'S')\n end", "def get_value(data, key)\n if data.has_key?(key) == false || data[key].nil? || data[key] == []\n return ''\n end\n value = data[key]\n if value.is_a?(Array)\n return value[0]\n end\n return value\n end", "def get_variable( var_name)\n\t\tvar = Vim::evaluate(\n\t\t\t\"exists(\\\"#{var_name}\\\") ? #{var_name} : \\\"__NIL__\\\"\"\n\t\t)\n\n\t\tvar == '__NIL__' ? nil : var\n\tend", "def get_token(tag, tokens)\n tokens.each do |key, value|\n if tag.index(key) != nil then\n return value\n end\n end\n\n return nil\n end", "def get\n val\n end", "def get\n val\n end", "def fetch_value( oid, key )\n\t\toid = normalize_oid( oid )\n\t\tkey = normalize_key( key )\n\t\tdata = @storage[ oid ] or return nil\n\n\t\treturn data[ key ]\n\tend", "def lookup_value (workitem, options={})\n\n lookup_vf_attribute(workitem, 'value', options) ||\n lookup_vf_attribute(workitem, 'val', options)\n end", "def get_value_for(room)\n rooms = {:heating => LocalizeHelper::get_string(:Central_heating),\n :bathroom => LocalizeHelper::get_string(:Own_in_appartement), \n :wc => LocalizeHelper::get_string(:Own_in_appartement),\n :warm_water => LocalizeHelper::get_string(:Central) }\n \n if ((rooms.include?(room)) && (self.get_attribute(room) != \"\"))\n return self.get_attribute(room)\n elsif rooms.include?(room)\n return rooms[room]\n end\n end", "def get_value\n read_attribute('text_value')\n end", "def find(key)\n # TODO(himanshujaju) - possible improvement by not checking for contains.\n if contains?(key)\n return @key_data[key].value\n end\n\n return nil\n end", "def get_value(element, label = false, _browser = @browser)\n wait = Selenium::WebDriver::Wait.new(:timeout => 5)\n elem = wait.until { _browser.find_element(:xpath => element) }\n val = nil\n text = nil\n if (label)\n val = elem.find_element(:xpath => \"//option[@selected]\").text\n else\n val = elem.attribute(\"value\")\n text = elem.text\n Log.logger.info(\"Value: #{val} Text: #{text}\")\n end\n return val if text.nil? or text.empty? or (text == val)\n return text\n end", "def to_r\n\t\traw = value.to_s;\n\n\t\tif (self.type & TLV_META_TYPE_STRING == TLV_META_TYPE_STRING)\n\t\t\traw += \"\\x00\"\n\t\telsif (self.type & TLV_META_TYPE_UINT == TLV_META_TYPE_UINT)\n\t\t\traw = [value].pack(\"N\")\n\t\telsif (self.type & TLV_META_TYPE_BOOL == TLV_META_TYPE_BOOL)\n\t\t\tif (value == true)\n\t\t\t\traw = [1].pack(\"c\")\n\t\t\telse\n\t\t\t\traw = [0].pack(\"c\")\n\t\t\tend\n\t\tend\n\t\t\n\t\t# check if the tlv is to be compressed...\n\t\tif( @compress )\n\t\t\traw_uncompressed = raw\n\t\t\t# compress the raw data\n\t\t\traw_compressed = Rex::Text.zlib_deflate( raw_uncompressed )\n\t\t\t# check we have actually made the raw data smaller...\n\t\t\t# (small blobs often compress slightly larger then the origional) \n\t\t\t# if the compressed data is not smaller, we dont use the compressed data\n\t\t\tif( raw_compressed.length < raw_uncompressed.length )\n\t\t\t\t# if so, set the TLV's type to indicate compression is used\n\t\t\t\tself.type = self.type | TLV_META_TYPE_COMPRESSED\n\t\t\t\t# update the raw data with the uncompressed data length + compressed data\n\t\t\t\t# (we include the uncompressed data length as the C side will need to know this for decompression)\n\t\t\t\traw = [ raw_uncompressed.length ].pack(\"N\") + raw_compressed\n\t\t\tend\n\t\tend\n\t\t\n\t\treturn [raw.length + 8, self.type].pack(\"NN\") + raw\n\tend", "def get_vin_by_plate\n vin = VehicleRegistration.get_vin(self.plate, self.plate_state)\n if vin && vin.class == String && vin.length > 8 && vin.length < 20\n self.vin = vin\n else \n return nil\n end \n end", "def value\n nil\n end", "def get_val(xpath, type)\n case type\n when 'int'\n @page.xpath(xpath).text.to_s.gsub(/[[:space:]]/, '').to_i\n when 'bool'\n @page.xpath(xpath).text.strip.downcase == YES\n else\n @page.xpath(xpath).text.strip\n end\n end", "def get_field_value(obj, name)\n begin\n @struct_field_getter.call(obj, name)\n rescue\n 0\n end\n end", "def get_value value\n \n begin\n \n # Debugging:\n #puts \"in get_value: \" + value.to_s\n \n if value.nil? \n rtnval = \"\"\n #puts 'Nil value detected here!'\n end\n \n rescue\n puts \"Some error occurred in get_value, with value = (#{value})\"\n else\n rtnval = value\n end\n \n return rtnval\n\nend", "def getvalue(key)\r\n return @@params[key] if (key != nil)\r\n return nil\r\n end", "def get_node_value (doc, node_name, embed_code)\n\n node_value = doc.get_elements(\"list/item/#{node_name}\")[0].get_text().value rescue nil\n \n if @log && @node_value == nil\n $LOG.info(\"Value not found for: #{node_name}, embed_code: #{embed_code}\") \n end\n\n return node_value\n end", "def get(value)\n value\n end", "def get_value(element)\n\t\t\tif ['input','select','textarea'].include? element.tag_name.downcase\n\t\t\t\telement.attribute('value')\n\t\t\telse\n\t\t\t\telement.text\n\t\t\tend\n\t\tend", "def value\n @value ||= extract_value\n end", "def value (timeout = nil)\n\t\treturn @value if delivered?\n\n\t\t@mutex.synchronize {\n\t\t\tcond.wait(@mutex, *timeout)\n\t\t}\n\n\t\treturn @value if delivered?\n\tend", "def value\n wait_until_exists\n @text_field.value\n end", "def value\n return @value if @value\n result = nil\n return result if @code == nil\n\n starttime = Time.now.to_f\n\n begin\n Timeout.timeout(limit) do\n if @code.is_a?(Proc)\n result = @code.call()\n else\n result = Facter::Util::Resolution.exec(@code)\n end\n end\n rescue Timeout::Error => detail\n Facter.warn \"Timed out seeking value for %s\" % self.name\n\n # This call avoids zombies -- basically, create a thread that will\n # dezombify all of the child processes that we're ignoring because\n # of the timeout.\n Thread.new { Process.waitall }\n return nil\n rescue => details\n Facter.warn \"Could not retrieve %s: %s\" % [self.name, details]\n return nil\n end\n\n finishtime = Time.now.to_f\n ms = (finishtime - starttime) * 1000\n Facter.show_time \"#{self.name}: #{\"%.2f\" % ms}ms\"\n\n return nil if result == \"\"\n return result\n end", "def find_tag_struct(t)\n p = find_tag(t)\n if(p)\n return p.parent_struct\n else\n return nil\n end\n end", "def get_hash_val(name)\n\t\tfetch(name) if has_key?(name)\n\tend", "def get_struct(field)\n field['structValue']\n end", "def get_value(element)\n element.value\n end", "def find_value(value) \n find { |item| item.data == value }\n end", "def value\r\n assert_exists\r\n option_value\r\n end", "def add_tlv(type, value = nil, replace = false)\n\t\ttlv = nil\n\n\t\t# If we should replace any TLVs with the same type...remove them first\n\t\tif (replace)\n\t\t\teach(type) { |tlv|\n\t\t\t\tif (tlv.type == type)\n\t\t\t\t\tself.tlvs.delete(tlv)\n\t\t\t\tend\n\t\t\t}\n\t\tend\n\n\t\tif (type & TLV_META_TYPE_GROUP == TLV_META_TYPE_GROUP)\n\t\t\ttlv = GroupTlv.new(type)\n\t\telse\n\t\t\ttlv = Tlv.new(type, value)\n\t\tend\n\n\t\tself.tlvs << tlv\n\n\t\treturn tlv\n\tend" ]
[ "0.6762493", "0.6762493", "0.6418291", "0.5981156", "0.5981156", "0.58768827", "0.5690261", "0.55697", "0.5522212", "0.5402827", "0.5337459", "0.5290298", "0.528098", "0.5278988", "0.5274449", "0.523043", "0.52296036", "0.5215547", "0.52152973", "0.52152973", "0.51826054", "0.5176784", "0.5176784", "0.5168303", "0.5133035", "0.5112941", "0.5083781", "0.5083781", "0.50658417", "0.50652015", "0.5051075", "0.50396895", "0.50393337", "0.50391185", "0.50288314", "0.5022633", "0.5018704", "0.5005625", "0.5004918", "0.50038415", "0.4991495", "0.49821874", "0.49789485", "0.49789485", "0.4978671", "0.4978671", "0.4974214", "0.49608263", "0.49535412", "0.49404526", "0.49404526", "0.49350542", "0.49340266", "0.49270573", "0.49264434", "0.49252763", "0.49230772", "0.49213764", "0.49181905", "0.49167377", "0.49070498", "0.49049446", "0.49038538", "0.49030307", "0.4901197", "0.4895602", "0.48946807", "0.48887163", "0.48821613", "0.48810726", "0.4866312", "0.4866312", "0.48541412", "0.4851522", "0.48452267", "0.48438388", "0.48428485", "0.4830121", "0.48289198", "0.48196426", "0.4816191", "0.48117188", "0.4805816", "0.4803629", "0.48025972", "0.4801156", "0.4797606", "0.47939047", "0.47890973", "0.47829401", "0.47818512", "0.47790703", "0.47644395", "0.47629288", "0.4761093", "0.4754055", "0.47523895", "0.47488284", "0.47481248" ]
0.72710985
1
Returns an array of values for all tlvs of type type.
def get_tlv_values(type) get_tlvs(type).collect { |a| a.value } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_tlvs(type)\n\t\tif (type == TLV_TYPE_ANY)\n\t\t\treturn self.tlvs\n\t\telse\n\t\t\ttype_tlvs = []\n\n\t\t\tself.tlvs.each() { |tlv|\n\t\t\t\tif (tlv.type?(type))\n\t\t\t\t\ttype_tlvs << tlv\n\t\t\t\tend\n\t\t\t}\n\n\t\t\treturn type_tlvs\n\t\tend\n\tend", "def get_tlvs(type)\n\t\tif (type == TLV_TYPE_ANY)\n\t\t\treturn self.tlvs\n\t\telse\n\t\t\ttype_tlvs = []\n\n\t\t\tself.tlvs.each() { |tlv|\n\t\t\t\tif (tlv.type?(type))\n\t\t\t\t\ttype_tlvs << tlv\n\t\t\t\tend\n\t\t\t}\n\n\t\t\treturn type_tlvs\n\t\tend\n\tend", "def all\n all_by_type.values.flatten\n end", "def each(type = TLV_TYPE_ANY, &block)\n\t\tget_tlvs(type).each(&block)\n\tend", "def each(type = TLV_TYPE_ANY, &block)\n\t\tget_tlvs(type).each(&block)\n\tend", "def values\n enumerations.dig(type, :values)\n end", "def vans_collection\n collection = []\n vans.map(&:type).uniq.each { |type| collection << [type.to_sym, Van::TYPE[type.to_sym]] }\n collection\n end", "def get_types(type)\n result = []\n types = TYPE_CONVERSION_TREE[type]\n if types\n result += types\n types.each do |t|\n result |= get_types(t)\n end\n end\n result\n end", "def return_trains_by_type(type)\n (@trains_list.map { |a| a if a.type == type }).compact\n end", "def each\n @type_variants.values.each { |tv| tv.each { |t| yield t } }\n end", "def index\n @type_of_values = TypeOfValue.all\n end", "def getValues\n values = []\n values << @layerTC.get_value()\n values << @densTC.get_value().to_f\n return values\n end", "def values\n @values ||= self == Enum ? nil : begin\n connection.enum_values(type_name).freeze\n end\n end", "def patterns_for_type(type_)\n @mutex.synchronize do\n typedata_ = @types[type_]\n typedata_ ? typedata_.dup : []\n end\n end", "def each_with_index(type = TLV_TYPE_ANY, &block)\n\t\tget_tlvs(type).each_with_index(&block)\n\tend", "def each_with_index(type = TLV_TYPE_ANY, &block)\n\t\tget_tlvs(type).each_with_index(&block)\n\tend", "def values\n to_enum(:each_value).to_a\n end", "def all_by_name_and_type(name, type)\n where(name: name, array_type: type).order_by(&:array_index).to_a\n end", "def get_array_values(init,type)\n if type == \"fecha\"\n final = Time.new.year\n unidad = \"\"\n elsif type == \"rango\"\n final = 5000\n unidad = \"m2\"\n elsif type == \"aforo\"\n final = 500\n unidad = \"\"\n end\n array_ = []\n\n #((final.to_i).downto(Integer(init))).each do |n|\n (Integer(init)..(final.to_i)).each do |n|\n array_ << \"#{n}#{unidad}\"\n end\n return array_\n end", "def to_tsvectors\n []\n end", "def convert_to(ary, type)\n new = []\n ary.each_index do |row|\n new << ary[row].collect {|elem| elem.send(type)}\n end\n new\n end", "def getValues\n values = []\n values << @cityTC.get_value()\n values << @countryTC.get_value()\n values << @latTC.get_value().to_f\n values << @longTC.get_value().to_f\n values << @tzChoices[@tzC.get_selection()].to_f\n values << @elevTC.get_value().to_f\n if ($DS_VERSION == '2.1')\n values << @northTC.get_value().to_f\n values << (@snC.get_selection == 0) ? true : false\n else\n values << 0\n values << false\n end\n return values\n end", "def Array(type)\n Strict(::Array).of(type)\n end", "def values\n []\n end", "def entries\n ary = []\n self.each{|*val|\n # __svalue is an internal method\n ary.push val.__svalue\n }\n ary\n end", "def components_with_type(type)\n array = []\n @components.each_value do |c|\n array << c.proxy.name if c.proxy.respond_to?(:has_type?) &&\n c.proxy.has_type?(type)\n end\n array\n end", "def to_a\n self.sort_by{|l| l.type}.map{|l| l.to_s}\n end", "def types\n @data.keys & TYPES\n end", "def values\n list = []\n each_value{|value| list << value}\n list\n end", "def types\n @types ||= []\n end", "def get_task_types_eng\n [\"vat_jan\", \"vat_mar\", \"vat_may\", \"vat_jul\", \"vat_sept\", \"vat_nov\", \"voucher\", \"income_tax\"]\n end", "def find_by_type(types)\n matches = []\n matches << self if to_type == types\n @value.each do |v|\n matches += v.find_by_type(types) if v.respond_to?(:find_by_type)\n end\n matches\n end", "def category_types\n @category_types.each\n end", "def stat_hash(*type)\n\n if type === []\n type = @type \n end \n\n return type.map {|t| @raw[t]}\n\n end", "def getValues\n values = []\n values << @dvChoices[@dvC.get_selection()]\n values << @logChoices[@logC.get_selection()].to_i\n values << (@triC.get_selection == 0) ? true : false\n unit = @unitTC.get_value().to_f\n if unit != 0\n values << unit\n else\n printf \"unit setting not a number(#{@unitTC.get_value()}) => ignored\\n\"\n values << $UNIT\n end\n values << @sdTC.get_value()\n values << (@ulC.get_selection == 0) ? true : false\n values << @dbTC.get_value()\n values << @mdTC.get_value()\n\n return values\n end", "def add_tlvs(tlvs)\n\t\tif (tlvs != nil)\n\t\t\ttlvs.each { |tlv|\n\t\t\t\tadd_tlv(tlv['type'], tlv['value'])\n\t\t\t}\n\t\tend\n\tend", "def add_tlvs(tlvs)\n\t\tif (tlvs != nil)\n\t\t\ttlvs.each { |tlv|\n\t\t\t\tadd_tlv(tlv['type'], tlv['value'])\n\t\t\t}\n\t\tend\n\tend", "def all(*types); end", "def get_variable\n result = Array.new\n if @node_type == :lval\n result << self\n else\n result += @sons.map { |s| s.get_variable }\n end\n\n return result.flatten\n end", "def types\n @types.dup\n end", "def types\n @types.dup\n end", "def datatypes\n value.document.fetch(\"#{value.key}_type\", [])\n end", "def values value_type = :formatted_value\n return @values unless @values.nil?\n\n @values = []\n while @rowset.next do\n @values << 1.upto(self.columns.size).map do |i|\n @rowset.getString i\n end\n end\n\n @values\n end", "def values\n rows.map{|r| r.value}\n end", "def types\n @stmt.types\n end", "def get_value_in_view rtype, view\n self.check_rtype rtype\n v = @views[view][rtype] || []\n v += (@views[nil][rtype] || []) if view\n return v if v.count > 0\n return @parent.get_value_in_view rtype, view if @parent\n return []\n end", "def get_data_elements_by_type(patient, type)\n matches = []\n patient.dataElements.each do |data_element|\n matches << data_element if data_element[:_type] == type\n end\n matches\n end", "def values\n to_a\n end", "def get_line_types\n @lines.line_types\n end", "def get_type_trophies(type)\n trophies = []\n @knights.each do |knight|\n knight.trophies.each do |trophy|\n packet = [knight.id, trophy] \n trophies << packet if trophy.type == type\n end\n end\n return trophies\n end", "def elements\n return @types.dup\n end", "def get_trains_by_type(train_class)\n @trains.select { |train| train.class == train_class }\n end", "def get_trains_by_type(train_class)\n @trains.select { |train| train.class == train_class }\n end", "def diff_array\n array = [self.id]\n home_stats = statistics.joins(:appearance).where(appearances: {team_id: home_team.id})\n away_stats = statistics.joins(:appearance).where(appearances: {team_id: away_team.id})\n Statistic::TYPES.each do |key|\n home_val = home_stats.where(stat_type: key).map{|s| s.value}.sum\n away_val = away_stats.where(stat_type: key).map{|s| s.value}.sum\n array << home_val - away_val\n end\n return array\n end", "def values\n vals = []\n each{|k,v| vals << v}\n vals\n end", "def values\n return @values\n end", "def arrays\n @vectors\n end", "def values\n return @values\n end", "def values\n return @values\n end", "def proficiencies_by_type(type)\n\t\t\t\tself.proficiencies.find_by_taggable_type(type).to_a\n\t\tend", "def values() end", "def values(*) end", "def values\n @values ||= []\n end", "def types(array)\n yield(array)\nend", "def values(tf = true)\n attributes(tf).map{ |k, a| @this.send(k)}\n end", "def values\n entries.map {|e| e.value }\n end", "def types\n [\n { value: 'bus', name: 'Bus' },\n { value: 'coach', name: 'Coach' },\n { value: 'hgv', name: 'Heavy goods vehicle' },\n { value: 'van', name: 'Van' },\n { value: 'minibus', name: 'Minibus' },\n { value: 'private_car', name: 'Car' },\n { value: 'motorcycle', name: 'Motorcycle' }\n ]\n end", "def values_array\n @_field_path.map{ |field_| @_values[field_.name] }\n end", "def values\n @values ||= []\n end", "def load_selectors(value_type)\n selectors.active.where(value_type: value_type).to_a\n end", "def to_verts_array a=[]\n\t\t@primitives.each do |p|\n\t\t\tp[:verts].each do |index|\n\t\t\t\ta += @verts[index][:vector]\n\t\t\tend\n\t\tend\n\t\ta\n\tend", "def values\n @data.values\n end", "def index\n @tvs = Tv.all\n end", "def types\n @stmt.types\n end", "def initialize(type)\n\t\tsuper(type)\n\n\t\tself.tlvs = [ ]\n\tend", "def initialize(type)\n\t\tsuper(type)\n\n\t\tself.tlvs = [ ]\n\tend", "def event_result_types_array\n @event_result_types_array = ClientWebhookSetting.get_bits_set_for_event_result_types(event_result_types)\n end", "def free_tems_with_sec(sec_type)\n tems = []\n @free_tems.each do |index_tem, true_value|\n tems << index_tem.last if @with[sec_type].include? index_tem.last\n end\n tems\n end", "def get_zones_per_space_type(space_type)\n list_of_zones = []\n model_space_type = @model.getSpaceTypeByName(space_type.name.get).get\n model_space_type.spaces.each do |space|\n list_of_zones << space.thermalZone.get\n end\n return list_of_zones\n end", "def fields_for_type(type)\n return @field_mapping[type] || Set.new\n end", "def to_a\n if @value.nil?\n [@type]\n else\n [@type, @value]\n end\n end", "def service_types_generated \n types = [ ServiceTypeValue[:fulltext], ServiceTypeValue[:holding], ServiceTypeValue[:table_of_contents], ServiceTypeValue[:relevant_link] ]\n \n return types\n end", "def my_activity_types_by_log\n my_logs.map {|log| log.activity_type}\n end", "def values; end", "def values; end", "def values; end", "def values; end", "def values; end", "def values; end", "def values; end", "def get_ecs_data_matching_pattern(type, pid)\n result_hash = @enums_and_chrons[type][pid]\n results = []\n if result_hash\n result_hash.keys.sort.each { |occnum| results << result_hash[occnum] }\n end\n return results\n end", "def get_context_types_list\n [\n context_type_meeting_header,\n context_type_category_header,\n context_type_relay_header,\n context_type_team_ranking,\n context_type_team_stats,\n context_type_stats,\n context_type_result_row,\n context_type_relay_row,\n context_type_ranking_row,\n context_type_stats_details\n ]\n end", "def collect\r\n array = []\r\n @table.each do |subarray|\r\n array.concat subarray\r\n end\r\n array\r\n end", "def token_tuples(type)\n results = get_tokens(type)\n results.map do |app_result|\n token_fields(type).map do |field|\n app_result[field]\n end.transpose\n end.flatten(1)\nend", "def value_types; end", "def entity_values(kind)\n self.entities.kind(kind.to_s).pluck('value')\n end", "def values\n @values.values\n end", "def array_of(*kinds, &block)\n lambda do |node|\n result = NodeFilters.filter(node, kinds)\n block ? result.map(&block) : result\n end\n end", "def by_type\n return @by_type if @by_type\n\n @by_type = {}\n self.all.each do |set|\n next unless set[:types].count > 0\n\n set[:types].each do |t|\n @by_type[t] ||= []\n @by_type[t] << set\n end\n end\n\n @by_type\n end" ]
[ "0.75675505", "0.75675505", "0.65907633", "0.64082175", "0.64082175", "0.59582686", "0.5935431", "0.5657677", "0.5644466", "0.5640378", "0.5611651", "0.55993783", "0.5592396", "0.5590408", "0.55671597", "0.55671597", "0.5558564", "0.5556186", "0.55391705", "0.5527216", "0.55107594", "0.5454887", "0.53799355", "0.5323574", "0.5305078", "0.528412", "0.528135", "0.5275701", "0.52712697", "0.5266233", "0.52522874", "0.52217484", "0.52162105", "0.52128685", "0.5206038", "0.520153", "0.520153", "0.51961124", "0.51811546", "0.5175029", "0.5175029", "0.51667476", "0.51659566", "0.5153234", "0.51393414", "0.51384455", "0.5133971", "0.51201487", "0.51168656", "0.5114332", "0.5102085", "0.50979054", "0.50979054", "0.50972587", "0.50944823", "0.50905466", "0.50902617", "0.5089976", "0.5089976", "0.50816447", "0.5079874", "0.50681764", "0.50674623", "0.5067448", "0.5061326", "0.5056819", "0.504886", "0.50367904", "0.5034988", "0.50334066", "0.50330466", "0.5020244", "0.5016339", "0.5015403", "0.5012832", "0.5012832", "0.49969015", "0.4987194", "0.49846327", "0.4979467", "0.49726054", "0.49646437", "0.49628496", "0.49531728", "0.49531728", "0.49531728", "0.49531728", "0.49531728", "0.49531728", "0.49531728", "0.4948748", "0.49475864", "0.49455544", "0.4943823", "0.49428982", "0.4936753", "0.49359515", "0.4932605", "0.4931564" ]
0.736128
3
Checks to see if the container has a TLV of a given type.
def has_tlv?(type) return get_tlv(type) != nil end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def has_type?\n ! type.nil?\n end", "def has_type?\n ! get_internal_word(TYPE_INDEX).nil?\n end", "def type?\n @data[:type].empty? ? false : true\n end", "def has_type?(type_)\n @mutex.synchronize do\n @types.has_key?(type_)\n end\n end", "def has_encounter_type?(enc_type)\r\n return false if !enc_type\r\n return @encounter_tables[enc_type] && @encounter_tables[enc_type].length > 0\r\n end", "def check_type(type)\n %w{galera mysql}.each do |t|\n return true if t == type\n end\n false\n end", "def valid_type?(type)\n !native_database_types[type].nil?\n end", "def has_type?(type)\n @properties.has_type?(type)\n end", "def type?\n !@type.nil? && @type != :any\n end", "def type_of?(type)\n type.raw_type == raw_type\n end", "def has_etype?(etype)\n mask_for_etype = self.class.mask_from_etype(etype)\n return (self.mask & mask_for_etype).eql?(mask_for_etype)\n end", "def valid_type?\n %w[ip domain cert].include? type\n end", "def __typedeaf_valid_type?(value, type)\n return value.is_a? type\n end", "def is_typed?(key, type)\n return (!datas.has_key?(key) or datas[key].kind_of?(type))\n end", "def type?(type)\n\t\treturn self.type == type\n\tend", "def type?(type)\n\t\treturn self.type == type\n\tend", "def pbHasType?(type)\n if type.is_a?(String) || type.is_a?(Symbol)\n type = getID(PBTypes,type)\n end\n for pokemon in $Trainer.pokemonParty\n return true if pokemon.hasType?(type)\n end\n return false\nend", "def valid_type?(type)\n super || extended_types.include?(type)\n end", "def structure?(type)\n STRUCTURES.include?(type)\n end", "def valid_ape_type?(type)\n ITEM_TYPES.include?(type)\n end", "def type?(type)\n type = type.to_str\n\n types = param('TYPE')\n\n if types\n types = types.detect { |t| Vpim::Methods.casecmp?(t, type) }\n end\n end", "def valid?\n !type.nil?\n end", "def valid?\n !type.nil?\n end", "def valid_type?\n %w[ip domain].include? type\n end", "def type_allowed? type # Will check if the type is included in the list_types hash\n return @@list_types.keys.include?(type.to_sym)\n end", "def type?( in_type )\n type == in_type\n end", "def type_check(type = nil)\n children {|child| type = child.type_check(nil)}\n return type\n end", "def has_type?(type_sym)\n each_term do |term|\n if is?(term, type_sym)\n return true\n end\n end\n \n false\n end", "def has_datatype?\n !datatype.nil?\n end", "def check_type(type, value)\n return unless type && value && !value.is_a?(type)\n\n \"should be of type #{type} but is of type #{value.class}\"\n end", "def supports_type? type\n if type.is_a? Class\n type.to_packed\n elsif type.is_a? Array\n return type.detect{|obj| not supports_type? obj }.nil?\n else\n type.class.to_packed\n end\n return true\n rescue NoMethodError\n return false\n end", "def valid?\n return false if @type.nil?\n return true\n end", "def has_typekit?(name)\n available_typekits.has_key?(name)\n end", "def type?(type)\n return (type1 == type || type2 == type || type3 == type)\n end", "def encounter_exists?(type)\n # Vitals may be collected from a different program so don't check\n # for existence of an encounter rather check for the existence\n # of the actual vitals.\n return false if type.name == VITALS\n\n Encounter.where(type: type, patient: @patient, program: @program)\\\n .where('encounter_datetime BETWEEN ? AND ?', *TimeUtils.day_bounds(@date))\\\n .exists?\n end", "def type?(*types)\n types.each &method(:assert_simple_type)\n existing = get('type', nil)\n if existing.is_a? Json::Array\n (existing.to_a & types).any?\n else\n types.include? existing\n end\n end", "def type_exists?(name)\n user_defined_types.key? name.to_s\n end", "def string?\n type == \"STRING\"\n end", "def needs_encoding?\n ![ :binary, :date, :datetime, :boolean, :float, :integer ].include?(type)\n end", "def any_of_type?(type)\n keys_by_type[type]&.any?\n end", "def check_type\n \t self.type = TYPES[0] if !TYPES.include?(self.type)\n\t end", "def bytes?\n type == \"BYTES\"\n end", "def uids_exist?(type)\n val_fatal(\"Invalid UID type\", type) unless UID_TYPES.include?(type)\n return (self.uids.keys.include?(type) && self.uids[type].keys.length > 0)\n end", "def needs_encoding?\n ![ :binary, :date, :datetime, :boolean, :float, :integer ].include?(type)\n end", "def is(type)\n @value.include?(type)\n end", "def valid_type?(data_type)\n object_type = @plural_form ||\n @object_instance.class.name.pluralize.underscore.dasherize\n unless data_type == object_type\n return set_failure_message(\n format(FailureMessages::DATA_TYPE_MISMATCH, data_type, object_type)\n )\n end\n true\n end", "def unknown?\n @type == 'TYPE_UNSPECIFIED'\n end", "def has_to_data?\n @types.any? { |type| type.has_to_data? }\n end", "def valid?\n return false if @type.nil?\n type_validator = EnumAttributeValidator.new('String', [\"ITEM\", \"CATEGORY\", \"ITEM_VARIATION\", \"TAX\", \"DISCOUNT\", \"MODIFIER_LIST\", \"MODIFIER\"])\n return false unless type_validator.valid?(@type)\n return false if @id.nil?\n return false if @id.to_s.length < 1\n return true\n end", "def valid_itemtype?(valid_types, itemtype)\n return true if valid_types.include?(:any)\n vocabulary = Vocabulary.find(itemtype)\n valid_types.find {|type| vocabulary.kind_of?(type) }\n end", "def recognized?\n return !self.etypes.empty?\n end", "def ltype?\n return true\n end", "def is_valid_type?(namespace_prefix, template_name = \"default\")\n get_child_types(namespace_prefix).each do\n |template|\n return true if template.template.to_s.strip == template_name.strip && !template.hidden\n end\n false\n end", "def type_supported?(type)\n Sequel.synchronize{return @supported_types[type] if @supported_types.has_key?(type)}\n supported = from(:pg_type).where(:typtype=>'b', :typname=>type.to_s).count > 0\n Sequel.synchronize{return @supported_types[type] = supported}\n end", "def is_cantidad_type?\n tag_name.eql?(CANTIDAD)\n end", "def type\n @data[:type].empty? ? false : @data[:type]\n end", "def valid_type? item_type\n [BATTLE_ITEMS, KEY_ITEMS, INGREDIENTS, TREASURES, CAR_PARTS, LEISURE].include?(item_type)\n end", "def check_card_type\n card_type && (card_type == 'VISA' || card_type == 'MASTERCARD' || card_type == 'AMEX')\n end", "def is_boxtype?(); @type == GRT_BOXTYPE; end", "def get_tlv(type, index = 0)\n\t\ttype_tlvs = get_tlvs(type)\n\n\t\tif (type_tlvs.length > index)\n\t\t\treturn type_tlvs[index]\n\t\tend\n\n\t\treturn nil\n\tend", "def get_tlv(type, index = 0)\n\t\ttype_tlvs = get_tlvs(type)\n\n\t\tif (type_tlvs.length > index)\n\t\t\treturn type_tlvs[index]\n\t\tend\n\n\t\treturn nil\n\tend", "def valid_type?\n %w[host web].include? type\n end", "def of_kind?(attribute, type = :invalid)\n attribute, type = normalize_arguments(attribute, type)\n\n if type.is_a? Symbol\n !where(attribute, type).empty?\n else\n messages_for(attribute).include?(type)\n end\n end", "def valid?(value)\n @type_checker.valid?(value)\n end", "def datatype?(elora, die=nil)\n die = @proofsheet.die(elora.inherited_namespace, elora.absolute_xpath) if not die\n validity = true # default cdata, so valid\n if die\n if die.datatype\n dts = Datatypes.new\n if not dts.valid?(die.datatype, content(elora))\n validity = false\n error = \"DATATYPE '#{content(elora)}' :#{die.datatype}:\"\n @errors << [die.namespace, die.xpath, error]\n end\n end\n end\n return validity\n end", "def multiple_type?(node)\n node.name == 'content' && !node.attributes['type'].nil?\n end", "def is_struct_type?(type)\n return type.kind_of? Array\n end", "def check_child?\n [\"AcademicClass\", \"Center\", \"CenterAdmin\", \"InstituteAdmin\", \"Institution\", \"Publisher\", \"Section\", \"StudentGroup\", \"Teacher\", \"CdnUser\", \"Moe\"].include? self.type\n end", "def valid?\n return false if @content.nil?\n return false if @type.nil?\n true\n end", "def member_uses_custom_type?(field)\n field.type.schemas.any? do |klass|\n Avromatic.type_registry.fetch(klass) != NullCustomType\n end\n end", "def valid?\n use_tls_validator = EnumAttributeValidator.new('String', [\"0\", \"1\"])\n return false unless use_tls_validator.valid?(@use_tls)\n type_validator = EnumAttributeValidator.new('String', [\"random\", \"hash\", \"client\"])\n return false unless type_validator.valid?(@type)\n true\n end", "def string?\n data_type == String\n end", "def check?(token_type)\n return false if at_end?\n return peek.type == token_type\n end", "def typed?\n type != :object\n end", "def matches_type? value, expected_type: type\n case expected_type\n # Raw class types\n when Array\n case expected_type.length\n when 0\n return value.is_a?(Array)\n when 1\n return value.all?{ |v| matches_type?(v, expected_type: expected_type[0]) }\n else\n return expected_type.zip([value].flatten(1)).all?{ |t, v| matches_type?(v, expected_type: t) }\n end\n else\n value.is_a?(expected_type)\n end\n end", "def type_registered?(klass_or_type)\n end", "def dummy?\n @type.nil?\n end", "def meta_type?(meta)\n\t\treturn (self.type & meta == meta)\n\tend", "def meta_type?(meta)\n\t\treturn (self.type & meta == meta)\n\tend", "def include?(singleton_type)\n if singleton_type.is_union_type?\n raise AssertionError.new(\"Union type can never be included in union type\")\n end\n\n @types.include?(singleton_type)\n end", "def valid?\n type_validator = EnumAttributeValidator.new('String', ['active', 'notActive', 'unknown'])\n return false unless type_validator.valid?(@type)\n true\n end", "def has_stream_of( type )\n has = false\n streams.each do |stream| has = true if stream.type == type end\n return has\n end", "def text?\n type == :text\n end", "def check_exist(type, value)\n return $browser.text_field(:\"#{type}\" => \"#{value}\").exist?\n end", "def mix_type_ok?(item)\n Bubs::Mix::MIX_TYPES.include?(item.mix_type)\n end", "def check_typecode(v)\n if TYPECODE.include?(v)\n return true\n else\n raise InvalidComponentError,\n \"bad typecode(expected #{TYPECODE.join(', ')}): #{v}\"\n end\n end", "def check_type(validation:, key:, schema:)\n return false if !validation[:required] && schema.nil? # Optional and not here, dont check\n return false unless validation[:type]\n if validation[:type] == 'Boolean'\n return false unless !(schema.is_a?(TrueClass) || schema.is_a?(FalseClass) || schema.nil?)\n else\n return false unless !(schema.is_a?(validation[:type]) || schema.nil?)\n end\n\n error! key, \"supposed to be a #{validation[:type]} but was #{schema.class}\"\n true\n end", "def is?(btype)\n type == btype\n end", "def valid?\n return false if @class_id.nil?\n class_id_validator = EnumAttributeValidator.new('String', [\"hyperflex.StorageContainer\"])\n return false unless class_id_validator.valid?(@class_id)\n return false if @object_type.nil?\n object_type_validator = EnumAttributeValidator.new('String', [\"hyperflex.StorageContainer\"])\n return false unless object_type_validator.valid?(@object_type)\n accessibility_summary_validator = EnumAttributeValidator.new('String', [\"NOT_APPLICABLE\", \"ACCESSIBLE\", \"NOT_ACCESSIBLE\", \"PARTIALLY_ACCESSIBLE\"])\n return false unless accessibility_summary_validator.valid?(@accessibility_summary)\n kind_validator = EnumAttributeValidator.new('String', [\"UNKNOWN\", \"USER_CREATED\", \"INTERNAL\"])\n return false unless kind_validator.valid?(@kind)\n mount_status_validator = EnumAttributeValidator.new('String', [\"NOT_APPLICABLE\", \"NORMAL\", \"ALERT\", \"FAILED\"])\n return false unless mount_status_validator.valid?(@mount_status)\n mount_summary_validator = EnumAttributeValidator.new('String', [\"NOT_APPLICABLE\", \"MOUNTED\", \"UNMOUNTED\", \"MOUNT_FAILURE\", \"UNMOUNT_FAILURE\"])\n return false unless mount_summary_validator.valid?(@mount_summary)\n type_validator = EnumAttributeValidator.new('String', [\"NFS\", \"SMB\", \"iSCSI\"])\n return false unless type_validator.valid?(@type)\n true\n end", "def correct_type?(object)\n object.type == type\n end", "def obj_exists_and_is_not_type?(obj:, type:)\n obj.nil? ? false : obj != type\n end", "def record_with_type?(record)\n record.include?(inheritance_column) && !record[inheritance_column].nil? && \n !record[inheritance_column].empty?\n end", "def validate_type?\n config[:validate_type] || config[:validate_types]\n end", "def is_text_header?(header)\n not header.include?('/Subtype') and not header.match(/\\/Length[1-3]+/)\n end", "def contained?\n !container.nil?\n end", "def test? value\n value.nil? || @type.test?( value )\n end", "def valid_type?\n type == \"domain\"\n end", "def valid_type?\n type == \"domain\"\n end", "def key_of_type?(hash, key, type)\n return false unless hash.length == 1\n\n hash.key?(key) && hash[key].is_a?(type)\n end" ]
[ "0.6494128", "0.6314078", "0.6088852", "0.60273576", "0.6008003", "0.5998794", "0.5949617", "0.58603334", "0.580964", "0.57994646", "0.57676595", "0.57545716", "0.5713449", "0.5710575", "0.570083", "0.570083", "0.56475633", "0.563804", "0.5596937", "0.5565976", "0.5558136", "0.5497793", "0.5497793", "0.54849875", "0.5462006", "0.5456173", "0.54540604", "0.5448518", "0.5397734", "0.5391767", "0.5353109", "0.5344417", "0.5335285", "0.53344864", "0.5328514", "0.53134227", "0.52732635", "0.52636117", "0.5228315", "0.52187073", "0.5208497", "0.51978034", "0.51848286", "0.5184551", "0.5178935", "0.5171571", "0.517135", "0.5163534", "0.5162805", "0.51598275", "0.5156556", "0.5154991", "0.51532555", "0.51453894", "0.51435757", "0.5117126", "0.5113863", "0.5104731", "0.5104088", "0.51028377", "0.51028377", "0.50934035", "0.50841457", "0.5075263", "0.5049272", "0.50470257", "0.50352854", "0.5031764", "0.5022076", "0.49991858", "0.49977303", "0.4986225", "0.49818772", "0.49818107", "0.49767813", "0.49704918", "0.49565482", "0.4955849", "0.4955849", "0.4953709", "0.4950068", "0.49463448", "0.49436793", "0.4935175", "0.49351603", "0.4931757", "0.49142712", "0.49111524", "0.4910069", "0.4907547", "0.49030173", "0.48940974", "0.48936734", "0.488989", "0.4887287", "0.48862964", "0.48815247", "0.48815247", "0.48790422" ]
0.8031238
1
Zeros out the array of TLVs.
def reset self.tlvs = [] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def zero(&contents) X(0, &contents) end", "def clear\n @field.each_index { |i| @field[i] = 0 }\n end", "def zero()\n\treturn([0,0,0,0,0,0,0,0,0])\nend", "def zero\n 0.upto(@words-1) do |w|\n @bits[w] = 0\n end\n end", "def reset\n @array = nil\n end", "def clear\n @store.fill(nil,0...@size)\n end", "def empty_bits(_options = {})\n array_span = (0..(size - 1)).to_a\n empty_bits = array_span - used_bits\n empty_bits\n end", "def zero\n self.group = []\n end", "def reset!()\n # fixed-length fields\n @status = 0\n @flags = 0\n @server_msg_len = 0\n @data_len = 0 \n \n # variable-length fields\n @server_msg = nil\n @data = nil\n \n return(nil)\n end", "def reset\n (0...self.class.size).each { |i| Utils.string_setbyte @data,i, 0 }\n sync_to_owner\n end", "def reset!()\n # fixed-length fields\n @user_msg_len = 0\n @data_len = 0\n @flags = 0\n \n # variable-length fields\n @user_msg = nil\n @data = nil\n return(nil)\n end", "def empty!\n @items = []\n @reservations = []\n @total = 0.0\n @shipping_charge = 0.0\n @balance = 0.0\n @quantity_error = nil\n end", "def zeros\n counter = 0\n @l.each_value do |v|\n\tcounter +=1 if v == '0'\n end # do\n counter\n end", "def unpad_1_9()\n new_arr = []\n @value.each do |string|\n string = string.dup # to avoid changing the original\n while (string.getbyte(-1) == 0) \n string.chop!\n end\n new_arr.push string\n end\n new_arr\n end", "def empty!\r\n\t\t@items = []\r\n\tend", "def nulls(l)\r\n fail 'requires #{l} to be +ve' if l < 0\r\n [].pack('x' * l).force_encoding('ascii-8bit')\r\nend", "def reset()\n\n\t\t@aChecksum = [ 0xFF, 0xFF ];\n\n\tend", "def clear\n @data = \"O\" * size\n end", "def clear()\n if @extend then\n @tiers.clear\n else\n @tiers.each do |tier|\n tier.clear\n end\n end\n \n @length = 0\n end", "def reset!()\n # fixed-length fields\n @server_msg_len = 0\n @data_len = 0\n @status = 0\n \n # variable-length fields\n @server_msg = nil\n @data = nil\n\n return(nil)\n end", "def nulls(l)\n fail 'requires #{l} to be +ve' if l < 0\n [].pack('x' * l).force_encoding('ascii-8bit')\nend", "def nulls(l)\n fail 'requires #{l} to be +ve' if l < 0\n [].pack('x' * l).force_encoding('ascii-8bit')\nend", "def clear\n @level = 0\n @out = []\n @labels = []\n self\n end", "def clear!\n @slots.map(&:clear!)\n @filled = 0\n end", "def clear_data \n @data = []\n end", "def array_of_nils(length:)\n Array.new(length, nil)\nend", "def zero_all\n UkAccountValidator::ModulusWeight.new(\n modulus_weight.sort_code_start,\n modulus_weight.sort_code_end,\n modulus_weight.modulus,\n 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n modulus_weight.exception\n )\n end", "def clear\n @instructions = []\n end", "def clear\n @instructions = []\n end", "def clear\n with(keys: EMPTY_ARRAY)\n end", "def zeros_like\n return self.class.zeros_like(self)\n end", "def clear\n @table = Array.new(@table.size)\n @count = 0\n end", "def clear\n @table = Array.new(@table.size)\n @count = 0\n end", "def without_zeros()\n @hops.find_all { |hop| hop.ip != \"0.0.0.0\" }\n end", "def clear ; @data.clear ; end", "def reset\n @index = -1\n @element = nil\n @value = nil\n end", "def empty\n @regs = []\n @addresses = {}\n self\n end", "def empty_slots\n # INITIALIZE an array of empty slots\n empty_slots_indices = []\n # FOR EACH empty slot access its index\n @slots.each_with_index do |slot_num, index|\n # IF slot_num is 0\n if slot_num == 0\n # ADD its index in the collection of empty slots\n empty_slots_indices << index\n end\n end\n empty_slots_indices\n end", "def reset\n\t\t@hand = Array.new\n\t\t@total = 0\n\tend", "def zero_initializer\n '{}'\n end", "def empty!\n @items = []\n @total_price = 0.0\n end", "def empty\n each { |x| x.inner_html = nil }\n end", "def clear\n @a.clear\n end", "def rb_array(len: T.unsafe(nil)); end", "def clear\n @speed = 0\n @kind = 0\n @basic = -1\n @skill_id = 0\n @item_id = 0\n @target_index = -1\n @forcing = false\n @value = 0\n\n @custom_action = nil\n end", "def new_zeros\n self.class.zeros(*shape)\n end", "def reset\n\t\tself.raw = ''\n\t\tself.hdr_length_left = 8\n\t\tself.payload_length_left = 0\n\tend", "def clear()\n @hands = Array.new\n end", "def reset!()\n # fixed-length fields\n @action = 0\n @priv_lvl = 0\n @authen_type = 0\n @service = 0\n @user_len = 0\n @port_len = 0\n @rem_addr_len = 0\n @data_len = 0\n\n # variable-length fields\n @user = nil\n @port = nil\n @rem_addr = nil\n @data = nil\n return(nil)\n end", "def zero_weight_update_values\n weight_update_values = []\n 26.times do weight_update_values << 0.0 end\n\n weight_update_values\n end", "def initialize(array)\r\n @elements = array\r\n\r\n @zero = Zero\r\n end", "def clear\n @items = []\n end", "def init\n for i in 0...@tree.size\n @tree[i] = 0\n end\n end", "def nilitems\n size - nitems\n end", "def empty\n @cards.shift(@cards.size)\n end", "def clear\n @root = nil\n @size = 0\n @header = Node.new(nil, nil, nil, nil)\n end", "def empty!\n @head = @tail = nil\n @size = 0\n end", "def clear!\n @data = []\n return self\n end", "def reset\n @hand = []\n @value = nil\n @status = \"unfinished\"\n end", "def clear\n @data.resize(0, 0)\n self\n end", "def reset\n\tfor i in 0..8\n\t\t@bo[i] = '-'\n\tend\n end", "def off(*a)\n case a.size\n when 1 then var(a[0], Array).clear\n when 2 then var(a[0], Array).tap { |e| e.delete a[1] }\n when 3 then var(a[0], Array).tap { |e| e.delete a[1].method(a[2]) }\n end\n self\n end", "def strip_nils array\n ArrayUtils.strip_nils array\n end", "def empty()\n \n end", "def empty()\n @size == 0\n end", "def empty()\n @size == 0\n end", "def empty(array, length)\r\n i = 0;\r\n while i < array.length\r\n array[i] = 'SPECIAL_VALUE';\r\n i++;\r\n end\r\nend", "def clean_up_arrays\n self.likes.reject! {|l| l.empty? } if self.likes\n self.outdoor_activities.reject! {|l| l.empty? } if self.outdoor_activities\n self.nightlife.reject! {|l| l.empty? } if self.nightlife\n end", "def reset\n @offset = 0\n end", "def reset\n @printed = false\n @structs.each(&:reset)\n end", "def empty!; end", "def clear() end", "def clear() end", "def clear\n @count = 0\n @head = nil\n @tail = nil\n end", "def clear\n @head = nil\n @tail = nil\n @size = 0\n end", "def clear_flags\n each(&:clear_flags)\n self\n end", "def initialize\n @size = 0\n clear\n end", "def strip_array_nils array\n ArrayUtils.strip_array_nils array\n end", "def empty(r0)\n source, stop_index = r0.source, r0.stop_index\n factor_result(source, stop_index, stop_index)\n end", "def clear\n @data = nil\n end", "def clear()\n if @idArray.not_nil? then\n @idArray.clear\n end\n @is_first_access = true\n end", "def empty_element(*args, &block)\n __empty_element__(*args, &block)\n end", "def empty_element(*args, &block)\n __empty_element__(*args, &block)\n end", "def empty\n @passengers = []\n end", "def clear\n @known = []\n end", "def reset\n @ret_val = 999\n @keys = []\n @keys_to_check = []\n @keys_used = []\n @unsigned_keys = []\n @algs = []\n @last_nsec3_hashed = nil\n @nsec3param = nil\n @first_nsec3 = nil\n @count = 0\n @last_nsec = nil\n @first_nsec = nil\n @warned_about_nsec3param = false\n @zone_name = \"\"\n @soa = nil\n @config = nil\n @key_tracker = nil\n @key_cache = nil\n @unknown_nsecs = {}\n @empty_nonterminals = []\n end", "def clear\n self.filled = false; self.pid = nil; self.seg = nil;\n self\n end", "def zero n\r\n rows_x = []\r\n n.times { rows_x << [0]*n }\r\n Matrix[ *rows_x ]\r\n end", "def clear_damage_values\n mrts_conditional_drops_clear_damage_values\n @element = 0\n end", "def zeros(size, dtype = :float64)\n NMatrix.new([size,1], 0, dtype: dtype)\n end", "def clear\n @ary.clear\n @heapsize = 0\n @mode = nil\n end", "def clear(i)\n raise ArgumentError, \"argument (#{i}) should be between 0 and #{@size}\" if i < 0 or i >= @size\n @array[get_index(i)] &= ~(1 << get_shift(i))\n end", "def empty()\n @s1.length == 0\n end", "def remove_all()\n @datatype_properties = Array.new\n end", "def empty_puzzle\n result = []\n @amount_row.times do |index|\n result << [0]*@amount_column\n end\n result\n end", "def none_of(*field_names)\n [].tap do |list|\n lack_num = any_of_number(*field_names)\n self.each_value { |num| list << num if (num & lack_num) == 0 }\n end\n end", "def clear()\n @fields = []\n @mbox_from = nil\n self\n end", "def zero_matrix\n @zeroed_rows = Set.new\n @zeroed_cols = Set.new\n matrix = @matrix.dup\n\n find_zeros\n zeroize_rows(matrix)\n zeroize_cols(matrix)\n\n Matrix.new matrix\n end", "def clear\n @resp_message_codes = -1\n @resp_message = []\n @req_message_code = -1\n @req_message = ''\n @response = ''\n @status = false\n @buffer = ''\n end" ]
[ "0.6547851", "0.63611776", "0.62478995", "0.6174784", "0.5755311", "0.57310677", "0.5726876", "0.5709297", "0.56672347", "0.5639802", "0.5623227", "0.56199676", "0.5542608", "0.55307347", "0.55280787", "0.551068", "0.5469376", "0.5459057", "0.5449602", "0.5447047", "0.54459727", "0.54459727", "0.5441027", "0.54129386", "0.54043436", "0.53769857", "0.53735733", "0.536031", "0.53501564", "0.53407633", "0.53350115", "0.53338516", "0.53338516", "0.5325531", "0.5321233", "0.5317409", "0.5316233", "0.53091156", "0.5298645", "0.5297543", "0.5264187", "0.52603483", "0.5258759", "0.52477294", "0.5241628", "0.52361906", "0.52347434", "0.5222496", "0.5215882", "0.5213944", "0.52126664", "0.52121204", "0.52026445", "0.5192739", "0.51898974", "0.5165887", "0.51597995", "0.5147105", "0.5144848", "0.51276416", "0.5118869", "0.5117369", "0.5114088", "0.5092498", "0.5073841", "0.5073841", "0.50660473", "0.5064726", "0.5064403", "0.5062494", "0.5060065", "0.5057244", "0.5057244", "0.50403666", "0.50348896", "0.50321966", "0.50300837", "0.5023704", "0.5021513", "0.5019344", "0.50138694", "0.501209", "0.501209", "0.5011893", "0.5008738", "0.50086266", "0.50071454", "0.50048596", "0.50024706", "0.5000088", "0.49998522", "0.49936718", "0.49910465", "0.49858075", "0.497512", "0.49693382", "0.49680123", "0.49627346", "0.49624288" ]
0.5074507
65
Serializers Converts all of the TLVs in the TLV array to raw and prefixes them with a container TLV of this instance's TLV type.
def to_r raw = '' self.each() { |tlv| raw << tlv.to_r } return [raw.length + 8, self.type].pack("NN") + raw end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_r\n\t\traw = value.to_s;\n\n\t\tif (self.type & TLV_META_TYPE_STRING == TLV_META_TYPE_STRING)\n\t\t\traw += \"\\x00\"\n\t\telsif (self.type & TLV_META_TYPE_UINT == TLV_META_TYPE_UINT)\n\t\t\traw = [value].pack(\"N\")\n\t\telsif (self.type & TLV_META_TYPE_BOOL == TLV_META_TYPE_BOOL)\n\t\t\tif (value == true)\n\t\t\t\traw = [1].pack(\"c\")\n\t\t\telse\n\t\t\t\traw = [0].pack(\"c\")\n\t\t\tend\n\t\tend\n\t\t\n\t\t# check if the tlv is to be compressed...\n\t\tif( @compress )\n\t\t\traw_uncompressed = raw\n\t\t\t# compress the raw data\n\t\t\traw_compressed = Rex::Text.zlib_deflate( raw_uncompressed )\n\t\t\t# check we have actually made the raw data smaller...\n\t\t\t# (small blobs often compress slightly larger then the origional) \n\t\t\t# if the compressed data is not smaller, we dont use the compressed data\n\t\t\tif( raw_compressed.length < raw_uncompressed.length )\n\t\t\t\t# if so, set the TLV's type to indicate compression is used\n\t\t\t\tself.type = self.type | TLV_META_TYPE_COMPRESSED\n\t\t\t\t# update the raw data with the uncompressed data length + compressed data\n\t\t\t\t# (we include the uncompressed data length as the C side will need to know this for decompression)\n\t\t\t\traw = [ raw_uncompressed.length ].pack(\"N\") + raw_compressed\n\t\t\tend\n\t\tend\n\t\t\n\t\treturn [raw.length + 8, self.type].pack(\"NN\") + raw\n\tend", "def to_r\n\t\traw = value.to_s;\n\n\t\tif (self.type & TLV_META_TYPE_STRING == TLV_META_TYPE_STRING)\n\t\t\traw += \"\\x00\"\n\t\telsif (self.type & TLV_META_TYPE_UINT == TLV_META_TYPE_UINT)\n\t\t\traw = [value].pack(\"N\")\n\t\telsif (self.type & TLV_META_TYPE_BOOL == TLV_META_TYPE_BOOL)\n\t\t\tif (value == true)\n\t\t\t\traw = [1].pack(\"c\")\n\t\t\telse\n\t\t\t\traw = [0].pack(\"c\")\n\t\t\tend\n\t\tend\n\n\t\treturn [raw.length + 8, self.type].pack(\"NN\") + raw\n\tend", "def from_r(raw)\n\t\toffset = 8\n\n\t\t# Reset the TLVs array\n\t\tself.tlvs = []\n\t\tself.type = raw.unpack(\"NN\")[1]\n\n\t\t# Enumerate all of the TLVs\n\t\twhile (offset < raw.length-1)\n\n\t\t\ttlv = nil\n\n\t\t\t# Get the length and type\n\t\t\tlength, type = raw[offset..offset+8].unpack(\"NN\")\n\n\t\t\tif (type & TLV_META_TYPE_GROUP == TLV_META_TYPE_GROUP)\n\t\t\t\ttlv = GroupTlv.new(type)\n\t\t\telse\n\t\t\t\ttlv = Tlv.new(type)\n\t\t\tend\n\n\t\t\ttlv.from_r(raw[offset..offset+length])\n\n\t\t\t# Insert it into the list of TLVs\n\t\t\ttlvs << tlv\n\n\t\t\t# Move up\n\t\t\toffset += length\n\t\tend\n\tend", "def from_r(raw)\n\t\toffset = 8\n\n\t\t# Reset the TLVs array\n\t\tself.tlvs = []\n\t\tself.type = raw.unpack(\"NN\")[1]\n\n\t\t# Enumerate all of the TLVs\n\t\twhile (offset < raw.length-1)\n\n\t\t\ttlv = nil\n\n\t\t\t# Get the length and type\n\t\t\tlength, type = raw[offset..offset+8].unpack(\"NN\")\n\n\t\t\tif (type & TLV_META_TYPE_GROUP == TLV_META_TYPE_GROUP)\n\t\t\t\ttlv = GroupTlv.new(type)\n\t\t\telse\n\t\t\t\ttlv = Tlv.new(type)\n\t\t\tend\n\n\t\t\ttlv.from_r(raw[offset..offset+length])\n\n\t\t\t# Insert it into the list of TLVs\n\t\t\ttlvs << tlv\n\n\t\t\t# Move up\n\t\t\toffset += length\n\t\tend\n\tend", "def serialize\n @raw_data\n end", "def raw\n @raw ||= []\n end", "def get_field_deserializers()\n return super.merge({\n \"audiences\" => lambda {|n| @audiences = n.get_collection_of_primitive_values(String) },\n \"description\" => lambda {|n| @description = n.get_string_value() },\n \"issuer\" => lambda {|n| @issuer = n.get_string_value() },\n \"name\" => lambda {|n| @name = n.get_string_value() },\n \"subject\" => lambda {|n| @subject = n.get_string_value() },\n })\n end", "def from_r(raw)\n\t\tself.value = nil\n\n\t\tlength, self.type = raw.unpack(\"NN\");\n\n\t\t# check if the tlv value has been compressed...\n\t\tif( self.type & TLV_META_TYPE_COMPRESSED == TLV_META_TYPE_COMPRESSED )\n\t\t\t# set this TLV as using compression\n\t\t\t@compress = true\n\t\t\t# remove the TLV_META_TYPE_COMPRESSED flag from the tlv type to restore the \n\t\t\t# tlv type to its origional, allowing for transparent data compression.\n\t\t\tself.type = self.type ^ TLV_META_TYPE_COMPRESSED\n\t\t\t# decompress the compressed data (skipping the length and type DWORD's)\n\t\t\traw_decompressed = Rex::Text.zlib_inflate( raw[8..length-1] )\n\t\t\t# update the length to reflect the decompressed data length (+8 for the length and type DWORD's)\n\t\t\tlength = raw_decompressed.length + 8\n\t\t\t# update the raw buffer with the new length, decompressed data and updated type.\n\t\t\traw = [length, self.type].pack(\"NN\") + raw_decompressed\n\t\tend\n\t\t\n\t\tif (self.type & TLV_META_TYPE_STRING == TLV_META_TYPE_STRING)\n\t\t\tif (raw.length > 0)\n\t\t\t\tself.value = raw[8..length-2]\n\t\t\telse\n\t\t\t\tself.value = nil\n\t\t\tend\n\t\telsif (self.type & TLV_META_TYPE_UINT == TLV_META_TYPE_UINT)\n\t\t\tself.value = raw.unpack(\"NNN\")[2]\n\t\telsif (self.type & TLV_META_TYPE_BOOL == TLV_META_TYPE_BOOL)\n\t\t\tself.value = raw.unpack(\"NNc\")[2]\n\n\t\t\tif (self.value == 1)\n\t\t\t\tself.value = true\n\t\t\telse\n\t\t\t\tself.value = false\n\t\t\tend\n\t\telse\n\t\t\tself.value = raw[8..length-1]\n\t\tend\n\n\t\treturn length;\n\tend", "def json_serialize\n # A vcard does not have sub-components, so we're overriding this\n # method to remove that array element.\n properties = []\n\n children.each do |child|\n properties << child.json_serialize\n end\n\n [@name.downcase, properties]\n end", "def to_simple_value(options = Hash.new)\n apply_changes_from_converted_types\n if options[:pack_simple_arrays] && element_t.respond_to?(:pack_code)\n Hash[pack_code: element_t.pack_code,\n size: self.class.length,\n data: Base64.strict_encode64(to_byte_array)]\n else\n raw_each.map { |v| v.to_simple_value(options) }\n end\n end", "def raw_tags_plist=(value)\n obj = value.to_s.from_plist\n self.raw_tags = obj\n end", "def tags_raw=(values)\n self.tags = []\n self.tags = values.split(\"\\n\").map(&:strip)\n end", "def to_json\n MultiJson.dump(raw)\n end", "def to_json\n MultiJson.dump(raw)\n end", "def tags_raw=(values)\n self.tags = []\n self.tags = values.split(\"\\n\").map { |w| w.strip }\n end", "def raws\n @raws = {} unless defined? @raws\n @raws\n end", "def tags_raw\n self.tags.join(\"\\n\") unless self.tags.nil?\n end", "def serialize\n data = MultiJson::dump(self)\n header = [data.length].pack('Q')\n data.prepend(header)\n end", "def encode_fields(*fields)\n fields.map do |type, value|\n case type\n when :raw\n value\n when :string\n encode_string(value)\n when :list\n encode_list(value)\n when :mpint\n encode_mpint(value)\n when :time\n encode_time(value)\n when :uint64\n encode_uint64(value)\n when :uint32\n encode_uint32(value)\n when :options\n encode_options(value)\n else\n raise DecodeError, \"bad type: #{type}\"\n end\n end.join\n end", "def encode(object, options={})\n object = object.to_a if defined?(ActiveRecord::Relation) && object.is_a?(ActiveRecord::Relation)\n fields_to_hash(options)\n if object.is_a?(Array)\n if options[:fields]\n encode_partial_array(object, options)\n else\n encode_array(object, options)\n end\n elsif options[:fields]\n encode_partial_single(object, options)\n else\n encode_single(object, options)\n end\n end", "def marshal_dump\n [@lsi_vector, @lsi_norm, @raw_vector, @raw_norm, @categories, @word_hash]\n end", "def dump\n zeroes = ZEROBYTE * 32\n raw = ZEROBYTE * ID3::ID3v1tagSize\n raw[0..2] = 'TAG'\n\n self.each{ |key,value|\n\n range = ID3::Symbol2framename['1.1'][key]\n\n if range.class == Range \n length = range.last - range.first + 1\n paddedstring = value + zeroes\n raw[range] = paddedstring[0..length-1]\n elsif range.class == Fixnum\n raw[range] = value.to_i.chr # supposedly assigning a binary integer value to the location in the string\n else\n # this can't happen the way we defined the hash..\n next\n end\n }\n\n return raw\n end", "def from_r(raw)\n\t\tself.value = nil\n\n\t\tlength, self.type = raw.unpack(\"NN\");\n\n\t\tif (self.type & TLV_META_TYPE_STRING == TLV_META_TYPE_STRING)\n\t\t\tif (raw.length > 0)\n\t\t\t\tself.value = raw[8..length-2]\n\t\t\telse\n\t\t\t\tself.value = nil\n\t\t\tend\n\t\telsif (self.type & TLV_META_TYPE_UINT == TLV_META_TYPE_UINT)\n\t\t\tself.value = raw.unpack(\"NNN\")[2]\n\t\telsif (self.type & TLV_META_TYPE_BOOL == TLV_META_TYPE_BOOL)\n\t\t\tself.value = raw.unpack(\"NNc\")[2]\n\n\t\t\tif (self.value == 1)\n\t\t\t\tself.value = true\n\t\t\telse\n\t\t\t\tself.value = false\n\t\t\tend\n\t\telse\n\t\t\tself.value = raw[8..length-1]\n\t\tend\n\n\t\treturn length;\n\tend", "def serialize\n super(ATTR_NAME_ARY)\n end", "def serialize\n super(ATTR_NAME_ARY)\n end", "def serialize\n super(ATTR_NAME_ARY)\n end", "def serialize\n super(ATTR_NAME_ARY)\n end", "def serialize\n super(ATTR_NAME_ARY)\n end", "def inspect\n self.class.name + \"<#{container.type}>\" + \"{\" + container.accepted_elements.collect {|e|\n e.name + \":\" + (e.is_a?(Container) ? \"...\": self.send(e.name).inspect)\n }.join(',') + \"}\"\n end", "def encode\n ret = [ id & 0xff, id >> 8, data_type ]\n ret << Zigbee::ZCL::DataType.class_for(data_type).new(value).encode_data\n ret.flatten\n end", "def from_array(array)\n array.pack('U*')\n end", "def type_cast_code_with_patch(var_name)\n klass = self.class.name\n case type\n when /array$/\n base_type = type.to_s.gsub(/_array/, '')\n \"#{var_name}.from_postgres_array(:#{base_type.parameterize('_')})\"\n when :inet, :cidr\n \"#{klass}.cidr_to_string(#{var_name})\"\n else\n type_cast_code_without_patch(var_name)\n end\n end", "def to_s\n pad_field :data, :options\n recalc_block_len\n super\n end", "def to_s\n data = [@name.concat(Array.new(32 - @name.size, 0)),\n @name_size,\n @type,\n @color,\n @left,\n @right,\n @child,\n @created,\n @modified,\n @sector,\n @size].flatten\n data.pack(PACKING)\n end", "def flatten_struct!(fields, prefix: nil)\n fields.map do |field|\n type = field.first\n name = [prefix, field.last].compact.join(\"_\")\n\n if type.is_a? Array then\n flatten_struct!(type, prefix: name)\n else\n [[type.to_sym, name.to_sym]]\n end\n end.flatten(1)\n end", "def tags_raw\n tags.join(\"\\n\") unless tags.nil?\n end", "def _serializable_array\n if @options[:single_record]\n super.first\n else\n super\n end\n end", "def to_raw; end", "def get_field_deserializers()\n return super.merge({\n \"self\" => lambda {|n| @self_escaped = n.get_string_value() },\n })\n end", "def get_field_deserializers()\n return super.merge({\n \"cidrAddress\" => lambda {|n| @cidr_address = n.get_string_value() },\n })\n end", "def simplified_type_with_patch(field_type)\n case field_type\n when 'inet'\n :inet\n when 'cidr'\n :cidr\n when 'macaddr'\n :macaddr\n when /^numeric.+\\[\\]$/\n :decimal_array\n when /character varying.*\\[\\]/\n :string_array\n when /^(?:real|double precision)\\[\\]$/\n :float_array\n when /timestamp.*\\[\\]/\n :timestamp_array\n when /\\[\\]$/\n field_type.gsub(/\\[\\]/, '_array').to_sym\n else\n simplified_type_without_patch(field_type)\n end\n end", "def encode_to_array\n components = []\n components << [self.class.id, @channel, @payload.bytesize].pack(PACK_CHAR_UINT16_UINT32)\n components << self.class.encoded_payload(@payload)\n components << FINAL_OCTET\n components\n end", "def to_s\n pad_field :data\n recalc_block_len\n super\n end", "def serialize\n end", "def serialize(object)\n object ? constraint.convert(object) : []\n end", "def to_raw_data\n [@pao_type, @letter_pair.to_raw_data].join(SEPARATOR)\n end", "def to_vector\n return @vector_formatted_value if @vector_formatted_value\n\n vals = map(&:to_vector)\n vals.reverse! if endian == :little\n @vector_formatted_value = vals.join('')\n end", "def set_raw!(value)\n value = value.to_s\n\n @objects = nil\n @memory = FFI::MemoryPointer.new(:uchar, value.length) \n @memory.write_bytes(value)\n\n self[:type] = :raw\n\n raw = self[:values][:raw]\n raw[:size] = value.length\n raw[:ptr] = @memory\n end", "def node()\n result = super.stringify_keys\n result.merge! volume.attributes.stringify_keys unless volume.nil?\n result\n end", "def encode_bound_fields\n @bound_fields.map do |(name,value)|\n WordField[name].encode(value)\n end.inject do |memo,encoded_value|\n memo | encoded_value\n end\n end", "def marshal_load array\n initialize array[0]\n end", "def pack\n @volume_uuid + [@offset].pack(\"L\")\n end", "def json\n value.sub(/^serialized-/, '')\n end", "def normalize\n @data << \"\"\n end", "def wddx_serialize # :nodoc:\n \"<binary length='#{self.length}'>#{self.encode}</binary>\"\n end", "def to_s\n \"#<#{self.class}:0x%016x index=%d, id=%d, codec_type=:%s>\" %\n [ object_id, self[:index], self[:id], self[:codec][:codec_type] ]\n end", "def serialize(object)\n case object\n when String\n {\n type: \"string\",\n value: object,\n description: object\n }\n when Numeric\n {\n type: \"number\",\n value: object,\n description: object.to_s\n }\n when TrueClass, FalseClass\n {\n type: \"boolean\",\n value: object,\n description: object.to_s\n }\n when Symbol\n {\n type: \"symbol\",\n value: object,\n description: object.to_s\n }\n when Array\n result = {\n type: \"object\",\n className: object.class.to_s,\n description: \"Array(#{object.length})\",\n objectId: register(object),\n subtype: \"array\"\n }\n\n result.merge!(\n preview: result.merge(\n overflow: false,\n properties: get_properties(object)\n )\n )\n\n result\n when nil\n {\n type: \"object\",\n subtype: \"null\",\n value: nil\n }\n else\n {\n type: \"object\",\n className: object.class.to_s,\n description: object.to_s,\n objectId: register(object)\n }\n end\n end", "def convert_field_values_to_utf8!(struct)\n return nil if struct.nil?\n struct.each_with_index do |value, index|\n if value.is_a?(String)\n converted = Puppet::Util::CharacterEncoding.convert_to_utf_8!(value)\n struct[index] = converted if !converted.nil?\n elsif value.is_a?(Array)\n struct[index] = convert_array_values_to_utf8!(value)\n end\n end\n end", "def encode(options={})\n self.class.format.encode(attributes, {:root => self.class.element_name}.merge(options))\n end", "def remove_all_raws!\n @raws = {}\n end", "def to_s\n %w( name display_name uuid ).collect { |k| \"#{k}=#{ self.send(k) }\" }.join(' | ') + \" | types=#{ types.join(',') }\"\n end", "def package_array(array, opts = {})\n if array && array.size > 0\n serializer = \"#{array.first.class.name}Serializer\".safe_constantize\n opts[:meta] = { total: array.size }\n hash = serializer.new(array, opts).serializable_hash if serializer\n else\n {data: []}\n end\n end", "def get_field_deserializers()\n return super.merge({\n \"certificateList\" => lambda {|n| @certificate_list = n.get_collection_of_object_values(lambda {|pn| MicrosoftGraph::Models::Pkcs12CertificateInformation.create_from_discriminator_value(pn) }) },\n })\n end", "def serialize(tag_name_array, withscores=false)\n results = {data: []}\n if withscores\n # Not doing anything different here yet.\n # Can adjust to key:value in json if needed\n tag_name_array.each do |tag_name|\n results[:data] << {name: tag_name[0], votes: tag_name[1]}\n end\n else\n tag_name_array.each do |tag_name|\n results[:data] << {name: tag_name}\n end\n end\n return results\n end", "def to_s\n\n\t\tpuntero=@head\n\t\tcadena='['\n\t\t\tif(@head!=nil)\n\t\t\t\twhile (puntero!= nil) do\n\t\t\t\t\tcadena+=puntero.value.to_s + ']'\n\t\t\t\t\tif(puntero.nest!=nil)\n\t\t\t\t\t\tpuntero=puntero.nest\n\t\t\t\t\t\tcadena+= '['\n\t\t\t\t\telse\n\t\t\t\t\t\tpuntero=nil\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\n\tend", "def raw\n @raw = true\n self\n end", "def to_base\n RDF::NTriples.serialize(self).freeze\n end", "def [](name)\n field(name).convert(@raw)\n end", "def serialize_attrs\n @serialize_attrs ||= []\n end", "def encode\n Logger.debug \"encoding #{self.inspect}\"\n class_mapper = RocketAMF::ClassMapper.new\n ser = RocketAMF::Serializer.new class_mapper\n\n if amf3?\n ser.stream << \"\\x00\"\n end\n\n ser.serialize 0, command\n ser.serialize 0, transaction_id\n\n if amf3?\n ser.stream << \"\\x05\"\n ser.stream << \"\\x11\"\n ser.serialize 3, values.first\n else\n values.each do |value|\n ser.serialize 0, value\n end\n end\n\n ser.stream\n end", "def marshal_dump # :nodoc:\n [ @identifier, @handler, @compiled, @original_encoding, @locals, @virtual_path, @updated_at, @format, @variants ]\n end", "def to_binary\n Formatters::Binary.new.serialize self\n end", "def serialize(object) end", "def marshal\n @data\n end", "def all\n instantiate(raw)\n end", "def output_values(raw)\n raw.map do |x|\n if x.is_a? Array\n x.map!{|s| escape(s)}\n x.join(@internal_delimiter)\n else\n escape(x)\n end\n end\n end", "def to_s\n Forme.transform(:serializer, @opts, @form.opts, self)\n end", "def array_to_r_vector(array, options = {})\n options = {:string_vals => false}.merge(options)\n str = \"c(\"\n\n if options[:string_vals]\n array.each {|ret| str << '\\'' << ret.to_s << '\\'' << \",\"}\n else\n array.each {|ret| str << ret.to_s << \",\"}\n end\n\n str.chomp!(\",\")\n str << \")\"\n end", "def raw *things\n\t\t\tappend! things.join\n\t\tend", "def marshal_load(array)\n @dont_rename_initialize = nil\n @is_alias_for = nil\n @token_stream = nil\n\n @name = array[1]\n @full_name = array[2]\n @singleton = array[3]\n @visibility = array[4]\n @comment = array[5]\n @call_seq = array[6]\n @block_params = array[7]\n @aliases = array[8]\n @params = array[9]\n\n @parent_name = if @full_name =~ /#/ then\n $`\n else\n name = @full_name.split('::')\n name.pop\n name.join '::'\n end\n\n array[8].each do |old_name, new_name, comment|\n add_alias RDoc::Alias.new(nil, old_name, new_name, comment)\n end\n end", "def as_extended_json(**options)\n subtype = @raw_type.each_byte.map { |c| c.to_s(16) }.join\n subtype = \"0#{subtype}\" if subtype.length == 1\n\n value = Base64.encode64(data).strip\n\n if options[:mode] == :legacy\n { '$binary' => value, '$type' => subtype }\n else\n { '$binary' => { 'base64' => value, 'subType' => subtype } }\n end\n end", "def convert_all_pokemon\n pokemon_json = []\n @data.each_with_index do |pokemons, id|\n forms = []\n pokemon_json << {\n regionalId: pokemons.first.id_bis,\n db_symbol: pokemons.first.db_symbol || :__undef__,\n id: id,\n forms: forms\n }\n pokemons.each { |pokemon| forms << convert_single_pokemon(pokemon) if pokemon }\n end\n return pokemon_json\n end", "def add_tlv(t,l,v=nil)\n tlv = [(t << 9) + l, v]\n self.payload += tlv.flatten.pack(\"na*\")\n end", "def to_s\n raw\n end", "def to_s(flatten_form=true)\n fill(flatten_form)\n @baos.toByteArray\n end", "def to_s\n pad_field :data, :options\n recalc_block_len\n to_a.map(&:to_s).join\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 mongoize\n ::Array.mongoize(self)\n end", "def tags\n normal[:tags] = Array(normal[:tags])\n normal[:tags]\n end", "def collection_serialization_options\n {:except => [:variant_id, :type, :position], :methods => [:classification, :options]}\n end", "def to_raw_data\n @letters.join(SEPARATOR)\n end", "def serialize(options = T.unsafe(nil)); end", "def serialize(options = T.unsafe(nil)); end", "def encode\n type_byte + encode_data\n end", "def variants=(value)\n subtags = Array(value).flatten\n if subtags.empty?\n self.variants_sequence = nil\n else\n self.variants_sequence = subtags.join(HYPHEN)\n @variants = subtags\n end\n end", "def accept_raw raw\n @res << raw.parts.join(\"\\n\")\n end", "def accept_raw raw\n @res << raw.parts.join(\"\\n\")\n end", "def get_field_deserializers()\n return super.merge({\n \"additionalTags\" => lambda {|n| @additional_tags = n.get_collection_of_primitive_values(String) },\n \"contentWebUrl\" => lambda {|n| @content_web_url = n.get_string_value() },\n \"contributors\" => lambda {|n| @contributors = n.get_collection_of_primitive_values(String) },\n \"createdDateTime\" => lambda {|n| @created_date_time = n.get_date_time_value() },\n \"description\" => lambda {|n| @description = n.get_string_value() },\n \"duration\" => lambda {|n| @duration = n.get_duration_value() },\n \"externalId\" => lambda {|n| @external_id = n.get_string_value() },\n \"format\" => lambda {|n| @format = n.get_string_value() },\n \"isActive\" => lambda {|n| @is_active = n.get_boolean_value() },\n \"isPremium\" => lambda {|n| @is_premium = n.get_boolean_value() },\n \"isSearchable\" => lambda {|n| @is_searchable = n.get_boolean_value() },\n \"languageTag\" => lambda {|n| @language_tag = n.get_string_value() },\n \"lastModifiedDateTime\" => lambda {|n| @last_modified_date_time = n.get_date_time_value() },\n \"numberOfPages\" => lambda {|n| @number_of_pages = n.get_number_value() },\n \"skillTags\" => lambda {|n| @skill_tags = n.get_collection_of_primitive_values(String) },\n \"sourceName\" => lambda {|n| @source_name = n.get_string_value() },\n \"thumbnailWebUrl\" => lambda {|n| @thumbnail_web_url = n.get_string_value() },\n \"title\" => lambda {|n| @title = n.get_string_value() },\n })\n end" ]
[ "0.5961077", "0.55862504", "0.5171367", "0.5171367", "0.4940702", "0.4853383", "0.48212346", "0.47799745", "0.47709346", "0.47346047", "0.47083202", "0.4617202", "0.4575752", "0.4575752", "0.45729294", "0.4497814", "0.44894177", "0.4464", "0.4462754", "0.44606584", "0.44339305", "0.44259837", "0.44199142", "0.44062024", "0.44062024", "0.44062024", "0.44062024", "0.44062024", "0.43883365", "0.43776482", "0.43547222", "0.4352297", "0.43408975", "0.4314743", "0.43054295", "0.4304208", "0.42995757", "0.42989513", "0.42899147", "0.42673987", "0.4263857", "0.4263601", "0.42527905", "0.4245581", "0.42388836", "0.42345837", "0.42226297", "0.42139724", "0.42110077", "0.42079893", "0.419261", "0.41916397", "0.41893974", "0.41751736", "0.41731605", "0.41712096", "0.4155553", "0.41554365", "0.41514215", "0.41479033", "0.41447935", "0.41414127", "0.4138868", "0.41387182", "0.41298252", "0.4127604", "0.41216478", "0.4119946", "0.41136023", "0.41108504", "0.4109497", "0.41082948", "0.4102103", "0.41012812", "0.40964535", "0.40961644", "0.40908676", "0.40763506", "0.40647587", "0.40627787", "0.40613464", "0.40562785", "0.40557954", "0.40554887", "0.40461954", "0.40437734", "0.4043446", "0.4043446", "0.40389046", "0.40293324", "0.40276176", "0.4027403", "0.40267792", "0.40267792", "0.40266815", "0.40240827", "0.40211818", "0.40211818", "0.40209886" ]
0.52299935
3
Converts the TLV group container from raw to all of the individual TLVs.
def from_r(raw) offset = 8 # Reset the TLVs array self.tlvs = [] self.type = raw.unpack("NN")[1] # Enumerate all of the TLVs while (offset < raw.length-1) tlv = nil # Get the length and type length, type = raw[offset..offset+8].unpack("NN") if (type & TLV_META_TYPE_GROUP == TLV_META_TYPE_GROUP) tlv = GroupTlv.new(type) else tlv = Tlv.new(type) end tlv.from_r(raw[offset..offset+length]) # Insert it into the list of TLVs tlvs << tlv # Move up offset += length end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def from_r(raw)\n\t\tself.value = nil\n\n\t\tlength, self.type = raw.unpack(\"NN\");\n\n\t\t# check if the tlv value has been compressed...\n\t\tif( self.type & TLV_META_TYPE_COMPRESSED == TLV_META_TYPE_COMPRESSED )\n\t\t\t# set this TLV as using compression\n\t\t\t@compress = true\n\t\t\t# remove the TLV_META_TYPE_COMPRESSED flag from the tlv type to restore the \n\t\t\t# tlv type to its origional, allowing for transparent data compression.\n\t\t\tself.type = self.type ^ TLV_META_TYPE_COMPRESSED\n\t\t\t# decompress the compressed data (skipping the length and type DWORD's)\n\t\t\traw_decompressed = Rex::Text.zlib_inflate( raw[8..length-1] )\n\t\t\t# update the length to reflect the decompressed data length (+8 for the length and type DWORD's)\n\t\t\tlength = raw_decompressed.length + 8\n\t\t\t# update the raw buffer with the new length, decompressed data and updated type.\n\t\t\traw = [length, self.type].pack(\"NN\") + raw_decompressed\n\t\tend\n\t\t\n\t\tif (self.type & TLV_META_TYPE_STRING == TLV_META_TYPE_STRING)\n\t\t\tif (raw.length > 0)\n\t\t\t\tself.value = raw[8..length-2]\n\t\t\telse\n\t\t\t\tself.value = nil\n\t\t\tend\n\t\telsif (self.type & TLV_META_TYPE_UINT == TLV_META_TYPE_UINT)\n\t\t\tself.value = raw.unpack(\"NNN\")[2]\n\t\telsif (self.type & TLV_META_TYPE_BOOL == TLV_META_TYPE_BOOL)\n\t\t\tself.value = raw.unpack(\"NNc\")[2]\n\n\t\t\tif (self.value == 1)\n\t\t\t\tself.value = true\n\t\t\telse\n\t\t\t\tself.value = false\n\t\t\tend\n\t\telse\n\t\t\tself.value = raw[8..length-1]\n\t\tend\n\n\t\treturn length;\n\tend", "def to_r\n\t\traw = value.to_s;\n\n\t\tif (self.type & TLV_META_TYPE_STRING == TLV_META_TYPE_STRING)\n\t\t\traw += \"\\x00\"\n\t\telsif (self.type & TLV_META_TYPE_UINT == TLV_META_TYPE_UINT)\n\t\t\traw = [value].pack(\"N\")\n\t\telsif (self.type & TLV_META_TYPE_BOOL == TLV_META_TYPE_BOOL)\n\t\t\tif (value == true)\n\t\t\t\traw = [1].pack(\"c\")\n\t\t\telse\n\t\t\t\traw = [0].pack(\"c\")\n\t\t\tend\n\t\tend\n\t\t\n\t\t# check if the tlv is to be compressed...\n\t\tif( @compress )\n\t\t\traw_uncompressed = raw\n\t\t\t# compress the raw data\n\t\t\traw_compressed = Rex::Text.zlib_deflate( raw_uncompressed )\n\t\t\t# check we have actually made the raw data smaller...\n\t\t\t# (small blobs often compress slightly larger then the origional) \n\t\t\t# if the compressed data is not smaller, we dont use the compressed data\n\t\t\tif( raw_compressed.length < raw_uncompressed.length )\n\t\t\t\t# if so, set the TLV's type to indicate compression is used\n\t\t\t\tself.type = self.type | TLV_META_TYPE_COMPRESSED\n\t\t\t\t# update the raw data with the uncompressed data length + compressed data\n\t\t\t\t# (we include the uncompressed data length as the C side will need to know this for decompression)\n\t\t\t\traw = [ raw_uncompressed.length ].pack(\"N\") + raw_compressed\n\t\t\tend\n\t\tend\n\t\t\n\t\treturn [raw.length + 8, self.type].pack(\"NN\") + raw\n\tend", "def from_r(raw)\n\t\tself.value = nil\n\n\t\tlength, self.type = raw.unpack(\"NN\");\n\n\t\tif (self.type & TLV_META_TYPE_STRING == TLV_META_TYPE_STRING)\n\t\t\tif (raw.length > 0)\n\t\t\t\tself.value = raw[8..length-2]\n\t\t\telse\n\t\t\t\tself.value = nil\n\t\t\tend\n\t\telsif (self.type & TLV_META_TYPE_UINT == TLV_META_TYPE_UINT)\n\t\t\tself.value = raw.unpack(\"NNN\")[2]\n\t\telsif (self.type & TLV_META_TYPE_BOOL == TLV_META_TYPE_BOOL)\n\t\t\tself.value = raw.unpack(\"NNc\")[2]\n\n\t\t\tif (self.value == 1)\n\t\t\t\tself.value = true\n\t\t\telse\n\t\t\t\tself.value = false\n\t\t\tend\n\t\telse\n\t\t\tself.value = raw[8..length-1]\n\t\tend\n\n\t\treturn length;\n\tend", "def tlv_select\n info 'os10_lldp_interface::tlv select'\n begin\n lldp_interface_data = @tlv_ret[:stdout].split(\"\\n\")\n temp_data = {}\n\n lldp_interface_data.each do |data|\n if data.include? 'lldp tlv-select'\n tlv_data = data.split(' ')\n if tlv_data.length == 4\n temp_data[tlv_data[3]] = [' ']\n elsif temp_data[tlv_data[3]].nil? && tlv_data.length >= 4\n temp_data[tlv_data[3]] = [tlv_data[4]]\n elsif tlv_data[4]\n temp_data[tlv_data[3]] = temp_data[tlv_data[3]] << tlv_data[4]\n temp_data[tlv_data[3]] = temp_data[tlv_data[3]].sort\n end\n end\n end\n return temp_data\n rescue Exception => e\n err 'Exception in tlv select'\n err e.message\n err e.backtrace[0]\n raise\n end\n end", "def parse_raw_data\n data_slices.to_a\n end", "def parse(output) #:nodoc:\n volumes = []\n\n output.split(\"\\n\").each do |line|\n args = process_line(attributes, line)\n\n # now we force some types to ints since we've requested them as bytes\n # without a suffix\n args[:size] = args[:size].to_i\n\n # we resolve the attributes line to nicer symbols\n args.merge!(parse_vg_attr(args[:attr]))\n\n # finally build our object\n volume = VolumeGroup.new(args)\n\n if block_given?\n yield volume\n else\n volumes << volume\n end\n end\n\n return volumes\n end", "def parse(rawdata)\n end", "def parse_content_raw(parser)\n elements = parser.parse(@content_raw)\n elements.each do |element|\n\n # correct line-numbers\n element.line_number += @line_number\n\n if element.kind_of?(Attribute)\n @attribs[element.name.to_sym] = element.value\n else\n element.parse_content_raw(parser)\n @children << element\n end\n end\n end", "def to_r\n\t\traw = value.to_s;\n\n\t\tif (self.type & TLV_META_TYPE_STRING == TLV_META_TYPE_STRING)\n\t\t\traw += \"\\x00\"\n\t\telsif (self.type & TLV_META_TYPE_UINT == TLV_META_TYPE_UINT)\n\t\t\traw = [value].pack(\"N\")\n\t\telsif (self.type & TLV_META_TYPE_BOOL == TLV_META_TYPE_BOOL)\n\t\t\tif (value == true)\n\t\t\t\traw = [1].pack(\"c\")\n\t\t\telse\n\t\t\t\traw = [0].pack(\"c\")\n\t\t\tend\n\t\tend\n\n\t\treturn [raw.length + 8, self.type].pack(\"NN\") + raw\n\tend", "def to_r\n\t\traw = ''\n\n\t\tself.each() { |tlv|\n\t\t\traw << tlv.to_r\n\t\t}\n\n\t\treturn [raw.length + 8, self.type].pack(\"NN\") + raw\n\tend", "def to_r\n\t\traw = ''\n\n\t\tself.each() { |tlv|\n\t\t\traw << tlv.to_r\n\t\t}\n\n\t\treturn [raw.length + 8, self.type].pack(\"NN\") + raw\n\tend", "def process_group_data( node, loop_detection = [] )\n result = []\n \n case node.type.name\n when \"group_spec\"\n node.specifications.each do |spec|\n if elements = process_group_data(spec, loop_detection) then\n result.concat elements\n else\n nyi( \"what happens here?\" )\n end\n end\n \n when \"rule_spec\"\n result << Reference.new(create_name(node.name))\n \n when \"spec_reference\"\n name = node.name.text\n if @specifications.member?(name) then\n spec = @specifications[name]\n \n case spec.type.name\n when \"group_spec\"\n if @group_defs.member?(name) then\n result.concat @group_defs[name].member_references.collect{|r| r.clone()}\n else\n \n #\n # If we have to process a :group_spec directly, we don't store the result. This is because\n # we flatten groups via transitive closure, and shortcut out if we detect a loop (ie. somebody\n # \"above us\" is already processing it). We don't want to store such partial results.\n \n unless loop_detection.member?(name)\n result.concat process_group_data(spec, loop_detection + [name])\n end\n end\n \n when \"rule_spec\"\n result << Reference.new( create_name(node.name) )\n else\n nyi( \"error handling for group reference to macro or other ineligible name [#{name}]\" )\n end\n else\n nyi( \"error handling for missing rule/word/character reference in group [#{name}]\", node )\n end\n else\n nyi( \"support for node type [#{node.type}]\", node )\n end\n \n return result\n end", "def parse_all\n @raw_string.split( \"\\n\" ).each do |line|\n parse_line( line )\n end\n @all.values\n end", "def all\n instantiate(raw)\n end", "def parse_controls\n controls = []\n @transformed_data.each do |contr|\n nist = find_nist(contr[:cis]) unless contr[:cis] == 'No CIS Control'\n control = {}\n control['id'] = \"M-#{contr[:title].split[0]}\"\n control['title'] = contr[:title]\n control['desc'] = contr[:descr]\n control['impact'] = Utils::InspecUtil.get_impact('medium')\n control['tags'] = {}\n control['tags']['severity'] = Utils::InspecUtil.get_impact_string(control['impact'])\n control['tags']['ref'] = contr[:ref] unless contr[:ref].nil?\n control['tags']['applicability'] = contr[:applicability] unless contr[:applicability].nil?\n control['tags']['cis_id'] = contr[:title].split[0] unless contr[:title].nil?\n control['tags']['cis_control'] = [contr[:cis], @nist_mapping[0][:cis_ver]] unless contr[:cis].nil? # tag cis_control: [5, 6.1] ##6.1 is the version\n control['tags']['cis_level'] = contr[:level] unless contr[:level].nil?\n control['tags']['nist'] = nist unless nist.nil? # tag nist: [AC-3, 4] ##4 is the version\n control['tags']['check'] = contr[:check] unless contr[:check].nil?\n control['tags']['fix'] = contr[:fix] unless contr[:fix].nil?\n control['tags']['Default Value'] = contr[:default] unless contr[:default].nil?\n controls << control\n end\n controls\n end", "def handle_grouped_chunk(grouped_chunk, bt_mode, timestamp)\n tx_power = nil\n grouped_chunk.each do |grp|\n\n # when we only have a single line in a group we can handle simply\n if grp.count == 1\n line = grp[0]\n\n # next line was not nested, treat as single line\n parse_single_line(line, bt_mode, timestamp, tx_power)\n\n # if we have multiple lines in our group of lines determine how to\n # process and set\n else\n case\n\n # these special messags had effectively duplicate header lines\n # which is be shifted off and then re-grouped\n when grp[0] =~ /^\\s+(LE|ATT|L2CAP)/\n grp.shift\n grp = group_by_depth(grp)\n grp.each do |entry|\n if entry.count == 1\n line = entry[0]\n parse_single_line(line, bt_mode, timestamp, tx_power)\n else\n handle_grouped_chunk(grp, bt_mode, timestamp)\n end\n end\n\n # Attribute type: Primary Service (0x2800)\n # UUID: Unknown (7905f431-b5ce-4e99-a40f-4b1e122d00d0)\n when grp[0] =~ /^\\s+Attribute type: Primary Service/\n vals = grp.map(&:strip)\n uuid = vals.select{|x| x =~ /^UUID/}[0]\n set_attr(\"#{bt_mode}_service_uuids\".to_sym, uuid.split(': ')[1])\n\n when grp[0] =~ /^\\s+Flags:/\n grp.shift\n vals = grp.map(&:strip)\n set_attr(\"#{bt_mode}_flags\".to_sym, vals.join(\", \"))\n\n\n # Page: 1/1\n # Features: 0x07 0x00 0x00 0x00 0x00 0x00 0x00 0x00\n # Secure Simple Pairing (Host Support)\n # LE Supported (Host)\n # Simultaneous LE and BR/EDR (Host)\n when grp[0] =~ /^\\s+Page/\n page = grp.shift.split(':')[1].strip.split('/')[0]\n bitmap = grp.shift.split(':')[1].strip\n vals = grp.map(&:strip)\n set_attr(\"#{bt_mode}_features_bitmap\".to_sym, [page, bitmap])\n set_attr(\"#{bt_mode}_features\".to_sym, vals.join(\", \"))\n\n # Features: 0x07 0x00 0x00 0x00 0x00 0x00 0x00 0x00\n # Secure Simple Pairing (Host Support)\n # LE Supported (Host)\n # Simultaneous LE and BR/EDR (Host)\n when grp[0] =~ /^\\s+Features/\n bitmap = grp.shift.split(':')[1].strip\n vals = grp.map(&:strip)\n\n # default page value is here set to '0'\n set_attr(\"#{bt_mode}_features_bitmap\".to_sym, ['0',bitmap])\n set_attr(\"#{bt_mode}_features\".to_sym, vals.join(\", \"))\n\n when grp[0] =~ /^\\s+Channels/\n header = grp.shift.split(':')[1].strip\n vals = grp.map(&:strip)\n vals.unshift(header)\n set_attr(\"#{bt_mode}_channels\".to_sym, vals.join(\", \"))\n\n # not in spec fixtures...\n # \" 128-bit Service UUIDs (complete): 2 entries\\r\\n\",\n # \" 00000000-deca-fade-deca-deafdecacafe\\r\\n\",\n # \" 2d8d2466-e14d-451c-88bc-7301abea291a\\r\\n\",\n when grp[0] =~ /128-bit Service UUIDs \\((complete|partial)\\):/\n grp.shift # header line\n vals = grp.map(&:strip)\n vals.each do |uuid|\n set_attr(\"#{bt_mode}_service_uuids\".to_sym, uuid)\n end\n\n # Company: Apple, Inc. (76)\n # Type: iBeacon (2)\n # UUID: 7988f2b6-dc41-1291-8746-ecf83cc7a06c\n # Version: 15104.61591\n # TX power: -56 dB\n # Data: 01adddd439aed386c76574e9ab9e11958e25c1f70ae203\n\n when grp[0] =~ /Company:/\n vals = grp.map(&:strip)\n\n #hack because datamapper doesn't respect varchar255 setting\n company_tmp = vals.shift.split(': ')[1]\n company_hex = company_tmp.scan(/\\(([^)]+)\\)/).flatten[0].to_i.to_s(16)\n if company_tmp.length > 49 && company_tmp.scan(/\\(/).count == 2\n company_tmp = company_tmp.split('(')\n company_tmp.delete_at(1)\n company_tmp = company_tmp.join('(')\n if company_tmp.length > 49\n BlueHydra.logger.warn(\"Attempted to handle long company and still too long:\")\n BlueHydra.logger.warn(\"company_tmp: #{company_tmp}\")\n BlueHydra.logger.warn(\"Truncating company...\")\n company_tmp = company_tmp[0,49]\n end\n end\n if company_tmp.length > 49\n BlueHydra.logger.warn(\"Did not attempt to handle long company and still too long:\")\n BlueHydra.logger.warn(\"company_tmp: #{company_tmp}\")\n BlueHydra.logger.warn(\"Truncating company...\")\n company_tmp = company_tmp[0,49]\n end\n\n set_attr(:company, company_tmp)\n\n # Company can also contain multiple types....\n # so we need to reset the parsing on every Type line\n\n # Company: Apple, Inc. (76)\n # Type: Unknown (12)\n # Data: 00188218be794011f7678726540b\n # Type: Unknown (16)\n # Data: 1b1ca2bea2\n\n company_type = nil\n company_type_last_set = nil\n vals.each do |company_line|\n case\n when company_line =~ /^Type:/\n company_type = company_line.split(': ')[1]\n company_type_hex = company_type.scan(/\\(([^)]+)\\)/).flatten[0].to_i.to_s(16)\n company_type_last_set = timestamp.split(': ')[1].to_f\n set_attr(:company_type, company_type)\n flipped_prox_uuid = nil\n major = nil\n minor = nil\n when company_line =~ /^UUID:/\n if company_type && company_type =~ /\\(2\\)/ && company_type_last_set && company_type_last_set == timestamp.split(': ')[1].to_f\n flipped_prox_uuid = company_line.split(': ')[1].gsub('-','').scan(/.{2}/).reverse.join.scan(/(.{8})(.{4})(.{4})(.*)/).join('-')\n set_attr(\"#{bt_mode}_proximity_uuid\".to_sym, flipped_prox_uuid)\n else\n set_attr(\"#{bt_mode}_company_uuid\".to_sym, company_line.split(': ')[1])\n end\n when company_line =~/^Version:/\n if company_type && company_type =~ /\\(2\\)/ && company_type_last_set && company_type_last_set == timestamp.split(': ')[1].to_f\n #bluez decodes this as little endian but it's actually big so we have to reverse it\n major = company_line.split(': ')[1].split('.')[0].to_i.to_s(16).rjust(4, '0').scan(/.{2}/).map { |i| i.to_i(16).chr }.join.unpack('S<*').first\n minor = company_line.split(': ')[1].split('.')[1].to_i.to_s(16).rjust(4, '0').scan(/.{2}/).map { |i| i.to_i(16).chr }.join.unpack('S<*').first\n set_attr(\"#{bt_mode}_major_num\".to_sym, major)\n set_attr(\"#{bt_mode}_minor_num\".to_sym, minor)\n else\n set_attr(\"#{bt_mode}_company_version\".to_sym, company_line.split(': ')[1])\n end\n when company_line =~ /^TX power:/\n tx_power = company_line.split(': ')[1]\n set_attr(\"#{bt_mode}_tx_power\".to_sym, tx_power)\n when company_line =~ /^Data:/\n set_attr(\"#{bt_mode}_company_data\".to_sym, company_line.split(': ')[1])\n end\n end\n\n # not in spec fixtures...\n # \" 16-bit Service UUIDs (complete): 7 entries\\r\\n\",\n # \" PnP Information (0x1200)\\r\\n\",\n # \" Handsfree Audio Gateway (0x111f)\\r\\n\",\n # \" Phonebook Access Server (0x112f)\\r\\n\",\n # \" Audio Source (0x110a)\\r\\n\",\n # \" A/V Remote Control Target (0x110c)\\r\\n\",\n # \" NAP (0x1116)\\r\\n\",\n # \" Message Access Server (0x1132)\\r\\n\",\n when grp[0] =~ /16-bit Service UUIDs \\(complete\\):/\n grp.shift # header line\n vals = grp.map(&:strip)\n vals.each do |uuid|\n set_attr(\"#{bt_mode}_uuids\".to_sym, uuid)\n end\n\n # not in spec fixtures...\n # \" Class: 0x7a020c\\r\\n\",\n # \" Major class: Phone (cellular, cordless, payphone, modem)\\r\\n\",\n # \" Minor class: Smart phone\\r\\n\",\n # \" Networking (LAN, Ad hoc)\\r\\n\",\n # \" Capturing (Scanner, Microphone)\\r\\n\",\n # \" Object Transfer (v-Inbox, v-Folder)\\r\\n\",\n # \" Audio (Speaker, Microphone, Headset)\\r\\n\",\n # \" Telephony (Cordless telephony, Modem, Headset)\\r\\n\",\n when grp[0] =~ /Class:/\n grp = grp.map(&:strip)\n vals = []\n\n grp.each do |line|\n case\n when line =~ /^Class:/\n vals << line.split(':')[1].strip\n when line =~ /^Major class:/\n set_attr(\"#{bt_mode}_major_class\".to_sym, line.split(':')[1].strip)\n when line =~ /^Minor class:/\n set_attr(\"#{bt_mode}_minor_class\".to_sym, line.split(':')[1].strip)\n else\n vals << line\n end\n end\n\n set_attr(\"#{bt_mode}_class\".to_sym, vals) unless vals.empty?\n\n when grp[0] =~ /^\\s+Manufacturer/\n grp.map do |line|\n parse_single_line(line, bt_mode, timestamp)\n end\n\n else\n set_attr(\"#{bt_mode}_unknown\".to_sym, grp.inspect)\n end\n end\n end\n end", "def bytes_to_items(raw_data)\n (0...raw_data.length).step(2).each do |i|\n @items[i/2] = Item.new raw_data[i], raw_data[i+1]\n end\n end", "def remove_all_raws!\n @raws = {}\n end", "def add_tlv(type, value = nil, replace = false, compress=false)\n\n\t\t# If we should replace any TLVs with the same type...remove them first\n\t\tif (replace)\n\t\t\teach(type) { |tlv|\n\t\t\t\tif (tlv.type == type)\n\t\t\t\t\tself.tlvs.delete(tlv)\n\t\t\t\tend\n\t\t\t}\n\t\tend\n\n\t\tif (type & TLV_META_TYPE_GROUP == TLV_META_TYPE_GROUP)\n\t\t\ttlv = GroupTlv.new(type)\n\t\telse\n\t\t\ttlv = Tlv.new(type, value, compress)\n\t\tend\n\n\t\tself.tlvs << tlv\n\n\t\treturn tlv\n\tend", "def all\n containers = service.list_containers\n data = []\n containers.each do |container|\n c = parse_storage_object(container)\n c[:acl] = 'unknown'\n data << c\n end\n load(data)\n end", "def parse_multipart_alternative raw_body\n\n\t\t# Use the boundary to split up each part of the email\n\t\tboundary = get_boundary(@headers[\"Content-Type\"])\n\t\tbodies = raw_body.split(boundary + \"\\n\")[1..-1].map { |body|\n\n\t\t\t# Lather, rinse, repeat: get the content and bodies of each part, then parse\n\t\t\tbody_content_type = body.split(\"Content-Type: \", 2).last.split(\";\", 2).first\n\t\t\tbody = body.split(/\\n\\n/, 2).last.gsub(/#{boundary}--/, \"\")\n\t\t\tparse_body(body_content_type, body)\n\t\t}.flatten\n\tend", "def parse_tag_collection(body)\n dom = parse_and_validate_response(body, :root_name => 'tags')\n dom.root.elements.collect('tag') { |xml| Tag.from_rexml(xml) }\n end", "def accept_raw raw\n @res << raw.parts.join(\"\\n\")\n end", "def accept_raw raw\n @res << raw.parts.join(\"\\n\")\n end", "def add_tlv(type, value = nil, replace = false)\n\t\ttlv = nil\n\n\t\t# If we should replace any TLVs with the same type...remove them first\n\t\tif (replace)\n\t\t\teach(type) { |tlv|\n\t\t\t\tif (tlv.type == type)\n\t\t\t\t\tself.tlvs.delete(tlv)\n\t\t\t\tend\n\t\t\t}\n\t\tend\n\n\t\tif (type & TLV_META_TYPE_GROUP == TLV_META_TYPE_GROUP)\n\t\t\ttlv = GroupTlv.new(type)\n\t\telse\n\t\t\ttlv = Tlv.new(type, value)\n\t\tend\n\n\t\tself.tlvs << tlv\n\n\t\treturn tlv\n\tend", "def build_groups # rubocop:disable Metrics/AbcSize\n group_array = []\n @data['controls'].each do |control|\n group = HappyMapperTools::Benchmark::Group.new\n group.id = control['id']\n group.title = control['gtitle']\n group.description = \"<GroupDescription>#{control['gdescription']}</GroupDescription>\" if control['gdescription']\n\n group.rule = HappyMapperTools::Benchmark::Rule.new\n group.rule.id = control['rid']\n group.rule.severity = control['severity']\n group.rule.weight = control['rweight']\n group.rule.version = control['rversion']\n group.rule.title = control['title'].tr(\"\\n\", ' ') if control['title']\n group.rule.description = \"<VulnDiscussion>#{control['desc'].tr(\"\\n\", ' ')}</VulnDiscussion><FalsePositives></FalsePositives><FalseNegatives></FalseNegatives><Documentable>false</Documentable><Mitigations></Mitigations><SeverityOverrideGuidance></SeverityOverrideGuidance><PotentialImpacts></PotentialImpacts><ThirdPartyTools></ThirdPartyTools><MitigationControl></MitigationControl><Responsibility></Responsibility><IAControls></IAControls>\"\n\n if ['reference.dc.publisher', 'reference.dc.title', 'reference.dc.subject', 'reference.dc.type', 'reference.dc.identifier'].any? { |a| @attribute.key?(a) }\n group.rule.reference = build_rule_reference\n end\n\n group.rule.ident = build_rule_idents(control['cci']) if control['cci']\n\n group.rule.fixtext = HappyMapperTools::Benchmark::Fixtext.new\n group.rule.fixtext.fixref = control['fix_id']\n group.rule.fixtext.fixtext = control['fix']\n\n group.rule.fix = build_rule_fix(control['fix_id']) if control['fix_id']\n\n group.rule.check = HappyMapperTools::Benchmark::Check.new\n group.rule.check.system = control['checkref']\n\n # content_ref is optional for schema compliance\n if @attribute['content_ref.name'] || @attribute['content_ref.href']\n group.rule.check.content_ref = HappyMapperTools::Benchmark::ContentRef.new\n group.rule.check.content_ref.name = @attribute['content_ref.name']\n group.rule.check.content_ref.href = @attribute['content_ref.href']\n end\n\n group.rule.check.content = control['check']\n\n group_array << group\n end\n @benchmark.group = group_array\n end", "def normalize_all_albums\n albums.each{|tuple| normalize_album(tuple[:albid])}\n end", "def parse\n @chunks = parse_chunks extract_chunks decode_blob @blob\n end", "def parse_multipart_alternative raw_body\n\n # Use the boundary to split up each part of the email\n boundary = get_boundary(@headers[\"Content-Type\"])\n bodies = raw_body.split(boundary + \"\\n\")[1..-1].map { |body|\n\n # Lather, rinse, repeat: get the content and bodies of each part, then parse\n body_content_type = body.split(\"Content-Type: \", 2).last.split(\";\", 2).first\n body = body.split(/\\n\\n/, 2).last.gsub(/#{boundary}--/, \"\")\n parse_body(body_content_type, body)\n }.flatten\n end", "def tags_raw=(values)\n self.tags = []\n self.tags = values.split(\"\\n\").map { |w| w.strip }\n end", "def tags_raw=(values)\n self.tags = []\n self.tags = values.split(\"\\n\").map(&:strip)\n end", "def convert_field_values_to_utf8!(struct)\n return nil if struct.nil?\n struct.each_with_index do |value, index|\n if value.is_a?(String)\n converted = Puppet::Util::CharacterEncoding.convert_to_utf_8!(value)\n struct[index] = converted if !converted.nil?\n elsif value.is_a?(Array)\n struct[index] = convert_array_values_to_utf8!(value)\n end\n end\n end", "def delete_all_vlan_groups\n super\n end", "def parse_bit_fields raw\n @raw = raw\n \n # Setup\n @unpacked = @raw.unpack( self.class.unpack_recipe )\n @attributes ||= {}\n \n self.class.fields.each_with_index do |name, position|\n \n @attributes[name] = @unpacked[position]\n \n if bit_fields = self.class.bit_fields[name]\n \n bit_value = attributes[name]\n \n # We must extract bits from end since \n # ruby doesn't have types (and fixed lengths)\n bit_fields.reverse.each do |(bit_name, bits_number, bit_mask)|\n @attributes[bit_name] = bit_value & bit_mask\n bit_value = bit_value >> bits_number\n end\n end\n end\n end", "def unpack raw, limit: nil\n raw = ::StringIO.new raw unless raw.respond_to? :read\n result = []\n \n # Either loop infinately or the number of times \n # specified by limit\n \n (limit.nil? ? loop : limit.times).each do\n result << unpack_single(raw)\n end\n \n return result\n rescue EndOfPacket\n return result\n end", "def preprocess___tags data\n\t\tname = 'general' \n\t\ttags_alaise = [:tag, :type]\n\t\ttags_alaise.each do | item |\n\t\t\tname = data.delete(item) if data.include?(item)\n\t\tend\n\t\tif DB[:_tags].filter(:name => name).empty?\n\t\t\tDB[:_tags].insert(:name => name) \n\t\tend\n\t\tdata[:tid] = DB[:_tags].filter(:name => name).get(:tid)\n\t\tdata\n\tend", "def convert_groups(json)\n hash = JSON.parse(json)\n hash.map{|gr| FilmOn::Group.new(gr)}\n end", "def labeled_group(field, options={})\n options = { :id => field_id(field), :selected => field_value(field) }.update(options)\n options.update(error_class(field)){ |_,*values| values.compact.join(' ') }\n selected_values = resolve_checked_values(field, options)\n variants_for_group(options).inject(SafeBuffer.new) do |html, (caption,value)|\n variant_id = \"#{options[:id]}_#{value}\"\n attributes = { :value => value, :id => variant_id, :checked => selected_values.include?(value) }\n caption = yield(attributes) << ' ' << caption\n html << @template.label_tag(\"#{field_name(field)}[]\", :for => variant_id, :caption => caption)\n end\n end", "def convertAllUnits\n # Let the user know what we're doing\n puts \"Converting units.\"\n startTime = Time.now\n\n # Load allStruct and traverse it. This will create Unit and Unit_hier records for all units,\n # and delete any extraneous old ones.\n DB.transaction do\n allStructPath = \"/apps/eschol/erep/xtf/style/textIndexer/mapping/allStruct.xml\"\n open(allStructPath, \"r\") { |io|\n convertUnits(Nokogiri::XML(io, &:noblanks).root, {}, {}, Set.new)\n }\n end\nend", "def general_parse(_index = 0)\n array = @socket_array[_index][0].force_encoding('utf-8').strip.split(\"\\\\\")\n array.delete(array.first) # Remove blank first item\n\n keys = []\n values = []\n\n array.each_with_index do |object, index|\n keys << object if index.even?\n values << object if index.odd?\n end\n\n keys.each_with_index do |key, index|\n value = values[index]\n @status[\"#{key}\"] = value if @mode == 'status'\n @general[\"#{key}\"]= value if @mode != 'status'\n end\n end", "def transform(raw_data)\n if self.content =~ /\\A(---.*?)---(.*)/m\n self.attributes = YAML.load($1).symbolize_keys\n self.content = $2\n\n [:created_at, :updated_at].each do |field|\n attr = self.attributes[field]\n self.attributes[field] = Time.parse(attr) if attr\n end\n end\n end", "def all\n @raw.map { |l| l['language'] }\n end", "def to_boxes\n boxes = []\n @contents.each do |c|\n if @type == VERTICAL\n boxes << Box.new(c[0], 0, c[1], c[2])\n else\n boxes << Box.new(0, c[0], c[2], c[1])\n end\n end\n boxes\n end", "def normalize_fields\n new_fields = CICPHash.new\n fields.each do |key, value|\n new_fields[key] = ApeItem.create(key, value).normalize_encodings\n end\n @fields = new_fields\n end", "def convert_v_card(data, target)\n data = VObject::Reader.read(data)\n case target\n when 'vcard4'\n data = data.convert(VObject::Document::VCARD40)\n new_result = data.serialize\n when 'jcard'\n data = data.convert(VObject::Document::VCARD40)\n new_result = data.json_serialize.to_json\n else\n data = data.convert(VObject::Document::VCARD30)\n new_result = data.serialize\n end\n\n # Destroy circular references to PHP will GC the object.\n data.destroy\n\n new_result\n end", "def normalize_data(sort_mode)\n $logger.info('Normalizing group data...')\n groups_grouped = @groups.collect(&:to_hash).group_by do|a|\n { 'gid' => a['gid'],\n 'name' => a['name'],\n 'members' => a['members'] }\n end\n out = groups_grouped.collect do |a|\n a[0].merge('nodes' => a[1].collect { |b| b['source_node'] }.uniq.sort!)\n end\n out.compact!\n out = out.group_by do |a|\n { 'gid' => a['gid'], 'name' => a['name'], 'membership' => { 'members' => a['members'], 'nodes' => a['nodes'] } }\n end\n out = out.keys\n out = out.group_by { |a| { 'gid' => a['gid'], 'name' => a['name'] } }.collect do |a|\n a[0].merge('membership' => a[1].collect { |b| b['membership'] })\n end\n sort_key = sort_mode == 'id' ? 'gid' : 'name'\n out.sort! { |a, b| a[sort_key] <=> b[sort_key] }\n end", "def all\n @all ||= raw.map { |item| new(item) }\n end", "def deconvert\n result = []\n yield result\n array.each do |converted_item|\n result << UniversalDumper.deconvert(converted_item)\n end\n result\n end", "def convert_all_pokemon\n pokemon_json = []\n @data.each_with_index do |pokemons, id|\n forms = []\n pokemon_json << {\n regionalId: pokemons.first.id_bis,\n db_symbol: pokemons.first.db_symbol || :__undef__,\n id: id,\n forms: forms\n }\n pokemons.each { |pokemon| forms << convert_single_pokemon(pokemon) if pokemon }\n end\n return pokemon_json\n end", "def _parse_for_prot_groups(stream, with_peps=false, tp='axml')\n prtgrps = []\n case tp\n when 'axml'\n root = AXML.parse(stream)\n root.protein_group.each do |protein_group|\n pg = ProtGroup.new(protein_group.attrs) do \n protein_group.map do |protein|\n Prot.new(protein.attrs)\n end\n end\n prtgrps << pg \n end\n end\n prtgrps\n end", "def each(type = TLV_TYPE_ANY, &block)\n\t\tget_tlvs(type).each(&block)\n\tend", "def each(type = TLV_TYPE_ANY, &block)\n\t\tget_tlvs(type).each(&block)\n\tend", "def index\n @tag_type_groups = TagTypeGroup.all\n end", "def pack_bit_fields\n @unpacked = []\n \n self.class.fields.each_with_index do |name, position|\n \n if bit_fields = self.class.bit_fields[name]\n \n bit_value = 0\n bit_fields.each do |(bit_name, bits_number, bit_mask)|\n masked = @attributes[bit_name] & bit_mask\n \n raise ValueOverflow, \n \"the value #{@attributes[bit_name]} \"+\n \"is too big for #{bits_number} bits\" if masked != @attributes[bit_name]\n \n bit_value = bit_value << bits_number\n bit_value |= masked\n end\n \n # Value of fields composed by binary fields is always overwritten\n # by the composition of the latter\n attributes[name] = bit_value\n end\n \n @unpacked[position] = @attributes[name] || 0\n \n end\n \n @raw = @unpacked.pack( self.class.unpack_recipe )\n end", "def decode_tlv(data)\n raise OutOfData if (data.length == 2 && data[1].ord != 0) || data.length < 2\n tag = data[0].ord\n length = data[1].ord\n if length < 0x80\n value = data[2, length]\n remainder = data[length+2..-1]\n else\n # ASN.1 says this octet can't be 0xff\n raise InvalidLength, length.to_s if length == 0xff\n num_octets = length & 0x7f\n length = build_integer(data, 2, num_octets)\n value = data[num_octets+2, length]\n remainder = data[num_octets+2+length..-1]\n end\n return tag, value, remainder\n end", "def raw_to_xml(xml_ilv, raw_str)\n\n $test_logger.log(\"Raw to XML\")\n\n #Initialize class variables\n @nodes_to_delete = nil\n @is_parse_error = false\n @unknown_flag = false\n @parse_error_message = \"\"\n\n if raw_str\n raw_str_cpy = String.new(raw_str)\n fill_xml(xml_ilv, raw_str_cpy)\n\n if @unknown_flag\n @is_parse_error = true\n @parse_error_message = \"Unexpected ILV data received for filling XML!\"\n end\n else\n @is_parse_error = true\n @parse_error_message = \"No ILV data received for processing!\"\n end\n\n ##Log parsed data in XML format\n #$test_logger.log(to_s)\n\n end", "def tag_groups\n build_tag_groups_array RubyRedtail::Query.run(\"settings/taggroups\", @api_hash, \"GET\")\n end", "def convert_children\n children.map {|ch| convert ch }.compact\n end", "def denormalize_data(sort_mode)\n $logger.info('Denormalizing group data...')\n # Since members are stored in a subarray, we have to compute the needed number of columns and populate them\n max_member_columns = @groups.max_by { |a| a.members.uniq.size }.members.uniq.size\n out = @groups.collect(&:to_hash)\n out.collect { |a| (0..[max_member_columns,a['members'].size].min - 1).collect { |b| a[\"Member_#{b}\"] = a['members'][b] } }\n # Having expanded the members data, delete the original form since it's not needed or probably parseable meaningfully\n out.collect { |a| a.delete('members') }\n sort_key = sort_mode == 'id' ? 'gid' : 'name'\n out.sort! { |a, b| a[sort_key] <=> b[sort_key] }\n end", "def raw\n @raw ||= []\n end", "def get_groups_a\n\n return [] if self.groups.nil? or self.groups.empty?\n\n array = self.groups.split('|')\n array.compact!\n array.delete('')\n\n return array\n end", "def raw_families\n {}.tap { |ret|\n descriptor.families.each do |family|\n name = family.name_as_string\n ret[name] = parse_raw_map family.values\n end\n }\n end", "def preprocess(groups)\n end", "def dumpGroup\n user = $evm.root['user']\n unless user.nil?\n miq_group = user.miq_group\n unless miq_group.nil?\n $evm.log(\"info\",\"#{@method} - Group:<#{miq_group.description}> Begin Attributes [miq_group.attributes]\")\n miq_group.attributes.sort.each { |k, v| $evm.log(\"info\", \"#{@method} - Group:<#{miq_group.description}> Attributes - #{k}: #{v.inspect}\")} unless $evm.root['user'].miq_group.nil?\n $evm.log(\"info\",\"#{@method} - Group:<#{miq_group.description}> End Attributes [miq_group.attributes]\")\n $evm.log(\"info\", \"\")\n\n $evm.log(\"info\",\"#{@method} - Group:<#{miq_group.description}> Begin Associations [miq_group.associations]\")\n miq_group.associations.sort.each { |assc| $evm.log(\"info\", \"#{@method} - Group:<#{miq_group.description}> Associations - #{assc}\")}\n $evm.log(\"info\",\"#{@method} - Group:<#{miq_group.description}> End Associations [miq_group.associations]\")\n $evm.log(\"info\",\"\")\n\n unless miq_group.tags.nil?\n $evm.log(\"info\",\"#{@method} - Group:<#{miq_group.description}> Begin Tags [miq_group.tags]\")\n miq_group.tags.sort.each { |tag_element| tag_text = tag_element.split('/'); $evm.log(\"info\", \"#{@method} - Group:<#{miq_group.description}> Category:<#{tag_text.first.inspect}> Tag:<#{tag_text.last.inspect}>\")}\n $evm.log(\"info\",\"#{@method} - Group:<#{miq_group.description}> End Tags [miq_group.tags]\")\n $evm.log(\"info\",\"\")\n end\n\n $evm.log(\"info\",\"#{@method} - Group:<#{miq_group.description}> Begin Virtual Columns [miq_group.virtual_column_names]\")\n miq_group.virtual_column_names.sort.each { |vcn| $evm.log(\"info\", \"#{@method} - Group:<#{miq_group.description}> Virtual Columns - #{vcn}: #{miq_group.send(vcn).inspect}\")}\n $evm.log(\"info\",\"#{@method} - Group:<#{miq_group.description}> End Virtual Columns [miq_group.virtual_column_names]\")\n $evm.log(\"info\",\"\")\n end\n end\n end", "def add_tlv(t,l,v=nil)\n tlv = [(t << 9) + l, v]\n self.payload += tlv.flatten.pack(\"na*\")\n end", "def get_tlv_values(type)\n\t\tget_tlvs(type).collect { |a| a.value }\n\tend", "def get_tlv_values(type)\n\t\tget_tlvs(type).collect { |a| a.value }\n\tend", "def build_grouping_body\n arr = []\n data.each do |_,group| \n arr << render_group(group, options)\n end\n output << arr.join(\",\\n\")\n end", "def to_tracks(raw_tracks)\n result = []\n raw_tracks.each do |raw_track|\n \tresult << to_track(raw_track)\n end\n\n return result\n end", "def remove_tags_container(t, c)\n l, r = container_array(c)\n t.gsub!(l, '')\n t.gsub!(r, '')\n t\n end", "def decode\n\t\t\n\t\t# go through all of the encoded blocks and fund new singles\n\t\t@encoded.each do |enc|\n\t\t\t@encoded.delete(enc)\n\t \t\tenc = decode_new_multi(enc)\n\t\t\tnd = enc.blocks.length\n\t\t\tif nd == 0\n\t\t\t\t# Got them all, discard\n\t\t\telsif nd == 1\n\t\t\t\t# new single block\n\t\t\t\tadd_single_block(enc)\n\t\t\telse\n\t\t\t\t# add to the pile of unknowns\n\t\t\t\t@encoded << enc\n\t\t\tend\n\t\tend\n\tend", "def the_fields_grouped(field_keys)\n res = []\n object.get_fields_grouped(field_keys).each do |_group|\n group = {}.with_indifferent_access\n _group.keys.each do |k|\n group[k] = _group[k].map{|v| h.do_shortcode(v.to_s.translate(@_deco_locale), object) }\n end\n res << group\n end\n res\n end", "def tag_data\n @tag_data ||= object.tags.group_by(&:type)\n end", "def convertUnits(el, parentMap, childMap, allIds)\n id = el[:id] || el[:ref] || \"root\"\n allIds << id\n #puts \"name=#{el.name} id=#{id.inspect} name=#{el[:label].inspect}\"\n\n # Create or update the main database record\n if el.name != \"ref\"\n puts \"Converting unit #{id}.\"\n unitType = id==\"root\" ? \"root\" : id==\"lbnl\" ? \"campus\" : el[:type]\n Unit.update_or_replace(id,\n type: unitType,\n name: id==\"root\" ? \"eScholarship\" : el[:label],\n status: el[:directSubmit] == \"moribund\" ? \"archived\" :\n el[:hide] == \"eschol\" ? \"hidden\" :\n \"active\"\n )\n\n # We can't totally fill in the brand attributes when initially inserting the record,\n # so do it as an update after inserting.\n attrs = {}\n el[:directSubmit] and attrs[:directSubmit] = el[:directSubmit]\n el[:hide] and attrs[:hide] = el[:hide]\n attrs.merge!(convertUnitBrand(id, unitType))\n Unit[id].update(attrs: JSON.generate(attrs))\n\n addDefaultWidgets(id, unitType)\n end\n\n # Now recursively process the child units\n UnitHier.where(unit_id: id).delete\n el.children.each { |child|\n if child.name != \"allStruct\"\n id or raise(\"id-less node with children\")\n childID = child[:id] || child[:ref]\n childID or raise(\"id-less child node\")\n parentMap[childID] ||= []\n parentMap[childID] << id\n childMap[id] ||= []\n childMap[id] << childID\n end\n convertUnits(child, parentMap, childMap, allIds)\n }\n\n # After traversing the whole thing, it's safe to form all the hierarchy links\n if el.name == \"allStruct\"\n puts \"Linking units.\"\n linkUnit(\"root\", childMap, Set.new)\n\n # Delete extraneous units from prior conversions\n deleteExtraUnits(allIds)\n end\nend", "def parse(bytes)\n # tack new bytes on to partial packet\n @packet.concat(bytes.force_encoding('BINARY'))\n # find START_BYTE\n until (startPos = @packet.index(START_BYTE)).nil?\n after = @packet.slice(startPos+1 .. -1)\n nread = case after[0]\n when ID_ADC_STATUS\n parseADCStatus(after)\n when ID_DATA\n parseDataPacket(after)\n when ID_IO_STATUS\n parseIOStatus(after)\n when nil # no more bytes\n 0\n else\n # consume up to next START_BYTE\n after.index(START_BYTE) || 0\n end\n @packet = after.slice(nread .. -1)\n end\n end", "def flatten\n messages = struct.messages.map do |message| \n if message.compressed?\n s = message.decompressed_value\n MessageSet.read_without_size(Protocol::ResponseBuffer.new(s)).flatten\n else\n message\n end\n end.flatten\n end", "def parse_chunk_EQDN stream\n parse_itemized_chunk stream, [\n {:name => :id},\n {:name => :domain, :encoding => :hex}\n ]\n end", "def normalize\n return if @children.nil?\n old = nil\n children = @children.to_a.dup\n children.each do |child|\n if !old.nil? && old.nodeType == TEXT_NODE &&\n child.nodeType == TEXT_NODE\n old.appendData(child.nodeValue)\n self.removeChild(child)\n else\n if child.nodeType == ELEMENT_NODE\n child.normalize\n end\n old = child\n end\n end\n end", "def type_specific_part_raw\n return @type_specific_part_raw unless @type_specific_part_raw.nil?\n @type_specific_part_raw = type_specific_part_raw_with_io.data\n @type_specific_part_raw\n end", "def transform_elements_fields(elements)\n # keytech does not send layout data with data dictioniers for switched types\n # TASK_MAF / MAIL_WF\n # MailCategories,\n # TaskCategories\n # TaskConditions\n # TaskStatus\n # TaskPriority\n # MailPriority\n elements.each do |element|\n class_key = helpers.class_key(element.key)\n\n if ['TASK_WF', 'MAIL_WF'].include?(class_key)\n transform_element_fields(element)\n end\n end\n end", "def normalise!(tree)\n tree.each.with_index do |node, i|\n if node.is_a?(Array)\n if node.first == :loop && tree[i+1]\n key = tree[i+1][0]\n if key == :block\n tree[i+1][0] = :lblock\n elsif key == :query # wrap queries like `c.each(&:destroy)` \n tree[i+1] = [:lblock, tree[i+1]]\n end\n end\n tree[i] = normalise!(node)\n end\n end\n tree\n end", "def visit_group(attribute, preprocess = false)\n if preprocess\n name = attribute.name\n header = attribute.header\n keys = attribute.tuple_keys\n\n others = header.preprocessed\n\n compose do |ops|\n ops << t(:group, name, keys)\n ops << t(:map_array, t(:map_value, name, t(:filter_empty)))\n ops << others.map { |attr|\n t(:map_array, t(:map_value, name, visit(attr, true)))\n }\n end\n else\n visit_array(attribute)\n end\n end", "def process_tags(data)\n @tagmap.each do |id, tag|\n data.gsub!(id, process_tag(tag))\n end\n data\n end", "def parse_xml(raw)\n result = ::Crack::XML.parse(raw)[\"response\"]\n\n # put necessary changes in a lambda\n fix_sound_hash = lambda do |hash|\n fixed = hash.fs_symbolize_keys.flatten_single_element_array_values.numberize_values\n fixed[:tags] = fixed[:tags][:resource]\n fixed\n end\n\n if result[\"sounds\"]\n result[\"sounds\"].map do |sound|\n fix_sound_hash.call(sound)\n end\n else\n fix_sound_hash.call(result)\n end\n end", "def read_all(container)\n\tbuffer = \"\"\n\treadSize = 128 # amount of data to read at a time\n\n\twhile(!container.eof)\n\n\t\ttmp = container.readpartial(readSize)\n\n\t\tbuffer = buffer + tmp\n\n\t\tif tmp.length < readSize\n\t\t\tbreak\n\t\tend\n\n\t\ttmp = \"\"\n\n\tend\n\n\treturn buffer\nend", "def unmarshal_all(data)\n data.split(/\\n\\n/).\n map { |event| unpack(event) }.\n reject(&:empty?)\n end", "def grouped_options_for_select(collection, state = {})\n collection.map do |item|\n caption = item.shift\n attributes = item.last.kind_of?(Hash) ? item.pop : {}\n value = item.flatten(1)\n attributes = value.pop if value.last.kind_of?(Hash)\n html_attributes = { :label => caption }.merge(attributes||{})\n content_tag(:optgroup, options_for_select(value, state), html_attributes)\n end\n end", "def parse\n physical_storage_families\n physical_storages\n storage_resources\n storage_services\n cloud_volumes\n end", "def parse_record_packet\n @packet.utiny # skip first byte\n null_bit_map = @packet.read((@fields.length+7+2)/8).unpack(\"b*\").first\n rec = @fields.each_with_index.map do |f, i|\n if null_bit_map[i+2] == ?1\n nil\n else\n unsigned = f.flags & Field::UNSIGNED_FLAG != 0\n v = Protocol.net2value(@packet, f.type, unsigned)\n if v.nil? or v.is_a? Numeric or v.is_a? Time\n v\n elsif f.type == Field::TYPE_BIT or f.charsetnr == Charset::BINARY_CHARSET_NUMBER\n Charset.to_binary(v)\n else\n Charset.convert_encoding(v, @encoding)\n end\n end\n end\n rec\n end", "def boxes \n\n all_boxes = []\n @raw.each do |h|\n\n if [\"status\", \"media\", \"request\"].include?(h[0]) == false && h[1]['boxes'] != nil \n all_boxes << h[1]['boxes'][0] \n end \n end \n return all_boxes\n end", "def move_collection_names\n @record.xpath('./datafield[@tag=\"710\"]/subfield[@code=\"5\"]').each do |subfield|\n collection = subfield.parent.at_xpath('./subfield[@code=\"a\"]').text\n\n Nokogiri::XML::Builder.with(@doc.at('record')) do |xml|\n xml.datafield('ind1' => '0', 'ind2' => '0', 'tag' => '773') do\n xml.subfield(collection, 'code' => 't')\n end\n end\n\n subfield.parent.remove\n end\n end", "def normalize(node)\n return normalize_str(node) if node.is_a?(String)\n\n html = node.dup\n\n remove_trackers! html\n remove_blacklisted_images! html\n remove_style_attrs! html\n wrap_stray_text! html\n move_stray_images! html\n\n blocks(html).each do |blk|\n if block?(blk)\n add_class blk, 'short' if blk.content.size < 50\n add_class blk, 'image' if image_paragraph?(blk)\n handle_duplicate_brs! blk\n fix_pseudo_headings! blk\n end\n end\n\n blocks(html).each do |blk|\n blk.remove if blank?(blk) # Not recursive\n end\n\n html\n end", "def all\n @collection.deserialize(run)\n end", "def convert(aRawParse)\n case configuration.parse_repr\n when :parse_tree\n to_ptree(aRawParse)\n when :parse_forest\n to_pforest(aRawParse)\n end\n end", "def raws\n @raws = {} unless defined? @raws\n @raws\n end", "def load(raw)\n raw\n end", "def groups\n find(:group).map { |g| g.content }\n end", "def flatten_translations(locale, data, escape, subtree); end", "def read\n Typelib.to_ruby(raw_read)\n end" ]
[ "0.5510347", "0.53835297", "0.49199915", "0.47071126", "0.46451247", "0.46189794", "0.46009475", "0.45888084", "0.45409986", "0.45144984", "0.45144984", "0.44911018", "0.44801974", "0.44712278", "0.44627753", "0.44476873", "0.44408685", "0.43709478", "0.43474317", "0.43166432", "0.43147442", "0.42802858", "0.42795208", "0.42795208", "0.42698863", "0.42670947", "0.4250588", "0.42364419", "0.42195472", "0.41995686", "0.41871935", "0.41813082", "0.41710016", "0.41658965", "0.41651383", "0.4155217", "0.41534513", "0.41376212", "0.41371906", "0.41325375", "0.4120104", "0.4119265", "0.41157046", "0.41108602", "0.41082036", "0.41009235", "0.40994185", "0.40979514", "0.40869614", "0.40799385", "0.40740934", "0.40740934", "0.40669844", "0.4058906", "0.40549144", "0.40442026", "0.40431768", "0.40318963", "0.40291405", "0.40252027", "0.4017015", "0.4015191", "0.40106022", "0.40076143", "0.40053", "0.4004654", "0.4004654", "0.39841667", "0.39744762", "0.39739048", "0.39670274", "0.3929667", "0.39195603", "0.39175344", "0.39156136", "0.39094925", "0.39078596", "0.3905916", "0.39029446", "0.3902093", "0.38997728", "0.389166", "0.38912523", "0.38903642", "0.388026", "0.38802233", "0.3874356", "0.38734168", "0.38716182", "0.38707408", "0.38695082", "0.38673988", "0.38670668", "0.38647762", "0.3863721", "0.3855633", "0.384385", "0.38419983", "0.38369817" ]
0.670376
1
Constructor Initializes the packet to the supplied packet type and method, if any. If the packet is a request, a request identifier is created.
def initialize(type = nil, method = nil) super(type) if (method) self.method = method end self.created_at = ::Time.now # If it's a request, generate a random request identifier if ((type == PACKET_TYPE_REQUEST) || (type == PACKET_TYPE_PLAIN_REQUEST)) rid = '' 32.times { |val| rid << rand(10).to_s } add_tlv(TLV_TYPE_REQUEST_ID, rid) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initialize(type = nil, method = nil)\n\t\tsuper(type)\n\n\t\tif (method)\n\t\t\tself.method = method\n\t\tend\n\n\t\t# If it's a request, generate a random request identifier\n\t\tif ((type == PACKET_TYPE_REQUEST) ||\n\t\t (type == PACKET_TYPE_PLAINTEXT_REQUEST))\n\t\t\trid = ''\n\n\t\t\t32.times { |val| rid << rand(10).to_s }\n\n\t\t\tadd_tlv(TLV_TYPE_REQUEST_ID, rid)\n\t\tend\n\tend", "def initialize(packet_type, length = 0, payload = '') \n @codec_id = CODEC_ID\n @packet_type = packet_type\n @length = length\n\n case @packet_type\n when 'response'\n @data_length = length - 1 # codec id not included here - skip 1 byte\n @data_to_read = @data_length + SIZE_CRC # size from \"number of data 1\" to crc\n @data = [] # binary data\n when 'command'\n @payload = payload\n end\n\n @records = [] # parsed records\n @status = 'pending' # status of packet\n end", "def initialize(packet)\n @db, @table, @org_table, @name, @org_name, @charsetnr, @length, @type, @flags, @decimals, @default =\n packet.db, packet.table, packet.org_table, packet.name, packet.org_name, packet.charsetnr, packet.length, packet.type, packet.flags, packet.decimals, packet.default\n @flags |= NUM_FLAG if is_num_type?\n end", "def initialize(packet)\n @db, @table, @org_table, @name, @org_name, @charsetnr, @length, @type, @flags, @decimals, @default =\n packet.db, packet.table, packet.org_table, packet.name, packet.org_name, packet.charsetnr, packet.length, packet.type, packet.flags, packet.decimals, packet.default\n @flags |= NUM_FLAG if is_num_type?\n end", "def initialize(attributes)\n super(attributes)\n self.resource_name = attributes[:resource_name]\n self.method_name = attributes[:method_name]\n self.data = attributes[:data]\n self.message_id = attributes[:message_id] || rand(10**12)\n end", "def initialize(type, time, action, id)\n @type, @time, @action, @id = type, time, action, id\n end", "def initialize(mtype = INVALID)\n @message_type = mtype\n\n @flags = 0\n @protocol = 1\n @body_length = 0\n @signature = \"\"\n @@serial_mutex.synchronize do\n @serial = @@serial\n @@serial += 1\n end\n @params = Array.new\n\n if mtype == METHOD_RETURN\n @flags = NO_REPLY_EXPECTED\n end\n end", "def initialize(opcode, types, operands, destination, branch_destination, branch_condition, length)\n @opcode = opcode\n @types = types\n @operands = operands\n @destination = destination\n @branch_to = branch_destination\n @branch_on = branch_condition\n @length = length\n end", "def initialize(client, resource_type, method, params)\n @client = client\n @resource_type = resource_type.to_sym\n @method = method.to_sym\n @params = params\n perform\n end", "def initialize(type, id)\n @type = type.to_s\n @id = id.to_s\n end", "def initialize(type, id)\n @type = type.to_s\n @id = id.to_s\n end", "def initialize(param)\n raise Indy::Source::Invalid if param.nil?\n if param.respond_to?(:keys)\n if param[:cmd] # and param[:cmd].length > 0\n set_connection(:cmd, param[:cmd])\n elsif param[:file] # and File.size(param[:file].path) > 0\n set_connection(:file, param[:file])\n elsif param[:string]\n set_connection(:string, param[:string])\n end\n else\n discover_connection(param)\n end\n end", "def initialize(method=nil, *args)\n case method\n when :file then create_from_file(*args)\n when :parts then create_from_parts(*args)\n when :string then create_from_string(*args) # unused\n # if no method, do no intialization\n end\n end", "def initialize\n @opcode = 0\n @buffer = nil\n @options = {}\n end", "def initialize(request=nil) \n\t# if is not wrapped in a transaction then we'll wrap it to make unified handling of the request\t\n\tif !check_transaction(request)\t\t\n\t\treq_hash = HashWithIndifferentAccess.new\n\t\treq_hash[:transaction] = HashWithIndifferentAccess.new\n\t\treq_hash[:transaction][:transactionNum] = -1 \t\t\t\t\n\t\treq_list = Array.new\n\t\treq_list << request\n\t\treq_hash[:transaction][:operations] = req_list\n\t\t@request = req_hash\n\telse\n\t\t@request = request\n\tend\t \n end", "def build_packet(kind, type, payload, target, callback = false)\n kind_str = kind.to_s\n persistent = !!(kind_str =~ /persistent/)\n if kind_str =~ /push/\n packet = Push.new(type, payload)\n packet.selector = target[:selector] || :any if target.is_a?(Hash)\n packet.confirm = true if callback\n else\n packet = Request.new(type, payload)\n ttl = @options[:time_to_live]\n packet.expires_at = Time.now.to_i + ttl if !persistent && ttl && ttl != 0\n packet.selector = :any\n end\n packet.from = @identity\n packet.token = AgentIdentity.generate\n packet.persistent = persistent\n if target.is_a?(Hash)\n packet.tags = target[:tags] || []\n packet.scope = target[:scope]\n else\n packet.target = target\n end\n packet\n end", "def initialize(type, limit = 4096)\n @type = type\n @table = (type == :request) ? REQ_DEFAULTS.dup : RESP_DEFAULTS.dup\n @limit = limit\n @refset = []\n end", "def initialize(net_id, data)\n\n $test_logger.log(\"New MA5G Serial Packet, net id='#{net_id}', data size='#{data.size}'\")\n\n @start_str = START_STR\n @net_id = net_id\n @data = data\n @data_size = data.size\n @checksum = MA5GSerialPacket.calculate_checksum(data)\n\n end", "def makePacket(dest_ip, src_ip, type, seqNum, ackNum, data)\n\tpacket = Packet.new\n\n\tpacket.dest_ip = dest_ip\n\tpacket.src_ip = src_ip\n\tpacket.type = type\n\tpacket.seqNum = seqNum\n\tpacket.ackNum = ackNum\n\tpacket.data = data\n\n\treturn packet\nend", "def build_request(method)\n Request.create(method) do |req|\n req.params = self.params.dup\n req.headers = self.headers.dup\n req.options = self.options\n yield(req) if block_given?\n end\n end", "def initialize(connection, messageId)\n @connection = connection\n @respEnvelope = OpenSSL::ASN1::Sequence([\n OpenSSL::ASN1::Integer(messageId),\n # protocolOp,\n # controls [0] OPTIONAL,\n ])\n @schema = @connection.opt[:schema]\n @server = @connection.opt[:server]\n @rescount = 0\n end", "def initialize(request_info)\n @action = request_info[:action]\n @path = request_info[:path]\n @metadata = request_info[:metadata]\n @params = request_info[:params]\n @request = request_info[:request]\n\n # publishing actions\n @users_to_notify = []\n\n @response = nil\n end", "def initialize(payload)\n @named_elements = {}\n super\n @type = read_byte\n instantiate!\n end", "def makePacket(destIP, sourceIP, type, seqNum, ackNum)\n\tpacket = Packet.new\n\n\tpacket.destIP = destIP\n\tpacket.sourceIP = sourceIP\n\tpacket.type = type\n\tpacket.seqNum = seqNum\n\tpacket.ackNum = ackNum\n\n\tif(type == 0)\n\t\tpacket.data = \"This is ack #{ackNum}\"\n\telsif(type == 1)\n\t\tpacket.data = \"This is packet #{seqNum}\"\n\telse\n\t\tpacket.data = \"This is an EOT\"\n\tend\n\t\t\n\n\treturn packet\nend", "def initialize(packet_item, *args)\n @packet_item = packet_item\n @sort_key = nil\n @reversed = 1\n @is_deleted = false\n super(*args)\n end", "def initialize(type, limit = 4096)\n @type = type\n @table = (type == :request) ? REQ_DEFAULTS.dup : RESP_DEFAULTS.dup\n @limit = limit\n @workset = []\n end", "def initialize(method, uri, body: nil, headers: nil, opts: {})\n @tag = 0\n method = method.downcase.to_sym\n unless method == :get || method == :put || method == :post || method == :delete\n raise ArgumentError, \"Invalid method #{method} for request : '#{uri}'\"\n end\n self.method = method\n self.path = uri\n self.body = body\n self.headers = headers || {}\n self.opts = opts || {}\n end", "def initialize(type,data=nil)\n self.class.check_msg_type(type)\n self.type = type\n @data = data\n @bytes_per_record = 0\n @bytes_expected = 5\n @keysize = @valuesize = 0\n @parsed = false\n @buffer = String.new\n @parse_phase = PARSE_PHASES.first\n end", "def initialize(agent_id, kind, type, params)\n raise \"Unknown message.\" unless TYPES.include?(type)\n @agent_id = agent_id\n @type = type\n @kind = kind\n @params = params\n end", "def initialize(id, length, payload)\n\n # This field is parsed\n @id = id\n\n # This field is parsed\n @length = length\n\n # This field is not parsed (literally the bytes we were sent)\n @payload = payload\n end", "def initialize(requestId)\n raise ArgumentError if requestId.nil? or requestId.empty?\n @request_id = requestId\n @headers = ''\n end", "def initialize(request, response)\n @request = request\n @response = response\n end", "def initialize(http_client, metric)\n super(http_client, entity_name: 'method', collection_name: 'methods')\n @service = metric.service\n @metric = metric\n @resource_instance = Method\n end", "def initialize(client, cid, type, flags)\n\t\tsuper(client, cid, type, flags)\n\tend", "def initialize(response, request)\n @response = response\n @request = request\n end", "def initialize(options=nil)\n\n $test_logger.log(\"Initialize message with #{options}\")\n\n #Options available\n #\n #Eg: \"enroll.xml\"\n @xml_file_name = nil\n #\n #Eg: \"<Ping><Identifier>0x8</Identifier></Ping>\"\n @xml_str = nil\n #\n #Eg: \"Root/Request\", \"Root/Reply\", etc..\n @xml_ilv_tag = nil\n #\n #Eg: Response from device in raw format\n @ilv_raw_str = nil\n #\n #Eg: Response from device in hex format\n @ilv_hex_str = nil\n\n #Initial values\n @xml_doc = nil\n @xml_ilv_node = nil\n @is_parse_error = false\n @parse_error_message = \"\"\n @chk_serial_comm = false\n @is_reply_ilv = false\n\n #intialize default packet type and terminal identifier\n @pkt_type = PacketType::Data_PKT\n @ter_id = TERMINAL_ID\n @s_mode = SERIAL_MODE\n\n #Assign specified options to class varilables\n if options\n @xml_file_name = options[:xml_file_name] if options[:xml_file_name] != nil\n @xml_ilv_tag = options[:xml_ilv_tag] if options[:xml_ilv_tag] != nil\n @ilv_raw_str = options[:ilv_raw_str] if options[:ilv_raw_str] != nil\n @ilv_hex_str = options[:ilv_hex_str] if options[:ilv_hex_str] != nil\n @xml_str = options[:xml_str] if options[:xml_str] != nil\n end\n\n #Raise exceptions, if req\n #raise \"Option :xml_ilv_tag not specified\" if !@xml_ilv_tag\n #raise \"Option :xml_file_name not specified\" if !@xml_file_name\n raise \"Both options :ilv_raw_str and :ilv_hex_str cannot be specified at the same time!\" if @ilv_raw_str && @ilv_hex_str\n raise \"Both options :xml_file_name and :xml_str cannot be specified at the same time!\" if @xml_file_name && @xml_str\n\n #Process XML template/data\n if @xml_file_name\n #Raise error if xml file not found\n xml_file_path = File.join(FWConfig::DATA_FOLDER_PATH, FWConfig::XML_FOLDER,@xml_file_name)\n raise \"XML file does not exist in data folder!\\n#{xml_file_path}\" if !File.exist?(xml_file_path)\n\n #XML data from specified file\n xml_data = File.new xml_file_path\n else\n #Specified XML string\n if @xml_str\n xml_data = @xml_str\n #Default XML document\n else\n xml_data = DEF_XML_DOC\n end\n\n #Replace ruby string null character to XML null character\n if xml_data.include? \"\\x0\"\n xml_data.gsub!(\"\\x0\", NULL)\n null_replaced = true\n $test_logger.log(\"Ruby NULL character replaced with XML NULL char!\")\n end\n end\n\n begin\n #Initialize ILV tag\n @xml_doc = Document.new xml_data\n\n if @xml_ilv_tag\n xml_ilv_node = @xml_doc.elements[@xml_ilv_tag]\n #If specified ILV tag is not found in xml then create default reply\n if xml_ilv_node == nil\n @xml_doc = Document.new DEF_XML_DOC\n xml_ilv_node = @xml_doc.root\n end\n else\n\n xml_ilv_node = @xml_doc.elements[REQ_TAG] if !xml_ilv_node\n xml_ilv_node = @xml_doc.elements[REP_TAG] if !xml_ilv_node\n xml_ilv_node = @xml_doc.root if xml_ilv_node == nil\n end\n\n #Check if current ILV is reply ILV\n @is_reply_ilv = true if REP_TAG[/#{xml_ilv_node.name}/]\n\n #Update @xml_ilv_node to store only data from ilv node, i.e. discard parent nodes\n @xml_ilv_node = Document.new xml_ilv_node.to_s\n rescue Exception => ex\n $test_logger.log \"\\nError while parsing input XML data:\\n@@@@@@@@@@\\n#{xml_data}\\n@@@@@@@@@@\\n\", true\n raise\n end\n\n #If null character was replaced then replace back the original character\n if null_replaced\n replace_xml_str @xml_ilv_node, NULL, \"\\x0\"\n $test_logger.log(\"XML NULL character replaced back with ruby NULL char!\")\n end\n\n #Load data for specified input channel\n #RAW ILV str\n if @ilv_raw_str\n notify_change(InputChannel::RAW)\n #HEX ILV str\n elsif @ilv_hex_str\n notify_change(InputChannel::HEX)\n #Data from XML\n else\n notify_change(InputChannel::XML)\n end\n end", "def initialize timestamp, length, capture_length, captured, datalink, headers\n @capture_length = capture_length\n @captured = captured\n @datalink = datalink\n @length = length\n @protocols = headers.keys\n @timestamp = timestamp\n\n @arp_header = headers[:arp]\n @ethernet_header = headers[:ethernet]\n @icmp_header = headers[:icmp]\n @ipv4_header = headers[:ipv4]\n @ipv6_header = headers[:ipv6]\n @tcp_header = headers[:tcp]\n @udp_header = headers[:udp]\n @unknown_layer3_header = headers[:unknown_layer3]\n end", "def initialize(message, type = nil)\n @type = type\n super(message)\n end", "def initialize(method_name = nil, *parameters) #:nodoc:\n create!(method_name, *parameters) if method_name\n end", "def initialize(data)\n @header = Hash.new\n\n # Parse request\n line = data.gets.split\n @protocol = line[2]\n @method = line[0]\n @query_string = line[1].match(/\\?(.*?)$/)\n unless @query_string.nil?\n @query_string = @query_string[1]\n end\n @path = line[1].gsub(/\\?(.*?)$/, '')\n\n # Parse header\n while (line = data.gets) != \"\\r\\n\"\n line = line.split\n @header[line[0][0..-2]] = line[1..-1].join(' ')\n end\n\n # Deal with WebSocket\n if @header['Upgrade'] == 'websocket' && @header['Connection'] == 'Upgrade'\n @method = 'WEBSOCKET'\n end\n\n # Deal with EventSource\n if @header['Accept'] == 'text/event-stream'\n @method = 'EVENTSOURCE'\n end\n\n # Parse body\n @body = data.read\n end", "def initialize(type = nil, to = nil)\n super(\"iq\")\n if not to.nil?\n set_to(to)\n end \n if not type.nil?\n set_type(type)\n end \n end", "def initialize type, **options\n super **options\n @type = NRSER::Types.make type\n end", "def initialize type, **options\n super **options\n @type = NRSER::Types.make type\n end", "def initialize request\n @request = request\n loader = Loader.new\n @files = request.proto_file.map do |fd|\n loader.load_file fd, request.file_to_generate.include?(fd.name)\n end\n @services = @files.flat_map(&:services)\n @messages = @files.flat_map(&:messages)\n @enums = @files.flat_map(&:enums)\n end", "def initialize(request, data={}) #:nodoc:\n @request, @data = request, data\n @code, @message = data[:code] || FX_OK, data[:message]\n end", "def initialize(type, data=nil)\n # Verify then set the record type\n @type = type\n ensure_valid_type\n self.data = data\n end", "def initialize type, options={}\n if ( @@collectors.keys.include?(type) )\n @type = type\n else\n raise TypeRequired\n end\n\n @name = determine_name\n @id = fetch_id\n @options = options\n @report = {}\n\n raise NoNameError unless @name\n end", "def initialize(request:, response: nil)\n @request = request\n @response = response\n end", "def initialize(client, cid, type, flags)\n\t\tsuper(client, cid, type, flags)\n\t\t# the instance variable that holds all incoming datagrams.\n\t\t@datagrams = []\n\tend", "def initialize_instance\n super\n userHandle.value = get_parameter(:handle)\n request.pduHead.frag_length = self.num_bytes\n request.opnum.value = 47 \t\t#SamrQueryInformationUser2\n end", "def initialize(label, bit, type)\n fail 'Label has to be a String' unless label.is_a?(String)\n fail 'Bit has to be a String' unless bit.is_a?(String)\n\n @label = label\n @bit = bit\n @type = type\n end", "def initialize(line)\n fields = line.split\n @ip = fields[0]\n @event = nil\n @status = fields[8]\n @method = fields[5].sub('\"', '')\n @path = fields[6].sub(/\\?.*/, '')\n @event_time = parse_time(fields[3] + fields[4])\n @pid = nil\n @agent = line.split('\"')[5]\n end", "def initialize network:\n super network[:type], network[:struct], act_fn: network[:act_fn]\n end", "def initialize(payload, message, options = {})\n options = {:base64 => false,\n :agent => nil,\n :headers => {},\n :type => :message,\n :request => nil,\n :filter => Util.empty_filter,\n :collective => nil}.merge(options)\n\n @payload = payload\n @message = message\n @requestid = nil\n\n @type = options[:type]\n @headers = options[:headers]\n @base64 = options[:base64]\n @filter = options[:filter]\n\n if options[:request]\n @request = options[:request]\n @agent = request.agent\n @collective = request.collective\n @type = :reply\n else\n @agent = options[:agent]\n @collective = options[:collective]\n end\n\n base64_decode!\n end", "def initialize(initial_hash = nil)\n super\n @optional_method_names = %i[command data]\n end", "def initialize(type=nil)\n @type = type\n end", "def initialize(initial_hash = nil)\n super\n @optional_method_names = %i[kind]\n end", "def initialize(initial_hash = nil)\n super\n @optional_method_names = %i[kind]\n end", "def initialize(type_name, data_type, attribute_name, resource_hash, _referrable_type = nil)\n @type_name = type_name\n @data_type = data_type\n @attribute_name = attribute_name\n super(**resource_hash) # Pass resource to parent Puppet class.\n end", "def initialize(uri = T.unsafe(nil), response = T.unsafe(nil), body_io = T.unsafe(nil), code = T.unsafe(nil)); end", "def initialize( path: nil, type: nil )\n @path = path\n @type = type\n @metadata = {}\n end", "def initialize( path: nil, type: nil )\n @path = path\n @type = type\n @metadata = {}\n end", "def initialize(initial_params = {})\n raise \"Cannot directly instantiate a #{self.class}.\" if\n self.class == Request\n @params = initial_params\n end", "def initialize(options = {}, &block)\n @api_key = options.fetch(:api_key)\n @url = options.fetch(:url)\n @method = options.fetch(:method)\n @body = options[:body]\n @request = typhoeus_request\n @block = block\n end", "def initialize request\n loader = Loader.new\n @files = request.proto_file.map do |fd|\n loader.load_file fd, request.file_to_generate.include?(fd.name)\n end\n @services = @files.flat_map(&:services)\n @messages = @files.flat_map(&:messages)\n @enums = @files.flat_map(&:enums)\n end", "def initialize(fields)\n @type = fields['type'].to_sym\n @hierarchy = fields['hierarchy']\n @id = fields['id']\n end", "def initialize(connection, type, local_id, max_pkt_size = T.unsafe(nil), max_win_size = T.unsafe(nil), &on_confirm_open); end", "def initialize(options)\n\n opt_str = \"\"\n\n #Get specified options in printable form\n options.each {|a,b|\n \n if b.is_a?(Array)\n ##print \"#{a} => \"\n #opt_str << \"#{a}=>\"\n #b.each{|x| print \"#{x.to_s(16)} \"}\n #puts \"\" \n opt_str << \"#{a}=>Array[#{b.size}], \"\n elsif b.is_a?(Fixnum) or b.is_a?(Bignum)\n opt_str << \"#{a}=>#{b.to_s(16)}, \"\n else\n opt_str << \"#{a}=>#{b}, \"\n end\n }\n \n #Make debug log for options\n $test_logger.log(\"Initialize packet with options '#{opt_str[0..-3]}'\") # Print Packet with opt 0..-3 for removing comma and space\n #Initial values \n verify_checksum = nil\n @net_id = 0\n @pkt_no = 0\n @cmd_id = nil\n @res_req = true\n @ack_req = true\n @ack_bit = false\n @err_bit = false\n @data = nil\n @cmd_pkt = nil\n @cmd_str = nil\n @error_no = 0\n @error_desc = \"<NO ERROR>\"\n @sync_dword = DEFAULT_SYNC\n @reserved_dword = 0\n \n #Load variables from parameter options \n @net_id = options[:net_id] if options[:net_id]!=nil\n @pkt_no = options[:pkt_no] if options[:pkt_no]!=nil\n @cmd_id = options[:cmd_id] if options[:cmd_id]!=nil\n @res_req = options[:res_req] if options[:res_req]!=nil\n @ack_req = options[:ack_req] if options[:ack_req]!=nil\n @ack_bit = options[:ack_bit] if options[:ack_bit]!=nil\n @err_bit = options[:err_bit] if options[:err_bit]!=nil\n @data = Common.get_obj_copy(options[:data]) if options[:data]!=nil\n @sync_dword = options[:sync_dword] if options[:sync_dword]!=nil\n @reserved_dword = options[:reserved_dword] if options[:reserved_dword]!=nil\n \n verify_checksum = options[:verify_checksum] if options[:verify_checksum]!=nil \n if options[:ignore_chksum]!=nil \n ignore_chksum = options[:ignore_chksum] \n else\n ignore_chksum = false\n end \n \n #Swap for endianess on data\n if @data && @data.is_a?(Array) \n for i in 0..(@data.size - 1)\n @data[i] = BioPacket.swap_dword(@data[i]) if @data[i] && @data[i].to_s != CmdManager::DONT_CARE\n end\n end\n \n #Build cmd\n if ((@net_id.to_s.include? CmdManager::DONT_CARE) || (@pkt_no.to_s.include? CmdManager::DONT_CARE) || (@cmd_id.to_s.include? CmdManager::DONT_CARE) || (@ack_bit.to_s.include? CmdManager::DONT_CARE) || (@data.to_s.include? CmdManager::DONT_CARE) || (@err_bit.to_s.include? CmdManager::DONT_CARE)) \n $test_logger.log(\"Command Includes 'Dont care' #{CmdManager::DONT_CARE} so Command can't be build !\")\n else\n $test_logger.log(\"Buliding Command...!\") \n \n begin\n #Check for error\n check_error_no\n build_cmd(verify_checksum, ignore_chksum)\n rescue Exception=>ex\n raise ex, ex.message + \"\\nError while creating command!\", ex.backtrace\n end\n end \n end", "def initialize(attrs={})\n attrs.each {|k,v| send(\"#{k}=\", v)}\n self.command ||= nil\n self.transaction_id ||= self.class.next_transaction_id\n self.values ||= []\n self.version ||= 0x00\n end", "def initialize(attrs, key, klass, client, request_method, path, options)\n @key = key.to_sym\n @klass = klass\n @client = client\n @request_method = request_method.to_sym\n @path = path\n @options = options\n @collection = []\n set_attrs(attrs)\n end", "def request(type, *args, &callback)\n request = Request.new(self, type, protocol.send(type, *args), &callback)\n info { \"sending #{type} packet (#{request.id})\" }\n pending_requests[request.id] = request\n end", "def initialize\n @file = ''\n @content = Hash.new\n\n @uri = NULL_IP\n\n self.class.count += 1\n # @todo Allow IP version to be changeable based on execution\n end", "def initialize(uri = T.unsafe(nil), response = T.unsafe(nil), body = T.unsafe(nil), code = T.unsafe(nil)); end", "def initialize(eth_type: nil, ipv4_destination: nil, ipv4_source: nil,\n ipv6_source: nil, ipv6_destination: nil, ipv6_flabel: nil,\n ipv6_ext_header: nil, ethernet_destination: nil, ethernet_source: nil,\n in_port: nil, in_physical_port: nil, ip_protocol_num: nil, ip_dscp: nil,\n ip_ecn: nil, tcp_source_port: nil, tcp_destination_port: nil,\n udp_source_port: nil, udp_destination_port: nil, icmpv4_type: nil,\n icmpv4_code: nil, icmpv6_type: nil, icmpv6_code: nil,\n arp_op_code: nil, arp_source_ipv4: nil, arp_target_ipv4: nil,\n arp_source_hardware_address: nil, arp_target_hardware_address: nil,\n vlan_id: nil, vlan_pcp: nil, sctp_destination: nil, sctp_source: nil,\n mpls_label: nil, mpls_tc: nil, mpls_bos: nil, tunnel_id: nil,\n metadata: nil, metadata_mask: nil)\n @eth_type = eth_type\n @ipv4_dst = ipv4_destination\n @ipv4_src = ipv4_source\n @ipv6_dst = ipv6_destination\n @ipv6_src = ipv6_source\n @ipv6_flabel = ipv6_flabel\n @ipv6_ext_hdr = ipv6_ext_header\n @ethernet_dst = ethernet_destination\n @ethernet_src = ethernet_source\n @in_port = in_port\n @in_phy_port = in_physical_port\n @ip_proto = ip_protocol_num\n @ip_dscp = ip_dscp\n @ip_ecn = ip_ecn\n @tcp_src_port = tcp_source_port\n @tcp_dst_port = tcp_destination_port\n @udp_dst_port = udp_destination_port\n @udp_src_port = udp_source_port\n @icmpv4_type = icmpv4_type\n @icmpv4_code = icmpv4_code\n @icmpv6_type = icmpv6_type\n @icmpv6_code = icmpv6_code\n @arp_op_code = arp_op_code\n @arp_src_ipv4 = arp_source_ipv4\n @arp_tgt_ipv4 = arp_target_ipv4\n @arp_src_hw_addr = arp_source_hardware_address\n @arp_tgt_hw_addr = arp_target_hardware_address\n @vlan_id = vlan_id\n @vlan_pcp = vlan_pcp\n @sctp_dst = sctp_destination\n @sctp_src = sctp_source\n @mpls_label = mpls_label\n @mpls_tc = mpls_tc\n @mpls_bos = mpls_bos\n @tunnel_id = tunnel_id\n @metdata = metadata\n @metadata_mask = metadata_mask\n end", "def create_request publisher, method, params\n CnsBase::RequestResponse::RequestSignal.new(publisher, method, params)\n end", "def initialize( ident, command, filename=nil, arch_info=nil )\n @ident = ident\n @command = command\n @filename = filename\n @arch_info = arch_info\n @maps = {}\n modelitem_init\n target_init\n end", "def initialize(method_name)\n @method_name = method_name\n end", "def initialize\n @logger = Cabin::Channel.get\n @opcode = 0\n @masking_key = \"\"\n @flag_final_payload = 0\n @flag_mask = 0\n\n transition(:flags_and_opcode, 1)\n @buffer = \"\"\n @buffer.force_encoding(\"BINARY\")\n end", "def initialize(response)\n super\n # XXX assign to :signal\n end", "def initialize(arg1 = \"plum\\x00\\x00\\x00\\x00\".b, arg2 = nil)\n if !arg2\n raise ArgumentError.new(\"data must be 8 octets\") if arg1.bytesize != 8\n arg1 = arg1.b if arg1.encoding != Encoding::BINARY\n initialize_base(type: :ping, stream_id: 0, payload: arg1)\n else\n initialize_base(type: :ping, stream_id: 0, flags: [:ack], payload: arg2)\n end\n end", "def initialize(type)\n @type = type\n end", "def initialize(type)\n @type = type\n end", "def initialize(type)\n @type = type\n end", "def initialize(type)\n @type = type\n end", "def initialize(type)\n @type = type\n end", "def initialize(type = TYPES[:empty])\n @type = type\n end", "def initialize(request_id)\n super request_id, SERVERDATA_RESPONSE_VALUE, nil\n end", "def initialize(parent, id, instructions)\n @parent = parent\n @id = id\n @target = (id == 0 ? 1 : 0)\n\n @registers = Array('a'..'z').zip(Array.new(26, 0)).to_h\n @registers['p'] = id\n\n @instructions = instructions.dup\n @ic = 0 # Instruction counter\n\n @waiting = false\n @receiver = nil\n end", "def initialize (params = {})\n\n @uniprotid = params.fetch(:uniprotid, \"XXXXXX\")\n @intactid = params.fetch(:intactid, nil)\n @networkid = params.fetch(:networkid, nil)\n\n @@prot_obj[uniprotid] = self\n\n if intactid\n @@prot_int_obj[intactid] = self #We only introduce the data in the hash if the protein has an Intact ID, and will use it as key\n end\n\n end", "def initialize(params:)\n raise('Missing required params: [:dip_location] and [:package_metadata][:dip_uuid] are required') unless params[:dip_location] && params[:package_metadata][:dip_uuid]\n @params = params\n @package_payload = {}\n @works_payload = []\n @dip = DIPReader.new(params[:dip_location])\n @dip_id = params[:package_metadata][:dip_uuid]\n @bag_key = dip_id\n rescue StandardError => e\n raise e\n end", "def initialize(json_request)\n super\n @intent = json_request['request']['intent']\n raise ArgumentError, 'Intent should exist on an IntentRequest' if @intent.nil?\n @type = 'INTENT_REQUEST'\n @name = @intent['name']\n @slots = @intent['slots']\n end", "def initialize(method, path, body = nil)\n super\n @warn = false\n content_length = body ? body.bytesize.to_s : '0'\n @headers.update({\n 'x-ms-version' => '2014-06-01',\n 'Content-Type' => 'application/xml',\n 'Content-Length' => content_length\n })\n @uri = URI.parse(Azure.config.management_endpoint + Azure.config.subscription_id + path)\n @key = Azure.config.http_private_key\n @cert = Azure.config.http_certificate_key\n end", "def initialize(mode, type, **options)\n fail ArgumentError unless %i(bind connect).include? mode\n @context = options[:context] || EZMQ::Context.new\n @socket = @context.socket type\n @encode = options[:encode] || -> m { m }\n @decode = options[:decode] || -> m { m }\n endpoint = options.select { |k, _| %i(transport address port).include? k }\n method(mode).call endpoint\n end", "def initialize(action: nil, method: nil, namespace: nil, **part_args)\n @action = action\n @method = method\n @namespace = namespace\n\n super(part_args)\n end", "def initialize(attributes = {})\n @id = attributes[:id] || attributes[:device_id]\n @user_id = attributes[:user_id] || attributes[:uuid]\n @token = attributes[:token] || attributes[:push_token]\n @type = attributes[:type] || attributes[:push_type]\n @application = attributes[:application]\n end", "def initialize msgclass, src_addr, src_uid, target_addr = nil\n\t\t\traise 'Do not instantiate XapMessage directly (use a subclass)' if self.class == XapMessage\n\t\t\traise 'src_addr must be an XapAddress' unless src_addr.is_a? XapAddress\n\t\t\traise 'target_addr must be nil or an XapAddress' unless target_addr.nil? || target_addr.is_a?(XapAddress)\n\n\t\t\t@src_addr = src_addr\n\t\t\t@target_addr = target_addr\n\t\t\t@version = 12\n\t\t\t@hop = 1\n\t\t\t@uid = src_uid\n\t\t\t@msgclass = msgclass\n\t\t\t@blocks = {}\n\t\t\t@headers = {}\n\t\tend", "def initialize(request, params)\n @request = request\n\n if params['CartId']\n perform_request 'Get', params\n else\n perform_request 'Create', params\n end\n end", "def initialize(payload); end", "def initialize(id, length, payload)\n @id = id\n @length = length\n @payload = payload\n end", "def initialize()\n @type = ''\n @destination = ''\n @tag = ''\n @data = ''\n @timeout = 10000\n end" ]
[ "0.7971575", "0.63409096", "0.63333994", "0.63333994", "0.59193516", "0.57540977", "0.55405766", "0.55356", "0.54965144", "0.5494459", "0.5494459", "0.5466833", "0.54543734", "0.5431925", "0.54091877", "0.5394551", "0.5359059", "0.5281987", "0.5274823", "0.527208", "0.5262265", "0.52615964", "0.5254731", "0.52545583", "0.5238391", "0.5225843", "0.52193534", "0.52140546", "0.52093923", "0.52093077", "0.5193045", "0.51909", "0.51828474", "0.51820517", "0.51782787", "0.5170176", "0.5169907", "0.51698214", "0.5168746", "0.516748", "0.51574045", "0.5152199", "0.5152199", "0.51491517", "0.5137758", "0.512442", "0.5122178", "0.51136875", "0.50984395", "0.50935537", "0.5091799", "0.50894004", "0.5088061", "0.50853103", "0.50594664", "0.505375", "0.5051029", "0.5051029", "0.5048777", "0.5043965", "0.5039776", "0.5039776", "0.503884", "0.5037173", "0.50332654", "0.5032712", "0.50271475", "0.5026312", "0.5024614", "0.5023941", "0.50222164", "0.5013003", "0.50096846", "0.49997932", "0.49993724", "0.4989854", "0.49888432", "0.49884036", "0.49828923", "0.49812073", "0.49806088", "0.49806088", "0.4972114", "0.4972114", "0.4972114", "0.49680215", "0.49602476", "0.49589133", "0.49559098", "0.4954626", "0.4951592", "0.49505934", "0.49453467", "0.49412405", "0.49365336", "0.4935079", "0.49340266", "0.49297014", "0.4912898", "0.49113715" ]
0.80640596
0
Conditionals Checks to see if the packet is a response.
def response? return ((self.type == PACKET_TYPE_RESPONSE) || (self.type == PACKET_TYPE_PLAIN_RESPONSE)) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def response?\n @type == :response\n end", "def command_response?\n type == :command_response\n end", "def response?\n !!response\n end", "def response?\n !response.nil?\n end", "def response_received?\n !! @status\n end", "def response_received?\n !! @status\n end", "def response?(params)\n params.key?('responseStatusCode') || params.key?('responseErrorReason')\n end", "def non_empty_http_response?(http)\n http.response.present?\n end", "def check_response!\n body[:stat] == 'ok' || fail(ClientError, \"#{ body.inspect }\")\n end", "def ok?(response)\n case response\n when Net::HTTPSuccess\n true\n else\n false\n end\n end", "def ok? \n @response.is_a? Net::HTTPOK\n end", "def response?\n qr?\n end", "def has_accepted_response?\n self.responses.accepted.any? {|response| response.accepted?}\n end", "def response?\n done? ? @grpc_op.result == :response : false\n end", "def response?\n done? && !error?\n end", "def valid_response?(message)\n return true\n end", "def successful?(response)\n (response[\"GatewayRspCode\"] == \"0\") && ((response[\"RspCode\"] || \"0\") == \"0\")\n end", "def eval_response(response)\n return (response == \"OK\")\n end", "def handle_response(response)\n case response[:status]\n when :success, :created\n self.instance_variable_set('@notsaved', false)\n true\n when :errors\n Amfetamine.logger.warn \"Errors from response\\n #{response[:body]}\"\n response[:body].each do |attr, error_messages|\n error_messages.each do |msg|\n errors.add(attr.to_sym, msg)\n end\n end\n false\n when :server_error\n Amfetamine.logger.warn \"Something went wrong at the remote end.\"\n false\n end\n end", "def parse_response?\n parse_response\n end", "def check_response\n errors.add(:base, :invalid) unless response.present? && response[\"res\"] == 1\n end", "def allows_response_by(responder)\n self.allows_response?(responder)\n end", "def has_responses?\n if is_standard?\n respond_to?(:copy_responses_count_col) ? (copy_responses_count_col || 0) > 0 : copies.any?(&:has_responses?)\n else\n responses_count > 0\n end\n end", "def parse_response?\n parse_response\n end", "def check_ok_response( socket, msg )\n result = socket.recv( 100 )\n logger.debug( \"Result for #{msg} : #{result}\" )\n raise \"Invalid response for #{msg}\" unless result == \"OK\\n\"\n end", "def handle_response(response)\n token = response.token\n if response.is_a?(Result)\n if result = OperationResult.from_results(response)\n if result.non_delivery?\n @non_delivery_stats.update(result.content.nil? ? \"nil\" : result.content.inspect)\n elsif result.error?\n @result_error_stats.update(result.content.nil? ? \"nil\" : result.content.inspect)\n end\n @result_stats.update(result.status)\n else\n @result_stats.update(response.results.nil? ? \"nil\" : response.results)\n end\n\n if handler = @pending_requests[token]\n if result && result.non_delivery? && handler.kind == :send_retryable_request &&\n [OperationResult::TARGET_NOT_CONNECTED, OperationResult::TTL_EXPIRATION].include?(result.content)\n # Log and ignore so that timeout retry mechanism continues\n # Leave purging of associated request until final response, i.e., success response or retry timeout\n Log.info(\"Non-delivery of <#{token}> because #{result.content}\")\n else\n deliver(response, handler)\n end\n elsif result && result.non_delivery?\n Log.info(\"Non-delivery of <#{token}> because #{result.content}\")\n else\n Log.debug(\"No pending request for response #{response.to_s([])}\")\n end\n end\n true\n end", "def call_response?\n false\n end", "def reply?\n self.operation == OP_REPLY\n end", "def bodiless?\n\t\treturn self.extended_reply? ||\n\t\t\tself.body.nil? ||\n\t\t\tHTTP::BODILESS_HTTP_RESPONSE_CODES.include?( self.status )\n\tend", "def process_response!(response)\n\t\t\t\tfinish_request!\n\t\t\t\t\n\t\t\t\tif Exception === response\n\t\t\t\t\t@logger.warn \"[#{@message.id}] Failure while processing response #{response}!\" if @logger\n\t\t\t\t\tRubyDNS.log_exception(@logger, response) if @logger\n\t\t\t\t\t\n\t\t\t\t\ttry_next_server!\n\t\t\t\telsif response.tc != 0\n\t\t\t\t\t@logger.warn \"[#{@message.id}] Received truncated response!\" if @logger\n\t\t\t\t\t\n\t\t\t\t\ttry_next_server!\n\t\t\t\telsif response.id != @message.id\n\t\t\t\t\t@logger.warn \"[#{@message.id}] Received response with incorrect message id: #{response.id}\" if @logger\n\t\t\t\t\t\n\t\t\t\t\ttry_next_server!\n\t\t\t\telse\n\t\t\t\t\t@logger.debug \"[#{@message.id}] Received valid response #{response.inspect}\" if @logger\n\t\t\t\t\t\n\t\t\t\t\tsucceed response\n\t\t\t\tend\n\t\t\tend", "def applies_to?(response)\n status, header, body = response\n\n # Some stati don't have to be processed\n return false if [301, 302, 303, 307].include?(status)\n\n # Check mime type\n return false if @mime_types.all? do |type|\n !header['Content-Type'].to_s.include?(type)\n end\n\n # Find ESI tags\n response[2] = [body = join_body(body)]\n body.include?('<esi:')\n end", "def constructed_response?\n @constructed_response\n end", "def response?(params); end", "def response_code_is_ok?\n return true if %w(00 24).include? response_code\n\n false\n end", "def validate_response(resp)\n # The length for a chunked response is 0, so checking it isn't meaningful.\n return resp if resp.headers['Transfer-Encoding'] == 'chunked'\n\n exp_content_length = resp.headers['Content-Length'].to_i\n actual_content_length = resp.body.length\n return resp if actual_content_length == exp_content_length\n\n errmsg = \"Incomplete response received from Symphony for #{@catkey} - expected #{exp_content_length} bytes but got #{actual_content_length}\"\n Honeybadger.notify(errmsg)\n raise ResponseError, errmsg\n end", "def has_response_field?(field, target)\n !!get_response_field(field, target)\n end", "def empty?(response); end", "def receive_any(packet)\n RightLinkLog.debug(\"RECV #{packet.to_s}\")\n case packet\n when Advertise\n RightLinkLog.info(\"RECV #{packet.to_s}\") unless RightLinkLog.level == :debug\n advertise_services\n when Request, Push\n RightLinkLog.info(\"RECV #{packet.to_s([:from, :tags])}\") unless RightLinkLog.level == :debug\n @dispatcher.dispatch(packet)\n when Result\n RightLinkLog.info(\"RECV #{packet.to_s([])}\") unless RightLinkLog.level == :debug\n @mapper_proxy.handle_result(packet)\n else\n RightLinkLog.error(\"Agent #{@identity} received invalid packet: #{packet.to_s}\")\n end\n true\n end", "def receive_packet(response)\n pending_pos = nil\n pending_callback = nil\n @pending.each_with_index do |(pending_opaque,pending_cb),i|\n if response[:opaque] == pending_opaque\n pending_pos = i\n pending_callback = pending_cb\n break\n end\n end\n\n if pending_pos\n @pending = @pending[pending_pos..-1]\n begin\n if pending_callback.call(response) != :proceed\n @pending.shift\n end\n rescue Exception => e\n $stderr.puts \"#{e.class}: #{e}\\n\" + e.backtrace.join(\"\\n\")\n end\n end\n end", "def valid_response?\n if self.required? && !self.has_response? then\n false\n else\n # other validations\n true\n end\n end", "def allow?(packet); end", "def waiting_for_response_tb?\n e = $game_map.events[@tb_ev_respond_id]\n # print \"e.list:\\n #{e.list}\\n\" if e\n !TM.response_queue.empty? || (e && e.tb_response_wait)\n end", "def ok?\n first[OK] == 1 || reply.nil?\n end", "def has_response_body?\n !response.body.nil? && !response.body.empty?\n end", "def error_response?(response, _parsed_response)\n !(200..299).cover?(response.code)\n end", "def has_no_accepted_response?\n !self.has_accepted_response?\n end", "def response_successful?(response)\n return false if response.body[\"errors\"]\n response.success?\n end", "def success?(response)\n response[:response_code] == 0\n end", "def valid_response?\n return false unless response\n\n valid_hmac? && valid_amount? && valid_account?\n end", "def contains_response_and_soln?() true ; end", "def valid_status?(response)\n response.is_a?(Net::HTTPSuccess)\n end", "def has_response_body?\n @raw_link.media_type != \"null\"\n end", "def request_successful(response)\n\t\tresponse.code == \"200\"\n\tend", "def success_from(response)\n response == 'SUCCESSFUL' || response =~ /^\\d+$/ || response == 'true'\n end", "def has_associated_response?\n @associated_responses ||= []\n not @associated_responses.empty?\n end", "def check_for_valid_response(resp)\n if resp == 'exit!'\n game_data.save\n elsif game_data.chosen_letters.include?(resp)\n repeat_response_query('repeat')\n elsif resp.length > 1\n repeat_response_query('multiple')\n else\n action(resp)\n end\n end", "def valid_http_response?(http)\n http.is_a?(EM::HttpClient) && non_empty_http_response?(http)\n end", "def is_negative?\n return NEGATIVE_RESPONSES.include?(self)\n end", "def handle_response(response)\n begin\n if ok?(response.code)\n if response.body.present?\n parse_response_body(response.body)\n else\n true # blank body\n end\n else\n Rails.logger.error \"Unexpected response #{response.code}, not sure what to do here...\"\n response.message\n end\n rescue => e\n # don't report, just return\n response.message\n end\n end", "def reply\n receive_packet 1400\n\n if @buffer.long == 0xFFFFFFFE\n split_packets = []\n begin\n request_id = @buffer.long\n packet_number_and_count = @buffer.getbyte\n packet_count = packet_number_and_count & 0xF\n packet_number = (packet_number_and_count >> 4) + 1\n\n split_packets[packet_number - 1] = @buffer.get\n\n log.debug \"Received packet #{packet_number} of #{packet_count} for request ##{request_id}\"\n\n if split_packets.size < packet_count\n begin\n bytes_read = receive_packet\n rescue SteamCondenser::Error::Timeout\n bytes_read = 0\n end\n else\n bytes_read = 0\n end\n end while bytes_read > 0 && @buffer.long == 0xFFFFFFFE\n\n packet = SteamCondenser::Servers::Packets::SteamPacketFactory.reassemble_packet(split_packets)\n else\n packet = SteamCondenser::Servers::Packets::SteamPacketFactory.packet_from_data(@buffer.get)\n end\n\n log.debug \"Got reply of type \\\"#{packet.class.to_s}\\\".\"\n\n packet\n end", "def on_response(session)\n peer_session = get_peer_session(session)\n if peer_session && session[:_sipper_b2b_transparent]\n peer_session.respond_with(session.iresponse.code)\n else\n super\n end\n end", "def success?\n @response.is_a? Net::HTTPSuccess\n end", "def reply\n bytes_read = receive_packet 1400\n is_compressed = false\n\n if @buffer.long == 0xFFFFFFFE\n split_packets = []\n begin\n # Parsing of split packet headers\n request_id = @buffer.long\n is_compressed = ((request_id & 0x80000000) != 0)\n packet_count = @buffer.byte\n packet_number = @buffer.byte + 1\n\n if is_compressed\n @buffer.long\n packet_checksum = @buffer.long\n else\n @buffer.short\n end\n\n # Caching of split packet data\n split_packets[packet_number - 1] = @buffer.get\n\n puts \"Received packet #{packet_number} of #{packet_count} for request ##{request_id}\" if $DEBUG\n\n # Receiving the next packet\n if split_packets.size < packet_count\n begin\n bytes_read = receive_packet\n rescue TimeoutException\n bytes_read = 0\n end\n else\n bytes_read = 0\n end\n end while bytes_read > 0 && @buffer.long == 0xFFFFFFFE\n\n if is_compressed\n packet = SteamPacketFactory.reassemble_packet(split_packets, true, packet_checksum)\n else\n packet = SteamPacketFactory.reassemble_packet(split_packets)\n end\n else\n packet = SteamPacketFactory.packet_from_data(@buffer.get)\n end\n\n if is_compressed\n puts \"Got compressed reply of type \\\"#{packet.class.to_s}\\\".\" if $DEBUG\n else\n puts \"Got reply of type \\\"#{packet.class.to_s}\\\".\" if $DEBUG\n end\n\n packet\n end", "def accounting_reply?\n return true if (self.kind_of?(AccountingReply))\n return false\n end", "def matches?(response)\n return false unless valid_response?(response)\n\n @parsed_response = JSON.parse(response.body)\n\n return false if response_is_error?\n return false unless valid_data_section?\n if JsonapiRspec.configuration.meta_required\n return false unless valid_meta_section?\n end\n\n @parsed_response.each do |key, value|\n case key.to_sym\n when :data\n return false unless match_object?(value)\n when :meta\n return false unless valid_meta_section?\n when :jsonapi\n next # this can legally be anything\n when :included\n next # TODO: handle included objects\n when :links\n next # TODO: handle links objects\n else\n return set_failure_message(FailureMessages::UNEXPECTED_TOP_LVL_KEY % key)\n end\n end\n\n true\n end", "def waiting_for?(packet)\n\t\treturn (packet.rid == rid)\n\tend", "def responded_to?(kase)\n !!self.responses.find(:first, :conditions => [\"responses.kase_id = ?\", kase.id])\n end", "def check_response_ok(response)\n if response[\"ok\"]\n response\n else\n logger.error(\"Unexpected response from database - #{response['ok']}\")\n raise CouchFooError, \"Couldn't understand database response:#{response}\"\n end\n end", "def send_response\n\t # Create response packet\n udp_packet = PacketFu::UDPPacket.new(:config => @cfg)\n \n udp_packet.udp_src = @packet.udp_dst\n udp_packet.udp_dst = @packet.udp_src\n udp_packet.eth_daddr = @victim_mac\n udp_packet.ip_daddr = @victim_ip\n udp_packet.ip_saddr = @packet.ip_daddr\n udp_packet.payload = @packet.payload[0, 2]\n \n udp_packet.payload += \"\\x81\\x80\" + \"\\x00\\x01\" + \"\\x00\\x01\"\n udp_packet.payload += \"\\x00\\x00\" + \"\\x00\\x00\"\n \n @domain_name.split('.').each do |part|\n udp_packet.payload += part.length.chr\n udp_packet.payload += part\n end # @domain_name.split('.').each do |part|\n\n udp_packet.payload += \"\\x00\\x00\\x01\\x00\" + \"\\x01\\xc0\\x0c\\x00\"\n udp_packet.payload += \"\\x01\\x00\\x01\\x00\" + \"\\x00\\x1b\\xf9\\x00\" + \"\\x04\"\n \n # Address\n spoof_ip = @spoof_ip.split('.')\n udp_packet.payload += [spoof_ip[0].to_i, spoof_ip[1].to_i, spoof_ip[2].to_i, spoof_ip[3].to_i].pack('c*')\n \n udp_packet.recalc\n \n\t send(udp_packet, @iface) \n end", "def response_unavailable?\n !!(content_for_scanner =~ /Server too busy, try again later/)\n end", "def got_response(response)\n case dump_responses_to\n when :stderr, \"stderr\"\n $stderr.puts \"RegApi2.Response:\\n#{response}\"\n when :stdout, \"stdout\"\n $stdout.puts \"RegApi2.Response:\\n#{response}\"\n when Proc\n dump_responses_to.call(response)\n when nil\n ;\n else\n raise ArgumentError.new( \"Bad dump_responses_to field: #{dump_responses_to.inspect}\" )\n end\n nil\n end", "def is_last? response, page\n ( (page >= response.max_pages) ||\n (response && response.healthy? && partial_response?(response)) )\n end", "def response_throttled?\n !!node(\"response-throttled\")\n end", "def response_ok?(response, request)\n \n # first allow for debugging\n d {request.object_id}\n d {request}\n d {response.object_id}\n d {response.code}\n d {response.headers_hash}\n d {response.body}\n\n case response.code.to_i\n\n when 502, 503, 504\n raise AMEE::ConnectionFailed.new(\"A connection error occurred while talking to AMEE: HTTP response code #{response.code}.\\nRequest: #{request.method.upcase} #{request.url.gsub(request.host, '')}\")\n when 408\n raise AMEE::TimeOut.new(\"Request timed out.\")\n when 404\n raise AMEE::NotFound.new(\"The URL was not found on the server.\\nRequest: #{request.method.upcase} #{request.url.gsub(request.host, '')}\")\n when 403\n raise AMEE::PermissionDenied.new(\"You do not have permission to perform the requested operation.\\nRequest: #{request.method.upcase} #{request.url.gsub(request.host, '')}\\n#{request.body}\\Response: #{response.body}\")\n when 401\n authenticate\n return false\n when 400\n if response.body.include? \"would have resulted in a duplicate resource being created\"\n raise AMEE::DuplicateResource.new(\"The specified resource already exists. This is most often caused by creating an item that overlaps another in time.\\nRequest: #{request.method.upcase} #{request.url.gsub(request.host, '')}\\n#{request.body}\\Response: #{response.body}\")\n else\n raise AMEE::BadRequest.new(\"Bad request. This is probably due to malformed input data.\\nRequest: #{request.method.upcase} #{request.url.gsub(request.host, '')}\\n#{request.body}\\Response: #{response.body}\")\n end\n when 200, 201, 204\n return response\n when 0\n connection_failed\n end\n # If we get here, something unhandled has happened, so raise an unknown error.\n raise AMEE::UnknownError.new(\"An error occurred while talking to AMEE: HTTP response code #{response.code}.\\nRequest: #{request.method.upcase} #{request.url}\\n#{request.body}\\Response: #{response.body}\")\n end", "def autoresponse?(message)\n !!(\n # If any of the following headers are present and have the given value.\n {\n 'Delivered-To' => 'Autoresponder',\n 'Precedence' => 'auto_reply',\n 'Return-Path' => nil, # in most cases, this would signify a bounce\n 'X-Autoreply' => 'yes',\n 'X-FC-MachineGenerated' => 'true',\n 'X-POST-MessageClass' => '9; Autoresponder',\n 'X-Precedence' => 'auto_reply',\n }.find do |name,value|\n message[name] && message[name].decoded == value\n end ||\n # If any of the following headers are present.\n [\n 'X-Autogenerated', # value is one of Forward, Group, Letter, Mirror, Redirect or Reply\n 'X-AutoReply-From', # value is an email address\n 'X-Autorespond', # value is an email subject\n 'X-Mail-Autoreply', # value is often \"dtc-autoreply\" but can be another tag\n ].any? do |name|\n message[name]\n end ||\n # If the Auto-Submitted header is present and is not equal to \"no\".\n (\n message['Auto-Submitted'] &&\n message['Auto-Submitted'].decoded != 'no'\n ) ||\n # If the message subject matches the autoresponse pattern.\n (\n MultiMail.autoresponse_pattern &&\n message.subject &&\n message.subject[MultiMail.autoresponse_pattern]\n )\n )\n end", "def has_response?\n if @answers.nil? then\n false\n else\n rc = false\n @answers.each do |answer| # loop through Answers\n if !answer.value.blank? then # any response is good enough\n rc = true\n break\n end\n end\n rc\n end\n end", "def receive_response hResp\n resp = Response.factory( hResp )\n Handler.log.debug \"Response received from #{ip_port}##{resp.id} : #{resp.result? ? resp.result : resp.error}\"\n emit( 'response', resp )\n if resp.id && @response_waited[resp.id]\n @response_waited.delete(resp.id).call(resp)\n elsif resp.result?\n Handler.log.warn \"No handler for this response !\"\n end\n resp\n end", "def response?\n !self.query?\n end", "def allows_response?(responder=nil)\n self.active? && self.open?\n end", "def boolean_from_response(method, path, options = {})\n request(method, path, options)\n @last_response.status == 204\n rescue Gocdkit::NotFound\n false\n end", "def boolean_from_response(method, path, options = {})\n request(method, path, options)\n @last_response.status == 204\n rescue Hyperkit::NotFound\n false\n end", "def responds?\n begin\n @patron.head(\"/#{@path}/\")\n true\n rescue Patron::ConnectionFailed\n false\n end\n end", "def check_response(response)\n response =~ /^Y,/ ? true : false\n end", "def transform_response?(headers, body)\n @transform_response &&\n json_content_type?(headers) &&\n body &&\n true # so the return value is true if all prior conditions are true\n end", "def well_formated_response?\n all_expected_fields_received? && validate_bank_response_signature\n end", "def process_response\n case @msg.sip_method\n when :INVITE\n if client_transaction = @msg.connection.class.invite_client_transactions[@msg.via_branch_id]\n client_transaction.receive_response(@msg)\n return\n end\n when :ACK\n when :CANCEL\n if client_transaction = @msg.connection.class.invite_client_transactions[@msg.via_branch_id]\n client_transaction.receive_response_to_cancel(@msg)\n return\n end\n else\n if client_transaction = @msg.connection.class.non_invite_client_transactions[@msg.via_branch_id]\n client_transaction.receive_response(@msg)\n return\n end\n end\n log_system_debug \"ignoring a response non matching a client transaction (#{@msg.sip_method} #{@msg.status_code})\" if $oversip_debug\n end", "def complete?\n params[\"x_response_code\"] == '1'\n end", "def valid_rpc_response?(response)\n # validate response is an object\n return false unless response.is_a?(Hash)\n\n JSON_RPC_RESPONSE_REQUIRED_MEMBERS.each do |member|\n tmp_member = @symbolize_names ? member : member.to_s\n return false unless response.key?(tmp_member)\n end\n\n # validate response members are correct types\n response.each do |member, value|\n tmp_member = @symbolize_names ? member : member.to_sym\n return false if JSON_RPC_RESPONSE_MEMBER_TYPES.key?(tmp_member) &&\n !JSON_RPC_RESPONSE_MEMBER_TYPES[tmp_member].one? { |type| value.is_a?(type) }\n end\n\n return false if response[:jsonrpc] != JSON_RPC_VERSION\n\n result_key = @symbolize_names ? :result : :result.to_s\n error_key = @symbolize_names ? :error : :error.to_s\n\n return false if response.key?(result_key) && response.key?(error_key)\n\n if response.key?(error_key)\n error_response = response[error_key]\n # validate error response is an object\n return false unless error_response.is_a?(Hash)\n\n JSON_RPC_ERROR_RESPONSE_REQUIRED_MEMBERS.each do |member|\n tmp_member = @symbolize_names ? member : member.to_s\n return false unless error_response.key?(tmp_member)\n end\n\n # validate error response members are correct types\n error_response.each do |member, value|\n tmp_member = @symbolize_names ? member : member.to_sym\n return false if JSON_RPC_ERROR_RESPONSE_MEMBER_TYPES.key?(tmp_member) &&\n !JSON_RPC_ERROR_RESPONSE_MEMBER_TYPES[tmp_member].one? { |type| value.is_a?(type) }\n end\n end\n\n true\n end", "def error?(response)\n response.key?('errorcode')\n end", "def complete?\n params[\"x_response_code\"] == '1'\n end", "def response_equal_answer?\n @response.to_i == eval(@question)\n end", "def send_packet_wait_response(packet, t)\n\t\t# First, add the waiter association for the supplied packet\n\t\twaiter = add_response_waiter(packet)\n\n\t\t# Transmit the packet\n\t\tif (send_packet(packet) <= 0)\n\t\t\treturn nil\n\t\tend\n\n\t\t# Wait for the supplied time interval\n\t\twaiter.wait(t)\n\n\t\t# Remove the waiter from the list of waiters in case it wasn't \n\t\t# removed\n\t\tremove_response_waiter(waiter)\n\n\t\t# Return the response packet, if any\n\t\treturn waiter.response\n\tend", "def reply\n receive_packet 1400\n is_compressed = false\n packet_checksum = 0\n\n if @buffer.long == 0xFFFFFFFE\n split_packets = []\n begin\n request_id = @buffer.long\n is_compressed = ((request_id & 0x80000000) != 0)\n packet_count = @buffer.getbyte\n packet_number = @buffer.getbyte + 1\n\n if is_compressed\n @buffer.long\n packet_checksum = @buffer.long\n else\n @buffer.short\n end\n\n split_packets[packet_number - 1] = @buffer.get\n\n log.debug \"Received packet #{packet_number} of #{packet_count} for request ##{request_id}\"\n\n bytes_read = 0\n if split_packets.size < packet_count\n begin\n bytes_read = receive_packet\n rescue SteamCondenser::Error::Timeout\n end\n end\n end while bytes_read > 0 && @buffer.long == 0xFFFFFFFE\n\n packet = SteamCondenser::Servers::Packets::SteamPacketFactory.reassemble_packet(split_packets, is_compressed, packet_checksum)\n else\n packet = SteamCondenser::Servers::Packets::SteamPacketFactory.packet_from_data(@buffer.get)\n end\n\n if log.debug?\n packet_class = packet.class.name[/[^:]*\\z/]\n if is_compressed\n log.debug \"Got compressed reply of type \\\"#{packet_class}\\\".\"\n else\n log.debug \"Got reply of type \\\"#{packet_class}\\\".\"\n end\n end\n\n packet\n end", "def process_response(cgi_response, ssb_response)\n case\n when ssb_response.nil?\n ['response is nil', 'N/A']\n when ssb_response.instance_of?(String)\n string_response(cgi_response, ssb_response)\n when ['301', '302'].include?(ssb_response.code)\n redirect_response(cgi_response, ssb_response)\n else\n ok_response(cgi_response, ssb_response)\n end\n end", "def status\n return false if !@responses.include?(200)\n \n true\n end", "def got_response(response)\n end", "def response_incomplete?\n content_for_scanner.strip == \"\"\n end", "def is_positive?\n return POSITIVE_RESPONSES.include?(self)\n end", "def json_response?(headers)\n (headers['Content-Type'] == 'application/json')\n end" ]
[ "0.7562703", "0.71092147", "0.7090517", "0.7055952", "0.6656699", "0.6656699", "0.65791756", "0.6459464", "0.64453536", "0.64201343", "0.63938594", "0.6357915", "0.6324102", "0.63155806", "0.6286529", "0.62470406", "0.62134886", "0.6127917", "0.6115845", "0.6079836", "0.60617656", "0.60553277", "0.60464853", "0.6016601", "0.60052234", "0.598915", "0.5984423", "0.597886", "0.59672", "0.5962058", "0.59497494", "0.59315187", "0.5920791", "0.5913307", "0.5912528", "0.5907581", "0.58992356", "0.5895497", "0.5892465", "0.5878915", "0.58704066", "0.58555484", "0.58520675", "0.5842733", "0.58231103", "0.580025", "0.5786609", "0.577854", "0.57736826", "0.5771836", "0.57670397", "0.57540584", "0.5725837", "0.57237834", "0.5719873", "0.57053095", "0.57051975", "0.569426", "0.5687376", "0.5687274", "0.56764853", "0.5673929", "0.56715894", "0.5668748", "0.56624335", "0.5659978", "0.5643299", "0.56421655", "0.5636642", "0.5633913", "0.5620858", "0.56155545", "0.5610175", "0.5608787", "0.5607255", "0.5598125", "0.5587262", "0.5583844", "0.55837744", "0.55806553", "0.55781394", "0.55712456", "0.5562339", "0.5554894", "0.5550384", "0.55469865", "0.5546525", "0.55343837", "0.55247253", "0.55244845", "0.55227685", "0.55190265", "0.5516902", "0.5513414", "0.5512633", "0.55110055", "0.5507435", "0.5500845", "0.54987013" ]
0.83357817
1
Accessors Checks to see if the packet's method is equal to the supplied method.
def method?(method) return (get_tlv_value(TLV_TYPE_METHOD) == method) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def method?(meth)\n get_method(meth)\n end", "def method?(name)\n method_name == name.to_sym\n end", "def method?\n type == TYPE_METHOD\n end", "def method?\n type == TYPE_METHOD\n end", "def method_missing(method, *args)\n method = method.to_s\n if method =~ /^(\\w+)\\?$/\n if args.empty?\n !!self[$1]\n else\n self[$1] == args.first\n end\n else\n self[method]\n end\n end", "def matches? meth\n Citero.map(\"\").respond_to?(meth) && ( directionize(meth).eql?(\"to\") || directionize(meth).eql?(meth.to_s) )\n end", "def method\n @method\n end", "def method\n @method\n end", "def protocol?(method)\n Vpim::Methods.casecmp?(protocol, method)\n end", "def method\n @method\n end", "def method=(value)\n @method = value\n end", "def method\n return @method\n end", "def has_convenience_method?(method_)\n @mutex.synchronize do\n @methods.has_key?(method_)\n end\n end", "def method\n attributes.fetch(:method)\n end", "def method\n @attributes[:method]\n end", "def ===(method); end", "def respond_to?(method)\n @data.key?(method.to_s) || super\n end", "def respond_to?(method_sym, _include_private=false)\n name = method_sym.to_s\n key = :getter?\n if name =~ /^(.*)=$/\n name = Regexp.last_match(1)\n # Use table_map_set() to set these properties\n return false if name == 'table_map' || name == 'table_map_filter'\n key = :setter?\n elsif name =~ /^default_(.*)$/\n name = Regexp.last_match(1)\n key = :default_value?\n end\n begin\n ref = node.cmd_ref.lookup('bgp_af', name)\n ref.send(key)\n rescue IndexError\n super\n end\n end", "def matches? meth\n navigate_method?(meth) || element_id_method?(meth) || wait_method?(meth) || element_id_exists_method?(meth)\n end", "def method\n return @method if defined? @method\n @method = headers[METHOD_KEY]\n @method = @method.downcase.to_sym if @method\n @method\n end", "def respond_to?(method)\n # @hash.key? method is broken so check keys list\n ([method, method.to_s] - @hash.keys).length < 2 || component?(method.to_s) || super\n end", "def respond_to?(method, include_priv = false)\n method_name = method.to_s\n if attributes.nil?\n return super\n elsif attributes.has_key?(method_name)\n return true\n elsif ['?','='].include?(method_name.last) && attributes.has_key?(method_name.first(-1))\n return true\n end\n # super must be called at the end of the method, because the inherited respond_to?\n # would return true for generated readers, even if the attribute wasn't present\n super\n end", "def match_attribute_method?(method_name)\n rebuild_attribute_method_regexp unless defined?(@@attribute_method_regexp) && @@attribute_method_regexp\n @@attribute_method_regexp.match(method_name)\n end", "def respond_to?(meth)\n super(meth) || @value.respond_to?(meth)\n end", "def method\n\t\treturn get_tlv_value(TLV_TYPE_METHOD)\n\tend", "def method\n\t\treturn get_tlv_value(TLV_TYPE_METHOD)\n\tend", "def method(method = nil)\n return @method unless method\n case method\n when :get, :post, :put, :delete\n @method = method\n else\n raise \"Unknown HTTP method :#{method}.\"\n end\n end", "def respond_to?(method)\n instance_variable = \"@#{method.to_s}\".to_sym\n return true if @@keys.include? instance_variable\n super\n end", "def operator_method?\n OPERATOR_METHODS.include?(method_name)\n end", "def member?(meth)\n if valid_meth?(meth)\n @excluded.member?(meth.to_s)\n else\n false\n end\n end", "def respond_to?(method)\n field = method.to_s\n field.chomp!('=')\n\n return true if @name_to_type.key?(field)\n super\n end", "def comparison_method?\n Node::COMPARISON_OPERATORS.include?(method_name)\n end", "def log_collision?(method_key); end", "def matches?(method)\n navigate_method?(method) || element_id_method?(method) || wait_method?(method) || element_id_exists_method?(method)\n end", "def binary_method_operator?\n arguments.one? && Types::BINARY_METHOD_OPERATORS.include?(selector)\n end", "def respond_to?(method)\n return true if name?(method.to_sym)\n super\n end", "def ==(other)\n other.class == Method &&\n @receiver.equal?(other.receiver) &&\n (@executable == other.executable ||\n Rubinius::MethodEquality.method_equal_to_delegated_method_receiver?(self, other))\n end", "def has(method_name)\n @methods.include?(method_name)\n end", "def mplayer_respond_to?(method, include_private = false)\n (@player.nil? && MPlayer::Slave.method_defined?(method)) ||\n @player.respond_to?(method)\n end", "def respond_to?(method)\n return true if @hash.has_key?(method.gsub('=', ''))\n super(method)\n end", "def ==(other)\n return false unless(other.kind_of?(self.class))\n return false unless(@method_name == other.method_name)\n self.class == other.class\n end", "def method=(method)\n if !method.nil? && method.to_s.length > 50\n fail ArgumentError, 'invalid value for \"method\", the character length must be smaller than or equal to 50.'\n end\n\n if !method.nil? && method.to_s.length < 0\n fail ArgumentError, 'invalid value for \"method\", the character length must be great than or equal to 0.'\n end\n\n @method = method\n end", "def supported?(method)\n !@operations.include?(MAP.fetch(method))\n end", "def respond_to?(method, include_private=false)\n control_class = ::Instrument::Control.lookup(method.to_s)\n return true if control_class != nil\n super\n end", "def method_missing(method, *args)\n if method.to_s =~ /^(\\w+)\\?$/\n v = self.class.find_by_symbol($1)\n raise NameError unless v\n other = v.to_sym\n self.class.class_eval { define_method(method) { self.to_sym == other }}\n return self.to_sym == other\n end\n super\n end", "def respond_to?(method, include_private = false)\n get_node.respond_to?(method)\n end", "def http_method\n METHODS[self[:method]]\n end", "def method_missing(method_id, *arguments)\n if match = /is_(\\w+)\\?/.match(method_id.to_s)\n self.status == match[1]\n else\n super\n end\n end", "def assignment_method?\n !comparison_method? && method_name.to_s.end_with?('=')\n end", "def respond_to?(method, include_private = false)\n (actions(current_api).include? method) ? true : super\n end", "def requested_method\n\t\t\t\t# respond to websocket special case\n\t\t\t\treturn :pre_connect if request.upgrade?\n\t\t\t\t# respond to save 'new' special case\n\t\t\t\treturn (self.class.has_method?(:save) ? :save : false) if (request.request_method =~ /POST|PUT|PATCH/i.freeze) && (params[:id].nil? || params[:id] == 'new'.freeze)\n\t\t\t\t# set DELETE method if simulated\n\t\t\t\trequest.request_method = 'DELETE'.freeze if params[:_method] && params[:_method].to_s.downcase == 'delete'.freeze\n\t\t\t\t# respond to special :id routing\n\t\t\t\tparams[:id].to_s.downcase.to_sym.tap { |met| return met if self.class.has_exposed_method?(met) } if params[:id]\n\t\t\t\t#review general cases\n\t\t\t\tcase request.request_method\n\t\t\t\twhen 'GET'.freeze, 'HEAD'.freeze\n\t\t\t\t\treturn (self.class.has_method?(:index) ? :index : false) unless params[:id]\n\t\t\t\t\treturn (self.class.has_method?(:show) ? :show : false)\n\t\t\t\twhen 'POST'.freeze, 'PUT'.freeze, 'PATCH'.freeze\n\t\t\t\t\treturn (self.class.has_method?(:update) ? :update : false)\n\t\t\t\twhen 'DELETE'.freeze\n\t\t\t\t\treturn (self.class.has_method?(:delete) ? :delete : false)\n\t\t\t\tend\n\t\t\t\tfalse\n\t\t\tend", "def respond_to?(method,type=false)\n return true if delegated_instance_methods.include?(method)\n old_respond_to?(method,type)\n end", "def respond_to?(method,type=false)\n return true if delegated_instance_methods.include?(method)\n old_respond_to?(method,type)\n end", "def respond_to_missing?(method, include_private = false)\n attributes.respond_to?(method, false)\n end", "def method_check(compiler)\n ok_label = SlotMachine::Label.new(self,\"method_ok_#{self.object_id}\")\n compile_method = SlotMachine::Slotted.for( compiler.get_method )\n runtime_method = SlotMachine::Slotted.for( :message , [ :method] )\n check = SlotMachine::NotSameCheck.new(compile_method , runtime_method, ok_label)\n # TODO? Maybe create slot instructions for this\n #builder = compiler.builder(\"yield\")\n #Risc::Macro.exit_sequence(builder)\n #check << builder.built\n check << ok_label\n end", "def method=(method)\n\t\tadd_tlv(TLV_TYPE_METHOD, method, true)\n\tend", "def method=(method)\n\t\tadd_tlv(TLV_TYPE_METHOD, method, true)\n\tend", "def respond_to?(method)\n @data_source.respond_to?(\"get_#{method}_info\") || super\n end", "def test_Method_InstanceMethods_eql?\n\t\t# Inside eql?\n\t\tdef fred() return \"a\"+\"b\" end\n\t\talias bert fred\n\t\tm1 = method(:fred)\n\t\tm2 = method(:bert)\n\t\tassert_equal(true, m1.eql?(m2))\n\tend", "def respond_to?(method_name, include_private=false)\n return true if key?(method_name) || method_name.to_s.slice(/[=?!_]\\Z/)\n super\n end", "def ==(other)\n other.class == Method and\n @receiver.equal?(other.receiver) and\n @executable == other.executable\n end", "def safe_send(method)\n return nil unless type = self.class.safe_method_type([method])\n self.send(type[:method])\n end", "def respond_to? meth, include_private=false\n if(matches? meth)\n return true\n else\n super\n end\n end", "def method_missing(method, *args) # {{{\n return @data[method.to_sym] if @data[method.to_sym]\n end", "def respond_to_missing?(method, _include_private = false)\n if @key && _resource.respond_to?(@key) && (delegate = _resource.send(@key)) && delegate.respond_to?(method.to_s)\n true\n else\n _resource.respond_to?(method.to_s)\n end\n end", "def respond_to?(method, include_all = false)\n method_name = method.to_s\n method_name.gsub(/=$/, '')\n (@hash && @converted && (@hash.keys.map(&:to_s) + @converted.keys.map(&:to_s)).include?(method_name)) || super\n end", "def valid_method?(obj, method)\n return true if is_class_method?(obj, method)\n return false unless obj.respond_to?(:instance_methods)\n is_instance_method?(obj, method)\n end", "def valid_meth?(fn)\n fn.is_a?(Method)\n end", "def ==(other)\n return false unless other.kind_of?(self.class)\n return false unless @method_name == other.method_name\n self.class == other.class\n end", "def respond_to?(method)\n @data_source.respond_to? \"get_#{method}_info\" || super\n end", "def respond_to?(meth)\n\t\ttrue\n\tend", "def respond_to?(method_name)\n super || rpc_methods.include?(method_name.to_sym)\n end", "def singleton?(method_name)\n @obj.methods(false).include?(method_name.to_s)\n end", "def respond_to?(method_id, include_private = false)\r\n if method_id.to_s =~ /^mark_as_([a-z]+)_for\\!$/ || method_id.to_s =~ /^mark_as_not_([a-z]+)_for\\!$/ || method_id.to_s =~ /^check_([a-z]+)_for\\?$/\r\n true\r\n else\r\n super\r\n end\r\n end", "def method=(tup)\n @method = tup\n end", "def method=(tup)\n @method = tup\n end", "def event_method?(method_sym)\n @_aggregate.class.event_methods.include? method_sym\n end", "def respond_to?(method_sym, include_private = false)\n super(method_sym, include_private) || data.respond_to?(method_sym, include_private)\n end", "def respond_to?(method_name)\n key?(method_name) ? true : super\n end", "def method=(method)\n raise ArgumentError, \"Invalid method #{method} to apply\" unless INTERFACE_METHODS.include?(method)\n @method = method\n end", "def method_property\n @method_property\n end", "def respond_to?(method)\n return super unless part(method)\n part(method)\n end", "def check_attribute_method_support(name, method)\n raise \"Type #{key_objects[name].type} doesn't support #{method}\" unless @attribute_objects[name].respond_to?(method.to_sym)\n true\n end", "def method_missing(method_id, *arguments) \n match = method_id.to_s.match(/is_(.*)\\?/)\n if match && STATUSES.keys.map { |k| k.to_s }.include?(match[1])\n return self.status == STATUSES[match[1].to_sym]\n end\n \n super\n end", "def method_symbol; end", "def assert_correct_value_for(meth)\n if vm.supports?(meth)\n refute_nil snapshot.send(meth)\n else\n assert_nil snapshot.send(meth)\n end\n end", "def method(method_name)\n \n @_method = method_name.to_s\n \n end", "def respond_to?(method, include_priv = false)\n if @attributes.nil?\n return super\n elsif attr_name = self.class.column_methods_hash[method.to_sym]\n return true if @attributes.include?(attr_name) || attr_name == self.class.primary_key\n return false if self.class.read_methods.include?(attr_name)\n elsif @attributes.include?(method.to_s)\n return true\n elsif md = self.class.match_attribute_method?(method.to_s)\n return true if @attributes.include?(md.pre_match)\n end\n # super must be called at the end of the method, because the inherited respond_to?\n # would return true for generated readers, even if the attribute wasn't present\n super\n end", "def attribute_method?(attr)\n super || attributes.keys.include?(attr)\n end", "def respond_to?(api_method) # :nodoc:\n @client.wsdl.soap_actions.include?(api_method.to_sym)\n end", "def method\r\n@method ||= check_method(env[\"rack.methodoverride.original_method\"] || env['REQUEST_METHOD'])\r\nend", "def expected_method; end", "def matches_directly?(request_path, http_method)\n @paths.path[request_path]&.operation(http_method)\n end", "def [](method)\n self.send(method.to_sym)\n rescue NoMethodError\n nil\n end", "def respond_to?(method, include_private = false)\r\n method.in? self.public_methods(false) || super\r\n end", "def method_missing(method, *args, &block)\n attribute = Ldaptic.encode(method)\n if attribute[-1] == ?=\n attribute.chop!\n if may_must(attribute)\n return write_attribute(attribute, *args, &block)\n end\n elsif attribute[-1] == ??\n attribute.chop!\n if may_must(attribute)\n if args.empty?\n return !read_attribute(attribute).empty?\n else\n return args.flatten.any? {|arg| compare(attribute, arg)}\n end\n end\n elsif attribute =~ /\\A(.*)-before-type-cast\\z/ && may_must($1)\n return read_attribute($1, *args, &block)\n elsif may_must(attribute)\n return read_attribute(attribute, *args, &block).one\n end\n super(method, *args, &block)\n end", "def respond_to?(method, include_private = false)\n super || model.respond_to?(method) || relationships.has_key?(method)\n end", "def eql?(other)\n self.test_class == other.test_class &&\n self.method == other.method\n end", "def allowed_method(method=nil)\n if method.class == Symbol && !block_given?\n @j_del.java_method(:allowedMethod, [Java::IoVertxCoreHttp::HttpMethod.java_class]).call(Java::IoVertxCoreHttp::HttpMethod.valueOf(method))\n return self\n end\n raise ArgumentError, \"Invalid arguments when calling allowed_method(method)\"\n end" ]
[ "0.69155854", "0.64431316", "0.641461", "0.641461", "0.6277275", "0.62540424", "0.62319046", "0.62319046", "0.62219185", "0.6196342", "0.6066746", "0.59882295", "0.59676826", "0.5954562", "0.5952327", "0.59304565", "0.59228283", "0.58531755", "0.583721", "0.5803583", "0.58011746", "0.5772808", "0.57704896", "0.5761486", "0.57335144", "0.57335144", "0.57262355", "0.5713266", "0.5704873", "0.5695485", "0.5687999", "0.56850564", "0.56787974", "0.5669209", "0.56685805", "0.56599826", "0.5658647", "0.5643813", "0.56346714", "0.56262845", "0.5611393", "0.5609667", "0.56076574", "0.5592784", "0.55779034", "0.55756974", "0.55681574", "0.5561841", "0.5558309", "0.5552356", "0.55431813", "0.55369604", "0.55369604", "0.55362225", "0.5529251", "0.55280304", "0.55280304", "0.5524986", "0.55099195", "0.5481129", "0.54732805", "0.5469404", "0.54690635", "0.5455055", "0.54506445", "0.54486537", "0.5438063", "0.5437134", "0.5433935", "0.5424166", "0.54225045", "0.5419301", "0.54192215", "0.541686", "0.5406433", "0.5406433", "0.54056084", "0.54021364", "0.5397982", "0.53904945", "0.5386778", "0.53826135", "0.5382529", "0.538072", "0.5370667", "0.5362488", "0.53620505", "0.5355708", "0.5353678", "0.53473186", "0.53462106", "0.53387463", "0.53380424", "0.53297144", "0.53201604", "0.53180254", "0.5317823", "0.531634", "0.53134257" ]
0.7064831
1
Sets the packet's method TLV to the method supplied.
def method=(method) add_tlv(TLV_TYPE_METHOD, method, true) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def method=(value)\n @method = value\n end", "def method=(method)\n if !method.nil? && method.to_s.length > 50\n fail ArgumentError, 'invalid value for \"method\", the character length must be smaller than or equal to 50.'\n end\n\n if !method.nil? && method.to_s.length < 0\n fail ArgumentError, 'invalid value for \"method\", the character length must be great than or equal to 0.'\n end\n\n @method = method\n end", "def method\n\t\treturn get_tlv_value(TLV_TYPE_METHOD)\n\tend", "def method\n\t\treturn get_tlv_value(TLV_TYPE_METHOD)\n\tend", "def method=(method)\n raise ArgumentError, \"Invalid method #{method} to apply\" unless INTERFACE_METHODS.include?(method)\n @method = method\n end", "def method(method_name)\n \n @_method = method_name.to_s\n \n end", "def method=(tup)\n @method = tup\n end", "def method=(tup)\n @method = tup\n end", "def method(method = nil)\n return @method if method.nil?\n\n @method = method.to_s.capitalize\n end", "def method(method = nil)\n return @method unless method\n case method\n when :get, :post, :put, :delete\n @method = method\n else\n raise \"Unknown HTTP method :#{method}.\"\n end\n end", "def sig_method=(value)\n @children['sigMethod'][:value] = value\n end", "def sig_method=(value)\n @children['sigMethod'][:value] = value\n end", "def method?(method)\n\t\treturn (get_tlv_value(TLV_TYPE_METHOD) == method)\n\tend", "def method?(method)\n\t\treturn (get_tlv_value(TLV_TYPE_METHOD) == method)\n\tend", "def method(method)\n raise ArgumentError, \"Invalid form method \\\"#{method}\\\"\" unless %i[create update].include?(method)\n\n @form_method = method\n end", "def method\n return @method if defined? @method\n @method = headers[METHOD_KEY]\n @method = @method.downcase.to_sym if @method\n @method\n end", "def method_tag\n method = options[:method]\n\n case method\n when /^get$/ # must be case-insensitive, but can't use downcase as might be nil\n options[:method] = 'get'\n ''\n when /^post$/, '', nil\n options[:method] = 'post'\n ''\n else\n options[:method] = 'post'\n Hidden.(value: method, name: '_method').to_s\n end\n end", "def method\n @method ||= options[:method]\n end", "def set_method_type\n @method_type = MethodType.find(params[:id])\n end", "def add_method(method)\n # THREAD CRITICAL BEGIN\n remove_method(method.signature)\n @method.push(method)\n method.multimethod = self\n @lookup_method = { } # flush cache\n # THREAD CRITICAL END\n end", "def parse_method=(method)\n if not [:XML, :HTML].include?(method)\n raise ArgumentError, \"parse_method must be one of :XML, :HTML!\"\n end\n @parse_method = method\n end", "def reset_method_type\n @method_type = :instance_method\n end", "def safe_send(method)\n return nil unless type = self.class.safe_method_type([method])\n self.send(type[:method])\n end", "def allowed_method(method=nil)\n if method.class == Symbol && !block_given?\n @j_del.java_method(:allowedMethod, [Java::IoVertxCoreHttp::HttpMethod.java_class]).call(Java::IoVertxCoreHttp::HttpMethod.valueOf(method))\n return self\n end\n raise ArgumentError, \"Invalid arguments when calling allowed_method(method)\"\n end", "def dcv_method=(value)\n @dcv_method = value.downcase\n end", "def add_method(relation, method)\n relation.instance_variable_get(:@available_methods).add(method)\n relation\n end", "def gen_setter(method_spec)\n method_id = \"0x\" + calc_id(gen_method_id(method_spec[\"name\"], get_types(method_spec)))\n self.class.send(:define_method, method_spec[\"name\"].underscore << \"!\") do |*args|\n options = args[-1]\n encoded_inputs = W3::Encoder::encode_inputs(args[0..-2], method_spec[\"inputs\"])\n @eth.send_transaction!({\n \"from\" => options[\"from\"],\n \"to\" => @address,\n \"data\" => encoded_inputs.unshift(method_id).join\n })\n end\n end", "def http_method= new_verb\n @http_method = new_verb.to_s.upcase\n end", "def http_method= new_verb\n @http_method = new_verb.to_s.upcase\n end", "def send_method(method, value)\n values = [value]\n class_method = method.first.split('.') if method.is_a?(Array)\n class_method = method.split('.') if method.is_a?(String)\n klass = Object.const_get(class_method.first)\n values << method.drop(1).map { |x| x } if method.is_a? Array\n klass.send(class_method.last, *values)\n end", "def http_method(v)\n endpoint_info[:http_method] = v\n end", "def authen_method=(val)\n if (val.kind_of?(Integer))\n @authen_method = val & 0xff\n elsif(val.kind_of?(String))\n raise ArgumentError, \"Value must be 1-byte, but was #{val.length}.\" if (val.length != 1) \n @authen_method = val.unpack('C')[0]\n else\n raise ArgumentError, \"Expected String or Integer, but #{val.class} provided.\" \n end\n return(nil)\n end", "def methods=(value)\n @methods = value\n end", "def method\n @method\n end", "def method\n @method\n end", "def method\n options.fetch(:method, nil)\n end", "def method\n @method\n end", "def callback_method=(callback_method)\n validator = EnumAttributeValidator.new('String', [\"POST\", \"GET\"])\n unless validator.valid?(callback_method)\n fail ArgumentError, \"invalid value for \\\"callback_method\\\", must be one of #{validator.allowable_values}.\"\n end\n @callback_method = callback_method\n end", "def method\n @method ||= XmlRpc::API::Message.parse_value(@document.root.elements[\"methodName\"])\n end", "def subject=(value)\n unless value =~ METHOD_DEF\n raise ArgumentError, \"not a method definition: #{value}\"\n end\n \n @method_name = $1\n @arguments = scan_args($2)\n \n super\n end", "def method\n parse_request! if @method.nil?\n @method\n end", "def fallback_method=(fallback_method)\n validator = EnumAttributeValidator.new('String', [\"POST\", \"GET\"])\n unless validator.valid?(fallback_method)\n fail ArgumentError, \"invalid value for \\\"fallback_method\\\", must be one of #{validator.allowable_values}.\"\n end\n @fallback_method = fallback_method\n end", "def method=(_); end", "def type\n 'Method'\n end", "def set_payment_with!(method)\n\t\tself.update_column(:payment_method, method)\n\tend", "def add(method)\n key = [method.receiver, method.name]\n @methods[key] = method\n end", "def method\n @attributes[:method]\n end", "def http_method\n\t\t\t\treturn @http_method if defined?(@http_method)\n\n\t\t\t\tmethod_from_method =\n\t\t\t\t\tbegin\n\t\t\t\t\t\tparams['_method']\n\t\t\t\t\trescue ArgumentError => e\n\t\t\t\t\t\t## https://github.com/rack/rack/issues/337#issuecomment-48555831\n\t\t\t\t\t\traise unless e.message.include?('invalid %-encoding')\n\t\t\t\t\tend\n\n\t\t\t\t@http_method = (method_from_method || request_method).upcase.to_sym\n\t\t\tend", "def firewall_packet_queueing_method=(value)\n @firewall_packet_queueing_method = value\n end", "def http_method\n METHODS[self[:method]]\n end", "def method\n options[:method] || :get\n end", "def method_missing(methName, arg, &block)\n methods[methName] = arg\n self\n end", "def method\n attributes.fetch(:method)\n end", "def use_as_method\n @method = true\n end", "def digest_method=(value)\n @children['digestMethod'][:value] = value\n end", "def digest_method=(value)\n @children['digestMethod'][:value] = value\n end", "def write_method=(val)\n @write_method = val if %w(:flock :normal).include(val)\n end", "def struct_writer(method)\n class_eval <<-RUBY\n attr_writer :#{method}\n RUBY\n end", "def create_input_edge_method(method_id, carrier_name, side, method)\n if /^(.*)_(constant|share|inversedflexible|flexible)$/.match?(carrier_name)\n carrier_name, edge_type =\n carrier_name.match(/^(.*)_(constant|share|inversedflexible|flexible)$/).captures\n\n edge_type = 'inversed_flexible' if edge_type == 'inversedflexible'\n end\n\n define_method method_id do\n if (slot = node.send(side, carrier_name.to_sym))\n edge = if edge_type.nil?\n slot.edges.first\n else\n slot.edges.detect { |l| l.send(\"#{edge_type}?\") }\n end\n\n edge&.send(method)\n end\n end\n end", "def restrict_method(m)\n m = m.intern if m.is_a?(String)\n\n raise ArgumentError, _(\"'%{m}' is not an allowed value for method directive\") % { m: m } unless ALL.include?(m)\n\n # if we were allowing all methods, then starts from scratch\n if @methods === ALL\n @methods = []\n end\n\n raise ArgumentError, _(\"'%{m}' is already in the '%{name}' ACL\") % { m: m, name: name } if @methods.include?(m)\n\n @methods << m\n end", "def data_to_method(data)\n raise \"No safe methods defined!\" unless @safe_methods.size > 0\n @safe_methods.each do |method|\n if data['mode'] == method.to_s\n self.send(data['mode'], data)\n end\n end\n end", "def method_Code\n method = \"method_Code\"\n end", "def initialize(method_name)\n @method_name = method_name\n end", "def method_symbol\r\nHTTP_METHOD_LOOKUP[method]\r\nend", "def set_code_method\n @code_method = CodeMethod.find(params[:id])\n end", "def request_method(query)\n (options[:method] || DEFAULT_METHOD).to_sym\n end", "def fido2_methods=(value)\n @fido2_methods = value\n end", "def register_method(method, &block)\n self.class.register_method(method, &block)\n end", "def redefine_method(method, &block)\n visibility = method_visibility(method)\n remove_possible_method(method)\n define_method(method, &block)\n send(visibility, method)\n end", "def protocol\n m = @properties['METHOD']\n m ? m.upcase : m\n end", "def select(method, choices = nil, options = {}, html_options = {}, &block)\n html_options['data-bind'] = \"value: #{method}\"\n super(method, choices, options, html_options, &block)\n end", "def add_method\n <<-CODE\n next_literal;\n t1 = stack_pop();\n t2 = stack_pop();\n cpu_add_method(state, c, t1, _lit, t2);\n stack_push(t2);\n cpu_perform_hook(state, c, t1, global->sym_method_added, _lit);\n CODE\n end", "def set_handler(name,type,method)\n raise \"type must be one of #{@handlers.keys}\" unless @handlers.keys.include?(type)\n Log.log.debug(\"setting #{type} handler for #{name}\")\n @handlers[type][name]=method\n end", "def parse_tree_for_method(klass, method, is_cls_meth=false)\n $stderr.puts \"** parse_tree_for_method(#{klass}, #{method}):\" if $DEBUG\n r = parse_tree_for_meth(klass, method.to_sym, is_cls_meth)\n r\n end", "def shipping_method=(method)\n raise ArgumentError.new(\"method cannot be nil\") unless method.present?\n self.shipping_name = method.name\n self.shipping_cost = method.cost\n end", "def attribute_method\n method_options = options\n\n lambda do |name, type = Object, options = {}|\n super(name, type, method_options.update(options))\n end\n end", "def set_payment_with!(method)\n\t\tself.update_columns(payment_method: method)\n\tend", "def method_missing(method)\n\t\t self[method]\n\t\tend", "def tag(method, *tags)\n @yuuki_methods ||= {}\n @yuuki_methods[method] ||= {}\n @yuuki_methods[method][:tags] ||= Set.new\n @yuuki_methods[method][:tags].merge(tags)\n end", "def method_missing(meth, options = T.unsafe(nil)); end", "def redefine_method(method, &block)\n remove_possible_method(method)\n define_method(method, &block)\n end", "def http_method(value = nil)\n if value\n @http_method = value\n else\n @http_method\n end\n end", "def execute(method)\n send(method)\n end", "def method\n return @method\n end", "def method_missing(method,val=nil)\n if val.nil?\n get(method)\n else\n method = method.to_s[0..-2].to_sym # get rid of = sign\n set(method,val)\n end\n end", "def add_method method\n return method unless @document_self\n\n # HACK: avoid duplicate 'new' in io.c & struct.c (1.8.7 source code)\n key = method.pretty_name\n known = @methods_hash[key]\n\n if known then\n if @store then # otherwise we are loading\n known.comment = method.comment if known.comment.empty?\n previously = \", previously in #{known.file}\" unless\n method.file == known.file\n @store.rdoc.options.warn \\\n \"Duplicate method #{known.full_name} in #{method.file}#{previously}\"\n end\n else\n @methods_hash[key] = method\n if @current_line_visibility\n method.visibility, @current_line_visibility = @current_line_visibility, nil\n else\n method.visibility = @visibility\n end\n add_to @method_list, method\n resolve_aliases method\n end\n\n method\n end", "def alert_method=(alert_method)\n validator = EnumAttributeValidator.new('String', ['none', 'sms', 'email'])\n unless validator.valid?(alert_method)\n fail ArgumentError, 'invalid value for \"alert_method\", must be one of #{validator.allowable_values}.'\n end\n @alert_method = alert_method\n end", "def key_method method\n @key_method = method\n validates_presence_of method\n validates_length_of method, minimum: 1\n define_method(:key) { prepare_key(self.send method) }\n end", "def method(name = nil)\n name.nil? ? @method : super(name)\n end", "def attach_method\n <<-CODE\n next_literal;\n t1 = stack_pop();\n t2 = stack_pop();\n cpu_attach_method(state, c, t1, _lit, t2);\n stack_push(t2);\n cpu_perform_hook(state, c, t1, global->sym_s_method_added, _lit);\n CODE\n end", "def compatible_call(method, *options)\n compatibility_version.send(method, *options)\n rescue NameError\n not_supported \"the \\\"#{method}\\\" action\"\n rescue\n end", "def method\n @method ||= ( ( ( m = @request.request_method.downcase ) == 'post' and\n ( n = @request['_method'] ) ) ? n.downcase : m ).intern\n end", "def assign_operation(method)\n\n\n\n # 231:7: variable_name[method] assign_operator ( expression[method] )* ';'\n variable_name(method)\n\n assign_operator()\n\n # 231:45: ( expression[method] )*\n while true\n alt32 = 2\n # ()* loopback of 231:45: ( expression[method] )*\n look_ahead32_0 = look_ahead(1)\n if look_ahead32_0 == :IDENTIFIER || look_ahead32_0 == :NUMBER || (TOKENS[look_ahead32_0] >= 25 && TOKENS[look_ahead32_0] <= 26) || look_ahead32_0 == :ECOMMERCIAL || (TOKENS[look_ahead32_0] >= 31 && TOKENS[look_ahead32_0] <= 32) || (TOKENS[look_ahead32_0] >= 35 && TOKENS[look_ahead32_0] <= 46) || (TOKENS[look_ahead32_0] >= 48 && TOKENS[look_ahead32_0] <= 49) || look_ahead32_0 == :T58 \n alt32 = 1\n end\n case alt32\n when 1\n # 231:47: expression[method]\n expression(method)\n\n else\n break\n end\n end\n match(:SEMICOLON)\n\n\n\n end", "def method_symbol; end", "def set_handler(method, val)\n send(\"#{method}=\", val)\n end", "def select_timing_method(method)\n if @handle.ptr == nil\n raise \"this is disposed\"\n end\n Native.RunEditor_select_timing_method(@handle.ptr, method)\n end", "def insert_param_method_generic(param_name,method_name)\n setter_method = param_name + \"=\"\n if send(param_name)\n @new_item.send(setter_method,send(param_name).send(method_name))\n end\n end", "def upload_method=(upload_method)\n allowed_values = [\"SINGLE_PUT\", \"MULTIPART_POST\"]\n if upload_method && !allowed_values.include?(upload_method)\n fail ArgumentError, \"invalid value for 'upload_method', must be one of #{allowed_values}.\"\n end\n @upload_method = upload_method\n end", "def method\r\n@method ||= check_method(env[\"rack.methodoverride.original_method\"] || env['REQUEST_METHOD'])\r\nend" ]
[ "0.67816097", "0.65247405", "0.63467485", "0.63467485", "0.6029751", "0.5918826", "0.59114987", "0.59114987", "0.57330585", "0.5731458", "0.56493545", "0.56493545", "0.5646641", "0.5646641", "0.56248724", "0.56207037", "0.5620436", "0.55733067", "0.5537182", "0.55149496", "0.54550034", "0.5439585", "0.54379445", "0.5386849", "0.53428775", "0.533865", "0.53251386", "0.5312168", "0.5312168", "0.5293919", "0.52912307", "0.52598774", "0.52144516", "0.520471", "0.520471", "0.5189917", "0.5185677", "0.51784843", "0.51450914", "0.51088804", "0.5089659", "0.5065203", "0.50380814", "0.5037292", "0.5032528", "0.50269145", "0.50051963", "0.4993662", "0.49485105", "0.49457896", "0.49189505", "0.4909768", "0.49008784", "0.48988858", "0.4895395", "0.4895395", "0.48892587", "0.48606998", "0.48407298", "0.48364344", "0.4835869", "0.48314598", "0.48144552", "0.47621053", "0.47571418", "0.47502038", "0.47477168", "0.47401172", "0.473507", "0.47270796", "0.47261512", "0.47237", "0.4712884", "0.46917138", "0.46767098", "0.4672995", "0.46648282", "0.46518627", "0.46501702", "0.46365112", "0.46344727", "0.46279424", "0.462642", "0.4623881", "0.46188837", "0.4613699", "0.4611767", "0.4602844", "0.46024498", "0.46008104", "0.45955303", "0.458975", "0.45873713", "0.45795852", "0.4575823", "0.45756605", "0.45725724", "0.45658553", "0.45619226" ]
0.7885921
1
Returns the value of the packet's method TLV.
def method return get_tlv_value(TLV_TYPE_METHOD) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def method\n @attributes[:method]\n end", "def method\n @method ||= XmlRpc::API::Message.parse_value(@document.root.elements[\"methodName\"])\n end", "def method=(method)\n\t\tadd_tlv(TLV_TYPE_METHOD, method, true)\n\tend", "def method=(method)\n\t\tadd_tlv(TLV_TYPE_METHOD, method, true)\n\tend", "def method\n return @method\n end", "def method\n attributes.fetch(:method)\n end", "def method_code\r\n method_info[:method_code]\r\n end", "def method\n @json['method']\n end", "def method\n parse_request! if @method.nil?\n @method\n end", "def method?(method)\n\t\treturn (get_tlv_value(TLV_TYPE_METHOD) == method)\n\tend", "def method?(method)\n\t\treturn (get_tlv_value(TLV_TYPE_METHOD) == method)\n\tend", "def method\n @method\n end", "def type\n 'Method'\n end", "def method\n @method\n end", "def method\n @method\n end", "def get(method)\n if method.is_a? Symbol\n @fields[get_by_sym(method)] || Blank.new\n elsif method.is_a? Integer\n return @fields[method] || Blank.new\n end\n end", "def method\n return @method if defined? @method\n @method = headers[METHOD_KEY]\n @method = @method.downcase.to_sym if @method\n @method\n end", "def protocol\n m = @properties['METHOD']\n m ? m.upcase : m\n end", "def http_method\n METHODS[self[:method]]\n end", "def value\n @methods\n end", "def method_tag\n method = options[:method]\n\n case method\n when /^get$/ # must be case-insensitive, but can't use downcase as might be nil\n options[:method] = 'get'\n ''\n when /^post$/, '', nil\n options[:method] = 'post'\n ''\n else\n options[:method] = 'post'\n Hidden.(value: method, name: '_method').to_s\n end\n end", "def http_method\n @parser.http_method\n end", "def extract_grpc_method(grpc_method_object)\n owner = grpc_method_object.owner\n\n return VALUE_UNKNOWN unless owner.instance_variable_defined?(:@rpc_descs)\n\n method, = owner.rpc_descs.find do |k, _|\n ::GRPC::GenericService.underscore(k.to_s) == grpc_method_object.name.to_s\n end\n\n return VALUE_UNKNOWN if method.nil?\n\n method.to_s\n end", "def method_field(name)\n self.method_fields.where(fieldable_id: self.id).where(\"payload->>'key' = ?\", name).first\n end", "def method_symbol\r\nHTTP_METHOD_LOOKUP[method]\r\nend", "def request_method\n @attributes[:request_method]\n end", "def form_method\n\t\t\t\tspecial_method = Webrat::XML.css_search(@element, 'input[name=\"_method\"]').first\n\t\t\t\tunless special_method.nil?\n\t\t\t\t\tspecial_method['value']\n\t\t\t\telse\n\t\t\t\t\tWebrat::XML.attribute(@element, \"method\").blank? ? :get : Webrat::XML.attribute(@element, \"method\").downcase\n\t\t\t\tend\n\t\t\tend", "def method=(value)\n @method = value\n end", "def value\n @method.call\n end", "def method\n @method ||= options[:method]\n end", "def type\n @type ||= @method[(@method.rindex('/') + 1)..-1]\n end", "def method_information(type, name)\n return constant.send(type, name)\n end", "def execute\n case @method\n when \"0001\"\n print decode_twos_complement(@value)\n when \"0010\"\n print decode_floating_point(@value)\n else\n print @value.binary_to_decimal.chr\n end\n end", "def method\n link_schema['method'].downcase.to_sym\n end", "def name\n method_descriptor_proto.name\n end", "def getopcode(op)\n field_m(op)\nend", "def method_name\r\n method_info[:method_name]\r\n end", "def message\n\t\t\t@packet.message\n\t\tend", "def method\n unescape params['x_method']\n end", "def method_property\n @method_property\n end", "def authen_method=(val)\n if (val.kind_of?(Integer))\n @authen_method = val & 0xff\n elsif(val.kind_of?(String))\n raise ArgumentError, \"Value must be 1-byte, but was #{val.length}.\" if (val.length != 1) \n @authen_method = val.unpack('C')[0]\n else\n raise ArgumentError, \"Expected String or Integer, but #{val.class} provided.\" \n end\n return(nil)\n end", "def type\n\t\t\t@packet.type\n\t\tend", "def result\n\t\treturn get_tlv_value(TLV_TYPE_RESULT)\n\tend", "def result\n\t\treturn get_tlv_value(TLV_TYPE_RESULT)\n\tend", "def method\n unescape params['x_method']\n end", "def method_symbol; end", "def method_information(type, name)\n return constant.__send__(type, name)\n end", "def allowed_2fa_method_totp\n @attributes[:allowed_2fa_method_totp]\n end", "def tagMethod?()\r\n\t\tlang = language()\r\n\t\treturn (@type == \"m\" || @type==\"f\") if (lang == \"java\")\r\n\t\treturn (@type == \"f\") if (lang == \"cpp\")\r\n\tend", "def authentication_method\n @authentication_method ||= begin\n method = nil\n send_line('PROTOCOLINFO')\n loop do\n # TODO: support for reading multiple authentication methods\n case reply = read_reply\n when /^250-AUTH METHODS=(\\w*)/\n method = $1.strip.downcase.to_sym\n method = method.eql?(:null) ? nil : method\n when /^250-/ then next\n when '250 OK' then break\n end\n end\n method\n end\n end", "def get_value_with_method_name(method_name)\n get_contact_detail_value(hash_from_method_name(method_name))\n end", "def method\n @headers[\"REQUEST_METHOD\"].downcase.to_sym\n end", "def method\n options[:method] || :get\n end", "def voting_method\n VOTING_METHODS[self.voting_method_id]\n end", "def parse_field_method(method_name)\n method_name = method_name.to_s\n return nil unless method_name.end_with? '_field'\n\n field_type_name = method_name.delete_suffix('_field').to_sym\n config.field_types.find(field_type_name)\n end", "def get_Method(initial)\n\tinitial.split(' ',3)[0]\nend", "def request_method(verb)\n Net::HTTP.const_get(verb.to_s.capitalize)\n end", "def value sym\r\n @@tag_methods.has_key?(sym) ? value(@@tag_methods[sym]) : @values[sym]\r\n end", "def method\n expect :call, :attrasgn, :safe_call, :safe_attrasgn, :super, :zsuper, :result\n\n case self.node_type\n when :call, :attrasgn, :safe_call, :safe_attrasgn\n self[2]\n when :super, :zsuper\n :super\n when :result\n self.last\n end\n end", "def dcv_method=(value)\n @dcv_method = value.downcase\n end", "def method_name\n return @method_name if defined? @method_name\n\n @method_name = protocol_name.downcase.sub(/::/, '_')\n end", "def sig_method=(value)\n @children['sigMethod'][:value] = value\n end", "def sig_method=(value)\n @children['sigMethod'][:value] = value\n end", "def method_missing(method, *args)\n if opt = get(method)\n opt.value\n else\n raise NoMethodError, method\n end\n end", "def method_Code\n method = \"method_Code\"\n end", "def method(method = nil)\n return @method if method.nil?\n\n @method = method.to_s.capitalize\n end", "def get_tlv_value(type, index = 0)\n\t\ttlv = get_tlv(type, index)\n\n\t\treturn (tlv != nil) ? tlv.value : nil\n\tend", "def get_tlv_value(type, index = 0)\n\t\ttlv = get_tlv(type, index)\n\n\t\treturn (tlv != nil) ? tlv.value : nil\n\tend", "def callee\n @method\n end", "def request_method_symbol\r\nHTTP_METHOD_LOOKUP[request_method]\r\nend", "def http_method\n\t\t\t\treturn @http_method if defined?(@http_method)\n\n\t\t\t\tmethod_from_method =\n\t\t\t\t\tbegin\n\t\t\t\t\t\tparams['_method']\n\t\t\t\t\trescue ArgumentError => e\n\t\t\t\t\t\t## https://github.com/rack/rack/issues/337#issuecomment-48555831\n\t\t\t\t\t\traise unless e.message.include?('invalid %-encoding')\n\t\t\t\t\tend\n\n\t\t\t\t@http_method = (method_from_method || request_method).upcase.to_sym\n\t\t\tend", "def method\n request.method\n end", "def get_byte\n get(1).ord\n end", "def fetch_value(method)\n fetch(:lens, nil)&.fetch(method, nil) || fetch(method, nil)\n end", "def build_v5_authentication_method_message(auth_method)\n message = case auth_method\n when 0x00 then\n \"No authentication\"\n when 0x01 then\n \"GSSAPI authentication\"\n when 0x02 then\n \"Username/Password authentication\"\n when 0x03..0x7F then\n \"Authentication method assigned by IANA\"\n when 0x80..0xFE then\n \"Authentication method reserved for private use\"\n when 0xFF then\n \"Unsupported authentication\"\n else\n \"Unknown authentication\"\n end\n\n \"%s (Method: 0x%02X)\" % [message, auth_method]\n\n rescue\n \"Authentication Method: #{auth_method.inspect}\"\n end", "def http_method\n @http_method.to_s.upcase\n end", "def getbyte\n end", "def getbyte\n end", "def method\n @method ||= ( ( ( m = @request.request_method.downcase ) == 'post' and\n ( n = @request['_method'] ) ) ? n.downcase : m ).intern\n end", "def operation\n self[:operation].to_endian(:big)\n end", "def method(method = nil)\n return @method unless method\n case method\n when :get, :post, :put, :delete\n @method = method\n else\n raise \"Unknown HTTP method :#{method}.\"\n end\n end", "def method(method_name)\n \n @_method = method_name.to_s\n \n end", "def get_tlv(type, index = 0)\n\t\ttype_tlvs = get_tlvs(type)\n\n\t\tif (type_tlvs.length > index)\n\t\t\treturn type_tlvs[index]\n\t\tend\n\n\t\treturn nil\n\tend", "def get_tlv(type, index = 0)\n\t\ttype_tlvs = get_tlvs(type)\n\n\t\tif (type_tlvs.length > index)\n\t\t\treturn type_tlvs[index]\n\t\tend\n\n\t\treturn nil\n\tend", "def opcode\n\t\t\treturn OPCODE_NAME[ self.numeric_opcode ]\n\t\tend", "def decode_tlv(data)\n raise OutOfData if (data.length == 2 && data[1].ord != 0) || data.length < 2\n tag = data[0].ord\n length = data[1].ord\n if length < 0x80\n value = data[2, length]\n remainder = data[length+2..-1]\n else\n # ASN.1 says this octet can't be 0xff\n raise InvalidLength, length.to_s if length == 0xff\n num_octets = length & 0x7f\n length = build_integer(data, 2, num_octets)\n value = data[num_octets+2, length]\n remainder = data[num_octets+2+length..-1]\n end\n return tag, value, remainder\n end", "def gen_getter(method_spec)\n method_id = \"0x\" + calc_id(gen_method_id(method_spec[\"name\"], get_types(method_spec)))\n self.class.send(:define_method, method_spec[\"name\"].underscore) do |*args|\n encoded_inputs = W3::Encoder::encode_inputs(args, method_spec[\"inputs\"])\n outputs = @eth.call({\n \"to\" => @address,\n \"data\" => encoded_inputs.unshift(method_id).join\n })\n W3::Decoder::decode_outputs(outputs, method_spec[\"outputs\"])\n end\n end", "def method\n if self[:method].blank?\n PERCENTAGE\n else\n self[:method]\n end\n end", "def method\n options.fetch(:method, nil)\n end", "def method(name=nil) # :nodoc:\n return name ? super : @meth\n end", "def http_method\n return if request_response_pairs.empty?\n request_response_pairs.first.first.request_method\n end", "def version; PACKET_VERSION; end", "def get_method\n request_object.method\n end", "def get_internal_byte context\n compiler = compiler_for(:Word , :get_internal_byte)\n source = \"get_internal_byte\"\n me , index = self_and_arg(compiler,source)\n # reduce me to me[index]\n compiler.add_code GetByte.new( source , me , index , me)\n # and put it back into the return value\n compiler.add_code Register.set_slot( source , me , :message , :return_value)\n return compiler.method\n end", "def analysis_method_name\n method = self.payload['computational_method']\n method.present? ? method.gsub(/https:\\/\\/api\\.firecloud\\.org\\/api\\/methods\\//, '') : ''\n end", "def select_support_method(client)\n version, nmethods = client.read(2).unpack('CC')\n\n supported_methods = []\n nmethods.times {\n supported_methods << client.read(1).ord\n }\n supported_methods.first\nend", "def download_method\n @attributes[:download_method]\n end", "def get_value\r\n @bitstring\r\n end", "def method\n @method || @method = self.variations.not_deleted.first.garment_size.gender.downcase if self.variations.not_deleted.length > 0 && !self.variations.not_deleted.first.garment_size.nil?\n end" ]
[ "0.66449827", "0.6427894", "0.62348956", "0.62348956", "0.61928266", "0.6185657", "0.61612", "0.6147445", "0.60788554", "0.60273", "0.60273", "0.59890664", "0.59378624", "0.590511", "0.590511", "0.58919007", "0.5833403", "0.5778146", "0.573545", "0.5673272", "0.56294584", "0.54756224", "0.5456649", "0.54364", "0.5421986", "0.5398096", "0.53872263", "0.53742725", "0.5360507", "0.53164417", "0.5257437", "0.5255051", "0.52516246", "0.5248796", "0.52469754", "0.52454156", "0.5218241", "0.5208117", "0.520128", "0.51957333", "0.51918375", "0.51897126", "0.5181686", "0.5181686", "0.51691085", "0.513639", "0.51320875", "0.51031786", "0.5100964", "0.5099305", "0.509266", "0.5077857", "0.50735927", "0.50647974", "0.5062238", "0.506052", "0.5056227", "0.5037059", "0.5012743", "0.5011673", "0.5008154", "0.50076646", "0.50076646", "0.49876666", "0.4984187", "0.4975111", "0.49623162", "0.49623162", "0.49569827", "0.4949101", "0.49357572", "0.49349725", "0.49305928", "0.49296466", "0.49175045", "0.49147007", "0.49072236", "0.49072236", "0.4893335", "0.48923534", "0.489085", "0.4886304", "0.48756433", "0.48756433", "0.48753023", "0.48686317", "0.48659703", "0.4859613", "0.48554003", "0.48485237", "0.484789", "0.4813047", "0.48035073", "0.4801487", "0.47839472", "0.4782545", "0.47817323", "0.4779709", "0.4770975" ]
0.85062265
1
Checks to see if the packet's result value is equal to the supplied result.
def result?(result) return (get_tlv_value(TLV_TYPE_RESULT) == result) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def validate_answer(answer)\n answer == @result\n end", "def expected_result\n if @assert['result'] == '&result'\n @result\n elsif @assert['result'] != 'void'\n to_hex(@assert['result']['$hex'])\n end\n end", "def result(answer)\n @answer == answer.to_i \n end", "def next_result\n return false unless more_results\n check_connection\n @fields = nil\n nfields = @protocol.get_result\n if nfields\n @fields = @protocol.retr_fields nfields\n @result_exist = true\n end\n return true\n end", "def compare_result(test, result)\n if @per_test_insert\n expected = translate_column_names(test['expected'])\n else\n expected = test['expected']\n end\n expected.each do |key, value|\n if value == 'ignore'\n next\n end\n\n if !compare_values(value, result[key])\n @num_fails += 1\n @failed_tests.push(test['name'])\n\n puts \" Expected: \\\"#{key}\\\": #{value}\"\n puts \" Result: \\\"#{key}\\\": #{result[key]}\"\n puts \" Status: Failed\"\n return\n end\n end\n\n @num_successes += 1\n puts \" Status: Passed\"\n end", "def result?\n !@result.equal?(NOT_SET)\n end", "def run(result)\n false\n end", "def valid?(result)\n log(result)\n\n true\n end", "def res_ok?(x)\n x.to_i == x\nend", "def ok?\n skip? || @result\n end", "def verify_result()\n #puts \"{#@recode}\" \"return code\"\n #puts \"{#@expect_code}\" \"expect code\"\n # method to show object's type, include both basic type and class type.\n #puts @recode.class\n #puts @expect_code.class\n # to_i to interger\n # to_f to float\n # to_s to string\n \n if @recode == @expect_code.to_s\n @output.puts \"Verification Success\"\n puts \"Verification Success\"\n\n else\n @output.puts \"ERROR: Verification Failiure errorcode:\" + @recode + \" errormsg:\" + @remsg\n puts \"ERROR: Verification Failiure error code:\" + @recode + \" errormsg:\" + @remsg\n end\n\n end", "def verify_checksum(res)\n msg, chksum = res.match(/^\\$(.*)#(\\h{2})$/)[1..2]\n checksum(msg) == chksum\n end", "def success?()\n result != false\n end", "def result?\n self.type == :result\n end", "def check_status\n if (self.status == HostResult::STATUS_OK)\n # A valid result must have a value.\n if (self.value.blank?)\n # Return an error if no value is present\n errors.add(:value, 'valid result must have a value')\n return false\n else\n # If the value is present, clean the error msg\n self.error = nil\n # Round the reuslt\n self.value = self.value.round(4)\n end\n elsif (self.status == HostResult::STATUS_ERROR)\n self.value = nil\n elsif (self.status == HostResult::STATUS_INACTIVE)\n self.value = nil\n self.error = nil\n else\n # Result type undefined???\n errors.add(:result, \"the result is undefined\")\n return false\n end\n\n # If everything goes well, return true\n return true\n end", "def add_result?(barcode,result,existing_barcodes)\n\t\tbegin\n\t\t\tInteger(result)\n\t\t\t#puts \"result is: #{result}\"\n\t\t\treturn false if existing_barcodes.include? barcode\n\t\t\treturn false if result.to_i == 0\n\t\t\t#puts \"the result is not zero\"\n\t\t\texisting_result = $redis.hget(ESR_RESULTS_HASH,barcode)\n\t\t\t#puts \"existing result is: #{existing_result}\"\n\t\t\tif (existing_result.blank?)\n\t\t\t\ttrue\n\t\t\telse\n\t\t\t\tif existing_result != result\n\t\t\t\t\ttrue\n\t\t\t\tend\n\t\t\tend \n\t\trescue => e\n\t\t\tputs e.to_s\n\t\t\tfalse\n\t\tend\n\t\t\n\tend", "def ok?\n @result.retval == 0\n end", "def assertEquals(results, expected, msg)\n puts \"#{calling_method}: #{msg}\\n\"\n if(results != expected)\n puts \"Expected #{expected} not #{results}\\n\"\n return false\n end\n \n return true\n end", "def result?\n true\n end", "def verify_result(test_data)\n verify_values_match(test_data[UseOfCollections::RESULT.name], element_value(result_text_area))\n end", "def verify_result(test_data)\n verify_values_match(test_data[CoreUseOfCollectionsData::RESULT.name], element_value(result_text_area))\n end", "def result?\n false\n end", "def result_to_get?\n if not @result.nil?\n if @result.downcase == 'true'\n return true\n else\n return false\n end\n else\n return false\n end\n end", "def attempted?\n 'Attempted' == result\n end", "def eval_response(response)\n return (response == \"OK\")\n end", "def is_correct?\n self.match.final_result == selected_result\n end", "def success_from(response)\n response == 'SUCCESSFUL' || response =~ /^\\d+$/ || response == 'true'\n end", "def update_result(new_result)\n @result = new_result if new_result > @result\n end", "def ran?\n @result != Result::NoResult\n end", "def check_in_result(result, type, atr, value)\n addr_obj_from_result(result).map { |adr| return (adr.send atr).casecmp(value).zero? if adr.types.include? type }.include? true\nend", "def valid_checksum?(checksum_value)\n checksum_value == checksum\n end", "def response_equal_answer?\n @response.to_i == eval(@question)\n end", "def remove_result_ok?(remove_result)\n remove_result.is_a?(Hash) && remove_result[\"err\"] == nil && remove_result[\"n\"] == 1\n end", "def add_result(result)\n raise \"invalid result\" unless result.class == ICU::Result\n raise \"player number (#{@num}) is not matched to result player number (#{result.inspect})\" unless @num == result.player\n already = @results.find_all { |r| r.round == result.round }\n return if already.size == 1 && already[0].eql?(result)\n raise \"player #{@num} already has a result in round #{result.round} (#{already[0].inspect}) which does not match the one being added (#{result.inspect})\" unless already.size == 0\n if @results.size == 0 || @results.last.round <= result.round\n @results << result\n else\n i = (0..@results.size-1).find { |n| @results[n].round > result.round }\n @results.insert(i, result)\n end\n end", "def check_answer(answer)\n result = @num_1 + @num_2\n if answer == result\n return true\n end\n return false\n end", "def == expected\n self.out == expected\n end", "def check_success(success_condition: true)\n success = parse_key('success')\n raise Steam::SteamError unless success == success_condition\n\n true\n end", "def success?\n @result[:payment] === true\n end", "def checkLoginMatch(result, loginName, loginPwd)\n\treturn result['password'] == loginPwd\nend", "def error_check_nonblock result_code\n if result_code >= 0\n true\n else\n # need to check result_code again because !eagain? could be true\n # and we need the result_code test to fail again to give the right result\n # !eagain? is true, result_code is -1 => return false\n # !eagain? is false, result_code is -1 => return false\n !eagain? && result_code >= 0\n end\n end", "def check\n if @value1 == @value2\n @message = \"#{@value1} == #{@value2}\"\n true\n else\n @message = \"#{@value1} != #{@value2}\"\n false\n end\n end", "def result=(result)\n\t\tadd_tlv(TLV_TYPE_RESULT, result, true)\n\tend", "def result=(result)\n\t\tadd_tlv(TLV_TYPE_RESULT, result, true)\n\tend", "def store_result\n check_connection\n raise ClientError, 'invalid usage' unless @result_exist\n res = Result.new @fields, @protocol\n @server_status = @protocol.server_status\n @result_exist = false\n res\n end", "def == other\n return false if outputs.count != other.outputs.count\n return false if outputs.any? do |output|\n other.outputs.none? do |other_output|\n output['name'] == other_output['name'] and\n output['res'] == other_output['res']\n end\n end\n return true\n end", "def success?\n got.equal?(true)\n end", "def check_ok_response( socket, msg )\n result = socket.recv( 100 )\n logger.debug( \"Result for #{msg} : #{result}\" )\n raise \"Invalid response for #{msg}\" unless result == \"OK\\n\"\n end", "def succeeded?\n result == \"SUCCESS\"\n end", "def check_result(filename, result, must_fail, tag)\n if must_fail && !result.match(/^No search results$/)\n s = \"\"\n s << \"This case must be failed (type unsafe)\\n\"\n\n return s\n end\n\n if File.exists?(filename)\n content = File.read(filename)\n if result != content\n s = \"\"\n s << \"===== expect:\\n\"\n s << content\n s << \"\\n\"\n s << \"===== actual:\\n\"\n s << result\n s << \"\\n\"\n s << \"=====\"\n\n return s\n else\n return nil\n end\n\n else\n if result.length > 0\n puts \"[!] WARNING: no test for #{tag} (#{filename}) ===== \"\n\n # auto_generate_testcase(filename, result)\n\n puts result\n puts \" \" + \"=\" * 20\n end\n\n return nil\n end\nend", "def valid?\n !!result\n end", "def cvv_result(response)\n case response[:raw][:CardSecurityCodeMatch]\n when \"Pass\"\n return \"M\" # Match\n when \"Fail\"\n return \"N\" # No Match\n else\n return \"P\" # Not Processed\n end\n end", "def success?\n got.equal?(true)\n end", "def boolean_answers_person(player, player_result, right_result, dsp_result)\n # condition matching the player result with right result\n if player_result == right_result\n system(\"clear\")\n view_current\n puts \"You picked: \\n#{dsp_result}\"\n puts Paint[\"Woo! Correct!\" + \" \\u{2705}\" + \" \" + \"\\u{1f600}\", :green]\n system (\"say yay\")\n player.increase_score\n @player_correct << true\n else\n system(\"clear\")\n view_current\n puts \"You picked: \\n#{dsp_result}\"\n puts Paint[\"Fail bro.\" + \" \\u{274c}\" + \" \" + \"\\u{1f625}\", :red]\n system (\"say damn\")\n @player_correct << false\n end\n end", "def test_result_new_success?(test_result)\n run_result = test_result.run_result\n test = test_result.test\n changed = run_result.change_events.where(test_id: test, value: Automation::Test::Change::TestStartedPassing.value).first\n\n !changed.nil?\n end", "def result\n @wordcard = Wordcard.find(params[:wordcard_id])\n return if !@wordcard\n result = params.fetch :result\n return if result.nil?\n\n if result == \"true\"\n @wordcard.bin = [@wordcard.bin + 1, 11].min\n notice = \"Correct! '#{@wordcard.word}' was moved to bin #{@wordcard.bin}\"\n elsif result == \"false\"\n @wordcard.bin = 1\n notice = \"Incorrect. '#{@wordcard.word}' was moved back to bin 1\"\n @wordcard.times_wrong += 1\n if @wordcard.times_wrong >= 10\n @wordcard.bin = 13 #unlucky bin..never show again!\n end\n end\n @wordcard.reviewed_at = DateTime.now\n @wordcard.save\n\n redirect_to :root, :notice => notice\n end", "def return_result_from_query?\n @this_val_where[:mode] == 'return_result'\n end", "def verify_operation_result(actual)\n expected = test_instance.expected_outcome.result\n if expected.is_a?(Array)\n if expected.empty?\n expect(actual).to be_empty\n else\n expected.each_with_index do |expected_elt, i|\n verify_result(expected_elt, actual[i])\n end\n end\n else\n verify_result(expected, actual)\n end\n end", "def test_result_changed_failure?(test_result)\n run_result = test_result.run_result\n test = test_result.test\n changed = run_result.change_events.where(test_id: test, value: Automation::Test::Change::TestChangedFailure.value).first\n\n !changed.nil?\n end", "def check_rest_result_valid(json_result)\n \n\tdevice = Api::Device.find_by(mac_address: @device_given_attrs['mac_address'], serial_number: @device_given_attrs['serial_number'])\n\t\n # device register 的流程應檢查的項目包含:\n # 1. API response 內容\n # 2. personal cloud db\n # 3. xmpp db\n # 4. redis\n\n # 確認 API response 內容\n check_device_register_json_response(device, json_result)\n\n # 確認 personal cloud db 內容\n check_device_register_db_result(device)\n\n # 確認 xmpp db 內容\n check_device_register_xmpp_db_result(device)\n\n # 確認 redis 內容\n check_device_register_redis_result(device)\nend", "def success?\n hash[:smarter_u][:result] == 'Success'\n rescue\n false\n end", "def run_and_success?(cmd)\n run(cmd).success?\n end", "def checksum?\n self.checksum == compute_checksum\n end", "def equal?(other)\n comparable = StatusCode.new other\n return @code == comparable.code if exact? && comparable.exact?\n self_s = to_s\n comparable_s = comparable.to_s\n (0...3).all? do |i|\n StatusCode.equal_digit?(self_s[i], comparable_s[i])\n end\n end", "def update_result_ok?(update_result)\n update_result.is_a?(Hash) && update_result[\"updatedExisting\"] == true\n end", "def check_solution(test_number, argument, expected)\n actual = fields(argument)\n if actual != expected\n puts \"Test ##{test_number}: Incorrect value: got #{actual}, expected #{expected}\"\n return false\n end\n\n puts \"Test ##{test_number}: Correct\"\n return true\nend", "def success?\n result.success\n end", "def test(*params)\n if result == false\n @tests += 1\n self._test *params\n self.result = false if result.nil?\n end\n result\n end", "def assert_result(query, savedresultfile, sortfield=nil, fieldstocompare=nil, qrserver_id=0, explanationstring=\"\")\n assert_result_with_timeout(5, query, savedresultfile, sortfield, fieldstocompare, qrserver_id, explanationstring)\n end", "def made?\n result >= 0\n end", "def successful?(response)\n (response[\"GatewayRspCode\"] == \"0\") && ((response[\"RspCode\"] || \"0\") == \"0\")\n end", "def ==(b) # :nodoc:\n ( b.respond_to?(:result_attributes) &&\n result_attributes == b.result_attributes && \n @result_attributes.all?{ |k| send(k) == b.send(k) } )\n end", "def process_result(player, result)\n result_object = nil\n self.results.to_a.each do |result|\n if result.player == player\n result_object = result\n end\n end\n result_object.value = result\n result_object.save!\n calculate\n end", "def assert_result(expected_result, err_msg, &block)\n if /Error/ =~ expected_result.to_s\n if expected_result.is_a?(String)\n expected_result = Object.const_get(expected_result)\n end\n assert_raises(expected_result, &block)\n else\n value = block.call\n assert_equal(expected_result, value, err_msg)\n end\n end", "def assert_result(expected_result, err_msg, &block)\n if /Error/ =~ expected_result.to_s\n if expected_result.is_a?(String)\n expected_result = Object.const_get(expected_result)\n end\n assert_raises(expected_result, &block)\n else\n value = block.call\n assert_equal(expected_result, value, err_msg)\n end\n end", "def _send_result state\n unless @one_way || state.message.one_way\n # $stderr.write \"\\n _send_result #{state.result_payload.inspect}\\n\\n\"\n _write(state.result_payload, state.out_stream, state)\n true\n end\n end", "def one?\n result.equal?(:one)\n end", "def assert_field_value(query_or_result, fieldname, expectedvalue, hitnumber=0, explanationstring=\"\")\n if explanationstring != \"\"\n explanationstring=explanationstring + \": \"\n else\n explanationstring = \"Expected hit[#{hitnumber}].#{fieldname} == '#{expectedvalue}'\"\n end\n result = (query_or_result.is_a?(String) ? search(query_or_result, 0) : query_or_result)\n\n # check that the hits are equal to the saved hits\n assert_equal(to_utf8(expectedvalue), result.hit[hitnumber].field[fieldname].to_s, explanationstring)\n end", "def parse_result(_res)\r\n\t\t#form of the response: \r\n\t\t#VALID RESULTS (arbitrary value) ==> 200 result=1 (1119166301)\r\n\t\t#VALID RESULTS (integer) ==> Response: 200 result=0\r\n\t\t#BAD COMMAND ==> 510\r\n\t\t#USAGE ERROR ==> 520...520..\\n\r\n\t\t#if I get 510, then the command was not found, sorry\r\n\t\t\r\n\t\tif (_res=~/510/)==0 then # 510 = BAD COMMAND\r\n\t\t\twhile !(_res=~/510/) # asterisk may send more than one at at time. lame.\r\n\t\t\t\t#RAGI.LOGGER.info(\"Received \" + _res);\r\n\t\t\t\t_res = read_line()\r\n\t\t\t\t#RAGI.LOGGER.info(\"STUFF2: #{_res}\")\r\n\t\t\tend\r\n\t\t\r\n\t\t\tRAGI.LOGGER.info(\"Received 510 Command not found error #{_res}\")\r\n\t\t\t_cmd = /\\(.*\\)/.match(_res).to_s.gsub(/[\\(\\)]/,'')\r\n\t\t\traise CmdNotFoundError, \"Command could not be found = #{_cmd}\"\r\n\t\t\treturn nil\r\n \r\n\t\t\t#if I get 520, then the command usage was not found, sorry\r\n\t\telsif (_res=~/520/)==0 then # 520 = USAGE ERRROR\r\n\t\t\tRAGI.LOGGER.info(\"Received 520 Invalid Command Usage #{_res}\")\r\n\t\t\t_usage = ''\r\n\t\t\t_res = read_line()\r\n\t\t\t#RAGI.LOGGER.info(\"STUFF: #{_res}\")\r\n\t\t\twhile !(_res=~/520/) # asterisk may send more than one at at time. lame.\r\n\t\t\t\t#RAGI.LOGGER.info(\"Received \" + _res);\r\n\t\t\t\t_usage += _usage\r\n\t\t\t\t_res = read_line()\r\n\t\t\t\t#RAGI.LOGGER.info(\"STUFF2: #{_res}\")\r\n\t\t\tend\r\n\t\t\traise UsageError, \"Command Usage Incorrect, correct usage - #{_usage}\"\r\n\t\t\treturn nil\r\n\t\telsif ((_res=~/200/)==0) then # 200 = Results\r\n\t\t\teqindex =_res.index(\"=\") \r\n\t\t\tif (eqindex==nil)\r\n\t\t\t\tRAILS_DEFAULT_LOGGER.error(\"Error, unexpected 200 result with no value \" + _res.to_s)\r\n\t\t\t\treturn nil\r\n\t\t\tend\r\n\t\t\t\r\n\t\t\t#if there is a value in parens, return it.\r\n\t\t\tlb=_res.index(\"(\")\r\n\t\t\trb=_res.rindex(\")\")\r\n\t\t\tif (lb != nil and rb != nil)\r\n value = _res[lb+1, rb-lb-1]\r\n if value == \"timeout\" then\r\n # in the case of \"200 result=<num> (timeout)\" we should return <num>\r\n value = _res[eqindex+1,lb-eqindex-1]\r\n end\r\n \r\n value.chomp!(\" \")\r\n return value\r\n\t\t\telse\r\n # there is an int result we hope.\r\n value = _res[eqindex+1, _res.length]\r\n return value.chomp!\r\n\t\t\tend\r\n\t\tend\r\n end", "def tst_result\n passed? ? \"p\" : \"f\"\n end", "def ==(other)\n @success == other.success &&\n @failed == other.failed &&\n @result == other.result &&\n @error_code == other.error_code &&\n @error_msg == other.error_msg &&\n @error_class == other.error_class\n end", "def boolean_answers_computer(computer, com_result, right_result, display_rst)\n if com_result == right_result\n puts \"\\n#{computer.name} selected: \"\n $stdout.flush\n sleep(1.5)\n puts \"#{display_rst}\"\n puts Paint[\"#{computer.name} is catching up!\" + \" \\u{2705}\" + \" \" + \"\\u{1f600}\", :green]\n computer.increase_score\n @computer_correct << true\n else\n puts \"\\n#{computer.name} selected: \"\n $stdout.flush\n # sleep(1.5)\n puts \"#{display_rst}\"\n puts Paint[\"#{computer.name} is falling behind, hurry RUN faster!\" + \" \\u{274c}\" + \" \" + \"\\u{1f625}\", :red]\n @computer_correct << false\n end\n end", "def successful?(result)\n if defined?(result.cancelPackageReply)\n SUCCESSFUL_RESPONSES.any? {|r| r == result.cancelPackageReply.highestSeverity }\n else\n SUCCESSFUL_RESPONSES.any? {|r| r == result.highestSeverity }\n end\n end", "def detect_result(dealer_hand, player_hand)\n player_total = calculate_total(player_hand)\n dealer_total = calculate_total(dealer_hand)\n\n if player_total > 21\n :player_busted\n elsif dealer_total > 21\n :dealer_busted\n elsif dealer_total < player_total\n :player\n elsif player_total < dealer_total\n :dealer\n else\n :tie\n end\nend", "def matches(value)\n output, status = provider.run_unless_sql_command(value)\n status = output.exitcode if status.nil?\n\n output='0' unless status == 0\n\n result_count = output.strip.to_i\n self.debug(\"Found #{result_count} row(s) executing 'onlyif' clause\")\n result_count == 0\n end", "def store_result(result); end", "def verify_operation_result(expected, actual)\n if expected.is_a?(Array)\n if expected.empty?\n expect(actual).to be_empty\n else\n expected.each_with_index do |expected_elt, i|\n # If the YAML spec test does not define a result,\n # do not assert the operation's result - the operation may\n # have produced a result, the test just does not care what it is\n if expected_elt\n verify_result(expected_elt, actual[i])\n end\n end\n end\n else\n verify_result(expected, actual)\n end\n end", "def success?\n @code.to_i == 0\n end", "def result\n @result || :no_answer\n end", "def result\n @result || :no_answer\n end", "def detect_result(dealer_cards, player_cards)\n player_total = total(player_cards)\n dealer_total = total(dealer_cards)\n\n if player_total > WINNING_VALUE\n :player_busted\n elsif dealer_total > WINNING_VALUE\n :dealer_busted\n elsif dealer_total < player_total\n :player\n elsif dealer_total > player_total\n :dealer\n else\n :tie\n end\nend", "def _receive_result state\n unless @one_way || state.message.one_way\n state.result_payload = _read(state.in_stream, state)\n true\n end\n end", "def ==(other)\n @success == other.success &&\n @failed == other.failed &&\n @result == other.result &&\n @error_code == other.error_code &&\n @error_msg == other.error_msg &&\n @error_class == other.error_class\n end", "def compare_answer\n\n if @question.answer == @user_answer \n return true\n end\n\n # return false if incorrect\n false\n\n end", "def complete_result?\n @result_count < 1000\n end", "def success?\n type == :ok\n end", "def verify_answer(answer)\n if answer == @total.to_s\n puts \"Right!\".green\n @current_player.get_point\n else\n puts \"Wrong! The correct answer is #{@total}.\".red\n @current_player.lose_life\n end\n end", "def context_return_value(desired_test_result)\n raise 'desired_test_result value must be either \"pass\" or \"fail\"' unless\n %w[pass fail].include?(desired_test_result)\n\n if desired_test_result == 'fail'\n 'returns offending logical resource id'\n else\n 'returns empty list'\n end\nend", "def correct?\n\n if @guess == @card.answer #returned false. Fixed it.\n p true\n elsif @guess != @card.answer\n p false\n end\n end", "def test_it_evaluates_card_value_when_same\n card = Card.new(\"10\",\"Hearts\")\n response = \"10 of Clubs\"\n guess = Guess.new(response, card)\n assert_equal :same, Evaluation.evaluate_value(guess)\n end" ]
[ "0.6461885", "0.62522304", "0.6238519", "0.6054772", "0.6046574", "0.60230297", "0.6018356", "0.60050684", "0.5895863", "0.5877504", "0.58765954", "0.58644533", "0.58367515", "0.57947993", "0.5793753", "0.57920253", "0.57537067", "0.574996", "0.5731237", "0.5721371", "0.57113814", "0.56535965", "0.56339866", "0.56119585", "0.55835074", "0.5572416", "0.5566956", "0.5561679", "0.5560428", "0.55419886", "0.5512617", "0.5507205", "0.54826653", "0.5480331", "0.5462015", "0.5454326", "0.544366", "0.5433476", "0.54073846", "0.5401706", "0.5397831", "0.5362553", "0.5362553", "0.5357416", "0.53461844", "0.53405", "0.53396547", "0.5338199", "0.53249466", "0.53237647", "0.53233445", "0.531081", "0.53095365", "0.5276853", "0.52586687", "0.52509725", "0.52496105", "0.52467406", "0.5224116", "0.5219737", "0.5207604", "0.5194228", "0.5180012", "0.5166946", "0.5161892", "0.51609045", "0.5160614", "0.51524544", "0.51484966", "0.5146336", "0.5132854", "0.5120025", "0.51081157", "0.51081157", "0.50918365", "0.5086787", "0.50769126", "0.5074406", "0.5060706", "0.50507057", "0.504925", "0.50479054", "0.50454545", "0.5033391", "0.50322324", "0.5031976", "0.5027596", "0.50169647", "0.50169647", "0.5011313", "0.50053006", "0.500031", "0.49972582", "0.49862385", "0.49848646", "0.49748886", "0.4968617", "0.49638376", "0.4960736" ]
0.7156735
1
Sets the packet's result TLV.
def result=(result) add_tlv(TLV_TYPE_RESULT, result, true) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def result\n\t\treturn get_tlv_value(TLV_TYPE_RESULT)\n\tend", "def result\n\t\treturn get_tlv_value(TLV_TYPE_RESULT)\n\tend", "def result=(r)\n\n fields['__result__'] = r\n end", "def set_result\n raw.data.status_code = raw.statusCode\n raw.data.status_text = raw.statusText\n @result = raw.data\n end", "def set_result\n @result = Result.new\n end", "def set_result(xml)\n el = elements[\"result\"]\n el = add_element(\"result\") if el.nil?\n if xml.kind_of? REXML::Element\n el << xml\n else\n el.add_text(xml)\n end\n end", "def set_result\n results = result_params\n unless results.nil?\n if results.is_a?(String)\n parts = results.split(\"#\")\n @result = @measurement.results.find(parts[0].to_i)\n end\n end\n end", "def set_result\n @result = Api::V1::Result.find(params[:id])\n end", "def result=(value)\n Namespace.root.add_variable(variable_name, value)\n end", "def result_info=(value)\n @result_info = value\n end", "def result_info=(value)\n @result_info = value\n end", "def set_result\n @result = Admin::Result.find(params[:id])\n end", "def initialize\n @result = result\n end", "def result=(value)\n target_address = @memory[@instruction_pointer + 3]\n @memory[target_address] = value\n end", "def set_result\n @result = Result.find(params[:id])\n end", "def result?(result)\n\t\treturn (get_tlv_value(TLV_TYPE_RESULT) == result)\n\tend", "def result?(result)\n\t\treturn (get_tlv_value(TLV_TYPE_RESULT) == result)\n\tend", "def get_result(result_type) ; add_result(result_type, false) ; end", "def set_result\n @result = Result.find(params[:id])\n end", "def set_result\n @result = Result.find(params[:id])\n end", "def set_result\n @result = Result.find(params[:id])\n end", "def set_result\n @result = Result.find(params[:id])\n end", "def set_result\n @result = Result.find(params[:id])\n end", "def set_result\n @result = Result.find(params[:id])\n end", "def set_result\n @result = Result.find(params[:id])\n end", "def set_result\n @result = Result.find(params[:id])\n end", "def set_result\n @result = Result.find(params[:id])\n end", "def set_result\n @result = Result.find(params[:id])\n end", "def initialize(result)\n @result = result\n end", "def initialize(result)\n @result = result\n end", "def initialize(result)\n @result = result\n end", "def set_result( result )\n SQLite::API.set_result( @func, result )\n end", "def store_result\n check_connection\n raise ClientError, 'invalid usage' unless @result_exist\n res = Result.new @fields, @protocol\n @server_status = @protocol.server_status\n @result_exist = false\n res\n end", "def result_type(result_type='mixed')\n @query[:result_type] = result_type\n self\n end", "def store_result(result); end", "def value(result)\n result\n end", "def set_dvd_result\n @dvd_result = subject_class.find(params[:id])\n end", "def call(packet, buffer)\n\t @results[:VOLTAGE] = voltage(packet.read(\"VOLTAGE_RAW\", :RAW, buffer))\n\t @results[:AMPERAGE] = amperage(packet.read(\"AMPERAGE_RAW\", :RAW, buffer))\n\t @results[:POWER] = packet.read(\"AMPERAGE\", :CONVERTED, buffer) * 28.0\n end", "def parse_result_response(result)\n h = {}\n h[\"ResponseName\"] = result.elements[\"b:ResponseName\"].text\n\n attributes = XML::MessageParser.parse_key_value_pairs(result.elements[\"b:Results\"])\n h.merge(attributes)\n end", "def send_result( assembly_id, result )\n\t\tmessage = Assemblage::Protocol.encode( :result, assembly_id, result )\n\t\tself.send_message( message )\n\tend", "def set_result\n @result = Result.find(params[:id])\n end", "def expected_result\n if @assert['result'] == '&result'\n @result\n elsif @assert['result'] != 'void'\n to_hex(@assert['result']['$hex'])\n end\n end", "def add_result(res)\n change_cursor { |c|\n saved_format = c.char_format # moving changes char format\n c.move_position document.character_count - 1\n c.char_format = saved_format\n\n ANSIToQt.insert(c, res)\n }\n end", "def respond(res)\n @rres = res\n end", "def ws_populate_one_cipher_result(suite_index, result)\n return unless(result)\n case result.status\n when true\n @ws_cipher_grid.set_cell_value(suite_index, SUPPORTED_COL, \"Yes\")\n @ws_cipher_grid.set_cell_background_colour(suite_index, SUPPORTED_COL, Wx::GREEN)\n @ws_cipher_grid.set_cell_value(suite_index, HTTP_COL, \"HTTP\\/#{result.data.http_version} #{result.data.code} #{result.data.msg}\") if(result.data)\n when false\n @ws_cipher_grid.set_cell_value(suite_index, SUPPORTED_COL, \"No\")\n @ws_cipher_grid.set_cell_background_colour(suite_index, SUPPORTED_COL, Wx::RED)\n @ws_cipher_grid.set_cell_value(suite_index, HTTP_COL, \"#{result.data}\") if(result.data)\n end # end of case\n end", "def add_result name, res\n \n end", "def manage_record_result(id, result)\n separator = @global_opts[:csv] ? \",\" : \": \"\n if @client.is_success?\n @response_data.root << result.at_xpath(RECORD_XPATH,\n \"marc\" => XMLNS_MARC\n )\n @response_status << id + separator + PAST_TENSE[@cmd] + \"\\n\"\n puts id + separator + PAST_TENSE[@cmd] if @global_opts[:verbose]\n @successes += 1\n else\n if @global_opts[:csv]\n @response_status << [id, \"failed\", result.to_s].to_csv\n else\n @response_status << id + separator + \"failed\\n\"\n @response_status << result.to_s\n end\n puts id + separator + \"failed\" if @global_opts[:verbose]\n @failures += 1\n end\n end", "def result\n data(\"result\")\n end", "def parse_result_response(result)\n h = {}\n h[\"LogicalName\"] = h[\"type\"] = result.elements[\"b:LogicalName\"].text\n h[\"Id\"] = h[\"id\"] = result.elements[\"b:Id\"].text\n\n attributes = XML::MessageParser.parse_key_value_pairs(result.elements[\"b:Attributes\"])\n h.merge(attributes)\n end", "def process_result(value, reply)\n @result[:value] += value\n end", "def update_result(new_result)\n @result = new_result if new_result > @result\n end", "def set_vulnerability_scan_result\n @vulnerability_scan_result = VulnerabilityScanResult.find(params[:id])\n end", "def new_result\n return_types.map do |type|\n result_value_for(type)\n end\n end", "def parse_result(data)\n Parser.process(data)\n end", "def result(res)\n clear_eval\n puts Debugger::PROMPTS[:result] + res.to_s\n end", "def result(res)\n clear_eval\n puts Debugger::PROMPTS[:result] + res.to_s\n end", "def result\n self.result_payload[\"result\"] if self.result_payload\n end", "def set_contest_result\n @contest_result = ContestResult.find(params[:id])\n end", "def set_test_result\n @test_result = TestResult.find(params[:id])\n end", "def set_test_result\n @test_result = TestResult.find(params[:id])\n end", "def set_ep_result\n ep = EventParticipant.find(params[:id])\n @successful = ep.update_attribute(:result, params[:value])\n ep.save!\n ep.reload\n render :text => ep.result\n end", "def result\n\t\t@result\n\tend", "def normalize_result(result)\n end", "def get_result\n begin\n res_packet = ResultPacket.parse read\n if res_packet.field_count.to_i > 0 # result data exists\n set_state :FIELD\n return res_packet.field_count\n end\n if res_packet.field_count.nil? # LOAD DATA LOCAL INFILE\n send_local_file(res_packet.message)\n res_packet = ResultPacket.parse read\n end\n @affected_rows, @insert_id, @server_status, @warning_count, @message =\n res_packet.affected_rows, res_packet.insert_id, res_packet.server_status, res_packet.warning_count, res_packet.message\n set_state :READY\n return nil\n rescue\n set_state :READY\n raise\n end\n end", "def new_result\n Result.new(self)\n end", "def parse_result(_res)\r\n\t\t#form of the response: \r\n\t\t#VALID RESULTS (arbitrary value) ==> 200 result=1 (1119166301)\r\n\t\t#VALID RESULTS (integer) ==> Response: 200 result=0\r\n\t\t#BAD COMMAND ==> 510\r\n\t\t#USAGE ERROR ==> 520...520..\\n\r\n\t\t#if I get 510, then the command was not found, sorry\r\n\t\t\r\n\t\tif (_res=~/510/)==0 then # 510 = BAD COMMAND\r\n\t\t\twhile !(_res=~/510/) # asterisk may send more than one at at time. lame.\r\n\t\t\t\t#RAGI.LOGGER.info(\"Received \" + _res);\r\n\t\t\t\t_res = read_line()\r\n\t\t\t\t#RAGI.LOGGER.info(\"STUFF2: #{_res}\")\r\n\t\t\tend\r\n\t\t\r\n\t\t\tRAGI.LOGGER.info(\"Received 510 Command not found error #{_res}\")\r\n\t\t\t_cmd = /\\(.*\\)/.match(_res).to_s.gsub(/[\\(\\)]/,'')\r\n\t\t\traise CmdNotFoundError, \"Command could not be found = #{_cmd}\"\r\n\t\t\treturn nil\r\n \r\n\t\t\t#if I get 520, then the command usage was not found, sorry\r\n\t\telsif (_res=~/520/)==0 then # 520 = USAGE ERRROR\r\n\t\t\tRAGI.LOGGER.info(\"Received 520 Invalid Command Usage #{_res}\")\r\n\t\t\t_usage = ''\r\n\t\t\t_res = read_line()\r\n\t\t\t#RAGI.LOGGER.info(\"STUFF: #{_res}\")\r\n\t\t\twhile !(_res=~/520/) # asterisk may send more than one at at time. lame.\r\n\t\t\t\t#RAGI.LOGGER.info(\"Received \" + _res);\r\n\t\t\t\t_usage += _usage\r\n\t\t\t\t_res = read_line()\r\n\t\t\t\t#RAGI.LOGGER.info(\"STUFF2: #{_res}\")\r\n\t\t\tend\r\n\t\t\traise UsageError, \"Command Usage Incorrect, correct usage - #{_usage}\"\r\n\t\t\treturn nil\r\n\t\telsif ((_res=~/200/)==0) then # 200 = Results\r\n\t\t\teqindex =_res.index(\"=\") \r\n\t\t\tif (eqindex==nil)\r\n\t\t\t\tRAILS_DEFAULT_LOGGER.error(\"Error, unexpected 200 result with no value \" + _res.to_s)\r\n\t\t\t\treturn nil\r\n\t\t\tend\r\n\t\t\t\r\n\t\t\t#if there is a value in parens, return it.\r\n\t\t\tlb=_res.index(\"(\")\r\n\t\t\trb=_res.rindex(\")\")\r\n\t\t\tif (lb != nil and rb != nil)\r\n value = _res[lb+1, rb-lb-1]\r\n if value == \"timeout\" then\r\n # in the case of \"200 result=<num> (timeout)\" we should return <num>\r\n value = _res[eqindex+1,lb-eqindex-1]\r\n end\r\n \r\n value.chomp!(\" \")\r\n return value\r\n\t\t\telse\r\n # there is an int result we hope.\r\n value = _res[eqindex+1, _res.length]\r\n return value.chomp!\r\n\t\t\tend\r\n\t\tend\r\n end", "def mssql_parse_ret(data, info)\n\t\tret = data.slice!(0,4).unpack('N')[0]\n\t\tinfo[:ret] = ret\n\t\tinfo\n\tend", "def response=(value)\n @response_before_type_cast = value\n self.textual_response = value\n end", "def set_battle_result\n @battle_result = BattleResult.find(params[:id])\n end", "def response\n result = {}\n res_xml.blank? ? xml = '' : xml = res_xml\n doc = Hpricot.XML(xml)\n case status\n when 'REQUEST'\n result[:status] = 'BEGIN'\n when 'UPDATE'\n result[:status] = 'NORMAL'\n when 'EXCEPTION'\n result[:status] = 'ERROR'\n end\n result[:xml] = ErpHelper.xml2html(doc.to_s)\n case (doc/:IAVSResult).inner_text\n when 'Y'\n result[:avsresult] = 'Match'\n when 'N'\n result[:avsresult] = 'No Match'\n when 'X'\n result[:avsresult] = 'No Provide'\n end\n result[:zipmatch] = (doc/:AVSResult/:ZipMatch).inner_text\n result[:streetmatch] = (doc/:AVSResult/:StreetMatch).inner_text\n pfp_res_code_msg = open(RAILS_ROOT+\"/db/pfp_transaction_result_code_and_message.yml\") {|f| YAML.load(f)}\n pfp_res_code_msg[res_code].blank? ? result[:pfp_res_code_msg] = 'Credit Card Processing Gateway Error.' : result[:pfp_res_code_msg] = pfp_res_code_msg[res_code]\n return result\n end", "def set_ts_result\n @ts_result = TsResult.find(params[:id])\n @ts_tbl = TsTbl.find(@ts_result.ts_tbl.id)\n end", "def result\n if not elements[\"result\"].nil?\n r = elements[\"result\"].elements[1]\n if r.nil?\n elements[\"result\"].text\n else\n r\n end\n else\n nil\n end\n end", "def set_user_result\n @user_result = UserResult.find(params[:id])\n end", "def result\n\n fields['__result__']\n end", "def format_result(result)\n result\n end", "def set_result_info\n @result_info = ResultInfo.find(params[:id])\n end", "def result \n @result\n end", "def tlv_select\n info 'os10_lldp_interface::tlv select'\n begin\n lldp_interface_data = @tlv_ret[:stdout].split(\"\\n\")\n temp_data = {}\n\n lldp_interface_data.each do |data|\n if data.include? 'lldp tlv-select'\n tlv_data = data.split(' ')\n if tlv_data.length == 4\n temp_data[tlv_data[3]] = [' ']\n elsif temp_data[tlv_data[3]].nil? && tlv_data.length >= 4\n temp_data[tlv_data[3]] = [tlv_data[4]]\n elsif tlv_data[4]\n temp_data[tlv_data[3]] = temp_data[tlv_data[3]] << tlv_data[4]\n temp_data[tlv_data[3]] = temp_data[tlv_data[3]].sort\n end\n end\n end\n return temp_data\n rescue Exception => e\n err 'Exception in tlv select'\n err e.message\n err e.backtrace[0]\n raise\n end\n end", "def cast\n p @result\n end", "def set_fields result\n @txn.confirmation_no = result.id \n if CREDIT_CARD_API == 'balanced'\n @txn.payment_type, @txn.credit_card_no, @txn.debit_token = result.source.card_type, result.source.last_four, result.uri\n else\n @txn.payment_type, @txn.credit_card_no, @txn.debit_token = result.source.brand, result.source.last4, result.source.id\n end\n end", "def result\n @result\n end", "def set_test_case_result\n @test_case_result = TestCaseResult.find(params[:id])\n end", "def avs_result(response)\n attrs={}\n # Check the Street Address:\n case response[:raw][:AVSStreet]\n when \"Pass\"\n attrs[:street_match] = 'Y'\n when \"Fail\"\n attrs[:street_match] = 'N'\n else\n attrs[:street_match] = nil\n end \n \n # Check the Postal Code:\n case response[:raw][:AVSZip]\n when \"Pass\"\n attrs[:postal_match] = 'Y'\n when \"Fail\"\n attrs[:postal_match] = 'N'\n else\n attrs[:postal_match] = nil\n end\n \n attrs \n end", "def to(result_unit)\n RubyUnits::Unit.new(\"#{value} #{unit}\").\n convert_to(result_unit).\n scalar\n end", "def result\n @result || :no_answer\n end", "def result\n @result || :no_answer\n end", "def format_result(result)\n result\n end", "def result_code\n self[:result_code]\n end", "def build_response_packet\n rpacket = RCon::Packet::Source.new\n total_size = 0\n request_id = 0\n type = 0\n response = \"\"\n message = \"\"\n message2 = \"\"\n\n tmp = @socket.recv(4)\n if tmp.nil?\n return nil\n end\n size = tmp.unpack(\"V1\")\n tmp = @socket.recv(size[0])\n request_id, type, message, message2 = tmp.unpack(\"V1V1a*a*\")\n total_size = size[0]\n \n #puts \"size: \"+size.to_s \n #puts \"type: \"+type.to_s\n #puts \"message: \"+message\n #puts \"message2: \"+message2\n \n rpacket.packet_size = total_size\n rpacket.request_id = request_id\n rpacket.command_type = type\n \n # strip nulls (this is actually the end of string1 and string2)\n message.sub! /\\x00\\x00$/, \"\"\n message2.sub! /\\x00\\x00$/, \"\"\n rpacket.string1 = message\n rpacket.string2 = message2\n return rpacket\n end", "def add_result(result)\n @results.push(result)\n end", "def add_result(result)\n @results.push(result)\n end", "def add_result(result)\n @results.push(result)\n end", "def add_result(result_tuple)\n @test_results << result_tuple\n end", "def cvv_result(response)\n case response[:raw][:CardSecurityCodeMatch]\n when \"Pass\"\n return \"M\" # Match\n when \"Fail\"\n return \"N\" # No Match\n else\n return \"P\" # Not Processed\n end\n end", "def store_result()\n #This is a stub, used for indexing\n end", "def result\n @data['result']\n end", "def set_result_tnmtfirst\n @result_tnmtfirst = ResultTnmtfirst.find(params[:id])\n end", "def from_r(raw)\n\t\tself.value = nil\n\n\t\tlength, self.type = raw.unpack(\"NN\");\n\n\t\t# check if the tlv value has been compressed...\n\t\tif( self.type & TLV_META_TYPE_COMPRESSED == TLV_META_TYPE_COMPRESSED )\n\t\t\t# set this TLV as using compression\n\t\t\t@compress = true\n\t\t\t# remove the TLV_META_TYPE_COMPRESSED flag from the tlv type to restore the \n\t\t\t# tlv type to its origional, allowing for transparent data compression.\n\t\t\tself.type = self.type ^ TLV_META_TYPE_COMPRESSED\n\t\t\t# decompress the compressed data (skipping the length and type DWORD's)\n\t\t\traw_decompressed = Rex::Text.zlib_inflate( raw[8..length-1] )\n\t\t\t# update the length to reflect the decompressed data length (+8 for the length and type DWORD's)\n\t\t\tlength = raw_decompressed.length + 8\n\t\t\t# update the raw buffer with the new length, decompressed data and updated type.\n\t\t\traw = [length, self.type].pack(\"NN\") + raw_decompressed\n\t\tend\n\t\t\n\t\tif (self.type & TLV_META_TYPE_STRING == TLV_META_TYPE_STRING)\n\t\t\tif (raw.length > 0)\n\t\t\t\tself.value = raw[8..length-2]\n\t\t\telse\n\t\t\t\tself.value = nil\n\t\t\tend\n\t\telsif (self.type & TLV_META_TYPE_UINT == TLV_META_TYPE_UINT)\n\t\t\tself.value = raw.unpack(\"NNN\")[2]\n\t\telsif (self.type & TLV_META_TYPE_BOOL == TLV_META_TYPE_BOOL)\n\t\t\tself.value = raw.unpack(\"NNc\")[2]\n\n\t\t\tif (self.value == 1)\n\t\t\t\tself.value = true\n\t\t\telse\n\t\t\t\tself.value = false\n\t\t\tend\n\t\telse\n\t\t\tself.value = raw[8..length-1]\n\t\tend\n\n\t\treturn length;\n\tend", "def block_result=(block_result)\n @block_result = block_result\n stop_server\n end" ]
[ "0.6488828", "0.6488828", "0.63450575", "0.6304807", "0.59019977", "0.58609015", "0.5736919", "0.55704635", "0.55072874", "0.5491611", "0.5491611", "0.5338689", "0.52981764", "0.52925867", "0.5281694", "0.52587295", "0.52587295", "0.5245461", "0.5219698", "0.5218221", "0.5218221", "0.5218221", "0.5218221", "0.5218221", "0.5218221", "0.5218221", "0.5218221", "0.5218221", "0.52131325", "0.52131325", "0.52131325", "0.5175045", "0.5164225", "0.5144115", "0.51062626", "0.50571173", "0.5051775", "0.50467354", "0.5006283", "0.5002464", "0.4987996", "0.49698055", "0.49656343", "0.4953163", "0.49527746", "0.49480653", "0.49429375", "0.49245512", "0.49075946", "0.49036825", "0.49011225", "0.48918548", "0.4884606", "0.48584068", "0.48462993", "0.48462993", "0.4830017", "0.48268634", "0.48256898", "0.48256898", "0.4824441", "0.4815078", "0.48098493", "0.4788463", "0.47815555", "0.4777026", "0.4776023", "0.47726122", "0.47691974", "0.47578365", "0.47547477", "0.47397614", "0.47353083", "0.47280067", "0.47278357", "0.47276124", "0.47225365", "0.47223788", "0.47123003", "0.4704829", "0.4696539", "0.4684827", "0.4678255", "0.46738425", "0.46710354", "0.46710354", "0.46691868", "0.4665458", "0.46605444", "0.4654936", "0.4654936", "0.4654936", "0.46384457", "0.4633388", "0.4620102", "0.46001178", "0.45990002", "0.45970476", "0.45941505" ]
0.80659664
1
Gets the value of the packet's result TLV.
def result return get_tlv_value(TLV_TYPE_RESULT) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def result\n if not elements[\"result\"].nil?\n r = elements[\"result\"].elements[1]\n if r.nil?\n elements[\"result\"].text\n else\n r\n end\n else\n nil\n end\n end", "def value(result)\n result\n end", "def result=(result)\n\t\tadd_tlv(TLV_TYPE_RESULT, result, true)\n\tend", "def result=(result)\n\t\tadd_tlv(TLV_TYPE_RESULT, result, true)\n\tend", "def result\n\n fields['__result__']\n end", "def result\n @data['result']\n end", "def result\n self.result_payload[\"result\"] if self.result_payload\n end", "def get_tlv_value(type, index = 0)\n\t\ttlv = get_tlv(type, index)\n\n\t\treturn (tlv != nil) ? tlv.value : nil\n\tend", "def get_tlv_value(type, index = 0)\n\t\ttlv = get_tlv(type, index)\n\n\t\treturn (tlv != nil) ? tlv.value : nil\n\tend", "def result\n data(\"result\")\n end", "def get_result\n begin\n res_packet = ResultPacket.parse read\n if res_packet.field_count.to_i > 0 # result data exists\n set_state :FIELD\n return res_packet.field_count\n end\n if res_packet.field_count.nil? # LOAD DATA LOCAL INFILE\n send_local_file(res_packet.message)\n res_packet = ResultPacket.parse read\n end\n @affected_rows, @insert_id, @server_status, @warning_count, @message =\n res_packet.affected_rows, res_packet.insert_id, res_packet.server_status, res_packet.warning_count, res_packet.message\n set_state :READY\n return nil\n rescue\n set_state :READY\n raise\n end\n end", "def result\n @result\n end", "def result?(result)\n\t\treturn (get_tlv_value(TLV_TYPE_RESULT) == result)\n\tend", "def result?(result)\n\t\treturn (get_tlv_value(TLV_TYPE_RESULT) == result)\n\tend", "def expected_result\n if @assert['result'] == '&result'\n @result\n elsif @assert['result'] != 'void'\n to_hex(@assert['result']['$hex'])\n end\n end", "def result\n meta.fetch(:result, :one)\n end", "def get_value\r\n @bitstring\r\n end", "def value\n result = nil\n return result if @code == nil\n\n starttime = Time.now.to_f\n\n begin\n Timeout.timeout(limit) do\n if @code.is_a?(Proc)\n result = @code.call()\n else\n result = Facter::Util::Resolution.exec(@code)\n end\n end\n rescue Timeout::Error => detail\n warn \"Timed out seeking value for %s\" % self.name\n\n # This call avoids zombies -- basically, create a thread that will\n # dezombify all of the child processes that we're ignoring because\n # of the timeout.\n Thread.new { Process.waitall }\n return nil\n rescue => details\n warn \"Could not retrieve %s: %s\" % [self.name, details]\n return nil\n end\n\n finishtime = Time.now.to_f\n ms = (finishtime - starttime) * 1000\n Facter.show_time \"#{self.name}: #{\"%.2f\" % ms}ms\"\n\n return nil if result == \"\"\n return result\n end", "def result_code\n self[:result_code]\n end", "def result_info\n return @result_info\n end", "def result_info\n return @result_info\n end", "def value\n error! unless self.kind_of?(HTTPSuccess)\n end", "def result_text\n raise \"No result yet.\" if !@result\n return Gtk::ResponseType[@result].to_sym\n end", "def value\n return @value if @value\n result = nil\n return result if @code == nil\n\n starttime = Time.now.to_f\n\n begin\n Timeout.timeout(limit) do\n if @code.is_a?(Proc)\n result = @code.call()\n else\n result = Facter::Util::Resolution.exec(@code)\n end\n end\n rescue Timeout::Error => detail\n Facter.warn \"Timed out seeking value for %s\" % self.name\n\n # This call avoids zombies -- basically, create a thread that will\n # dezombify all of the child processes that we're ignoring because\n # of the timeout.\n Thread.new { Process.waitall }\n return nil\n rescue => details\n Facter.warn \"Could not retrieve %s: %s\" % [self.name, details]\n return nil\n end\n\n finishtime = Time.now.to_f\n ms = (finishtime - starttime) * 1000\n Facter.show_time \"#{self.name}: #{\"%.2f\" % ms}ms\"\n\n return nil if result == \"\"\n return result\n end", "def result \n @result\n end", "def value(timeout = nil)\n return @result if @result\n \n poll_for_result\n \n if notify && pool # listen for task completion notification if the task is set up to do that\n listen_for_result_notification(timeout)\n elsif result_uri.nil? # wait for a result if we don't already have one\n wait_for_result(timeout)\n end\n \n @result\n end", "def get_result(key)\n r = results\n if r != nil\n return r.fetch(key, nil)\n end\n nil\n end", "def result\n @@result\n end", "def result\n results[0]\n end", "def get_item_from_result(res)\n res.fetch('value', {}).fetch('S', nil)\n end", "def value\n parsed_value\n end", "def cvv_result(response)\n case response[:raw][:CardSecurityCodeMatch]\n when \"Pass\"\n return \"M\" # Match\n when \"Fail\"\n return \"N\" # No Match\n else\n return \"P\" # Not Processed\n end\n end", "def cvn_result\n params['CVNRESULT']\n end", "def get_rdata_value(dns_query, parsed_dns, length)\n template = length == LONG_LENGTH ? \"N\" : \"n\"\n value = dns_query[parsed_dns[:index], length].unpack(template)[0]\n parsed_dns[:index] += length\n return value\n end", "def result\n @result || :no_answer\n end", "def result\n @result || :no_answer\n end", "def value\n error! unless self.kind_of?(Net::HTTPSuccess)\n end", "def result\n\t\t@result\n\tend", "def get_value\n send_request(FUNCTION_GET_VALUE, [], '', 2, 'S')\n end", "def result_variant\n custom_result_variant? ? custom_result_variant : read_attribute(:result_variant)\n end", "def result\n operation.result\n end", "def get_result(key)\n return @outputs[key]\n end", "def get_operation_result\n @connection.get_operation_result\n end", "def value\n case object_type\n when Constants::ASN_OCTET_STR, Constants::ASN_OPAQUE\n struct.val[:string].read_string(struct.val_len)\n when Constants::ASN_INTEGER\n struct.val[:integer].read_long\n when Constants::ASN_UINTEGER, Constants::ASN_TIMETICKS, Constants::ASN_COUNTER, Constants::ASN_GAUGE\n struct.val[:integer].read_ulong\n when Constants::ASN_IPADDRESS\n struct.val[:objid].read_string(struct.val_len).unpack('CCCC').join(\".\")\n when Constants::ASN_NULL\n nil\n when Constants::ASN_OBJECT_ID\n Net::SNMP::OID.from_pointer(struct.val[:objid], struct.val_len / OID.oid_size)\n when Constants::ASN_COUNTER64\n counter = Wrapper::Counter64.new(struct.val[:counter64])\n counter.high * 2^32 + counter.low\n when Constants::ASN_BIT_STR\n # XXX not sure what to do here. Is this obsolete?\n when Constants::SNMP_ENDOFMIBVIEW\n :endofmibview\n when Constants::SNMP_NOSUCHOBJECT\n :nosuchobject\n when Constants::SNMP_NOSUCHINSTANCE\n :nosuchinstance\n else\n raise Net::SNMP::Error.new, \"Unknown value type #{object_type}\"\n end\n end", "def value\n data[1]\n end", "def result_to_s\n self.class.construct_value @result\n end", "def cast\n p @result\n end", "def get_tag_value (tag_path, fetch_datatype=false)\n\n $test_logger.log(\"Get tag value #{tag_path}\")\n\n raise \"XML doc not loaded\" if @xml_ilv_node == nil\n\n #Get target tag\n target_tag = @xml_ilv_node.root.elements[tag_path]\n\n #Fetch target value\n val = \"\"\n val = target_tag.get_text.value if target_tag && target_tag.get_text\n\n #Get data type for element\n if fetch_datatype\n data_type = ILVMessage.get_type_for_ele(target_tag)\n return val, data_type\n else\n return val\n end\n end", "def extract(result)\n if !result.nil? then\n init(result)\n case \n when @type.name == \"Float\"\n return extract_as_currency(result)\n \n when @type.name == \"String\"\n return extract_as_str(result)\n end\n end\n return nil\n end", "def result\n @s.first[1] || t.default\n end", "def response\n result = {}\n res_xml.blank? ? xml = '' : xml = res_xml\n doc = Hpricot.XML(xml)\n case status\n when 'REQUEST'\n result[:status] = 'BEGIN'\n when 'UPDATE'\n result[:status] = 'NORMAL'\n when 'EXCEPTION'\n result[:status] = 'ERROR'\n end\n result[:xml] = ErpHelper.xml2html(doc.to_s)\n case (doc/:IAVSResult).inner_text\n when 'Y'\n result[:avsresult] = 'Match'\n when 'N'\n result[:avsresult] = 'No Match'\n when 'X'\n result[:avsresult] = 'No Provide'\n end\n result[:zipmatch] = (doc/:AVSResult/:ZipMatch).inner_text\n result[:streetmatch] = (doc/:AVSResult/:StreetMatch).inner_text\n pfp_res_code_msg = open(RAILS_ROOT+\"/db/pfp_transaction_result_code_and_message.yml\") {|f| YAML.load(f)}\n pfp_res_code_msg[res_code].blank? ? result[:pfp_res_code_msg] = 'Credit Card Processing Gateway Error.' : result[:pfp_res_code_msg] = pfp_res_code_msg[res_code]\n return result\n end", "def value\n return @val\n end", "def result(job_id, result_type)\n\n url=\"#{@base_url}/#{@tool}/result/#{URI.encode(job_id)}/#{URI.encode(result_type)}\"\n uri = URI.parse(url)\n\n resp = Net::HTTP.get_response(uri)\n \n return resp.body\n\n\n end", "def result(uuid)\n @result[uuid]\n end", "def get_result(result_type) ; add_result(result_type, false) ; end", "def get_tlv(type, index = 0)\n\t\ttype_tlvs = get_tlvs(type)\n\n\t\tif (type_tlvs.length > index)\n\t\t\treturn type_tlvs[index]\n\t\tend\n\n\t\treturn nil\n\tend", "def get_tlv(type, index = 0)\n\t\ttype_tlvs = get_tlvs(type)\n\n\t\tif (type_tlvs.length > index)\n\t\t\treturn type_tlvs[index]\n\t\tend\n\n\t\treturn nil\n\tend", "def result(res)\n clear_eval\n puts Debugger::PROMPTS[:result] + res.to_s\n end", "def result(res)\n clear_eval\n puts Debugger::PROMPTS[:result] + res.to_s\n end", "def text(result)\n [result.text] if result\n end", "def value\n if @value_set\n @value\n else\n value_from_response\n end\n end", "def binary_value\n\t\treturn self.value.unpack( 'm' ).first\n\tend", "def text\n getvalue\n end", "def get_result\n\t\texecute unless @result\n\t\treturn @result\n\tend", "def result(ast)\n case @truth.fetch(ast, process(ast))\n when :true\n :true\n when :false\n :false\n else\n nil\n end\n end", "def get\n val\n end", "def get\n val\n end", "def getvalue\n @variable.get_value @name\n end", "def get\n @value\n end", "def get\n data[\"_value\"]\n end", "def fetch\n @value\n end", "def status_from_result(result)\n return :failed if result.nil?\n\n if result.include?(:error) && !result[:error].nil?\n return :timed_out if result[:error].is_a?(BawAudioTools::Exceptions::AudioToolTimedOutError)\n\n return :failed\n end\n\n :successful\n end", "def value (timeout = nil)\n\t\treturn @value if delivered?\n\n\t\t@mutex.synchronize {\n\t\t\tcond.wait(@mutex, *timeout)\n\t\t}\n\n\t\treturn @value if delivered?\n\tend", "def results_status()\n r = attr_get(\"status\")\n if(r.eql?(\"passed\"))\n \"passed\"\n else\n \"failed\"\n end\n end", "def response\n @rpc.response\n end", "def value\n data[ address ]\n end", "def mssql_parse_ret(data, info)\n\t\tret = data.slice!(0,4).unpack('N')[0]\n\t\tinfo[:ret] = ret\n\t\tinfo\n\tend", "def get_tlv_values(type)\n\t\tget_tlvs(type).collect { |a| a.value }\n\tend", "def get_tlv_values(type)\n\t\tget_tlvs(type).collect { |a| a.value }\n\tend", "def value\n if eng_unit_type\n \"#{data} #{eng_unit_type.tag}\"\n else\n data.to_s\n end\n end", "def value\n return @value if defined? @value\n\n result = @future_result.result\n @value = if @block\n @block.call(result)\n else\n result\n end\n end", "def getvalue\n @text1\n end", "def result\n @result ||= calculate_result\n end", "def type\n result_hash['typ']\n end", "def value\n data.value\n end", "def value\n return @value unless @value.nil?\n @value = string.data\n @value\n end", "def return_val_type\n TypeSpec.new(@spec['return']['type'])\n end", "def get_execution_result\n @result\n end", "def decode_tlv(data)\n raise OutOfData if (data.length == 2 && data[1].ord != 0) || data.length < 2\n tag = data[0].ord\n length = data[1].ord\n if length < 0x80\n value = data[2, length]\n remainder = data[length+2..-1]\n else\n # ASN.1 says this octet can't be 0xff\n raise InvalidLength, length.to_s if length == 0xff\n num_octets = length & 0x7f\n length = build_integer(data, 2, num_octets)\n value = data[num_octets+2, length]\n remainder = data[num_octets+2+length..-1]\n end\n return tag, value, remainder\n end", "def response\n return unless response?\n\n return @grpc_op.response.unpack(@result_type) if @result_type\n\n descriptor = Google::Protobuf::DescriptorPool.generated_pool.lookup(\n @grpc_op.response.type_name\n )\n return @grpc_op.response.unpack(descriptor.msgclass) if descriptor\n\n @grpc_op.response\n end", "def result\n r = REXML::Document.new @response.body\n success? ? r.root.elements['SOAP-ENV:Body'].elements[\"#{@ns}:#{@action}Response\"].elements['return'].text : r.root.elements['SOAP-ENV:Body'].elements[\"SOAP-ENV:Fault\"].elements['faultstring'].text\n end", "def get_fusion_value(options)\n exists = check_fusion_vm_exists(options)\n fusion_vmx_file = get_fusion_vm_vmx_file(options)\n if exists == true\n message = \"Information:\\tGetting Parameter \"+options['param']+\" for \"+options['name']\n command = \"'#{options['vmrun']}' readVariable '#{fusion_vmx_file}' runtimeConfig '#{options['param']}'\"\n output = execute_command(options,message,command)\n handle_output(options,output)\n else\n handle_output(options,\"Warning:\\t#{options['vmapp']} VM #{options['name']} does not exist\")\n quit(options)\n end\n return\nend", "def return_value\n @return_value\n end", "def type\n return :unknown unless properties['result_type']\n\n properties['result_type'].to_sym\n end", "def get_result_attribute_for_element element\n return nil unless element[\"attrs\"] and element[\"attrs\"][\"phemaObject\"] and element[\"attrs\"][\"phemaObject\"][\"attributes\"]\n attr_hash = Hash.new\n attribute = element[\"attrs\"][\"phemaObject\"][\"attributes\"].find { |key, value| key == \"Result\" }\n attribute\n end", "def renderResult(result)\n\t\thas_keys = result.has_key?(:type) and result.has_key?(:result)\n\t\treturn \"Error processing input\" if !has_keys or result[:type] == 'error' or result[:type].nil?\n\t\treturn result[:result] if result[:result].is_a?(String)\n\t\treturn result[:result].join(\" \") if result[:result].is_a?(Array)\n\n\t\treturn \"Error processing result\"\n\tend", "def getResult\n return @out\n end", "def get_value name=nil\n @value\n end", "def value\n return @value\n end" ]
[ "0.6561463", "0.6532747", "0.6441651", "0.6441651", "0.63099337", "0.6220412", "0.6183481", "0.61491686", "0.61491686", "0.6082777", "0.6055409", "0.6023753", "0.5932441", "0.5932441", "0.5871171", "0.5732631", "0.5697697", "0.5693756", "0.56585586", "0.56520253", "0.56520253", "0.5635571", "0.56283057", "0.56183815", "0.56107706", "0.55882776", "0.55657923", "0.55584013", "0.55449724", "0.5528058", "0.55253595", "0.55060375", "0.5469138", "0.5464736", "0.54635173", "0.54635173", "0.54528767", "0.54202735", "0.54126215", "0.5409278", "0.53959763", "0.53919405", "0.53137976", "0.53096914", "0.5306513", "0.5300351", "0.5296922", "0.52694434", "0.52630913", "0.52437484", "0.52406925", "0.52274394", "0.521261", "0.52116555", "0.51926804", "0.5156209", "0.5156209", "0.51490635", "0.51490635", "0.5140477", "0.5127056", "0.51134", "0.5101384", "0.5100811", "0.5099593", "0.50981843", "0.50981843", "0.5095992", "0.5091041", "0.5084547", "0.50770867", "0.50514543", "0.5047622", "0.50425094", "0.50407356", "0.5036549", "0.5036281", "0.5034583", "0.5034583", "0.5024485", "0.50228566", "0.5019597", "0.50005233", "0.49979642", "0.49968112", "0.4993382", "0.49932265", "0.49913594", "0.49884695", "0.49722528", "0.4959772", "0.4959563", "0.49576044", "0.49552613", "0.49549913", "0.49481478", "0.49457166", "0.4943885", "0.4940699" ]
0.8387234
1
Gets the value of the packet's request identifier TLV.
def rid return get_tlv_value(TLV_TYPE_REQUEST_ID) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def request_id\n @error['request_id']\n end", "def get_request_id\n request_id = ''\n @id_lock.synchronize do\n request_id = @@current_request_id += 1\n end\n request_id\n end", "def get_request_id\n request_id = ''\n @id_lock.synchronize do\n request_id = @@current_request_id += 1\n end\n request_id\n end", "def request_id\n if metadata = @body[@body.keys.first][\"ResponseMetadata\"]\n metadata[\"RequestId\"]\n elsif id = @body[@body.keys.first][\"requestId\"]\n id\n else\n nil\n end\n end", "def id(request, required: true)\n\t\t\t\tdevice_id = request.env['HTTP_X_DEVICE_ID']\n\t\t\t\traise ::TVManager::BadRequest, 'Client device identifier was not supplied' if required && (device_id.nil? || device_id.empty?)\n\n\t\t\t\tdevice_id\n\t\t\tend", "def request_id\n @rid ||= Jabber::Generators.request\n end", "def get_request_id\n\t\treturn @transport.get_path(\"meta\",\"id\")\n\tend", "def request_id\n # FIXME make this number configurable and document the probabilities of clashes\n @request_id ||= SecureRandom.hex(DEFAULT_REQUEST_ID_LENGTH)\n end", "def req_id(env)\n env.request.context[:request_id].to_s\n end", "def request_id; end", "def current_request_id\n RequestStore.store[:current_request_id] || \"NONE\"\n end", "def request_id\n SecureRandom.hex(17)\n end", "def request_id\n SecureRandom.hex(17)\n end", "def get_request_id()\n\t\t\t@random_instance ||= Random.new\n\t\t\tBase64.urlsafe_encode64(@random_instance.bytes(12))\n\t\tend", "def request_id\n # This one set by Rack::RequestId middleware\n Thread.current[:request_id]\n end", "def last_request_id\n @last_response && @last_response.body.to_s[%r{<requestId>(.+?)</requestId>}] && $1\n end", "def request_id\n SecureRandom.hex(5)\n end", "def extract_request_id(env)\n SecureRandom.uuid\n end", "def get_request_status\n $test_logger.log(\"Get request status in integer\")\n get_tag_value_int(\"//#{VALUE_TAG}/#{REQ_STAT_TAG}\")\n end", "def request_id=(_arg0); end", "def identification\n request('getIdentification')\n end", "def request_id=(_); end", "def _appointment_request_id\n appointment_request_id\n end", "def request_value\n title\n end", "def get_kit_id(op)\n op.inputs[0].retrieve\n op.inputs[0].item&.get(KIT_KEY) || op.input(KIT_PARAMETER)&.value\n end", "def to_s\n self.request_id.to_s\n end", "def incident_id\n @attrs['IncidentID']\n end", "def request_token\n @request_token\n end", "def context_id\n params[\"#{ params[:constraint][:context_type].singularize }_id\"]\n end", "def TGET_ID(id)\r\n ((id & TID_MSK) >> TID_POS) & 0xFF\r\n end", "def get_field(request)\n data, _status_code, _headers = get_field_with_http_info(request)\n request_token if _status_code == 401\n data\n end", "def request_type; \"RequestType\"; end", "def identifier\n attributes.fetch(:identifier)\n end", "def identifier\n @info.identifier\n end", "def identifier\n @info.identifier\n end", "def get_trans_id()\n return @RESPONSE_HASH['RRNO']\n end", "def request_type\n return @request_type\n end", "def identifier\n @identifiers[0]\n end", "def identifier_code\n 'QuestionnaireResponseID'\n end", "def get_session_id\n\t\t\tresponse = perform_request(MAGIC_BYTES + REQUEST_BYTE[:challenge] + CLIENT_ID)\n\t\t\t\n\t\t\t# the challenge token comes back as a series of bytes that represent the\n\t\t\t# integer we want, so we have to convert it to the actual 32bit int\n\t\t\t[response.slice(5..-2).to_i].pack(\"l>\").bytes.to_a\n\t\tend", "def client_id\n request.headers['X-Client-ID']\n end", "def next_request_id\n @next_request_mutex.synchronize do\n request_id = @next_request_id\n @next_request_id += 1\n return request_id\n end\n end", "def spot_instance_request_id\n data[:spot_instance_request_id]\n end", "def serial_number\n raw_response[4..-1].pack('c*').unpack('H*').first.upcase\n end", "def EVIOCGID; _IOR('E', 0x02, struct_input_id);end", "def id_request(name, flag, *_)\n _process_conditional(flag) { @definitions[name] }\n end", "def item_id\n params['VendorTxCode']\n end", "def identifier_value\n user.icn\n end", "def key_id\n metadata[\"keyid\"]\n end", "def identifier\n num\n end", "def input_identifier(v)\n (i = identifier_input_method) ? v.to_s.send(i) : v.to_s\n end", "def ensure_request_id(request_id)\n request_id = request_id.to_s.gsub(/[^\\w\\-]/, '')\n request_id.length.positive? ? request_id : Sysrandom.uuid\n end", "def build_id\n build_id_offsets.each do |offset|\n next unless @leak.n(@libbase + offset + 12, 4) == \"GNU\\x00\"\n\n return @leak.n(@libbase + offset + 16, 20).unpack1('H*')\n end\n nil\n end", "def auth_id\n params['TxAuthNo']\n end", "def device_id\n apn_device_token\n end", "def id\n # FIXME: make this number configurable and document the probabilities of clashes\n @id ||= @env[Action::REQUEST_ID] = SecureRandom.hex(Action::DEFAULT_ID_LENGTH)\n end", "def decode_tlv(data)\n raise OutOfData if (data.length == 2 && data[1].ord != 0) || data.length < 2\n tag = data[0].ord\n length = data[1].ord\n if length < 0x80\n value = data[2, length]\n remainder = data[length+2..-1]\n else\n # ASN.1 says this octet can't be 0xff\n raise InvalidLength, length.to_s if length == 0xff\n num_octets = length & 0x7f\n length = build_integer(data, 2, num_octets)\n value = data[num_octets+2, length]\n remainder = data[num_octets+2+length..-1]\n end\n return tag, value, remainder\n end", "def transaction_id\n response_code\n end", "def message_send_device_id() -1003; end", "def get_form_field(request)\n data, _status_code, _headers = get_form_field_with_http_info(request)\n request_token if _status_code == 401\n data\n end", "def id\n value[0]\n end", "def get_request_token\n @consumer.get_request_token\n end", "def device_discoverer_id_param\n params[:device_discoverer_id]\n end", "def id_for(request)\n raise NotImplementedError\n end", "def extract_id\n selector[:_id]\n end", "def manufacturer_id\n mac[0..7]\n end", "def identifier\n fetch_response.display_identifier\n end", "def request_token\n consumer.get_request_token\n end", "def get_int\n raise EOFError if @position + 4 > @size\n value = @response[@position, 4].unpack('N*').first\n @position += 4\n return value\n end", "def identify_request\n klass = @layout == \"miq_request_ae\" ? AutomationRequest : MiqRequest\n @miq_request = @record = identify_record(params[:id], klass)\n end", "def card_identification\n message.fields[6].strip\n end", "def ctid\n\t\tif tmp = vzlist('--no-header', '-a','-N',resource[:name]).split(\" \")[0]\n\t\t\tid = tmp\n\t\telsif !id = resource[:id]\n\t\t\tout = vzlist('--no-header', '-a', '-o','ctid')\n\t\t\ttmp = out.empty? ? 100 : Integer(out.split.last)\n\t\t\tid = tmp <= 100 ? 101 : tmp + 1\n\t\tend\n\t\tif id\n\t\t\treturn id\n\t\telse\n\t\t\tfail \"CTID not specified\"\n\t\tend\n\tend", "def allocation_id\n data[:allocation_id]\n end", "def get_request_counter_key(type, name)\n generate_store_key(\"#{type}-r:#{name}\")\n end", "def ctpid\n nspid[1]\n end", "def vehicle_id(event)\n event[:vehicle_id]\n end", "def request_uid(*args)\n uid\n end", "def request_uid(*args)\n uid\n end", "def request_uid(*args)\n uid\n end", "def get_id\n params[:id]\n end", "def get_int(s, context = \"?\")\n int = s.recv(4)\n\n if(int.nil? || int.length != 4)\n puts(\"Receive failed :: #{context}\");\n exit\n end\n\n return int.unpack(\"I\").pop\nend", "def req\n return @req\n end", "def idkey\n post('/api/1/generic/idkey')\n end", "def capacity_reservation_id\n data[:capacity_reservation_id]\n end", "def get_command_id()\n @query['command_id'] || nil\n end", "def message_id\n data[:message_id]\n end", "def getIdString\r\n\t\t\t\t\r\n\t\t\t\t\treturn @idString\r\n\t\t\t\t\t\r\n\t\t\t\tend", "def getIdString\r\n\t\t\t\t\r\n\t\t\t\t\treturn @idString\r\n\t\t\t\t\t\r\n\t\t\t\tend", "def requests_get\n @attributes[:requests_get]\n end", "def get_raw_token_identity(token,options={})\n response = els_http_request(\"/attributes\",\"subjectid=#{token}\",options)\n if response.code.eql? \"200\"\n response.body\n else\n response.error!\n end\n end", "def kernel_id\n data[:kernel_id]\n end", "def identifiers\n request[:ids]\n end", "def type_id\n index = MQTT::PACKET_TYPES.index(self.class)\n raise \"Invalid packet type: #{self.class}\" if index.nil?\n index\n end", "def identifier\n self.class.identifier_for(send(self.class.identifying_attribute))\n end", "def get_user_device_id(req)\n device_id = req.params['device_id']\n if (not device_id.nil?) and (not device_id.empty?)\n return device_id\n end\n user_agent = req.user_agent\n # try to identify android device using old method\n if user_agent =~ /.*\\(RecognizerIntentActivity.* ([\\w-]+); .*/\n return $1\n elsif user_agent =~ /RecognizerTester.* (\\S+)/\n return $1\n end\n return \"default\"\n end", "def token\n return nil if !id\n encode(id)\n end", "def id\n token\n end", "def name_id\n @name_id ||= begin\n node = REXML::XPath.first(document, \"/p:Response/a:Assertion/a:Subject/a:NameID\", { \"p\" => PROTOCOL, \"a\" => ASSERTION })\n node.text\n end\n end", "def unique_id\n params['unique_id']\n end" ]
[ "0.6200948", "0.61256003", "0.61256003", "0.6103415", "0.5917814", "0.5907701", "0.5843926", "0.57700074", "0.57154477", "0.5599692", "0.5570395", "0.55416703", "0.55416703", "0.5513826", "0.5486862", "0.5425236", "0.5393464", "0.5386217", "0.5377741", "0.53320426", "0.5258218", "0.5244901", "0.52446115", "0.5219355", "0.5170916", "0.5159316", "0.5154583", "0.5149903", "0.5140051", "0.5090427", "0.50730854", "0.5067091", "0.502835", "0.50236064", "0.50236064", "0.5007188", "0.49754447", "0.49650323", "0.49632147", "0.49535558", "0.4935087", "0.49324048", "0.49122614", "0.49009836", "0.48857138", "0.486105", "0.4842082", "0.4824594", "0.47961554", "0.4771027", "0.4768523", "0.47475508", "0.47380567", "0.47379768", "0.4728921", "0.47240737", "0.47210538", "0.4720003", "0.47176924", "0.47001988", "0.46929494", "0.4667343", "0.466278", "0.4650328", "0.46454716", "0.4644921", "0.46399578", "0.46374354", "0.4635987", "0.4618749", "0.46051028", "0.46040496", "0.45963895", "0.45945993", "0.45887828", "0.45834473", "0.45797652", "0.45797652", "0.45797652", "0.4577715", "0.45770755", "0.45765695", "0.45743188", "0.4569429", "0.45688295", "0.4563709", "0.45623416", "0.45623416", "0.45546642", "0.45511204", "0.4547171", "0.4546687", "0.45359772", "0.45175314", "0.45151043", "0.4506882", "0.44983003", "0.44979107", "0.44940472" ]
0.73957974
1
def select_category_from_projects "SELECT category FROM projects;" end Make sure each ruby method returns a string containing a valid SQL statement.
def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_name "SELECT projects.title, SUM (pledges.amount) FROM projects INNER JOIN pledges ON projects.id = pledges.project_id GROUP BY title ORDER BY title ASC;" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def select_category_from_projects\n\"SELECT category FROM projects;\"\nend", "def selects_the_category_names_and_pledge_amounts_of_all_pledges_in_the_music_category\n\"SELECT projects.category, pledges.amount\nFROM pledges\nINNER JOIN projects\nON projects.id = pledges.project_id\nWHERE projects.category = 'music';\n\"\nend", "def current_categories(db)\r\n\tretrieve_categories = '\r\n\tSELECT name FROM categories'\r\n\tcategories = db.execute(retrieve_categories)\r\nend", "def selects_the_category_name_and_the_sum_total_of_the_all_its_pledges_for_the_books_category\n\"SELECT projects.category, SUM(pledges.amount)\nFROM pledges\nINNER JOIN projects\nON pledges.project_id = projects.id \nWHERE projects.category = 'books';\"\nend", "def selects_the_category_name_and_the_sum_total_of_the_all_its_pledges_for_the_books_category\n\"SELECT Projects.category, SUM(Pledges.amount) FROM Projects JOIN Pledges ON Pledges.project_id = Projects.id WHERE Projects.category = 'books';\"\nend", "def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_title\n \"Write your SQL query Here\"\nend", "def categories()\n db = connect()\n db.execute('SELECT * FROM categories')\n end", "def category()\n sql = \"SELECT * FROM categories WHERE id = $1 ORDER BY name;\"\n values = [@category_id]\n sql_result = SqlRunner.run(sql, values)\n return Category.new(sql_result[0])\n end", "def get_category_name(category_id)\n db = SQLite3::Database.new \"#{$script_dir}/cfps.db\"\n category = db.get_first_value(\"select name from category where id = ?\", [category_id])\n\n return categor\nend", "def projects\n where(:_type => ProjectCategory.name)\n end", "def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_name\n \"Write your SQL query Here\"\n \"SELECT projects.title, SUM(pledges.amount)\n FROM projects\n INNER JOIN pledges\n ON projects.id = pledges.project_id\n GROUP BY projects.title ORDER BY projects.title;\"\nend", "def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_name\n\"Write your SQL query Here\"\n \"SELECT projects.title, SUM(amount) FROM projects\n INNER JOIN pledges ON project_id = projects.id\n GROUP BY title;\"\nend", "def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_name\n\"SELECT title, SUM(amount)\nFROM projects\nINNER JOIN pledges\nON projects.id = pledges.project_id\nGROUP BY title\nORDER BY title\"\n\n# FROM owners\n# INNER JOIN cats_owners\n# ON owners.id = cats_owners.owner_id\n# JOIN cats ON cats_owners.cat_id = cats.id\n# WHERE cats_owners.owner_id = 2;\n\nend", "def current_categorized_expenses(db, user_name)\r\n\tretrieve_categorized_expenses = '\r\n\tSELECT categories.name, amount FROM expenses\r\n\tJOIN users ON expenses.user_id = users.id\r\n\tJOIN categories ON expenses.category_id = categories.id\r\n\tWHERE users.name = ?'\r\n\tcategorized_expenses = db.execute(retrieve_categorized_expenses, [user_name])\r\nend", "def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_name\n\"Write your SQL query Here\"\n\"SELECT projects.title, SUM(pledges.amount) FROM projects INNER JOIN pledges ON projects.id = pledges.project_id GROUP BY(projects.title) ;\"\nend", "def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_name\n sql = <<-SQL\n SELECT projects.title, SUM(pledges.amount) FROM projects JOIN pledges ON pledges.project_id = projects.id GROUP BY projects.title;\n SQL\n\nend", "def getCategories(_, _, _)\n @db.categories\n end", "def selects_the_titles_of_all_projects_and_their_pledge_amounts\n <<-SQL\n SELECT projects.title , sum(pledges.amount)\n FROM projects\n INNER JOIN pledges\n ON projects.id = pledges.project_id\n GROUP BY pledges.project_id\n ORDER BY projects.title\n SQL\nend", "def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_title\n \"Write your SQL query Here\"\n \n\"SELECT projects.title, SUM(amount) \nFROM pledges \nINNER JOIN projects \nON pledges.project_id = projects.id GROUP BY projects.title;\"\nend", "def category(id)\n db = connect()\n return db.execute('SELECT Id,Title FROM discussions WHERE CatId=?', id), db.execute('SELECT * FROM categories WHERE Id=?', id)\n end", "def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_name\n\"Write your SQL query Here\"\n \"SELECT projects.title, SUM(pledges.amount) FROM projects INNER JOIN pledges ON pledges.project_id = projects.id GROUP BY projects.title ORDER BY title\"\nend", "def list_projects # :nologin:\n query = create_query(:Project, :all, :by => :title)\n show_selected_projects(query)\n end", "def get_category_id(category)\n db = SQLite3::Database.new \"#{$script_dir}/cfps.db\"\n category_id = db.get_first_value(\"select id from category where name = ?\", [category])\n\n return category_id\nend", "def select(db); end", "def select(db); end", "def get_records_for_category categ\n if categ.nil? or categ == \"\"\n #return @records\n get_data \"select * from todo\"\n else\n #return @records.select { |row| row[0] == categ }\n get_data \"select * from todo where categ = '#{categ}' \"\n end\n end", "def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_title\n <<-SQL \n SELECT projects.title, SUM(pledges.amount)\n FROM projects \n INNER JOIN pledges on projects.id = pledges.project_id \n GROUP BY projects.title\n ORDER BY projects.title\n SQL\nend", "def project_statement\n project_clauses = []\n active_subprojects_ids = []\n\n active_subprojects_ids = project.descendants.active.map(&:id) if project\n if active_subprojects_ids.any?\n if has_filter?(\"subproject_id\")\n case operator_for(\"subproject_id\")\n when '='\n # include the selected subprojects\n ################\n # Smile specific : [project.id] + removed\n ids = values_for(\"subproject_id\").map(&:to_i)\n project_clauses << \"#{Project.table_name}.id IN (%s)\" % ids.join(',')\n when '!'\n # exclude the selected subprojects\n\n ################\n # Smile specific : [project.id] + removed\n ids = active_subprojects_ids - values_for(\"subproject_id\").map(&:to_i)\n project_clauses << \"#{Project.table_name}.id IN (%s)\" % ids.join(',')\n when '!*'\n # main project only\n project_clauses << \"#{Project.table_name}.id = %d\" % project.id\n else\n # all subprojects\n project_clauses << \"#{Project.table_name}.lft >= #{project.lft} AND #{Project.table_name}.rgt <= #{project.rgt}\"\n end\n elsif Setting.display_subprojects_issues?\n project_clauses << \"#{Project.table_name}.lft >= #{project.lft} AND #{Project.table_name}.rgt <= #{project.rgt}\"\n else\n project_clauses << \"#{Project.table_name}.id = %d\" % project.id\n end\n elsif project\n project_clauses << \"#{Project.table_name}.id = %d\" % project.id\n end\n project_clauses.any? ? project_clauses.join(' AND ') : nil\n end", "def select(sql, name = nil)\n raise NotImplementedError, \"select is an abstract method\"\n end", "def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_name\n<<-SQL\n SELECT projects.title, SUM(pledges.amount)\n FROM projects\n JOIN pledges\n ON projects.id = pledges.project_id\n GROUP BY projects.title;\nSQL\nend", "def index\n\n # @sql = \"Projects.name ILIKE '#{'%'+params[:name]+'%'}' \" if params[:name].present?\n @sql = params[:name].present? ? \"Projects.name ILIKE '#{'%'+params[:name]+'%'}' \" : \"Projects.name ILIKE '%' \"\n @sql += \"OR Projects.description ILIKE '#{'%'+params[:name]+'%'}' \" if params[:name].present?\n\n @sql += \"and Projects.category ILIKE '#{'%'+params[:categorysdigital]+'%'}' \" if params[:categorysdigital].present?\n if params[:categorysdigital].present?\n @sql += \"or Projects.category ILIKE '#{'%'+params[:categorysmarketing]+'%'}' \" if params[:categorysmarketing].present?\n else\n @sql += \"And Projects.category ILIKE '#{'%'+params[:categorysmarketing]+'%'}' \" if params[:categorysmarketing].present?\n end\n\n if params[:categorysdigital].present? || params[:categorysmarketing].present?\n @sql += \"or Projects.category ILIKE '#{'%'+params[:categorysdesign]+'%'}' \" if params[:categorysdesign].present?\n else\n @sql += \"And Projects.category ILIKE '#{'%'+params[:categorysdesign]+'%'}' \" if params[:categorysdesign].present?\n end\n\n @sql += \"and Projects.progress = #{params[:progresspropose].to_i} \" if params[:progresspropose].present?\n if params[:progresspropose].present?\n @sql += \"or Projects.progress = #{params[:progressselected].to_i} \" if params[:progressselected].present?\n else\n @sql += \"and Projects.progress = #{params[:progressselected].to_i} \" if params[:progressselected].present?\n end\n\n if params[:progressselected].present?\n @sql += \"or Projects.progress = #{params[:progressclose].to_i} \" if params[:progressclose].present?\n else\n @sql += \"and Projects.progress = #{params[:progressclose].to_i} \" if params[:progressclose].present?\n end\n\n # @sql += \"ORDER progress\"\n @projects = Project.where(@sql).order(:progress)\n @count = @projects.count\n @count_tt = Project.count\n end", "def projects_countries(site, category_id = nil)\n if category_id.present? && category_id.to_i > 0\n if site.navigate_by_cluster?\n category_join = \"inner join clusters_projects as cp on cp.project_id = p.id and cp.cluster_id = #{category_id}\"\n else\n category_join = \"inner join projects_sectors as pse on pse.project_id = p.id and pse.sector_id = #{category_id}\"\n end\n end\n\n Country.find_by_sql(\n<<-SQL\nselect c.id,c.name,count(ps.*) as count from countries as c\n inner join countries_projects as pr on c.id=pr.country_id\n inner join projects as p on p.id=pr.project_id\n inner join projects_sites as ps on p.id=ps.project_id and ps.site_id=#{site.id}\n #{category_join}\n where p.primary_organization_id=#{self.id}\n group by c.id, c.name order by count DESC\nSQL\n ).map do |r|\n [r, r.count.to_i]\n end\n end", "def projects_countries(site, category_id = nil)\n if category_id.present?\n if site.navigate_by_cluster?\n category_join = \"inner join clusters_projects as cp on cp.project_id = p.id and cp.cluster_id = #{category_id}\"\n else\n category_join = \"inner join projects_sectors as pse on pse.project_id = p.id and pse.sector_id = #{category_id}\"\n end\n end\n\n Country.find_by_sql(\n<<-SQL\nselect c.id,c.name,count(ps.*) as count from countries as c\n inner join countries_projects as pr on c.id=pr.country_id\n inner join projects as p on p.id=pr.project_id and (p.end_date is null OR p.end_date > now())\n inner join projects_sites as ps on p.id=ps.project_id and ps.site_id=#{site.id}\n #{category_join}\n where p.primary_organization_id=#{self.id}\n group by c.id, c.name order by count DESC\nSQL\n ).map do |r|\n [r, r.count.to_i]\n end\n end", "def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_name\n\"SELECT projects.title, SUM(pledges.amount)\nFROM pledges\nINNER JOIN projects \nON pledges.project_id = projects.id\nGROUP BY project_id\nORDER BY projects.title;\"\nend", "def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_name\n# Select projects title column and the sum of the pledges amount column\n# from the projects database,\n# join the pledges (Join table)\n# with projects.id and the pledges project id. Match these numbers\n# Group the tables together by Projects title and then\n# sort by projects.title\n\"SELECT Projects.title, SUM(Pledges.amount)\n FROM Projects\n JOIN Pledges\n ON Projects.id = Pledges.project_id\n GROUP BY Projects.title\n ORDER BY Projects.title;\n\"\nend", "def get_project_name(id)\n con = PG::Connection.connect(\"localhost\",5432,nil,nil,\"aaa\",\"admin\")\n sql = \"SELECT name \"\n sql += \"FROM projects \"\n sql += \"WHERE id='#{id}' \"\n res = con.exec(sql)\n con.close\n name = \"NA\"\n name = res[0]['name'] if res.num_tuples > 0\nend", "def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_name\n<<-SQL\n SELECT DISTINCT title ,SUM(amount) FROM projects INNER JOIN pledges ON projects.id = pledges.project_id\n GROUP BY projects.title\n SQL\nend", "def sql\n <<-SQL\n -- Search learning paths\n SELECT DISTINCT\n c.id,\n c.name,\n c.course_code,\n c.settings,\n cc.content,\n 'learning_path' AS content_type,\n c.id AS learning_path_id,\n 0 AS learning_objective_id\n FROM courses c\n LEFT OUTER JOIN fearless_taggings ts\n ON ts.taggable_id = c.id AND ts.taggable_type = 'LearningPath'\n LEFT OUTER JOIN fearless_tags t\n ON t.id = ts.tag_id\n LEFT OUTER JOIN fearless_custom_contents cc\n ON cc.contentable_id = c.id AND cc.contentable_type = 'LearningPath'\n WHERE 0=0\n #{construct_account_clause}\n #{construct_course_worklow_clause}\n #{construct_name_sql}\n #{construct_all_tags_search('t', 'name')}\n UNION ALL\n -- Search learning objectives\n SELECT DISTINCT\n cm.id,\n cm.name,\n c.course_code,\n c.settings,\n cc.content,\n 'learning_objective' AS content_type,\n cm.context_id::bigint AS learning_path_id,\n cm.id::bigint AS learning_objective_id\n FROM context_modules cm\n INNER JOIN courses c\n ON c.id = cm.context_id\n AND cm.context_type = 'Course'\n LEFT OUTER JOIN fearless_taggings ts\n ON ts.taggable_id = cm.id AND ts.taggable_type = 'LearningObjective'\n LEFT OUTER JOIN fearless_tags t\n ON t.id = ts.tag_id\n LEFT OUTER JOIN fearless_custom_contents cc\n ON cc.contentable_id = cm.id AND cc.contentable_type = 'LearningObjective'\n WHERE 0=0\n #{construct_account_clause}\n #{construct_generic_workflow_clause('cm')}\n #{construct_name_sql('cm')}\n #{construct_all_tags_search('t', 'name')}\n UNION ALL\n -- Search learning learning_event\n SELECT DISTINCT\n ct.id,\n ct.title AS name,\n c.course_code,\n c.settings,\n cc.content,\n 'learning_event' AS content_type,\n ct.context_id::bigint AS learning_path_id,\n ct.context_module_id::bigint AS learning_objective_id\n FROM content_tags ct\n INNER JOIN courses c\n ON c.id = ct.context_id\n AND ct.context_type = 'Course'\n LEFT OUTER JOIN fearless_taggings ts\n ON ts.taggable_id = ct.id AND ts.taggable_type = 'LearningEvent'\n LEFT OUTER JOIN fearless_tags t\n ON t.id = ts.tag_id\n LEFT OUTER JOIN fearless_custom_contents cc\n ON cc.contentable_id = ct.id AND cc.contentable_type = 'LearningEvent'\n WHERE 0=0\n #{construct_account_clause}\n #{construct_generic_workflow_clause('ct')}\n #{construct_name_sql('ct', 'title')}\n #{construct_all_tags_search('t', 'name')}\n SQL\n end", "def get_category_name\n Category.find(:first, :select => ['name'],:conditions=>['has_complexity=?',false]).name rescue ''\n end", "def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_title\n \"\nSELECT \nProjects.title,\nSUM(Pledges.amount)\nFROM Pledges\nINNER JOIN Projects\nON Pledges.project_id = Projects.id\nGROUP BY Projects.title\nORDER BY Projects.title\n\"\nend", "def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_name\n\"SELECT Projects.title, SUM(pledges.amount) \nFROM projects \nJOIN pledges \nON Projects.id = pledges.project_id \nGROUP BY title\"; \nend", "def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_name\n\"SELECT projects.title, SUM(pledges.amount)\nFROM projects\nINNER JOIN pledges \nON projects.id=pledges.project_id\nGROUP BY projects.id\nORDER BY projects.title;\"\nend", "def makeQueryTableAll(tableName)\n #sql = \"SELECT * FROM [\" << tableName << \"]\"\n sql = \"SELECT * FROM [\" << tableName << \"]\" << \" WHERE id < 3\"\n #puts(sql) #debug\n return sql\nend", "def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_title\n \"SELECT projects.title, sum_pledges FROM (SELECT pledges.project_id, SUM(pledges.amount) AS sum_pledges FROM pledges GROUP BY pledges.project_id) INNER JOIN projects ON projects.id = project_id ORDER BY projects.title\"\nend", "def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_name\n<<-SQL\nSELECT projects.title, SUM(pledges.amount) \nFROM projects \nINNER JOIN pledges on projects.id = pledges.project_id\nGROUP BY (pledges.project_id)\nORDER BY projects.title;\nSQL\nend", "def category_totals(db, user_name, number)\r\n\tretrieve_totals = '\r\n\tSELECT categories.name, SUM(amount) FROM expenses\r\n\tJOIN users ON expenses.user_id = users.id\r\n\tJOIN categories ON expenses.category_id = categories.id\r\n\tWHERE categories.id = ?\r\n\tAND users.name = ?'\r\n\ttotals = db.execute(retrieve_totals, [number, user_name])[0]\r\nend", "def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_name\r\n\"SELECT title, SUM(pledges.amount) FROM projects\r\nJOIN pledges ON projects.id = pledges.project_id\r\nGROUP BY projects.id\r\nORDER BY title ASC\"\r\nend", "def add_category(db, category)\r\n\tnew_category = '\r\n\tINSERT INTO categories (name)\r\n\tVALUES (?)'\r\n\tdb.execute(new_category, [category])\r\nend", "def select_category\n #Parbauda vai ekrans ir redzams\n @screens.screen_create_filter.visible?\n #Pievieno kategoriju no filtra datiem\n @screens.screen_create_filter.select_row(@filter_data.category)\n end", "def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_name\n\"Select title, amount from projects, pledges where projects.id = pledges.id order by title ASC;\"\nend", "def projects_countries(site, category_id = nil, organization_id = nil, location_id = nil)\n if category_id.present? && category_id.to_i > 0\n if site.navigate_by_cluster?\n category_join = \"inner join clusters_projects as cp on cp.project_id = p.id and cp.cluster_id = #{category_id}\"\n else\n category_join = \"inner join projects_sectors as pse on pse.project_id = p.id and pse.sector_id = #{category_id}\"\n end\n end\n\n if organization_id.present? && organization_id.to_i > 0\n organization_filter = \"and p.primary_organization_id = #{organization_id}\"\n end\n\n if location_id.present?\n location_filter = \"and c.id IN (#{location_id})\"\n end\n\n Country.find_by_sql(\n<<-SQL\nselect c.id,c.name,count(ps.*) as count from countries as c\n inner join countries_projects as pr on c.id=pr.country_id #{location_filter}\n inner join projects as p on p.id=pr.project_id and (p.end_date is null OR p.end_date > now()) #{organization_filter}\n inner join projects_sites as ps on p.id=ps.project_id and ps.site_id=#{site.id}\n inner join donations as dn on dn.project_id = p.id\n #{category_join}\n where dn.donor_id = #{self.id}\n group by c.id, c.name order by count DESC\nSQL\n ).map do |r|\n [r, r.count.to_i]\n end\n end", "def selects_the_titles_of_all_projects_and_their_pledge_amounts\n\"SELECT projects.title, SUM(pledges.amount) FROM pledges INNER JOIN projects ON projects.id=pledges.project_id GROUP BY projects.title;\"\n## FROM - where are they talking to each other - where is the scotch tape\nend", "def select(componentName, text, componentInfo=nil)\n $marathon.select(ComponentId.new(componentName, componentInfo), text.to_s)\nend", "def selects_the_titles_of_all_projects_and_their_pledge_amounts\n \"SELECT projects.title,\n SUM(pledges.amount)\n FROM pledges\n INNER JOIN projects\n ON projects.id = pledges.project_id\n GROUP BY projects.title;\"\n\nend", "def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_name\n\"SELECT projects.title, \nSUM(pledges.amount) \nFROM projects\nJOIN pledges ON pledges.project_id = projects.id\nGROUP BY projects.title\nORDER BY projects.title ASC;\"\nend", "def select_all(sql, name = nil) end", "def select\n @pds_projects = PdsProject.includes(:company).where('ProjectID in (?)', PROJECT_LIST)\n end", "def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_name\n\"SELECT projects.title, sum(amount) AS pledge_amount\nFROM pledges\nJOIN projects\nWHERE pledges.project_id = projects.id\nGROUP BY project_id\nORDER BY projects.title;\"\nend", "def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_title\n <<-SQL\n SELECT\n title, sum(amount)\n FROM\n projects\n JOIN pledges\n ON pledges.project_id = projects.id\n GROUP BY\n title\n ORDER BY\n title\n SQL\nend", "def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_name\n\"SELECT projects.title, SUM(pledges.amount )\nFROM projects \nJOIN pledges\nON projects.id = pledges.project_id \nGROUP BY projects.title \nORDER BY projects.title \";\nend", "def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_name\n \"SELECT projects.title,(SELECT SUM(pledges.amount))\n FROM projects\n INNER JOIN pledges ON projects.id = pledges.project_id\n GROUP BY projects.title;\"\nend", "def selects_the_titles_of_all_projects_and_their_pledge_amounts\n \"SELECT projects.title, sum(pledges.amount)\n FROM projects\n INNER JOIN pledges\n ON projects.id = pledges.project_id\n GROUP BY pledges.project_id\n ORDER BY projects.title ASC;\n \"\nend", "def db_fetch\n \"SELECT *\" + from_table_where + sql_match_conditions\n end", "def get_category(cate, limitl, limitr)\n return Product.find_by_sql(\"select * from products where tag like '%#{cate}%' order by id limit #{limitl}, #{limitr}\")\n end", "def selects_the_titles_of_all_projects_and_their_pledge_amounts\n\"SELECT projects.title, SUM(pledges.amount) FROM pledges INNER JOIN projects ON projects.id = pledges.project_id GROUP BY projects.title ORDER BY projects.title \"\nend", "def select_project\n @projects = Project.find(:all)\n end", "def selects_the_titles_of_all_projects_and_their_pledge_amounts\n\"SELECT projects.title, SUM(pledges.amount)\n FROM projects\n JOIN pledges\n ON projects.id = pledges.project_id\n GROUP BY projects.title;\"\nend", "def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_name\n\"SELECT title, SUM(amount)\nFROM projects\nINNER JOIN pledges\nON projects.id = pledges.project_id\nGROUP BY projects.title\nORDER BY projects.title;\"\nend", "def sql_statement_find\n @sql_statement_find ||=\n <<-SQL\n SELECT\n applications.id AS id,\n teams.name AS team_name,\n projects.name AS project_name,\n (application_data -> :project_id)::int AS project_id,\n application_data -> :project_plan AS project_plan,\n application_data -> :why_selected_project AS why_selected_project,\n application_data -> :signed_off_at AS signed_off_at,\n (application_data -> :signed_off_by)::int AS signed_off_by,\n application_data -> :mentor_fav AS mentor_fav,\n CASE WHEN :project_id::text = 'project1_id' THEN 1 ELSE 2 END AS choice,\n hstore_to_json_loose(slice(application_data, ARRAY[:student0_attrs])) AS student0,\n hstore_to_json_loose(slice(application_data, ARRAY[:student1_attrs])) AS student1\n FROM applications\n INNER JOIN teams\n ON teams.id = applications.team_id\n INNER JOIN projects\n ON projects.id::text = applications.application_data -> :project_id\n WHERE (application_data -> :project_id)::int IN (:project_ids)\n AND applications.season_id = :season_id\n AND applications.id = :id;\n SQL\n end", "def selects_the_titles_of_all_projects_and_their_pledge_amounts\n\"SELECT Projects.title, SUM(Pledges.amount)\n FROM projects\n JOIN pledges\n ON Projects.id = Pledges.project_id\n GROUP BY project_id\n ORDER BY Projects.title\"\nend", "def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_name\n\"SELECT projects.title, SUM(pledges.amount)\n FROM pledges\n INNER JOIN projects\n ON pledges.project_id = projects.id\n GROUP BY projects.title\n ORDER BY projects.title\n\"\nend", "def select(componentName, text, componentInfo=nil)\n $marathon.select(ComponentId.new(componentName, componentInfo), text.to_s)\nend", "def sql\n @sql ||= begin\n bind_params = []\n 1.upto(selector_keys.length + setter_keys.length) { |i| bind_params << \"$#{i}\" }\n %{SELECT #{name}(#{bind_params.join(', ')})}\n end\n end", "def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_name\n\"SELECT projects.title, SUM(pledges.amount)\nFROM projects\nJOIN pledges\nON projects.id = pledges.project_id\nGROUP BY projects.title;\"\nend", "def getCat \n\t\tputs ''\n\t\tputs 'Fetching categories . . '\n\t\t@page.css('ul.dropdown li a').each do |cat|\n\t\t\tarr=[]\n\t\t\tarr.push cat.text\n\t\t\tarr.push cat['href']\n\t\t\t@arr_cat.push arr\n\t\t\tprint '. '\n\t\tend\n\t\ti=0\n\t\t@arr_cat.each do |pair|\n\t\t\t@db.execute 'insert into category values (?, ? ,?)', i, pair[0], pair[1]\n \t\t\ti +=1\n \t\tend\n\tend", "def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_name\n\"SELECT Projects.title, SUM(Pledges.amount) FROM Projects JOIN Pledges ON Pledges.project_id = Projects.id GROUP BY Projects.title;\"\nend", "def add_project_name_to_jql jql_string\n unless jql_string.empty?\n jql_string.insert(0, \"project=#{@project} AND \")\n else\n \"project=#{@project}\"\n end\n end", "def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_name\n\"SELECT title, SUM(amount) FROM pledges INNER JOIN projects ON projects.id = pledges.project_id GROUP BY projects.id ORDER BY title;\"\nend", "def search(category, query_term)\nresult = @conn.exec(\"SELECT * FROM students WHERE #{category} = '#{query_term}';\");\n puts student\n result.each do |student|\n puts \"#{k}: #{v}\"\n end\nend", "def selects_the_titles_of_all_projects_and_their_pledge_amounts\n\"SELECT projects.title, SUM(pledges.amount)\n FROM projects\n INNER JOIN pledges\n ON pledges.project_id = projects.id\n GROUP BY(projects.title);\"\nend", "def show_categories(html_dsl)\r\n categories = Category.where(\"user_id = #{session[:user_id]} and category_id is null\").order('name ASC')\r\n category_html = create_category_table(categories)\r\n html_dsl.inject(category_html)\r\n end", "def show_categories(html_dsl)\r\n categories = Category.where(\"user_id = #{session[:user_id]} and category_id is null\").order('name ASC')\r\n category_html = create_category_table(categories)\r\n html_dsl.inject(category_html)\r\n end", "def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_name\n\"SELECT projects.title, sum(pledges.amount) FROM projects INNER JOIN pledges on pledges.project_id=projects.id group by pledges.project_id ORDER BY projects.title ASC\"\nend", "def selects_all_female_bears_return_name_and_age\n <<-SQL \n SELECT \n bears.name, \n bears.age \n FROM bears \n WHERE sex='F';\n SQL\nend", "def selects_the_titles_of_all_projects_and_their_pledge_amounts\n \"SELECT projects.title, SUM(pledges.amount) FROM projects\n JOIN pledges ON projects.id = pledges.project_id\n GROUP BY projects.title;\"\nend", "def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_name\n \"SELECT projects.title, SUM(pledges.amount) FROM projects INNER JOIN pledges ON pledges.project_id=projects.id GROUP BY projects.title ORDER BY projects.title;\"\nend", "def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_name\n\"SELECT projects.title, SUM(pledges.amount)\nFROM projects\nINNER JOIN pledges\nON projects.id = pledges.project_id GROUP BY projects.title;\"\nend", "def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_title\n # SELECT titles, amounts FROM projects, pledges ORDER BY titles ASC\n #SELECT titles.projects, pledges.amounts ORDER BY titles ASC\n \"SELECT projects.title, SUM(pledges.amount) FROM projects\n JOIN pledges \n ON pledges.project_id = projects.id \n GROUP BY(pledges.project_id)\n ORDER BY projects.title ASC\n \";\nend", "def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_name\n \"SELECT projects.title, SUM(pledges.amount)\n FROM projects\n JOIN pledges ON pledges.project_id = projects.id\n GROUP BY title\n ORDER BY title ASC;\"\nend", "def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_name\n\"SELECT projects.title, SUM(pledges.amount) FROM projects INNER JOIN pledges ON projects.id = pledges.project_id GROUP BY projects.title ORDER BY projects.title ASC;\"\nend", "def sql_statement_all\n @sql_statement_all ||=\n <<-SQL\n SELECT\n applications.id AS id,\n teams.name AS team_name,\n projects.name AS project_name,\n (application_data -> :project_id)::int AS project_id,\n application_data -> :signed_off_at AS signed_off_at,\n (application_data -> :signed_off_by)::int AS signed_off_by,\n application_data -> :mentor_fav AS mentor_fav,\n CASE WHEN :project_id::text = 'project1_id' THEN 1 ELSE 2 END AS choice\n FROM applications\n INNER JOIN teams\n ON teams.id = applications.team_id\n INNER JOIN projects\n ON projects.id::text = applications.application_data -> :project_id\n WHERE (application_data -> :project_id)::int IN (:project_ids)\n AND applications.season_id = :season_id;\n SQL\n end", "def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_name\n\"select\nprojects.title,\nsum(pledges.amount) as sum_all_pledges\nfrom projects\ninner join pledges\non projects.id = pledges.project_id\ngroup by projects.title\norder by projects.title;\n\"\nend", "def selects_the_titles_of_all_projects_and_their_pledge_amounts\n \"SELECT projects.title, SUM(pledges.amount) \n FROM projects\n JOIN pledges\n ON pledges.project_id = projects.id\n GROUP BY projects.title;\"\nend", "def category_selection(category)\n category = Public_apis.find_by_name(category)\n #goes over list item array . find method to find item\n\n \n end", "def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_name\n\"SELECT projects.title, SUM(pledges.amount)\nFROM projects\nLEFT JOIN pledges\nON projects.id=pledges.project_id\nGROUP BY projects.title\nORDER BY projects.title;\"\nend", "def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_name\n #SELECT title, SUM(quantity) FROM groceries GROUP BY aisle ORDER BY SUM(quantity);\n\n \"SELECT projects.title, sum( pledges.amount)\nFROM projects\nJOIN pledges\nwhere projects.id=pledges.project_id\ngroup by projects.title order by projects.title\n;\"\n\nend", "def frey_example\n # Find all the cats that are the same color as the cat named 'Freyja'.\n # Including 'Freyja' in the results.\n # DO NOT USE A SUBQUERY\n\n execute(<<-SQL)\n SELECT\n color_cats.name\n FROM\n cats AS freyja_cats\n JOIN\n cats AS color_cats ON freyja_cats.color = color_cats.color\n WHERE\n freyja_cats.name = 'Freyja';\n SQL\nend", "def select &blck\n @projects.select(&blck)\n end", "def select &blck\n @projects.select(&blck)\n end", "def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_name\n\"SELECT p.title, SUM(pl.amount) FROM pledges pl INNER JOIN projects p ON pl.project_id = p.id GROUP BY pl.project_id ORDER BY p.title\"\nend" ]
[ "0.91975725", "0.70677555", "0.6991048", "0.6650848", "0.6622102", "0.65142804", "0.6486619", "0.6324411", "0.6060808", "0.5940286", "0.5938452", "0.5936497", "0.59008545", "0.5882288", "0.58708847", "0.5854367", "0.5853117", "0.5840391", "0.58196145", "0.57844824", "0.5782323", "0.5699479", "0.56962615", "0.56908596", "0.56908596", "0.5690099", "0.5682939", "0.56795293", "0.56339574", "0.56285524", "0.5619901", "0.5618796", "0.5615018", "0.55893004", "0.5582245", "0.55740756", "0.55737764", "0.55722576", "0.55683357", "0.5544428", "0.5540983", "0.55276155", "0.5486528", "0.5480275", "0.547941", "0.5476871", "0.5475882", "0.5464613", "0.5461787", "0.54593414", "0.5450467", "0.54476595", "0.54341006", "0.54305166", "0.54301846", "0.5427839", "0.54239625", "0.5423491", "0.54228365", "0.54159963", "0.5407836", "0.53929824", "0.5386029", "0.5384626", "0.5381931", "0.53814876", "0.53810024", "0.53731465", "0.53618735", "0.53517103", "0.5351534", "0.5349513", "0.5348637", "0.53480995", "0.53410536", "0.533275", "0.5332083", "0.5321954", "0.5321023", "0.5319559", "0.5311521", "0.5311521", "0.53068143", "0.5299451", "0.5296459", "0.52909446", "0.5286771", "0.5284667", "0.52844983", "0.5283471", "0.52832884", "0.52765894", "0.52735233", "0.5272648", "0.52687514", "0.52644944", "0.5259528", "0.5257457", "0.5257457", "0.5255126" ]
0.53407246
75
Function to determine the status of a piece of a equipment attached to the booking
def get_item_status(item_id) status = "" overdue = true equipment = Equipment.find_by_id(item_id) # if a equipment is not in or signed out return the status if equipment.status > 1 status = Equipment.get_status(equipment.status) return status end # Is the booking recurring? if self.schedule.nil? # Not recurring # Is item in signed out list? if self.sign_out_times.key?(item_id) # Item signed out. if self.sign_in_times.key?(item_id) #If it is also signed in, it is "In" status = "In" equipment.status = 1 else # If it is not signed in, it is "Out" or "Overdue" depending on time self.events.each do |ev| if ev.end >= Time.now #Item is out for a current event, so status is "Out" not "Overdue" overdue = false end #If item is not found to be out for a current event it will be "Overdue" end if overdue status = "Overdue" else status = "Out" end equipment.status = 0 end else # Item not signed out, it is "Booked" status = "Booked" equipment.status = 1 end else # Recurring # Is item in signed out list? if self.sign_out_times.key?(item_id) #Item signed out if self.sign_in_times.key?(item_id) #Item is signed in if self.sign_out_times[item_id] >= self.sign_in_times[item_id] #Item is signed in and out, but the out time is after the in time #This means that the "In" was from a previous event in the recurrence, while the #"Out" is from a more recent event. Therefore the "Out"/"Overdue" takes precedence. # If it is not signed in, it is "Out" or "Overdue" depending on time self.events.each do |ev| if (ev.start <= Time.now) & (ev.end >= Time.now) #Item is out for a current event, so status is "Out" not "Overdue" overdue = false end #If item is not found to be out for a current event it will be "Overdue" end if overdue status = "Overdue" else status = "Out" end equipment.status = 0 else if self.events.last.end <= Time.now #End of last event has passed (is before Now), item is permanently "In" status = "In" else #End of last event has not passed (so there are events in the future), item is "Booked" status = "Booked" end equipment.status = 1 end else # If it is not signed in, it is "Out" or "Overdue" depending on time self.events.each do |ev| if (ev.start <= Time.now) & (ev.end >= Time.now) #Item is out for a current event, so status is "Out" not "Overdue" overdue = false end #If item is not found to be out for a current event it will be "Overdue" end if overdue status = "Overdue" else status = "Out" end equipment.status = 0 end else #Item not signed out status = "Booked" equipment.status = 1 end end equipment.save! status end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def availability\n STATUS_TO_AVAILABILITY[self.status]\n end", "def is_basic_equipment_status?\n type == 'EquipmentStatus'\n end", "def status\n return I18n.t('activerecord.attributes.item.building') if rq_prod_point > built_point\n if mob.blank?\n return I18n.t('activerecord.attributes.item.not_equiped')\n else\n return mob.name + I18n.t('activerecord.attributes.item.equiping')\n end\n end", "def booking_status\n 'Confirmed'\n end", "def check_status \n return self.status == :open_hotel_block\n end", "def status\n\t\t# puts \"Status #{@ip} ...\"\n\t\toutput = `#{ipmi_command} chassis power status`\n\t\t# p output\n\t\tif output =~ /on/\n\t\t\t@status = true\n\t\telsif output =~ /off/\n\t\t\t@status = false\n\t\tend\n\tend", "def status\n if @object.deadpooled_on\n 'deadpooled'\n elsif @object.acquired_by.any?\n 'acquired'\n elsif @object.initial_public_offering.present?\n 'IPOed'\n else\n 'alive'\n end\n end", "def get_status\n status_booking_response = hotel_service.get_status(params)\n service_reponse = process_response(status_booking_response, 'HotelItineraryResponse')\n if service_reponse[\"status\"] == OK\n response = JSON.parse(service_reponse[\"response\"])\n booking = response[\"HotelItineraryResponse\"]\n @booking_info = booking[\"Itinerary\"].except(\"HotelConfirmation\")\n hotels_confirmation = booking[\"Itinerary\"][\"HotelConfirmation\"]\n if hotels_confirmation.kind_of? Array\n @hotels_confirmation = hotels_confirmation\n @hotel_info = @hotels_confirmation.first[\"Hotel\"].first\n else\n @hotels_confirmation = []\n @hotels_confirmation << hotels_confirmation\n @hotel_info = hotels_confirmation[\"Hotel\"].first\n end\n\n respond_to do |format|\n format.html # get_status.html.erb\n format.xml { render :xml => @hotel }\n end\n else\n ##TODO: handle Errors here\n @error = service_reponse[\"error\"]\n respond_to do |format|\n format.html { render :template => \"shared/error\"}\n format.json { render :json => @error }\n end\n end\n end", "def good\n @status\n end", "def property_status(last_booking_event)\n last_booking_event.nil? || last_booking_event.type == 'BookingCheckedOut' ? 'empty' : 'occupied'\n end", "def reservation_status(start_date, location)\n check = location.reservations.where('start_date = ? ', start_date)\n\n return 'free' if check.empty?\n\n check.first.status\n end", "def reservation_status(start_date, location)\n check = location.reservations.where('start_date = ? ', start_date)\n\n return 'free' if check.empty?\n\n check.first.status\n end", "def warmer_plate_status; end", "def get_vehicle_status\n if (@age < 5)\n return \"a service.\"\n end\n return \"to be scrapped.\"\n end", "def status\n return STATUSES[:hidden] unless hit\n return STATUSES[:water] unless occupied?\n boat.sunk? ? STATUSES[:sunk] : STATUSES[:hit]\n end", "def status\n STATUSES[self.status_id]\n end", "def status\n @parcel.status\nend", "def get_reservation_status(reservation)\n owner = reservation.item_owner\n case reservation.status\n when \"pending_owner\"\n is_current_user?(owner) ? \"awaiting_acceptance_from_you\" : \"awaiting_acceptance_from_other_party\"\n when \"pending_reserver\"\n is_current_user?(owner) ? \"awaiting_acceptance_from_other_party\" : \"awaiting_acceptance_from_you\"\n else\n \"reservation_\" + reservation.status\n end \n end", "def status x\n system(\"clear\")\n puts x.center @lw\n puts\n puts ('USS ' + @shipname.capitalize + ' Command Interface').center(35)\n puts\n if @phasers\n puts 'Phasers: Armed'\n else\n puts 'Phasers: Disarmed'\n end\n\n if @photons\n puts 'Photon Torpedoes: Armed'\n else\n puts 'Photon Torpedoes: Disarmed'\n end\n\n if @shields\n puts 'Shields: Raised'\n else\n puts 'Shields: Lowered'\n end\n\n puts 'Alert: ' + @alert\n puts 'Engines: ' + @engines\n\n if @sensors == []\n puts 'Sensors: None Selected'\n else\n puts 'Sensors: ' + @sensors.join(', ')\n end\n\n select\n end", "def employee_wotc_status(employee_id)\n get(\"employees#{employee_id}/wotc/status\")\n end", "def availability\n end", "def availability\n end", "def get_status\n shipment= Shipment.find_by_tracking(params[:tracking_no])\n shipment.status if shipment\n end", "def status\n return 'Appealed' if self.punishment.appealed?\n return 'Closed' if !self.open || self.locked\n return 'Escalated' if self.escalated\n return 'Open'\n end", "def current_status\n return status if [:finished, :failed].include? status\n if address&.start_with?(\"0x\")\n state = HacksContract::Hackathon.new(address).state\n s = case state\n when 0\n :preparation\n when 1\n :crow_funding\n when 2\n :apply_participation\n when 3\n :gaming\n when 4\n :voting\n when 5\n :finished\n else\n :failed\n end\n else\n current = Time.now\n s = if current < crow_funding_start_at\n :preparation\n elsif current < apply_start_at\n :crow_funding\n elsif current < game_start_at\n :apply_participation\n elsif current < vote_start_at\n :gaming\n elsif current < finished_at\n :voting\n else\n :finished\n end\n end\n\n if s != status\n update_column(:status, s)\n end\n s\n end", "def state\n self.well_info.state\n end", "def status\n refund? ? 3 : redeemed? ? 1 : (used_status? ? 2 : 0)\n end", "def get_status\n send_command(0x79)\n end", "def get_status\n\t\tstatus\n\tend", "def find_status\n message = \"\"\n # If the auction is over, check if we won or lost\n if self.item[:get_item_response][:item][:time_left] == \"PT0S\" && self.auction_status != \"Deleted\"\n begin\n if self.item[:get_item_response][:item][:selling_status][:high_bidder][:user_id] == self.user.username\n self.auction_status = \"Won\"\n message = \"Congratulations! You won the auction for \\\"#{self.item[:get_item_response][:item][:title][0,113]}\\\"! :)\"\n else\n self.auction_status = \"Lost\"\n message = \"Sorry, but you have lost the auction for \\\"#{self.item[:get_item_response][:item][:title][0,113]}\\\". :(\"\n end\n rescue\n # There was no high_bidder, which means no one bid.\n self.auction_status = \"Lost\"\n message = \"Sorry, but you have lost the auction for \\\"#{self.item[:get_item_response][:item][:title][0,113]}\\\". :(\"\n end\n \n # Send out the notification of win/loss if the user wants it and hasn't been notified yet.\n if self.user_notification == \"Text Message\" && self.been_notified.to_s.split(\",\")[0] != self.id &&\n self.been_notified.to_s.split(\",\")[1] != self.auction_status.downcase\n Resque.enqueue(NotificationSender, self.id, message)\n self.been_notified = self.id.to_s + \",#{self.auction_status.downcase}\"\n end\n elsif self.auction_status != \"Deleted\"\n self.auction_status = \"Active\"\n end\n end", "def status\n monster = @game.current_room_model.monster\n return unless monster\n\n weapons = @game.player.weapons\n\n output = \"Fighting against #{monster.name}\\n\"\n weapons.each_with_index do |weapon, i|\n output << \"#{i + 1} - #{weapon}\\n\"\n end\n\n output\n end", "def derivedStatus\n\t\t# lets first get all the events to do this we need to:\n\t\t# 1. get all bet_item_clones for this ticket \n\t\t# 2. then for each clone we need to trickle up to its bet through its bet_item\n\t\t# 3. the bets are placed in an array\n\n\t\tstatus = \"Win\"\n\n\t\tbet_item_clones = self.bet_item_clones # --we have all bet_item we can see if all are true or false\n\n\t\tbets = Array.new\n\n\t\t\n\t\tbet_item_clones.each do |bet_item_clone|\n\t\t\tbets.push(bet_item_clone.bet_item.bet) \n\t\tend\n\n\t\tresults = Array.new\n\n\t\tbets.each do |bet|\n\t\t\tresults.push(bet.event.result) # -- we have all results we can see if any nill exists\n\t\t\tputs \"result: \" + bet.event.result\n\t\tend\n\n\t\tresults.each do |result|\n\t\t\tif result.nil? or result.blank? or result == \"\"\n\t\t\t\tstatus = \"Pending\" # if there is a pending result \n\t\t\tend\n\t\tend\n\t\tputs \"status after loop:\" + status\n\n\t\t if !(status.eql? \"Pending\") # the ticket is either a winning or losing ticket now\n\t\t \tstatus = \"Won\"\n\t\t \tbet_item_clones.each do |clone|\n\t\t \t\tif !(clone.bet_item.active)\n\t\t \t\t\tstatus = \"Lost\"\n\t\t \t\tend\n\t\t \tend\n\n\t\t end\n\n\t\t return status\n\tend", "def equipment; end", "def status\n if status_code.present?\n if status_code['HL7 ActStatus']\n status_code['HL7 ActStatus'].first()\n elsif status_code['SNOMED-CT']\n case status_code['SNOMED-CT'].first()\n when '55561003'\n 'active'\n when '73425007'\n 'inactive'\n when '413322009' \n 'resolved'\n end\n end\n end\n end", "def status\n status = stats.fetch @resource[:name], nil\n debug \"Got status: '#{status}'\"\n return :absent unless status\n return :present if [:present, :absent].include? @resource[:ensure]\n return :up if status == 'UP'\n return :down if status == 'DOWN'\n :present\n end", "def status\n @status ||= RecipeStatus.find status_id\n end", "def status\n return STATUS[:full] if next_fixed_shift_count >= max_attendants\n\n hours_diff = (next_fixed_shift - Chronic.parse(\"now\")) / 3600\n if hours_diff > close_inscription && hours_diff < open_inscription\n STATUS[:open]\n else\n STATUS[:close]\n end\n\n end", "def set_equipment_status\n @equipment_status = EquipmentStatus.find(params[:id])\n end", "def book_it\n unclaimed_reservation = rooms_available\n \n unclaimed_reservation.first.change_block_status\n \n return unclaimed_reservation.first\n end", "def status\n STATUSES[self.status_id || 0]\n end", "def status(act)\r\n extratext = \"\"\r\n moneytext = \"YOU HAVE NO MONEY\\n\"\r\n perkstext = \"\"\r\n help_text = \"\"\r\n\r\n if $strength <10\r\n extratext << \"WARNING, #{$name} , YOUR STRENGTH IS RUNNING LOW\\n\"\r\n end \r\n if $wealth >= 1\r\n moneytext = \"YOU HAVE $ #{$wealth}.\\n\"\r\n end\r\n if $food >= 1\r\n extratext << \"YOUR PROVISIONS SACK HOLDS #{$food} UNITS OF FOOD\\n\"\r\n end \r\n\r\n if $suit >= 1\r\n perkstext << \"YOU ARE WEARING ARMOR.\\n\"\r\n end\r\n\r\n if ($sword !=0 or $amulet !=0 or $axe !=0)\r\n perkstext << \"YOU ARE CARRYING \"\r\n if $sword >= 1\r\n perkstext << \"A SWORD \"\r\n end\r\n if $amulet >= 1\r\n if $sword != 0 and $axe != 0\r\n perkstext << \", \"\r\n elsif $sword != 0 and axe == 0\r\n perkstext << \"AND \"\r\n end\r\n perkstext << \"AN AMULET\"\r\n end\r\n\r\n if $axe >= 1\r\n if $sword != 0 or $amulet != 0\r\n perkstext << \" AND \"\r\n end\r\n perkstext << \"AN AXE\"\r\n end\r\n perkstext << \"\\n\"\r\n end\r\n\r\n if act == \"ROOM\" or act == \"GREETING\" or act == \"I\"\r\n if $light == 0 and $roomnumber != 6\r\n extratext << \"IT IS TOO DARK TO SEE ANYTHING\\n\"\r\n else\r\n extratext << \"#{room_descriptions_method} \\n\" \r\n end\r\n end\r\n\r\n if act == \"GREETING\"\r\n help_text = \"(YOU CAN PRESS H AT ANY MOMENT TO GET SOME HELP)\"\r\n end\r\n\r\n roomcontents = room_contents\r\n\r\n puts(\"#{$name}, YOUR STRENGTH IS #{$strength}.\\n#{moneytext}#{perkstext}\\n#{asterSick}\\n#{extratext}#{roomcontents}#{help_text}\\n\") \r\nend", "def status\n state = (active_instance.nil? ? 999 : active_instance.status)\n case state\n when 0 \n 'missing'\n when 1 \n 'none'\n when 2 \n 'pending'\n when 3 \n 'unready'\n when 4 \n 'failed'\n when 5 \n 'ready'\n when 666 \n 'deleted'\n when 999\n 'inactive'\n else \n 'hold'\n end\n end", "def status\n case @status\n when 0 then :off\n when 1 then :on\n end\n end", "def item_status!(item)\n item['status'] = item_status(item.fetch('loc_current', ''), item['loc_n'])\n if item['status'] == 'Available'\n if offsite?(item)\n item['status'] = 'Available upon request'\n elsif reserve?(item)\n item['status'] = 'Available - On Reserve'\n elsif kindle?(item)\n item['status'] = 'Available - Libraries Kindle only'\n end\n end\n item['status'] = item['status'] + ' (Library use only)' if library_use_only?(item)\n end", "def is_ep?\n @status\n end", "def outcome\n status.first\n end", "def get_book_info(book)\n if book.status = available\n\t\t puts \"#{book.title} is currently available\"\n else \n puts \"#{book.title} is currently checked out by #{user.checked_out_books} and is due in #{due_date} seconds\"\n\t end\n end", "def display_status\n busy? ? 'busy' : 'available'\n end", "def determine_status\n if opponent_board.present? and opponent_board.all_ships_are_sunk?\n \"You Win! Congratulations!\"\n elsif player_board.present? and player_board.all_ships_are_sunk?\n \"You Lose! Better luck next time...\"\n end\n end", "def get_item_availability(holding, item)\n # is_offsite = LOCATIONS['offsite_locations'].include? holding[:location_code]\n # if is_offsite\n if is_offsite_location_code?(holding[:location_code])\n self.fetch_scsb_availabilty unless @scsb_availability\n return @scsb_availability[ item[:barcode] ] if @scsb_availability.has_key?(item[:barcode])\n else\n # If we didn't find an offsite availability for this item, check Voyager availability\n self.fetch_voyager_availability unless @voyager_availability\n return @voyager_availability[ item[:item_id] ]\n end \n end", "def retrieve_status\n \n end", "def status\n output = StringIO.new\n output << @game.player.to_s\n output << \"\\n\"\n\n output << \"#{@game.current_room_model.description}\\n\"\n\n treasure = @game.current_room_model.treasure\n output << \"\\nThere is treasure here worth $#{treasure}.\\n\" if treasure && treasure > 0\n\n monster = @game.current_room_model.monster\n if monster\n output << \"\\nDANGER... THERE IS A MONSTER HERE....\\n\\n\"\n output << \"#{@game.current_room_model.monster}\\n\\n\"\n end\n\n if @game.current_room_model.name != \"Exit\"\n output << \"\\nWhat do you want to do? \"\n end\n \n output.string\n end", "def status\n @status\n end", "def status\n @status\n end", "def status\n Status.find(self.status_id).name\n end", "def get_status\n if draft\n :draft\n elsif closed || gross_amount <= paid_amount\n :closed\n elsif due_date and due_date > Date.today\n :opened\n else\n :overdue\n end\n end", "def getStatus\r\n\t\t\t\t\treturn @status\r\n\t\t\t\tend", "def friendly_status\n\n case self.status\n when \"no response\"\n \"You have not responded\"\n when \"reserve\"\n \"Reserved\"\n when \"decline\"\n \"Declined\"\n else\n \"Unknown\"\n end\n\n end", "def status\n @battery_reader.call\n end", "def current_status\n # Get current day and time\n current_day = Date.today.wday\n current_time = Tod::TimeOfDay.parse(Time.now.strftime(\"%H:%M:%S\"))\n # Get current day schedule\n schedule = self.location_schedules[current_day]\n open_time = Tod::TimeOfDay.parse(schedule.open_time)\n close_time = Tod::TimeOfDay.parse(schedule.close_time)\n # Verify if location is open\n (open_time <= current_time) && (current_time <= close_time) ? 'open' : 'close'\n end", "def status\n status = \"\"\n if points < 4000\n status = \"Baby Seeder\"\n elsif points < 8000\n status = \"Aspiring Gardener\"\n elsif points < 15000\n status = \"Garden Hero\"\n else\n status = \"Plant Wizard\"\n end\n end", "def status\n power_of_attorney = ClaimsApi::PowerOfAttorney.find_using_identifier_and_source(id: params[:id],\n source_name: source_name)\n raise ::Common::Exceptions::ResourceNotFound.new(detail: 'Resource not found') unless power_of_attorney\n\n render json: power_of_attorney, serializer: ClaimsApi::PowerOfAttorneySerializer\n end", "def fo_tool\n return actor.equips[0] if actor.primary_use == 1\n return actor.equips[1] if actor.primary_use == 2\n return actor.assigned_item if actor.primary_use == 3\n return actor.assigned_item2 if actor.primary_use == 4\n return actor.assigned_item3 if actor.primary_use == 5\n return actor.assigned_item4 if actor.primary_use == 6\n return actor.assigned_skill if actor.primary_use == 7\n return actor.assigned_skill2 if actor.primary_use == 8\n return actor.assigned_skill3 if actor.primary_use == 9\n return actor.assigned_skill4 if actor.primary_use == 10\n end", "def status\n\t\treturn @status\n\tend", "def status\n if complete?\n \"PAID\"\n else\n \"PENDING\"\n end\n end", "def status\n # You can also check the status of each field, which is a more direct way of observing the status of your fields (their size and type). It should also tell you how much total food you have produced up until this point.\n Crop.status\n end", "def opportunity_availability_friendly(opportunity)\n if opportunity.availability == 0\n 'Tiempo completo'\n elsif opportunity.availability == 1\n 'Medio tiempo'\n elsif opportunity.availability == 2\n 'Menos de 20 horas por semana'\n end\n end", "def status_panel(equipment, notification_level = 'primary')\n last_status = equipment.statuses.last\n render 'batches/equipment_status_panel',\n equipment: {\n title: equipment.panel_title,\n status: status_indicator_label_text(last_status),\n label: status_indicator_label_type(last_status),\n notification: notification_level\n }\n end", "def status\n info['status']\n end", "def status\n \"#{@description} #{@status}\"\n end", "def on_hold?\n status == :inactive\n end", "def check_cell_status(x_coord, y_coord)\n\t\treturn @state[x_coord][y_coord].content\n\tend", "def status_of(assignment_name)\n assignment_row(assignment_name).td(:headers=>\"status\").text\n end", "def isolated?\n attributes['status'] == 7\n end", "def status\n result = \"online\"\n if Current.room.ready? && Current.room.poker_records.find_by(user_id: object.id).present?\n result += \" played\"\n end\n result\n end", "def status\n case status_id\n when ReferenceData::PO_ITEM_PREPARING\n \"<em style='color:red'>Ordering</em>\"\n when ReferenceData::PO_ITEM_SENT_TO_CENTRAL\n \"<em style='color:brown'>Sent to Central</em>\"\n when ReferenceData::PO_ITEM_SENT_TO_SUPPLIER\n \"<em style='color:green'>Sent to PO</em>\"\n when ReferenceData::PO_ITEM_UNCATEGORIZED\n \"<em style='color:red'>Uncategorized</em>\"\n end\n \n end", "def status\n if self.started_at.nil? and self.stopped_at.nil?\n 'Pending'\n elsif self.started_at.present? and self.stopped_at.nil?\n 'Active'\n elsif self.started_at.present? and self.stopped_at.present?\n 'Completed'\n end\n end", "def status\n @attributes[:status]\n end", "def status\n @attributes[:status]\n end", "def status\n @attributes[:status]\n end", "def status\n @attributes[:status]\n end", "def get_status\n if draft\n :draft\n elsif paid\n :paid\n elsif due_date\n if due_date > Date.today\n :pending\n else\n :overdue\n end\n else\n # An invoice without a due date can't be overdue\n :pending\n end\n end", "def get_status\n if criteria_type == Constants::CRITERIA_TYPE_PASS_FAIL\n temp_status = status\n else\n temp_status = point.zero? ? Constants::CRITERIA_STATUS_FAILED : Constants::CRITERIA_STATUS_PASSED\n end\n temp_status\n end", "def status(book)\n\t\tif book.status == \"available\"\n\t\t\tputs \"#{book.title} is not checked out.\"\n\t\telse\n\t\t\tputs \"#{book.title} is checked out. Please try again later.\"\t\t\n\t\tend \n\tend", "def getStatus\n @status\n end", "def assignment_status(assignment)\n if self.student_assignments.where('student_id = ?', self.id).where(\"assignment_id = ?\", assignment.id)[0][:status] == false\n \"Incomplete\"\n else\n \"Completed\"\n end\n end", "def show_status\r\n puts \"Status for room #{id}:\"\r\n if @contents.empty?\r\n puts \" The room is empty.\"\r\n else\r\n puts \" Contents: #{sorted_contents.join(', ')}\"\r\n end\r\n if @exits.empty?\r\n puts \" No exits.\"\r\n else\r\n doors = []\r\n doors << 'north' if @exits[:north]\r\n doors << 'south' if @exits[:south]\r\n doors << 'east' if @exits[:east]\r\n doors << 'west' if @exits[:west]\r\n puts \" There are exits to the #{doors.join(', ')}.\"\r\n end\r\n end", "def status\n if params['fraud_status'] == 'pass' || params['credit_card_processed'] == 'Y'\n 'Completed'\n elsif params['fraud_status'] == 'wait'\n 'Pending'\n else\n 'Failed'\n end\n end", "def determine_status(mfhd_status)\n\n unavailable_count = 0\n mfhd_status.each do |item_id, item|\n statusCode = item[:statusCode].to_i\n unavailable_count += 1 if statusCode > 1 && statusCode != 11\n end\n\n case\n when unavailable_count == 0\n return 'available'\n when unavailable_count == mfhd_status.size\n return 'not_available'\n else\n return 'some_available'\n end\n\n\n # # assume available\n # status = 'available'\n # unavailable = 0\n # # if statusCode > 1 some item status is set so some item may not be available; 11 (returned) is the exception\n # records.each { |record| unavailable += 1 if record[:statusCode].to_i > 1 && record[:statusCode].to_i != 11 }\n # unless unavailable == 0\n # if unavailable == item_count.to_i\n # status = 'not_available'\n # else\n # status = 'some_available'\n # end\n # end\n # \n # status\n\n end", "def status\n if caberawit?\n 'caberawit'\n elsif praremaja?\n 'praremaja'\n elsif remaja?\n 'remaja'\n elsif dewasa?\n 'dewasa'\n end\n end", "def intervention?\n self.status == \"Intervention\"\n end", "def status\n @status\n end", "def status\n @status\n end", "def get_status\n fetch_status unless status == :completed\n status\n end", "def get_status\n fetch_status unless status == :completed\n status\n end", "def status\n @browser.span(:css => field_cell_css(:name) + \" .status\").when_present.text\n end", "def status\n params[\"Status\"]\n end", "def residential_status\n if @filing_info.residentialStatus1 == \"RES\"\n return FilingInfo::RESIDENTIAL_STATUS.fetch(0).fetch(0)\n elseif @filing_info.residentialStatus1 == \"NRI\"\n return FilingInfo::RESIDENTIAL_STATUS.fetch(1).fetch(0) \n else @filing_info.residentialStatus1 == \"NOR\"\n return FilingInfo::RESIDENTIAL_STATUS.fetch(2).fetch(0) \n end \n end", "def extract_arrived_aircraft_status(section)\n # We are aiming at find detail string in a structure like:\n # ...\n # <th ...>Status</th>\n # <td ...>\n # <span ...>Arrived at gate 33 minutes ago ...</span>\n # ...\n # </td>\n # ...\n # ...\n #\n # happen to be same as the other function.\n extract_aircraft_status_raw_text(section).gsub(' (track log & graph)', '')\n end", "def status\n instance_get(:status)\n end" ]
[ "0.6663784", "0.66445756", "0.63720214", "0.63123393", "0.6297724", "0.6172591", "0.6144509", "0.60678864", "0.6031442", "0.60260904", "0.6020678", "0.6020678", "0.6000286", "0.5986241", "0.5950257", "0.5937592", "0.5923177", "0.5901572", "0.58922786", "0.58764285", "0.5876188", "0.5875904", "0.5869202", "0.58625305", "0.58485496", "0.5838362", "0.5833756", "0.5807042", "0.5805533", "0.5791801", "0.57867026", "0.57817847", "0.5767987", "0.5761096", "0.5759347", "0.5727869", "0.5717437", "0.5717435", "0.57105416", "0.5707957", "0.5702337", "0.5697293", "0.56873727", "0.56775683", "0.56701505", "0.5660233", "0.5647055", "0.5643419", "0.5640053", "0.5637478", "0.5629956", "0.56199783", "0.56177086", "0.56177086", "0.5610863", "0.56074864", "0.55886966", "0.55816454", "0.5576495", "0.5563282", "0.5563264", "0.55594766", "0.55344784", "0.5533197", "0.55314255", "0.5528126", "0.5526086", "0.5522331", "0.5518601", "0.55159605", "0.55152845", "0.55099756", "0.5508993", "0.5504431", "0.5501293", "0.5497381", "0.54941106", "0.54936475", "0.54936475", "0.54936475", "0.54936475", "0.54923016", "0.54883575", "0.54828495", "0.54807234", "0.5479159", "0.54742503", "0.5469829", "0.54659265", "0.54652995", "0.54628664", "0.54624903", "0.54624903", "0.5460312", "0.5460312", "0.5459623", "0.5452891", "0.5450837", "0.54463106", "0.54426163" ]
0.6505924
2
GET /keywords GET /keywords.json
def index @user_keywords = @login_user.user_keywords.includes(:keyword).group_by{|u_k| u_k.keyword.category} end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def call\n Success(\n JSON.parse(decode(@params['keywords']))\n )\n rescue StandardError\n Failure(\n Response::ApiResult.new(\n status: :bad_request,\n message: 'Keywords not found'\n )\n )\n end", "def index\n @keywords = Keyword.order(\"name asc\").all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @keywords }\n end\n end", "def keyword_autocomplete\n search_keyword = params[\"search\"]\n similar_keywords =\n Keyword.get_similar_keywords(search_keyword, [])\n similar_keywords.map! { |keyword| keyword.name }\n render json: similar_keywords\n end", "def keywords\n response = request :keywords\n keywords = Hash.new\n response[\"labels\"].each do |label|\n keywords[label[\"keyword\"]] = label[\"content\"]\n end\n keywords\n end", "def index\n @search = Keyword.search(params[:search])\n @keywords = @search.paginate(:page => params[:page], :per_page => GlobalSettings.per_page).order('id DESC')\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @keywords }\n end\n end", "def get_keywords(query_obj=nil)\n uri = URI.parse(@uri + \"/Keywords\")\n results = get(uri,query_obj)\n end", "def index\n @keywords = Keyword.all\n end", "def index\n @keywords = Keyword.all\n end", "def index\n @keywords = Keyword.all\n end", "def index\n @keywords = Keyword.all\n end", "def index\n @keywords = Keyword.all\n end", "def index\n @keywords = Keyword.all\n end", "def index\n @keywords = Keyword.all\n end", "def list_keywords\n @entry = Entry.find(params[:id])\n @keywords = @entry.keywords\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @keywords }\n end\n rescue ActiveRecord::RecordNotFound => e\n prevent_access(e)\n end", "def index\r\n params[:page] = params[:page].blank? ? 1 : params[:page]\r\n @category = KeywordCategory.find(params[:cat]) unless params[:cat].blank?\r\n\r\n if @category\r\n @keywords = @category.keywords\r\n sort_keywords unless @category.sorted_keywords.blank?\r\n else\r\n @keywords = Keyword.includes([:keyword_category]).order_by(:title.asc).page(params[:page]).per(20).cache\r\n end\r\n\r\n respond_to do |format|\r\n format.html # index.html.erb\r\n format.xml { render :xml => @keywords }\r\n format.json { render :json =>@keywords }\r\n end\r\n end", "def show\n @keywords = Keyword.all\n end", "def search_all_terms\n render json: Article.with_all_terms(params[:query]).map(&:title)\n end", "def keywords\n\t\t\treturn @data['keywords']\n\t\tend", "def rest_keywords; end", "def get_keywords_for_text(retina_name, body)\n resource_path = '/text/keywords'\n verb = 'POST'\n query_params = { 'retina_name' => retina_name }\n post_data = body\n headers = {'Accept' => 'Application/json', 'Content-Type' => 'application/json'}\n\n response = @api_client.call_api(resource_path, verb, query_params,post_data, headers)\n\n JSON.parse(response.body, symbolize_names: true)\n end", "def show\n @keyword = Keyword.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @keyword }\n end\n end", "def show\n @keyword = Keyword.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @keyword }\n end\n end", "def search\n terms = @authority.search(url_search)\n render json: terms\n end", "def keyword_params\n ActiveModelSerializers::Deserialization.jsonapi_parse(params, only: [:keyword, :collection_id, :id])\n end", "def search\n expose Challenge.search(@oauth_token, params[:keyword])\n end", "def keywords\n get_keywords.flatten.uniq\n end", "def index\n @keywords = Keyword.rank.page params[:page]\n @keyword_indices = KeywordIndex.all\n end", "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 @spec_keywords = SpecKeyword.all\n end", "def keyword_params\n params.fetch(:keyword, {})\n end", "def get_keywords(site)\n response = Net::HTTP.get_response(site, \"/\")\n Hpricot(response.body).\n search(\"meta[@name='keywords']\")[0]. #Select meta keywords element\n attributes[\"content\"]. #Select its content\n split(\",\"). #Keywords are coma separated\n collect{ |k| k.strip.downcase } #Remove start and end white spaces\nend", "def search_any_term\n render json: Article.with_any_terms(params[:query]).map(&:title)\n end", "def search keyword, opts = {}\n get '/v1/search/illust', {\n **SEARCH_DEFAULT_OPT,\n word: keyword,\n **opts\n }\n end", "def search\n spotyfy_client = SpotyfyClient.new(params[:search])\n spotyfy_client.perform\n items = SpotyfyService.parse_hash(spotyfy_client.body)\n render :json => items.to_json\n end", "def keywords\n keywords = []\n metadata[dataset_uri][dcat.keyword.to_s].each do |k|\n keywords << k\n end\n rescue\n []\n end", "def search #recipes_search_path\n #binding.pry\n @keywords = params['keywords']\n if @keywords.blank?\n redirect_to root_path\n else\n @number_of_recipes = EdamamApiWrapper.find_number_of_recipes(@keywords)\n @recipes = EdamamApiWrapper.list_recipes(@keywords, 0, 9)\n end\n end", "def keywords\n [self.keyword]\n end", "def get_keywords\r\n\t@keywords = Keyword.all\r\n\t@keywords.sort! { |a, b| a.name <=> b.name }\r\n end", "def index\n @keywords = Keyword.order('title')\n \n respond_to do |format|\n format.html # index.rhtml\n format.xml { render :xml => @keywords.to_xml }\n end\n end", "def search\n @links = Link.search do\n keywords params[:query]\n end.results\n\n respond_to do |format|\n format.html { render :action => \"index\" }\n format.json { render :json => @links }\n end\n end", "def content_by_keyword(keyword)\n x = keyword.gsub(\" \", \"%20\")\n JSON.parse(self.class.get(\"#{x}\" + \"#{@token}\").body)\n end", "def keywords\n read_attribute(:keywords).to_a.compact.map(&:downcase)\n end", "def index\n @suspicious_keywords = SuspiciousKeyword.all\n end", "def keywords\n @keywords_accessed = true\n @keywords\n end", "def keywords(keywords)\n ensure_valid_parameter('keywords', keywords, lambda {|k| k.is_a? Array or k.is_a? String})\n keywords = keywords.join(' ') if keywords.is_a? Array\n @request[:keywords] = keywords\n self\n end", "def index\n @keywords = Keyword.all\n\n # @new_kw = Keyword.new\n# \n # @new_kw.words = \"米国 米 アメリカ\"\n # @new_kw.save\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @keywords }\n end\n end", "def search_keywords\n @developer_id = Developer.find_by_gamer_id(current_gamer.id).id\n @projects = Project.where(owner_id: @developer_id).all\n @project_id = params[:project_id]\n @search_keyword = params[\"search\"]\n if(!@search_keyword.blank?)\n @search_keyword = @search_keyword.strip\n @search_keyword = @search_keyword.split(\" \").join(\" \")\n if Keyword.find_by_name(@search_keyword)\n redirect_to search_path, search: @search_keyword\n end\n @similar_keywords =\n Keyword.get_similar_keywords(@search_keyword, [])\n end\n end", "def keywords\n ks = Keyword.where(meta_key_id: id)\n if keywords_alphabetical_order\n ks.order('keywords.term ASC')\n else\n ks.order('keywords.position ASC')\n end\n end", "def search_by_keyword\n space(1)\n puts \"What do you want to search for?\"\n space(1)\n keyword = get_input\n url = \"https://app.ticketmaster.com/discovery/v2/events?apikey=pyLDDCYURYJ8LZfAUnOayESRsPBTWnKM&keyword=#{keyword}&locale=en&sort=date,asc\"\n response = RestClient.get(url)\n if JSON.parse(response)[\"_embedded\"][\"events\"]\n attractions = JSON.parse(response)[\"_embedded\"][\"events\"]\n attractions[0...20]\n else\n puts \"Sorry, your search returned no results. Try again.\"\n search_by_city\n end\nend", "def search\n cookies[:dance] = false\n cookies[:party] = false\n cookies[:weather] = \"\"\n cookies[:feeling] = \"\"\n cookies[:genre] = \"\"\n cookies[:search] = params[:word]\n\n @tracks = TracksHelper::Track.lyrics_keywords(params[:word])\n\n\n respond_to do |format|\n if @tracks.length > 0\n format.html {render :show, layout: false}\n format.json {render json: @tracks.map{|track| track.as_json.slice(\"title\", \"artist_name\", \"track_youtube_id\")}}\n else\n flash[:danger] = 'There was a problem'\n format.html { render :_no_results, layout: false }\n end\n end\n end", "def keyword_params\n # params.fetch(:keyword, {})\n params.require(:keyword)\n end", "def search_keywords\n @categories = params[:categories]\n @project_id = params[:project_id]\n if @categories.present?\n categories_array = @categories.split(/,/)\n categories_array.map! { |x| x.strip }\n categories_array.reject! { |x| x.blank? }\n categories_array.uniq!\n else\n categories_array = []\n end\n @search_keyword = params[\"search\"]\n if(!@search_keyword.blank?)\n @search_keyword = @search_keyword.strip\n @search_keyword = @search_keyword.split(\" \").join(\" \")\n end\n @similar_keywords =\n Keyword.get_similar_keywords(@search_keyword, categories_array)\n @categories = categories_array.join(\", \")\n end", "def search\n @search = Sunspot.search(Job) do\n keywords(params[:searchterm])\n end\n end", "def keyword_params\n params.require(:keyword).permit(:name)\n end", "def keyword_params\n params.require(:keyword).permit(:name)\n end", "def extract_keyword_sentiment\n # Build the request URL for the API call\n endpoint = BASE_URL + \"calls/url/URLGetRankedNamedEntities\"\n request_params = options.to_query\n request_url = [endpoint, request_params].join(\"?\")\n\n # Make the request\n @response = HTTParty.get request_url\n\n # If results are returned, traverse the response and return keyword data\n # Keyword data is in @response[\"results\"][\"keywords\"][\"keyword\"] as of 6/12/14\n %w( results entities entity ).reduce(response) do |data, key|\n return nil unless data[key]\n data = data[key]\n end\n end", "def show\n @keyword = Keyword.find(params[:id])\n \n drop_breadcrumb(@keyword.name, admin_keyword_path(@keyword))\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @keyword }\n end\n end", "def suggestion_search\n keywords = params[:q]\n keywords = Utils.nomalize_string(keywords)\n\n if keywords.include? '-'\n keywords = keywords.gsub! '-', \" \"\n end\n\n pattern = /#{Regexp.escape(keywords)}/i\n\n users = User.or({:name => pattern}, {:email => pattern}).map { |user|\n UserSerializer.new(user).suggestion_search_hash\n }\n\n render json: users, root: false\n return\n end", "def dame_keyword\n k = Metamares::Keyword.new\n k.nombre_keyword = params[:nombre_keyword]\n\n respond_to do |format|\n format.json { render json: k.busca_keyword.map{ |k| { id: k.nombre_keyword, value: k.nombre_keyword } } }\n format.html { @keyword = k }\n end\n end", "def show\n @keyword = Keyword.find(params[:id])\n end", "def keywords(page_keywords) \n content_for(:keywords){\"<meta name=\\\"keywords\\\" content=\\\"#{page_keywords}\\\" />\\n\"} \n end", "def keywords\n plot_keywords.css(\"a[href^='/keyword/']\").map { |keyword| keyword.text.strip } rescue []\n end", "def search_keywords(*keywords)\n params = keywords.last.is_a?(Hash) ? keywords.pop : {:SearchIndex => :Books, :ResponseGroup => :Medium}\n response = call(params.merge(:Operation => :ItemSearch, :Keywords => keywords.join(' ')))\n arrayfy(response['ItemSearchResponse']['Items']['Item']).map {|item| handle_type(item, :item)}\n end", "def keywords\n my_nodes_tagged(:querykeywordexpr)\n end", "def keywords\n my_nodes_tagged(:querykeywordexpr)\n end", "def keywords\n @entries.keys.sort # sorts keys to alphabetical \n end", "def create_keywords(data=nil,generate_objects=false)\n uri = URI.parse(@uri + \"/Keywords\")\n results = post(uri,data,generate_objects)\n end", "def getAutocompleteKeyword( str, language)\n params = Hash.new\n params['str'] = str\n params['language'] = language\n return doCurl(\"get\",\"/autocomplete/keyword\",params)\n end", "def content_by_exact(keyword)\n JSON.parse(self.class.get(\"#{\"keyword\"}\" + \"#{@token}\").body)\n end", "def get_project_keywords(query_obj=nil)\n uri = URI.parse(@uri + \"/ProjectKeywords\")\n results = get(uri,query_obj)\n end", "def get(keyword)\n # Create URL to Yandex.Xml\n xml_url = create_url(keyword)\n # Get data XML\n xml = Net::HTTP.get_response(URI.parse(xml_url)).body\n # Convert XML to Hash\n converter = Nori.new(:convert_dashes_to_underscores => true)\n hash = converter.parse(xml)\n # Convert Hash to OpenStruct\n data = JSON.parse(hash.to_json, object_class: OpenStruct)\n # Create short route to data\n groups = data.yandexsearch.response.results.grouping.group\n\n result = {}\n\n result[:meta] = {\n keyword: data.yandexsearch.request.query,\n timestamp: Time.now\n }\n\n data_array = []\n\n groups.each_with_index do |i, index|\n result_hash = {\n position: index + 1,\n url: i.doc.url,\n domain: i.doc.domain,\n title: i.doc.title,\n modtime: i.doc.modtime,\n size: i.doc.size,\n charset: i.doc.charset,\n # passage: i.doc.passages.passage, # TODO: not work\n passages_type: i.doc.properties._PassagesType,\n mime_type: i.doc.mime_type,\n saved_copy_url: i.doc.saved_copy_url,\n headline: i.doc.headline,\n turbo_cgi_url: i.doc.properties.TurboCgiUrl,\n turbo_fallback: i.doc.properties.TurboFallback,\n turbo_link: i.doc.properties.TurboLink\n }\n\n data_array << result_hash\n end\n\n result[:data] = data_array\n result\n end", "def the_keywords\n k = object.get_option(\"keywords\", \"\")\n k = h.current_site.the_keywords if object.class.name != \"CamaleonCms::Site\" && !k.present?\n k.to_s.translate(get_locale)\n end", "def keywords(page_keywords)\n content_for(:keywords) do\n \"<meta name=\\\"keywords\\\" content=\\\"#{page_keywords}\\\" />\\n\"\n end\n end", "def keywords(page_keywords)\n content_for(:keywords) do\n \"<meta name=\\\"keywords\\\" content=\\\"#{page_keywords}\\\" />\\n\"\n end\n end", "def search(keyword)\n req_str = \"#{TECHNET}/security/bulletin/services/GetBulletins?\"\n req_str << \"searchText=#{keyword}&\"\n req_str << 'sortField=0&'\n req_str << 'sortOrder=1&'\n req_str << 'currentPage=1&'\n req_str << 'bulletinsPerPage=9999&'\n req_str << 'locale=en-us'\n\n res = send_http_get_request(req_str)\n begin\n return JSON.parse(res.body)\n rescue JSON::ParserError\n end\n\n {}\n end", "def index\n @search_keywords = SearchKeyword.where(team_id: params[:team_id])\n end", "def get_keywords(input_text, relevance)\n\tkeywords = Keyword.extract(input_text)\n\trelevant_words = keywords.select {|w| w[\"text\"] if w[\"relevance\"].to_f > relevance }\n\treturn relevant_words.map{|w| w[\"text\"]}\nend", "def keyword_params\n params.require(:keyword).permit(:name, :course)\n end", "def keyword_params\n params.require(:keyword).permit(:article_id, :keyword)\n end", "def keyword_params\n params.require(:keyword).permit(:article_id, :keyword)\n end", "def search_request(user_id, keywords)\n keyword_queries = keywords.map do |keyword|\n {\n bool: {\n should: [\n { term: { title: keyword.downcase } },\n { term: { content: keyword.downcase } }\n ]\n }\n }\n end\n\n __elasticsearch__.search(\n query: {\n bool: {\n must: keyword_queries\n }\n },\n filter: {\n term: {\n user_id: user_id\n }\n },\n sort: [\n {\n created_at: {\n order: 'desc'\n }\n }\n ],\n size: ES_LIMIT_SIZE\n )\n end", "def search\n search_param = params[:term]\n matching_keys = UserKey.submitted.search(search_param).collect { |u| { value: \"#{u.name}\", data: u.id } }\n render json: { suggestions: matching_keys }\n end", "def search\n @google = Rails.application.secrets.google_api_key\n puts query[\"query\"]\n @response = HTTParty.get(\"https://www.googleapis.com/books/v1/volumes?q=#{query[\"query\"]}&key=#{@google}\")\n render json: {data: @response}\n end", "def keywords\n if @model\n return @keywords || @model.keywords || Keywords.empty_keywords\n end\n @keywords || Keywords.empty_keywords\n end", "def search_for(keywords, options = {})\n solr_server.find(keywords, options.merge(:results => PublicEarth::Search::CollectionResults))\n end", "def search\n @quotes = QuoteCrawler.search_crawler(params[:search_tag])\n render json: @quotes, status: :ok\n end", "def show_keywords (url, keywords)\n if keywords.nil?\n puts \"Warning: (#{url}) needs keywords.\"\n else\n puts \"The url's (#{url}) Keywords are:\" \n keywords.split(',').each do |keyword|\n puts \"keyword: #{keyword}\"\n end\n end\nend", "def keyword_params\n params.require(:keyword).permit(:title, :description)\n end", "def create_keyword_lists(options = {})\r\n # Prepare query url.\r\n _query_builder = Configuration.base_uri.dup\r\n _query_builder << '/keyword/lists.json'\r\n _query_url = APIHelper.clean_url _query_builder\r\n\r\n # Prepare form parameters.\r\n _parameters = {\r\n 'page' => options['page'],\r\n 'pagesize' => options['pagesize'],\r\n 'Keyword' => options['keyword'],\r\n 'Shortcode' => options['shortcode']\r\n }\r\n _parameters = APIHelper.form_encode_parameters(_parameters)\r\n\r\n # Prepare and execute HttpRequest.\r\n _request = @http_client.post(\r\n _query_url,\r\n parameters: _parameters\r\n )\r\n BasicAuth.apply(_request)\r\n _context = execute_request(_request)\r\n validate_response(_context)\r\n\r\n # Return appropriate response type.\r\n _context.response.raw_body\r\n end", "def keyword_params\n params.require(:keyword).permit(:site_id, :word)\n end", "def keywords\n xml.css('keyword').map{|c| Allorails::Keyword.new(c)}\n end", "def show\n @keywords = @report.keywords\n end", "def list\n if params[:keyword]\n name_pattern = \"%#{params[:keyword]}%\"\n else\n name_pattern = \"#{params[:letter]}%\"\n end\n \n @entities = GetText::Db::Entity.find(\n :all,\n :conditions => ['name like ?', name_pattern]\n )\n end", "def prefix_search\n @tags = Tag.where(\"name LIKE :prefix\", prefix: \"#{params.permit(:s)[:s]}%\")\n render json: @tags.collect{|tag| tag.strip}\n end", "def required_keywords; end", "def render_keywords(tags)\n keywords = TextNormalizer.normalize_keywords(meta_tags.extract(:keywords))\n normalized_meta_tags[:keywords] = keywords\n tags << Tag.new(:meta, :name => :keywords, :content => keywords) if keywords.present?\n end", "def new\n @keyword = Keyword.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @keyword }\n end\n end", "def new\n @keyword = Keyword.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @keyword }\n end\n end", "def keywords\n @emphasis[:stemming] = use_stemming?\n\n keywords = Keywords.new\n\n Keywords.find_keywords(processed_content, wordlist, word_pattern).each do |text|\n text = text.to_s\n text = text.stem if @emphasis[:stemming]\n\n if not (text.match(/^[\\d]+(\\.[\\d]+){0,1}$/) or text.length <= 2)\n keywords << Highscore::Keyword.new(text, weight(text))\n elsif allow_short_words\n keywords << Highscore::Keyword.new(text, weight(text))\n end\n end\n\n keywords\n end", "def suggest\n @result = Artist.search( params[:term] )\n \n respond_to do |format|\n format.html\n format.json { render :json => @result }\n end\n end", "def BuildKeywords(query, index, hits)\n assert { query.instance_of? String }\n assert { index.instance_of? String }\n assert { hits.instance_of?(TrueClass) || hits.instance_of?(FalseClass) }\n \n # build request\n request = Request.new\n # v.1.0 req\n request.put_string query # req query\n request.put_string index # req index\n request.put_int hits ? 1 : 0\n\n response = PerformRequest(:keywords, request)\n \n # parse response\n begin\n res = []\n nwords = response.get_int\n 0.upto(nwords - 1) do |i|\n tokenized = response.get_string\n normalized = response.get_string\n \n entry = { 'tokenized' => tokenized, 'normalized' => normalized }\n entry['docs'], entry['hits'] = response.get_ints(2) if hits\n \n res << entry\n end\n rescue EOFError\n @error = 'incomplete reply'\n raise SphinxResponseError, @error\n end\n \n return res\n end" ]
[ "0.7787767", "0.74239135", "0.74185944", "0.7270267", "0.7241232", "0.7170488", "0.7048936", "0.7048936", "0.7048936", "0.7048936", "0.7048936", "0.7048936", "0.7048936", "0.68914783", "0.68455505", "0.68270147", "0.6742713", "0.67107964", "0.6705525", "0.6669747", "0.66688883", "0.66688883", "0.6521068", "0.64809364", "0.6443734", "0.6441739", "0.6438608", "0.64058137", "0.6395742", "0.6386266", "0.63783014", "0.6369715", "0.6351217", "0.6339488", "0.6333212", "0.633255", "0.63273567", "0.6316998", "0.6238263", "0.619848", "0.6197538", "0.6194468", "0.61793816", "0.61725706", "0.61714", "0.6160636", "0.615789", "0.6157377", "0.61418337", "0.614015", "0.61189467", "0.6110974", "0.60778916", "0.6072107", "0.6072107", "0.60715014", "0.60652894", "0.60620236", "0.6051526", "0.60416853", "0.6031876", "0.602428", "0.6021648", "0.6016664", "0.6016664", "0.6000724", "0.59746605", "0.59708047", "0.5967849", "0.59594625", "0.5955261", "0.59527063", "0.5930412", "0.5930412", "0.591743", "0.5916784", "0.5894391", "0.58932257", "0.5888639", "0.5888639", "0.5886559", "0.588092", "0.58740795", "0.58715266", "0.5862591", "0.58428764", "0.5830222", "0.5823481", "0.5817655", "0.58158237", "0.58121985", "0.58105147", "0.58076715", "0.5802366", "0.5798661", "0.5792502", "0.57845414", "0.57677853", "0.5764622", "0.5764574", "0.57636195" ]
0.0
-1
POST /keywords POST /keywords.json
def create Keyword.transaction do @keyword = Keyword.where(:value => params[:keyword][:value], :category => params[:keyword][:category]).first if @keyword.blank? @keyword = Keyword.new(params[:keyword].permit(:value, :category)) @keyword.save end if @keyword.user_keywords.where(:user_id => @login_user.id).count > 0 forbidden else @user_keyword = @keyword.user_keywords.create(:user_id => @login_user.id) end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def call\n Success(\n JSON.parse(decode(@params['keywords']))\n )\n rescue StandardError\n Failure(\n Response::ApiResult.new(\n status: :bad_request,\n message: 'Keywords not found'\n )\n )\n end", "def create_keywords(data=nil,generate_objects=false)\n uri = URI.parse(@uri + \"/Keywords\")\n results = post(uri,data,generate_objects)\n end", "def keyword_params\n params.require(:keyword).permit(:name)\n end", "def keyword_params\n params.require(:keyword).permit(:name)\n end", "def create\n @keyword = Keyword.new(params[:keyword])\n\n respond_to do |format|\n if @keyword.save\n format.html { redirect_to @keyword, notice: 'Keyword was successfully created.' }\n format.json { render json: @keyword, status: :created, location: @keyword }\n else\n format.html { render action: \"new\" }\n format.json { render json: @keyword.errors, status: :unprocessable_entity }\n end\n end\n end", "def keywords(keywords)\n ensure_valid_parameter('keywords', keywords, lambda {|k| k.is_a? Array or k.is_a? String})\n keywords = keywords.join(' ') if keywords.is_a? Array\n @request[:keywords] = keywords\n self\n end", "def create\n @keyword = Keyword.new(keyword_params)\n\n respond_to do |format|\n if @keyword.save\n format.html { redirect_to @keyword, notice: 'Keyword was successfully created.' }\n format.json { render :show, status: :created, location: @keyword }\n else\n format.html { render :new }\n format.json { render json: @keyword.errors, status: :unprocessable_entity }\n end\n end\n end", "def keyword_params\n params.require(:keyword).permit(:title, :description)\n end", "def create\n @suspicious_keyword = SuspiciousKeyword.new(suspicious_keyword_params)\n\n respond_to do |format|\n if @suspicious_keyword.save\n format.html { redirect_to @suspicious_keyword, notice: 'Suspicious keyword was successfully created.' }\n format.json { render action: 'show', status: :created, location: @suspicious_keyword }\n else\n format.html { render action: 'new' }\n format.json { render json: @suspicious_keyword.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @keywords = Keyword.all\n\n # @new_kw = Keyword.new\n# \n # @new_kw.words = \"米国 米 アメリカ\"\n # @new_kw.save\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @keywords }\n end\n end", "def keyword_params\n params.require(:keyword).permit(:article_id, :keyword)\n end", "def keyword_params\n params.require(:keyword).permit(:article_id, :keyword)\n end", "def keyword_params\n params.require(:keyword).permit(:site_id, :word)\n end", "def create\n @idea = Idea.new(idea_params)\n keyword_ids = params[:idea][:keyword_ids]\n keywords =\n Keyword.select do |k|\n keyword_ids.include? k.id.to_s\n end\n if @idea.save\n @idea.keywords << keywords\n redirect_to @idea\n else\n @keywords = Keyword.all\n respond_to do |format|\n format.html { render action: 'new' }\n format.json { render json: @idea.errors, status: :unprocessable_entity }\n end\n end\n end", "def keyword_params\n params.require(:keyword).permit(:name, :course)\n end", "def get_keywords_for_text(retina_name, body)\n resource_path = '/text/keywords'\n verb = 'POST'\n query_params = { 'retina_name' => retina_name }\n post_data = body\n headers = {'Accept' => 'Application/json', 'Content-Type' => 'application/json'}\n\n response = @api_client.call_api(resource_path, verb, query_params,post_data, headers)\n\n JSON.parse(response.body, symbolize_names: true)\n end", "def create\n @search_keyword = SearchKeyword.new(search_keyword_params)\n\n respond_to do |format|\n if @search_keyword.save\n format.html { redirect_to @search_keyword, notice: 'Search keyword was successfully created.' }\n format.json { render action: 'show', status: :created, location: @search_keyword }\n else\n format.html { render action: 'new' }\n format.json { render json: @search_keyword.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @keyword = Keyword.new(keyword_params)\n @keyword.user_id = current_user.id\n respond_to do |format|\n if @keyword.save\n format.html { redirect_to @keyword, notice: 'Keyword was successfully created.' }\n format.json { render :show, status: :created, location: @keyword }\n else\n format.html { render :new }\n format.json { render json: @keyword.errors, status: :unprocessable_entity }\n end\n end\n end", "def keywords\n response = request :keywords\n keywords = Hash.new\n response[\"labels\"].each do |label|\n keywords[label[\"keyword\"]] = label[\"content\"]\n end\n keywords\n end", "def create\n @keyword = Keyword.new(keyword_params)\n @keyword.user_id = @current_user.uid\n @keyword.user_name = @current_user.name\n respond_to do |format|\n if @keyword.save\n format.html { redirect_to admin_keyword_path(@keyword), notice: '关键词创建成功.' }\n format.json { render json: @keyword, status: :created, location: @keyword }\n else\n format.html { render action: \"new\" }\n format.json { render json: @keyword.errors, status: :unprocessable_entity }\n end\n end\n end", "def keyword_params\n params.require(:keyword).permit(:value, :site_id)\n end", "def create\n journal = Journal.find(params[:journal_id])\n issue = journal.issues.find(params[:issue_id])\n article = issue.articles.find(params[:article_id])\n @keyword = article.keywords.new(keyword_params)\n\n respond_to do |format|\n if @keyword.save\n format.html { redirect_to admin_journal_issue_article_keywords_url(@keyword.article.issue.journal, @keyword.article.issue, @keyword.article), notice: '关键词保存成功!' }\n format.json { render :show, status: :created, location: @keyword }\n else\n format.html { render :new }\n format.json { render json: @keyword.errors, status: :unprocessable_entity }\n end\n end\n end", "def suspicious_keyword_params\n params.require(:suspicious_keyword).permit(:keyword)\n end", "def create\n @keyword = Keyword.new(keyword_params)\n @keyword.tweet_count = 0\n\n respond_to do |format|\n if @keyword.save\n format.html { redirect_to @keyword, notice: 'Keyword was successfully created.' }\n format.json { render :show, status: :created, location: @keyword }\n else\n format.html { render :new }\n format.json { render json: @keyword.errors, status: :unprocessable_entity }\n end\n end\n end", "def keyword_params\n params.require(:keyword).permit(:value, :sport_id, :priority, :black_flag)\n end", "def keyword_params\n params.fetch(:keyword, {})\n end", "def search_params\n params.require(:search).permit(:keywords)\n end", "def keyword_params\n params.require(:keyword).permit(:description, :avatar)\n end", "def keyword_autocomplete\n search_keyword = params[\"search\"]\n similar_keywords =\n Keyword.get_similar_keywords(search_keyword, [])\n similar_keywords.map! { |keyword| keyword.name }\n render json: similar_keywords\n end", "def keyword_params\n # params.fetch(:keyword, {})\n params.require(:keyword).permit(:keyword_name, :keywordgroup_id)\n # params.fetch(:keyword, {}).permit(:keyword_name)\n end", "def keyword_params\n ActiveModelSerializers::Deserialization.jsonapi_parse(params, only: [:keyword, :collection_id, :id])\n end", "def create\r\n @keyword = Keyword.new(params[:keyword])\r\n\r\n respond_to do |format|\r\n if @keyword.save\r\n prepare_dependencies_data\r\n format.html { redirect_to(admin_keywords_url, :notice => \"#{@keyword.title} was successfully created.\") }\r\n format.xml { render :xml => @keyword, :status => :created, :location => @keyword }\r\n else\r\n format.html { render :action => \"new\" }\r\n format.xml { render :xml => @keyword.errors, :status => :unprocessable_entity }\r\n end\r\n end\r\n end", "def create\n @art = Art.new(art_params)\n Art.transaction do\n @art.save\n p params[:art][:keyword_ids]\n (params[:art][:keyword_ids]||[]).each do |keyword_id|\n p keyword_id + \" being added!!!\"\n @art.keywords << Keyword.find(keyword_id)\n end\n end\n respond_to do |format|\n if @art.id\n format.html { redirect_to @art, notice: 'Art was successfully created.' }\n format.json { render :show, status: :created, location: @art }\n else\n format.html { render :new }\n format.json { render json: @art.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @keyword = Keyword.new(keyword_params)\n # @easterEgg = 'Enjoy your work and have a nice day! --wang ziyue'\n @notice = 'Keyword was successfully created.'\n if params[:keyword][:name] == '好累'\n @notice = @easterEgg\n end\n respond_to do |format|\n if @keyword.save\n format.html { redirect_to @keyword, notice: \"#{@notice}\" }\n format.json { render :show, status: :created, location: @keyword }\n else\n format.html { render :new }\n format.json { render json: @keyword.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_keyword_lists(options = {})\r\n # Prepare query url.\r\n _query_builder = Configuration.base_uri.dup\r\n _query_builder << '/keyword/lists.json'\r\n _query_url = APIHelper.clean_url _query_builder\r\n\r\n # Prepare form parameters.\r\n _parameters = {\r\n 'page' => options['page'],\r\n 'pagesize' => options['pagesize'],\r\n 'Keyword' => options['keyword'],\r\n 'Shortcode' => options['shortcode']\r\n }\r\n _parameters = APIHelper.form_encode_parameters(_parameters)\r\n\r\n # Prepare and execute HttpRequest.\r\n _request = @http_client.post(\r\n _query_url,\r\n parameters: _parameters\r\n )\r\n BasicAuth.apply(_request)\r\n _context = execute_request(_request)\r\n validate_response(_context)\r\n\r\n # Return appropriate response type.\r\n _context.response.raw_body\r\n end", "def index\n @keywords = Keyword.order(\"name asc\").all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @keywords }\n end\n end", "def setKeywords(keywords)\n @fields['keywords'] = keywords\n self\n end", "def setKeywords(keywords)\n @fields['keywords'] = keywords\n self\n end", "def setKeywords(keywords)\n @fields['keywords'] = keywords\n self\n end", "def setKeywords(keywords)\n @fields['keywords'] = keywords\n self\n end", "def spec_keyword_params\n params.require(:spec_keyword).permit(:spec_id, :keyword_id)\n end", "def keyword_params\n # params.fetch(:keyword, {})\n params.require(:keyword)\n end", "def dame_keyword\n k = Metamares::Keyword.new\n k.nombre_keyword = params[:nombre_keyword]\n\n respond_to do |format|\n format.json { render json: k.busca_keyword.map{ |k| { id: k.nombre_keyword, value: k.nombre_keyword } } }\n format.html { @keyword = k }\n end\n end", "def new\n @keyword = Keyword.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @keyword }\n end\n end", "def create\n @meme = Meme.new(meme_params)\n respond_to do |format|\n if @meme.save\n items = @meme.keywords_string.split(\" \")\n items.each do |item| \n attrs = { :key => item }\n @keyword = Keyword.new(attrs)\n if @keyword.save\n Mapping.create(:meme_id => @meme.id, :keyword_id => @keyword.id)\n end\n end\n format.html { redirect_to @meme, notice: 'Meme was successfully created. Keywords were successfully added' }\n format.json { render :show, status: :created, location: @meme }\n else\n format.html { render :new }\n format.json { render json: @meme.errors, status: :unprocessable_entity }\n end\n end\n end", "def index_keywords!\n update_attribute(:_keywords, set_keywords)\n end", "def rest_keywords; end", "def new\n @keyword = Keyword.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @keyword }\n end\n end", "def restaurant_search_params\n params.require(:restaurant_search).permit(:keywords)\n end", "def create\n @keyword = Keyword.new(keyword_params)\n success = @keyword.save\n \n respond_to do |format|\n if success\n flash[:notice] = ts('new.successful', :what => Keyword.model_name.human.capitalize)\n format.html { redirect_to keywords_url }\n format.xml { head :created, :location => keyword_url(@keyword) }\n else\n format.html { render media_url }\n format.xml { render :xml => @keyword.errors.to_xml }\n end\n end\n end", "def search_keyword_params\n params.require(:search_keyword).permit(:team_id, :name)\n end", "def create_keyword\n @entry = current_user.entries.find(params[:id])\n @keyword = Keyword.find_by_value(params[:keyword_value])\n if @keyword.nil?\n @keyword = Keyword.create(params[:keyword])\n end\n @relevance = Relevance.new(params[:relevance])\n @relevance.entry = @entry\n @relevance.keyword = @keyword\n @relevance.save\n respond_to do |format|\n format.html do\n flash[:notice] = 'Keyword was successfully created.'\n redirect_to(@keyword)\n end\n format.xml { render :text => \"success\" }\n end\n rescue ActiveRecord::RecordNotFound => e\n prevent_access(e)\n end", "def index\n @search = Keyword.search(params[:search])\n @keywords = @search.paginate(:page => params[:page], :per_page => GlobalSettings.per_page).order('id DESC')\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @keywords }\n end\n end", "def create\n @key_word = KeyWord.new(params[:key_word])\n\n respond_to do |format|\n if @key_word.save\n format.html { redirect_to @key_word, notice: 'Key word was successfully created.' }\n format.json { render json: @key_word, status: :created, location: @key_word }\n else\n format.html { render action: \"new\" }\n format.json { render json: @key_word.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @keyword = Keyword.new(params[:keyword])\n @keyword.user = current_user\n\n respond_to do |format|\n if @keyword.save\n \n #recovery twittes\n #@keyword.recover_all_twittes\n RecoverTwittesWorker.perform_async(@keyword.id,@keyword.name)\n \n format.html { redirect_to keywords_url, notice: 'Keyword was successfully created.' }\n format.json { render json: @keyword, status: :created, location: @keyword }\n else\n format.html { render action: \"new\" }\n format.json { render json: @keyword.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @keywords = Keyword.all\n end", "def index\n @keywords = Keyword.all\n end", "def index\n @keywords = Keyword.all\n end", "def index\n @keywords = Keyword.all\n end", "def index\n @keywords = Keyword.all\n end", "def index\n @keywords = Keyword.all\n end", "def index\n @keywords = Keyword.all\n end", "def create\n @keyword = Keyword.new(keyword_params)\n @keywordgroup = Keywordgroup.create!(user_id: current_user.id)\n @keyword.keywordgroup_id = @keywordgroup.id\n\n if @keyword.save\n flash[:notice] = \"Keyword was successfully created.\"\n redirect_to edit_keywordgroup_path @keywordgroup\n else\n flash[:error] = \"Keyword creation was failed.\"\n redirect_to new_keywordgroup_path\n end\n\n # respond_to do |format|\n # if @keyword.save\n # format.html { redirect_to edit_keywordgroup_path @keywordgroup.id, notice: \"Keyword was successfully created. #{@keyword.errors.full_messages}\" }\n # format.json { render :show, status: :created, location: @keyword }\n # else\n # format.html { redirect_to new_keywordgroup_path}\n # format.json { render json: @keyword.errors, status: :unprocessable_entity }\n # end\n # end\n end", "def keywords_attributes=(new_keywords)\n keywords.clear\n\n (new_keywords || []).each do |word|\n keywords.build(:word => word)\n end\n end", "def search_params\n params.permit(:search_terms)\n end", "def BuildKeywords(query, index, hits)\n assert { query.instance_of? String }\n assert { index.instance_of? String }\n assert { hits.instance_of?(TrueClass) || hits.instance_of?(FalseClass) }\n \n # build request\n request = Request.new\n # v.1.0 req\n request.put_string query # req query\n request.put_string index # req index\n request.put_int hits ? 1 : 0\n\n response = PerformRequest(:keywords, request)\n \n # parse response\n begin\n res = []\n nwords = response.get_int\n 0.upto(nwords - 1) do |i|\n tokenized = response.get_string\n normalized = response.get_string\n \n entry = { 'tokenized' => tokenized, 'normalized' => normalized }\n entry['docs'], entry['hits'] = response.get_ints(2) if hits\n \n res << entry\n end\n rescue EOFError\n @error = 'incomplete reply'\n raise SphinxResponseError, @error\n end\n \n return res\n end", "def keywords_field= params\n\t\t\t\ttmp = params.uniq\n\t\t\t\tself.keywordings.each do |k|\n\t\t\t\t\tself.keywords.delete(k.keyword) unless tmp.delete(k.keyword.name)\n\t\t\t\tend\n\t\t\t\ttmp.each do |keyword_name|\n\t\t\t\t\tkeyword = Keyword.find(:first, :conditions => { :name => keyword_name }) || Keyword.new(:name => keyword_name)\n\t\t\t\t\tself.keywordings.build(:keyword => keyword)\n\t\t\t\tend\n\t\t\tend", "def search_all_terms\n render json: Article.with_all_terms(params[:query]).map(&:title)\n end", "def before_create\n keywords = []\n subkeywords = []\n end", "def required_keywords; end", "def add_keywords(keyword_titles)\n self.keywords = []\n keyword_titles.each do |keyword_title|\n keyword = Keyword.where(title: keyword_title).first_or_create\n self.keywords << keyword\n end\n self.keywords = self.keywords.uniq\n end", "def create\n @show_tables = session[:show_tables]\n @title = params[:title]\n kw = keyword_params[:value].downcase.strip\n site_id = keyword_params[:site_id] || 0\n\n @keyword = Keyword.find_by(:value => kw, :site_id => site_id)\n if @keyword && @keyword.created_at < 24.hours.ago\n @keyword.destroy\n @keyword = nil\n end\n unless @keyword\n @keyword = Keyword.new(keyword_params)\n results = query_ebay(kw, site_id)\n @keyword.suggested_categories = get_suggested_categories(kw)\n @keyword.suggestions = results.map {|resp| Suggestion.from_ebay_response *resp }\n end\n logger.info @keyword.suggested_categories\n respond_to do |format|\n if @keyword.save\n format.html { render action: 'show' }\n else\n format.html { render action: 'new' }\n end\n end\n end", "def new\n @keyword = Keyword.new\n \n drop_breadcrumb('新增')\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @keyword }\n end\n end", "def create\n @sport_keyword = SportKeyword.new(sport_keyword_params)\n\n respond_to do |format|\n if @sport_keyword.save\n format.html { redirect_to @sport_keyword, notice: 'Sport keyword was successfully created.' }\n format.json { render action: 'show', status: :created, location: @sport_keyword }\n else\n format.html { render action: 'new' }\n format.json { render json: @sport_keyword.errors, status: :unprocessable_entity }\n end\n end\n end", "def keywords( *args )\n @allowed_keywords = Array([*args])\n end", "def simple_search_params\n params.require(:simple_search).permit(:keywords, :location)\n end", "def destroy\n @suspicious_keyword.destroy\n respond_to do |format|\n format.html { redirect_to suspicious_keywords_url }\n format.json { head :no_content }\n end\n end", "def search_request(user_id, keywords)\n keyword_queries = keywords.map do |keyword|\n {\n bool: {\n should: [\n { term: { title: keyword.downcase } },\n { term: { content: keyword.downcase } }\n ]\n }\n }\n end\n\n __elasticsearch__.search(\n query: {\n bool: {\n must: keyword_queries\n }\n },\n filter: {\n term: {\n user_id: user_id\n }\n },\n sort: [\n {\n created_at: {\n order: 'desc'\n }\n }\n ],\n size: ES_LIMIT_SIZE\n )\n end", "def create\n @key_word_set = KeyWordSet.new(params[:key_word_set])\n\n respond_to do |format|\n if @key_word_set.save\n format.html { redirect_to @key_word_set, notice: 'Key word set was successfully created.' }\n format.json { render json: @key_word_set, status: :created, location: @key_word_set }\n else\n format.html { render action: \"new\" }\n format.json { render json: @key_word_set.errors, status: :unprocessable_entity }\n end\n end\n end", "def new_search_request(keywords, user)\n search_request= SearchRequest.create(SearchRequest.splitUp(keywords), user)\n add_search_request search_request\n search_request\n end", "def keywords\n [self.keyword]\n end", "def set_Keywords(value)\n set_input(\"Keywords\", value)\n end", "def search_keywords\n @categories = params[:categories]\n @project_id = params[:project_id]\n if @categories.present?\n categories_array = @categories.split(/,/)\n categories_array.map! { |x| x.strip }\n categories_array.reject! { |x| x.blank? }\n categories_array.uniq!\n else\n categories_array = []\n end\n @search_keyword = params[\"search\"]\n if(!@search_keyword.blank?)\n @search_keyword = @search_keyword.strip\n @search_keyword = @search_keyword.split(\" \").join(\" \")\n end\n @similar_keywords =\n Keyword.get_similar_keywords(@search_keyword, categories_array)\n @categories = categories_array.join(\", \")\n end", "def create_keyword_categories(data=nil,generate_objects=false)\n uri = URI.parse(@uri + \"/KeywordCategories\")\n results = post(uri,data,generate_objects)\n end", "def official_search_params\n params.permit(:official_ids, :keyword)\n end", "def create\n\t\t# Need to make this use acts_as_nested_set...\n\t\tparent_id = params[:parent][:id] || 1\n\t\t@parent = Keyword.find(parent_id)\n\t\t@keyword = Keyword.create(params[:keyword])\n\t\t@parent.add_child(@keyword)\n\n respond_to do |format|\n if @keyword.save\n flash[:notice] = 'Keyword was successfully created.'\n format.html { redirect_to(@keyword) }\n format.xml { render :xml => @keyword, :status => :created, :location => @keyword }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @keyword.errors, :status => :unprocessable_entity }\n end\n end\n end", "def keylist_params\n params.require(:keylist).permit(:keywords, :active, resources: [:id, :name] )\n end", "def keyword!(keyword_ids:)\n action = mirrored_with_taggings? ? :build : :create\n keyword_ids.each { |id| taggings.send(action, tag_id: id) }\n end", "def cla_params\n params.require(:cla).permit(:title, :keyword)\n end", "def set_keyword\n @keyword = params[:id] ? Keyword.find(params[:id]) : Keyword.new(keyword_params)\n end", "def set_keyword\n @keyword = params[:id] ? Keyword.find(params[:id]) : Keyword.new(keyword_params)\n end", "def search #recipes_search_path\n #binding.pry\n @keywords = params['keywords']\n if @keywords.blank?\n redirect_to root_path\n else\n @number_of_recipes = EdamamApiWrapper.find_number_of_recipes(@keywords)\n @recipes = EdamamApiWrapper.list_recipes(@keywords, 0, 9)\n end\n end", "def render_keywords(tags)\n keywords = TextNormalizer.normalize_keywords(meta_tags.extract(:keywords))\n normalized_meta_tags[:keywords] = keywords\n tags << Tag.new(:meta, :name => :keywords, :content => keywords) if keywords.present?\n end", "def word_params\n params.require(:word).permit(:english, :french, :hiragana, :katakana, :kanji, :tags, :tags_list)\n end", "def destroy\n @keyword.destroy\n respond_to do |format|\n format.html { redirect_to keywords_url, notice: 'Keyword was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @keyword.destroy\n respond_to do |format|\n format.html { redirect_to keywords_url, notice: 'Keyword was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @keyword.destroy\n respond_to do |format|\n format.html { redirect_to keywords_url, notice: 'Keyword was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @keyword.destroy\n respond_to do |format|\n format.html { redirect_to keywords_url, notice: 'Keyword was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @keyword.destroy\n respond_to do |format|\n format.html { redirect_to keywords_url, notice: 'Keyword was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def keywords\n @keywords_accessed = true\n @keywords\n end" ]
[ "0.70997", "0.6996516", "0.6916172", "0.6916172", "0.6849703", "0.6844992", "0.6826331", "0.68003076", "0.66363025", "0.6631286", "0.659442", "0.659442", "0.65702176", "0.654342", "0.6498331", "0.64907765", "0.6483866", "0.6453119", "0.6372649", "0.6347654", "0.6313034", "0.6289739", "0.6282208", "0.6270559", "0.62559414", "0.6253719", "0.6195082", "0.61928356", "0.6192573", "0.6155273", "0.6116644", "0.61044896", "0.60988075", "0.60901797", "0.6069341", "0.6048044", "0.60159737", "0.60159737", "0.60159737", "0.60159737", "0.5997336", "0.5988329", "0.5963973", "0.59630835", "0.59574574", "0.5949265", "0.59463936", "0.59385407", "0.5894922", "0.58750826", "0.5867887", "0.5848988", "0.5827966", "0.57961065", "0.57666737", "0.5760848", "0.5760848", "0.5760848", "0.5760848", "0.5760848", "0.5760848", "0.5760848", "0.5736664", "0.5703421", "0.56890833", "0.568458", "0.56650776", "0.5655855", "0.5648493", "0.56406564", "0.5621627", "0.5607602", "0.56013507", "0.55951786", "0.5587478", "0.55867594", "0.55763024", "0.55565035", "0.5551347", "0.5549058", "0.55421716", "0.55199856", "0.5512824", "0.55087745", "0.54890823", "0.5483574", "0.5477871", "0.5470927", "0.5439319", "0.543707", "0.543707", "0.542833", "0.5427027", "0.54148465", "0.5406112", "0.5406112", "0.5406112", "0.5406112", "0.5406112", "0.5388435" ]
0.5695796
64
DELETE /keywords/1 DELETE /keywords/1.json
def destroy UserKeyword.transaction do begin @user_keyword = @login_user.user_keywords.find(params[:id]) @keyword = @user_keyword.keyword @user_keyword.destroy @keyword.destroy if @keyword.user_keywords.count == 0 rescue ActiveRecord::RecordNotFound missing end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @keyword = Keyword.find(params[:id])\n @keyword.destroy\n\n respond_to do |format|\n format.html { redirect_to keywords_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @keyword = Keyword.find(params[:id])\n @keyword.destroy\n\n respond_to do |format|\n format.html { redirect_to query_url(admin_keywords_url, Keyword, @current_user.uid) }\n format.json { head :no_content }\n end\n end", "def destroy\n @keyword.destroy\n respond_to do |format|\n format.html { redirect_to keywords_url, notice: 'Keyword was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @keyword.destroy\n respond_to do |format|\n format.html { redirect_to keywords_url, notice: 'Keyword was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @keyword.destroy\n respond_to do |format|\n format.html { redirect_to keywords_url, notice: 'Keyword was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @keyword.destroy\n respond_to do |format|\n format.html { redirect_to keywords_url, notice: 'Keyword was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @keyword.destroy\n respond_to do |format|\n format.html { redirect_to keywords_url, notice: 'Keyword was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @keyword = Keyword.find(params[:id])\n @keyword.destroy\n\n respond_to do |format|\n format.html { redirect_to(keywords_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @keyword = Keyword.find(params[:id])\n @keyword.destroy\n\n respond_to do |format|\n format.html { redirect_to(keywords_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @keyword = Keyword.find(params[:id])\n @keyword.destroy\n\n respond_to do |format|\n format.html { redirect_to keywords_url }\n format.xml { head :ok }\n end\n end", "def destroy\n @suspicious_keyword.destroy\n respond_to do |format|\n format.html { redirect_to suspicious_keywords_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @search_keyword.destroy\n respond_to do |format|\n format.html { redirect_to search_keywords_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @keyword.destroy\n respond_to do |format|\n format.html { redirect_to admin_journal_issue_article_keywords_url(@keyword.article.issue.journal, @keyword.article.issue, @keyword.article), notice: 'Keyword was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @key_word = KeyWord.find(params[:id])\n @key_word.destroy\n\n respond_to do |format|\n format.html { redirect_to key_words_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @key_word_set = KeyWordSet.find(params[:id])\n @key_word_set.destroy\n\n respond_to do |format|\n format.html { redirect_to key_word_sets_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @spec = @spec_keyword.spec\n @spec_keyword.destroy\n respond_to do |format|\n format.html { redirect_to edit_spec_url(@spec) }\n format.json { head :no_content }\n end\n end", "def destroy\n @sport_keyword.destroy\n respond_to do |format|\n format.html { redirect_to sport_keywords_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @keyword_store.destroy\n respond_to do |format|\n format.html { redirect_to keyword_stores_url, notice: 'Keyword store was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete(_url)\n # do nothing since we can't find the key by url\n end", "def delete(*rest) end", "def delete(*args)\n request(:delete, *args)\n end", "def delete\n request(:delete)\n end", "def delete_by_query index, query, conflicts_proceed\n conflicts = conflicts_proceed ? 'conflicts=proceed' : ''\n uri = URI(\"http://#{@host}:#{@port_s}/#{index}/_doc/_delete_by_query?#{conflicts}\")\n\n req = Net::HTTP::Post.new(uri)\n req.body = query.to_json\n run(uri, req)\n end", "def delete(*args)\n Request.delete(*args)\n end", "def delete path\n make_request(path, \"delete\", {})\n end", "def delete!\n request! :delete\n end", "def delete\n render json: Alien.delete(params[\"id\"])\n end", "def delete(key)\n\n end", "def delete\n if body.empty? && params[:id]\n client.delete(params)\n elsif body.empty?\n client.delete_by_query(params.merge(body: body.merge(ALL)))\n else\n client.delete_by_query(params.merge(body: body))\n end\n end", "def destroy\n @serach_word = SerachWord.find(params[:id])\n @serach_word.destroy\n\n respond_to do |format|\n format.html { redirect_to serach_words_url }\n format.json { head :no_content }\n end\n end", "def delete(*args)\n prepare_request(:delete, args)\n @@client.add(:delete, @path, *args)\n end", "def destroy\n @kwasny.destroy\n respond_to do |format|\n format.html { redirect_to kwasnies_url }\n format.json { head :no_content }\n end\n end", "def delete\n api(\"Delete\")\n end", "def destroy\n @search_phrase = SearchPhrase.find(params[:id])\n @search_phrase.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_search_phrases_url) }\n format.xml { head :ok }\n end\n end", "def delete!(*rest) end", "def destroy\n @go_term = GoTerm.find(params[:id])\n @go_term.destroy\n\n respond_to do |format|\n format.html { redirect_to go_terms_url }\n format.json { head :no_content }\n end\n end", "def delete(key); end", "def delete(key); end", "def delete(key); end", "def delete(key); end", "def delete(key); end", "def delete(*args)\n execute(:delete, *args)\n end", "def destroy\n @word.destroy\n respond_to do |format|\n format.html { redirect_to vocab_list_path }\n format.json { head :no_content }\n end\n end", "def delete\n start { |connection| connection.request http :Delete }\n end", "def delete\n render json: Like.delete(params[\"id\"])\n end", "def destroy\n check_access\n @word.destroy\n respond_to do |format|\n format.html { redirect_to words_url }\n format.json { head :no_content }\n end\n end", "def delete!( opts = {} )\n http_action :delete, nil, opts\n end", "def destroy\n @word.destroy\n respond_to do |format|\n format.html { redirect_to words_url }\n format.json { head :no_content }\n end\n end", "def delete\n client.delete(\"/#{id}\")\n end", "def delete(url, headers = {})\n http :delete, \"#{url}.json\", headers\n end", "def delete(path, params)\n headers = {:Authorization => \"token #{token}\", :content_type => :json, :accept => :json}\n res = RestClient.delete(\"#{github_api_uri}/#{path}\", params.to_json, headers)\n Yajl.load(res)\n end", "def delete(path)\n RestClient.delete request_base+path\n end", "def destroy\n @flagged_word = FlaggedWord.find(params[:id])\n @flagged_word.destroy\n\n respond_to do |format|\n format.html { redirect_to flagged_words_url }\n format.json { head :no_content }\n end\n end", "def delete(key)\n perform_delete(:delete, key)\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\n api_client.delete(url)\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 @api_noun = Api::Noun.find(params[:id])\n @api_noun.destroy\n\n respond_to do |format|\n format.html { redirect_to api_nouns_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @searchterm.destroy\n respond_to do |format|\n format.html { redirect_to searchterms_url, notice: 'Searchterm was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @word_count = WordCount.find(params[:id])\n @word_count.destroy\n\n respond_to do |format|\n format.html { redirect_to word_counts_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @key = Key.find(params[:id])\n @key.destroy\n\n respond_to do |format|\n format.html { redirect_to keys_url }\n format.json { head :no_content }\n end\n end", "def _delete(type, *args)\n type = type.to_s.camelize\n metadata = args.map { |full_name| {:full_name => full_name} }\n request :delete do |soap|\n soap.body = {\n :metadata => metadata\n }.merge(attributes!(type))\n end\n end", "def destroy\n @lsa_test_word = LsaTestWord.find(params[:id])\n @lsa_test_word.destroy\n\n respond_to do |format|\n format.html { redirect_to lsa_test_words_url }\n format.json { head :no_content }\n end\n end", "def delete(path)\n\t\trequest(path, :delete)\n\tend", "def destroy_relevance\n @entry = current_user.entries.find(params[:id])\n @relevance = Relevance.find_by_entry_id_and_keyword_id(params[:id], params[:keyword_id])\n @relevance.destroy\n respond_to do |format|\n format.html { redirect_to(keywords_url) }\n format.xml { render :text => \"success\" }\n end\n rescue ActiveRecord::RecordNotFound => e\n prevent_access(e)\n end", "def delete\n client.delete(url)\n @deleted = true\nend", "def destroy\n @word = Word.find(params[:id])\n @word.destroy\n\n respond_to do |format|\n format.html { redirect_to words_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @word = Word.find(params[:id])\n @word.destroy\n\n respond_to do |format|\n format.html { redirect_to words_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @word = Word.find(params[:id])\n @word.destroy\n\n respond_to do |format|\n format.html { redirect_to words_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @word = Word.find(params[:id])\n @word.destroy\n\n respond_to do |format|\n format.html { redirect_to words_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @word = Word.find(params[:id])\n @word.destroy\n\n respond_to do |format|\n format.html { redirect_to words_url }\n format.json { head :no_content }\n end\n end", "def delete_data(index_name)\n uri = @client.make_uri(\"/#{index_name}/update/\")\n req = HTTP::Post.new(uri)\n req.content_type = 'text/xml'\n req.body = '<delete><query>*:*</query></delete>'\n response = @client.send_http(req, true, ['200'])\n end", "def destroy\n @sensitive.destroy\n respond_to do |format|\n format.html { redirect_to xmt_press_sensitives_path, notice: '敏感词删除成功' }\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 @jc_term = JcTerm.find(params[:id])\n @jc_term.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 delete(url, headers={})\n RestClient.delete url, headers\n end", "def delete(id)\n request(:delete, \"/recipes/#{id}.json\")\n end", "def delete\n url = prefix + \"delete\"\n return response(url)\n end", "def delete\n url = prefix + \"delete\"\n return response(url)\n end", "def delete\n redis.eval(LUA_SCRIPT_DELETE, :keys => [build_key('*')])\n end", "def destroy\n @knowledge.destroy\n respond_to do |format|\n format.html { redirect_to knowledges_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @tagsearch = Tagsearch.find(params[:id])\n @tagsearch.destroy\n\n respond_to do |format|\n format.html { redirect_to tagsearches_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @case_insensitive.destroy\n respond_to do |format|\n format.html { redirect_to case_insensitives_url }\n format.json { head :no_content }\n end\n end", "def unfollow(keyword_id)\n developer = Developer.find(self.id)\n keyword = Keyword.find(keyword_id)\n developer.keywords.delete(keyword)\n end", "def delete(name)\n raise('wrong type: String required') unless name.is_a?(String)\n raise('wrong value: name must be valid') unless !name.nil? && !name.empty?\n\n @client.post({\n 'action' => 'del',\n 'object' => 'htpl',\n 'values' => name,\n }.to_json)\n end", "def destroy\n @advance_search.destroy\n respond_to do |format|\n format.html { redirect_to advance_searches_url }\n format.json { head :no_content }\n end\n end", "def delete_term(params)\n send_get \"delete_term\", params\n end", "def destroy\n @txt3 = Txt3.find(params[:id])\n @txt3.destroy\n\n respond_to do |format|\n format.html { redirect_to txt3s_url }\n format.json { head :ok }\n end\n end", "def delete(path, params)\n parse_response @client[path].delete(:params => params)\n end", "def delete\n @client.delete_document(@path)\n end", "def destroy\n @keyword_quiz.destroy\n respond_to do |format|\n format.html { redirect_to keyword_quizzes_url, notice: 'Keyword quiz was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete(url)\n do_request(\"delete\", url)\n end", "def api_delete(path, data = {})\n api_request(:delete, path, :data => data)\n end", "def delete(path)\n request 'DELETE', path\n end", "def delete(path, params = {})\n post(path, params.merge(\"_method\" => \"delete\"))\n end", "def destroy\n @word_set.destroy\n respond_to do |format|\n format.html { redirect_to browse_path, warning: \"Word set deleted.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @topickey = Topickey.find(params[:id])\n @topickey.destroy\n\n respond_to do |format|\n format.html { redirect_to topickeys_url }\n format.json { head :no_content }\n end\n end" ]
[ "0.7552868", "0.74610204", "0.73675156", "0.73675156", "0.73675156", "0.73675156", "0.73675156", "0.73285633", "0.73285633", "0.72880286", "0.72091866", "0.7166722", "0.71421427", "0.686459", "0.66316104", "0.6629172", "0.6543365", "0.64898705", "0.6456973", "0.6388983", "0.63553286", "0.6349163", "0.62957287", "0.62761664", "0.62727296", "0.62499535", "0.6235409", "0.62309945", "0.6224786", "0.61682326", "0.61486214", "0.6144994", "0.61209273", "0.6109298", "0.6097858", "0.60974234", "0.60925746", "0.60925746", "0.60925746", "0.60925746", "0.60925746", "0.60887545", "0.60865015", "0.60812885", "0.60800815", "0.6052046", "0.6047068", "0.60290474", "0.60193163", "0.6015498", "0.60136825", "0.60110694", "0.60060656", "0.60014904", "0.6001343", "0.6001343", "0.6001343", "0.6001343", "0.5998936", "0.5996127", "0.59933597", "0.59928304", "0.59916466", "0.598918", "0.59860736", "0.5982701", "0.5981017", "0.59747195", "0.5966988", "0.5960171", "0.5960171", "0.5960171", "0.5960171", "0.5960171", "0.5946242", "0.59409404", "0.5938108", "0.59371275", "0.5933092", "0.59325635", "0.5930805", "0.5930805", "0.5930654", "0.5929672", "0.59279424", "0.5926945", "0.5923249", "0.5919446", "0.59184986", "0.5918304", "0.5917728", "0.59142363", "0.5911395", "0.59104556", "0.5907449", "0.5905745", "0.5904448", "0.59016526", "0.59011847", "0.5900255" ]
0.6214952
29
Log request/response information in common log format to logger.
def _roda_after_90__common_logger(result) super if result && _common_log_request?(result) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def log(request, response)\n time = Time.new.strftime(\"%Y-%m-%d %H-%M-%S\")\n http_request = \"#{request.http_method} #{request.uri}\"\n http_response = \"#{response.code}\"\n @log_file.puts \"#{++@log_no} -- [#{time}] #{http_request} #{http_response}\"\n end", "def log_request\n logger.info \"HTTP request received => #{request.fullpath} , params => #{params} \"\n end", "def log_request\n # REQUEST_LOG.info( {\n # time: Time.now.to_s,\n # ip: request.remote_ip,\n # path: request.path,\n # site: request.host,\n # user_agent: request.user_agent,\n # params: (request.request_parameters.blank? ? request.query_parameters : request.request_parameters),\n # device: sub_group_type,\n # referer_header: referer,\n # current_page_header: current_page,\n # landing_url_header: land_url,\n # visitor_id_header: request.env['HTTP_VISITOR_ID'],\n # session_id_header: request.env['HTTP_SESSION_ID'],\n # visitor_id: visitor_id,\n # session_id: session_id,\n # params: params\n # } )\n end", "def global_request_logging \n http_request_header_keys = request.headers.keys.select{|header_name| header_name.match(\"^HTTP.*\")}\n http_request_headers = request.headers.select{|header_name, header_value| http_request_header_keys.index(header_name)}\n logger.info \"Received #{request.method.inspect} to #{request.url.inspect} from #{request.remote_ip.inspect}. Processing with headers #{http_request_headers.inspect} and params #{params.inspect}\"\n begin \n yield \n ensure \n logger.info \"Responding with #{response.status.inspect} => #{response.body.inspect}\"\n end \n end", "def access_logger\n Rails.application.config.another_logger.info(\"#{request.method} '#{request.path}' #{request.version} from: #{request.remote_ip}\")\n end", "def __log(method, path, params, body, url, response, json, took, duration)\n logger.info \"#{method.to_s.upcase} #{url} \" +\n \"[status:#{response.status}, request:#{sprintf('%.3fs', duration)}, query:#{took}]\"\n logger.debug \"> #{__convert_to_json(body)}\" if body\n logger.debug \"< #{response.body}\"\n end", "def log_request(request, response)\n puts \"\\nRequest Headers\"\n request.each {|head,val| puts \"#{head}: #{val}\"}\n puts \"\\nResponse Headers\"\n response.each {|head,val| puts \"#{head}: #{val}\"}\n puts \"\\nResponse Body\"\n puts response.body\n puts \"\\nResponse Type\"\n puts \"#{response.class} (#{response.code})\"\nend", "def request_log(request); end", "def on_request(env)\n env['sinatra.commonlogger'] = true\n super\n end", "def log_request\n ServerRequestLog.create! default_log_hash\n end", "def log_http_request(request)\n log :info, \"Starting request: #{request.method} #{request.path}\"\n\n return unless log_debug?\n\n log :debug, \" body : #{request.body}\"\n log :debug, \" headers :\"\n request.each_header do |name, value|\n log :debug, \" #{name}: #{value}\"\n end\n end", "def log_request\n \"#{request.ip} - #{session[:login] ? session[:login].name : '-'} [#{Time.now.strftime('%d/%m/%Y:%H:%M:%S %z')}] \\\"#{request.request_method} #{request.path} HTTP\\\" #{response.status} #{response.content_length} #{timer.stop(request.object_id).round(3)}\"\n end", "def log_response response\n if config.logger\n message = config.log_formatter.format(response)\n config.logger.send(config.log_level, message)\n end\n nil\n end", "def log_response\n log \"SOAP response (status #{@response.code}):\"\n log @response.body\n end", "def global_request_logging\n http_request_header_keys = request.headers.env.keys.select { |header_name| header_name.match('^HTTP.*') }\n http_request_headers = request.headers.select { |header_name, header_value| http_request_header_keys.index(header_name) }\n\n logger.debug \"[ApplicationController] Processing with params #{params.inspect}\"\n if request.body.respond_to?(:string)\n logger.debug \"[ApplicationController] Processing with body #{request.body.string.inspect}\" unless request.body.string.blank?\n elsif request.body.respond_to?(:read) && request.body.respond_to?(:rewind)\n request.body.rewind\n logger.debug \"[ApplicationController] Processing with body #{request.body.read.inspect}\"\n end\n\n # Run Warden if not already done, to avoid incomplete log entries after authN fail\n authenticate!\n\n begin\n yield\n ensure\n logger.debug \"[ApplicationController] Responding with headers #{response.headers.inspect}\"\n logger.debug \"[ApplicationController] Responding with body #{response.body.inspect}\" unless response.body.blank?\n end\n end", "def log_http(response)\n resp_template = '[http] Response: %s (%s bytes in %s seconds)'\n log_status = (response.status || 0)\n log_total_time = response.total_time.truncate(3)\n\n Wgit.logger.debug(\"[http] Request: #{response.url}\")\n Wgit.logger.debug(\n format(resp_template, log_status, response.size, log_total_time)\n )\n end", "def on_request(env)\n logger.tagged(*tags) do\n logger.info { formatter.request(env) }\n logger.debug { formatter.request_body(env) }\n end\n end", "def _roda_after_90__common_logger(result)\n return unless result && result[0] && result[1]\n\n env = @_request.env\n\n qs = env[\"QUERY_STRING\"]\n query_string = \"?#{ qs }\" unless qs.empty?\n\n length = result[1][\"Content-Length\"]\n length = \"\" if length == \"0\"\n\n LOGGER.request \"#{ env['HTTP_X_FORWARDED_FOR'] || env['REMOTE_ADDR'] || '-' } - \\\"#{ env['REQUEST_METHOD'] } #{ env['SCRIPT_NAME'] }#{ env['PATH_INFO'] }#{ query_string } #{ env['HTTP_VERSION'] }\\\" #{ result[0] } #{ length }\\n\"\n end", "def log_request(req)\n message = [req.remote_ip, req.command, req.args.join(' ')].join(' ')\n log.info(message)\n end", "def logger\n if request.respond_to? :logger\n request.logger\n else\n Logger.new(STDOUT)\n end\n end", "def log_request(request, type, current_user, logger = Gitlab::AuthLogger)\n request_information = {\n message: 'Application_Rate_Limiter_Request',\n env: type,\n remote_ip: request.ip,\n request_method: request.request_method,\n path: request.fullpath\n }\n\n if current_user\n request_information.merge!({\n user_id: current_user.id,\n username: current_user.username\n })\n end\n\n logger.error(request_information)\n end", "def log_request\n log \"SOAP request: #{@soap.endpoint}\"\n log soap_headers.merge(headers).map { |key, value| \"#{key}: #{value}\" }.join(\", \")\n log @soap.to_xml\n end", "def log_request_response(exception = nil)\n super(exception) if exception.present?\n end", "def record!\n if OhMyLog::Log.configuration.print_log\n p \"REQUEST\"\n p @request.to_s\n p \"RESPONSE\" unless @effects.empty?\n @effects.each {|effect| p effect.to_s}\n end\n\n print_into_log\n\n #we can record everything that happend (OPTIONALL)\n if OhMyLog::Log.configuration.record_history\n OhMyLog::Log.history << self\n end\n #We always save the last operation recorded\n OhMyLog::Log.last_recorded = self\n #save this string on file or upload it somewhere\n end", "def log_request(url, headers, body)\n logger = @api.logger\n logger.debug(\"Report request to: '%s'\" % url)\n logger.debug('HTTP headers: [%s]' %\n (headers.map { |k, v| [k, v].join(': ') }.join(', ')))\n logger.debug(body)\n end", "def log(path)\n case path\n when *Global.boring\n else\n Log.info(\"Dynamic request from #{request.ip}: #{request.request_uri}\")\n end\n end", "def logger\n @logger ||= Logger.new(File.join(Rails.root, 'log', 'meta_request.log'))\n end", "def log_request_begin(logger, env)\n # Assuming remote addresses are IPv4, make them all align to the same width\n remote_addr = env['HTTP_X_FORWARDED_FOR'] || env[\"REMOTE_ADDR\"] || \"-\"\n remote_addr = remote_addr.ljust(15)\n\n # Log the fact that a query string was present, but do not log its contents\n # because it may have sensitive data.\n if (query = env[\"QUERY_STRING\"]) && !query.empty?\n query_info = '?...'\n else\n query_info = ''\n end\n\n # Session\n if env['global_session']\n cookie = env['global_session']\n info = [ env['global_session'].id,\n cookie.keys.map{|k| %{\"#{k}\"=>\"#{cookie[k]}\"} }.join(', ') ]\n sess = %Q{Session ID: %s Session Data: {%s}} % info\n else\n sess = \"\"\n end\n\n shard_info = 'Shard: ' + (env['HTTP_X_SHARD'] || 'default').to_s + ';'\n\n params = [\n env[\"REQUEST_METHOD\"],\n env[\"PATH_INFO\"],\n query_info,\n remote_addr,\n sess,\n shard_info,\n env[\"rack.request_uuid\"] || ''\n ]\n\n logger.info %Q{Processing %s \"%s%s\" (for %s) %s %s Request ID: %s} % params\n end", "def append_info_to_payload(payload)\n super\n request_logging_context_data.each do |key, value|\n payload[key] = BlackSquareLoggingRails.format_value(value)\n end\n\n # Add request parameters to lograge output when the logger is in DEBUG mode\n if BlackSquareLoggingRails.enable_request_parameter_logging\n parameters = request.filtered_parameters.except(*ActionController::LogSubscriber::INTERNAL_PARAMS)\n payload[:request_params] = BlackSquareLoggingRails.format_value(parameters) if parameters.any?\n end\n end", "def log(message); logger.info(message); end", "def log_request_info(env, req_id)\n query_string = \"?#{env.url.query}\" if env.url.query\n size = env.body.respond_to?(:size) ? env.body.size : env.request_headers['Content-Length']\n info { \"{#{req_id}} [OUT] #{env.method} #{env.url.path}#{query_string} (#{size || 0})\" }\n end", "def log_response_debug(_env, resp, req_id)\n debug { \"{#{req_id}} [IN] #{resp.body}\" }\n end", "def log_response_info(env, resp, req_id)\n info { \"{#{req_id}} [IN] #{resp.status} #{env.url.path} (#{resp.body&.size || 0})\" }\n end", "def log (msg, **kwargs) Log.write(msg, :info, kwargs) end", "def install\n Rack::CommonLogger.class_eval do\n\n alias_method :original_log, :log\n\n def log(env, status, header, began_at)\n logger = @logger || env['rack.errors']\n\n blob = {\n :length => header['Content-Length'] || 0,\n :code => status.to_s[0 .. 3],\n :version => env['HTTP_VERSION'],\n :method => env['REQUEST_METHOD'],\n :duration => (Time.now - began_at),\n :query => env[\"QUERY_STRING\"],\n :path => env['PATH_INFO'],\n :remote_addr => env['REMOTE_ADDR'],\n :user => env['REMOTE_USER'],\n :user_agent => env['HTTP_USER_AGENT'],\n :timestamp => Time.now.utc.iso8601\n }\n\n # If there's an X-Forwarded-For header split it up into a\n # list of machine-readable IPs.\n blob[:forwarded_for] = env['HTTP_X_FORWARDED_FOR'].split(',') if env['HTTP_X_FORWARDED_FOR']\n\n if logger\n logger.write({:type => 'request',\n :event => blob}.to_json)\n logger.write(\"\\n\")\n end\n end\n end\n end", "def _roda_after_90__common_logger(result)\n return unless result && (status = result[0]) && (headers = result[1])\n\n elapsed_time = if timer = @_request_timer\n '%0.4f' % (CommonLogger.start_timer - timer)\n else \n '-'\n end\n\n env = @_request.env\n\n line = \"#{env['HTTP_X_FORWARDED_FOR'] || env[\"REMOTE_ADDR\"] || \"-\"} - #{env[\"REMOTE_USER\"] || \"-\"} [#{Time.now.strftime(\"%d/%b/%Y:%H:%M:%S %z\")}] \\\"#{env[\"REQUEST_METHOD\"]} #{env[\"SCRIPT_NAME\"]}#{env[\"PATH_INFO\"]}#{\"?#{env[\"QUERY_STRING\"]}\" if ((qs = env[\"QUERY_STRING\"]) && !qs.empty?)} #{@_request.http_version}\\\" #{status} #{((length = headers[RodaResponseHeaders::CONTENT_LENGTH]) && (length unless length == '0')) || '-'} #{elapsed_time}\\n\"\n if MUTATE_LINE\n line.gsub!(/[^[:print:]\\n]/){|c| sprintf(\"\\\\x%x\", c.ord)}\n # :nocov:\n else\n line = line.gsub(/[^[:print:]\\n]/){|c| sprintf(\"\\\\x%x\", c.ord)}\n # :nocov:\n end\n opts[:common_logger_meth].call(line)\n end", "def request(event)\n log_action_summary(event)\n log_request_details(event)\n log_response_details(event)\n end", "def logger_info\n {\n :url => url,\n :body => body.inspect\n }\n end", "def do_GET(request, _response)\n log_request(request)\n end", "def log_http_call(payload)\n logger.info \"Request[#{payload[:method]}]: #{payload[:uri].to_s}\"\n start_time = Time.now\n response = yield\n logger.info sprintf(\"Response[%s]: %s, Duration: %.3fs\", response.code,\n response.message, Time.now - start_time)\n response\n end", "def logger\n JsonApiServer.configuration.logger\n end", "def info(msg); @logger.info(msg); end", "def log_request_details(event)\n env = event.payload\n debug do\n \"[#{req_id(env)}] #{req_dest(env)} > \" \\\n \"#{env.request_headers.sort.to_h.to_json}\"\n end\n end", "def log_response_details(event)\n env = event.payload\n\n if env.response.nil?\n return error do\n \"[#{req_id(env)}] #{req_dest(env)} < #{res_result(env)}\"\n end\n end\n\n debug do\n \"[#{req_id(env)}] #{req_dest(env)} < \" \\\n \"#{env.response_headers.sort.to_h.to_json}\"\n end\n end", "def log_request\n result = super\n push_outstanding_request\n result\n end", "def log\n @client.get(\"#{path}/log\")\n end", "def log(log)\n post(formatter.call(log, self), log.time.strftime(@logging_path))\n end", "def call(params)\n log_email(params[:logger], \"RESPONSE\", params[:response])\n end", "def log(status_info = {})\n status_info[:authority_name] = authority_name\n status_info[:validation_type] = scenario_validation_type\n status_info[:subauth] = subauthority_name\n status_info[:service] = service\n status_info[:action] = action\n status_info[:url] = url\n status_info[:request_data] = request_data\n status_log.add(status_info)\n end", "def log_request_debug(env, req_id)\n debug { \"{#{req_id}} [OUT] #{env.body}\" }\n end", "def log\n end", "def log_history\n logger.info('[]' + request.method + \"\\t\" + request.fullpath + \"\\t\" + request.remote_ip + \"\\t\" + Time.now.strftime('%Y-%m-%d %H:%M:%S'))\n end", "def logger\n Restfulness.logger\n end", "def log\n advanced[:log]\n end", "def dump_log(request = nil, java = false)\n type_params = java ? '?type=java' : ''\n url = \"#{DUMP_LOG_ENDPOINT}#{type_params}\"\n request = request ? Request.new(symbolize_keys(request)) : {}\n\n logger.debug('Sending dump log request to mockserver')\n logger.debug(\"URL: #{url}. Payload: #{request.to_hash}\")\n\n response = @base[url].put(request.to_json)\n logger.debug(\"Got dump to log response: #{response.code}\")\n parse_string_to_json(response)\n end", "def logger ; @log end", "def get_request_log_with_http_info(request_log_id)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: DiagnosticsApi.get_request_log ...\"\n end\n # verify the required parameter 'request_log_id' is set\n fail ArgumentError, \"Missing the required parameter 'request_log_id' when calling DiagnosticsApi.get_request_log\" if request_log_id.nil?\n # resource path\n local_var_path = \"/v2.1/diagnostics/request_logs/{requestLogId}\".sub('{format}','json').sub('{' + 'requestLogId' + '}', request_log_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(['text/plain'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = []\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: DiagnosticsApi#get_request_log\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def log_request(request)\n access = Access.new\n access.host = request.ip\n access.referrer = request.referer\n access.timestamp = DateTime.now\n\n access.method = request.request_method\n \n (request.get? ? request.GET : request.POST).each_pair do |key, value|\n pair = FormDataPair.new\n pair.name = key\n pair.value = value\n access.form_data_pairs << pair\n end\n\n access.save\n\n status 404\n 'No one here but us chickens.'\nend", "def log_response(request_id, status_code, start_time, args = {})\n return unless @communicator_logger\n\n duration = (Time.now - start_time) * 1000 # in milliseconds\n headers = args[:headers]\n body = args[:body] unless args[:body].nil?\n content_type = args[:content_type]\n\n log_msg_builder = Ingenico::Connect::SDK::Logging::ResponseLogMessageBuilder.new(request_id, status_code, duration,\n @body_obfuscator,\n @header_obfuscator)\n unless headers.nil?\n headers = convert_from_sdk_headers(headers)\n headers.each do |key, value|\n log_msg_builder.add_headers(key, value)\n end\n end\n\n if binary_content_type?(content_type)\n log_msg_builder.set_body('<binary content>', content_type)\n else\n log_msg_builder.set_body(body, content_type)\n end\n\n begin\n @communicator_logger.log(log_msg_builder.get_message)\n rescue StandardError => e\n @communicator_logger.log(\"An error occurred trying to log response #{request_id}\", e)\n end\n end", "def log_info(*custom_infos)\r\n options = custom_infos.extract_options!\r\n options[:development_only] ||= false\r\n \r\n if options[:development_only]\r\n if Rails.env != \"production\"\r\n infos = create_info_log custom_infos\r\n\r\n if options[:write_to] && options[:write_to].to_sym == :error\r\n $log.error infos.join(\"\\n\")\r\n else\r\n $arb_log.info infos.join(\"\\n\")\r\n end\r\n end\r\n else\r\n infos = create_info_log_string custom_infos\r\n\r\n if options[:write_to] && options[:write_to].to_sym == :error\r\n $log.error infos.join(\"\\n\")\r\n else\r\n $arb_log.info infos.join(\"\\n\")\r\n end\r\n end\r\nend", "def write( message )\n\t\t\tApache.request.server.log_debug( message )\n\t\tend", "def internal_send_request(request, options)\n log_method = request == 'append_error' ? :error : :info\n log_text = AuditFormatter.send(format_method(request), options[:text])[:detail]\n log_text.chomp.split(\"\\n\").each { |l| RightLinkLog.__send__(log_method, l) }\n options[:audit_id] = @audit_id\n RightScale::RequestForwarder.push(\"/auditor/#{request}\", options)\n true\n end", "def log(env, status, header, began_at)\n now = Time.now\n length = extract_content_length(header)\n\n data =\n {\n :remote_ip => env['HTTP_X_FORWARDED_FOR'] || env[\"REMOTE_ADDR\"] || \"?\",\n :remote_user => env[\"REMOTE_USER\"] || \"\",\n :http_method => env[\"REQUEST_METHOD\"],\n :path => env[\"PATH_INFO\"],\n :query => env[\"QUERY_STRING\"].empty? ? \"\" : \"?\"+env[\"QUERY_STRING\"],\n :http_version => env[\"HTTP_VERSION\"],\n :http_status => status.to_s[0..3],\n :content_length => length,\n :duration => now - began_at\n }\n\n logger = @logger || env['rack.errors']\n #logger.write data\n end", "def log(*data)\n hash = log_data_as_hash(*data)\n Log.log(prepend_log_context(hash))\n end", "def log(message)\n @logger.info message\n end", "def logs\n\n end", "def log\n @log\n end", "def log_response(response)\n pop_outstanding_request\n super\n end", "def log(context, msg)\n @log << \"#{context}: #{msg}\"\n end", "def log(*args)\n\t\t\trouter.log(*args)\n\t\tend", "def log(type, msg, meta=nil)\n post type, msg, meta\n end", "def logs\n end", "def solr_log(str, name = nil)\n if block_given?\n if @logger and @logger.level <= Logger::INFO\n result = nil\n seconds = Benchmark.realtime { result = yield }\n solr_log_info(str, name, seconds)\n result\n else\n yield\n end\n else\n solr_log_info(str, name, 0)\n nil\n end\n rescue Exception => e\n # Log message and raise exception.\n # Set last_verfication to 0, so that connection gets verified\n # upon reentering the request loop\n @last_verification = 0\n message = \"#{e.class.name}: #{e.message}: #{str}\"\n solr_log_info(message, name, 0)\n raise message\n end", "def enable_logging(logger = Logger.new(STDOUT), log_level: Logger::DEBUG)\n stack.after 'request.factory', 'request.logger', AsyncRequestLogger.new(logger, log_level: log_level)\n stack.before 'response.factory', 'response.logger', AsyncResponseLogger.new(logger, log_level: log_level)\n self\n end", "def log(env, status, response_headers, began_at, body)\n data = {\n :method => env[\"REQUEST_METHOD\"],\n :path => env[\"PATH_INFO\"],\n :query_string => env[\"QUERY_STRING\"],\n :host => Socket.gethostname,\n :status => status.to_i,\n :duration => (Time.now - began_at),\n :remote_addr => env['REMOTE_ADDR'],\n :request => request_line(env),\n :\"X-Forwarded-For\" => response_headers['X-Forwarded-For']\n\n }\n\n # Added calling for the proc and merge the data if it exists\n\n if @proc\n begin\n new_hash = @proc.call(env)\n data = data.merge new_hash if new_hash.class == Hash\n rescue Exception => e\n STDERR.puts \"Exception in your proc : #{e.message}.\"\n end\n end\n\n # This just works for all body types (magic?)... see http://www.rubydoc.info/github/rack/rack/Rack/BodyProxy\n body.each{|x| data[:body] = x[0..@options[:body_len]] }\n @options[:request_headers].each { |header, log_key| env_key = \"HTTP_#{header.upcase.gsub('-', '_')}\" ; data[log_key] = env[env_key] if env[env_key]} if !@options[:request_headers].nil?\n @options[:response_headers].each { |header, log_key| data[log_key] = response_headers[header] if response_headers[header] } if !@options[:response_headers].nil?\n\n data[:error_msg] = env[\"sinatra.error\"] if env.has_key?(\"sinatra.error\")\n\n\n\n @options[:body_regex].each { |k,v| data[k] = data[:body].to_s.match(/#{v}/).captures[0].gsub(\"\\\\\",\"\").gsub(\"\\\"\",\"\") rescue data[k]= \"\" } if !@options[:body_regex].nil?\n\n severity = \"DEBUG\"\n case status\n when 300..399 then severity = \"WARN\"\n when 400..599 then severity = \"ERROR\"\n end\n event = {:severity => severity}.merge data\n # TODO to include this lines\n begin\n device.puts( event.to_json )\n rescue Exception => e\n STDERR.puts \"Error : Failed to write log to : #{@options[:url]}, #{e.message}.\"\n @device = nil\n end\n end", "def log(msg)\n logger.info(\"#{tag} #{msg}\")\n end", "def logger; end", "def logger; end", "def logger; end", "def logger; end", "def logger; end", "def logger; end", "def logger; end", "def logger; end", "def logger; end", "def logger; end", "def logger; end", "def logger; end", "def logger; end", "def logger; end", "def logger; end", "def logger; end", "def logger; end", "def logger; end", "def logger; end", "def logger_output; end", "def grid_rest_log(method, url, rparams = {}, emsg = \"\")\n if current_namespace\n return unless GridRest.grid_config.namespaces[current_namespace]['logging']\n else\n return unless GridRest.grid_config['logging']\n end\n grid_rest_log_message(rparams.any? ? \"#{Time.now.to_s(:db)} #{method.to_s.upcase} #{url} with #{rparams.inspect} #{emsg}\" : \"#{Time.now.to_s(:db)} #{method.to_s.upcase} #{url} #{emsg}\")\n end", "def info(msg) log(6, msg); end", "def debug_info(address, body, response)\n puts \"Request: #{address}\"\n puts \"Body: #{body}\"\n puts \"Response: #{response.body}\"\n end", "def debug_output= logger\n @debug_output = logger\n @rpc.instance_eval(\"@http\").set_debug_output logger\n end" ]
[ "0.7614704", "0.73613125", "0.7317517", "0.73113173", "0.72239053", "0.7180419", "0.71608245", "0.7125867", "0.68964547", "0.68443376", "0.68349683", "0.67651093", "0.67422485", "0.66206527", "0.6585409", "0.6527793", "0.64848816", "0.6470006", "0.646892", "0.63984", "0.6373305", "0.6363512", "0.6275614", "0.62489444", "0.62139314", "0.61428434", "0.6138342", "0.61308163", "0.60887647", "0.60723835", "0.6066713", "0.6051333", "0.60501903", "0.60408837", "0.60307646", "0.60287553", "0.6012903", "0.6009552", "0.6001563", "0.59832907", "0.5980935", "0.5970569", "0.5966243", "0.5958905", "0.5946444", "0.59204704", "0.58754", "0.5872299", "0.582048", "0.58054626", "0.5800379", "0.579268", "0.5792082", "0.57906824", "0.5785521", "0.57853115", "0.5760504", "0.5756479", "0.57519954", "0.57408696", "0.57370436", "0.5731494", "0.57181627", "0.5706443", "0.56977254", "0.5695875", "0.5690777", "0.5688863", "0.5684986", "0.5679607", "0.567934", "0.5676629", "0.5662711", "0.56548715", "0.56507283", "0.5644632", "0.5638841", "0.5638841", "0.5638841", "0.5638841", "0.5638841", "0.5638841", "0.5638841", "0.5638841", "0.5638841", "0.5638841", "0.5638841", "0.5638841", "0.5638841", "0.5638841", "0.5638841", "0.5638841", "0.5638841", "0.5638841", "0.5638841", "0.56271863", "0.56226164", "0.56167406", "0.5612969", "0.56018364" ]
0.5973035
41
TODO [11/9/10 12:18 AM] => VALIDATIONS ADD_VALIDATIONS_FOR_DOCUMENTS ADD_VALIDATIONS_FOR_SECTION_AND_ITEM_TEMPLATE_IF_NECESSARY def Item.all_active Item.find_all_by_is_active(true) end
def update_completed_count self.section.update_completed_count end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fetch_all_active_items\n @items.values.select{|item| item.active}\n end", "def get_active_items\r\n self.items.select { |i| i.active? } #TODO only fixed or only auction\r\n end", "def get_active_items\n self.items.select { |i| i.active? } #TODO only fixed or only auction\n end", "def active_items\n @items.values.select { |value| value.state == :active || value.state == :auction}\n end", "def active\n return @all_active if @all_active\n @all_active = all.find_all{ |enum| enum.active? }.freeze\n end", "def list_items\r\n return_list = Array.new\r\n for s in self.item_list\r\n if s.is_active?\r\n return_list.push(s)\r\n end\r\n end\r\n # AK This is a very common pattern, so there is a method for that:\r\n #return item_list.select {|s| s.is_active?}\r\n return return_list\r\n end", "def all_items_for_sell\r\n list = Array.new\r\n items.each{ |item|\r\n if item.active == true\r\n list.push(item)\r\n end}\r\n list\r\n end", "def list_items_inactive\r\n return_list = Array.new\r\n for s in self.item_list\r\n if !s.is_active?\r\n return_list.push(s)\r\n end\r\n end\r\n return return_list\r\n end", "def list_items_inactive\r\n return_list = Array.new\r\n for s in self.item_list\r\n if !s.is_active?\r\n return_list.push(s)\r\n end\r\n end\r\n return return_list\r\n end", "def list_items\r\n return_list = Array.new\r\n for s in self.item_list\r\n if s.is_active?\r\n return_list.push(s)\r\n end\r\n end\r\n return return_list\r\n end", "def fetch_active_items_of(account_id)\n fetch_items_of(account_id.to_i).select {|s| s.is_active? }\n end", "def all\n active + inactive\n end", "def active\n @active.flatten.compact\n end", "def index\n @items = Item.order(name: :asc)\n @available_items = Item.where(available: :true)\n @unavailable_items = Item.where(available: :false)\n end", "def inactive\n return @all_inactive if @all_inactive\n @all_inactive = all.find_all{ |enum| !enum.active? }.freeze\n end", "def manage_items\n @pending_items = Item.find_all_by_item_status_id(1)\n @for_sale_items = Item.find_all_by_item_status_id(2)\n @free_items = Item.find_all_by_item_status_id(3)\n @claimed_items = Item.find_all_by_item_status_id(4)\n @sold_items = Item.find_all_by_item_status_id(5)\n end", "def index\n @items = Item.includes(:user).where(availability: TRUE)\n end", "def active_item_type\n sorted_item_types.find(&method(:active?))\n end", "def items_on_sale\r\n sale = Array.new\r\n\r\n if(self.items.size > 0)\r\n self.items.each {|val|\r\n if (val.is_active )\r\n sale.push(val)\r\n end\r\n }\r\n end\r\n\r\n return sale\r\n end", "def active_lineitems\n @active_lineitems ||= lineitems.select(&:active?).freeze\n end", "def fetch_all_active_items_but_of(account_id)\n fail \"No account with id #{account_id}\" unless DAOAccount.instance.account_exists?(account_id)\n @items.values.select{|item| item.owner.id != account_id && item.active}\n end", "def all?\n only_with('all?', 'Boolean')\n items.compact.all?\n end", "def active_prices\n prices.where('active = 1')\n end", "def get_checked_items\n find_all { | i | checked?(i) } \n end", "def active_tasks\n @tasks.select { | task | task.active }\n end", "def all_items(item)\r\n result = false\r\n\r\n if(self.items.size > 0)\r\n self.items.each {|val|\r\n if (val.get_name == item.get_name )\r\n return true\r\n else\r\n result = false\r\n end\r\n }\r\n else\r\n result = false\r\n end\r\n\r\n return result\r\n end", "def index\n @load = Item.includes(:user, thumbnail_attachment: :blob)\n @items = []\n for item in @load\n if item.active == true\n @items << item\n end\n end\n end", "def found_show_all\n showing_all_items?\n end", "def sellable_items\n all_items.select { |item| item.traddable? }\n end", "def list_items_inactive\n return_list = Array.new\n for s in self.offers\n unless s.auction\n if !s.active && !s.auction\n return_list.push(s)\n end\n end\n end\n return return_list\n end", "def active_packages(_packages=nil)\n _packages ||= self.packages\n _packages.select{|p| p.active == true}\n end", "def active_transfer_items\n transfer_items.joins(transfer: :shipment).merge(Shipment.active)\n end", "def all_active_shops\n Shop.all\n end", "def active_cells; @cells.select(&:active?) end", "def active\n where(:state => \"new\")\n #actions = Action.arel_table\n #where(actions[:state].eq('new').or(actions[:state].eq('copied')))\n end", "def active?\n # find first condition that doesn't pass (nil if all pass)\n self.conditions.find(:all).find { |c| !c.evaluate? }.nil? # true if all pass\n end", "def active_by_group\n submodules_by_group(active)\n end", "def active\n raise 'No \"Active\" header' unless headers.include?('Active')\n select { |row| row['Active'] == 'TRUE' }\n end", "def active_group_loan_memberships\n self.group_loan_memberships.where(:is_active => true )\n end", "def test_supportItem\n f = ItemFilter.new(\"support\", true)\n new_list = @usableItems.find_all{|x| f.apply(x)}\n return new_list.size == 3\n end", "def availability_items\n return @availability_items if @availability_items\n @availability_items = @connection.availability_items(self.id)\n end", "def list_items\n return_list = Array.new\n for s in self.offers\n unless s.auction\n if s.is_active?\n return_list.push(s)\n end\n end\n end\n return return_list\n end", "def index\n @items=Item.where(:activated => true) #TODO: Add availability\n @categories = Category.all\n @search = Item.search(params[:search])\n @keyword = params[:search]\n @items = @search.where(:activated => true) # or @search.relation to lazy load in view\n @items = @items.paginate(:per_page=>16, :page=>params[:page]) #@category.items\n end", "def active_todos\n todos.active.order('created_at DESC')\n end", "def all_items_ready?\n ready = false\n items.each do |i|\n if !i.obsolete\n ready = item_ready?(i)\n end\n break if !ready\n end\n ready\n end", "def index\n @adds = Add.friendly.paginate(:page => params[:page], :per_page => 3)\n # Find only the adds marked as active\n # @adds = Add.friendly.where(active: true) \n end", "def active_recordings\n self.recordings.where(active: true)\n end", "def active_recordings\n self.recordings.where(active: true)\n end", "def index\n @item_collections = ItemCollection.where('is_private=false')\n if !params[:search].nil? || params[:search] == ''\n t = ItemCollection.arel_table\n @item_collections = ItemCollection.where(t[:name].matches(\"%#{params[:search]}%\").and(t[:is_private].eq(false)))\n #@item_collections = ItemCollection.where('name LIKE ? AND is_private=false', \"%#{params[:search]}%\")\n end\n end", "def active\n projects.select { |project| !project.archived? }\n end", "def row_items\n object.manifest_items.scope.active\n end", "def find_all\n products = []\n @db.query(\"SELECT id, name FROM products WHERE is_active = 1\", :symbolize_keys => true).each do |prod|\n products << prod\n end\n products\n end", "def fetch_inactive_items_of(account_id)\n fetch_items_of(account_id.to_i).select {|s| !s.is_active? }\n end", "def active_projects\n self.projects.where(:is_canceled => false, :is_finished => false )\n end", "def index\n @resources = Resource.where(active: true)\n @general = Resource.where(active: true, general: true)\n @motivation = Resource.where(active: true, motivation: true)\n @mindset = Resource.where(active: true, mindset: true)\n @resourcing = Resource.where(active: true, resourcing: true)\n @planning = Resource.where(active: true, planning: true)\n @time_management = Resource.where(active: true, time_management: true)\n @discipline = Resource.where(active: true, discipline: true)\n end", "def index\n @item_additional_conditions = ItemAdditionalCondition.all\n end", "def filter_available_for *items\n items.any? do |item|\n item = [item] unless item.is_a? Array\n item.reduce(filter_params) do |memo,it|\n if memo.is_a?(Hash)\n if memo[it].nil?\n false\n else\n memo[it]\n end\n else\n false\n end\n end\n end\n end", "def collect_eligible(items)\n items.select{|item| eligible?(item) }\n end", "def active?\n @rows && !@rows.empty?\n end", "def active=(active)\n @active = active\n @ucIcon.active = active\n @cItemName.active = active\n @cItemPrice.active = active\n @cItemPossess.active = active\n @ucItemNumber.active = active\n end", "def index\n @active_items = Item.select(&:active?).sort_by(&:name)\n @inactive_items = Item.select(&:inactive?).sort_by(&:name)\n\n @item = Item.new\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @items }\n end\n end", "def activated_abilities\n activated = abilities.select{|ability| ability.activated?}\n \n # Add the item abilities\n return activated + item_actions\n end", "def current_item_enabled?\n true\n end", "def current \n find_by_active(true)\n end", "def active_params\n @params.values.select { |param| param.active? }\n end", "def has_item(item)\r\n result = false\r\n\r\n if(self.items.size > 0)\r\n self.items.each {|val|\r\n if (val.get_name == item.get_name and item.is_active )\r\n return true\r\n else\r\n result = false\r\n end\r\n }\r\n else\r\n result = false\r\n end\r\n\r\n return result\r\n end", "def current_item_enabled?\n return true\n end", "def items(opts = {})\n Item.all(opts)\n end", "def get_active_trip_offers\n get_trip_offers(active=true)\n end", "def active_transactions\n if last_balance_check\n from = last_balance_check.checked_at\n trans.where(\"\n ((state = 'created') AND (transaction_at > ?))\n OR\n ((state = 'reconciled') AND (reconciled_at > ?))\",\n from, from)\n else\n trans.where(:state => ['created', 'reconciled'])\n end\n end", "def active_item\n return @active_item if @active_item\n # Simple configuration means that name is returned immediately\n @active_item = get_value(controller_active_item_config)\n\n # If the configuration is a Hash then we need to find the first\n # menu item that has a passing condition\n if @active_item.is_a? Hash\n @active_item.each do |condition, key|\n @active_item = key and break if @template.instance_eval(condition)\n end\n end\n @active_item\n end", "def all\n where\n end", "def all\n @items\n end", "def active_listings\n @active_listings ||= Listing.find_all_active_by_category(category_name)\n end", "def index\n @availabilities = Availability.where(:active => true)\n end", "def active_plans\n self.plans.includes(:template).where(\"roles.active\": true).where(Role.not_reviewer_condition)\n end", "def selected_items\n ((m = marked_items).any? ? m : Array(current_item)).reject {|i| %w(. ..).include? i.name}\n end", "def show_completed_items\n return @to_do_item.select { |x| x.is_done? == true }\n end", "def inactivate_all! records\n records.update_all(active: false)\n end", "def items_no_sale\r\n sale = Array.new\r\n\r\n if(self.items.size > 0)\r\n self.items.each {|val|\r\n if (!val.is_active )\r\n sale.push(val)\r\n end\r\n }\r\n end\r\n\r\n return sale\r\n end", "def index\n # @application_cases = current_user.application_cases.all\n if params[:active].present?\n @application_cases = current_user.application_cases.where(nil) # creates an anonymous scope\n @application_cases = @application_cases.active_status(params[:active]) if params[:active].present?\n else \n @application_cases = current_user.application_cases.active_status('Active')\n end\n\n end", "def any_items_ready?\n ready = false\n if items.blank?\n ready = true\n else\n items.each do |i|\n if !i.obsolete\n if i.digital_object\n ready = i.state_reached_for_order(:ready_at_use_location, self.id)\n else\n ready = i.state_reached_for_order(:ready_at_temporary_location, self.id)\n end\n end\n break if ready\n end\n end\n ready\n end", "def set_active_inactive\n to_set_inactive = (EvaluationTemplate.where.not(id: self.id)).\n where(active: true).where(quarter_id: self.quarter_id)\n if self.active?\n to_set_inactive.each { |t| t.update_attributes(active: false) }\n end\n end", "def filter_items\n @filter_items ||= []\n end", "def active\n\t\t\t\t\tfind(:all, :conditions => 'username != \"\"')\n\t\t\t\tend", "def show\n @field_values = CategoryFieldValue.joins(:category_field).where(item_id: @item.id, category_fields: { category_id: @item.category_id }).all.select{ |fv| !fv.category_field.nil? }\n\n @available_subitems = @item.subitems_for_category \n\n end", "def active_facebook_accounts\n facebook_accounts.where(is_active: true)\n end", "def all_actions_for_all_items\n @item_actions\n end", "def index \n \t@items = Item.paginate(page: params[:page])\n\n @user_items = current_user.user_items.pluck(:id).uniq\n @all_user_items = UserItem.where(id: @user_items)\n end", "def get_active_recipe_ids\n users_recipes.find_all {|ur| ur.active}.map {|ur| ur.recipe_id}\n end", "def active_service_components\n self.service_components.where(:is_deleted => false).order(\"created_at DESC\")\n end", "def all\n @disabled\n end", "def get_autocomplete_items(parameters)\r\n super(parameters).active rescue nil\r\n end", "def get_autocomplete_items(parameters)\r\n super(parameters).active rescue nil\r\n end", "def get_autocomplete_items(parameters)\r\n super(parameters).active rescue nil\r\n end", "def show\n @task_items = @task_list.items.active\n end", "def items\n items = []\n @collection.each_with_index do |item, index|\n if index == @current && index == @selected\n items << [true, true, item]\n\n elsif index == @current\n items << [false, true, item]\n\n elsif index == @selected\n items << [true, false, item]\n\n else\n items << [false, false, item]\n\n end\n end\n items\n end", "def all\n inactive + active\n rescue Exception::LibvirtError\n # If inactive isn't supported, then we just return the active\n # storage pools.\n active\n end", "def active?\n # find first condition that doesn't pass (nil if all pass)\n self.conditions.find { |c| !c.evaluate? }.nil? # true if all pass\n end", "def inactive\n @inactive_users = User.where(isActive:false).paginate(:page => params[:inactive_users_page], :per_page => 10)\n end", "def current_item_enabled?\n current_data ? current_data[:enabled] : false\n end" ]
[ "0.8136205", "0.76644063", "0.75894743", "0.7191235", "0.7152048", "0.6791746", "0.6701609", "0.66791606", "0.66791606", "0.6678782", "0.6300499", "0.6263089", "0.6246039", "0.6228809", "0.61847275", "0.61354446", "0.6099375", "0.6056984", "0.60555136", "0.6044676", "0.60349834", "0.6028385", "0.6026792", "0.6021691", "0.59444547", "0.5906545", "0.59056747", "0.58958197", "0.5887324", "0.58657426", "0.58140016", "0.58032113", "0.57610935", "0.5746877", "0.57092845", "0.56856704", "0.56855756", "0.5670364", "0.56632197", "0.56556463", "0.5654027", "0.564948", "0.5637268", "0.5633957", "0.55847734", "0.55614984", "0.5558947", "0.55583525", "0.5556473", "0.55557543", "0.55501294", "0.5549981", "0.5549938", "0.5549801", "0.5531733", "0.55157614", "0.5512874", "0.55088186", "0.5507665", "0.5503841", "0.54973245", "0.549337", "0.5493175", "0.5488153", "0.5487948", "0.5484229", "0.54838395", "0.5480746", "0.54753196", "0.5463363", "0.5461009", "0.5445564", "0.54221904", "0.5409037", "0.53939307", "0.53896165", "0.53877574", "0.5379662", "0.5377758", "0.5372996", "0.53720576", "0.53692085", "0.53561926", "0.53540796", "0.53272164", "0.5324448", "0.53200984", "0.53193444", "0.530719", "0.530517", "0.5304704", "0.5294831", "0.5293721", "0.5293721", "0.5293721", "0.5283893", "0.5270615", "0.5270499", "0.5264752", "0.5260972", "0.52595127" ]
0.0
-1
update_attributes should be used, but it isn't working perfectly for some weired reason :(
def mark_as_complete(options) self.is_complete = options[:is_complete] self.is_applicable = true # if item.is_complete self.save_with_validation(false) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_attributes!(args = {})\n assign_attributes(args)\n save!\n end", "def update(...)\n assign_attributes(...)\n save\n end", "def update_attributes!(attributes)\n assign_attributes attributes\n save!\n end", "def update_attributes(args = {})\n assign_attributes(args)\n save\n end", "def update_attributes attributes\n @attributes.merge! attributes\n end", "def update_attributes(_params)\n assign_attributes _params\n save\n end", "def nested_attributes_update_attributes(meta, obj, attributes)\n nested_attributes_check_key_modifications(meta, obj) do\n nested_attributes_set_attributes(meta, obj, attributes)\n end\n end", "def update_attributes(attributes)\n assign_attributes attributes\n save\n end", "def update(context={})\n self.pre_cast_attributes\n m2o = @relations.reject{|k, v| !self.class.many2one_relations.has_key?(k)}\n vals = @attributes.reject {|key, value| key == 'id'}.merge(m2o.merge(m2o){|k, v| v.is_a?(Array) ? v[0] : v})\n self.class.rpc_execute('write', self.id, vals, context)\n reload_from_record!(self.class.find(self.id, :context => context))\n end", "def update_attributes!(attributes)\n self.attributes = attributes\n save!\n end", "def update_attributes!(attributes)\n self.attributes = attributes\n save!\n end", "def update_attributes!(attributes)\n self.attributes = attributes\n save!\n end", "def update_attributes!(attributes)\n self.attributes = attributes\n save!\n end", "def update_attributes( hash={} )\n set_attributes hash\n valid_without_errors? and save\n end", "def update_attributes!(attributes = nil)\r\n self.attributes = attributes\r\n save!\r\n end", "def update attributes\n attributes.each do |name, value|\n send \"#{name}=\", value if respond_to? \"#{name}=\"\n end\n save\n end", "def update!(**args)\n @attributes = args[:attributes] if args.key?(:attributes)\n end", "def update_attributes(attributes = nil)\r\n self.attributes = attributes\r\n save\r\n end", "def update!(attributes)\n assign_attributes(attributes)\n save!\n end", "def update_attributes(attrs)\n self.attributes = attrs\n save\n end", "def update_with(attributes)\n assign_attributes(attributes)\n end", "def update_attributes!(hash)\n merge_attributes(hash)\n save!\n end", "def update_attributes(attributes)\n self.attributes = attributes\n save\n end", "def update_attributes(attributes)\n self.attributes = attributes\n save\n end", "def update_attributes(attributes)\n self.attributes = attributes\n save\n end", "def update(attributes = {}, *allowed)\n attributes = attributes.only(*allowed) if allowed.any?\n dirty_attributes = model.new(attributes).dirty_attributes\n dirty_attributes.empty? || all? { |r| r.update(attributes, *allowed) }\n end", "def update_attributes(attributes={})\n attributes = convert_attributes(attributes)\n \n attributes.each { |name, value| send( \"#{name}=\", value ) }\n end", "def update(attributes = {})\n self.attributes = attributes\n self.save\n end", "def update\n\n end", "def update_attributes(hash)\n update_attributes_without_saving hash\n save\n end", "def update\n upsert do\n # NOTE:\n # 1. update ++then++ valid to set new values in @record to draw form.\n # 1. user_scoped may have joins so that record could be\n # ActiveRecord::ReadOnlyRecord so that's why access again from\n # model.\n @record = model.find(user_scoped.find(params[:id]).id)\n #upsert_files\n if !@record.update_attributes(permitted_params(:update))\n raise ActiveRecord::RecordInvalid.new(@record)\n end\n end\n end", "def update(attributes)\n assign_attributes(attributes)\n save\n end", "def update(attributes)\n update_attributes(attributes)\n save\n end", "def update_attributes(attributes)\n attributes.to_h.each { |name, value| send(\"#{name}=\", value) }\n end", "def update_attributes(params = {})\n super validate_attributes(params)\n end", "def update\n record.assign_attributes(data)\n record.save! if record.changed?\n end", "def update(params)\n self.attributes = params\n save\n end", "def update(params)\n self.attributes = params\n save\n end", "def update(attributes)\n self.attributes = process_attributes(attributes)\n save\n end", "def update_attributes(hash)\r\n @hash.merge!(hash)\r\n save\r\n end", "def update(attrs, opts={})\n update_attributes(attrs)\n save(opts)\n end", "def update_attributes(target, *attributes)\n update(target, :only => attributes)\n end", "def update_attribute\n end", "def update_attributes(args = {})\n args.each do |name, value|\n send(\"#{name}=\", value)\n end\n save\n end", "def update!(attributes = {}, *allowed)\n attributes = attributes.only(*allowed) if allowed.any?\n\n dirty_attributes = model.new(attributes).dirty_attributes\n\n if dirty_attributes.empty?\n true\n elsif dirty_attributes.only(*model.key).values.any? { |v| v.blank? }\n false\n else\n updated = repository.update(dirty_attributes, query)\n\n if loaded?\n each { |r| r.attributes = attributes }\n updated == size\n else\n true\n end\n end\n end", "def nested_attributes_update(meta, obj, attributes)\n nested_attributes_update_attributes(meta, obj, attributes)\n delay_validate_associated_object(meta[:reflection], obj)\n # Don't need to validate the object twice if :validate association option is not false\n # and don't want to validate it at all if it is false.\n after_save_hook{obj.save_changes(:validate=>false)}\n obj\n end", "def update!(attributes)\n # The following transaction covers any possible database side-effects of the\n # attributes assignment. For example, setting the IDs of a child collection.\n # with_transaction_returning_status do\n # assign_attributes(attributes)\n # save!\n # end\n send_log \"#{self.class}(#{self.id})\\n -update!(attributes=#{attributes}) - new_record? #{self.new_record?}\", BLUE, WHITE_BG\n super\n end", "def update(attributes)\n attributes.each { |k, v| send(\"#{k}=\", v) }\n valid?\n end", "def update_resource object, attributes\n object.update attributes\n end", "def update_attributes(instance, attributes = {})\n attributes.each do |method_name, value|\n instance.send(:\"#{method_name}=\", ::Marshal.load(::Marshal.dump(value)))\n end\n\n return\n end", "def update_attributes(attrs)\n result = nil\n obj = self.strip_braces(self.object)\n self.instance_variables.each do |method|\n method = method.to_s.gsub(/@/,\"\")\n val = self.send method.to_sym\n # Don't save objects with braces to database\n new_val = attrs[method]\n # if the object's value doesn't match the database record\n # then we procede with update\n if new_val and val != new_val\n unless self.method_name_reserved?(method) or new_val.length == 0\n # update viewable list\n result = Rhom::RhomDbAdapter::update_into_table(Rhom::TABLE_NAME,\n {\"value\"=>new_val},\n {\"object\"=>obj, \"attrib\"=>method})\n # update sync list\n result = Rhom::RhomDbAdapter::insert_into_table(Rhom::TABLE_NAME,\n {\"source_id\"=>self.get_inst_source_id,\n \"object\"=>obj,\n \"attrib\"=>method,\n \"value\"=>new_val,\n \"update_type\"=>'update'})\n end\n end\n end\n result\n end", "def update_attributes(hash)\n merge_attributes(hash)\n save\n end", "def update_attributes(new_attributes = {})\n new_attributes.all? do |name, value|\n self[name] = value\n end && save\n end", "def update_attributes!(attributes)\n raise NotImplemented\n end", "def update!(attributes)\n # The following transaction covers any possible database side-effects of the\n # attributes assignment. For example, setting the IDs of a child collection.\n with_transaction_returning_status do\n assign_attributes(attributes)\n save!\n end\n end", "def update(id, attributes)\n # attributes = {name: 'chocolate and peanuts', calories: 10}\nend", "def update_attributes!(key_value_pairs)\n key_value_pairs.each { |k,v| instance_variable_set \"@#{k}\", v }\n save!\n end", "def update!(**args)\n @attributes = args[:attributes] if args.key?(:attributes)\n @usage_info = args[:usage_info] if args.key?(:usage_info)\n end", "def update; end", "def update; end", "def update; end", "def update; end", "def update; end", "def update; end", "def update; end", "def update; end", "def update!(**args)\n @attributes = args[:attributes] if args.key?(:attributes)\n @id = args[:id] if args.key?(:id)\n @kind = args[:kind] if args.key?(:kind)\n end", "def update!(raw: false)\n if valid? == false\n errors.full_messages.each do |msg|\n warn \"[#{parse_class}] warning: #{msg}\"\n end\n end\n response = client.update_object(parse_class, id, attribute_updates, session_token: _session_token)\n if response.success?\n result = response.result\n # Because beforeSave hooks can change the fields we are saving, any items that were\n # changed, are returned to us and we should apply those locally to be in sync.\n set_attributes!(result)\n end\n puts \"Error updating #{self.parse_class}: #{response.error}\" if response.error?\n return response if raw\n response.success?\n end", "def update!(**args)\n @attribute_map = args[:attribute_map] if args.key?(:attribute_map)\n @dropped_attributes_count = args[:dropped_attributes_count] if args.key?(:dropped_attributes_count)\n end", "def update_attributes_and_sync(attributes)\n if update_attributes(attributes)\n update_salesforce_attributes(attributes)\n end\n end", "def update\n create_or_update\n end", "def update\n @dirty = true\n end", "def update\n update_all\n end", "def update(params)\n self.attributes = params\n end", "def update_attributes\n return transform_attributes.except(:id) if klass == Collection\n if attributes[:collection].present?\n transform_attributes.except(:id).except(:collection).merge(member_of_collections_attributes: { 0 => { id: collection.id } })\n elsif attributes[:collections].present?\n collection_ids = attributes[:collections].each.with_index.each_with_object({}) do |(element, index), ids|\n ids[index] = element\n end\n transform_attributes.except(:id).except(:collections).merge(member_of_collections_attributes: collection_ids)\n else\n transform_attributes.except(:id)\n end\n end", "def test_update_record_bug\n p = Post.find(6)\n assert p.update_attributes(:body => p.body + ' crane')\n assert_equal 2, result_ids('crane').size\n assert_equal 2, result_ids('ship').size\n end", "def update(attributes)\n HashProxy.with(attributes) do |proxy|\n self.class.attribute_names.each do |name|\n send(\"#{name}=\", proxy[name]) if proxy.key?(name)\n end\n end\n save\n end", "def update\n \n end", "def update_attributes(attributes)\n raise NotImplemented\n end", "def update!\n self.save\n end", "def update ; end", "def update_attributes(attributes)\n update_attributes!(attributes)\n rescue AnsibleTowerClient::Error\n false\n end", "def update(model_data)\n end", "def update(opts)\n assign_attributes(opts)\n save\n end", "def update(attributes)\n @sunstone_updating = :updating\n Thread.current[:sunstone_updating_model] = self\n\n # The following transaction covers any possible database side-effects of the\n # attributes assignment. For example, setting the IDs of a child collection.\n with_transaction_returning_status do\n assign_attributes(attributes)\n save\n end\n ensure\n @sunstone_updating = false\n Thread.current[:sunstone_updating_model] = nil\n end", "def update_attributes(attrs)\n if id = attrs.delete(:id)\n @id = id\n end\n attrs.each do |key, value|\n setter = :\"#{key}=\"\n send(setter, value) if respond_to?(setter)\n end\n end", "def update\n\t\t# Left empty intentionally.\n\tend", "def update\n \n end", "def update_attributes(attrs)\n super({})\n end", "def update(...)\n end", "def update_attributes(attributes)\n attributes, rdf_attributes = extract_attributes!(attributes)\n rdf_attributes.each do |k,v|\n send(k + \"=\", v)\n send('save_' + k)\n end\n end", "def update\r\n end", "def update_collection(attrs)\n # OVERRIDE: add call to custom #null_controlled_fields! method\n null_controlled_fields!(attrs)\n\n object.attributes = attrs\n object.save!\n end", "def update_attributes(atts)\n atts.each { |att, val| send(:\"#{att}=\", val) }\n end", "def update_attributes(datas)\n search_attributes.each do |val|\n self.send(\"#{val.field}=\", val.cast_value(datas[val.field]))\n end\n end", "def update_attributes(attr = {})\n attr.each_pair do |k, v|\n if v.is_a?(Array) || v.is_a?(Hash)\n send(\"#{k}=\", v.dup)\n else\n send(\"#{k}=\", v)\n end\n end\n end", "def update\n\n DBConnection.execute2(<<-SQL, attribute_values)\n UPDATE\n #{class_obj.table_name}\n SET\n #{sql_update_set}\n WHERE\n id = #{self.id}\n SQL\n\n end", "def update\n\n end", "def update\n\n end", "def update\n\n end", "def update\n\n end" ]
[ "0.7645054", "0.7633404", "0.73756105", "0.7366844", "0.73351717", "0.7297924", "0.71421564", "0.71411645", "0.71272355", "0.7118093", "0.7118093", "0.7118093", "0.7118093", "0.7071239", "0.70699656", "0.7041255", "0.70398355", "0.69911385", "0.6910913", "0.69062734", "0.68597525", "0.68394417", "0.68131614", "0.68131614", "0.68131614", "0.6799483", "0.67663467", "0.6750684", "0.67351574", "0.67346114", "0.6733714", "0.67298543", "0.6727001", "0.6698991", "0.6693433", "0.66831654", "0.66807145", "0.66807145", "0.66719186", "0.6670684", "0.6665886", "0.6658803", "0.66411257", "0.6631038", "0.6621217", "0.6619149", "0.6612301", "0.6589535", "0.65845156", "0.65835714", "0.65738237", "0.65733683", "0.6572285", "0.65647805", "0.65564257", "0.65555197", "0.65146875", "0.6502777", "0.64940524", "0.64940524", "0.64940524", "0.64940524", "0.64940524", "0.64940524", "0.64940524", "0.64940524", "0.6490001", "0.6485996", "0.648114", "0.64693654", "0.6468042", "0.6462391", "0.6457785", "0.6452919", "0.64412034", "0.6433515", "0.64313656", "0.6430091", "0.6427553", "0.6416688", "0.64117503", "0.6411185", "0.640798", "0.6405472", "0.6400952", "0.6398717", "0.63980436", "0.6396403", "0.639209", "0.6387843", "0.6385324", "0.6378066", "0.6372068", "0.6370349", "0.63627243", "0.63626397", "0.6360769", "0.63573265", "0.63573265", "0.63573265", "0.63573265" ]
0.0
-1
Set some defaults when the task lib is set up.
def setup( _name, **options ) super if defined?( super ) self.extensions.include( Rake::DevEiate::EXT_DIR + EXTENSION_GLOB_PATTERN ) @disable_rake_compiler = false end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_defaults\n self.help ||= ENV['help_text']\n self.help_url ||= ENV['help_url']\n self.created_at ||= DateTime.current\n end", "def define_default_tasks\n\n\t\t# task used to indicate that rake-deveiate has already been setup once; for\n\t\t# global rakefiles.\n\t\ttask :deveiate do\n\t\t\t# no-op\n\t\tend\n\n\t\tdesc \"The task that runs by default\"\n\t\ttask( :default => :spec )\n\n\t\tdesc \"Check in the current changes\"\n\t\ttask :checkin => [ :precheckin, :check, :test ]\n\t\ttask :commit => :checkin\n\t\ttask :ci => :checkin\n\t\ttask :precheckin\n\n\t\tdesc \"Sanity-check the project\"\n\t\ttask :check\n\n\t\tdesc \"Update the history file\"\n\t\ttask :update_history\n\n\t\tdesc \"Package up and push a release\"\n\t\ttask :release => [ :prerelease, :gem, :release_gem, :postrelease ]\n\t\ttask :prerelease\n\t\ttask :release_gem\n\t\ttask :postrelease\n\n\t\tdesc \"Run all the project's tests\"\n\t\ttask :test\n\t\ttask :spec\n\t\ttask :integration\n\n\t\tdesc \"Set up the project for development\"\n\t\ttask :setup do\n\t\t\tself.install_dependencies\n\t\tend\n\n\t\tdesc \"Turn on maintainer mode: build with extra warnings and debugging\"\n\t\ttask :maint do\n\t\t\tENV['MAINTAINER_MODE'] = 'yes'\n\t\tend\n\n\tend", "def set_defaults\n end", "def set_defaults\n end", "def setup_defaults\n @program_title = 'PROGRAM TITLE'\n @program_site = 'PROGRAM SITE'\n @request_availability = false\n @meeting_times = ''\n @sourcing_options = ''\n @course_options = ''\n @student_id_required = false\n @student_id_format = ''\n @student_id_format_help = ''\n @student_id_excluded_chars = ''\n @contact_email = 'info@bebraven.org'\n @is_preaccelerator_student = false\n end", "def set_defaults!\n __load_config( DEFAULTS )\n end", "def set_defaults\n\n end", "def set_defaults\n\n end", "def set_defaults\n\n end", "def set_defaults\n\n end", "def set_defaults\n\n end", "def set_defaults\n\n end", "def build_default_tasks\n @rake_task << self.step_template # get General Configuration information\n end", "def configure_tasks\n end", "def setup_defaults\n\n @logger.debug(\"AwsWorkers::S3::BackupBucketTask.setup_defaults called\")\n\n @permissions = 'private' if @permissions.blank?\n @max_thread_count = 1 if @max_thread_count.blank?\n\n raise \"Source bucket missing.\" if @source_bucket_name.blank?\n raise \"Destination bucket missing.\" if @destination_bucket_name.blank?\n end", "def set_task(name,task=nil) # Add a Task and its name\n @defaults['taskname']=name.to_s # taskname = task name\n if ! task.nil?\n @defaults['taskobj']=task # taskobj = the Task\n @defaults['env']=task.envars # env = the Task's env vars\n @defaults['seq']=task.seq # seq = Task's index location\n end\n return self\n end", "def taskOpts\nend", "def _set_defaults(opts={})\n @miq_provider_name = opts.fetch(:miq_provider, 'noop')\n @export_dir = opts.fetch(:export_dir, 'automate')\n @export_name = opts.fetch(:export_name, @name)\n @miq_import_method = opts.fetch(:miq_import_method, :partial)\n @miq_priority = opts.fetch(:miq_priority, 10)\n @branch_name = opts.fetch(:branch_name, 'No Branch')\n end", "def load_defaults\n @dev_port = @default_dev_port\n @dev_pid = @default_dev_pid\n @dev_log = @default_dev_log\n @prod_port = @default_prod_port\n @prod_pid = @default_prod_pid\n @prod_log = @default_prod_log\nend", "def define_tasks\r\n define_clobber_task\r\n define_build_task\r\n end", "def define_tasks\r\n define_repeat_task\r\n define_clobber_task\r\n define_build_task\r\n end", "def set_defaults\n self.last_run ||= '1999-9-9 00:00:00 UTC'\n self.status ||= 3\n self.query_run_time ||= 0\n self.alert_value ||= '0'\n end", "def set_default_values\n # Ethernet configuration\n self.network_1_id ||= 1\n self.ethernet_ip_assignment_method_id ||=1\n # GRPS\n self.gprs_mtu ||= 1450\n # PSTN\n self.pstn_mtu ||= 1500\n # Time configuration\n self.time_zone ||= 'UTC'\n # Interval configuration\n self.configuration_update_interval ||= 3600\n self.status_interval ||= 3600\n self.send_data_interval ||= 86400\n # Software update configuration\n self.auto_update ||= false\n self.software_update_interval ||= 604800\n self.repo_type ||= 'stable'\n # Log configuration\n self.send_log_files ||= false\n # State XML\n self.state_xml ||= \"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?>\\n<modified>true</modified>\\n\"\n end", "def load_defaults\n @project_root ||= default_project_root\n @packaging_root ||= default_packaging_root\n\n Pkg::Params::DEFAULTS.each do |v|\n unless self.instance_variable_get(\"@#{v[:var]}\")\n self.instance_variable_set(\"@#{v[:var]}\", v[:val])\n end\n end\n end", "def init_quick_defaults\n @quick_defaults=Hash.new\n @quick_defaults['enabled']=false\n @quick_defaults['launch']='ONETIME'\n @quick_defaults['launch_now']=true\n @quick_defaults['description']='Created with nessus_rest'\n end", "def initialize(*args)\n super(*args)\n if args.first.is_a?(Hash)\n initializers = args.first\n if task_definition = initializers[:prototype] then\n setup_task_definition_defaults(task_definition)\n end\n end\n end", "def set_defaults\n unless persisted? \n self.active ||= false\n self.complete ||= false\n self.start_on ||= Date.today\n self.finished_on ||= Date.today + 1\n end\n end", "def initialize task_name, rake_application\n super\n @logger = $stdout\n @mm_config = MMConfig.new\n @reader = LogFile.new\n @trust_config = Trust.new\n @process = nil\n @input = task_name\n\n @pkg_name = FlashPlayer::NAME\n @pkg_version = FlashPlayer::VERSION\n end", "def deferred_defaults\n set_default_path\n set_default_properties\n end", "def get_default_options\n get_options([:default_task_heartbeat_timeout, :default_task_schedule_to_close_timeout, :default_task_schedule_to_start_timeout, :default_task_start_to_close_timeout])\n end", "def default_task_options\n {:reatime => false}\n end", "def setup_defaults!\n @options[:touch] = true unless @options.key?(:touch)\n end", "def add_task_option_defaults(options)\n registered_task_options.each { |option| options.add(option.key, option.default) }\n end", "def set_default_options\n end", "def set_defaults\n self.not_to_exceed ||= false\n self.emergency ||= false\n end", "def set_defaults\n self.not_to_exceed ||= false\n self.emergency ||= false\n end", "def set_defaults\n if self.state.blank?\n self.state ||= :unsubmitted\n end\n if self.priority.blank?\n self.priority ||= :medium\n end\n if self.start.blank?\n self.start = Time.now + 1.day\n end\n if self.end.blank?\n self.end = start.to_time + 1.hour\n end\n if self.repeats.blank?\n end\n end", "def options_defaults(options)\n options[:parallel_run] = 0\n end", "def initialize\r\n load_tasks\r\n end", "def set_defaults\n self.completed ||= false\n end", "def set_defaults\n self.created_at ||= DateTime.now.utc\n self.keyword ||= nil\n self.extra ||= nil\n end", "def use_defaults(*args)\n default_setup(*args)\n default_teardown(*args)\n end", "def apply_system_defaults\n if @region.nil? && @zone.nil?\n @region, @zone = Rudy::DEFAULT_REGION, Rudy::DEFAULT_ZONE\n elsif @region.nil?\n @region = @zone.to_s.gsub(/[a-z]$/, '').to_sym\n elsif @zone.nil?\n @zone = \"#{@region}b\".to_sym\n end\n \n @environment ||= Rudy::DEFAULT_ENVIRONMENT\n @role ||= Rudy::DEFAULT_ROLE\n @localhost ||= Rudy.sysinfo.hostname || 'localhost'\n @auto = false if @auto.nil?\n end", "def required_defaults; end", "def setup(settings = {})\n @config = defaults.merge(settings)\n end", "def initialize\n set_defaults\n end", "def initialize\n set_defaults\n end", "def default_configuration=(_arg0); end", "def set_prerun_config_defaults\n @@config.daemon_name = File.basename(__FILE__) unless @@config.daemon_name\n @@config.pid_file = \"#{@@config.daemon_name}.pid\" unless @@config.pid_file\n @@config.force_kill_wait = nil unless @@config.force_kill_wait\n @@config.group = nil unless @@config.group\n @@config.user = nil unless @@config.user\n end", "def set_default_options()\n @options = OpenStruct.new(\n :output_base => nil,\n :verbose => false,\n :config_file => nil,\n :samples => nil,\n :delay => 30,\n :scheduler_opts => ''\n )\nend", "def default_values\n\t\tself.done ||= 'false'\n\t\tself.flag ||= 'false'\n\tend", "def set_defaults\n self.state ||= 'ACTIVE'\n self.account_user_id ||= Gizmo::Util::Uuid.generate\n self.is_owner ||= false\n end", "def initializeDefaultParams()\n @fcName = nil # Flowcell name\n @baseCallsDir = nil # BaseCalls dir of the flowcell\n @useBasesMask = nil # Custom value to provide to BCL->FastQ convertor\n @sampleSheet = nil # Path to SampleSheet.csv\n\n yamlConfigFile = PathInfo::CONFIG_DIR + \"/config_params.yml\" \n @configReader = YAML.load_file(yamlConfigFile)\n @queue = SchedulerInfo::CASAVA_QUEUE # The processing queue on the cluster\n end", "def set_defaults\n self.main_image ||= Placeholder.image_generator(height: 600, width: 400) # go to concern folder\n self.thumb_image ||= Placeholder.image_generator(height: 350, width: 200) # go to concern folder\n end", "def define_tasks\n define_weave_task\n connect_common_tasks\n end", "def initialize options: nil, tasks: nil, validators: nil\n @options = options.nil? ? {} : options.clone\n @tasks = tasks.nil? ? {} : tasks.clone\n @validators = validators.nil? ? {} : validators.clone\n\n @options.each do |key,val|\n define_option_accessor key.to_sym\n end\n\n @validators.each do |key,val|\n define_validator key.to_sym\n end\n end", "def define_tasks\n # Run the command on the local system\n def run(cmd)\n Kernel.system(cmd.runnable)\n end\n # Basic setup action\n def setup_application\n @options ||= PoolParty.options(ARGV.dup)\n end\n \n # Require the poolparty specific tasks\n compiled_rakefile\n \n desc \"Reload the static variables\"\n task :reload do\n reload!\n end\n true\n end", "def set_defaults\n self.published ||= false\n self.archived ||= false\n self.is_default ||= false\n self.version ||= 0\n self.visibility = ((self.org.present? && self.org.funder_only?) || self.is_default?) ? Template.visibilities[:publicly_visible] : Template.visibilities[:organisationally_visible] unless self.id.present?\n self.customization_of ||= nil\n self.family_id ||= new_family_id\n self.archived ||= false\n self.links ||= { funder: [], sample_plan: [] }\n end", "def set_defaults\n @defaults = RHC::Vendor::ParseConfig.new()\n @opts = RHC::Vendor::ParseConfig.new() # option switches that override config file\n\n @env_config = RHC::Vendor::ParseConfig.new()\n @global_config = nil\n @local_config = nil\n @opts_config = nil # config file passed in the options\n @additional_config = nil\n\n @default_proxy = nil\n\n @defaults.add('insecure', false)\n @defaults.add('libra_server', openshift_online_server)\n\n @env_config.add('libra_server', libra_server_env) if libra_server_env\n @env_config.add('libra_server', rhc_server_env) if rhc_server_env\n\n @opts_config_path = nil\n 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 apply_environment_defaults\n @format = env(:format, @format) if @format.nil?\n @autopath = env(:autopath, @autopath) if @autopath.nil?\n @files = env(:files, @files) if @files.empty?\n @match = env(:match, @match) if @match.empty?\n @tags = env(:tags, @tags) if @tags.empty?\n @units = env(:units, @units) if @units.empty?\n @requires = env(:requires, @requires) if @requires.empty?\n @loadpath = env(:loadpath, @loadpath) if @loadpath.empty?\n end", "def initialize\n dependencies = if defined?(::Rails)\n [:environment]\n else\n []\n end\n\n define_tasks(dependencies)\n end", "def prepare_task\n end", "def set_defaults\n self.main_image ||= Placeholder.image_generator(height: '600', width: '400')\n self.thumb_image ||= Placeholder.image_generator(height: '350', width: '200')\n end", "def set_defaults\n\t\tself.main_image ||= Placeholder.image_generator(height: '600', width: '400')\n\t\tself.thumb_image ||= Placeholder.image_generator(height: '350', width: '200')\n\tend", "def set_defaults\n\t\tself.main_image ||= Placeholder.image_generator(height: '200', width: '200')\n\t\tself.thumb_image ||= Placeholder.image_generator(height: '300', width: '300')\n\tend", "def set_defaults\n self.active = self.active.nil? ? true : self.active\n self.sogr ||= false\n self.notional ||= false\n self.multi_year ||= false\n self.emergency ||= false\n self.state ||= :unsubmitted\n self.project_number ||= 'TEMP'\n # Set the fiscal year to the current fiscal year which can be different from\n # the calendar year\n self.fy_year ||= current_fiscal_year_year\n end", "def set_defaults\n self.active = self.active.nil? ? true : self.active\n self.estimated_cost ||= 0\n self.anticipated_cost ||= 0\n end", "def set_defaults\n super\n end", "def set_defaults\n super\n end", "def init_defaults\n if @action == \"list\"\n init_colors\n else\n\n # only for adding a bug\n t = Time.now\n # in order to support the testing framework\n #ut = ENV[\"TODO_TEST_TIME\"]\n #t = Time.at(ut.to_i) if ut\n @now = t.strftime(\"%Y-%m-%d %H:%M:%S\")\n #@today = t.strftime(\"%Y-%m-%d\")\n @verbose = @options[:verbose]\n # menu MENU\n @valid_type = %w[bug enhancement feature task] \n @valid_severity = %w[normal critical moderate] \n @valid_status = %w[open started closed stopped canceled] \n @valid_priority = %w[P1 P2 P3 P4 P5] \n $prompt_desc = $prompt_type = $prompt_status = $prompt_severity = $prompt_assigned_to = $prompt_priority = true\n $default_priority = nil\n $default_type = \"bug\"\n $default_severity = \"normal\"\n $default_status = \"open\"\n $default_priority = \"P3\"\n $default_assigned_to = \"unassigned\"\n $default_due = 5 # how many days in advance due date should be\n #$bare = @options[:bare]\n $use_readline = true\n $g_row = nil\n end\n # we need to load the cfg file here, if given # , or else in home dir.\n # we place this here so it can override defaults\n if @options[:config]\n load @options[:config]\n end\n end", "def init!\n @defaults = {\n :@refresh_token => ENV[\"STC_REFRESH_TOKEN\"],\n :@client_id => ENV[\"STC_CLIENT_ID\"],\n :@client_secret => ENV[\"STC_CLIENT_SECRET\"],\n :@language_code => \"nl-NL\",\n :@environment => 'test',\n :@version => 1,\n :@verbose => false,\n }\n end", "def set_defaults\n self.active = self.active.nil? ? true : self.active\n self.show_in_dashboard = self.show_in_dashboard.nil? ? true : self.show_in_dashboard\n self.system_activity = self.system_activity.nil? ? false : self.system_activity\n self.frequency_quantity ||= 1\n end", "def initialize task_name, rake_application\n super\n @input = task_name\n @player = FlashPlayer::Executable.new\n @pkg_name = FlashPlayer::NAME\n @pkg_version = FlashPlayer::VERSION\n end", "def set_defaults\n # should set the default based on category\n if self.fta_asset_category.try(:name) == 'Facilities'\n self.useful_life_benchmark ||= 3\n self.useful_life_benchmark_unit ||= 'condition_rating'\n elsif self.fta_asset_category.try(:name) != 'Infrastructure'\n self.useful_life_benchmark ||= self.asset_level.try(:default_useful_life_benchmark)\n self.useful_life_benchmark_unit ||= self.asset_level.try(:useful_life_benchmark_unit)\n end\n\n self.useful_life_benchmark_locked = self.useful_life_benchmark_locked.nil? ? false : self.useful_life_benchmark_locked\n\n if self.fta_asset_category.try(:name) == 'Infrastructure'\n self.pcnt_goal ||= 10\n else\n self.pcnt_goal ||= 0\n end\n\n self.pcnt_goal_locked = self.pcnt_goal_locked.nil? ? false : self.pcnt_goal_locked\n\n end", "def initialize(task)\n super()\n @task= task \n end", "def use_defaults_if_nil\n @move = TactBattleManager::Defaults::Move if @move.nil?\n @jump_length = TactBattleManager::Defaults::Jump if @jump_length.nil?\n @passables = TactBattleManager::Defaults::Passables if @passables.nil?\n @jumpables = TactBattleManager::Defaults::Jumpables if @jumpables.nil?\n end", "def _init_configuration\n\t\t# Set defaults\n\t\t@setup = { \"create\" => false, \"environment\" => false, \"test\" => true, \"destroy\" => false }\n\t\t@config = false\n\tend", "def init_default_config\n configuration.project_id ||= Debugger.default_project_id\n configuration.credentials ||= Debugger.default_credentials\n configuration.service_name ||= Debugger.default_service_name\n configuration.service_version ||= Debugger.default_service_version\n end", "def default_options=(opts); end", "def set_defaults\n\t\tself.module_info = {\n\t\t\t'Name' => 'No module name',\n\t\t\t'Description' => 'No module description',\n\t\t\t'Version' => '0',\n\t\t\t'Author' => nil,\n\t\t\t'Arch' => nil, # No architectures by default.\n\t\t\t'Platform' => [], # No platforms by default.\n\t\t\t'Ref' => nil,\n\t\t\t'Privileged' => false,\n\t\t\t'License' => MSF_LICENSE,\n\t\t}.update(self.module_info)\n\t\tself.module_store = {}\n\tend", "def set_defaults\n self.allow_download ||= false\n self.allow_streaming ||= false\n self.expired ||= false\n self.revoked ||= false\n end", "def setup\n # noop\n end", "def defaults \n default_run_options[:pty] = true\n\tset :deploy_to, \"/usr/local/www/#{application}-#{rails_env}\"\n\tset :apache_config_file, \"#{application}-#{rails_env}.conf\"\n\tset :apache_logs, \"/var/log/apache2/#{application}-#{rails_env}\"\n set :files_dir, \"#{deploy_to}/files\"\n\n # Environment specific tasks\n case rails_env\n when \"staging\"\n after \"deploy:symlink\", \"deploy:cleanup\" # cleanup older versions if successful\n when \"preview\"\n # nothing yet\n when \"production\"\n # nothing yet\n end\nend", "def set_async_defaults\n @async_transport_options ||= {}\n defaults = {\n queue: \"magic_pipe\"\n }\n @async_transport_options = defaults.merge(@async_transport_options)\n end", "def default_options\n {\n thread_count: DEFAULT_THREAD_COUNT,\n ssh: Hash.new\n }\n end", "def default_options\n {\n thread_count: DEFAULT_THREAD_COUNT,\n ssh: Hash.new\n }\n end", "def setup_defaults()\n {\n 'box' => {\n 'memory' => '2048',\n 'cpus' => '2'\n }\n }\nend", "def set_defaults\n\t\t#when ever you are creating a new portfolio item (nothing else)\n\t\t#||= means if nil, replace with this:\n\t\tself.main_image ||= Placeholder.image_generator(height: '600', width: '400')\n\t\tself.thumb_image ||= Placeholder.image_generator(height: '350', width: '200')\n\tend", "def add_defaults_local\n super\n self.timestamp ||= Java.now\n self.user ||= default_user\n end", "def initializeDefaultParams()\n @fcName = nil # Flowcell name\n @baseCallsDir = nil # BaseCalls dir of the flowcell\n @useBasesMask = nil # Custom value to provide to BCL->FastQ convertor\n @sampleSheet = nil # Path to SampleSheet.csv\n yamlConfigFile = File.dirname(File.expand_path(File.dirname(__FILE__))) +\n \"/config/config_params.yml\" \n @configReader = YAML.load_file(yamlConfigFile)\n @queue = \"high\" # The processing queue on the cluster\n end", "def set_defaults\n #self.required_by_manufacturer ||= true\n end" ]
[ "0.70905405", "0.69210917", "0.68945366", "0.68945366", "0.6879856", "0.6806768", "0.6771333", "0.6771333", "0.6771333", "0.6771333", "0.6771333", "0.6771333", "0.67461807", "0.66423833", "0.6638912", "0.6575797", "0.65376776", "0.6518301", "0.65101755", "0.650838", "0.64936835", "0.6473928", "0.6462837", "0.6429125", "0.6423657", "0.64226604", "0.63875854", "0.63708955", "0.63405514", "0.6265598", "0.62542313", "0.6231559", "0.62181777", "0.6208528", "0.6182695", "0.6182695", "0.6165787", "0.61644375", "0.61614215", "0.61595786", "0.615815", "0.6155429", "0.6145401", "0.61343455", "0.6126691", "0.612139", "0.612139", "0.6120405", "0.61127794", "0.6101575", "0.60908866", "0.60873586", "0.6063912", "0.60556024", "0.6044845", "0.60414463", "0.60338295", "0.60257506", "0.60256845", "0.6024222", "0.6024222", "0.6024222", "0.6024222", "0.6024222", "0.6024222", "0.6024222", "0.6024222", "0.6024222", "0.6024222", "0.6010451", "0.59995943", "0.5999345", "0.599825", "0.5987961", "0.5984943", "0.5984006", "0.5981511", "0.5980613", "0.5980613", "0.5975587", "0.59738386", "0.5958528", "0.5953818", "0.59498525", "0.59423447", "0.59366214", "0.5932032", "0.5929527", "0.59289855", "0.5926598", "0.59264594", "0.5922792", "0.59205985", "0.5916332", "0.59063756", "0.59063756", "0.5904065", "0.58928835", "0.5890351", "0.5887563", "0.5885123" ]
0.0
-1
Predicate for the disable_rake_compiler attribute.
def disable_rake_compiler? return self.disable_rake_compiler ? true :false end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def has_rakecompiler_dependency?\n\t\treturn self.dependencies.any? do |dep|\n\t\t\tdep.name == 'rake-compiler'\n\t\tend\n\tend", "def agent_should_start?\n !blacklisted_constants? &&\n !blacklisted_executables? &&\n !in_blacklisted_rake_task?\n end", "def auto_exclude?\n @auto_exclude\n end", "def needed_if_relevant?\n false\n end", "def needed_if_relevant?\n false\n end", "def without_autobuild?\n Threaded.executing?(:without_autobuild)\n end", "def ignore_force?(task)\n !(metadata[\"run_#{task}\"].nil? || metadata[\"run_#{task}\"])\n end", "def _validate_compiler_flags(flags)\n if flags.join(' ').split(' ').any? { |flag| flag.start_with?('-Wno') }\n results.add_warning('compiler_flags', 'Warnings must not be disabled' \\\n '(`-Wno compiler` flags).')\n end\n end", "def ignore_task?(task)\n return true if metadata[\"run_#{task}\"] == false\n\n !clade? && @@INCLADE_TASKS.include?(task) && metadata[\"run_#{task}\"] != true\n end", "def compiling?\n !@converging\n end", "def is_rake\n\tFile.basename($0) == 'rake'\nend", "def should_skip\n if @needed.nil?\n @needed = prerequisite_tasks.empty? || \\\n input_files.since(@last_executed).any? || \\\n @force\n\n # We also make sure that if the rakefile was modified since last\n # execution, we force reexecution\n if @application.rakefile\n @needed ||= File.mtime(@application.rakefile) > @last_executed\n end\n end\n !@needed\n end", "def initialize_compiler\n self.compile_tasks = [:multi, :test, :check_manifest]\n end", "def constant_false_predicate?\n ! (predicate.respond_to?(:call) || constant_true_predicate?)\n end", "def compilable?\n false\n end", "def ignore_task?(task)\n return true unless is_active?\n return !metadata[\"run_#{task}\"] unless metadata[\"run_#{task}\"].nil?\n return true if task==:taxonomy and project.metadata[:ref_project].nil?\n pattern = [true, false]\n ( [@@_EXCLUDE_NOREF_TASKS_H[task], is_ref? ]==pattern or\n [@@_ONLY_MULTI_TASKS_H[task], is_multi? ]==pattern or\n [@@_ONLY_NONMULTI_TASKS_H[task], is_nonmulti?]==pattern )\n end", "def toggle_allow_evals\n update_attribute :allow_evals, !allow_evals?\n allow_evals?\n end", "def is_cross_compiled?\n return @cross_compiled\n end", "def ignore_production_checks?\n ignore_production_checks != 'false'\n end", "def disabled?\n Support.new(ENV, verbose: verbose).disabled?\n end", "def test_disabled?\n ENV['NO_TEST'] == '1'\nend", "def test_disabled?\n ENV['NO_TEST'] == '1'\nend", "def disabled?\n super || !gemfile.exist?\n end", "def never\n to_unbound_task_predicate.never\n end", "def should_remove_librun_and_stc_sources\n !(core_developer? or ENV['RETAIN_STX_AND_LIBRUN_SOURCE'] == 'yespleaseretain!')\nend", "def runCompiler(_override_type = nil)\n runOpen3StuckPrevention('make', '-j', $compileThreads.to_s) == 0\n end", "def activate_compiler_deps\n dependency \"rake-compiler\", \"~> 1.0\", :development\n\n gem \"rake-compiler\", \"~> 1.0\"\n rescue LoadError\n warn \"Couldn't load rake-compiler. Skipping. Run `rake newb` to fix.\"\n end", "def config_tool_needed?\n false\n end", "def negate\n to_unbound_task_predicate.negate\n end", "def ignore_task?(task)\n why_ignore(task) != :execute\n end", "def explain_false(task); end", "def compiled?\n !!@compiled\n end", "def compiled?\n !!@compiled\n end", "def compilable?\n false\n end", "def skip_unless(eng, bt: caller)\n skip_msg = case eng\n when :darwin then \"Skip unless darwin\" unless RUBY_PLATFORM[/darwin/]\n when :jruby then \"Skip unless JRuby\" unless Puma.jruby?\n when :windows then \"Skip unless Windows\" unless Puma.windows?\n when :mri then \"Skip unless MRI\" unless Puma.mri?\n else false\n end\n skip skip_msg, bt if skip_msg\n end", "def spec_is_disabled?(file_name_spec)\n file_name_spec = Noop::Utils.convert_to_path file_name_spec\n spec_run_metadata.fetch(file_name_spec, {}).fetch(:disable, false)\n end", "def exclude_css?\n options.include?( :exclude_css ) && ( options[:exclude_css] == 'true' || options[:exclude_css] == true )\n end", "def runnable?\n tool_class.public_instance_methods(false).include?(:run)\n end", "def disable?\n false\n end", "def bypass_maintenance?\n !!runopts(:bypass_maintenance)\n end", "def exclude_target?\n @exclude_target.nil? ? self.auto? : !!@exclude_target\n end", "def recompile?\n true\n end", "def recompile?\n true\n end", "def suppress?\n !!@suppress\n end", "def compileif\n\n end", "def test_prerelease?(_)\n false\n end", "def force_analysis\n false\n end", "def force_analysis\n false\n end", "def should_build?\n config.auto_build && !dev_server_running?\n end", "def compiled?\n !@result.nil?\n end", "def disabled?\n deprecated? || deleted?\n end", "def exclude?(fn)\n calculate_exclude_regexp unless @exclude_re\n fn =~ @exclude_re\n end", "def ignore_project?(task)\n task == :taxonomy && project.option(:ref_project).nil?\n end", "def conditionally_false\n\t\t!self\n\tend", "def safe_compile!(compiler)\n begin\n compiler.compile!\n rescue\n recompile_assets!(compiler)\n end\n end", "def enabled_dependencies\n @dependencies.reject(&:ignore?)\n end", "def disable!\n\n @enabled = false\n \n @gems_or_gemsets.each do |this_gem_or_gemset, true_value|\n this_gem_or_gemset.disable!\n end\n \n return self\n \n end", "def emails_disabled?\n ENV[\"#{self.class}_emails_disabled\"] == 'true'\n end", "def disabled?; end", "def disabled?; end", "def disable_warnings?(method_key = T.unsafe(nil)); end", "def dependency_unmet?(*args, &block); end", "def manual_enabled?\n return true\n end", "def skip_eager_load_paths?(path)\n path =~ %r{/cli} ||\n path =~ %r{/core_ext} ||\n path =~ %r{/default/application} ||\n path =~ %r{/functions} ||\n path =~ %r{/internal/app} ||\n path =~ %r{/jets/stack} ||\n path =~ %r{/rackup_wrappers} ||\n path =~ %r{/overrides} ||\n path =~ %r{/reconfigure_rails} ||\n path =~ %r{/templates/} ||\n path =~ %r{/version} ||\n path =~ %r{/webpacker}\n end", "def deploy_disabled?\n ENV['NO_DEPLOY'] == '1'\nend", "def deploy_disabled?\n ENV['NO_DEPLOY'] == '1'\nend", "def deploy_disabled?\n ENV['NO_DEPLOY'] == '1'\nend", "def anti_reflect?\n !note[TSBS::AntiReflect].nil?\n end", "def anti_reflect?\n !note[TSBS::AntiReflect].nil?\n end", "def transproc\n Functions[:exclude, selector]\n end", "def ignore_by_type?(task, type)\n return false if force_task?(task)\n\n test, list =\n case type.to_sym\n when :noref\n [:ref?, self.class.EXCLUDE_NOREF_TASKS]\n when :multi\n [:multi?, self.class.ONLY_MULTI_TASKS]\n when :nonmulti\n [:nonmulti?, self.class.ONLY_NONMULTI_TASKS]\n else\n raise \"Unexpected error, unknown type reason: #{type}\"\n end\n\n list.include?(task) && !send(test)\n end", "def optimizable?\n super || !predicate.equal?(operation.predicate)\n end", "def source_required?\n false\n end", "def source_required?\n false\n end", "def source_required?\n false\n end", "def enabled\n !false?(configuration[:enabled])\n end", "def allowed_on_commandline?\n @deprecated == :allowed_on_commandline\n end", "def exclude?(fn)\n calculate_exclude_regexp unless @exclude_re\n fn =~ @exclude_re\n end", "def tool_enabled?(tool)\n options[\"#{tool}_enabled\"].to_i == 1\n end", "def evaluable?\n true\n end", "def ignore?\n @should_ignore\n end", "def supports_exclusion_constraints?\n false\n end", "def source_required?\n false\n end", "def disabled?(visitor)\n visitor.is_a?(HamlLint::Linter) &&\n comment_configuration.disabled?(visitor.name)\n end", "def disable(probe)\n Ruby.primitive :taskprobe_disable\n raise PrimtiveFailure, \"TaskProbe#disable primitive failed\"\n end", "def is_for_test_rail_plan\n !ENV[\"TESTRAIL_RUN\"].nil? && !ENV[\"TESTRAIL_PLAN_ID\"].nil? && !ENV[\"TESTRAIL_ENTRY_ID\"].nil? && !ENV[\"TESTRAIL_ENTRY_RUN_ID\"].nil?\n end", "def executable?\n @executable || (@executable.nil? && !garbage? && plan && plan.executable?)\n end", "def enabled?; end", "def enabled?; end", "def compile_time?\n check_for_old_attributes!\n node['build-essential']['compile_time']\n end", "def preconditions arr\n arr.each {|i|\n if (i.is_bool? && i==false) || (i.is_a?(Proc) && (i.call==false))\n return false\n end\n }\n return true\nend", "def threshold_disabled?\n !@enable_threshold\n end", "def change_declaration_required?\n (application_type != 'LO-WD')\n end", "def skip_comments?\n @skip_comments\n end", "def to_bool() false end", "def is_for_test_rail_run\n !ENV[\"TESTRAIL_RUN_ID\"].nil? && ENV[\"TESTRAIL_RUN\"].nil? && ENV[\"TESTRAIL_PLAN_ID\"].nil?\n end", "def cond; end", "def cond; end", "def cond; end", "def config_disabled(thing)\n check = thing.to_s\n to_check = [Carnivore::Config.get(:fission, :core, :disable)].flatten.compact\n to_check.include?(check)\n end" ]
[ "0.6383474", "0.55502146", "0.54244685", "0.5416403", "0.5401313", "0.5360261", "0.5332903", "0.53170156", "0.53077435", "0.522613", "0.5174628", "0.51405907", "0.51320493", "0.5130798", "0.5088376", "0.5084573", "0.5083059", "0.50676864", "0.5049461", "0.50479543", "0.5043592", "0.5043592", "0.5030506", "0.50272954", "0.50262576", "0.5025907", "0.5003042", "0.49745476", "0.49510694", "0.49417758", "0.49381053", "0.49000266", "0.49000266", "0.48845363", "0.48783976", "0.48768508", "0.4874435", "0.4873456", "0.48727357", "0.48717713", "0.48655668", "0.48635775", "0.48635775", "0.48508742", "0.48484102", "0.48390532", "0.48348016", "0.48348016", "0.48303825", "0.48177385", "0.4809911", "0.47870713", "0.47796306", "0.47741374", "0.47709647", "0.4763728", "0.4762708", "0.47612688", "0.47495916", "0.47495916", "0.47410142", "0.47355452", "0.47316778", "0.4731115", "0.4727132", "0.47257602", "0.47257602", "0.47217402", "0.47217402", "0.47192934", "0.47174746", "0.47134298", "0.47001123", "0.46993193", "0.46993193", "0.4697576", "0.46944255", "0.46936175", "0.46909922", "0.46840417", "0.46814147", "0.4681176", "0.46774194", "0.4674722", "0.46745184", "0.46734324", "0.46618247", "0.4659292", "0.4659292", "0.46541438", "0.46496585", "0.46496212", "0.464711", "0.46464786", "0.46418524", "0.46414244", "0.463964", "0.463964", "0.463964", "0.46330786" ]
0.8187891
0
Returns +true+ if there appear to be extensions as part of the current project.
def extensions_present? return !self.extensions.empty? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def appearable_extensions?\n exs = @extensions.keys - APPEARABLE_CH_EXTENSIONS\n return true if exs.empty?\n\n !(exs - DEFINED_EXTENSIONS).empty?\n end", "def missing_extensions?\n return false if extensions.empty?\n return false if default_gem?\n return false if File.exist? gem_build_complete_path\n\n true\n end", "def extension? name\n @extensions.include? name\n end", "def supports_extensions?\n false\n end", "def supports_extensions?\n false\n end", "def extension?\n @extension != \"\"\n end", "def extension_loaded?\n !!extension_loaded\n end", "def extension_loaded?\n !!extension_loaded\n end", "def complete?\n not @extensions.empty?\n end", "def extension?\n node.name == \"extend\"\n end", "def use_namespaces?\n extensions.count > 1\n end", "def extension_registered?(const)\n @@extensions.include?(const)\n end", "def extension_registered?(const)\n @@extensions.include?(const)\n end", "def complete?\n !@extensions.empty?\n end", "def extension?\n !@arg[:extension].nil?\n end", "def uses_extension?\n @format =~ /\\.[^\\.]+$/\n end", "def extensions_optimizable?\n !extensions.eql?(operation.extensions)\n end", "def registering_extension?\n !register_path.nil?\n end", "def complete?\n (detected_extension and env['PATH_INFO'] =~ /^\\/?(\\.#{Regexp.quote(detected_extension)}\\/?)?$/) ||\n (detected_extension.nil? and env['PATH_INFO'] =~ /^\\/?$/)\n end", "def requires_liberty_extensions?\n false\n end", "def requires_liberty_extensions?\n false\n end", "def requires_liberty_extensions?\n false\n end", "def included_extension_module?(base, extension_module)\n if base.kind_of?(Class)\n direct_superclass = base.superclass\n base.ancestors.take_while { |ancestor| ancestor != direct_superclass}.include?(extension_module)\n else\n base < extension_module # can't do better than that for modules\n end\n end", "def xcode_file?\n ['.nib', '.xcworkspacedata', '.xcuserstate'].include?(extname)\n end", "def include_extensions\n @included_extensions ||= include_extensions!\n end", "def includes_modules?\n @includes_modules\n end", "def precompiled?\n @extname ||= File.extname(self.filepath)[1..-1]\n PRECOMPILED_FILE_TYPES.include?(@extname)\n end", "def contains_requirable_file?(file)\n if @ignored\n return false\n elsif missing_extensions?\n @ignored = true\n\n if Gem::Platform::RUBY == platform || Gem::Platform.local === platform\n warn \"Ignoring #{full_name} because its extensions are not built. \" +\n \"Try: gem pristine #{name} --version #{version}\"\n end\n\n return false\n end\n\n have_file? file, Gem.suffixes\n end", "def has_ext?(path, *exts)\n exts.include? Pa.ext2(get(path))\n end", "def has_modules?\n m = @context.modules.find{|m| m.document_self}\n m ? true : false\n end", "def application?\n (filtered_file =~ /^\\[PROJECT_ROOT\\]/i) && !(filtered_file =~ /^\\[PROJECT_ROOT\\]\\/vendor/i)\n end", "def has_archive_extension?\n self.class.has_archive_extension? stored_file\n end", "def is_supported? filename\n a = filename.split('.')\n $extensions.each do |e|\n return true if e == a.last.downcase\n end\n return false\n end", "def formatted?(path)\n MARKUPS.values.any? { |exts| exts.include?(File.extname(path)) }\n end", "def extname? path\n (last_dot_idx = path.rindex '.') && !(path.index '/', last_dot_idx)\n end", "def registered?(const)\n @@extensions.include?(const)\n end", "def valid_ext?(file, ext_include, ext_exclude = nil)\n ext = File.extname(file).trim('.', '').downcase\n\n is_excluded_ext = false\n is_excluded_ext = ext_exclude.include?(ext) unless ext_exclude.blank?\n\n ext_include.include?(ext) && !is_excluded_ext\n end", "def available_extension?(extension)\n %w[png svg json jpg jpeg].include?(extension)\n end", "def active?(submodule_name)\n active.select { |s| s[:name].to_s == submodule_name.to_s }.any?\n end", "def visit_ext?(path)\n @ext_rules.accept?(File.extname(path)[1..-1])\n end", "def has_extension?(template, extension)\n comparison_length = extension.size + 1 # account for the separator `.`\n template[-comparison_length, comparison_length] == \".#{extension}\"\n end", "def supported?\n PlainTextExtractor.supported_extensions.include?(self.ext_as_sym) unless ext_as_sym==:no_extension and !plain_text?\n end", "def understands_ext?(path)\n extensions.find{|ext| ext == File.extname(path)}\n end", "def page?\n PAGE_EXTS.include? extname\n end", "def installed?\n results = target_files.map {|f| is_my_file?(f) }\n return false if results.include? false\n return true\n end", "def projet_scrivener?\n extension == '.scriv'\nend", "def included?\n @_included\n end", "def file_has_valid_extension?\n file_extension = File.extname(@filename)\n ACCEPTED_FILE_EXTENSIONS.include? file_extension\n end", "def extensions\n\t\teigenclass = ( class << self; self; end )\n\t\treturn eigenclass.included_modules.find_all do |mod|\n\t\t\t(class << mod; self; end).include?(Treequel::Model::ObjectClass)\n\t\tend\n\tend", "def add_files?\n true\n end", "def has_classes_or_modules?\n has_classes? || has_modules?\n end", "def extension_modules\n local_extensions =\n class <<self\n included_modules-Object.included_modules\n end\n if local_extensions.size > 0\n local_extensions\n else\n [] # There weren't any; must be a literal node\n end\n end", "def matches(ext)\n (self.class.extname_list || []).include?(ext.downcase)\n end", "def tracked?\n $repo.ls_files.keys.include?(@name)\n end", "def coffeescript_file?\n extname == \".coffee\"\n end", "def extensions\n @@extensions\n end", "def extensions\n @@extensions\n end", "def gemspec?\n !gemspecs.empty?\n end", "def coffeescript_file?\n ext == \".coffee\"\n end", "def matches(_ext)\n true\n end", "def has_current_version_for?(path)\n file_with_any_ext_exists_for?(non_versioned_path(path))\n end", "def opendocument?\n OPENDOCUMENT_EXTENSIONS.include? file_extension.upcase\n end", "def extension_exists?\n execute(\"SELECT * FROM pg_available_extensions WHERE name = 'hypopg' AND installed_version IS NOT NULL\").any?\n end", "def optimizable?\n super || extensions_optimizable?\n end", "def include?(filename)\n \n end", "def registered?(ext); end", "def registered?(ext); end", "def possibly_include_hidden?\n return @possibly_include_hidden if defined?(@possibly_include_hidden)\n\n @possibly_include_hidden = patterns_to_include.any? do |s|\n s.is_a?(Regexp) || s.start_with?('.') || s.include?('/.')\n end\n end", "def possibly_include_hidden?\n return @possibly_include_hidden if defined?(@possibly_include_hidden)\n\n @possibly_include_hidden = patterns_to_include.any? do |s|\n s.is_a?(Regexp) || s.start_with?('.') || s.include?('/.')\n end\n end", "def external_frame?(f)\n !!(f =~ %r{bundle/gems})\n end", "def add_files?\n false\n end", "def project_is_configured_for_git?\n\t\t\tFile.directory? '.git'\n\t\tend", "def extensions\n @extensions ||= Dir['ext/**/extconf.rb']\n end", "def extensions\n if wrapper\n (wrapper.extensions + config[:extensions]).uniq\n else\n config[:extensions]\n end\n end", "def extension_whitelist\r\n self.class.available_extensions\r\n end", "def project?\n true\n end", "def matches(ext)\n extname_list.include?(ext.downcase)\n end", "def extensions\n @extensions ||= Dir[File.join(@ext_dir, '*')]\n end", "def valid_extensions\n %w[.rb .js]\n end", "def include?\n @options[:include]\n end", "def is_git_directory?\n Dir.entries('.').include? '.git'\n end", "def yaml_file?\n YAML_FILE_EXTS.include?(extname)\n end", "def check_file_extname(path, extnames)\n case extnames\n when Array\n raise \"Extension is not #{extnames}: #{path}\" unless extnames.include?(File.extname(path))\n when File.extname(path)\n true\n else\n raise \"Extension is not #{extnames}: #{path}\"\n end\n end", "def checkFileExtension(file, extensions)\n name = file.original_filename\n ext = getFileExt(name)\n \n if(extensions.include?(ext.downcase))\n return true\n end\n end", "def object_has_hierarchy?\n filepaths.any?(/\\/+/)\n end", "def contents_detected?\n true if find_first_match(:matching => /Gitlab/, :in_file => \"Rakefile\")\n end", "def for_current_impl?\n File.basename(@test_case.folder) =~ /-#{Regexp.quote(@test_case.impl)}/\n end", "def translates?\n included_modules.include?(InstanceMethods)\n end", "def is_framework_package?(name)\n options.current_execution_environment.packages.include?(name) || options.extra_packages.include?(name)\n end", "def matches?(filename)\n filename = filename.downcase\n @extensions.any? { |ext| filename.end_with?(ext) }\n end", "def extension_elidable?(feature)\n feature.to_s.end_with?(\".rb\", \".so\", \".o\", \".dll\", \".dylib\")\n end", "def hasImageFileExtension?(file)\n extensions = %w(cr2 jpg jpeg nef nrw dng)\n extensions.each { |extension|\n if file.downcase.include?(extension)\n return true\n end\n }\n return false\n end", "def matches(ext)\n ext =~ /^\\.org$/i\n end", "def format_extension\n extensions.reverse.detect { |ext|\n @environment.mime_types(ext) && !@environment.engines(ext)\n }\n end", "def gem_only_available?()\n return !determine_common_folder() && is_dtk_common_core_gem_installed?\nend", "def load_extension_inclusions\n return unless config_hash[\"Extensions\"]\n config_options[:extensions] = config_hash[\"Extensions\"]\n end", "def dotindex?\n @_dotindex ||= File.exist?(File.join(location, '.index'))\n end", "def file?(s)\n s.include? '.'\nend", "def minified_files?\n return unless ['.js', '.css'].include? extname\n if lines.any?\n (lines.inject(0) { |n, l| n += l.length } / lines.length) > 110\n else\n false\n end\n end", "def extensions\n @config[:extensions]\n end" ]
[ "0.7635198", "0.75941896", "0.74812496", "0.73279864", "0.73279864", "0.7179598", "0.70683795", "0.70683795", "0.7045263", "0.70179784", "0.6989766", "0.6984739", "0.6984739", "0.6905511", "0.67384905", "0.6601999", "0.6594085", "0.6456295", "0.6452495", "0.6432571", "0.6432571", "0.6432571", "0.6420111", "0.6413786", "0.63944346", "0.6380536", "0.63750285", "0.6364541", "0.6325538", "0.6324479", "0.63117194", "0.628023", "0.6268036", "0.6198884", "0.6190614", "0.6181231", "0.61755216", "0.6167225", "0.6163462", "0.61517453", "0.6137762", "0.61226994", "0.610385", "0.6073749", "0.6061035", "0.60437506", "0.6032122", "0.60181636", "0.6002448", "0.59950924", "0.59920883", "0.59568864", "0.5953791", "0.595032", "0.59453964", "0.5935924", "0.5935924", "0.59316546", "0.5928799", "0.59283364", "0.5890735", "0.5872801", "0.586681", "0.58622444", "0.5859178", "0.5857812", "0.5857812", "0.58555764", "0.58555764", "0.5850723", "0.5844999", "0.58445656", "0.5841405", "0.58344376", "0.58200777", "0.58185935", "0.5814104", "0.5813098", "0.5809191", "0.5805546", "0.5803809", "0.58037907", "0.57922727", "0.5778501", "0.57694787", "0.575263", "0.5748704", "0.5745493", "0.5743958", "0.5743513", "0.57284236", "0.5719929", "0.57166606", "0.5701894", "0.56990224", "0.5694756", "0.5693176", "0.56931514", "0.5678411", "0.5676161" ]
0.77635753
0
Set up the tasks to build extensions.
def define_extension_tasks ENV['RUBY_CC_VERSION'] ||= RUBY_VERSION[ /(\d+\.\d+)/ ] require 'rake/extensiontask' self.extensions.each do |extconf| Rake::ExtensionTask.new( extconf.pathmap('%{ext/,}d') ) end task :spec => :compile task :maint do ENV['V'] = '1' ENV['MAINTAINER_MODE'] = 'yes' end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def define_tasks\r\n define_clobber_task\r\n define_build_task\r\n end", "def define_compiler_tasks\n require \"rake/extensiontask\"\n\n @extensions.each do |name|\n clean_globs << \"lib/#{name}/*.{so,bundle,dll}\"\n\n Rake::ExtensionTask.new name, spec do |ext|\n ext.lib_dir = File.join(*[\"lib\", name.to_s, ENV[\"FAT_DIR\"]].compact)\n end\n end\n\n compile_tasks.each do |t|\n task t => :compile\n end\n rescue LoadError\n warn \"Couldn't load rake-compiler. Skipping. Run `rake newb` to fix.\"\n end", "def define_tasks\r\n define_repeat_task\r\n define_clobber_task\r\n define_build_task\r\n end", "def make_tasks\n make_clean_task\n make_wix_folder_task\n make_copy_file_tasks\n make_sourcery_wxs_file_task\n make_sourcery_wixobj_file_task\n make_product_wxs_file_task\n make_product_wixobj_file_task\n make_msi_file_task\n make_msi_task\n make_test_task\n end", "def setup\n @build_dir = File.join project.dir, 'build'\n unless Dir.exists? @build_dir\n Dir.mkdir @build_dir\n end\n\n task 'default' => 'build'\n\n desc 'Build the project'\n task 'build' => project.target do\n puts \"Built #{File.basename project.target}\".green\n end\n\n self.setup_target\n self.setup_source_files\n\n if project.test_target\n self.setup_test_target\n self.setup_test_files\n end\n\n desc 'Clean up build artifacts and target'\n task 'clean' do\n sh \"rm -f #{project.target}\"\n project.sources.each do |fn|\n fn = objectsify fn\n sh \"rm -f #{fn}\"\n end\n end\n \n namespace 'test' do\n desc 'Build the test target'\n task 'build' => project.test_target do\n puts \"Built #{File.basename project.test_target}\".green\n end\n desc 'Clean test build artifacts'\n task 'clean' do\n sh \"rm -f #{project.test_target}\"\n project.test_sources.each do |fn|\n fn = objectsify fn\n sh \"rm -f #{fn}\"\n end\n end\n end\n \n end", "def setup\n @ext_targets.each do |et|\n path, options, block = et\n path = expand_ext_path(path)\n case\n when options[:mkmf]\n setup_mkmf(path, options, block)\n end \n end\n end", "def setup( _name, **options )\n\t\tsuper if defined?( super )\n\n\t\tself.extensions.include( Rake::DevEiate::EXT_DIR + EXTENSION_GLOB_PATTERN )\n\t\t@disable_rake_compiler = false\n\tend", "def define_tasks\n define_weave_task\n connect_common_tasks\n end", "def configure_tasks\n super\n all_object_files = []\n all_object_folders = []\n @toolchains.each do |toolchain, sources|\n toolchain.add_include_paths(@api_headers+@configuration_headers)\n object_files, object_folders = toolchain.create_compile_tasks(sources)\n all_object_files |= object_files\n all_object_folders |= object_folders\n end\n\n project_filename = @parent_project.project_name.to_s.gsub(':','-')\n library_files, library_folders = @default_toolchain.create_static_library_tasks(all_object_files, project_filename)\n dependencies = @dependencies+all_object_folders+library_folders+library_files\n\n desc \"Build library '#{@parent_project.project_name}' with configuration '#{@configuration_name}'\"\n new_task = static_library_task @configuration_name => dependencies do |t|\n @post_build.call if @post_build.respond_to? :call\n puts \"built library #{t.name}.\"\n @tests.each do |test|\n if Rake::Task.task_defined? test\n Rake::Task[test].invoke\n else\n $stderr.puts \"warning: Skipping unknown test '#{test}'\"\n end\n end\n end\n new_task.api_headers = @api_headers\n new_task.configuration_headers = @configuration_headers\n new_task.library_files = library_files\n end", "def exec_setup\n exec_task_traverse 'setup'\n end", "def install_tasks\n load 'falkorlib/tasks/git.rake'\n load 'falkorlib/tasks/gitflow.rake'\n end", "def configure_tasks\n super\n all_sources = []\n @toolchains.each do |toolchain, sources|\n all_sources |= sources\n toolchain.output_folder = @output_folder\n toolchain.project_folder = @project_folder\n toolchain.output_decorator = \"-#{@configuration_name}\"\n CompiledConfiguration.add_framework_dependencies_to_toolchain(toolchain, @dependencies)\n end\n # Give the default toolchain an opportunity to scan all source files for\n # any special needs. For example, a toolchain might look for .cpp files\n # to determine that it should link a project with the \"g++\" vs \"gcc\".\n @default_toolchain.scan_sources(all_sources)\n end", "def create_compile_ext_tasks(source_root, dest_root, invoking_task)\n compiled_ext = \"#{source_root}/#{SPECIAL_BUNDLE_NAMES[File.basename(source_root)] || File.basename(source_root)}.bundle\"\n create_copy_file_tasks(FileList[compiled_ext], source_root, dest_root, invoking_task)\n file compiled_ext => FileList[\"#{source_root}/*.c\"] do\n cd source_root do\n `ruby extconf.rb; make >/dev/null 2>&1`\n end\n end\nend", "def setup_test_files\n project.test_sources.each do |src|\n compile_task objectsify(src), src\n end\n end", "def setup_tasks\n namespace(:npm) do\n desc 'Build package.json from template'\n task :'package.json' do\n template = ERB.new(File.read(File.join(src, 'package.json.erb')))\n generated = template.result_with_hash(scope: SCOPE, gemspec: gemspec, contributors: contributors)\n File.write(File.join(src, 'package.json'), JSON.pretty_generate(JSON.parse(generated)))\n end\n\n desc 'Ensure the destination directory exist'\n task :dest do\n FileUtils.mkdir_p(dest)\n end\n\n desc 'Build package tarball into the pkg directory'\n task build: %i[package.json dest] do\n system(\"cd #{src} && npm pack --pack-destination #{dest}/\")\n end\n\n desc 'Build and push package to npmjs.com'\n task release: %i[build] do\n system(\"npm publish #{tarball} --access public\")\n end\n end\n end", "def configure_tasks\n end", "def define_test_tasks\n default_tasks = []\n\n if File.directory? \"test\" then\n desc 'Run the test suite. Use FILTER or TESTOPTS to add flags/args.'\n task :test do\n ruby make_test_cmd\n end\n\n desc 'Run the test suite using multiruby.'\n task :multi do\n ruby make_test_cmd(:multi)\n end\n\n desc 'Show which test files fail when run alone.'\n task :test_deps do\n tests = Dir[\"test/**/test_*.rb\"] + Dir[\"test/**/*_test.rb\"]\n\n paths = ['bin', 'lib', 'test'].join(File::PATH_SEPARATOR)\n null_dev = Hoe::WINDOZE ? '> NUL 2>&1' : '&> /dev/null'\n\n tests.each do |test|\n if not system \"ruby -I#{paths} #{test} #{null_dev}\" then\n puts \"Dependency Issues: #{test}\"\n end\n end\n end\n\n default_tasks << :test\n end\n\n if File.directory? \"spec\" then\n begin\n require 'spec/rake/spectask'\n\n desc \"Run all specifications\"\n Spec::Rake::SpecTask.new(:spec) do |t|\n t.libs = self.rspec_dirs\n t.spec_opts = self.rspec_options\n end\n rescue LoadError\n # do nothing\n end\n default_tasks << :spec\n end\n\n desc 'Run the default task(s).'\n task :default => default_tasks\n\n desc 'Run ZenTest against the package.'\n task :audit do\n libs = %w(lib test ext).join(File::PATH_SEPARATOR)\n sh \"zentest -I=#{libs} #{spec.files.grep(/^(lib|test)/).join(' ')}\"\n end\n end", "def define_tasks!\n\n define_test_tasks! if has_tests?\n define_rspec_tasks! if has_specs?\n\n namespace(@task_namespace) do\n desc \"Updates the filelist in the gemspec file\"\n task(:manifest) { manifest_task }\n\n desc \"Builds the .gem package\"\n task(:build => :manifest) { build_task }\n\n desc \"Sets the version of the gem in the gemspec\"\n task(:set_version => [:check_version, :check_current_branch]) { version_task }\n task(:check_version => :fetch_origin) { check_version_task }\n\n task(:fetch_origin) { fetch_origin_task }\n task(:check_current_branch) { check_current_branch_task }\n task(:check_clean_status) { check_clean_status_task }\n task(:check_not_diverged => :fetch_origin) { check_not_diverged_task }\n\n checks = [:check_current_branch, :check_clean_status, :check_not_diverged, :check_version]\n checks.unshift('spec:basic') if has_specs?\n checks.unshift('test:basic') if has_tests?\n # checks.push << [:check_rubyforge] if gemspec.rubyforge_project\n\n desc \"Perform all checks that would occur before a release\"\n task(:release_checks => checks)\n\n release_tasks = [:release_checks, :set_version, :build, :github_release, :gemcutter_release]\n # release_tasks << [:rubyforge_release] if gemspec.rubyforge_project\n\n desc \"Release a new version of the gem using the VERSION environment variable\"\n task(:release => release_tasks) { release_task }\n \n namespace(:release) do\n desc \"Release the next version of the gem, by incrementing the last version segment by 1\"\n task(:next => [:next_version] + release_tasks) { release_task }\n\n desc \"Release the next version of the gem, using a patch increment (0.0.1)\"\n task(:patch => [:next_patch_version] + release_tasks) { release_task }\n\n desc \"Release the next version of the gem, using a minor increment (0.1.0)\"\n task(:minor => [:next_minor_version] + release_tasks) { release_task }\n\n desc \"Release the next version of the gem, using a major increment (1.0.0)\"\n task(:major => [:next_major_version] + release_tasks) { release_task }\n end\n\n # task(:check_rubyforge) { check_rubyforge_task }\n # task(:rubyforge_release) { rubyforge_release_task }\n task(:gemcutter_release) { gemcutter_release_task }\n task(:github_release => [:commit_modified_files, :tag_version]) { github_release_task }\n task(:tag_version) { tag_version_task }\n task(:commit_modified_files) { commit_modified_files_task }\n\n task(:next_version) { next_version_task }\n task(:next_patch_version) { next_version_task(:patch) }\n task(:next_minor_version) { next_version_task(:minor) }\n task(:next_major_version) { next_version_task(:major) }\n \n desc \"Updates the gem release tasks with the latest version on Github\"\n task(:update_tasks) { update_tasks_task }\n end\n end", "def setup_c_extension(extension_name, gem_spec = nil)\n # use the DLEXT for the true extension name\n ext_name = \"#{extension_name}.#{RbConfig::CONFIG['DLEXT']}\"\n\n # we need lib\n directory 'lib'\n\n # verify if the extension is in a folder\n ext_dir = File.join('ext', extension_name)\n unless File.directory?(ext_dir)\n # the extension is in the root of ext.\n ext_dir = 'ext'\n end\n\n # getting this file is part of the compile task\n desc \"Compile Extension for current Ruby (= compile:mri)\"\n task :compile => [ 'compile:mri' ] unless JRUBY\n\n namespace :compile do\n desc 'Compile C Extension for Ruby 1.8 (MRI)'\n task :mri => [:clean, \"rake:compile:lib/#{ext_name}\"]\n\n task \"#{ext_dir}/#{ext_name}\" => FileList[\"#{ext_dir}/Makefile\", \"#{ext_dir}/*.c\", \"#{ext_dir}/*.h\"] do\n # Visual C make utility is named 'nmake', MinGW conforms GCC 'make' standard.\n make_cmd = RUBY_PLATFORM =~ /mswin/ ? 'nmake' : 'make'\n Dir.chdir(ext_dir) do\n sh make_cmd\n end\n end\n\n file \"#{ext_dir}/Makefile\" => \"#{ext_dir}/extconf.rb\" do\n Dir.chdir(ext_dir) do\n ruby 'extconf.rb'\n end\n end\n\n task \"lib/#{ext_name}\" => ['lib', \"#{ext_dir}/#{ext_name}\"] do\n cp \"#{ext_dir}/#{ext_name}\", \"lib/#{ext_name}\"\n end\n end\n\n unless Rake::Task.task_defined?('native')\n if gem_spec\n desc \"Build Extensions into native binaries.\"\n task :native => [:compile] do |t|\n # use CURRENT platform instead of RUBY\n gem_spec.platform = Gem::Platform::CURRENT\n\n # clear the extension (to avoid RubyGems firing the build process)\n gem_spec.extensions.clear\n\n # add the precompiled binaries to the list of files\n # (taken from compile task dependency)\n gem_spec.files += Rake::Task['compile'].prerequisites\n end\n end\n end\nend", "def initialize_compiler\n self.compile_tasks = [:multi, :test, :check_manifest]\n end", "def define_test_tasks\n default_tasks = []\n\n task :test\n\n if File.directory? \"test\" then\n case testlib\n when :minitest then\n require \"minitest/test_task\" # in minitest 5.16+\n\n test_prelude = self.test_prelude\n self.test_task = Minitest::TestTask.create :test do |t|\n t.test_prelude = test_prelude\n t.libs.prepend Hoe.include_dirs.uniq\n end\n when :none then\n # do nothing\n else\n warn \"Unsupported? Moving to Minitest::TestTask. Let me know if you use this!\"\n end\n\n desc \"Run the test suite using multiruby.\"\n task :multi do\n skip = with_config do |config, _|\n config[\"multiruby_skip\"] + self.multiruby_skip\n end\n\n ENV[\"EXCLUDED_VERSIONS\"] = skip.join(\":\")\n system \"multiruby -S rake\"\n end\n\n default_tasks << :test\n end\n\n desc \"Run the default task(s).\"\n task :default => default_tasks\n\n desc \"Run ZenTest against the package.\"\n task :audit do\n libs = %w[lib test ext].join(File::PATH_SEPARATOR)\n sh \"zentest -I=#{libs} #{spec.files.grep(/^(lib|test)/).join(\" \")}\"\n end\n end", "def define_inline_tasks\n task :test => :clean\n\n return unless ENV[\"INLINE\"]\n\n s.platform = ENV[\"FORCE_PLATFORM\"] || Gem::Platform::CURRENT\n\n return unless defined? Inline\n\n # Try collecting Inline extensions for +name+\n directory \"lib/inline\"\n\n dlext = RbConfig::CONFIG[\"DLEXT\"]\n\n Inline.registered_inline_classes.each do |cls|\n name = cls.name.gsub(/::/, \"\")\n # name of the extension is CamelCase\n alternate_name = if name =~ /[A-Z]/ then\n name.gsub(/([A-Z])/, '_\\1').downcase.sub(/^_/, \"\")\n elsif name =~ /_/ then\n name.capitalize.gsub(/_([a-z])/) { $1.upcase }\n end\n extensions = Dir.chdir(Inline.directory) {\n Dir[\"Inline_{#{name},#{alternate_name}}_*.#{dlext}\"]\n }\n\n extensions.each do |ext|\n # add the inlined extension to the spec files\n s.files += [\"lib/inline/#{ext}\"]\n\n # include the file in the tasks\n file \"lib/inline/#{ext}\" => [\"lib/inline\"] do\n cp File.join(Inline.directory, ext), \"lib/inline\"\n end\n end\n end\n end", "def connect_common_tasks\n desc \"Build the code narrative HTML\"\n ::Rake::Task.define_task(:codnar => \"codnar_weave\")\n desc \"Remove woven HTML documentation\"\n ::Rake::Task.define_task(\"clobber_codnar\") { rm_rf(@output) }\n ::Rake::Task.define_task(:clobber => \"clobber_codnar\")\n end", "def run\n run_build_tasks before_tasks, basic_tasks, after_tasks\n end", "def setup_source_files\n project.sources.each do |src|\n # Figure out where stuff should come from and go to\n source_file = src\n object_file = objectsify src\n compile_task object_file, source_file\n end#project.sources.each\n end", "def define\n desc \"Create Rails plug-in package\"\n task :rails_plugin do\n @dest = \"#@package_dir/#{@name}_#{@version}\"\n makedirs(@dest,:verbose=>false)\n @plugin_files.each do |fn|\n cp(fn, @dest,:verbose=>false)\n add_file(File.basename(fn))\n end\n\n @package_files.each do |fn|\n puts \". #{fn}\" if verbose\n f = File.join(@dest, fn)\n fdir = File.dirname(f)\n unless File.exist?(fdir)\n mkdir_p(fdir,:verbose=>false)\n add_folder(\"#{fdir}/\")\n end\n if File.directory?(fn)\n mkdir_p(f,:verbose=>false)\n add_folder(\"#{fn}/\")\n else\n cp(fn, f, :verbose=>false)\n add_file(fn)\n end\n end\n\n generate_index_files()\n end\n end", "def define\n desc \"Create Ruby on Rails plug-in package\"\n task :rails_plugin do\n @dest = \"#@package_dir/#{@name}_#{@version}\"\n makedirs(@dest,:verbose=>false)\n @plugin_files.each do |fn|\n cp(fn, @dest,:verbose=>false)\n add_file(File.basename(fn))\n end\n \n @package_files.each do |fn|\n puts \". #{fn}\" if verbose\n f = File.join(@dest, fn)\n fdir = File.dirname(f)\n unless File.exist?(fdir)\n mkdir_p(fdir,:verbose=>false)\n add_folder(\"#{fdir}/\")\n end\n if File.directory?(fn)\n mkdir_p(f,:verbose=>false)\n add_folder(\"#{fn}/\")\n else\n cp(fn, f, :verbose=>false)\n add_file(fn)\n end\n end\n \n generate_index_files()\n end\n end", "def define_tasks\n # Run the command on the local system\n def run(cmd)\n Kernel.system(cmd.runnable)\n end\n # Basic setup action\n def setup_application\n @options ||= PoolParty.options(ARGV.dup)\n end\n \n # Require the poolparty specific tasks\n compiled_rakefile\n \n desc \"Reload the static variables\"\n task :reload do\n reload!\n end\n true\n end", "def load\n super()\n load_rspec_tasks\n load_generic_deploy_pack_tasks\n load_this_deploy_packs_tasks\n end", "def define_packaging_tasks\n\n\t\t### Task: prerelease\n\t\tunless Rake::Task.task_defined?( :pre )\n\t\t\tdesc \"Append the package build number to package versions\"\n\t\t\ttask :pre do\n\t\t\t\trev = get_numeric_rev()\n\t\t\t\ttrace \"Current rev is: %p\" % [ rev ]\n\t\t\t\t$hoespec.spec.version.version << \"pre#{rev}\"\n\t\t\t\tRake::Task[:gem].clear\n\n\t\t\t\tGem::PackageTask.new( $hoespec.spec ) do |pkg|\n\t\t\t\t\tpkg.need_zip = true\n\t\t\t\t\tpkg.need_tar = true\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\n\t\tnamespace :deps do\n\n\t\t\tif RVM_GEMSET.exist?\n\t\t\t\tdesc \"Update the project's RVM gemset\"\n\t\t\t\ttask :gemset do\n\t\t\t\t\tdeps = make_gemset_recommendations( $hoespec.spec )\n\t\t\t\t\tupdates = deps.values.compact\n\n\t\t\t\t\tif !updates.empty?\n\t\t\t\t\t\t$stderr.puts \"%d gems in the current gemset have newer matching versions:\" %\n\t\t\t\t\t\t\t [ updates.length ]\n\t\t\t\t\t\tdeps.each do |old, newer|\n\t\t\t\t\t\t\tnext unless newer\n\t\t\t\t\t\t\t$stderr.puts \" #{old} -> #{newer}\"\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\tif ask( \"Update? \" )\n\t\t\t\t\t\t\tupdate_rvm_gemset( deps )\n\t\t\t\t\t\t\trun 'rvm', 'gemset', 'import', RVM_GEMSET.to_s\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\n\t\tend\n\n\t\t### Make the ChangeLog update if the repo has changed since it was last built\n\t\tfile '.hg/branch'\n\t\tfile 'ChangeLog' => '.hg/branch' do |task|\n\t\t\t$stderr.puts \"Updating the changelog...\"\n\t\t\tcontent = make_changelog()\n\t\t\tFile.open( task.name, 'w', 0644 ) do |fh|\n\t\t\t\tfh.print( content )\n\t\t\tend\n\t\tend\n\n\tend", "def setup\n add_standard_properties\n #\n create_banner\n create_standard_options\n create_advanced_options\n create_mode_options\n create_application_options\n create_feature_options\n create_tail_options\n #\n parse_options\n load_config_configuration\n create_result_directory\n load_results_archive\n end", "def run_build_tasks(*tasks)\n tasks.flatten.each { |t| run_build_task t }\n end", "def post_process\n bind_files\n make_tasks\n end", "def create_tasks\n Application.features[self].each{ |f|\n extend Rake::DSL\n taskname = \"#{f.to_s.split('::').last}\"\n desc \"Feature\"\n task taskname => [\"#{taskname}:install\"] do\n end\n namespace taskname do\n desc \"install #{taskname}\"\n task :install do\n puts \"----> installing #{taskname}\"\n puts \"#{self} | #{f}\"\n Application.install[f.name].each{ |c|\n puts \"#{c}\"\n }\n end\n end \n } if Application.features[self]\n end", "def add_files_to_project\n # add/overwrite some files\n mkdir('config/init')\n mkdir_p('lib/tasks')\n cp_r(Dir.glob('../files/*'), '.')\n # gem changed the api in version 1.3.2, I think, at least it is changed\n # in version 1.3.4, so the following merb hack is necessary for merb\n # 1.0.11\n # TODO: this should be generically performed outside of the spec2merb script\n if Versionomy.parse(`gem --version`) < Versionomy.parse('1.3.4')\n raise Exception.new 'Please upgrade rubygems to at least 1.3.4 (sudo gem update --system)'\n end\n if File.exist?('tasks/merb.thor/gem_ext_4.rb')\n rm('tasks/merb.thor/gem_ext.rb') if File.exist?('tasks/merb.thor/gem_ext.rb')\n mv('tasks/merb.thor/gem_ext_4.rb', 'tasks/merb.thor/gem_ext.rb')\n end\n end", "def setup\n make_config\n make_users_file\n end", "def load_task_libraries\n\t\ttaskdir = Pathname( __FILE__.delete_suffix('.rb') )\n\t\ttasklibs = Rake::FileList[ taskdir + '*.rb' ].pathmap( '%-2d/%n' )\n\n\t\tself.trace( \"Loading task libs: %p\" % [ tasklibs ] )\n\t\ttasklibs.each do |lib|\n\t\t\trequire( lib )\n\t\tend\n\n\t\tself.class.constants.\n\t\t\tmap {|c| self.class.const_get(c) }.\n\t\t\tselect {|c| c.respond_to?(:instance_methods) }.\n\t\t\tselect {|c| c.instance_methods(false).include?(:define_tasks) }.\n\t\t\teach do |mod|\n\t\t\t\tself.trace \"Loading tasks from %p\" % [ mod ]\n\t\t\t\textend( mod )\n\t\t\tend\n\n\t\tself.setup( self.name, **self.options )\n\tend", "def setup\n install_latest_ruby\n\n install_global_gems\n end", "def list_available_build_tasks\n cd 'cookbooks/example'\n unset_bundler_env_vars\n run_simple 'bundle exec rake -T'\n end", "def build_extensions # :nodoc:\n return if extensions.empty?\n return if default_gem?\n return if File.exist? gem_build_complete_path\n return if !File.writable?(base_dir)\n return if !File.exist?(File.join(base_dir, 'extensions'))\n\n begin\n # We need to require things in $LOAD_PATH without looking for the\n # extension we are about to build.\n unresolved_deps = Gem::Specification.unresolved_deps.dup\n Gem::Specification.unresolved_deps.clear\n\n require_relative 'config_file'\n require_relative 'ext'\n require_relative 'user_interaction'\n\n ui = Gem::SilentUI.new\n Gem::DefaultUserInteraction.use_ui ui do\n builder = Gem::Ext::Builder.new self\n builder.build_extensions\n end\n ensure\n ui.close if ui\n Gem::Specification.unresolved_deps.replace unresolved_deps\n end\n end", "def setup_tests\n Rake::TestTask.new do |t|\n t.libs << \"test\"\n t.test_files = FileList['test/test*.rb']\n t.verbose = true\n end\nend", "def build_default_tasks\n @rake_task << self.step_template # get General Configuration information\n end", "def define\n namespace :install do\n @project.builds.each do |build,packages|\n path = packages[:gem]\n\n task build => path do\n status \"Installing #{File.basename(path)} ...\"\n\n install(path)\n end\n end\n end\n\n desc \"Installs all built gem packages\"\n gemspec_tasks :install\n\n task :install_gem => :install # backwards compatibility with Hoe\n end", "def initialize\n dependencies = if defined?(::Rails)\n [:environment]\n else\n []\n end\n\n define_tasks(dependencies)\n end", "def setup()\n create_directories\n end", "def create_all_library_tasks(env, libraries, dependent_task)\n libraries.each do | library |\n create_library_tasks(env, library, dependent_task)\n end\n\n desc \"Remove all dependency libraries from the lib directory\"\n task :clean do\n libraries.each do | library |\n rm_rf env.dependent_library_dir(library.name)\n end\n sh \"ino clean\"\n end\n\n desc \"Build the project\"\n task :build => dependent_task do\n sh \"ino build\"\n end\n end", "def setup\n Athenry::setup.target(\"fetchstage\", \"extractstage\", \"fetchsnapshot\", \"updatesnapshot\", \"copysnapshot\", \"copy_scripts\", \"copy_configs\")\n end", "def register_tasks(&block)\n namespace(@name) do |ns|\n\n file file_name => BUILD::DIRS + [(base_image.file_name rescue nil)].compact do\n puts \"Building #{@full_comment} image\"\n build_image\n end\n\n desc \"Build a #{@full_comment} image\"\n task :build => file_name\n\n desc \"Rebuild a #{@full_comment} image\"\n task :rebuild do\n Rake::Task[\"#{@name}:clean\"].invoke\n Rake::Task[file_name].invoke\n end\n\n desc \"Start a #{@full_comment} image\"\n task :start => file_name do\n puts \"Starting #{@full_comment} image\"\n Smallworld.start_gis @name\n end\n\n desc \"Run unit tests for #{@full_comment} image\"\n task :test do\n puts \"Starting unit tests for #{@full_comment} image\"\n\n ENV['TEST_RUNNER_PRODUCT'] = 'munit'\n Rake::Task[\"#{@name}:rebuild\"].invoke\n end\n\n desc \"Run a script with #{@full_comment} image\"\n task :run_script => :build do\n\n script_file = ENV['RUN_SCRIPT']\n fail \"#{@name}:run: set environment variable RUN_SCRIPT to the appropriate file\" if not script_file\n fail \"#{@name}:run: '#{script_file}' does not exist\" if not File.exists?(script_file)\n\n run_image = self.clone\n\n run_image.filters = [IgnoreOutputFilter.new] if not Rake::application.options.trace\n\n puts \"Running script '#{script_file}' for image #{@full_comment}\"\n exit_code = run_image.run @name, script_file\n\n fail \"running the script failed: runalias.exe returned #{exit_code}\" if exit_code != 0\n end\n\n desc \"Remove the image for #{@full_comment}\"\n task :clean do\n rm_f file_name\n end\n\n ns.tasks.each do |task|\n task.enhance(&block) if block_given?\n end\n\n end\n end", "def define_tasks\n fail \"Version required (or :noversion)\" if @version.nil?\n @version = nil if :noversion == @version\n\n desc \"Build the disk image file\"\n task :dmg => \"#{package_dir}/#{dmg_file}\"\n\n file \"#{package_dir}/#{dmg_file}\" => dmg_dir_path do\n chdir package_dir do\n sh \"#{dmg_command} create #{dmg_options}\"\n end\n end\n\n directory package_dir\n\n file dmg_dir_path => source_files + extra_source_files.keys do\n prefix_to_strip = /^#{@strip}/ if @strip\n mkdir_p package_dir rescue nil\n source_files.each do |fn|\n fn_stripped = @strip == nil ? fn : fn.sub(prefix_to_strip, '')\n f = File.join(dmg_dir_path, fn_stripped)\n fdir = File.dirname(f)\n mkdir_p(fdir) if !File.exist?(fdir)\n if File.directory?(fn)\n mkdir_p(f)\n else\n rm_f f\n safe_ln(fn, f)\n end\n end\n extra_source_files.each do |k, v|\n f = File.join(dmg_dir_path, v)\n mkdir_p(File.dirname(f)) rescue nil\n rm_f f\n safe_ln k, f\n end\n end\n\n desc \"Remove the disk image files\"\n task :clobber_dmg do\n rm_r package_dir rescue nil\n end\n\n task :clobber => :clobber_dmg\n\n desc \"Force a rebuild of the disk image file\"\n task :rebuild_dmg => [:clobber_dmg, :dmg]\n\n self\n end", "def build_package_tasks(config)\n # The name of the task to build the package\n package_task_name = \"build_#{config[:package_name]}\"\n\n # Add task name to the list of dependencies for the :deb_packages task\n task :deb_packages => package_task_name\n\n # The path to the package source directory\n pkg_src_dir = File.join(PACKAGE_CONSTRUCTION_DIR, source_dir_name(config))\n\n # Directory task to ensure the existence of the directory\n directory pkg_src_dir\n\n # Create the tarball task\n orig_source_tarball_path = File.join(PACKAGE_CONSTRUCTION_DIR, \"#{orig_tar_ball_name(config)}.orig.tar.gz\")\n\n # The File task to construct the original source tarball.\n file orig_source_tarball_path => PACKAGE_CONSTRUCTION_DIR do\n system \"tar zcf #{orig_source_tarball_path} --directory #{PACKAGE_CONSTRUCTION_DIR} #{source_dir_name(config)}\"\n end\n\n # The path to the debian directory within the extracted source directory\n package_debian_path = File.join(pkg_src_dir, 'debian')\n\n # Directory task to the package debian path to ensure existence.\n directory package_debian_path\n\n # The task that actually constructs the debian package\n task package_task_name => orig_source_tarball_path do\n # Build the spanky little thing.\n debuild_flag = ENV['debuild'] || 'true'\n if debuild_flag == 'true'\n system \"cd #{pkg_src_dir}; debuild -us -uc\"\n else\n puts \"Skipping build; debug flag was set\"\n end\n end\n\n # Ensure we have set up the tasks for all the files to be included\n # in the package.\n config[:exes].each do | exe_name |\n exe_path = File.join(pkg_src_dir, exe_name.split('.').first)\n file exe_path => pkg_src_dir do\n cp exe_name, exe_path\n end\n\n # Add the file path as a dependency of the source tarball\n task orig_source_tarball_path => exe_path\n end\n\n # Create the task to populate the debian directory\n debian_task = \"populate_#{config[:package_name]}_debian_files\"\n task debian_task => package_debian_path do\n cp_r \"package_source/#{config[:package_name]}/debian\", pkg_src_dir\n end\n\n # Finally add the debian task as a dependency for the package task.\n task package_task_name => debian_task\nend", "def setup\r\n setup_wiki\r\n setup_host_map\r\n setup_host\r\n end", "def define_gemcutter_tasks\n desc \"Push gem to gemcutter.\"\n task :release_to_gemcutter => [:clean, :package, :release_sanity] do\n pkg = \"pkg/#{spec.name}-#{spec.version}\"\n gems = Dir[\"#{pkg}*.gem\"]\n\n gem_push gems\n end\n\n task :release_to => :release_to_gemcutter\n end", "def do_extensions_debug( task, args )\n\t\tself.prompt.say( \"Extension config scripts:\", color: :bright_green )\n\n\t\tif self.extensions.empty?\n\t\t\tself.prompt.say \"None.\"\n\t\telse\n\t\t\tself.extensions.uniq.each do |path|\n\t\t\t\tself.prompt.say \"- %s\" % [ path ]\n\t\t\tend\n\t\tend\n\n\t\tif self.has_rakecompiler_dependency?\n\t\t\tself.prompt.say \"\\n\"\n\t\t\tself.prompt.say \"✔ has rake-compiler dependency\"\n\t\tend\n\n\t\tself.prompt.say( \"\\n\" )\n\tend", "def define_common_tasks(vcs, workdir, task_prefix, plines=[])\n vcs.map do |files, (lines, nvcs)|\n fn = \"#{task_prefix}#{Digest::SHA1.hexdigest(files.join)}\"\n File.write(File.join(workdir, fn), (plines + lines).join)\n task fn do\n docker_build(fn, workdir)\n end\n\n nfn = define_common_tasks(nvcs, workdir, task_prefix, plines + lines)\n nfn.each do |file|\n task file => fn\n end\n files.each do |file|\n task file => fn\n end\n fn\n end\n end", "def setup\n ensure_not_in_dest\n\n plugin_manager.conscientious_require\n\n self.converters = instantiate_subclasses(Jekyll::Converter)\n self.generators = instantiate_subclasses(Jekyll::Generator)\n end", "def define_default_tasks\n\n\t\t# task used to indicate that rake-deveiate has already been setup once; for\n\t\t# global rakefiles.\n\t\ttask :deveiate do\n\t\t\t# no-op\n\t\tend\n\n\t\tdesc \"The task that runs by default\"\n\t\ttask( :default => :spec )\n\n\t\tdesc \"Check in the current changes\"\n\t\ttask :checkin => [ :precheckin, :check, :test ]\n\t\ttask :commit => :checkin\n\t\ttask :ci => :checkin\n\t\ttask :precheckin\n\n\t\tdesc \"Sanity-check the project\"\n\t\ttask :check\n\n\t\tdesc \"Update the history file\"\n\t\ttask :update_history\n\n\t\tdesc \"Package up and push a release\"\n\t\ttask :release => [ :prerelease, :gem, :release_gem, :postrelease ]\n\t\ttask :prerelease\n\t\ttask :release_gem\n\t\ttask :postrelease\n\n\t\tdesc \"Run all the project's tests\"\n\t\ttask :test\n\t\ttask :spec\n\t\ttask :integration\n\n\t\tdesc \"Set up the project for development\"\n\t\ttask :setup do\n\t\t\tself.install_dependencies\n\t\tend\n\n\t\tdesc \"Turn on maintainer mode: build with extra warnings and debugging\"\n\t\ttask :maint do\n\t\t\tENV['MAINTAINER_MODE'] = 'yes'\n\t\tend\n\n\tend", "def setup_files(config_generator)\n raise NotImplementedError\n end", "def setup\n end", "def setup\n end", "def setup\n end", "def setup\n end", "def setup\n end", "def define_test_tasks!\n require 'rake/testtask'\n\n namespace(:test) do\n Rake::TestTask.new(:basic) do |t|\n t.pattern = test_pattern\n t.verbose = true\n t.libs << 'test'\n end\n end\n\n desc \"Run all unit tests for #{gemspec.name}\"\n task(:test => ['test:basic'])\n end", "def setup\n super\n handle_packages\n end", "def setup()\n end", "def require_tasks system_config\n system_config.gaudi_modules.each do |gm|\n mass_require(Rake::FileList[\"#{system_config.base}/tools/build/lib/#{gm}/tasks/*.rb\"])\n end\n end", "def load_dummy_tasks(app_root)\n @target_extension_path = Pathname.new(app_root.to_s)\n load 'refinery/tasks/testing.rake'\n end", "def setup\n copy_definitions\n package_agent\n end", "def setup\n copy_definitions\n package_agent\n end", "def setup\n templates = ['default']\n templates << @opts[:testkitchen] if @opts[:testkitchen]\n\n templates.each { |type| create_file(type) }\n end", "def define_sanitycheck_tasks\n\n\t\ttask 'hg:precheckin' => [:spec] if File.directory?( 'spec' )\n\t\ttask 'hg:prep_release' => [ :check_manifest, :check_history ]\n\n\t\t# Rebuild the ChangeLog immediately before release\n\t\ttask :check_manifest => 'ChangeLog'\n\t\ttask :prerelease => 'ChangeLog'\n\n\tend", "def tools_setup(config)\n config[:tools].each_key do |name|\n tool = config[:tools][name]\n\n # populate name if not given\n tool[:name] = name.to_s if (tool[:name].nil?)\n\n # handle inline ruby string substitution in executable\n if (tool[:executable] =~ RUBY_STRING_REPLACEMENT_PATTERN)\n tool[:executable].replace(@system_wrapper.module_eval(tool[:executable]))\n end\n\n # populate stderr redirect option\n tool[:stderr_redirect] = StdErrRedirect::NONE if (tool[:stderr_redirect].nil?)\n\n # populate background execution option\n tool[:background_exec] = BackgroundExec::NONE if (tool[:background_exec].nil?)\n\n # populate optional option to control verification of executable in search paths\n tool[:optional] = false if (tool[:optional].nil?)\n end\n end", "def setup\n\n end", "def setup\n\n end", "def initialize(*args)\n super\n\n self.targets.each do |tgt|\n tgt_f = application.define_task(Rake::FileTask, File.join(self.to_s, tgt))\n tgt_f.comment = \"Build #{tgt} in #{self}\"\n tgt_f.enhance([self])\n end\n end", "def define_newgem_tasks\n unless self.extra_dev_deps.find { |dep| dep.first == 'newgem' }\n require File.dirname(__FILE__) + '/../newgem'\n self.extra_dev_deps ||= []\n self.extra_dev_deps << ['newgem', \">= #{::Newgem::VERSION}\"] unless name == 'newgem'\n end\n \n return if Rake::Task.tasks.find { |t| t.name == 'gemspec' }\n desc \"Generate a #{name}.gemspec file\"\n task :gemspec do\n File.open(\"#{name}.gemspec\", \"w\") do |file|\n file.puts spec.to_ruby\n end\n end\n \n task :release do\n puts <<-EOS.gsub(/^ /,'')\n Remember to create tag your release; eg for Git:\n git tag REL-#{$hoe.version}\n\n Announce your release on RubyForge News:\n rake post_news\n EOS\n end\n\n task :check_version do\n unless ENV['VERSION']\n puts 'Must pass a VERSION=x.y.z release version'\n exit\n end\n unless ENV['VERSION'] == $hoe.version\n puts \"Please update your lib/#{$hoe.name}.rb to match the release version, currently #{$hoe.version}\"\n exit\n end\n end\n\n desc 'Install the package as a gem, without generating documentation(ri/rdoc)'\n task :install_gem_no_doc => [:clean, :package] do\n sh \"#{'sudo ' unless Hoe::WINDOZE }gem install pkg/*.gem --no-rdoc --no-ri\"\n end\n \n task :ruby_env do\n $ruby_app = if RUBY_PLATFORM =~ /java/\n \"jruby\"\n else\n \"ruby\"\n end\n end\n \n end", "def define_racc_tasks\n racc_files = self.spec.files.find_all { |f| f =~ /\\.y$/ }\n rex_files = self.spec.files.find_all { |f| f =~ /\\.rex$/ }\n\n parser_files = racc_files.map { |f| f.sub(/\\.y$/, \".rb\") }\n lexer_files = rex_files.map { |f| f.sub(/\\.rex$/, \".rb\") }\n\n self.clean_globs += parser_files\n self.clean_globs += lexer_files\n\n rule \".rb\" => \".y\" do |t|\n begin\n sh \"racc #{racc_flags} -o #{t.name} #{t.source}\"\n rescue\n abort \"need racc, sudo gem install racc\"\n end\n end\n\n rule \".rb\" => \".rex\" do |t|\n begin\n sh \"rex #{rex_flags} -o #{t.name} #{t.source}\"\n rescue\n abort \"need rexical, sudo gem install rexical\"\n end\n end\n\n task :isolate # stub task\n\n desc \"build the parser\" unless parser_files.empty?\n task :parser => :isolate\n\n desc \"build the lexer\" unless lexer_files.empty?\n task :lexer => :isolate\n\n task :parser => parser_files\n task :lexer => lexer_files\n\n racc_tasks.each do |t|\n task t => [:parser, :lexer]\n end\n end", "def define_package_tasks\n prerelease_version\n\n Gem::PackageTask.new spec do |pkg|\n pkg.need_tar = @need_tar\n pkg.need_zip = @need_zip\n end\n\n desc \"Install the package as a gem. (opt. NOSUDO=1)\"\n task :install_gem => [:clean, :package, :check_extra_deps] do\n install_gem Dir[\"pkg/*.gem\"].first\n end\n\n desc \"Package and upload; Requires VERSION=x.y.z (optional PRE=a.1)\"\n task :release => [:prerelease, :release_to, :postrelease]\n\n # no doco, invisible hook\n task :prerelease do\n abort \"Fix your version before you release\" if spec.version.to_s =~ /borked/\n end\n\n # no doco, invisible hook\n task :release_to\n\n # no doco, invisible hook\n task :postrelease\n\n desc \"Sanity checks for release\"\n task :release_sanity do\n v = ENV[\"VERSION\"] or abort \"Must supply VERSION=x.y.z\"\n\n pre = ENV[\"PRERELEASE\"] || ENV[\"PRE\"]\n v += \".#{pre}\" if pre\n\n c = changes[/\\d\\S+/]\n\n abort \"Versions don't match: %s vs %s\" % [v, version] if v != version\n abort \"Versions don't match %s: %s vs %s\" % [history_file, v, c] if v != c\n end\n end", "def make_copy_file_tasks\n @files.each do |source, destination|\n next if source == destination\n next if Rake::FileTask.task_defined? destination\n type = File.directory?(source) ? 'folder' : 'file'\n task = Rake::FileTask.define_task destination do |t|\n folder = File.dirname(t.name)\n FileUtils.mkpath folder unless File.directory? folder\n FileUtils.copy source, t.name\n end\n task.comment = \"Create the #{destination} #{type}\"\n task.enhance ['wix']\n if Rake::FileTask.task_defined? source\n task.enhance [source]\n end\n end\n end", "def setup\n end", "def setup\n end", "def setup\n end", "def setup\n end", "def setup\n end", "def setup\n end", "def setup\n end", "def setup\n end", "def setup\n end", "def setup\n end", "def setup\n end", "def setup\n end", "def add_standard_buildr_plus_tasks\n add_standard_buildr_tasks\n\n desc 'Normalize the gitignore file based on buildr_plus rules'\n command(:normalize_gitignore) do |app|\n if File.exist?('vendor/tools/buildr_plus')\n git_clean_filesystem\n bundle_exec('buildr gitignore:fix')\n git_reset_index\n git_add_all_files\n mysystem('git add --all --force .gitignore 2> /dev/null > /dev/null')\n git_commit('Normalize .gitignore', false)\n end\n end\n\n desc 'Normalize the whitespace in files based on zapwhite rules'\n command(:normalize_whitespace, :in_app_dir => false) do |app|\n unless Zim.current_suite.application_by_name(app).tags.include?('zapwhite=no')\n app_directory = dir_for_app(app)\n if File.exist?(\"#{app_directory}/vendor/tools/buildr_plus\")\n Zim.in_dir(app_directory) do\n git_clean_filesystem\n bundle_exec('buildr zapwhite:fix')\n git_reset_index\n git_add_all_files\n mysystem('git add --all --force .gitattributes 2> /dev/null > /dev/null')\n git_commit('Normalize whitespace', false)\n end\n elsif File.exist?(\"#{app_directory}\")\n Zim.in_dir(app_directory) do\n git_clean_filesystem\n end\n mysystem(\"bundle exec zapwhite -d #{app_directory}\", false)\n Zim.in_dir(app_directory) do\n git_reset_index\n git_add_all_files\n mysystem('git add --all --force .gitattributes 2> /dev/null > /dev/null')\n git_commit('Normalize whitespace', false)\n end\n end\n end\n end\n\n desc 'Normalize the travis configuration based on buildr_plus rules'\n command(:normalize_travisci) do |app|\n if File.exist?('vendor/tools/buildr_plus') && File.exist?('.travis.yml')\n git_clean_filesystem\n bundle_exec('buildr travis:fix')\n git_reset_index\n git_add_all_files\n mysystem('git add --all --force .travis.yml 2> /dev/null > /dev/null')\n git_commit('Normalize travis configuration', false)\n end\n end\n\n desc 'Normalize the jenkins configuration based on buildr_plus rules'\n command(:normalize_jenkins) do |app|\n if File.exist?('vendor/tools/buildr_plus') && File.exist?('Jenkinsfile')\n git_clean_filesystem\n bundle_exec('buildr jenkins:fix')\n git_reset_index\n git_add_all_files\n mysystem('git add --all --force Jenkinsfile 2> /dev/null > /dev/null')\n mysystem('git add --all --force .jenkins 2> /dev/null > /dev/null', false)\n git_commit('Normalize jenkins configuration', false)\n end\n end\n\n desc 'Normalize the Gemfile based on buildr_plus rules'\n command(:normalize_gemfile) do |app|\n if File.exist?('vendor/tools/buildr_plus')\n git_clean_filesystem\n mysystem('rm Gemfile.lock')\n bundle_exec('buildr gems:fix')\n git_reset_index\n git_add_all_files\n mysystem('git add --all --force Gemfile Gemfile.lock 2> /dev/null > /dev/null')\n git_commit('Normalize Gemfile', false)\n end\n end\n\n desc 'Normalize files using buildr_plus rules'\n command(:normalize_all) do |app|\n run(:normalize_gemfile, app)\n run(:normalize_gitignore, app)\n run(:normalize_whitespace, app)\n run(:normalize_travisci, app)\n run(:normalize_jenkins, app)\n end\n end", "def setup_files\n create_application_rb\n create_production_rb\n end", "def setup_java_extension(extension_name, gem_spec = nil, opts = {})\n ext_name = \"#{extension_name}.jar\"\n directory 'lib'\n opts = {\n :source_dir => 'ext-java/src/main/java',\n :add_buildr_task => true\n }.merge!(opts)\n\n desc 'Compile Extension for current Ruby (= compile:jruby)'\n task :compile => [ 'compile:jruby' ] if JRUBY\n\n namespace :compile do\n\n desc \"Compile Java Extension for JRuby\"\n task :jruby => [ :clean ] do\n pkg_classes = File.join(*%w(pkg classes))\n mkdir_p pkg_classes\n\n if extension_name == 'do_jdbc_internal'\n classpath_arg = java_classpath_arg\n else\n unless File.exists?('../do_jdbc/lib/do_jdbc_internal.jar')\n # Check for the presence of do_jdbc_internal.jar in the do_jdbc project\n # which we need to compile against.\n print \"\\n\"; 80.times { print '-' }; print \"\\n\"\n puts \"To compile the Java extension, #{extension_name}, you will first need to compile\"\n puts \"common JDBC support for DataObjects, do_jdbc:\"\n puts \"cd ../do_jdbc; jruby -S rake compile\"\n 80.times { print '-' }; print \"\\n\\n\"\n\n raise \"Required file for compilation (do_jdbc_internal.jar) not found.\"\n end\n\n classpath_arg = java_classpath_arg '../do_jdbc/lib/do_jdbc_internal.jar'\n end\n\n # just use the extension directory from the executing java\n # for compilation as well\n extdir = java.lang.System.getProperty('java.ext.dirs')\n extdir_arg = extdir.nil? ? \"\" : \"-extdirs #{extdir}\"\n\n # Check if DO_JAVA_DEBUG env var was set to TRUE\n # TRUE means compile java classes with debug info\n if ENV['DO_JAVA_DEBUG'] && ENV['DO_JAVA_DEBUG'].upcase.eql?(\"TRUE\")\n sh \"javac #{extdir_arg} -target 1.5 -source 1.5 -Xlint:unchecked -g -d pkg/classes #{classpath_arg} #{FileList[\"#{opts[:source_dir]}/**/*.java\"].join(' ')}\"\n else\n sh \"javac #{extdir_arg} -target 1.5 -source 1.5 -Xlint:unchecked -d pkg/classes #{classpath_arg} #{FileList[\"#{opts[:source_dir]}/**/*.java\"].join(' ')}\"\n end\n\n sh \"jar cf lib/#{ext_name} -C #{pkg_classes} .\"\n end\n\n if opts[:add_buildr_task]\n desc \"Compile Java Extension for JRuby (with buildr)\"\n task :jruby_buildr do\n begin\n # gem 'buildr', '~>1.3'\n # FIXME: this is throwing RSpec activation errors, as buildr relies on\n # an older version of Rake.\n\n sh %{#{RUBY} -S buildr package}\n\n buildr_output = extension_name.gsub(/_(ext)$/, '-\\1-java-1.0.jar')\n cp \"ext-java/target/#{buildr_output}\", \"lib/#{ext_name}\"\n rescue LoadError\n puts \"#{spec.name} requires the buildr gem to compile the Java extension\"\n end\n end\n end\n\n end\n file \"lib/#{ext_name}\" => 'compile:jruby'\n\nend", "def define_all_task\n define_desc_task(\"Version, verify, document, package\", :all => [ :version, :verify, :doc, :package ])\n define_verify_task\n define_doc_task\n define_commit_task\n # This is a problem. If the version number gets updated, Gem::PackageTask\n # fails. This is better than if it used the old version number, I\n # suppose, but not as nice as if it just used @spec.version everywhere.\n # The solution for this is to do a dry run before doing the final +rake+\n # +commit+, which is a good idea in general.\n Gem::PackageTask.new(@spec) { |package| }\n end", "def setup\n switch_dir\n end", "def load_tasks\n RakeLoader.new.load_tasks\n end", "def define_debug_tasks\n desc \"Create a fresh ~/.hoerc file.\"\n task :config_hoe do\n with_config do |config, path|\n File.open(path, \"w\") do |f|\n YAML.dump(Hoe::DEFAULT_CONFIG.merge(config), f)\n end\n\n editor = ENV[\"EDITOR\"] || \"vi\"\n system \"#{editor} #{path}\" if ENV[\"SHOW_EDITOR\"] != \"no\"\n end\n end\n\n desc \"Verify the manifest.\"\n task :check_manifest => :clean do\n check_manifest\n end\n\n desc \"Show information about the gem.\"\n task :debug_gem do\n puts spec.to_ruby\n end\n\n task :isolate # stub\n task :irb => :isolate do\n name = spec.name.gsub(\"-\", \"/\")\n file = (spec.files.grep(/^lib\\/#{name}\\.rb$/).first ||\n spec.files.grep(/^lib\\/[^\\/]*\\.rb$/).first)\n\n require = File.basename(file, \".rb\") if file\n require &&= \"-r#{require}\"\n\n ruby \"#{Hoe::RUBY_FLAGS} -S irb #{require}\"\n end\n end", "def setup\n @executor.start_section \"Vundle\"\n @executor.create_path_in_home \".vim\", \"bundle\", \"vundle\"\n @executor.execute \"Cloning Vundle\", \"git clone #{@vundle_repo} #{vundle_folder}\" do |output, error_output|\n raise TaskSkipped.new(\"Already exists\") if error_output.include? \"already exists\"\n end\n end", "def define\n fail \"Name required (or :noversion)\" if @name.nil?\n @name = nil if :noname == @name\n\n desc \"Build all the packages\"\n task :compile => :pack do\n [images_dir, css_dir].each { |dir| mkdir_p(\"#{package_dir_path}/#{dir}\") }\n FileUtils.cp(image_files, package_images_path)\n FileUtils.cp(css_files, package_css_path)\n FileUtils.cp(package_files, package_dir_path)\n end\n \n desc \"Force a rebuild of the package files\"\n task :recompile => [:clobber_compile, :compile]\n \n desc \"Remove compile products\" \n task :clobber_compile do\n FileUtils.rm_r(package_dir_path) rescue nil\n end\n \n desc \"Merge js files into one\"\n task :merge do\n FileUtils.mkdir(package_dir_path) rescue nil\n `#{sed_command}`\n end\n \n desc \"Compress js files to min\"\n task :pack => :merge do\n `#{packer_command}`\n end\n\n task :clobber => [:clobber_compile]\n\n self\n end" ]
[ "0.71884984", "0.7062708", "0.70167685", "0.6988959", "0.6921596", "0.6753971", "0.6698098", "0.66938114", "0.6672065", "0.6625058", "0.66134447", "0.65917397", "0.6524384", "0.64845943", "0.6466148", "0.6444607", "0.63418984", "0.63400584", "0.62423944", "0.6240044", "0.6226615", "0.6153396", "0.61061084", "0.6103492", "0.60797673", "0.6035586", "0.60344076", "0.6026473", "0.6002134", "0.5971331", "0.5947902", "0.594359", "0.5941429", "0.59096295", "0.59033823", "0.5880819", "0.5870262", "0.58668786", "0.58581984", "0.5846814", "0.5836406", "0.582576", "0.58107895", "0.58043367", "0.58030885", "0.5802949", "0.57953125", "0.57842475", "0.57693064", "0.5759375", "0.5752759", "0.57507974", "0.574071", "0.57326937", "0.57086676", "0.5705291", "0.56996626", "0.5676811", "0.5676811", "0.5676811", "0.5676811", "0.5676811", "0.56716764", "0.5669006", "0.5655793", "0.5654732", "0.5625761", "0.5621017", "0.5621017", "0.5617383", "0.5614445", "0.5591851", "0.5582883", "0.5582883", "0.5581495", "0.5574547", "0.55671394", "0.55600834", "0.55465746", "0.554571", "0.554571", "0.554571", "0.554571", "0.554571", "0.554571", "0.554571", "0.554571", "0.554571", "0.554571", "0.554571", "0.554571", "0.5540692", "0.5533503", "0.5532631", "0.55239546", "0.55228066", "0.55159205", "0.55020946", "0.5500834", "0.54945266" ]
0.78485155
0
Returns +true+ if the projects dependencies include `rakecompiler`.
def has_rakecompiler_dependency? return self.dependencies.any? do |dep| dep.name == 'rake-compiler' end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def disable_rake_compiler?\n\t\treturn self.disable_rake_compiler ? true :false\n\tend", "def has_dependencies?\n update_for.length > 0 or requires.length > 0\n end", "def is_rake\n\tFile.basename($0) == 'rake'\nend", "def activate_compiler_deps\n dependency \"rake-compiler\", \"~> 1.0\", :development\n\n gem \"rake-compiler\", \"~> 1.0\"\n rescue LoadError\n warn \"Couldn't load rake-compiler. Skipping. Run `rake newb` to fix.\"\n end", "def dependency_met?\n true\n end", "def should_build?\n config.auto_build && !dev_server_running?\n end", "def build?\n engine == :ruby && %w(1.8.7 1.9.2).include?(ruby_version)\n end", "def project?\n true\n end", "def compiling?\n !@converging\n end", "def development?\n @dependency.type == :development\n end", "def is_cross_compiled?\n return @cross_compiled\n end", "def dependencies_resolved?\n !@resolved_dependencies.nil?\n end", "def dependencies_met?\n @dependencies_met ||= command_dependencies_met?(command_options)\n end", "def has_dependency?\n return true unless @dependency.nil?\n end", "def modules_enabled?\n return nil unless target\n setting = target.resolved_build_setting(\"CLANG_ENABLE_MODULES\")[\"Release\"]\n return nil unless setting\n setting == \"YES\"\n end", "def depends_on?(node)\n dependency_list = []\n @dependencies.each do |d|\n dependency_list << d if node.run_list.include? d\n end\n [dependency_list.any?, dependency_list]\n end", "def dependent?\n @flags.include?(:dependent)\n end", "def needed?(sources, target, dependencies)\n map = compile_map(sources, target)\n return false if map.empty?\n return true unless File.exist?(target.to_s)\n source_files_not_yet_compiled = map.select { |source, target| !File.exist?(target) }.to_a\n trace \"Compile needed because source file #{source_files_not_yet_compiled[0][0]} has no corresponding #{source_files_not_yet_compiled[0][1]}\" unless source_files_not_yet_compiled.empty?\n return true if map.any? { |source, target| !File.exist?(target) || File.stat(source).mtime > File.stat(target).mtime }\n oldest = map.map { |source, target| File.stat(target).mtime }.min\n return dependencies.any? { |path| file(path).timestamp > oldest }\n end", "def prerelease?\n requirements.any? {|r| r.last.prerelease? }\n end", "def is_rake_running?\n `ps -ef | grep rake | grep #{Process.ppid} | grep -v 'grep'`.size > 0\n end", "def needed?\n topology.packages.length > 1\n end", "def dependencies_installed?(builder)\n warn_if_gif2webp_missing builder\n cwebp_installed? builder\n end", "def has_compiler_flag(file, flag)\n settings = file.settings\n return false if settings.nil?\n\n compiler_flags = settings['COMPILER_FLAGS']\n return false if compiler_flags.nil?\n\n compiler_flags.include? flag\n end", "def cmake_has_parallel_flag?\n (CMAKE_VERSION <=> [3, 12]) >= 0\nend", "def python?\n exist? 'requirements.txt'\n end", "def build_tool?(build_tool)\n ENV[\"PATH\"].split(File::PATH_SEPARATOR).each do |path|\n builder = File.join(path, build_tool)\n\n if File.exists?(builder)\n return true\n end\n end\n false\n end", "def precompiled?\n @extname ||= File.extname(self.filepath)[1..-1]\n PRECOMPILED_FILE_TYPES.include?(@extname)\n end", "def gcc?\n linux? && present?('g++')\n end", "def dep_defined?\n @dep_defined\n end", "def have_exact_prebuild_cache?\n\n # check if need build frameworks\n return false if local_manifest == nil\n \n changes = prebuild_pods_changes\n added = changes.added\n changed = changes.changed \n unchanged = changes.unchanged\n deleted = changes.deleted \n \n exsited_framework_pod_names = sandbox.exsited_framework_pod_names\n missing = unchanged.select do |pod_name|\n not exsited_framework_pod_names.include?(pod_name)\n end\n\n needed = (added + changed + deleted + missing)\n \n return needed.empty?\n end", "def has_pre_tasks?\n !@pre_tasks.empty?\n end", "def include_dev?\n config.dig(\"composer\", \"include_dev\") == true\n end", "def dependencies_are_ready?\n return @dependencies_are_ready unless @dependencies_are_ready.nil?\n return false if @dependencies_have_failed\n ready = all? do |task|\n task.successful? or task.skipped?\n end\n debug 'All dependencies are ready' if ready\n @dependencies_are_ready = ready\n end", "def depends_on?(other_task)\n depends_on.include?(other_task)\n end", "def warnings?\n !gem?(\"shelly-dependencies\")\n end", "def compiled_cython_file?\n return false unless ['.c', '.cpp'].include? extname\n return false unless lines.count > 1\n return lines[0].include?(\"Generated by Cython\")\n end", "def compiled?\n !!@compiled\n end", "def compiled?\n !!@compiled\n end", "def using_compass_compiler\n bool(options[:compass] && options[:compass][:compiler_in_use])\n end", "def should_build?\n return true if tagged_build?\n return should_build_nightly? if ENV['IS_NIGHTLY']\n\n # Find the oldest common revision between HEAD's parent and our\n # default branch.\n #\n # HEAD's parent may _be_ our default branch, or the commit before\n # `master` if we've forked to a branch off it. More than likely,\n # though, `HEAD^1` is some commit in our stream of history, and will\n # be sufficient to find the starting point of divergence, if such a\n # point exists.\n #\n # If HEAD is a merge commit on `master`, then HEAD^1 points to the\n # previous commit on `master`, which should clearly be completely\n # separate from the branch that was merged, and hence the fork point\n # will be the point of divergence.\n oldest_shared_revision = sh(\"git merge-base '#{DEFAULT_BRANCH}' 'HEAD^1'\")\n\n # Get all files that changed between the fork point and HEAD\n changed_files = git_log_between(oldest_shared_revision, 'HEAD').unique_lines\n\n # 1. Check if any packages we care about changed\n if changed_files.include?('package.json') &&\n npm_native_package_changed?(oldest_shared_revision, 'HEAD')\n puts \"some dependency matching #{NPM_DEP_NAME_REGEXP.inspect} changed\"\n return true\n end\n\n # 2. Check if any files we care about changed\n if native_file_changed?(changed_files)\n puts 'some native file changed'\n return true\n end\n\n # 3. If we haven't decided to build yet, we aren't going to.\n puts 'build skippable'\n false\nend", "def config_tool_needed?\n false\n end", "def tooling?\n true\n end", "def recompile?\n true\n end", "def recompile?\n true\n end", "def gem_only_available?()\n return !determine_common_folder() && is_dtk_common_core_gem_installed?\nend", "def without_autobuild?\n Threaded.executing?(:without_autobuild)\n end", "def rake_task?\n defined?(::Rake) && !Rake.application.top_level_tasks.empty?\n end", "def dependencies_satisfied?\n missing_dependencies.empty?\n end", "def dependencies_installed?(database)\n dependencies.all?{|_, d| d.installed?(database)}\n end", "def has_conflicts?\n return true unless Gem.env_requirement(name).satisfied_by?(version)\n self.dependencies.any? do |dep|\n if dep.runtime?\n spec = Gem.loaded_specs[dep.name]\n spec and not spec.satisfies_requirement? dep\n else\n false\n end\n end\n end", "def meets_pods_project_source_dependency(source_filename, dependent_source_filename)\n has_pods_project_source_file(source_filename) ? has_pods_project_source_file(dependent_source_filename) : true\nend", "def meets_pods_project_source_dependency(source_filename, dependent_source_filename)\n has_pods_project_source_file(source_filename) ? has_pods_project_source_file(dependent_source_filename) : true\nend", "def prerelease?\n @prerelease || requirement.prerelease?\n end", "def node_modules?\n !!name.match(/node_modules\\//)\n end", "def deps_satisfied?(deps)\n deps.each do |dep|\n if dep.to_s =~ /^no_(.*)$/\n return false if @used_legos.include?( $1 )\n else\n return false unless @used_legos.include?( dep.to_s )\n end\n end\n\n true\nend", "def generated?\n xcode_file? ||\n generated_net_designer_file? ||\n generated_net_specflow_feature_file? ||\n composer_lock? ||\n node_modules? ||\n godeps? ||\n generated_by_zephir? ||\n minified_files? ||\n source_map? ||\n compiled_coffeescript? ||\n generated_parser? ||\n generated_net_docfile? ||\n generated_postscript? ||\n compiled_cython_file? ||\n generated_go? ||\n generated_protocol_buffer? ||\n generated_apache_thrift? ||\n generated_jni_header? ||\n generated_unity3d_meta? ||\n vcr_cassette?\n end", "def using_gcc?\n # Match gcc, /usr/local/bin/gcc-4.2, etc. (Clang is \"xcrun cc\")\n File.basename(RbConfig::MAKEFILE_CONFIG[\"CC\"]).match(/\\Agcc\\b/)\nend", "def installed?\n MacOS.dev_tools_path == Pathname.new(\"/usr/bin\")\n end", "def applies_to?(project, task)\n paths = task.sources + [sources].flatten.map { |src| Array(project.path_to(:source, task.usage, src.to_sym)) }\n paths.flatten!\n\n paths.each { |path|\n Find.find(path) {|found|\n if (!File.directory?(found)) && found.match(/.*\\.#{Array(source_ext).join('|')}/)\n return true\n end\n } if File.exist? path.to_s\n }\n false\n end", "def is_for_project?\n not self.project.nil?\n end", "def gemspec?\n !gemspecs.empty?\n end", "def from_dependency?\n source_options && version_dependency\n end", "def is_dependencies_installed?\n is_pkgs = @ssh.do_ssh_cmd('which puppet && which git')\n if is_pkgs[:exit_code] != 0\n abort 'Please install git and puppet on the targeted node'\n end\n true\n end", "def ruby?\n exist? 'Gemfile'\n end", "def dependency_backward_any?\n backward_dependencies.any?\n end", "def has_remote_package_sets?\n each_remote_package_set.any? { true }\n end", "def dependencies_satisfied?(deps)\n deps.all? do |dep|\n depprop = Proposal.where(barclamp: dep[\"barclamp\"], name: dep[\"inst\"]).first\n depprop_queued = depprop[\"deployment\"][dep[\"barclamp\"]][\"crowbar-queued\"] rescue false\n depprop_deployed = (depprop[\"deployment\"][dep[\"barclamp\"]][\"crowbar-status\"] == \"success\") rescue false\n\n depprop && !depprop_queued && depprop_deployed\n end\n end", "def valid?\n gemfile? && gemfile_lock? && gem?(\"thin\") &&\n gem?(\"rake\") && config_ru?\n end", "def needs_rebuild?\n (@items.size > 1) && (@version != @built_at_version)\n end", "def warnings?\n !gem?(\"shelly-dependencies\") || gem?(\"shelly\")\n end", "def should_do_requirements_install\n if has_python_requirements\n if not install_date('pythonenv')\n # We've never done an install from requirements.txt before\n return true\n else\n return (requirements_edit_date > install_date('pythonenv'))\n end\n else\n return false\n end\n end", "def run_build?\n ENV['BUILD_ASSETS'].to_s == 'true' ||\n build_files.blank? ||\n src_files.select { |f| File.mtime(f) >= File.mtime(cache_file) }.any?\n end", "def built?\n Namespace.root.executed_blueprints.include?(self)\n end", "def should_skip\n if @needed.nil?\n @needed = prerequisite_tasks.empty? || \\\n input_files.since(@last_executed).any? || \\\n @force\n\n # We also make sure that if the rakefile was modified since last\n # execution, we force reexecution\n if @application.rakefile\n @needed ||= File.mtime(@application.rakefile) > @last_executed\n end\n end\n !@needed\n end", "def project?\n ! @project.nil?\n end", "def compiled?\n !@result.nil?\n end", "def dependencies_have_failed?\n return @dependencies_have_failed unless @dependencies_have_failed.nil?\n failed = select do |task|\n task.failed?\n end\n debug \"Found failed dependencies: #{failed.map { |t| t.name }.join ', '}\" if failed.any?\n @dependencies_have_failed = failed.any?\n end", "def is_dependency_installed?\n if self.dependable\n $db.services.each do |service|\n if service[:service_type] == self.type\n return true\n end\n end\n end\n false\n end", "def satisfied?\n dependencies.none? { |_, v| v.empty? }\n end", "def dependency?(software)\n name = software.is_a?(Software) ? software.name : software\n dependencies.include?(name)\n end", "def dependency?(software)\n name = software.is_a?(Software) ? software.name : software\n dependencies.include?(name)\n end", "def missing_extensions?\n return false if extensions.empty?\n return false if default_gem?\n return false if File.exist? gem_build_complete_path\n\n true\n end", "def quiet_deps_option\n !!jekyll_sass_configuration.fetch(\"quiet_deps\", false)\n end", "def built?\n @built = false if @built.nil?\n @built\n end", "def rakeAppAndRvm\n\t\t\t(rakeApp? && rvm?)\n\t\tend", "def dependency?(software)\n name = if software.respond_to?(:name)\n software.send(:name)\n else\n software\n end\n @dependencies.include?(name)\n end", "def needs_compilation?(path, locals)\n return true if Merb::Config[:reload_templates] || !METHOD_LIST[path]\n \n current_locals = SUPPORTED_LOCALS_LIST[path]\n current_locals != locals &&\n !(locals - current_locals).empty?\n end", "def build?\n config[:mode] == :build\n end", "def buildable?\n git_url.present? and tags.include? :web_framework\n end", "def prerelease?\n comparable.prerelease?\n end", "def project_model?(name)\n return Rake::application[name].respond_to?('project_model')\n end", "def project_blueprint?\n true\n end", "def rake_running\n `ps | grep 'rake' | grep -v 'grep' | wc -l`.to_i > 1\nend", "def requires_transcoding?\n variant_jobs.all? { |j| j.requires_transcoding? }\n end", "def ruby?\n RUBY_ENGINE == 'jruby'\n end", "def packaging\n compiler && @compiler.class.packaging\n end", "def prerelease?\n parts.any? { |part| part.alpha? }\n end", "def dependency_forward_any?\n forward_dependencies.any?\n end", "def updateDeps(rakeTask)\n\t\treturn true\n\tend", "def updateDeps(rakeTask)\n\t\treturn true\n\tend" ]
[ "0.7176959", "0.6499878", "0.6452307", "0.6440881", "0.6309507", "0.62916625", "0.62530977", "0.61711013", "0.6141234", "0.6139968", "0.6090912", "0.6054291", "0.60233134", "0.5975129", "0.5960222", "0.59555286", "0.595487", "0.59412783", "0.59394854", "0.5927395", "0.592355", "0.5898502", "0.5897163", "0.58849484", "0.58715254", "0.5870104", "0.5869503", "0.58678716", "0.5854573", "0.5842586", "0.5817851", "0.58132553", "0.5796357", "0.57931685", "0.5788873", "0.57738715", "0.5770709", "0.5770709", "0.57652265", "0.576316", "0.5761866", "0.57583386", "0.57555974", "0.57555974", "0.5752496", "0.5731505", "0.57234", "0.57199967", "0.56705225", "0.566551", "0.56475097", "0.56475097", "0.56419975", "0.56335866", "0.56012297", "0.55849236", "0.5580767", "0.5578863", "0.55732054", "0.5559052", "0.5553369", "0.5546484", "0.5543164", "0.5523956", "0.55232966", "0.5510443", "0.5509944", "0.55085343", "0.55080754", "0.54794604", "0.54781485", "0.54771644", "0.54631513", "0.5463095", "0.5455186", "0.54521596", "0.54488015", "0.5445086", "0.54290247", "0.5424186", "0.5424186", "0.54238623", "0.5418915", "0.5409253", "0.5408654", "0.5404667", "0.54032606", "0.53909296", "0.5390329", "0.5385872", "0.5385385", "0.53843987", "0.53805727", "0.5374327", "0.53742564", "0.5373604", "0.53646606", "0.53502023", "0.5350003", "0.5350003" ]
0.8673069
0
Task function output debugging for extension tasks.
def do_extensions_debug( task, args ) self.prompt.say( "Extension config scripts:", color: :bright_green ) if self.extensions.empty? self.prompt.say "None." else self.extensions.uniq.each do |path| self.prompt.say "- %s" % [ path ] end end if self.has_rakecompiler_dependency? self.prompt.say "\n" self.prompt.say "✔ has rake-compiler dependency" end self.prompt.say( "\n" ) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def print_task(task)\n print \"==> \".info, task.bold, \"\\n\"\nend", "def print_task_info(task:)\n path = task.files.first['path'].chomp(\"/tasks/#{task.files.first['name']}\")\n module_dir = if path.start_with?(Bolt::Config::Modulepath::MODULES_PATH)\n \"built-in module\"\n else\n path\n end\n @stream.puts task.to_h.merge(module_dir: module_dir).to_json\n end", "def define_debug_tasks\n\t\ttask( :base_debug ) do\n\t\t\tself.output_documentation_debugging\n\t\t\tself.output_project_files_debugging\n\t\t\tself.output_dependency_debugging\n\t\tend\n\n\t\ttask :debug => :base_debug\n\tend", "def debug; end", "def debug; end", "def debug; end", "def debug; end", "def dump\n puts\n puts \"WorkFlow '#{ @label }' consists of the following tasks:\"\n @task_list.each{ |t| t.dump }\n puts\n end", "def task_details_for_log\n \"Node #{@puppet_mclient.node_id}, task #{@task}, manifest \"\\\n \"#{@puppet_mclient.manifest}\"\n end", "def debug(stuff)\n puts \"DEBUG: #{stuff}\"\nend", "def debug_output=(arg); end", "def debug\n @transform_tasks.push(\n add_transform_task('debug')\n )\n response = UploadUtils.make_call(url, 'get')\n JSON.parse(response.body)\n end", "def debug(msg)\n #puts msg\n end", "def dump\n unless @obsolete then\n puts \" WorkFlow task ##{ @id } '#{ @label }':\"\n puts \" #{ @inflows.count{ |f| !f.obsolete }} incoming flows:\"\n @inflows.each_with_index do |f,i|\n puts \" (#{ i }) #{ f.dump_info_from }\" unless f.obsolete\n end\n puts \" #{ @outflows.count{ |f| !f.obsolete }} outgoing flows:\"\n @outflows.each_with_index do |f,i| \n puts \" (#{ i }) #{ f.dump_info_to }\" unless f.obsolete\n end\n end\n end", "def set_debug_output(arg); end", "def debug\n\t\t\texec_parsed_action('debug', [], false)\n\t\tend", "def debug(msg)\n $tftplog.debug('tftp+') { msg }\nend", "def show # Show tasks method\n all_tasks.map.with_index { |l, i| \"(#{i.next}): #{l}\"} # Show all tasks array in numerical order and whether a task is completed\n end", "def debug_output_file\n \"debug.log\"\nend", "def debug?; end", "def debug?; end", "def print_task()\n puts @task_name\n puts \" Assigned to: #{@assigned_to}\"\n puts \" Priority: #{@priority}\"\n print \" Start Date: #{@date_start.month}/\"\n print \"#{@date_start.day}/\"\n puts \"#{@date_start.year}\"\n print \" End Date: #{@date_end.month}/\"\n print \"#{@date_end.day}/\"\n puts \"#{@date_end.year}\"\n self.get_duration\n end", "def debug(*args); end", "def debug(*args); end", "def debug(*args); end", "def taskDescription _args\n \"taskDescription _args;\" \n end", "def dump_info_to\n \"to task #{ target_task_id } as '#{ status }'#{ ' >obsolete<' if obsolete }\"\n end", "def print(*arg)\n CE.task.call(*arg)\nend", "def vputs(str)\n puts str if Rake.application.options.trace\nend", "def debug(msg, thread = nil)\n return nil unless $opt[:debug]\n function = (thread ? \"#{thread}.\" : '') + \\\n (caller[0][/`.*'/] ? caller[0][/`.*'/][1..-2].split(' ').last : 'core');\n puts \"#{function}#{(function.split(/\\.([^.]*)$/).last == 'core' ? '' : '()')}: #{msg}\".white\nend", "def exp_task\n\t\texperiments.each do |e|\n\t\t\tif !e.task_desc.nil?\n\t\t\t\te.task_desc + ' '\n\t\t\tend\n\t\tend\n\tend", "def external_task\n output[:task]\n end", "def debug_print(thing, title = nil, print_path = false)\n return if !%w[test development].include?(Rails.env)\n\n divider = \"#{\"-\" * 80}\"\n\n puts divider\n if title.present?\n puts %Q(#{title} (#{thing.class.name}))\n else\n puts thing.class.name\n end\n pp thing\n\n if print_path\n puts caller.first[0..caller.first.index(\":in\") - 1]\n end\n\n puts divider\n\n puts\n end", "def __debug_impl(*args, **opt, &block)\n opt.reverse_merge!(\n debug: true,\n leader: DEBUG_LEADER,\n max: DEBUG_MAX,\n omission: '...'\n )\n __output_impl(*args, **opt, &block)\nend", "def explain_true(task); end", "def displayRakeTasks\n Rake.application.tasks.each do |iTask|\n log_info \"+-#{iTask.name}: #{iTask.comment}\"\n iTask.prerequisites.each do |iPrerequisiteTaskName|\n log_info \"| +-#{iPrerequisiteTaskName}\"\n end\n log_info '|'\n end\n end", "def debug=(_arg0); end", "def debug=(_arg0); end", "def debug(msg)\n $stderr.puts(\"DEBUG: #{msg}\") if $options['verbose']\nend", "def debug(msg)\n $stderr.puts(\"DEBUG: #{msg}\") if $options['verbose']\nend", "def debug(msg)\n $stderr.puts(\"DEBUG: #{msg}\") if $options['verbose']\nend", "def inspect\n context = @solution.map{|k, v| \"#{k}: #{v}\"}.join(',')\n \"#<Twilio.Taskrouter.V1.TaskContext #{context}>\"\n end", "def debug(*info)\n puts(info) if debug_mode?\n end", "def debug(info)\n puts(info) if @debug\n end", "def debug(thing, tag = 'pre')\n %Q{<#{tag}>#{thing.to_yaml}</#{tag}>}\n end", "def debug?; run_options[:debug]; end", "def debug\n Puppet::Util::Log.level = :debug\n end", "def debug(message)\n puts \"#{Time.now.strftime(\"%H:%M:%S.%L\")} - \\t#{message}\" if DEBUG\nend", "def debug_log( arg )\r\n print('DEBUG: ')\r\n puts (arg)\r\nend", "def inspect\n context = @solution.map {|k, v| \"#{k}: #{v}\"}.join(',')\n \"#<Twilio.Taskrouter.V1.TaskContext #{context}>\"\n end", "def show\n @tasks.each do |project_name, project_tasks|\n @output.puts project_name\n project_tasks.each do |task|\n @output.printf(\" [%c] %d: %s : %s \\n\", (task.done? ? 'x' : ' '), task.id, task.description, task.deadline)\n end\n @output.puts\n end\n end", "def display_tasks_and_comments\n puts \"Displaying tasks... \\n\"\n puts\n if(options.show_tasks == :tasks)\n # Get the maximum width of all task names\n all_displayable_tasks = tasks.select { |t|\n t.comment && t.name =~ options.show_task_pattern\n }\n \n #puts \"Displayable tasks: #{all_displayable_tasks}\\n\"\n \n width = all_displayable_tasks.collect { |t| t.name_with_args.length }.max || 10\n max_column = truncate_output? ? terminal_width() - name.size - width - 7 : nil\n \n @ProjectFileLoader.LoadedProjectFiles().each do |projectFile|\n if(projectFile.HasTasks())\n headline = \"Tasks in project file: '#{projectFile.Path().RelativePath()}'\\n\"\n puts headline\n puts \"-\" * headline.length\n puts projectFile.GetTaskDescriptions(width, max_column)\n end \n end\n else\n super\n end\n end", "def debug(s)\n\t#puts \"DEBUG: #{s}\"\nend", "def debug(*args); puts(*args) if $test; end", "def print_debug(s)\n config = BeEF::Core::Configuration.instance\n if config.get('beef.debug') || BeEF::Core::Console::CommandLine.parse[:verbose]\n puts Time.now.localtime.strftime(\"[%k:%M:%S]\")+'[>]'.yellow+' '+s.to_s\n end\nend", "def debug_msg msg\n puts msg if @options[:debug]\n end", "def debugLog _args\n \"debugLog _args;\" \n end", "def debug( msg )\n puts Time.now.strftime(\"- %I:%M%p: \") + msg if @debug\nend", "def simpleTasks _args\n \"simpleTasks _args;\" \n end", "def debug args, msg\n args.outputs.debug << {\n x: 10,\n y: 700,\n text: msg\n }.label\nend", "def verbose_logging; end", "def taskOpts\nend", "def display_task(task)\n\t\t\tsplit_task(task.name).each_with_index do |name_line, line_index|\n\t\t\t\tcol_1 = pad((task.start_time if line_index==0), 5)\n\t\t\t\tcol_2 = pad(name_line, @name_width)\n\t\t\t\tcol_3 = pad((task.elapsed_time if line_index==0), @elapsed_time_width)\n\n\t\t\t\tif task.current? and TrackingConfig[:color_current_task]\n\t\t\t\t\tcurrent_task_color = TrackingConfig[:current_task_color]\n\t\t\t\t\tcurrent_task_color = TrackingConfig.defaults[:current_task_color] unless String.colors.include? current_task_color\n\n\t\t\t\t\tcol_1 = col_1.colorize current_task_color\n\t\t\t\t\tcol_2 = col_2.colorize current_task_color\n\t\t\t\t\tcol_3 = col_3.colorize current_task_color\n\t\t\t\tend\n\n\t\t\t\tputs \"| #{col_1} | #{col_2} | #{col_3} |\"\n\t\t\tend\n\t\tend", "def tapp\n Babushka::LogHelpers.deprecated! '2017-09-01'\n tap { STDOUT.puts \"#{File.basename caller[2]}: #{self.inspect}\" }\n end", "def __debug(*args, **opt, &block)\n __debug_impl(*args, **opt, &block)\nend", "def info_string\n \"#{step}: #{process}\"\n end", "def do_debug\n # debugging = true\n debugging = false\n puts yield if debugging\n end", "def show_tasks\n\t\tputs \"here are the tasks on the #{self.name} list...\"\n\t\t@tasks.map.with_index {|task, i| puts \"#{i.next}. \" + task.description + \" | complete: \" + task.status.to_s}\n\t\tputs \"\\n\"\n\tend", "def registeredTasks _args\n \"registeredTasks _args;\" \n end", "def dump_info_from\n \"from task #{ source_task_id } as '#{ status_id }'#{ ' >obsolete<' if obsolete }\"\n end", "def description\n \"This task converts a netblock into host records\"\nend", "def describe(detail=0, indent=0)\n i = ' ' * indent\n lines = [\"#{i}#{name} (#{self.class}) {\"]\n @tasks.each_value { |t|\n lines << t.describe(detail, indent + 2)\n }\n lines << i + \"}\"\n lines.join(\"\\n\")\n end", "def debug(*text)\n if configuration.debug\n channel.write(\"command\" => \"debug\", \"text\" => \"worker #{runner_id}.#{worker_number}: #{text.join}\", \"worker_number\" => worker_number)\n end\n end", "def debug(msg)\n end", "def debug1(text) debug text, 1 end", "def display_tasks\n puts \"What do you want to do? \\n\"\n puts TASKS.values\n end", "def debug( msg )\n puts Time.now.strftime(\"- %I:%M%p: \") + msg\nend", "def pre_generation_hook(task)\n end", "def debug(options = T.unsafe(nil)); end", "def dump_pending\n end", "def dump_pending\n end", "def debug_emit(fname = \"output\")\n file = File.new(fname+\".debug\", \"w+\")\n @instr.each{|i|\n file.puts \"#{i.to_s}\"\n }\n file.close \n end", "def debug_print_wrapper(title = nil, print_path = true, &block)\n return if !%w[test development].include?(Rails.env)\n\n start_divider = \"#{\">\" * 80}\"\n end_divider = \"#{\"<\" * 80}\"\n\n\n if title.present?\n puts \" #{title} \".upcase.center(80, start_divider[0])\n else\n puts start_divider\n end\n\n block.call\n\n if print_path\n puts \" Wrapped from block call at: \".center(80, \"-\")\n puts caller.first[0..caller.first.index(\":in\") - 1]\n end\n\n puts end_divider\n puts\n end", "def show\n #binding.pry\n end", "def explain_static(task); end", "def dump(task)\n MultiJson.dump({}.tap do |h|\n h[:title] = task.title\n h[:uuid] = task.uuid\n h[:project] = task.project.uuid if task.project\n end)\n end", "def task_warning( task )\n warn \"WARNING: '#{task}' tasks are not defined. Please run 'rake develop'\"\n end", "def define_debug_tasks\n desc \"Create a fresh ~/.hoerc file.\"\n task :config_hoe do\n with_config do |config, path|\n File.open(path, \"w\") do |f|\n YAML.dump(Hoe::DEFAULT_CONFIG.merge(config), f)\n end\n\n editor = ENV[\"EDITOR\"] || \"vi\"\n system \"#{editor} #{path}\" if ENV[\"SHOW_EDITOR\"] != \"no\"\n end\n end\n\n desc \"Verify the manifest.\"\n task :check_manifest => :clean do\n check_manifest\n end\n\n desc \"Show information about the gem.\"\n task :debug_gem do\n puts spec.to_ruby\n end\n\n task :isolate # stub\n task :irb => :isolate do\n name = spec.name.gsub(\"-\", \"/\")\n file = (spec.files.grep(/^lib\\/#{name}\\.rb$/).first ||\n spec.files.grep(/^lib\\/[^\\/]*\\.rb$/).first)\n\n require = File.basename(file, \".rb\") if file\n require &&= \"-r#{require}\"\n\n ruby \"#{Hoe::RUBY_FLAGS} -S irb #{require}\"\n end\n end", "def debug(message)\n $stderr.puts(message) if @options[:debug]\nend", "def get\n super\n .tap { |result| __ext_debug(\"--> #{result.inspect}\") }\n end", "def do_docs_debug( task, args )\n\t\tself.prompt.say( \"Docs are published to:\", color: :bright_green )\n\t\tif ( publish_url = self.publish_to )\n\t\t\tself.prompt.say( self.indent(publish_url, 4) )\n\t\telse\n\t\t\tself.prompt.say( self.indent(\"n/a\"), color: :bright_yellow )\n\t\tend\n\t\tself.prompt.say( \"\\n\" )\n\tend", "def debug(msg)\n puts \"[watchr debug] #{msg}\" if options.debug\n end", "def what_task\n if running_task?\n puts \"Current task: \" + get_last_task_name + \", #{(Time.now.to_i - get_last_task_stime.to_i).duration}\"\n else\n puts \"No task running!\"\n end\n end", "def dump_code( type_switch = 1 )\n wf_name = label.downcase.gsub(/ /,'_')\n puts\n puts \"Code Snippets for #{ label }:\"\n puts\n puts \"Number of tasks: #{ @task_list.count }\"\n puts \"Number of flows: #{ @flow_list.count }\"\n puts \"Number of states: #{ @status_list.count }\"\n puts\n puts \"List of Task Labels (I18n format):\"\n puts \n puts \" workflow:\"\n puts \" w00:\"\n puts \" label:\\t'#{ label }'\"\n puts \" tasks:\"\n @task_list.each_with_index do |t,i|\n next if t.nil?\n puts \" #{ sprintf('t%02d',i)}:\\t'#{ t.label }#{ ' <obsolete>' if t.obsolete }'\"\n end\n puts \" states:\"\n obsolete_marker = Array.new( status_list.count, false )\n @flow_list.each{ |f| obsolete_marker[ f.status_id ] |= f.obsolete }\n @status_list.each_with_index do |l,i|\n puts \" #{ sprintf('s%02d',i )}:\\t'#{ status_list[ i ]}#{ ' <obsolete>' if obsolete_marker[ i ] }'\"\n end\n puts\n puts \"Transition Structure:\"\n puts\n printf \"@#{ wf_name } = WorkFlowHelper.new([\"\n\n case type_switch\n when 0\n sep = \"\\n\"\n @task_list.each do |t|\n flows = t.outflows.collect{ |f| f.id }.join(',')\n tasks = t.outflows.collect{ |f| f.target_task_id }.join(',')\n printf \"%s [[%s],[%s]]\", sep, flows, tasks\n sep = \",\\n\"\n end\n when 1\n sep = \"\\n\"\n flow_tasks = ''\n @task_list[0...-1].each do |t|\n next if t.nil?\n flow_tasks = t.outflows.collect{ |f| \"[ %d, %d ]\" % [ f.status_id, f.target_task_id ]}.join(',')\n printf \"%s [%s]\", sep, flow_tasks\n sep = \",\\n\"\n end\n printf \"%s [[ -1, %d ]]\\n\", sep, @task_list.length - 1\n end\n\n puts \"])\"\n puts\n\n # list all roles with tasks for which they are responsible\n\n puts 'Responsibilities:'\n puts\n @role_list.each_with_index do |r,i|\n s = sprintf \"%-20s\", @role_list[ i ]\n sep = ''\n @task_list[0...-1].each_with_index do |t,j|\n next if t.nil?\n if t.role_id == i then\n s += sep + j.to_s\n sep = ','\n end\n end\n puts s\n end\n puts\n\n # better warn the user if there were any validation errors ...\n\n if @validation_errors > 0 then\n puts \">>> Errors detected during validation - check full report above. <<<\"\n puts\n end\n\n end", "def tapp\n tap { puts \"#{File.basename caller[4]}: #{self.inspect}\" }\n end", "def to_s # Method to display completion status and description of Task\n \"#{represent_status} : #{description}\"\n end", "def debug (msg = \"\")\n if Object.const_defined?('Puppet')\n Puppet.debug 'facter(extra_modulepath):'+msg\n else\n if ENV['FACTER_DEBUG'] == 'true'\n $stdout.puts msg\n $stdout.flush\n end\n end\nend", "def debug_msg( str )\n puts str if @debug == true\n end", "def debug! \n $DEBUG = true\n end", "def inspect\n \"<Celluloid::Task:0x#{object_id.to_s(16)} @type=#{@type.inspect}, @running=#{@fiber.alive?}>\"\n end" ]
[ "0.6818291", "0.67156774", "0.66474164", "0.6489559", "0.6489559", "0.6489559", "0.6489559", "0.6459194", "0.6370725", "0.6303394", "0.6285485", "0.6280167", "0.61767304", "0.61711234", "0.613699", "0.60860735", "0.6062757", "0.6056759", "0.60391605", "0.6021989", "0.6021989", "0.6012888", "0.60124207", "0.60124207", "0.60124207", "0.59924173", "0.5989689", "0.59841436", "0.5977727", "0.5968779", "0.59453046", "0.594014", "0.59202224", "0.58646595", "0.5857137", "0.5851283", "0.58497185", "0.58497185", "0.58293563", "0.58293563", "0.58293563", "0.5809654", "0.5795247", "0.5792939", "0.5792512", "0.5788034", "0.5778818", "0.57463986", "0.5744643", "0.5737246", "0.57262653", "0.5716137", "0.5715706", "0.5691106", "0.56841767", "0.5676783", "0.56594664", "0.56533974", "0.5650948", "0.5649199", "0.5643479", "0.5643372", "0.56257045", "0.56145066", "0.5614037", "0.5602058", "0.5595858", "0.5592726", "0.55831075", "0.55830985", "0.5572677", "0.5567589", "0.5560853", "0.5553981", "0.5553898", "0.5549488", "0.55492187", "0.5543688", "0.5543492", "0.5541231", "0.5541231", "0.5538194", "0.5537549", "0.55374104", "0.55361265", "0.55285746", "0.55266035", "0.5493893", "0.5491803", "0.5476891", "0.5475865", "0.545422", "0.5450507", "0.5449778", "0.5440128", "0.54311126", "0.54269546", "0.5422892", "0.5419821", "0.5419306" ]
0.7081757
0
Receives a view and update it accordingly with the given object id and the association cardinality.
def update(view, object) raise NotImplementedError end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def UpdateView params = {}\n \n APICall(path: 'views.json',method: 'PUT',payload: params.to_json)\n \n end", "def record_view\n self.views += 1\n save\n end", "def hit!\n raise ActiveRecord::MissingAttributeError, \"can't hit! #{ self.short_inspect }, missing attribute: views\" unless respond_to?(:views)\n self.class.increment_counter(:views, id)\n end", "def update\n @view = View.find(params[:id])\n\n respond_to do |format|\n if @view.update_attributes(params[:view])\n format.html { redirect_to @view, notice: 'View was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @view.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\t\t@relation = Relation.find(params[:id])\n\t\t@views = View.all\n\t\t@types = Typesobject.get_types(\"relation\")\n\t\t@status = Statusobject.get_status(\"relation\")\n\t\t@relation.update_accessor(current_user)\n\t\trespond_to do |format|\n\t\t\tif @relation.update_attributes(params[:relation])\n\t\t\t\tflash[:notice] = t(:ctrl_object_updated,:typeobj =>t(:ctrl_relation),:ident=>@relation.ident)\n\t\t\t\tshow_\n\t\t\t\tformat.html { render :action => \"show\" }\n\t\t\t\t#format.html { redirect_to(@relation, :notice => 'Relation was successfully updated.') }\n\t\t\t\tformat.xml { head :ok }\n\t\t\telse\n\t\t\t\tflash[:error] = t(:ctrl_object_not_updated,:typeobj =>t(:ctrl_relation),:ident=>@relation.ident, :error => @object_plm.errors.full_messages)\n\t\t\t\tformat.html { render :action => \"edit\" }\n\t\t\t\tformat.xml { render :xml => @relation.errors, :status => :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend", "def update_view (idea_id)\n # check to only update view once a day\n view = View.where(:user_id => current_user.id, :idea_id => idea_id).last\n \n go = false\n \n if view\n created_at = view.created_at\n time = Time.now\n difference = time - created_at\n \n if difference > 86400\n go = true\n end\n else\n go = true\n end \n \n if go == true\n view = View.new\n view.idea_id = idea_id\n view.user_id = current_user.id\n view.save \n end\n \n end", "def update\n @view = View.find(params[:id])\n\n respond_to do |format|\n if @view.update_attributes(params[:view])\n flash[:notice] = 'View was successfully updated.'\n format.html { redirect_to(@view) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @view.errors, :status => :unprocessable_entity }\n end\n end\n end", "def mark_as_viewed\n self.views += 1\n self.save( :validate => false)\n end", "def update\n\t\t@relation = Relation.find(params[:id])\n\t\t@datas=@relation.datas\n\t\t@views = View.all\n\t\t@relation.update_accessor(current_user)\n\t\trespond_to do |format|\n\t\t\tif @relation.update_attributes(params[:relation])\n\t\t\t\tflash[:notice] = t(:ctrl_object_updated,:typeobj =>t(:ctrl_relation),:ident=>@relation.ident)\n\t\t\t\tformat.html { redirect_to(@relation, :notice => 'Relation was successfully updated.') }\n\t\t\t\tformat.xml { head :ok }\n\t\t\telse\n\t\t\t\tflash[:error] = t(:ctrl_object_not_updated,:typeobj =>t(:ctrl_relation),:ident=>@relation.ident)\n\t\t\t\tformat.html { render :action => \"edit\" }\n\t\t\t\tformat.xml { render :xml => @relation.errors, :status => :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend", "def update!(**args)\n @view_count = args[:view_count] if args.key?(:view_count)\n end", "def update!(**args)\n @view_count = args[:view_count] if args.key?(:view_count)\n end", "def update!(**args)\n @view_count = args[:view_count] if args.key?(:view_count)\n end", "def set_view\n @view = View.find(params[:id])\n end", "def update\n @view = View.find(params[:id])\n\n respond_to do |format|\n if @view.update_attributes(params[:view])\n # There can only be one default view\n if params[:view][:default_view]\n @ministry.views.each do |view|\n view.update_attribute(:default_view, false) unless view == @view\n end\n end\n flash[:notice] = 'View was successfully updated.'\n format.html { redirect_to views_url }\n format.xml { head :ok }\n format.js\n else\n edit\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @view.errors.to_xml }\n format.js\n end\n end\n end", "def show\n @buy_ad.views += 1\n @buy_ad.save!\n end", "def show\n @ads = Announcement.find(params[:id])\n if (@ads.viewn.nil?)\n @viewn = 1\n else\n @viewn = @ads.viewn + 1\n end\n Announcement.all.update(@ads.id, :viewn => @viewn)\n end", "def show \n @videoshop = Videoshop.find(params[:id])\n id = @videoshop.id\n x = @videoshop.views\n vw = Videoshop.update(id, :views => x+1)\n vw.save\n end", "def update\n @view = View.find(params[:id])\n\n # We want to have three possible outcomes.\n # 1) The change is allowed and it succeeds (allowed == true and\n # result == true)\n # 2) The change is allowed but it fails (allowed == true and\n # result != true)\n # 3) The change is not allowed. (allowed != true)\n\n # What is allowed?\n # 1) A user that owns the view can change its attributes. This is\n # if @view.owner_id == @application_user.id and copy is false.\n # 2) A user that owns the view can changes its name and make a\n # copy (which will cause copies of the elements that belong to\n # the view to be created as well) This is if @view.owner_id ==\n # @application_user.id and copy is true.\n # 3) A user that does not own the view can create a new copy of\n # the view just like in #2 except the new view will be owned by\n # the current user. This is if @view.owner_id !=\n # @application_user.id and copy is true.\n allowed = false\n result = false\n if params[:copy] == true || params[:copy] == \"true\"\n allowed = true\n new_copy = View.new(params[:view])\n new_copy.owner_id = @application_user.id\n # See if we can save the new view\n if (result = new_copy.save)\n # New view is saved, now copy elements from original view to\n # new view.\n @view.elements.each do |element|\n new_element = new_copy.elements.build(element.attributes)\n new_element.owner_id = @application_user.id\n # We ignore the result of the following save. It should\n # never fail and if it does, we have a new view created and\n # some of the elements didn't get copied but there isn't\n # really a way to convey that to the user.\n new_element.save\n end\n @view = new_copy # redirect to new copy\n else\n # new_copy has the error messages. Move them to @view because\n # we want to call edit again with the same record but have the\n # error messages displayed.\n new_copy.errors.each_error do |attr, err|\n @view.errors.add(attr, err)\n end\n end\n elsif @view.owner_id == @application_user.id\n allowed = true\n result = @view.update_attributes(params[:view])\n end\n respond_to do |format|\n if allowed\n if result\n flash[:notice] = 'View was successfully updated.'\n format.html { redirect_to(@view) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @view.errors, :status => :unprocessable_entity }\n end\n else\n @view.errors.add_to_base \"You are not the owner of the view so you must make a copy\"\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @view.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @view_query = args[:view_query] if args.key?(:view_query)\n end", "def update!(**args)\n @view_query = args[:view_query] if args.key?(:view_query)\n end", "def update!(**args)\n @response_view = args[:response_view] if args.key?(:response_view)\n end", "def update\n params[:interview][:scheduler_id] = current_user.id\n @interview = @candidate.interviews.find(params[:id])\n params[:interview][:scheduled_at] = params[:edit][:date_scheduled_at]\n @interview.interviewers.create!(convert_string_to_hash(params[:interviewer_id], :user_id)) unless params[:interviewer_id].blank?\n @interview.interviewers.destroy(*params[:mark_to_delete].split(',').uniq) unless params[:mark_to_delete].blank?\n\n respond_to do |format|\n if @interview.update_attributes(params[:interview])\n format.html { redirect_to candidate_path(@candidate), notice: 'Interview was successfully updated.' }\n format.js { render :index }\n format.json { render json: @interview, status: :updated }\n else\n format.html { render action: \"edit\" }\n format.js { render :index }\n format.json { render json: @interview.errors, status: :unprocessable_entity }\n end\n end\n end", "def viewed!\n \tself.update_attribute :view_count, self.view_count+1\n end", "def show\n @ask = Ask.find(params[:id])\n ActiveRecord::Base.connection.update(\"update asks set views = views+1 where id = #{@ask.id}\")\n @ask_answers = AskAnswer.where(\"ask_id = :ask_id\" , {:ask_id => params[:id]}).order(\"created_at desc\")\n end", "def view\n ads = Ad.find(params[:id])\n views = AdsView.new\n views.ad_id = ads.id\n views.ipaddress = request.remote_ip\n views.hostname = request.host\n views.save\n \n Ad.increment_counter(:total_views, ads.id)\n redirect_to ads.redirect_to\n end", "def update_view_stats\n return unless respond_to?(:num_views=) || respond_to?(:last_view=)\n\n @old_num_views = num_views\n @old_last_view = last_view\n self.class.record_timestamps = false\n self.num_views = (num_views || 0) + 1 if respond_to?(:num_views=)\n self.last_view = Time.zone.now if respond_to?(:last_view=)\n save_without_our_callbacks\n self.class.record_timestamps = true\n end", "def update\n @resource_view = ResourceView.find(params[:id])\n\n respond_to do |format|\n if @resource_view.update_attributes(params[:resource_view])\n format.html { redirect_to new_resource_view_path(:current_part_id => @resource_view.part_id), notice: 'Resource view was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @resource_view.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_view name, type, columns, options={}\n view_structure = ActiveRecord::Base.connection.select_value(\"select definition from pg_views where viewname='#{name}'\")\n raise ViewNotExistException(\"View #{name} does not exist in current db\") unless view_structure\n \n columns_str = columns.is_a?(Array) ? columns.join(',') : columns\n \n select_pattern = /select (.*) from/i\n select_str = view_structure[select_pattern,1]\n\n case type\n when :add\n view_structure.gsub!(select_pattern, \"SELECT #{select_str}, #{columns_str} FROM\")\n when :remove\n select_str.gsub!(\", #{columns_str}\", '')\n view_structure.gsub!(select_pattern, \"SELECT #{select_str} FROM\")\n when :replace\n view_structure.gsub!(select_pattern, \"SELECT #{columns_str} FROM\")\n end\n\n drop_views name, options[:dependent_views] \n execute \"CREATE VIEW #{name} AS #{view_structure};\"\n end", "def show\n @article.update(view_count: @article.view_count.to_i + 1)\n end", "def set_yourview\n @yourview = Yourview.find(params[:id])\n end", "def update\n respond_to do |format|\n if @view.update(view_params)\n format.html { redirect_to @view, notice: 'View was successfully updated.' }\n format.json { render :show, status: :ok, location: @view }\n else\n format.html { render :edit }\n format.json { render json: @view.errors, status: :unprocessable_entity }\n end\n end\n end", "def view_ad(ad_id)\n \tmodify_adstat(ad_id, \"views\")\n end", "def update!(**args)\n @entity_view = args[:entity_view] if args.key?(:entity_view)\n @header = args[:header] if args.key?(:header)\n end", "def show\n @article.views = @article.views + 1\n @article.save\n end", "def update\n @entry_view = EntryView.find(params[:id])\n\n respond_to do |format|\n if @entry_view.update_attributes(params[:entry_view])\n format.html { redirect_to @entry_view, notice: 'Entry view was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @entry_view.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_design_doc(design_doc, db = database)\n saved = db.get(design_doc['_id']) rescue nil\n if saved\n design_doc['views'].each do |name, view|\n saved['views'][name] = view\n end\n db.save_doc(saved)\n saved\n else\n design_doc.database = db\n design_doc.save\n design_doc\n end\n end", "def view=(list_item)\n frm.select(:id=>\"view\").set(list_item)\n end", "def update\n @view_mapping = ViewMapping.find(params[:id])\n\n respond_to do |format|\n if @view_mapping.update_attributes(params[:view_mapping])\n format.html { redirect_to @view_mapping, notice: 'View mapping was successfully updated.' }\n format.json { render :json =>@view_mapping, :status=>:ok, :location=>@view_mapping.dojo_url }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @view_mapping.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @vouch = Vouch.find(params[:id])\n\n if current_user.id == @vouch.grantor_id\n case params[:commit]\n when \"Approve\"\n @vouch.confirm \n when \"Pending\"\n @vouch.pending\n when \"Deny\"\n @vouch.reject\n end\n end\n\n respond_to do |format|\n if @vouch.save\n format.js { render :action => \"update\", :content_type => 'text/javascript'}\n format.html { redirect_to polymorphic_path([parent,Vouch.new]), :notice => 'Vouch was successfully updated.' }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @vouch.errors, :status => :unprocessable_entity }\n format.js { render :partial => @vouch, :layout => false }\n end\n end\n end", "def increment_view_count\n increment(:view_count) # add view_count += 1\n write_second_level_cache # update cache per hit, but do not touch db\n # update db per 10 hits\n self.class.update_all({:view_count => view_count}, :id => id) if view_count % 10 == 0\n end", "def update\n pass_query_params\n # basic sanitizing of the param. ivars needed in js response\n # checked is a string!\n @reviewed = params[:reviewed] == \"1\"\n return unless (obs = Observation.find(params[:id]))\n\n # update_view_stats creates an o_v if it doesn't exist\n @obs_id = obs.id # ivar used in the js template\n ov = ObservationView.update_view_stats(@obs_id, User.current_id)\n # now we can update it\n ov.update(reviewed: @reviewed)\n respond_to do |format|\n format.js\n format.html do\n return redirect_to(identify_observations_path)\n end\n end\n end", "def update\n @interview = Interview.find(params[:id])\n @interview.user_id = current_user.id\n respond_to do |format|\n if @interview.update_attributes(params[:interview])\n format.html { redirect_to(@interview, :notice => 'Interview was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @interview.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n enforce_permissions!('manage_collection', params[:id])\n\n @object = retrieve_object!(params[:id])\n # If a cover image was uploaded, remove it from the params hash\n cover_image = params[:digital_object]&.delete(:cover_image)\n\n @institutes = Institute.all\n @inst = Institute.new\n\n supported_licences\n\n @object.assign_attributes(update_params)\n unless @object.valid?\n flash[:alert] = t('dri.flash.alert.invalid_object', error: @object.errors.full_messages.inspect)\n render :edit\n return\n end\n\n @object.increment_version\n\n if cover_image.present?\n url = Storage::CoverImages.validate_and_store(cover_image, @object)\n if url\n @object.cover_image = url\n else\n flash[:error] = t('dri.flash.error.cover_image_not_saved')\n end\n end\n\n respond_to do |format|\n if save_and_index\n post_save do\n mint_or_update_doi(@object, doi) if doi\n end\n\n flash[:notice] = t('dri.flash.notice.updated')\n format.html { redirect_to controller: 'my_collections', action: 'show', id: @object.alternate_id }\n format.json { render json: @object }\n else\n flash[:alert] = t('dri.flash.error.unable_to_persist')\n format.html { render action: 'edit' }\n end\n end\n end", "def increment_views_count\n increment(:views_count)\n save\n end", "def update\n respond_to do |format|\n if @view.update(view_params)\n format.html { redirect_to @view, notice: \"View was successfully updated.\" }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @view.errors, status: :unprocessable_entity }\n end\n end\n end", "def mtm_update(request, assoc, obj, add, remove)\n ref = model.association_reflection(assoc)\n assoc_class = associated_model_class(assoc)\n ret = nil\n model.db.transaction do\n [[add, ref.add_method], [remove, ref.remove_method]].each do |ids, meth|\n if ids\n ids.each do |id|\n next if id.to_s.empty?\n ret = assoc_class ? assoc_class.with_pk(:association, request, id) : obj.send(:_apply_association_options, ref, ref.associated_class.dataset.clone).with_pk!(id)\n begin\n model.db.transaction(:savepoint=>true){obj.send(meth, ret)}\n rescue S::UniqueConstraintViolation\n # Already added, safe to ignore\n rescue S::ConstraintViolation\n # Old versions of sqlite3 and jdbc-sqlite3 can raise generic\n # ConstraintViolation instead of UniqueConstraintViolation\n # :nocov:\n raise unless model.db.database_type == :sqlite\n # :nocov:\n end\n end\n end\n end\n end\n ret\n end", "def set_viewing\n @viewing = Viewing.find(params[:id])\n end", "def update\n @routine_interview = RoutineInterview.find(params[:id])\n @interview = Interview.find(@routine_interview.interview_id)\n\n respond_to do |format|\n if @routine_interview.update_attributes(params[:routine_interview]) && @interview.update_attributes(params[:interview])\n format.html { redirect_to @routine_interview, notice: 'Followup interview was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @routine_interview.errors, status: :unprocessable_entity }\n end\n end\n end", "def materialize_view(name, sql)\n unless @enduser\n raise Empire::MissingEnduserError.new\n end\n path = \"view/#{name}\"\n data = {'query' => sql}\n request path, :put, {}, data\n end", "def update_hash_for(viewmodel_class, model)\n refhash = { '_type' => viewmodel_class.view_name, 'id' => model.id }\n yield(refhash) if block_given?\n refhash\n end", "def increment\n self.transaction do\n self.views += 1\n self.save\n end\n end", "def create_view(id,doc)\n resp = get_design_doc(id)\n ddoc = set_views(resp,doc)\n\n create_design_doc(id,ddoc)\n end", "def set_interview\n @interview = Interview.find(params[:id])\n end", "def show\n if params[:from_id]\n cv = CustomerVisit.find_or_create_by(from_id:params[:from_id],to_id:params[:to_id])\n cv.update(view_count:cv.view_count.to_i + 1) \n end \n end", "def set_interview\n @interview = Interview.find(params[:id])\n end", "def refresh_view(view)\n notify_observers :refreshing_view, view.controller, self, view\n view.configure\n view.proxy.refresh\n @configured = true\n end", "def show\n @photo = Photo.find(params[:id])\n abc = @photo.views += 1\n @photo.update_attribute \"views\", abc\n end", "def update\n respond_to do |format|\n if @yourview.update(yourview_params)\n format.html { redirect_to @yourview, notice: 'Your view was successfully updated.' }\n format.json { render :show, status: :ok, location: @yourview }\n else\n format.html { render :edit }\n format.json { render json: @yourview.errors, status: :unprocessable_entity }\n end\n end\n end", "def refresh\r\n @view.refresh\r\n end", "def update\n @interview_decision.update(interview_decision_params)\n @interview_decisions = InterviewDecision.all\n @interview_decision = InterviewDecision.new\n end", "def set_interview\n @interview = Interview.find_by_id(params[:id])\n end", "def update\n @viewing = Viewing.find(params[:id])\n\n respond_to do |format|\n if @viewing.update_attributes(params[:viewing])\n flash[:notice] = 'Viewing was successfully updated.'\n format.html { redirect_to(@viewing) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @viewing.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @pageview = Pageview.find(params[:id])\n\n respond_to do |format|\n if @pageview.update_attributes(params[:pageview])\n flash[:notice] = 'Pageview was successfully updated.'\n format.html { redirect_to(@pageview) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @pageview.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @response_view = args[:response_view] if args.key?(:response_view)\n @task = args[:task] if args.key?(:task)\n end", "def set_interview\n @interview = Interview.find(params[:id])\n end", "def set_interview\n @interview = Interview.find(params[:id])\n end", "def set_interview\n @interview = Interview.find(params[:id])\n end", "def set_interview\n @interview = Interview.find(params[:id])\n end", "def set_interview\n @interview = Interview.find(params[:id])\n end", "def update!(**args)\n @object_id_prop = args[:object_id_prop] if args.key?(:object_id_prop)\n @relation = args[:relation] if args.key?(:relation)\n @subject_id = args[:subject_id] if args.key?(:subject_id)\n end", "def show\n @entry = Entry.find(params[:id])\n\t@entry.viewed += 1\n\t@entry.update_attributes(params[:id])\n\t\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @entry }\n\t format.rss { render :rss => @entry }\n end\n end", "def set_object\n @votesable = model_klass.find(params[:id])\n end", "def view=(item)\n frm.select(:id=>\"view\").select(item)\n end", "def refresh\n update_attributes_from_id(@id)\n end", "def set_view_count\n pa = params[:view_count]\n @view_count = params[:id].to_i.zero? ? ViewCount.where(user_id: pa[:user_id], post_id: pa[:post_id]).take : ViewCount.find(params[:id])\n end", "def set_view_statistic\n @view_statistic = ViewStatistic.find(params[:id])\n end", "def view( model, view, assigns = {} )\n self << Waves.main::Views[ model ].process( request ) do\n send( view, assigns )\n end\n end", "def set_object\n @object = Object.find(params[:id])\nend", "def reload! view: nil\n ensure_service!\n @view = view || @view\n @grpc = service.get_schema name, @view\n @reference = nil\n @exists = nil\n self\n end", "def set_viewing\n @viewing = Viewing.find(params[:id])\n end", "def update!(**args)\n @canonical_id = args[:canonical_id] if args.key?(:canonical_id)\n @deep_link_data = args[:deep_link_data] if args.key?(:deep_link_data)\n @id = args[:id] if args.key?(:id)\n @provenance = args[:provenance] if args.key?(:provenance)\n @render_id = args[:render_id] if args.key?(:render_id)\n @signature = args[:signature] if args.key?(:signature)\n @transient_data = args[:transient_data] if args.key?(:transient_data)\n @type = args[:type] if args.key?(:type)\n end", "def update!(**args)\n @canonical_id = args[:canonical_id] if args.key?(:canonical_id)\n @deep_link_data = args[:deep_link_data] if args.key?(:deep_link_data)\n @id = args[:id] if args.key?(:id)\n @provenance = args[:provenance] if args.key?(:provenance)\n @render_id = args[:render_id] if args.key?(:render_id)\n @signature = args[:signature] if args.key?(:signature)\n @transient_data = args[:transient_data] if args.key?(:transient_data)\n @type = args[:type] if args.key?(:type)\n end", "def show\n @PUBLIC_AGENCY = find_agency_by_id( params[ :id ] )\n increment_views_amount( @PUBLIC_AGENCY )\n end", "def anonymize_work_view_event( view_event )\n\n # find an anomomyzed version\n event = find_existing_view_event( view_event.date, view_event.work_id, nil )\n if event.nil? == false\n event.work_views += view_event.work_views\n else\n event = create_new_view_event( view_event.work_id, nil )\n event.date = view_event.date\n end\n save_safely( event )\n\n view_event.destroy\n end", "def set_interview\n @interview = Interview.find(params[:id])\n end", "def update\n @lens = Lens.find(params[:id])\n attrb = select_params(lens_params)\n # linear_data is an array of Objects of Components Properties\n # that needs to be deserialized correctly\n attrb[\"linear_data\"] = JSON.parse(attrb[\"linear_data\"])\n lens = Lens.update(attrb)\n \n # @lens.update(lens_params)\n # render inline: \"<%= @lens.id %>\"\n end", "def update!(**args)\n @annotated_relationship = args[:annotated_relationship] if args.key?(:annotated_relationship)\n @annotations = args[:annotations] if args.key?(:annotations)\n @collections = args[:collections] if args.key?(:collections)\n @entity_join = args[:entity_join] if args.key?(:entity_join)\n @id = args[:id] if args.key?(:id)\n @mrf = args[:mrf] if args.key?(:mrf)\n end", "def show\n super\n\n @post.update_attributes(view_count: @post.view_count+1)\n end", "def update!(**args)\n @kind = args[:kind] if args.key?(:kind)\n @share_id = args[:share_id] if args.key?(:share_id)\n @view_id = args[:view_id] if args.key?(:view_id)\n end", "def write_association(serialize_context: new_serialize_context, deserialize_context: new_deserialize_context, lock_owner: nil)\n require_external_referenced_association!\n\n association_view = nil\n pre_rendered = owner_viewmodel.transaction do\n update_hash, refs = parse_viewmodel_updates\n\n update_hash =\n ViewModel::ActiveRecord.add_reference_indirection(\n update_hash,\n association_data: association_data,\n references: refs,\n key: 'write-association',\n )\n\n owner_view = owner_viewmodel.find(owner_viewmodel_id, eager_include: false, lock: lock_owner)\n\n association_view = owner_view.replace_associated(association_name, update_hash,\n references: refs,\n deserialize_context: deserialize_context)\n\n ViewModel::Callbacks.wrap_serialize(owner_view, context: serialize_context) do\n child_context = owner_view.context_for_child(association_name, context: serialize_context)\n ViewModel.preload_for_serialization(association_view)\n association_view = yield(association_view) if block_given?\n prerender_viewmodel(association_view, serialize_context: child_context)\n end\n end\n render_json_string(pre_rendered)\n association_view\n end", "def update\n @interview = Interview.find(params[:id])\n\n respond_to do |format|\n if @interview.update_attributes(params[:interview])\n @interview.activify\n format.html { redirect_to '/teacher_applications', notice: 'Interview details have been updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @interview.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @view_count.update(view_count_params)\n format.html {redirect_to @view_count, notice: 'View count was successfully updated.'}\n format.json {render json: @view_count, status: :ok}\n else\n format.html {render :edit}\n format.json {render json: @view_count.errors, status: :unprocessable_entity}\n end\n end\n end", "def update\n @followup_interview = FollowupInterview.find(params[:id])\n @interview = Interview.find(@followup_interview.interview_id)\n\n respond_to do |format|\n if @followup_interview.update_attributes(params[:followup_interview]) && @interview.update_attributes(params[:interview])\n format.html { redirect_to @followup_interview, notice: 'Followup interview was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @followup_interview.errors, status: :unprocessable_entity }\n end\n end\n end", "def view(name = \"\", viewpoint: :total, elements: :all, relationships: :for_elements)\n dia = __model.diagrams.find { |diagram| diagram.name == name }\n __model.remove_reference(dia) if dia\n __model.diagrams << View.new(__model, name, dia&.id, viewpoint, elements, relationships).render\n end", "def update!(**args)\n @default_viewport = args[:default_viewport] if args.key?(:default_viewport)\n @id = args[:id] if args.key?(:id)\n @key = args[:key] if args.key?(:key)\n @name = args[:name] if args.key?(:name)\n @type = args[:type] if args.key?(:type)\n @visibility = args[:visibility] if args.key?(:visibility)\n end", "def update\n @current_view.update\n if @alert_view != nil\n @alert_view.update\n end\n end", "def view(question_id, items)\n return if items.empty? || !RankAlgorithm.exists?(DEFAULT_RANK_ALGO)\n stat = for_items(question_id, items)\n if stat\n views = stat.views + 1\n stat.update_attributes({ :views => views, :score => score(stat.rank_algorithm.data.to_i, stat.votes, views) })\n else\n stat = create(default(question_id))\n stat.items << items\n end\n stat\n end", "def set_view(view)\n add_actions \"SetView(#{view})\"\n end", "def update\n enforce_permissions!('manage_collection', params[:id])\n\n @object = retrieve_object!(params[:id])\n\n # If a cover image was uploaded, remove it from the params hash\n cover_image = params[:batch].delete(:cover_image)\n\n @institutes = Institute.all\n @inst = Institute.new\n\n supported_licences\n\n doi.update_metadata(params[:batch].select { |key, _value| doi.metadata_fields.include?(key) }) if doi\n\n @object.object_version ||= '1'\n @object.increment_version\n\n updated = @object.update_attributes(update_params)\n\n if updated\n if cover_image.present?\n flash[:error] = t('dri.flash.error.cover_image_not_saved') unless Storage::CoverImages.validate_and_store(cover_image, @object)\n end\n\n # Do the preservation actions\n preservation = Preservation::Preservator.new(@object)\n preservation.preserve(false, false, ['descMetadata','properties'])\n\n else\n flash[:alert] = t('dri.flash.alert.invalid_object', error: @object.errors.full_messages.inspect)\n end\n\n # purge params from update action\n purge_params\n\n respond_to do |format|\n if updated\n version_and_record_committer(@object, current_user)\n update_doi(@object, doi, \"metadata update\") if doi && doi.changed?\n\n flash[:notice] = t('dri.flash.notice.updated', item: params[:id])\n format.html { redirect_to controller: 'my_collections', action: 'show', id: @object.id }\n else\n format.html { render action: 'edit' }\n end\n end\n end", "def show\n find_agencies(params[:id])\n increment_views_amount(@public_agency)\n end" ]
[ "0.5944343", "0.58926123", "0.58195937", "0.57695425", "0.5719503", "0.5638591", "0.5634786", "0.5610564", "0.55988353", "0.5581667", "0.5581667", "0.5581667", "0.55463135", "0.5542066", "0.55208164", "0.55062175", "0.54996866", "0.54605067", "0.54462576", "0.54462576", "0.5377464", "0.53677016", "0.5354133", "0.53526026", "0.5348288", "0.5338962", "0.5324758", "0.5323155", "0.53110224", "0.52731794", "0.52566993", "0.52349895", "0.52312505", "0.52086866", "0.5200737", "0.5198245", "0.519705", "0.5182306", "0.5176898", "0.51733834", "0.516579", "0.5156748", "0.51564026", "0.515524", "0.51547307", "0.51422477", "0.5135591", "0.5132682", "0.51146656", "0.5111323", "0.51084834", "0.5101187", "0.50845176", "0.5065596", "0.5061677", "0.50587755", "0.5055154", "0.5054301", "0.5033773", "0.5025959", "0.5020617", "0.50200945", "0.50024796", "0.49905214", "0.49904907", "0.49904907", "0.49904907", "0.49904907", "0.49903172", "0.49890828", "0.4986062", "0.4981624", "0.49727663", "0.4971729", "0.496816", "0.49577487", "0.49558207", "0.49462533", "0.49360928", "0.49239412", "0.49230683", "0.49230683", "0.49177414", "0.4913928", "0.4907761", "0.49074322", "0.49059725", "0.49051192", "0.49024856", "0.489339", "0.48832557", "0.48828438", "0.48784125", "0.48692808", "0.48637506", "0.4862804", "0.48516634", "0.4844381", "0.4843163", "0.48401213" ]
0.6959323
0
Includes this module into a Class, and changes all public methods to protected. Examples: module MyCoolUtils def some_meth "hi" end self.include_safely_into(FooController) end or: MyCoolUtils.include_safely_into(FooController, SomeOtherClass)
def include_safely_into(*args) [args].flatten.each do |a| if a.is_a?(String) || a.is_a?(Symbol) a = a.to_s.constantize end a.send(:include, self.convert_security_of_methods) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def inherited(klass)\n super\n klass.send :include, ::Henshin::Safety\n klass.instance_variable_set(:@unsafe_methods, @unsafe_methods)\n end", "def included(other)\n class <<other\n include ClassMethods\n end\nend", "def extend_class(class_, module_)\n class_.class_eval do\n include module_\n extend module_.const_get(:ClassMethods) if module_.const_defined?(:ClassMethods, false)\n prepend module_.const_get(:PrependMethods) if module_.const_defined?(:PrependMethods, false)\n end\n end", "def enable!\n @mutex.synchronize do\n return self if @enabled\n\n this = self\n mod_target.instance_eval do\n case this.scope\n when :public\n else\n public this.meth\n end\n\n alias_method this.old_meth, this.meth if\n ! method_defined? this.old_meth\n\n alias_method this.meth, this.new_meth\n\n case this.scope\n when :private\n private this.meth\n when :protected\n protected this.meth\n end\n end\n\n enabled!\n @enabled = true\n end\n self\n end", "def protected_methods(all=true) end", "def protect(protectee, protector)\n PublicMethodCache.set!(protector)\n\n # Extract the eigenclass (the class on which `def self.x; end` would be\n # defined) of any object\n # https://medium.com/@ethan.reid.roberts/rubys-anonymous-eigenclass-putting-the-ei-in-team-ebc1e8f8d668\n eigenclass = (class << protectee; self; end)\n\n # Rewrite eigenclass' future public instance methods\n Rewriter.add_instance_rewrite_hooks!(eigenclass, protector)\n # Rewrite eigenclass' future public singleton methods\n Rewriter.add_singleton_rewrite_hooks!(eigenclass, protector)\n end", "def hide!\n singleton_class.send(:define_method, :nodoc) { true }\n end", "def protected_instance_methods(include_super=true) end", "def mixes_in_class_methods(mod)\n Private::Mixins.declare_mixes_in_class_methods(self, mod)\n end", "def include_helpers_in_class(view_klass)\n view_klass.send(:include, self.class.master_helper_module)\n end", "def include_helpers_in_class(view_klass)\n view_klass.send(:include, self.class.master_helper_module)\n end", "def include_helpers_in_class(view_klass)\n view_klass.send(:include, self.class.master_helper_module)\n end", "def include_helpers_in_class(view_klass)\n view_klass.send(:include, self.class.master_helper_module)\n end", "def use_class_helpers!\n self.class.class_helpers.each { |helper| use helper }\n end", "def safe_methods\n SafeClass.safe_methods_for(self)\n end", "def include_into(klass)\n unless klass.kind_of? Module\n raise TypeError, \"invalid argument class #{klass.class}, expected Module\"\n end\n\n # check other.frozen\n # taint other from self\n\n insert_at = klass\n mod = self\n changed = false\n\n while mod\n\n # Check for a cyclic include\n if mod == klass\n raise ArgumentError, \"cyclic include detected\"\n end\n\n # Try and detect check_mod in klass's heirarchy, and where.\n #\n # I (emp) tried to use Module#< here, but we need to also know\n # where in the heirarchy the module is to change the insertion point.\n # Since Module#< doesn't report that, we're going to just search directly.\n #\n superclass_seen = false\n add = true\n\n k = klass.direct_superclass\n while k\n if k.kind_of? Rubinius::IncludedModule\n # Oh, we found it.\n if k == mod\n # ok, if we're still within the directly included modules\n # of klass, then put future things after mod, not at the\n # beginning.\n insert_at = k unless superclass_seen\n add = false\n break\n end\n else\n superclass_seen = true\n end\n\n k = k.direct_superclass\n end\n\n if add\n if mod.kind_of? Rubinius::IncludedModule\n original_mod = mod.module\n else\n original_mod = mod\n end\n\n im = Rubinius::IncludedModule.new(original_mod).attach_to insert_at\n insert_at = im\n\n changed = true\n end\n\n mod = mod.direct_superclass\n end\n\n if changed\n method_table.each do |meth, obj, vis|\n Rubinius::VM.reset_method_cache meth\n end\n end\n\n return self\n end", "def private_instance_methods(include_super=true) end", "def mark_parent_class_methods_publicize(class_name, method_name)\n klass = Prepares.klasses.find { |klass| klass.to_s == class_name }\n if klass&.extend_class_name\n mark_parent_class_methods_publicize(klass.extend_class_name, method_name)\n mark_publicize(class_name, method_name)\n end\n end", "def included(base)\n base.extend(ClassMethods)\n base.extend(ModuleMethods) unless base.is_a?(Class)\n end", "def included(klass); end", "def included(klass); end", "def mixin(source_module) # :doc:\n include source_module\n \n return unless source_module.respond_to? :mixins\n \n self.mixins = source_module.mixins.dup || []\n self.mixins << source_module\n \n self.mixins.each do |mixin|\n if mixin.const_defined? :ClassMethods\n extend mixin.const_get :ClassMethods\n end # if\n end # each\n end", "def make_public(obj)\n obj.private_methods.each do |method_name|\n obj.singleton_class.class_eval { public method_name }\n end\n obj\nend", "def include_required_submodules!\n class_eval do\n @sorcery_config.submodules = ::Sorcery::Controller::Config.submodules\n @sorcery_config.submodules.each do |mod|\n # TODO: Is there a cleaner way to handle missing submodules?\n # rubocop:disable Lint/HandleExceptions\n begin\n include Submodules.const_get(mod.to_s.split('_').map(&:capitalize).join)\n rescue NameError\n # don't stop on a missing submodule. Needed because some submodules are only defined\n # in the controller side.\n end\n # rubocop:enable Lint/HandleExceptions\n end\n end\n end", "def add_public_and_protected(doc)\n\n return if doc.nil?\n\n store_public_and_protected_class_members(doc)\n\n next_doc = load_parent(doc)\n add_public_and_protected(next_doc)\n\n end", "def my_protected\n puts \"Hello from protected\"\n end", "def include( *modules )\n \n super if defined?( super )\n original_include( *modules )\n \n end", "def include_into(klass)\n unless klass.kind_of? Module\n raise TypeError, \"invalid argument class #{klass.class}, expected Module\"\n end\n\n if kind_of? Class\n raise TypeError, \"invalid receiver class #{__class__}, expected Module\"\n end\n\n Rubinius::Type.include_modules_from(self, klass.origin)\n Rubinius::Type.infect(klass, self)\n\n self\n end", "def method_missing(wh,*therest)\n # xxx internal methods must be protected at some point\n end", "def not_sandboxed_methods(include_superclasses = false, allowed_mixins=[], *disallowed_methods)\n\n __the_methods_to_check = public_instance_methods(false)\n puts \"#{self.name}: direct: #{__the_methods_to_check.inspect}\" if $DEBUG\n if include_superclasses\n clz = self.superclass\n while !clz.nil?\n unless clz == Object || (defined? BasicObject && clz == BasicObject)\n puts \"#{self.name}: #{clz.name}: #{clz.public_instance_methods(false).inspect}\" if $DEBUG\n __the_methods_to_check += clz.public_instance_methods(false)\n end\n clz = clz.superclass\n end\n \n if allowed_mixins.length > 0\n #we include any mixins\n for m in self.included_modules\n if allowed_mixins.include?(m)\n puts \"#{self.name}: #{m.name}: #{m.public_instance_methods(false).inspect}\" if $DEBUG\n __the_methods_to_check += m.public_instance_methods(false)\n end\n end\n end\n end\n \n __the_methods_to_check << \"nil?\".intern\n \n __the_methods_to_check.uniq!\n \n unless disallowed_methods.nil? || disallowed_methods.length == 0\n not_bang = false\n if disallowed_methods.include?(:bang_methods) #just remove all xxx! methods that modify in place\n __the_methods_to_check.reject! { |meth| meth.to_s[-1, 1] == \"!\"}\n not_bang = true\n end\n unless not_bang || disallowed_methods.length > 1\n __the_methods_to_check.reject! { |meth| disallowed_methods.include?(meth)}\n end\n end\n \n puts \"#{self.name}: #{__the_methods_to_check.inspect}\" if $DEBUG\n \n sandboxed_methods(*__the_methods_to_check)\n \n \n \n end", "def protected_methods(all=true)\n __getobj__.protected_methods(all) | super\n end", "def extend(mod)\n super\n class << self\n include(RobotDisabler.dup) unless defined?(mod::SELF) && mod::SELF == RobotDisabler\n end\n end", "def included_modules() end", "def generate_inclusion_method(mod, method_name)\n mc = mod.instance_eval{class << self ; self ; end}\n \n # if there is already such a method, alias it\n if mod.respond_to?(method_name)\n aliased_method_name = \"class_dependencies_#{method_name}\"\n raise \"can't include ClassDependencies twice\" if mod.respond_to?(aliased_method_name)\n mc.send(:alias_method, aliased_method_name, method_name) \n end\n\n mc.send(:define_method, method_name) do |mod2|\n# raise \"include #{mod.to_s} on a Class... doesn't work with intermediate modules\" if ! mod2.is_a? Class\n mod.descendants << class_to_sym(mod2)\n mod2.instance_eval do\n mc2 = class << self ; include ClassDependencies::ClassName ; self ; end\n dep_method_name = mod.relationship_name || class_to_sym(mod)\n mc2.send(:define_method, dep_method_name){|*params| mod.add_dependency(mod2, *params)}\n end\n\n # call any aliased method. if only Ruby had :after advice etc\n mod.send(aliased_method_name, mod2) if aliased_method_name\n end\n end", "def include_modules\n @mods = Devium::PageBuilder.new(page, details).parse_page_modules\n mods.map do |mod|\n extend Object.const_get(\"#{self.class}::#{mod}\")\n end\n end", "def make_public!\n reinitialize_rules!\n allow_if do\n true\n end\n return self\n end", "def a_protected_method\n \"Yes, I'm protected!\"\n end", "def a_protected_method\n \"Yes, I'm protected!\"\n end", "def unmodulize(*method_syms)\n method_syms.each do |method_sym|\n methname = method_sym.to_s\n orig_methname_sym = \"#{methname}_before_modulize\".to_sym\n if instance_methods(false).include?(orig_methname_sym) # if it was modulized\n class_eval <<-EOM\n alias_method method_sym, orig_methname_sym\n remove_method orig_methname_sym\n EOM\n end\n end\n end", "def acts_as_msfte\n extend ClassMethods\n end", "def install_helpers # :nodoc:\n mod = @module\n ActionView::Base.class_eval do\n include mod\n end\n end", "def hide_methods(mod, except_defaults, *stuff)\n options = stuff.last.is_a?(Hash) ? stuff.pop : {}\n include_ancestors = options.fetch(:ancestors){false}\n except = Array(options.fetch(:except){except_defaults})\n protect = Array(options[:protect])\n except_methods = collect_methods(true, *except)\n protect_methods = collect_methods(true, *protect)\n methods_to_hide = collect_methods(include_ancestors, *stuff)\n (methods_to_hide - except_methods).each do |method_name|\n mod.module_eval do\n next unless method_defined?(method_name)\n if protect_methods.include?(method_name)\n protected method_name\n else\n private method_name\n end\n end\n end\n end", "def protected_method\n end", "def protected_instance_methods(arg0, arg1, *rest)\n end", "def freeze #:nodoc:\n self.class.private_instance_methods(false).each do |m|\n if m.to_s =~ /\\A__\\d+__\\Z/\n instance_variable_set(:\"@#{m}\", [send(m)])\n end\n end\n\n super\n end", "def included(base)\n super(base)\n base.extend(ClassMethods)\n base.extend(ClassScope)\n end", "def wrap_module(mod)\n Module.new do\n include Strainer::Logable\n\n mod.instance_methods.each do |method|\n next unless method.to_s.ends_with?('_path')\n\n define_method(method) do |*arguments, &block|\n if instance_variable_defined?(:@_controller) && @_controller.is_a?(ActionMailer::Base)\n strainer_log('PATH_HELPER_IN_MAILER', custom: { helper_method: __method__ })\n end\n super(*arguments, &block)\n end\n end\n end\n end", "def guard_method(method)\n StoneWall::Helpers.guard(@guarded_class, method)\n StoneWall::Helpers.fix_alias_for(@guarded_class, method)\n end", "def modulize_include(*mod_consts)\n mod_consts.each do |mod_const|\n modulize *(mod_const.instance_methods)\n include mod_const\n end\n end", "def included(host)\n host.instance_exec(@block) do |block|\n define_singleton_method(:call, &block)\n end\n\n host.extend(ClassMethods)\n end", "def included(mod); end", "def include_session_auth_concern\n log :include_session_auth_concern, \"\"\n content = <<-EOF\n protect_from_forgery with: :exception, unless: -> { request.format.json? }\n include SessionAuthentication\n EOF\n\n replace_in_file 'app/controllers/application_controller.rb',\n 'protect_from_forgery with: :exception', content\n\n # insert_into_file(\"app/controllers/application_controller.rb\",\n # content,\n # after: \"protect_from_forgery with: :exception\\n\\n\")\n end", "def internal_methods\n controller = self\n\n controller = controller.superclass until controller.abstract?\n controller.public_instance_methods(true)\n end", "def internal_methods(controller)\n controller = controller.superclass until controller.abstract?\n controller.public_instance_methods(true)\n end", "def include_helpers(scope); end", "def include(mod)\n mod.append_features(self)\n Rubinius.privately do\n mod.included self\n end\n self\n end", "def test_only_adds_methods_to_host_that_are_part_of_public_api\n host_class = Class.new { include ::NewRelic::Agent::MethodTracer }\n plain_class = Class.new\n\n host_instance_methods = host_class.new.methods\n plain_instance_methods = plain_class.new.methods\n\n added_methods = host_instance_methods - plain_instance_methods\n\n public_api_methods = %w[\n trace_execution_unscoped\n trace_execution_scoped\n ]\n\n assert_equal(public_api_methods.sort, added_methods.map(&:to_s).sort)\n end", "def include(*modules)\n modules.reverse_each do |mod|\n if !mod.kind_of?(Module) or mod.kind_of?(Class)\n raise TypeError, \"wrong argument type #{mod.class} (expected Module)\"\n end\n\n Rubinius.privately do\n mod.append_features self\n end\n\n Rubinius.privately do\n mod.included self\n end\n end\n self\n end", "def include(*modules)\n modules.reverse_each do |mod|\n if !mod.kind_of?(Module) or mod.kind_of?(Class)\n raise TypeError, \"wrong argument type #{mod.class} (expected Module)\"\n end\n\n Rubinius.privately do\n mod.append_features self\n end\n\n Rubinius.privately do\n mod.included self\n end\n end\n self\n end", "def disable!\n @mutex.synchronize do\n return self if ! @enabled\n\n this = self\n mod_target.instance_eval do\n if method_defined? this.old_meth\n alias_method this.meth, this.old_meth\n\n case this.scope\n when :private\n private this.meth\n when :protected\n protected this.meth\n end\n end\n end\n\n disabled!\n @enabled = false\n end\n\n self\n end", "def protected_method\n\tend", "def add_methods_to_included_class!(dynamic_methods_module, association_name, target_class, options)\n return if (! flex_column_class.delegation_type)\n\n prefix = if options.has_key?(:prefix) then options[:prefix] else flex_column_class.delegation_prefix end\n is_private = private? || (flex_column_class.delegation_type == :private) || (options[:visibility] == :private)\n\n if is_private && options[:visibility] == :public\n raise ArgumentError, %{You asked for public visibility for methods included from association #{association_name.inspect},\n but the flex column #{flex_column_class.model_class.name}.#{flex_column_class.column_name} has its methods\n defined with private visibility (either in the flex column itself, or at the model level).\n\n You can't have methods be 'more public' in the included class than they are in the class\n they're being included from.}\n end\n\n mn = field_name\n mn = \"#{prefix}_#{mn}\".to_sym if prefix\n\n fcc = flex_column_class\n fn = field_name\n\n if target_class._flex_columns_safe_to_define_method?(mn)\n dynamic_methods_module.define_method(mn) do\n associated_object = send(association_name) || send(\"build_#{association_name}\")\n flex_column_object = associated_object.send(fcc.column_name)\n flex_column_object.send(fn)\n end\n\n dynamic_methods_module.define_method(\"#{mn}=\") do |x|\n associated_object = send(association_name) || send(\"build_#{association_name}\")\n flex_column_object = associated_object.send(fcc.column_name)\n flex_column_object.send(\"#{fn}=\", x)\n end\n\n if is_private\n dynamic_methods_module.private(mn)\n dynamic_methods_module.private(\"#{mn}=\")\n end\n end\n end", "def import(*classes)\n setup_delegator_strategy!\n use_for(classes, self)\n # the problem here is that use_for sets the wrong target - the class instance, and not the instance itself.\n # this will lead to problems when a helper needs :method. :method will be called on the class, not on \n # the instance, which is wrong.\n end", "def rebuild_class options = {}\n ActiveRecord::Base.send(:include, Strongbox)\n Object.send(:remove_const, \"Dummy\") rescue nil\n Object.const_set(\"Dummy\", Class.new(ActiveRecord::Base))\n Dummy.class_eval do\n include Strongbox\n encrypt_with_public_key :secret, options\n end\n Dummy.reset_column_information\nend", "def freeze\n context and inclusions and super\n end", "def dispatch\n raise(NotImplemetedError, \"subclass responsability\")\n end", "def internal_methods; end", "def mark_publicize(class_name, method_name)\n method = get_method(class_name, method_name)\n method&.publicize\n end", "def protected(name)\n if entry = @method_table.lookup(name)\n entry.visibility = :protected\n end\n end", "def with_actions(mod, exclude: [])\n\t\t\t\tModule.new do\n\t\t\t\t\t@mod = mod\n\t\t\t\t\t@exclude = exclude\n\n\t\t\t\t\tdef self.included(ctrl)\n\t\t\t\t\t\tctrl.include @mod\n\n\t\t\t\t\t\t(@mod.public_instance_methods - @exclude).each do |meth|\n\t\t\t\t\t\t\tctrl.send :define_method, meth, @mod.public_instance_method(meth)\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend", "def add_discerner_user_method\n current_user_helper = options[\"current-user-helper\"].presence ||\n ask(\"What is the current_user helper called in your app? [current_user]\").presence ||\n 'current_user if defined?(current_user)'\n puts \"Defining discerner_user method inside ApplicationController...\"\n\n discerner_user_method = %Q{\n def discerner_user\n #{current_user_helper}\n end\n helper_method :discerner_user\n}\n inject_into_file(\"#{Rails.root}/app/controllers/application_controller.rb\",\n discerner_user_method,\n after: \"ActionController::Base\\n\", force: false)\n end", "def expose!\n expose_attribute!\n expose_helper_methods!\n end", "def authenticates_access\n include InstanceMethods\n end", "def private_class_method(*rest) end", "def cleanroom\n exposed = exposed_methods.keys\n parent = self.name || 'Anonymous'\n\n Class.new(Object) do\n class << self\n def class_eval\n raise Cleanroom::InaccessibleError.new(:class_eval, self)\n end\n\n def instance_eval\n raise Cleanroom::InaccessibleError.new(:instance_eval, self)\n end\n end\n\n define_method(:initialize) do |instance|\n define_singleton_method(:__instance__) do\n unless caller[0].include?(__FILE__)\n raise Cleanroom::InaccessibleError.new(:__instance__, self)\n end\n\n instance\n end\n end\n\n exposed.each do |exposed_method|\n define_method(exposed_method) do |*args, &block|\n __instance__.public_send(exposed_method, *args, &block)\n end\n end\n\n define_method(:class_eval) do\n raise Cleanroom::InaccessibleError.new(:class_eval, self)\n end\n\n define_method(:inspect) do\n \"#<#{parent} (Cleanroom)>\"\n end\n alias_method :to_s, :inspect\n end\n end", "def overridable_methods_module\n include(@overridable_methods_module = Module.new) unless @overridable_methods_module\n @overridable_methods_module\n end", "def overridable_methods_module\n include(@overridable_methods_module = Module.new) unless @overridable_methods_module\n @overridable_methods_module\n end", "def add_to_classes_or_modules mod\n @classes_or_modules << mod\n end", "def controller\n inject_into_class 'app/controllers/application_controller.rb', ApplicationController do\n \" include SeoLandingPages::Controllers::Helpers\\n\\n\"\n end\n end", "def transform_attrs_methods\n @transform_attrs_methods ||= Module.new.tap { |x| prepend x }\n end", "def protected_method\n end", "def private_methods(all=true) end", "def sniff\n return [] if context.singleton_method? || context.module_function?\n return [] if context.references_self?\n return [] if num_helper_methods.zero?\n return [] if ignore_method?\n\n [smell_warning(\n lines: [source_line],\n message: \"doesn't depend on instance state (maybe move it to another class?)\")]\n end", "def helpers\n @helpers ||= begin\n request = ActionDispatch::Request.new @env\n request.routes = controller._routes\n\n instance = controller.new\n instance.set_request!(request)\n instance.set_response!(controller.make_response!(request))\n instance.helpers\n end\n end", "def protected(*syms) end", "def module_move_up(mod) end", "def include(mod)\n mod.included(self)\n end", "def included(a_module)\n end", "def exclude_common_methods!\r\n ExcludeCommonMethods.apply!(self)\r\n end", "def test_private_method\n make_controller :private_method\n get :index\n assert_protected\n get :secret_ferret_brigade\n assert_protected\n end", "def include(*args)\n include_private(*args)\n end", "def public_instance_methods(include_super=true) end", "def included(othermod) end", "def included(base)\n base.extend ::Forwardable\n base.def_delegators self, *singleton_methods\n end", "def module_include(base, mod)\n old_methods = {}\n\n mod.instance_methods.each do |sym|\n old_methods[sym] = base.instance_method(sym) if base.method_defined?(sym)\n end\n\n unless UNBOUND_METHODS_BIND_TO_ANY_OBJECT\n base.send(:include, mod) unless base < mod\n end\n\n mod.instance_methods.each do |sym|\n method = mod.instance_method(sym)\n base.send(:define_method, sym, method)\n end\n\n yield\n ensure\n mod.instance_methods.each do |sym|\n base.send(:undef_method, sym) if base.method_defined?(sym)\n end\n old_methods.each do |sym, method|\n base.send(:define_method, sym, method)\n end\n end", "def hide_singletons(*stuff)\n hide_methods(singleton_class, [Class], *stuff)\n end", "def add_doc_helper_methods_to(a_module)\n a_module.instance_eval do\n\n # Implement access to the model id\n define_method :id do\n return @id unless @d.nil?\n # retrieve the class and id from data\n klass_name, id = data.split(\"-\")\n @id = id.to_i\n end\n\n # Implement access to the indexed object\n define_method :indexed_object do\n return @indexed_object unless @indexed_object.nil?\n # retrieve the class and id from data\n klass_name, id = data.split(\"-\")\n klass = Kernel.const_get(klass_name)\n @indexed_object = klass.find(id.to_i)\n end\n\n end\n\n end", "def included_modules; end", "def attach_outer_class_methods!(inherited = false)\n outer_module = Object.const_get(outer_module_name(name))\n outer_module.methods(inherited).each do |m|\n attach_function m\n end\n end", "def disable_unsafe_method(target, *names, &block)\n block ||= ->(*) {}\n names.each { |name| target.define_singleton_method name, &block }\n end" ]
[ "0.5964037", "0.5789869", "0.5714196", "0.55760556", "0.54506856", "0.5437987", "0.5415791", "0.5403711", "0.53042275", "0.5301927", "0.5301927", "0.5301927", "0.5301927", "0.5301461", "0.5268169", "0.5256856", "0.5197367", "0.51913303", "0.5171968", "0.5105985", "0.5105985", "0.5043182", "0.50426054", "0.5040805", "0.50174683", "0.49732804", "0.49229184", "0.49203128", "0.49137044", "0.49109632", "0.4898105", "0.48878044", "0.48788708", "0.48660943", "0.48578772", "0.4854388", "0.48342028", "0.48342028", "0.48287854", "0.4817188", "0.48139483", "0.48050132", "0.4784942", "0.47837204", "0.47773197", "0.47717053", "0.47714922", "0.47632363", "0.4761647", "0.4760016", "0.47523117", "0.4741983", "0.47415966", "0.4739681", "0.4737305", "0.4712875", "0.47054687", "0.47025046", "0.47025046", "0.47016132", "0.46987644", "0.46969453", "0.46945962", "0.4688229", "0.46839538", "0.46811697", "0.4677163", "0.46764445", "0.46736684", "0.46726575", "0.4670105", "0.46434498", "0.46428874", "0.46404505", "0.46389073", "0.46340078", "0.46340078", "0.4628835", "0.46244743", "0.46242124", "0.4623825", "0.46230668", "0.4622778", "0.46214095", "0.46212134", "0.46172288", "0.46146357", "0.45982122", "0.45969227", "0.45932508", "0.4577435", "0.4562891", "0.4558421", "0.4554957", "0.45540124", "0.45364475", "0.45301318", "0.45288244", "0.45167896", "0.45130867" ]
0.5939363
1
Override with your own usage banner.
def banner "Usage: #{$0} my_controller controller" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def usage; end", "def usage; end", "def banner\n \"#{basename} #{self_command.formatted_usage(self, false)}\"\n end", "def display_usage\n end", "def print_usage; end", "def banner\n unless @banner\n @banner = +\"Usage: #{program_name} [options]\"\n visit(:add_banner, @banner)\n end\n @banner\n end", "def banner\n\t\t\t@banner || \"Usage: #{program_prefix} [arguments]\"\n\t\tend", "def usage\n puts @usage_text\n end", "def banner\n \"Usage: #{$0} #{spec.name} <action>\"\n end", "def usage()\n\tputs \"Usage:\"\n\tputs \"\t\" + $0 + \" banner.bnr outfolder\"\nend", "def banner(command, namespace = nil, subcommand = false)\n \"#{basename} #{command.formatted_usage(self, $thor_runner, subcommand)}\"\n end", "def help; summarize(\"#{banner}\".sub(/\\n?\\z/, \"\\n\")) end", "def banner(arg=nil)\n @banner = arg if arg\n @banner || description\n end", "def desc(usage = nil, description = nil, options = {})\n if usage\n super\n else\n class_usage\n end\n end", "def banner\n \"Usage: #{$0} #{spec.name} #{spec.name.camelize}Name [options]\"\n end", "def usage(args_and_such=nil)\n _banner = \"usage: #{File.basename($0)}\"\n (_banner << ' ' << args_and_such) if args_and_such\n @option_parser.banner = _banner\n end", "def banner\r\n \"Usage: #{$0} generator [options] [args]\"\r\n end", "def banner(arg=nil)\n arg.nil? ? @option_parser.banner : (@option_parser.banner = arg)\n end", "def banner\n \"Usage: #{$0} minimal_cart\"\n end", "def usage(description = nil)\n return @usage unless description\n @usage = description\n end", "def banner\n checkConnection()\n @banner\n end", "def banner\n checkConnection()\n @banner\n end", "def banner\n out = <<-EOD;\n Usage: #{$0} authenticated ModelName [ControllerName] \n EOD\n end", "def banner\n <<-EOS\nUsage #{$0} GeneratorName [license=#{LICENSES.join('|')}] [migration=true] [dir=/dir/to/install] [named=true]\n\nOptional arguments:\n\n named : When =true, generates a NamedBase generator.\n\n license : The license to install in the generator.\n\n migration : When =true (or when the generator name ends in\n 'migration') adds extra code to the generator.\n\n dir : Directory to install into. vendor/generator/generator_name\n is the default.\n\nEOS\n end", "def usage\n self.class.const_get(:USAGE)\n end", "def print_usage\n puts @@usage\n end", "def info\n fill_usage_info\n end", "def show_usage(*args)\n args_def.show_usage(*args)\n end", "def usage_start\n \"\\\\usage{\"\n end", "def help(shell, *) # :nodoc:\n super\n shell.say class_usage if class_usage\n end", "def usage(text)\n help('Usage', text)\n end", "def banner\n I18n.t 'command.impressbox.usage', cmd: 'vagrant impressbox'\n end", "def about_us; end", "def banner\n say %(\n\n ******************************************************************\n\n Your extension has been generated with a gemspec dependency on\n Archangel ~> v#{archangel_version}\n\n I have a feeling you're about to build something amazing.\n\n ******************************************************************\n\n )\n end", "def usage(err = true)\n\t\tdst = err ? $stderr : $stdout\n\t\tdst.print(@banner)\n\t\tself.class::COMMANDS.each do |cmd|\n\t\t\tif (self.respond_to?(cmd))\n\t\t\t\tputs(\"\\n\")\n\t\t\t\tif (self.respond_to?(\"help_\" + cmd))\n\t\t\t\t\tprint(self.send(\"help_\" + cmd))\n\t\t\t\telse\n\t\t\t\t\tprint(\"*** Command '#{cmd}' supported but no help available!\\n\")\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend", "def banner\n lines = []\n \n name_line = \"#{ name } role\"\n lines << name_line\n lines << \"=\" * name_line.length\n lines << ''\n if meta['description']\n lines << meta['description']\n lines << ''\n end\n lines << 'Usage:'\n lines << ''\n lines << \" #{ usage }\"\n lines << ''\n lines << ''\n \n lines.join(\"\\n\")\n end", "def about_us\n # it's deliberate that there's no code in here... but we should have a helpful error when we request the URL again\n end", "def output_usage\n print \"== Usage \n karmabyns number_of_dice value_sought\"\n end", "def usage\n puts <<End\n\nWarning: This currently attempts to run blkid, fdisk -l, and hdparm -i with sudo, which may prompt for a password.\nThis command may not pass on the password prompt to you but will just sit there.\nIt is recommended that you add those commands to your sudoers file with NOPASSWD so that it won't prompt for a password.\n\nusername ALL = NOPASSWD: \\\n ...\n /usr/bin/du, \\\n /bin/df, \\\n /usr/sbin/smartctl, \\\n /usr/sbin/hddtemp, \\\n /sbin/vol_id, \\\n /sbin/hdparm, \\\n /sbin/blkid, \\\n /sbin/fdisk -l, \\\n\nOptions:\n -d, --device -- groups by device, and shows model name/serial number/disk capacity of each physical device (this is now the default)\n\n --no-color -- disable color\nEnd\n exit 1\nend", "def usage #:nodoc:\n usage = name.to_s\n usage += ' [command options]' if !flags.empty? || !switches.empty?\n usage += ' ' + @arguments_description if @arguments_description\n usage\n end", "def docopt_usage \n doc = [\"\\nUsage:\"];\n @actions.each do |_name, action|\n doc << \" run #{action.usage}\" unless action.usage == false\n end\n basic_flags = @version ? \"(-h|--help|--version)\" : \"(-h|--help)\"\n if @superspace\n doc << \" run #{@superspace} #{basic_flags}\\n\"\n else\n doc << \" run #{basic_flags}\\n\"\n end\n doc\n end", "def banner\n self.class.instance_variable_get(:@__banner)\n end", "def usage\n return @usage\n end", "def banner\n \"Usage #{$0} compass_sass somethingelse whoknowswhat\"\n end", "def usage( extra_usage = '' )\n extra_usage += ' '\n\n print_line <<USAGE\n Usage: #{File.basename( $0 )} #{extra_usage}\\[options\\] url\n\n Supported options:\n\n\n General ----------------------\n\n -h\n --help Output this.\n\n --version Show version information and exit.\n\n -v Be verbose.\n\n --debug Show what is happening internally.\n (You should give it a shot sometime ;) )\n\n --only-positives Echo positive results *only*.\n\n --http-username=<string> Username for HTTP authentication.\n\n --http-password=<string> Password for HTTP authentication.\n\n --http-req-limit=<integer> Concurrent HTTP requests limit.\n (Default: #{@opts.http_req_limit})\n (Be careful not to kill your server.)\n (*NOTE*: If your scan seems unresponsive try lowering the limit.)\n\n --http-queue-size=<integer> Maximum amount of requests to keep in the queue.\n Bigger size means better scheduling and better performance,\n smaller means less RAM consumption.\n (Default: #{@opts.http_queue_size})\n\n --http-timeout=<integer> HTTP request timeout in milliseconds.\n\n --cookie-jar=<filepath> Netscape HTTP cookie file, use curl to create it.\n\n --cookie-string='<name>=<value>; <name2>=<value2>'\n\n Cookies, as a string, to be sent to the web application.\n\n --user-agent=<string> Specify user agent.\n\n --custom-header='<name>=<value>'\n\n Specify custom headers to be included in the HTTP requests.\n (Can be used multiple times.)\n\n --authed-by=<string> E-mail address of the person who authorized the scan.\n (It'll make it easier on the sys-admins during log reviews.)\n (Will be used as a value for the 'From' HTTP header.)\n\n --login-check-url=<url> A URL used to verify that the scanner is still logged in to the web application.\n (Requires 'login-check-pattern'.)\n\n --login-check-pattern=<regexp>\n\n A pattern used against the body of the 'login-check-url' to verify that the scanner is still logged in to the web application.\n (Requires 'login-check-url'.)\n\n Profiles -----------------------\n\n --save-profile=<filepath> Save the current run profile/options to <filepath>.\n\n --load-profile=<filepath> Load a run profile from <filepath>.\n (Can be used multiple times.)\n (You can complement it with more options, except for:\n * --modules\n * --redundant)\n\n --show-profile Will output the running profile as CLI arguments.\n\n\n Crawler -----------------------\n\n -e <regexp>\n --exclude=<regexp> Exclude urls matching <regexp>.\n (Can be used multiple times.)\n\n --exclude-page=<regexp> Exclude pages whose content matches <regexp>.\n (Can be used multiple times.)\n\n -i <regexp>\n --include=<regexp> Include *only* urls matching <regex>.\n (Can be used multiple times.)\n\n --redundant=<regexp>:<limit>\n\n Limit crawl on redundant pages like galleries or catalogs.\n (URLs matching <regexp> will be crawled <limit> amount of times.)\n (Can be used multiple times.)\n\n --auto-redundant=<limit> Only follow <limit> amount of URLs with identical query parameter names.\n (Default: inf)\n (Will default to 10 if no value has been specified.)\n\n -f\n --follow-subdomains Follow links to subdomains.\n (Default: off)\n\n --depth=<integer> Directory depth limit.\n (Default: inf)\n (How deep Arachni should go into the site structure.)\n\n --link-count=<integer> How many links to follow.\n (Default: inf)\n\n --redirect-limit=<integer> How many redirects to follow.\n (Default: #{@opts.redirect_limit})\n\n --extend-paths=<filepath> Add the paths in <file> to the ones discovered by the crawler.\n (Can be used multiple times.)\n\n --restrict-paths=<filepath> Use the paths in <file> instead of crawling.\n (Can be used multiple times.)\n\n --https-only Forces the system to only follow HTTPS URLs.\n\n\n Auditor ------------------------\n\n -g\n --audit-links Audit links.\n\n -p\n --audit-forms Audit forms.\n\n -c\n --audit-cookies Audit cookies.\n\n --exclude-cookie=<name> Cookie to exclude from the audit by name.\n (Can be used multiple times.)\n\n --exclude-vector=<name> Input vector (parameter) not to audit by name.\n (Can be used multiple times.)\n\n --audit-headers Audit HTTP headers.\n (*NOTE*: Header audits use brute force.\n Almost all valid HTTP request headers will be audited\n even if there's no indication that the web app uses them.)\n (*WARNING*: Enabling this option will result in increased requests,\n maybe by an order of magnitude.)\n\n Coverage -----------------------\n\n --audit-cookies-extensively Submit all links and forms of the page along with the cookie permutations.\n (*WARNING*: This will severely increase the scan-time.)\n\n --fuzz-methods Audit links, forms and cookies using both GET and POST requests.\n (*WARNING*: This will severely increase the scan-time.)\n\n --exclude-binaries Exclude non text-based pages from the audit.\n (Binary content can confuse recon modules that perform pattern matching.)\n\n Modules ------------------------\n\n --lsmod=<regexp> List available modules based on the provided regular expression.\n (If no regexp is provided all modules will be listed.)\n (Can be used multiple times.)\n\n\n -m <modname,modname,...>\n --modules=<modname,modname,...>\n\n Comma separated list of modules to load.\n (Modules are referenced by their filename without the '.rb' extension, use '--lsmod' to list all.\n Use '*' as a module name to deploy all modules or as a wildcard, like so:\n xss* to load all xss modules\n sqli* to load all sql injection modules\n etc.\n\n You can exclude modules by prefixing their name with a minus sign:\n --modules=*,-backup_files,-xss\n The above will load all modules except for the 'backup_files' and 'xss' modules.\n\n Or mix and match:\n -xss* to unload all xss modules.)\n\n\n Reports ------------------------\n\n --lsrep=<regexp> List available reports based on the provided regular expression.\n (If no regexp is provided all reports will be listed.)\n (Can be used multiple times.)\n\n --repload=<filepath> Load audit results from an '.afr' report file.\n (Allows you to create new reports from finished scans.)\n\n --report='<report>:<optname>=<val>,<optname2>=<val2>,...'\n\n <report>: the name of the report as displayed by '--lsrep'\n (Reports are referenced by their filename without the '.rb' extension, use '--lsrep' to list all.)\n (Default: stdout)\n (Can be used multiple times.)\n\n\n Plugins ------------------------\n\n --lsplug=<regexp> List available plugins based on the provided regular expression.\n (If no regexp is provided all plugins will be listed.)\n (Can be used multiple times.)\n\n --plugin='<plugin>:<optname>=<val>,<optname2>=<val2>,...'\n\n <plugin>: the name of the plugin as displayed by '--lsplug'\n (Plugins are referenced by their filename without the '.rb' extension, use '--lsplug' to list all.)\n (Can be used multiple times.)\n\n Platforms ----------------------\n\n --lsplat List available platforms.\n\n --no-fingerprinting Disable platform fingerprinting.\n (By default, the system will try to identify the deployed server-side platforms automatically\n in order to avoid sending irrelevant payloads.)\n\n --platforms=<platform,platform,...>\n\n Comma separated list of platforms (by shortname) to audit.\n (The given platforms will be used *in addition* to fingerprinting. In order to restrict the audit to\n these platforms enable the '--no-fingerprinting' option.)\n\n Proxy --------------------------\n\n --proxy=<server:port> Proxy address to use.\n\n --proxy-auth=<user:passwd> Proxy authentication credentials.\n\n --proxy-type=<type> Proxy type; can be http, http_1_0, socks4, socks5, socks4a\n (Default: http)\n\n\nUSAGE\n end", "def banner\n puts \"TITO-BOT\\n\"\nend", "def usage\n\t\t$stderr.printf \"usage: %s [ options ]\\n\",$0\n\t\t$stderr.printf \"\\n%s\\n\",$help\n\t\texit 0\n\tend", "def banner\n \"Usage: #{$0} simple_spec_controller [ControllerName]\"\n end", "def help\n\t\tself.usage(false)\n\t\texit EX_OK\n\tend", "def cli_banner()\n print \"> \"\n end", "def create_banner\n option_separator\n option_separator 'Usage: main.rb <application>-<mode> [options]'\n end", "def usage_page\n Format.usage(\"You can run me with the following flags: #{File.basename(__FILE__)} -[d|e|h] -[f] <path/to/file/if/any>\")\n exit\nend", "def show_help\n display banner\n display \"\"\n display short_help\n display \"\"\n end", "def banner\n \"Usage: #{$0} admin_ka ModelName\"\n end", "def usage\n puts \"#{@description}\\n\\n\" unless @description.nil?\n puts 'Usage:'\n\n _commands_usage $PROGRAM_NAME\n end", "def usage\n \"#{balance_details 2}GB of #{balance_details 3}GB remaining\"\n end", "def usage_break(label)\n @arg_opts = {usage_break: label}\n end", "def purpose\n end", "def print_usage\n puts \"USAGE: #{PROGNAME} <ip|host> [warning,critical] [snmp_community]\"\n puts \" Default values: warning=80, critical=90, snmp_community=public\"\nend", "def usage\n str = @appname + \"\\n\\n\"\n unless @description.empty?\n str += \"DESCRIPTION\\n\"\n str += @description.join + \"\\n\"\n end\n unless @examples.empty?\n str += \"EXAMPLES\\n\"\n str += @examples.join + \"\\n\"\n end\n str += \"OPTIONS\"\n str += @parser.to_s.rstrip + \"\\n\"\n str\n end", "def usage\n str =<<USAGE\nadvantage - Calculate chance of beating a roll with advantage (or disadvantage)\n\nUsage:\nadvantage - show 1-20 advantage/disadvantage table\nadvantage <dc> <bonus|penalty> - show % chance of beating a specific DC with a\n given penalty or bonus, e.g advantage 23 +5 or advantage 10 -3.\nUSAGE\nend", "def showBanner\n\treturn unless $options.show_banner\n\tputs <<BANNER\n ____ ____ ____ ___________ ____ __ __ ______\n / ___\\\\_/ __ \\\\ / \\\\_/ __ \\\\_ __ \\\\/ _ \\\\| | \\\\/ ___/\n / /_/ > ___/| | \\\\ ___/| | \\\\( <_> ) | /\\\\___ \\\\\n \\\\___ / \\\\___ >___| /\\\\___ >__| \\\\____/|____//____ >\n\\\\_____/ \\\\/ \\\\/ \\\\/ project generator \\\\/\n\nBANNER\nend", "def banner\n \"Usage: #{$0} static_gen_specs ModelName [table_name]\"\n end", "def usage\n puts <<USAGE\n== Synopsis\n\nopm list-available-cartridges: Prints a list of all available cartridges and provided features\n\n== Usage\n\nopm list-available-cartridges\n\nOptions:\n-h|--help:\n Prints this message\nUSAGE\nend", "def banner\n\tputs\n\tputs \"#{HC}#{FWHT}Linux Log Cleaner\"\n\tputs \"By: #{FGRN}Hood3dRob1n#{RS}\"\n\tputs\nend", "def description\n super + \", Soy\"\n end", "def print_banner(meta_info = nil)\n banner = meta_info.nil? ? \"#{@banner}\" : \"#{meta_info}\\n #{@banner}\"\n puts banner\n end", "def usage_end\n '}'\n end", "def usage\n\tputs <<EOU\nUsage:\tausgaben {j,c,w}[g]add BETRAG [TAGS]\n\tausgaben sum {jo|caro|wir} [MONAT] [JAHR]\n\tausgaben list {jo|caro|wir} [MONAT] [JAHR]\n\tausgaben ausgleich [MONAT] [JAHR]\nEOU\n\texit\nend", "def describe(name)\n super\n end", "def usage_instructions\n \"Usage: #{$0} (--ec2-user-id | -u) (--aws-access-key-id | -a) (--aws-secret-access-key | -s) (--host_role | -r) (--snapshot | (--restore-most-recent | --start-most-recent) ) [--volume-size] [--tell] [--debug]\"\n end", "def usage=(value)\n @usage = value\n end", "def print_usage_and_exit\n puts usage\n exit\n end", "def desc(usage, desc, long_desc = nil)\n @usage = usage\n @desc = desc\n @long_desc = long_desc\n end", "def print_banner\n notice( \"\\n=== #{@key} ===\", [:CYAN, :BOLD])\n notice( description, [:CYAN] )\n notice( \"----> OS value: #{os_value.inspect}\", [:CYAN] ) if os_value\n notice( \"----> Recommended value: #{recommended_value.inspect}\", [:CYAN] ) if recommended_value\n end", "def usage(s)\n puts s\n print <<EOM\nUsage:\n #{$0} [--debug]\n [--conf file]\n [--image image_file]\n [--interval sec]\n [--thres n]\n [--txt text]\n [--allow pat1] [--allow pat2] ...\n [--version]\nExample:\n\nEOM\nend", "def deprecated(msg, src)\n red(msg)\n green(\"Called from \" + src)\n end", "def usage_presentation\n \" #{command.syntax}\"\n end", "def usage\n usages = <<-EOF\n #{program_name} list probe_packages [options] > OUTPUT/FILE\n Or: #{program_name} create mo < INPUT/JSON/FILE > OUTPUT/FILE\n EOF\n usages.gsub!(/^\\s+/, '')\n usages.gsub!(/\\n$/, '')\n usages\n end", "def output_help\n RDoc::usage()\n end", "def banner\n \"Usage: #{$0} sexy_scaffold ModelName [field:type field:type]\"\n end", "def usage message\n puts \"error: #{message}\" unless nil == message\n printf USAGE_MESSAGE, VERSION\n exit 1\nend", "def help; end", "def help; end", "def help; end", "def usage()\n puts <<-\"USAGE\"\n\n Usage: #{$0} path/to/file.ofx\n\n USAGE\n exit 1\nend", "def banner\n \"Usage: #{$0} ya_scaffold ModelName [field:type field:type]\"\n end", "def help(shell)\n shell.say \"Usage:\"\n shell.say \" #{banner}\\n\"\n shell.say\n class_options_help(shell)\n shell.say desc if desc\n end", "def basic_usage\n return '' if args.nil?\n usage_args.map {|e|\n (e.size < 2) ? e[0].upcase : \"[#{e[0].upcase}]\"\n }.join(' ')\n end", "def about_us\n\n\tend", "def description\n \"#{super} - Tramezzino\"\n end", "def description(*args)\n #do nothing\n end", "def usage()\n\tputs \"Usage: #{$0} [width resolution in pixels] [height resolution in pixels] [diagnonal size in inch]\"\nend", "def brief_description\n call_proc_or_return_value(self::BRIEF_DESCRIPTION)\n end", "def short_usage\n short =<<HERE_YOU_GO\nmax_hp - calculate max HP for character, per AD&D rules (*FIRST* Edition,\nSpecifically as implemented by Pool of Radiance!)\n\nUsage:\nmax_hp [options] <constitution> <class><level> [<class><level> [...]]\n\nUse max_hp -h or max_hp --help for more help.\nHERE_YOU_GO\nend", "def description\n super + \", Whip\"\n end", "def usage(text)\n Runner.instance.last_usage = text\n end", "def usage\n puts <<EOU\nUSAGE:\n #{__FILE__} ALIAS E-POST [ARGUMENT]\n\nTa bort ett e-postalias från mailservern\n\nExempel:\n #{__FILE__} arthur@example.com arthur.dent@example.com\n #{__FILE__} zaphod@example.net zaphod@example.com\n\nArgument:\n -h, --help Visa denna information\n -s, --simulate Simulera allt, gör inga ändringar i filsystem eller databas\n\nFör att ta bort ett alias måste \"hela\" aliaset anges (Dvs både ALIAS och MOTTAGARE).\nI nuvarande version går det inte att ta bort alla mottagare för ett alias på en gång!\nEOU\n\n # We also exit the script here..\n exit(0)\nend", "def about_us\n end", "def about_us\n end" ]
[ "0.77102196", "0.77102196", "0.7697215", "0.758689", "0.7539001", "0.7450375", "0.7229269", "0.71680474", "0.7024788", "0.70237845", "0.6986238", "0.69539636", "0.68358403", "0.67964435", "0.67648196", "0.6731819", "0.6729866", "0.6591336", "0.658199", "0.65733933", "0.65469635", "0.65469635", "0.65183353", "0.65096223", "0.65037614", "0.6485493", "0.6482101", "0.64687574", "0.64371896", "0.64346296", "0.6380366", "0.63335204", "0.63115144", "0.6308648", "0.6305962", "0.6296972", "0.6279699", "0.62573326", "0.62453", "0.6237521", "0.62367344", "0.62264293", "0.622209", "0.62004477", "0.618343", "0.6181353", "0.6175002", "0.61661303", "0.6165463", "0.61450344", "0.61210746", "0.61043334", "0.61022216", "0.609206", "0.60825455", "0.60323614", "0.6020953", "0.6013594", "0.5981872", "0.5974435", "0.59714776", "0.5955128", "0.59515995", "0.5948088", "0.5926976", "0.59108007", "0.59043044", "0.590104", "0.5885217", "0.5880501", "0.5874924", "0.58612627", "0.58539844", "0.58535075", "0.5846135", "0.58357644", "0.583324", "0.58316857", "0.5827128", "0.5823151", "0.5806919", "0.5806442", "0.5803403", "0.5803403", "0.5803403", "0.57749146", "0.57689595", "0.57685345", "0.57670283", "0.5764965", "0.5762809", "0.5762507", "0.5761028", "0.57569164", "0.57519335", "0.57467926", "0.5746074", "0.5742274", "0.5740465", "0.5740465" ]
0.64513123
28
only contain 4 elements and be in the form (x y) where x and y are both integers, and return the area of the rectangle formed by the 4 points on a Cartesian grid. The 4 elements will be in arbitrary order. For example: if strArr is ["(0 0)", "(3 0)", "(0 2)", "(3 2)"] then your program should return 6 because the width of the rectangle is 3 and the height is 2 and the area of a rectangle is equal to the width height. Input:"(1 1)","(1 3)","(3 1)","(3 3)" Output:4 Input:"(0 0)","(1 0)","(1 1)","(0 1)" Output:1
def RectangleArea(strArr) # code goes here return strArr end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def rectangle_area(str_arr)\n str_arr = str_arr.sort.map do |co_ord|\n co_ord.delete('()').split.map(&:to_i)\n end\n width = str_arr[2][0] - str_arr[0][0]\n height = str_arr[1][1] - str_arr[0][1]\n width * height\nend", "def RectangleArea(strArr)\n pool = strArr.join.scan(/(-?[0-9]+)/).flatten.map{|i|i.to_i}\n\n rec_l = [pool[1], pool[3], pool[5], pool[7]].sort\n rec_w = [pool[0], pool[2], pool[4], pool[6]].sort\n\n length = (rec_l[-1] - rec_l[0]).abs\n width = (rec_w[-1] - rec_w[0]).abs\n\n length * width\nend", "def area(arr)\n \n x_values = []\n y_values = []\n arr.each do |xy|\n x_values << xy.first\n y_values << xy.last\n end\n \n xmin = x_values.min\n xmax = x_values.max\n \n ymin = y_values.min\n ymax = y_values.max\n \n area = (ymax - ymin) * (xmax - xmin)\n \n area\nend", "def area_of_rect(l, w)\n return l * w\nend", "def area_of_rectangle(width, length)\n width*length\nend", "def rectangleArea(l, w)\n\t#Calculate the area\n\tl * w\nend", "def rectangle_area(width, height)\n area = width * height\nend", "def rectangleArea(h, w)\r\n h * w\r\nend", "def solve(input)\n left = 0 \n right = input.length - 1\n area = 0 \n while(left < right)\n if !input[left]\n left += 1\n next\n end\n if !input[right]\n right += 1\n next\n end\n height = [input[left], input[right]].min\n width = right - 1 - left\n area = [area, (height * width)].max\n if input[left] < input[right]\n left += 1\n else\n right += 1\n end\n end\n p area\nend", "def find_area(height, width)\n height * width\nend", "def area; rect size; end", "def polygon_area(vertices)\n raise \"A polygon must have 3 or more vertices, not #{vertices.length}\" unless vertices.length >= 3\n\n area = 0\n\n # Rely on Ruby's circular array indexing for negative indices\n vertices.size.times do |idx|\n x2, y2 = vertices[idx]\n x1, y1 = vertices[idx - 1]\n area += x1 * y2 - x2 * y1\n end\n\n return area * 0.5\n end", "def total_paper(dimensions)\n\tsides = dimensions.split(\"x\").map { |n| n.to_i }\n\tlength, width, height = sides[0], sides[1], sides[2]\n\ta, b, c = (length * width), (width * height), (height * length)\n\tmin_area = [a, b, c].min\n\tresult = (2 * a) + (2 * b) + (2 * c) + min_area\nend", "def area(length, width)\n length * width\nend", "def find_area height, width\n\theight * width\nend", "def find_area height, width \n area= height * width \n puts area \nend", "def sq_area_max(coordinates, matrix_length)\n binding.pry\n area = matrix_length ** 2\n right = (matrix_length-1) - coordinates[0]\n left = (matrix_length - 1) - right\n top= (matrix_length-1) - coordinates[1]\n bottom= (matrix_length -1) - top\n return [top* right, top*left, bottom * right, bottom*left].max\nend", "def shape_check(a,b,c,d,e)\n shape = [@board[a[0]][a[1]],\n\t\t\t@board[b[0]][b[1]],\n\t\t\t@board[c[0]][c[1]],\n\t\t\t@board[d[0]][d[1]],\n\t\t\t@board[e[0]][e[1]],] \n\treturn shape.count('x') == 5\t\t\n end", "def find_area height, width\n\n\theight * width\nend", "def area\n result = @length * @breadth\n puts\n puts \"area of square of length 4 should be 16 ✔\"\n puts \"area of rectangle with #{@length}, #{@breadth} should be #{result} ✔\"\n\n end", "def area(length, width)\n a = length * width\n return a\nend", "def calc_area(len, wid)\n\tarea = len * wid\n\treturn area\nend", "def rectangleArea(width, height)\n # return width * height\n width * height\n # set end of rectangleArea function\nend", "def getArea\n @width * @height * @length\n end", "def area(length, width)\n length * width # Implicit return\nend", "def find_area height, width\n area = height * width\n p area\nend", "def area\n x, y, z = sides.sort\n (\n 0.25 * Math.sqrt((x + (y + c)) * (z - (x - y)) * (z + (x - y)) * (x + (y - z)))\n ).to_f.round(precision)\n end", "def area\n\n return @side_len * @side_len\n\n\n end", "def getTriangleArea(x, y)\n # Write your code here\n base=x.max-x.min\n height=y.max-y.min\n\n (base*height)/2\nend", "def four_sum?(arr, target)\n hash = Hash.new { |h, v| h[v] = [] }\n (0...arr.length - 1).each do |i|\n (i + 1...arr.length).each do |j|\n sum = arr[i] + arr[j]\n hash[sum] << [i, j]\n end\n end\n # p hash\n hash.each do |first_number, first_pairs|\n second_number = target - first_number\n if hash.has_key?(second_number)\n second_number_values = hash[second_number]\n # uniq on first pairs and second pairs\n second_number_values.each do |x2, y2|\n first_pairs.each do |x1, y1|\n if [x1, y1, x2, y2].uniq.length == 4\n # p [x1, y1, x2, y2]\n return true\n end\n end\n end\n end\n end\n false\nend", "def area\n (@p1.x * @p2.y + @p2.x * @p3.y + @p3.x * @p1.y - @p1.y * @p2.x - @p2.y * @p3.x - @p3.y * @p1.x).abs / 2.0\n end", "def getArea()\n getWidth() * getHeight()\n end", "def getArea(ringNumber)\n\t((ringNumber-1)*2+1)**2\nend", "def recArea(w, h) \n w * h \nend", "def area\n width() * height\n end", "def area\n return @side_length * @side_length\n end", "def area\r\n return (( (@p1.x*(@p2.y - @p3.y)) + (@p2.x*(@p3.y - @p1.y)) + (@p3.x*(@p1.y - @p2.y)) )/2.0).abs\r\n end", "def shapeArea(n)\n return (n*n) + ((n-1)*(n-1))\nend", "def parse_coordinate_data(input_string)\n # extract substrings matching ( int , int ) into an array, ignoring whitespace\n coords_string = input_string.scan(@coords_regex)\n\n #if nothing matches then return an empty array\n if coords_string == nil\n return []\n end\n\n # remove the brackets, split the coordinate strings, convert to integers, leave as array of arrays\n coords_array = coords_string.map do |a|\n b = a.gsub(/[()]/, \"\")\n c = b.split(/,\\s*/)\n x, y = c.map { |x| x.to_i}\n end\n\n @logger.info coords_array\n\n # check here that the coordinates in the array don't exceed the grid dimensions ever\n coords_array.each do |a|\n if a[0] > @grid_dimensions[0] || a[0] < 0\n raise ArgumentError, \"x-coord exceeds grid size. Destination: #{a} in grid #{@grid_dimensions}\"\n end\n\n if a[1] > @grid_dimensions[1] || a[1] < 0\n raise ArgumentError, \"y-coord exceeds grid size. Destination: #{a} in grid #{@grid_dimensions}\"\n end\n end\n end", "def get_area(type_area, array_point)\n if type_area == 'circle'\n area = { circle: { centerLatitude: array_point[0], centerLongitude: array_point[1], radius: array_point[2] } }\n else\n points = []\n array_point.each do |c|\n c = c.split(',')\n points << { latitude: c[0], longitude: c[1] }\n end\n area = { polygon: { vertices: points } }\n end\n area\n end", "def coordinate_area\n (@x_max.to_f - @x_min.to_f) * (@y_max.to_f - @y_min.to_f)\n end", "def find_area\n\t\t@area = 0.5 * ((@point1.x - @point3.x)*(@point2.y - @point1.y) - (@point1.x - @point2.x)*(@point3.y - @point1.y)).abs\n\tend", "def area_of_triangle(base, height)\n (base * height) / 2\nend", "def area()\n segments.map { |seg| seg.area(start_point) }.reduce(:+)\n end", "def area_for_x(x)\n if (@hex0..@hexN-(@asc_width>>1)).include?(x) then HEX_AREA\n elsif (@asc0..@ascN).include?(x) then ASCII_AREA\n end\n end", "def largest_area(input_array)\n max = 0\n \n input_array.each do |item|\n area = item[0] * item[1] # 1 * 2\n if area > max\n max = area\n end\n end\n return max\n end", "def getArea\n getWidth() * getHeight\n end", "def getArea\n getWidth() * getHeight\n end", "def print_area(*args)\n # Check for a cell reference in A1 notation and substitute row and column\n if args =~ /^\\D/\n args = substitute_cellref(*args)\n end\n\n return if args.size != 4 # Require 4 parameters\n\n @print_rowmin, @print_colmin, @print_rowmax, @print_colmax = args\n end", "def calc(arr)\n arr.unshift(0)\n arr.push(0)\n areas = []\n stack = []\n (0...(arr.size)).each do |index|\n if stack.empty? || arr[index] > arr[stack.last]\n # increasing\n stack << index\n else\n # decreased\n while !stack.empty? && arr[stack.last] >= arr[index]\n stack_last_index = stack.pop\n height = arr[stack_last_index]\n if stack.empty?\n width = index + 1 - 2\n else\n width = index - stack.last + 1 - 2\n puts \"width: #{width}, #{index}- #{stack.last}\"\n end\n area = width * height\n puts \"#{arr[stack_last_index]}: #{arr[index]}, area: #{area}\"\n areas << area\n end\n stack << index\n end\n end\n areas.max\n end", "def getArea\n getWidth() * getHeight\n end", "def largest_area(nums)\n max_area = nums[0][0] * nums[0][1]\n\n nums.each do |num_set|\n if max_area < (num_set[0] * num_set[1])\n max_area = num_set[0] * num_set[1]\n end\n end\n\n return max_area\nend", "def area_of_square(length)\n length*length\nend", "def getArea\n getWidth() * getHeight\n end", "def total_area\n\t\tarea = 0\n\t\tshapes.each do |shape|\n\t\t\tarea = area + shape.area\n\t\tend\n\t\treturn area\n\tend", "def overlap_area(rect)\n if !overlap?(rect)\n return 0\n end\n\n x_overlap = ([rect.x2,@x2].min) - ([rect.x1, @x1].max)\n y_overlap = ([rect.y2,@y2].min) - ([rect.y1, @y1].max)\n overlap = x_overlap * y_overlap\n end", "def fill_area4(canvas, pt1, pt2, pt3, pt4, opt={})\n color = opt[:color] || opt[:c]\n color = canvas.type == :ppm ? [canvas.maxgray, canvas.maxgray, canvas.maxgray] : canvas.type == :pgm ? canvas.maxgray : 1 unless opt.has_key?(:color) || opt.has_key?(:c)\n \n ab = line(pt1, pt2)\n ad = line(pt1, pt4)\n sum_a = ab.merge(ad)\n cb = line(pt3, pt2)\n cd = line(pt3, pt4)\n sum_c = cb.merge(cd)\n \n final = []\n canvas.height.times do |y|\n row = []\n canvas.width.times do |x|\n pixel = canvas.pixels[y][x]\n if (sum_a.has_key?(x) && sum_c.has_key?(x)) && !(y >= sum_a[x] || y <= sum_c[x])\n pixel = color\n end\n row << pixel\n end\n final << row\n end\n \n PNM.create(final, {:type => :ppm, :maxgray => 255})\n end", "def area\n \t@width * @height\n end", "def area_or_perimeter(l , w)\n if l === w\n (l * w)\n else \n 2*(l+w)\n end\nend", "def max_area(height)\n left = 0\n right = height.size - 1\n max_area = 0\n while left < right do \n max_area = [max_area, ([height[left], height[right]].min) * (right - left)].max\n if height[left] < height[right]\n left += 1\n else\n right -= 1\n end\n end\n max_area\nend", "def calculate_area\n\t\t\tif @num_sides.is_a?(Fixnum) \n\t\t\tangle = (Math::PI * 2)/@num_sides\n\t\t\t# add *(r**2) if you want radius\n\t\t\tsolved = (0.5)*@num_sides*Math.sin(angle)\n\t\t\t@solved = solved\n\t\tend\n\tend", "def test_example_part_two\n input = ['1, 1', '1, 6', '8, 3', '3, 4', '5, 5', '8, 9'].join(\"\\n\")\n grid = Grid.new(input, true, 32)\n\n assert_equal 16, grid.region_size\n end", "def get_area\n\n # get the keyword value of shape\n shape = get_keyword_value(\"SHAPE\")\n\n # if the shape value is nil, or it is defined as \"NO-SHAPE\", the get_area value\n # would be defined, and would represent the get_area of the space\n if ( shape == nil || shape == \"NO-SHAPE\")\n area = get_keyword_value(\"AREA\")\n area = area.to_f\n return area\n\n # if the shape value is \"BOX\", the height and width key values are given,\n # and the get_area would be defined as their product\n elsif ( shape == \"BOX\" )\n height = get_keyword_value(\"HEIGHT\")\n width = get_keyword_value(\"WIDTH\")\n height = height.to_f\n width = width.to_f\n return height * width\n\n # if the shape value is defined as a polygon , the get_area of the polygon would\n # represent the get_area of the space\n elsif ( shape == \"POLYGON\")\n return @polygon.get_area\n else\n raise \"Error: The area could not be evaluated. Please check inputs\\n \"\n\n end\n end", "def input4\n [\n [1, 0, 0, 0, 1],\n [0, 0, 0, 1, 3],\n [0, 1, 0, 0, 5],\n [0, 0, 1, 0, 8]\n ]\nend", "def area\n\t\t@side_length * @side_length\n\tend", "def island_perimeter(grid)\n perimeter = 0\n last_row = grid.length - 1\n \n grid.each_with_index do |row, row_idx|\n row.each_with_index do |col, col_idx|\n last_col = row.length - 1\n \n if col == 1\n if row_idx == 0\n perimeter += 1\n else\n perimeter += 1 if grid[row_idx - 1][col_idx] == 0\n end\n \n if col_idx == 0\n perimeter += 1\n elsif row[col_idx - 1] == 0\n perimeter += 1\n end\n \n if col_idx == last_col\n perimeter += 1\n elsif row[col_idx + 1] == 0\n perimeter += 1\n end\n \n if row_idx == last_row\n perimeter += 1\n elsif grid[row_idx + 1][col_idx] == 0\n perimeter += 1\n end\n end\n end\n end\n perimeter\nend", "def VowelSquare(strArr)\n vowels = %w(a e i o u)\n matrix = strArr.map(&:chars)\n \n matrix.each_with_index do |sub_arr, y|\n next if y >= matrix.size - 1\n sub_arr.each_with_index do |el, x|\n next if x >= matrix[0].size - 1\n combined_value = [matrix[y][x]] + [matrix[y + 1][x]] +\n [matrix[y][x + 1]] + [matrix[y + 1][x + 1]]\n return [y, x].join('-') if (combined_value - vowels).empty? \n end\n end\n 'not found'\nend", "def getArea\n\t\tgetWidth() * getHeight\n\tend", "def getArea\n\t\tgetWidth() * getHeight\n\tend", "def area\n w * h\n end", "def num_cells_in_range(str)\n cells = str.split(':')\n return 1 if cells.count == 1\n raise ArgumentError.new(\"invalid range string: #{str}. Supported range format 'A1:B2'\") if cells.count != 2\n x1, y1 = split_coordinate(cells[0])\n x2, y2 = split_coordinate(cells[1])\n (x2 - (x1 - 1)) * (y2 - (y1 - 1))\n end", "def get_area()\n unless check_keyword?(\"HEIGHT\") and check_keyword?(\"WIDTH\")\n raise \"Error: In the command #{@utype}:#{@command_name} the area could not be evaluated. Either the HEIGHT or WIDTH is invalid.\\n #{output}\"\n end\n return get_keyword_value(\"WIDTH\").to_f * get_keyword_value(\"HEIGHT\").to_f\n end", "def max_area(height)\n max_area = 0\n left = 0\n right = height.length - 1\n while right > left\n min_height = [height[left], height[right]].min\n area = find_area(min_height, left, right)\n if area > max_area\n max_area = area\n end\n \n if height[left] >= height[right]\n right -= 1\n else\n left += 1\n end\n \n end\n \n max_area\n \n \nend", "def check_area(point1, point2, point3)\n area = (point1.x * (point2.y - point3.y) +\n point2.x * (point3.y - point1.y) +\n point3.x * (point1.y - point2.y))/2\n if (area < 0)\n area = -area\n end\n return area\nend", "def getAnswer(polygons, precision)\n s = nil\n w = nil\n n = nil\n e = nil\n init = false\n polygons.elements.each do |polygon|\n coordinates = polygon.text.split\n coordinates.each do |coord|\n arr = coord.split \",\"\n if (!init)\n s = arr[1].to_f\n w = arr[0].to_f\n n = s\n e = w\n init = true\n else\n s = s > arr[1].to_f ? arr[1].to_f : s\n n = n < arr[1].to_f ? arr[1].to_f : n\n w = w > arr[0].to_f ? arr[0].to_f : w\n e = e < arr[0].to_f ? arr[0].to_f : e\n end\n end\n end\n # give a human a chance to get into the square\n s = (s-precision).round(4)\n w = (w-precision).round(4)\n n = (n+precision).round(4)\n e = (e+precision).round(4)\n return \"{#{s},#{w},#{n},#{e}}\"\n end", "def area(box)\n nw_lon = box[0][0]\n nw_lat = box[0][1]\n se_lon = box[1][0]\n se_lat = box[1][1]\n y = abs(nw_lat - se_lat)\n x = abs(nw_lon - se_lon)\n x = x < 180 ? x : 360-x\n return x*y\n end", "def max_area(height)\n left = 0\n right = height.length - 1\n max = 0\n while left < right\n current = [height[left], height[right]].min * (right - left)\n max = current if current > max\n if height[left] < height[right]\n left += 1\n else\n right -= 1\n end\n end\n max\nend", "def max_area_brute(heights)\n max_area = 0\n\n (0..heights.length - 1).each do |i|\n ((i + 1)..heights.length - 1).each do |j|\n min_height = [heights[i], heights[j]].min\n\n local_area = min_height * (j - i)\n max_area = [max_area, local_area].max\n end\n end\n\n max_area\nend", "def create_general_area_span_for_numbered size\n area_span = []\n row_zero = [[0,0]]\n n = size + (size - 1)\n m = ::Matrix.build(n,n){|x,y| [x,y]} #.to_a.flatten(1).to_set\n (1...size).each do |i|\n row_zero << [0,i]\n row_zero << [0,-i]\n end\n\n row_zero.sort.each do |y,x|\n # Bellow is the trick for the diagonal\n # on the diamond\n (0..(x.abs-size+1).abs).each do |i|\n area_span << [y+i,x]\n area_span << [y-i,x]\n end\n end\n\n area_span.uniq\n end", "def area_of_triangle(base, height)\n #sign for multiply is *, not x. changed b to base\n base * height / 2\nend", "def largest_rectangle_area(heights)\n n, ans = heights.size, -Float::INFINITY\n (0..n-1).each do |i|\n min = heights[i]\n (i..n-1).each do |j|\n min = [min, heights[j]].min\n ans = [ans, min*(j-i+1)].max\n end\n end\n ans\nend", "def vowel_square(input)\n vowels = %w(a e i o u)\n\n i = 0\n while i < input.length - 1\n j = 0\n while j < input[0].length - 1\n left_top = input[i][j]\n right_top = input[i][j+1]\n left_bottom = input[i+1][j]\n right_bottom = input[i+1][j+1]\n\n if vowels.include?(left_top) && vowels.include?(right_top) && vowels.include?(left_bottom) && vowels.include?(right_bottom)\n return [i,j]\n end\n j += 1\n end\n i += 1\n end\n nil\nend", "def largestRectangle(h)\n stack = [0]; length = h.length; h << 0; area = 0; index = 1\n\n while index <= length do\n if stack.empty? || h[index] > h[stack[-1]]\n stack << index\n index += 1\n else\n element_index = stack.pop\n t_area = h[element_index] * (stack.empty? ? index : (index - stack[-1] -1))\n area = [area, t_area].max\n end\n end\n\n return area\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 sqInRectInner(length, width)\n max = [length, width].max\n min = [length, width].min\n if min * max == 0\n return []\n else\n return [min] + sqInRectInner(max - min, min)\n end\nend", "def max_area_of_island(grid)\n area = 0\n (0...grid.size).each do |i|\n (0...grid[0].size).each do |j|\n area = [area, island_area(grid, i, j)].max if grid[i][j] == 1\n end\n end\n area\nend", "def get_area\n height = get_keyword_value(\"HEIGHT\")\n width = get_keyword_value(\"WIDTH\")\n \n if height == nil || width == nil\n raise \"Error: In the command #{@utype}:#{@command_name} the area could not be evaluated. Either the HEIGHT or WIDTH is invalid.\\n #{output}\"\n end\n \n height = height.to_f\n width = width.to_f\n \n return height * width\n end", "def area\n return @area if defined?(@area)\n\n sum = 0.0\n (0...vertices.length).each do |i|\n prev = vertices[i - 1]\n curr = vertices[i]\n\n sum += ((prev.x * curr.y) - (prev.y * curr.x))\n end\n\n @area = sum / 2\n @area\n end", "def calculate_area\n puts \"Area depends of figure, but we can calculate through triangles\"\n end", "def largest_rectangle_area(heights)\n return 0 if heights.empty?\n largest(MinSpTable.new(heights), 0, heights.size-1)\nend", "def area_of_triangle(base, height)\n 0.5*base*height\nend", "def area_span_for_numbered_tile tile\n area_span = create_general_area_span_for_numbered @b_nl[tile[0],tile[1]]\n area_span.map!{|x,y| [(x+tile[0]), (y+tile[1])] }\n area_span.reject!{|x,y| x < 0 || y < 0 || x > (@row_count-1) || y > (@col_count-1)}\n area_span\n end", "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 perimeter_of_smallest_side(dimensions)\n dimensions.sort!\n (dimensions[0] * 2) + (dimensions[1] * 2)\nend", "def rectangle_finder(arr)\n # Find the upper left coordinates\n ul_row = arr.index { |row| row.include?(1) }\n ul_col = arr[ul_row].index(1)\n\n # Find the bottom right coordinates from this\n br = bottom_right(arr, [ul_row, ul_col])\n\n # Return the two together\n [[ul_row, ul_col], br]\nend", "def calc_area (base1,base2,height)\r\n\tarea = height * (base1 + base2) / 2.0\r\n\treturn area\r\nend", "def area_of_triangle(base, height)\n# change x to *\n # puts b x height / 2\n puts base * height / 2\nend", "def computeArea(h, w) # define a function with 2 parameters\n HALF * h * w # calculate area of triangle\nend", "def rectangles_finder(arr)\n rectangle_spots = {} # will keep track of where rectangles occupy\n rectangles = [] # will keep track of the rectangle corners for output\n\n arr.each_with_index do |row, i|\n row.each_with_index do |el, j|\n if el == 1 && !rectangle_spots.include?([i, j])\n # Found a new rectangle corner\n ul = [i, j]\n br = bottom_right(arr, ul)\n\n # Add the rectangle corners to the output\n rectangles << [ul, br]\n\n # Add the new coordinates to the hash\n rectangle_spots = update_hash(rectangle_spots, [ul, br])\n end\n end\n end\n\n # Return the rectangles\n rectangles\nend", "def max_product_of_four_adjacent_numbers_from_collection_of_arrays(lines)\n max_product = 1\n \n lines.each {|line|\n line_max = max_product_of_four_adjacent_numbers_from_array(line)\n max_product = line_max if (max_product < line_max)\n }\n \n return max_product\nend" ]
[ "0.77164143", "0.7568225", "0.670488", "0.63067716", "0.62193173", "0.6018003", "0.591587", "0.59056187", "0.5904961", "0.5836517", "0.5782233", "0.5743191", "0.5674866", "0.5671332", "0.5616109", "0.5564751", "0.5564439", "0.5563994", "0.5545396", "0.55370104", "0.553384", "0.5473117", "0.5435296", "0.5421259", "0.54178685", "0.54144853", "0.54063994", "0.5394839", "0.5367543", "0.5365094", "0.53605694", "0.53588665", "0.5347676", "0.5344449", "0.53129303", "0.5304875", "0.52992487", "0.52874726", "0.52802294", "0.52768475", "0.5275482", "0.5271991", "0.52618", "0.5258169", "0.52580667", "0.52336115", "0.52325946", "0.52325946", "0.52298874", "0.5217055", "0.5216966", "0.52037394", "0.52030784", "0.5202177", "0.5201419", "0.5182789", "0.5164393", "0.51638055", "0.5141116", "0.5140759", "0.5113818", "0.510415", "0.5093892", "0.50893384", "0.5087522", "0.5087065", "0.5082375", "0.50728154", "0.50725806", "0.50642043", "0.5055884", "0.50194013", "0.50165385", "0.49992505", "0.49964452", "0.49836472", "0.4973795", "0.497307", "0.4971296", "0.49679488", "0.4952959", "0.49524945", "0.49442315", "0.4940901", "0.4938909", "0.49302596", "0.49248946", "0.49233985", "0.4922338", "0.49107477", "0.49073485", "0.4906501", "0.49042943", "0.4898407", "0.48978812", "0.48967034", "0.4879901", "0.48635295", "0.48492515", "0.4839202" ]
0.6193472
5
=end def self.create_with_omniauth(auth) create! do |user| user.provider = auth["provider"] user.uid = auth["uid"] user.name = auth["info"]["name"] end end private def generate_authentication_token! begin self.auth_token = Devise.friendly_token end while self.class.exists?(auth_token: auth_token) end
def admin? self.role == 53 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def generate_authentication_token!\n begin\n self.auth_token = Devise.friendly_token\n end while self.class.exists?(auth_token: auth_token)\n end", "def generate_authentication_token!\n begin\n self.auth_token = Devise.friendly_token\n end while self.class.exists?(auth_token: auth_token)\n end", "def generate_authentication_token!\n begin\n self.auth_token = Devise.friendly_token\n end while self.class.exists?(auth_token: auth_token)\n end", "def generate_authentication_token!\n begin\n self.auth_token = Devise.friendly_token\n end while self.class.exists?(auth_token: auth_token)\n end", "def create_authentication(omniauth)\n authentications.create! do |a|\n a.provider = omniauth.provider\n a.uid = omniauth.uid\n end\n end", "def generate_authentication_token!\n begin\n self.auth_token = Devise.friendly_token\n end while User.exists?(auth_token: auth_token)\n end", "def generate_authentication_token!\n begin\n self.auth_token = Devise.friendly_token\n end while User.exists?(auth_token: auth_token)\n end", "def create_authentication(omniauth)\n authentications.create! do |a|\n a.provider = omniauth.provider\n a.uid = omniauth.uid\n end\n end", "def generate_authentication_token!\n begin\n self.auth_token = Devise.friendly_token\n end while self.class.exists?(auth_token: self.auth_token)\n end", "def generate_authentication_token!\n\tbegin\n\t\tself.auth_token = Devise.friendly_token\n\tend while self.class.exists?(auth_token: auth_token)\nend", "def generate_auth_token!\n begin\n self.auth_token = Devise.friendly_token\n end while self.class.exists?(auth_token: auth_token)\n end", "def generate_auth_token!\n \tbegin\n \t\tself.auth_token = Devise.friendly_token\n \tend while User.exists?(auth_token: auth_token)\n\tend", "def generate_authentication_token\n begin\n self.access_token = Devise.friendly_token\n end while self.class.exists?(access_token: access_token)\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 create_authentication_token!\n begin\n self.authentication_token = User.token\n end while User.exists?(authentication_token: self.authentication_token)\n end", "def generate_auth_token\n token = AuthToken.new(user: self)\n token if token.save\n end", "def create_by_omniauth(auth)\n User.create do |user|\n user.assign_attributes(name: auth.info.name, email: auth.info.email,\n password: Devise.friendly_token[0, 20])\n user.skip_confirmation! if user.email\n user.link_with_omniauth(auth)\n end\n end", "def create\n auth = request.env[\"omniauth.auth\"]\n user_info = auth[\"info\"] ? auth[\"info\"] : auth[\"user_info\"]\n authentication = Authorization.where(:provider => auth['provider'], :uid => auth['uid']).first\n authentication = Authorization.new(:provider => auth['provider'], :uid => auth['uid']) if !authentication\n session[:fb_token] = auth['credentials']['token'] if auth['credentials']['token'] != nil\n # if the user exists, but does not have a link with the social service\n if !authentication.user && current_user\n authentication.user = current_user\n authentication.save\n end\n # twitter only (gets no email)\n if !authentication.user && !user_info[\"email\"]\n flash[:notice] = \"No user linked to this account. Please sign in or create a new account\"\n redirect_to '/users/sign_up/'\n # if user doesnt exists, register user\n elsif !authentication.user\n user = User.where(email: user_info['email']).first\n if user\n authentication.user = user\n else\n new_user = User.new(email: user_info['email'], username: user_info['name'], first_name: user_info['first_name'], last_name: user_info['last_name'], role: \"registered\")\n new_user.save\n authentication.user = new_user\n end\n authentication.save\n end\n # if user exists, sign in. Gives a Mongoid glitch of not signing in after registration. So double sign in\n if authentication.user\n if !current_user\n sign_in authentication.user\n sign_out authentication.user\n sign_in authentication.user\n # raise \"user signed in? #{user_signed_in?.to_s}\".inspect\n flash[:notice] = \"Authorization successful.\"\n redirect_to root_path\n else\n flash[:notice] = \"Linked successfully.\"\n redirect_to '/users/'+current_user.id\n end\n end\n end", "def create_from_omniauth\n auth_hash = request.env[\"omniauth.auth\"]\n authentication = Authentication.find_by_provider_and_uid(auth_hash[\"provider\"], auth_hash[\"uid\"]) || Authentication.create_with_omniauth(auth_hash)\n\n # if: previously already logged in with OAuth\n if authentication.user\n user = authentication.user\n authentication.update_token(auth_hash)\n @next = root_url\n @notice = \"Signed in!\"\n # else: user logs in with OAuth for the first time\n else\n user = User.create_with_auth_and_hash(authentication, auth_hash)\n # you are expected to have a path that leads to a page for editing user details\n @next = edit_user_path(user)\n @notice = \"User created. Please confirm or edit details\"\n end\n\n sign_in(user)\n redirect_to @next, :notice => @notice\n end", "def generate_authentication_token!\n begin\n self.auth_token = SecureRandom.hex(20)\n end while self.class.exists?(auth_token: auth_token)\n end", "def create \n # render :text => request.env[\"omniauth.auth\"].to_yaml\n omniauth = request.env[\"omniauth.auth\"]\n authentication = Authentication.find_by_provider_and_uid(omniauth['provider'], omniauth['uid'])\n if authentication\n flash[:notice] = \"Signed in successfully.\"\n sign_in_and_redirect(:user, authentication.user)\n elsif current_user # if user logged in but doesn't have this auth in DB\n current_user.authentications.create!(:provider => omniauth['provider'], :uid => omniauth['uid'])\n flash[:notice] = \"Authentication successful.\"\n redirect_to authentications_url\n else # if user doesn't exist\n user = User.new\n user.apply_omniauth(omniauth)\n if user.save #if validation passes\n flash[:notice] = \"Signed in successfully.\"\n sign_in_and_redirect(:user, user)\n else #if validation doesn't pass\n session[:omniauth] = omniauth.except('extra')\n redirect_to new_user_registration_url\n end\n end \n end", "def apply_omniauth(omniauth)\n authentications.build(provider: omniauth['provider'],\n uid: omniauth['uid'],\n token: omniauth['credentials']['token'],\n secret: omniauth['credentials']['secret'])\n end", "def generate_token\n begin\n self[:auth_token] = SecureRandom.urlsafe_base64\n end while User.exists?(:auth_token => self[:auth_token])\n end", "def apply_omniauth(auth)\n self.email = auth['extra']['raw_info']['email'] if auth['extra']['raw_info']['email']\n self.password = Devise.friendly_token[0,20]\n authentications.build(:provider=>auth['provider'], :uid=>auth['uid'], :token=>auth['credentials']['token'], :secret=>auth['credentials']['secret'])\n end", "def create\n\n\t\t@auth = request.env[\"omniauth.auth\"]\n\n\t\tprovider = @auth.provider\n\t\tuid = @auth.uid\n\t\taccess_token = @auth.credentials.token\n\t\ttoken_secret = @auth.credentials.secret\n\t\tconsumer_key = \"\"\n\t\tconsumer_secret = \"\"\n\n\t\tif provider == \"bitbucket\"\n\t\t\tconsumer_key = @auth.extra.access_token.consumer.key\n\t\t\tconsumer_secret = @auth.extra.access_token.consumer.secret\n\t\tend\n\n\t\t@authentication = Authentication.find_by_provider_and_uid(provider, uid)\n\n\t\tif @authentication.present?\n\t\t\t# The authentication is already there\n\t\t\t# Get the user\n\t\t\tuser = @authentication.user\n\n\t\t\t# And sign him in\n\t\t\tflash[:notice] = \"Signed in successfully\"\n\t\t\tsign_in_and_redirect :user, user\n\n\t\telsif current_user.present?\n\t\t\t# There's no authentication in db, but the user is present\n\n\t\t\t# Create an authentication for the user and redirect\n\t\t\tcurrent_user.authentications.create! :provider => provider, \n\t\t\t\t\t\t\t\t\t\t\t\t :uid => uid, \n\t\t\t\t\t\t\t\t\t\t\t\t :access_token => access_token,\n\t\t\t\t\t\t\t\t\t\t\t\t :token_secret => token_secret,\n\t\t\t\t\t\t\t\t\t\t\t\t :consumer_key => consumer_key,\n\t\t\t\t\t\t\t\t\t\t\t\t :consumer_secret => consumer_secret\n\t\t\tredirect_to deployable_applications_url, :notice => \"Successfully added authentication.\"\n\n\t\telse\n\n\t\t\tredirect_to new_user_registration_url and return\n\n\t\t\t# Uncomment this to make the user log in with integrations\n\n\t\t\t# # There is no @auth and no user\n\t\t\t# # So create a new user\n\t\t\t# user = User.new\n\n\t\t\t# # Create an authentication for the new user\n\t\t\t# user.apply_omniauth(@auth)\n\n\t\t\t# if user.save\n\t\t\t# \t# Sign him in if no errors\n\t\t\t# \tflash[:notice] = \"Signed in successfully\"\n\t\t\t# \tflash[:just_signed_up] = true\n\t\t\t# \tsign_in_and_redirect :user, user\n\t\t\t# else\n\t\t\t# \t# Complete registration if any errors\n\t\t\t# \tsession[:omniauth] = @auth.except('extra')\n\t\t\t# \tredirect_to new_user_registration_url\n\t\t\t# end\n\t\tend\n\n\tend", "def generate_auth_token!\n loop do\n @token = Devise.friendly_token\n break unless Token.find_by(token: @token)\n end\n self.tokens.create token: @token\n return @token\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 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 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\n @omniauth = request.env[\"omniauth.auth\"]\n \n authentication = Authentications.find_by_provider_and_uid(@omniauth['provider'], @omniauth['uid'])\n\n if(@@logingIn ==0) \n registering(authentication)\n elsif(@@logingIn ==1)\n signingIn(authentication)\n end\n\nend", "def create \n omniauth = request.env[\"omniauth.auth\"]\n \n authentication = Authentication.find_by_provider_and_uid(omniauth['provider'], omniauth['uid'])\n if authentication\n #directly sign in existing user with existing authentication\n flash[:notice] = \"signed in successfully\"\n sign_in_and_redirect(:user, authentication.user)\n elsif current_user\n #create a new authentication for currently signed in user\n current_user.authentications.create(:provider => omniauth['provider'], :uid => omniauth['uid']) \n flash[:notice] = \"Authentication successful.\" \n redirect_to authentications_url\n else\n # user does not have an account or is authenticated through a provider\n user = User.new\n user.apply_omniauth(omniauth) \n if user.save\n flash[:notice] = \"Signed in successfully.\" \n sign_in_and_redirect(:user, user) \n else\n session[:omniauth] = omniauth.except('extra') \n redirect_to new_user_registration_url\n end \n end\n end", "def create\n omniauth = request.env['omniauth.auth']\n authparams = ActionController::Parameters.new(omniauth.slice 'provider', 'uid').permit('provider', 'uid')\n # Our query parameters appear in env['omniauth.params']\n if origin_url = request.env['omniauth.origin'] # Remove any enclosing quotes\n origin_url.sub! /^\"?([^\"]*)\"?/, '\\\\1'\n end\n # Originator is where we came from, so we can go back there if login fails\n if originator = request.env['omniauth.params']['originator'] # Remove any enclosing quotes\n originator.sub! /^\"?([^\"]*)\"?/, '\\\\1'\n end\n # Check for existing authorization\n @authentication = Authentication.find_by_provider_and_uid(omniauth['provider'], omniauth['uid'])\n (info = omniauth['info']) && (email = info['email']) && (user = User.find_by_email(email))\n intention = request.env['omniauth.params']['intention'] # If intention is 'signup', don't accept existing authentications\n if intention == \"signup\"\n if @authentication || user # This authentication method already in use\n flash[:notice] = \"That #{omniauth.provider.capitalize} login is already in use on RecipePower.<br>Perhaps you just need to sign in?\"\n response_service.amend originator\n url_to = originator\n else # No user and no authentication: perfect\n # Just create the account, getting what we can get out of the authorization info\n (user = User.new).apply_omniauth(omniauth)\n response_service.amend originator\n if user.save\n @authentication = user.authentications.create!(authparams) # Link authorization to user\n sign_in user, :event => :authentication\n response_service.user = user\n SignupEvent.post user # RpMailer.welcome_email(user).deliver\n flash[:notice] =\n %Q{Welcome to RecipePower, #{user.polite_name}! Introductory email is on its way. }\n url_to = after_sign_in_path_for(user)\n else\n # If user can't be saved, go back to edit params\n url_to = response_service.decorate_path(new_user_registration_url)\n end\n end\n # Intention is not signing up\n elsif current_user\n if @authentication # Authentication already in use\n if @authentication.user == current_user\n flash[:notice] = \"You're already connected through #{@authentication.provider_name}!\"\n else\n flash[:notice] = \"Sorry, your current #{@authentication.provider_name} login is tied to another RecipePower user.\"\n end\n else\n # Add the authentication method to the current user. We return to the authentications dialog\n current_user.apply_omniauth(omniauth)\n @authentication = current_user.authentications.create!(authparams) # Link to existing user\n flash[:notice] = \"Yay! You're now connected to RecipePower through #{@authentication.provider_name}.\"\n end\n url_to = origin_url\n elsif @authentication\n flash[:notice] = \"Yay! Signed in with #{@authentication.provider_name}. Welcome back, #{@authentication.user.handle}!\"\n sign_in @authentication.user, :event => :authentication\n response_service.amend originator\n url_to = after_sign_in_path_for(@authentication.user)\n # This is a new authentication (not previously linked to a user) and there is\n # no current user to link it to. It's possible that the authentication will come with\n # an email address which we can use to log the user in.\n elsif user\n user.apply_omniauth(omniauth)\n @authentication = user.authentications.create!(authparams) # Link to existing user\n sign_in user, :event => :authentication\n flash[:notice] = \"Yay! Signed in with #{@authentication.provider_name}. Nice to see you again, #{user.handle}!\"\n response_service.amend originator\n url_to = after_sign_in_path_for(user)\n end\n # We haven't managed to get the user signed in by other means, but we still have an authorization\n if !(current_user || user) # Failed login not because of failed invitation\n # The email didn't come in the authorization, so we now need to\n # discriminate between an existing user(and have them log in)\n # and a new user (and have them sign up). Time to throw the problem\n # over to the user controller, providing it with the authorization.\n session[:omniauth] = omniauth.except('extra')\n flash[:notice] = \"Hmm, apparently that service isn't linked to your account. If you log in by other means (perhaps you need to create an account?), you can link that service in Sign-In Services\"\n url_to = originator || new_user_session_path\n end\n # response_service.amend origin_url # Amend response expectations according to the originating URL\n render 'callback', :layout => false, :locals => { url_to: url_to }\n end", "def generate_authentication_token\n loop do\n token = Devise.friendly_token\n break token unless self.class.exists?(authentication_token: token)\n end\n end", "def apply_omniauth(omniauth)\n case omniauth['provider']\n when 'facebook'\n self.apply_facebook(omniauth)\n end\n authentications.build(:provider => omniauth['provider'], :uid => omniauth['uid'], :token =>(omniauth['credentials']['token'] rescue nil))\n end", "def create_from_oauth\n if stored_anonymous_user?\n user, from_registration = update_from_omniauth(env[\"omniauth.auth\"], params[:provider])\n else\n user, from_registration = create_from_omniauth(env[\"omniauth.auth\"], params[:provider])\n end\n\n if user.errors.any?\n redirect_to_registration_page(user)\n else\n change_global_user_id(user.id)\n sign_in(user)\n fandom_play_login(user)\n \n if from_registration\n log_data = { 'form_data' => env[\"omniauth.auth\"], 'user_id' => current_user.id }\n log_synced(\"registration from oauth\", adjust_user_and_log_data_with_utm(user, log_data))\n\n set_account_up()\n cookies[:from_registration] = true \n end\n\n if $site.force_facebook_tab && !request_is_from_mobile_device?(request)\n redirect_to request.site.force_facebook_tab\n else\n redirect_after_oauth_successful_login()\n end\n end\n end", "def apply_omniauth(omniauth)\n self.email = omniauth['info']['email'] if email.blank?\n self.username = omniauth['info']['name'] if username.blank?\n puts \"******************************\"\n puts omniauth\n puts \"******************************\"\n authentications.build(provider:omniauth['provider'], uid:omniauth['uid'])\n end", "def create_auth\n\t\t@auth = request.env['omniauth.auth']\n\t\tif User.where(:spotify_id => @auth[\"info\"][\"id\"]).first\n\t\t\t@user = User.where(:spotify_id => @auth[\"info\"][\"id\"]).first\n\t\telse\n\t\t\tif @auth[\"info\"][\"images\"][0][\"url\"] == \"\"\n\t\t\t\t@user = User.create(\n\t\t\t\t:display_name => @auth[\"info\"][\"display_name\"],\n\t\t\t\t:token => @auth[\"credentials\"][\"token\"],\n\t\t\t\t:refresh_token => @auth[\"credentials\"][\"refresh_token\"],\n\t\t\t\t:image_url => 'muziqala_logo.jpq',\n\t\t\t\t:spotify_id => @auth[\"info\"][\"id\"],\n\t\t\t\t:user_uri => @auth[\"info\"][\"uri\"]\n\t\t\t\t)\n\t\t\telse\n\t\t\t@user = User.create(\n\t\t\t\t:display_name => @auth[\"info\"][\"display_name\"],\n\t\t\t\t:token => @auth[\"credentials\"][\"token\"],\n\t\t\t\t:refresh_token => @auth[\"credentials\"][\"refresh_token\"],\n\t\t\t\t:image_url => @auth[\"info\"][\"images\"][0][\"url\"],\n\t\t\t\t:spotify_id => @auth[\"info\"][\"id\"],\n\t\t\t\t:user_uri => @auth[\"info\"][\"uri\"]\n\t\t\t\t)\n\t\t\tend\n\t\tend\n\t\tsession[:user_id] = @user.id\n\t\tredirect_to user_path(@user)\n\tend", "def ensure_authentication_token\n authorization = Authorization.where(:provider => 'devise', :customer_id => id.to_s).first_or_initialize\n\n if authorization.token.blank?\n #generate new token\n authorization.token = Devise.friendly_token\n end\n\n authorization.save\n end", "def create\n \n \n user = User.from_omniauth(env[\"omniauth.auth\"])\n session[:user_id] = user.id\n \n redirect_to root_path\n \n #render :text => auth_hash.inspect\n #raise request.env[\"omniauth.auth\"].to_yaml\n \n #Original\n # user=Authorization.find_by_provider_and_uid(auth[\"provider\"],auth[\"uid\"]) || Authorization.create_with_omniauth(auth)\n # #session[:user_id] = user.id\n #redirect_to root_path\n \n end", "def amniauth_create\n user = User.find_or_create_by(:provider => auth_hash[:provider], :uid => auth_hash[:uid]) do |user|\n user.name = auth_hash[:info][:name]\n end\n\n session[:user_id] = user.id\n redirect_to user_path(user)\n end", "def create\n omniauth = request.env[\"omniauth.auth\"]\n\n authentication = Authentication.find_by_provider_and_uid(\n omniauth['provider'],\n omniauth['uid']\n )\n\n if authentication\n\n sign_in_and_redirect(:user, authentication.user)\n\n elsif current_user\n current_user.authentications.create(:provider => omniauth['provider'],\n :uid => omniauth['uid'])\n flash[:notice] = \"Authentication with #{omniauth['provider']} was successful.\"\n redirect_to authentications_url\n else\n # New user\n user = User.new\n\n user.apply_omniauth(omniauth)\n if user.save\n check_event_entry user.authentications[0]\n sign_in_and_redirect(:user, user)\n else\n session[:omniauth] = omniauth.except('extra')\n redirect_to new_user_registration_url\n end\n end\n end", "def create\n\n\t\t# grab the authentication return\n\t\tauth = request.env[\"omniauth.auth\"]\n\n\t\t# now create a temporary user with the auth element etc\n\t\tuser = User.omniauth_create auth\n\n\t\t# now set the session_id \n\t\tsession[:id] = user.id\n\n\t\t# redirect back to the root which can successfully switch the pages of the application etc\n\t\tredirect_to root_url, :notice => \"Successful Authentication\"\t\n\tend", "def apply_omniauth(omniauth)\n authentications.build(:provider => omniauth['provider'], :uid => omniauth['uid'])\n end", "def create_with_facebook\n auth_hash = request.env['omniauth.auth']\n authorization = Authorization.find_by_provider_and_uid(auth_hash['provider'], auth_hash['uid'])\n name = auth_hash['info']['name'].split\n email = auth_hash['info']['email']\n first, last = name[0], name[1..-1].join(' ')\n user = User.find_by_first_name_and_last_name_and_email(first, last, email)\n\n # when both a user and an authorization have been found\n if authorization && user\n user.oauth_token = auth_hash['credentials']['token']\n user.save\n authorization.update_attribute 'user', user\n sessionize authorization.user\n\n # if only a user exists, build an authorization\n elsif user\n user.authorizations.build :provider => auth_hash['provider'], :uid => auth_hash['uid']\n sessionize user\n\n # No user or authorization; build them\n else\n user = User.new(:first_name => first, :last_name => last, :email => email)\n user.authorizations.build :provider => auth_hash['provider'], :uid => auth_hash['uid']\n user.save\n sessionize user\n end\n\n redirect_to root_path\n end", "def generate_authentication_token\n\t\tloop do\n\t\t\ttoken = SecureRandom.base64.tr('+/=', 'Qrt')\n\t\t\tbreak token unless User.exists?(authentication_token: token)\n\t\tend\n\tend", "def create\n auth = request.env[\"omniauth.auth\"]\n user = User.find_by_provider_and_uid(auth[\"provider\"], auth[\"uid\"]) || User.create_with_omniauth(auth)\n User.update(user.id, :fb_nickname => auth[\"info\"][\"nickname\"])\n session[:user_id] = user.id\n redirect_to root_url\n end", "def create\n\t # get the authentication parameter from the Rails router\n\t params[:provider] ? authentication_route = params[:provider] : authentication_route = 'No authentication recognized (invalid callback)'\n\n\t # get the full hash from omniauth\n\t omniauth = request.env['omniauth.auth']\n\t \n\t # continue only if hash and parameter exist\n\t if omniauth and params[:provider] == 'identity'\n\t # in the session his user id and the authentication id used for signing in is stored\n\t session[:identity] = omniauth['uid']\n\t redirect_to root_url, :notice => \"Signed in successfully.\"\n\t \n\t elsif omniauth and params[:provider]\n\t # create a new hash\n\t @authhash = Hash.new\n\t if authentication_route == 'google_oauth2'\n\t omniauth['info']['email'] ? @authhash[:email] = omniauth['info']['email'] : @authhash[:email] = ''\n\t omniauth['info']['name'] ? @authhash[:name] = omniauth['info']['name'] : @authhash[:name] = ''\n\t omniauth['uid'] ? @authhash[:uid] = omniauth['uid'].to_s : @authhash[:uid] = ''\n\t omniauth['provider'] ? @authhash[:provider] = omniauth['provider'] : @authhash[:provider] = ''\n\t else \n\t # debug to output the hash that has been returned when adding new authentications\n\t render :text => omniauth.to_yaml\n\t return\n\t end\n\t \n\t if @authhash[:uid] != '' and @authhash[:provider] != ''\n\t auth = Authentication.find_by_provider_and_uid(@authhash[:provider], @authhash[:uid])\n\t # if the user is currently signed in, he/she might want to add another account to signin\n\t if logged_in?\n\t if auth\n\t flash[:notice] = 'Your account at ' + @authhash[:provider].capitalize + ' is already connected with this site.'\n\t redirect_to authentications_path\n\t else\n\t current_user.authentications.create!(:provider => @authhash[:provider], :uid => @authhash[:uid], :uname => @authhash[:name], :uemail => @authhash[:email])\n\t flash[:notice] = 'Your ' + @authhash[:provider].capitalize + ' account has been added for signing in at this site.'\n\t redirect_to authentications_path\n\t end\n\t else\n\t if auth\n\t # signin existing user\n\t # in the session his user id and the authentication id used for signing in is stored\n\t session[:user] = auth.user.id\n\t session[:authentication_id] = auth.id\n\t \n\t flash[:notice] = 'Signed in successfully.'\n\t redirect_to root_url\n\t else\n\t # this is a new user; show signup; @authhash is available to the view and stored in the sesssion for creation of a new user\n\t if Rails.env == \"development\" or @authhash[:email].split('@').include?('intridea.com')\n\t session[:authhash] = @authhash\n\t render signup_authentications_path\n\t end\n\t # render signup_authentications_path\n\t end\n\t end\n\t else\n\t flash[:error] = 'Error while authenticating via ' + authentication_route + '/' + @authhash[:provider].capitalize + '. The authentication returned invalid data for the user id.'\n\t redirect_to login_path\n\t end\n\t else\n\t flash[:error] = 'Error while authenticating via ' + authentication_route.capitalize + '. The authentication did not return valid data.'\n\t redirect_to login_path\n\t end\n\t end", "def create\n omniauth = request.env[\"omniauth.auth\"]\n authentication = Authentication.find_by_provider_and_uid(omniauth['provider'], omniauth['uid'])\n initial_session(omniauth)\n\n if current_user\n if authentication #if such user with such SN already exists\n accounts_merge(authentication)\n sign_in_and_redirect(:user, authentication.user)\n else\n current_user.authentications.create(:provider => omniauth['provider'], :uid => omniauth['uid'])\n redirect_to authentications_path, :notice => t('authentication.succes')\n end\n elsif authentication\n flash[:notice] = t('authentication.signed_succes')\n sign_in_and_redirect(:user, authentication.user)\n else\n if User.find_by_email(omniauth['info']['email'])\n user = User.new(:email => omniauth['provider'] + \":\" +omniauth['info']['email'])\n else\n user = User.new(:email => omniauth['info']['email'])\n end\n user.authentications.build(:provider => omniauth['provider'], :uid => omniauth['uid'])\n set_profile(user, omniauth)\n user.save\n user.save(:validate => false)\n flash[:notice] = t('authentication.signed_succes')\n sign_in_and_redirect(:user, user)\n end\n end", "def create\n omniauth = request.env['omniauth.auth']\n authentication = Authentication.find_by_provider_and_uid(omniauth['provider'], omniauth['uid'])\n if authentication\n flash[:notice] = \"Signed in successfully\"\n sign_in_and_redirect(:user, authentication.user)\n else\n user = User.new\n user.apply_omniauth(omniauth)\n user.login = omniauth['info'] && omniauth['info']['nickname']\n if user.save\n flash[:notice] = \"Successfully registered\"\n sign_in_and_redirect(:user, user)\n else\n session[:omniauth] = omniauth.except('extra')\n session[:omniauth_login] = user.login\n\n # Check if login already taken. If so, ask user to link_accounts\n if user.errors[:login][0] =~ /has already been taken/ # omniauth? TBD\n # fetch the user with this login id!\n user = User.find_by_login(user.login)\n return redirect_to link_accounts_url(user.id)\n end\n redirect_to new_user_registration_url\n end\n end\n end", "def create\n # Store authentication hash from 3rd party web service \n omniauth = request.env['omniauth.auth']\n logger.debug \"\\n\\n\\t omniauth \\n\\n\"\n logger.debug omniauth\n\n \n # Attempt to find an existing authentication in the database\n authentication = Authentication.\n find_by_provider_and_uid(omniauth['provider'], omniauth['uid'])\n \n # handle returning user, new authentication for existing user, \n # or new user cases\n if authentication\n # we found an authentication in the database so\n # we know this is a returning user\n flash[:notice] = \"Signed in successfully\"\n # redirect to user's profile\n sign_in_and_redirect(:user, authentication.user)\n elsif current_user\n # We did not find a matching authentication in the \n # database but current_user is defined. This tells\n # us that a currently logged in user is adding a new\n # authentication method to their existing account.\n\n # build new authentication for current_user\n current_user.build_authentication(omniauth)\n\n flash[:notice] = \"Authentication successful\"\n # redirect to the page for managing authentications\n redirect_to authentications_url\n else\n # We did not find a matching authentication and there\n # is no current_user. So, we need to create a new User\n # and a new Authentication.\n\n # Find the invited user by the invitation_token\n user = User.accept_invitation!(:invitation_token => session[:invitation_token])\n\n # Build a new authentication\n user.build_authentication(omniauth)\n \n # try to save the user\n if user.save\n # if we pass the authentications redirect the new user\n # to the user's profile page\n flash[:notice] = \"Signed in successfully.\"\n sign_in_and_redirect(:user, user)\n else\n # if we did not pass the authentications (e.g. the new\n # user did not have an email address) we redirect to \n # the new_user_registration_url so that the new user\n # can give us the information that we need. This is where\n # we collect emails from people who sign up with LinkedIn or \n # Facebook.\n session[:omniauth] = omniauth.except('extra')\n redirect_to new_user_registration_url\n end\n end\n end", "def create\n auth = request.env[\"omniauth.auth\"]\n user = User.find_by_provider_and_uid(auth[\"provider\"], auth[\"uid\"]) || User.create_with_omniauth(auth)\n session[:user_id] = user.id\n redirect_to app_path\n end", "def generate_authentication_token\n loop do\n token = Devise.friendly_token\n break token unless User.where(authentication_token: token).first\n end\n end", "def generate_authentication_token\n loop do\n token = Devise.friendly_token\n break token unless User.where(authentication_token: token).first\n end\n end", "def generate_authentication_token\n loop do\n token = Devise.friendly_token\n break token unless User.where(authentication_token: token).first\n end\n end", "def generate_authentication_token\n loop do\n token = Devise.friendly_token\n break token unless User.where(authentication_token: token).first\n end\n end", "def generate_new_authentication_token\n token = User.generate_unique_secure_token\n update_attributes authentication_token: token\n end", "def apply_omniauth(omniauth)\n #add some info about the user\n self.login ||= omniauth['user_info']['nickname']\n self.picture_url = omniauth['user_info']['image']\n self.email ||= omniauth['user_info']['email']\n #self.nickname = omniauth['user_info']['nickname'] if nickname.blank?\n \n # unless omniauth['credentials'].blank?\n # user_tokens.build(:provider => omniauth['provider'], :uid => omniauth['uid'])\n # else\n user_tokens.build(:provider => omniauth['provider'], :uid => omniauth['uid'], \n :token => omniauth['credentials']['token'], :token_secret => omniauth['credentials']['secret'])\n # end\n #self.confirm!# unless user.email.blank?\n end", "def new\n @user = env['omniauth.identity'] ||= User.new\n\n #if signed_in?\n #@user = User.new\n #else\n #auth = session['auth']\n #@user = User.create_with_omniauth(auth)\n #end\n end", "def apply_omniauth(omniauth)\n # self.email = omniauth['info']['email'] if email.blank? # Twitter does not return an email\n authentications.build(provider: omniauth[\"provider\"], uid: omniauth[\"uid\"])\n end", "def generate_auth_token\n loop do \n token = SecureRandom.hex\n break token unless self.class.exists?(auth_token: token)\n end\n end", "def create_with_api\n @user = User.find_or_create_from_auth_hash(request.env[\"omniauth.auth\"])\n if @user\n session[:user_id] = @user.id\n redirect_to @user\n else \n flash.now[:danger] = \"Whoops, something went wrong!\"\n render 'new'\n end\n end", "def create\n omniauth = request.env['omniauth.auth']\n authentication = Authentication.find_by_provider_and_uid(omniauth['provider'], omniauth['uid'])\n if authentication\n flash[:notice] = \"Signed in successfully\"\n sign_in_and_redirect(:user, authentication.user)\n else\n user = User.new\n user.apply_omniauth(omniauth)\n user.email = omniauth['extra'] && omniauth['extra']['user_hash'] && omniauth['extra']['user_hash']['email']\n if user.save\n flash[:notice] = \"Successfully registered\"\n sign_in_and_redirect(:user, user)\n else\n session[:omniauth] = omniauth.except('extra')\n session[:omniauth_email] = omniauth['extra'] && omniauth['extra']['user_hash'] && omniauth['extra']['user_hash']['email']\n\n # Check if email already taken. If so, ask user to link_accounts\n if user.errors[:email][0] =~ /has already been taken/ # omniauth? TBD\n # fetch the user with this email id!\n user = User.find_by_email(user.email)\n return redirect_to link_accounts_url(user.id)\n end\n redirect_to new_user_registration_url\n end\n end\n end", "def omniauth \n\n @user = User.create_by_google_omniauth(auth)\n # @user = User.find_or_create_by(username: auth[:info][:email]) do |u| #moved this method to user model\n # u.password = SecureRandom.hex \n # end\n\n session[:user_id] = @user.id\n #if you havent set the password, it wont assign a userid, which means we won't have a user here to deal with\n redirect_to user_path(@user)\n\n #User.where(email: auth[:info][:email]).first_or_initialize\n #both .where method and .find_or_create_by method accomplish same thing\n \n end", "def create_from_omniauth(omniauth_hash)\n info_hash = omniauth_hash['info']\n return nil unless email = info_hash && info_hash['email']\n user = User.new\n user.credentials << Credentials::Email.new(email: email, verified: true)\n user.save!\n user\n end", "def create\n omniauth = env['omniauth.auth']\n\n user = User.find_by(uid: omniauth['uid'])\n unless user\n # New user registration\n user = User.new(uid: omniauth['uid'])\n end\n user.email = omniauth['info']['email']\n user.save\n\n # p omniauth\n\n # Currently storing all the info\n session[:user_id] = omniauth\n\n flash[:notice] = t(:successfully_logged_in)\n redirect_to root_path\n end", "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 create\n\t\t#get the user info\n\t\t\n\t\tauth = request.env[\"omniauth.auth\"]\n\t\tif auth == nil and \n\t\t\tif session[:temp] == true\n\t\t\t auth = {:info => {:email => \"jkoshakow@wesleyan.edu\"} }\n\t\t\telse\n\t\t\t auth = {:info => {:email => \"koshy44@gmail.com\"} }\t\n\t\t\tend\n\t\tend\n\t\t#whitelist \n\t\tif auth[:info][:email].to_s =~ /.+@wesleyan.edu/\n\t\t\tuser = User.find_by_uid(auth[\"uid\"]) || User.createUser(auth)\n\t\t\tsession[:user_id] = user.id \n\t\t\tsession[:admin] = user.admin\n\t\t\tsession[:authenticated] = true\n\t\t\tredirect_to links_path\n\t\telse\n\t\t\tsession[:authenticated] = false\n\t\t\tsession[:error] = \"Must have a wesleyan email address\"\n\t\t\tredirect_to root_path\n\t\tend\t\n\tend", "def create\n user = User.find_by(email: auth_params[:email])\n if user&.valid_password?(auth_params[:password])\n @token = user.api_tokens.find_or_create_by(name: (auth_params[:name] || \"default\")) do |token|\n token.make_token.save!\n end\n render json: {\n token: @token.token\n }\n else\n head :unauthorized\n end\n end", "def generate_auth_token\n self.auth_token = SecureRandom.hex\n end", "def create\n auth_hash = request.env['omniauth.auth']\n if auth_hash and auth_hash[:uid]\n username = auth_hash[:uid].split('@').first\n user = User.new.tap do |u|\n u.username = username\n end\n # `admin` is used in development.\n if user.username == 'admin' or user.medusa_admin?\n return_url = clear_and_return_return_path\n sign_in user\n # We can access other information via auth_hash[:extra][:raw_info][key]\n # where key is one of the shibboleth* keys in shibboleth.yml\n # (which have to correspond to passed attributes).\n redirect_to return_url\n return\n end\n end\n flash['error'] = sprintf('Sign-in failed. Ensure that you are a member '\\\n 'of the %s AD group.',\n ::Configuration.instance.medusa_admins_group)\n redirect_to root_url\n end", "def create_or_update_token(omniauth)\n # Update token if present\n if token\n token.update_attributes(\n twitter_id: omniauth.uid.to_i,\n token: omniauth.credentials.token,\n secret: omniauth.credentials.secret\n )\n # or create token\n else\n create_token do |t|\n t.twitter_id = omniauth.uid.to_i\n t.token = omniauth.credentials.token\n t.secret = omniauth.credentials.secret\n end\n end\n end", "def create_user(mobile = nil)\n session[:user_id] = nil\n session[:user_oauth_id] = nil\n\n auth = request.env[\"omniauth.auth\"]\n\n oauths = Authentication.where(:provider => auth[\"provider\"],\n :uid => auth[\"uid\"],\n :user_id.ne => nil,\n :master_id => @master.id).order(\"created_at desc\").all\n oauth = oauths.first\n oauths.drop(1).each do |oa|\n logger.error \"sessions#create_user: Removing extra authentications\"\n oa.destroy()\n end\n\n session[:master_id] = @master.id\n if oauth\n user = oauth.user\n if user != nil\n if @master != user.master\n # This is really bad.\n logger.error \"sessions#create_user: Authentication has mismatched master for user. Removing.\"\n oauth.destroy()\n redirect_to params[:failure_path] || root_path, :notice => \"Session Expired or Invalid. Please retry to sign in.\"\n return\n end\n session[:user_oauth_id] = oauth.id\n session[:user_id] = user.id\n oauth.last_info = auth[\"info\"]\n oauth.save\n if mobile\n redirect_to \"busme://oauthresponse?access_token=#{current_user.get_access_token}&master=#{@master.slug}\"\n else\n redirect_to master_active_path(user.master), :notice => \"Signed in!\"\n end\n else\n session[:user_oauth_id] = oauth.id\n redirect_to new_master_user_registration_path(@master, :mobile => mobile),\n :notice => \"Could not find you. Please create an account.\"\n end\n else\n oauth = Authentication.create_with_omniauth(auth)\n oauth.master = @master\n oauth.save\n session[:user_oauth_id] = oauth.id\n redirect_to new_master_user_registration_path( @master, :mobile => mobile),\n :notice => \"Need to create an account.\"\n end\n end", "def create\n user = User.find_for_authentication(email: user_params[:email])\n\n if user && user.valid_password?(user_params[:password])\n user.generate_authentication_token\n\n expose({\n user_id: user.id,\n token: user.authentication_token\n })\n else\n error! :unauthenticated\n end\n end", "def create_new_user_and_identity(auth, params)\n user = User.create!(\n first_name: auth.info[:first_name],\n last_name: auth.info[:last_name],\n email: auth.info[:email],\n oauth_signup: true,\n # referred_by_user_id => params.andand[\"rid\"]\n )\n user.confirm!\n create_new_identity(user, auth)\n end", "def ensure_authentication_token\n self.authentication_token ||= generate_authentication_token\n end", "def create\n auth = request.env[\"omniauth.auth\"] \n user = User.find_by_fb_id(auth[\"uid\"]) || User.create_with_omniauth(auth) \n #for those update from feeds\n if user.access_token.empty?\n user.access_token = auth[\"credentials\"][\"token\"]\n user.save\n end\n redirect_to FB_APP_URL \n end", "def oauth_signup\n @user = User.new(\n nickname: params[:nickname],\n sex: params[:sex],\n phone: params[:phone],\n birthday: params[:birthday],\n province: params[:province],\n city: params[:city],\n area: params[:area] )\n @user.created_by_oauth = 'mobile'\n @user.authentications.build(\n uid: params[:oauth_uid],\n provider: params[:provider],\n access_token: params[:access_token])\n if @user.save\n @user.confirm!\n render :login\n else\n render json: {\n success: false,\n message: @user.errors.messages\n }\n end\n end", "def generate_authentication_tokens\n self.client = Devise.friendly_token\n self.access_token = Devise.friendly_token\n end", "def create\n super do\n resource.authentication_token = Devise.friendly_token\n resource.save\n end\n end", "def ensure_authentication_token\n if authentication_token.blank?\n self.authentication_token = generate_authentication_token\n end\n end", "def create\n @user = ::Accounts::User.new data_params\n @user.ensure_authentication_token\n\n render_create @user, :with_token\n end", "def create\n\t\t@user = User.find_or_create_from_auth_hash(request.env[\"omniauth.auth\"])\n\t\tredirect_to(@@extension_url + '?access_token=' + @user.oauth_token)\n\tend", "def build_resource(*args)\n # Call the parent function to build the User model.\n super\n \n # If we have :omniauth in our session cookie we will build\n # an authentication for the new user from that and then \n # check to make sure the user is valid (i.e. get the password\n # from someone who created an account via LinkedIn or Facebook).\n if session[:omniauth]\n @user.build_authentication(session[:omniauth])\n @user.valid?\n end\n end", "def create\n # Where do we want to redirect to with our new session\n path = cookies.encrypted[:continue] || success_path\n\n # Get auth hash from omniauth\n auth = request.env[OMNIAUTH]\n\n if auth.nil?\n return login_failure({})\n end\n\n # Find an authentication or create an authentication\n auth_model = ::Auth::Authentication.from_omniauth(auth)\n\n # adding a new auth to existing user\n if auth_model.nil? && signed_in?\n logger.info \"User signed in and re-authenticating\"\n\n ::Auth::Authentication.create_with_omniauth(auth, current_user.id)\n redirect_to path\n Auth::Authentication.after_login_block.call(current_user, auth[PROVIDER], auth)\n\n # new auth and new user\n elsif auth_model.nil?\n args = safe_params(auth.info)\n user = ::User.new(args)\n\n # Use last name and first name by preference\n fn = args[:first_name]\n if fn && !fn.empty?\n user.name = \"#{fn} #{args[:last_name]}\"\n end\n\n authority = current_authority\n\n existing = ::User.find_by_email(authority.id, user.email)\n user = existing if existing\n user.deleted = false if user.respond_to?(:deleted)\n\n user.authority_id = authority.id\n\n # now the user record is initialised (but not yet saved), give\n # the installation the opportunity to modify the user record or\n # reject the signup outright\n result = Auth::Authentication.before_signup_block.call(user, auth[PROVIDER], auth)\n\n logger.info \"Creating new user: #{result.inspect}\\n#{user.inspect}\"\n \n if result != false && user.save\n # user is created, associate an auth record or raise exception\n Auth::Authentication.create_with_omniauth(auth, user.id)\n\n # make the new user the currently logged in user\n remove_session\n new_session(user)\n\n # redirect the user to the page they were trying to access and\n # run any custom post-login actions\n redirect_to path\n Auth::Authentication.after_login_block.call(user, auth[PROVIDER], auth)\n else\n logger.info \"User save failed: #{user.errors.messages}\"\n\n # user save failed (db or validation error) or the before\n # signup block returned false. redirect back to a signup\n # page, where /signup is a required client side path.\n store_social(auth[UID], auth[PROVIDER])\n redirect_to '/signup/index.html?' + auth_params_string(auth.info)\n end\n\n # existing auth and existing user\n else\n begin\n # Log-in the user currently authenticating\n remove_session if signed_in?\n user = User.find_by_id(auth_model.user_id)\n new_session(user)\n redirect_to path\n Auth::Authentication.after_login_block.call(user, auth[PROVIDER], auth)\n rescue => e\n logger.error \"Error with user account. Possibly due to a database failure:\\nAuth model: #{auth_model.inspect}\\n#{e.inspect}\"\n raise e\n end\n end\n end", "def apply_omniauth(omni)\n self.authentications.build(:provider => omni['provider'],\n :uid => omni['uid'],\n :token => omni['credentials']['token'],\n :token_secret => omni['credentials']['secret'])\n\n self.send(\"set_#{omni['provider']}_info\", omni)\n end", "def identity_create\n # Potential threat of overlap\n identity = Identity.create(uid:rand(100000000..9999999999), provider: 'registration')\n identity.user_id = resource.id\n identity.name = params['user']['name'] #Looks very ugly\n identity.email = resource.email\n identity.save\n end", "def apply_omniauth(omniauth)\r\n self.email = omniauth['user_info']['email'] if email.blank?\r\n authentications.build(:provider => omniauth['provider'], :uid => omniauth['uid'])\r\n end", "def ensure_authentication_token\n self.authentication_token ||= generate_authentication_token\n end", "def create\n email = params[:email]\n password = params[:password]\n fb_token = params[:fbtoken]\n if request.format != :json\n render :status => 406, :json => {:message => 'The request must be json'}\n return\n end\n\n if (email.nil? or password.nil?) && fb_token.nil?\n render :status => 400,\n :json => {:message => 'The request must contain the user email and password or FB token.'}\n return\n end\n\n if fb_token\n #check token\n begin\n facebook_graph = ::Koala::Facebook::API.new('595428443887130|BMCDixQJlECImLZsnnxGBO2jtoI')\n @token_info = facebook_graph.debug_token(fb_token)\n logger.info @token_info.inspect\n @user = User.find_by(fb_id: @token_info['data']['user_id'])\n rescue => e\n logger.error e.message\n @user = nil\n end\n else\n @user = User.find_by(email: email.downcase)\n end\n\n if @user.nil?\n logger.info(\"User #{email || fb_token} failed signin, user cannot be found.\")\n render :status => 401, :json => {:message => 'Invalid email or password or FB token.'}\n return\n end\n\n # http://rdoc.info/github/plataformatec/devise/master/Devise/Models/TokenAuthenticatable\n #@user.generate_authentication_token\n\n valid = (!fb_token && @user.valid_password?(password)) || (fb_token && @token_info['data']['app_id'] == '595428443887130')\n\n if valid\n @user.ensure_authentication_token\n logger.info 'Token: ' + @user.authentication_token.to_s\n @user.save_device_token(params[:device_token])\n render :status => 200, :json => {:token => @user.authentication_token, :email => @user.email, :premium => !@user.role?(:free)}\n else\n logger.info(\"User #{email} failed signin, password \\\"#{password}\\\" is invalid\")\n render :status => 401, :json => {:message => 'Invalid email or password or FB token.'}\n end\n end", "def add_omniauth(auth)\n self.authentications.find_or_create_by(\n provider: auth['provider'],\n uid: auth['uid'].to_s\n )\n end", "def create_oauth_user(name, email, token)\n User.from_omniauth(\n OpenStruct.new(\n info: OpenStruct.new(email: email, name: name), \n credentials: OpenStruct.new(refresh_token: token)\n )\n )\n end", "def create\n auth_hash = request.env['omniauth.auth']\n user = User.find_or_create_by(uid: auth_hash[\"uid\"], provider: auth_hash['provider'])\n user.update_attributes(\n name: auth_hash.info['name'],\n nickname: auth_hash.info['nickname'],\n email: auth_hash.info['email'],\n image: auth_hash.info['image'],\n access_token: auth_hash.credentials['token'])\n sign_in user\n if user\n redirect_to :gem_notes\n else\n render 'home/index'\n end\n end", "def create\n # get the authorization parameter from the Rails router\n params[:authorization] ? authorization_route = params[:authorization] : authorization_route = 'No authorization recognized (invalid callback)'\n # get the full hash from omniauth\n omniauth = request.env['omniauth.auth']\n #flash[:success] = omniauth['credentials']['token']\n # continue only if hash and parameter exist\n if omniauth and params[:authorization]\n\n # map the returned hashes to our variables first - the hashes differs for every authorization\n \n # create a new hash\n @authhash = Hash.new\n \n if authorization_route == 'facebook'\n omniauth['info']['email'] ? @authhash[:email] = omniauth['info']['email'] : @authhash[:email] = ''\n omniauth['info']['name'] ? @authhash[:name] = omniauth['info']['name'] : @authhash[:name] = ''\n omniauth['credentials']['token'] ? @authhash[:token] = omniauth['credentials']['token'] : @authhash[:token] = ''\n omniauth['credentials']['secret'] ? @authhash[:secret] = omniauth['credentials']['secret'] : @authhash[:secret] = ''\n omniauth['uid'] ? @authhash[:uid] = omniauth['uid'].to_s : @authhash[:uid] = ''\n omniauth['provider'] ? @authhash[:provider] = omniauth['provider'] : @authhash[:provider] = ''\n elsif authorization_route == 'google_oauth2'\n omniauth['info']['email'] ? @authhash[:email] = omniauth['info']['email'] : @authhash[:email] = ''\n omniauth['info']['name'] ? @authhash[:name] = omniauth['info']['name'] : @authhash[:name] = ''\n omniauth['credentials']['token'] ? @authhash[:token] = omniauth['credentials']['token'] : @authhash[:token] = ''\n omniauth['credentials']['secret'] ? @authhash[:secret] = omniauth['credentials']['secret'] : @authhash[:secret] = '' \n omniauth['uid'] ? @authhash[:uid] = omniauth['uid'].to_s : @authhash[:uid] = ''\n omniauth['provider'] ? @authhash[:provider] = omniauth['provider'] : @authhash[:provider] = '' \n elsif authorization_route == 'twitter'\n omniauth['info']['email'] ? @authhash[:email] = omniauth['info']['email'] : @authhash[:email] = (omniauth['info']['name']).gsub(\" \", \"_\")+'@twitter.com'\n omniauth['info']['name'] ? @authhash[:name] = omniauth['info']['name'] : @authhash[:name] = ''\n omniauth['credentials']['token'] ? @authhash[:token] = omniauth['credentials']['token'] : @authhash[:token] = ''\n omniauth['credentials']['secret'] ? @authhash[:secret] = omniauth['credentials']['secret'] : @authhash[:secret] = ''\n omniauth['uid'] ? @authhash[:uid] = omniauth['uid'].to_s : @authhash[:uid] = ''\n omniauth['provider'] ? @authhash[:provider] = omniauth['provider'] : @authhash[:provider] = ''\n elsif authorization_route == 'github'\n omniauth['user_info']['email'] ? @authhash[:email] = omniauth['user_info']['email'] : @authhash[:email] = ''\n omniauth['user_info']['name'] ? @authhash[:name] = omniauth['user_info']['name'] : @authhash[:name] = ''\n omniauth['credentials']['token'] ? @authhash[:token] = omniauth['credentials']['token'] : @authhash[:token] = ''\n omniauth['credentials']['secret'] ? @authhash[:secret] = omniauth['credentials']['secret'] : @authhash[:secret] = '' \n omniauth['extra']['user_hash']['id'] ? @authhash[:uid] = omniauth['extra']['user_hash']['id'].to_s : @authhash[:uid] = ''\n omniauth['provider'] ? @authhash[:provider] = omniauth['provider'] : @authhash[:provider] = '' \n elsif ['google', 'yahoo', 'myopenid', 'open_id'].index(authorization_route) != nil\n omniauth['info']['email'] ? @authhash[:email] = omniauth['info']['email'] : @authhash[:email] = ''\n omniauth['info']['name'] ? @authhash[:name] = omniauth['info']['name'] : @authhash[:name] = ''\n omniauth['credentials']['token'] ? @authhash[:token] = omniauth['credentials']['token'] : @authhash[:token] = ''\n omniauth['credentials']['secret'] ? @authhash[:secret] = omniauth['credentials']['secret'] : @authhash[:secret] = ''\n omniauth['uid'] ? @authhash[:uid] = omniauth['uid'].to_s : @authhash[:uid] = ''\n omniauth['provider'] ? @authhash[:provider] = omniauth['provider'] : @authhash[:provider] = ''\n else \n # debug to output the hash that has been returned when adding new authorizations\n render :text => omniauth.to_yaml\n return\n end \n \n if @authhash[:uid] != '' and @authhash[:provider] != ''\n \n auth = Authorization.find_by_provider_and_uid(@authhash[:provider], @authhash[:uid])\n\n # if the user is currently signed in, he/she might want to add another account to signin\n if signed_in?\n if auth\n flash[:notice] = 'Your account at ' + @authhash[:provider].capitalize + ' is already connected with this site.'\n redirect_to root_path\n else\n current_user.add_authorization(@authhash)\n flash[:notice] = 'Your ' + @authhash[:provider].capitalize + ' account has been added for signing in at this site.'\n redirect_to root_path\n end\n else\n if auth\n # signin existing user\n # in the session his user id and the authorization id used for signing in is stored\n sign_in_ auth.user\n #session[:authorization_id] = auth.id\n \n flash[:notice] = 'Signed in successfully via ' + @authhash[:provider].capitalize + '.'\n redirect_back_or root_url\n else\n # this is a new user; show signup; @authhash is available to the view and stored in the sesssion for creation of a new user\n #session[:authhash] = @authhash\n #render signup_authorizations_path\n #crappy way to bypass password requirement for user, potential loophole\n password = SecureRandom.hex\n user = User.new(name: @authhash[:name], email: @authhash[:email], password: password, password_confirmation: password)\n user.authorizations.build(provider: @authhash[:provider], uid: @authhash[:uid], token: @authhash[:token], secret: @authhash[:secret])\n user.save\n flash[:success] = \"Hi #{user.name}! You've signed up via #{@authhash[:provider]}.\"\n sign_in_ user\n redirect_back_or root_path \n end\n end\n else\n flash[:error] = 'Error while authenticating via ' + authorization_route + '/' + @authhash[:provider].capitalize + '. The authorization returned invalid data for the user id.'\n redirect_to signin_path\n end\n else\n flash[:error] = 'Error while authenticating via ' + authorization_route.capitalize + '. The authorization did not return valid data.'\n redirect_to signin_path\n end\n end", "def ensure_auth_token\n unless self.auth_token\n self.auth_token = User.generate_token\n end\n end", "def ensure_authentication_token\n if authentication_token.blank?\n self.authentication_token = generate_authentication_token\n end\n end", "def from_omniauth auth\n user = User.find_by email: auth.info.email\n\n user = User.new unless user.present?\n user.name = auth.info.name.present? ? auth.info.name : auth.info.email\n user.email = auth.info.email\n user.provider = auth.provider\n user.password = User.generate_unique_secure_token if user.new_record?\n user.token = auth.credentials.token\n user.refresh_token = auth.credentials.refresh_token\n user.save\n user\n end", "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 create\n auth_hash = request.env['omniauth.auth']\n\n @authorization = Authorization.find_by(\n provider: auth_hash[\"provider\"],\n uid: auth_hash[\"uid\"]\n )\n\n session[:user_id] = auth_hash[:uid]\n\n if @authorization\n redirect_to \"/games\"\n else\n @user = User.find_or_initialize_by(uid: auth_hash[:uid])\n @user.name = auth_hash[\"info\"][\"name\"]\n @user.save\n\n redirect_to games_url\n end\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 access_token\n User.create_access_token(self)\n end", "def find_or_create_for_omniauth auth, &block\n email = auth.info.email\n # This is just a placeholder for indexes and validations etc.\n # (twitter doesn't give us an email)\n email ||= \"#{auth.info.nickname || auth.uid}@#{auth.provider}.auth\"\n\n user = find_for_omniauth auth\n user ||= find_or_initialize_by email: email\n\n user.omniauth!(auth, &block) and user\n end" ]
[ "0.7944953", "0.7944953", "0.7944953", "0.7944953", "0.7916079", "0.7912612", "0.7912612", "0.7891473", "0.7885886", "0.78756183", "0.78655016", "0.7824129", "0.76585925", "0.76384014", "0.7603551", "0.7575889", "0.7527779", "0.7495971", "0.7456773", "0.7430941", "0.7403918", "0.7390097", "0.73364806", "0.7326686", "0.7280085", "0.72553605", "0.7236298", "0.7220029", "0.72009695", "0.71940446", "0.7189307", "0.7176834", "0.71644354", "0.7131054", "0.71153575", "0.70924157", "0.7069901", "0.70410955", "0.7040846", "0.7011314", "0.70060897", "0.7000517", "0.6957299", "0.6952031", "0.69389683", "0.6935583", "0.69346964", "0.693262", "0.6929858", "0.69292694", "0.68929106", "0.6868884", "0.6868884", "0.686519", "0.6864478", "0.68451124", "0.6829384", "0.6828313", "0.6825178", "0.68182576", "0.6815026", "0.68011665", "0.67993826", "0.67790246", "0.6778268", "0.6759922", "0.67562443", "0.6745282", "0.67428493", "0.6738467", "0.67323726", "0.67303246", "0.67295444", "0.67254686", "0.6724942", "0.6721661", "0.6715404", "0.6694354", "0.66904944", "0.66848236", "0.6679628", "0.6678513", "0.66732854", "0.6668355", "0.66565526", "0.6655614", "0.6653073", "0.66423464", "0.6640511", "0.6631317", "0.6627614", "0.6620022", "0.66179526", "0.6615528", "0.6608717", "0.65956944", "0.6589275", "0.6588824", "0.6579893", "0.6577491", "0.65720415" ]
0.0
-1
this allows you to have a gemwide layout
def index @translations = TRANSLATION_STORE end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def layouts; end", "def layouts; end", "def layout; end", "def set_layout\n if 1==1\n 'application'\n else\n 'dean'\n end\n end", "def place_in_layout?; end", "def place_in_layout?; end", "def layout\n lookup_layout\n end", "def determine_layout\n 'akinu'\n end", "def layout_contents\n @layout = <<-LAYOUT\n blueprint-deploy:\n layout: #{spec_bp_name} # name of the layout file we use\n blueprint : #{spec_bp_name} # name of the default blueprint\n servers:\n - server1:\n name: util\n applications:\n - app1:\n - app2:\n - server2:\n name: review\n applications:\n - app1:\n - app3:\n LAYOUT\n @layout\n end", "def determine_layout\r\n #\"earthlingtwo/earthlingtwo\"\r\n \"#{template_name}/#{template_name}\"\r\n end", "def layouts=(_arg0); end", "def layouts=(_arg0); end", "def layout\n nil\n end", "def set_layout\n @layoutme = 1\n end", "def layout\n @layout\n end", "def wiselinks_layout\n 'layouts/application'\n end", "def _implied_layout_name; end", "def layout\n case @mode\n when :injector\n \"injector\"\n when :page\n \"application\"\n else\n false\n end\n end", "def layout\n nil\n end", "def generate_layout\n if options.sass?\n directory 'app'\n gem 'compass', '>=0.10.5'\n gem 'compass-960-plugin', '>=0.10.0'\n directory 'config'\n else\n copy_file \"stylesheet.css\", \"public/stylesheets/#{file_name}.css\" if options.stylesheet?\n copy_file \"handheld.css\", \"public/stylesheets/handheld.css\" if options.stylesheet?\n end\n copy_file \"modernizr-1.5.min.js\", \"public/javascripts/modernizr-1.5.min.js\"\n copy_file \"jquery-1.4.2.min.js\", \"public/javascripts/jquery-1.4.2.min.js\"\n copy_file \"dd_belatedpng.js\", \"public/javascripts/dd_belatedpng.js\"\n\n template \"layout.html.erb\", \"app/views/layouts/#{file_name}.html.erb\"\n copy_file 'layout_helper.rb', 'app/helpers/layout_helper.rb'\n end", "def layout(sugar)\n # otherwise use standard layout for non moved residues?\n remove_layout(sugar)\n do_initial_layout(sugar)\n setup_scaling(sugar)\n seen_residues = do_chain_layout(sugar)\n seen_residues += do_stubs(sugar,seen_residues)\n do_basic_layout(sugar,seen_residues)\n do_box_layout(sugar)\n do_sibling_bunching(sugar)\n do_center_boxes_more(sugar)\n do_sibling_bunching(sugar)\n do_multi_residue_widening(sugar)\n class << sugar\n alias_method :uncondensed_box, :box\n def box\n box_block = lambda { |r|\n ! r.is_stub?\n }\n return uncondensed_box(&box_block)\n end\n end\n \n end", "def _conditional_layout?; end", "def layout\n self.class.layout || @app.layout\n end", "def site_layout\n File.join PATHS[:layouts], \"site_layout.html.erb\"\n end", "def layout_by_resource\n \"admin_layout\"\n end", "def layout\n \"application\"\n end", "def allow_layout?\n true\n end", "def layout \n return @layout\n end", "def render_layout(output, layout, info); end", "def admin_layout\n render layout: 'admin_layout'\n end", "def default_layout\n 'default' if html?\n end", "def admin_layout \n @admin_layout\n end", "def middleman_layout(name, opts = {}, &block)\n locs = opts.delete(:locals) || {}\n opts[:layout] ||= name\n\n res = self.class.app_resource\n res.render(opts, res.locals.merge(locs), &block)\n end", "def layout(name=:default, &block)\n @layouts[name] = block\n end", "def inject_into_layout\n application_layout_path_prefix = 'app/views/layouts/application.html'\n\n api_key = ask 'What is your kit ID (leave blank to specify later):'\n api_key = '- YOUR KIT ID HERE -' if api_key.blank?\n\n layout_templates = { slim: { content: \" = typekit '#{api_key}'\", after: \"head\\n\" }}\n layout_templates[:erb] = { content: \" <%#{layout_templates[:slim][:content].lstrip} %>\", after: \"<head>\\n\" }\n\n layout_templates.each_pair do |lang,options|\n path = ::File.join(destination_root, \"#{application_layout_path_prefix}.#{lang}\")\n if ::File.exists?(path)\n inject_into_file path, after: options[:after] do\n \"#{options[:content]}\\n\"\n end\n end\n end\n end", "def layout_by_resource\n if user_signed_in?\n # \"admin\"\n #else\n \"application\"\n end\n end", "def layout_file_name\n layout = \"application\"\n fail unless Content::Aggregator.original_content\n prepare_layout(layout)\n end", "def layout( content = nil )\n content ||= site\n doctype\n html {\n head {\n\n meta :name => 'description', :content => site['description']\n meta :name => 'verify-v1', :content => 'SJp07enRMbdu2hJ8AhT08Wc6OyTAGjtvxVzo7X1k83g='\n link :rel => 'alternate', :type => 'application/rss+xml', :href => 'http://feeds.feedburner.com/MouseTrap20'\n\n stylesheet content.stylesheet,\n 'syntaxhighlighter_2/styles/shCore',\n 'syntaxhighlighter_2/styles/shThemeDefault'\n\n javascript 'http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js',\n 'syntaxhighlighter_2/scripts/shCore',\n 'syntaxhighlighter_2/scripts/shBrushRuby',\n :site\n\n title content.title\n\n }\n body {\n sidebar {\n img( :src => paths(:image).get( 'banner.png' ) )\n block {\n welcome = model(:story).find(:sidebar)\n h4 welcome.title\n p { textile( welcome.content ) }\n }\n }\n page { yield }\n }\n }\n end", "def configure_layout\n contributable = (@workflow || @pack || @blob)\n layout = nil\n\n # For testing skins\n if params[\"layout_preview\"]\n layout = Conf.layouts[params[\"layout_preview\"]]\n # Skins on resources\n elsif contributable && contributable.contribution && contributable.contribution.policy\n if contributable.contribution.policy.layout\n layout = Conf.layouts[contributable.contribution.policy.layout]\n if layout.nil?\n logger.error(\"Missing layout for #{contributable.class.name} #{contributable.id}: \"+\n \"#{contributable.contribution.policy.layout}\")\n end\n end\n # Skins on groups, or when in a group context\n elsif (network = @network) || (@context.is_a?(Network) && (network = @context))\n layout = network.layout\n end\n\n # Check skin exists\n if layout && layout[\"layout\"] && !File.exists?(\"#{RAILS_ROOT}/app/views/layouts/#{layout[\"layout\"]}.html.erb\")\n logger.error(\"Missing layout #{RAILS_ROOT}/app/views/layouts/#{layout[\"layout\"]}.html.erb\")\n layout = nil\n end\n\n # Use default skin if all else fails\n if layout.nil?\n @layout = {\"layout\" => 'application', \"stylesheets\" => [Conf.stylesheet]}\n else\n @layout = layout\n end\n\n @layout[\"layout\"]\n end", "def theme; end", "def theme; end", "def theme; end", "def layout\n html do\n head do\n title 'TrackTime'\n end\n body do\n h1 \"welcome to tracktime\"\n div.content do\n self << yield\n end\n end\n end\n end", "def static_layout\n nil\n end", "def get_layout\n layout ||= Spree::Frontend::Config[:layout]\n end", "def _layout_for_option(name); end", "def layout( content = nil )\n content ||= site\n doctype\n html {\n head {\n\n meta :name => 'description', :content => site['description']\n meta :name => 'verify-v1', :content => 'SJp07enRMbdu2hJ8AhT08Wc6OyTAGjtvxVzo7X1k83g='\n link :rel => 'alternate', :type => 'application/rss+xml', :href => 'http://feeds.feedburner.com/MouseTrap20'\n\n stylesheet content.stylesheet\n javascript 'http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js', :site\n title content.title\n\n }\n body {\n page { \n banner { img( :src => paths(:image).get( 'banner.png' ) ) }\n main { yield }\n sidebar {\n block {\n welcome = model(:story).find(:sidebar)\n p { textile( welcome.content ) }\n }\n }\n }\n }\n }\n end", "def default_layout\n nil\n end", "def pre_layouts\n ['layouts/borders.yml', 'layouts/debug.yml']\n end", "def register_layout_setup\n @tab = :register\n end", "def layout_children\n \n end", "def layout_by_resource\n if user_signed_in?\n # \"admin\"\n #else\n \"application\"\n end\n end", "def page_layout\n @user = User.current\n @blocks = @user.pref.my_page_layout\n end", "def get_layout\n layout ||= Spree::Config[:layout]\n end", "def layout(layout_type)\n\t\t#most content. that is loaded into the artist content area (just content)\n\t\tif layout_type.nil? || layout_type.blank?\n\t\t\t@layout = false\n\t\t\t@hook = \"#content\"\n\t\t#when artist page has to be loaded (logo, nave and content)\n\t\telsif layout_type == \"artist\"\n\t\t\t@layout = \"layouts/artist_admin_and_artist_floating_content.html.erb\"\n\t\t\t@hook = \".dynamicContent\"\n\t\tend\n\tend", "def layout(model)\n #Rfm.layout(model.storage_name, options.symbolize_keys) #query.repository.adapter.options.symbolize_keys)\n model.layout\n end", "def no_layout?; end", "def layout()\n layout_children()\n end", "def admin_layout\n self.class.layout \"admin\" if current_user && admin?(current_user)\n end", "def _layout_for(name = nil)\n name ||= :layout\n view_flow.get(name).html_safe\n end", "def base_layouts\n ['layouts/constants.yml']\n end", "def app_layout\n layout_content = read_view :application, :folder => 'layouts' #, :type => :erb\n\n [:alert, :notice].each{|name| insert_flash_displayer name}\n end", "def home #uses default admin layout\n end", "def layout_for\n if devise_controller?\n 'full_page'\n else\n 'application'\n end\n end", "def scaffold_setup_helper\n engine :Erubis\n include ScaffoldingExtensions::Controller\n include ScaffoldingExtensions::RamazeController\n include ScaffoldingExtensions::Helper\n include ScaffoldingExtensions::PrototypeHelper\n unless trait[:layout] && trait[:layout][:all]\n layout(:scaffold_layout) \n define_method(:scaffold_layout){::Ramaze::Action.current.template = scaffold_path(:layout)}\n end\n end", "def get_layout\n layout ||= Amz::Config[:layout] \n layout = Amz::Config[:amp_layout] \n # layout = Amz::Config[:mobile_layout] if browser.mobile?\n # layout = Amz::Config[:tablet_layout] if browser.tablet?\n layout\n end", "def layout_list_with_engine_additions\n plugin_layouts = Rails.plugins.by_precedence.map do |p| \n File.join(p.root, \"app\", \"views\", \"layouts\")\n end\n layout_list_without_engine_additions + Dir[\"{#{plugin_layouts.join(\",\")}}/**/*\"]\n end", "def version\n render layout: \"layouts/full_page\"\n end", "def version\n render layout: \"layouts/full_page\"\n end", "def layout(name=:layout, &b)\n template(name, &b)\n end", "def layout_by_resource\n if devise_controller? && resource_name == :client\n 'public'\n else\n 'lims'\n end\n end", "def render_site_layout(&block)\n render current_alchemy_site, &block\n rescue ActionView::MissingTemplate\n warning(\"Site layout for #{current_alchemy_site.try(:name)} not found. Please run `rails g alchemy:site_layouts`\")\n \"\"\n end", "def layout_config\n @squeezed_layout_config\n end", "def build_layout\n year = Time.now.year\n add_call('Notification des abonnements électroniques', ->() { notifier })\n add_call(\"Extension des abonnements gratuits et d'échange de l'année #{year - 1}\", ->() { freesubs(year - 1) })\n add_call(\"Extension des abonnements gratuits et d'échange de l'année #{year}\", ->() { freesubs(year) })\n add_call('Création d\\'un abonnement collectif', ->() { collective_manager })\n add_call('Exploitation des abonnements collectifs', ->() { collective_exploitation })\n add_call('Recherche des tiers par facture', ->() { billing_manager })\n add_call('(Pour développeur) Fichiers de requête', ->() { sql_files })\n @layout.add_stretch\n end", "def user_layout_setup\n @tab = :user\n end", "def layout_full_center\n nil\n end", "def dashboard_h\n render :layout => 'application-h'\n end", "def _layout(*_arg0); end", "def dynamic_layout\n # ALL THIS SUCKS, I KNOW..\n \n # No layout for AJAX calls\n @layout = if request.xhr? \n nil\n # dialog param = lightview popup\n elsif params[:dialog]\n 'dialog'\n # uses user 'role' name for layout ... bad\n elsif current_user && !current_user.role.nil?\n current_user.role.downcase\n # no user, check for 'about' action\n elsif controller_name == 'about'\n 'about'\n # none of the above, use Rails default\n else\n 'home'\n end\n return nil unless @layout\n \n Rails.logger.debug \"Dyamic layout = #{@layout}\"\n # Layouts further divided by site subdomain: www vs vault\n if current_subdomain == 'vault'\n # Then public vs logged in...ugh\n if current_user\n @layout = 'vault/private/' + @layout\n else\n @layout = 'vault/public/' + @layout\n end\n end\n @layout\n end", "def kopal_layout_after_page_header\n\n end", "def layout(name=:layout, &block)\n return super(name, &block) if block_given?\n @_layout = name\n end", "def layout\n yield(monitoring_layout)\n monitoring_layout\n end", "def layout\n properties[:layout]\n end", "def layout_by_resource\n if devise_controller?\n 'admin'\n else\n 'application'\n end\n end", "def require_theme_deps; end", "def find_template(views, name, engine, &block)\n\t\t \t#normal\n\t\t super(views, name, engine, &block)\n\t\t #_layout folder\n\t\t super(Paths.layout_path, name.to_s, engine, &block)\n\t\t end", "def set_layout\n if %w( print plain ).include? params[:layout]\n params[:layout]\n else\n 'default'\n end\n end", "def kopal_layout_after_page_sidebar\n\n end", "def layout\n @current_layout ||= :default_layout\n send(\"#{@current_layout}\"){ yield }\n end", "def init\n @title_page = 'Pine app'\n erb :welcome, layout: :template\nend", "def layout_template_file(program:)\n template_file(\n template_name: program.layout_template_name,\n extension: :LAYOUT_EXT\n )\n end", "def layout=(_arg0); end", "def index\n super\n use_widgets do |root|\n root << jqg_top_widget('program')\n end\n render\n end", "def html_contents\n layout_contents\n end", "def layout_by_resource\n if devise_controller?\n \"admin\"\n else\n \"application\"\n end\n end", "def default_layout\n @default_layout ||= (\n IO.read(LIBDIR + \"/templates/layouts/page.mustache\")\n )\n end", "def layout\n yield(layout_for) if block_given?\n layout_for\n end", "def layout_by_resource\n if devise_controller?\n 'integral/login'\n else\n 'integral/backend'\n end\n end", "def layout_by_resource\n if devise_controller?\n 'integral/login'\n else\n 'integral/backend'\n end\n end", "def default_layout\n site.config.page_layout\n end", "def layout_by_resource\n if devise_controller?\n \"devise_layout\"\n else\n \"application\"\n end\n end" ]
[ "0.7322657", "0.7322657", "0.72663337", "0.69341785", "0.6756317", "0.6756317", "0.6700033", "0.6642863", "0.66199946", "0.66178036", "0.6592611", "0.6592611", "0.65076905", "0.6495358", "0.64934576", "0.6459209", "0.6453792", "0.64510304", "0.6444389", "0.64278203", "0.63888276", "0.6380612", "0.6379801", "0.62942135", "0.6281888", "0.6226938", "0.6224458", "0.6221556", "0.6207728", "0.6183941", "0.61770785", "0.617178", "0.6146427", "0.6134885", "0.6093984", "0.605067", "0.6048795", "0.60337216", "0.60304695", "0.60258937", "0.60258937", "0.60258937", "0.60230905", "0.60093266", "0.6008114", "0.599775", "0.59887445", "0.59880275", "0.59825224", "0.5979355", "0.59787446", "0.59708464", "0.59696096", "0.59667724", "0.5958321", "0.5947413", "0.5945861", "0.59357953", "0.5934459", "0.59325224", "0.59190667", "0.5910097", "0.5899003", "0.58879143", "0.5885809", "0.58820033", "0.5878429", "0.5873604", "0.5873604", "0.5867275", "0.58365387", "0.58102167", "0.5793478", "0.5789223", "0.5783543", "0.5781322", "0.57772756", "0.5769682", "0.5769194", "0.5766812", "0.57666117", "0.57605743", "0.57529294", "0.57456523", "0.57398915", "0.57371247", "0.5732562", "0.5731904", "0.5727402", "0.572435", "0.5718572", "0.57178193", "0.5708218", "0.5708053", "0.57064164", "0.5702838", "0.57005095", "0.56999373", "0.56999373", "0.56984454", "0.56966275" ]
0.0
-1
Sort by the follow list first and then based on score
def newsfeed posts = @@posts.map { |_, v| v } posts.sort do |a, b| if @follows[a.username] && !@follows[b.username] -1 elsif !@follows[a.username] && @follows[b.username] 1 else a <=> b end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sort_using_rank\n score[1]\n end", "def sort\n @hits = all.sort {|x,y| y.score <=> x.score }\n end", "def sorted_results(unsorted)\n scores = []\n sorted = []\n\n unsorted.group_by(&:itself).each_pair do |result, results|\n relevance = result_relevance(result, results.length)\n new_index = scores.bsearch_index { |val| val < relevance }\n # if this result has the lowest score, add it to the end\n new_index ||= -1 \n\n scores.insert(new_index, relevance)\n sorted.insert(new_index, result.first)\n end\n sorted\n end", "def sorted_scores\n self.object.teams.map {|team| team.score}.sort.reverse\n end", "def sort_teams_and_adjs\n @teams.sort! { |a,b| b.calc_rank <=> a.calc_rank }\n @adjs.sort! { |a,b| b.score <=> a.score }\n\n #@teams.sort! { |a,b| b.score <=> a.score } #allows sorting by score only\n #expression is flipped in terms of a and b\n #therefore we have decending in teams by score\n end", "def player_sort()\n\t\tsession[:player].sort {|a, b| a.total_score <=> b.total_score }\n\tend", "def sort_scores(unsorted_scores, highest_possible_score)\n array = []\n array << highest_possible_score\n unsorted_scores.sort.reverse.each { |score| array << score }\nend", "def create_leaderboard(team_scorecard)\n #sort scorecard first by wins in decending order\n #sort scorecard then by ties in decending order\n #sort scorecard last by losses in ascending order\n team_scorecard.sort_by {|team_info| [-team_info[1][:wins], -team_info[1][:ties], team_info[1][:losses]]}\nend", "def sort\n @items.sort { |x,y| x.rank <=> y.rank }\n end", "def sort_items_by_descending_scores_and_ascending_timestamp(items)\n items.sort! {|a, b| a['timestamp'] <=> b['timestamp']}\n items.sort! {|a, b| b['score'] <=> a['score']}\nend", "def create_leaderboard(team_scorecard)\n #sort scorecard first by wins in decending order\n #sort scorecard then by ties in decending order\n #sort scorecard last by losses in ascending order\n team_scorecard.sort_by! {|team_info| [team_info[1][:wins], team_info[1][:ties], -team_info[1][:losses]]}.reverse!\nend", "def sort_related_posts(related_scores)\n related_scores.sort do |a,b|\n if a[1] < b[1]\n 1\n elsif a[1] > b[1]\n -1\n else\n b[0].date <=> a[0].date\n end\n end.collect {|post,freq| post}\n end", "def sort_companies(companies)\n companies.sort_by do |company|\n company.score\n end.reverse\n end", "def ordered_by_qualifications(candidates)\n\n candidates.sort_by{ |candidate| [-candidate[:years_of_experience], -candidate[:github_points]] }\n\nend", "def sort_related_posts(related_scores)\n related_scores.sort do |a, b|\n if a[1] < b[1]\n 1\n elsif a[1] > b[1]\n -1\n else\n b[0].date <=> a[0].date\n end\n end.collect { |post, _freq| post }\n end", "def ordered_by_qualifications(candidates)\n candidates.sort {|candidate1, candidate2| candidate1[:years_of_experience] == candidate2[:years_of_experience]? candidate2[:github_points] <=> candidate1[:github_points] : candidate2[:years_of_experience] <=> candidate1[:years_of_experience]}\nend", "def ordered_by_qualifications(candidates)\n sortedCandidates = candidates.sort_by! { |candidate| [candidate[:years_of_experience], candidate[:github_points]] }\n return sortedCandidates.reverse! \nend", "def ordered_by_qualifications(candidates)\n candidates.sort_by{ |candidate| [candidate[:years_of_experience], candidate[:github_points]] }\n .reverse\n\nend", "def ordered_by_qualifications(candidates)\n candidates.sort_by {|candidate| [-candidate[:years_of_experience], -candidate[:github_points]]}\nend", "def lowest_score\n sort\n all.last.score\n end", "def ordered_by_qualifications (collection)\n collection.sort_by {|x| [x[:years_of_experience], x[:github_points]]}.reverse!\nend", "def ordered_by_qualifications(candidates)\n if [:years_of_experience] == [:years_of_experience]\n @candidates.sort_by { |experience| experience[:years_of_experience] }.reverse\n else\n @candidates.sort_by { |github| github[:github_points]}.reverse\n end\nend", "def sort_scores(unsorted_scores, highest_possible_score)\n\n # array of 0s at indices 0..highest_possible_score\n score_counts = [0] * (highest_possible_score+1)\n\n # populate score_counts\n unsorted_scores.each do |score|\n score_counts[score] += 1\n end\n\n # populate the final sorted array\n sorted_scores = []\n\n # for each item in score_counts\n score_counts.each_with_index do |count, score|\n\n # for the number of times the item occurs\n (0...count).each do |time|\n\n # add it to the sorted array\n sorted_scores.push(score)\n end\n end\n\n return sorted_scores\nend", "def sort_group_scores(groups, attr)\n groups\n .map(&:group_scores).flatten # collect all group scores\n .sort_by(&attr).reverse\n end", "def ordered_by_qualifications(candiates)\n # Candidates with the most experience are at the top\n return candiates.sort_by { | obj | [obj[:years_of_experience], obj[:github_points]] }\n # return candiates.sort! { |a, b| b[:years_of_experience] <=> a[:years_of_experience] }\n\n # return candiates.sort_by {|:years_of_experience, :github_points|[ :github_points, :years_of_experience]}\n\n # return candiates.sort { | a, b | }\n # array.sort { |a,b| [ a[1], a[0] ] <=> [ b[1], b[0] ] }\n\n\n # For Candidates that have the same years of experience, \n #they are further sorted by their number of Github points (highest first)\nend", "def stable_sort_by(list); end", "def ordered_by_qualifications(candidates)\n\n return @candidates.sort_by{ |candidate| [candidate[:years_of_experience], candidate[:github_points]] }\n\nend", "def sort_scores(unsorted_scores, highest_possible_score)\n arr = []\n unsorted_scores.each do |score|\n if arr[score]\n arr[score] += 1\n else\n arr[score] = 1\n end\n end\n \n output = []\n arr.each_with_index do |num, idx|\n if num\n num.times { |_| output.unshift(idx)}\n end\n end\n output\nend", "def leaderboard\n # TODO: there's probably a smart way to do this in DM\n User.all.map do |u|\n s = u.best_submission_for(self)\n [u, s] if s\n end.compact.sort_by { |u,s| [s.score, s.created_at] }\n end", "def ordered_by_qualifications(candidates)\n myArray = candidates\n #first sort by github points\n myArray.sort! { |a, b| a[:github_points] <=> b[:github_points] }\n #sort by experience\n myArray.sort! { |a, b| a[:years_of_experience] <=> b[:years_of_experience] }\n\n return myArray\nend", "def ordered_by_qualifications(candidates)\n ordered_by_qualification = [] #creates an empty array for the candidates\n years_of_experience = candidates.sort { |a, b| [a[:years_of_experience], a[:github_points]] <=> [b[:years_of_experience], b[:github_points]] }\n ordered_by_qualification << years_of_experience.reverse\n return ordered_by_qualification\nend", "def sort_relevant_rules\r\n # sort array in rule priority order\r\n @relevant_rules = @relevant_rules.sort do |r1, r2| \r\n r2.priority <=> r1.priority \r\n end\r\n end", "def sort_ranking\n @sorted_hash = @hash_ranking.sort_by { |_name, points| -points }\n @sorted_hash = @sorted_hash.first(10)\n @sorted_hash.map { |k, v| \"#{k}\\t#{v}\" }.join(\"\\n\")\n end", "def sort(unsorted, highest)\n\t# create a hash for each unsorted score\n scores_occurances = {}\n # result array\n sorted_scores = []\n # walk over the unsorted array and add 1 to our hash for each occurance\n unsorted.each do |score| \n \tif(scores_occurances.has_key?(score))\n\t \tscores_occurances[score] += 1\n\t else\n\t \tscores_occurances[score] = 1 \n\t end\n end\n\n (1..highest).each do |int|\n \tif(scores_occurances.has_key?(int))\n scores_occurances[int].times { sorted_scores.push(int) }\n end\n end\n \n sorted_scores\nend", "def ordered_by_qualifications(candidates)\n ordered_candidates = candidates.sort_by { |candidate| [candidate[:years_of_experience], candidate[:github_points]] }\n return (ordered_candidates).reverse\n\n # @ordered_by_qualifications = []\n\n # candidates.each do |candidate|\n # years_exp s=candidate[:years_of_experience]\n # @ordered_by_qualifications << years_exp\n # if years_exp == years_exp += 1\n # candidate[:github_points] > candidate[github_points] += 1\n # end \n \n # end\n # return @ordered_by_qualifications.sort!.reverse\n #This line returns the values 12..1 \n # return @ordered_by_qualifications.sort!.reverse\nend", "def top_10 (matches)\n matches.sort_by! { |match| match['score'] }.reverse[:10]\nend", "def sorted_affinities\n unless @sorted_affinities\n @sorted_affinities = hash_pidurl_affinity.collect { |product_idurl, affinity| affinity }\n @sorted_affinities.sort! { |a1, a2| a2.measure <=> a1.measure }\n current_ranking = 0; previous_measure = nil\n @sorted_affinities.each do |affinity|\n if affinity.measure != previous_measure\n current_ranking += 1\n previous_measure = affinity.measure\n end\n affinity.ranking = current_ranking\n end\n end\n @sorted_affinities\n end", "def get_next list\n if list.length < 1 then nil end\n\n nxt = list[0]\n list.each do |item|\n if item[:score] < nxt[:score] then\n nxt = item\n end\n end\n\n nxt\nend", "def sort_games\n games.order(:score).limit(5)\n end", "def placings\n score_ordering = low? ? :asc : :desc\n\n scores.order(disqualified: :asc)\n .order(participated: :desc)\n .order(tier: :asc)\n .order(score: score_ordering)\n .order(tiebreaker_place: :asc)\n end", "def tournament_players_sorted_by_prestige\n TournamentPlayer.where(:tournament_id => self.id).order(\"prestige DESC\").order(\"match_points DESC\")\n end", "def sort_searched_tweets(tweets)\n word_scores = []\n scores = tweets.map do |t|\n score = 0\n score, str = score_for_tweet(t)\n word_scores << str\n score\n end\n tweets = tweets.map.with_index.sort_by { |t, index| -scores[index] }.map(&:first)\n word_scores = word_scores.map.with_index.sort_by { |t, index| -scores[index] }.map(&:first)\n [tweets, word_scores]\n end", "def ordered_by_qualifications(candidates)\n begin\n sorted = candidates.sort_by { |candidate| [candidate[:years_of_experience], candidate[:github_points]] }\n sorted.reverse!\n rescue\n puts \"There must be a years of experience and github points key.\"\n end\nend", "def sort_by_rating(nearby_places)\n nearby_places.sort_by! {|place| place.values[0][:rating]}\n\n nearby_places.reverse\nend", "def get_scores\r\n items_db = DYNAMODB.scan(table_name: TABLE_NAME).items\r\n items_hash = make_result_list(items_db)\r\n items = items_hash.sort_by { |hash| hash['score'] }\r\n make_response(HttpStatus::OK, items.reverse().first(10))\r\nend", "def sort\n self.roster.each do |grade, students|\n students.sort!\n end\n self.roster\n end", "def sort_scores_arr(unsorted_scores, highest_possible_score)\n score_counts = [0] * (highest_possible_score + 1)\n\n unsorted_scores.each do |score|\n score_counts[score] += 1\n end\n\n sorted_scores = []\n\n i = HIGHEST_POSSIBLE_SCORE\n\n while i >= 0\n count = score_counts[i]\n unless count > 0\n i = i - 1\n end\n count.times { sorted_scores << i }\n i = i - 1\n end\n\n sorted_scores\nend", "def appearence_order(candidates, mention)\n positions = candidates.collect{|code, score, name|\n next unless @synonyms[code]\n pos = nil\n @synonyms[code].each_with_index{|list,i|\n next if pos\n pos = i if list.include? mention\n }\n pos \n }\n\n return nil if positions.compact.empty?\n\n best = candidates.zip(positions).sort{|a,b| \n case\n when (a[1].nil? and b[1].nil?)\n 0\n when b[1].nil?\n 1\n when a[1].nil?\n -1\n else\n a[1] <=> b[1]\n end\n }.first[1]\n candidates.zip(positions).select{|p| p[1] == best}\n end", "def cards_by_score\n scores = {}\n\n @cards.each do |card|\n scores[card] = card.score\n end\n\n Hash[scores.sort_by { |card, score| -score }]\n\n end", "def sort_results(results, weights)\n results.sort_by {|item| weights[item.name] }.reverse\n end", "def parse_score_leaders()\n users = []\n $redis.scan_each(:match => \"user_score:*\"){ |key| user_id = key.gsub(\"user_score:\", \"\"); users << { :user_id => user_id, :score => get_user_score(user_id), :user_name => get_slack_name(user_id) } }\n finalists = []\n if users.size > 0\n users.each do |user|\n if user[:score] >= 1\n finalists.push(user)\n end\n end\n finalists = finalists.uniq{ |f| f[:user_id] }.sort{ |a, b| b[:score] <=> a[:score] }.slice(0, 100)\n end\n finalists\nend", "def ordered_by_qualifications(array)\n\nloop do \n swapped = false\n for i in 0...(array.length-1)\n if array[i][:years_of_experience] > array[i+1][:years_of_experience]\n array[i], array[i+1] = array[i+1], array[i]\n swapped = true\n end\n end\n break if not swapped\nend\n\nloop do \n swapped = false\n for i in 0...(array.length-1)\n if array[i][:years_of_experience] == array[i+1][:years_of_experience]\n if array[i][:github_points] > array[i+1][:github_points]\n array[i], array[i+1] = array[i+1], array[i]\n swapped = true\n end\n end\n end\n break if not swapped\nend\n array.reverse\n\nend", "def sort_scores_hash(unsorted_scores, highest_possible_score)\n score_counts = {}\n unsorted_scores.each do |score|\n score_counts[score] = 0 unless score_counts[score]\n score_counts[score] += 1\n end\n\n sorted_scores = []\n i = HIGHEST_POSSIBLE_SCORE\n while i >= 0\n unless score_counts[i]\n i = i - 1\n next\n end\n\n score_counts[i].times { sorted_scores << i }\n i = i - 1\n end\n\n sorted_scores\nend", "def get_scores\n scores = get_from_url(@scores_conn, SCORES_KEY, {})\n scores.sort! {|a, b| a['date_time'] <=> b['date_time']}\n scores.reverse!\n scores.sort! {|a, b| a['score'] <=> b['score']}\n scores.reverse!\n end", "def sort_using(xs, sidebar)\n # caching is possible but doesn't improve significantly the build times\n\n rank_lookup = rank_lookup_from_sidebar(sidebar)\n\n xs.sort {|x, y|\n # The default rank is very high so that pages that don't appear in the sidebar are put at the end\n rx = rank_lookup[x.url] || 10000\n ry = rank_lookup[y.url] || 10000\n\n rx <=> ry\n }\n\n end", "def sort_naively(players)\n players.group_by(&:rating).sort.reverse.map do |rb|\n rb[1].group_by(&:team_rating).sort.reverse.map do |tb|\n tb[1].group_by(&:conf_rating).sort.reverse.map do |cb|\n cb[1].group_by(&:id).sort.reverse.map do |ib|\n ib[1]\n end\n end.flatten\n end.flatten\n end.flatten\nend", "def candidates_above_default\n Array(@ranking[0...@default_rank]).flatten.sort\n end", "def best(n)\n @score.sort{|a,b| b[1][0] <=> a[1][0]}[0..n-1]\n end", "def sorted_scores(unsorted_scores, highest_score)\n score_counts = Array.new(101, 0) # 101 because it has to be inclusive of 100\n\n unsorted_scores.each do |score|\n score_counts[score] += 1\n end\n\n sorted_scores = []\n\n highest_score.downto(0) do |score|\n count = score_counts[score]\n\n count.times do |_time|\n sorted_scores.push(score)\n end\n end\n\n sorted_scores\nend", "def display_stories stories\n #Double the score for each title with \"cat\" or \"dog\" in the title.\n cat_dog(stories)\n\n stories.sort_by! { |story| story[:score] }\n\n stories.reverse!\n\n stories.each do |story|\n # \"Title: title, Category: category, Upvotes: score\"\n puts \"Title: #{story[:title]}, Category: #{story[:category]}, Upvotes: (#{story[:score]})\"\n end\nend", "def rate_order\n infos = []\n self.matches.each do |match|\n infos += match.score_infos\n end\n infos = infos.sort_by{|x| x[3]}.reverse\n return infos.map{|x| \"#{x[0]}(#{\"%3.2f\" % x[3].to_f} @ #{x[2]}位)\"}\n end", "def ordered_results_for_student(student_object)\n completed_results = student_object.all_completed_performances\n ordered_results = completed_results.order(student_score: :desc)\n return ordered_results\nend", "def game_players_by_points\n game_players.sort_by{|game_player| [-game_player.points, game_player.player.email.downcase]}\n end", "def answer(unsorted_scores, highest_possible_score)\n score_counts = [0] * (highest_possible_score + 1) # array of 0's at indices 0..highest_possible_score\n unsorted_scores.each { |score| score_counts[score] += 1 } # populate score_counts\n sorted_scores = [] # populate the final sorted_scores\n highest_possible_score.downto(0) do |score|\n count = score_counts[score]\n (0...count).each { |time| sorted_scores << score }\n end\n return sorted_scores\nend", "def sort_ranks(_ranks)\n raise NotImplementedError\n end", "def highest_score\n sort\n all.first.score\n end", "def sort\n @sort ||= Vidibus::Words.sort_by_occurrence(list)\n end", "def sort_by_most_recently_popular(experiences)\n\t\tsorted = experiences.sort_by do |experience|\n\t\t\t(ONE_VOTE * experience.rating) + experience.created_at.to_i\n\t\tend.reverse\n\tend", "def rank(result_array)\n # Highest first.\n return result_array.sort_by{ |hash| - hash[:score] + (hash[:enabled]==false ? 10 : 0) }\n end", "def sort\n @roster.each do |grade, studen_name|\n studen_name.sort!\n end\n end", "def get_score_leaders(options = {})\n options = { :limit => 10, :order => \"desc\" }.merge(options)\n leaders = []\n $redis.scan_each(:match => \"user_score:*\"){ |key| user_id = key.gsub(\"user_score:\", \"\"); leaders << { :user_id => user_id, :score => get_user_score(user_id)} }\n if leaders.size > 1\n if options[:order] == \"desc\"\n leaders = leaders.uniq{ |l| l[:user_id] }.sort{ |a, b| b[:score] <=> a[:score] }.slice(0, options[:limit])\n else\n leaders = leaders.uniq{ |l| l[:user_id] }.sort{ |a, b| a[:score] <=> b[:score] }.slice(0, options[:limit])\n end\n else\n leaders\n end\nend", "def proefssorted\n \tproefs.order(:position)\n end", "def options_by_score\n self.options.sort{ |x, y| y.score <=> x.score }\n end", "def sorted_gems\n # sort with putting gems without average_score at the end\n @gems.sort do |a, b|\n if a.average_score && b.average_score\n a.average_score <=> b.average_score\n else\n a.average_score ? -1 : 1\n end\n end\n end", "def rank(hits)\n\t\thits = Search.fill_meta(hits)\n\t\t\n\t\thits.each do |h|\n\t\t\th[:distance] = distance(query, h[:object].display)\n\t\t\th[:score] = h[:distance] * HIT_WEIGHT_SIMILARITY + \n\t\t\t h[:popularity] * HIT_WEIGHT_POPULARITY\n\t\tend\n\t\t\n\t\thits = hits.sort_by { |h| -1 * h[:score] }\n\tend", "def popularity_list\n @movie_list.values.sort{|a,b| b.popularity <=> a.popularity}\n end", "def filter_and_sort_players(filters)\n self.players.where(filters).sort do |a, b|\n \n #\n # get scores\n #\n a_score = a.score\n b_score = b.score\n \n # \n # if the scores are the same sort based on the first\n # team to get to the current score\n # \n if a_score == b_score\n \n #\n # get solved challenges\n #\n future_date = Time.now + 100.years\n a_most_recent = a.solved_challenges.order(:created_at).last\n a_date = (a_most_recent) ? a_most_recent.created_at : future_date\n b_most_recent = b.solved_challenges.order(:created_at).last\n b_date = (b_most_recent) ? b_most_recent.created_at : future_date\n \n #\n # if both teams have solved challenges\n #\n if a_date == b_date\n a.display_name <=> b.display_name\n else\n a_date <=> b_date\n end\n \n #\n # sort based on score\n #\n else\n b_score <=> a_score\n end\n end\n end", "def priority_sort(result_list, free_bandwidth)\n priority_list = result_list.sort\n new_results = []\n priority_index = 0\n priority_list.each_index do |i|\n result = \"PASSED\"\n priority_index = priority_list[i].slice!(/^\\d+/).to_i\n bc = priority_list[i].split(\"|\")[0].unpack(\"a2a2a2\")\n if bc[2] == \"BF\"\n # fails if minimum failed and it's the top priority stream\n result = \"FAILED\" if bc[0] == \"YM\" && i == 0\n # fails if minimum failed and there was free bandwidth\n result = \"FAILED\" if bc[0] == \"YM\" && free_bandwidth > 0\n # fails if the bandwidth is over maximum specified\n result = \"FAILED\" if bc[1] == \"YN\"\n end\n new_results << priority_list[i].split(\"|\")[1].insert(0, \"[#{priority_index >= 0 ? sprintf(\"%d\", priority_index) : \"NONE\"}] [#{result}] \")\n end\n return new_results\nend", "def sort_by_popularity\n @song_data = @song_data.sort_by {|x| [-x[:plays], x[:index]] }\n end", "def sort_my_list\n @tracks.clear\n @artists.clear\n @genres.clear\n @user_list.each do |item|\n @tracks << item['id'] if item['type'] == 'track'\n @artists << item['id'] if item['type'] == 'artist'\n @genres << item['name'].downcase if item['type'] == 'genre'\n end\n end", "def get_scores\n items = DYNAMODB.scan(table_name: TABLE).items\n sort_items_by_descending_scores_and_ascending_timestamp(items)\n make_result_list(items)\nend", "def analyze_most_generic(item_key, score_value, doc_key)\n # unless the value is bigger than the minimum to make the list, return\n return unless analyze_most_greater_than_min?(score_value, doc_key)\n\n doc = DocumentStore.get_document(doc_key)\n\n list = doc[:list]\n\n in_list = false\n\n # go through list and see if user is already in the list, if so, update the score\n list.each do |u|\n if u[0] == item_key\n u[1] = score_value\n in_list = true\n break\n end\n end\n\n # if user wasn't in the list, add them to the end\n unless in_list\n list.push([item_key, score_value])\n end\n\n # now sort the list by comparing prolific score\n list.sort! { |x,y| y[1] <=> x[1]}\n\n # if we added to the list, trim it back to size\n if list.size > MOST_LIST_SIZE\n list.slice!(0, MOST_LIST_SIZE)\n end\n\n # save minimum value to be in list (speeds value-checks up), for floats, multiple by 10000 to preserve enough significant digits, and convert to integer\n if list.last[1].is_a? Float\n DocumentStore.force_set_document(doc_key + \"::min\", (list.last[1] * 10000).to_i)\n else\n DocumentStore.force_set_document(doc_key + \"::min\", list.last[1].to_i)\n end\n\n # copy modified list back to doc\n doc[:list] = list\n\n # replace list in Couchbase\n DocumentStore.replace_document(doc_key, doc)\n end", "def scoreboard\n teams.sort { |team1, team2| team1.score == team2.score ? team1.name <=> team2.name : team2.score <=> team1.score }.each_with_object([]) do |team, scoreboard|\n scoreboard << { name: team.name, score: team.score, goals: team.goals }\n end\n end", "def leader\n self.players.order(score: :desc).first\n end", "def sort_if_needed(deliverables)\n if session[@sort_name] && %w(score spent progress labor_budget).include?(session[@sort_name][:key])\n case session[@sort_name][:key]\n when \"score\" then\n sorted = deliverables.sort {|a,b| a.score <=> b.score}\n when \"spent\" then\n sorted = deliverables.sort {|a,b| a.spent <=> b.spent}\n when \"progress\" then\n sorted = deliverables.sort {|a,b| a.progress <=> b.progress}\n when \"labor_budget\" then\n sorted = deliverables.sort {|a,b| a.labor_budget <=> b.labor_budget}\n end\n\n return sorted if session[@sort_name][:order] == 'asc'\n return sorted.reverse! if session[@sort_name][:order] == 'desc'\n else\n return deliverables\n end\n end", "def determine_winner\n @active_players.sort! do |player1, player2|\n if player1.strongest_hand > player2.strongest_hand\n -1\n elsif player1.strongest_hand < player2.strongest_hand\n 1\n else\n 0\n end\n end\nend", "def candidates_below_default\n Array(@ranking[@default_rank+1...@ranking.length]).flatten.sort\n end", "def sort_points(args)\n points\n .sort_by { |point| point[:distance] }\n .first(args[:k])\n .map do |point|\n point[:weight] = calc_point_weight(args[:weight], point[:distance])\n point\n end\n end", "def sort\n @pokers.sort.reverse\n end", "def sort_if_needed\n @rules.sort! unless @sorted\n @sorted = true\n end", "def sort\n sorted_list = {}\n @roster.each do |grade, student|\n sorted_list[grade] = student.sort\n end\n return sorted_list\n end", "def order_by_value\n @hand = @hand.sort_by{|card| card.point }\n end", "def compare_further p1hand, p2hand, rank, secondary\n p1values = p1hand.map{|c| $value_map[c[0]]}.sort\n p2values = p2hand.map{|c| $value_map[c[0]]}.sort\n # no further comparison if it's a straight\n return 0 if rank == 9 || rank == 8 || rank == 4\n if rank == 7 # four of a kind\n comp1 = (p1values[0] == secondary ? p1values[4] : p1values[0])\n comp2 = (p2values[0] == secondary ? p2values[4] : p2values[0])\n return 1 if comp1 > comp2\n return 2 if comp2 > comp1\n return 0\n end\n if rank == 6 # full house\n comp1 = (p1values - [secondary]).uniq[0]\n comp2 = (p2values - [secondary]).uniq[0]\n return 1 if comp1 > comp2\n return 2 if comp2 > comp1\n return 0\n end\n if rank <= 5 # all remaining ranks\n comp1 = (p1values - [secondary]).uniq.reverse\n comp2 = (p2values - [secondary]).uniq.reverse\n comp1.each_with_index do |e,i|\n return 1 if e > comp2[i]\n return 2 if comp2[i] > e\n end\n return 0\n end\nend", "def sort\r\n @roster.each do |key, value|\r\n value.sort!\r\n end\r\n end", "def filter_and_sort_players(filters)\n players.where(filters).sort do |a, b|\n #\n # get scores\n #\n a_score = a.score\n b_score = b.score\n\n #\n # if the scores are the same sort based on the first\n # team to get to the current score\n #\n if a_score == b_score\n\n #\n # get solved challenges\n #\n future_date = Time.zone.now + 100.years\n a_most_recent = a.solved_challenges.order(:created_at).last\n a_date = a_most_recent ? a_most_recent.created_at : future_date\n b_most_recent = b.solved_challenges.order(:created_at).last\n b_date = b_most_recent ? b_most_recent.created_at : future_date\n\n #\n # if both teams have solved challenges\n #\n if a_date == b_date\n a.display_name <=> b.display_name\n else\n a_date <=> b_date\n end\n\n #\n # sort based on score\n #\n else\n b_score <=> a_score\n end\n end\n end", "def sort_votes(list)\n list.sort_by! { |option| option.vote } # Sorts the list by the vote attribute of each option\n list.reverse! # Reverses the list because it naturally sorts ascending order\nend", "def sort_votes(list)\n list.sort_by! { |option| option.vote } # Sorts the list by the vote attribute of each option\n list.reverse! # Reverses the list because it naturally sorts ascending order\nend", "def stories_sorted_by_growth_rate\n stories = @stories.values.sort_by do |story|\n story.growth_rate\n end\n stories.reverse\n end", "def ordered_results_for_activity(activity_object)\n all_results_for_activity = Result.where({\"activity_id\" => activity_object.id}).where.not({\"student_score\" => nil})\n ordered_results = all_results_for_activity.order(student_score: :desc)\n return ordered_results\n end", "def top_matches(n=3)\n \n scores = Array.new\n \n @prefs.each_pair do |key,value|\n if key != @person\n scores << [@similarity.compute(key),key]\n end\n end\n \n (scores.sort!.reverse!)[0..n]\n \n end", "def sort(array:)\n return [] unless array.present? && array.is_a?(Array)\n\n # Sort the results by score + weight + name\n array.sort do |a, b|\n # left = [a[:weight], a[:score], a[:sort_name]]\n # right = [b[:weight], b[:score], b[:sort_name]]\n [a[:weight], a[:sort_name]] <=> [b[:weight], b[:sort_name]]\n end\n end" ]
[ "0.7518348", "0.73827475", "0.67644227", "0.6711024", "0.66596", "0.66506", "0.66304684", "0.6618273", "0.66063637", "0.6534374", "0.6513551", "0.64678913", "0.6459505", "0.64507", "0.64472705", "0.6446873", "0.64281577", "0.64167196", "0.6407793", "0.64047974", "0.6399341", "0.63987625", "0.6395552", "0.6354393", "0.63226086", "0.62549746", "0.62484527", "0.62430334", "0.6242557", "0.62342846", "0.6218783", "0.618963", "0.61853147", "0.61327684", "0.61324334", "0.61272985", "0.6104157", "0.6100538", "0.6088516", "0.60778016", "0.60705745", "0.6067408", "0.60438013", "0.603145", "0.6015839", "0.60106367", "0.6008842", "0.6003535", "0.5997699", "0.5996627", "0.59913117", "0.59809256", "0.5971909", "0.597133", "0.5971232", "0.5969011", "0.5962622", "0.5959499", "0.59565645", "0.59489226", "0.59441376", "0.59272194", "0.5927191", "0.59071505", "0.58963346", "0.5894786", "0.58878237", "0.5881626", "0.5880675", "0.5871934", "0.5863236", "0.5854009", "0.5852328", "0.5851144", "0.58469456", "0.58394694", "0.5838464", "0.5838343", "0.58268845", "0.5825178", "0.58215654", "0.58194137", "0.5809264", "0.57915175", "0.57898146", "0.5777056", "0.5766739", "0.5764443", "0.5751802", "0.57491213", "0.57318956", "0.5724347", "0.5719015", "0.57175547", "0.5713437", "0.5710717", "0.5710717", "0.5679791", "0.5678302", "0.56728905", "0.56718796" ]
0.0
-1
... and delegate "everything else" via method_missing, taking care that a nil card template isn't a problem
def method_missing(name, *args, &block) respond_to_missing?(name) ? card_template.andand.send(name, *args, &block) : super end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def method_missing(method, *args, &block)\n if @card.respond_to?(method)\n @card.send(method, *args, &block)\n else\n super\n end\n end", "def default_card\n # noop\n end", "def get_card\n end", "def get_card_data method\n get_card.send(method) rescue nil\n end", "def method_missing(code, *args, &blk); end", "def method_missing(code, *args, &blk); end", "def method_missing(method_name, *arguments)\n @value ? super : Representations.representation_for(nil, @template, method_name, self)\n end", "def card_detection\n end", "def method_missing(method_sym, *args, &block)\n return nil\n end", "def method_missing(*)\n invertable nil\n end", "def method_missing(method_id) #search for method, if it doesn't have it go up the chain, doesn't find it, and comes back and finds method missing\n singular_currency = method_id.to_s.gsub( /s$/, '') #if there is an 's' at the end take it out \n if @@currencies.has_key?(singular_currency) #check if we have the currency \n self * @@currencies[singular_currency] # This multiplys the self by the multiplier, creates a method on the fly\n else\n super #just return the super\n end\n end", "def method_missing(id, *attr, &block); end", "def method_missing(name, *args, &block); end", "def method_missing(name, *args, &block); end", "def method_missing(name, *args, &block); end", "def method_missing(name, *args, &block); end", "def valid_card(card_type: T.unsafe(nil)); end", "def method_missing(*args, &block); end", "def method_missing(name, *args); end", "def method_missing(name, *args); end", "def method_missing(method, *args, &block); end", "def method_missing(method, *arguments, &block); end", "def method_missing(*)\n return nil\n end", "def method_missing(method, *args, &blk); end", "def method_missing(*args, &block)\n @template.send(*args, &block)\n end", "def method_missing(*args, &block)\n @template.send(*args, &block)\n end", "def method_missing(*args, &block)\n @template.send(*args, &block)\n end", "def method_missing(method_name, *args); end", "def method_missing(method_name, *args); end", "def method_missing(sym, *args, &block)\n # if match = sym.to_s.match(/^not_(.+)/)\n # sym = match[1]\n eval(\"Healing::Structure::#{sym.to_s.camelcase}\").new @target, *args, &block\n end", "def card_factory(unformatted_cards)\n unformatted_cards.each do |hash|\n add_cards_to_deck(Card.new(hash))\n end \n end", "def method_missing(mth, *args, &block); end", "def method_missing(*args)\n puts \"YOU CAN'T DO THAT\"\n end", "def action_missing(*)\n end", "def place(card)\n end", "def method_missing(meth, *args); end", "def method_missing(method_sym, *arguments, &block)\n if self[\"#{method_sym.to_s}\"] != nil\n self[\"#{method_sym.to_s}\"]\n else\n super\n end\n end", "def method_missing(meth, *args, &block); end", "def method_missing(meth, *args, &block); end", "def method_missing(meth, *args, &block); end", "def method_missing(*)\n nil\n end", "def method_missing(meth, *args, &block)\n\n end", "def initialize(format = UprightCard.new)\n @format = format\n @card_data = pick_card\n end", "def method_missing(action, *args, &block)\n return nil\n end", "def invalid_card(card_error: T.unsafe(nil)); end", "def deal_card!(cards)\n\nend", "def method_missing(method_called)\n raise StandardError, \n \"Method \\\"#{method_called}\\\" does not exist for Display class: #{@type}\"\n end", "def method_missing(name)\n return nil\n end", "def method_missing(sym, *argv, &argb)\n if @sprite.respond_to?(sym)\n return @sprite.send(sym, *argv, &argb)\n end\n super(sym, *argv, &argb)\n end", "def method_missing(*args, &block)\n @template.send(*args, &block)\n end", "def method_missing(method_sym, *arguments)\n\n if method_sym.to_s =~ DECORATOR_METHOD_SIGNATURE\n # Strip off the decorator and see who can handle the real request\n actual_method_sym = method_sym.to_s[4..-1]\n if (asset_fleet_type.groups.include? actual_method_sym) || (asset_fleet_type.custom_groups.include? actual_method_sym) || (asset_fleet_type.label_groups.include? actual_method_sym)\n typed_asset = Asset.get_typed_asset(active_assets.first)\n typed_asset.try(actual_method_sym)\n end\n else\n puts \"Method #{method_sym.to_s} with #{arguments}\"\n # Pass the call on -- probably generates a method not found exception\n super\n end\n end", "def method_missing(m, *a, &b)\n\ta.empty? ? m : super\nend", "def hcard(record, options = {})\n h = {} \n case record\n when User\n user = record\n h[:fn] = user.name\n h[:tel] = user.phone\n h[:email] = user.email\n h[:url] = user_url(user)\n when Label\n label = record\n h[:org] = true\n h[:fn] = label.name\n h[:tel] = label.phone\n h[:email] = label.email\n h[:url] = label_url(label)\n when Artist\n return \"\"\n else\n raise \"Record of type '#{record.class}' cannot be represented as hCard\"\n end\n \n content_tag(:div,\n (h[:org] ? content_tag(:span, link_to(content_tag(:span, h[:fn], :class => 'fn org'), \n h[:url], :class => 'url')) :\n content_tag(:span, link_to([content_tag(:span, h[:fn].first, :class => 'given-name'), \n content_tag(:span, h[:fn].last, :class => 'family-name')].join(' '), \n h[:url], :class => 'url'), \n :class => \"fn n\")) +\n content_tag(:span, \n content_tag(:span, 'work', :class => 'type hide') +\n content_tag(:span, number_to_phone(h[:tel]), :class => 'value'),\n :class => 'tel') +\n content_tag(:span, \n content_tag(:span, 'work', :class => 'type hide') +\n mail_to(h[:email], h[:email], :encode => :javascript, :class => 'value'), \n :class => 'email'),\n :class => ['vcard', options[:class]].join(' '))\n end", "def card\n false\n end", "def method_missing(method_name, *args) self end", "def method_missing(method_name, *args) self end", "def method_missing(:name, *args)\nend", "def define_suit(card)\n # Good luck\nend", "def method_missing(*rest) end", "def default_card\n Card.find_by_class_name!(self.class.name)\n end", "def method_missing(meth, *args, &blk)\n meth.to_s == 'id' ? super : chargeable_unit_properties.send(meth, *args, &blk)\n rescue NoMethodError\n super\n end", "def add_card_without_revealing_details(card)\n player.add_card_to_hand(card)\n message = \"#{player.name} drew a card from the center.\"\n game.players.each {|player| player.send_message_to_user(message)}\n end", "def method_missing(selector, *args, &block); end", "def method_missing(meth, *args, &block)\n if @template.respond_to?(meth)\n @template.send(meth, *args)\n else\n super\n end\n end", "def method_missing(meth, *args, &block)\n if @template.respond_to?(meth)\n @template.send(meth, *args)\n else\n super\n end\n end", "def card_identifier\n raise 'card_identifier must be overwritten by the child class'\n end", "def method_missing(name, *args, &block)\n @@template.send(name, *args, &block)\n end", "def method_missing(name, *args, &block)\n #puts \"RSHelper method_missing called; name = #{name.inspect}; #{name.class}\"\n\n case name.to_s\n when /^rs/i, /^google/\n RSPages.find(name.to_s) # return the page so that the helper-method can use it\n else\n super\n end\n end", "def method_missing(method, *args, &block)\n super(method, *args) unless block_given?\n options, attrs, element = (args.detect { |arg| arg.is_a?(Hash) } || {}), {}, nil\n\n # handle methods separately if they match the pre-defined elements\n if ELEMENTS.include?(method.to_sym)\n attrs, element = options, method\n else \n attrs, element = { :class => method.to_s.downcase.gsub('_', options[:glue] || ' ') }, :div \n end\n \n wrapper(element, attrs, @template.capture(&block), block.binding)\n end", "def method_missing(method, *args, &block) \n return super unless part(method)\n part(method).render\n end", "def method_missing(wh,*therest)\n # xxx internal methods must be protected at some point\n end", "def method_missing(method, *args, &block)\n if template_defined?(method)\n expand(method, *args, &block)\n else\n super\n # action(method, *args, &block)\n end\n end", "def method_missing name, *named, **ordered, &block\n #log \"method #{name} missing on #{@name}\"\n capability_name = name[0..-2].to_sym\n params = RBCM::Params.new named, ordered\n if not @@capabilities.include? capability_name\n super\n elsif name =~ /\\!$/\n return # never call cap! diectly\n elsif name =~ /\\?$/\n __search capability_name, params, &block\n end\n end", "def report_card variant\n return if variant.blank?\n @report_cards ||= {}\n @report_cards[variant] ||= begin\n rcard = Card.new name: name.trait(:report_search), type_id: Card::SearchTypeID\n # note: #new is important here, because we want different cards\n # for different variants\n rcard.variant = variant\n rcard\n end\nend", "def method_missing(m, *args, &block)\n end", "def method_missing(method_name, *args)\n if m = method_name.to_s.match(/\\A(\\w+)_(label|Label)\\Z/)\n customer_label(m[1], :titleize => m[2] == \"Label\")\n elsif respond_to?(method_name)\n try(method_name.to_s, *args)\n else\n super(method_name, *args)\n end\n end", "def method_missing(name, *args, &block)\n if abilities.key?(name)\n if TRUE_FLAGS.include?(abilities[name])\n true\n elsif FALSE_FLAGS.include?(abilities[name])\n false\n else\n if self.class === abilities[name]\n abilities[name]\n else\n abilities[name] = self.class.new(abilities[name], true) # true for subcan\n end\n end\n else\n if subcan\n false\n else\n # If not exist a key(resource) then mock a key with a blank can instance, so\n # we can call chain like this: <tt>can.resource_name.read # => false</tt>\n abilities[name] = self.class.new({}, true)\n end\n end\n end", "def method_missing(symbol, *args)\n super(symbol, *args) if @enemy.nil?\n @enemy.method(symbol).call(*args)\n end", "def method_missing(name, *args, &block)\n if @obj.respond_to?(name)\n @obj.send(name, *args, &block)\n elsif templates.key?(name.to_s)\n render(name)\n else\n super\n end\n end", "def method_missing(method, *args)\n child_resource_template = resource_template.find_by_rel(method.to_s).first\n if child_resource_template && (child_class = child_class_for(self, method, params, child_resource_template))\n positional_params, params_hash = extract_params(args, params)\n complete_params_hash!(params_hash, child_resource_template.positional_params(resource_template), positional_params)\n child(child_class, method, params_hash, child_resource_template)\n else\n super\n end\n end", "def method_missing(method)\n \"N/A\"\n end", "def respond_to_missing?( id, priv = false ) id != :call; end", "def method_missing(method, *args, &block)\n if (stars.key?(method) || stars[type].key?(method)) && args.length == 0\n stars[method] || stars[type][method]\n else\n super\n end\n end", "def method_missing(m, *args, &block)\n # ignore\nend", "def method_missing(symbol, *args, &block)\n constructor = :element\n text = symbol.to_s\n\n if text =~ /!\\z/\n text.chop!\n constructor = :element!\n elsif text =~ /\\?\\z/\n text.chop!\n constructor = :anonymous\n end\n\n if text =~ /_$/ # alternate for clashes with existing methods\n text.chop!\n end\n\n if text =~ /_/\n # Single _ gets converted to : for XML name spaces\n # Double _ gets converted to single _\n text = text.gsub(/([^_])_([^_])/){|x| \"#{$1}:#{$2}\"}.gsub(/__/, '_')\n end\n\n if self != Jig::XML and self != Jig::XHTML\n namespace = name.split('::').last.downcase\n text = \"#{namespace}:#{text}\"\n end\n send(constructor, text, *args, &block)\n end", "def play_card(card)\n puts 'begin playcard id :' + card.id.to_s\n if self.respond_to?(card.name.gsub(' ','_'), true)\n update_attributes(played_card_id: card.id)\n self.send(card.name.gsub(' ','_'), nil)\n else\n puts 'No card played! gamemanager couldnt find details for ' + card.cardmapping.name\n end\n end", "def card_label\n end", "def method_missing(name, *args, &blk)\n self\n end", "def method_missing(method, *args)\n self.person.send(method, *args) if self.person\n end", "def card\n if self.stripe_card_id.present?\n customer.sources.retrieve(self.stripe_card_id)\n else\n create_card\n end\n end", "def method_missing(method, *params)\n # if the method is one of known - just skip it ...\n return if [:comment, :attlistdecl, :notationdecl, :elementdecl, \n :entitydecl, :cdata, :xmldecl, :attlistdecl, :instruction, \n :doctype].include?(method)\n # ... else - call super to raise an exception\n super(method, params)\n end", "def from_hcard()\n end", "def initialize(cards = Deck.all_cards)\n end", "def method_missing(undefined_meth_yet,*args,&block)\n \"#{self.class.to_s} doesn't know how to perform :#{undefined_meth_yet}\"\n end", "def card_image\n false\n end", "def method_missing(*args)\n default\n end", "def respond_to_missing?(*_args); super; end", "def show\n set_card\n end", "def method_missing(meth, *args, &block)\n if !(meth.to_s =~ /=/) and (suffixed_method = \"#{meth.to_s}__c\") and respond_to?(suffixed_method)\n send(suffixed_method)\n else\n super\n end\n end", "def method_missing(method, *args)\n child_resource_template = resource_templates_by_name[method.to_s]\n if child_resource_template && (child_class = child_class_for(self, method, params, child_resource_template))\n positional_params, params_hash = extract_params(args, params)\n complete_params_hash!(params_hash, child_resource_template.positional_params(nil), positional_params)\n child(child_class, method, params_hash, child_resource_template)\n else\n super\n end\n end" ]
[ "0.7059851", "0.65993464", "0.6114283", "0.59664536", "0.5779522", "0.5779522", "0.5755772", "0.57497287", "0.5702806", "0.5657755", "0.56481373", "0.5642659", "0.56303084", "0.56303084", "0.56303084", "0.56303084", "0.5611988", "0.5561731", "0.5558175", "0.5558175", "0.5507013", "0.5489852", "0.54794306", "0.54708683", "0.54637086", "0.54637086", "0.54637086", "0.54555106", "0.54555106", "0.5451896", "0.5433491", "0.5426848", "0.54080117", "0.54036075", "0.539499", "0.53909737", "0.53904593", "0.536519", "0.536519", "0.536519", "0.53510404", "0.53393257", "0.5339168", "0.5334756", "0.5327507", "0.5321867", "0.5317494", "0.5313373", "0.53102547", "0.53052765", "0.5287561", "0.527431", "0.5268406", "0.5263439", "0.52631384", "0.52631384", "0.52627003", "0.52592003", "0.52589595", "0.5246498", "0.5232731", "0.5229139", "0.520105", "0.5196383", "0.5196383", "0.5187429", "0.51749265", "0.51633507", "0.5158255", "0.5147805", "0.51433784", "0.5142172", "0.5138586", "0.51269877", "0.51231235", "0.5121604", "0.511392", "0.5113276", "0.5112548", "0.51101923", "0.5099751", "0.5098157", "0.5095504", "0.5086105", "0.5079967", "0.5078451", "0.50769114", "0.50644034", "0.50557315", "0.505501", "0.50545794", "0.5049195", "0.5029022", "0.5026868", "0.50264", "0.5022497", "0.50190544", "0.50053006", "0.50047344", "0.5003005" ]
0.78657037
0
requires login for new and create actions only+
def new # render login page end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n #user wants to log in \n end", "def new\n #user wants to log in \n end", "def new\n # If someone is already logged in, skip this step\n login(current_user) and return if logged_in?\n end", "def create?\n #everyone who is loggedin can do this action\n true\n end", "def new #login page\n end", "def require_login\n end", "def authorise\n unless User.find_by_id(session[:user_id]) || (self.controller_name == 'users' && (self.action_name == 'new' || self.action_name == 'create'))\n session[:original_uri] = request.request_uri\n flash[:notice] = \"Please login!\"\n redirect_to login_url\n end\n end", "def new\n attempt_login\n redirect_to root_path if logged_in?\n end", "def new\n render :new\n endl\n\n def create\n user = User.find_by_credentials(\n params[:user][:user_name],\n params[:user][:password]\n )\n\n if user.nil?\n flash.now[:errors] = [\"Invalid username or password\"]\n render :new\n else\n login!(user)\n redirect_to cats_url\n end\n end\n\n def destroy\n logout!\n redirect_to new_session_url\n end\n\nend", "def login; end", "def create\n if request.get? && params[:action] == 'new' && @open_auth\n @open_auth.open_authentication.connection_established\n log_in @open_auth.open_authentication.user\n redirect_back_or_default user_newsfeed_url(@open_auth.open_authentication.user)\n end\n end", "def create\n if params[:login]\n self.login\n else\n self.add\n end\n end", "def show\n # Authorizing that only logged in users can see that new\n authorize @new\n end", "def login\n end", "def login\n end", "def login\n end", "def login\n end", "def login\n end", "def login\n end", "def login\n end", "def login\n end", "def login\n end", "def login\n end", "def login\n\tend", "def login\n\n end", "def login\n\n end", "def new\n if logged_in?\n redirect_to admin_url\n end\n end", "def create?\n # false # no access\n user.present? # minimum requirement for creating records \n # like posts or comments is that a user exist and be logged in. \n end", "def create\n\t\tredirect_to '/users/sign_in', alert: 'Access denied.'\n\tend", "def new\n if logged_in?\n redirect_to tasks_path, notice: \"ログイン済だよ。新規作成できない\"\n else\n @user = User.new\n end\n # if unless @user == current_user\n # redirect_to tasks_path, notice: \"登録は一回だけだよ\"\n # else\n # render :new \n # end\n # #\n end", "def require_creator\n unless logged_in? && current_user = @post.user\n flash[:error] = \"Can't be done\"\n redirect_to root_path\n end\n end", "def create\n # Creating a new with strong params\n @new = New.new(new_params)\n # Assinging that new to a specific user\n @new.user = User.first\n\n # Authorizing that only admin users can create a new\n authorize @new\n\n # If new is created and saved\n if @new.save\n # Show the specific new just created\n render :show, status: :created\n else\n # Show an error on the creation of the new\n render_error\n end\n end", "def create\n user=ApiM8::Client::Account::Users.instance.login(params[:login], params[:password])\n puts user.current_user\n\n if user\n session[:current_user_id]=user.id\n redirect_to role_super_admin_dashboards_url, :notice => \"Logged in as #{params[:login]}!\"\n else\n flash[:danger] = 'Invalid email/password combination' # Not quite right!\n render \"new\"\n end\n\n\n end", "def new\n redirect_to root_path if logged_in?\n end", "def new_user\n \n end", "def new\n redirect_to(login_path)\n end", "def needs_login?() false end", "def new \n\tif signed_in?\n\t\t@current_client = current_user.username\n\t\tif current_user.username == 'admin'\n\t\t\t@client = Client.new\n\t\telse\n\t\t\tredirect_to home_path\n\t\tend\n\t\t@actype = ''\n\telse\n\t\tredirect_to signin_path\n\tend\n end", "def create\n login\n lock\n end", "def new\n unless has_cookies_enabled?\n flash[:error] = t 'ubiquo.auth.cookies_error'\n end\n unless ubiquo_users?\n flash.now[:notice] = t 'ubiquo.auth.create_superadmin'\n end\n if logged_in?\n redirect_to ubiquo.home_path\n end\n end", "def login_required\n if params[:create_user] # hidden field in posted form. Create the user.\n user = User.new\n user.last_login = request.remote_ip\n if user.save && user.errors.empty?\n self.current_user = user # !! now logged in\n else\n flash[:error] = \"I am sorry. the system could not create a new account for you.\"\n access_denied\n end\n elsif authorized?\n return true\n else\n access_denied\n end\n end", "def new\n if !session[:id] && !session[:token]\n redirect_to({controller:'users', action:'signin'})\n end\n end", "def new\n\n if signed_in? && !isAdmin?\n sign_out\n redirect_to signup_url\n elsif signed_in? && isAdmin?\n redirect_to \"/new_prof\"\n end\n @title= \"Sign Up\"\n @user = User.new\n\n \n end", "def create_user_information # for new users. runs last according to rails.\n self.dj_name = name\n self.roles = Role.where(:title => 'noob')\n self.active = true\n set_password\n end", "def newUser\n end", "def new\n user = User.not_deleted.find_for_database_authentication(:email => params[:email])\n if user.nil? then\n expose :message=>'User or password incorrect for this site', :error=>true\n return;\n end\n\n # Invalidate any session the user ha now\n # invalidateUserSession user\n\n # Validate the password, as you can see, if the password is wrong, the user seession is already\n # gone, this can improve security.\n if !user.valid_password?(params[:password]) then\n expose :message=>'User or password incorrect for this site', :error=>true\n return;\n end\n\n #Validate the customer id\n if !user.isAdmin? && !user.valid_customer_id(params[:customer_id]) then\n expose :message=>'User, password or customer id incorrect for this site', :error=>true\n return\n end\n\n #Validate the user site\n if user.isSiteLogin? && (params[:site_name].nil? || !user.valid_site?(params[:site_name])) then\n expose :message=>'User, password or customer id incorrect for this site', :error=>true\n return\n end\n\n if params[:user_type] then\n if user.user_type_name.downcase != params[:user_type].downcase\n expose :message=>\"Only '#{params[:user_type].capitalize}' Users are available to use this app\", :error => true\n return\n end\n end\n\n # Create a new session\n site = Site.find_site_by_name params[:site_name]\n customer = Customer.find_by_customer_id params[:customer_id]\n token = generateUserSession(user, site, customer)\n\n setCurrentUser user\n expose :token => token, :role => getCurrentRole.role_id\n end", "def new\n if logged_in?\n redirect_to index_path\n end\n end", "def new\n @user = User.new\n authorize! :create, @user\n end", "def create\n user = User.authenticate(params[:username], params[:password])\n if user\n session[:user_id] = user.id\n if !user.admin_rights\n redirect_to posts_url, :notice => \"Welcome #{user.username}!\"\n else\n redirect_to :controller => :admin, :action=>\"index\"\n # check for admin_rights\n # redirect to admin\n end\n else\n flash.now.alert = \"Login Denied! Invalid username or password\"\n render 'sessions/login'\n end\n end", "def new\n raise CanCan::AccessDenied\n end", "def create\n email = params[:session][\"email\"] # both will work ->: will use less memory\n password = params[:session][:password]\n user = User.authenticate(email, password)\n \n if user # if auth is successful\n session[:user_id] = user.id # this is a session\n flash[:notice] = \"You are logged in.\"\n redirect_to session[:referrer] || :root # to whatever is the root of your webserver ()\n #:referrer -> send to page that started from (if tried to edit if not logged in)\n else # if wrong credentials\n flash[:error] = \"add to your FAIL blog and Please try again!\"\n render :action => \"new\" # just shows def new end (at the beginning again)\n end\n end", "def new?\n if is_super_admin?\n true\n elsif is_admin? && !has_company?\n true\n else\n false\n end\n end", "def new\n reset_session_key(:user, :new, {})\n redirect_to admin_user_step_path(id: 'identity')\n end", "def require_login\n not_authorized(\"Please sign up or log in above to access this resource.\") unless current_user\n end", "def new\n # render the login form\n end", "def create\n if using_open_id?\n open_id_authentication(params[:openid_url])\n elsif params[:login]\n password_authentication(params[:login], params[:password])\n end\n# self.current_user = User.authenticate(params[:login], params[:password])\n# if logged_in?\n# session[:user] = User.find(self.current_user)\n# \n# redirect_to :controller => :users, :action => :show, :id => self.current_user\n# flash[:notice] = \"Logged in successfully\"\n# else\n# render :action => 'new'\n# end\n end", "def new\n \t@request=Request.new\n if !logged_in?\n flash[:danger]=\"Please login to access our services\"\n redirect_to root_url\n end\n end", "def new_user\n \trender action: 'new_user'\n end", "def new\n authorize\n @post = Post.new\n end", "def auth_create_filter\n if not self.class.allowed_to_create\n false\n else\n true\n end\n end", "def create\n session[:enable_admin_pages] = false\n user = User.find_by(netid: auth_hash['extra']['netid'])\n if user\n session[:netid] = user.netid\n flash[:success] = \"Signed in as #{user.name}\"\n\n # Check auth for admin paths - in this case they have a user record, so set true\n # In other apps further permissions can be checked e.g. admin user type\n session[:enable_admin_pages] = true\n\n redirect_to session[:return_url] || root_path\n else\n redirect_to not_authorized_path\n end\n end", "def new\n # return if need_login true, true\n update_and_decorate\n response_service.title = \"New Site\"\n render :edit\n end", "def new\n @city = City.new\n authorize @city\n end", "def new\n @new_job = Job.new\n # Authorizes the correct user to access new job page\n authorize @new_job\n end", "def authorization; end", "def new\n redirect_to(dashboard_url) if user_signed_in?\n @allowedmethods = Identity.allowedmethods\n end", "def new?\n @user\n end", "def create\n self.current_person = Person.authenticate(params[:login], params[:password])\n if logged_in?\n if params[:remember_me] == \"1\"\n current_person.remember_me unless current_person.remember_token?\n cookies[:auth_token] = { value: self.current_person.remember_token , expires: self.current_person.remember_token_expires_at }\n end\n flash[:notice] = t('sessions.create.access_granted')\n redirect_back_or_default(root_path)\n else\n flash.now[:error] = t('sessions.create.access_denied')\n render action: 'new'\n end\n end", "def new\r\n create\r\n# logout_keeping_session!\r\n# respond_to do |format|\r\n# format.html\r\n# end\r\n end", "def create\n user = User.find_by(username: params[:session][:username])\n if (user && (!user.disabled? && user.authenticate(params[:session][:password]))) \n log_in user \n redirect_back_or active_jobs_path \n else \n flash.now[:danger] = \"Invalid Username/Password Combination\" \n render :new\n end\n end", "def new\n do_new_resource\n get_project_site\n do_set_attributes\n do_authorize_instance\n\n respond_new\n end", "def new\n if current_user && current_user.role == \"admin\"\n @user = User.new \n else\n redirect_to new_user_session_path\n end \n end", "def new\n if params[:create_user] == '1' or session[:id]\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n else\n flash[:error] = \"You will need to Sign In to view this page.\"\n redirect_to :controller => 'system', :action => 'index'\n end\n end", "def assert_access_without_login(*actions)\n\t\t\tuser_options = actions.extract_options!\n\n\t\t\toptions = {}\n\t\t\tif ( self.constants.include?(:ASSERT_ACCESS_OPTIONS) )\n\t\t\t\toptions.merge!(self::ASSERT_ACCESS_OPTIONS)\n#\t\t\telsif ( self.constants.include?('ASSERT_ACCESS_OPTIONS') )\n#\t\t\t\toptions.merge!(self::ASSERT_ACCESS_OPTIONS)\n\t\t\tend\n\t\t\toptions.merge!(user_options)\n\t\t\tactions += options[:actions]||[]\n\n\t\t\tm_key = options[:model].try(:underscore).try(:to_sym)\n\n\t\t\ttest \"#{brand}AWoL should get new without login\" do\n\t\t\t\tget :new\n\t\t\t\tassert_response :success\n\t\t\t\tassert_template 'new'\n\t\t\t\tassert assigns(m_key), \"#{m_key} was not assigned.\"\n\t\t\t\tassert_nil flash[:error], \"flash[:error] was not nil\"\n\t\t\tend if actions.include?(:new) || options.keys.include?(:new)\n\n\t\t\ttest \"#{brand}AWoL should post create without login\" do\n\t\t\t\targs = if options[:create]\n\t\t\t\t\toptions[:create]\n\t\t\t\telsif options[:attributes_for_create]\n\t\t\t\t\t{m_key => send(options[:attributes_for_create])}\n\t\t\t\telse\n\t\t\t\t\t{}\n\t\t\t\tend\n\t\t\t\tassert_difference(\"#{options[:model]}.count\",1) do\n\t\t\t\t\tsend(:post,:create,args)\n\t\t\t\tend\n\t\t\t\tassert_response :redirect\n\t\t\t\tassert_nil flash[:error], \"flash[:error] was not nil\"\n\t\t\tend if actions.include?(:create) || options.keys.include?(:create)\n\n#\t\t\ttest \"should NOT get edit without login\" do\n#\t\t\t\targs=[]\n#\t\t\t\tif options[:factory]\n#\t\t\t\t\tobj = Factory(options[:factory])\n#\t\t\t\t\targs.push(:id => obj.id)\n#\t\t\t\tend\n#\t\t\t\tsend(:get,:edit, *args)\n#\t\t\t\tassert_redirected_to_login\n#\t\t\tend if actions.include?(:edit) || options.keys.include?(:edit)\n#\n#\t\t\ttest \"should NOT put update without login\" do\n#\t\t\t\targs={}\n#\t\t\t\tif options[:factory]\n#\t\t\t\t\tobj = Factory(options[:factory])\n#\t\t\t\t\targs[:id] = obj.id\n#\t\t\t\t\targs[options[:factory]] = Factory.attributes_for(options[:factory])\n#\t\t\t\tend\n#\t\t\t\tsend(:put,:update, args)\n#\t\t\t\tassert_redirected_to_login\n#\t\t\tend if actions.include?(:update) || options.keys.include?(:update)\n\n\t\t\ttest \"#{brand}AWoL should get show without login\" do\n\t\t\t\targs={}\n\t\t\t\tif options[:method_for_create]\n\t\t\t\t\tobj = send(options[:method_for_create])\n\t\t\t\t\targs[:id] = obj.id\n\t\t\t\tend\n\t\t\t\tsend(:get,:show, args)\n\t\t\t\tassert_response :success\n\t\t\t\tassert_template 'show'\n\t\t\t\tassert assigns(m_key), \"#{m_key} was not assigned.\"\n\t\t\t\tassert_nil flash[:error], \"flash[:error] was not nil\"\n\t\t\tend if actions.include?(:show) || options.keys.include?(:show)\n\n#\t\t\ttest \"should NOT delete destroy without login\" do\n#\t\t\t\targs=[]\n#\t\t\t\tif options[:factory]\n#\t\t\t\t\tobj = Factory(options[:factory])\n#\t\t\t\t\targs.push(:id => obj.id)\n#\t\t\t\tend\n#\t\t\t\tassert_no_difference(\"#{options[:model]}.count\") do\n#\t\t\t\t\tsend(:delete,:destroy,*args)\n#\t\t\t\tend\n#\t\t\t\tassert_redirected_to_login\n#\t\t\tend if actions.include?(:destroy) || options.keys.include?(:destroy)\n#\n#\t\t\ttest \"should NOT get index without login\" do\n#\t\t\t\tget :index\n#\t\t\t\tassert_redirected_to_login\n#\t\t\tend if actions.include?(:index) || options.keys.include?(:index)\n\n\t\t\ttest \"#{brand}should get index without login\" do\n\t\t\t\tget :index\n\t\t\t\tassert_response :success\n\t\t\t\tassert_template 'index'\n\t\t\t\tassert assigns(m_key.try(:to_s).try(:pluralize).try(:to_sym)),\n\t\t\t\t\t\"#{m_key.try(:to_s).try(:pluralize).try(:to_sym)} was not assigned.\"\n\t\t\t\tassert_nil flash[:error], \"flash[:error] was not nil\"\n\t\t\tend if actions.include?(:index) || options.keys.include?(:index)\n\n\t\t\ttest \"#{brand}should get index without login and items\" do\n\t\t\t\tsend(options[:before]) if !options[:before].blank?\n\t\t\t\t3.times{ send(options[:method_for_create]) } if !options[:method_for_create].blank?\n\t\t\t\tget :index\n\t\t\t\tassert_response :success\n\t\t\t\tassert_template 'index'\n\t\t\t\tassert assigns(m_key.try(:to_s).try(:pluralize).try(:to_sym)),\n\t\t\t\t\t\"#{m_key.try(:to_s).try(:pluralize).try(:to_sym)} was not assigned.\"\n\t\t\t\tassert_nil flash[:error], \"flash[:error] was not nil\"\n\t\t\tend if actions.include?(:index) || options.keys.include?(:index)\n\n\t\tend", "def new?\n\t\tcreate?\n\tend", "def new\n if logged_in?\n # User who has logged in has no need to access create action\n redirect_to current_user\n else\n # Get ready to display signup page by declaring instance var\n \t @user = User.new\n end\n end", "def new_authenticate\n\t\tif !current_admin and !current_user\n\t\t\tauthenticate_user\n\t\tend\n\tend", "def new\n \t if !session[:user_id]\n\t\tredirect_to :action=> 'login'\n\t else\n @gebruiker = Gebruiker.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @gebruiker }\n end\n end\nend", "def create\n params.permit!\t\n @user = User.new(params[:user], params[:password])\n if params[:login]\n redirect_to(:action => \"login\")\n elsif params[:add_user]\n redirect_to(:action => \"add\") \n end\n# if @user.save\n# redirect_to(:action => \"add\")\n# end\n end", "def new\n __log_activity\n __debug_route\n @item = new_record\n user_authorize!\n rescue => error\n failure_status(error)\n end", "def show\n self.current_user\n \n if not @current_user\n redirect_to login_path\n else\n render :action => 'edit'\n end\n end", "def new?\n super && !user.admin? && not_a_visitor && !user_has_other_application?\n end", "def new\n if logged_in?\n # Users who are logged in should not be shown the logon page, per feedback from confused users\n redirect_back_or_home \n elsif request.referer\n # If the user tried to access a page was denied, redirect them to the original page they\n # were denied access to, and not the '/denied' page\n flash[:login_referer_page] = (flash[:denied_path] ? flash[:denied_path] : request.referer)\n end\n end", "def create\n if user = User.find_by_login(params[:login])\n # Save the user ID in the session so it can be used in subsequent requests\n session[:current_user_id] = user.id\n redirect_to root_url\n end\n end", "def new\n return appctrl_not_permitted() unless @current_user.admin?\n @record = @user = User.new\n end", "def new\n\t#Are they already logged in?\n\t# if current_user #They are! Can't create them again.\n\t# @user = User.new\n\t# if params[:email] == current_user.email\n\t# if current_user.email\n\tif current_user\n\t\t# redirect_to users_url\n\t\tredirect_to users_results_url\n\telse\n\t\t@user = User.new\n\t\t# redirect_to users_results_url\n\t\trender :new\n\tend\nend", "def show\n authorize! :create, Administrator\n end", "def new\n\n\t\t\n\tend", "def create\n\t\tuser = User.from_sso(cookies[:UTEP_SE], cookies[:UTEP_SA])\n\t\tlog_in(user) if user\n\t\tredirect_to root_url\n\tend", "def create\n user = User.find_by_email(params[:session][:email].downcase)\n if user\n administrator = Administrator.find_by_user_id(user.id)\n end\n if user && user.authenticate(params[:session][:password]) && administrator\n if administrator.status \n sign_in user\n if administrator.admin\n redirect_to :controller => 'users', :action => 'index'\n else\n redirect_to :controller => 'products', :action => 'index'\n end\n else \n flash[:notice] = \"Inactive user\"\n render 'new'\n end\n else\n flash[:notice] = \"Invalid Email/Password combination\"\n render 'new' \n end\n end", "def new\n @usuario = Usuario.new\n if current_user\n session[:admin_new] = true\n else\n session[:admin_new] = false\n end\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @usuario }\n end\n end", "def new\n @employee = Employee.new\n @lawfirm_admin = User.new\n @roles = Role.scoped_by_company_id(current_user.company_id)\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lawfirm_admin }\n authorize!(:new,current_user) unless current_user.role?:lawfirm_admin\n end\n end", "def create\n user = User.find_by(username: params[:session][:username])\n\n if user && user.authenticate(params[:session][:password])\n # Log the user in\n log_in user\n user.update_attribute(:is_login, true)\n redirect_to index_path\n else\n # Using render in case any error flash message is to shown in future. \n render 'new'\n end # END IF-ELSE login\n end", "def new\n @user = User.new\n\t # @organizations = Organization.all\n\t# @roles = Role.all\n respond_to do |format|\n format.html {redirect_to :controller => :login, :action => :register}# new.html.erb\n end\n end", "def create\n redirect_or_render authorization.authorize\n end", "def create\n # logging in can be done via email or username interchangeably\n user = User.find_by email: params[:session][:username].downcase\n # ||= only runs the find command if the user was not set by the above\n user ||= User.find_by username: params[:session][:username].downcase\n\n if user && user.authenticate(params[:session][:password])\n # Log the user in and redirect to the user's show page\n log_in user\n flash[:success] = \"Logged in as #{user.username}\"\n redirect_to user_url(user)\n else\n # Flash an error message\n flash.now[:danger] = 'Invalid email or password'\n render 'new'\n end\n end", "def new\n\n end", "def new\n\n end", "def new\n\n end", "def new\n\n end" ]
[ "0.7438733", "0.7438733", "0.7344537", "0.728793", "0.71829647", "0.70024157", "0.69352365", "0.6924324", "0.68553334", "0.6844659", "0.6827712", "0.6824782", "0.6806438", "0.6767501", "0.6767501", "0.6767501", "0.6767501", "0.6767501", "0.6767501", "0.6767501", "0.6767501", "0.6767501", "0.6751396", "0.67432696", "0.6732248", "0.6732248", "0.67277956", "0.67178124", "0.66788214", "0.6678492", "0.663753", "0.66375035", "0.6622951", "0.66183406", "0.65983725", "0.6586009", "0.6583857", "0.651148", "0.6497114", "0.6485449", "0.6475447", "0.64721376", "0.6471059", "0.6448028", "0.6443018", "0.64388806", "0.64322555", "0.6430903", "0.641106", "0.640413", "0.6400017", "0.63979477", "0.6372256", "0.63641965", "0.63516253", "0.6350742", "0.6347695", "0.6344563", "0.6342173", "0.6333745", "0.63308984", "0.6330883", "0.6325139", "0.63238853", "0.6318686", "0.6312522", "0.63089406", "0.63033545", "0.6295891", "0.6293529", "0.62926674", "0.6289852", "0.62893724", "0.6282316", "0.62799233", "0.62742496", "0.62682474", "0.62682176", "0.6252561", "0.6248018", "0.6237948", "0.6236744", "0.6236679", "0.6235805", "0.62307227", "0.6227759", "0.6221522", "0.6219121", "0.62052363", "0.62007785", "0.6198467", "0.6193263", "0.61915183", "0.6191116", "0.6190597", "0.6184235", "0.6182144", "0.6182144", "0.6182144", "0.6182144" ]
0.68266046
11
Use callbacks to share common setup or constraints between actions.
def set_repository @repository = @user.owned_repositories.find_by_slug!(params[:repository_id]) raise ActiveRecord::RecordNotFound unless @repository.has_issues? 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
POST /accounts POST /accounts.json POST /accounts.xml
def create @account = Account.new(params[:account]) respond_to do |format| if @account.save #format.html { redirect_to(@account, :notice => 'Account was successfully created.') } format.json { render :json => @account, :status => :created, :location => @account } format.xml { render :xml => @account, :status => :created, :location => @account } else #format.html { render :action => "new" } format.json { render :json => @account.errors, :status => :unprocessable_entity } format.xml { render :xml => @account.errors, :status => :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n megam_rest.post_accounts(to_hash)\n end", "def post_accounts(json_hash)\n @options = {:path => '/users.json',\n :body => json_hash[:json]}.merge(@options)\n\n request(\n :expects => 201,\n :method => :post,\n :body => @options[:body]\n )\n end", "def create\n @account = current_user.accounts.build params[:account]\n \n account_array = accounts_from_credentials @account.api_email, @account.api_password\n \n accounts = account_array.map do |account_info|\n account = current_user.accounts.build params[:account]\n \n account.api_id = account_info.accountID\n account.api_name = account_info.accountName\n account.api_user_id = account_info.userID\n \n account\n end\n\n respond_to do |format|\n if !accounts.blank? && accounts.map(&:valid?).all? && accounts.map(&:save).all?\n flash[:notice] = \"#{accounts.size == 1 ? 'Account was' : \"#{accounts.size} accounts were\"} successfully created.\"\n format.html { redirect_to(@account) }\n format.xml { render :xml => @account, :status => :created, :location => @account }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @account.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @account = Account.new(params[:account])\n @account.member = current_member\n logger.info @account.inspect\n \n respond_to do |format|\n if @account.save\n flash[:notice] = 'Thanks for signing up!' \n format.html { \n redirect_back_or_default('/')\n }\n format.xml do\n headers[\"Location\"] = account_url(@account)\n render :nothing => true, :status => \"201 Created\"\n end\n else\n flash[:notice] = 'There was a problem creating your account, but we can address that later. If you need to sell something right now, please contact support.'\n redirect_back_or_default('/')\n format.xml { render :xml => @account.errors.to_xml }\n end\n end\n end", "def create\n @account = current_user.accounts.new(params[:account])\n\n respond_to do |format|\n if @account.save\n flash[:notice] = 'Account was successfully created.'\n format.html { redirect_to([current_user, @account]) }\n format.xml { render :xml => @account, :status => :created, :location => @account }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @account.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create_accounts\n end", "def create\n @account = Account.new(params[:account])\n respond_to do |format|\n if @account.save\n \n format.html { redirect_to \"http://#{@account.name}.#{request.domain}#{request.port_string}/login\", notice: 'Account was successfully created.' }\n format.json { render json: @account, status: :created, location: @account }\n else\n format.html { render action: \"new\" }\n format.json { render json: @account.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_account(options)\n form_data = options.merge({ 'action' => 'createaccount' })\n res, dummy = make_api_request(form_data)\n res\n end", "def create\n @account = Account.new(params[:account])\n @account.owner = current_user\n\n respond_to do |format|\n if @account.save\n format.html { redirect_to @account, notice: 'Account was successfully created.' }\n format.json { render json: @account, status: :created, location: @account }\n else\n format.html { render action: \"new\" }\n format.json { render json: @account.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @api_v1_account = Api::V1::Account.new(api_v1_account_params)\n\n respond_to do |format|\n if @api_v1_account.save\n format.html { redirect_to @api_v1_account, notice: 'Account was successfully created.' }\n format.json { render :show, status: :created, location: @api_v1_account }\n else\n format.html { render :new }\n format.json { render json: @api_v1_account.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @account = Account.new(account_params)\n @account.user = @user\n\n respond_to do |format|\n if @account.save\n format.html { redirect_to @account, notice: 'Account was successfully created.' }\n format.json { render :show, status: :created, location: @account }\n else\n format.html { render :new }\n format.json { render json: @account.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @account = Account.new(params[:account])\n\n respond_to do |format|\n if @account.save\n format.html { redirect_to @account, notice: 'Account was successfully created.' }\n format.json { render json: @account, status: :created, location: @account }\n else\n format.html { render action: \"new\" }\n format.json { render json: @account.errors, status: :unprocessable_entity }\n end\n end\n end", "def add_account(payload)\n post(url_, payload)\n end", "def create\r\n @account = Account.new(params[:account])\r\n\r\n respond_to do |format|\r\n if @account.save\r\n format.html { redirect_to @account, notice: 'Account was successfully created.' }\r\n format.json { render json: @account, status: :created, location: @account }\r\n else\r\n format.html { render action: \"new\" }\r\n format.json { render json: @account.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end", "def create\n @account = Account.new(params[:account])\n \n respond_to do |format|\n if @account.save\n format.html { redirect_to @account, notice: 'Account was successfully created.' }\n format.json { render json: @account, status: :created, location: @account }\n else\n format.html { render action: \"new\" }\n format.json { render json: @account.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @account = Account.new(account_params)\n\n respond_to do |format|\n if @account.save\n format.html { redirect_to @account, notice: 'Account was successfully created.' }\n format.json { render :show, status: :created, location: @account }\n else\n format.html { render :new }\n format.json { render json: @account.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @account = Account.new(account_params)\n\n respond_to do |format|\n if @account.save\n format.html { redirect_to @account, notice: 'Account was successfully created.' }\n format.json { render :show, status: :created, location: @account }\n else\n format.html { render :new }\n format.json { render json: @account.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @account = Account.new(account_params)\n\n respond_to do |format|\n if @account.save\n format.html { redirect_to @account, notice: 'Account was successfully created.' }\n format.json { render :show, status: :created, location: @account }\n else\n format.html { render :new }\n format.json { render json: @account.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @account = Account.new(account_params)\n\n respond_to do |format|\n if @account.save\n format.html { redirect_to @account, notice: 'Account was successfully created.' }\n format.json { render :show, status: :created, location: @account }\n else\n format.html { render :new }\n format.json { render json: @account.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @account = Account.new(account_params)\n\n respond_to do |format|\n if @account.save\n format.html { redirect_to @account, notice: 'Account was successfully created.' }\n format.json { render :show, status: :created, location: @account }\n else\n format.html { render :new }\n format.json { render json: @account.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @account = Account.new(account_params)\n\n respond_to do |format|\n if @account.save\n format.html { redirect_to @account, notice: 'Account was successfully created.' }\n format.json { render :show, status: :created, location: @account }\n else\n format.html { render :new }\n format.json { render json: @account.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @account = Account.new(account_params)\n\n respond_to do |format|\n if @account.save\n format.html { redirect_to @account, notice: 'Account was successfully created.' }\n format.json { render :show, status: :created, location: @account }\n else\n format.html { render :new }\n format.json { render json: @account.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @account = Account.new(account_params)\n\n respond_to do |format|\n if @account.save\n format.html { redirect_to @account, notice: 'Account was successfully created.' }\n format.json { render :show, status: :created, location: @account }\n else\n format.html { render :new }\n format.json { render json: @account.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @account = Account.new(account_params)\n\n respond_to do |format|\n if @account.save\n format.html { redirect_to @account, notice: 'Account was successfully created.' }\n format.json { render :show, status: :created, location: @account }\n else\n format.html { render :new }\n format.json { render json: @account.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @account = Account.new(account_params)\n\n respond_to do |format|\n if @account.save\n format.html { redirect_to accounts_path, notice: 'account was successfully created.' }\n format.json { render json: @account, status: :created, location: @account }\n else\n format.html { render action: \"new\" }\n format.json { render json: @account.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @account = Admin::Account.new(params[:account])\n\n respond_to do |format|\n if @account.save\n flash[:notice] = 'Admin::Account was successfully created.'\n format.html { redirect_to(@account) }\n format.xml { render :xml => @account, :status => :created, :location => @account }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @account.errors, :status => :unprocessable_entity }\n end\n end\n end", "def post_save xml, options={:mapping=>:_default}\n xml.root.add_attributes(\"xmlns\"=>\"http://schema.intuit.com/platform/fdatafeed/creditaccount/v1\")\n end", "def create\n @account = Account.new(account_params)\n\n respond_to do |format|\n if @account.save\n format.html { redirect_to root_path, success: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @account }\n else\n format.html { render :new }\n format.json { render json: @account.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @user_account = UserAccount.new(params[:user_account])\n\n respond_to do |format|\n if @user_account.save\n format.html { redirect_to(@user_account, :notice => 'User account was successfully created.') }\n format.xml { render :xml => @user_account, :status => :created, :location => @user_account }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @user_account.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @user_account = UserAccount.new(params[:user_account])\n\n respond_to do |format|\n if @user_account.save\n format.html { redirect_to user_account_url(@user_account.user, @user_account), notice: 'User account was successfully created.' }\n format.json { render json: @user_account, status: :created, location: @user_account }\n format.xml { render xml: @user_account, status: :created, location: @user_account }\n else\n format.html { render action: \"new\" }\n format.json { render json: @user_account.errors, status: :unprocessable_entity }\n format.xml { render xml: @user_account.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n printf(\"create : %s/%s \\n\", params[\"name\"], params[\"password\"])\n @account = Account.new(:name => params[\"name\"], :email => params[\"email\"], :password => params[\"password\"])\n \n respond_to do |format|\n if @account.save\n printf(\"save OK\\n\")\n format.html { redirect_to(@account, :notice => 'Account was successfully created.') }\n format.xml { render :xml => @account, :status => :created, :location => @account }\n else\n printf(\"save FAIL\\n\")\n format.html { render :action => \"new\" }\n format.xml { render :xml => @account.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @account = Account.new(account_params)\n @account.user_id = current_user.id\n\n respond_to do |format|\n if @account.save\n format.html { redirect_to @account, notice: 'Account was successfully created.' }\n format.json { render :show, status: :created, location: @account }\n else\n format.html { render :new }\n format.json { render json: @account.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @account = current_account\n\n respond_to do |format|\n if @account.save\n flash[:notice] = 'User::Account was successfully created.'\n format.html { redirect_to(@account) }\n format.xml { render :xml => @account, :status => :created, :location => @account }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @account.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create_account\n\n end", "def create\n email = AuthenticationHelper::Auth.instance.getEmailFromJWT( request )\n if ( email == nil )\n render json: :nothing, status: :unprocessable_entity\n return\n end\n\n user = User.find_by(email: email)\n\n if ( user )\n user_id = user[\"id\"]\n balance = account_params[\"balance\"] \n account = Account.new(user_id: user_id, balance: balance)\n\n if account.save\n render json: account, status: :created\n else\n render json: account.errors, status: :unprocessable_entity\n end\n else\n render json: :nothing, status: :unprocessable_entity\n end\n \n end", "def create\n response = @account_api.create(params)\n\n respond_to do |format|\n if response[:status] == 201\n format.html { redirect_to accounts_path , notice: 'Account successfully created.' }\n format.json { render :show, status: :created, location: user_path(response[:body]) }\n else\n format.html { redirect_to new_account_path, alert: formatted_error_message(response).join(\"<br/>\").html_safe }\n format.json { render json: response[:body], status: :unprocessable_entity }\n end\n end\n end", "def create\n\t\t@account = Account.new(:name => params[:name])\n\t\trespond_to do |format|\n\t\t\tif @account.save\n\t\t\t\tformat.json { render json: @account, status: :created }\n\t\t\telse\n\t\t\t\tformat.json { render json: @account.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend", "def create_account(account_form)\r\n # the base uri for api requests\r\n query_builder = Configuration.base_uri.dup\r\n\r\n # prepare query string for API call\r\n query_builder << '/accounts'\r\n\r\n # validate and preprocess url\r\n query_url = APIHelper.clean_url query_builder\r\n\r\n # prepare headers\r\n headers = {\r\n 'user-agent' => 'APIMATIC 2.0',\r\n 'accept' => 'application/json',\r\n 'content-type' => 'application/json; charset=utf-8',\r\n 'X-Auth-Token' => Configuration.x_auth_token\r\n }\r\n\r\n # invoke the API call request to fetch the response\r\n response = Unirest.post query_url, headers: headers, parameters: account_form.to_json\r\n\r\n # Error handling using HTTP status codes\r\n if response.code == 401\r\n raise APIException.new 'You are not authenticated', 401, response.raw_body\r\n elsif response.code == 403\r\n raise APIException.new 'This action needs a valid WSSE header', 403, response.raw_body\r\n elsif response.code == 404\r\n raise APIException.new 'Resource not found', 404, response.raw_body\r\n elsif response.code == 400\r\n raise APIException.new 'Http bad request', 400, response.raw_body\r\n elsif !response.code.between?(200, 206) # [200,206] = HTTP OK\r\n raise APIException.new 'HTTP Response Not OK', response.code, response.raw_body\r\n end\r\n\r\n response.body\r\n end", "def create\n @account = Account.new(account_params)\n @account.zip = Account.random_zip\n @account.user_id = @current_user.id if @current_user\n respond_to do |format|\n if @account.save\n format.html { redirect_to @account, notice: 'Account was successfully created.' }\n format.json { render :show, status: :created, location: @account }\n else\n format.html { render :new }\n format.json { render json: @account.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @account = Account.new(account_params)\n @account.user_created_id = current_user.id\n respond_to do |format|\n if @account.save\n format.html { redirect_to accounts_path, notice: I18n.t('account.controller.create') }\n format.json { render :show, status: :created, location: @account }\n else\n format.html { render :new }\n format.json { render json: @account.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @account = Account.new(account_params.merge({ user_id: @current_user.id }))\n\n if @account.save\n render :show, status: :created, location: @account\n else\n render json: @account.errors, status: :unprocessable_entity\n end\n end", "def create\n # Get the credit card details submitted by the form\n @account = Account.new\n authorize @account\n @account.user_id = account_params[:user_id]\n @account.package_id = account_params[:package_id];\n @user = User.find(account_params[:user_id])\n @account.users << @user\n @account.active = FALSE\n\n if @account.save\n render json: {status: :created, account: @account}\n else\n render json: { error: @account.errors, status: :unprocessable_entity }\n end\n end", "def add_user_for_tenant(args = {}) \n post(\"/tenants.json/#{args[:tenantId]}/users\", args)\nend", "def post_save xml, options={:mapping=>:_default}\n xml.root.add_attributes(\"xmlns\"=>\"http://schema.intuit.com/platform/fdatafeed/investmentaccount/v1\")\n end", "def post_save xml, options={:mapping=>:_default}\n xml.root.add_attributes(\"xmlns\"=>\"http://schema.intuit.com/platform/fdatafeed/bankingaccount/v1\")\n end", "def accounts\n get('/accounts')['accounts']\n end", "def add_tenant_circle(args = {}) \n post(\"/tenantcircles.json/\", args)\nend", "def eth_accounts\n params = []\n data = {\"jsonrpc\" => \"2.0\", \"method\" => \"eth_accounts\", \"params\" => params, \"id\" => \":1\"}\n @http_client.post(data) do |response|\n NSLog(response.to_s)\n @accounts_result.stringValue = response\n end\nend", "def create\n\t\t@account = Account.new(params[:account])\n\n\t\trespond_to do |format|\n\t\t\tif @account.save\n\t\t\t\t# If we provide tokens (manually)\n\t\t\t\tif !@account.tokens?\n\t\t\t\t\tredirect_to '/auth/twitter?screen_name=' + @account.username\n\t\t\t\t\treturn\n\t\t\t\telse\n\t\t\t\t\tformat.html { redirect_to @account, notice: 'Account was successfully created.' }\n\t\t\t\t\tformat.json { render json: @account, status: :created, location: @account }\t\n\t\t\t\tend\n\t\t\telse\n\t\t\t\tformat.html { render action: \"new\" }\n\t\t\t\tformat.json { render json: @account.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend", "def create\n @account = Account.new(account_params)\n\n respond_to do |format|\n if @account.save\n format.html { redirect_to accounts_url, notice: 'Account was successfully created.' }\n format.json { render action: 'show', status: :created, location: @account }\n else\n format.html { render action: 'new' }\n format.json { render json: @account.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_account\n set_user\n set_payer\n set_user_sport\n save_account\n end", "def create\n @account = Current.book.accounts.new(account_params)\n\n respond_to do |format|\n if @account.save\n format.html { redirect_to @account, notice: 'Account was successfully created.' }\n format.json { render :show, status: :created, location: @account }\n else\n format.html { render :new }\n format.json { render json: @account.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @account = Account.new(params[:account])\n\n respond_to do |format|\n if @account.save\n format.html { redirect_to dashboard_path, notice: 'Account was successfully created.' }\n format.json { render json: @account, status: :created, location: @account }\n else\n format.html { render action: \"new\" }\n format.json { render json: @account.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_crm_account_from_lead\n doc = Hpricot::XML(request.raw_post)\n doc = doc.to_s.gsub(\"&amp;\",\"&\") \n doc = Hpricot::XML(doc) \n id = parse_xml(doc/:params/'id')\n account_doc = Crm::CrmLeadCrud.generate_xml_for_account(doc) \n @accounts=Crm::CrmLeadCrud.create_account_from_lead(account_doc,id)\n account = @accounts.first if !@accounts.empty?\n if account.errors.empty?\n render:text=>'success'\n else\n respond_to_errors(account.errors)\n end\n end", "def create\n @user_account = UserAccount.new(user_account_params)\n\n respond_to do |format|\n if @user_account.save\n format.html { redirect_to @user_account, notice: 'User account was successfully created.' }\n format.json { render :show, status: :created, location: @user_account }\n else\n format.html { render :new }\n format.json { render json: @user_account.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @account = current_user.accounts.build(params[:account])\n respond_to do |format|\n if @account.save\n # add budget RT\n @recurring = Recurring.new\n @recurring.name = \"Monthly Budget\"\n @recurring.account_id = @account.id\n @recurring.transaction_type = \"Budget\"\n @recurring.amount = 0\n @recurring.monthly = true\n @recurring.save\n flash[:notice] = 'Account was successfully created.'\n format.html { redirect_to(user_accounts_path(current_user)) }\n format.xml { render :xml => @account, :status => :created, :location => @account }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @account.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create_users(accountId, model) path = \"/api/v2/accounts/#{accountId}/users\"\n post(path, model, {}, AvaTax::VERSION) end", "def create\n @account = Account.new(params[:account])\n @account.role = 1\n\n\n respond_to do |format|\n if @account.save\n format.html { redirect_to(new_account_session_path, :notice => 'アカウントの作成に成功しました。下記フォームからログインして下さい。') }\n format.xml { render :xml => @account, :status => :created, :location => @account }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @account.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @acct = EmployeeAcct.new(employee_acct_params)\n @acct.account = current_account\n\n respond_to do |format|\n if @acct.save\n format.html { redirect_to \"/\", notice: 'Employee Account was successfully created.' }\n format.json { redirect_to \"/\", status: :created, location: @acct }\n else\n format.html { render :new }\n format.json { render json: @acct.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n flash[:notice] = 'The account was successfully created.' if account.save\n respond_with(account)\n end", "def create_basic_account(http, account_name, identity_card)\n begin\n response = http.post 'Create a new account', \"#{SERVER}/accounts\", {\n 'lineId' => 1,\n 'username' => account_name,\n 'password' => account_name,\n 'email' => \"#{account_name}@lvs.co.uk\",\n 'countryCode' => 'IL',\n 'currencyCode' => 'ILS',\n 'online' => true,\n 'status' => 'open',\n 'identityCardNumber'=> identity_card\n }\n account_id = JSON.parse(response.body)['id']\n account_uri = response.headers[:location]\n \n response = http.post 'Create a new transaction', \"#{SERVER}/accounts/#{account_id}/transactions\", {\n 'transactionSubType' => 'CREDIT_CARD',\n 'transactionType' => 'PAYMENTRECEIPT',\n 'accountId' => account_id,\n 'credit' => '10000',\n 'description' => 'Payment via REST API',\n }\n return account_id, account_uri\n end\nend", "def create\n @account = BlackberryAccount.new(params[:blackberry_account])\n current_user.person.blackberry_accounts << @account\n\n respond_to do |format|\n if @account.save\n format.html { redirect_to( accounts_path, :notice => 'Account was successfully created.') }\n format.json { render :json => @account, :status => :created, :location => @account }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @account.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @account = Account.new(name: account_params[:name])\n \n respond_to do |format|\n if @account.save\n user = @account.users.build(account_params[:users_attributes])\n if user.save\n session[:user_id] = user.id\n format.html { redirect_to samples_path, notice: 'account was successfully created.' }\n format.json { render samples_path, status: :created, location: @account }\n else\n format.html { redirect_to register_path, notice: 'Error, in user save' }\n format.json { render json: @account.errors, status: :unprocessable_entity }\n end\n else\n format.html { render :new, notice: 'Error, in account save' }\n format.json { render json: @account.errors, status: :unprocessable_entity }\n end\n end\n end", "def post_save xml, options={:mapping=>:_default}\n xml.root.add_attributes(\"xmlns\"=>\"http://schema.intuit.com/platform/fdatafeed/rewardsaccount/v1\")\n end", "def create\n @account = PhoneAccount.new(params[:phone_account])\n current_user.person.phone_accounts << @account\n\n respond_to do |format|\n if @account.save\n format.html { redirect_to( accounts_path, :notice => 'Account was successfully created.') }\n format.json { render :json => @account, :status => :created, :location => @account }\n else\n format.html { render :action => 'new' }\n format.json { render :json => @account.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n \n @transaction = Transaction.new(account_params)\n #@account.user_id = current_user.id\n respond_to do |format|\n if @transaction.save\n format.html { redirect_to @transaction, notice: 'Account was successfully created.' }\n format.json { render :show, status: :created, location: @transaction }\n else\n format.html { render :new }\n format.json { render json: @transaction.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @account = Account.new(params[:account])\n\n respond_to do |format|\n if @account.save\n format.html { redirect_to @account, notice: t('common.created', model: human_name) }\n format.json { render json: @account, status: :created, location: @account }\n else\n format.html { render action: \"new\" }\n format.json { render json: @account.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n #@current_account = CurrentAccount.new(current_account_params)\n @current_account = current_user.current_accounts.new(current_account_params)\n\n respond_to do |format|\n if @current_account.save\n format.html { redirect_to @current_account, flash: { success: \"AccountPayable was successfully created.\" } }\n format.json { render :show, status: :created, location: @current_account }\n else\n format.html { render :new }\n format.json { render json: @current_account.errors, status: :unprocessable_entity }\n end\n end\n end", "def test_create_account_email_address_already_an_account\n data = read_json_file(\"valid_create_account_request\")\n\n data[\"emailAddress\"] = \"joetester@example.com\"\n pp_response = @account_request.create_account(data)\n\n assert !pp_response.success?\n assert_equal \"An account already exists for the specified email address\", pp_response[\"error\"].first[\"message\"]\n end", "def create\n @account = current_user.accounts.new(params[:account])\n \n #respond_to do |format|\n if @account.save\n default_account = Account.count == 1 || (Account.count > 1 && params[:default_account])\n current_user.update_attribute(:default_account, @account.id) if default_account\n\n flash[:notice] = 'Account was successfully created.'\n head :ok\n #format.html { redirect_to(@account) }\n #format.xml { render :xml => @account, :status => :created, :location => @account }\n else\n #format.html { render :action => \"new\" }\n #format.xml { render :xml => @account.errors, :status => :unprocessable_entity }\n head :unprocessable_entity\n end\n #end\n end", "def setup_accounts\n self.accounts.create({:name => \"Checking\"})\n self.accounts.create({:name => \"Savings\"})\n end", "def create\n @account = current_user.accounts.new(account_params)\n if @account.save\n redirect_to @account, notice: 'Account was successfully created.'\n else\n render :new\n end\n end", "def save\n # TODO validar atributos?\n response = Http.post(\"/organizations/api/identities/#{self.identity.uuid}/accounts/\", create_body)\n raise \"unexpected response: #{response.code} - #{response.body}\" unless response.code == 201\n attributes_hash = MultiJson.decode(response.body)\n set_attributes(attributes_hash)\n @persisted = true\n @errors = {}\n true\n rescue *[RestClient::BadRequest] => e\n @persisted = false\n @errors = MultiJson.decode(e.response.body)\n false\n end", "def create\n @dorm_account = DormAccount.new(params[:dorm_account])\n\n respond_to do |format|\n if @dorm_account.save\n flash[:notice] = 'DormAccount was successfully created.'\n format.html { redirect_to(@dorm_account) }\n format.xml { render :xml => @dorm_account, :status => :created, :location => @dorm_account }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @dorm_account.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @account = Account.new(account_params)\n\n respond_to do |format|\n if @account.save\n\n if params[:commit] == \"Create and Go To Account\"\n url = account_path(@account)\n else\n url = new_account_path\n end\n\n flash[:notice] = \"Account was successfully created\"\n format.html { redirect_to url }\n format.json { render :show, status: :created, location: @account }\n else\n flash[:error] = \"Unable to save account: #{@account.errors.full_messages.to_sentence}\"\n format.html { render :new }\n format.json { render json: @account.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @account = Account.new(account_params)\n #@account.user_id = current_account.id\n respond_to do |format|\n if @account.save\n format.html { redirect_to root_url, notice: 'Account was successfully created.' }\n format.json { render :json => @account.as_json}\n format.js {}\n else\n format.html { render :action => :new}\n format.json { render :json => @account.as_json, :status => :unprocessable_entity}\n format.js {}\n end\n end\n end", "def create\n @account = Account.new(account_params)\n\n respond_to do |format|\n if @account.save\n\n # sign in user\n user = @account.users.first\n sign_in(:user, user)\n @account.update_attributes(user_id: user.id)\n\n format.html { redirect_to prism_root_path(@account), notice: 'Welcome to Satiisfy!' }\n format.json { render action: 'show', status: :created, location: @account }\n else\n format.html { render action: 'new' }\n format.json { render json: @account.errors, status: :unprocessable_entity }\n end\n end\n end", "def create(params)\n put('v1/account', params)\n end", "def create\n @account = Account.new(params[:account])\n\n respond_to do |format|\n\n\n if @account.save\n\n # create initial dashboard\n dashboard = Dashboard.new\n dashboard.name = @account.name + \" Dashboard\"\n dashboard.account_id = @account.id\n dashboard.save\n\n #send welcome mail to user\n @user = User.new\n @user.account_id = @account.id\n @user.first_name = @account.contact_firstname\n @user.last_name = @account.contact_lastname\n @user.email = @account.contact_email\n @user.role = \"admin\"\n logger.debug \"Creating user #{@user.email}\"\n new_password = @user.set_random_password\n #new_password = user.set_random_password\n #Emailer.deliver_welcome_email(user, new_password)\n @user.save\n #Setup Chargify Customer\n customer_id = @account.create_chargify_customer\n @account.create_chargify_subscription\n logger.debug \"new chargify customer id: #{customer_id}\"\n format.html { redirect_to(\"/success.html\", :notice => 'Account was successfully created.') }\n \n format.xml { render :xml => @account, :status => :created, :location => @account }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @account.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n current_account.follow(@account)\n # TODO: Set up a mailer for notifying accounts of new followers\n respond_to do |format|\n format.html { redirect_to account_url }\n format.json { render :status }\n end\n\n end", "def create\n @om_account = OmAccount.new(params[:om_account])\n @om_account.user_id = current_user.id\n @om_account.credentials = {:tag => params[:tag], :password => params[:password]}.to_yaml\n\n respond_to do |format|\n if @om_account.save\n flash[:notice] = 'account was successfully accessed.'\n format.html { redirect_to(om_accounts_url) }\n format.xml { render :xml => @om_account, :status => :created, :location => @om_account }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @om_account.errors, :status => :unprocessable_entity }\n end\n end\n end", "def test_create_transaction\n params = {\n bank_transaction: {\n bank_account_id: 1,\n date: Time.local(2012, 4, 16),\n amount: 55\n }\n }\n\n post '/api/banks/1/transactions', params\n data = ActiveSupport::JSON.decode last_response.body\n\n assert last_response.successful?\n assert_match('application/json', last_response.content_type)\n assert BankTransaction.find(data['id'])\n end", "def create\n @account = Account.find(params[:account_id])\n @account_item = @account.account_items.create(params[:account_item])\n respond_to do |format|\n if @account_item.save\n format.html { redirect_to(account_account_items_url, :notice => 'Account item was successfully created.') }\n format.xml { render :xml => @account_item, :status => :created, :location => @account_item }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @account_item.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @account = Account.new(:name=>params[:account_name].downcase, :password=>params[:password], :password_confirmation =>params[:password_confirmation], :account_type=>params[:account_type])\n user = User.new\n user.nick_name = params[:nick_name]\n @account.user = user\n\n respond_to do |format|\n if @account.save\n session[:user_id] = @account.user.id\n format.html { redirect_to(:controller=>'yueyue_objects', :action => \"index\") }\n format.xml { render :xml => @account, :status => :created, :location => @account }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @account.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create(name=\"Default Name\", age=\"50\")\r\n xml_req =\r\n \"<?xml version='1.0' encoding='UTF-8'?>\r\n <person>\r\n <name>#{name}</name>\r\n <age>#{age}</age>\r\n </person>\"\r\n \r\n request = Net::HTTP::Post.new(@url)\r\n request.add_field \"Content-Type\", \"application/xml\"\r\n request.body = xml_req\r\n \r\n http = Net::HTTP.new(@uri.host, @uri.port)\r\n response = http.request(request)\r\n response.body \r\n end", "def create\n account = Account.find(params[:account_id].to_i)\n @transaction = account.transactions.build(transaction_params)\n if @transaction.save\n account.update(balance: account.get_balance)\n transaction_json = TransactionSerializer.new(@transaction).serialized_json\n render json: transaction_json\n else\n render json: {\n errors: @transaction.errors.full_messages\n }\n end\n end", "def accounts\n end", "def create\n @account = IphoneAccount.new(params[:iphone_account])\n current_user.person.iphone_accounts << @account\n\n respond_to do |format|\n if @account.save\n format.html { redirect_to( accounts_path, :notice => 'Account was successfully created.') }\n format.json { render :json => @account, :status => :created, :location => @account }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @account.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @account_user = AccountUser.new(account_user_params)\n respond_to do |format|\n if @account_user.save\n format.html { redirect_to @account_user, notice: 'Account user was successfully created.' }\n format.json { render :show, status: :created, location: @account_user }\n else\n format.html { render :new }\n format.json { render json: @account_user.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @admin_account = AdminAccount.new(params[:admin_account])\n\n respond_to do |format|\n if @admin_account.save\n format.html { redirect_to(@admin_account, :notice => 'Admin account was successfully created.') }\n format.xml { render :xml => @admin_account, :status => :created, :location => @admin_account }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @admin_account.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @account = Account.new(account_params)\n\n respond_to do |format|\n if @account.save\n format.html { send_emails_after_create_and_redirect }\n else\n format.html { render :new }\n end\n end\n end", "def create\n respond_to do |format|\n if CreateAccount.new(@account).save\n format.html { redirect_to first_user_registration_url, notice: 'Account was successfully created.' }\n format.json { render :show, status: :created, location: @account.cname }\n else\n format.html { render :new }\n format.json { render json: @account.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @analytic_account = AnalyticAccount.new(analytic_account_params)\n\n respond_to do |format|\n if @analytic_account.save\n format.html { redirect_to wizard_index_path, notice: 'Analytic account was successfully created.' }\n\n else\n format.html { render :new }\n format.json { render json: @analytic_account.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @account = @user.accounts.new(params[:account])\n\n @account.balance = 0\n @account.principal = 0\n @account.allocation_rate = params[:allocation_rate]\n\n respond_to do |format|\n if @account.save\n format.html { redirect_to accounts_path, notice: 'Account was successfully created.' }\n format.json { render json: @account, status: :created, location: @account }\n else\n format.html { render action: \"new\" }\n format.json { render json: @account.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @account_transaction = AccountTransaction.new(params[:account_transaction])\n\n respond_to do |format|\n if @account_transaction.save\n format.html { redirect_to(@account_transaction, :notice => 'Account transaction was successfully created.') }\n format.xml { render :xml => @account_transaction, :status => :created, :location => @account_transaction }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @account_transaction.errors, :status => :unprocessable_entity }\n end\n end\n end", "def save\n Account.create!(account_params.map do |data|\n {\n type: :facebook,\n user: current_user,\n name: data[:name],\n data: data\n }\n end)\n\n render json: success\n end", "def create\n @account = @project.accounts.build(account_params)\n\n respond_to do |format|\n if @account.save\n format.html { redirect_to @account, notice: 'Account was successfully created.' }\n format.json { render :show, status: :created, location: @account }\n else\n @record = [@project, @account]\n format.html { render :new }\n format.json { render json: @account.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @external_account = ExternalAccount.new(params[:external_account])\n\n respond_to do |format|\n if @external_account.save\n format.html { redirect_to(@external_account, :notice => 'External account was successfully created.') }\n format.xml { render :xml => @external_account, :status => :created, :location => @external_account }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @external_account.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @email_account = current_user.email_accounts.new(email_account_params)\n\n respond_to do |format|\n if @email_account.save\n format.html { redirect_to @email_account, notice: 'Email account was successfully created.' }\n format.json { render action: 'show', status: :created, location: @email_account }\n else\n format.html { render action: 'new' }\n format.json { render json: @email_account.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n # authorize @accounts\n @account = Account.new(account_params)\n @account.user_id=current_user.id\n if @account.save\n redirect_to @account, notice: \"Account was successfully created.\" \n else\n render :new\n end\n end" ]
[ "0.71102715", "0.6868741", "0.6684269", "0.6524815", "0.6496906", "0.64758265", "0.6316858", "0.62342477", "0.6197244", "0.6140472", "0.6137", "0.61312675", "0.61183816", "0.6117599", "0.6101864", "0.60753256", "0.60753256", "0.60753256", "0.60753256", "0.60753256", "0.60753256", "0.60753256", "0.60753256", "0.60753256", "0.6073005", "0.60463315", "0.60322833", "0.60288244", "0.60132337", "0.60130244", "0.59952503", "0.5992489", "0.5977682", "0.59767014", "0.59759396", "0.597493", "0.5956922", "0.59481466", "0.5941058", "0.59252906", "0.59162587", "0.59086007", "0.5904711", "0.5903894", "0.5901176", "0.58997595", "0.589654", "0.58896405", "0.58888686", "0.58887917", "0.58825076", "0.5876008", "0.5868645", "0.586778", "0.58636135", "0.5856763", "0.5837844", "0.5819079", "0.5807239", "0.580471", "0.57794845", "0.5776239", "0.57722646", "0.5771201", "0.57661396", "0.57613754", "0.5760822", "0.5748774", "0.5742845", "0.57391286", "0.57311547", "0.5727833", "0.5727128", "0.57118225", "0.57030964", "0.5702691", "0.57017773", "0.56920034", "0.5685107", "0.5681638", "0.56805146", "0.5677393", "0.5673104", "0.5669389", "0.564651", "0.5634721", "0.56336576", "0.56269175", "0.5623755", "0.5621123", "0.5615176", "0.56112975", "0.56103337", "0.56096816", "0.5608755", "0.56064105", "0.5602055", "0.55976737", "0.559641", "0.5584072" ]
0.6160803
9
PUT /accounts/1 PUT /accounts/1.json PUT /accounts/1.xml
def update @account = Account.find(params[:id]) respond_to do |format| if @account.update_attributes(params[:account]) format.html { redirect_to(@account, :notice => 'Account was successfully updated.') } #format.xml { head :ok } format.json { render :json => @account } format.xml { render :xml => @account } else #format.html { render :action => "edit" } format.json { render :json => @account.errors, :status => :unprocessable_entity } format.xml { render :xml => @account.errors, :status => :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update \n begin\n @resource = Account.find(params[:id])\n @resource.update_attributes!(params[:account])\n render :response => :PUT\n rescue Exception => e\n @error = process_exception(e)\n render :response => :error\n end\n end", "def update\n @account = Account.find(params[:id])\n \n respond_to do |format|\n if @account.update_attributes(params[:account])\n format.html { redirect_to account_url(@account) }\n format.xml { render :nothing => true }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @account.errors.to_xml } \n end\n end\n end", "def update\n respond_to do |format|\n if @api_v1_account.update(api_v1_account_params)\n format.html { redirect_to @api_v1_account, notice: 'Account was successfully updated.' }\n format.json { render :show, status: :ok, location: @api_v1_account }\n else\n format.html { render :edit }\n format.json { render json: @api_v1_account.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_tenant_circle(args = {}) \n put(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend", "def update\n @account = current_user.accounts.find(params[:id])\n\n respond_to do |format|\n if @account.update_attributes(params[:account])\n flash[:notice] = 'Account was successfully updated.'\n format.html { redirect_to([current_user, @account]) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @account.errors, :status => :unprocessable_entity }\n end\n end\n end", "def test_put_invoices_1_xml\n @parameters = {:invoice => {:number => 'NewNumber'}}\n \n Redmine::ApiTest::Base.should_allow_api_authentication(:put,\n '/invoices/1.xml',\n {:invoice => {:number => 'NewNumber'}},\n {:success_code => :ok})\n \n assert_no_difference('Invoice.count') do\n put '/invoices/1.xml', @parameters, credentials('admin')\n end\n \n invoice = Invoice.find(1)\n assert_equal \"NewNumber\", invoice.number\n \n end", "def update opts = {}\n opts[:headers] ||= {}\n opts[:headers]['Content-Type'] ||= 'text/xml'\n post 'update', opts\n end", "def update!\n @authorize = nil\n update_plan! &&\n resp = put(\"/users/#{username}.xml\", {\n :user_key => apikey,\n \"user[first_name]\" => first_name,\n \"user[last_name]\" => last_name\n })\n end", "def update_account(client, options)\n accounts = get_accounts(client, options)\n if accounts.nil?\n return\n end\n\n account = find_account(accounts, options[:email])\n if !account.nil?\n if !options[:firstname].nil?\n account.given_name = options[:firstname]\n end\n if !options[:surname].nil?\n account.surname = options[:surname]\n end\n if !options[:username].nil?\n account.username = options[:username]\n end \n if !options[:password].nil?\n account.password = options[:password]\n end\n if !options[:status].nil?\n account.status = (options[:status] == \"disabled\" ? Stormpath::Resource::Status::DISABLED : Stormpath::Resource::Status::ENABLED)\n end\n\n begin\n account.save\n puts \"Account updated.\"\n rescue Stormpath::Error => e\n print_error(e)\n end\n else\n puts \"Account not found\"\n return\n end\nend", "def update\n @account = account.find(params[:id])\n\n respond_to do |format|\n if @account.update_attributes(params[:account])\n flash[:notice] = 'account was successfully updated.'\n format.html { redirect_to(@account) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @account.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @account = Account.find(params[:id])\n\n respond_to do |format|\n if @account.update_attributes(params[:account])\n format.html { redirect_to(@account, :notice => 'Account was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @account.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update(id, name= \"Updated Name\")\n xml_req =\n \"<?xml version='1.0' encoding='UTF-8'?>\n <customer>\n <id type='integer'>#{id}</id>\n <name>#{name}</name>\n </customer>\"\n\n request = Net::HTTP::Put.new(\"#{@url}/#{id}.xml\")\n request.add_field \"Content-Type\", \"application/xml\"\n request.body = xml_req\n\n http = Net::HTTP.new(@uri.host, @uri.port)\n response = http.request(request)\n\n # no response body will be returned\n case response\n when Net::HTTPSuccess\n return \"#{response.code} OK\"\n else\n return \"#{response.code} ERROR\"\n end\n end", "def update\n @account = current_user.account.find(params[:id])\n\n respond_to do |format|\n if @account.update_attributes(params[:account])\n flash[:notice] = 'Account was successfully updated.'\n format.html { redirect_to(@account) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @account.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @account = Account.find(params[:id])\n\n respond_to do |format|\n if @account.update_attributes(params[:account])\n format.html { redirect_to(\"/home\", :notice => 'Account was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @account.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update(id, name=\"Updated Name\", age=\"55\")\r\n xml_req =\r\n \"<?xml version='1.0' encoding='UTF-8'?>\r\n <person>\r\n <id type='integer'>#{id}</id>\r\n <name>#{name}</name>\r\n <age>#{age}</age> \r\n </person>\"\r\n request = Net::HTTP::Put.new(\"#{@url}/#{id}.xml\")\r\n request.add_field \"Content-Type\", \"application/xml\"\r\n request.body = xml_req\r\n http = Net::HTTP.new(@uri.host, @uri.port)\r\n response = http.request(request)\r\n # no response body will be returned\r\n case response\r\n when Net::HTTPSuccess\r\n return \"#{response.code} OK\"\r\n else\r\n return \"#{response.code} ERROR\"\r\n end\r\n end", "def update_user(id, accountId, model) path = \"/api/v2/accounts/#{accountId}/users/#{id}\"\n put(path, model, {}, AvaTax::VERSION) end", "def set_api_v2_account\n # @account = MasterData::Account.find(params[:id])\n @account = MasterData::Account.find_by(uuid: params[:uuid])\n not_found unless @account\n end", "def put(uri, xml)\r\n req = Net::HTTP::Put.new(uri)\r\n req[\"content-type\"] = \"application/xml\"\r\n req.body = xml\r\n request(req)\r\n end", "def test_should_update_project_via_API_XML\r\n get \"/logout\"\r\n put \"/projects/1.xml\", :project => {:user_id => 1,\r\n :url => 'http://www.apiproject.com',\r\n :name => 'API Project',\r\n :description => 'API Project Desc' }\r\n assert_response 401\r\n end", "def rest_update(uri, method: Net::HTTP::Put)\n request = Net::HTTP::Get.new uri\n request.add_field(\"Accept\",\"application/xml\")\n auth_admin(request)\n \n Net::HTTP.start(uri.host, uri.port) do |http|\n response = http.request request\n response.value\n\n doc = REXML::Document.new response.body\n \n doc = strip_class_attributes(yield doc)\n \n request2 = method.new uri\n request2.content_type = 'application/xml'\n auth_admin(request2)\n\n request2.body=doc.to_s\n \n response2 = http.request request2\n response.value\n\n end\n \nend", "def update\r\n @account = Account.find(params[:id])\r\n\r\n respond_to do |format|\r\n if @account.update_attributes(params[:account])\r\n format.html { redirect_to @account, notice: 'Account 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: @account.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end", "def update_user_for_tenant(args = {}) \n id = args['id']\n temp_path = \"/tenants.json/{tenantId}/users/{userId}\"\n path = temp_path\nargs.keys.each do |key|\n if (key == \"tenantId\")\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 @account = Account.find(params[:id])\n\n respond_to do |format|\n if @account.update_attributes(params[:account])\n format.html { redirect_to @account, notice: 'Account was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @account.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @account.update_attributes(params[:account])\n flash[:notice] = 'Account was successfully updated.'\n format.html { redirect_to(user_accounts_path(current_user)) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @account.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @account = Account.find(params[:id])\n\n respond_to do |format|\n if @account.update_attributes(params[:account])\n format.html { redirect_to @account, notice: 'Account was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @account.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @account = Account.find(params[:id])\n\n respond_to do |format|\n if @account.update_attributes(params[:account])\n format.html { redirect_to @account, notice: 'Account was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @account.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n authorize @account\n if @account.update(account_params)\n render json: { status: :ok, account: @account }\n else\n render json: {error: @account.errors, status: :unprocessable_entity }\n end\n end", "def update\n @account = Admin::Account.find(params[:id])\n\n respond_to do |format|\n if @account.update_attributes(params[:account])\n flash[:notice] = 'Admin::Account was successfully updated.'\n format.html { redirect_to(@account) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @account.errors, :status => :unprocessable_entity }\n end\n end\n end", "def test_should_update_link_via_API_XML\r\n get \"/logout\"\r\n put \"/links/1.xml\", :link => {:user_id => 1,\r\n :title => 'API Link 1',\r\n :url => 'http://www.api.com'}\r\n assert_response 401\r\n end", "def test_should_update_invite_via_API_XML\r\n get \"/logout\"\r\n put \"/invites/1.xml\", :invite => {:message => 'API Invite 1',\r\n :accepted => false,\r\n :email => 'test@email.com',\r\n :user_id => 1 }\r\n assert_response 401\r\n end", "def update\n @account = Account.find(params[:id])\n\n respond_to do |format|\n if @account.update_attributes(params[:account])\n format.html { redirect_to edit_account_url(@account), notice: 'Account was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @account.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_account(id, params)\n put(\"accounts/#{id}\", account: params)\n end", "def update\n @account = current_account \n respond_to do |format|\n if @account.update_attributes(params[:account])\n flash[:notice] = 'Account was successfully updated.'\n format.html { redirect_to user_account_url }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @account.errors, :status => :unprocessable_entity }\n end\n end\n end", "def test_update\n #Again the delete feature from ActiveResource does not work out of the box.\n #Using custom delete function\n puts \"--create a new account--\"\n new_acct = Salesforce::Rest::Account.new(:Name => \"test numero uno\", :BillingStreet=> \"Fairway Meadows\",\n :BillingState => \"NY\", :ShippingCity => \"New York\")\n resp = new_acct.save()\n\n assert (resp.code == 201)\n j = ActiveSupport::JSON\n @sf_oid = j.decode(resp.body)[\"id\"]\n puts \"New Object created: id -> \" + @sf_oid\n\n puts \"--update that new account--\"\n serialized_json = '{\"BillingState\":\"WA\"}'\n #http = Net::HTTP.new(@rest_svr_url, 443)\n http = Net::HTTP.new('na7.salesforce.com', 443)\n http.use_ssl = true\n \n class_name = \"Account\"\n path = \"/services/data/v21.0/sobjects/#{class_name}/#{@sf_oid}\"\n headers = {\n 'Authorization' => \"OAuth \"+ @oauth_token,\n \"content-Type\" => 'application/json',\n }\n code = serialized_json\n\n \n req = Net::HTTPGenericRequest.new(\"PATCH\", true, true, path, headers)\n\n resp = http.request(req, code) { |response| }\n assert !resp.nil?\n\n puts resp.to_s\n end", "def update!(**args)\n @accounts = args[:accounts] if args.key?(:accounts)\n end", "def update\n @account = Account.find(params[:id])\n\n respond_to do |format|\n if @account.update_attributes(params[:account])\n format.html { redirect_to quick_launch_path, notice: 'Account was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @account.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\t\t\t\ttoken = params[:auth_token]\n\t\t\t\tid = params[:id].to_i\n\n\t\t\t\tif token.nil?\n\t\t\t\t\trender :status => 400,\n\t\t\t\t\t\t:json => { :message => \"The request must contain an auth token.\"}\n\t\t\t\t\treturn\n\t\t\t\tend\n\t\t\t\t@user = User.find_by_authentication_token(token)\n\t\t\t\taccount = JSON.parse params[:account]\n\n\t\t\t\tif account[\"username\"].nil?\n\t\t\t\t\trender :status => 400,\n\t\t\t\t\t\t:json => { :message => \"'username' cannot be null.\"}\n\t\t\t\t\treturn\n\t\t\t\tend\n\t\t\t\tif account[\"computer_id\"].nil?\n\t\t\t\t\trender :status => 400,\n\t\t\t\t\t\t:json => { :message => \"The request must contain a 'computer_id'.\"}\n\t\t\t\t\treturn\n\t\t\t\tend\n\t\t\t\t@accounts = Account.where computer_id: @user.computer_ids\n\t\t\t\tif id != 0\n\t\t\t\t\tunless @accounts.pluck(:id).include? id\n\t\t\t\t\t\trender :status => 401,\n\t\t\t\t\t\t\t:json => { :message => \"Access Denied, check account Id.\"}\n\t\t\t\t\t\treturn\n\t\t\t\t\tend\n\t\t\t\tend\n\n\t\t\t\tputs \n\t\t\t\tputs account\n\t\t\t\tputs \n\t\t\t\tputs account[\"account_process_attrubutes\"]\n\t\t\t\tputs \n\t\t\t\tputs \n\t\t\t\t@account = Account.find(id)\n\t\t\t\tif Account.update(id, account)\n\t\t\t\t\trender json: {account: @account}\n\t\t\t\telse\n\t\t\t\t\trender :json => { :message => \"Something went wrong with saving the entity.\"}\n\t\t\t\t\treturn\n\t\t\t\tend\n\t\t\tend", "def put!\n request! :put\n end", "def update\n @account = Account.find(params[:id])\n\n respond_to do |format|\n if @account.update(account_params)\n format.html { redirect_to \"/\", notice: 'Account was successfully updated.' }\n format.json { render :index, status: :ok, location: @account }\n else\n format.html { render :edit }\n format.json { render json: @account.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n email = AuthenticationHelper::Auth.instance.getEmailFromJWT( request )\n if ( email == nil )\n render json: :nothing, status: :unprocessable_entity\n return\n end\n\n user = User.find_by(email: email)\n if ( user )\n account = Account.find_by(user_id: user[\"id\"], id: params[:id])\n \n if ( account == nil )\n render json: :nothing, status: :unprocessable_entity\n return\n end\n\n if account.update(account_params)\n render json: account, status: :ok\n else\n render json: account.errors, status: :unprocessable_entity\n end\n else\n render json: :nothing, status: :unprocessable_entity\n end\n end", "def update options={}\n client.put(\"/#{id}\", options)\n end", "def update\n @account = Account.find(params[:id])\n\n respond_to do |format|\n if @account.update_attributes(params[:account])\n format.html { redirect_to @account, notice: t('common.updated', model: human_name) }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @account.errors, status: :unprocessable_entity }\n end\n end\n end", "def edit_account(account_id, payload)\n put(\"/account/#{account_id}\", payload)\n end", "def update\n @user_account = UserAccount.find(params[:id])\n\n respond_to do |format|\n if @user_account.update_attributes(params[:user_account])\n format.html { redirect_to(@user_account, :notice => 'User account was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @user_account.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @external_account = ExternalAccount.find(params[:id])\n\n respond_to do |format|\n if @external_account.update_attributes(params[:external_account])\n format.html { redirect_to(@external_account, :notice => 'External account was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @external_account.errors, :status => :unprocessable_entity }\n end\n end\n end", "def set_api_v1_account\n @api_v1_account = Api::V1::Account.find(params[:id])\n end", "def update(args)\n builder.update_rest(type, ref, args, username, password)\n self.elements(true)\n end", "def put(*args)\n request :put, *args\n end", "def update\n @company = Company.find(id_from_params)\n\n respond_to do |format|\n if @company.accounts.exists? current_user.account.id\n @company.accounts.delete(current_user.account)\n @company.accounts << current_user.account\n\n format.html { redirect_to root_path, notice: 'Company was successfully updated.' }\n format.json { head :no_content }\n else\n @company.accounts << current_user.account\n format.html { redirect_to root_path, notice: 'Company was successfully updated.' }\n format.json { render json: @company.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @account = Account.find(params[:id])\n authorize! :update, @account\n respond_to do |format|\n if @account.update_attributes(params[:account])\n format.html { redirect_to @account, notice: 'Account was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @account.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @user_account = UserAccount.find(params[:id])\n\n respond_to do |format|\n if @user_account.update_attributes(params[:user_account])\n format.html { redirect_to user_account_url(@user_account.user, @user_account), notice: 'User account was successfully updated.' }\n format.json { head :ok }\n format.xml { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user_account.errors, status: :unprocessable_entity }\n format.xml { render xml: @user_account.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @account = Account.find(params[:id])\n params[:account].delete(:role)\n\n respond_to do |format|\n if @account.update_attributes(params[:account])\n format.html { redirect_to(@account, :notice => 'Account was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @account.errors, :status => :unprocessable_entity }\n end\n end\n end", "def set_account\n response = @account_api.find(params[:id])\n @account = response[:account]\n end", "def update(url, data)\n RestClient.put url, data, :content_type => :json\nend", "def update\n @account = Account.find(params[:id])\n\n respond_to do |format|\n if @account.update(account_params)\n format.html { redirect_to accounts_path, notice: 'Account was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @account.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n account = current_organization.accounts.find(params[:id])\n return forbidden unless account && current_account.allowed_to_edit_account?(account, current_organization)\n return json(account) unless account.update_attributes pick(params, :first_name, :last_name, :email,:language, :document_language)\n\n role = pick(params, :role)\n #account.update_attributes(role) if !role.empty? && current_account.admin?\n membership = current_organization.role_of(account)\n membership.update_attributes(role) if !role.empty? && current_account.admin?\n password = pick(params, :password)[:password]\n if (current_account.id == account.id) && password\n account.update(password: password)\n end\n json account.canonical(membership: membership)\n end", "def update\n @account = current_user.person.iphone_accounts.find(params[:id])\n\n respond_to do |format|\n if @account.update_attributes(params[:iphone_account])\n format.html { redirect_to( accounts_path, :notice => 'Account was successfully updated.') }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @account.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @account.update(account_params)\n format.html { redirect_to action: \"index\" }\n \n else\n format.html { render :edit }\n format.json { render json: @account.errors, status: :unprocessable_entity }\n end\n end\n end", "def update(organisation_id, account_number, name, classification, type, tax, currency, options = {})\n body = options.has_key?(:body) ? options[:body] : {}\n body[:organisation_id] = organisation_id\n body[:account_number] = account_number\n body[:name] = name\n body[:classification] = classification\n body[:type] = type\n body[:tax] = tax\n body[:currency] = currency\n\n response = @client.post \"/core.account/update/#{@account_id}\", body, options\n\n return response\n end", "def update_account(account_number, account_form)\r\n # the base uri for api requests\r\n query_builder = Configuration.base_uri.dup\r\n\r\n # prepare query string for API call\r\n query_builder << '/accounts/{account_number}'\r\n\r\n # process optional query parameters\r\n query_builder = APIHelper.append_url_with_template_parameters query_builder, {\r\n 'account_number' => account_number\r\n }\r\n\r\n # validate and preprocess url\r\n query_url = APIHelper.clean_url query_builder\r\n\r\n # prepare headers\r\n headers = {\r\n 'user-agent' => 'APIMATIC 2.0',\r\n 'content-type' => 'application/json; charset=utf-8',\r\n 'X-Auth-Token' => Configuration.x_auth_token\r\n }\r\n\r\n # invoke the API call request to fetch the response\r\n response = Unirest.put query_url, headers: headers, parameters: account_form.to_json\r\n\r\n # Error handling using HTTP status codes\r\n if response.code == 401\r\n raise APIException.new 'You are not authenticated', 401, response.raw_body\r\n elsif response.code == 403\r\n raise APIException.new 'This action needs a valid WSSE header', 403, response.raw_body\r\n elsif response.code == 404\r\n raise APIException.new 'Resource not found', 404, response.raw_body\r\n elsif response.code == 400\r\n raise APIException.new 'Http bad request', 400, response.raw_body\r\n elsif !response.code.between?(200, 206) # [200,206] = HTTP OK\r\n raise APIException.new 'HTTP Response Not OK', response.code, response.raw_body\r\n end\r\n\r\n response.body\r\n end", "def update\n params[:account][:label_ids] ||= []\n process_file_uploads(@account)\n respond_to do |format|\n if @account.update_attributes(account_params)\n format.html { redirect_to(@account,\n notice: \"Account was successfully updated. #{undo_link}\") }\n format.xml { head :ok }\n else\n handle_error(format, @account, 'edit')\n end\n end\n end", "def update\n\t\t@account = Account.find(params[:id])\n\n\t\trespond_to do |format|\n\t\t\tif @account.update_attributes(params[:account])\n\t\t\t\tformat.html { redirect_to @account, notice: 'Account was successfully updated.' }\n\t\t\t\tformat.json { head :ok }\n\t\t\telse\n\t\t\t\tformat.html { render action: \"edit\" }\n\t\t\t\tformat.json { render json: @account.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend", "def update\n respond_to do |format|\n @account.assign_attributes(account_params)\n if @account.save\n format.html { redirect_to @account, notice: 'Account was successfully updated.' }\n format.json { render :show, status: :ok, location: @account }\n else\n format.html { render :edit }\n format.json { render json: @account.errors, status: :unprocessable_entity }\n end\n end\n end", "def put(user: nil, account_id: nil, service: nil, endpoint: nil, extra_path: nil, query: {}, page: nil, headers: {})\n post(user: user, account_id: account_id, service: service, endpoint: endpoint, extra_path: extra_path, query: query, page: page, headers: headers, method: :put)\n end", "def update(id, params)\n if valid_data?(params)\n update_execution('accounts', params, id)\n else\n print(\"ERROR: couldn't insert account data\")\n end\n end", "def update\n @account = Account.find(params[:id])\n\n respond_to do |format|\n if @account.update_attributes(params[:account])\n format.html { redirect_to @account, :notice => 'Account was successfully updated.' }\n format.json { head :ok }\n else\n @suppliers = Supplier.all(:order=>:name).collect{|c| [c.name, c.id]}\n @aircraft_types = AircraftType.all(:order => :name).collect{|c| [c.name, c.id]}\n\n format.html { render :action => \"edit\" }\n format.json { render :json => @account.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @account = current_user.person.blackberry_accounts.find(params[:id])\n\n respond_to do |format|\n if @account.update_attributes(params[:blackberry_account])\n format.html { redirect_to( accounts_path, :notice => 'Account was successfully updated.') }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @account.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @account_transaction = AccountTransaction.find(params[:id])\n\n respond_to do |format|\n if @account_transaction.update_attributes(params[:account_transaction])\n format.html { redirect_to(@account_transaction, :notice => 'Account transaction was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @account_transaction.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @account = Account.find(params[:id])\n\n respond_to do |format|\n if @account.update_attributes(account_params)\n format.html { redirect_to @account, notice: 'Account was successfully updated.' }\n format.json { head :no_content }\n else\n flash[:error] = @account.errors.empty? ? \"Error\" : @account.errors.full_messages.to_sentence\n format.html { render action: \"edit\" }\n format.json { render json: @account.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @account.update(account_params)\n format.html { redirect_to @account, notice: 'Account was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @account.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_current_logged_in_user(args = {}) \n put(\"/users.json/current\", args)\nend", "def update\n respond_to do |format|\n if @account.update(account_params)\n format.html { redirect_to @account, notice: 'Account was successfully updated.' }\n format.json { render :show, status: :ok, location: @account }\n else\n format.html { render :edit }\n format.json { render json: @account.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @account.update(account_params)\n format.html { redirect_to @account, notice: 'Account was successfully updated.' }\n format.json { render :show, status: :ok, location: @account }\n else\n format.html { render :edit }\n format.json { render json: @account.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @account.update(account_params)\n format.html { redirect_to @account, notice: 'Account was successfully updated.' }\n format.json { render :show, status: :ok, location: @account }\n else\n format.html { render :edit }\n format.json { render json: @account.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @account.update(account_params)\n format.html { redirect_to @account, notice: 'Account was successfully updated.' }\n format.json { render :show, status: :ok, location: @account }\n else\n format.html { render :edit }\n format.json { render json: @account.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @account.update(account_params)\n format.html { redirect_to @account, notice: 'Account was successfully updated.' }\n format.json { render :show, status: :ok, location: @account }\n else\n format.html { render :edit }\n format.json { render json: @account.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @account.update(account_params)\n format.html { redirect_to @account, notice: 'Account was successfully updated.' }\n format.json { render :show, status: :ok, location: @account }\n else\n format.html { render :edit }\n format.json { render json: @account.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @account.update(account_params)\n format.html { redirect_to @account, notice: 'Account was successfully updated.' }\n format.json { render :show, status: :ok, location: @account }\n else\n format.html { render :edit }\n format.json { render json: @account.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @account.update(account_params)\n format.html { redirect_to @account, notice: 'Account was successfully updated.' }\n format.json { render :show, status: :ok, location: @account }\n else\n format.html { render :edit }\n format.json { render json: @account.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @account.update(account_params)\n format.html { redirect_to @account, notice: 'Account was successfully updated.' }\n format.json { render :show, status: :ok, location: @account }\n else\n format.html { render :edit }\n format.json { render json: @account.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @account.update(account_params)\n format.html { redirect_to @account, notice: 'Account was successfully updated.' }\n format.json { render :show, status: :ok, location: @account }\n else\n format.html { render :edit }\n format.json { render json: @account.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @account.update(account_params)\n format.html { redirect_to @account, notice: 'Account was successfully updated.' }\n format.json { render :show, status: :ok, location: @account }\n else\n format.html { render :edit }\n format.json { render json: @account.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @account.update(account_params)\n format.html { redirect_to @account, notice: 'Account was successfully updated.' }\n format.json { render :show, status: :ok, location: @account }\n else\n format.html { render :edit }\n format.json { render json: @account.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @account.update(account_params)\n format.html { redirect_to @account, notice: 'Account was successfully updated.' }\n format.json { render :show, status: :ok, location: @account }\n else\n format.html { render :edit }\n format.json { render json: @account.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @account.update(account_params)\n format.html { redirect_to @account, notice: 'Account was successfully updated.' }\n format.json { render :show, status: :ok, location: @account }\n else\n format.html { render :edit }\n format.json { render json: @account.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @account.update(account_params)\n format.html { redirect_to @account, notice: 'Account was successfully updated.' }\n format.json { render :show, status: :ok, location: @account }\n else\n format.html { render :edit }\n format.json { render json: @account.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @account.update(account_params)\n format.html { redirect_to @account, notice: 'Account was successfully updated.' }\n format.json { render :show, status: :ok, location: @account }\n else\n format.html { render :edit }\n format.json { render json: @account.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @account.update(account_params)\n format.html { redirect_to @account, notice: 'Account was successfully updated.' }\n format.json { render :show, status: :ok, location: @account }\n else\n format.html { render :edit }\n format.json { render json: @account.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @account = Account.find(params[:id])\n\n respond_to do |format|\n if @account.update_attributes(params[:account])\n sign_in @account\n format.html { redirect_to @account, notice: 'Account was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @account.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @account.update(account_params)\n render :show, status: :ok, location: @account\n else\n render json: @account.errors, status: :unprocessable_entity\n end\n end", "def account_put_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: IdentityApi.account_put ...\"\n end\n # resource path\n local_var_path = \"/account\"\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = @api_client.object_to_http_body(opts[:'body'])\n auth_names = ['basicAuth']\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 => 'AccountResponse')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: IdentityApi#account_put\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def update\n respond_to do |format|\n if @account.update(account_params)\n format.html { redirect_to account_path(@account), notice: I18n.t('notice.update', model: t('account.name')) }\n format.json { render :show, status: :ok, location: @account }\n else\n format.html { render :edit }\n format.json { render json: @account.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @transaction.update(account_params)\n format.html { redirect_to @transaction, notice: 'Account was successfully updated.' }\n format.json { render :show, status: :ok, location: @transaction }\n else\n format.html { render :edit }\n format.json { render json: @transaction.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n set_action(:update)\n set_account_type\n validate_account_type!\n assign_params\n set_affiliate\n set_updated_by\n\n after_update\n account\n end", "def update\n flash[:notice] = 'The account was successfully updated.' if account.update_attributes(params[:account])\n respond_with(account)\n end", "def set_account\n @accounts = Account.find(params[:id])\n end", "def test_put_expenses_1_xml\n @parameters = {:expense => {:description => 'NewDescription'}}\n if ActiveRecord::VERSION::MAJOR < 4\n Redmine::ApiTest::Base.should_allow_api_authentication(:put,\n '/expenses/1.xml',\n {:expense => {:description => 'NewDescription'}},\n {:success_code => :ok})\n end\n\n assert_no_difference('Expense.count') do\n put '/expenses/1.xml', @parameters, credentials('admin')\n end\n\n expense = Expense.find(1)\n assert_equal \"NewDescription\", expense.description\n end", "def test_should_update_membership\n login_as(:john)\n put :update, :id => 1, :membership => { }\n assert_response :redirect\n end", "def test_should_update_membership\n login_as(:john)\n put :update, :id => 1, :membership => { }\n assert_response :redirect\n end" ]
[ "0.6582911", "0.62882286", "0.6170285", "0.6144252", "0.61401206", "0.6111649", "0.60994047", "0.6091328", "0.6059104", "0.6051299", "0.6023935", "0.5987549", "0.5971014", "0.59697706", "0.5955359", "0.5952719", "0.5938624", "0.59378016", "0.5932825", "0.59210664", "0.5893963", "0.58896315", "0.58854276", "0.5871166", "0.5866095", "0.5866095", "0.5862787", "0.5860281", "0.5847801", "0.5839009", "0.58261925", "0.58231044", "0.58148885", "0.58082616", "0.5790985", "0.5787674", "0.5750255", "0.57465357", "0.57262135", "0.5721112", "0.5714749", "0.57022387", "0.56927556", "0.56832176", "0.566935", "0.56658393", "0.5665375", "0.56574833", "0.5646208", "0.56443787", "0.56389445", "0.5626809", "0.56253266", "0.5623447", "0.56218934", "0.56194", "0.5617454", "0.5611716", "0.5610784", "0.5609813", "0.55847603", "0.5574355", "0.5571689", "0.5569997", "0.55698144", "0.55580384", "0.55567163", "0.55546194", "0.55516684", "0.55497766", "0.55425894", "0.55412745", "0.55384797", "0.55384797", "0.55384797", "0.55384797", "0.55384797", "0.55384797", "0.55384797", "0.55384797", "0.55384797", "0.55384797", "0.55384797", "0.55384797", "0.55384797", "0.55384797", "0.55384797", "0.55384797", "0.55384797", "0.55296236", "0.55241376", "0.55234563", "0.5498494", "0.5491661", "0.5473493", "0.5469607", "0.5453645", "0.5451305", "0.5434103", "0.5434103" ]
0.6237412
2
By this point, we assume ScheduleMergeRequestDiffMigrations the first version of this has already run. On GitLab.com, we have ~220k unmigrated rows, but these rows will, in general, take a long time. With a gap of 10 minutes per batch, and 500 rows per batch, these migrations are scheduled over 220_000 / 500 / 6 ~= 74 hours, which is a little over three days.
def up queue_background_migration_jobs_by_range_at_intervals(MergeRequestDiff, MIGRATION, DELAY_INTERVAL, batch_size: BATCH_SIZE) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def up\n Build.where(stage_id: nil).each_batch(of: BATCH_SIZE) do |relation, index|\n relation.each_batch(of: RANGE_SIZE) do |relation|\n range = relation.pluck('MIN(id)', 'MAX(id)').first\n\n BackgroundMigrationWorker\n .perform_in(index * 2.minutes, MIGRATION, range)\n end\n end\n end", "def migrate_merge_requests\n batched_migrate(MergeRequest, :author_id)\n batched_migrate(MergeRequest, :merge_user_id)\n end", "def find_migration_tuples # rubocop:disable Metrics/AbcSize, Metrics/PerceivedComplexity\n up_mts = []\n down_mts = []\n files.each do |path|\n f = File.basename(path)\n fi = f.downcase\n if target\n if migration_version_from_file(f) > target\n down_mts << [load_migration_file(path), f, :down] if applied_migrations.include?(fi)\n elsif !applied_migrations.include?(fi)\n up_mts << [load_migration_file(path), f, :up]\n end\n elsif !applied_migrations.include?(fi)\n up_mts << [load_migration_file(path), f, :up]\n end\n end\n up_mts + down_mts.reverse\n end", "def pending_migrations\n (migrations - performed_migrations).sort\n end", "def up\n return unless Gitlab.ee?\n\n JobArtifact\n .where(\"file_type = 10 OR file_type = 101\")\n .each_batch(column: :job_id, of: 1000) do |relation|\n min, max = relation.pluck('MIN(job_id)', 'MAX(job_id)').flatten\n\n ActiveRecord::Base.connection.execute <<~SQL\n WITH ci_job_artifacts_with_row_number as (\n SELECT job_id, id, ROW_NUMBER() OVER (PARTITION BY job_id ORDER BY id ASC) as row_number\n FROM ci_job_artifacts\n WHERE (file_type = #{LICENSE_SCANNING_FILE_TYPE} OR file_type = #{LICENSE_MANAGEMENT_FILE_TYPE})\n AND job_id >= #{Integer(min)} AND job_id < #{Integer(max)}\n )\n DELETE FROM ci_job_artifacts\n WHERE ci_job_artifacts.id IN (SELECT id from ci_job_artifacts_with_row_number WHERE ci_job_artifacts_with_row_number.row_number > 1)\n SQL\n end\n\n JobArtifact.where(file_type: LICENSE_MANAGEMENT_FILE_TYPE).each_batch(column: :job_id, of: 1000) do |relation|\n relation.update_all(file_type: LICENSE_SCANNING_FILE_TYPE)\n end\n end", "def run\n connect\n src = @source_connection\n dest = @destination_connection\n\n log \"BEGINNING MIGRATION\\n\" +\n \"-------------------\"\n\n # Iterate through table mappings\n maps.each do |table|\n log \"MIGRATING TABLE #{table.source}\"\n\n # Fetch all rows from source table\n rows = src[table.source.to_sym].all\n \n # Iterate through the records and migrate each one\n rows.each do |row|\n new_record = {}\n\n # Identify the columns we need to grab data from\n table.maps.each do |column|\n new_record.merge!(\n column.destination.to_sym => row[column.source.to_sym]\n )\n end\n\n # Insert new record to destination table\n log \" -> Inserting record into #{table.destination}\"\n dest[table.destination.to_sym].insert(new_record)\n end\n end\n\n log \"-------------------\\n\" +\n \"MIGRATION COMPLETED\"\n end", "def up\n delete_queued_jobs(MIGRATION)\n\n requeue_background_migration_jobs_by_range_at_intervals(MIGRATION, DELAY_INTERVAL)\n end", "def perform_migration\n download_threads = []\n upload_threads = []\n\n @source_container.files.each { |f| @download_list.push(f) }\n\n DOWNLOAD_THREAD_COUNT.times do\n download_threads << download_thread\n end\n UPLOAD_THREAD_COUNT.times do\n upload_threads << upload_thread\n end\n\n download_threads.each { |t| t.join }\n @download_finished = true\n upload_threads.each { |t| t.join }\n true\n rescue => e\n if @options[:verbose]\n puts \"#{CLI.bold}#{CLI.red}*** Error ***#{CLI.reset}\"\n puts e.inspect\n puts e.backtrace\n puts\n end\n false\n end", "def update_migration_files\n migration_templates = Dir.children(File.join(TEMPLATES, 'migrations')).sort\n migration_templates.each do |template_file|\n destination_file = template_file.match(/^\\d*_(.*\\.rb)/)[1] # 01_create_good_jobs.rb.erb => create_good_jobs.rb\n migration_template \"migrations/#{template_file}\", File.join(db_migrate_path, destination_file), skip: true\n end\n end", "def execute_update!( activerecord_class )\n collector = @row_collectors[ activerecord_class.table_name ]\n process_text_log << \"Updating #{ activerecord_class.name }...\\r\\n\"\n sql_diff_text_log << \"\\r\\n-- Updates for #{ activerecord_class.name }:\\r\\n\"\n is_ok = true\n begin\n collector.non_duplicates_rows.each do |row|\n sql_attributes = {}\n if row.respond_to?(:swimmer_id) # Correct the swimmer_id link:\n row.swimmer_id = @master_swimmer.id\n sql_attributes['swimmer_id'] = @master_swimmer.id\n end\n # Correct the badge link, when included in the matrix:\n if row.respond_to?(:badge_id) && @dup_badge_matrix_ids.has_key?( row.badge_id )\n row.badge_id = @dup_badge_matrix_ids[ row.badge_id ]\n sql_attributes['badge_id'] = row.badge_id\n end\n\n if row.invalid? # Check validation:\n msg = \"\\r\\n\\r\\n-- *** Swimmer Merge: validation ERROR during #{ row.class.name } update!\\r\\n\" <<\n \"- row..............: #{ row.inspect }\\r\\n\" <<\n \"- sql_attributes...: #{ sql_attributes.inspect }\\r\\n\" <<\n \"\\r\\n- ERROR............: #{ ValidationErrorTools.recursive_error_for( row ) }\\r\\n\"\n# DEBUG\n puts msg\n process_text_log << msg\n end\n row.save!\n # Build-up SQL-diff:\n if sql_attributes.size > 0 # (false = no additional comment)\n sql_diff_text_log << to_sql_update( row, false, sql_attributes, \"\\r\\n\" )\n end\n end\n rescue\n process_text_log << \"\\r\\n\\r\\n*** Swimmer Merge: exception caught!\\r\\n\"\n process_text_log << \"*** Phase '#{ activerecord_class.name } UPDATE': #{ $!.to_s }\\r\\n\" if $!\n process_text_log << sql_diff_text_log\n is_ok = false\n end\n is_ok\n end", "def performed_migrations\n rows = column_family.select\n rows.map { |row|\n path = migrations_path.join(\"#{row['version']}_#{row['name']}.rb\")\n MigrationProxy.new(path)\n }.sort\n end", "def migrate\n with_maintenance do\n backup if backup?\n run_migration\n restart\n end\n end", "def updatable_merge_requests_union_sql\n metrics_not_exists_clause =\n 'NOT EXISTS (SELECT 1 FROM merge_request_metrics WHERE merge_request_metrics.merge_request_id = merge_requests.id)'\n\n without_metrics_data = <<-SQL.strip_heredoc\n merge_request_metrics.merged_by_id IS NULL OR\n merge_request_metrics.latest_closed_by_id IS NULL OR\n merge_request_metrics.latest_closed_at IS NULL\n SQL\n\n mrs_without_metrics_record = MergeRequest\n .where(metrics_not_exists_clause)\n .select(:id)\n\n mrs_without_events_data = MergeRequest\n .joins('INNER JOIN merge_request_metrics ON merge_requests.id = merge_request_metrics.merge_request_id')\n .where(without_metrics_data)\n .select(:id)\n\n Gitlab::SQL::Union.new([mrs_without_metrics_record, mrs_without_events_data]).to_sql\n end", "def migrations\n @migrations ||= {}\n end", "def migrate(table_arr)\n table_arr.each do |table_name|\n self.task_queue << {:name=>:migrate_table,:args=>[table_name]}\n end\n end", "def process!()\n # Regarding updates or deletions of :badge_id\n # --------------------------------------------------------------------\n # This has to change only if it refers to a duplicate row;\n # that is, a row that will become a duplicate (and it will have to\n # be deleted) once that the update (and translation) process has been\n # completed.\n #\n # Thus, each linked entity that has a reference to one of these\n # possibly duplicate IDs has to be updated with the new destination value\n # (of which they are the duplicate); else, the value for :badge_id can stay untouched.\n\n merge_done = false\n if check\n process_text_log << \"\\r\\nMerging '#{ @slave_swimmer.complete_name }' (id: #{ @slave_swimmer.id}) => '#{@master_swimmer.complete_name}' (id: #{@master_swimmer.id })...\\r\\n\\r\\n\"\n sql_diff_text_log << \"-- Merging '#{ @slave_swimmer.complete_name }' (id: #{ @slave_swimmer.id}) => '#{@master_swimmer.complete_name}' (id: #{@master_swimmer.id })...\\r\\n\\r\\n\"\n\n # Define merge schema (involved entities)\n @involved_entities = SwimmerMerger.get_involved_entities\n\n # Collect entity row to merge\n @involved_entities.each do |involved_entity|\n collect_swimmer_inolved_entity( involved_entity )\n end\n\n # Collect badges to merge (both swimmers have badges for the same season)\n collect_badges_to_merge\n\n # N.B. Checks for some recalculation needed should be performed before update and delete phases\n # Check if Goggle Cup standards needs recalculation\n needs_goggle_cup_recalculation = needs_goggle_cup_recalculation?\n\n # Check if seasonal personal standards needs recalculation\n needs_season_personal_standard_recalculation = needs_season_personal_standard_recalculation?\n\n # Perform the merge: update and delete phases\n # Bail out from any of these, if something goes wrong:\n merge_done = update_phase! && create_alias_phase! && delete_phase! && execute_delete!( Swimmer )\n\n if merge_done\n if @row_collectors[ MeetingIndividualResult.table_name ].non_duplicates_rows.size > 0\n # Recalculate personal bests\n process_text_log << \"\\r\\n\\r\\nPersonal-bests recalculation needed...\\r\\n\"\n swimmer_best_updater = SwimmerPersonalBestUpdater.new( @master_swimmer )\n swimmer_best_updater.scan_for_personal_best!\n sql_diff_text_log << swimmer_best_updater.sql_diff_text_log\n process_text_log << \"Personal-bests recalculation done!\\r\\n\"\n end\n\n # TODO if needed, also recalculate goggle_cup_standards\n if needs_goggle_cup_recalculation\n process_text_log << \"\\r\\n\\r\\n*** I M P O R T A N T ***\\r\\n\"\n process_text_log << \"Goggle-cup standards recalculation needed...\\r\\n\"\n end\n\n # TODO if needed, also recalculate season_personal_standards\n if needs_season_personal_standard_recalculation?\n process_text_log << \"\\r\\n\\r\\n*** I M P O R T A N T ***\\r\\n\"\n process_text_log << \"Season personal standards recalculation needed...\\r\\n\"\n end\n end\n end\n merge_done\n end", "def assume_migrated_upto_version(version, migrations_paths)\n migrations_paths = Array(migrations_paths)\n version = version.to_i\n\n migrated = ActiveRecord::SchemaMigration.all_versions.map(&:to_i)\n versions = migration_context.migration_files.map do |file|\n migration_context.parse_migration_filename(file).first.to_i\n end\n\n unless migrated.include?(version)\n execute insert_versions_sql(version)\n end\n\n inserting = (versions - migrated).select { |v| v < version }\n if inserting.any?\n if (duplicate = inserting.detect { |v| inserting.count(v) > 1 })\n raise \"Duplicate migration #{duplicate}. Please renumber your migrations to resolve the conflict.\"\n end\n if supports_multi_insert?\n execute insert_versions_sql(inserting)\n else\n inserting.each do |v|\n execute insert_versions_sql(v)\n end\n end\n end\n end", "def prepare_wellfargo_corresp_batch\n lockbox_number = parse(config[\"BATCH\"][\"lockbox\"]).to_s\n deposit_date = parse(config[\"BATCH\"][\"date\"][0]).to_s\n deposit_date = Date.rr_parse(deposit_date)\n index_batch_number = parse(config['BATCH']['batchid']).to_s\n reconciliation_informations = ReconciliationInformation.find_all_by_deposit_date_and_lockbox_number(deposit_date, lockbox_number)\n raise \"ERROR >> Reconciliation information not found for this cut. Please load reconciliation csv first. Command: 'rake new_input:import_reconciliation_csv['<path>']'\" if reconciliation_informations.blank?\n current_batch = reconciliation_informations.detect{|ri| ri.index_batch_number.to_s.strip == index_batch_number}\n raise \"ERROR >> This batch(batchid: #{index_batch_number}) is not mentioned in reconciliation CSV. PLease check it\" if current_batch.blank?\n\n\n batch_ids_in_cut = reconciliation_informations.collect(&:index_batch_number)\n corresp_batch_ids = batch_ids_in_cut.select{|id|(900..999).include?(id.to_i)}\n @bat = Batch.find_by_date_and_lockbox(deposit_date, lockbox_number)\n unless @bat\n raise \"ERROR >> This batch(batchid: #{index_batch_number}) has already been loaded\" if current_batch.is_batch_loaded\n payment_batch_ids = batch_ids_in_cut - corresp_batch_ids\n prepare_batch\n @bat.index_batch_number = payment_batch_ids.blank? ? '2' : payment_batch_ids.sort.last.to_i + 1\n end\n\n current_batch.update_attributes(:is_batch_loaded => 1)\n @bat.status = (reconciliation_informations.detect{|ri| (900..999).include?(ri.index_batch_number.to_i) && !ri.is_batch_loaded }).blank? ? BatchStatus::NEW : 'Incomplete Cut'\n end", "def perform(table, old_column, new_column)\n return unless column_exists?(table, new_column)\n\n rows_to_migrate = define_model_for(table)\n .where(new_column => nil)\n .where\n .not(old_column => nil)\n\n if rows_to_migrate.any?\n BackgroundMigrationWorker.perform_in(\n RESCHEDULE_DELAY,\n self.class.name,\n [table, old_column, new_column]\n )\n else\n cleanup_concurrent_schema_change(table, old_column, new_column)\n end\n end", "def auto_merge_teams(unassigned_teams, _final_team_topics)\n assignment = Assignment.find(params[:id])\n # Sort unassigned\n unassigned_teams = Team.where(id: unassigned_teams).sort_by {|t| !t.users.size }\n unassigned_teams.each do |team|\n sorted_bids = Bid.where(user_id: team.id).sort_by(&:priority) # Get priority for each unassignmed team\n sorted_bids.each do |b|\n winning_team = SignedUpTeam.where(topic: b.topic_id).first.team_id\n next unless TeamsUser.where(team_id: winning_team).size + team.users.size <= assignment.max_team_size # If the team can be merged to a bigger team\n TeamsUser.where(team_id: team.id).update_all(team_id: winning_team)\n Bid.delete_all(user_id: team.id)\n Team.delete(team.id)\n break\n end\n end\n end", "def test_pending_migration_is_not_applied\r\n @mm.set_pending(@config, @connection)\r\n assert_equal(false, @mm.applied?(@config, @connection))\r\n end", "def assume_migrated_upto_version(version, migrations_paths = nil)\n unless migrations_paths.nil?\n ActiveSupport::Deprecation.warn(<<~MSG.squish)\n Passing migrations_paths to #assume_migrated_upto_version is deprecated and will be removed in Rails 6.1.\n MSG\n end\n\n version = version.to_i\n sm_table = quote_table_name(schema_migration.table_name)\n\n migrated = migration_context.get_all_versions\n versions = migration_context.migrations.map(&:version)\n\n unless migrated.include?(version)\n execute insert_versions_sql(version.to_s)\n end\n\n inserting = (versions - migrated).select { |v| v < version }\n if inserting.any?\n if (duplicate = inserting.detect { |v| inserting.count(v) > 1 })\n raise \"Duplicate migration #{duplicate}. Please renumber your migrations to resolve the conflict.\"\n end\n\n execute insert_versions_sql(inserting.map(&:to_s))\n end\n end", "def copy_migrations\n [\n 'create_file_view_stats.rb',\n 'create_file_download_stats.rb'\n ].each do |file|\n better_migration_template file\n end\n end", "def create_or_update_previous_runs!; end", "def create_or_update_previous_runs!; end", "def run_upwards\n result = request\n\n bond.applying_migrations.each do |migration|\n result = migration.up(result)\n end\n\n result\n end", "def migrate_files_to_external_storage!\n return if stored_externally? || !use_external_diff? || merge_request_diff_files.count == 0\n\n rows = build_merge_request_diff_files(merge_request_diff_files)\n\n transaction do\n MergeRequestDiffFile.where(merge_request_diff_id: id).delete_all\n create_merge_request_diff_files(rows)\n save!\n end\n\n merge_request_diff_files.reset\n end", "def migrate\n run_migrations pending_migrations, :up\n end", "def migratable\n migratable_since(default_migratable_date)\n end", "def upgrade(migrations, context, meta_node)\n migrations.each do |m|\n Neo4j.logger.info \"Running upgrade: #{m}\"\n m.execute_up(context, meta_node)\n end\n end", "def apply_single\n validate_schema\n\n # Prepare some lists of columns.\n key_cols = @db1.primary_key(@table1)\n data_cols = @db1.except_primary_key(@table1)\n all_cols = @db1.column_names(@table1)\n\n # Let our public know we are beginning.\n @patch.begin_diff\n\n # Advertise column names.\n @rc_columns = DiffColumns.new\n @rc_columns.title_row = all_cols\n @rc_columns.update(0)\n cells = all_cols.map{|v| { :txt => v, :value => v, :cell_mode => \"\" }}\n rc = RowChange.new(\"@@\",cells)\n @patch.apply_row(rc)\n\n # If requested, we will be providing context rows around changed rows.\n # This is not a natural thing to do with SQL, so we do it only on request.\n # When requested, we need to buffer row changes.\n @pending_rcs = []\n\n # Prepare some useful SQL fragments to assemble later.\n sql_table1 = @db1.quote_table(@table1)\n sql_table2 = @db1.quote_table(@table2)\n sql_key_cols = key_cols.map{|c| @db1.quote_column(c)}.join(\",\")\n sql_all_cols = all_cols.map{|c| @db1.quote_column(c)}.join(\",\")\n sql_key_match = key_cols.map{|c| @db1.quote_column(c)}.map{|c| \"#{sql_table1}.#{c} IS #{sql_table2}.#{c}\"}.join(\" AND \")\n sql_data_mismatch = data_cols.map{|c| @db1.quote_column(c)}.map{|c| \"#{sql_table1}.#{c} IS NOT #{sql_table2}.#{c}\"}.join(\" OR \")\n\n # For one query we will need to interleave columns from two tables. For\n # portability we need to give these columns distinct names.\n weave = all_cols.map{|c| [[sql_table1,@db1.quote_column(c)],\n [sql_table2,@db2.quote_column(c)]]}.flatten(1)\n dbl_cols = weave.map{|c| \"#{c[0]}.#{c[1]}\"}\n sql_dbl_cols = weave.map{|c| \"#{c[0]}.#{c[1]} AS #{c[0].gsub(/[^a-zA-Z0-9]/,'_')}_#{c[1].gsub(/[^a-zA-Z0-9]/,'_')}\"}.join(\",\")\n\n # Prepare a map of primary key offsets.\n keys_in_all_cols = key_cols.each.map{|c| all_cols.index(c)}\n keys_in_dbl_cols = keys_in_all_cols.map{|x| 2*x}\n\n # Find rows in table2 that are not in table1.\n sql = \"SELECT #{sql_all_cols} FROM #{sql_table2} WHERE NOT EXISTS (SELECT 1 FROM #{sql_table1} WHERE #{sql_key_match})\"\n apply_inserts(sql,all_cols,keys_in_all_cols)\n\n # Find rows in table1 and table2 that differ while having the same primary\n # key.\n sql = \"SELECT #{sql_dbl_cols} FROM #{sql_table1} INNER JOIN #{sql_table2} ON #{sql_key_match} WHERE #{sql_data_mismatch}\"\n apply_updates(sql,dbl_cols,keys_in_dbl_cols)\n\n # Find rows that are in table1 but not table2\n sql = \"SELECT #{sql_all_cols} FROM #{sql_table1} WHERE NOT EXISTS (SELECT 1 FROM #{sql_table2} WHERE #{sql_key_match})\"\n apply_deletes(sql,all_cols,keys_in_all_cols)\n\n # If we are supposed to provide context, we need to deal with row order.\n if @patch.want_context\n sql = \"SELECT #{sql_all_cols}, 0 AS __coopy_tag__ FROM #{sql_table1} UNION SELECT #{sql_all_cols}, 1 AS __coopy_tag__ FROM #{sql_table2} ORDER BY #{sql_key_cols}, __coopy_tag__\"\n apply_with_context(sql,all_cols,keys_in_all_cols)\n end\n\n # Done!\n @patch.end_diff\n end", "def apply_single\n validate_schema\n\n # Prepare some lists of columns.\n key_cols = @db1.primary_key(@table1)\n data_cols = @db1.except_primary_key(@table1)\n all_cols = @db1.column_names(@table1)\n\n # Let our public know we are beginning.\n @patch.begin_diff\n\n # Advertise column names.\n @rc_columns = DiffColumns.new\n @rc_columns.title_row = all_cols\n @rc_columns.update(0)\n cells = all_cols.map{|v| { :txt => v, :value => v, :cell_mode => \"\" }}\n rc = RowChange.new(\"@@\",cells)\n @patch.apply_row(rc)\n\n # If requested, we will be providing context rows around changed rows.\n # This is not a natural thing to do with SQL, so we do it only on request.\n # When requested, we need to buffer row changes.\n @pending_rcs = []\n\n # Prepare some useful SQL fragments to assemble later.\n sql_table1 = @db1.quote_table(@table1)\n sql_table2 = @db1.quote_table(@table2)\n sql_key_cols = key_cols.map{|c| @db1.quote_column(c)}.join(\",\")\n sql_all_cols = all_cols.map{|c| @db1.quote_column(c)}.join(\",\")\n sql_key_match = key_cols.map{|c| @db1.quote_column(c)}.map{|c| \"#{sql_table1}.#{c} IS #{sql_table2}.#{c}\"}.join(\" AND \")\n sql_data_mismatch = data_cols.map{|c| @db1.quote_column(c)}.map{|c| \"#{sql_table1}.#{c} IS NOT #{sql_table2}.#{c}\"}.join(\" OR \")\n\n # For one query we will need to interleave columns from two tables. For\n # portability we need to give these columns distinct names.\n weave = all_cols.map{|c| [[sql_table1,@db1.quote_column(c)],\n [sql_table2,@db2.quote_column(c)]]}.flatten(1)\n dbl_cols = weave.map{|c| \"#{c[0]}.#{c[1]}\"}\n sql_dbl_cols = weave.map{|c| \"#{c[0]}.#{c[1]} AS #{c[0].gsub(/[^a-zA-Z0-9]/,'_')}_#{c[1].gsub(/[^a-zA-Z0-9]/,'_')}\"}.join(\",\")\n\n # Prepare a map of primary key offsets.\n keys_in_all_cols = key_cols.each.map{|c| all_cols.index(c)}\n keys_in_dbl_cols = keys_in_all_cols.map{|x| 2*x}\n\n # Find rows in table2 that are not in table1.\n sql = \"SELECT #{sql_all_cols} FROM #{sql_table2} WHERE NOT EXISTS (SELECT 1 FROM #{sql_table1} WHERE #{sql_key_match})\"\n apply_inserts(sql,all_cols,keys_in_all_cols)\n\n # Find rows in table1 and table2 that differ while having the same primary\n # key.\n sql = \"SELECT #{sql_dbl_cols} FROM #{sql_table1} INNER JOIN #{sql_table2} ON #{sql_key_match} WHERE #{sql_data_mismatch}\"\n apply_updates(sql,dbl_cols,keys_in_dbl_cols)\n\n # Find rows that are in table1 but not table2\n sql = \"SELECT #{sql_all_cols} FROM #{sql_table1} WHERE NOT EXISTS (SELECT 1 FROM #{sql_table2} WHERE #{sql_key_match})\"\n apply_deletes(sql,all_cols,keys_in_all_cols)\n\n # If we are supposed to provide context, we need to deal with row order.\n if @patch.want_context\n sql = \"SELECT #{sql_all_cols}, 0 AS __coopy_tag__ FROM #{sql_table1} UNION SELECT #{sql_all_cols}, 1 AS __coopy_tag__ FROM #{sql_table2} ORDER BY #{sql_key_cols}, __coopy_tag__\"\n apply_with_context(sql,all_cols,keys_in_all_cols)\n end\n\n # Done!\n @patch.end_diff\n end", "def apply_single\n validate_schema\n\n # Prepare some lists of columns.\n key_cols = @db1.primary_key(@table1)\n data_cols = @db1.except_primary_key(@table1)\n all_cols = @db1.column_names(@table1)\n\n # Let our public know we are beginning.\n @patch.begin_diff\n\n # Advertise column names.\n @rc_columns = DiffColumns.new\n @rc_columns.title_row = all_cols\n @rc_columns.update(0)\n cells = all_cols.map{|v| { :txt => v, :value => v, :cell_mode => \"\" }}\n rc = RowChange.new(\"@@\",cells)\n @patch.apply_row(rc)\n\n # If requested, we will be providing context rows around changed rows.\n # This is not a natural thing to do with SQL, so we do it only on request.\n # When requested, we need to buffer row changes.\n @pending_rcs = []\n\n # Prepare some useful SQL fragments to assemble later.\n sql_table1 = @db1.quote_table(@table1)\n sql_table2 = @db1.quote_table(@table2)\n sql_key_cols = key_cols.map{|c| @db1.quote_column(c)}.join(\",\")\n sql_all_cols = all_cols.map{|c| @db1.quote_column(c)}.join(\",\")\n sql_key_match = key_cols.map{|c| @db1.quote_column(c)}.map{|c| \"#{sql_table1}.#{c} IS #{sql_table2}.#{c}\"}.join(\" AND \")\n sql_data_mismatch = data_cols.map{|c| @db1.quote_column(c)}.map{|c| \"#{sql_table1}.#{c} IS NOT #{sql_table2}.#{c}\"}.join(\" OR \")\n\n # For one query we will need to interleave columns from two tables. For\n # portability we need to give these columns distinct names.\n weave = all_cols.map{|c| [[sql_table1,@db1.quote_column(c)],\n [sql_table2,@db2.quote_column(c)]]}.flatten(1)\n dbl_cols = weave.map{|c| \"#{c[0]}.#{c[1]}\"}\n sql_dbl_cols = weave.map{|c| \"#{c[0]}.#{c[1]} AS #{c[0].gsub(/[^a-zA-Z0-9]/,'_')}_#{c[1].gsub(/[^a-zA-Z0-9]/,'_')}\"}.join(\",\")\n\n # Prepare a map of primary key offsets.\n keys_in_all_cols = key_cols.each.map{|c| all_cols.index(c)}\n keys_in_dbl_cols = keys_in_all_cols.map{|x| 2*x}\n\n # Find rows in table2 that are not in table1.\n sql = \"SELECT #{sql_all_cols} FROM #{sql_table2} WHERE NOT EXISTS (SELECT 1 FROM #{sql_table1} WHERE #{sql_key_match})\"\n apply_inserts(sql,all_cols,keys_in_all_cols)\n\n # Find rows in table1 and table2 that differ while having the same primary\n # key.\n sql = \"SELECT #{sql_dbl_cols} FROM #{sql_table1} INNER JOIN #{sql_table2} ON #{sql_key_match} WHERE #{sql_data_mismatch}\"\n apply_updates(sql,dbl_cols,keys_in_dbl_cols)\n\n # Find rows that are in table1 but not table2\n sql = \"SELECT #{sql_all_cols} FROM #{sql_table1} WHERE NOT EXISTS (SELECT 1 FROM #{sql_table2} WHERE #{sql_key_match})\"\n apply_deletes(sql,all_cols,keys_in_all_cols)\n\n # If we are supposed to provide context, we need to deal with row order.\n if @patch.want_context\n sql = \"SELECT #{sql_all_cols}, 0 AS __coopy_tag__ FROM #{sql_table1} UNION SELECT #{sql_all_cols}, 1 AS __coopy_tag__ FROM #{sql_table2} ORDER BY #{sql_key_cols}, __coopy_tag__\"\n apply_with_context(sql,all_cols,keys_in_all_cols)\n end\n\n # Done!\n @patch.end_diff\n end", "def copy_migrations\n \n # get an array of the migrations in your engine's db/migrate/ \n # folder:\n \n migrations = Dir[Bulky::Engine.root.join(\"db/migrate/*.rb\")]\n migrations.each_with_index do |migration, i|\n \n # The migrations will be created with the same timestamp if you \n # create them all at once. So if you have more than one migration \n # in your engine, add one second to the second migration's file\n # timestamp and a third second to the third migration's timestamp \n # and so on:\n \n seconds = (DateTime.now.strftime(\"%S\").to_i + i).to_s\n seconds = seconds.to_s.length == 2 ? seconds : \"0#{seconds}\"\n timestamp = (DateTime.now.strftime \"%Y%m%d%H%M\") + seconds\n \n # get the filename from the engine migration minus the timestamp:\n name = migration.split(\"/\").last.split(\"_\")[1..-1].join(\"_\")\n # puts name\n \n # See if a the name of your engine migration is already in your\n # host app's db/migrate folder:\n \n if Rails.root.join(\"db/migrate/*#{name}\").exist?\n \n # do nothing:\n puts \"Migration #{name} has already been copied to your app\"\n else\n \n # copy your engine migration over to the host app with a new \n # timestamp:\n copy_file migration, \"db/migrate/#{timestamp}_#{name}\"\n end\n end\n end", "def mysql_v2_migration_lookup_scripts\n #TODO fix this so epoch is not hard coded.\n puts \"WE ARE HARDCODING THE TOOL BOX NAMES TO USE 11H1.b1\"\n scripts = [\n [ 'restore', 'restore and become' ],\n [ 'slave_init', 'slave init' ],\n [ 'promote', 'EBS promote to master' ],\n [ 'backup', 'EBS backup' ],\n [ 'terminate', 'TERMINATE SERVER' ]\n ]\n ebs_toolbox_scripts = [\n [ 'create_stripe' , 'EBS stripe volume create' ]\n ]\n mysql_toolbox_scripts = [\n [ 'create_mysql_ebs_stripe' , 'DB Create MySQL EBS stripe volume' ],\n [ 'create_migrate_script' , 'DB EBS create migrate script from MySQL EBS v1' ]\n ]\n raise \"FATAL: Need 2 MySQL servers in the deployment\" unless @servers.size == 2\n \n # Use the HEAD revision.\n ebs_tbx = ServerTemplate.find_by(:nickname) { |n| n =~ /EBS Stripe Toolbox - 11H1/ }.first\n raise \"Did not find ebs toolbox template\" unless ebs_tbx\n \n puts \"TODO: USING MySQL 5.0 toolbox (should account for differences between 5.0/5.1)\" #<--- TODO\n db_tbx = ServerTemplate.find_by(:nickname) { |n| n =~ /Database Manager with MySQL 5.0 Toolbox - 11H1/ }.first\n raise \"Did not find mysql toolbox template\" unless db_tbx\n \n st_dbm = ServerTemplate.find(resource_id(s_two.server_template_href))\n load_script_table(st_dbm,scripts,st_dbm)\n load_script_table(ebs_tbx,ebs_toolbox_scripts,st_dbm)\n load_script_table(db_tbx,mysql_toolbox_scripts,st_dbm)\n \n # st_v2\n ebs_tbx = ServerTemplate.find_by(:nickname) { |n| n =~ /MySQL EBS Stripe Toolbox v2/ }.first\n raise \"Did not find ebs toolbox template\" unless ebs_tbx\n \n puts \"TODO: USING MySQL 5.0 toolbox (should account for differences between 5.0/5.1)\" #<--- TODO\n db_tbx = ServerTemplate.find_by(:nickname) { |n| n =~ /MySQL 5.0 Stripe Toolbox v5/ }.first\n raise \"Did not find mysql toolbox template\" unless db_tbx\n \n st_v2 = ServerTemplate.find(resource_id(s_one.server_template_href))\n load_script_table(st_v2,scripts,st_v2)\n load_script_table(ebs_tbx,ebs_toolbox_scripts,st_v2)\n load_script_table(db_tbx,mysql_toolbox_scripts,st_v2)\n \n # hardwired script! (this is an 'anyscript' that users typically use to setup the master dns)\n # This a special version of the register that uses MASTER_DB_DNSID instead of a test DNSID\n # This is identical to \"DB register master\" However it is not part of the template.\n load_script('master_init', RightScript.new('href' => \"/api/acct/2901/right_scripts/195053\"))\n raise \"Did not find script\" unless script_to_run?('master_init')\n end", "def calculate_changes\n\t\t@added_properties = []\n\t\t@removed_properties = []\n\t\tall_migrations = find_all_migrations\n\t\tall_migrations.each do |migration_name|\n\t\t\teval File.read(migration_name)\n\t\tend\n\tend", "def find_all_migrations\n\t\tsorted_list = Dir.glob(\"#{MIGRATIONS_DIR}/**\").sort do |file1, file2|\n\t\t\tCassandraVersion.new(File.basename(file1).split(\"_\")[1]) <=> CassandraVersion.new(File.basename(file2).split(\"_\")[1])\n\t\tend\n\t\tin_range = false\n\t\tapplicable_migrations = []\n\t\tsorted_list.each do |migration|\n\t\t\tapplicable_migrations << migration if in_range\n\t\t\tif !in_range and (File::basename(migration) == \"cassandra_#{@start_version}\")\n\t\t\t\tin_range = true\n\t\t\tend\n\t\t\tif in_range and (File::basename(migration) == \"cassandra_#{@end_version}\")\n\t\t\t\treturn applicable_migrations\n\t\t\tend\n\t\tend\n\tend", "def sync_users\n start = Time.now\n stats[:users_added] = 0\n stats[:users_deleted] = 0\n stats[:users_synced] = 0\n stats[:user_errors] = 0\n threads = []\n\n org_users = github_admin.org_users.values\n\n destroyed = GithubUser.joins(\n GithubUser.arel_table.join(User.arel_table, Arel::Nodes::OuterJoin).\n on(GithubUser.arel_table[:user_id].eq(User.arel_table[:id])).\n join_sources\n ).where.not(id: org_users.map { |u| u[:id] }).\n where(User.arel_table[:id].eq(nil)).\n destroy_all\n stats[:users_deleted] = destroyed.count\n\n processed = []\n thread_for_each(org_users) do |org_user|\n begin\n synchronize do\n next if processed.include?(org_user[:login])\n processed << org_user[:login]\n end\n github_user = GithubUser.find_or_initialize_by(id: org_user[:id])\n is_new = github_user.new_record?\n github_user.login = org_user[:login]\n github_user.avatar_url = org_user[:avatar_url]\n github_user.html_url = org_user[:html_url]\n github_user.mfa = org_user[:mfa_enabled]\n github_user.last_sync_at = Time.now unless github_user.token\n github_user.save!\n # Sync with the user's token, if available\n github_user.sync! if github_user.token\n synchronize do\n if github_user.sync_error\n stats[:user_errors] += 1\n @errors << \"Error synchronizing #{github_user.login}: #{github_user.sync_error}\"\n elsif is_new\n stats[:users_added] += 1\n else\n stats[:users_synced] += 1\n end\n end\n rescue => e\n synchronize do\n stats[:user_errors] += 1\n @errors << e\n Rails.logger.error \"Error processing user #{org_user[:login]}: #{e.message}\"\n end\n end\n end\n\n stats[:user_errors] == 0\n rescue => e\n @errors << e\n Rails.logger.error \"Error processing user: #{e.message}\"\n false\n ensure\n stats[:users_time] = Time.now.to_f - start.to_f\n end", "def migrate\n metrics_list = []\n timestamp = Time.now.to_i.to_s\n ipstring = @option[:ip_address].gsub '.', '-'\n\n # @result.each_pair do |key, value|\n # puts \"|#{key}|\"\n # value.each_pair do |ifname, ifvalue|\n # puts \"|#{ifname}|#{ifvalue}|\"\n # end\n # end\n [[:InSpeed, :InOctets], [:OutSpeed, :OutOctets]].each do |item|\n @result.each_pair do |vlannm, vlanvalue|\n #puts \"|#{vlannm}|\"\n if @exvlan.include? vlannm\n next\n end\n sorted = Hash[vlanvalue.sort_by {|a, b| -b[item[1]].to_i}]\n index = 0\n sorted.each_pair do |ifname, ifvalue|\n if @tops.to_i > 0 && index >= @tops.to_i\n break\n end\n index += 1\n\n #puts \"--#{ifname}, #{ifvalue}\"\n info = {\n :sn => ipstring + \"-\" + timestamp + \"-\" + ifname,\n :target => @option[:org_env] + \".\" + @option[:basetarget] +\n \".#{ipstring}.traffic.#{vlannm}.#{item[0]}\",\n :instance => ifname,\n :status => ifvalue[item[0]],\n :details => \"top#{index}\",\n :timestamp => Time.now().to_i() * 1000,\n :duration => 0,\n :attachments => []\n }\n #puts info\n metrics = Metrics.new(@option[:pin_code], info)\n #puts metrics\n metrics_list << metrics\n end\n end\n end\n\n merged = Metrics.merge(metrics_list)\n end", "def load_reactivations\n CustomerServicesOperations.where(\" (name like '%Customer Services Reactivate%' or name = 'Billing Component Reactivate') and imported_at IS NULL \" \n ).find_in_batches do |group|\n puts \"cant #{group.count}\"\n group.each do |op|\n begin\n @member = PhoenixMember.find_by_id_and_club_id op.contact_id, CLUB\n unless @member.nil?\n @log.info \" * processing CS operation ##{op.id}\"\n add_operation(op.operation_date, nil, nil, op.name, Settings.operation_types.recovery, op.created_on, op.updated_on, op.author_id)\n op.update_attribute :imported_at, Time.now.utc\n print \".\"\n end\n rescue Exception => e\n @log.info \" [!] failed: #{$!.inspect}\\n\\t#{$@[0..9] * \"\\n\\t\"}\"\n puts \" [!] failed: #{$!.inspect}\\n\\t#{$@[0..9] * \"\\n\\t\"}\"\n exit\n end\n end\n end\nend", "def do_backed_up\n self.update_attributes(:needs_initial_scan => false)\n update_last_backup_times\n end", "def reconcile!\n table_reconciles = []\n Volt::RootModels.model_classes.each do |model_class|\n table_reconciles << TableReconcile.new(@adaptor, @db, model_class)\n end\n\n # Make any missing tables\n table_reconciles.each(&:ensure_table)\n\n # Make sure the migrations are up to date first.\n Volt::MigrationRunner.new(@db).run\n\n # After the migrations, reconcile tables\n table_reconciles.each(&:run)\n\n # After the initial reconcile!, we add a listener for any new models\n # created, so we can reconcile them (in specs mostly)\n reset!\n @@listener = RootModels.on('model_created') do |model_class|\n # We do a full invalidate and wait for the next db access, because the\n # model_created gets called before the class is actually fully defined.\n # (ruby inherited limitation)\n @adaptor.invalidate_reconcile!\n end\n end", "def fix_scheduled_actions\n @db.transaction do\n # Removing hanging Scheduled Actions\n @to_delete.each do |o|\n @db[:schedaction_pool].where(:oid => o.id, :type => o.type).delete\n end\n end\n end", "def check_sql_before_running; tarif_optimizator.check_sql_before_running; end", "def merge_requests_to_import\n project.merge_requests.id_not_in(already_imported_objects).with_state(:merged)\n end", "def run_db_migrate_rake_task(rollback = false)\n run_custom_build_steps :before_database_migrations\n\n old_schema_version = 0\n old_schema_version = @metadata.read(schema_version_cache).chomp.to_i if @metadata.exists?(schema_version_cache)\n rollback = true if old_schema_version > schema_version\n old_schema_version = @metadata.read(rollback_schema_version_cache).chomp if @metadata.exists?(rollback_schema_version_cache) && rollback\n return true if schema_same_since?(old_schema_version)\n\n instrument \"rails3.run_db_migrate_rake_task\" do\n log(\"db_migrate\") do\n\n migrate = rake.task(\"db:migrate\")\n migrate = rake.task(\"db:rollback\") if rollback\n\n return true unless migrate.is_defined?\n\n if ENV['FORCE_DATABASE_MIGRATIONS']\n topic(\"Forcing database migrations.\")\n else\n topic(\"Running database migrations\") unless rollback\n topic(\"Rolling back database to version #{old_schema_version}\") if rollback\n end\n\n if user_env_hash.empty?\n default_env = {\n \"DATABASE_URL\" => ENV[\"DATABASE_URL\"] || default_database_url\n }\n else\n default_env = {\n \"DATABASE_URL\" => default_database_url\n }\n end\n\n default_env['VERSION'] = old_schema_version if rollback\n\n cache.load migrations_cache if rollback # we need the newer migrations to be able to rollback\n\n migrate.invoke(env: default_env.merge(user_env_hash).merge(\"RAILS_ENV\" => \"migrations\"))\n\n if migrate.success?\n log \"db_migrate\", :status => \"success\"\n puts \"Database migrations completed (#{\"%.2f\" % migrate.time}s)\" unless rollback\n puts \"Database rollback completed (#{\"%.2f\" % migrate.time}s)\" if rollback\n\n FileUtils.mkdir_p(heroku_metadata)\n @metadata.write(rollback_schema_version_cache, old_schema_version, false)\n @metadata.write(schema_version_cache, schema_version, false) unless rollback\n @metadata.write(schema_version_cache, old_schema_version, false) if rollback\n @metadata.save\n\n cache.store migrations_cache\n\n run_custom_build_steps :after_database_migrations\n else\n log \"db_migrate\", :status => \"failure\"\n error \"Database migrations failed.\" unless rollback\n error \"Database rollback failed.\" if rollback\n end\n end\n end\n end", "def create_retrievals\n work_ids = Work.pluck(:id)\n existing_ids = RetrievalStatus.where(:source_id => id).pluck(:work_id)\n\n (0...work_ids.length).step(1000) do |offset|\n ids = work_ids[offset...offset + 1000] & existing_ids\n InsertRetrievalJob.perform_later(self, ids)\n end\n end", "def copy_migrations\n [\n 'change_audit_log_pid_to_generic_file_id.rb',\n 'change_proxy_deposit_request_pid_to_generic_file_id.rb'\n ].each do |file|\n better_migration_template file\n end\n end", "def undo_cleanup_concurrent_column_rename(table, old_column, new_column, type: nil, batch_column_name: :id)\n Gitlab::Database::QueryAnalyzers::RestrictAllowedSchemas.require_ddl_mode!\n\n setup_renamed_column(__callee__, table, new_column, old_column, type, batch_column_name)\n\n with_lock_retries do\n install_bidirectional_triggers(table, old_column, new_column)\n end\n end", "def orm_patches_applied; end", "def bump_old_submissions\n while grouping.reload.has_submission?\n old_submission = grouping.current_submission_used\n if self.submission_version.nil? || (self.submission_version <= old_submission.submission_version)\n self.submission_version = old_submission.submission_version + 1\n end\n old_submission.submission_version_used = false\n old_submission.save\n old_result = old_submission.get_original_result\n old_result.released_to_students = false\n old_result.save\n end\n end", "def optimize\n @database.execute 'VACUUM'\n end", "def penalty_swap\n swap_start_finish do\n update_columns(start: start, finish: finish) if persisted?\n end\n end", "def run\n load_migrations\n @migrations.each do |mig_class, version|\n mig_class.up\n # Add it to the schema_migrations table as well\n # This will fail if auto-migrations is only and always used,\n # as the schema_migrations table will not exist.\n SchemaMigration.find_or_create_by_version(version) rescue nil\n end\n end", "def destroy_old_commits_which_errored_during_import\n log(\"[destroy_old_commits_which_errored_during_import]\")\n Commit.errored_during_import.where(\"created_at < ?\", 2.days.ago).each do |commit|\n log(\"import errors for #{commit.revision}: #{commit.import_errors}\")\n destroy_and_notify_stash(commit)\n end\n end", "def rollout(percent_to_update)\n\n# load 'data.csv' and 'finalstage.csv' to separate hashes so that regardless of\n# the input field order the required output format can be achieved\n\n #\n # -Get all the old stuff and all the new stuff to combine together\n #\n csv_data = CSV.read 'update-data-regen.csv';\n headers = csv_data.shift;\n rhash = csv_data.map { |row| Hash[*headers.zip(row).flatten] };\n\n csv_data = CSV.read 'original-data.csv';\n headers = csv_data.shift;\n rhash_old = csv_data.map { |row| Hash[*headers.zip(row).flatten] };\n\n number_of_records = (rhash.count() * (percent_to_update.to_f()/100)).floor()\n rhash_new = {}\n ids_hash = {}\n\n #\n # -Add the new stuff\n # -Fix those labels\n #\n number_of_records.times do |index|\n ids_hash[rhash[index][\"id\"]] = \"\";\n rhash_new[index] = rhash[index]\n end\n\n rhash_new.each_with_index do |record,index|\n record = record.pop\n rollout_label = \"\"\n\n if(record['label'])\n labels = record['label'].split\n labels.each do |label|\n rollout_label += ((ids_hash[label]) ? label : @revxref[label]) + \" \"\n end\n end\n rhash_new[index]['label'] = rollout_label\n\n target = rhash_new[index]\n\n if target['options']\n code = target['code']\n opts = target['options']\n code.gsub! /(^\\w*?);/, '\\1tmp;'\n code.gsub! /\\((\\w*?)\\)/, '(\\1tmp)'\n code.gsub!(/=(\\w*?)(&|$)/, '=\\1tmp\\2')\n opts.gsub! /\\((\\w*?)\\)/, '(\\1tmp)'\n else\n target['code'].gsub! /$/, 'tmp'\n end\n\n end\n\n #\n # -Chop off what we just did and now the old array has to be fixed\n # -Fix the labels and add the fixed records to the new hash\n #\n to_delete = rhash_old.shift(number_of_records)\n\n rhash_old.each_index do |index|\n record = rhash_old[index]\n rollout_label = \"\"\n\n if(record['label'])\n labels = record['label'].split\n labels.each do |label|\n rollout_label += ((ids_hash[@xref[label]]) ? @xref[label] : label) + \" \"\n end\n end\n rhash_old[index]['label'] = rollout_label\n rhash_new[rhash_new.count+1] = rhash_old[index]\n end\n\n #\n # -Remove problematic data - ie 'code', 'options', etc from obsolete records\n # -Update path of obsolete records to place them in 'TODELETE' section\n #\n\n to_delete.each_index do |td|\n # -to update the 'code' and 'options' data I'll have to parse and update\n # this: see <to_delete-notes.txt>\n target = to_delete[td]\n\n if target['options']\n code = target['code']\n opts = target['options']\n code.gsub! /(^\\w*?);/, '\\1old;'\n code.gsub! /\\((\\w*?)\\)/, '(\\1old)'\n code.gsub!(/=(\\w*?)(&|$)/, '=\\1old\\2')\n opts.gsub! /\\((\\w*?)\\)/, '(\\1old)'\n else\n target['code'].gsub! /$/, 'old'\n end\n\n target['path'] = 'TODELETE'\n\n # then put the processed original data record back into the output array\n rhash_new[rhash_new.count+1] = target\n end\n#\n###############################################################################\n# TODO - need to pick out the rollout redirects, which ones?\n# TODO - prepare the pictures for upload - should I preserve the original images\n# for the TODELETE set? Original data doesn't have images, does it?\n###############################################################################\n#\n #binding.pry\n\n #\n # -Output to csv file\n # - but first specify the exact fields and field order for the output\n #\n\n keys = \"id code abstract sale-price product-url headline isbn orderable\n google-base-product-type options ship-weight page-title taxable\n availability description family price merchant-category condition\n path gift-certificate label manufacturer-part-number caption keywords\n brand upc name inset icon additional-image-1 additional-image-2\n additional-image-3 image download leaf\".split\n\n rollout_csv = CSV.open('rollout_data.csv', 'wb')\n # keys = rhash_new.first[1].keys\n rollout_csv << keys\n rhash_new.each do |record|\n\n row = []\n keys.each do |key|\n row.push record[1][key]\n end\n rollout_csv << row\n end\n rollout_csv.close\nend", "def migrate_data_new(opts, tenant_name, c = 2)\n ap 'TENANT NAME' + tenant_name\n # PREP VARS\n repos_changes = {}\n db = opts[:db] || DB.create(R8::Config[:database])\n match_username_regex = /^(sm|tm)?\\-?(\\w+)\\-/\n admin_tenant_name = \"dtk-admin-#{tenant_name}\"\n git_tenant_name = tenant_name.gsub('dtk', 'git')\n\n # SETUP GITOLITE MANAGER\n puts 'Migrating data ... '\n overriden_configuration = Gitolite::Configuration.new(\n 'conf/repo-configs',\n 'conf/group-defs',\n 'keydir',\n \"/home/#{tenant_name}\"\n )\n gitoliteMng = Gitolite::Manager.new(\"/home/#{tenant_name}/gitolite-admin\", overriden_configuration)\n\n # PROJECT DATA\n default_project = ::DTK::Project.get_all(ModelHandle.new(c, :project)).first\n\n session = CurrentSession.new\n session.set_user_object(default_project.get_field?(:user))\n session.set_auth_filters(:c, :group_ids)\n\n # GET ALL THE MODULES\n columns = [:id, :display_name, :c, :group_id, :repos, :remote_repos]\n modules = Model.get_objs(default_project.model_handle(:component_module), cols: columns)\n services = Model.get_objs(default_project.model_handle(:service_module), cols: columns)\n tests = Model.get_objs(default_project.model_handle(:test_module), cols: columns)\n\n components = modules + services + tests\n fail 'No data to migrate, exiting ...' if components.empty?\n\n components.each do |e|\n next if e[:display_name].eql?('.workspace')\n\n # if remote records exists\n if e[:repo_remote] && e[:repo_remote][:repo_namespace]\n remote_namespace = e[:repo_remote][:repo_namespace]\n else\n remote_namespace = Namespace.default_namespace_name\n end\n\n remote_namespace_obj = Namespace.find_or_create(default_project.model_handle(:namespace), remote_namespace)\n\n ref_name = \"#{remote_namespace}::#{e[:display_name]}\"\n e.update(namespace_id: remote_namespace_obj.id(), ref: ref_name)\n\n if e[:repo]\n old_repo_name = e[:repo][:repo_name]\n\n if old_repo_name.nil? || old_repo_name.empty?\n puts \"Skipping '#{ref_name}' missing repo name!!!\"\n next\n end\n\n username = old_repo_name.match(match_username_regex)[2]\n\n if username\n new_repo_name = ModuleBranch::Location::Server::Local.private_user_repo_name(username, e.module_type(), e.module_name(), remote_namespace)\n\n puts \"Successfully updated to namespace convention '#{ref_name}'\"\n\n old_repo = gitoliteMng.open_repo(old_repo_name)\n new_repo = gitoliteMng.open_repo(new_repo_name)\n\n old_repo.add_username_with_rights(git_tenant_name, 'RW+')\n old_repo.add_username_with_rights(admin_tenant_name, 'RW+')\n\n new_repo.rights_hash = old_repo.rights_hash\n new_repo.commit_messages = [\"Preparing renaming: '#{old_repo.repo_dir_path}' > '#{new_repo.repo_dir_path}'\"]\n\n new_repo.remove_group('tenants')\n old_repo.remove_group('tenants')\n\n repos_changes.store(old_repo_name, new_repo_name: new_repo_name,\n old_dir: \"/home/#{tenant_name}/r8server-repo/#{old_repo_name}\",\n new_dir: \"/home/#{tenant_name}/r8server-repo/#{new_repo_name}\",\n branch_name: \"workspace-private-#{username}\"\n )\n\n e[:repo].update(\n ref: new_repo_name,\n display_name: new_repo_name,\n repo_name: new_repo_name,\n local_dir: \"/home/#{tenant_name}/r8server-repo/#{new_repo_name}\",\n remote_repo_namespace: remote_namespace,\n remote_repo_name: e[:repo_remote] ? e[:repo_remote][:repo_name] : nil\n )\n else\n puts 'MISSSING USERNAME!!!!'\n end\n end\n end\n\n ap repos_changes\n\n ap 'THE PusH'\n ap gitoliteMng.push()\n\n ap 'CLONE DATA'\n clone_data(git_tenant_name, repos_changes, gitoliteMng)\n\n ap 'UPDATE IMPLEMENTATIONS'\n update_all_implementations(c)\n\n ap 'MIGRATE DATE - FINISHED'\n end", "def migrate_actions\n source_keys_matching('?*:?*:actions').each do |timestamp_key|\n timestamp_key =~ /\\A(#{ENTITY_PATTERN_FRAGMENT}):(#{CHECK_PATTERN_FRAGMENT}):actions\\z/\n entity_name = $1\n check_name = $2\n if entity_name.nil? || check_name.nil?\n raise \"Bad regex for #{timestamp_key}\"\n end\n\n check = find_check(entity_name, check_name)\n\n timestamps = @source_redis.hgetall(timestamp_key)\n timestamps.each_pair do |timestamp, action|\n\n start_range = Zermelo::Filters::IndexRange.new(nil, time, :by_score => true)\n previous_state = check.states.intersect(:created_at => start_range).last\n previous_cond = previous_state.nil? ? nil : previous_state.condition\n\n state = Flapjack::Data::State.new(:action => action,\n :condition => previous_cond, :created_at => timestamp,\n :updated_at => timestamp)\n\n state.save\n raise state.errors.full_messages.join(\", \") unless state.persisted?\n\n check.states << states\n end\n end\n end", "def has_migrated?(handle: nil, work: nil, force_update: false)\n work_id = work.present? ? work.id : nil\n log(\"MigrateOrderedMetadataService(handle:#{handle}, work:#{work_id}) : Processing\")\n doc = solr_doc(handle, work)\n if migrated?(doc) && !force_update\n log(\"MigrateOrderedMetadataService(handle:#{handle}, work:#{work_id}) : #{doc['id']} : Work has already been migrated\")\n else\n creators = creators(handle, doc)\n titles = titles(handle, doc)\n related_items = related_items(doc)\n contributors = contributors(handle, doc)\n additional_informations = additional_informations(doc)\n abstracts = abstracts(doc)\n\n log(\"MigrateOrderedMetadataService(handle:#{handle}, work:#{work_id}) : #{doc['id']} : Finding work, attempting to migrate\")\n\n work = fedora_work(doc['id']) unless work.present?\n\n unless creators.empty?\n log(\"MigrateOrderedMetadataService(handle:#{handle}, work:#{work_id}) : #{doc['id']} : Attempting to migrate creators [solr]: creator_tesim: #{doc['creator_tesim']}\")\n log(\"MigrateOrderedMetadataService(handle:#{handle}, work:#{work_id}) : #{doc['id']} : Attempting to migrate creators [fedora]: work.nested_ordered_creator: #{work.nested_ordered_creator.to_json} work.creator: #{work.creator.to_json}\")\n log(\"MigrateOrderedMetadataService(handle:#{handle}, work:#{work_id}) : #{doc['id']} : Attempting to migrate creators [csv/solr]: #{creators}\")\n work.nested_ordered_creator = []\n work.nested_ordered_creator_attributes = creators\n end\n\n unless titles.empty?\n log(\"MigrateOrderedMetadataService(handle:#{handle}, work:#{work_id}) : #{doc['id']} : Attempting to migrate titles [solr]: title_tesim: #{doc['title_tesim']}\")\n log(\"MigrateOrderedMetadataService(handle:#{handle}, work:#{work_id}) : #{doc['id']} : Attempting to migrate titles [fedora]: work.nested_ordered_title: #{work.nested_ordered_title.to_json} work.title: #{work.title.to_json}\")\n log(\"MigrateOrderedMetadataService(handle:#{handle}, work:#{work_id}) : #{doc['id']} : Attempting to migrate titles [csv/solr]: #{titles}\")\n work.nested_ordered_title = []\n work.nested_ordered_title_attributes = titles\n end\n\n unless related_items.empty?\n log(\"MigrateOrderedMetadataService(handle:#{handle}, work:#{work_id}) : #{doc['id']} : Attempting to migrate related_items [solr]: nested_related_items_label_ssim: #{doc['nested_related_items_label_ssim']}\")\n log(\"MigrateOrderedMetadataService(handle:#{handle}, work:#{work_id}) : #{doc['id']} : Attempting to migrate related_items [fedora]: work.nested_related_items: #{work.nested_related_items.to_json}\")\n log(\"MigrateOrderedMetadataService(handle:#{handle}, work:#{work_id}) : #{doc['id']} : Attempting to migrate related_items [csv/solr]: #{related_items}\")\n work.nested_related_items = []\n work.nested_related_items_attributes = related_items\n end\n\n unless contributors.empty?\n log(\"MigrateOrderedMetadataService(handle:#{handle}, work:#{work_id}) : #{doc['id']} : Attempting to migrate contributors [solr]: contributor_tesim: #{doc['contributor_tesim']}\")\n log(\"MigrateOrderedMetadataService(handle:#{handle}, work:#{work_id}) : #{doc['id']} : Attempting to migrate contributors [fedora]: work.nested_ordered_contributor: #{work.nested_ordered_contributor.to_json} work.contributor: #{work.contributor.to_json}\")\n log(\"MigrateOrderedMetadataService(handle:#{handle}, work:#{work_id}) : #{doc['id']} : Attempting to migrate contributors [csv/solr]: #{contributors}\")\n work.nested_ordered_contributor = []\n work.nested_ordered_contributor_attributes = contributors\n end\n\n unless additional_informations.empty?\n log(\"MigrateOrderedMetadataService(handle:#{handle}, work:#{work_id}) : #{doc['id']} : Attempting to migrate additional_informations [solr]: additional_information_tesim: #{doc['additional_information_tesim']}\")\n log(\"MigrateOrderedMetadataService(handle:#{handle}, work:#{work_id}) : #{doc['id']} : Attempting to migrate additional_informations [fedora]: work.nested_ordered_additional_information: #{work.nested_ordered_additional_information.to_json} work.additional_information: #{work.additional_information.to_json}\")\n log(\"MigrateOrderedMetadataService(handle:#{handle}, work:#{work_id}) : #{doc['id']} : Attempting to migrate additional_informations [csv/solr]: #{additional_informations}\")\n work.nested_ordered_additional_information = []\n work.nested_ordered_additional_information_attributes = additional_informations\n end\n\n unless abstracts.empty?\n log(\"MigrateOrderedMetadataService(handle:#{handle}, work:#{work_id}) : #{doc['id']} : Attempting to migrate abstract: [solr]: abstract_tesim: #{doc['abstract_tesim']}\")\n log(\"MigrateOrderedMetadataService(handle:#{handle}, work:#{work_id}) : #{doc['id']} : Attempting to migrate abstract: [fedora]: work.nested_ordered_abstract: #{work.nested_ordered_abstract.to_json} work.abstract: #{work.abstract.to_json}\")\n log(\"MigrateOrderedMetadataService(handle:#{handle}, work:#{work_id}) : #{doc['id']} : Attempting to migrate abstract [csv/solr]: #{abstracts}\")\n work.nested_ordered_abstract = []\n work.nested_ordered_abstract_attributes = abstracts\n end\n\n work.save\n log(\"MigrateOrderedMetadataService(handle:#{handle}, work:#{work_id}) : #{doc['id']} : Work successfully migrated\")\n\n work.members.reject { |m| m.class.to_s == 'FileSet' }.each do |child|\n log(\"MigrateOrderedMetadataService(handle:#{handle}, work:#{work_id}) : child_work:#{child.id} : Finding child work, attempting to migrate\")\n\n unless creators.empty?\n log(\"MigrateOrderedMetadataService(handle:#{handle}, work:#{work_id}) : child_work:#{child.id} : Attempting to migrate creators [solr]: child creator_tesim: #{doc['creator_tesim']}\")\n log(\"MigrateOrderedMetadataService(handle:#{handle}, work:#{work_id}) : child_work:#{child.id} : Attempting to migrate creators [fedora]: child.nested_ordered_creator: #{child.nested_ordered_creator.to_json} child.creator: #{child.creator.to_json}\")\n log(\"MigrateOrderedMetadataService(handle:#{handle}, work:#{work_id}) : child_work:#{child.id} : Attempting to migrate creators [csv/solr]: #{creators}\")\n child.nested_ordered_creator = []\n child.nested_ordered_creator_attributes = creators\n end\n\n log(\"MigrateOrderedMetadataService(handle:#{handle}, work:#{work_id}) : child_work:#{child.id} : Attempting to migrate titles [solr]: child title_tesim: #{doc['title_tesim']}\")\n log(\"MigrateOrderedMetadataService(handle:#{handle}, work:#{work_id}) : child_work:#{child.id} : Attempting to migrate titles [fedora]: child.nested_ordered_title: #{child.nested_ordered_title.to_json} child.title: #{child.title.to_json}\")\n log(\"MigrateOrderedMetadataService(handle:#{handle}, work:#{work_id}) : child_work:#{child.id} : Attempting to migrate titles [csv/solr]: #{child.title.to_json}\")\n child.nested_ordered_title = []\n child.nested_ordered_title_attributes = ordered_solr_metadata({ 'title_tesim' => child.title }, 'title_tesim', 'title')\n\n unless related_items.empty?\n log(\"MigrateOrderedMetadataService(handle:#{handle}, work:#{work_id}) : child_work:#{child.id} : Attempting to migrate related_items [solr]: child nested_related_items_label_ssim: #{doc['nested_related_items_label_ssim']}\")\n log(\"MigrateOrderedMetadataService(handle:#{handle}, work:#{work_id}) : child_work:#{child.id} : Attempting to migrate related_items [fedora]: child.nested_related_items: #{child.nested_related_items.to_json}\")\n log(\"MigrateOrderedMetadataService(handle:#{handle}, work:#{work_id}) : child_work:#{child.id} : Attempting to migrate related_items [csv/solr]: #{related_items}\")\n child.nested_related_items = []\n child.nested_related_items_attributes = related_items\n end\n\n unless contributors.empty?\n log(\"MigrateOrderedMetadataService(handle:#{handle}, work:#{work_id}) : child_work:#{child.id} : Attempting to migrate contributors [solr]: child contributor_tesim: #{doc['contributor_tesim']}\")\n log(\"MigrateOrderedMetadataService(handle:#{handle}, work:#{work_id}) : child_work:#{child.id} : Attempting to migrate contributors [fedora]: child.nested_ordered_contributor: #{child.nested_ordered_contributor.to_json} child.contributor: #{child.contributor.to_json}\")\n log(\"MigrateOrderedMetadataService(handle:#{handle}, work:#{work_id}) : child_work:#{child.id} : Attempting to migrate contributors [csv/solr]: #{contributors}\")\n child.nested_ordered_contributor = []\n child.nested_ordered_contributor_attributes = contributors\n end\n\n unless additional_informations.empty?\n log(\"MigrateOrderedMetadataService(handle:#{handle}, work:#{work_id}) : child_work:#{child.id} : Attempting to migrate additional_informations [solr]: child additional_information_tesim: #{doc['additional_information_tesim']}\")\n log(\"MigrateOrderedMetadataService(handle:#{handle}, work:#{work_id}) : child_work:#{child.id} : Attempting to migrate additional_informations [fedora]: child.nested_ordered_additional_information: #{child.nested_ordered_additional_information.to_json} child.additional_information: #{child.additional_information.to_json}\")\n log(\"MigrateOrderedMetadataService(handle:#{handle}, work:#{work_id}) : child_work:#{child.id} : Attempting to migrate additional_informations [csv/solr]: #{additional_informations}\")\n child.nested_ordered_additional_information = []\n child.nested_ordered_additional_information_attributes = additional_informations\n end\n\n unless abstracts.empty?\n log(\"MigrateOrderedMetadataService(handle:#{handle}, work:#{work_id}) : child_work:#{child.id} : Attempting to migrate abstract: [solr]: child abstract_tesim: #{doc['abstract_tesim']}\")\n log(\"MigrateOrderedMetadataService(handle:#{handle}, work:#{work_id}) : child_work:#{child.id} : Attempting to migrate abstract: [fedora]: child.nested_ordered_abstract: #{child.nested_ordered_abstract.to_json} child.abstract: #{child.abstract.to_json}\")\n log(\"MigrateOrderedMetadataService(handle:#{handle}, work:#{work_id}) : child_work:#{child.id} : Attempting to migrate abstract [csv/solr]: #{abstracts}\")\n child.nested_ordered_abstract = []\n child.nested_ordered_abstract_attributes = abstracts\n end\n child.save\n log(\"MigrateOrderedMetadataService(handle:#{handle}, work:#{work_id}) : child_work:#{child.id} : Work successfully migrated\")\n end\n end\n true\n rescue StandardError => e\n trace = e.backtrace.join(\"\\n\")\n msg = \"MigrateOrderedMetadataService(handle:#{handle}, work:#{work_id}) : Error migrating work; #{e.message}\\n#{trace}\"\n Rails.logger.error(msg)\n @logger.error(msg)\n false\n end", "def migrate(version = nil)\n pending = ->(_) { File.pending.map(&:version).include?(_) }\n migrated = ->(_) { File.migrated.map(&:version).include?(_) }\n\n case version\n when nil\n files = File.pending\n Migrate::Up.new(files).perform\n\n when pending\n files = File.pending.select { |f| f.version <= version }\n Migrate::Up.new(files).perform\n\n when migrated\n files = File.migrated.select { |f| f.version > version }.reverse\n Migrate::Down.new(files).perform\n\n else\n out.puts(\"Invalid Version: #{version} does not exist.\")\n end\n end", "def migrate_comments()\n switch_to_legacy\n\n find_in_batches(\"SELECT comments.user_id, comments.body, events.id, comments.created_at, comments.updated_at FROM comments LEFT OUTER JOIN events ON comments.searchable_id = events.searchable_id WHERE events.id IS NOT NULL\") do |comments|\n comment_inserts = []\n \n comments.each do |comment|\n comment_inserts.push(\n \"(\n '#{comment[0]}',\n '#{comment[1] ? comment[1].gsub(/[']/, \"''\") : nil}',\n '#{comment[2]}',\n '#{comment[3] || Time.now}',\n '#{comment[4] || Time.now}'\n )\"\n )\n end\n\n switch_to_current\n\n sql = \"INSERT INTO comments (\nuser_id,\nbody,\nevent_id,\ncreated_at,\nupdated_at\n) VALUES #{comment_inserts.join(\", \")}\"\n\n ActiveRecord::Base.connection.insert(sql)\n \n switch_to_legacy\n end\n\n find_in_batches(\"SELECT comments.user_id, comments.body, events.id, comments.created_at, comments.updated_at FROM actions LEFT OUTER JOIN actions AS ref_actions ON actions.id = ref_actions.action_id INNER JOIN comments ON comments.id = ref_actions.reference_id INNER JOIN events ON actions.event_id = events.id WHERE actions.action_type = 'Event Comment' AND ref_actions.action_type = 'Action Comment'\") do |comments|\n comment_inserts = []\n\n comments.each do |comment|\n comment_inserts.push(\n \"(\n '#{comment[0]}',\n '#{comment[1] ? comment[1].gsub(/[']/, \"''\") : nil}',\n '#{comment[2]}',\n '#{comment[3] || Time.now}',\n '#{comment[4] || Time.now}'\n )\"\n )\n end\n\n switch_to_current\n\n sql = \"INSERT INTO comments (\nuser_id,\nbody,\nevent_id,\ncreated_at,\nupdated_at\n) VALUES #{comment_inserts.join(\", \")}\"\n\n ActiveRecord::Base.connection.insert(sql)\n\n switch_to_legacy\n end\n end", "def migrations\n raise(ArgumentError, \"Can't set migrations while using :version option\") if @using_deprecated_version_setting\n yield\n end", "def copy_migrations\n # Can't get this any more DRY, because we need this order.\n %w{acts_as_follower_migration.rb\tadd_social_to_users.rb\t\tcreate_single_use_links.rb\tadd_ldap_attrs_to_user.rb\nadd_avatars_to_users.rb\t\tcreate_checksum_audit_logs.rb\tcreate_version_committers.rb\nadd_groups_to_users.rb\t\tcreate_local_authorities.rb\tcreate_trophies.rb}.each do |f|\n better_migration_template f\n end\n end", "def fix_skel_migrations(skel_dir = File.dirname(__FILE__) + '/../skel')\n # expect, remove and modify need to be fixed, add doesn't\n for verb in %w(expect remove modify)\n skel_targets(skel_dir, verb, '/db/migrate') do |src_file, target_file|\n pattern = target_file.sub(/\\d{14}/, '*')\n matches = Dir.glob(pattern)\n raise FileNotFound, pattern if matches.empty?\n raise AmbiguousMigration, matches.inspect if matches.size > 1\n File.rename(matches.first, target_file)\n end\n end\n end", "def stuck_merge_requests\n MergeRequest.select('id, merge_jid').with_state(:locked).where.not(merge_jid: nil).reorder(nil)\n end", "def db_fix_merged_at(db, client, issues, org, repo)\n issues.each do |item|\n if(item.pull_request)\n # sqlite queries much cheaper than github requests, so protect from unnecessary github requests\n countRow = db[\"SELECT COUNT(id) FROM pull_requests WHERE org=? AND repo=? AND pr_number=? AND merged_at IS NOT NULL\", org, \"#{repo}\", item.number.to_s]\n count = countRow.first[:count]\n if(count == 0)\n pr=client.pull_request( \"#{org}/#{repo}\", item.number )\n if(pr.merged_at)\n db_update_pull_request(db, pr, org, repo)\n end\n end\n end\n end\n end", "def addUnchangedFilesToCommit(prev_commit, commit, changed_files) #:doc:\n# sql = \"select devfiles.path, devfiles.name, devfiles.blob_id from devfiles, blobs, blobs_in_commits where blobs.devfile_id=devfiles.id and blobs_in_commits.blob_id=blobs.id and blobs_in_commits.commit_id=#{prev_commit.id};\"\n# devfiles_of_prev_commit = ActiveRecord::Base.connection.execute(sql)\n#\n devfiles_of_prev_commit = Devfile.find_by_sql(\"select devfiles.path, devfiles.name, devfiles.blob_id from devfiles, blobs, blobs_in_commits where blobs.devfile_id=devfiles.id and blobs_in_commits.blob_id=blobs.id and blobs_in_commits.commit_id=#{prev_commit.id};\")\n if devfiles_of_prev_commit.size > 0\n ActiveRecord::Base.connection.execute(\"begin\")\n now = DateTime.now\n devfiles_of_prev_commit.each do |df|\n if not changed_files.has_key?(df.path + df.name)\n begin\n sql = \"insert into blobs_in_commits(blob_id, commit_id, created_at, updated_at) values('#{df['blob_id']}', '#{commit.id}', '#{now}', '#{now}');\"\n ActiveRecord::Base.connection.execute(sql)\n rescue\n # do nothing\n end\n end\n end\n ActiveRecord::Base.connection.execute(\"commit\")\n end\n end", "def schema_migrations_cleanup\n # Read all schema_migrations values from the dump.\n values = dump.scan(/^(\\(\\'\\d{14}\\'\\))[,;]\\n/).flatten.sort\n\n # Replace the schema_migrations values.\n dump.sub!(\n /(?<=INSERT INTO \"schema_migrations\" \\(version\\) VALUES).+;\\n*/m,\n \"\\n #{values.join(\"\\n,\")}\\n;\\n\\n\"\n )\n end", "def schema_migrations_cleanup\n # Read all schema_migrations values from the dump.\n values = dump.scan(/^(\\(\\'\\d{14}\\'\\))[,;]\\n/).flatten.sort\n\n # Replace the schema_migrations values.\n dump.sub!(\n /(?<=INSERT INTO \"schema_migrations\" \\(version\\) VALUES).+;\\n*/m,\n \"\\n #{values.join(\"\\n,\")}\\n;\\n\\n\"\n )\n end", "def destroy_removed_migrations\n # @todo Make these methods into a more DRY manner for grabbing each record type and diff'ing them.\n # \n # We create an array for each record type that includes all records that we are going to destroy. We do this by taking the previous records array, converting them to a standard array and keeping them if any previous records occur in the migrated records array.\n versions_to_remove = GuidesGenerator::Migrator::previous_versions.to_a.keep_if do |version|\n !GuidesGenerator::Migrator::migrated_versions.include?(version)\n end\n\n sections_to_remove = GuidesGenerator::Migrator::previous_sections.to_a.keep_if do |sections|\n !GuidesGenerator::Migrator::migrated_sections.include?(sections)\n end\n\n documents_to_remove = GuidesGenerator::Migrator::previous_documents.to_a.keep_if do |document|\n !GuidesGenerator::Migrator::migrated_documents.include?(document)\n end\n\n # After we have all the arrays of records to remove iterate over each array and destroy the records.\n [versions_to_remove, sections_to_remove, documents_to_remove].each {|records| records.each {|record| record.destroy}}\n end", "def migrate\n count = 0\n client.token = kv.read(root_key_prefix, shard: 'root') if client.token.nil?\n with_lock do\n Dir[\"#{path}/*.rb\"].each do |file|\n version, class_name = parse_migration(file)\n next if latest >= version\n puts \"Starting migration #{file}\"\n count += 1\n require file\n klass = Object.const_get(\"::#{class_name}\")\n klass.new(client, fig, kv).migrate\n\n # All of the client methods will properly raise exceptions, which will\n # halt this loop. We don't want to swallow that backtrace so we'll just\n # let the error pass along\n update_version(version)\n end\n end\n if count.positive?\n puts \"Ran #{count} migration#{'s' unless count == 1 }.\"\n else\n puts \"No migrations to run. Up to date\"\n end\n end", "def execute_merger(placed_sur_tiles, orphan, placed_tile)\n other_tiles = []\n if orphan\n num = 1\n else\n num = 0\n end\n hotel_name1 = placed_sur_tiles[0].hotel\n hotel_name2 = placed_sur_tiles[1].hotel\n game_hotel1 = self.game_hotels.where(name: hotel_name1).first\n game_hotel2 = self.game_hotels.where(name: hotel_name2).first\n if game_hotel1.chain_size > game_hotel2.chain_size || game_hotel1.chain_size == game_hotel2.chain_size\n dominant_hotel = game_hotel1.hotel\n acquired_hotel = game_hotel2\n self.acquired_hotel = game_hotel2.name\n self.dominant_hotel = game_hotel1.name\n self.save\n color = dominant_hotel.color\n c = game_hotel2.hotel.color\n game_tiles = self.game_tiles.where(hotel: hotel_name2)\n game_tiles.each do |tile|\n tile.hotel = dominant_hotel.name\n tile.save\n temp = [tile.tile.row, tile.tile.column, c]\n other_tiles << temp\n end\n placed_tile.hotel = dominant_hotel.name\n placed_tile.save\n acquired_hotel_size = game_hotel2.chain_size\n game_hotel1.chain_size += game_tiles.length + num + 1\n game_hotel1.save\n game_hotel1.update_share_price\n game_hotel2.chain_size = 0\n game_hotel2.save\n game_hotel2.update_share_price\n elsif game_hotel2.chain_size > game_hotel1.chain_size\n dominant_hotel = game_hotel2.hotel\n acquired_hotel = game_hotel1\n self.acquired_hotel = game_hotel1.name\n self.dominant_hotel = game_hotel2.name\n self.save\n color = dominant_hotel.color\n c = game_hotel1.hotel.color\n game_tiles = self.game_tiles.where(hotel: hotel_name1)\n game_tiles.each do |tile|\n tile.hotel = dominant_hotel.name\n tile.save\n temp = [tile.tile.row, tile.tile.column, c]\n other_tiles << temp\n end\n placed_tile.hotel = dominant_hotel.name\n placed_tile.save\n acquired_hotel_size = game_hotel1.chain_size\n game_hotel2.chain_size += game_tiles.length + num + 1\n game_hotel2.save\n game_hotel2.update_share_price\n game_hotel1.chain_size = 0\n game_hotel1.save\n game_hotel1.update_share_price\n end\n\n [color, other_tiles, dominant_hotel, acquired_hotel, acquired_hotel_size]\n end", "def up\n final_covers = Task.find_by_name(\"Final Covers\")\n return if final_covers.nil?\n\n # create Update PSD task\n new_task = Task.new\n new_task.name = 'Update PSD'\n new_task.tab_text = 'Update PSD'\n new_task.partial = 'update_psd'\n new_task.icon = 'icon-cloud-upload'\n new_task.next_id = nil\n new_task.team_only = true\n new_task.workflow = final_covers.workflow\n new_task.save\n\n # add Update PSD after Final Covers\n final_covers_tab = Tab.find_by_task_id(final_covers.id)\n new_tab = Tab.new\n new_tab.task = new_task\n new_tab.phase = final_covers_tab.phase\n new_tab.order = final_covers_tab.order + 1\n new_tab.save\n\n # adjust all remaining tabs\n remaining_tabs = new_tab.phase.tabs.joins(:task)\n .where(\"tabs.order >= ? and tasks.name != ? \", new_tab.order, new_task.name)\n remaining_tabs.each do | tab |\n tab.order = tab.order + 1\n tab.save\n end\n\n # unlock update_psd for everything beyond \"Final Covers\"\n task = final_covers\n while task.next_id\n task = Task.find(task.next_id)\n task.unlocked_tasks.create!(unlocked_task: new_task)\n end\n\n # retext some stuff so that the tabs will all fit in 1280px!\n @@renames.each do |rename|\n retext_tab(rename[:old_text], rename[:new_text])\n end\n end", "def run\n start_time = Time.now\n\n setup\n\n importer_run.update_attributes( started_at: start_time,\n source_model: source_model.name,\n destination_model: destination_model.name,\n importer_version: VERSION )\n\n # get a total count of records to process, bail out if none are found\n count = base_query(false).count\n\n logger.info \"\"\n if count == 0\n logger.info \"no #{source_model.name.pluralize} to import, exiting\"\n return\n end\n\n logger.info \"Starting import from #{source_model.table_name} into #{destination_model.name}...\"\n\n # step through the records in batches\n (0..count).step(batch_size) do |offset|\n thread_pool.schedule do\n with_connections do\n batch_elapsed_time = Benchmark.realtime do\n logger.info \"Importing from #{source_model.table_name} into #{destination_model.name} (#{offset / batch_size + 1}/#{count / batch_size + 1})\"\n\n # wipe the slate from the last batch\n prepare_for_new_batch\n\n benchmarks[:source_db] << Benchmark.realtime do\n # grab this batch of records from source\n fetch_records(offset)\n end\n\n # bail if there aren't any\n next if records.empty?\n\n logger.info \" #{records.count} source records fetched in #{benchmarks[:source_db].last}s\"\n if source_order_by\n logger.info \" #{source_order_by}: from #{records.first.read_attribute(source_order_by)} to #{records.last.read_attribute(source_order_by)}\"\n end\n\n # process this batch of records\n process_batch(records)\n\n logger.info \" #{records.count} records processed in #{benchmarks[:processing].last}s\"\n\n insert_and_update_batch\n end\n logger.info \" batch processed in #{batch_elapsed_time}s\"\n end\n end\n end\n thread_pool.shutdown\n \n print_validation_errors\n\n logger.info \"-------------------------------------------------\"\n logger.info \"Processing: #{benchmarks[:processing].sum}s total, #{benchmarks[:processing].sum / count}s per record\"\n logger.info \"source Database: #{benchmarks[:source_db].sum}s total, #{benchmarks[:source_db].sum / count}s per record\"\n logger.info \"dest Database: #{benchmarks[:destination_db].sum}s total, #{benchmarks[:destination_db].sum / count}s per record\"\n logger.info \"Total: #{Time.now - start_time}s elapsed\"\n importer_run.update_attributes( completed_at: Time.now )\n rescue Exception => e\n importer_run.update_attributes( error_trace: \"#{e.class} - #{e.message}\\n#{e.backtrace.join(\"\\n\")}\" )\n raise e\n ensure\n importer_run.update_attributes( records_created: records_created,\n records_updated: records_updated,\n duration: ((Time.now - start_time) * 1000).round,\n validation_errors: validation_errors )\n end", "def generateDelayToIntegrationByMergeScenario(projectName, localClone, pathOutput)\n\t\tprefixProjectName = formatProjectName(projectName)\n\t\tintegrationLine = []\n\t\tintegrationLineAuthorDateList = []\n\t\tintegrationLineCommitDateList = []\n\n\t\tFile.open(localClone+pathOutput+prefixProjectName+\"_CommitList.csv\", 'r') do |f1|\n\t\t while line = f1.gets \n\t\t\tf1.each_line do |line|\n\t\t\t\tleftAuthorsList = []\n\t\t rightAuthorsList = []\n\t\t\t\tcampos = line.split(\",\")#.length\t\n\t\t\t\tmergeCommitID = campos[0].gsub(\"\\r\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\tisConflicting = campos[1].gsub(\"\\r\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\tleftCommits = campos[10].split(\"@@\")\n\t\t\t\trightCommits = campos[11].split(\"@@\")\n leftDelayIntegration = 0\n\t\t\t\trightDelayIntegration = 0\n\t\t\t\tarithmeticMeanDelayIntegration = 0\n\t\t\t\tgeometricMeanDelayIntegration = 0\n\t\t\t\tdeltaIntegration = 0\n\n\t\t\t\tif leftCommits.include?(\"\\n\")\n\t\t\t\t\tleftCommits.delete(\"\\n\")\n\t\t\t\tend\n\t\t\t\t\n\t\t\t\tif rightCommits.include?(\"\\n\")\n\t\t\t\t\trightCommits.delete(\"\\n\")\n\t\t\t\tend\n\t\t\t\t\n\t\t\t\t# Metric\n\t\t\t\t\tstartDate = Date.parse %x(git --no-pager log -1 --pretty=format:\"%ad\" --date=local #{leftCommits[0]}).gsub(\"\\r\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\tendDate = Date.parse %x(git --no-pager log -1 --pretty=format:\"%cd\" --date=local #{mergeCommitID}).gsub(\"\\r\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\tleftDelayIntegration = (endDate - startDate).to_i\n\t\t\t\t\tstartDate = Date.parse %x(git --no-pager log -1 --pretty=format:\"%ad\" --date=local #{rightCommits[0]}).gsub(\"\\r\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\tendDate = Date.parse %x(git --no-pager log -1 --pretty=format:\"%cd\" --date=local #{mergeCommitID}).gsub(\"\\r\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\trightDelayIntegration = (endDate - startDate).to_i\n\n\t\t\t\t\tleftDelayLessThanZero = false\n\t\t\t\t\tif (leftDelayIntegration==0)\n\t\t\t\t\t\tleftDelayIntegration = 1\n\t\t\t\t\tend\n\t\t\t\t\trightDelayLessThanZero = false\n\t\t\t\t\tif (rightDelayIntegration==0)\n\t\t\t\t\t\trightDelayIntegration = 1\n\t\t\t\t\tend\n\n\t\t\t\t\tif leftDelayIntegration > rightDelayIntegration\n\t\t\t\t\t\tdeltaIntegration = leftDelayIntegration - rightDelayIntegration\n\t\t\t\t\telsif rightDelayIntegration > leftDelayIntegration\n\t\t\t\t\t\tdeltaIntegration = rightDelayIntegration - leftDelayIntegration\n\t\t\t\t\telse\n\t\t\t\t\t\tdeltaIntegration = 0\n\t\t\t\t\tend\n\n\t\t\t\t\tif (rightDelayIntegration <0)\n\t\t\t\t\t\tleftDelayLessThanZero = true\n\t\t\t\t\tend\n\n\t\t\t\t\tif((leftDelayIntegration * rightDelayIntegration) <0)\n\t\t\t\t\t\tif(leftDelayIntegration <0)\n\t\t\t\t\t\t\tleftDelayIntegration = 1\n\t\t\t\t\t\telse \n\t\t\t\t\t\t\trightDelayIntegration = 1\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\t\t\n\t\t\t\t\tarithmeticMeanDelayIntegration = (Float(leftDelayIntegration + rightDelayIntegration)/2).round(2)\n\t\t\t\t\tgeometricMeanDelayIntegration = Math.sqrt(Float(leftDelayIntegration*rightDelayIntegration)).round(2)\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\tlinha = mergeCommitID+\",\"+isConflicting+\",\"+leftDelayIntegration.to_s+\",\"+rightDelayIntegration.to_s+\",\"+arithmeticMeanDelayIntegration.to_s+\",\"+geometricMeanDelayIntegration.to_s+\",\"+deltaIntegration.to_s\n\t\t\t\t\tintegrationLine.push(linha.gsub(\"\\n\", \"\"))\t\t\n\t\t\t\t\t\n\t\t\t\t\t File.open(localClone+pathOutput+prefixProjectName+\"_DelayDeltaIntegrationList.csv\", 'w') do |file|\n\t\t\t\t\t\tfile.puts \"mergeCommitID, isConflicting, leftDelayIntegration, rightDelayIntegration, arithmeticMeanDelayIntegration, geometricMeanDelayIntegration, deltaIntegration\"\n\t\t\t\t\t\tintegrationLine.each do |dado|\n\t\t\t\t\t\t\tfile.puts \"#{dado}\"\n\t\t\t\t\t\tend\n\t\t\t\t\t end\t\t\t\t \n\n\t\t\t\t# exploring more data - extra internal test\n\t\t\t\t\tstartDate = Date.parse %x(git --no-pager log -1 --pretty=format:\"%cd\" --date=local #{leftCommits[0]}).gsub(\"\\r\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\tendDate = Date.parse %x(git --no-pager log -1 --pretty=format:\"%cd\" --date=local #{mergeCommitID}).gsub(\"\\r\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\tleftDelayIntegration = (endDate - startDate).to_i\n\n\t\t\t\t\tstartDate = Date.parse %x(git --no-pager log -1 --pretty=format:\"%cd\" --date=local #{rightCommits[0]}).gsub(\"\\r\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\tendDate = Date.parse %x(git --no-pager log -1 --pretty=format:\"%cd\" --date=local #{mergeCommitID}).gsub(\"\\r\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\trightDelayIntegration = (endDate - startDate).to_i\n\n\t\t\t\t\tif leftDelayIntegration > rightDelayIntegration\n\t\t\t\t\t\tdeltaIntegration = leftDelayIntegration - rightDelayIntegration\n\t\t\t\t\telsif rightDelayIntegration > leftDelayIntegration\n\t\t\t\t\t\tdeltaIntegration = rightDelayIntegration - leftDelayIntegration\n\t\t\t\t\telse\n\t\t\t\t\t\tdeltaIntegration = 0\n\t\t\t\t\tend\n\n\t\t\t\t\tif leftDelayIntegration * rightDelayIntegration < 0\n\t\t\t\t\t\tif leftDelayIntegration < 0\n\t\t\t\t\t\t\tleftDelayIntegration = leftDelayIntegration * -1\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\trightDelayIntegration = rightDelayIntegration * -1\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\t\tarithmeticMeanDelayIntegration = (Float(leftDelayIntegration + rightDelayIntegration)/2).round(2)\n\t\t\t\t\tgeometricMeanDelayIntegration = Math.sqrt(Float(leftDelayIntegration*rightDelayIntegration)).round(2)\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\tlinha = mergeCommitID+\",\"+isConflicting+\",\"+leftDelayIntegration.to_s+\",\"+rightDelayIntegration.to_s+\",\"+arithmeticMeanDelayIntegration.to_s+\",\"+geometricMeanDelayIntegration.to_s+\",\"+deltaIntegration.to_s\n\t\t\t\t\tintegrationLineCommitDateList.push(linha.gsub(\"\\n\", \"\"))\t\t\n\t\t\t\t\t\n\t\t\t\t\t File.open(localClone+pathOutput+prefixProjectName+\"_DelayDeltaIntegrationCommitDatesList.csv\", 'w') do |file|\n\t\t\t\t\t\tfile.puts \"mergeCommitID, isConflicting, leftDelayIntegration, rightDelayIntegration, arithmeticMeanDelayIntegration, geometricMeanDelayIntegration, deltaIntegration\"\n\t\t\t\t\t\tintegrationLineCommitDateList.each do |dado|\n\t\t\t\t\t\t\tfile.puts \"#{dado}\"\n\t\t\t\t\t\tend\n\t\t\t\t\t end\n\n\n\t\t\t\t# exploring more data - extra test\n\t\t\t\t\tstartDate = Date.parse %x(git --no-pager log -1 --pretty=format:\"%ad\" --date=local #{leftCommits[0]}).gsub(\"\\r\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\tendDate = Date.parse %x(git --no-pager log -1 --pretty=format:\"%ad\" --date=local #{mergeCommitID}).gsub(\"\\r\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\tleftDelayIntegration = (endDate - startDate).to_i\n\n\t\t\t\t\tstartDate = Date.parse %x(git --no-pager log -1 --pretty=format:\"%ad\" --date=local #{rightCommits[0]}).gsub(\"\\r\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\tendDate = Date.parse %x(git --no-pager log -1 --pretty=format:\"%ad\" --date=local #{mergeCommitID}).gsub(\"\\r\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\trightDelayIntegration = (endDate - startDate).to_i\n\n\t\t\t\t\tif leftDelayIntegration > rightDelayIntegration\n\t\t\t\t\t\tdeltaIntegration = leftDelayIntegration - rightDelayIntegration\n\t\t\t\t\telsif rightDelayIntegration > leftDelayIntegration\n\t\t\t\t\t\tdeltaIntegration = rightDelayIntegration - leftDelayIntegration\n\t\t\t\t\telse\n\t\t\t\t\t\tdeltaIntegration = 0\n\t\t\t\t\tend\n\t\t\t\t\tif leftDelayIntegration * rightDelayIntegration < 0\n\t\t\t\t\t\tif leftDelayIntegration < 0\n\t\t\t\t\t\t\tleftDelayIntegration = leftDelayIntegration * -1\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\trightDelayIntegration = rightDelayIntegration * -1\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\t\tarithmeticMeanDelayIntegration = (Float(leftDelayIntegration + rightDelayIntegration)/2).round(2)\n\t\t\t\t\tgeometricMeanDelayIntegration = Math.sqrt(Float(leftDelayIntegration*rightDelayIntegration)).round(2)\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\tlinha = mergeCommitID+\",\"+isConflicting+\",\"+leftDelayIntegration.to_s+\",\"+rightDelayIntegration.to_s+\",\"+arithmeticMeanDelayIntegration.to_s+\",\"+geometricMeanDelayIntegration.to_s+\",\"+deltaIntegration.to_s\n\t\t\t\t\tintegrationLineAuthorDateList.push(linha.gsub(\"\\n\", \"\"))\t\t\n\t\t\t\t\t\n\t\t\t\t\t File.open(localClone+pathOutput+prefixProjectName+\"_DelayDeltaIntegrationAuthorDatesList.csv\", 'w') do |file|\n\t\t\t\t\t\tfile.puts \"mergeCommitID, isConflicting, leftDelayIntegration, rightDelayIntegration, arithmeticMeanDelayIntegration, geometricMeanDelayIntegration, deltaIntegration\"\n\t\t\t\t\t\tintegrationLineAuthorDateList.each do |dado|\n\t\t\t\t\t\t\tfile.puts \"#{dado}\"\n\t\t\t\t\t\tend\n\t\t\t\t\t end\t\t\t\t \n\n\t\t\tend #f1eachline\n\t\t end #while\n\t\tend #Fileopen\n\tputs \"end running generateDelayToIntegrationByMergeScenario from #{prefixProjectName} project\"\n\tend", "def deploy\n\t# This task is typiclly run after the site is updated but before the server is restarted.\n\tcall 'migrate'\nend", "def schema_updates\n @schema_updates ||= %i[\n add_vpc_subnet_id_to_amazon_clouds\n add_cluster_code_to_clusters\n add_ssh_port_to_data_centers\n add_ssh_port_to_amazon_clouds\n add_custom_jmeter_installer_url_to_projects\n ]\n end", "def copy_migrations\n [\n \"acts_as_follower_migration.rb\",\n \"add_social_to_users.rb\",\n \"add_ldap_attrs_to_user.rb\",\n \"add_avatars_to_users.rb\",\n \"add_groups_to_users.rb\",\n \"create_local_authorities.rb\",\n \"create_trophies.rb\",\n 'add_linkedin_to_users.rb',\n 'create_tinymce_assets.rb',\n 'create_content_blocks.rb',\n 'create_featured_works.rb',\n 'add_external_key_to_content_blocks.rb'\n ].each do |file|\n better_migration_template file\n end\n end", "def notify_if_can_migrate\n\n last_precinct_count = ElectionDataMigration.last_precinct_count(self.id)\n\n if (completed_precinct_count - last_precinct_count) == ElectionDataMigration::MIN_PRECINCTS_CHANGE\n message = Message.new\n message.locale = I18n.locale\n message.subject = I18n.t(\"mailer.notification.can_migrate.subject\", :locale => I18n.locale, :env => Rails.env, :app_name => I18n.t('app.common.app_name'))\n message.message = I18n.t(\"mailer.notification.can_migrate.message\", :locale => I18n.locale)\n\n NotificationMailer.can_migrate(message).deliver\n end\n end", "def run_migrations\n return unless pending_migrations?\n callback(:run_migrations) do\n notify(:run_migrations)\n heroku.run_migrations\n end\n end", "def migrate_advancing\n # @contest is fetched by CanCan\n\n load_migration_resources # Loads possible target contests, migratable performances and already migrated\n target_contest = @possible_target_contests.find(params[:target_contest_id]) # Load selected target\n\n if target_contest.nil?\n flash[:error] = \"Der Zielwettbewerb wurde nicht gefunden.\"\n render 'list_advancing'\n end\n\n # Collect performances for migration\n new_performances = []\n @performances.each do |performance|\n # Find corresponding contest category from target contest\n new_contest_category = target_contest.contest_categories\n .where(category_id: performance.contest_category.category_id)\n .first\n\n next if new_contest_category.nil?\n\n new_performance = performance.amoeba_dup # Deep duplicate\n\n # Remove appearances that don't advance\n # This is buggy when not deleting all at once, probably due to coupling during age group calculation\n not_advancing = new_performance.appearances.select { |a|\n !a.may_advance_to_next_round? && !a.accompaniment?\n # TODO: Currently non-qualified pop accompanist groups must be removed by hand after migration\n }\n new_performance.appearances.delete(not_advancing)\n\n # Assign to contest category in new contest\n new_performance.contest_category = new_contest_category\n\n # Reset attributes that should not carry over when advancing\n new_performance.stage_time = nil\n new_performance.stage_venue = nil\n new_performance.results_public = false\n\n new_performance.appearances.each { |appearance| appearance.points = nil } # Clear points\n new_performance.predecessor = performance # Link to predecessor\n new_performances << new_performance # Add to list of performances that will be migrated\n end\n\n # Perform migration\n begin\n ActiveRecord::Base.transaction { new_performances.each(&:save!) }\n flash[:success] = \"#{new_performances.size} \\\n #{Performance.model_name.human(count: new_performances.size)} \\\n wurde(n) erfolgreich nach #{target_contest.name} migriert.\"\n redirect_to jmd_contest_path(target_contest)\n rescue ActiveRecord::RecordInvalid\n flash[:error] = \"Die Vorspiele konnten nicht migriert werden.\"\n render 'list_advancing'\n end\n end", "def next_migration_number\n # Lifted directly from ActiveRecord::Generators::Migration\n # Unfortunately, no API is provided by Rails at this time.\n next_migration_number = current_migration_number + 1\n if ActiveRecord::Base.timestamped_migrations\n [Time.now.utc.strftime(\"%Y%m%d%H%M%S\"), \"%.14d\" % next_migration_number].max\n else\n \"%.3d\" % next_migration_number\n end\n end", "def migrate\n DataMapper.auto_migrate!\n end", "def copy_migrations\n # Can't get this any more DRY, because we need this order.\n better_migration_template \"create_searches.rb\"\n better_migration_template \"create_bookmarks.rb\"\n better_migration_template \"remove_editable_fields_from_bookmarks.rb\"\n better_migration_template \"add_user_types_to_bookmarks_searches.rb\"\n end", "def recalculate_usage\n # For some reason, ANALYZE TABLE doesn't update statistics in Travis' environment\n ActiveRecord::Base.connection.execute(\"OPTIMIZE TABLE #{binding.database}.stuff\")\n end", "def reconcile\n \n #First sync instances \n Instance.sync_with_ec2\n \n #then make sure this farm is operating withing limits... start and stop based on limits\n #now lets go through our configs and sync what is running with what is configured to run\n\n num_stop = 0\n num_start = 0\n\n logger.info \"Reconciling farm #{ami_id}...\"\n EventLog.info \"Reconciling farm #{ami_id}...\"\n \n ia = instances.select{ |i| i.running?} \n if ia.size < min\n num_start = min.to_i - ia.size\n # need to start some of them\n logger.info \"Attempting to start #{num_start} #{ami_id} instances... may take a few moments.\"\n EventLog.info \"Attempting to start #{num_start} #{ami_id} instances... may take a few moments.\"\n start_and_create_instances(num_start)\n\n elsif ia.size > max\n # need to stop some of the instances, if they are either 'IDLE' or 'LAUNCHED' state or \"ERROR\"\n num_stop = ia.size - max.to_i\n count = 0\n ia.each do |ri|\n break if count >= num_stop\n if ri.available? || ri.error?\n #shut it down!\n logger.info \"Shutting down instance #{ami_id} -- #{ri.instance_id}...\"\n EventLog.info \"Shutting down instance #{ami_id} -- #{ri.instance_id}...\"\n ri.terminate\n count += 1\n end \n end\n end\n \n # shutdown what we can from idle\n \n num_stop += scale_down\n \n #########################\n #\n # now that we scaled down, lets recycle those compute nodes that have not checked in for a while (15 mins)\n # we're looking for those that are available or busy and are compute nodes\n #\n \n ia = instances.select{ |i| i.running?} \n \n ia.each do |ri|\n if (ri.available? || ri.state.eql?('busy')) && ri.farm.farm_type.eql?('compute') && ri.silent_since?(NODE_TIMEOUT)\n #shut down silent nodes\n logger.info \"Shutting down instance #{ri.farm.ami_id} -- #{ri.instance_id} because it was unresponsive.\"\n EventLog.info \"Shutting down instance #{ri.farm.ami_id} -- #{ri.instance_id} because it was unresponsive.\"\n ri.terminate\n \n #recycle if not heard from in a while\n # if ri.cycle_count < NODE_CYCLE_MAX\n # logger.info \"Recycling instance #{ri.farm.ami_id} -- #{ri.instance_id}...\"\n # EventLog.info \"Recycling instance #{ri.farm.ami_id} -- #{ri.instance_id}...\"\n # ri.recycle\n # else\n # logger.info \"Shutting down instance #{ri.farm.ami_id} -- #{ri.instance_id} because it was unresponsive and exceeded max recycle tries.\"\n # EventLog.info \"Shutting down instance #{ri.farm.ami_id} -- #{ri.instance_id} because it was unresponsive and exceeded max recycle tries.\"\n # ri.terminate \n # end\n end \n end\n \n \n return {:farm_name => name, :message => 'Finished reconciling', :num_shutdown => num_stop, :num_started => num_start}\n \n end", "def run_local_migrations()\n setup_local_environment\n # Runs migrations against the local database.\n common = Common.new\n Dir.chdir('db') do\n common.run_inline %W{./run-migrations.sh main}\n end\n Dir.chdir('db-cdr/generate-cdr') do\n common.run_inline %W{./init-new-cdr-db.sh --cdr-db-name cdr}\n end\n common.run_inline %W{gradle :loadConfig -Pconfig_key=main -Pconfig_file=config/config_local.json}\n common.run_inline %W{gradle :loadConfig -Pconfig_key=cdrBigQuerySchema -Pconfig_file=config/cdm/cdm_5_2.json}\n common.run_inline %W{gradle :loadConfig -Pconfig_key=featuredWorkspaces -Pconfig_file=config/featured_workspaces_local.json}\n common.run_inline %W{gradle :updateCdrConfig -PappArgs=['config/cdr_config_local.json',false]}\nend", "def recreate_batched_jobs(id)\n batched_jobs(id).each do |job|\n job.recreate\n end.size\n end", "def run_before_migrate_setup\n Chef::Log.info 'No before migrate setup defined.'\n end", "def deploy_rollback\n info \"--- Rolling Back upgrade ---\"\n duration = Benchmark.realtime do\n output = %x'jruby -S bundle exec cap upgrade deploy:rollback RAILS_ENV=#{environment} 2>&1'\n if $?.success?\n info(output)\n else\n error(output)\n error(\"Rollback failed. Please contact support@6fusion.com. Details located at #{logfile}\")\n exit(1)\n end\n end\n duration\n end", "def perform_after_commit\n bm_after_commit('Efs::TwitterUser.import_from!') do\n Efs::TwitterUser.import_from!(id, uid, screen_name, profile_text, @reserved_friend_uids, @reserved_follower_uids)\n end\n\n bm_after_commit('InMemory::TwitterUser.import_from') do\n InMemory::TwitterUser.import_from(id, uid, screen_name, profile_text, @reserved_friend_uids, @reserved_follower_uids)\n end\n\n bm_after_commit('S3::Friendship.import_from!') do\n S3::Friendship.import_from!(id, uid, screen_name, @reserved_friend_uids, async: true)\n end\n\n bm_after_commit('S3::Followership.import_from!') do\n S3::Followership.import_from!(id, uid, screen_name, @reserved_follower_uids, async: true)\n end\n\n bm_after_commit('S3::Profile.import_from!') do\n S3::Profile.import_from!(id, uid, screen_name, profile_text, async: true)\n end\n\n status_tweets = @reserved_statuses.map { |t| t.slice(:uid, :screen_name, :raw_attrs_text) }\n favorite_tweets = @reserved_favorites.map { |t| t.slice(:uid, :screen_name, :raw_attrs_text) }\n mention_tweets = @reserved_mentions.map { |t| t.slice(:uid, :screen_name, :raw_attrs_text) }\n\n # S3\n\n bm_after_commit('S3::StatusTweet.import_from!') do\n S3::StatusTweet.import_from!(uid, screen_name, status_tweets)\n end\n\n bm_after_commit('S3::FavoriteTweet.import_from!') do\n S3::FavoriteTweet.import_from!(uid, screen_name, favorite_tweets)\n end\n\n bm_after_commit('S3::MentionTweet.import_from!') do\n S3::MentionTweet.import_from!(uid, screen_name, mention_tweets)\n end\n\n # EFS (Automatically deleted)\n\n # bm_after_commit('Efs::StatusTweet.import_from!') do\n # Efs::StatusTweet.import_from!(uid, screen_name, status_tweets)\n # end\n #\n # bm_after_commit('Efs::FavoriteTweet.import_from!') do\n # Efs::FavoriteTweet.import_from!(uid, screen_name, favorite_tweets)\n # end\n #\n # bm_after_commit('Efs::MentionTweet.import_from!') do\n # Efs::MentionTweet.import_from!(uid, screen_name, mention_tweets)\n # end\n\n # In memory (Automatically deleted)\n\n bm_after_commit('InMemory::StatusTweet.import_from') do\n InMemory::StatusTweet.import_from(uid, status_tweets)\n end\n\n bm_after_commit('InMemory::FavoriteTweet.import_from') do\n InMemory::FavoriteTweet.import_from(uid, favorite_tweets)\n end\n\n bm_after_commit('InMemory::MentionTweet.import_from') do\n InMemory::MentionTweet.import_from(uid, mention_tweets)\n end\n end", "def uncompacted_update(messages)\n BatchSlicer.\n slice(messages).\n each(&method(:update_database))\n end", "def big_merger(placed_sur_tiles, placed_tile)\n other_tiles = []\n hotel_name1 = placed_sur_tiles[0].hotel\n hotel_name2 = placed_sur_tiles[1].hotel\n hotel_name3 = placed_sur_tiles[2].hotel\n game_hotel1 = self.game_hotels.where(name: hotel_name1).first\n game_hotel2 = self.game_hotels.where(name: hotel_name2).first\n game_hotel3 = self.game_hotels.where(name: hotel_name3).first\n if (game_hotel1.chain_size >= game_hotel2.chain_size) && (game_hotel1.chain_size >= game_hotel3.chain_size)\n dominant_hotel = game_hotel1.hotel\n acquired_hotel1 = game_hotel2\n acquired_hotel2 = game_hotel3\n color = dominant_hotel.color\n c2 = game_hotel2.hotel.color\n c3 = game_hotel3.hotel.color\n game_tiles2 = self.game_tiles.where(hotel: hotel_name2)\n game_tiles2.each do |tile|\n tile.hotel = dominant_hotel.name\n tile.save\n temp = [tile.tile.row, tile.tile.column, c2]\n other_tiles << temp\n end\n game_tiles3 = self.game_tiles.where(hotel: hotel_name3)\n game_tiles3.each do |tile|\n tile.hotel = dominant_hotel.name\n tile.save\n temp = [tile.tile.row, tile.tile.column, c3]\n other_tiles << temp\n end\n game_hotel1.chain_size += game_tiles2.length + game_tiles3.length\n game_hotel1.save\n game_hotel1.update_share_price\n game_hotel2.chain_size = 0\n game_hotel2.save\n game_hotel2.update_share_price\n game_hotel3.chain_size = 0\n game_hotel3.save\n game_hotel3.update_share_price\n elsif (game_hotel2.chain_size >= game_hotel1.chain_size) && (game_hotel2.chain_size >= game_hotel3.chain_size)\n dominant_hotel = game_hotel2.hotel\n acquired_hotel1 = game_hotel1\n acquired_hotel2 = game_hotel3\n color = dominant_hotel.color\n c1 = game_hotel1.hotel.color\n c3 = game_hotel3.hotel.color\n game_tiles1 = self.game_tiles.where(hotel: hotel_name1)\n game_tiles1.each do |tile|\n tile.hotel = dominant_hotel.name\n tile.save\n temp = [tile.tile.row, tile.tile.column, c1]\n other_tiles << temp\n end\n game_tiles3 = self.game_tiles.where(hotel: hotel_name3)\n game_tiles3.each do |tile|\n tile.hotel = dominant_hotel.name\n tile.save\n temp = [tile.tile.row, tile.tile.column, c3]\n other_tiles << temp\n end\n game_hotel2.chain_size += game_tiles1.length + game_tiles3.length\n game_hotel2.save\n game_hotel2.update_share_price\n game_hotel1.chain_size = 0\n game_hotel1.save\n game_hotel1.update_share_price\n game_hotel3.chain_size = 0\n game_hotel3.save\n game_hotel3.update_share_price\n elsif (game_hotel3.chain_size >= game_hotel1.chain_size) && (game_hotel3.chain_size >= game_hotel2.chain_size)\n dominant_hotel = game_hotel3.hotel\n acquired_hotel1 = game_hotel1\n acquired_hotel2 = game_hotel2\n color = dominant_hotel.color\n c1 = game_hotel1.hotel.color\n c2 = game_hotel2.hotel.color\n game_tiles1 = self.game_tiles.where(hotel: hotel_name1)\n game_tiles1.each do |tile|\n tile.hotel = dominant_hotel.name\n tile.save\n temp = [tile.tile.row, tile.tile.column, c1]\n other_tiles << temp\n end\n game_tiles2 = self.game_tiles.where(hotel: hotel_name2)\n game_tiles2.each do |tile|\n tile.hotel = dominant_hotel.name\n tile.save\n temp = [tile.tile.row, tile.tile.column, c2]\n other_tiles << temp\n end\n game_hotel3.chain_size += game_tiles1.length + game_tiles2.length\n game_hotel3.save\n game_hotel3.update_share_price\n game_hotel1.chain_size = 0\n game_hotel1.save\n game_hotel1.update_share_price\n game_hotel2.chain_size = 0\n game_hotel2.save\n game_hotel2.update_share_price\n end \n\n [color, other_tiles, acquired_hotel1, acquired_hotel1_size, acquired_hotel2, acquired_hotel2_size] \n end", "def ImportUsers zd,params,client,profile\n \n limit = 1000000000\n limit = params['limit'] if params['limit']\n \n attempt = ImportAttempts.create(profile_id: profile['id'],state: params['type'])\n orgs = ZdUsers.where(state: 'pending',error: 0,profile_id: profile['id']).limit(limit)\n fields = ZendeskField.where(zendesk: 1,state: 'users')\n olist = []\n orgs.each do |o|\n \n tmp = {}\n \n fields.each do |f|\n \n key = f['db_name'].to_s\n val = o[f['db_name']]\n if val\n val.strip! if key.include? 'email'\n #val << '.fake.zd' if key == 'email' #COMMENT OUT FOR LIVE\n tmp = tmp.merge(key => val)\n end\n \n end\n \n olist << [o['id'],tmp]\n \n end\n \n tasks = RinoThread.new(7)\n olist.each_with_index do |item,i|\n tasks.queue do\n 1.times do\n \n a_t = Time.now\n\n sql = Mysql2::Client.new(:host => 'localhost',:username => 'root',:database => 'migrationrocket_v2')\n\n q = \"SELECT * FROM import_attempts WHERE profile_id = #{profile['id']} AND state = '#{params['type']}' ORDER BY id DESC LIMIT 1\"\n breakit = false\n sql.query(q).each do |ia|\n #JP %{|||----- #{ia['active']}}\n if ia['active'] == 0\n @on = false\n breakit = true\n end\n end\n \n if breakit\n sql.close\n break \n end\n\n tmp = {user: item[1]}\n pres = {i => tmp}\n #JP pres\n #sql.close\n #break\n call = zd.postCall('/api/v2/users.json',tmp.to_json)\n pres = {time: call[:time],i => tmp}\n JP pres\n\n q = \"UPDATE zd_users SET code = #{call[:code].to_f.round}\"\n\n update = {code: call[:code]}\n if call[:code].to_f.round == 201\n\n update = update.merge(status: 'imported')\n q << \",state = 'imported'\"\n q << \",zendesk_id = #{call[:body]['user']['id']}\"\n\n else\n\n update = update.merge(status: 'imported',error: 1,report: call[:body].to_json)\n q << \",state = 'imported'\"\n q << \",error = 1\"\n q << \",report = '#{sql.escape(call[:body].to_json)}'\"\n\n end\n\n q << \" WHERE id = #{item[0]}\"\n\n sql.query(q)\n sql.close\n\n b_t = Time.now\n\n #JP %{#{(i+1)} ::: #{b_t.to_f-a_t.to_f}\\n}\n \n end\n end\n end\n \n tasks.execute\n \n \n attempt.update_attributes(active: 0)\n \n end", "def reset_migrations!\n @migrations = nil\n @migrate_to = nil\n Neo4j::Transaction.run do\n Neo4j.ref_node[:_db_version] = nil\n end\n end", "def reload_diffs\n new_attributes = {}\n new_diffs = []\n\n if commits.size.zero?\n new_attributes[:state] = :empty\n else\n diff_collection = unmerged_diffs\n\n if diff_collection.overflow?\n # Set our state to 'overflow' to make the #empty? and #collected?\n # methods (generated by StateMachine) return false.\n new_attributes[:state] = :overflow\n end\n\n new_attributes[:real_size] = diff_collection.real_size\n\n if diff_collection.any?\n new_diffs = dump_diffs(diff_collection)\n new_attributes[:state] = :collected\n end\n end\n\n new_attributes[:st_diffs] = new_diffs\n\n new_attributes[:start_commit_sha] = self.target_branch_sha\n new_attributes[:head_commit_sha] = self.source_branch_sha\n new_attributes[:base_commit_sha] = branch_base_sha\n\n update_columns_serialized(new_attributes)\n\n keep_around_commits\n end", "def reload_commits\n new_attributes = {}\n\n commit_objects = unmerged_commits\n\n if commit_objects.present?\n new_attributes[:st_commits] = dump_commits(commit_objects)\n end\n\n update_columns_serialized(new_attributes)\n end", "def import_new_commits_in_branch(branch)\n batch_size = 50\n ncommits = 0\n offset = 0\n three_months = 3.months.ago\n\n logger.info(\"importing new commits from branch #{branch}\")\n loop do\n commits = @grit_repo.commits(branch, batch_size, offset)\n return ncommits if commits.empty?\n commits.each do |commit|\n if Commit.exists?(:sha1 => commit.id)\n if commit.committed_date < three_months\n # We need to stop at some point, so let's assume that no merge is\n # older than 3 months.\n return ncommits\n else\n # A merge can import commits older than existing ones, so just go on.\n next\n end\n end\n import_grit_commit(commit, branch)\n ncommits += 1\n end\n offset += commits.size\n end\n end", "def auto_upgrade!\n AutoMigrator.auto_upgrade(name)\n end", "def auto_upgrade!\n AutoMigrator.auto_upgrade(name)\n end" ]
[ "0.6388077", "0.5842477", "0.5773407", "0.56487805", "0.54802555", "0.547335", "0.54634887", "0.53449374", "0.5319112", "0.52696264", "0.5211735", "0.515682", "0.5112737", "0.5086521", "0.50740397", "0.5068204", "0.50645584", "0.5062173", "0.5035551", "0.5032376", "0.503051", "0.50238496", "0.50138485", "0.5012445", "0.5012445", "0.5010619", "0.49989802", "0.49964607", "0.4993151", "0.49599093", "0.49347177", "0.49347177", "0.49347177", "0.49309176", "0.49229002", "0.4903559", "0.48963866", "0.4884008", "0.48718825", "0.48652816", "0.48651886", "0.48547873", "0.482464", "0.4808065", "0.48001003", "0.47983402", "0.47967342", "0.4795497", "0.479283", "0.4780481", "0.47452447", "0.47426856", "0.4736915", "0.47335073", "0.47310773", "0.47307038", "0.47307032", "0.472841", "0.47184902", "0.47169662", "0.47148493", "0.47084677", "0.4699982", "0.46943492", "0.46868235", "0.4686464", "0.46855563", "0.46831477", "0.46831477", "0.46751386", "0.46713936", "0.46709618", "0.46684185", "0.46560588", "0.46545562", "0.464831", "0.46477", "0.4642687", "0.46373075", "0.46308473", "0.46210852", "0.4620032", "0.46190837", "0.46153164", "0.46152264", "0.4609761", "0.46024814", "0.4596437", "0.45959", "0.45943892", "0.45941514", "0.4593778", "0.45934772", "0.45910197", "0.4586443", "0.45862147", "0.45775136", "0.4575363", "0.45739883", "0.45739883" ]
0.6655419
0
search_text is found within the full_text. Usage example: solution('aa_bb_cc_dd_bb_e', 'bb') should return 2 since bb shows up twice solution('aaabbbcccc', 'bbb') should return 1 =begin Input: Output: Data types: Algorithm: =end
def substr(str) arr = [] 0.upto(str.size - 1) do |idx1| idx1.upto(str.size - 1) do |idx2| arr << str[idx1..idx2] end end arr end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def search_substr( fullText, searchText, allowOverlap = true )\n if searchText == ''\n 0\n else\n fullText.scan(allowOverlap ? Regexp.new(\"(?=(#{searchText}))\") : searchText).size\n end\nend", "def fulltextsearch(query, text, words=2)\n result = \"\"\n if text =~ /.*#{query}.*/i\n text_words = text.scan(/\\w*/)\n indexes = []\n text_words.each_with_index do |word,index|\n if word =~ /.*#{query}.*/i\n i = []\n i << index - words unless words == 0 || index - words < 0\n i << index\n i << index + words unless words == 0 || index + words > text_words.length\n indexes << i\n end\n end\n indexes.each do |i|\n result += \"... \" unless i.length == 1\n i.each {|j| result += \"#{text_words[j]} \"}\n result += \" ...\" unless i.length == 1\n end\n end\n result\n end", "def find(prepostion)\n\t\tpartial_search_kb = string_to_internal(preposition)\n\t\tpartial_search_kb.each do |sentence|\n\t\t\tind = @kb.index(sentence)\n\t\tend\n\t\treturn ind\n\tend", "def string_search(main_string, sub_string)\n count = 0\n i = 0\n while i <= (main_string.length - sub_string.length) do # number of potential tests\n if main_string[i, sub_string.length] == sub_string # string slice is starting position, length\n count += 1;\n end\n i +=1;\n end\n return count\nend", "def find(t)\n text = t\n text.downcase! unless @case_sensitive\n text.gsub!(/\\s+/,' ') # Get rid of multiple spaces.\n @state = 0\n index = 0\n text.each_char do |char|\n # Incrementing now so that I can announce index - @length.\n index += 1\n @state = step(@state,char)\n if @state == @length # Yay, we've got ourselves a match!\n puts \"Match found for #{@word[1,@length]} at #{index - @length}\"\n @state = 0\n end\n end\n end", "def match(search)\n search_words = words(search)\n haystack_words = words(haystack)\n\n (\n search_words.count { |search_word| haystack_words.include? search_word } /\n search_words.count.to_f *\n 100\n ).round\n rescue ZeroDivisionError\n 0\n end", "def find_smallest_subsequence(text, pattern)\n puts \"text= #{text}; pattern= #{pattern}\"\n beginPtr, minBeginPtr, endPtr, minEndPtr = 0, 0, text.length-1, -1\n hasFound = Hash.new(0)\n needToFind = Hash.new(0)\n counter, windowLen, minWindowLen = 0,0,-1\n\n pattern.chars.each { |c| needToFind[c] += 1 }\n\n text.chars.each_with_index do |c, idx| \n endPtr = idx\n # puts \"looking at text char #{c}; beginPtr= #{beginPtr}; endPtr=#{endPtr}\"\n\n if needToFind.has_key?(c)\n hasFound[c] += 1\n if hasFound[c] <= needToFind[c]\n counter += 1 \n end\n\n ch = text.chars[beginPtr] \n if counter == pattern.length \n\n # puts \"hasFound= #{hasFound.inspect}\"\n # puts \"ch= #{ch}; beginPtr= #{beginPtr}; endPtr=#{endPtr}\"\n\n while hasFound[ch] > needToFind[ch] || needToFind[ch] == 0\n # puts \"hasFound[#{ch}] = #{hasFound[ch]}; needToFind[#{ch}] = #{needToFind[ch]}\"\n\n unless needToFind[ch] == 0\n hasFound[ch] -= 1 if hasFound.has_key?(ch)\n # puts \"changing ptrs; beginPtr= #{beginPtr}; endPtr=#{endPtr}; hasFound= #{hasFound.inspect}\"\n end\n beginPtr = beginPtr + 1 \n ch = text.chars[beginPtr] \n end\n windowLen = endPtr - beginPtr + 1\n # print \"Found the current minWindow ==> beginPtr= #{beginPtr}; endPtr=#{endPtr}; windowLen= #{windowLen}; minWindowLen= #{minWindowLen}\"\n if minWindowLen == -1 || windowLen < minWindowLen\n minWindowLen = windowLen \n minBeginPtr = beginPtr\n minEndPtr = endPtr\n end\n # print \" was changed to minWindowLen= #{minWindowLen}\"\n # puts \"\\n\\n\"\n end\n\n end\n end\n return ['none', 'none', 'none'] if minEndPtr == -1\n return [minBeginPtr, minEndPtr, text[minBeginPtr..minEndPtr]]\nend", "def bruteForceStringSearch(text,pattern)\n\treturn nil if pattern.nil? or text.nil?\n\tn = text.length\n\tm = pattern.length\n\t0.upto(n-m) do |i|\n\t\tj = 0\n\t\twhile (j < m) and text[i+j] == pattern[j] do\n\t\t\tj += 1\n\t\tend\n\t\treturn i if j==m\n\tend\n\treturn nil\nend", "def substrings(text, dictionary, results = {},first=true)\n\tinput_words = text.downcase.split(\" \")\n\t\n\tif (input_words.length > 1 || first)\n\t\tfirst = false\n\t\tinput_words.each do |each_word|\n\t\t\tsubstrings(each_word, dictionary, results,first)\n\t\tend\n\t\tputs results\n\telse\n\t\tdictionary.each do |word| \n\t\t\tif ( text.include?(word) )\n\t\t\t\tif (results.has_key?(word))\n\t\t\t\t\tresults[word] += 1\n\t\t\t\telse\n\t\t\t\t\tresults.store(word, 1)\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend\nend", "def test(pattern)\n amount_solved = 0\n steps_to_solution = 0\n\n p = pattern.split('')\n\n genome.split('').each do |c|\n steps_to_solution += 1\n val = p[0]\n if val == c\n amount_solved += 1\n p.slice!(0)\n break if p.length == 0\n end\n end\n\n steps_to_solution - amount_solved\n end", "def find_ocurrences(text, first, second)\n text = text.split(' ')\n \n word_output = []\n \n text.each_with_index do |word, index|\n next if index == 0 || index == 1\n \n word_output << word if text[index - 1] == second && text[index - 2] == first\n end\n \n word_output\nend", "def rabinKarpStringSearch(text, pattern)\n return nil if pattern.nil? or text.nil?\n n = text.length\n m = pattern.length\n\n patternHash = hash_of(pattern)\n textHash = hash_of(text[0,m]) \n\n 0.upto(n-m) do |i|\n if textHash == patternHash\n if text[i..i+m-1] == pattern\n return i\n end\n end\n \n textHash = hash_of(text[i+1..i+m])\n end\n \n nil\nend", "def full_text_search(integer)\n select_size integer\n hit_enter\n end", "def full_text_search(integer)\n select_size integer\n hit_enter\n end", "def exact_matches(search_word, string)\n regexp = Regexp.new(Regexp.escape(search_word), \"i\")\n return (string.scan(regexp) || []).length\n end", "def exact_match(guess)\n\t\t\t# keeps track of which indices have been matched\n\t\t\t@indices = [0,1,2,3]\n\t\t\t# creates array of the matching indices in guess and @code\n\t\t\t@indices.delete_if {|i| guess[i] == @code[i] }\n\t\t\t# returns number of exact matches\n\t\t\t4 - @indices.length\n\t\tend", "def exact_matches(other_code)\n exact_matches = 0\n @seq.each_with_index do |letter, index|\n exact_matches += 1 if self.is_exact_match?(other_code, index)\n end\n exact_matches\n end", "def find_word(search, word, maxRow, maxCol)\n (0..maxRow).each do |i|\n (0..maxCol).each do |j|\n if starts_here(search, word, i, j)\n puts \"The word '#{word}' starts at (#{i},#{j}).\"\n return\n end\n end\n end\n puts \"The word '#{word}' was not found!\"\nend", "def search(word)\r\n n = start_with_helper(word)\r\n #puts \"n=#{n}\"\r\n #puts \"n=#{n}, n.is_end=#{n.is_end}\"\r\n return !n.nil? && n.is_end\r\n end", "def naive_search(str, match_str)\n count = 0\n for i in 0...str.length do\n\n for j in 0...match_str.length do\n \n if(match_str[j] != str[i+j]) \n break\n end\n \n if(j == match_str.length - 1)\n count += 1\n end\n\n end\n\n end\n\n return count;\nend", "def search(word)\n \n end", "def _match_count (substr, text)\n return 0 if (!text || !substr)\n\n count = 0\n offset = 0\n while (result = text.index(substr, offset))\n count += 1\n offset = result + 1\n end\n count\n end", "def string_matching(words)\n result_words = []\n\n words.each_with_index do |possible_substring, index|\n (0..words.size - 1).each do |index_w|\n next if index_w == index || words[index_w].size < possible_substring.size\n \n result_words << possible_substring if words[index_w].index(possible_substring)\n end\n end\n \n result_words.uniq\nend", "def pattern_matching(pattern, genome)\n # Pattern Matching Problem: Find all occurrences of a pattern in a string.\n # Input: Two strings, Pattern and Genome.\n # Output: All starting positions where Pattern appears as a substring of Genome.\n\n # Sample Input:\n # ATAT\n # GATATATGCATATACTT\n\n # Sample Output:\n # 1 3 9\n\n match_indexes = []\n search_start_pos = 0\n while index = genome.index(pattern, search_start_pos)\n match_indexes << index\n # puts index\n search_start_pos = index + 1\n end\n return match_indexes\n end", "def sub_strings(arr,text)\n text = text.downcase\n result = Hash.new(0)\n arr.each do |word|\n result[word] += 1 unless text.scan(word.downcase).empty?\n end\n result\nend", "def long_word_count(text)\n \nend", "def substrings (search_word_list, dictionary)\n #Hash to track word and its count\n word_count_hash = Hash.new\n #Turns search_word_list into an array\n search_word_list_array = search_word_list.split(\" \")\n \n #Loops through the search_word_list\n search_word_list_array.each do |search_word|\n search_word.downcase!\n #Loops through the dictionary\n dictionary.each do |dictionary_word| \n #Checks if dictionary_word is in search_word\n if search_word.include? dictionary_word\n #Checks if the key already exists and increments count by 1 if it does\n if word_count_hash.key?(dictionary_word)\n word_count_hash[dictionary_word] += 1\n else \n #Sets the value of the key to 1 if it doesn't already exist\n word_count_hash[dictionary_word] = 1\n end\n end\n end\n end\n return word_count_hash\nend", "def solution(a)\n str = ''\n a.each do |item|\n i = 0\n while i < item.length\n matched = 0\n \n a.each do |string|\n matched += 1 if string.include?(str)\n end\n \n if matched == a.length && i > 0\n str += item[i-1]\n else\n break\n end\n i += 1\n end\n end\n return str\nend", "def supervising_checker(keywords, tline)\r\n lowestindex = tline.length\r\n counter = 0\r\n keywords.each do |word|\r\n counter += tline.scan(/(?=#{word})/).count\r\n if counter > 2\r\n lowestindex = 1\r\n end\r\n end\r\n return lowestindex\r\nend", "def findMatch str, subStr\n n = 0\n (0..(str.length - subStr.length)).each do |i|\n if subStr == str[i, subStr.length] then n += 1 end\n end\n return n\nend", "def brute_search string, pattern\n pattern_length = pattern.length\n for string_index in (0... string.length)\n match_count = 0\n loop do\n # if a non-match is found, then break.\n break if string[string_index + match_count] != pattern[match_count]\n # if it wasn't a non-match, it must be a match!\n match_count += 1\n # if match_count reaches the length of the pattern, you've found your pattern!\n # return the index in string where the pattern begins\n return string_index if match_count == pattern_length\n end\n end\n return \"not found\"\nend", "def brute_search string, pattern\n pattern_length = pattern.length\n for string_index in (0... string.length)\n match_count = 0\n loop do\n # if a non-match is found, then break.\n break if string[string_index + match_count] != pattern[match_count]\n # if it wasn't a non-match, it must be a match!\n match_count += 1\n # if match_count reaches the length of the pattern, you've found your pattern!\n # return the index in string where the pattern begins\n return string_index if match_count == pattern_length\n end\n end\n return \"not found\"\nend", "def knump (pattern, text, start, endpos, debug_trigger)\n\n debug = \"none\"\n\n if debug_trigger == true then\n debug = \"debug\"\n end\n\n if (!pattern) || (!text) then\n log(\"No pattern input or no string/file input.\", \"error\")\n return []\n end\n\n if pattern.length == 0 || text.length == 0 then\n log(\"Pattern or text of length zero.\", \"error\")\n return []\n end\n\n if pattern.length == 1 then\n log(\"Pattern is a single character. Using ordinary naive search.\", debug)\n return findchar(pattern, text, start, endpos)\n end\n\n if start >= endpos then\n if (pattern.length == 1) && (start == endpos) then\n if text[start] == pattern[0] then\n return [0]\n else\n log(\"Char in text differs from pattern char.\", debug)\n return []\n end\n end\n log(\"Start position is after end position. Seriously?\", debug)\n return []\n end\n\n if start < 0 || endpos >= text.length then\n log(\"Start position is less than zero or end position after last\\n\" +\n \"position in text (y u do dis... dolan pls)\", \"error\")\n return []\n end\n\n prefix = createPrefixTable(pattern)\n\n log(\"Prefix table created: [#{prefix}].\", debug)\n\n results = Array.new(0,0)\n\n iRes = 0\n iPat = 0 # position in pattern\n iPtx = 0 # position of pattern check in text\n iTex = start # position in text\n\n while true\n\n if iTex > endpos then\n log(\"Main loop reached end position: #{endpos}.\", debug)\n break\n end\n\n if text[iTex] != pattern[0] then\n iTex = iTex + 1\n else\n log(\"Partial match at: #{iTex}. Enter secondary loop.\", debug)\n iPtx = iTex\n iPat = 0\n\n while true\n\n if iPtx > endpos then\n log(\"Reached end at: #{endpos} during partial match.\", debug)\n return\n end\n\n if text[iPtx] == pattern[iPat] then\n iPtx = iPtx + 1\n iPat = iPat + 1\n else\n iPtx = iPtx + prefix[iPat]\n iPat = prefix[iPat]\n end\n\n if iPat >= pattern.length then\n results[iRes] = iTex\n iRes = iRes + 1\n iTex = iTex + prefix[iPat - 1] + 1\n log(\"We've got a match! Advance by #{iTex} and continue.\", debug)\n break\n end\n\n if iPat == 0 then\n log(\"We have reached root of pattern. Advance by 1.\", debug)\n iTex = iTex + 1\n break\n end\n\n end\n\n end\n end\n return results\nend", "def suggest(query_term)\n @qt = query_term\n @candidates = Candidates.new\n srs = for_term(@qt)\n\n srs.each do |seg|\n @lex.search(seg).each do |result|\n found(result)\n end\n end\n\n # Run substring rules\n # Check confidence\n # Run ngrams\n # Return most confident candidate set\n return @candidates\n end", "def solve(w, g, v)\n\n\tif $words[g] == -1\n\t\treturn v\n\telsif $words[g] == 1\n\t\treturn v + 1\n\tend\n\t#else $words[g] == 0\n\n\ttkn = next_token(w)\t\n\tfor char in tkn.chars\n\t\tv = solve(String.new(w), g + char, v)\n\tend\n\n\treturn v\nend", "def find_concepts( s )\n jump_count = 0 #prevent matched word from matching again\n ret = []\n return ret if s.blank?\n \n words = s.scan(LanguageModel::PTN_TERM).map{|w|w.downcase}\n 0.upto(words.length-1) do |i| #foreach word in sentence\n h = @ch\n if jump_count > 0 then jump_count-=1 ; next end\n \n i.upto(words.length-1) do |j| #foreach word try matching with concept table\n #p \" >Checking words[#{i},#{j}] = #{w}\"\n w = words[j] #'current word\n wn = words[j+1] if j+1 < words.length # next word\n if !h[w] # no concept is matched\n break \n elsif h[w].class == Hash #many concepts are matched\n # Next Word doesn't match & key was found\n if !h[w][wn] && h[w][:_key_]\n if block_given?\n yield h[w][:_key_] , words[i..j].join(' ')\n else\n #puts \"Found: #{words[i..j].join(' ')}\"\n ret << [h[w][:_key_], words[i..j].join(' ')]\n end\n break\n else #Move to Next Word\n jump_count += 1\n h = h[w]\n end\n elsif h[w].class == Fixnum #one concept is matched\n if block_given?\n yield h[w] , words[i..j].join(' ')\n else\n #puts \"Found: #{words[i..j].join(' ')}\"\n ret << [h[w], words[i..j].join(' ')]\n end\n break\n else\n error \"[ConceptStorage#find_concept] Invalid value #{h[w].inspect}\"\n end\n end#do\n end#do\n ret\n end", "def substrings (searchword, listOfWords)\n\n\n\n # create a array first with searchword and put any word in the array\n\n searchwords = searchword.split(/\\W+/)\n listOfWords = listOfWords\n\n\n dict = Hash.new(0)\n\n listOfWords.each do |word| # This function puts the word's inside the hash and increase the counter\n searchwords.each do |search|\n\n if search.downcase.include? word.downcase\n dict[word] += 1\n end\n end\n end\n\n\n dict.each do |word, count|\n\n puts \"Word: #{word} \\n Count: #{count}\"\n\n end\n\n\nend", "def test_approach\n prefix = \"This pangram tallies \"\n solution = \"This pangram tallies five a's, one b, one c, two d's, twenty-eight e's, eight f's, six g's, eight h's, thirteen i's, one j, one k, three l's, two m's, eighteen n's, fifteen o's, two p's, one q, seven r's, twenty-five s's, twenty-two t's, four u's, four v's, nine w's, two x's, four y's and one z.\"\n pangram = SelfDocumentingPangram.new(prefix)\n assert_equal(solution, pangram.add_count(pangram.count(solution)))\n\n prefix = \"This terribly inefficient pangram contains \"\n solution = \"This terribly inefficient pangram contains five a's, two b's, three c's, two d's, thirty-one e's, six f's, four g's, ten h's, sixteen i's, one j, one k, three l's, two m's, twenty n's, thirteen o's, two p's, one q, twelve r's, twenty-eight s's, twenty-eight t's, three u's, three v's, nine w's, four x's, six y's and one z.\"\n pangram = SelfDocumentingPangram.new(prefix)\n assert_equal(solution, pangram.add_count(pangram.count(solution)))\n end", "def boyerMooreStringSearch(text,pattern,bad_symbol_shift,good_suffix_shift)\n\treturn nil if pattern.nil? or text.nil?\n text, pattern = text.unpack('U*'), pattern.unpack('U*')\n n=0 \n while (n <= text.length - pattern.length) do \n m = pattern.length - 1 \n while (pattern[m] == text[m+n]) do\n return n if m==0 \n m -= 1; \n end \n # If not found, shift based on our precomputed tables\n n += max(good_suffix_shift[m], m - bad_symbol_shift[text[n+m]]);\n end\n return nil \nend", "def searching_single(phrase)\n analyse_result(Ca::SimilarTest.mechanize_work(phrase), phrase)\n end", "def find(search_string)\n result_array = []\n search_words = search_string.split(/\\s+/)\n\n # Loop over all entries in the index.\n @data.each{ |entry|\n begin\n # Check whether this entry matches the search words.\n score = 0\n search_words.each{ |search_word|\n next if search_word.empty?\n\n s = 2 * AE::LaunchUp::Scorer.score(search_word, entry[:name]) if entry[:name].is_a?(String)\n s += 2 * AE::LaunchUp::Scorer.score(search_word, entry[:description]) if entry[:description].is_a?(String)\n s += 2 * AE::LaunchUp::Scorer.score(search_word, entry[:category]) if entry[:category].is_a?(String)\n s += exact_matches(search_word, entry[:keywords].join(\" \"))/(entry[:keywords].length|1).to_f if entry[:keywords].is_a?(Array) && !entry[:keywords].empty?\n s += 2 * AE::LaunchUp::Scorer.score(search_word, entry[:keywords].join(\" \")) if entry[:keywords].is_a?(Array)\n s += exact_matches( search_word.gsub(/\\/|\\\\/, \"\"), entry[:file].gsub(/\\/|\\\\/, \"\") ) if entry[:file].is_a?(String) && search_word.length > 4\n\n # Skip if no match has been found.\n break score = 0.0 if s == 0.0\n score += s\n }\n\n # Tweaks for relevance:\n # Entries with icons match better with users's expectation,\n # urls or \"about\" rather not.\n score *= 3 if entry[:icon].is_a?(String)\n #score *= 0.5 if entry[:name][/about|paypal/i] || entry[:description][/http/]\n\n # Check wether the command is available in the current context. We don't\n # want to reject it completely from the search results, so that the user\n # won't miss it in an explicit search will. We give a hint if it's disabled.\n if entry[:validation_proc]\n status = nil\n begin\n status = entry[:validation_proc].call == MF_ENABLED\n rescue LocalJumpError => e\n # Validation proc contains a \"return\"?\n $stderr.write(\"Validation proc of '#{entry[:name]}' (#{entry[:id]}) contains 'return'\\n#{e.message.to_s}\\n#{e.backtrace.join(\"\\n\")}\" << $/)\n rescue Exception => e\n # Validation proc contains other bug.\n $stderr.write(\"Error in validation proc of '#{entry[:name]}' (#{entry[:id]})\\n#{e.message.to_s}\\n#{e.backtrace.join(\"\\n\")}\" << $/) if $VERBOSE\n end\n entry[:enabled] = status\n score *= 0.5 if status == false\n end\n\n # Skip if no match has been found.\n next if score < 1.0\n\n # Consider tracking data, how often this entry has been selected over others:\n # Divide track by half of average track (total_track/data.length).\n score += [entry[:track] / (@total_track|1).to_f * 0.5 * @data.length, 5].min if entry[:track]\n entry[:score] = score\n\n # Add it to results.\n result_array << entry\n rescue Exception => e\n $stderr.write(\"AE::LaunchUp::Index: Error in 'find' when searching '#{entry[:name]}' (#{entry[:id]})\\n#{e.message.to_s}\\n#{e.backtrace.join(\"\\n\")}\" << $/)\n break\n end\n }\n\n return result_array\n rescue Exception => e\n $stderr.write(\"AE::LaunchUp::Index: Error in 'find' when searching '#{search_string}'\\n#{e.message.to_s}\\n#{e.backtrace.join(\"\\n\")}\" << $/)\n return []\n end", "def test_long_string\n assert_equal(\"g\", @target.find_first_non_repeating(\"learning javascript is pretty lame\"))\n end", "def solve(str)\n idx = 0\n count = 0\n\n substr_1 = ''\n substr_2 = ''\n\n loop do\n substr_1 = str[0..idx]\n substr_2 = str[(idx + 1)..-1]\n\n substr_1.to_i.odd? ? count += 1 : nil \n substr_2.to_i.odd? ? count += 1 : nil \n \n idx += 1\n break if idx >= str.length\n end\n count\nend", "def final_suggestion\n longest_substring = 0\n best_suggestion = nil\n\n self.possible_suggestions.each do |suggestion|\n if suggestion.common_substring_length > longest_substring\n best_suggestion = suggestion.possible_word\n longest_substring = suggestion.common_substring_length\n end\n end\n\n best_suggestion\n end", "def test_9_return_positions_of_letter_in_word\r\n $word = \"repeated\"\r\n letter = \"e\"\r\n results = find_locations(letter)\r\n assert_equal([1, 3, 6], results)\r\n end", "def brute_force_matches string, pattern\n i = 0\n pos = []\n while i + pattern.length - 1 < string.length\n pos << i if string[i..(i + pattern.length - 1)] == pattern\n i += 1\n end\n pos\nend", "def search(word)\r\n \r\n end", "def included_once (haystack, needle)\n acc = 0\n haystack.each do |word|\n if word == \"#{needle}\"\n acc += 1\n end\n end\n if acc == 1\n puts \"True\"\n return true\n else\n puts \"False\"\n return false\n end\nend", "def calculate_match_probability\n # two heuristics: \n # 1 is are their multiple words in term_text? if so, mark as probable\n # if not, does it match the anchor regexp? if so, mark as probable\n # else, mark as improbable\n \n # multiple words?\n anchor_regexp = \"(featuring|plus|the|presents|with|plus|and|\\,|\\&|[()]|\\/|\\:|\\-|^|$)\"\n nix_regexp = \"parking|\\svs\\.?\\s\" \n if artist_name=~/#{nix_regexp}/i\n self.match_probability=\"unlikely\"\n return nil\n end\n text=term_text.strip\n if text[\" \"]\n self.match_probability=\"likely\"\n return \"multpl\"\n end\n if artist_name=~/#{anchor_regexp}\\s*#{text}\\s*#{anchor_regexp}/i\n self.match_probability=\"likely\"\n return \"regexp\"\n end\n# if artist_name=~/#{anchor_regexp}\\s+?#{text}\\s+?#{anchor_regexp}/i\n# match_probability=\"likely\"\n# return \"regexp\"\n# end\n self.match_probability=\"unlikely\"\n return nil\n end", "def find_word(letters, unused, mask, target_word, idx, adj_matrix)\n 0.upto mask.length do |letter_idx|\n if (mask[letter_idx] and\n unused[letter_idx] and\n (letters[letter_idx] == target_word[idx]))\n if idx == target_word.length - 1\n return true\n else\n unused[letter_idx] = false\n return find_word(letters, unused, adj_matrix[letter_idx],\n target_word, idx + 1, adj_matrix)\n end\n end\n end\n return false\nend", "def search(max_count=0,&block)\n @min_size = size\n @min_repeats = 1000\n @max_count = max_count\n @count = 0\n @word_letters = WordLetterMap.new @words\n begin\n pangram_search([],&block)\n rescue AllDone\n # Quit gracefully\n end\n end", "def count_word_combinations( text )\n combinations = @word_combinations_database.find_all{|v| text.index( v )}\n combinations.each{|combination|\n add_word( combination )\n }\n return combinations\n end", "def find_potential_matches\n comp_words.each_with_object([]) do |comp_word, collection|\n next if comp_word == word\n\n tokenized_comp_word = tokenize_string(comp_word)\n common_token_count = (tokenized_word & tokenized_comp_word).count\n similarity = (2 * common_token_count) / (word.length + comp_word.length).to_f\n collection << comp_word if similarity > PRECISION\n end\n end", "def solve(words)\n x = 0\n while x < words.max.length\n equal = words.all? do |word|\n word[0..x] == words[0][0..x]\n end\n if equal == false\n return words[0][0...x]\n end\n x += 1\n end\nend", "def search\n\t\terror_message = nil\n\t\tresults = []\n\t\tloop do\n\t\t\t# system \"clear\"\n\t\t\tputs error_message || \"Please enter how you'd like to search.\".green\n\t\t\tputs \"1) Exact Match\\n2) Partial Match\\n3) Begins With...\\n4) Ends With...\\n\"\n\t\t\tprint \">\".blink.cyan\n\t\t\tinput = gets.chomp.to_i\n\t\t\tif input.is_a?(Fixnum) && input >= 1 && input <= 4\n\t\t\t\tresults = @dictionary_analyzer.search(input, @dictionary)\n\t\t\t\tbreak\n\t\t\telse\n\t\t\t\terror_message = \"Sorry, invalid input. Please choose 1,2,3 or 4.\"\n\t\t\t\tredo\n\t\t\tend\t\n\t\tend\n\n\t\t# Now that we have the results let's do something\n\t\t# with them. Unless there aren't any.\n\t\tif results.count == 0\n\t\t\tputs \"Sorry, no words were found that match that string.\"\n\t\telse\n\t\t\tfound_match(results)\n\t\tend\n\tend", "def num_matching(one_bigrams, two_bigrams, acc = 0)\n return acc if one_bigrams.empty? || two_bigrams.empty?\n\n one_two = one_bigrams.index(two_bigrams[0])\n two_one = two_bigrams.index(one_bigrams[0])\n\n if one_two.nil? && two_one.nil?\n num_matching(one_bigrams.drop(1), two_bigrams.drop(1), acc)\n else\n # If one is nil, it is set to the other\n two_one ||= one_two\n one_two ||= two_one\n\n if one_two < two_one\n num_matching(one_bigrams.drop(one_two + 1),\n two_bigrams.drop(1), acc + 1)\n else\n num_matching(one_bigrams.drop(1),\n two_bigrams.drop(two_one + 1), acc + 1)\n end\n end\n end", "def find_solution(first_word, second_word)\n\tif first_word.length != second_word.length\n\t\treturn \"bad input, words must be the same length\"\n\tend\n\n\tcurrent_word = first_word\n\t$chain << first_word\n\n\twhile true\n\t\tpossible = words_1_letter_diff(current_word)\n\t\tpossible = possible - $seen\n\t\tif possible.include?(second_word)\n\t\t\treturn $chain << second_word\n\t\tend\n\n\t\tif possible != []\n\t\t\t$chain << possible.last\n\t\t\t$seen << possible.last\n\t\t\tcurrent_word = $chain.last\n\t\telse\n\t\t\tbacktrack()\n\t\t\tcurrent_word = $chain.last\n\t\tend\n\n\t\tif $chain == []\n\t\t\treturn \"impossible\"\n\t\tend\n\n\t\tif $chain.last == second_word\n\t\t\treturn $chain\n\t\tend\n\tend\nend", "def recursion_part_of_search(path, word)\n if word.length <= 1 # word was found\n @word_path = path # save the entire path to instance variable\n return true\n end\n\n for offset in 0...8 # test if any adjacent locations on board is contains the next letter in word and not used already\n if should_use_array_location?([path[-1][0] + @location_offset[offset][0], path[-1][1] + @location_offset[offset][1]], path, word)\n return true if recursion_part_of_search(path.clone << [path[-1][0] + @location_offset[offset][0], path[-1][1] + @location_offset[offset][1]], word.clone.split(//).drop(1).join(\"\"))\n end\n end\n false\n end", "def search(word)\r\n #puts \"hehe, search(#{word})\"\r\n if word.length == 0\r\n # handle separately\r\n return @empty_string_exist\r\n end\r\n\r\n stack = []\r\n\r\n if word[0] == '.'\r\n nodes = all_node_in_this_idx(@root)\r\n nodes.each do |node|\r\n stack << [node, 0]\r\n end\r\n else\r\n node = search_node_or_insert_node(@root, word[0])\r\n #puts \"node=#{node}, letter=#{node.letter}\"\r\n if !node.nil? && node.letter == word[0]\r\n stack << [node, 0]\r\n end\r\n end\r\n\r\n while !stack.empty? do\r\n n, idx = stack.pop\r\n #puts \"search, n=#{n}, n.letter=#{n.letter}, idx=#{idx}\"\r\n\r\n if idx == word.length - 1\r\n #puts \"maozi\"\r\n if n.is_end\r\n return true\r\n end\r\n else\r\n #puts \"maozi1\"\r\n if word[idx + 1] == '.'\r\n\r\n #puts \"maozi2\"\r\n nodes = all_node_in_this_idx(n.next)\r\n nodes.each do |node|\r\n stack << [node, idx + 1]\r\n end\r\n else\r\n #puts \"maozi3\"\r\n #puts \"n.next=#{n.next}\"\r\n #puts \"n.next.right=#{n.next.right}\"\r\n node = search_node_or_insert_node(n.next, word[idx + 1])\r\n #puts \"maozi4\"\r\n #puts \"node=#{node}, letter=#{node.letter}, idx=#{idx}\"\r\n #puts \"#{n.next}\"\r\n if !node.nil? && node.letter == word[idx + 1]\r\n #puts \"xbh\"\r\n stack << [node, idx + 1]\r\n end\r\n end\r\n end\r\n end\r\n\r\n return false\r\n end", "def search_full(pattern, advance_pointer, return_string)\n do_scan pattern, advance_pointer, return_string, false\n end", "def substrings(word_string, dictionary)\r\n results = {}\r\n count = 0\r\n word_array = (word_string.downcase).split(' ')\r\n dictionary.each do |search_phrase|\r\n word_array.each do |word|\r\n count+=1 if (word.include? search_phrase)\r\n end\r\n results[search_phrase] = count if count > 0\r\n count = 0\r\n end\r\n return results\r\nend", "def get_word_occurence_index(word, sentence_index, word_sentence_index)\n word_occurence = 0\n i = 0\n \n while i<sentence_index\n word_occurence += @sentences[i].get_word_frequncy(word, nil)\n i += 1\n end\n \n word_occurence += @sentences[sentence_index].get_word_frequncy(word, word_sentence_index)\n return word_occurence\n end", "def try_to_match(tokens, match_start)\n progress = PatternMatchProgress.progress_start\n (match_start...tokens.length).each do |i|\n token = tokens[i]\n features = token.feature.split(',')\n y = features.last\n if reWord !~ y\n if y == '、'\n next\n end\n return nil\n end\n if progress.word_start? && !jiritu_token?(features)\n return nil\n end\n n = count_char(y)\n progress = progress.add_sentence(token.surface, n)\n\n if progress.word_length_matched?\n progress = progress.mark_word_break\n elsif progress.word_length_over?\n return nil\n end\n return progress.sentence if progress.matched?\n end\n nil\n end", "def strstr(haystack, needle)\n i = 0\n while i < haystack.length do\n if haystack[i] == needle[0]\n found = true\n needle.length.times do |j|\n if haystack[i + j] != needle[j]\n found = false\n break\n end\n end\n return i if found\n end\n \n i += 1\n end\n \n false\nend", "def score_word(a, b)\n count = 0\n a.split('').each_index do |i|\n if a[i] == b[i]\n count += (a.length - i)\n end\n end\n return count\n end", "def exact_match_length(search_word, string)\n regexp = Regexp.new(Regexp.escape(search_word), \"i\")\n return ((string.scan(regexp) || [\"\"]).map{ |s| s.length}.first || 0) / search_word.length\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 solution(a)\n shortest = a.min_by &:length\n maxlen = shortest.length\n maxlen.downto(0) do |len|\n 0.upto(maxlen - len) do |start|\n substr = shortest[start,len]\n return substr if a.all?{|str| str.include? substr }\n end\n end\nend", "def exact_beginning_length(search_word, string)\n regexp = Regexp.new(\"(?:\\\\b\" + search_word.gsub(/(?!^)./){ |e| \"#{Regexp.escape(e)}?\"}, \"i\")\n return ((string.scan(regexp) || [\"\"]).max{ |a, b| a.length <=> b.length} || 0) / search_word.length\n end", "def search(word)\n last = word.each_char.inject(@root) do |curr, char|\n curr.is_a?(TrieNode) ? curr[char] : nil\n end \n last && last[:_] || false \n end", "def match_text text\n @lookups.each do |rx_curr|\n return true if text =~ rx_curr\n end\n false\n end", "def search(word)\n pnt = @r\n word.chars.each do |x|\n return false if !pnt[x]\n pnt = pnt[x]\n end\n return true if pnt['end']\n return false\n end", "def search_full(pattern, succptr, getstr)\n _scan(pattern, succptr, getstr)\n end", "def fuzzy_match( input, match_against )\n [*match_against].each_with_index do |targ, idx|\n if input =~ /^#{targ}$/i\n return idx\n elsif input.slice(0..5) =~ /^#{targ.slice(0..5)}/i\n return idx\n end\n end\n return nil\n\n end", "def calculate\n @text.scan(\"#{@keyword}\").size\n end", "def exact_match_count\n (0..3).inject(0) do |count, index|\n count + (exact_match?(index) ? 1 : 0)\n end\n end", "def kiwixKeywordSearch(question, acc)\n\tif acc[-1] == '2'\n\t\tputs 'end with 2'\n\t\tif acc.length == 2\n\t\t\tacc = acc[0..-2]\n\t\t\tputs acc\t\t\n\t\t\tterm = question.scan(/\\b#{acc[0]}\\w*/)[1]\n\t\telse\n\t\t\tacc = acc[0..-2]\n\t\t\tputs acc\t\t\n\t\t\tterm = question.scan(/\\b#{acc[0]}\\w*\\s#{acc[1]}\\w*/)[1]\n\t\tend\n\telsif acc[-1] == '3'\n\t\tif acc.length == 2\n\t\t\tacc = acc[0..-2]\n\t\t\tputs acc\t\t\n\t\t\tterm = question.scan(/\\b#{acc[0]}\\w*/)[2]\n\t\telse\n\t\t\tacc = acc[0..-2]\n\t\t\tputs acc\t\t\n\t\t\tterm = question.scan(/\\b#{acc[0]}\\w*\\s#{acc[1]}\\w*/)[2]\n\t\tend\n\telsif acc.length == 1\n\t\tterm = question[/\\b#{acc[0]}\\w*/]\n\telsif acc.length == 2\n\t\tterm = question[/\\b#{acc[0]}\\w*\\s#{acc[1]}\\w*/]\n\telsif acc.length == 3\n\t\tterm = question[/\\b#{acc[0]}\\w*\\s#{acc[1]}\\w*\\s#{acc[2]}\\w*/]\n\telsif acc.length == 4\n\t\tterm = question[/\\b#{acc[0]}\\w*\\s#{acc[1]}\\w*\\s#{acc[2]}\\w*\\s#{acc[3]}\\w*/]\n\telsif acc.length == 5\n\t\tterm = question[/\\b#{acc[0]}\\w*\\s#{acc[1]}\\w*\\s#{acc[2]}\\w*\\s#{acc[3]}\\w*\\s#{acc[0]}\\w*/]\n\telsif acc.length == 6\n\t\tterm = question[/\\b#{acc[0]}\\w*\\s#{acc[1]}\\w*\\s#{acc[2]}\\w*\\s#{acc[3]}\\w*\\s#{acc[0]}\\w*\\s#{acc[0]}\\w*/]\n\telse \n\t\tterm = question[/\\b#{acc[0]}\\w*\\s#{acc[1]}\\w*\\s#{acc[2]}\\w*\\s#{acc[3]}\\w*\\s#{acc[0]}\\w*\\s#{acc[0]}\\w*\\s#{acc[0]}\\w*/]\n\tend\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\n\tprint \"term = \" + term.to_s + \"\\n\\n\"\n\n\tbegin\n\t\taddress ='http://127.0.0.1:8000/wikipedia_en_all_nopic_01_2012/A/' + URI::encode(term) + '.html'\n\trescue\n\t\tputs \"address encoding error\"\n\t#---------------------------To be removed?\n\thtml = HTTParty.get(address)\n\t#puts html +\"\\n\\n\\n\"\n\treturn html\nend\n\n\n# puts a colour aided wikipedia article to screen, with pnum the number of the paragraph\ndef paras(text, q, aA, aB, aC, aD, pnum = 0)\n\tcommon_words = [\"the\", \"be\", \"of\", \"and\", \"a\", \"is\", \"to\", \"in\", \"he\", \"have\", \"it\", \"that\", \"for\", \"they\", \"I\", \"with\", \"as\", \"not\", \"on\", \"she\", \"at\", \"by\", \"this\", \"we\", \"you\", \"do\", \"but\", \"from\", \"or\", \"which\", \"one\", \"would\", \"all\", \"will\", \"there\", \"say\", \"who\", \"make\", \"when\", \"can\", \"more\", \"if\", \"no\", \"man\", \"out\", \"other\", \"so\", \"what\", \"time\", \"up\", \"go\", \"about\", \"than\", \"into\", \"could\", \"only\", \"these\", \"come\", \"these\", \"some\", \"then\", \"any\"] #, \"state\", \"only\", \"new\", \"year\", \"some\", \"take\", \"come\", \"these\", \"know\", \"see\", \"use\", \"get\", \"like\", \"then\", \"first\", \"any\", \"work\", \"now\", \"may\", \"such\", \"give\", \"over\", \"think\", \"most\", \"even\", \"find\", \"day\", \"also\", \"after\", \"way\", \"many\", \"must\", \"look\", \"before\", \"great\", \"back\", \"through\", \"long\", \"where\", \"much\", \"should\", \"well\", \"people\", \"down\", \"own\", \"just\", \"because\", \"good\", \"each\", \"those\", \"feel\", \"seem\", \"how\", \"high\", \"too\", \"place\", \"little\", \"world\", \"very\", \"still\", \"nation\", \"hand\", \"old\", \"life\", \"tell\", \"write\", \"become\", \"here\", \"show\", \"house\", \"both\"]\n\n\tnumberWords = [\"one\", \"two\", \"three\", \"four\", \"five\", \"six\", \"seven\", \"eight\", \"nine\", \"ten\", \"eleven\", \"twelve\", \"thirteen\", \"fourteen\", \"fifteen\", \"sixteen\", \"seventeen\", \"eighteen\", \"nineteen\", \"twenty\", \"thirty\", \"forty\", \"fifty\", \"sixty\", \"seventy\", \"eighty\", \"ninety\", \"hundred\", \"thousand\", \"million\", \"billion\", \"trillion\"] \n\tnumberWords = Regexp.union(numberWords)\n\n\taWords = []\n\taWords << aA << aB << aC << aD\t\n\tqWords = q.split(\" \")\n\tallWords = aWords + qWords\n \ttext = text.scan(/(\\<p\\>)(.*?)(\\<\\/p\\>)/m).map(&:join)[pnum]\n \twrittenNumbers = []\n\n \tputs \"allWords = \" + allWords.to_s\n\n\n\ttext.gsub!(/<\\/?[^>]*>/,\"\")\n\ttext.gsub!(/(&#160;)/,\"\")\n\ttext.gsub!(/(\\[\\d+\\])/,\"\")\n\twrittenNumbers = text.downcase.scan(/\\b#{numberWords}(?:(?:\\s+and\\s+|\\s+)#{numberWords})*\\b/i)\n\twrittenNumbers.concat text.scan(/\\b[\\d\\.*,*]+\\b/)\n\tputs \"writtenNumbers = \" + writtenNumbers.to_s\n\n\taWords.each do |i|\n\t\ti2 = i.gsub(/(\\?|\\.|\\,|\\!)/,\"\")\n\t\tif common_words.include?(i2) == false\n\t\t\ttext.gsub!(/\\b#{i2}\\b/i, orange(i2))\n\t\tend\n\tend\n\n\tqWords.each do |i|\n\t\ti2 = i.gsub(/(\\?|\\.|\\,|\\!)/,\"\")\n\t\tif common_words.include?(i2) == false\n\t\t\ttext.gsub!(/\\b#{i2}\\b/i, pink(i2))\n\t\tend\n\tend\t\t\n\n\twrittenNumbers.each do |wnum|\n\t\tif wnum.numberize != 0 \n\t\t\tputs \"wnum = \" + wnum.numberize.to_s\n\t\tend\n\t\tallWords.each do |qora|\n\t\t\tif qora.numberize != 0\n\t\t\t\tputs \"qora = \" + qora.numberize.to_s \n\t\t\tend \n\t\t\tif wnum.numberize < qora.numberize * 1.05 and wnum.numberize > qora.numberize * 0.95\n\t\t\t\ttext.gsub!(/\\b#{wnum.to_s}\\b/i, blue(wnum.to_s))\n\t\t\tend\n\t\tend\n\tend\n\treturn text\nend\n\n\n\n#returns list of uris from a google search\ndef googleSearch(q, n = 5)\n\n\tsearch = Google::Search::Web.new do |search|\n\t search.query = q\n\t search.size = :small\n\tend\n\tbegin\n\t\turis = search.first(n).map(&:uri)\n\trescue\n\t\t\"uri fault\"\n\tend\n\n\treturn uris\nend\n\n\n#iterably counts number of hits of each answer in a list of uris\ndef hitCount(uris, aA, aB, aC, aD)\n\n\thitCountStart = Time.now\n\taAll = []\n\taAll << aA << aB << aC << aD\n\n countA = 0\n\tcountB = 0\n\tcountC = 0\n\tcountD = 0\n\n\n\taA = aA.downcase\n\taB = aB.downcase\n\taC = aC.downcase\n\taD = aD.downcase\n\t\n\n\taTotal = []\n\tbTotal = []\n\tcTotal = []\n\tdTotal = []\n\n\tplaintexts=[]\n\n\tn = uris.size\n\n\tn.times {|i|\n\t\tif Time.now - hitCountStart < 8\n\t\t\tbegin\n\t\t\t\tbegin\n\t\t\t \tdoc = Nokogiri::HTML(open(uris[i]))\n\t\t\t \tdoc.css('script, link').each { |node| node.remove }\n\t\t\t \t\tplaintexts << doc.css('body').text.downcase.split(\"\\n\"). collect { |line| line.strip }.join(\"\\n\")\n\t\t\t \trescue\n\t\t\t \t\tputs \"Nokogiri could not read\"\n\t\t\t \tend\n\t\t \t#rescue\n\t\t \t#\t\"Nokogiri fault\"\n\n\t\t \t\t\t\t\t\n\t\t\tplaintexts[i].each_line { |bar|\n\n\t\t\t\tbegin\n\t\t\t\t\tcountA += bar.scan(/\\b#{aA}\\b/i).size\n\t\t\t\trescue\n\t\t\t\tend\t\t\t\t\t\n\t\t\t\tbegin\n\t\t\t\t\tcountB += bar.scan(/\\b#{aB}\\b/i).size\n\t\t\t\trescue\n\t\t\t\tend\n\t\t\t\tbegin\t\t\t\t\t\n\t\t\t\t\tcountC += bar.scan(/\\b#{aC}\\b/i).size\n\t\t\t\trescue\n\t\t\t\tend\t\n\t\t\t\tbegin\t\t\t\t\n\t\t\t\t\tcountD += bar.scan(/\\b#{aD}\\b/i).size\n\t\t\t\trescue\n\n\t\t\t\tend\n\n\t\t\t}\n\t\t\tputs \"A = \" + countA.to_s +\t\" B = \" + countB.to_s + \" C = \" + countC.to_s +\t\" D = \" + countD.to_s\n\t\tend\n\tend\n\t}\nend\n\n\ndef definitionAnswers(aA, aB, aC, aD)\n\taAll = []\n\taAll << aA << aB << aC << aD\n\taAll.each do |answer|\n\tif Dictionary.key?(answer)\n\t\tputs \"\\n\" + answer + \": \" + Dictionary[answer] +\"\\n\\n\"\n\telse\n\t\tputs \"\\n\" + answer + ' not found' +\"\\n\\n\"\n\tend\nend\nend\n\n\ndef dots(q, aA, aB, aC, aD)\n\tdotA = q.sub(/\\.\\.\\./,\" \" + aA)[/(‘|').*?(‘|')/][1..-2]\n\tdotB = q.sub(/\\.\\.\\./,\" \" + aB)[/(‘|').*?(‘|')/][1..-2]\n\tdotC = q.sub(/\\.\\.\\./,\" \" + aC)[/(‘|').*?(‘|')/][1..-2]\n\tdotD = q.sub(/\\.\\.\\./,\" \" + aD)[/(‘|').*?(‘|')/][1..-2]\n\t \n\n\taddress1 ='http://127.0.0.1:8000/wikipedia_en_all_nopic_01_2012/A/' + URI::encode(dotA) + '.html'\n\taddress2 ='http://127.0.0.1:8000/wikipedia_en_all_nopic_01_2012/A/' + URI::encode(dotB) + '.html'\n\taddress3 ='http://127.0.0.1:8000/wikipedia_en_all_nopic_01_2012/A/' + URI::encode(dotC) + '.html'\n\taddress4 ='http://127.0.0.1:8000/wikipedia_en_all_nopic_01_2012/A/' + URI::encode(dotD) + '.html'\n\n\thtmls = []\n\thtmls << HTTParty.get(address1) << HTTParty.get(address2) << HTTParty.get(address3) << HTTParty.get(address4)\n\treturn htmls\nend\nend", "def find_ladders(begin_word, end_word, word_list)\n word_list = create_dictionary(word_list)\n queue = [[begin_word, 1, {}, [begin_word]]]\n paths = []\n min_count = nil\n \n until queue.empty?\n word, count, visited, path = queue.shift\n\n (0...word.length).each do |idx|\n sliced = word[0...idx] + \"_\" + word[idx + 1..-1]\n\n word_list[sliced].each do |w|\n if !visited[w]\n current_visited = visited.dup\n current_path = path.dup\n current_visited[w] = true\n current_path << w\n queue << [w, count + 1, current_visited, current_path]\n\n if w == end_word && !min_count\n min_count = count + 1\n paths << current_path\n elsif w == end_word && min_count == count + 1\n paths << current_path\n end\n end\n end\n end\n end\n\n paths\nend", "def unordered_match (target_word, matrix, ans_arr_el, index, track, trace)\t\n\tif index == 0 \n\t\t$seed[ans_arr_el[0][0]][:num_groups][ans_arr_el[0][1]].each do |word|\n\t\t\ttemp_word = track + word \n\t\t\tif(target_word == temp_word.chars.sort.join)\t\t\t\t\n\t\t\t\ttemp_answer = trace.dup\n\t\t\t\ttemp_answer.push(word)\n\t\t\t\t$answer[:words].push(temp_answer)\t\t\t\t\n\t\t\tend\n\t\tend\n\telsif index > 0\n\t\t$seed[ans_arr_el[index][0]][:num_groups][ans_arr_el[index][1]].each do |word|\n\t\t\tc = trace.dup\n\t\t\tc.push(word)\n\t\t\tunordered_match(target_word, matrix, ans_arr_el, index - 1, track + word, c)\t\t\t\t\t\t\n\t\tend\t\t\n\tend\t\nend", "def search_words\n begin\n regex = Regexp.new(@pattern)\n rescue RegexpError => msg\n error_msg(msg)\n rescue NameError => msg\n error_msg(msg)\n end\n @results = DICT.select do |word|\n regex =~ word\n end\n @num_results = @results.length\n format_results\n display_results\n end", "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 hasSubstring(find,y)\n find = find.split(//)\n y = y.split(//)\n if find == y\n return true\n end\n\n for i in 0..(y.length-1) do\n foundNonMatch = false\n for j in 0..(find.length-1) do\n puts i.to_s + \" and \" + j.to_s\n if y[i+j] != find[j]\n foundNonMatch = true\n break\n end\n end\n if !foundNonMatch\n return true\n end\n end\n false\nend", "def exact_matches(other_code)\n num_matches = 0\n self.pegs.each_with_index do |code, index|\n if(code == other_code[index])\n num_matches += 1\n end\n end\n num_matches\n end", "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 word_pattern(pattern, str)\n str_hash = {}\n pattern_hash = {}\n \n return false if pattern.chars.size != str.split(' ').size\n \n str.split(' ').each_with_index do |substr, index|\n if str_hash[pattern[index]]\n return false unless str_hash[pattern[index]] == substr\n else\n str_hash[pattern[index]] = substr\n end\n \n if pattern_hash[substr]\n return false unless pattern_hash[substr] == pattern[index]\n else\n pattern_hash[substr] = pattern[index]\n end\n \n puts str_hash\n puts pattern_hash\n end\n \n true\nend", "def compound_match(fragments, target)\n match_set = fragments.map.with_index{|word, idx| [target.split(word), idx]}.select{|item| item[0].include?(\"\")}\n match_set = match_set.select{ |item| fragments.index(item.first&.last) != nil}\n index1 = match_set.first&.last\n index2 = fragments.index(match_set&.first&.first&.last) || nil\n return nil if index2.nil?\n\n if fragments[index1] + fragments[index2] == target\n if index1 < index2\n return [fragments[index1], fragments[index2], [index1, index2]]\n else\n return [fragments[index2], fragments[index1], [index1, index2]]\n end\n else\n if index1 < index2\n return [fragments[index1], fragments[index2], [index2, index1]]\n else\n return [fragments[index2], fragments[index1], [index2, index1]]\n end\n end\nend", "def start_word_pattern; end", "def solve(words)\n return 0 if words.length == 0\n\n longest_sublist = 1\n current_sublist = 1\n\n i = 0\n while i < words.length - 1\n if words[i][0] == words[i+1][0]\n current_sublist += 1\n if current_sublist > longest_sublist\n longest_sublist = current_sublist\n end\n else\n current_sublist = 1\n end\n i += 1\n end\n\n return longest_sublist\nend", "def my_array_finding_method(source, thing_to_find)\n match_words = []\n source.each do |word| \n for i in 0...word.to_s.length\n if thing_to_find === word[i]\n match_words.push(word)\n break\n end\n end\n end\n return match_words\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 solution(a)\n candidate = a[0]\n count = 0\n index = 0\n a.each_with_index do |d, idx|\n count = candidate == d ? count += 1 : count -= 1\n if count == 0\n candidate = d\n count = 1\n index = idx\n end\n end\n a.count { |d| d == candidate } * 2 > a.length ? index : -1\nend", "def check_for_correct_indexes(user_guess, solution)\n zipped = @solution.zip(user_guess)\n @correct_indexes = zipped.count do |char, idx|\n char == idx\n end\n end", "def match_input(letter)\n return $word.index(letter[0])\nend", "def word_pattern(pattern, input)\n \nend", "def highlight_search_res(sentence, word)\n count = sentence.split.count{ |matched| matched.downcase.include?('can') }\n capital_word = word.dup.capitialize()\n s = \"\"\n s += sentence.gsub(\"#{word}\", \"(#{word})\").gsub(\"#{capital_word}\", \"(#{capital_word})\")\n s += \"\\n\"\n s += \"Total occurence found : #{count}\"\nend", "def search(word)\n w = word.chars\n w.push('end')\n search_arr(w)\n end", "def article_match? (query, article_title)\n found = false\n return true if query.empty?\n temp_article = article_title.downcase\n query.each do |kw|\n pattern = Regexp.new /.*#{kw.downcase}.*/\n found = true if temp_article =~ pattern\n end\n found\nend", "def matching(mweid, mwe, leftconst, s_id, sentence, lemma, sentpos, consthash, outdata)\n\tm_frg, leftconst, totallen = 0, leftconst[0].scan(/.{1,2}/), 0\n\n\tlemma.each_with_index do |lempart, idx| \t# sentence loop\n\t\tif mwe[0] == lempart \t# 文の形態素とMWEの形態素が一部マッチ\n\t\t\tm_frg, start_idx = 1, idx\n\t\t\tstartlen, endlen = totallen+1, totallen\n\t\t\tfor cnt in 0..mwe.length-1 do\n\t\t\t\tif lemma[idx+cnt] != mwe[cnt]\n\t\t\t\t\tm_frg = 0\n\t\t\t\t\tbreak\n\t\t\t\telse\n\t\t\t\t\tendlen += lemma[idx+cnt].length\n\t\t\t\tend\n\t\t\tend\n\n\t\t\t# 品詞等の制約を確認\t\t\t\n\t\t\tconstlist = consthash[leftconst[0]]\t\t# leftconst[1]は全て\"90\"\n\t\t\tif m_frg == 1\n\t\t\t\tm_frg = constCheck(constlist, sentpos[start_idx-2], start_idx, m_frg)\n\t\t\t\tm_frg = constCheck(constlist, sentpos[start_idx-1], start_idx, m_frg) unless m_frg != 0\n\t\t\tend\n\t\t\t# MWEが完全にマッチしたとき\n\t\t\tif m_frg == 1\n\t\t\t\tprecont, matched, postcont, startlen, endlen = splitCont(mwe, start_idx, sentence)\t\t# 出現形の文に対してのstartlen等を取得\n\t\t\t\toutdata.push([mweid, s_id, startlen.to_s, endlen.to_s, precont, matched, postcont])\t# startlen, endlen: 標準形の文に対してのもの\n\t\t\t\t# outdata.push([mweid, s_id, startlen.to_s, endlen.to_s, precont, matched, postcont, meaning])\t# startlen, endlen: 標準形の文に対してのもの\n\t\t\t\tm_frg = 0\n\t\t\tend\n\t\tend\n\t\ttotallen += lempart.length\n\tend\n\n\treturn outdata\nend", "def indexes_of(substring)\n cipher_text.\n gsub(/\\s/, ''). # remove all whitespace\n enum_for(:scan, substring).map { Regexp.last_match.begin(0) }\n end", "def substrings(string, array)\n string_a = string.downcase.split(' ')\n results = Hash.new(0)\n\n array.each do |element|\n string_a.each do |word|\n if word.include? element\n results[element] += 1\n else\n next\n end\n end\n end\n\n puts results\nend", "def run\n searching if @nr_of_words >= @phrase_length\n end" ]
[ "0.641207", "0.6186786", "0.6085298", "0.5994506", "0.5994298", "0.5979353", "0.59656686", "0.5902823", "0.5877119", "0.5868725", "0.5821212", "0.5814449", "0.5771998", "0.5771998", "0.57702315", "0.5757451", "0.575182", "0.5749668", "0.5718444", "0.57113755", "0.5709403", "0.56682265", "0.5656322", "0.56363916", "0.56234306", "0.55781627", "0.5573483", "0.55722326", "0.55715543", "0.55637324", "0.55543023", "0.55543023", "0.55476916", "0.5541692", "0.55329233", "0.54860306", "0.54833764", "0.5479075", "0.5475463", "0.54691976", "0.5466778", "0.54613745", "0.5459735", "0.5451262", "0.54432625", "0.54372174", "0.5430522", "0.54262835", "0.5413733", "0.5406158", "0.54003817", "0.53949183", "0.5385966", "0.5384691", "0.53786016", "0.5377352", "0.5377231", "0.53673273", "0.5340691", "0.5340057", "0.5337087", "0.53349113", "0.5334109", "0.53340423", "0.53311396", "0.5327473", "0.53241885", "0.53127277", "0.5309836", "0.5308078", "0.5307226", "0.530629", "0.5301344", "0.52989215", "0.5297163", "0.5286216", "0.5276815", "0.5271051", "0.5266434", "0.52556527", "0.5250996", "0.5234763", "0.52322614", "0.5228671", "0.5223673", "0.5220681", "0.52145004", "0.5211638", "0.52112406", "0.5207533", "0.5198004", "0.5192317", "0.5192228", "0.51837945", "0.51820153", "0.51755387", "0.51710105", "0.51703644", "0.5169024", "0.51689535", "0.5166234" ]
0.0
-1
get all user's responses
def userReponses user=User.find(params[:userId]) render :json=> user.response end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @user_responses = UserResponse.all\n end", "def responses\n @responses\n end", "def all_users\n all_users = User.all\n @api_response[:code] = @response_codes[:success]\n @api_response[:result] = all_users\n rescue Exception => e\n @errors, @api_response = api_exception_handler(e)\n ensure\n #send the response back to the user\n send_response(@api_response, @errors)\n end", "def users\n self.class.get(\"/user\", @options).parsed_response[\"items\"]\n end", "def responses\n participants.flat_map(&:responses)\n end", "def index\n \t @responses = Response.all\n end", "def index\n @responses = Response.all\n end", "def index\n @responses = Response.all\n end", "def index\n @responses = Response.all\n end", "def index\n @responses = Response.all\n end", "def index\n @responses = Response.all\n end", "def get_responses(entries)\n responses = entries.map do |entry|\n entry.responses\n end\n responses.flatten.compact\n end", "def users\n\t\trespond_with User.all\n\tend", "def all\n results_from(response)\n end", "def index\n \n # if the current user is a teacher or admin, display all responses submitted\n # otherwise current user is a student, and may only view his/her own responses\n @responses = current_user.top_role.id < 3 ? Response.all : Response.user_responses(current_user.id)\n\n @question_groups = QuestionGroup.all\n\n respond_with(@responses)\n end", "def show\n @responses_user = Response.all.where(user_id: params[:id])\n @user = User.find(params[:id])\n end", "def responders\n return [] if self.responder_ids.blank?\n User.find(self.responder_ids.flatten - [self.user_id]) # don't include author\n end", "def get_questionnaire_responses\n @get_questionnaire_responses ||=\n questionnaire_response_service.search(\n source: user.icn,\n authored: [date_ge_one_month_ago, date_le_two_weeks_from_now],\n _count: '100'\n )\n end", "def get_users(request); end", "def all\n result = Client.request(:get, 'users')\n\n if result.is_a?(Result::Success)\n result.body[:users].map { |data| User.new(data) }\n else\n []\n end\n end", "def check_all(response)\n user = nil\n # Check for a successful request\n if response.code == '200'\n # Parse the response body, which is in JSON format.\n # ADD CODE TO PARSE THE RESPONSE BODY HERE\n user = JSON.parse(response.body)\n # Pretty-print the user object to see what data is available.\n puts JSON.pretty_generate(user)\n else\n # There was an error issuing the request.\n puts \"Expected a response of 200 but got #{response.code} instead\"\n end\n\n user\nend", "def all_users()\n @endpoint = \"/users.json?limit=100\"\n setup_get\n res = @http.request(@req)\n return JSON.load(res.body)[\"users\"].sort_by { |user| user[\"lastname\"] }\n end", "def index\n respond_with ApidUser.all\n end", "def index\r\n respond_with User.all\r\n end", "def users\n get('get_users')\n end", "def index\n @lesson_responses = LessonResponse.all.where(user_id: current_user.id)\n end", "def index\n respond_with User.all\n end", "def recieved_requests_users\n recieved_requests.map(&:user)\n end", "def index\n @responses = Response.all\n puts \"\\n\\n\\n\\nyo dude I think its working \\n\\n\\n\\n\"\n end", "def list\n get('users')['users']\n end", "def fremont_users\n\ttmp = Array.new\n\tres = Array.new\n\ti = 0\n\twhile (tmp = TOKEN.get('/v2/campus/7/users', params: { page: i, per_page: 100 }).parsed).length > 0\n\t\tputs 'user request page is ' + i.to_s\n\t\ttmp.each do |page|\n\t\t\tres.push(page)\n\t\tend\n\t\ti += 1\n\tend\n\treturn res\nend", "def responses\n @responses ||= api::BatchResponse.new(responses: responses_by_request.values.uniq)\n end", "def users\n result_hash['usr']\n end", "def user_list\n\t\tget_call = Curl::Easy.http_get(\"#{@ip_address}:#{@port_2}/v2.0/users/\"\n\t\t) do |curl| curl.headers['x-auth-token'] = @token end\n\t\t\n\t\tputs \"Here is a list of users...\"\n\t\tparsed_json = JSON.parse(get_call.body_str)\n\t\t\n\t\tputs parsed_json\n\t\treturn parsed_json\n\tend", "def list_users\n self.class.get('/users')\n end", "def messages\n responses.map(&:messages).flatten\n end", "def results\n return error if error?\n return response if response?\n end", "def index\n if !@current_user.admin?\n redirect_to '/home'\n end\n\n @responses = Response.paginate(:page => params[:page], :per_page => 15)\n end", "def get_users\r\n # Prepare query url.\r\n _path_url = '/users'\r\n _query_builder = Configuration.get_base_uri\r\n _query_builder << _path_url\r\n _query_url = APIHelper.clean_url _query_builder\r\n # Prepare headers.\r\n _headers = {\r\n 'accept' => 'application/json'\r\n }\r\n # Prepare and execute HttpRequest.\r\n _request = @http_client.get(\r\n _query_url,\r\n headers: _headers\r\n )\r\n CustomHeaderAuth.apply(_request)\r\n _context = execute_request(_request)\r\n validate_response(_context)\r\n # Return appropriate response type.\r\n decoded = APIHelper.json_deserialize(_context.response.raw_body)\r\n decoded.map { |element| User.from_hash(element) }\r\n end", "def all\n response = RestClient.get(@all_url, params)\n parsed = JSON.parse(response)\n \n parsed['results']['result']\n end", "def all(options = {})\n raise MethodNotAllowed.new(self, :all) unless self.class.permissions && self.class.permissions[:read]\n response_body = http_get(parse_params(options))\n response = parse_response(response_body, options)\n response_items = response.response_items || []\n end", "def list_users()\n response = HTTParty.get(\"https://graph.microsoft.com/v1.0/users\", { \n headers: {\n \"Authorization\" => \"Bearer #{bearerToken}\",\n \"Host\" => 'graph.microsoft.com' \n }\n })\n return JSON.parse response.read_body\n end", "def get_all_users\n @users = []\n results = User.all\n results.each do |user|\n @users << user.to_hash\n end\n end", "def get_all\n @user_repository.get_all_users\n end", "def index\n json_response(User.all) \n end", "def index\n redirect_user\n @respondents = Respondent.all\n end", "def users\n searchUrl = \"#{url}?page=userResults\"\n response = getHtml(searchUrl)\n if response.status == 200\n userCollection = response.body.scan /UserMatchFrame\\\">([^<]*)/\n c = userCollection.collect {|u| u[0]}\n return c\n else\n logInfoMsg(\"WARNING: userDomainAux.users getHtml request did not succeed (status=#{response.status})\")\n end\n end", "def getAllUsers()\n puts \"\\nUSERS:\"\n puts \"-------------------------------------------------\"\n @users.each {|user| puts \"ID: \" + user.id.to_s + \" Name: \" + user.name}\n puts \"-------------------------------------------------\"\n end", "def results\n return error if error?\n response if response?\n end", "def userrequests\n @requests = Request.where(user_id: params[:user_id])\n render json: { total: @requests.size, requests: @requests.as_json(:methods => [:is_republishable] ) }, status: 200\n end", "def returning_users\n []\n end", "def all\n response = conn.get do |request|\n request.url \"/v1/admin/users.json\"\n end\n\n response.body[\"users\"].map {|attributes| Nuwe::User.new(attributes)}\n end", "def answers\n request('answers')\n end", "def all_users\n every_user =\n $all_posts.group_by { |row| row.name}\n .map { |row| row.first }\n render json: every_user\n end", "def get_all\n\t\tif !params.has_key?(\"count\") or params[:count].empty?\n\t\t\tparams[:count]= 50\n\t\tend\n\t\tif !params.has_key?(\"start\") or params[:start].empty? \n\t\t\tparams[:start] = 0 \n\t\tend\n\t\tusers = []\n\t\tUser.all.limit(params[:count]).offset(params[:start]).each do |u|\n\t\t\thash = u.attributes \n\t\t\thash[:client] = u.client ? u.client.name : nil\n\t\t\tusers.push(hash)\n\t\tend\n\t\trespond({ status: 0, users: users, start: params[:start] })\n\tend", "def get_all_user_data\n load_user_data(nil)\n end", "def index\n @responses = Response.all\n @response = Response.new\n end", "def list_all_users\n\n end", "def to_response\n []\n end", "def index\n\t\t@user = User.all\n\t\tCUSTOM_LOGGER.info(\"Start to return users #{@user.to_yaml}\")\n\tend", "def list\n @all_users = User.find(:all)\n end", "def list\n response = @client.get(\"/users\")\n response[\"users\"].map {|u| User.new(@client, u) }\n end", "def index\n authorize! :manage, :multiple_users\n\n respond_with(users)\n end", "def get_all_users\n @users = []\n User.all.each do |user|\n @users << user.to_hash\n end\n end", "def get_all_users\n @users = []\n\n User.all.each do|user|\n @users << user.to_hash\n end\n end", "def get_users\n\n headers = {:x_storageapi_token => @kbc_api_token, :accept => :json, :content_type => :json}\n\n response = RestClient.get \"#{@api_endpoint}/users?writerId=#{@writer_id}\", headers\n\n return response\n\n end", "def friend_requests\n get(\"users/requests\").requests\n end", "def index\n @users = User.all\n\n respond_with @users\n end", "def index\n @q = apply_scopes(User).all.search(params[:q])\n @users = @q.result(distinct: true).page(params[:page])\n\n respond_with(@users)\n end", "def users\n\t\t@recipes = Recipe.where('published = ?',1).find_by_user_id(params[:id])\n\t\trespond_with @recipes\t\n\tend", "def users\n # TODO use SQL\n results = self.approvers + self.observers + [self.requester]\n results.compact\n end", "def all\n api_get(path)\n end", "def list_users_for_all_tenants(args = {}) \n get(\"/users.json/global\", args)\nend", "def list_users_for_all_tenants(args = {}) \n get(\"/users.json/global\", args)\nend", "def all_users(**args)\n params = parameters(args) do\n optional_params\n end\n request(:get, 'users', params)\n end", "def index\n\t\t@users = User.all\n\n\t\trespond_to do |format|\n\t\t\tformat.html\n\t\t\tformat.json { render json: @users.map(&:as_json) }\n\t\tend\n\tend", "def index\n users = User.all\n json_response(users)\n end", "def index\n @responders = Responder.all\n end", "def index\n respond_with current_user\n end", "def index\n @whos_home_responses = WhosHomeResponse.all\n end", "def index\n @users = User.all\n respond_with @users\n end", "def index\n @users = User.all\n respond_with @users\n end", "def get_answers_for\n user = current_user\n render_401 and return unless user\n prospect = User.find_by_id(params[:for_user_id])\n render_404 and return unless prospect\n\n answers = ShortQuestion.get_latest_n_answers_for(prospect.id, params[:num], params[:start])\n render :json => {\n :success => true,\n :answers => answers\n }\n end", "def users\n gateway_check\n @users\n end", "def requests\n @requests_obj.list\n end", "def index\n @user_requests = UserRequest.all\n end", "def list_user_names(iam)\r\n list_users_response = iam.list_users\r\n list_users_response.users.each do |user|\r\n puts user.user_name\r\n end\r\nend", "def response_set\n if defined?(@response_set)\n return @response_set unless wipe_response_set?\n end\n @wipe_response_set = false\n @response_set = LimeExt::ResponseLoaders.responses_for self\n return @response_set\n end", "def all\n @users = User.all\n end", "def index\n if params[:sent] == \"true\"\n @requests = current_user.sent_requests\n else\n @requests = current_user.recieve_requests\n end\n end", "def my_requests\n\t\tuser = current_user\n\n\t\t# get all requests accepted by user\n\t\t# in the future, edit this to filter out fulfilled (completed)\n\t\t@accepted_requests = user.accepteds\n\tend", "def view_all_users\n # !! get all user so can interact after viewing them? all_users\n # User.select(:username).each_with_index {|user, index| puts \"#{index+1}. #{user.username}\"}\n #??????\n User.select(:username).each {|user| puts user.username}\n end", "def index\n @users = current_user.requesters.where('requests.accepted = ?', false)\n end", "def responses\n question=Question.find(params[:questionId])\n render :json=> question.response\n end", "def get_all_info_from_user()\n\n db = connect_to_db(\"db/db.db\")\n\n db.execute(\"SELECT * FROM users\")\n end", "def answers\n extracted_answers = []\n\n unless self.qp_values.nil?\n self.qp_values.each do |answer| \n extracted_answers.push(ResponseAnswer.new(answer))\n end \n end\n\n return extracted_answers \n end", "def index\n @user_responsibilities = UserResponsibility.all\n end", "def results\n response['data']\n end", "def all\n @@responders\n end", "def list_users\n http_get(:uri=>\"/users\", :fields=>x_cookie)\n end" ]
[ "0.7613305", "0.70175827", "0.7017241", "0.6954248", "0.6937111", "0.6867089", "0.6733598", "0.6733598", "0.6733598", "0.6733598", "0.6733598", "0.66834754", "0.66497314", "0.66495097", "0.6509322", "0.6469114", "0.64436543", "0.6442597", "0.6400458", "0.63912696", "0.6374723", "0.6370072", "0.6350693", "0.6346903", "0.63390774", "0.6313642", "0.6295612", "0.62925196", "0.62813133", "0.62380284", "0.6205343", "0.6196559", "0.616863", "0.6165973", "0.61600727", "0.61469144", "0.61368275", "0.61085284", "0.6071713", "0.6060867", "0.6052866", "0.60429525", "0.6029244", "0.600783", "0.60029775", "0.60014313", "0.59997064", "0.5982359", "0.5980845", "0.5956688", "0.5955706", "0.5949064", "0.59433186", "0.5938262", "0.59225386", "0.5891486", "0.588859", "0.587998", "0.5868843", "0.5868472", "0.5860295", "0.58572567", "0.5847896", "0.5837627", "0.58365804", "0.5833138", "0.583302", "0.58324796", "0.5828329", "0.5825769", "0.58237576", "0.58225876", "0.58208054", "0.58208054", "0.5819549", "0.5817884", "0.5814728", "0.58071095", "0.5802949", "0.57994974", "0.5793132", "0.5792906", "0.5771569", "0.5755409", "0.5753204", "0.5748958", "0.57426554", "0.5734561", "0.57286906", "0.57281035", "0.5726106", "0.57145435", "0.5710895", "0.57090575", "0.5701967", "0.56993973", "0.56978536", "0.5697586", "0.5693183", "0.5690273" ]
0.59532887
51
get all responses that belongs to a qeustion
def responses question=Question.find(params[:questionId]) render :json=> question.response end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def responses\n object.questions.map do |q|\n Embedded::ResponseSerializer.new(q.filtered_responses.first,root: false)\n end\n end", "def answers\n extracted_answers = []\n\n unless self.qp_values.nil?\n self.qp_values.each do |answer| \n extracted_answers.push(ResponseAnswer.new(answer))\n end \n end\n\n return extracted_answers \n end", "def getResponses(surveyId)\n return survey_responses.where({:survey_id => surveyId})\n end", "def responses\n @responses\n end", "def set_responses\n\t\t@responses = Response.where(question_id: params[:id] ) rescue nil\n\tend", "def get_questionnaire_responses\n @get_questionnaire_responses ||=\n questionnaire_response_service.search(\n source: user.icn,\n authored: [date_ge_one_month_ago, date_le_two_weeks_from_now],\n _count: '100'\n )\n end", "def replies\n Reply.find_by_question_id(self.id)\n end", "def sibling_responses\n question.responses.where.not(id: self.id)\n end", "def responses\n @responses ||= api::BatchResponse.new(responses: responses_by_request.values.uniq)\n end", "def mailq\n mailq = []\n\n req(\"mailq\") do |resp|\n mailq.concat [resp[:body]].flatten\n end\n\n mailq\n end", "def responses_for(data_export_identifier)\n Response.includes([:answer, :question, :response_set]).where(\n \"response_sets.user_id = ? AND questions.data_export_identifier = ?\", self.id, data_export_identifier).\n order(\"responses.created_at\")\n end", "def responses\n participants.flat_map(&:responses)\n end", "def sibling_responses\n self.question.responses.where.not(id: self.id)\n end", "def sibling_responses\n self.question.responses.where.not(id: self.id)\n end", "def all\n @q\n end", "def replies\n Reply.find_by_question_id(@id)\n end", "def get_responses(entries)\n responses = entries.map do |entry|\n entry.responses\n end\n responses.flatten.compact\n end", "def check_questions\n response = Request.get_request(URL_QUESTION)\n questions = []\n if response.success?\n data = Request.manage_response(response)\n end\n data.each do |question|\n questions << Question.new(question)\n end\n questions\nend", "def get_general_queue\n reply = @client.call(:get_general_queue)\n data = reply.body.dig(:get_general_queue_response,\n :get_general_queue_result,\n :array_of_string)\n data = check_if_data_exists(data)\n\n data.map do |attrs|\n {\n service_id: attrs[:string][0],\n service_name: attrs[:string][1],\n channel_id: attrs[:string][2],\n channel_name: attrs[:string][3],\n contact_type: attrs[:string][4],\n directive: attrs[:string][5],\n queue_length: attrs[:string][6],\n time_in_queue: attrs[:string][7]\n }\n end\n rescue Savon::HTTPError => error\n Rails.logger.debug error.http.code\n return []\n end", "def answer(question)\n response = []\n begin\n\ttexto = QUERY_TEMPLATE.sub(/%command%/, question)\n\tprint texto \n\tquery = QueryFactory.create(texto)\n\t# qexec = SparqlDLExecutionFactory.create(query, storage.inferred)\n\tqexec = QueryExecutionFactory.create(query, storage.inferred); #qexec = QueryExecutionFactory.create(query, storage.model);\n results = qexec.execSelect\n response = parse_results(results)\n ensure\n qexec.close if qexec\n end\n response\n end", "def sibling_responses\n # exclude yourself\n # load questions, then load responses\n question.responses.where.not(id: id)\n end", "def sip_responses\n hashed_sip[appt_id]\n end", "def sibling_responses\n ac = {answer_choice_id: self.answer_choice_id, id: self.id}\n Response.find_by_sql([<<-SQL, ac])\n SELECT\n\t\t\t\t\trespones.*\n\t\t\t\tFROM (\n\t\t\t\t\tSELECT\n\t\t\t\t\t\tquestions.*\n\t\t\t\t\tFROM\n\t\t\t\t\t\tquestions\n\t\t\t\t\t\t\tJOIN answer_choices ON answer_choices.question_id = questions.id\n\t\t\t\t\tWHERE\n\t\t\t\t\t\tanswer_choices.id = :answer_choice_id\n\t\t\t\t\t) AS quest\n\t\t\t\t\tJOIN\n\t\t\t\t\t\tanswer_choices ON answer_choices.question_id = questions.id\n\t\t\t\t\tJOIN\n\t\t\t\t\t\tresponses ON responses.answer_choice_id = answer_choices.id\n\t\t\t\t\tWHERE\n\t\t\t\t\t\t(responses.id != :id)\n\t\t\t\tSQL\n end", "def get_questions\n items = get_items\n make_response(HttpStatus::OK, make_result_list(items))\nend", "def getResponse(surveyId, questionId)\n return survey_responses.where({:survey_id => surveyId, :survey_question_id => questionId}).first\n end", "def qr_responses\n hashed_qr[appt_id]\n end", "def index\n @qors = Qor.all\n end", "def find_all(name)\n if name and not name.empty?\n proxy_owner.send(:list_queues, \"QueueNamePrefix\" => name)\n else\n proxy_target\n end\n end", "def index\n @qrs = Qr.all\n end", "def queries\n qrs = []\n self.each_query {|qr| qrs << qr }\n qrs\n end", "def index\n \t @responses = Response.all\n end", "def sibling_responses\n if !Response.exists?(self) #checks if instance is stored in database\n question.responses #even if instance class = Reponse, returns false if not in database\n else\n self.question.responses\n .where(\"responses.user_id != ?\", respondent.id)\n end\n\n end", "def quotations\n response = self.class.get('/quotations', OPTIONS)\n\n if response.success?\n parse_quotations(response)\n else\n []\n end\n end", "def search(q)\n url = build_query_url q\n begin\n raw_response = json(url)\n rescue JSON::ParserError\n Rails.logger.info \"Could not parse response as JSON. Request url: #{url}\"\n return []\n end\n parse_authority_response(raw_response)\n end", "def responses_request(input_params = {})\n params = input_params.dup\n requests = [ResponsesRequest.new(params, client.get('form/' + id, params))]\n\n loop do\n break if requests.last.last_request?\n next_params = requests.last.params.dup\n next_params['offset'] += requests.last.responses_count\n requests << ResponsesRequest.new(next_params, client.get('form/' + id, next_params))\n end\n\n requests.map(&:response).map(&:parsed_json).reduce do |combined, next_set|\n next_set.dup.tap { |response|\n response['responses'] = combined['responses'] + next_set['responses']\n }\n end\n end", "def requests\n @requests ||= EbanqApi::Requests.new(self)\n end", "def qing_ids\n questionings.collect{|qing| qing.id}\n end", "def response_domains\n grid_rds_qs.map { |x| x.response_domain }\n end", "def questions\n results = CONNECTION.execute(\"SELECT * FROM questions WHERE student_id = #{@id};\")\n \n results_as_objects = []\n \n results.each do |result_hash|\n results_as_objects << Question.new(result_hash[\"id\"], result_hash[\"student_id\"], result_hash[\"content\"])\n end\n \n return results_as_objects\n end", "def answers\n return Answer.where(question_id: self.id) \n end", "def index\n @responses = Response.all\n end", "def index\n @responses = Response.all\n end", "def index\n @responses = Response.all\n end", "def index\n @responses = Response.all\n end", "def index\n @responses = Response.all\n end", "def my_requests()\n request_array = []\n self.problems.each do |problem|\n Request.where({ problem_id: problem.id}).each do |request|\n request_array.push(request)\n end\n end\n request_array\n end", "def questions\n # Get a list of questionnaires that belong to instances of the current race\n if @course\n questionnaire_ids = @course.questionnaire_ids\n elsif @instance\n questionnaire_ids = @instance.questionnaire_ids\n else\n questionnaire_ids = []\n end\n\n # Collect question_ids that are used in those questionnaires\n question_ids = Set.new\n Questionnaire.where(:id => questionnaire_ids).find_each do |questionnaire|\n question_ids.merge(questionnaire.question_ids)\n end\n\n @questions = Question.find(question_ids.to_a)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @questions.to_json }\n end\n end", "def all\n results_from(response)\n end", "def get_question_section(dns_query, parsed_dns)\n question = {}\n question_section = []\n qdcount = parsed_dns[:dns_header_field][:qdcount]\n return if qdcount == 0\n for cnt in 0..qdcount-1\n question = {\n :qname => get_name(dns_query, parsed_dns),\n :qtype => get_type(dns_query, parsed_dns),\n :qclass => get_class(dns_query, parsed_dns)}\n question_section << question\n end\n question_section\n end", "def requests\n @requests_obj.list\n end", "def all_answers_for(question)\n answers.select {|a| a.question == question}\n end", "def get_questionnaires\n @get_questionnaires ||= questionnaire_service.search('context-type-value': get_use_context)\n end", "def questions_with_qr(key)\n hashed_questionnaires[key].map do |quest|\n { id: quest.resource.id, title: quest.resource.title, questionnaire_response: {} }\n end\n end", "def dns_responses\n decoded_responses = udp_packets_with_src_port(DNS_PORT).map { |p| Resolv::DNS::Message.decode(p.payload) }\n\n decoded_responses.each_with_object({}) do |response, memo|\n name = response.question.first.first.to_s\n memo[name] ||= []\n response.answer.each do |ans|\n case ans.last\n when Resolv::DNS::Resource::IN::CNAME\n memo[name] << ans.last.name\n when Resolv::DNS::Resource::IN::AAAA, Resolv::DNS::Resource::IN::A\n memo[name] << ans.last.address\n else\n puts ans.last\n end\n end\n end\n end", "def result_set\n klass.requestor.get(nil, { query: to_s })\n end", "def index\n @survey_question_responses = SurveyQuestionResponse.all\n end", "def getCompletedQuests\n completed = []\n $PokemonGlobal.quests.completed_quests.each do |s|\n completed.push(s.id)\n end\n return completed\nend", "def response_for(request)\n @responses_by_request[request]\n end", "def index\n @responses = @survey.responses\n @questions = Question.all\n end", "def questions\n self.class.get(\"/2.2/questions\", @options)\n end", "def uniq\n return :responses\n end", "def results_from(response)\n response.data.collect do |obj|\n case resource\n when RedboothRuby::Client\n next unless resource_form_hash(obj.merge(session: session))\n resource_form_hash(obj.merge(session: session))\n else\n resource.new(obj.merge(session: session))\n end\n end.compact\n end", "def sibling_responses\n if self.id\n self.question.responses.where(\"responses.id != ?\", self.id)\n else\n self.question.responses\n end\n end", "def response_set\n if defined?(@response_set)\n return @response_set unless wipe_response_set?\n end\n @wipe_response_set = false\n @response_set = LimeExt::ResponseLoaders.responses_for self\n return @response_set\n end", "def index\n @qbs = Qb.all\n end", "def everything\n raw = JSON.parse(`curl -sX GET 'https://api.nirvanahq.com/?api=rest&appid=gem&authtoken=#{@token}&method=everything&since=0'`)\n raw['results']\n end", "def get_answers_for_question(question_id)\n answers = Array.new\n question = Question.find_by_id(question_id, :include => :answers)\n question.answers.each do |ans|\n answers << ans\n end\n return answers\n end", "def response_to(kase)\n self.responses.find(:first, :conditions => [\"responses.kase_id = ?\", kase.id])\n end", "def find_response(answer_id)\n self.responses.find_by_answer_id(answer_id)\n end", "def get_questions(number)\n @questions_array = get_from_url(@questions_conn, QUESTIONS_OBTAINTION_KEY, {size: number})\n end", "def questions\n extracted_questions = []\n\n unless self.qp_questions.nil?\n self.qp_questions.each do |question| \n extracted_questions.push(Question.new(question))\n end \n end\n\n return extracted_questions\t\t\t\n\t\tend", "def sibling_responses\n if persisted?\n return self.question.responses\n elsif self.question.responses.includes(self)\n return self.question.responses.where(\"responses.id <> ?\", self.id)\n end\n end", "def getActiveQuests\n active = []\n $PokemonGlobal.quests.active_quests.each do |s|\n active.push(s.id)\n end\n return active\nend", "def count_question_responses(question)\n Response.count(:conditions => [\"response_set_id =? AND question_id=?\", self.id, question.id])\n end", "def sibling_responses\n # self.question.responses.where(\"responses.id != ?\", self.id)\n self.question.responses.where.not(id: self.id)\n end", "def get_quest\n\t\tget_data\n\n\t\t$finish = false\n\t\tunless $finish == true\n\t\t\t$randId = rand(0...(@data.length-1))\n\t\t\twhile $quiz_arr.include?(@data[$randId]['id'])\n\t\t\t\t$randId = rand(0...(@data.length-1))\n\t\t\tend\n\t\t\t$quiz_arr.push(@data[$randId]['id'])\n\t\t\t$i += 1\n\n\t\t\tif $i == 7\n\t\t\t\t$finish = true\n\t\t\tend\n\n\t\t\t@quest = @data[$randId]['question_name']\n\t\t\t@c_answer = @data[$randId]['c_answer']\n\t\t\t@alt1 = @data[$randId]['alt1']\n\t\t\t@alt2 = @data[$randId]['alt2']\n\t\t\t@alt3 = @data[$randId]['alt3']\n\t\t\t@imgurl = @data[$randId]['imgurl']\n\t\t\t@url = @data[$randId]['news_url']\n\t\t\t@cat = @data[$randId]['category_id']\n\t\t\t@hex = @data[$randId]['category_hex_code']\n\t\t\tget_descriptions(@url)\n\t\t\t@image = @desc_data['image']\n\n\t\t\t$answer_array = Array.new()\n\t \tend\n\tend", "def get_valid_responses(form_name, question_id)\n resp = get_form(form_name)[:questions][question_id][:valid_responses]\n if resp.is_a? Symbol and !FormValidation::RESPONSE_TYPES.include?(resp)\n resp = self.send(resp)\n end\n return resp\n end", "def check_in_all_respond(type, atr, value)\n all_results.map { |result| check_in_result(result, type, atr, value) }.uniq\nend", "def messages\n responses.map(&:messages).flatten\n end", "def resource_specific(responses, resource)\n logger.verbose(\"Looking through #{responses.size} matching cache \" \\\n \"entries for resource #{resource}.\")\n responses.select { |response| response.resource == resource }\n .map(&:token_response).first\n end", "def answers_for_question(question)\n @answers_for_question ||= {}\n @answers_for_question[question] ||= Answer.first_level_only\n .joins(:form_item)\n .where(response_id: responses.map(&:id))\n .where(\"form_items.question_id\" => question.id)\n .index_by(&:response_id)\n end", "def find_completed\n completed = self.user_quests.where(complete: true)\n completed.map do |x|\n x.quest_id\n end\n end", "def queries(queries)\n result = @client.api_helper.get_response(Config::TODOIST_QUERY_COMMAND, \n queries: queries.to_json)\n return ParseHelper.make_objects_as_hash(result, \"query\")\n end", "def get_all\n\t\trender json: {quests: Quest.all.as_json(include: :images)}\n\tend", "def get_requests\n @requests\n end", "def queries\n @requested_queries.map { |key| Gquery.get(key) }.compact\n end", "def results\n return error if error?\n return response if response?\n end", "def message_responses(text_id)\n command = Command.new('GetSMSResponse', license_key)\n responses = Response.parse( \n command.execute({:TextID => text_id}) \n )[\"ArrayOfSmsResponse\"][\"SmsResponse\"] || []\n\n\t\t\tresponses.is_a?(Array) ? responses.collect { |r| MessageResponse.new(r) } : MessageResponse.new(responses)\n end", "def query(soql)\n response = api_get 'query', :q => soql\n mashify? ? response.body : response.body['records']\n end", "def index\n @t_qconnections = TQconnection.all\n end", "def query_json\n joined_response_ids = response_ids.join(',')\n query = \"SELECT t1.id, REPLACE(t1.value::text, '\\\"', '') AS choice, COUNT(t1.value) AS total FROM (SELECT key AS id, value->0 AS value FROM thinkspace_readiness_assurance_responses t, jsonb_each((t.answers)::jsonb) WHERE t.id IN (#{joined_response_ids})) t1 GROUP BY t1.id, t1.value;\"\n @assessment.class.connection.select_all(query)\n end", "def index\n @qs = Q.all\n end", "def build_response(options={})\n\t\t\n\t\tresponses = []\n\n\t\tone_response = ''\n\n\t\tputs \"sample ids are:\"\n\t\tputs self.sample_ids\n\n\t\treturn responses unless sample_ids\n\n\t\tself.sample_ids.each_with_index {|sid,key|\n\t\t\tputs \"doing sample id: #{sid}\"\n\t\t\t## tests are got from the requisitions hash.\n\t\t\ttests = get_tests(sid)\n\t\t\tputs \"tests are: #{tests}\"\n\t\t\t## default sequence number is 0 (THIS MAY LEAD TO PROBLEMS.)\n\t\t\tsequence_number = \"#{key.to_s}\"\n\n\t\t\t## default patient id:\n\t\t\tpatient_id = \"abcde#{Time.now.to_i.to_s}\"\n\t\t\t\n\t\t\tpatient = Patient.new({:sequence_number => sequence_number, :patient_id => patient_id})\n\t\t\t\n\t\t\torder = Order.new({:sequence_number => patient.sequence_number, :specimen_id => sid, :tests => tests, :priority => \"R\"})\n\n\t\t\tresponses << (patient.build_response(options) + order.build_response(options.merge({sequence_number: self.sequence_number, carrier_number: self.carrier_number, position_number: self.position_number, sample_type: self.sample_type, container_type: self.container_type})))\n\n\t\t}\n\n\t\tputs \"responses are:\"\n\t\tputs responses.to_s\n\n\t\treturn responses\n\t\t\n\tend", "def solr_resp_ids_from_query(query)\n solr_resp_doc_ids_only({'q'=> query})\nend", "def index\n @qas = Qa.all\n end", "def index\n \n # if the current user is a teacher or admin, display all responses submitted\n # otherwise current user is a student, and may only view his/her own responses\n @responses = current_user.top_role.id < 3 ? Response.all : Response.user_responses(current_user.id)\n\n @question_groups = QuestionGroup.all\n\n respond_with(@responses)\n end", "def results\n responses\n .includes(answer_choices)\n .group(:answer)\n .count\n end", "def collect_pick_any_responses(data_export_identifier)\n result = Array.new\n sorted_responses.each do |r|\n dei = r.question.data_export_identifier\n result << r if known_keys.include?(dei) && dei == data_export_identifier\n end\n result\n end", "def requests\n REQUESTS\n end", "def req(command, recipient=\"\", sender=\"\", msgid=\"\", queuematch=\"\")\n req = {:command => command,\n :recipient => recipient,\n :sender => sender,\n :msgid => msgid,\n :queuematch => queuematch}\n\n result = []\n @client.req(req, \"exim\", @options, discover.size) do |resp|\n if block_given?\n yield(resp)\n else\n result << resp\n end\n end\n\n return [result].flatten unless block_given?\n end" ]
[ "0.6753169", "0.63133025", "0.6192644", "0.61607665", "0.6005587", "0.5984561", "0.59360796", "0.5927058", "0.5915947", "0.58813715", "0.5841246", "0.58410424", "0.5832909", "0.5832909", "0.5826983", "0.5824624", "0.5822528", "0.58136135", "0.5797115", "0.5780034", "0.5742842", "0.57391095", "0.57363135", "0.5732329", "0.57280517", "0.5711328", "0.5683539", "0.5651319", "0.56461346", "0.5632348", "0.56243247", "0.56058824", "0.5591994", "0.55866987", "0.55840886", "0.55752754", "0.55606014", "0.5551551", "0.5547531", "0.5523169", "0.55182314", "0.55182314", "0.55182314", "0.55182314", "0.55182314", "0.55133", "0.5508157", "0.55028474", "0.55016005", "0.5487142", "0.54817396", "0.54785293", "0.5474384", "0.54739934", "0.54478216", "0.5420928", "0.54070026", "0.54059404", "0.5385985", "0.5385366", "0.5376155", "0.53750885", "0.53664595", "0.5362552", "0.535714", "0.5357", "0.53517205", "0.53498685", "0.5324922", "0.5324135", "0.53106654", "0.52874655", "0.5277338", "0.5271413", "0.52657866", "0.5263071", "0.52475935", "0.5241872", "0.5239379", "0.5237657", "0.5233974", "0.5223707", "0.5222993", "0.5221097", "0.52175516", "0.5210834", "0.5206427", "0.52007693", "0.51997507", "0.5199069", "0.51987565", "0.519038", "0.5185162", "0.518211", "0.5177548", "0.5147963", "0.5147579", "0.51380336", "0.5136684", "0.5134982" ]
0.5933696
7
Creates a new BlockArgs object
def initialize @block_args = [] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initialize args\n hash_make args, BlockState::ARG_SPECS\n end", "def initialize args = {}\n hash_make args, Block::ARG_SPECS\n @initial_params = collect_params\n end", "def new_block_el(*args); end", "def new_block_el(*args)\n el = Element.new(*args)\n if @block_ial\n el.options[:ial] = @block_ial\n @block_ial = nil\n end\n el\n end", "def initialize(*args)\n if self.class == BlockCommand\n raise TypeError, 'BlockCommand.new should not be called directly'\n end\n super\n end", "def create_block(arg_type , frame_type)\n @callable.create_block(arg_type ,frame_type)\n end", "def initialize(args={}, &block)\n @args = args\n @targets = []\n if block\n self.instance_eval(&block)\n end\n end", "def initialize(attributes)\n @block_size = attributes[:block_size]\n @blocks = attributes[:block_count]\n @block_data = attributes[:blocks].map(&:dup)\n end", "def initialize(argument_types, block)\n @argument_types = argument_types\n @number_of_arguments = argument_types.size\n @block = block\n end", "def new\n\t\t@block = Block.new\n\tend", "def build_block(transactions, prev_hash = hash)\n Block.new(transactions, prev_hash)\n end", "def build_block_container(*args, &block)\n options = args.extract_options!\n\n anonymous = false\n if args.first\n name = args.shift\n else\n name = self.anonymous_block_name\n anonymous = true\n end\n\n block_container = Blocks::Container.new\n block_container.name = name.to_sym\n block_container.options = options\n block_container.block = block\n block_container.anonymous = anonymous\n block_container\n end", "def new(*args, **kwargs, &block)\n args = lookup_hash_args(*args, kwargs)\n\n return super(*args, **kwargs) if @finalized\n names = args.pop.delete(:names) if args.last.is_a?(Hash)\n\n raise ArgumentError unless args.all? { |type| type < Refined }\n tuple = Class.new(self) { def inspect; super; end }\n tuple.instance_variable_set(:@attributes, args)\n tuple.instance_variable_set(:@names, names.to_a)\n tuple.instance_variable_set(:@finalized, true)\n tuple.class_eval(&block) if block_given?\n tuple\n end", "def initialize(block_arg = nil, &block)\n @block = block || block_arg\n @run = false\n @ivars = {}\n if !@block\n raise ArgumentError, \"needs a block.\"\n end\n end", "def make_block args\n raise ArgumentError, \"args does not have :sample_rate key\" unless args.has_key?(:sample_rate)\n \n klass = find_class(@class_sym)\n block = klass.new :sample_rate => args[:sample_rate]\n block.restore_state self\n \n return block\n end", "def create(*args, &block)\n complete_args = @partial_args + args\n @klass.new(*complete_args, &block)\n end", "def create_block_object(&block)\n block\nend", "def initialize block_parser\n @block_parser = block_parser\nend", "def create_block(g, mod)\n pos(g)\n\n state = g.state\n state.scope.nest_scope self\n\n args = make_arguments(mod)\n\n blk = new_generator g, @name, args\n\n blk.push_state self\n\n blk.state.push_super state.super\n blk.state.push_eval state.eval\n\n blk.definition_line(@line)\n\n blk.state.push_name blk.name\n\n pos(blk)\n\n blk.state.push_block\n blk.push_modifiers\n blk.break = nil\n blk.next = nil\n blk.redo = blk.new_label\n blk.redo.set!\n\n # order matters quite a lot here\n args.bytecode(blk)\n\n recv = receiver_pattern(mod)\n if recv.binds?\n blk.push_self\n recv.deconstruct(blk, mod)\n end\n\n args.deconstruct_patterns(blk, mod)\n\n mod.compile(blk, @body)\n\n blk.pop_modifiers\n blk.state.pop_block\n\n blk.ret\n blk.close\n blk.pop_state\n\n blk.splat_index = args.splat_index\n blk.local_count = local_count\n blk.local_names = local_names\n\n g.create_block blk\n end", "def initialize(&block)\n @block = block\n end", "def initialize(&block)\n @block = block\n end", "def initialize(bot, key, type, attributes, block = nil)\n @bot = bot\n @key = key\n @type = type\n @attributes = attributes\n @block = block\n end", "def initialize(&block)\n @block = block\n end", "def construct( &block )\n self.instance_eval(&block)\n @options\n end", "def initialize( name, *args, &block )\n\t\t\t@name\t\t = name\n\t\t\t@block\t\t = block\n\n\t\t\t@description = args.shift if args.first.is_a?( String )\n\n\t\t\t@required\t = args.include?( :required )\n\t\t\t@multiple\t = args.include?( :multiple )\n\t\tend", "def initialize(*attrs, &block)\n @array = []\n @shared = false\n attrs.each do |a|\n case a\n when Array, AttrArray\n a.each do |aa|\n self << aa\n end\n when Hash\n attrs[0].each do |k, v|\n self << Attr.new(k, v)\n end\n else\n self << a\n end\n end\n\n if block_given?\n @body = yield \n else\n @body = Null\n end\n end", "def initialize(attributes = {}, &block)\n @attributes = defaults.merge!(attributes)\n @align = @attributes[:align]\n @text = @attributes[:text]\n @width = @attributes[:width]\n @parent = @attributes[:parent]\n\n if block_given?\n @self_before_instance_eval = eval('self', block.binding)\n\n instance_eval(&block)\n end\n end", "def initialize(*args, **kwargs, &block)\n if kwargs.has_key? :type\n @type = kwargs[:type]\n kwargs.delete :type\n else\n @type = :*\n end\n \n @args = args\n @kwargs = kwargs\n @codeblock = block\n \n @kwargs.keys\n .reject{ |m| [:kwargs, :args, :codeblock].include? m }\n .each { |m| singleton_class.send(:define_method, m) { @kwargs[m] } }\n end", "def define_block_container(*args, &block)\n block_container = self.build_block_container(*args, &block)\n blocks[block_container.name] = block_container if blocks[block_container.name].nil? && block_given?\n block_container\n end", "def initialize(attributes = {}, &block)\n super\n self.value = attributes.delete(:value) \n self.bucket = attributes.delete(:bucket)\n yield self if block_given?\n end", "def parse_block(*_arg0); end", "def initialize(opts = {}, &block)\n @parent = opts[:parent]\n @optional_attributes = []\n instance_eval(&block)\n end", "def with(*args, &block)\n @args = args\n @block = block if block_given?\n self\n end", "def initialize(atts = nil, &block)\n super(status: :pending) # Initialize with status pending\n\n return self unless atts.present?\n\n if atts.kind_of?(Hash)\n items = Array(atts[:item]) + Array(atts[:items])\n\n self.user = atts[:user] || items.first.try(:user)\n\n if (address = atts[:billing_address]).present?\n self.billing_address = address\n self.billing_address.full_name ||= user.to_s.presence\n end\n\n if (address = atts[:shipping_address]).present?\n self.shipping_address = address\n self.shipping_address.full_name ||= user.to_s.presence\n end\n\n atts.except(:item, :items, :user, :billing_address, :shipping_address).each do |key, value|\n self.send(\"#{key}=\", value)\n end\n\n add(items) if items.present?\n else # Attributes are not a Hash\n self.user = atts.user if atts.respond_to?(:user)\n add(atts)\n end\n\n self\n end", "def add(&block)\n @block_args << block\n end", "def initializer(name, opts = T.unsafe(nil), &block); end", "def initializer(name, opts = T.unsafe(nil), &block); end", "def with(attrs = {}, &block)\n if block_given?\n Lipa::Bunch.new(self, attrs, &block)\n end\n end", "def block=(_arg0); end", "def block=(_arg0); end", "def initialize_argument_list\n args = ArgumentList.new\n args.x = args.y = args.width = args.height = 0\n args.text = ''\n args.options = {}\n\n args\nend", "def initialize(*args, &block)\n super\n @fields = []\n args_all.each do |arg|\n @fields << arg if arg.include?(':')\n end\n end", "def initialize(&block)\n @required_options = []\n instance_exec &block\n end", "def initialize(**args)\n self.args = args\n self.args.freeze\n\n parse_arguments\n validate_arguments!\n\n end", "def parfait_block(compiler)\n return @parfait_block if @parfait_block\n @parfait_block = compiler.create_block( make_arg_type , make_frame(compiler))\n end", "def cp_block_params\n params.require(:block).permit(:name, :text, :title, :description, :keywords)\n end", "def func_block (arg1, arg2, block_args = {})\n p arg1.inspect\n p arg2.inspect\n p block_args.inspect\nend", "def new(*args,&block)\n Base.new(*args,&block)\n end", "def Cobble(name, *args, &block)\n Cobble.create(name, *args, &block)\nend", "def define_args(label = nil, &block)\n pre_def_arg_scope = ArgumentScope.new(label || \"Predefined args\")\n pre_def_arg_scope.instance_eval(&block)\n pre_def_arg_scope\n end", "def initialize args = {}\n hash_make args, Network::ARG_SPECS\n \n # ensure that all sample rates match given rate\n @blocks.each do |block_name, block|\n if block.sample_rate != @sample_rate\n raise ArgumentError, \"block sample rate #{block.sample_rate} does not match network sample rate #{@sample_rate}\"\n end\n end\n \n @links.each do |link|\n link.activate\n end\n end", "def new(&block)\n Builder.new(&block).to_client\n end", "def clone\n Block.new(@x, @y, @appearance, @window, @type)\n end", "def build_args\n @scope.argument_descriptors = build_arg_descriptor\n add CheckArityInstr.new(2, 0, false, false, -1)\n _in = @scope.get_new_local_variable(\"_in\", 0)\n add ReceivePreReqdArgInstr.new(_in, 0)\n _out = @scope.get_new_local_variable(\"_out\", 0)\n add ReceivePreReqdArgInstr.new(_out, 1)\n end", "def mab(&block)\n Markaby::Builder.new({}, self, &block)\n end", "def initialize(owner_class, *args, &block); end", "def yield_arg_block(compiler)\n arg_index = compiler.get_method.arguments_type.get_length - 1\n setup = SlotMachine::MessageSetup.new( arg_index )\n slot_receive = @receiver.to_slotted(compiler)\n args = @arguments.collect { |arg| arg.to_slotted(compiler)}\n setup << SlotMachine::ArgumentTransfer.new( self , slot_receive , args )\n setup << SlotMachine::BlockYield.new( self , arg_index )\n end", "def _klass_new(*args, &block)\n inst = super()\n inst._set_self(_self)\n inst._struct_class = _struct_class\n if args.first.is_a?(::Hash)\n inst._load(args.first)\n end\n if block\n inst.build!(&block)\n end\n inst\n end", "def initialize\n super(Network.generate_id(\"block_\"))\n end", "def initialize name, opts={}, **kwargs\n { arguments: []}.merge(opts).merge(kwargs) => { arguments: }\n @name = name\n @arguments = arguments\n end", "def initialize(scope, user, params, &block)\n @scope = scope\n @params = params.dup\n @user = user\n\n instance_eval(block) if block_given?\n\n build\n end", "def initialize(attributes={})\n @args = Array(attributes[:args])\n @valid_options = attributes[:valid_options] || {}\n end", "def initialize(**kwargs)\n assert_required_attributes(kwargs)\n assert_no_extra_attributes(kwargs)\n @attributes = Valuables::DeepFreeze.deep_freeze(kwargs)\n @hash = self.class.hash ^ @attributes.hash\n freeze\n end", "def generate_block_context(context:, block_param_node:)\n binds = ArgumentsBinder.new(generator: generator).bind(types: method_types, arguments: block_param_node.parameter)\n\n Contexts::BlockContext.new(parent: context, registry: registry, receiver: context.receiver, binds: binds)\n end", "def initialize(args)\n @attributes = args\n end", "def set_block_params(item)\n if block_params.blank?\n commands.object = item\n elsif item.is_a?(Array) && item.size > 1\n # split item into block variables\n # the # of @block_params may be < the # of subitems, so put it first\n block_params.zip(item).each {|param, subitem| commands.set(param, subitem) }\n else\n # now this item is available thru the block variable\n commands.set(block_params.first, item)\n end\n end", "def new_block blk\n time = Time.now\n res = store_block(blk)\n log.info { \"block #{blk.hash} \" +\n \"[#{res[0]}, #{['main', 'side', 'orphan'][res[1]]}] \" +\n \"(#{\"%.4fs, %3dtx, %.3fkb\" % [(Time.now - time), blk.tx.size, blk.payload.bytesize.to_f/1000]})\" } if res && res[1]\n res\n end", "def block_params\n params.require(:block).permit(:name, :left, :top, :width, :height, :space_id, :block_type, :parent_id, :is_floor, :max_head_cap, :footage, :equipment, :fee, :photo, :start_at, :end_at, :image, :intro, :user_id, :registration_id, :color, :unit_id)\n end", "def initialize(*args)\n @args = args\n assign_attributes\n end", "def initialize(model, &block)\n @model = model\n @associations = {}\n @fields = []\n @attributes = []\n @conditions = []\n @groupings = []\n @options = {}\n @delta_object = nil\n \n initialize_from_builder(&block) if block_given?\n end", "def initialize(args)\n args = defaults.merge(args)\n @chainring = args[:chainring]\n# ...\n end", "def initialize(args)\n args = defaults.merge(args)\n @chainring = args[:chainring]\nend", "def initialize opts={}, &block\n @name = opts[:name]\n @activation = opts[:activation]\n @icon = opts[:icon]\n @sound = opts[:sound]\n @block = block\n invariant\n end", "def initialize(*args, &block)\n self.__init_core(block, *args)\n end", "def initialize(attributes)\n hash = attributes.dup\n @name = hash.delete(:name) or raise ArgumentError\n @lib = hash.delete(:lib) or raise ArgumentError\n # since MethodInspector scrapes arguments from file by default\n @file_parsed_args = true\n INIT_ATTRIBUTES.each do |e|\n instance_variable_set(\"@#{e}\", hash.delete(e)) if hash.key?(e)\n end\n\n after_initialize(hash)\n\n if (args = hash.delete(:args))\n if args.is_a?(Array)\n @args = args\n elsif args.to_s[/^\\d+/]\n @arg_size = args.to_i\n elsif args == '*'\n @args = [['*args']]\n end\n end\n @config = Util.recursive_hash_merge hash, hash.delete(:config) || {}\n end", "def initialize(attributes = nil)\n super\n yield self if block_given?\n end", "def start_new_block_element(attrs)\n @current_block = {\n formatting_spans: [],\n paragraph_classes: [],\n }.merge(attrs)\n @block_elements << @current_block\n end", "def init_fields(args={})\n args[:type] = @int32.new(args[:type] || PcapNG::EPB_TYPE.to_i)\n args[:block_len] = @int32.new(args[:block_len] || MIN_SIZE)\n args[:interface_id] = @int32.new(args[:interface_id] || 0)\n args[:tsh] = @int32.new(args[:tsh] || 0)\n args[:tsl] = @int32.new(args[:tsl] || 0)\n args[:cap_len] = @int32.new(args[:cap_len] || 0)\n args[:orig_len] = @int32.new(args[:orig_len] || 0)\n args[:data] = StructFu::String.new(args[:data] || '')\n args[:options] = StructFu::String.new(args[:options] || '')\n args[:block_len2] = @int32.new(args[:block_len2] || MIN_SIZE)\n args\n end", "def initialize_block\n unless latest_block\n block = Bitcoin.chain_params.genesis_block\n genesis = ChainEntry.new(block.header, 0)\n db.save_entry(genesis)\n end\n end", "def initialize(attributes = {}, &block)\n @attributes = defaults.merge!(attributes)\n\n if block_given?\n @self_before_instance_eval = eval('self', block.binding)\n\n instance_eval(&block)\n end\n end", "def block_params\n params.require(:block).permit(:height, :native_id, :account, :payload_size_bytes, :total_amount_nqt, :total_fee_nqt, :total_pos_nqt)\n end", "def with_predefined_args(scope, &blk)\n if block_given?\n pre_defs = args_def.predefined_args\n args_def.predefined_args = scope\n yield\n args_def.predefined_args = pre_defs\n else\n args_def.predefined_args = scope\n end\n end", "def new(namespace, name, *args, &block); end", "def initialize(*args); end", "def new(*args)\n obj = allocate()\n\n Rubinius.asm(args, obj) do |args, obj|\n run obj\n run args\n push_block\n send_with_splat :initialize, 0, true\n # no pop here, as .asm blocks imply a pop as they're not\n # allowed to leak a stack value\n end\n\n return obj\n end", "def builder &block\n if block_given?\n @builder = Proc.new do\n say_name\n block.call\n shell.padding += 1\n save_instructions if instructions.present?\n shell.padding -= 1\n end\n else\n @builder\n end\n end", "def initialize(args=[], options={}, config={}, &block) #:nodoc:\n @_invocations = config[:invocations] || Hash.new { |h,k| h[k] = [] }\n @_initializer = [ args, options, config ]\n super\n end", "def define(*args, &block)\n options = args.extract_options!\n\n name = if args.first\n args.shift\n else\n anonymous = true\n self.anonymous_block_number += 1\n \"anonymous_block_#{anonymous_block_number}\"\n end\n\n block_definitions[name].tap do |block_definition|\n block_definition.reverse_merge! options, &block\n block_definition.anonymous = !!anonymous\n end\n end", "def initialize(name, depth = nil, overflow = nil, &ruby_block)\n @name = name.to_sym\n @body = ruby_block\n @depth = depth ? depth.to_i : nil\n @overflow = overflow ? overflow.to_proc : nil\n end", "def _initialize(name, args, opts)\n @name = name\n @args = args.freeze\n @opts = opts.freeze\n freeze\n end", "def initialize(type = :message, &block)\n @type = type\n @block = block if block_given?\n end", "def initialize(params ={}, &block)\n super\n instance_eval &block\n end", "def initialize(attributes = {}, &block)\n attributes.each do |name, value|\n send(\"#{name}=\", value)\n end\n\n instance_exec(self, &block) if block_given?\n end", "def initialize(*args, &block)\n raise ::ArgumentError, 'Only one value is accepted' if args.length > 1\n\n @mutex = ::Mutex.new\n @bindings = []\n if args.length == 1\n __bind_with_value(args[0])\n elsif block\n __bind_with_block(block)\n end\n end", "def new(*args, &block)\n obj = allocate()\n obj.initialize(*args, &block)\n obj\n end", "def initialize(options={}, &block)\n set_defaults\n apply_options(options, &block)\n end", "def initialize(&block)\n instance_eval(&block) if block_given?\n end", "def set_block_argument_names\n @block_argument_names = if has_block? && element[2].is_a?(Sexp) # HACK: for lambdas\n element[2].drop(1).map { |argument| argument }\n end || []\n end", "def block_params\n params.require(:block).permit(:previous_block, :nonce, :prev_timestamp, :success)\n end", "def decode_args_to_make(*args) #:nodoc:\n count, name, attributes = *decode_args(args)\n blueprint = ensure_blueprint(name)\n\n if count.nil?\n yield(blueprint, attributes)\n else\n Array.new(count) { yield(blueprint, attributes) }\n end\n end" ]
[ "0.7048354", "0.66508985", "0.651996", "0.6477823", "0.6382113", "0.63376254", "0.60286266", "0.6026347", "0.58338714", "0.57980645", "0.57770985", "0.5766437", "0.5714325", "0.5669368", "0.5618859", "0.5612283", "0.56080014", "0.55175626", "0.55001444", "0.54964507", "0.54964507", "0.5495269", "0.54891425", "0.5488336", "0.5486289", "0.5480492", "0.5475283", "0.5451449", "0.5446207", "0.5445256", "0.54400855", "0.54394317", "0.5437708", "0.5425373", "0.5418491", "0.54161406", "0.54161406", "0.5409118", "0.54011095", "0.54011095", "0.5394358", "0.5393596", "0.5382867", "0.5373418", "0.53713894", "0.53678286", "0.5361553", "0.5358707", "0.53572613", "0.53534317", "0.535009", "0.53391296", "0.5336187", "0.5334931", "0.5333884", "0.5325267", "0.5314648", "0.5307265", "0.53063655", "0.53044266", "0.5302246", "0.5297357", "0.5293288", "0.5283914", "0.5278277", "0.52743495", "0.52734035", "0.5263388", "0.52633053", "0.5260295", "0.5252438", "0.5250218", "0.52361804", "0.5232861", "0.5232336", "0.5232026", "0.52315927", "0.5220934", "0.52136034", "0.52119756", "0.5209905", "0.52062833", "0.5197817", "0.51809466", "0.5177717", "0.51682675", "0.5163709", "0.51626694", "0.5156258", "0.5143508", "0.51419866", "0.5140028", "0.51360154", "0.5131943", "0.51304805", "0.5118282", "0.51155376", "0.5106529", "0.5106103", "0.5105273" ]
0.6632462
2